From c0e109f2feb4fb40c9b345684ab18b8afd9e94cb Mon Sep 17 00:00:00 2001 From: Samuel Holland <samuel@sholland.org> Date: Sun, 20 Oct 2019 15:12:20 -0500 Subject: [PATCH] allwinner: Synchronize PMIC enumerations Ensure that the default (zero) value represents the case where we take no action. Previously, if a PLAT=sun50i_a64 build was booted on an unknown SoC ID, it would be treated as an H5 at shutdown. This removes some duplicate code and fixes error propagation on H6. Signed-off-by: Samuel Holland <samuel@sholland.org> Change-Id: I4e51d8a43a56eccb0d8088593cb9908e52e782bc --- plat/allwinner/sun50i_a64/sunxi_power.c | 3 ++- plat/allwinner/sun50i_h6/sunxi_power.c | 17 +++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/plat/allwinner/sun50i_a64/sunxi_power.c b/plat/allwinner/sun50i_a64/sunxi_power.c index d48ff56dc..13a6a9ba9 100644 --- a/plat/allwinner/sun50i_a64/sunxi_power.c +++ b/plat/allwinner/sun50i_a64/sunxi_power.c @@ -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. * Copyright (c) 2018, Icenowy Zheng <icenowy@aosc.io> * * SPDX-License-Identifier: BSD-3-Clause @@ -22,6 +22,7 @@ #include <sunxi_private.h> static enum pmic_type { + UNKNOWN, GENERIC_H5, GENERIC_A64, REF_DESIGN_H5, /* regulators controlled by GPIO pins on port L */ diff --git a/plat/allwinner/sun50i_h6/sunxi_power.c b/plat/allwinner/sun50i_h6/sunxi_power.c index 5b5bad177..36e3dbe74 100644 --- a/plat/allwinner/sun50i_h6/sunxi_power.c +++ b/plat/allwinner/sun50i_h6/sunxi_power.c @@ -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. * Copyright (c) 2018, Icenowy Zheng <icenowy@aosc.io> * * SPDX-License-Identifier: BSD-3-Clause @@ -21,12 +21,10 @@ #define AXP805_ADDR 0x36 #define AXP805_ID 0x03 -enum pmic_type { - NO_PMIC, +static enum pmic_type { + UNKNOWN, AXP805, -}; - -enum pmic_type pmic; +} pmic; int axp_i2c_read(uint8_t chip, uint8_t reg, uint8_t *val) { @@ -79,13 +77,12 @@ int sunxi_pmic_setup(uint16_t socid, const void *fdt) i2c_init((void *)SUNXI_R_I2C_BASE); NOTICE("PMIC: Probing AXP805\n"); - pmic = AXP805; ret = axp805_probe(); if (ret) - pmic = NO_PMIC; - else - pmic = AXP805; + return ret; + + pmic = AXP805; return 0; } -- GitLab