mfd: Add STMPE1600 support
[cascardo/linux.git] / drivers / mfd / axp20x.c
index e4e3297..fd80b09 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -93,7 +94,10 @@ static const struct regmap_range axp22x_writeable_ranges[] = {
 };
 
 static const struct regmap_range axp22x_volatile_ranges[] = {
+       regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP20X_PWR_OP_MODE),
        regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
+       regmap_reg_range(AXP22X_GPIO_STATE, AXP22X_GPIO_STATE),
+       regmap_reg_range(AXP20X_FG_RES, AXP20X_FG_RES),
 };
 
 static const struct regmap_access_table axp22x_writeable_table = {
@@ -157,6 +161,11 @@ static struct resource axp20x_usb_power_supply_resources[] = {
        DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"),
 };
 
+static struct resource axp22x_usb_power_supply_resources[] = {
+       DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
+       DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
+};
+
 static struct resource axp22x_pek_resources[] = {
        {
                .name   = "PEK_DBR",
@@ -524,6 +533,11 @@ static struct mfd_cell axp22x_cells[] = {
                .resources              = axp22x_pek_resources,
        }, {
                .name                   = "axp20x-regulator",
+       }, {
+               .name           = "axp20x-usb-power-supply",
+               .of_compatible  = "x-powers,axp221-usb-power-supply",
+               .num_resources  = ARRAY_SIZE(axp22x_usb_power_supply_resources),
+               .resources      = axp22x_usb_power_supply_resources,
        },
 };
 
@@ -664,6 +678,9 @@ static void axp20x_power_off(void)
 
        regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL,
                     AXP20X_OFF);
+
+       /* Give capacitors etc. time to drain to avoid kernel panic msg. */
+       msleep(500);
 }
 
 int axp20x_match_device(struct axp20x_dev *axp20x)