Skip to content

Commit b5bfc8a

Browse files
Andre-ARMlag-linaro
authored andcommitted
mfd: axp20x: Add support for AXP717 PMIC
The AXP717a is a PMIC chip produced by X-Powers, it can be connected to an I2C or RSB bus. It's a rather complete PMIC, with many regulators, interrupts, an ADC and battery charging functionality. It also offer USB type-C CC pin handling. Describe the regmap and the MFD bits, along with the registers exposed via I2C or RSB. This covers the regulator, interrupts and power key devices for now. Advertise the device using the new compatible string. Signed-off-by: Andre Przywara <[email protected]> Acked-by: Jernej Skrabec <[email protected]> Tested-by: Ryan Walklin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 3bfe7fe commit b5bfc8a

File tree

4 files changed

+160
-0
lines changed

4 files changed

+160
-0
lines changed

drivers/mfd/axp20x-i2c.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static const struct of_device_id axp20x_i2c_of_match[] = {
6565
{ .compatible = "x-powers,axp221", .data = (void *)AXP221_ID },
6666
{ .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
6767
{ .compatible = "x-powers,axp313a", .data = (void *)AXP313A_ID },
68+
{ .compatible = "x-powers,axp717", .data = (void *)AXP717_ID },
6869
{ .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
6970
{ .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
7071
{ .compatible = "x-powers,axp15060", .data = (void *)AXP15060_ID },
@@ -81,6 +82,7 @@ static const struct i2c_device_id axp20x_i2c_id[] = {
8182
{ "axp221", 0 },
8283
{ "axp223", 0 },
8384
{ "axp313a", 0 },
85+
{ "axp717", 0 },
8486
{ "axp803", 0 },
8587
{ "axp806", 0 },
8688
{ "axp15060", 0 },

drivers/mfd/axp20x-rsb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static void axp20x_rsb_remove(struct sunxi_rsb_device *rdev)
5858

5959
static const struct of_device_id axp20x_rsb_of_match[] = {
6060
{ .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
61+
{ .compatible = "x-powers,axp717", .data = (void *)AXP717_ID },
6162
{ .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
6263
{ .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
6364
{ .compatible = "x-powers,axp809", .data = (void *)AXP809_ID },

drivers/mfd/axp20x.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static const char * const axp20x_model_names[] = {
4242
"AXP223",
4343
"AXP288",
4444
"AXP313a",
45+
"AXP717",
4546
"AXP803",
4647
"AXP806",
4748
"AXP809",
@@ -207,6 +208,25 @@ static const struct regmap_access_table axp313a_volatile_table = {
207208
.n_yes_ranges = ARRAY_SIZE(axp313a_volatile_ranges),
208209
};
209210

211+
static const struct regmap_range axp717_writeable_ranges[] = {
212+
regmap_reg_range(AXP717_IRQ0_EN, AXP717_IRQ4_EN),
213+
regmap_reg_range(AXP717_DCDC_OUTPUT_CONTROL, AXP717_CPUSLDO_CONTROL),
214+
};
215+
216+
static const struct regmap_range axp717_volatile_ranges[] = {
217+
regmap_reg_range(AXP717_IRQ0_STATE, AXP717_IRQ4_STATE),
218+
};
219+
220+
static const struct regmap_access_table axp717_writeable_table = {
221+
.yes_ranges = axp717_writeable_ranges,
222+
.n_yes_ranges = ARRAY_SIZE(axp717_writeable_ranges),
223+
};
224+
225+
static const struct regmap_access_table axp717_volatile_table = {
226+
.yes_ranges = axp717_volatile_ranges,
227+
.n_yes_ranges = ARRAY_SIZE(axp717_volatile_ranges),
228+
};
229+
210230
static const struct regmap_range axp806_volatile_ranges[] = {
211231
regmap_reg_range(AXP20X_IRQ1_STATE, AXP20X_IRQ2_STATE),
212232
};
@@ -317,6 +337,11 @@ static const struct resource axp313a_pek_resources[] = {
317337
DEFINE_RES_IRQ_NAMED(AXP313A_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
318338
};
319339

340+
static const struct resource axp717_pek_resources[] = {
341+
DEFINE_RES_IRQ_NAMED(AXP717_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
342+
DEFINE_RES_IRQ_NAMED(AXP717_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
343+
};
344+
320345
static const struct resource axp803_pek_resources[] = {
321346
DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
322347
DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
@@ -391,6 +416,15 @@ static const struct regmap_config axp313a_regmap_config = {
391416
.cache_type = REGCACHE_MAPLE,
392417
};
393418

419+
static const struct regmap_config axp717_regmap_config = {
420+
.reg_bits = 8,
421+
.val_bits = 8,
422+
.wr_table = &axp717_writeable_table,
423+
.volatile_table = &axp717_volatile_table,
424+
.max_register = AXP717_CPUSLDO_CONTROL,
425+
.cache_type = REGCACHE_RBTREE,
426+
};
427+
394428
static const struct regmap_config axp806_regmap_config = {
395429
.reg_bits = 8,
396430
.val_bits = 8,
@@ -589,6 +623,40 @@ static const struct regmap_irq axp313a_regmap_irqs[] = {
589623
INIT_REGMAP_IRQ(AXP313A, DIE_TEMP_HIGH, 0, 0),
590624
};
591625

626+
static const struct regmap_irq axp717_regmap_irqs[] = {
627+
INIT_REGMAP_IRQ(AXP717, SOC_DROP_LVL2, 0, 7),
628+
INIT_REGMAP_IRQ(AXP717, SOC_DROP_LVL1, 0, 6),
629+
INIT_REGMAP_IRQ(AXP717, GAUGE_NEW_SOC, 0, 4),
630+
INIT_REGMAP_IRQ(AXP717, BOOST_OVER_V, 0, 2),
631+
INIT_REGMAP_IRQ(AXP717, VBUS_OVER_V, 0, 1),
632+
INIT_REGMAP_IRQ(AXP717, VBUS_FAULT, 0, 0),
633+
INIT_REGMAP_IRQ(AXP717, VBUS_PLUGIN, 1, 7),
634+
INIT_REGMAP_IRQ(AXP717, VBUS_REMOVAL, 1, 6),
635+
INIT_REGMAP_IRQ(AXP717, BATT_PLUGIN, 1, 5),
636+
INIT_REGMAP_IRQ(AXP717, BATT_REMOVAL, 1, 4),
637+
INIT_REGMAP_IRQ(AXP717, PEK_SHORT, 1, 3),
638+
INIT_REGMAP_IRQ(AXP717, PEK_LONG, 1, 2),
639+
INIT_REGMAP_IRQ(AXP717, PEK_FAL_EDGE, 1, 1),
640+
INIT_REGMAP_IRQ(AXP717, PEK_RIS_EDGE, 1, 0),
641+
INIT_REGMAP_IRQ(AXP717, WDOG_EXPIRE, 2, 7),
642+
INIT_REGMAP_IRQ(AXP717, LDO_OVER_CURR, 2, 6),
643+
INIT_REGMAP_IRQ(AXP717, BATT_OVER_CURR, 2, 5),
644+
INIT_REGMAP_IRQ(AXP717, CHARG_DONE, 2, 4),
645+
INIT_REGMAP_IRQ(AXP717, CHARG, 2, 3),
646+
INIT_REGMAP_IRQ(AXP717, DIE_TEMP_HIGH, 2, 2),
647+
INIT_REGMAP_IRQ(AXP717, CHARG_TIMER, 2, 1),
648+
INIT_REGMAP_IRQ(AXP717, BATT_OVER_V, 2, 0),
649+
INIT_REGMAP_IRQ(AXP717, BC_USB_DONE, 3, 7),
650+
INIT_REGMAP_IRQ(AXP717, BC_USB_CHNG, 3, 6),
651+
INIT_REGMAP_IRQ(AXP717, BATT_QUIT_TEMP_HIGH, 3, 4),
652+
INIT_REGMAP_IRQ(AXP717, BATT_CHG_TEMP_HIGH, 3, 3),
653+
INIT_REGMAP_IRQ(AXP717, BATT_CHG_TEMP_LOW, 3, 2),
654+
INIT_REGMAP_IRQ(AXP717, BATT_ACT_TEMP_HIGH, 3, 1),
655+
INIT_REGMAP_IRQ(AXP717, BATT_ACT_TEMP_LOW, 3, 0),
656+
INIT_REGMAP_IRQ(AXP717, TYPEC_REMOVE, 4, 6),
657+
INIT_REGMAP_IRQ(AXP717, TYPEC_PLUGIN, 4, 5),
658+
};
659+
592660
static const struct regmap_irq axp803_regmap_irqs[] = {
593661
INIT_REGMAP_IRQ(AXP803, ACIN_OVER_V, 0, 7),
594662
INIT_REGMAP_IRQ(AXP803, ACIN_PLUGIN, 0, 6),
@@ -776,6 +844,17 @@ static const struct regmap_irq_chip axp313a_regmap_irq_chip = {
776844
.num_regs = 1,
777845
};
778846

847+
static const struct regmap_irq_chip axp717_regmap_irq_chip = {
848+
.name = "axp717_irq_chip",
849+
.status_base = AXP717_IRQ0_STATE,
850+
.ack_base = AXP717_IRQ0_STATE,
851+
.unmask_base = AXP717_IRQ0_EN,
852+
.init_ack_masked = true,
853+
.irqs = axp717_regmap_irqs,
854+
.num_irqs = ARRAY_SIZE(axp717_regmap_irqs),
855+
.num_regs = 5,
856+
};
857+
779858
static const struct regmap_irq_chip axp803_regmap_irq_chip = {
780859
.name = "axp803",
781860
.status_base = AXP20X_IRQ1_STATE,
@@ -941,6 +1020,11 @@ static struct mfd_cell axp313a_cells[] = {
9411020
MFD_CELL_RES("axp313a-pek", axp313a_pek_resources),
9421021
};
9431022

1023+
static struct mfd_cell axp717_cells[] = {
1024+
MFD_CELL_NAME("axp20x-regulator"),
1025+
MFD_CELL_RES("axp20x-pek", axp717_pek_resources),
1026+
};
1027+
9441028
static const struct resource axp288_adc_resources[] = {
9451029
DEFINE_RES_IRQ_NAMED(AXP288_IRQ_GPADC, "GPADC"),
9461030
};
@@ -1181,6 +1265,12 @@ int axp20x_match_device(struct axp20x_dev *axp20x)
11811265
axp20x->regmap_cfg = &axp313a_regmap_config;
11821266
axp20x->regmap_irq_chip = &axp313a_regmap_irq_chip;
11831267
break;
1268+
case AXP717_ID:
1269+
axp20x->nr_cells = ARRAY_SIZE(axp717_cells);
1270+
axp20x->cells = axp717_cells;
1271+
axp20x->regmap_cfg = &axp717_regmap_config;
1272+
axp20x->regmap_irq_chip = &axp717_regmap_irq_chip;
1273+
break;
11841274
case AXP803_ID:
11851275
axp20x->nr_cells = ARRAY_SIZE(axp803_cells);
11861276
axp20x->cells = axp803_cells;

include/linux/mfd/axp20x.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ enum axp20x_variants {
1919
AXP223_ID,
2020
AXP288_ID,
2121
AXP313A_ID,
22+
AXP717_ID,
2223
AXP803_ID,
2324
AXP806_ID,
2425
AXP809_ID,
@@ -113,6 +114,38 @@ enum axp20x_variants {
113114
#define AXP313A_IRQ_EN 0x20
114115
#define AXP313A_IRQ_STATE 0x21
115116

117+
#define AXP717_ON_INDICATE 0x00
118+
#define AXP717_IRQ0_EN 0x40
119+
#define AXP717_IRQ1_EN 0x41
120+
#define AXP717_IRQ2_EN 0x42
121+
#define AXP717_IRQ3_EN 0x43
122+
#define AXP717_IRQ4_EN 0x44
123+
#define AXP717_IRQ0_STATE 0x48
124+
#define AXP717_IRQ1_STATE 0x49
125+
#define AXP717_IRQ2_STATE 0x4a
126+
#define AXP717_IRQ3_STATE 0x4b
127+
#define AXP717_IRQ4_STATE 0x4c
128+
#define AXP717_DCDC_OUTPUT_CONTROL 0x80
129+
#define AXP717_DCDC1_CONTROL 0x83
130+
#define AXP717_DCDC2_CONTROL 0x84
131+
#define AXP717_DCDC3_CONTROL 0x85
132+
#define AXP717_DCDC4_CONTROL 0x86
133+
#define AXP717_LDO0_OUTPUT_CONTROL 0x90
134+
#define AXP717_LDO1_OUTPUT_CONTROL 0x91
135+
#define AXP717_ALDO1_CONTROL 0x93
136+
#define AXP717_ALDO2_CONTROL 0x94
137+
#define AXP717_ALDO3_CONTROL 0x95
138+
#define AXP717_ALDO4_CONTROL 0x96
139+
#define AXP717_BLDO1_CONTROL 0x97
140+
#define AXP717_BLDO2_CONTROL 0x98
141+
#define AXP717_BLDO3_CONTROL 0x99
142+
#define AXP717_BLDO4_CONTROL 0x9a
143+
#define AXP717_CLDO1_CONTROL 0x9b
144+
#define AXP717_CLDO2_CONTROL 0x9c
145+
#define AXP717_CLDO3_CONTROL 0x9d
146+
#define AXP717_CLDO4_CONTROL 0x9e
147+
#define AXP717_CPUSLDO_CONTROL 0x9f
148+
116149
#define AXP806_STARTUP_SRC 0x00
117150
#define AXP806_CHIP_ID 0x03
118151
#define AXP806_PWR_OUT_CTRL1 0x10
@@ -732,6 +765,40 @@ enum axp313a_irqs {
732765
AXP313A_IRQ_PEK_RIS_EDGE,
733766
};
734767

768+
enum axp717_irqs {
769+
AXP717_IRQ_VBUS_FAULT,
770+
AXP717_IRQ_VBUS_OVER_V,
771+
AXP717_IRQ_BOOST_OVER_V,
772+
AXP717_IRQ_GAUGE_NEW_SOC = 4,
773+
AXP717_IRQ_SOC_DROP_LVL1 = 6,
774+
AXP717_IRQ_SOC_DROP_LVL2,
775+
AXP717_IRQ_PEK_RIS_EDGE,
776+
AXP717_IRQ_PEK_FAL_EDGE,
777+
AXP717_IRQ_PEK_LONG,
778+
AXP717_IRQ_PEK_SHORT,
779+
AXP717_IRQ_BATT_REMOVAL,
780+
AXP717_IRQ_BATT_PLUGIN,
781+
AXP717_IRQ_VBUS_REMOVAL,
782+
AXP717_IRQ_VBUS_PLUGIN,
783+
AXP717_IRQ_BATT_OVER_V,
784+
AXP717_IRQ_CHARG_TIMER,
785+
AXP717_IRQ_DIE_TEMP_HIGH,
786+
AXP717_IRQ_CHARG,
787+
AXP717_IRQ_CHARG_DONE,
788+
AXP717_IRQ_BATT_OVER_CURR,
789+
AXP717_IRQ_LDO_OVER_CURR,
790+
AXP717_IRQ_WDOG_EXPIRE,
791+
AXP717_IRQ_BATT_ACT_TEMP_LOW,
792+
AXP717_IRQ_BATT_ACT_TEMP_HIGH,
793+
AXP717_IRQ_BATT_CHG_TEMP_LOW,
794+
AXP717_IRQ_BATT_CHG_TEMP_HIGH,
795+
AXP717_IRQ_BATT_QUIT_TEMP_HIGH,
796+
AXP717_IRQ_BC_USB_CHNG = 30,
797+
AXP717_IRQ_BC_USB_DONE,
798+
AXP717_IRQ_TYPEC_PLUGIN = 37,
799+
AXP717_IRQ_TYPEC_REMOVE,
800+
};
801+
735802
enum axp803_irqs {
736803
AXP803_IRQ_ACIN_OVER_V = 1,
737804
AXP803_IRQ_ACIN_PLUGIN,

0 commit comments

Comments
 (0)