Skip to contentSkip to conversation

add axp313a support

PATCH Superseded SASANO Takayoshi 2 participants 5 messages Jul 15, 2023 – Jul 22, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add axp313a support

Here is the diff of AXP313A PMIC driver.
(No board configuration is included)

---

 arch/arm/mach-sunxi/pmic_bus.c |   4 +-
 board/sunxi/board.c            |   9 +-
 drivers/power/Kconfig          |  16 ++-
 drivers/power/Makefile         |   1 +
 drivers/power/axp313a.c        | 171 +++++++++++++++++++++++++++++++++
 drivers/power/pmic/axp.c       |   1 +
 include/axp313a.h              |  31 ++++++
 include/axp_pmic.h             |   2 +
 8 files changed, 226 insertions(+), 9 deletions(-)
 create mode 100644 drivers/power/axp313a.c
 create mode 100644 include/axp313a.h
arch/arm/mach-sunxi/pmic_bus.c +2 -2
index c090840637..3e7bb5a5d1 100644
@@ -21,7 +21,7 @@
 
 #define AXP209_I2C_ADDR			0x34
 
-#define AXP305_I2C_ADDR			0x36
+#define AXP305_I2C_ADDR			0x36 /* AXP305 and AXP313A */
 
 #define AXP221_CHIP_ADDR		0x68
 
@@ -32,7 +32,7 @@ static int pmic_i2c_address(void)
 {
 	if (IS_ENABLED(CONFIG_AXP152_POWER))
 		return AXP152_I2C_ADDR;
-	if (IS_ENABLED(CONFIG_AXP305_POWER))
+	if (IS_ENABLED(CONFIG_AXP305_POWER) || IS_ENABLED(CONFIG_AXP313A_POWER))
 		return AXP305_I2C_ADDR;
 
 	/* Other AXP2xx and AXP8xx variants */
board/sunxi/board.c +6 -3
index f321cd58a6..9b0069cd52 100644
@@ -584,6 +584,7 @@ void sunxi_board_init(void)
 
 #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
 	defined CONFIG_AXP221_POWER || defined CONFIG_AXP305_POWER || \
+	defined CONFIG_AXP313A_POWER || \
 	defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 	power_failed = axp_init();
 
@@ -605,7 +606,8 @@ void sunxi_board_init(void)
 	power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
 	power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
 #endif
-#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER)
+#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER) && \
+	!defined(CONFIG_AXP313A_POWER)
 	power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
 #endif
 #if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
@@ -617,10 +619,11 @@ void sunxi_board_init(void)
 	defined CONFIG_AXP818_POWER
 	power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
 #endif
-#if !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP305_POWER) && !defined(CONFIG_AXP313A_POWER)
 	power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
 #endif
-#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER) && \
+	!defined(CONFIG_AXP313A_POWER)
 	power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
 #endif
 #ifdef CONFIG_AXP209_POWER
drivers/power/Kconfig +12 -4
index 7f3b990d23..12189eec9f 100644
@@ -101,6 +101,14 @@ config AXP305_POWER
 	Select this to enable support for the axp305 pmic found on most
 	H616 boards.
 
+config AXP313A_POWER
+	bool "axp313a pmic support"
+	select AXP_PMIC_BUS
+	select CMD_POWEROFF
+	---help---
+	Select this to enable support for the axp313a pmic found on some
+	H616 boards.
+
 config AXP809_POWER
 	bool "axp809 pmic support"
 	depends on MACH_SUN9I
@@ -143,8 +151,8 @@ config AXP_DCDC1_VOLT
 
 config AXP_DCDC2_VOLT
 	int "axp pmic dcdc2 voltage"
-	depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER
-	default 900 if AXP818_POWER
+	depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP313A_POWER
+	default 900 if AXP818_POWER || AXP313A_POWER
 	default 1400 if AXP152_POWER || AXP209_POWER
 	default 1200 if MACH_SUN6I
 	default 1100 if MACH_SUN8I
@@ -161,8 +169,8 @@ config AXP_DCDC2_VOLT
 
 config AXP_DCDC3_VOLT
 	int "axp pmic dcdc3 voltage"
-	depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER
-	default 900 if AXP809_POWER || AXP818_POWER
+	depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP313A_POWER
+	default 900 if AXP809_POWER || AXP818_POWER || AXP313A_POWER
 	default 1500 if AXP152_POWER
 	default 1250 if AXP209_POWER
 	default 1100 if MACH_SUN8I_R40
drivers/power/Makefile +1 -0
index ba64b2c593..f851f4a94e 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_AXP152_POWER)	+= axp152.o
 obj-$(CONFIG_AXP209_POWER)	+= axp209.o
 obj-$(CONFIG_AXP221_POWER)	+= axp221.o
 obj-$(CONFIG_AXP305_POWER)	+= axp305.o
+obj-$(CONFIG_AXP313A_POWER)	+= axp313a.o
 obj-$(CONFIG_AXP809_POWER)	+= axp809.o
 obj-$(CONFIG_AXP818_POWER)	+= axp818.o
 obj-$(CONFIG_EXYNOS_TMU)	+= exynos-tmu.o
drivers/power/axp313a.c new file +171 -0

171 lines not on this page · raw message

drivers/power/pmic/axp.c +1 -0
index 025dac24f2..d23c16d996 100644
@@ -87,6 +87,7 @@ static const struct udevice_id axp_pmic_ids[] = {
 	{ .compatible = "x-powers,axp209", .data = AXP209_ID },
 	{ .compatible = "x-powers,axp221", .data = AXP221_ID },
 	{ .compatible = "x-powers,axp223", .data = AXP223_ID },
+	{ .compatible = "x-powers,axp313a", .data = AXP313A_ID },
 	{ .compatible = "x-powers,axp803", .data = AXP803_ID },
 	{ .compatible = "x-powers,axp806", .data = AXP806_ID },
 	{ .compatible = "x-powers,axp809", .data = AXP809_ID },
include/axp313a.h new file +31 -0
new file mode 100644
index 0000000000..a61a11a53c
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2023 SASANO Takayoshi <[email protected]>
+ */
+
+enum axp313a_reg {
+	AXP313A_POWER_STATUS = 0x00,
+	AXP313A_CHIP_VERSION = 0x03,
+	AXP313A_OUTPUT_CTRL = 0x10,
+	AXP313A_DCDC1_CTRL = 0x13,
+	AXP313A_DCDC2_CTRL = 0x14,
+	AXP313A_DCDC3_CTRL = 0x15,
+	AXP313A_ALDO1_CTRL = 0x16,
+	AXP313A_DLDO1_CTRL = 0x17,
+	AXP313A_SHUTDOWN = 0x1a,
+	AXP313A_IRQ_ENABLE = 0x20,
+	AXP313A_IRQ_STATUS = 0x21,
+};
+
+#define AXP313A_CHIP_VERSION_MASK	0xcf
+#define AXP313A_CHIP_VERSION_AXP1530	0x48
+#define AXP313A_CHIP_VERSION_AXP313A	0x4b
+#define AXP313A_CHIP_VERSION_AXP313B	0x4c
+
+#define AXP313A_OUTPUT_CTRL_DCDC1	BIT(0)
+#define AXP313A_OUTPUT_CTRL_DCDC2	BIT(1)
+#define AXP313A_OUTPUT_CTRL_DCDC3	BIT(2)
+#define AXP313A_OUTPUT_CTRL_ALDO1	BIT(3)
+#define AXP313A_OUTPUT_CTRL_DLDO1	BIT(4)
+
+#define AXP313A_POWEROFF		BIT(7)
include/axp_pmic.h +2 -0
index 4ac6486583..9b6d7d900c 100644
@@ -13,6 +13,7 @@
 #include <axp209.h>
 #include <axp221.h>
 #include <axp305.h>
+#include <axp313a.h>
 #include <axp809.h>
 #include <axp818.h>
 
@@ -32,6 +33,7 @@ enum {
 	AXP209_ID,
 	AXP221_ID,
 	AXP223_ID,
+	AXP313A_ID,
 	AXP803_ID,
 	AXP806_ID,
 	AXP809_ID,
Signature · 1 line
2.30.2
#1 lore raw

Hi,

Quoted 8 lines · SASANO Takayoshi

Here is the diff of AXP313A PMIC driver.
(No board configuration is included)

---

Quoted 12 lines
 arch/arm/mach-sunxi/pmic_bus.c |   4 +-
 board/sunxi/board.c            |   9 +-
 drivers/power/Kconfig          |  16 ++-
 drivers/power/Makefile         |   1 +
 drivers/power/axp313a.c        | 171 +++++++++++++++++++++++++++++++++
 drivers/power/pmic/axp.c       |   1 +
 include/axp313a.h              |  31 ++++++
 include/axp_pmic.h             |   2 +
 8 files changed, 226 insertions(+), 9 deletions(-)
 create mode 100644 drivers/power/axp313a.c
 create mode 100644 include/axp313a.h

Please can you write this to use driver model? There is a pmic uclass.

Quoted 47 lines
arch/arm/mach-sunxi/pmic_bus.c +2 -2
index c090840637..3e7bb5a5d1 100644
@@ -21,7 +21,7 @@
 
 #define AXP209_I2C_ADDR                        0x34
 
-#define AXP305_I2C_ADDR                        0x36
+#define AXP305_I2C_ADDR                        0x36 /* AXP305 and AXP313A */
 
 #define AXP221_CHIP_ADDR               0x68
 
@@ -32,7 +32,7 @@ static int pmic_i2c_address(void)
 {
        if (IS_ENABLED(CONFIG_AXP152_POWER))
                return AXP152_I2C_ADDR;
-       if (IS_ENABLED(CONFIG_AXP305_POWER))
+       if (IS_ENABLED(CONFIG_AXP305_POWER) || IS_ENABLED(CONFIG_AXP313A_POWER))
                return AXP305_I2C_ADDR;
 
        /* Other AXP2xx and AXP8xx variants */
board/sunxi/board.c +3 -1
index f321cd58a6..9b0069cd52 100644
@@ -584,6 +584,7 @@ void sunxi_board_init(void)
 
 #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
        defined CONFIG_AXP221_POWER || defined CONFIG_AXP305_POWER || \
+       defined CONFIG_AXP313A_POWER || \
        defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
        power_failed = axp_init();
 
@@ -605,7 +606,8 @@ void sunxi_board_init(void)
        power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
        power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
 #endif
-#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER)
+#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER) && \
+       !defined(CONFIG_AXP313A_POWER)
        power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
 #endif
 #if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
@@ -617,10 +619,11 @@ void sunxi_board_init(void)
        defined CONFIG_AXP818_POWER
        power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);

board/sunxi/board.c void sunxi_board_init(void) · line 628

Quoted 10 lines
board/sunxi/board.c +3 -2
 #endif
-#if !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP305_POWER) && !defined(CONFIG_AXP313A_POWER)
        power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
 #endif
-#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER) && \
+       !defined(CONFIG_AXP313A_POWER)
        power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
 #endif

OMG that is a mess. It looks like sunxi needs some conversion.

Quoted 7 lines
board/sunxi/board.c +0 -0
 #ifdef CONFIG_AXP209_POWER
drivers/power/Kconfig +0 -0
index 7f3b990d23..12189eec9f 100644
@@ -101,6 +101,14 @@ config AXP305_POWER
        Select this to enable support for the axp305 pmic found on most

drivers/power/Kconfig config AXP305_POWER · line 111

Quoted 10 lines
drivers/power/Kconfig +8 -0
        H616 boards.
 
+config AXP313A_POWER
+       bool "axp313a pmic support"
+       select AXP_PMIC_BUS
+       select CMD_POWEROFF
+       ---help---
+       Select this to enable support for the axp313a pmic found on some
+       H616 boards.
+

Regards,
Simon

#2 lore raw

Hello,

Quoted 25 lines · Simon Glass

Hi,

Quoted 8 lines · SASANO Takayoshi

Here is the diff of AXP313A PMIC driver.
(No board configuration is included)

---

Quoted 12 lines
 arch/arm/mach-sunxi/pmic_bus.c |   4 +-
 board/sunxi/board.c            |   9 +-
 drivers/power/Kconfig          |  16 ++-
 drivers/power/Makefile         |   1 +
 drivers/power/axp313a.c        | 171 +++++++++++++++++++++++++++++++++
 drivers/power/pmic/axp.c       |   1 +
 include/axp313a.h              |  31 ++++++
 include/axp_pmic.h             |   2 +
 8 files changed, 226 insertions(+), 9 deletions(-)
 create mode 100644 drivers/power/axp313a.c
 create mode 100644 include/axp313a.h
Quoted 1 line

Please can you write this to use driver model? There is a pmic uclass.

This is controller-specific driver for power/pmic/axp.c. axp.c (axp_pmic) belongs to UCLASS_PMIC.

--
U_BOOT_DRIVER(axp_pmic) = {

        .name           = "axp_pmic",
        .id             = UCLASS_PMIC,
        .of_match       = axp_pmic_ids,
        .bind           = axp_pmic_bind,
        .ops            = &axp_pmic_ops,

};
--

Quoted 29 lines
Quoted 29 lines
board/sunxi/board.c +4 -2
index f321cd58a6..9b0069cd52 100644
@@ -584,6 +584,7 @@ void sunxi_board_init(void)
 
 #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
        defined CONFIG_AXP221_POWER || defined CONFIG_AXP305_POWER || \
+       defined CONFIG_AXP313A_POWER || \
        defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
        power_failed = axp_init();
 
@@ -605,7 +606,8 @@ void sunxi_board_init(void)
        power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
        power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
 #endif
-#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER)
+#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER) && \
+       !defined(CONFIG_AXP313A_POWER)
        power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
 #endif
 #if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
@@ -617,10 +619,11 @@ void sunxi_board_init(void)
        defined CONFIG_AXP818_POWER
        power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
 #endif
-#if !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP305_POWER) && !defined(CONFIG_AXP313A_POWER)
        power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
Quoted 8 lines

board/sunxi/board.c void sunxi_board_init(void) · line 628

Quoted 6 lines
board/sunxi/board.c +2 -1
 #endif
-#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER) && \
+       !defined(CONFIG_AXP313A_POWER)
        power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
 #endif

OMG that is a mess. It looks like sunxi needs some conversion.

I think so. We have to rewrite what regulator output (dcdcX, aldoX, etc..) is supported (not by controller name), but is it necessary before adding AXP313A code?

Best regards,

Signature · 1 line
SASANO Takayoshi (JG1UAA) <[email protected]>
#3 lore raw

Hi SASANO,

Quoted 83 lines · SASANO Takayoshi

Hello,

Quoted 25 lines · Simon Glass

Hi,

Quoted 8 lines · SASANO Takayoshi

Here is the diff of AXP313A PMIC driver.
(No board configuration is included)

---

Quoted 12 lines
 arch/arm/mach-sunxi/pmic_bus.c |   4 +-
 board/sunxi/board.c            |   9 +-
 drivers/power/Kconfig          |  16 ++-
 drivers/power/Makefile         |   1 +
 drivers/power/axp313a.c        | 171 +++++++++++++++++++++++++++++++++
 drivers/power/pmic/axp.c       |   1 +
 include/axp313a.h              |  31 ++++++
 include/axp_pmic.h             |   2 +
 8 files changed, 226 insertions(+), 9 deletions(-)
 create mode 100644 drivers/power/axp313a.c
 create mode 100644 include/axp313a.h
Quoted 1 line

Please can you write this to use driver model? There is a pmic uclass.

This is controller-specific driver for power/pmic/axp.c. axp.c (axp_pmic) belongs to UCLASS_PMIC.

--
U_BOOT_DRIVER(axp_pmic) = {

        .name           = "axp_pmic",
        .id             = UCLASS_PMIC,
        .of_match       = axp_pmic_ids,
        .bind           = axp_pmic_bind,
        .ops            = &axp_pmic_ops,

};
--

Quoted 29 lines
Quoted 29 lines
board/sunxi/board.c +4 -2
index f321cd58a6..9b0069cd52 100644
@@ -584,6 +584,7 @@ void sunxi_board_init(void)
 
 #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
        defined CONFIG_AXP221_POWER || defined CONFIG_AXP305_POWER || \
+       defined CONFIG_AXP313A_POWER || \
        defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
        power_failed = axp_init();
 
@@ -605,7 +606,8 @@ void sunxi_board_init(void)
        power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
        power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
 #endif
-#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER)
+#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER) && \
+       !defined(CONFIG_AXP313A_POWER)
        power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
 #endif
 #if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
@@ -617,10 +619,11 @@ void sunxi_board_init(void)
        defined CONFIG_AXP818_POWER
        power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
 #endif
-#if !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP305_POWER) && !defined(CONFIG_AXP313A_POWER)
        power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
Quoted 8 lines

board/sunxi/board.c void sunxi_board_init(void) · line 628

Quoted 6 lines
board/sunxi/board.c +2 -1
 #endif
-#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER) && \
+       !defined(CONFIG_AXP313A_POWER)
        power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
 #endif

OMG that is a mess. It looks like sunxi needs some conversion.

Quoted 3 lines

I think so. We have to rewrite what regulator output (dcdcX, aldoX, etc..) is supported (not by controller name), but is it necessary before adding AXP313A code?

Looking at the driver, it seems to use a private sunxi implementation

I'm not sure what to do with this, but adding more to this heap doesn't sound like a good idea. You could try asking the pmic maintainer what to do...actually should be copied if you add a 'power:' tag to your patch

+Jaehoon Chung

Quoted 4 lines

Best regards,
--
SASANO Takayoshi (JG1UAA) <[email protected]>

Regards,
Simon

#4 lore raw

PATCH 1/1 power: add axp313a support (tag added to subject)

Hello,

Simon told me that you are maintainer of pmic section. I am trying to add AXP313A support to sunxi/AXP code.

Maybe previous mail is CCed but I think you have not read my diff. I attach it again.

board/sunxi/board.c looks complex to maintain. We have to think how handle it after AXP313A supported.

Best regards,

From 9127de42691f86ef5ed22dcf5fa0b44b03288a07 Mon Sep 17 00:00:00 2001
From: SASANO Takayoshi <[email protected]>
Date: Thu, 13 Jul 2023 20:41:40 +0900
Subject: [PATCH] add axp313a support

---

 arch/arm/mach-sunxi/pmic_bus.c |   4 +-
 board/sunxi/board.c            |   9 +-
 drivers/power/Kconfig          |  16 ++-
 drivers/power/Makefile         |   1 +
 drivers/power/axp313a.c        | 171 +++++++++++++++++++++++++++++++++
 drivers/power/pmic/axp.c       |   1 +
 include/axp313a.h              |  31 ++++++
 include/axp_pmic.h             |   2 +
 8 files changed, 226 insertions(+), 9 deletions(-)
 create mode 100644 drivers/power/axp313a.c
 create mode 100644 include/axp313a.h
arch/arm/mach-sunxi/pmic_bus.c +2 -2
index c090840637..3e7bb5a5d1 100644
@@ -21,7 +21,7 @@
 
 #define AXP209_I2C_ADDR			0x34
 
-#define AXP305_I2C_ADDR			0x36
+#define AXP305_I2C_ADDR			0x36 /* AXP305 and AXP313A */
 
 #define AXP221_CHIP_ADDR		0x68
 
@@ -32,7 +32,7 @@ static int pmic_i2c_address(void)
 {
 	if (IS_ENABLED(CONFIG_AXP152_POWER))
 		return AXP152_I2C_ADDR;
-	if (IS_ENABLED(CONFIG_AXP305_POWER))
+	if (IS_ENABLED(CONFIG_AXP305_POWER) || IS_ENABLED(CONFIG_AXP313A_POWER))
 		return AXP305_I2C_ADDR;
 
 	/* Other AXP2xx and AXP8xx variants */
board/sunxi/board.c +6 -3
index f321cd58a6..9b0069cd52 100644
@@ -584,6 +584,7 @@ void sunxi_board_init(void)
 
 #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
 	defined CONFIG_AXP221_POWER || defined CONFIG_AXP305_POWER || \
+	defined CONFIG_AXP313A_POWER || \
 	defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 	power_failed = axp_init();
 
@@ -605,7 +606,8 @@ void sunxi_board_init(void)
 	power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
 	power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
 #endif
-#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER)
+#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER) && \
+	!defined(CONFIG_AXP313A_POWER)
 	power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
 #endif
 #if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
@@ -617,10 +619,11 @@ void sunxi_board_init(void)
 	defined CONFIG_AXP818_POWER
 	power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
 #endif
-#if !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP305_POWER) && !defined(CONFIG_AXP313A_POWER)
 	power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
 #endif
-#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER)
+#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER) && \
+	!defined(CONFIG_AXP313A_POWER)
 	power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
 #endif
 #ifdef CONFIG_AXP209_POWER
drivers/power/Kconfig +12 -4
index 7f3b990d23..12189eec9f 100644
@@ -101,6 +101,14 @@ config AXP305_POWER
 	Select this to enable support for the axp305 pmic found on most
 	H616 boards.
 
+config AXP313A_POWER
+	bool "axp313a pmic support"
+	select AXP_PMIC_BUS
+	select CMD_POWEROFF
+	---help---
+	Select this to enable support for the axp313a pmic found on some
+	H616 boards.
+
 config AXP809_POWER
 	bool "axp809 pmic support"
 	depends on MACH_SUN9I
@@ -143,8 +151,8 @@ config AXP_DCDC1_VOLT
 
 config AXP_DCDC2_VOLT
 	int "axp pmic dcdc2 voltage"
-	depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER
-	default 900 if AXP818_POWER
+	depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP313A_POWER
+	default 900 if AXP818_POWER || AXP313A_POWER
 	default 1400 if AXP152_POWER || AXP209_POWER
 	default 1200 if MACH_SUN6I
 	default 1100 if MACH_SUN8I
@@ -161,8 +169,8 @@ config AXP_DCDC2_VOLT
 
 config AXP_DCDC3_VOLT
 	int "axp pmic dcdc3 voltage"
-	depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER
-	default 900 if AXP809_POWER || AXP818_POWER
+	depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER || AXP313A_POWER
+	default 900 if AXP809_POWER || AXP818_POWER || AXP313A_POWER
 	default 1500 if AXP152_POWER
 	default 1250 if AXP209_POWER
 	default 1100 if MACH_SUN8I_R40
drivers/power/Makefile +1 -0
index ba64b2c593..f851f4a94e 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_AXP152_POWER)	+= axp152.o
 obj-$(CONFIG_AXP209_POWER)	+= axp209.o
 obj-$(CONFIG_AXP221_POWER)	+= axp221.o
 obj-$(CONFIG_AXP305_POWER)	+= axp305.o
+obj-$(CONFIG_AXP313A_POWER)	+= axp313a.o
 obj-$(CONFIG_AXP809_POWER)	+= axp809.o
 obj-$(CONFIG_AXP818_POWER)	+= axp818.o
 obj-$(CONFIG_EXYNOS_TMU)	+= exynos-tmu.o
drivers/power/axp313a.c new file +171 -0

171 lines not on this page · raw message

drivers/power/pmic/axp.c +1 -0
index 025dac24f2..d23c16d996 100644
@@ -87,6 +87,7 @@ static const struct udevice_id axp_pmic_ids[] = {
 	{ .compatible = "x-powers,axp209", .data = AXP209_ID },
 	{ .compatible = "x-powers,axp221", .data = AXP221_ID },
 	{ .compatible = "x-powers,axp223", .data = AXP223_ID },
+	{ .compatible = "x-powers,axp313a", .data = AXP313A_ID },
 	{ .compatible = "x-powers,axp803", .data = AXP803_ID },
 	{ .compatible = "x-powers,axp806", .data = AXP806_ID },
 	{ .compatible = "x-powers,axp809", .data = AXP809_ID },
include/axp313a.h new file +31 -0
new file mode 100644
index 0000000000..a61a11a53c
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2023 SASANO Takayoshi <[email protected]>
+ */
+
+enum axp313a_reg {
+	AXP313A_POWER_STATUS = 0x00,
+	AXP313A_CHIP_VERSION = 0x03,
+	AXP313A_OUTPUT_CTRL = 0x10,
+	AXP313A_DCDC1_CTRL = 0x13,
+	AXP313A_DCDC2_CTRL = 0x14,
+	AXP313A_DCDC3_CTRL = 0x15,
+	AXP313A_ALDO1_CTRL = 0x16,
+	AXP313A_DLDO1_CTRL = 0x17,
+	AXP313A_SHUTDOWN = 0x1a,
+	AXP313A_IRQ_ENABLE = 0x20,
+	AXP313A_IRQ_STATUS = 0x21,
+};
+
+#define AXP313A_CHIP_VERSION_MASK	0xcf
+#define AXP313A_CHIP_VERSION_AXP1530	0x48
+#define AXP313A_CHIP_VERSION_AXP313A	0x4b
+#define AXP313A_CHIP_VERSION_AXP313B	0x4c
+
+#define AXP313A_OUTPUT_CTRL_DCDC1	BIT(0)
+#define AXP313A_OUTPUT_CTRL_DCDC2	BIT(1)
+#define AXP313A_OUTPUT_CTRL_DCDC3	BIT(2)
+#define AXP313A_OUTPUT_CTRL_ALDO1	BIT(3)
+#define AXP313A_OUTPUT_CTRL_DLDO1	BIT(4)
+
+#define AXP313A_POWEROFF		BIT(7)
include/axp_pmic.h +2 -0
index 4ac6486583..9b6d7d900c 100644
@@ -13,6 +13,7 @@
 #include <axp209.h>
 #include <axp221.h>
 #include <axp305.h>
+#include <axp313a.h>
 #include <axp809.h>
 #include <axp818.h>
 
@@ -32,6 +33,7 @@ enum {
 	AXP209_ID,
 	AXP221_ID,
 	AXP223_ID,
+	AXP313A_ID,
 	AXP803_ID,
 	AXP806_ID,
 	AXP809_ID,
Signature · 4 lines
2.30.2

-- 
SASANO Takayoshi (JG1UAA) <[email protected]>