]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/mfd/tps65910.c
Merge branch 'slab/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/penber...
[karo-tx-linux.git] / drivers / mfd / tps65910.c
index d3ce4d569deb57c2b707dc73d6cb7cf600962cab..0d79ce2b5014c938b0f366d74639eace2508659e 100644 (file)
 #include <linux/mfd/tps65910.h>
 #include <linux/of_device.h>
 
+static struct resource rtc_resources[] = {
+       {
+               .start  = TPS65910_IRQ_RTC_ALARM,
+               .end    = TPS65910_IRQ_RTC_ALARM,
+               .flags  = IORESOURCE_IRQ,
+       }
+};
+
 static struct mfd_cell tps65910s[] = {
        {
                .name = "tps65910-gpio",
@@ -33,6 +41,8 @@ static struct mfd_cell tps65910s[] = {
        },
        {
                .name = "tps65910-rtc",
+               .num_resources = ARRAY_SIZE(rtc_resources),
+               .resources = &rtc_resources[0],
        },
        {
                .name = "tps65910-power",
@@ -198,6 +208,8 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
 
        board_info->irq = client->irq;
        board_info->irq_base = -1;
+       board_info->pm_off = of_property_read_bool(np,
+                       "ti,system-power-controller");
 
        return board_info;
 }
@@ -210,6 +222,21 @@ struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
 }
 #endif
 
+static struct i2c_client *tps65910_i2c_client;
+static void tps65910_power_off(void)
+{
+       struct tps65910 *tps65910;
+
+       tps65910 = dev_get_drvdata(&tps65910_i2c_client->dev);
+
+       if (tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL,
+                       DEVCTRL_PWR_OFF_MASK) < 0)
+               return;
+
+       tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL,
+                       DEVCTRL_DEV_ON_MASK);
+}
+
 static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
                                        const struct i2c_device_id *id)
 {
@@ -267,6 +294,11 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
        tps65910_ck32k_init(tps65910, pmic_plat_data);
        tps65910_sleepinit(tps65910, pmic_plat_data);
 
+       if (pmic_plat_data->pm_off && !pm_power_off) {
+               tps65910_i2c_client = i2c;
+               pm_power_off = tps65910_power_off;
+       }
+
        return ret;
 }