diff options
author | Bhargav Raviprakash <bhargav.r@ltts.com> | 2024-04-22 09:48:53 +0000 |
---|---|---|
committer | Jaehoon Chung <jh80.chung@samsung.com> | 2024-04-29 09:20:51 +0900 |
commit | a08c8798cc79ca35c521727bfcef160786c2baf3 (patch) | |
tree | b8fd86199f8c86080ebc97c921d4c9ee799a2f2f | |
parent | 1468fbba6d55361c4ca742cbd6a84e7c83d616d0 (diff) | |
download | u-boot-a08c8798cc79ca35c521727bfcef160786c2baf3.zip u-boot-a08c8798cc79ca35c521727bfcef160786c2baf3.tar.gz u-boot-a08c8798cc79ca35c521727bfcef160786c2baf3.tar.bz2 |
power: regulator: tps65941: Added macros for BUCK ID
Adds macros for buck and ldo ids and switched to using switch
case instead of if else in probe functions. Helps in adding
support for TPS65224 PMIC.
Signed-off-by: Bhargav Raviprakash <bhargav.r@ltts.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
-rw-r--r-- | drivers/power/regulator/tps65941_regulator.c | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/drivers/power/regulator/tps65941_regulator.c b/drivers/power/regulator/tps65941_regulator.c index b041126..cf54e30 100644 --- a/drivers/power/regulator/tps65941_regulator.c +++ b/drivers/power/regulator/tps65941_regulator.c @@ -16,6 +16,25 @@ #include <power/regulator.h> #include <power/tps65941.h> +/* Single Phase Buck IDs */ +#define TPS65941_BUCK_ID_1 1 +#define TPS65941_BUCK_ID_2 2 +#define TPS65941_BUCK_ID_3 3 +#define TPS65941_BUCK_ID_4 4 +#define TPS65941_BUCK_ID_5 5 + +/* Multi Phase Buck IDs */ +#define TPS65941_BUCK_ID_12 12 +#define TPS65941_BUCK_ID_34 34 +#define TPS65941_BUCK_ID_123 123 +#define TPS65941_BUCK_ID_1234 1234 + +/* LDO IDs */ +#define TPS65941_LDO_ID_1 1 +#define TPS65941_LDO_ID_2 2 +#define TPS65941_LDO_ID_3 3 +#define TPS65941_LDO_ID_4 4 + static const char tps65941_buck_ctrl[TPS65941_BUCK_NUM] = {0x4, 0x6, 0x8, 0xA, 0xC}; static const char tps65941_buck_vout[TPS65941_BUCK_NUM] = {0xE, 0x10, 0x12, @@ -270,10 +289,15 @@ static int tps65941_ldo_probe(struct udevice *dev) uc_pdata->type = REGULATOR_TYPE_LDO; idx = dev->driver_data; - if (idx == 1 || idx == 2 || idx == 3 || idx == 4) { + switch (idx) { + case TPS65941_LDO_ID_1: + case TPS65941_LDO_ID_2: + case TPS65941_LDO_ID_3: + case TPS65941_LDO_ID_4: debug("Single phase regulator\n"); - } else { - printf("Wrong ID for regulator\n"); + break; + default: + pr_err("Wrong ID for regulator\n"); return -EINVAL; } @@ -292,18 +316,24 @@ static int tps65941_buck_probe(struct udevice *dev) uc_pdata->type = REGULATOR_TYPE_BUCK; idx = dev->driver_data; - if (idx == 1 || idx == 2 || idx == 3 || idx == 4 || idx == 5) { + switch (idx) { + case TPS65941_BUCK_ID_1: + case TPS65941_BUCK_ID_2: + case TPS65941_BUCK_ID_3: + case TPS65941_BUCK_ID_4: + case TPS65941_BUCK_ID_5: debug("Single phase regulator\n"); - } else if (idx == 12) { + break; + case TPS65941_BUCK_ID_12: + case TPS65941_BUCK_ID_123: + case TPS65941_BUCK_ID_1234: idx = 1; - } else if (idx == 34) { + break; + case TPS65941_BUCK_ID_34: idx = 3; - } else if (idx == 123) { - idx = 1; - } else if (idx == 1234) { - idx = 1; - } else { - printf("Wrong ID for regulator\n"); + break; + default: + pr_err("Wrong ID for regulator\n"); return -EINVAL; } |