aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajanikanth H.V <rajanikanth.hv@stericsson.com>2012-11-18 22:17:47 -0500
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-11-18 22:37:16 -0500
commit4aef72dbb2e8997e627dd94ae2b9109dc09fffaa (patch)
treea42fc76452996e6c73e1cac12144d0f61c9a3872
parentbd9e8ab2d58d2183aa723bf0eb8e07d4362b4975 (diff)
ab8500: Add devicetree support for charger
This patch adds device tree support for ab8500-charger 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/mfd/ab8500.txt14
-rw-r--r--Documentation/devicetree/bindings/power_supply/ab8500/charger.txt25
-rw-r--r--arch/arm/boot/dts/dbx5x0.dtsi6
-rw-r--r--drivers/mfd/ab8500-core.c5
-rw-r--r--drivers/power/ab8500_charger.c74
5 files changed, 95 insertions, 29 deletions
diff --git a/Documentation/devicetree/bindings/mfd/ab8500.txt b/Documentation/devicetree/bindings/mfd/ab8500.txt
index f2ee0e7a5da3..13b707b7355c 100644
--- a/Documentation/devicetree/bindings/mfd/ab8500.txt
+++ b/Documentation/devicetree/bindings/mfd/ab8500.txt
@@ -36,6 +36,20 @@ ab8500-btemp : : vtvout : Battery Temperature
36 : BTEMP_LOW_MEDIUM : : BtempLow < Btemp < BtempMedium,if battery temperature is between -10 and 0°C 36 : BTEMP_LOW_MEDIUM : : BtempLow < Btemp < BtempMedium,if battery temperature is between -10 and 0°C
37 : BTEMP_MEDIUM_HIGH : : BtempMedium < Btemp < BtempHigh,if battery temperature is between 0°C and“MaxTemp 37 : BTEMP_MEDIUM_HIGH : : BtempMedium < Btemp < BtempHigh,if battery temperature is between 0°C and“MaxTemp
38 : BTEMP_HIGH : : Btemp > BtempHigh, if battery temperature is higher than “MaxTemp 38 : BTEMP_HIGH : : Btemp > BtempHigh, if battery temperature is higher than “MaxTemp
39ab8500-charger : : vddadc : Charger interface
40 : MAIN_CH_UNPLUG_DET : : main charger unplug detection management (not in 8505)
41 : MAIN_CHARGE_PLUG_DET : : main charger plug detection management (not in 8505)
42 : MAIN_EXT_CH_NOT_OK : : main charger not OK
43 : MAIN_CH_TH_PROT_R : : Die temp is above main charger
44 : MAIN_CH_TH_PROT_F : : Die temp is below main charger
45 : VBUS_DET_F : : VBUS falling detected
46 : VBUS_DET_R : : VBUS rising detected
47 : USB_LINK_STATUS : : USB link status has changed
48 : USB_CH_TH_PROT_R : : Die temp is above usb charger
49 : USB_CH_TH_PROT_F : : Die temp is below usb charger
50 : USB_CHARGER_NOT_OKR : : allowed USB charger not ok detection
51 : VBUS_OVV : : Overvoltage on Vbus ball detected (USB charge is stopped)
52 : CH_WD_EXP : : Charger watchdog detected
39ab8500-gpadc : HW_CONV_END : vddadc : Analogue to Digital Converter 53ab8500-gpadc : HW_CONV_END : vddadc : Analogue to Digital Converter
40 SW_CONV_END : : 54 SW_CONV_END : :
41ab8500-gpio : : : GPIO Controller 55ab8500-gpio : : : GPIO Controller
diff --git a/Documentation/devicetree/bindings/power_supply/ab8500/charger.txt b/Documentation/devicetree/bindings/power_supply/ab8500/charger.txt
new file mode 100644
index 000000000000..6bdbb08ea9e0
--- /dev/null
+++ b/Documentation/devicetree/bindings/power_supply/ab8500/charger.txt
@@ -0,0 +1,25 @@
1=== AB8500 Charger Driver ===
2
3Required Properties:
4- compatible = Shall be "stericsson,ab8500-charger"
5- battery = Shall be battery specific information
6 Example:
7 ab8500_charger {
8 compatible = "stericsson,ab8500-charger";
9 battery = <&ab8500_battery>;
10 };
11
12- vddadc-supply: Supply for USB and Main charger
13 Example:
14 ab8500-charger {
15 vddadc-supply = <&ab8500_ldo_tvout_reg>;
16 }
17- autopower_cfg:
18 Boolean value depicting the presence of 'automatic poweron after powerloss'
19 Example:
20 ab8500-charger {
21 autopower_cfg;
22 };
23
24For information on battery specific node, Ref:
25Documentation/devicetree/bindings/power_supply/ab8500/fg.txt
diff --git a/arch/arm/boot/dts/dbx5x0.dtsi b/arch/arm/boot/dts/dbx5x0.dtsi
index d170fadd7ddb..1d4ad3098aeb 100644
--- a/arch/arm/boot/dts/dbx5x0.dtsi
+++ b/arch/arm/boot/dts/dbx5x0.dtsi
@@ -367,6 +367,12 @@
367 battery = <&ab8500_battery>; 367 battery = <&ab8500_battery>;
368 }; 368 };
369 369
370 ab8500_charger {
371 compatible = "stericsson,ab8500-charger";
372 battery = <&ab8500_battery>;
373 vddadc-supply = <&ab8500_ldo_tvout_reg>;
374 };
375
370 ab8500_usb { 376 ab8500_usb {
371 compatible = "stericsson,ab8500-usb"; 377 compatible = "stericsson,ab8500-usb";
372 interrupts = < 90 0x4 378 interrupts = < 90 0x4
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 94d45be5c1b4..c7a120bfd50a 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -1041,8 +1041,13 @@ static struct mfd_cell __devinitdata abx500_common_devs[] = {
1041static struct mfd_cell __devinitdata ab8500_bm_devs[] = { 1041static struct mfd_cell __devinitdata ab8500_bm_devs[] = {
1042 { 1042 {
1043 .name = "ab8500-charger", 1043 .name = "ab8500-charger",
1044 .of_compatible = "stericsson,ab8500-charger",
1044 .num_resources = ARRAY_SIZE(ab8500_charger_resources), 1045 .num_resources = ARRAY_SIZE(ab8500_charger_resources),
1045 .resources = ab8500_charger_resources, 1046 .resources = ab8500_charger_resources,
1047#ifndef CONFIG_OF
1048 .platform_data = &ab8500_bm_data,
1049 .pdata_size = sizeof(ab8500_bm_data),
1050#endif
1046 }, 1051 },
1047 { 1052 {
1048 .name = "ab8500-btemp", 1053 .name = "ab8500-btemp",
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 723edb47b1d8..dddc9473f72a 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -23,6 +23,8 @@
23#include <linux/err.h> 23#include <linux/err.h>
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/kobject.h> 25#include <linux/kobject.h>
26#include <linux/of.h>
27#include <linux/mfd/core.h>
26#include <linux/mfd/abx500/ab8500.h> 28#include <linux/mfd/abx500/ab8500.h>
27#include <linux/mfd/abx500.h> 29#include <linux/mfd/abx500.h>
28#include <linux/mfd/abx500/ab8500-bm.h> 30#include <linux/mfd/abx500/ab8500-bm.h>
@@ -181,9 +183,9 @@ struct ab8500_charger_usb_state {
181 * @vbat Battery voltage 183 * @vbat Battery voltage
182 * @old_vbat Previously measured battery voltage 184 * @old_vbat Previously measured battery voltage
183 * @autopower Indicate if we should have automatic pwron after pwrloss 185 * @autopower Indicate if we should have automatic pwron after pwrloss
186 * @autopower_cfg platform specific power config support for "pwron after pwrloss"
184 * @parent: Pointer to the struct ab8500 187 * @parent: Pointer to the struct ab8500
185 * @gpadc: Pointer to the struct gpadc 188 * @gpadc: Pointer to the struct gpadc
186 * @pdata: Pointer to the abx500_charger platform data
187 * @bat: Pointer to the abx500_bm platform data 189 * @bat: Pointer to the abx500_bm platform data
188 * @flags: Structure for information about events triggered 190 * @flags: Structure for information about events triggered
189 * @usb_state: Structure for usb stack information 191 * @usb_state: Structure for usb stack information
@@ -218,9 +220,9 @@ struct ab8500_charger {
218 int vbat; 220 int vbat;
219 int old_vbat; 221 int old_vbat;
220 bool autopower; 222 bool autopower;
223 bool autopower_cfg;
221 struct ab8500 *parent; 224 struct ab8500 *parent;
222 struct ab8500_gpadc *gpadc; 225 struct ab8500_gpadc *gpadc;
223 struct abx500_bmdevs_plat_data *pdata;
224 struct abx500_bm_data *bat; 226 struct abx500_bm_data *bat;
225 struct ab8500_charger_event_flags flags; 227 struct ab8500_charger_event_flags flags;
226 struct ab8500_charger_usb_state usb_state; 228 struct ab8500_charger_usb_state usb_state;
@@ -322,7 +324,7 @@ static void ab8500_power_loss_handling(struct ab8500_charger *di)
322static void ab8500_power_supply_changed(struct ab8500_charger *di, 324static void ab8500_power_supply_changed(struct ab8500_charger *di,
323 struct power_supply *psy) 325 struct power_supply *psy)
324{ 326{
325 if (di->pdata->autopower_cfg) { 327 if (di->autopower_cfg) {
326 if (!di->usb.charger_connected && 328 if (!di->usb.charger_connected &&
327 !di->ac.charger_connected && 329 !di->ac.charger_connected &&
328 di->autopower) { 330 di->autopower) {
@@ -2526,25 +2528,45 @@ static int __devexit ab8500_charger_remove(struct platform_device *pdev)
2526 power_supply_unregister(&di->usb_chg.psy); 2528 power_supply_unregister(&di->usb_chg.psy);
2527 power_supply_unregister(&di->ac_chg.psy); 2529 power_supply_unregister(&di->ac_chg.psy);
2528 platform_set_drvdata(pdev, NULL); 2530 platform_set_drvdata(pdev, NULL);
2529 kfree(di);
2530 2531
2531 return 0; 2532 return 0;
2532} 2533}
2533 2534
2535static char *supply_interface[] = {
2536 "ab8500_chargalg",
2537 "ab8500_fg",
2538 "ab8500_btemp",
2539};
2540
2534static int __devinit ab8500_charger_probe(struct platform_device *pdev) 2541static int __devinit ab8500_charger_probe(struct platform_device *pdev)
2535{ 2542{
2536 struct abx500_bmdevs_plat_data *plat_data = pdev->dev.platform_data; 2543 struct device_node *np = pdev->dev.of_node;
2537 struct ab8500_charger *di; 2544 struct ab8500_charger *di;
2538 int irq, i, charger_status, ret = 0; 2545 int irq, i, charger_status, ret = 0;
2539 2546
2540 if (!plat_data) { 2547 di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL);
2541 dev_err(&pdev->dev, "No platform data\n"); 2548 if (!di) {
2542 return -EINVAL; 2549 dev_err(&pdev->dev, "%s no mem for ab8500_charger\n", __func__);
2543 }
2544
2545 di = kzalloc(sizeof(*di), GFP_KERNEL);
2546 if (!di)
2547 return -ENOMEM; 2550 return -ENOMEM;
2551 }
2552 di->bat = pdev->mfd_cell->platform_data;
2553 if (!di->bat) {
2554 if (np) {
2555 ret = bmdevs_of_probe(&pdev->dev, np, &di->bat);
2556 if (ret) {
2557 dev_err(&pdev->dev,
2558 "failed to get battery information\n");
2559 return ret;
2560 }
2561 di->autopower_cfg = of_property_read_bool(np, "autopower_cfg");
2562 } else {
2563 dev_err(&pdev->dev, "missing dt node for ab8500_charger\n");
2564 return -EINVAL;
2565 }
2566 } else {
2567 dev_info(&pdev->dev, "falling back to legacy platform data\n");
2568 di->autopower_cfg = false;
2569 }
2548 2570
2549 /* get parent data */ 2571 /* get parent data */
2550 di->dev = &pdev->dev; 2572 di->dev = &pdev->dev;
@@ -2554,14 +2576,6 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
2554 /* initialize lock */ 2576 /* initialize lock */
2555 spin_lock_init(&di->usb_state.usb_lock); 2577 spin_lock_init(&di->usb_state.usb_lock);
2556 2578
2557 /* get charger specific platform data */
2558 di->pdata = plat_data;
2559 if (!di->pdata) {
2560 dev_err(di->dev, "no charger platform data supplied\n");
2561 ret = -EINVAL;
2562 goto free_device_info;
2563 }
2564
2565 di->autopower = false; 2579 di->autopower = false;
2566 2580
2567 /* AC supply */ 2581 /* AC supply */
@@ -2571,8 +2585,8 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
2571 di->ac_chg.psy.properties = ab8500_charger_ac_props; 2585 di->ac_chg.psy.properties = ab8500_charger_ac_props;
2572 di->ac_chg.psy.num_properties = ARRAY_SIZE(ab8500_charger_ac_props); 2586 di->ac_chg.psy.num_properties = ARRAY_SIZE(ab8500_charger_ac_props);
2573 di->ac_chg.psy.get_property = ab8500_charger_ac_get_property; 2587 di->ac_chg.psy.get_property = ab8500_charger_ac_get_property;
2574 di->ac_chg.psy.supplied_to = di->pdata->supplied_to; 2588 di->ac_chg.psy.supplied_to = supply_interface;
2575 di->ac_chg.psy.num_supplicants = di->pdata->num_supplicants; 2589 di->ac_chg.psy.num_supplicants = ARRAY_SIZE(supply_interface),
2576 /* ux500_charger sub-class */ 2590 /* ux500_charger sub-class */
2577 di->ac_chg.ops.enable = &ab8500_charger_ac_en; 2591 di->ac_chg.ops.enable = &ab8500_charger_ac_en;
2578 di->ac_chg.ops.kick_wd = &ab8500_charger_watchdog_kick; 2592 di->ac_chg.ops.kick_wd = &ab8500_charger_watchdog_kick;
@@ -2589,8 +2603,8 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
2589 di->usb_chg.psy.properties = ab8500_charger_usb_props; 2603 di->usb_chg.psy.properties = ab8500_charger_usb_props;
2590 di->usb_chg.psy.num_properties = ARRAY_SIZE(ab8500_charger_usb_props); 2604 di->usb_chg.psy.num_properties = ARRAY_SIZE(ab8500_charger_usb_props);
2591 di->usb_chg.psy.get_property = ab8500_charger_usb_get_property; 2605 di->usb_chg.psy.get_property = ab8500_charger_usb_get_property;
2592 di->usb_chg.psy.supplied_to = di->pdata->supplied_to; 2606 di->usb_chg.psy.supplied_to = supply_interface;
2593 di->usb_chg.psy.num_supplicants = di->pdata->num_supplicants; 2607 di->usb_chg.psy.num_supplicants = ARRAY_SIZE(supply_interface),
2594 /* ux500_charger sub-class */ 2608 /* ux500_charger sub-class */
2595 di->usb_chg.ops.enable = &ab8500_charger_usb_en; 2609 di->usb_chg.ops.enable = &ab8500_charger_usb_en;
2596 di->usb_chg.ops.kick_wd = &ab8500_charger_watchdog_kick; 2610 di->usb_chg.ops.kick_wd = &ab8500_charger_watchdog_kick;
@@ -2606,8 +2620,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
2606 create_singlethread_workqueue("ab8500_charger_wq"); 2620 create_singlethread_workqueue("ab8500_charger_wq");
2607 if (di->charger_wq == NULL) { 2621 if (di->charger_wq == NULL) {
2608 dev_err(di->dev, "failed to create work queue\n"); 2622 dev_err(di->dev, "failed to create work queue\n");
2609 ret = -ENOMEM; 2623 return -ENOMEM;
2610 goto free_device_info;
2611 } 2624 }
2612 2625
2613 /* Init work for HW failure check */ 2626 /* Init work for HW failure check */
@@ -2749,12 +2762,14 @@ free_regulator:
2749 regulator_put(di->regu); 2762 regulator_put(di->regu);
2750free_charger_wq: 2763free_charger_wq:
2751 destroy_workqueue(di->charger_wq); 2764 destroy_workqueue(di->charger_wq);
2752free_device_info:
2753 kfree(di);
2754
2755 return ret; 2765 return ret;
2756} 2766}
2757 2767
2768static const struct of_device_id ab8500_charger_match[] = {
2769 { .compatible = "stericsson,ab8500-charger", },
2770 { },
2771};
2772
2758static struct platform_driver ab8500_charger_driver = { 2773static struct platform_driver ab8500_charger_driver = {
2759 .probe = ab8500_charger_probe, 2774 .probe = ab8500_charger_probe,
2760 .remove = __devexit_p(ab8500_charger_remove), 2775 .remove = __devexit_p(ab8500_charger_remove),
@@ -2763,6 +2778,7 @@ static struct platform_driver ab8500_charger_driver = {
2763 .driver = { 2778 .driver = {
2764 .name = "ab8500-charger", 2779 .name = "ab8500-charger",
2765 .owner = THIS_MODULE, 2780 .owner = THIS_MODULE,
2781 .of_match_table = ab8500_charger_match,
2766 }, 2782 },
2767}; 2783};
2768 2784