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
This commit is contained in:
Samuel Holland 2019-10-20 15:12:20 -05:00
parent eb75518d98
commit c0e109f2fe
2 changed files with 9 additions and 11 deletions

View File

@ -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 */

View File

@ -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;
}