allwinner: h6: power: Switch to using the AXP driver
Chip ID checking and poweroff work just like they did before. Regulators are now enabled just like on A64/H5. This changes the signatures of the low-level register read/write functions to match the interface expected by the common driver. Signed-off-by: Samuel Holland <samuel@sholland.org> Change-Id: I14d63d171a094fa1375904928270fa3e21761646
This commit is contained in:
parent
f6d9c4cafa
commit
fb23b104c0
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
|
||||
# Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
@ -20,7 +20,8 @@ PLAT_BL_COMMON_SOURCES := drivers/ti/uart/${ARCH}/16550_console.S \
|
|||
${AW_PLAT}/common/plat_helpers.S \
|
||||
${AW_PLAT}/common/sunxi_common.c
|
||||
|
||||
BL31_SOURCES += drivers/arm/gic/common/gic_common.c \
|
||||
BL31_SOURCES += drivers/allwinner/axp/common.c \
|
||||
drivers/arm/gic/common/gic_common.c \
|
||||
drivers/arm/gic/v2/gicv2_helpers.c \
|
||||
drivers/arm/gic/v2/gicv2_main.c \
|
||||
drivers/delay_timer/delay_timer.c \
|
||||
|
|
|
@ -8,5 +8,4 @@
|
|||
include plat/allwinner/common/allwinner-common.mk
|
||||
|
||||
BL31_SOURCES += drivers/allwinner/axp/axp803.c \
|
||||
drivers/allwinner/axp/common.c \
|
||||
drivers/allwinner/sunxi_rsb.c
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
# The differences between the platform are covered by the include files.
|
||||
include plat/allwinner/common/allwinner-common.mk
|
||||
|
||||
BL31_SOURCES += drivers/mentor/i2c/mi2cv.c
|
||||
BL31_SOURCES += drivers/allwinner/axp/axp805.c \
|
||||
drivers/mentor/i2c/mi2cv.c
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <arch_helpers.h>
|
||||
#include <common/debug.h>
|
||||
#include <drivers/allwinner/axp.h>
|
||||
#include <drivers/delay_timer.h>
|
||||
#include <drivers/mentor/mi2cv.h>
|
||||
#include <lib/mmio.h>
|
||||
|
@ -19,31 +20,33 @@
|
|||
#include <sunxi_private.h>
|
||||
|
||||
#define AXP805_ADDR 0x36
|
||||
#define AXP805_ID 0x03
|
||||
|
||||
static enum pmic_type {
|
||||
UNKNOWN,
|
||||
AXP805,
|
||||
} pmic;
|
||||
|
||||
int axp_i2c_read(uint8_t chip, uint8_t reg, uint8_t *val)
|
||||
int axp_read(uint8_t reg)
|
||||
{
|
||||
uint8_t val;
|
||||
int ret;
|
||||
|
||||
ret = i2c_write(chip, 0, 0, ®, 1);
|
||||
ret = i2c_write(AXP805_ADDR, 0, 0, ®, 1);
|
||||
if (ret == 0)
|
||||
ret = i2c_read(chip, 0, 0, val, 1);
|
||||
if (ret)
|
||||
ret = i2c_read(AXP805_ADDR, 0, 0, &val, 1);
|
||||
if (ret) {
|
||||
ERROR("PMIC: Cannot read AXP805 register %02x\n", reg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int axp_i2c_write(uint8_t chip, uint8_t reg, uint8_t val)
|
||||
return val;
|
||||
}
|
||||
|
||||
int axp_write(uint8_t reg, uint8_t val)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = i2c_write(chip, reg, 1, &val, 1);
|
||||
ret = i2c_write(AXP805_ADDR, reg, 1, &val, 1);
|
||||
if (ret)
|
||||
ERROR("PMIC: Cannot write AXP805 register %02x\n", reg);
|
||||
|
||||
|
@ -53,23 +56,16 @@ int axp_i2c_write(uint8_t chip, uint8_t reg, uint8_t val)
|
|||
static int axp805_probe(void)
|
||||
{
|
||||
int ret;
|
||||
uint8_t val;
|
||||
|
||||
/* Switch the AXP805 to master/single-PMIC mode. */
|
||||
ret = axp_i2c_write(AXP805_ADDR, 0xff, 0x0);
|
||||
ret = axp_write(0xff, 0x0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = axp_i2c_read(AXP805_ADDR, AXP805_ID, &val);
|
||||
ret = axp_check_id();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
val &= 0xcf;
|
||||
if (val != 0x40) {
|
||||
ERROR("PMIC: Found unknown PMIC %02x\n", val);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -91,22 +87,20 @@ int sunxi_pmic_setup(uint16_t socid, const void *fdt)
|
|||
return ret;
|
||||
|
||||
pmic = AXP805;
|
||||
axp_setup_regulators(fdt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sunxi_power_down(void)
|
||||
{
|
||||
uint8_t val;
|
||||
|
||||
switch (pmic) {
|
||||
case AXP805:
|
||||
/* Re-initialise after rich OS might have used it. */
|
||||
sunxi_init_platform_r_twi(SUNXI_SOC_H6, false);
|
||||
/* initialise mi2cv driver */
|
||||
i2c_init((void *)SUNXI_R_I2C_BASE);
|
||||
axp_i2c_read(AXP805_ADDR, 0x32, &val);
|
||||
axp_i2c_write(AXP805_ADDR, 0x32, val | 0x80);
|
||||
axp_power_off();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue