[PATCH v4 4/9] mfd: bcm590xx: Add support for multiple device types + BCM59054 compatible

From: Artur Weber
Date: Sat Feb 15 2025 - 04:40:38 EST


The BCM59054 is another chip from the BCM590xx line of PMUs,
commonly used on devices with the BCM21664/BCM23550 chipsets.

Prepare the BCM590xx driver for supporting other devices by
adding a "bcm590xx_dev_type" enum with supported chip types
and store it in the MFD data struct as "dev_type". Then, add
a DT compatible for the BCM59054, and provide the device type
as OF match data.

Signed-off-by: Artur Weber <aweber.kernel@xxxxxxxxx>
---
Changes in v4:
- Rewrite commit message description
- Rename "device_type" member to "dev_type"
- Drop awkward line break to fit function call
- Add PMU ID/revision parsing function

Changes in v3:
- Fix compilation warning about device_type pointer cast type
- Name the device types enum and use it as the type in the MFD struct
---
drivers/mfd/bcm590xx.c | 5 ++++-
include/linux/mfd/bcm590xx.h | 8 ++++++++
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/bcm590xx.c b/drivers/mfd/bcm590xx.c
index 8b56786d85d0182acf91da203b5f943556c08422..632eb57d0d9e9f20f801fac22eae21b3c46cefd5 100644
--- a/drivers/mfd/bcm590xx.c
+++ b/drivers/mfd/bcm590xx.c
@@ -50,6 +50,8 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
bcm590xx->dev = &i2c_pri->dev;
bcm590xx->i2c_pri = i2c_pri;

+ bcm590xx->dev_type = (uintptr_t) of_device_get_match_data(bcm590xx->dev);
+
bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri,
&bcm590xx_regmap_config_pri);
if (IS_ERR(bcm590xx->regmap_pri)) {
@@ -91,7 +93,8 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
}

static const struct of_device_id bcm590xx_of_match[] = {
- { .compatible = "brcm,bcm59056" },
+ { .compatible = "brcm,bcm59054", .data = (void *)BCM59054_TYPE },
+ { .compatible = "brcm,bcm59056", .data = (void *)BCM59056_TYPE },
{ }
};
MODULE_DEVICE_TABLE(of, bcm590xx_of_match);
diff --git a/include/linux/mfd/bcm590xx.h b/include/linux/mfd/bcm590xx.h
index 6b8791da6119b22514447bf1572238b71c8b0e97..83e62b5a6c45805bc2acc88ccc7119d86f9ac424 100644
--- a/include/linux/mfd/bcm590xx.h
+++ b/include/linux/mfd/bcm590xx.h
@@ -13,12 +13,20 @@
#include <linux/i2c.h>
#include <linux/regmap.h>

+/* device types */
+enum bcm590xx_dev_type {
+ BCM59054_TYPE,
+ BCM59056_TYPE,
+ BCM590XX_TYPE_MAX,
+};
+
/* max register address */
#define BCM590XX_MAX_REGISTER_PRI 0xe7
#define BCM590XX_MAX_REGISTER_SEC 0xf0

struct bcm590xx {
struct device *dev;
+ enum bcm590xx_dev_type dev_type;
struct i2c_client *i2c_pri;
struct i2c_client *i2c_sec;
struct regmap *regmap_pri;

--
2.48.1