diff mbox series

[V4,11/15] mfd: axp20x: Add ADC, BAT, and USB cells for AXP717

Message ID 20240821215456.962564-12-macroalpha82@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add Battery and USB Supply for AXP717 | expand

Commit Message

Chris Morgan Aug. 21, 2024, 9:54 p.m. UTC
From: Chris Morgan <macromorgan@hotmail.com>

Add support for the AXP717 PMIC to utilize the ADC (for reading
voltage, current, and temperature information from the PMIC) as well
as the USB charger and battery.

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
---
 drivers/mfd/axp20x.c       | 25 ++++++++++++++++++++++++-
 include/linux/mfd/axp20x.h | 26 ++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletion(-)

Comments

Lee Jones Aug. 22, 2024, 1:54 p.m. UTC | #1
On Wed, 21 Aug 2024 16:54:52 -0500, Chris Morgan wrote:
> Add support for the AXP717 PMIC to utilize the ADC (for reading
> voltage, current, and temperature information from the PMIC) as well
> as the USB charger and battery.
> 
> 

Applied, thanks!

[11/15] mfd: axp20x: Add ADC, BAT, and USB cells for AXP717
        commit: e1043ad46060c181ffb8f981ccb25d9f698b2f09

--
Lee Jones [李琼斯]
Jonathan Cameron Aug. 26, 2024, 11:03 a.m. UTC | #2
On Thu, 22 Aug 2024 14:54:13 +0100
Lee Jones <lee@kernel.org> wrote:

> On Wed, 21 Aug 2024 16:54:52 -0500, Chris Morgan wrote:
> > Add support for the AXP717 PMIC to utilize the ADC (for reading
> > voltage, current, and temperature information from the PMIC) as well
> > as the USB charger and battery.
> > 
> >   
> 
> Applied, thanks!
> 
> [11/15] mfd: axp20x: Add ADC, BAT, and USB cells for AXP717
>         commit: e1043ad46060c181ffb8f981ccb25d9f698b2f09
> 
Hi Lee, patch 12 is dependent on this because of the header
additions.

If you don't mind can you pick up 1, 8 and 12
(all the IIO ones)?  Otherwise they'll have to wait for next
cycle. Guessing too late to ask for an IB?

I haven't checked but the later power supply ones may have
the same block.

Thanks,

Jonathan
> --
> Lee Jones [李琼斯]
>
Sebastian Reichel Aug. 27, 2024, 4:29 p.m. UTC | #3
Hi,

On Mon, Aug 26, 2024 at 12:03:42PM GMT, Jonathan Cameron wrote:
> On Thu, 22 Aug 2024 14:54:13 +0100
> Lee Jones <lee@kernel.org> wrote:
> 
> > On Wed, 21 Aug 2024 16:54:52 -0500, Chris Morgan wrote:
> > > Add support for the AXP717 PMIC to utilize the ADC (for reading
> > > voltage, current, and temperature information from the PMIC) as well
> > > as the USB charger and battery.
> > > 
> > >   
> > 
> > Applied, thanks!
> > 
> > [11/15] mfd: axp20x: Add ADC, BAT, and USB cells for AXP717
> >         commit: e1043ad46060c181ffb8f981ccb25d9f698b2f09
> > 
> Hi Lee, patch 12 is dependent on this because of the header
> additions.
> 
> If you don't mind can you pick up 1, 8 and 12
> (all the IIO ones)?  Otherwise they'll have to wait for next
> cycle. Guessing too late to ask for an IB?
> 
> I haven't checked but the later power supply ones may have
> the same block.

Yes, patches 13 + 14 are also blocked by the MFD patch adding
register defines. I merged the other power-supply patches before
noticing this, so patches 13 + 14 need to wait a cycle without
an immutable branch.

Greetings,

-- Sebastian
Lee Jones Aug. 29, 2024, 12:15 p.m. UTC | #4
On Mon, 26 Aug 2024, Jonathan Cameron wrote:

> On Thu, 22 Aug 2024 14:54:13 +0100
> Lee Jones <lee@kernel.org> wrote:
> 
> > On Wed, 21 Aug 2024 16:54:52 -0500, Chris Morgan wrote:
> > > Add support for the AXP717 PMIC to utilize the ADC (for reading
> > > voltage, current, and temperature information from the PMIC) as well
> > > as the USB charger and battery.
> > > 
> > >   
> > 
> > Applied, thanks!
> > 
> > [11/15] mfd: axp20x: Add ADC, BAT, and USB cells for AXP717
> >         commit: e1043ad46060c181ffb8f981ccb25d9f698b2f09
> > 
> Hi Lee, patch 12 is dependent on this because of the header
> additions.
> 
> If you don't mind can you pick up 1, 8 and 12
> (all the IIO ones)?  Otherwise they'll have to wait for next
> cycle. Guessing too late to ask for an IB?

Hold that thought!
Lee Jones Aug. 29, 2024, 12:17 p.m. UTC | #5
On Wed, 21 Aug 2024, Chris Morgan wrote:

> From: Chris Morgan <macromorgan@hotmail.com>
> 
> Add support for the AXP717 PMIC to utilize the ADC (for reading
> voltage, current, and temperature information from the PMIC) as well
> as the USB charger and battery.
> 
> Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
> ---
>  drivers/mfd/axp20x.c       | 25 ++++++++++++++++++++++++-
>  include/linux/mfd/axp20x.h | 26 ++++++++++++++++++++++++++
>  2 files changed, 50 insertions(+), 1 deletion(-)

Moved to an immutable branch and submitted for testing.

PR to follow.
diff mbox series

Patch

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index dacd3c96c9f5..4051551757f2 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -209,13 +209,23 @@  static const struct regmap_access_table axp313a_volatile_table = {
 };
 
 static const struct regmap_range axp717_writeable_ranges[] = {
+	regmap_reg_range(AXP717_PMU_FAULT, AXP717_MODULE_EN_CONTROL_1),
+	regmap_reg_range(AXP717_MIN_SYS_V_CONTROL, AXP717_BOOST_CONTROL),
+	regmap_reg_range(AXP717_VSYS_V_POWEROFF, AXP717_VSYS_V_POWEROFF),
 	regmap_reg_range(AXP717_IRQ0_EN, AXP717_IRQ4_EN),
 	regmap_reg_range(AXP717_IRQ0_STATE, AXP717_IRQ4_STATE),
+	regmap_reg_range(AXP717_ICC_CHG_SET, AXP717_CV_CHG_SET),
 	regmap_reg_range(AXP717_DCDC_OUTPUT_CONTROL, AXP717_CPUSLDO_CONTROL),
+	regmap_reg_range(AXP717_ADC_CH_EN_CONTROL, AXP717_ADC_CH_EN_CONTROL),
+	regmap_reg_range(AXP717_ADC_DATA_SEL, AXP717_ADC_DATA_SEL),
 };
 
 static const struct regmap_range axp717_volatile_ranges[] = {
+	regmap_reg_range(AXP717_ON_INDICATE, AXP717_PMU_FAULT),
 	regmap_reg_range(AXP717_IRQ0_STATE, AXP717_IRQ4_STATE),
+	regmap_reg_range(AXP717_BATT_PERCENT_DATA, AXP717_BATT_PERCENT_DATA),
+	regmap_reg_range(AXP717_BATT_V_H, AXP717_BATT_CHRG_I_L),
+	regmap_reg_range(AXP717_ADC_DATA_H, AXP717_ADC_DATA_L),
 };
 
 static const struct regmap_access_table axp717_writeable_table = {
@@ -308,6 +318,12 @@  static const struct resource axp22x_usb_power_supply_resources[] = {
 	DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
 };
 
+static const struct resource axp717_usb_power_supply_resources[] = {
+	DEFINE_RES_IRQ_NAMED(AXP717_IRQ_VBUS_OVER_V, "VBUS_OVER_V"),
+	DEFINE_RES_IRQ_NAMED(AXP717_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
+	DEFINE_RES_IRQ_NAMED(AXP717_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
+};
+
 /* AXP803 and AXP813/AXP818 share the same interrupts */
 static const struct resource axp803_usb_power_supply_resources[] = {
 	DEFINE_RES_IRQ_NAMED(AXP803_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
@@ -422,7 +438,7 @@  static const struct regmap_config axp717_regmap_config = {
 	.val_bits = 8,
 	.wr_table = &axp717_writeable_table,
 	.volatile_table = &axp717_volatile_table,
-	.max_register = AXP717_CPUSLDO_CONTROL,
+	.max_register = AXP717_ADC_DATA_L,
 	.cache_type = REGCACHE_MAPLE,
 };
 
@@ -1024,6 +1040,13 @@  static struct mfd_cell axp313a_cells[] = {
 static struct mfd_cell axp717_cells[] = {
 	MFD_CELL_NAME("axp20x-regulator"),
 	MFD_CELL_RES("axp20x-pek", axp717_pek_resources),
+	MFD_CELL_OF("axp717-adc",
+		    NULL, NULL, 0, 0, "x-powers,axp717-adc"),
+	MFD_CELL_OF("axp20x-usb-power-supply",
+		    axp717_usb_power_supply_resources, NULL, 0, 0,
+		    "x-powers,axp717-usb-power-supply"),
+	MFD_CELL_OF("axp20x-battery-power-supply",
+		    NULL, NULL, 0, 0, "x-powers,axp717-battery-power-supply"),
 };
 
 static const struct resource axp288_adc_resources[] = {
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index 8c0a33a2e9ce..9b7ef473adcb 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -115,6 +115,16 @@  enum axp20x_variants {
 #define AXP313A_IRQ_STATE		0x21
 
 #define AXP717_ON_INDICATE		0x00
+#define AXP717_PMU_STATUS_2		0x01
+#define AXP717_BC_DETECT		0x05
+#define AXP717_PMU_FAULT		0x08
+#define AXP717_MODULE_EN_CONTROL_1	0x0b
+#define AXP717_MIN_SYS_V_CONTROL	0x15
+#define AXP717_INPUT_VOL_LIMIT_CTRL	0x16
+#define AXP717_INPUT_CUR_LIMIT_CTRL	0x17
+#define AXP717_MODULE_EN_CONTROL_2	0x19
+#define AXP717_BOOST_CONTROL		0x1e
+#define AXP717_VSYS_V_POWEROFF		0x24
 #define AXP717_IRQ0_EN			0x40
 #define AXP717_IRQ1_EN			0x41
 #define AXP717_IRQ2_EN			0x42
@@ -125,6 +135,9 @@  enum axp20x_variants {
 #define AXP717_IRQ2_STATE		0x4a
 #define AXP717_IRQ3_STATE		0x4b
 #define AXP717_IRQ4_STATE		0x4c
+#define AXP717_ICC_CHG_SET		0x62
+#define AXP717_ITERM_CHG_SET		0x63
+#define AXP717_CV_CHG_SET		0x64
 #define AXP717_DCDC_OUTPUT_CONTROL	0x80
 #define AXP717_DCDC1_CONTROL		0x83
 #define AXP717_DCDC2_CONTROL		0x84
@@ -145,6 +158,19 @@  enum axp20x_variants {
 #define AXP717_CLDO3_CONTROL		0x9d
 #define AXP717_CLDO4_CONTROL		0x9e
 #define AXP717_CPUSLDO_CONTROL		0x9f
+#define AXP717_BATT_PERCENT_DATA	0xa4
+#define AXP717_ADC_CH_EN_CONTROL	0xc0
+#define AXP717_BATT_V_H			0xc4
+#define AXP717_BATT_V_L			0xc5
+#define AXP717_VBUS_V_H			0xc6
+#define AXP717_VBUS_V_L			0xc7
+#define AXP717_VSYS_V_H			0xc8
+#define AXP717_VSYS_V_L			0xc9
+#define AXP717_BATT_CHRG_I_H		0xca
+#define AXP717_BATT_CHRG_I_L		0xcb
+#define AXP717_ADC_DATA_SEL		0xcd
+#define AXP717_ADC_DATA_H		0xce
+#define AXP717_ADC_DATA_L		0xcf
 
 #define AXP806_STARTUP_SRC		0x00
 #define AXP806_CHIP_ID			0x03