diff options
author | Rajanikanth H.V <rajanikanth.hv@stericsson.com> | 2012-10-31 11:40:33 -0400 |
---|---|---|
committer | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-11-18 22:37:18 -0500 |
commit | a12810ab9fcf0c9fd5e50b5e350a3ffbeaa571be (patch) | |
tree | 9d691b2cfae398b454854a0c34c0308a7af74adb | |
parent | 4aef72dbb2e8997e627dd94ae2b9109dc09fffaa (diff) |
ab8500: Add devicetree support for chargalg
This patch adds device tree support for charging algorithm driver
Signed-off-by: Rajanikanth H.V <rajanikanth.hv@stericsson.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
-rw-r--r-- | Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt | 16 | ||||
-rw-r--r-- | arch/arm/boot/dts/dbx5x0.dtsi | 5 | ||||
-rw-r--r-- | drivers/mfd/ab8500-core.c | 5 | ||||
-rw-r--r-- | drivers/power/abx500_chargalg.c | 54 | ||||
-rw-r--r-- | include/linux/mfd/abx500.h | 6 |
5 files changed, 64 insertions, 22 deletions
diff --git a/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt b/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt new file mode 100644 index 00000000000..ef532837112 --- /dev/null +++ b/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt | |||
@@ -0,0 +1,16 @@ | |||
1 | === AB8500 Charging Algorithm Driver === | ||
2 | |||
3 | The properties below describes the node for chargalg driver. | ||
4 | |||
5 | Required Properties: | ||
6 | - compatible = Shall be: "stericsson,ab8500-chargalg" | ||
7 | - battery = Shall be battery specific information | ||
8 | |||
9 | Example: | ||
10 | ab8500_chargalg { | ||
11 | compatible = "stericsson,ab8500-chargalg"; | ||
12 | battery = <&ab8500_battery>; | ||
13 | }; | ||
14 | |||
15 | For information on battery specific node, Ref: | ||
16 | Documentation/devicetree/bindings/power_supply/ab8500/fg.txt | ||
diff --git a/arch/arm/boot/dts/dbx5x0.dtsi b/arch/arm/boot/dts/dbx5x0.dtsi index 1d4ad3098ae..12a68af4490 100644 --- a/arch/arm/boot/dts/dbx5x0.dtsi +++ b/arch/arm/boot/dts/dbx5x0.dtsi | |||
@@ -373,6 +373,11 @@ | |||
373 | vddadc-supply = <&ab8500_ldo_tvout_reg>; | 373 | vddadc-supply = <&ab8500_ldo_tvout_reg>; |
374 | }; | 374 | }; |
375 | 375 | ||
376 | ab8500_chargalg { | ||
377 | compatible = "stericsson,ab8500-chargalg"; | ||
378 | battery = <&ab8500_battery>; | ||
379 | }; | ||
380 | |||
376 | ab8500_usb { | 381 | ab8500_usb { |
377 | compatible = "stericsson,ab8500-usb"; | 382 | compatible = "stericsson,ab8500-usb"; |
378 | interrupts = < 90 0x4 | 383 | interrupts = < 90 0x4 |
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index c7a120bfd50..5ec70f26b9d 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c | |||
@@ -1071,8 +1071,13 @@ static struct mfd_cell __devinitdata ab8500_bm_devs[] = { | |||
1071 | }, | 1071 | }, |
1072 | { | 1072 | { |
1073 | .name = "ab8500-chargalg", | 1073 | .name = "ab8500-chargalg", |
1074 | .of_compatible = "stericsson,ab8500-chargalg", | ||
1074 | .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), | 1075 | .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), |
1075 | .resources = ab8500_chargalg_resources, | 1076 | .resources = ab8500_chargalg_resources, |
1077 | #ifndef CONFIG_OF | ||
1078 | .platform_data = &ab8500_bm_data, | ||
1079 | .pdata_size = sizeof(ab8500_bm_data), | ||
1080 | #endif | ||
1076 | }, | 1081 | }, |
1077 | }; | 1082 | }; |
1078 | 1083 | ||
diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index 758ea76de2f..dcdc4393b9e 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/completion.h> | 21 | #include <linux/completion.h> |
22 | #include <linux/workqueue.h> | 22 | #include <linux/workqueue.h> |
23 | #include <linux/kobject.h> | 23 | #include <linux/kobject.h> |
24 | #include <linux/of.h> | ||
25 | #include <linux/mfd/core.h> | ||
24 | #include <linux/mfd/abx500.h> | 26 | #include <linux/mfd/abx500.h> |
25 | #include <linux/mfd/abx500/ux500_chargalg.h> | 27 | #include <linux/mfd/abx500/ux500_chargalg.h> |
26 | #include <linux/mfd/abx500/ab8500-bm.h> | 28 | #include <linux/mfd/abx500/ab8500-bm.h> |
@@ -205,7 +207,6 @@ enum maxim_ret { | |||
205 | * @chg_info: information about connected charger types | 207 | * @chg_info: information about connected charger types |
206 | * @batt_data: data of the battery | 208 | * @batt_data: data of the battery |
207 | * @susp_status: current charger suspension status | 209 | * @susp_status: current charger suspension status |
208 | * @pdata: pointer to the abx500_chargalg platform data | ||
209 | * @bat: pointer to the abx500_bm platform data | 210 | * @bat: pointer to the abx500_bm platform data |
210 | * @chargalg_psy: structure that holds the battery properties exposed by | 211 | * @chargalg_psy: structure that holds the battery properties exposed by |
211 | * the charging algorithm | 212 | * the charging algorithm |
@@ -231,7 +232,6 @@ struct abx500_chargalg { | |||
231 | struct abx500_chargalg_charger_info chg_info; | 232 | struct abx500_chargalg_charger_info chg_info; |
232 | struct abx500_chargalg_battery_data batt_data; | 233 | struct abx500_chargalg_battery_data batt_data; |
233 | struct abx500_chargalg_suspension_status susp_status; | 234 | struct abx500_chargalg_suspension_status susp_status; |
234 | struct abx500_bmdevs_plat_data *pdata; | ||
235 | struct abx500_bm_data *bat; | 235 | struct abx500_bm_data *bat; |
236 | struct power_supply chargalg_psy; | 236 | struct power_supply chargalg_psy; |
237 | struct ux500_charger *ac_chg; | 237 | struct ux500_charger *ac_chg; |
@@ -1795,25 +1795,44 @@ static int __devexit abx500_chargalg_remove(struct platform_device *pdev) | |||
1795 | flush_scheduled_work(); | 1795 | flush_scheduled_work(); |
1796 | power_supply_unregister(&di->chargalg_psy); | 1796 | power_supply_unregister(&di->chargalg_psy); |
1797 | platform_set_drvdata(pdev, NULL); | 1797 | platform_set_drvdata(pdev, NULL); |
1798 | kfree(di); | ||
1799 | 1798 | ||
1800 | return 0; | 1799 | return 0; |
1801 | } | 1800 | } |
1802 | 1801 | ||
1802 | static char *supply_interface[] = { | ||
1803 | "ab8500_fg", | ||
1804 | }; | ||
1805 | |||
1803 | static int __devinit abx500_chargalg_probe(struct platform_device *pdev) | 1806 | static int __devinit abx500_chargalg_probe(struct platform_device *pdev) |
1804 | { | 1807 | { |
1805 | struct abx500_bmdevs_plat_data *plat_data; | 1808 | struct device_node *np = pdev->dev.of_node; |
1809 | struct abx500_chargalg *di; | ||
1806 | int ret = 0; | 1810 | int ret = 0; |
1807 | 1811 | ||
1808 | struct abx500_chargalg *di = | 1812 | di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL); |
1809 | kzalloc(sizeof(struct abx500_chargalg), GFP_KERNEL); | 1813 | if (!di) { |
1810 | if (!di) | 1814 | dev_err(&pdev->dev, "%s no mem for ab8500_chargalg\n", __func__); |
1811 | return -ENOMEM; | 1815 | return -ENOMEM; |
1816 | } | ||
1817 | di->bat = pdev->mfd_cell->platform_data; | ||
1818 | if (!di->bat) { | ||
1819 | if (np) { | ||
1820 | ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); | ||
1821 | if (ret) { | ||
1822 | dev_err(&pdev->dev, | ||
1823 | "failed to get battery information\n"); | ||
1824 | return ret; | ||
1825 | } | ||
1826 | } else { | ||
1827 | dev_err(&pdev->dev, "missing dt node for ab8500_chargalg\n"); | ||
1828 | return -EINVAL; | ||
1829 | } | ||
1830 | } else { | ||
1831 | dev_info(&pdev->dev, "falling back to legacy platform data\n"); | ||
1832 | } | ||
1812 | 1833 | ||
1813 | /* get device struct */ | 1834 | /* get device struct */ |
1814 | di->dev = &pdev->dev; | 1835 | di->dev = &pdev->dev; |
1815 | plat_data = pdev->dev.platform_data; | ||
1816 | di->pdata = plat_data; | ||
1817 | 1836 | ||
1818 | /* chargalg supply */ | 1837 | /* chargalg supply */ |
1819 | di->chargalg_psy.name = "abx500_chargalg"; | 1838 | di->chargalg_psy.name = "abx500_chargalg"; |
@@ -1821,8 +1840,8 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev) | |||
1821 | di->chargalg_psy.properties = abx500_chargalg_props; | 1840 | di->chargalg_psy.properties = abx500_chargalg_props; |
1822 | di->chargalg_psy.num_properties = ARRAY_SIZE(abx500_chargalg_props); | 1841 | di->chargalg_psy.num_properties = ARRAY_SIZE(abx500_chargalg_props); |
1823 | di->chargalg_psy.get_property = abx500_chargalg_get_property; | 1842 | di->chargalg_psy.get_property = abx500_chargalg_get_property; |
1824 | di->chargalg_psy.supplied_to = di->pdata->supplied_to; | 1843 | di->chargalg_psy.supplied_to = supply_interface; |
1825 | di->chargalg_psy.num_supplicants = di->pdata->num_supplicants; | 1844 | di->chargalg_psy.num_supplicants = ARRAY_SIZE(supply_interface), |
1826 | di->chargalg_psy.external_power_changed = | 1845 | di->chargalg_psy.external_power_changed = |
1827 | abx500_chargalg_external_power_changed; | 1846 | abx500_chargalg_external_power_changed; |
1828 | 1847 | ||
@@ -1842,7 +1861,7 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev) | |||
1842 | create_singlethread_workqueue("abx500_chargalg_wq"); | 1861 | create_singlethread_workqueue("abx500_chargalg_wq"); |
1843 | if (di->chargalg_wq == NULL) { | 1862 | if (di->chargalg_wq == NULL) { |
1844 | dev_err(di->dev, "failed to create work queue\n"); | 1863 | dev_err(di->dev, "failed to create work queue\n"); |
1845 | goto free_device_info; | 1864 | return -ENOMEM; |
1846 | } | 1865 | } |
1847 | 1866 | ||
1848 | /* Init work for chargalg */ | 1867 | /* Init work for chargalg */ |
@@ -1883,20 +1902,23 @@ free_psy: | |||
1883 | power_supply_unregister(&di->chargalg_psy); | 1902 | power_supply_unregister(&di->chargalg_psy); |
1884 | free_chargalg_wq: | 1903 | free_chargalg_wq: |
1885 | destroy_workqueue(di->chargalg_wq); | 1904 | destroy_workqueue(di->chargalg_wq); |
1886 | free_device_info: | ||
1887 | kfree(di); | ||
1888 | |||
1889 | return ret; | 1905 | return ret; |
1890 | } | 1906 | } |
1891 | 1907 | ||
1908 | static const struct of_device_id ab8500_chargalg_match[] = { | ||
1909 | { .compatible = "stericsson,ab8500-chargalg", }, | ||
1910 | { }, | ||
1911 | }; | ||
1912 | |||
1892 | static struct platform_driver abx500_chargalg_driver = { | 1913 | static struct platform_driver abx500_chargalg_driver = { |
1893 | .probe = abx500_chargalg_probe, | 1914 | .probe = abx500_chargalg_probe, |
1894 | .remove = __devexit_p(abx500_chargalg_remove), | 1915 | .remove = __devexit_p(abx500_chargalg_remove), |
1895 | .suspend = abx500_chargalg_suspend, | 1916 | .suspend = abx500_chargalg_suspend, |
1896 | .resume = abx500_chargalg_resume, | 1917 | .resume = abx500_chargalg_resume, |
1897 | .driver = { | 1918 | .driver = { |
1898 | .name = "abx500-chargalg", | 1919 | .name = "ab8500-chargalg", |
1899 | .owner = THIS_MODULE, | 1920 | .owner = THIS_MODULE, |
1921 | .of_match_table = ab8500_chargalg_match, | ||
1900 | }, | 1922 | }, |
1901 | }; | 1923 | }; |
1902 | 1924 | ||
diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index 33f2c58554f..2138bd33021 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h | |||
@@ -274,12 +274,6 @@ struct abx500_bm_data { | |||
274 | 274 | ||
275 | extern struct abx500_bm_data ab8500_bm_data; | 275 | extern struct abx500_bm_data ab8500_bm_data; |
276 | 276 | ||
277 | struct abx500_bmdevs_plat_data { | ||
278 | char **supplied_to; | ||
279 | size_t num_supplicants; | ||
280 | bool autopower_cfg; | ||
281 | }; | ||
282 | |||
283 | enum { | 277 | enum { |
284 | NTC_EXTERNAL = 0, | 278 | NTC_EXTERNAL = 0, |
285 | NTC_INTERNAL, | 279 | NTC_INTERNAL, |