summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <[email protected]>2026-04-09 15:30:38 -0500
committerDavid Lechner <[email protected]>2026-04-29 09:26:48 -0500
commitdf660cc7b26aa4287bb2ae6cd56e58ac59a805f2 (patch)
tree4b08488fdda1de0e0ab85f86f658e4b2429fd18a
parent27fdacf4208e30f3ae8f8ee97f268d4a164b7dea (diff)
power: pmic: mtk-pwrap: use pmic compatible to select child info
Change the logic for selecting pmic_children_info to use the compatible string from the devicetree instead of expecting the pwrap (part of the MCU) to correspond to the separate PMIC chip. In addition to being more correct, it also saves a few lines of code for each MCU type that is added by dropping the enum and type field. Reviewed-by: Julien Stephan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: David Lechner <[email protected]>
-rw-r--r--drivers/power/pmic/mtk-pwrap.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/drivers/power/pmic/mtk-pwrap.c b/drivers/power/pmic/mtk-pwrap.c
index d994e0a67c9..d41a43c8c95 100644
--- a/drivers/power/pmic/mtk-pwrap.c
+++ b/drivers/power/pmic/mtk-pwrap.c
@@ -340,12 +340,6 @@ static int mt8365_regs[] = {
[PWRAP_WDT_SRC_EN_1] = 0xf8,
};
-enum pwrap_type {
- PWRAP_MT8188,
- PWRAP_MT8189,
- PWRAP_MT8365,
-};
-
struct pwrap_slv_type {
const u32 *dew_regs;
u32 caps;
@@ -364,7 +358,6 @@ struct pmic_wrapper {
struct pmic_wrapper_type {
int *regs;
- enum pwrap_type type;
u32 arb_en_all;
u32 spi_w;
u32 wdt_src;
@@ -779,7 +772,6 @@ static int mtk_pwrap_bind(struct udevice *dev)
ofnode pmic_node, regulators_node;
int children;
const struct pmic_child_info *pmic_children_info;
- struct pmic_wrapper_type *pw_type = (void *)dev_get_driver_data(dev);
pmic_node = dev_read_first_subnode(dev);
if (!ofnode_valid(pmic_node)) {
@@ -787,16 +779,13 @@ static int mtk_pwrap_bind(struct udevice *dev)
return -ENXIO;
}
- switch (pw_type->type) {
- case PWRAP_MT8365:
+ if (ofnode_device_is_compatible(pmic_node, "mediatek,mt6357")) {
pmic_children_info = mt6357_pmic_children_info;
- break;
- case PWRAP_MT8188:
- case PWRAP_MT8189:
+ } else if (ofnode_device_is_compatible(pmic_node, "mediatek,mt6359")) {
pmic_children_info = mt6359_pmic_children_info;
- break;
- default:
- dev_err(dev, "pwrap type %d not supported\n", pw_type->type);
+ } else {
+ dev_err(dev, "pmic type %s not supported\n",
+ ofnode_read_string(pmic_node, "compatible"));
return -ENXIO;
}
@@ -845,7 +834,6 @@ static struct dm_pmic_ops mtk_pwrap_ops = {
static struct pmic_wrapper_type pwrap_mt8188 = {
.regs = mt8188_regs,
- .type = PWRAP_MT8188,
.arb_en_all = 0x777f,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
@@ -854,7 +842,6 @@ static struct pmic_wrapper_type pwrap_mt8188 = {
static struct pmic_wrapper_type pwrap_mt8189 = {
.regs = mt8189_regs,
- .type = PWRAP_MT8189,
.arb_en_all = 0x777f,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,
@@ -863,7 +850,6 @@ static struct pmic_wrapper_type pwrap_mt8189 = {
static const struct pmic_wrapper_type pwrap_mt8365 = {
.regs = mt8365_regs,
- .type = PWRAP_MT8365,
.arb_en_all = 0x3ffff,
.spi_w = PWRAP_MAN_CMD_SPI_WRITE,
.wdt_src = PWRAP_WDT_SRC_MASK_ALL,