]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge tag 'for-v3.19' of git://git.infradead.org/battery-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Dec 2014 01:36:45 +0000 (17:36 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Dec 2014 01:36:45 +0000 (17:36 -0800)
Pull power supply updates from Sebastian Reichel::
 "Power supply and reset changes for the v3.19 series

   - update power/reset drivers to use kernel restart handler
   - add power off driver for i.mx6
   - add DT support for gpio-charger"

* tag 'for-v3.19' of git://git.infradead.org/battery-2.6:
  power: reset: adjust priority of simple syscon reboot driver
  power: ds2782_battery: Simplify the PM hooks
  power/reset: brcmstb: Register with kernel restart handler
  power/reset: hisi: Register with kernel restart handler
  power/reset: keystone: Register with kernel restart handler
  power/reset: axxia: Register with kernel restart handler
  power/reset: xgene: Register with kernel restart handler
  power/reset: xgene: Use mdelay instead of jiffies based timeout
  power/reset: xgene: Use local variable dev instead of pdev->dev
  power/reset: xgene: Drop devm_kfree
  power/reset: xgene: Return -ENOMEM if out of memory
  power/reset: vexpress: Register with kernel restart handler
  power: reset: imx-snvs-poweroff: add power off driver for i.mx6
  power: gpio-charger: add device tree support
  dt-bindings: document gpio-charger bindings

1  2 
drivers/power/gpio-charger.c
drivers/power/reset/brcmstb-reboot.c
drivers/power/reset/keystone-reset.c

index 3ee889fe00219e1d2e4a7fa1b9f16f987b9444d7,df984ecad1cc12b6d5dd1e65f25527ed07a9e91e..aef74bdf7ab31690ebb1d286df3a593e24d18788
@@@ -22,6 -22,8 +22,8 @@@
  #include <linux/platform_device.h>
  #include <linux/power_supply.h>
  #include <linux/slab.h>
+ #include <linux/of.h>
+ #include <linux/of_gpio.h>
  
  #include <linux/power/gpio-charger.h>
  
@@@ -69,6 -71,59 +71,59 @@@ static enum power_supply_property gpio_
        POWER_SUPPLY_PROP_ONLINE,
  };
  
+ static
+ struct gpio_charger_platform_data *gpio_charger_parse_dt(struct device *dev)
+ {
+       struct device_node *np = dev->of_node;
+       struct gpio_charger_platform_data *pdata;
+       const char *chargetype;
+       enum of_gpio_flags flags;
+       int ret;
+       if (!np)
+               return ERR_PTR(-ENOENT);
+       pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+       if (!pdata)
+               return ERR_PTR(-ENOMEM);
+       pdata->name = np->name;
+       pdata->gpio = of_get_gpio_flags(np, 0, &flags);
+       if (pdata->gpio < 0) {
+               if (pdata->gpio != -EPROBE_DEFER)
+                       dev_err(dev, "could not get charger gpio\n");
+               return ERR_PTR(pdata->gpio);
+       }
+       pdata->gpio_active_low = !!(flags & OF_GPIO_ACTIVE_LOW);
+       pdata->type = POWER_SUPPLY_TYPE_UNKNOWN;
+       ret = of_property_read_string(np, "charger-type", &chargetype);
+       if (ret >= 0) {
+               if (!strncmp("unknown", chargetype, 7))
+                       pdata->type = POWER_SUPPLY_TYPE_UNKNOWN;
+               else if (!strncmp("battery", chargetype, 7))
+                       pdata->type = POWER_SUPPLY_TYPE_BATTERY;
+               else if (!strncmp("ups", chargetype, 3))
+                       pdata->type = POWER_SUPPLY_TYPE_UPS;
+               else if (!strncmp("mains", chargetype, 5))
+                       pdata->type = POWER_SUPPLY_TYPE_MAINS;
+               else if (!strncmp("usb-sdp", chargetype, 7))
+                       pdata->type = POWER_SUPPLY_TYPE_USB;
+               else if (!strncmp("usb-dcp", chargetype, 7))
+                       pdata->type = POWER_SUPPLY_TYPE_USB_DCP;
+               else if (!strncmp("usb-cdp", chargetype, 7))
+                       pdata->type = POWER_SUPPLY_TYPE_USB_CDP;
+               else if (!strncmp("usb-aca", chargetype, 7))
+                       pdata->type = POWER_SUPPLY_TYPE_USB_ACA;
+               else
+                       dev_warn(dev, "unknown charger type %s\n", chargetype);
+       }
+       return pdata;
+ }
  static int gpio_charger_probe(struct platform_device *pdev)
  {
        const struct gpio_charger_platform_data *pdata = pdev->dev.platform_data;
        int irq;
  
        if (!pdata) {
-               dev_err(&pdev->dev, "No platform data\n");
-               return -EINVAL;
+               pdata = gpio_charger_parse_dt(&pdev->dev);
+               if (IS_ERR(pdata)) {
+                       ret = PTR_ERR(pdata);
+                       if (ret != -EPROBE_DEFER)
+                               dev_err(&pdev->dev, "No platform data\n");
+                       return ret;
+               }
        }
  
        if (!gpio_is_valid(pdata->gpio)) {
        charger->get_property = gpio_charger_get_property;
        charger->supplied_to = pdata->supplied_to;
        charger->num_supplicants = pdata->num_supplicants;
+       charger->of_node = pdev->dev.of_node;
  
        ret = gpio_request(pdata->gpio, dev_name(&pdev->dev));
        if (ret) {
@@@ -189,12 -250,20 +250,19 @@@ static int gpio_charger_resume(struct d
  static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops,
                gpio_charger_suspend, gpio_charger_resume);
  
+ static const struct of_device_id gpio_charger_match[] = {
+       { .compatible = "gpio-charger" },
+       { }
+ };
+ MODULE_DEVICE_TABLE(of, gpio_charger_match);
  static struct platform_driver gpio_charger_driver = {
        .probe = gpio_charger_probe,
        .remove = gpio_charger_remove,
        .driver = {
                .name = "gpio-charger",
 -              .owner = THIS_MODULE,
                .pm = &gpio_charger_pm_ops,
+               .of_match_table = gpio_charger_match,
        },
  };
  
index c523ea7a90ee731b90115c0fa4de095ba026d62a,1ad56298c6c7527c11db3e3a3f907d19845ba0c2..100606f9b3dccb408b7fc59ada494db73a895e1f
@@@ -16,6 -16,7 +16,7 @@@
  #include <linux/init.h>
  #include <linux/io.h>
  #include <linux/jiffies.h>
+ #include <linux/notifier.h>
  #include <linux/of_address.h>
  #include <linux/of_irq.h>
  #include <linux/of_platform.h>
@@@ -26,8 -27,6 +27,6 @@@
  #include <linux/smp.h>
  #include <linux/mfd/syscon.h>
  
- #include <asm/system_misc.h>
  #define RESET_SOURCE_ENABLE_REG 1
  #define SW_MASTER_RESET_REG 2
  
@@@ -35,7 -34,8 +34,8 @@@ static struct regmap *regmap
  static u32 rst_src_en;
  static u32 sw_mstr_rst;
  
- static void brcmstb_reboot(enum reboot_mode mode, const char *cmd)
+ static int brcmstb_restart_handler(struct notifier_block *this,
+                                  unsigned long mode, void *cmd)
  {
        int rc;
        u32 tmp;
        rc = regmap_write(regmap, rst_src_en, 1);
        if (rc) {
                pr_err("failed to write rst_src_en (%d)\n", rc);
-               return;
+               return NOTIFY_DONE;
        }
  
        rc = regmap_read(regmap, rst_src_en, &tmp);
        if (rc) {
                pr_err("failed to read rst_src_en (%d)\n", rc);
-               return;
+               return NOTIFY_DONE;
        }
  
        rc = regmap_write(regmap, sw_mstr_rst, 1);
        if (rc) {
                pr_err("failed to write sw_mstr_rst (%d)\n", rc);
-               return;
+               return NOTIFY_DONE;
        }
  
        rc = regmap_read(regmap, sw_mstr_rst, &tmp);
        if (rc) {
                pr_err("failed to read sw_mstr_rst (%d)\n", rc);
-               return;
+               return NOTIFY_DONE;
        }
  
        while (1)
                ;
+       return NOTIFY_DONE;
  }
  
+ static struct notifier_block brcmstb_restart_nb = {
+       .notifier_call = brcmstb_restart_handler,
+       .priority = 128,
+ };
  static int brcmstb_reboot_probe(struct platform_device *pdev)
  {
        int rc;
                return -EINVAL;
        }
  
-       arm_pm_restart = brcmstb_reboot;
+       rc = register_restart_handler(&brcmstb_restart_nb);
+       if (rc)
+               dev_err(&pdev->dev,
+                       "cannot register restart handler (err=%d)\n", rc);
  
-       return 0;
+       return rc;
  }
  
  static const struct of_device_id of_match[] = {
@@@ -107,6 -117,7 +117,6 @@@ static struct platform_driver brcmstb_r
        .probe = brcmstb_reboot_probe,
        .driver = {
                .name = "brcmstb-reboot",
 -              .owner = THIS_MODULE,
                .of_match_table = of_match,
        },
  };
index 86bc100818b2bd0b297d428f036e0117539a673a,4b6b12e744775d435c1375584f8e412ab8bc3c2e..faedf16c8111895a84b0724e32d2fb219b84fb38
@@@ -12,9 -12,9 +12,9 @@@
  
  #include <linux/io.h>
  #include <linux/module.h>
+ #include <linux/notifier.h>
  #include <linux/reboot.h>
  #include <linux/regmap.h>
- #include <asm/system_misc.h>
  #include <linux/mfd/syscon.h>
  #include <linux/of_platform.h>
  
@@@ -52,7 -52,8 +52,8 @@@ static inline int rsctrl_enable_rspll_w
                                  RSCTRL_KEY_MASK, RSCTRL_KEY);
  }
  
- static void rsctrl_restart(enum reboot_mode mode, const char *cmd)
+ static int rsctrl_restart_handler(struct notifier_block *this,
+                                 unsigned long mode, void *cmd)
  {
        /* enable write access to RSTCTRL */
        rsctrl_enable_rspll_write();
        /* reset the SOC */
        regmap_update_bits(pllctrl_regs, rspll_offset + RSCTRL_RG,
                           RSCTRL_RESET_MASK, 0);
+       return NOTIFY_DONE;
  }
  
+ static struct notifier_block rsctrl_restart_nb = {
+       .notifier_call = rsctrl_restart_handler,
+       .priority = 128,
+ };
  static struct of_device_id rsctrl_of_match[] = {
        {.compatible = "ti,keystone-reset", },
        {},
@@@ -114,8 -122,6 +122,6 @@@ static int rsctrl_probe(struct platform
        if (ret)
                return ret;
  
-       arm_pm_restart = rsctrl_restart;
        /* disable a reset isolation for all module clocks */
        ret = regmap_write(pllctrl_regs, rspll_offset + RSISO_RG, 0);
        if (ret)
                        return ret;
        }
  
-       return 0;
+       ret = register_restart_handler(&rsctrl_restart_nb);
+       if (ret)
+               dev_err(dev, "cannot register restart handler (err=%d)\n", ret);
+       return ret;
  }
  
  static struct platform_driver rsctrl_driver = {
        .probe = rsctrl_probe,
        .driver = {
 -              .owner = THIS_MODULE,
                .name = KBUILD_MODNAME,
                .of_match_table = rsctrl_of_match,
        },