* Re: [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge [not found] ` <1351146654-9110-2-git-send-email-rajanikanth.hv@stericsson.com> @ 2012-10-27 15:07 ` Francesco Lavra 2012-10-27 16:00 ` Rajanikanth HV 0 siblings, 1 reply; 8+ messages in thread From: Francesco Lavra @ 2012-10-27 15:07 UTC (permalink / raw) To: Rajanikanth H.V Cc: lee.jones, arnd, anton.vorontsov, linus.walleij, linux-arm-kernel, linux-kernel, linaro-dev, patches, STEricsson_nomadik_linux On 10/25/2012 08:30 AM, Rajanikanth H.V wrote: > From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com> > > - This patch adds device tree support for fuelgauge driver > - optimize bm devices platform_data usage and of_probe(...) > Note: of_probe() routine for battery managed devices is made > common across all bm drivers. > - test status: > - interrupt numbers assigned differs between legacy and FDT mode. > > Signed-off-by: Rajanikanth H.V <rajanikanth.hv@stericsson.com> [...] > diff --git a/Documentation/devicetree/bindings/power_supply/ab8500/fg.txt b/Documentation/devicetree/bindings/power_supply/ab8500/fg.txt > new file mode 100644 > index 0000000..28eaf35 > --- /dev/null > +++ b/Documentation/devicetree/bindings/power_supply/ab8500/fg.txt > @@ -0,0 +1,58 @@ > +=== AB8500 Fuel Gauge Driver === > + > +AB8500 is a mixed signal multimedia and power management > +device comprising: power and energy-management-module, > +wall-charger, usb-charger, audio codec, general purpose adc, > +tvout, clock management and sim card interface. > + > +Fuelgauge support is part of energy-management-modules, other > +components of this module are: > +main-charger, usb-combo-charger and battery-temperature-monitoring. > + > +The properties below describes the node for fuelgauge driver. > + > +Required Properties: > +- compatible = This shall be: "stericsson,ab8500-fg" > +- battery = Shall be battery specific information > + Example: > + ab8500_fg { > + compatible = "stericsson,ab8500-fg"; > + battery = <&ab8500_battery>; > + }; > + > +dependent node: > + ab8500_battery: ab8500_battery { > + }; > + This node will provide information on 'thermistor interface' and > + 'battery technology type' used. > + > +Properties of this node are: > +thermistor-on-batctrl: > + A boolean value indicating thermistor interface to battery > + > + Note: > + 'btemp' and 'batctrl' are the pins interfaced for battery temperature > + measurement, 'btemp' signal is used when NTC(negative temperature > + coefficient) resister is interfaced external to battery whereas > + 'batctrl' pin is used when NTC resister is internal to battery. > + > + Example: > + ab8500_battery: ab8500_battery { > + thermistor-on-batctrl; > + }; > + indiactes: NTC resister is internal to battery, 'batctrl' is used s/indiactes/indicates [...] > +int __devinit > +bmdevs_of_probe(struct device *dev, > + struct device_node *np, > + struct abx500_bm_data **battery) > +{ > + struct abx500_battery_type *btype; > + struct device_node *np_bat_supply; > + struct abx500_bm_data *bat; > + const char *bat_tech; > + int i, thermistor; > + > + *battery = &ab8500_bm_data; > + > + /* get phandle to 'battery-info' node */ > + np_bat_supply = of_parse_phandle(np, "battery", 0); > + if (!np_bat_supply) { > + dev_err(dev, "missing property battery\n"); > + return -EINVAL; > + } > + if (of_property_read_bool(np_bat_supply, > + "thermistor-on-batctrl")) > + thermistor = NTC_INTERNAL; > + else > + thermistor = NTC_EXTERNAL; > + > + bat = *battery; > + if (thermistor == NTC_EXTERNAL) { > + bat->n_btypes = 4; > + bat->bat_type = bat_type_ext_thermistor; > + bat->adc_therm = ABx500_ADC_THERM_BATTEMP; > + } > + bat_tech = of_get_property(np_bat_supply, > + "stericsson,battery-type", NULL); > + if (!bat_tech) > + dev_warn(dev, "missing property battery-name/type\n"); > + > + if (strncmp(bat_tech, "LION", 4) == 0) { What if bat_tech is NULL? [...] > diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c > index bf02225..e117920 100644 > --- a/drivers/power/ab8500_fg.c > +++ b/drivers/power/ab8500_fg.c > @@ -22,15 +22,16 @@ > #include <linux/platform_device.h> > #include <linux/power_supply.h> > #include <linux/kobject.h> > -#include <linux/mfd/abx500/ab8500.h> > -#include <linux/mfd/abx500.h> > #include <linux/slab.h> > -#include <linux/mfd/abx500/ab8500-bm.h> > #include <linux/delay.h> > -#include <linux/mfd/abx500/ab8500-gpadc.h> > -#include <linux/mfd/abx500.h> > #include <linux/time.h> > +#include <linux/of.h> > #include <linux/completion.h> > +#include <linux/mfd/core.h> > +#include <linux/mfd/abx500.h> > +#include <linux/mfd/abx500/ab8500.h> > +#include <linux/mfd/abx500/ab8500-bm.h> > +#include <linux/mfd/abx500/ab8500-gpadc.h> > > #define MILLI_TO_MICRO 1000 > #define FG_LSB_IN_MA 1627 > @@ -212,7 +213,6 @@ struct ab8500_fg { > struct ab8500_fg_avg_cap avg_cap; > struct ab8500 *parent; > struct ab8500_gpadc *gpadc; > - struct abx500_fg_platform_data *pdata; pdata should be removed from the description of the struct members as well. -- Francesco ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge 2012-10-27 15:07 ` [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge Francesco Lavra @ 2012-10-27 16:00 ` Rajanikanth HV 2012-10-27 16:18 ` Francesco Lavra 0 siblings, 1 reply; 8+ messages in thread From: Rajanikanth HV @ 2012-10-27 16:00 UTC (permalink / raw) To: Francesco Lavra Cc: Rajanikanth H.V, linaro-dev, linus.walleij, arnd, patches, linux-kernel, anton.vorontsov, STEricsson_nomadik_linux, linux-arm-kernel On 27 October 2012 20:37, Francesco Lavra <francescolavra.fl@gmail.com> wrote: > On 10/25/2012 08:30 AM, Rajanikanth H.V wrote: >> From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com> >> + bat_tech = of_get_property(np_bat_supply, >> + "stericsson,battery-type", NULL); >> + if (!bat_tech) >> + dev_warn(dev, "missing property battery-name/type\n"); >> + >> + if (strncmp(bat_tech, "LION", 4) == 0) { > > What if bat_tech is NULL? It will be UNKNOWN ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge 2012-10-27 16:00 ` Rajanikanth HV @ 2012-10-27 16:18 ` Francesco Lavra 0 siblings, 0 replies; 8+ messages in thread From: Francesco Lavra @ 2012-10-27 16:18 UTC (permalink / raw) To: Rajanikanth HV Cc: Rajanikanth H.V, linaro-dev, linus.walleij, arnd, patches, linux-kernel, anton.vorontsov, STEricsson_nomadik_linux, linux-arm-kernel On 10/27/2012 06:00 PM, Rajanikanth HV wrote: > On 27 October 2012 20:37, Francesco Lavra <francescolavra.fl@gmail.com> wrote: >> On 10/25/2012 08:30 AM, Rajanikanth H.V wrote: >>> From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com> >>> + bat_tech = of_get_property(np_bat_supply, >>> + "stericsson,battery-type", NULL); >>> + if (!bat_tech) >>> + dev_warn(dev, "missing property battery-name/type\n"); >>> + >>> + if (strncmp(bat_tech, "LION", 4) == 0) { >> >> What if bat_tech is NULL? > It will be UNKNOWN I wanted to draw your attention to the fact that if bat_tech is NULL you are passing a NULL pointer to strncmp(), which is not good. So you should assign a default value to bat_tech in case the battery type property is not found in the DT, as below: if (!bat_tech) { dev_warn(dev, "missing property battery-name/type\n"); bat_tech = "UNKNOWN"; } -- Francesco ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1351146654-9110-3-git-send-email-rajanikanth.hv@stericsson.com>]
* Re: [PATCH 2/4] mfd: ab8500: add devicetree support for btemp [not found] ` <1351146654-9110-3-git-send-email-rajanikanth.hv@stericsson.com> @ 2012-10-27 15:08 ` Francesco Lavra 0 siblings, 0 replies; 8+ messages in thread From: Francesco Lavra @ 2012-10-27 15:08 UTC (permalink / raw) To: Rajanikanth H.V Cc: lee.jones, arnd, anton.vorontsov, linus.walleij, linux-arm-kernel, linux-kernel, linaro-dev, patches, STEricsson_nomadik_linux On 10/25/2012 08:30 AM, Rajanikanth H.V wrote: > From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com> > > This patch adds device tree support for > battery-temperature-monitor driver > > Signed-off-by: Rajanikanth H.V <rajanikanth.hv@stericsson.com> > --- > Documentation/devicetree/bindings/mfd/ab8500.txt | 6 ++ > .../bindings/power_supply/ab8500/btemp.txt | 16 +++++ > arch/arm/boot/dts/dbx5x0.dtsi | 5 ++ > drivers/mfd/ab8500-core.c | 5 ++ > drivers/power/Kconfig | 6 -- > drivers/power/ab8500_bmdata.c | 4 +- > drivers/power/ab8500_btemp.c | 66 ++++++++++++-------- > 7 files changed, 73 insertions(+), 35 deletions(-) > create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/btemp.txt > > diff --git a/Documentation/devicetree/bindings/mfd/ab8500.txt b/Documentation/devicetree/bindings/mfd/ab8500.txt > index 6ca8d81..179c802 100644 > --- a/Documentation/devicetree/bindings/mfd/ab8500.txt > +++ b/Documentation/devicetree/bindings/mfd/ab8500.txt > @@ -30,6 +30,12 @@ ab8500-fg : : vddadc : Fuel Gauge > : LOW_BAT_F : : LOW threshold battery voltage > : CC_INT_CALIB : : Coulomb Counter Internal Calibration > : CCEOC : : Coulomb Counter End of Conversion > +ab8500-btemp : : vtvout : Battery Temperature > + : BAT_CTRL_INDB : : Battery Removal Indicator > + : BTEMP_LOW : : Btemp < BtempLow, if battery temperature is lower than -10°C > + : BTEMP_HIGH : : BtempLow < Btemp < BtempMedium,if battery temperature is between -10 and 0°C > + : BTEMP_LOW_MEDIUM : : BtempMedium < Btemp < BtempHigh,if battery temperature is between 0°C and“MaxTemp > + : BTEMP_MEDIUM_HIGH : : Btemp > BtempHigh, if battery temperature is higher than “MaxTemp” BTEMP_HIGH, BTEMP_LOW_MEDIUM and BTEMP_MEDIUM_HIGH are in the wrong order and don't correspond to their description. -- Francesco ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1351146654-9110-4-git-send-email-rajanikanth.hv@stericsson.com>]
* Re: [PATCH 3/4] mfd: ab8500: add devicetree support for charger [not found] ` <1351146654-9110-4-git-send-email-rajanikanth.hv@stericsson.com> @ 2012-10-27 15:10 ` Francesco Lavra 0 siblings, 0 replies; 8+ messages in thread From: Francesco Lavra @ 2012-10-27 15:10 UTC (permalink / raw) To: Rajanikanth H.V Cc: lee.jones, arnd, anton.vorontsov, linus.walleij, linux-arm-kernel, linux-kernel, linaro-dev, patches, STEricsson_nomadik_linux On 10/25/2012 08:30 AM, Rajanikanth H.V wrote: > From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com> > > This patch adds device tree support for ab8500-charger > driver > > Signed-off-by: Rajanikanth H.V <rajanikanth.hv@stericsson.com> [...] > diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c > index 78a730c..956943e 100644 > --- a/drivers/power/ab8500_charger.c > +++ b/drivers/power/ab8500_charger.c > @@ -23,6 +23,8 @@ > #include <linux/err.h> > #include <linux/workqueue.h> > #include <linux/kobject.h> > +#include <linux/of.h> > +#include <linux/mfd/core.h> > #include <linux/mfd/abx500/ab8500.h> > #include <linux/mfd/abx500.h> > #include <linux/mfd/abx500/ab8500-bm.h> > @@ -183,7 +185,6 @@ struct ab8500_charger_usb_state { > * @autopower Indicate if we should have automatic pwron after pwrloss > * @parent: Pointer to the struct ab8500 > * @gpadc: Pointer to the struct gpadc > - * @pdata: Pointer to the abx500_charger platform data > * @bat: Pointer to the abx500_bm platform data > * @flags: Structure for information about events triggered > * @usb_state: Structure for usb stack information > @@ -218,9 +219,9 @@ struct ab8500_charger { > int vbat; > int old_vbat; > bool autopower; > + bool autopower_cfg; autopower_cfg should be added in the description of the struct members as well. -- Francesco ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1351146654-9110-5-git-send-email-rajanikanth.hv@stericsson.com>]
* Re: [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg [not found] ` <1351146654-9110-5-git-send-email-rajanikanth.hv@stericsson.com> @ 2012-10-27 15:11 ` Francesco Lavra 0 siblings, 0 replies; 8+ messages in thread From: Francesco Lavra @ 2012-10-27 15:11 UTC (permalink / raw) To: Rajanikanth H.V Cc: lee.jones, arnd, anton.vorontsov, linus.walleij, linux-arm-kernel, linux-kernel, linaro-dev, patches, STEricsson_nomadik_linux On 10/25/2012 08:30 AM, Rajanikanth H.V wrote: > From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com> > > This patch adds device tree support for charging algorithm > driver > > Signed-off-by: Rajanikanth H.V <rajanikanth.hv@stericsson.com> [...] > diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c > index 88b5cc1..829fcfd 100644 > --- a/drivers/power/abx500_chargalg.c > +++ b/drivers/power/abx500_chargalg.c > @@ -21,6 +21,8 @@ > #include <linux/completion.h> > #include <linux/workqueue.h> > #include <linux/kobject.h> > +#include <linux/of.h> > +#include <linux/mfd/core.h> > #include <linux/mfd/abx500.h> > #include <linux/mfd/abx500/ux500_chargalg.h> > #include <linux/mfd/abx500/ab8500-bm.h> > @@ -231,7 +233,6 @@ struct abx500_chargalg { > struct abx500_chargalg_charger_info chg_info; > struct abx500_chargalg_battery_data batt_data; > struct abx500_chargalg_suspension_status susp_status; > - struct abx500_bmdevs_plat_data *pdata; pdata should be removed from the description of the struct members as well. > struct abx500_bm_data *bat; > struct power_supply chargalg_psy; > struct ux500_charger *ac_chg; > @@ -1795,25 +1796,45 @@ static int __devexit abx500_chargalg_remove(struct platform_device *pdev) > flush_scheduled_work(); > power_supply_unregister(&di->chargalg_psy); > platform_set_drvdata(pdev, NULL); > - kfree(di); > > return 0; > } > > +static char *supply_interface[] = { > + "ab8500_fg", > +}; > + > static int __devinit abx500_chargalg_probe(struct platform_device *pdev) > { > - struct abx500_bmdevs_plat_data *plat_data; > + struct device_node *np = pdev->dev.of_node; > + struct abx500_chargalg *di; > int ret = 0; > > - struct abx500_chargalg *di = > - kzalloc(sizeof(struct abx500_chargalg), GFP_KERNEL); > - if (!di) > + di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL); > + if (!di) { > + dev_err(&pdev->dev, "%s no mem for ab8500_chargalg\n", __func__); > return -ENOMEM; > + } > + di->bat = pdev->mfd_cell->platform_data; > + if (!di->bat) { > + if (np) { > + ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); > + if (ret) { > + dev_err(&pdev->dev, > + "failed to get battery information\n"); > + return ret; > + } > + } else { > + dev_err(&pdev->dev, "missing dt node for ab8500_chargalg\n"); > + return -EINVAL; > + } > + } else { > + dev_info(&pdev->dev, "falling back to legacy platform data\n"); > + printk("%s falling back to legacy platform data\n", __func__); You forgot to remove the printk() call. -- Francesco ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/4] Implement device tree support for ab8500 BM Devices @ 2012-10-31 15:40 Rajanikanth H.V 2012-10-31 15:40 ` [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg Rajanikanth H.V 0 siblings, 1 reply; 8+ messages in thread From: Rajanikanth H.V @ 2012-10-31 15:40 UTC (permalink / raw) To: rob.herring, lee.jones, francescolavra.fl Cc: arnd, anton.vorontsov, linus.walleij, linux-arm-kernel, linux-kernel, linaro-dev, patches, STEricsson_nomadik_linux, rajanikanth.hv From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com> This patch-set adds device tree binding for ab8500 battery-managed devices. Removes the redundant platform structure maintained across bm devices and implements common DT probe routine across all the modules. Test status: a) Tested across 'legacy platform data' and DT binding support a.1) ab8500_charger driver fails to get regulator in the legacy platform mode. b) Interrupt numbers assigned differs between legacy and FDT mode. (a) Legacy platform_data Mode: root@ME:/ cat /proc/interrupts CPU0 CPU1 483: 0 0 ab8500 ab8500-ponkey-dbf 484: 0 0 ab8500 ab8500-ponkey-dbr 485: 0 0 ab8500 BATT_OVV 494: 0 1 ab8500 495: 0 0 ab8500 ab8500-rtc 501: 0 13 ab8500 NCONV_ACCU 503: 7 22 ab8500 CCEOC 504: 0 1 ab8500 CC_INT_CALIB 505: 0 0 ab8500 LOW_BAT_F 516: 0 34 ab8500 ab8500-gpadc 556: 0 0 ab8500 usb-link-status (b) FDT Mode: root@ME:/ cat /proc/interrupts CPU0 CPU1 6: 0 0 ab8500 ab8500-ponkey-dbf 7: 0 0 ab8500 ab8500-ponkey-dbr 8: 0 0 ab8500 BATT_OVV 162: 0 7 ab8500 ab8500-gpadc 163: 0 1 ab8500 164: 0 0 ab8500 ab8500-rtc 484: 0 0 ab8500 usb-link-status 499: 0 4 ab8500 NCONV_ACCU 500: 0 0 ab8500 LOW_BAT_F 502: 0 1 ab8500 CC_INT_CALIB 503: 0 6 ab8500 CCEOC c) Event handlers across bm-modules have been verified only during 'battery discharge process' as 'battery charging process' depends on ab8500-usb code Rajanikanth H.V (4): mfd: ab8500: add devicetree support for fuelgauge mfd: ab8500: add devicetree support for btemp mfd: ab8500: add devicetree support for charger mfd: ab8500: add devicetree support for chargalg Documentation/devicetree/bindings/mfd/ab8500.txt | 27 +- .../bindings/power_supply/ab8500/btemp.txt | 16 + .../bindings/power_supply/ab8500/chargalg.txt | 16 + .../bindings/power_supply/ab8500/charger.txt | 25 + .../devicetree/bindings/power_supply/ab8500/fg.txt | 58 +++ arch/arm/boot/dts/dbx5x0.dtsi | 28 +- drivers/mfd/ab8500-core.c | 20 + drivers/power/Kconfig | 6 - drivers/power/Makefile | 2 +- drivers/power/ab8500_bmdata.c | 518 ++++++++++++++++++++ drivers/power/ab8500_btemp.c | 76 +-- drivers/power/ab8500_charger.c | 83 ++-- drivers/power/ab8500_fg.c | 81 +-- drivers/power/abx500_chargalg.c | 56 ++- include/linux/mfd/abx500.h | 34 +- 15 files changed, 881 insertions(+), 165 deletions(-) create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/btemp.txt create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/charger.txt create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/fg.txt create mode 100644 drivers/power/ab8500_bmdata.c -- 1.7.10.4 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg 2012-10-31 15:40 [PATCH 0/4] Implement device tree support for ab8500 BM Devices Rajanikanth H.V @ 2012-10-31 15:40 ` Rajanikanth H.V 0 siblings, 0 replies; 8+ messages in thread From: Rajanikanth H.V @ 2012-10-31 15:40 UTC (permalink / raw) To: rob.herring, lee.jones, francescolavra.fl Cc: arnd, anton.vorontsov, linus.walleij, linux-arm-kernel, linux-kernel, linaro-dev, patches, STEricsson_nomadik_linux, rajanikanth.hv From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com> This patch adds device tree support for charging algorithm driver Signed-off-by: Rajanikanth H.V <rajanikanth.hv@stericsson.com> --- .../bindings/power_supply/ab8500/chargalg.txt | 16 ++++++ arch/arm/boot/dts/dbx5x0.dtsi | 5 ++ drivers/mfd/ab8500-core.c | 5 ++ drivers/power/abx500_chargalg.c | 54 ++++++++++++++------ include/linux/mfd/abx500.h | 6 --- 5 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt 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 0000000..ef53283 --- /dev/null +++ b/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt @@ -0,0 +1,16 @@ +=== AB8500 Charging Algorithm Driver === + +The properties below describes the node for chargalg driver. + +Required Properties: +- compatible = Shall be: "stericsson,ab8500-chargalg" +- battery = Shall be battery specific information + +Example: +ab8500_chargalg { + compatible = "stericsson,ab8500-chargalg"; + battery = <&ab8500_battery>; +}; + +For information on battery specific node, Ref: +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 b1ecb5d..a678afa 100644 --- a/arch/arm/boot/dts/dbx5x0.dtsi +++ b/arch/arm/boot/dts/dbx5x0.dtsi @@ -373,6 +373,11 @@ vddadc-supply = <&ab8500_ldo_tvout_reg>; }; + ab8500_chargalg { + compatible = "stericsson,ab8500-chargalg"; + battery = <&ab8500_battery>; + }; + ab8500_usb { compatible = "stericsson,ab8500-usb"; interrupts = < 90 0x4 diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index c7a120b..5ec70f2 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[] = { }, { .name = "ab8500-chargalg", + .of_compatible = "stericsson,ab8500-chargalg", .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), .resources = ab8500_chargalg_resources, +#ifndef CONFIG_OF + .platform_data = &ab8500_bm_data, + .pdata_size = sizeof(ab8500_bm_data), +#endif }, }; diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index 88b5cc1..c603556 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -21,6 +21,8 @@ #include <linux/completion.h> #include <linux/workqueue.h> #include <linux/kobject.h> +#include <linux/of.h> +#include <linux/mfd/core.h> #include <linux/mfd/abx500.h> #include <linux/mfd/abx500/ux500_chargalg.h> #include <linux/mfd/abx500/ab8500-bm.h> @@ -205,7 +207,6 @@ enum maxim_ret { * @chg_info: information about connected charger types * @batt_data: data of the battery * @susp_status: current charger suspension status - * @pdata: pointer to the abx500_chargalg platform data * @bat: pointer to the abx500_bm platform data * @chargalg_psy: structure that holds the battery properties exposed by * the charging algorithm @@ -231,7 +232,6 @@ struct abx500_chargalg { struct abx500_chargalg_charger_info chg_info; struct abx500_chargalg_battery_data batt_data; struct abx500_chargalg_suspension_status susp_status; - struct abx500_bmdevs_plat_data *pdata; struct abx500_bm_data *bat; struct power_supply chargalg_psy; struct ux500_charger *ac_chg; @@ -1795,25 +1795,44 @@ static int __devexit abx500_chargalg_remove(struct platform_device *pdev) flush_scheduled_work(); power_supply_unregister(&di->chargalg_psy); platform_set_drvdata(pdev, NULL); - kfree(di); return 0; } +static char *supply_interface[] = { + "ab8500_fg", +}; + static int __devinit abx500_chargalg_probe(struct platform_device *pdev) { - struct abx500_bmdevs_plat_data *plat_data; + struct device_node *np = pdev->dev.of_node; + struct abx500_chargalg *di; int ret = 0; - struct abx500_chargalg *di = - kzalloc(sizeof(struct abx500_chargalg), GFP_KERNEL); - if (!di) + di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL); + if (!di) { + dev_err(&pdev->dev, "%s no mem for ab8500_chargalg\n", __func__); return -ENOMEM; + } + di->bat = pdev->mfd_cell->platform_data; + if (!di->bat) { + if (np) { + ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); + if (ret) { + dev_err(&pdev->dev, + "failed to get battery information\n"); + return ret; + } + } else { + dev_err(&pdev->dev, "missing dt node for ab8500_chargalg\n"); + return -EINVAL; + } + } else { + dev_info(&pdev->dev, "falling back to legacy platform data\n"); + } /* get device struct */ di->dev = &pdev->dev; - plat_data = pdev->dev.platform_data; - di->pdata = plat_data; /* chargalg supply */ di->chargalg_psy.name = "abx500_chargalg"; @@ -1821,8 +1840,8 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev) di->chargalg_psy.properties = abx500_chargalg_props; di->chargalg_psy.num_properties = ARRAY_SIZE(abx500_chargalg_props); di->chargalg_psy.get_property = abx500_chargalg_get_property; - di->chargalg_psy.supplied_to = di->pdata->supplied_to; - di->chargalg_psy.num_supplicants = di->pdata->num_supplicants; + di->chargalg_psy.supplied_to = supply_interface; + di->chargalg_psy.num_supplicants = ARRAY_SIZE(supply_interface), di->chargalg_psy.external_power_changed = abx500_chargalg_external_power_changed; @@ -1842,7 +1861,7 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev) create_singlethread_workqueue("abx500_chargalg_wq"); if (di->chargalg_wq == NULL) { dev_err(di->dev, "failed to create work queue\n"); - goto free_device_info; + return -ENOMEM; } /* Init work for chargalg */ @@ -1883,20 +1902,23 @@ free_psy: power_supply_unregister(&di->chargalg_psy); free_chargalg_wq: destroy_workqueue(di->chargalg_wq); -free_device_info: - kfree(di); - return ret; } +static const struct of_device_id ab8500_chargalg_match[] = { + { .compatible = "stericsson,ab8500-chargalg", }, + { }, +}; + static struct platform_driver abx500_chargalg_driver = { .probe = abx500_chargalg_probe, .remove = __devexit_p(abx500_chargalg_remove), .suspend = abx500_chargalg_suspend, .resume = abx500_chargalg_resume, .driver = { - .name = "abx500-chargalg", + .name = "ab8500-chargalg", .owner = THIS_MODULE, + .of_match_table = ab8500_chargalg_match, }, }; diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index bbf3ad6..a14c1a6 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h @@ -389,12 +389,6 @@ struct abx500_bm_data { extern struct abx500_bm_data ab8500_bm_data; -struct abx500_bmdevs_plat_data { - char **supplied_to; - size_t num_supplicants; - bool autopower_cfg; -}; - enum { NTC_EXTERNAL = 0, NTC_INTERNAL, -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 0/4] Implement device tree support for ab8500 BM Devices @ 2012-11-22 18:43 Rajanikanth H.V 2012-11-22 18:43 ` [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg Rajanikanth H.V 0 siblings, 1 reply; 8+ messages in thread From: Rajanikanth H.V @ 2012-11-22 18:43 UTC (permalink / raw) To: rob.herring, robherring2, francescolavra.fl, anton.vorontsov Cc: lee.jones, arnd, linus.walleij, linux-arm-kernel, linux-kernel, linaro-dev, patches, STEricsson_nomadik_linux, rajanikanth.hv, Rajanikanth H.V From: "Rajanikanth H.V" <rajanikanth.hv@linaro.org> This patch-set adds device tree binding for ab8500 battery-managed devices. Removes the redundant platform structure maintained across bm devices and implements common DT probe routine across all the modules. Test status: a) Tested across 'legacy platform data' and DT binding support a.1) ab8500_charger driver fails to get regulator in the legacy platform mode. b) Interrupt numbers assigned differs between legacy and FDT mode. (a) Legacy platform_data Mode: root@ME:/ cat /proc/interrupts CPU0 CPU1 483: 0 0 ab8500 ab8500-ponkey-dbf 484: 0 0 ab8500 ab8500-ponkey-dbr 485: 0 0 ab8500 BATT_OVV 494: 0 1 ab8500 495: 0 0 ab8500 ab8500-rtc 501: 0 13 ab8500 NCONV_ACCU 503: 7 22 ab8500 CCEOC 504: 0 1 ab8500 CC_INT_CALIB 505: 0 0 ab8500 LOW_BAT_F 516: 0 34 ab8500 ab8500-gpadc 556: 0 0 ab8500 usb-link-status (b) FDT Mode: root@ME:/ cat /proc/interrupts CPU0 CPU1 6: 0 0 ab8500 ab8500-ponkey-dbf 7: 0 0 ab8500 ab8500-ponkey-dbr 8: 0 0 ab8500 BATT_OVV 162: 0 7 ab8500 ab8500-gpadc 163: 0 1 ab8500 164: 0 0 ab8500 ab8500-rtc 484: 0 0 ab8500 usb-link-status 499: 0 4 ab8500 NCONV_ACCU 500: 0 0 ab8500 LOW_BAT_F 502: 0 1 ab8500 CC_INT_CALIB 503: 0 6 ab8500 CCEOC c) Event handlers across bm-modules have been verified only during 'battery discharge process' as 'battery charging process' depends on ab8500-usb code d) observed nested IRQ issue, log below: root@ME:/ ------------[ cut here ]------------ WARNING: at /home/rhv00000/linaro_work/linux/kernel/irq/manage.c:635 irq_nested_primary_handler+0x20/0x28() Primary handler called for nested irq 193 Modules linked in: [<c0014884>] (unwind_backtrace+0x0/0xf8) from [<c001cbb4>] (warn_slowpath_common+0x4c/0x64) [<c001cbb4>] (warn_slowpath_common+0x4c/0x64) from [<c001cc60>] (warn_slowpath_fmt+0x30/0x40) [<c001cc60>] (warn_slowpath_fmt+0x30/0x40) from [<c0060f00>] (irq_nested_primary_handler+0x20/0x28) [<c0060f00>] (irq_nested_primary_handler+0x20/0x28) from [<c0060b80>] (handle_irq_event_percpu+0x50/0x194) [<c0060b80>] (handle_irq_event_percpu+0x50/0x194) from [<c0060d00>] (handle_irq_event+0x3c/0x5c) [<c0060d00>] (handle_irq_event+0x3c/0x5c) from [<c0063034>] (handle_simple_irq+0x8c/0xc4) [<c0063034>] (handle_simple_irq+0x8c/0xc4) from [<c0062d84>] (resend_irqs+0x40/0x68) [<c0062d84>] (resend_irqs+0x40/0x68) from [<c00236d8>] (tasklet_action+0x84/0x120) [<c00236d8>] (tasklet_action+0x84/0x120) from [<c0023ae4>] (__do_softirq+0xd8/0x198) [<c0023ae4>] (__do_softirq+0xd8/0x198) from [<c0023ed4>] (irq_exit+0x90/0x98) [<c0023ed4>] (irq_exit+0x90/0x98) from [<c000f2cc>] (handle_IRQ+0x50/0xb0) [<c000f2cc>] (handle_IRQ+0x50/0xb0) from [<c00084f0>] (gic_handle_irq+0x28/0x5c) [<c00084f0>] (gic_handle_irq+0x28/0x5c) from [<c000df80>] (__irq_svc+0x40/0x70) Exception stack(0xebc5dea8 to 0xebc5def0) dea0: c0f45340 ebc4cf00 00000000 1f321f32 eb196600 ebc4cf00 dec0: c05a3340 00000002 ebc4c600 00000000 eb1b2c00 ebc5df0c 00000000 ebc5def0 dee0: c0040c7c c02ca5ec 60000013 ffffffff [<c000df80>] (__irq_svc+0x40/0x70) from [<c02ca5ec>] (_raw_spin_unlock_irq+0x28/0x50) [<c02ca5ec>] (_raw_spin_unlock_irq+0x28/0x50) from [<c0040c7c>] (finish_task_switch+0x28/0xf0) [<c0040c7c>] (finish_task_switch+0x28/0xf0) from [<c02c93f0>] (__schedule+0x254/0x548) [<c02c93f0>] (__schedule+0x254/0x548) from [<c0040088>] (smpboot_thread_fn+0x11c/0x250) [<c0040088>] (smpboot_thread_fn+0x11c/0x250) from [<c0037fc8>] (kthread+0xa4/0xb0) [<c0037fc8>] (kthread+0xa4/0xb0) from [<c000e418>] (ret_from_fork+0x14/0x3c) ---[ end trace 1b75b31a2719ed1e ]--- Rajanikanth H.V (4): mfd: ab8500: add devicetree support for fuelgauge mfd: ab8500: add devicetree support for btemp mfd: ab8500: add devicetree support for charger mfd: ab8500: add devicetree support for chargalg Documentation/devicetree/bindings/mfd/ab8500.txt | 27 +- .../bindings/power_supply/ab8500/btemp.txt | 16 + .../bindings/power_supply/ab8500/chargalg.txt | 16 + .../bindings/power_supply/ab8500/charger.txt | 25 + .../devicetree/bindings/power_supply/ab8500/fg.txt | 58 +++ arch/arm/boot/dts/dbx5x0.dtsi | 26 + drivers/mfd/ab8500-core.c | 20 + drivers/power/Kconfig | 6 - drivers/power/Makefile | 2 +- drivers/power/ab8500_bmdata.c | 514 ++++++++++++++++++++ drivers/power/ab8500_btemp.c | 75 +-- drivers/power/ab8500_charger.c | 83 ++-- drivers/power/ab8500_fg.c | 81 +-- drivers/power/abx500_chargalg.c | 57 ++- include/linux/mfd/abx500.h | 34 +- 15 files changed, 879 insertions(+), 161 deletions(-) create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/btemp.txt create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/charger.txt create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/fg.txt create mode 100644 drivers/power/ab8500_bmdata.c -- 1.7.10.4 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg 2012-11-22 18:43 [PATCH 0/4] Implement device tree support for ab8500 BM Devices Rajanikanth H.V @ 2012-11-22 18:43 ` Rajanikanth H.V 0 siblings, 0 replies; 8+ messages in thread From: Rajanikanth H.V @ 2012-11-22 18:43 UTC (permalink / raw) To: rob.herring, robherring2, francescolavra.fl, anton.vorontsov Cc: lee.jones, arnd, linus.walleij, linux-arm-kernel, linux-kernel, linaro-dev, patches, STEricsson_nomadik_linux, rajanikanth.hv, Rajanikanth H.V From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com> This patch adds device tree support for charging algorithm driver Signed-off-by: Rajanikanth H.V <rajanikanth.hv@linaro.org> --- .../bindings/power_supply/ab8500/chargalg.txt | 16 ++++++ arch/arm/boot/dts/dbx5x0.dtsi | 5 ++ drivers/mfd/ab8500-core.c | 5 ++ drivers/power/abx500_chargalg.c | 56 ++++++++++++++------ include/linux/mfd/abx500.h | 6 --- 5 files changed, 66 insertions(+), 22 deletions(-) create mode 100644 Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt 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 0000000..ef53283 --- /dev/null +++ b/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt @@ -0,0 +1,16 @@ +=== AB8500 Charging Algorithm Driver === + +The properties below describes the node for chargalg driver. + +Required Properties: +- compatible = Shall be: "stericsson,ab8500-chargalg" +- battery = Shall be battery specific information + +Example: +ab8500_chargalg { + compatible = "stericsson,ab8500-chargalg"; + battery = <&ab8500_battery>; +}; + +For information on battery specific node, Ref: +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 7e9c01a..f1661b3 100644 --- a/arch/arm/boot/dts/dbx5x0.dtsi +++ b/arch/arm/boot/dts/dbx5x0.dtsi @@ -357,6 +357,11 @@ thermistor-on-batctrl; }; + ab8500-chargalg { + compatible = "stericsson,ab8500-chargalg"; + battery = <&ab8500_battery>; + }; + ab8500-charger { compatible = "stericsson,ab8500-charger"; battery = <&ab8500_battery>; diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index c7a120b..5ec70f2 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[] = { }, { .name = "ab8500-chargalg", + .of_compatible = "stericsson,ab8500-chargalg", .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), .resources = ab8500_chargalg_resources, +#ifndef CONFIG_OF + .platform_data = &ab8500_bm_data, + .pdata_size = sizeof(ab8500_bm_data), +#endif }, }; diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index 94bf69b..96eb2c5 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -21,6 +21,8 @@ #include <linux/completion.h> #include <linux/workqueue.h> #include <linux/kobject.h> +#include <linux/of.h> +#include <linux/mfd/core.h> #include <linux/mfd/abx500.h> #include <linux/mfd/abx500/ux500_chargalg.h> #include <linux/mfd/abx500/ab8500-bm.h> @@ -205,7 +207,6 @@ enum maxim_ret { * @chg_info: information about connected charger types * @batt_data: data of the battery * @susp_status: current charger suspension status - * @pdata: pointer to the abx500_chargalg platform data * @bat: pointer to the abx500_bm platform data * @chargalg_psy: structure that holds the battery properties exposed by * the charging algorithm @@ -231,7 +232,6 @@ struct abx500_chargalg { struct abx500_chargalg_charger_info chg_info; struct abx500_chargalg_battery_data batt_data; struct abx500_chargalg_suspension_status susp_status; - struct abx500_bmdevs_plat_data *pdata; struct abx500_bm_data *bat; struct power_supply chargalg_psy; struct ux500_charger *ac_chg; @@ -1795,35 +1795,55 @@ static int __devexit abx500_chargalg_remove(struct platform_device *pdev) flush_scheduled_work(); power_supply_unregister(&di->chargalg_psy); platform_set_drvdata(pdev, NULL); - kfree(di); return 0; } +static char *supply_interface[] = { + "ab8500_fg", +}; + static int __devinit abx500_chargalg_probe(struct platform_device *pdev) { - struct abx500_bmdevs_plat_data *plat_data; + struct device_node *np = pdev->dev.of_node; + struct abx500_chargalg *di; int ret = 0; - struct abx500_chargalg *di = - kzalloc(sizeof(struct abx500_chargalg), GFP_KERNEL); - if (!di) + di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL); + if (!di) { + dev_err(&pdev->dev, "%s no mem for ab8500_chargalg\n", + __func__); return -ENOMEM; + } + + di->bat = pdev->mfd_cell->platform_data; + if (!di->bat) { + if (np) { + ret = bmdevs_of_probe(&pdev->dev, np, &di->bat); + if (ret) { + dev_err(&pdev->dev, + "failed to get battery information\n"); + return ret; + } + } else { + dev_err(&pdev->dev, "missing dt node for ab8500_chargalg\n"); + return -EINVAL; + } + } else { + dev_info(&pdev->dev, "falling back to legacy platform data\n"); + } /* get device struct */ di->dev = &pdev->dev; - plat_data = pdev->dev.platform_data; - di->pdata = plat_data; - /* chargalg supply */ di->chargalg_psy.name = "abx500_chargalg"; di->chargalg_psy.type = POWER_SUPPLY_TYPE_BATTERY; di->chargalg_psy.properties = abx500_chargalg_props; di->chargalg_psy.num_properties = ARRAY_SIZE(abx500_chargalg_props); di->chargalg_psy.get_property = abx500_chargalg_get_property; - di->chargalg_psy.supplied_to = di->pdata->supplied_to; - di->chargalg_psy.num_supplicants = di->pdata->num_supplicants; + di->chargalg_psy.supplied_to = supply_interface; + di->chargalg_psy.num_supplicants = ARRAY_SIZE(supply_interface), di->chargalg_psy.external_power_changed = abx500_chargalg_external_power_changed; @@ -1843,7 +1863,7 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev) create_singlethread_workqueue("abx500_chargalg_wq"); if (di->chargalg_wq == NULL) { dev_err(di->dev, "failed to create work queue\n"); - goto free_device_info; + return -ENOMEM; } /* Init work for chargalg */ @@ -1884,20 +1904,24 @@ free_psy: power_supply_unregister(&di->chargalg_psy); free_chargalg_wq: destroy_workqueue(di->chargalg_wq); -free_device_info: - kfree(di); return ret; } +static const struct of_device_id ab8500_chargalg_match[] = { + { .compatible = "stericsson,ab8500-chargalg", }, + { }, +}; + static struct platform_driver abx500_chargalg_driver = { .probe = abx500_chargalg_probe, .remove = __devexit_p(abx500_chargalg_remove), .suspend = abx500_chargalg_suspend, .resume = abx500_chargalg_resume, .driver = { - .name = "abx500-chargalg", + .name = "ab8500-chargalg", .owner = THIS_MODULE, + .of_match_table = ab8500_chargalg_match, }, }; diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index 33f2c58..2138bd3 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h @@ -274,12 +274,6 @@ struct abx500_bm_data { extern struct abx500_bm_data ab8500_bm_data; -struct abx500_bmdevs_plat_data { - char **supplied_to; - size_t num_supplicants; - bool autopower_cfg; -}; - enum { NTC_EXTERNAL = 0, NTC_INTERNAL, -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-11-22 18:46 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <1351146654-9110-1-git-send-email-rajanikanth.hv@stericsson.com> [not found] ` <1351146654-9110-2-git-send-email-rajanikanth.hv@stericsson.com> 2012-10-27 15:07 ` [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge Francesco Lavra 2012-10-27 16:00 ` Rajanikanth HV 2012-10-27 16:18 ` Francesco Lavra [not found] ` <1351146654-9110-3-git-send-email-rajanikanth.hv@stericsson.com> 2012-10-27 15:08 ` [PATCH 2/4] mfd: ab8500: add devicetree support for btemp Francesco Lavra [not found] ` <1351146654-9110-4-git-send-email-rajanikanth.hv@stericsson.com> 2012-10-27 15:10 ` [PATCH 3/4] mfd: ab8500: add devicetree support for charger Francesco Lavra [not found] ` <1351146654-9110-5-git-send-email-rajanikanth.hv@stericsson.com> 2012-10-27 15:11 ` [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg Francesco Lavra 2012-10-31 15:40 [PATCH 0/4] Implement device tree support for ab8500 BM Devices Rajanikanth H.V 2012-10-31 15:40 ` [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg Rajanikanth H.V 2012-11-22 18:43 [PATCH 0/4] Implement device tree support for ab8500 BM Devices Rajanikanth H.V 2012-11-22 18:43 ` [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg Rajanikanth H.V
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).