]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
mfd: max77620: add support for configuring low-battery monitor
authorLaxman Dewangan <ldewangan@nvidia.com>
Wed, 7 Oct 2015 13:01:45 +0000 (18:31 +0530)
committermobile promotions <svcmobile_promotions@nvidia.com>
Fri, 9 Oct 2015 22:32:43 +0000 (15:32 -0700)
Add support to configure low battery monitor configuration register.

Change-Id: I426742d3af44b8bd1980f10da67142215b4e6d93
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
(cherry picked from commit 18d0e3f001a6e831172766fd51b42a4b8deefaa1)
Reviewed-on: http://git-master/r/815126
GVS: Gerrit_Virtual_Submit

Documentation/devicetree/bindings/mfd/max77620.txt
drivers/mfd/max77620-core.c
include/linux/mfd/max77620.h

index 40030f107f2b9ac13656e4bcfc40786b00355f9f..cd9bcd9517f6a34ed1edf077c12d189ca4b0ae40 100644 (file)
@@ -189,6 +189,26 @@ Optinal properties:
                        to nearest lower side if other than above is configured.
        -maxim,backup-battery-output-resister: Output resistor on Ohm.
                        Device supports 100/1000/3000/6000 Ohms.
+Low-Battery Monitor:
+==================
+This sub-node configure low battery monitor configuration registers. Device has
+support for low-battery monitor configuration through child DT node
+"low-battery-monitor".
+
+Optinal properties:
+       - maxim,low-battery-dac-enable: Enable low battery DAC.
+       - maxim,low-battery-dac-disable: Disable low battery DAC.
+       - maxim,low-battery-shutdown-enable: Enable low battery shutdown.
+       - maxim,low-battery-shutdown-disable: Disable low battery shutdown.
+       - maxim,low-battery-reset-enable: Enable low battery reset.
+       - maxim,low-battery-reset-disable: Disable low battery reset.
+Watchdog:
+==============
+This sub-node configure watchdog timer of the device. Device has watchdog
+for monitoring system health. If WDT expire, system get reset.
+
+Optinal properties:
+       -maxim,wdt-timeout: Watchdog timeout.
 Watchdog:
 ==============
 This sub-node configure watchdog timer of the device. Device has watchdog
index 3b3e2b26d69c371dcd0b7407b770f7daefb7611f..f0fe1516c0c4921fa566078a021bfd829a768d7f 100644 (file)
@@ -450,6 +450,56 @@ static int max77620_init_backup_battery_charging(struct max77620_chip *chip,
        return 0;
 }
 
+static int max77620_init_low_battery_monitor(struct max77620_chip *chip,
+               struct device *dev)
+{
+       struct device_node *np;
+       bool pval;
+       u8 mask = 0;
+       u8 val = 0;
+       int ret;
+
+
+       np = of_get_child_by_name(dev->of_node, "low-battery-monitor");
+       if (!np)
+               return 0;
+
+       pval = of_property_read_bool(np, "maxim,low-battery-dac-enable");
+       if (pval) {
+               mask |= MAX77620_CNFGGLBL1_LBDAC_EN;
+               val |= MAX77620_CNFGGLBL1_LBDAC_EN;
+       }
+       pval = of_property_read_bool(np, "maxim,low-battery-dac-disable");
+       if (pval)
+               mask |= MAX77620_CNFGGLBL1_LBDAC_EN;
+
+       pval = of_property_read_bool(np, "maxim,low-battery-shutdown-enable");
+       if (pval) {
+               mask |= MAX77620_CNFGGLBL1_MPPLD;
+               val |= MAX77620_CNFGGLBL1_MPPLD;
+       }
+       pval = of_property_read_bool(np, "maxim,low-battery-shutdown-disable");
+       if (pval)
+               mask |= MAX77620_CNFGGLBL1_MPPLD;
+
+       pval = of_property_read_bool(np, "maxim,low-battery-reset-enable");
+       if (pval) {
+               mask |= MAX77620_CNFGGLBL1_LBRSTEN;
+               val |= MAX77620_CNFGGLBL1_LBRSTEN;
+       }
+       pval = of_property_read_bool(np, "maxim,low-battery-reset-disable");
+       if (pval)
+               mask |= MAX77620_CNFGGLBL1_LBRSTEN;
+
+       ret = max77620_reg_update(dev, MAX77620_PWR_SLAVE,
+                       MAX77620_REG_CNFGGLBL1, mask, val);
+       if (ret < 0) {
+               dev_err(dev, "Reg CNFGGLBL1 update failed, %d\n", ret);
+               return ret;
+       }
+       return 0;
+}
+
 static int max77620_initialise_chip(struct max77620_chip *chip,
                        struct device *dev)
 {
@@ -624,6 +674,13 @@ static int max77620_probe(struct i2c_client *client,
                goto fail_free_irq;
        }
 
+       ret = max77620_init_low_battery_monitor(chip, &client->dev);
+       if (ret < 0) {
+               dev_err(&client->dev, "Low battery monitor init failed, %d\n",
+                       ret);
+               goto fail_free_irq;
+       }
+
        ret =  mfd_add_devices(&client->dev, -1, children->cells,
                        children->ncells, NULL, 0,
                        regmap_irq_get_domain(chip->top_irq_data));
index 579c19945c8fe4a763db7d79c7f1f3cc019ea7ae..19273a2238ca66123218a76af62e6b5909dff2a7 100644 (file)
 #define MAX77620_TWD_64s                       0x2
 #define MAX77620_TWD_128s                      0x3
 
+#define MAX77620_CNFGGLBL1_LBDAC_EN            BIT(7)
+#define MAX77620_CNFGGLBL1_MPPLD               BIT(6)
+#define MAX77620_CNFGGLBL1_LBHYST              (BIT(5) | BIT(4))
+#define MAX77620_CNFGGLBL1_LBDAC               0x0E
+#define MAX77620_CNFGGLBL1_LBRSTEN             BIT(0)
+
 /* CNFG BBC registers */
 #define MAX77620_CNFGBBC_ENABLE                        BIT(0)
 #define MAX77620_CNFGBBC_CURRENT_MASK          0x06