Re: [PATCH] twl4030_charger: add devicetree support.
On Thu, Oct 31, 2013 at 05:05:50PM +1100, NeilBrown wrote: This allows the charger to be enabled with devicetree, and allows the parameters for charging the backup battery to be set. Signed-off-by: NeilBrown ne...@suse.de Acked-by: Kumar Gala ga...@codeaurora.org Acked-by: Grant Likely grant.lik...@linaro.org -- This version with correct property names and some Acked-by's. - NB Applied, thank you! -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] twl4030_charger: add devicetree support.
This allows the charger to be enabled with devicetree, and allows the parameters for charging the backup battery to be set. Signed-off-by: NeilBrown ne...@suse.de Acked-by: Kumar Gala ga...@codeaurora.org Acked-by: Grant Likely grant.lik...@linaro.org -- This version with correct property names and some Acked-by's. - NB diff --git a/Documentation/devicetree/bindings/power/twl-charger.txt b/Documentation/devicetree/bindings/power/twl-charger.txt new file mode 100644 index ..d5c706216df5 --- /dev/null +++ b/Documentation/devicetree/bindings/power/twl-charger.txt @@ -0,0 +1,20 @@ +TWL BCI (Battery Charger Interface) + +Required properties: +- compatible: + - ti,twl4030-bci +- interrupts: two interrupt lines from the TWL SIH (secondary + interrupt handler) - interrupts 9 and 2. + +Optional properties: +- ti,bb-uvolt: microvolts for charging the backup battery. +- ti,bb-uamp: microamps for charging the backup battery. + +Examples: + +bci { + compatible = ti,twl4030-bci; + interrupts = 9, 2; + ti,bb-uvolt = 320; + ti,bb-uamp = 150; +}; diff --git a/arch/arm/boot/dts/twl4030.dtsi b/arch/arm/boot/dts/twl4030.dtsi index ae6a17aed9ee..5a12540b1d0f 100644 --- a/arch/arm/boot/dts/twl4030.dtsi +++ b/arch/arm/boot/dts/twl4030.dtsi @@ -19,6 +19,12 @@ interrupts = 11; }; + charger: bci { + compatible = ti,twl4030-bci; + interrupts = 9, 2; + bci3v1-supply = vusb3v1; + }; + watchdog { compatible = ti,twl4030-wdt; }; diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c index d98abe911e37..f14108844e1a 100644 --- a/drivers/power/twl4030_charger.c +++ b/drivers/power/twl4030_charger.c @@ -495,10 +495,38 @@ static enum power_supply_property twl4030_charger_props[] = { POWER_SUPPLY_PROP_CURRENT_NOW, }; +#ifdef CONFIG_OF +static const struct twl4030_bci_platform_data * +twl4030_bci_parse_dt(struct device *dev) +{ + struct device_node *np = dev-of_node; + struct twl4030_bci_platform_data *pdata; + u32 num; + + if (!np) + return NULL; + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return pdata; + + if (of_property_read_u32(np, ti,bb-uvolt, num) == 0) + pdata-bb_uvolt = num; + if (of_property_read_u32(np, ti,bb-uamp, num) == 0) + pdata-bb_uamp = num; + return pdata; +} +#else +static inline const struct twl4030_bci_platform_data * +twl4030_bci_parse_dt(struct device *dev) +{ + return NULL; +} +#endif + static int __init twl4030_bci_probe(struct platform_device *pdev) { struct twl4030_bci *bci; - struct twl4030_bci_platform_data *pdata = pdev-dev.platform_data; + const struct twl4030_bci_platform_data *pdata = pdev-dev.platform_data; int ret; u32 reg; @@ -506,6 +534,9 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) if (bci == NULL) return -ENOMEM; + if (!pdata) + pdata = twl4030_bci_parse_dt(pdev-dev); + bci-dev = pdev-dev; bci-irq_chg = platform_get_irq(pdev, 0); bci-irq_bci = platform_get_irq(pdev, 1); @@ -581,8 +612,11 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) twl4030_charger_enable_ac(true); twl4030_charger_enable_usb(bci, true); - twl4030_charger_enable_backup(pdata-bb_uvolt, - pdata-bb_uamp); + if (pdata) + twl4030_charger_enable_backup(pdata-bb_uvolt, + pdata-bb_uamp); + else + twl4030_charger_enable_backup(0, 0); return 0; @@ -631,10 +665,17 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id twl_bci_of_match[] = { + {.compatible = ti,twl4030-bci, }, + { } +}; +MODULE_DEVICE_TABLE(of, twl_bci_of_match); + static struct platform_driver twl4030_bci_driver = { .driver = { .name = twl4030_bci, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(twl_bci_of_match), }, .remove = __exit_p(twl4030_bci_remove), }; signature.asc Description: PGP signature
Re: [PATCH] twl4030_charger: add devicetree support.
On Oct 24, 2013, at 12:50 AM, NeilBrown wrote: [my first device-tree related patch. Please let me know what I got wrong so I wont repeat the mistake in all the others I have queued] This allows the charger to be enabled with devicetree, and allows the parameters for charging the backup battery to be set. Signed-off-by: NeilBrown ne...@suse.de diff --git a/Documentation/devicetree/bindings/power/twl-charger.txt b/Documentation/devicetree/bindings/power/twl-charger.txt new file mode 100644 index 000..8afaa9a --- /dev/null +++ b/Documentation/devicetree/bindings/power/twl-charger.txt @@ -0,0 +1,20 @@ +TWL BCI (Battery Charger Interface) + +Required properties: +- compatible: + - ti,twl4030-bci +- interrupts: two interrupt lines from the TWL SIH (secondary + interrupt handler) - interrupts 9 and 2. + +Optional properties: +- bb-uvolt: microvolts for charging the backup battery. +- bb-uamp: microamps for charging the backup battery. prop should have vendor prefix. ti,bb-uvolt, ti,bb-uamp - k + +Examples: + +bci { + compatible = ti,twl4030-bci; + interrupts = 9, 2; + bb-uvolt = 320; + bb-uamp = 150; +}; -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] twl4030_charger: add devicetree support.
On Thu, 24 Oct 2013 04:44:03 -0500, Kumar Gala ga...@codeaurora.org wrote: On Oct 24, 2013, at 12:50 AM, NeilBrown wrote: [my first device-tree related patch. Please let me know what I got wrong so I wont repeat the mistake in all the others I have queued] This allows the charger to be enabled with devicetree, and allows the parameters for charging the backup battery to be set. Signed-off-by: NeilBrown ne...@suse.de diff --git a/Documentation/devicetree/bindings/power/twl-charger.txt b/Documentation/devicetree/bindings/power/twl-charger.txt new file mode 100644 index 000..8afaa9a --- /dev/null +++ b/Documentation/devicetree/bindings/power/twl-charger.txt @@ -0,0 +1,20 @@ +TWL BCI (Battery Charger Interface) + +Required properties: +- compatible: + - ti,twl4030-bci +- interrupts: two interrupt lines from the TWL SIH (secondary + interrupt handler) - interrupts 9 and 2. + +Optional properties: +- bb-uvolt: microvolts for charging the backup battery. +- bb-uamp: microamps for charging the backup battery. prop should have vendor prefix. ti,bb-uvolt, ti,bb-uamp Agreed. Otherwise: Acked-by: Grant Likely grant.lik...@linaro.org - k + +Examples: + +bci { + compatible = ti,twl4030-bci; + interrupts = 9, 2; + bb-uvolt = 320; + bb-uamp = 150; +}; -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] twl4030_charger: add devicetree support.
On Thu, 24 Oct 2013 11:06:52 +0100 Grant Likely grant.lik...@linaro.org wrote: On Thu, 24 Oct 2013 04:44:03 -0500, Kumar Gala ga...@codeaurora.org wrote: On Oct 24, 2013, at 12:50 AM, NeilBrown wrote: [my first device-tree related patch. Please let me know what I got wrong so I wont repeat the mistake in all the others I have queued] This allows the charger to be enabled with devicetree, and allows the parameters for charging the backup battery to be set. Signed-off-by: NeilBrown ne...@suse.de diff --git a/Documentation/devicetree/bindings/power/twl-charger.txt b/Documentation/devicetree/bindings/power/twl-charger.txt new file mode 100644 index 000..8afaa9a --- /dev/null +++ b/Documentation/devicetree/bindings/power/twl-charger.txt @@ -0,0 +1,20 @@ +TWL BCI (Battery Charger Interface) + +Required properties: +- compatible: + - ti,twl4030-bci +- interrupts: two interrupt lines from the TWL SIH (secondary + interrupt handler) - interrupts 9 and 2. + +Optional properties: +- bb-uvolt: microvolts for charging the backup battery. +- bb-uamp: microamps for charging the backup battery. prop should have vendor prefix. ti,bb-uvolt, ti,bb-uamp Agreed. Otherwise: OK, I'll do that - thanks. NeilBrown Acked-by: Grant Likely grant.lik...@linaro.org - k + +Examples: + +bci { + compatible = ti,twl4030-bci; + interrupts = 9, 2; + bb-uvolt = 320; + bb-uamp = 150; +}; -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation signature.asc Description: PGP signature
Re: [PATCH] twl4030_charger: add devicetree support.
On Oct 24, 2013, at 5:41 AM, NeilBrown wrote: On Thu, 24 Oct 2013 11:06:52 +0100 Grant Likely grant.lik...@linaro.org wrote: On Thu, 24 Oct 2013 04:44:03 -0500, Kumar Gala ga...@codeaurora.org wrote: On Oct 24, 2013, at 12:50 AM, NeilBrown wrote: [my first device-tree related patch. Please let me know what I got wrong so I wont repeat the mistake in all the others I have queued] This allows the charger to be enabled with devicetree, and allows the parameters for charging the backup battery to be set. Signed-off-by: NeilBrown ne...@suse.de diff --git a/Documentation/devicetree/bindings/power/twl-charger.txt b/Documentation/devicetree/bindings/power/twl-charger.txt new file mode 100644 index 000..8afaa9a --- /dev/null +++ b/Documentation/devicetree/bindings/power/twl-charger.txt @@ -0,0 +1,20 @@ +TWL BCI (Battery Charger Interface) + +Required properties: +- compatible: + - ti,twl4030-bci +- interrupts: two interrupt lines from the TWL SIH (secondary + interrupt handler) - interrupts 9 and 2. + +Optional properties: +- bb-uvolt: microvolts for charging the backup battery. +- bb-uamp: microamps for charging the backup battery. prop should have vendor prefix. ti,bb-uvolt, ti,bb-uamp Agreed. Otherwise: OK, I'll do that - thanks. NeilBrown Ditto on the Ack once these changes are made: Acked-by: Kumar Gala ga...@codeaurora.org - k Acked-by: Grant Likely grant.lik...@linaro.org - k + +Examples: + +bci { + compatible = ti,twl4030-bci; + interrupts = 9, 2; + bb-uvolt = 320; + bb-uamp = 150; +}; -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] twl4030_charger: add devicetree support.
[my first device-tree related patch. Please let me know what I got wrong so I wont repeat the mistake in all the others I have queued] This allows the charger to be enabled with devicetree, and allows the parameters for charging the backup battery to be set. Signed-off-by: NeilBrown ne...@suse.de diff --git a/Documentation/devicetree/bindings/power/twl-charger.txt b/Documentation/devicetree/bindings/power/twl-charger.txt new file mode 100644 index 000..8afaa9a --- /dev/null +++ b/Documentation/devicetree/bindings/power/twl-charger.txt @@ -0,0 +1,20 @@ +TWL BCI (Battery Charger Interface) + +Required properties: +- compatible: + - ti,twl4030-bci +- interrupts: two interrupt lines from the TWL SIH (secondary + interrupt handler) - interrupts 9 and 2. + +Optional properties: +- bb-uvolt: microvolts for charging the backup battery. +- bb-uamp: microamps for charging the backup battery. + +Examples: + +bci { + compatible = ti,twl4030-bci; + interrupts = 9, 2; + bb-uvolt = 320; + bb-uamp = 150; +}; diff --git a/arch/arm/boot/dts/twl4030.dtsi b/arch/arm/boot/dts/twl4030.dtsi index ae6a17a..5a12540 100644 --- a/arch/arm/boot/dts/twl4030.dtsi +++ b/arch/arm/boot/dts/twl4030.dtsi @@ -19,6 +19,12 @@ interrupts = 11; }; + charger: bci { + compatible = ti,twl4030-bci; + interrupts = 9, 2; + bci3v1-supply = vusb3v1; + }; + watchdog { compatible = ti,twl4030-wdt; }; diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c index d98abe9..a06b973 100644 --- a/drivers/power/twl4030_charger.c +++ b/drivers/power/twl4030_charger.c @@ -495,10 +495,38 @@ static enum power_supply_property twl4030_charger_props[] = { POWER_SUPPLY_PROP_CURRENT_NOW, }; +#ifdef CONFIG_OF +static const struct twl4030_bci_platform_data * +twl4030_bci_parse_dt(struct device *dev) +{ + struct device_node *np = dev-of_node; + struct twl4030_bci_platform_data *pdata; + u32 num; + + if (!np) + return NULL; + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return pdata; + + if (of_property_read_u32(np, bb-uvolt, num) == 0) + pdata-bb_uvolt = num; + if (of_property_read_u32(np, bb-uamp, num) == 0) + pdata-bb_uamp = num; + return pdata; +} +#else +static inline const struct twl4030_bci_platform_data * +twl4030_bci_parse_dt(struct device *dev) +{ + return NULL; +} +#endif + static int __init twl4030_bci_probe(struct platform_device *pdev) { struct twl4030_bci *bci; - struct twl4030_bci_platform_data *pdata = pdev-dev.platform_data; + const struct twl4030_bci_platform_data *pdata = pdev-dev.platform_data; int ret; u32 reg; @@ -506,6 +534,9 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) if (bci == NULL) return -ENOMEM; + if (!pdata) + pdata = twl4030_bci_parse_dt(pdev-dev); + bci-dev = pdev-dev; bci-irq_chg = platform_get_irq(pdev, 0); bci-irq_bci = platform_get_irq(pdev, 1); @@ -581,8 +612,11 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) twl4030_charger_enable_ac(true); twl4030_charger_enable_usb(bci, true); - twl4030_charger_enable_backup(pdata-bb_uvolt, - pdata-bb_uamp); + if (pdata) + twl4030_charger_enable_backup(pdata-bb_uvolt, + pdata-bb_uamp); + else + twl4030_charger_enable_backup(0, 0); return 0; @@ -631,10 +665,17 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id twl_bci_of_match[] = { + {.compatible = ti,twl4030-bci, }, + { } +}; +MODULE_DEVICE_TABLE(of, twl_bci_of_match); + static struct platform_driver twl4030_bci_driver = { .driver = { .name = twl4030_bci, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(twl_bci_of_match), }, .remove = __exit_p(twl4030_bci_remove), }; signature.asc Description: PGP signature