diff options
author | Rex-BC Chen <rex-bc.chen@mediatek.com> | 2022-07-20 11:35:57 +0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-07-21 10:33:22 +0000 |
commit | c5d4d964f1728dad5a60d84b8ee0febe0426678b (patch) | |
tree | e6418c4f4bcf1e36f4ca34d7828ab218c4666ee1 /src | |
parent | d5dafb2c0a6bac5c9d87f0e07e339570e0fd3267 (diff) |
mb/google: Use boolean type for "enable" argument for regulator
Because 0 and 1 are the only possible values,
1. Change input argument "enable" of mainboard_enable_regulator to bool.
2. Change return value of mainboard_regulator_is_enabled() to bool.
TEST=build pass
BUG=b:233720142
Signed-off-by: Bo-Chen Chen <rex-bc.chen@mediatek.com>
Change-Id: Iae09c5fedf8f7394bfbb677e5aee37ed061304fd
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65997
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/mainboard/google/asurada/regulator.c | 10 | ||||
-rw-r--r-- | src/mainboard/google/cherry/regulator.c | 12 | ||||
-rw-r--r-- | src/soc/mediatek/common/include/soc/regulator.h | 4 | ||||
-rw-r--r-- | src/soc/mediatek/mt8192/msdc.c | 5 | ||||
-rw-r--r-- | src/soc/mediatek/mt8195/msdc.c | 4 |
5 files changed, 17 insertions, 18 deletions
diff --git a/src/mainboard/google/asurada/regulator.c b/src/mainboard/google/asurada/regulator.c index 5fd5d4b8d7..dff7123086 100644 --- a/src/mainboard/google/asurada/regulator.c +++ b/src/mainboard/google/asurada/regulator.c @@ -94,7 +94,7 @@ uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator) return 0; } -int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable) +int mainboard_enable_regulator(enum mtk_regulator regulator, bool enable) { /* Return 0 if the regulator is already enabled or disabled. */ if (mainboard_regulator_is_enabled(regulator) == enable) @@ -111,7 +111,7 @@ int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable) return google_chromeec_regulator_enable(id, enable); } -uint8_t mainboard_regulator_is_enabled(enum mtk_regulator regulator) +bool mainboard_regulator_is_enabled(enum mtk_regulator regulator) { int id; @@ -119,7 +119,7 @@ uint8_t mainboard_regulator_is_enabled(enum mtk_regulator regulator) if (id < 0) { printk(BIOS_WARNING, "Invalid regulator ID: %d\n; assuming disabled", regulator); - return 0; + return false; } uint8_t enabled; @@ -127,8 +127,8 @@ uint8_t mainboard_regulator_is_enabled(enum mtk_regulator regulator) printk(BIOS_WARNING, "Failed to query regulator ID: %d\n; assuming disabled", regulator); - return 0; + return false; } - return enabled; + return !!enabled; } diff --git a/src/mainboard/google/cherry/regulator.c b/src/mainboard/google/cherry/regulator.c index 12de049e98..61f53d1eaf 100644 --- a/src/mainboard/google/cherry/regulator.c +++ b/src/mainboard/google/cherry/regulator.c @@ -123,7 +123,7 @@ uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator) return 0; } -int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable) +int mainboard_enable_regulator(enum mtk_regulator regulator, bool enable) { if (check_regulator_control(regulator) < 0) return 0; @@ -154,17 +154,17 @@ int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable) return -1; } -uint8_t mainboard_regulator_is_enabled(enum mtk_regulator regulator) +bool mainboard_regulator_is_enabled(enum mtk_regulator regulator) { if (check_regulator_control(regulator) < 0) - return 0; + return false; int id; id = get_mt6360_regulator_id(regulator); if (id >= 0) { if (CONFIG(BOARD_GOOGLE_CHERRY)) { - return mt6360_is_enabled(id); + return !!mt6360_is_enabled(id); } else { uint8_t enabled; if (google_chromeec_regulator_is_enabled(id, &enabled) < 0) { @@ -172,12 +172,12 @@ uint8_t mainboard_regulator_is_enabled(enum mtk_regulator regulator) "Failed to retrieve is_enabled by ec; assuming disabled\n"); return 0; } - return enabled; + return !!enabled; } } printk(BIOS_ERR, "Invalid regulator ID: %d\n; assuming disabled", regulator); - return 0; + return false; } diff --git a/src/soc/mediatek/common/include/soc/regulator.h b/src/soc/mediatek/common/include/soc/regulator.h index 0acf91059d..2ff122637a 100644 --- a/src/soc/mediatek/common/include/soc/regulator.h +++ b/src/soc/mediatek/common/include/soc/regulator.h @@ -25,7 +25,7 @@ enum mtk_regulator { void mainboard_set_regulator_voltage(enum mtk_regulator regulator, uint32_t voltage_uv); uint32_t mainboard_get_regulator_voltage(enum mtk_regulator regulator); -int mainboard_enable_regulator(enum mtk_regulator regulator, uint8_t enable); -uint8_t mainboard_regulator_is_enabled(enum mtk_regulator regulator); +int mainboard_enable_regulator(enum mtk_regulator regulator, bool enable); +bool mainboard_regulator_is_enabled(enum mtk_regulator regulator); #endif /* SOC_MEDIATEK_COMMON_REGULATOR_H */ diff --git a/src/soc/mediatek/mt8192/msdc.c b/src/soc/mediatek/mt8192/msdc.c index 113069a27b..89f25a3adf 100644 --- a/src/soc/mediatek/mt8192/msdc.c +++ b/src/soc/mediatek/mt8192/msdc.c @@ -57,7 +57,6 @@ void mtk_msdc_configure_sdcard(void) void *gpio_base = (void *)IOCFG_RM_BASE; void *gpio_mode0_base = (void *)MSDC1_GPIO_MODE0_BASE; void *gpio_mode1_base = (void *)MSDC1_GPIO_MODE1_BASE; - uint8_t enable = 1; int i; const gpio_t sdcard_pu_pin[] = { @@ -85,6 +84,6 @@ void mtk_msdc_configure_sdcard(void) /* set sdcard dat1 pin to msdc1 mode */ clrsetbits32(gpio_mode1_base, MSDC1_GPIO_MODE1_MASK, MSDC1_GPIO_MODE1_VALUE); - mainboard_enable_regulator(MTK_REGULATOR_VCC, enable); - mainboard_enable_regulator(MTK_REGULATOR_VCCQ, enable); + mainboard_enable_regulator(MTK_REGULATOR_VCC, true); + mainboard_enable_regulator(MTK_REGULATOR_VCCQ, true); } diff --git a/src/soc/mediatek/mt8195/msdc.c b/src/soc/mediatek/mt8195/msdc.c index bbfeaa6c81..5f75c6444e 100644 --- a/src/soc/mediatek/mt8195/msdc.c +++ b/src/soc/mediatek/mt8195/msdc.c @@ -103,6 +103,6 @@ void mtk_msdc_configure_sdcard(void) if (CONFIG(BOARD_GOOGLE_CHERRY)) mt6360_init(I2C7); - mainboard_enable_regulator(MTK_REGULATOR_VCCQ, 1); - mainboard_enable_regulator(MTK_REGULATOR_VCC, 1); + mainboard_enable_regulator(MTK_REGULATOR_VCCQ, true); + mainboard_enable_regulator(MTK_REGULATOR_VCC, true); } |