[PATCH] mfd: axp20x: support AXP313A PMIC

Johannes Zink j.zink at pengutronix.de
Thu Dec 1 07:37:49 PST 2022


This adds the register definitions for the AXP313A PMIC to the AXP20X
mfd driver.

Signed-off-by: Wei Chen <wei.chen at streamunlimited.com>
Signed-off-by: Johannes Zink <j.zink at pengutronix.de>
---
 drivers/mfd/axp20x-i2c.c   |  1 +
 drivers/mfd/axp20x.c       | 21 ++++++++++++++++++++-
 include/linux/mfd/axp20x.h | 28 ++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/axp20x-i2c.c b/drivers/mfd/axp20x-i2c.c
index d0f6a0f394..d1bb96e735 100644
--- a/drivers/mfd/axp20x-i2c.c
+++ b/drivers/mfd/axp20x-i2c.c
@@ -51,6 +51,7 @@ static const struct of_device_id axp20x_i2c_of_match[] = {
 	{ .compatible = "x-powers,axp152", .data = (void *)AXP152_ID },
 	{ .compatible = "x-powers,axp202", .data = (void *)AXP202_ID },
 	{ .compatible = "x-powers,axp209", .data = (void *)AXP209_ID },
+	{ .compatible = "x-powers,axp313a", .data = (void *)AXP313A_ID },
 	{ .compatible = "x-powers,axp221", .data = (void *)AXP221_ID },
 	{ .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
 	{ .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 8d9de59e7d..62df91ff01 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -38,6 +38,7 @@ static const char * const axp20x_model_names[] = {
 	"AXP221",
 	"AXP223",
 	"AXP288",
+	"AXP313A",
 	"AXP803",
 	"AXP806",
 	"AXP809",
@@ -68,6 +69,12 @@ static const struct regmap_config axp288_regmap_config = {
 	.max_register	= AXP288_FG_TUNE5,
 };
 
+static const struct regmap_config axp313a_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,
+	.max_register	= AXP313A_POK_CONTROL,
+};
+
 static const struct regmap_config axp806_regmap_config = {
 	.reg_bits	= 8,
 	.val_bits	= 8,
@@ -160,6 +167,13 @@ static const struct mfd_cell axp288_cells[] = {
 	},
 };
 
+static const struct mfd_cell axp313a_cells[] = {
+	{
+		.name		= "axp313a-regulator"
+	},
+};
+
+
 static const struct mfd_cell axp803_cells[] = {
 	{
 		.name		= "axp221-pek",
@@ -271,6 +285,11 @@ int axp20x_match_device(struct axp20x_dev *axp20x)
 		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
 		axp20x->regmap_cfg = &axp288_regmap_config;
 		break;
+	case AXP313A_ID:
+		axp20x->cells = axp313a_cells;
+		axp20x->nr_cells = ARRAY_SIZE(axp313a_cells);
+		axp20x->regmap_cfg = &axp313a_regmap_config;
+		break;
 	case AXP803_ID:
 		axp20x->nr_cells = ARRAY_SIZE(axp803_cells);
 		axp20x->cells = axp803_cells;
@@ -351,7 +370,7 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
 	axp20x->poweroff.poweroff = axp20x_power_off;
 	axp20x->poweroff.priority = 200;
 
-	if (axp20x->variant != AXP288_ID)
+	if (!(axp20x->variant == AXP288_ID) || (axp20x->variant == AXP313A_ID))
 		poweroff_handler_register(&axp20x->poweroff);
 
 	return 0;
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index 5e068eb6ba..150ff063b8 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -18,6 +18,7 @@ enum axp20x_variants {
 	AXP221_ID,
 	AXP223_ID,
 	AXP288_ID,
+	AXP313A_ID,
 	AXP803_ID,
 	AXP806_ID,
 	AXP809_ID,
@@ -287,6 +288,24 @@ enum axp20x_variants {
 #define AXP288_FG_TUNE4             0xec
 #define AXP288_FG_TUNE5             0xed
 
+#define AXP313A_ON_INDICATE          0x00
+#define AXP313A_OFF_INDICATE         0x01
+#define AXP313A_IC_TYPE              0x03
+#define AXP313A_OUTPUT_CONTROL       0x10
+#define AXP313A_DCDC_DVM_PWM         0x12
+#define AXP313A_DCDC1_CONTROL        0x13
+#define AXP313A_DCDC2_CONTROL        0x14
+#define AXP313A_DCDC3_CONTROL        0x15
+#define AXP313A_ALDO1_CONTROL        0x16
+#define AXP313A_DLDO1_CONTROL        0x17
+#define AXP313A_POWER_STATUS         0x1A
+#define AXP313A_PWROK_SET            0x1B
+#define AXP313A_WAKEUP_CONRTOL       0x1C
+#define AXP313A_OUTOUT_MONITOR       0x1D
+#define AXP313A_POK_CONTROL          0x1E
+#define AXP313A_IRQ_ENABLE1          0x20
+#define AXP313A_IRQ_STATUS1          0x21
+
 /* Regulators IDs */
 enum {
 	AXP20X_LDO1 = 0,
@@ -323,6 +342,15 @@ enum {
 	AXP22X_REG_ID_MAX,
 };
 
+enum {
+	AXP313A_DCDC1 = 0,
+	AXP313A_DCDC2,
+	AXP313A_DCDC3,
+	AXP313A_LDO1,  /* RTCLDO */
+	AXP313A_LDO2,  /* RTCLDO1 */
+	AXP313A_REG_ID_MAX,
+};
+
 enum {
 	AXP806_DCDCA = 0,
 	AXP806_DCDCB,
-- 
2.30.2




More information about the barebox mailing list