diff options
author | Rajanikanth H.V <rajanikanth.hv@stericsson.com> | 2012-11-18 22:16:58 -0500 |
---|---|---|
committer | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-11-18 22:37:14 -0500 |
commit | bd9e8ab2d58d2183aa723bf0eb8e07d4362b4975 (patch) | |
tree | ed60bb0d0582b425cbfea321f80a115a6dc10b36 /drivers/power | |
parent | e0f1abeba5c2d8a2183566717d99294fd1a29c2e (diff) |
ab8500: Add devicetree support for btemp
This patch adds device tree support for battery-temperature-monitor driver
Signed-off-by: Rajanikanth H.V <rajanikanth.hv@stericsson.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/Kconfig | 6 | ||||
-rw-r--r-- | drivers/power/ab8500_bmdata.c | 4 | ||||
-rw-r--r-- | drivers/power/ab8500_btemp.c | 67 |
3 files changed, 41 insertions, 36 deletions
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 523a58014ed5..263499f8709a 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig | |||
@@ -346,12 +346,6 @@ config AB8500_BM | |||
346 | help | 346 | help |
347 | Say Y to include support for AB8500 battery management. | 347 | Say Y to include support for AB8500 battery management. |
348 | 348 | ||
349 | config AB8500_BATTERY_THERM_ON_BATCTRL | ||
350 | bool "Thermistor connected on BATCTRL ADC" | ||
351 | depends on AB8500_BM | ||
352 | help | ||
353 | Say Y to enable battery temperature measurements using | ||
354 | thermistor connected on BATCTRL ADC. | ||
355 | endif # POWER_SUPPLY | 349 | endif # POWER_SUPPLY |
356 | 350 | ||
357 | source "drivers/power/avs/Kconfig" | 351 | source "drivers/power/avs/Kconfig" |
diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index e7639b6659f7..03cc528425cb 100644 --- a/drivers/power/ab8500_bmdata.c +++ b/drivers/power/ab8500_bmdata.c | |||
@@ -30,7 +30,7 @@ static struct abx500_res_to_temp temp_tbl_A_thermistor[] = { | |||
30 | }; | 30 | }; |
31 | 31 | ||
32 | static struct abx500_res_to_temp temp_tbl_B_thermistor[] = { | 32 | static struct abx500_res_to_temp temp_tbl_B_thermistor[] = { |
33 | {-5, 165418}, | 33 | {-5, 200000}, |
34 | { 0, 159024}, | 34 | { 0, 159024}, |
35 | { 5, 151921}, | 35 | { 5, 151921}, |
36 | {10, 144300}, | 36 | {10, 144300}, |
@@ -240,7 +240,7 @@ static struct abx500_battery_type bat_type_thermistor[] = { | |||
240 | }, | 240 | }, |
241 | { | 241 | { |
242 | .name = POWER_SUPPLY_TECHNOLOGY_LIPO, | 242 | .name = POWER_SUPPLY_TECHNOLOGY_LIPO, |
243 | .resis_high = 165418, | 243 | .resis_high = 200000, |
244 | .resis_low = 82869, | 244 | .resis_low = 82869, |
245 | .battery_resistance = 300, | 245 | .battery_resistance = 300, |
246 | .charge_full_design = 900, | 246 | .charge_full_design = 900, |
diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index abc2abc16a5d..8135542ee746 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c | |||
@@ -20,11 +20,13 @@ | |||
20 | #include <linux/power_supply.h> | 20 | #include <linux/power_supply.h> |
21 | #include <linux/completion.h> | 21 | #include <linux/completion.h> |
22 | #include <linux/workqueue.h> | 22 | #include <linux/workqueue.h> |
23 | #include <linux/mfd/abx500/ab8500.h> | 23 | #include <linux/jiffies.h> |
24 | #include <linux/of.h> | ||
25 | #include <linux/mfd/core.h> | ||
24 | #include <linux/mfd/abx500.h> | 26 | #include <linux/mfd/abx500.h> |
27 | #include <linux/mfd/abx500/ab8500.h> | ||
25 | #include <linux/mfd/abx500/ab8500-bm.h> | 28 | #include <linux/mfd/abx500/ab8500-bm.h> |
26 | #include <linux/mfd/abx500/ab8500-gpadc.h> | 29 | #include <linux/mfd/abx500/ab8500-gpadc.h> |
27 | #include <linux/jiffies.h> | ||
28 | 30 | ||
29 | #define VTVOUT_V 1800 | 31 | #define VTVOUT_V 1800 |
30 | 32 | ||
@@ -76,7 +78,6 @@ struct ab8500_btemp_ranges { | |||
76 | * @parent: Pointer to the struct ab8500 | 78 | * @parent: Pointer to the struct ab8500 |
77 | * @gpadc: Pointer to the struct gpadc | 79 | * @gpadc: Pointer to the struct gpadc |
78 | * @fg: Pointer to the struct fg | 80 | * @fg: Pointer to the struct fg |
79 | * @pdata: Pointer to the abx500_btemp platform data | ||
80 | * @bat: Pointer to the abx500_bm platform data | 81 | * @bat: Pointer to the abx500_bm platform data |
81 | * @btemp_psy: Structure for BTEMP specific battery properties | 82 | * @btemp_psy: Structure for BTEMP specific battery properties |
82 | * @events: Structure for information about events triggered | 83 | * @events: Structure for information about events triggered |
@@ -93,7 +94,6 @@ struct ab8500_btemp { | |||
93 | struct ab8500 *parent; | 94 | struct ab8500 *parent; |
94 | struct ab8500_gpadc *gpadc; | 95 | struct ab8500_gpadc *gpadc; |
95 | struct ab8500_fg *fg; | 96 | struct ab8500_fg *fg; |
96 | struct abx500_bmdevs_plat_data *pdata; | ||
97 | struct abx500_bm_data *bat; | 97 | struct abx500_bm_data *bat; |
98 | struct power_supply btemp_psy; | 98 | struct power_supply btemp_psy; |
99 | struct ab8500_btemp_events events; | 99 | struct ab8500_btemp_events events; |
@@ -955,48 +955,57 @@ static int __devexit ab8500_btemp_remove(struct platform_device *pdev) | |||
955 | flush_scheduled_work(); | 955 | flush_scheduled_work(); |
956 | power_supply_unregister(&di->btemp_psy); | 956 | power_supply_unregister(&di->btemp_psy); |
957 | platform_set_drvdata(pdev, NULL); | 957 | platform_set_drvdata(pdev, NULL); |
958 | kfree(di); | ||
959 | 958 | ||
960 | return 0; | 959 | return 0; |
961 | } | 960 | } |
962 | 961 | ||
962 | static char *supply_interface[] = { | ||
963 | "ab8500_chargalg", | ||
964 | "ab8500_fg", | ||
965 | }; | ||
966 | |||
963 | static int __devinit ab8500_btemp_probe(struct platform_device *pdev) | 967 | static int __devinit ab8500_btemp_probe(struct platform_device *pdev) |
964 | { | 968 | { |
965 | struct abx500_bmdevs_plat_data *plat_data = pdev->dev.platform_data; | 969 | struct device_node *np = pdev->dev.of_node; |
966 | struct ab8500_btemp *di; | 970 | struct ab8500_btemp *di; |
967 | int irq, i, ret = 0; | 971 | int irq, i, ret = 0; |
968 | u8 val; | 972 | u8 val; |
969 | 973 | ||
970 | if (!plat_data) { | 974 | di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL); |
971 | dev_err(&pdev->dev, "No platform data\n"); | 975 | if (!di) { |
972 | return -EINVAL; | 976 | dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__); |
973 | } | ||
974 | |||
975 | di = kzalloc(sizeof(*di), GFP_KERNEL); | ||
976 | if (!di) | ||
977 | return -ENOMEM; | 977 | return -ENOMEM; |
978 | } | ||
979 | di->bat = pdev->mfd_cell->platform_data; | ||
980 | if (!di->bat) { | ||
981 | if (np) { | ||
982 | ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); | ||
983 | if (ret) { | ||
984 | dev_err(&pdev->dev, | ||
985 | "failed to get battery information\n"); | ||
986 | return ret; | ||
987 | } | ||
988 | } else { | ||
989 | dev_err(&pdev->dev, "missing dt node for ab8500_btemp\n"); | ||
990 | return -EINVAL; | ||
991 | } | ||
992 | } else { | ||
993 | dev_info(&pdev->dev, "falling back to legacy platform data\n"); | ||
994 | } | ||
978 | 995 | ||
979 | /* get parent data */ | 996 | /* get parent data */ |
980 | di->dev = &pdev->dev; | 997 | di->dev = &pdev->dev; |
981 | di->parent = dev_get_drvdata(pdev->dev.parent); | 998 | di->parent = dev_get_drvdata(pdev->dev.parent); |
982 | di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); | 999 | di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
983 | 1000 | ||
984 | /* get btemp specific platform data */ | ||
985 | di->pdata = plat_data; | ||
986 | if (!di->pdata) { | ||
987 | dev_err(di->dev, "no btemp platform data supplied\n"); | ||
988 | ret = -EINVAL; | ||
989 | goto free_device_info; | ||
990 | } | ||
991 | |||
992 | /* BTEMP supply */ | 1001 | /* BTEMP supply */ |
993 | di->btemp_psy.name = "ab8500_btemp"; | 1002 | di->btemp_psy.name = "ab8500_btemp"; |
994 | di->btemp_psy.type = POWER_SUPPLY_TYPE_BATTERY; | 1003 | di->btemp_psy.type = POWER_SUPPLY_TYPE_BATTERY; |
995 | di->btemp_psy.properties = ab8500_btemp_props; | 1004 | di->btemp_psy.properties = ab8500_btemp_props; |
996 | di->btemp_psy.num_properties = ARRAY_SIZE(ab8500_btemp_props); | 1005 | di->btemp_psy.num_properties = ARRAY_SIZE(ab8500_btemp_props); |
997 | di->btemp_psy.get_property = ab8500_btemp_get_property; | 1006 | di->btemp_psy.get_property = ab8500_btemp_get_property; |
998 | di->btemp_psy.supplied_to = di->pdata->supplied_to; | 1007 | di->btemp_psy.supplied_to = supply_interface; |
999 | di->btemp_psy.num_supplicants = di->pdata->num_supplicants; | 1008 | di->btemp_psy.num_supplicants = ARRAY_SIZE(supply_interface); |
1000 | di->btemp_psy.external_power_changed = | 1009 | di->btemp_psy.external_power_changed = |
1001 | ab8500_btemp_external_power_changed; | 1010 | ab8500_btemp_external_power_changed; |
1002 | 1011 | ||
@@ -1006,8 +1015,7 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev) | |||
1006 | create_singlethread_workqueue("ab8500_btemp_wq"); | 1015 | create_singlethread_workqueue("ab8500_btemp_wq"); |
1007 | if (di->btemp_wq == NULL) { | 1016 | if (di->btemp_wq == NULL) { |
1008 | dev_err(di->dev, "failed to create work queue\n"); | 1017 | dev_err(di->dev, "failed to create work queue\n"); |
1009 | ret = -ENOMEM; | 1018 | return -ENOMEM; |
1010 | goto free_device_info; | ||
1011 | } | 1019 | } |
1012 | 1020 | ||
1013 | /* Init work for measuring temperature periodically */ | 1021 | /* Init work for measuring temperature periodically */ |
@@ -1085,12 +1093,14 @@ free_irq: | |||
1085 | } | 1093 | } |
1086 | free_btemp_wq: | 1094 | free_btemp_wq: |
1087 | destroy_workqueue(di->btemp_wq); | 1095 | destroy_workqueue(di->btemp_wq); |
1088 | free_device_info: | ||
1089 | kfree(di); | ||
1090 | |||
1091 | return ret; | 1096 | return ret; |
1092 | } | 1097 | } |
1093 | 1098 | ||
1099 | static const struct of_device_id ab8500_btemp_match[] = { | ||
1100 | { .compatible = "stericsson,ab8500-btemp", }, | ||
1101 | { }, | ||
1102 | }; | ||
1103 | |||
1094 | static struct platform_driver ab8500_btemp_driver = { | 1104 | static struct platform_driver ab8500_btemp_driver = { |
1095 | .probe = ab8500_btemp_probe, | 1105 | .probe = ab8500_btemp_probe, |
1096 | .remove = __devexit_p(ab8500_btemp_remove), | 1106 | .remove = __devexit_p(ab8500_btemp_remove), |
@@ -1099,6 +1109,7 @@ static struct platform_driver ab8500_btemp_driver = { | |||
1099 | .driver = { | 1109 | .driver = { |
1100 | .name = "ab8500-btemp", | 1110 | .name = "ab8500-btemp", |
1101 | .owner = THIS_MODULE, | 1111 | .owner = THIS_MODULE, |
1112 | .of_match_table = ab8500_btemp_match, | ||
1102 | }, | 1113 | }, |
1103 | }; | 1114 | }; |
1104 | 1115 | ||