aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2016-03-29 05:22:26 -0400
committerLee Jones <lee.jones@linaro.org>2016-04-19 02:54:08 -0400
commit20147f0d4f50f6f0d1fbe1815fe3d4d0a6444a70 (patch)
treeb56224225f178018f024a8f3e47ff6460639acd9 /drivers/mfd
parentdedf24a28da67f6bf814cb5d05a5d12bb39093dc (diff)
mfd: axp20x: Add support for AXP809 PMIC
The X-Powers AXP809 is a new PMIC that is paired with Allwinner's A80 SoC, along with a slave AXP806 PMIC. This PMIC is quite similar to the earlier AXP223, though the interrupts and regulator have changed a bit. This patch adds support for the interrupts and power button of the PMIC. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/axp20x-rsb.c1
-rw-r--r--drivers/mfd/axp20x.c79
2 files changed, 80 insertions, 0 deletions
diff --git a/drivers/mfd/axp20x-rsb.c b/drivers/mfd/axp20x-rsb.c
index 28c20247c112..a407527bcd09 100644
--- a/drivers/mfd/axp20x-rsb.c
+++ b/drivers/mfd/axp20x-rsb.c
@@ -61,6 +61,7 @@ static int axp20x_rsb_remove(struct sunxi_rsb_device *rdev)
61 61
62static const struct of_device_id axp20x_rsb_of_match[] = { 62static const struct of_device_id axp20x_rsb_of_match[] = {
63 { .compatible = "x-powers,axp223", .data = (void *)AXP223_ID }, 63 { .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
64 { .compatible = "x-powers,axp809", .data = (void *)AXP809_ID },
64 { }, 65 { },
65}; 66};
66MODULE_DEVICE_TABLE(of, axp20x_rsb_of_match); 67MODULE_DEVICE_TABLE(of, axp20x_rsb_of_match);
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index a57d6e940610..1ce923277cc8 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -37,6 +37,7 @@ static const char * const axp20x_model_names[] = {
37 "AXP221", 37 "AXP221",
38 "AXP223", 38 "AXP223",
39 "AXP288", 39 "AXP288",
40 "AXP809",
40}; 41};
41 42
42static const struct regmap_range axp152_writeable_ranges[] = { 43static const struct regmap_range axp152_writeable_ranges[] = {
@@ -85,6 +86,7 @@ static const struct regmap_access_table axp20x_volatile_table = {
85 .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges), 86 .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges),
86}; 87};
87 88
89/* AXP22x ranges are shared with the AXP809, as they cover the same range */
88static const struct regmap_range axp22x_writeable_ranges[] = { 90static const struct regmap_range axp22x_writeable_ranges[] = {
89 regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE), 91 regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
90 regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1), 92 regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
@@ -211,6 +213,20 @@ static struct resource axp288_fuel_gauge_resources[] = {
211 }, 213 },
212}; 214};
213 215
216static struct resource axp809_pek_resources[] = {
217 {
218 .name = "PEK_DBR",
219 .start = AXP809_IRQ_PEK_RIS_EDGE,
220 .end = AXP809_IRQ_PEK_RIS_EDGE,
221 .flags = IORESOURCE_IRQ,
222 }, {
223 .name = "PEK_DBF",
224 .start = AXP809_IRQ_PEK_FAL_EDGE,
225 .end = AXP809_IRQ_PEK_FAL_EDGE,
226 .flags = IORESOURCE_IRQ,
227 },
228};
229
214static const struct regmap_config axp152_regmap_config = { 230static const struct regmap_config axp152_regmap_config = {
215 .reg_bits = 8, 231 .reg_bits = 8,
216 .val_bits = 8, 232 .val_bits = 8,
@@ -378,6 +394,41 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
378 INIT_REGMAP_IRQ(AXP288, BC_USB_CHNG, 5, 1), 394 INIT_REGMAP_IRQ(AXP288, BC_USB_CHNG, 5, 1),
379}; 395};
380 396
397static const struct regmap_irq axp809_regmap_irqs[] = {
398 INIT_REGMAP_IRQ(AXP809, ACIN_OVER_V, 0, 7),
399 INIT_REGMAP_IRQ(AXP809, ACIN_PLUGIN, 0, 6),
400 INIT_REGMAP_IRQ(AXP809, ACIN_REMOVAL, 0, 5),
401 INIT_REGMAP_IRQ(AXP809, VBUS_OVER_V, 0, 4),
402 INIT_REGMAP_IRQ(AXP809, VBUS_PLUGIN, 0, 3),
403 INIT_REGMAP_IRQ(AXP809, VBUS_REMOVAL, 0, 2),
404 INIT_REGMAP_IRQ(AXP809, VBUS_V_LOW, 0, 1),
405 INIT_REGMAP_IRQ(AXP809, BATT_PLUGIN, 1, 7),
406 INIT_REGMAP_IRQ(AXP809, BATT_REMOVAL, 1, 6),
407 INIT_REGMAP_IRQ(AXP809, BATT_ENT_ACT_MODE, 1, 5),
408 INIT_REGMAP_IRQ(AXP809, BATT_EXIT_ACT_MODE, 1, 4),
409 INIT_REGMAP_IRQ(AXP809, CHARG, 1, 3),
410 INIT_REGMAP_IRQ(AXP809, CHARG_DONE, 1, 2),
411 INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_HIGH, 2, 7),
412 INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_HIGH_END, 2, 6),
413 INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_LOW, 2, 5),
414 INIT_REGMAP_IRQ(AXP809, BATT_CHG_TEMP_LOW_END, 2, 4),
415 INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_HIGH, 2, 3),
416 INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_HIGH_END, 2, 2),
417 INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_LOW, 2, 1),
418 INIT_REGMAP_IRQ(AXP809, BATT_ACT_TEMP_LOW_END, 2, 0),
419 INIT_REGMAP_IRQ(AXP809, DIE_TEMP_HIGH, 3, 7),
420 INIT_REGMAP_IRQ(AXP809, LOW_PWR_LVL1, 3, 1),
421 INIT_REGMAP_IRQ(AXP809, LOW_PWR_LVL2, 3, 0),
422 INIT_REGMAP_IRQ(AXP809, TIMER, 4, 7),
423 INIT_REGMAP_IRQ(AXP809, PEK_RIS_EDGE, 4, 6),
424 INIT_REGMAP_IRQ(AXP809, PEK_FAL_EDGE, 4, 5),
425 INIT_REGMAP_IRQ(AXP809, PEK_SHORT, 4, 4),
426 INIT_REGMAP_IRQ(AXP809, PEK_LONG, 4, 3),
427 INIT_REGMAP_IRQ(AXP809, PEK_OVER_OFF, 4, 2),
428 INIT_REGMAP_IRQ(AXP809, GPIO1_INPUT, 4, 1),
429 INIT_REGMAP_IRQ(AXP809, GPIO0_INPUT, 4, 0),
430};
431
381static const struct regmap_irq_chip axp152_regmap_irq_chip = { 432static const struct regmap_irq_chip axp152_regmap_irq_chip = {
382 .name = "axp152_irq_chip", 433 .name = "axp152_irq_chip",
383 .status_base = AXP152_IRQ1_STATE, 434 .status_base = AXP152_IRQ1_STATE,
@@ -428,6 +479,18 @@ static const struct regmap_irq_chip axp288_regmap_irq_chip = {
428 479
429}; 480};
430 481
482static const struct regmap_irq_chip axp809_regmap_irq_chip = {
483 .name = "axp809",
484 .status_base = AXP20X_IRQ1_STATE,
485 .ack_base = AXP20X_IRQ1_STATE,
486 .mask_base = AXP20X_IRQ1_EN,
487 .mask_invert = true,
488 .init_ack_masked = true,
489 .irqs = axp809_regmap_irqs,
490 .num_irqs = ARRAY_SIZE(axp809_regmap_irqs),
491 .num_regs = 5,
492};
493
431static struct mfd_cell axp20x_cells[] = { 494static struct mfd_cell axp20x_cells[] = {
432 { 495 {
433 .name = "axp20x-pek", 496 .name = "axp20x-pek",
@@ -572,6 +635,16 @@ static struct mfd_cell axp288_cells[] = {
572 }, 635 },
573}; 636};
574 637
638static struct mfd_cell axp809_cells[] = {
639 {
640 .name = "axp20x-pek",
641 .num_resources = ARRAY_SIZE(axp809_pek_resources),
642 .resources = axp809_pek_resources,
643 }, {
644 .name = "axp20x-regulator",
645 },
646};
647
575static struct axp20x_dev *axp20x_pm_power_off; 648static struct axp20x_dev *axp20x_pm_power_off;
576static void axp20x_power_off(void) 649static void axp20x_power_off(void)
577{ 650{
@@ -631,6 +704,12 @@ int axp20x_match_device(struct axp20x_dev *axp20x)
631 axp20x->regmap_cfg = &axp288_regmap_config; 704 axp20x->regmap_cfg = &axp288_regmap_config;
632 axp20x->regmap_irq_chip = &axp288_regmap_irq_chip; 705 axp20x->regmap_irq_chip = &axp288_regmap_irq_chip;
633 break; 706 break;
707 case AXP809_ID:
708 axp20x->nr_cells = ARRAY_SIZE(axp809_cells);
709 axp20x->cells = axp809_cells;
710 axp20x->regmap_cfg = &axp22x_regmap_config;
711 axp20x->regmap_irq_chip = &axp809_regmap_irq_chip;
712 break;
634 default: 713 default:
635 dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); 714 dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant);
636 return -EINVAL; 715 return -EINVAL;