* [PATCH v2 0/5] BQ24190 devicetree config
@ 2017-08-07 19:54 Liam Breck
2017-08-07 19:54 ` [PATCH v2 1/5] power: bq24190_charger: Add ti,bq24192i to devicetree table Liam Breck
` (4 more replies)
0 siblings, 5 replies; 17+ messages in thread
From: Liam Breck @ 2017-08-07 19:54 UTC (permalink / raw)
To: Sebastian Reichel, linux-pm; +Cc: Tony Lindgren, Hans de Goede
Hi Sebastian, here is this series that was waiting on the power_supply_battery_info
patchset. Thanks!
Overview:
BQ24190 uses power_supply_battery_info fields for precharge & charge-termination
current and a DT property for system min voltage. A new DT binding documents these.
Changes in v2:
* new patch adds bq24192i to DT table
* dropped patches for power_supply precharge-current; they moved to bq27xxx series
* dropped patches for recently-applied fixes
* rebased to -next
Issues in v1:
* power_supply_prop_precharge & endcharge are added at end of enum to avoid sysfs breakage
* "Set bq24190-battery device .type=unknown" is a temporary workaround to be fixed in v2
Liam Breck (5):
power: bq24190_charger: Add ti,bq24192i to devicetree table
devicetree: power: Add docs for TI BQ24190 battery charger
power: bq24190_charger: Enable devicetree config
power: bq24190_charger: Add property system-minimum-microvolt
power: bq24190_charger: Add power_supply_battery_info support
.../devicetree/bindings/power/supply/bq24190.txt | 49 ++++++
drivers/power/supply/bq24190_charger.c | 177 ++++++++++++++++++---
2 files changed, 203 insertions(+), 23 deletions(-)
create mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt
--
2.13.2
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH v2 1/5] power: bq24190_charger: Add ti,bq24192i to devicetree table 2017-08-07 19:54 [PATCH v2 0/5] BQ24190 devicetree config Liam Breck @ 2017-08-07 19:54 ` Liam Breck 2017-08-25 20:28 ` Tony Lindgren 2017-08-07 19:54 ` [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger Liam Breck ` (3 subsequent siblings) 4 siblings, 1 reply; 17+ messages in thread From: Liam Breck @ 2017-08-07 19:54 UTC (permalink / raw) To: Sebastian Reichel, linux-pm; +Cc: Tony Lindgren, Hans de Goede, Liam Breck From: Liam Breck <kernel@networkimprov.net> bq24192i was previously only in ID table, so add it to DT table. Cc: Tony Lindgren <tony@atomide.com> Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Liam Breck <kernel@networkimprov.net> --- drivers/power/supply/bq24190_charger.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index 14199561..3340ffa2 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -1732,13 +1732,12 @@ MODULE_DEVICE_TABLE(i2c, bq24190_i2c_ids); #ifdef CONFIG_OF static const struct of_device_id bq24190_of_match[] = { { .compatible = "ti,bq24190", }, + { .compatible = "ti,bq24192i", }, { }, }; MODULE_DEVICE_TABLE(of, bq24190_of_match); #else -static const struct of_device_id bq24190_of_match[] = { - { }, -}; +static const struct of_device_id bq24190_of_match[] = { {} }; #endif static struct i2c_driver bq24190_driver = { -- 2.13.2 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v2 1/5] power: bq24190_charger: Add ti,bq24192i to devicetree table 2017-08-07 19:54 ` [PATCH v2 1/5] power: bq24190_charger: Add ti,bq24192i to devicetree table Liam Breck @ 2017-08-25 20:28 ` Tony Lindgren 0 siblings, 0 replies; 17+ messages in thread From: Tony Lindgren @ 2017-08-25 20:28 UTC (permalink / raw) To: Liam Breck; +Cc: Sebastian Reichel, linux-pm, Hans de Goede, Liam Breck * Liam Breck <liam@networkimprov.net> [170807 12:55]: > From: Liam Breck <kernel@networkimprov.net> > --- a/drivers/power/supply/bq24190_charger.c > +++ b/drivers/power/supply/bq24190_charger.c > #else > -static const struct of_device_id bq24190_of_match[] = { > - { }, > -}; > +static const struct of_device_id bq24190_of_match[] = { {} }; > #endif Maybe check what checkpatch says about this one? It might actually prefer what we have now. You should also mention it in the commit message or just drop that change as people could complain it's an unrelated change. Regards, Tony ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger 2017-08-07 19:54 [PATCH v2 0/5] BQ24190 devicetree config Liam Breck 2017-08-07 19:54 ` [PATCH v2 1/5] power: bq24190_charger: Add ti,bq24192i to devicetree table Liam Breck @ 2017-08-07 19:54 ` Liam Breck [not found] ` <20170807195420.20767-3-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> 2017-08-07 19:54 ` [PATCH v2 3/5] power: bq24190_charger: Enable devicetree config Liam Breck ` (2 subsequent siblings) 4 siblings, 1 reply; 17+ messages in thread From: Liam Breck @ 2017-08-07 19:54 UTC (permalink / raw) To: Sebastian Reichel, linux-pm Cc: Tony Lindgren, Hans de Goede, Rob Herring, devicetree, Liam Breck From: Liam Breck <kernel@networkimprov.net> Document monitored-battery and ti,system-minimum-microvolt properties. Cc: Rob Herring <robh@kernel.org> Cc: devicetree@vger.kernel.org Signed-off-by: Liam Breck <kernel@networkimprov.net> --- .../devicetree/bindings/power/supply/bq24190.txt | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt new file mode 100644 index 00000000..82a1c842 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt @@ -0,0 +1,49 @@ +TI BQ24190 Li-Ion Battery Charger + +Required properties: +- compatible: contains one of the following: + * "ti,bq24190" + * "ti,bq24192i" +- reg: integer, I2C address of the charger. +- interrupts[-extended]: configuration for charger INT pin. + +Optional properties: +- monitored-battery: phandle of battery characteristics devicetree node + The charger uses the following battery properties: + + precharge-current-microamp: maximum charge current during precharge + phase (typically 20% of battery capacity). + + charge-term-current-microamp: a charge cycle terminates when the + battery voltage is above recharge threshold, and the current is below + this setting (typically 10% of battery capacity). + See Documentation/devicetree/bindings/power/supply/battery.txt +- ti,system-minimum-microvolt: when power is connected and the battery is below + minimum system voltage, the system will be regulated above this setting. + +Other features: +- Use gpio-hog to set the OTG pin high to enable 500mA charge current on USB SDP port. + +Example: + + bat: battery { + compatible = "simple-battery"; + precharge-current-microamp = <256000>; + charge-term-current-microamp = <128000>; + // etc. + }; + + bq24190: charger@6a { + compatible = "ti,bq24190"; + reg = <0x6a>; + interrupts-extended = <&gpiochip 10 IRQ_TYPE_EDGE_FALLING>; + monitored-battery = <&bat>; + ti,system-minimum-microvolt = <3200000>; + }; + + &twl_gpio { + otg { + gpio-hog; + gpios = <6 0>; + output-high; + line-name = "otg-gpio"; + }; + }; -- 2.13.2 ^ permalink raw reply related [flat|nested] 17+ messages in thread
[parent not found: <20170807195420.20767-3-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org>]
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger [not found] ` <20170807195420.20767-3-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> @ 2017-08-11 2:50 ` Rob Herring 2017-08-11 21:57 ` Liam Breck 0 siblings, 1 reply; 17+ messages in thread From: Rob Herring @ 2017-08-11 2:50 UTC (permalink / raw) To: Liam Breck Cc: Sebastian Reichel, linux-pm-u79uwXL29TY76Z2rM5mHXA, Tony Lindgren, Hans de Goede, devicetree-u79uwXL29TY76Z2rM5mHXA, Liam Breck On Mon, Aug 07, 2017 at 12:54:17PM -0700, Liam Breck wrote: > From: Liam Breck <kernel-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> > > Document monitored-battery and ti,system-minimum-microvolt properties. > > Cc: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > Signed-off-by: Liam Breck <kernel-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> > --- > .../devicetree/bindings/power/supply/bq24190.txt | 49 ++++++++++++++++++++++ > 1 file changed, 49 insertions(+) > create mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt > > diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt > new file mode 100644 > index 00000000..82a1c842 > --- /dev/null > +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt > @@ -0,0 +1,49 @@ > +TI BQ24190 Li-Ion Battery Charger > + > +Required properties: > +- compatible: contains one of the following: > + * "ti,bq24190" > + * "ti,bq24192i" > +- reg: integer, I2C address of the charger. > +- interrupts[-extended]: configuration for charger INT pin. > + > +Optional properties: > +- monitored-battery: phandle of battery characteristics devicetree node > + The charger uses the following battery properties: > + + precharge-current-microamp: maximum charge current during precharge > + phase (typically 20% of battery capacity). > + + charge-term-current-microamp: a charge cycle terminates when the > + battery voltage is above recharge threshold, and the current is below > + this setting (typically 10% of battery capacity). > + See Documentation/devicetree/bindings/power/supply/battery.txt > +- ti,system-minimum-microvolt: when power is connected and the battery is below > + minimum system voltage, the system will be regulated above this setting. > + > +Other features: > +- Use gpio-hog to set the OTG pin high to enable 500mA charge current on USB SDP port. Why doesn't the charger driver control this? > + > +Example: > + > + bat: battery { > + compatible = "simple-battery"; > + precharge-current-microamp = <256000>; > + charge-term-current-microamp = <128000>; > + // etc. > + }; > + > + bq24190: charger@6a { > + compatible = "ti,bq24190"; > + reg = <0x6a>; > + interrupts-extended = <&gpiochip 10 IRQ_TYPE_EDGE_FALLING>; > + monitored-battery = <&bat>; > + ti,system-minimum-microvolt = <3200000>; > + }; > + > + &twl_gpio { > + otg { > + gpio-hog; > + gpios = <6 0>; > + output-high; > + line-name = "otg-gpio"; > + }; > + }; > -- > 2.13.2 > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger 2017-08-11 2:50 ` Rob Herring @ 2017-08-11 21:57 ` Liam Breck 2017-08-12 16:42 ` Sebastian Reichel 0 siblings, 1 reply; 17+ messages in thread From: Liam Breck @ 2017-08-11 21:57 UTC (permalink / raw) To: Rob Herring Cc: Sebastian Reichel, linux-pm, Tony Lindgren, Hans de Goede, devicetree, Liam Breck Hi Rob, On Thu, Aug 10, 2017 at 7:50 PM, Rob Herring <robh@kernel.org> wrote: > On Mon, Aug 07, 2017 at 12:54:17PM -0700, Liam Breck wrote: >> From: Liam Breck <kernel@networkimprov.net> >> >> Document monitored-battery and ti,system-minimum-microvolt properties. >> >> Cc: Rob Herring <robh@kernel.org> >> Cc: devicetree@vger.kernel.org >> Signed-off-by: Liam Breck <kernel@networkimprov.net> >> --- >> .../devicetree/bindings/power/supply/bq24190.txt | 49 ++++++++++++++++++++++ >> 1 file changed, 49 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt >> >> diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt >> new file mode 100644 >> index 00000000..82a1c842 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt >> @@ -0,0 +1,49 @@ >> +TI BQ24190 Li-Ion Battery Charger >> + >> +Required properties: >> +- compatible: contains one of the following: >> + * "ti,bq24190" >> + * "ti,bq24192i" >> +- reg: integer, I2C address of the charger. >> +- interrupts[-extended]: configuration for charger INT pin. >> + >> +Optional properties: >> +- monitored-battery: phandle of battery characteristics devicetree node >> + The charger uses the following battery properties: >> + + precharge-current-microamp: maximum charge current during precharge >> + phase (typically 20% of battery capacity). >> + + charge-term-current-microamp: a charge cycle terminates when the >> + battery voltage is above recharge threshold, and the current is below >> + this setting (typically 10% of battery capacity). >> + See Documentation/devicetree/bindings/power/supply/battery.txt >> +- ti,system-minimum-microvolt: when power is connected and the battery is below >> + minimum system voltage, the system will be regulated above this setting. >> + >> +Other features: >> +- Use gpio-hog to set the OTG pin high to enable 500mA charge current on USB SDP port. > > Why doesn't the charger driver control this? This pin/gpio has to be high when USB is plugged in to make the charger chip negotiate 500mA from a SDP port. It should generally be configured that way even if the driver is not loaded, as the chip does not require a driver to function. Some boards may do that with a pull-up. Also the user may want to change this via sysfs and not have the driver "fix" it. >> + >> +Example: >> + >> + bat: battery { >> + compatible = "simple-battery"; >> + precharge-current-microamp = <256000>; >> + charge-term-current-microamp = <128000>; >> + // etc. >> + }; >> + >> + bq24190: charger@6a { >> + compatible = "ti,bq24190"; >> + reg = <0x6a>; >> + interrupts-extended = <&gpiochip 10 IRQ_TYPE_EDGE_FALLING>; >> + monitored-battery = <&bat>; >> + ti,system-minimum-microvolt = <3200000>; >> + }; >> + >> + &twl_gpio { >> + otg { >> + gpio-hog; >> + gpios = <6 0>; >> + output-high; >> + line-name = "otg-gpio"; >> + }; >> + }; >> -- >> 2.13.2 >> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger 2017-08-11 21:57 ` Liam Breck @ 2017-08-12 16:42 ` Sebastian Reichel 2017-08-12 19:00 ` Liam Breck 0 siblings, 1 reply; 17+ messages in thread From: Sebastian Reichel @ 2017-08-12 16:42 UTC (permalink / raw) To: Liam Breck Cc: Rob Herring, linux-pm, Tony Lindgren, Hans de Goede, devicetree, Liam Breck [-- Attachment #1: Type: text/plain, Size: 2816 bytes --] Hi, On Fri, Aug 11, 2017 at 02:57:10PM -0700, Liam Breck wrote: > On Thu, Aug 10, 2017 at 7:50 PM, Rob Herring <robh@kernel.org> wrote: > > On Mon, Aug 07, 2017 at 12:54:17PM -0700, Liam Breck wrote: > >> From: Liam Breck <kernel@networkimprov.net> > >> > >> Document monitored-battery and ti,system-minimum-microvolt properties. > >> > >> Cc: Rob Herring <robh@kernel.org> > >> Cc: devicetree@vger.kernel.org > >> Signed-off-by: Liam Breck <kernel@networkimprov.net> > >> --- > >> .../devicetree/bindings/power/supply/bq24190.txt | 49 ++++++++++++++++++++++ > >> 1 file changed, 49 insertions(+) > >> create mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt > >> > >> diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt > >> new file mode 100644 > >> index 00000000..82a1c842 > >> --- /dev/null > >> +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt > >> @@ -0,0 +1,49 @@ > >> +TI BQ24190 Li-Ion Battery Charger > >> + > >> +Required properties: > >> +- compatible: contains one of the following: > >> + * "ti,bq24190" > >> + * "ti,bq24192i" > >> +- reg: integer, I2C address of the charger. > >> +- interrupts[-extended]: configuration for charger INT pin. > >> + > >> +Optional properties: > >> +- monitored-battery: phandle of battery characteristics devicetree node > >> + The charger uses the following battery properties: > >> + + precharge-current-microamp: maximum charge current during precharge > >> + phase (typically 20% of battery capacity). > >> + + charge-term-current-microamp: a charge cycle terminates when the > >> + battery voltage is above recharge threshold, and the current is below > >> + this setting (typically 10% of battery capacity). > >> + See Documentation/devicetree/bindings/power/supply/battery.txt > >> +- ti,system-minimum-microvolt: when power is connected and the battery is below > >> + minimum system voltage, the system will be regulated above this setting. > >> + > >> +Other features: > >> +- Use gpio-hog to set the OTG pin high to enable 500mA charge current on USB SDP port. > > > > Why doesn't the charger driver control this? > > This pin/gpio has to be high when USB is plugged in to make the > charger chip negotiate 500mA from a SDP port. It should generally be > configured that way even if the driver is not loaded, as the chip does > not require a driver to function. Some boards may do that with a > pull-up. Also the user may want to change this via sysfs and not have > the driver "fix" it. drivers/power/supply/qcom_smbb.c exposes the otg feature as regulator. I think in this case it could be exposed as gpio-regulator. -- Sebastian [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger 2017-08-12 16:42 ` Sebastian Reichel @ 2017-08-12 19:00 ` Liam Breck [not found] ` <CAKvHMgR+GxSqhy+iwdYmku2600HzoF__oXV7_w72ZJg-aK7O-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 17+ messages in thread From: Liam Breck @ 2017-08-12 19:00 UTC (permalink / raw) To: Sebastian Reichel Cc: Rob Herring, linux-pm-u79uwXL29TY76Z2rM5mHXA, Tony Lindgren, Hans de Goede, devicetree-u79uwXL29TY76Z2rM5mHXA, Liam Breck Hi Sebastian, On Sat, Aug 12, 2017 at 9:42 AM, Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote: > Hi, > > On Fri, Aug 11, 2017 at 02:57:10PM -0700, Liam Breck wrote: >> On Thu, Aug 10, 2017 at 7:50 PM, Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote: >> > On Mon, Aug 07, 2017 at 12:54:17PM -0700, Liam Breck wrote: >> >> From: Liam Breck <kernel-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> >> >> >> >> Document monitored-battery and ti,system-minimum-microvolt properties. >> >> >> >> Cc: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> >> >> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org >> >> Signed-off-by: Liam Breck <kernel-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> >> >> --- >> >> .../devicetree/bindings/power/supply/bq24190.txt | 49 ++++++++++++++++++++++ >> >> 1 file changed, 49 insertions(+) >> >> create mode 100644 Documentation/devicetree/bindings/power/supply/bq24190.txt >> >> >> >> diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt >> >> new file mode 100644 >> >> index 00000000..82a1c842 >> >> --- /dev/null >> >> +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt >> >> @@ -0,0 +1,49 @@ >> >> +TI BQ24190 Li-Ion Battery Charger >> >> + >> >> +Required properties: >> >> +- compatible: contains one of the following: >> >> + * "ti,bq24190" >> >> + * "ti,bq24192i" >> >> +- reg: integer, I2C address of the charger. >> >> +- interrupts[-extended]: configuration for charger INT pin. >> >> + >> >> +Optional properties: >> >> +- monitored-battery: phandle of battery characteristics devicetree node >> >> + The charger uses the following battery properties: >> >> + + precharge-current-microamp: maximum charge current during precharge >> >> + phase (typically 20% of battery capacity). >> >> + + charge-term-current-microamp: a charge cycle terminates when the >> >> + battery voltage is above recharge threshold, and the current is below >> >> + this setting (typically 10% of battery capacity). >> >> + See Documentation/devicetree/bindings/power/supply/battery.txt >> >> +- ti,system-minimum-microvolt: when power is connected and the battery is below >> >> + minimum system voltage, the system will be regulated above this setting. >> >> + >> >> +Other features: >> >> +- Use gpio-hog to set the OTG pin high to enable 500mA charge current on USB SDP port. >> > >> > Why doesn't the charger driver control this? >> >> This pin/gpio has to be high when USB is plugged in to make the >> charger chip negotiate 500mA from a SDP port. It should generally be >> configured that way even if the driver is not loaded, as the chip does >> not require a driver to function. Some boards may do that with a >> pull-up. Also the user may want to change this via sysfs and not have >> the driver "fix" it. > > drivers/power/supply/qcom_smbb.c exposes the otg feature as > regulator. I think in this case it could be exposed as > gpio-regulator. Hans is doing that here: https://patchwork.kernel.org/patch/9883717/ The datasheet labels one pin "OTG" but that's misleading; it really enables negotiation of 500mA input current, but does not turn on OTG mode. If this pin is low, it only prevents the driver from starting OTG mode via I2C msg. Tony & Matt & I discussed this at some length off-list. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <CAKvHMgR+GxSqhy+iwdYmku2600HzoF__oXV7_w72ZJg-aK7O-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger [not found] ` <CAKvHMgR+GxSqhy+iwdYmku2600HzoF__oXV7_w72ZJg-aK7O-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2017-08-16 15:47 ` Tony Lindgren 2017-08-16 20:11 ` Liam Breck 0 siblings, 1 reply; 17+ messages in thread From: Tony Lindgren @ 2017-08-16 15:47 UTC (permalink / raw) To: Liam Breck Cc: Sebastian Reichel, Rob Herring, linux-pm-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, devicetree-u79uwXL29TY76Z2rM5mHXA, Liam Breck * Liam Breck <liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> [170812 12:00]: > On Sat, Aug 12, 2017 at 9:42 AM, Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote: > > On Fri, Aug 11, 2017 at 02:57:10PM -0700, Liam Breck wrote: > >> >> +Other features: > >> >> +- Use gpio-hog to set the OTG pin high to enable 500mA charge current on USB SDP port. > >> > > >> > Why doesn't the charger driver control this? > >> > >> This pin/gpio has to be high when USB is plugged in to make the > >> charger chip negotiate 500mA from a SDP port. It should generally be > >> configured that way even if the driver is not loaded, as the chip does > >> not require a driver to function. Some boards may do that with a > >> pull-up. Also the user may want to change this via sysfs and not have > >> the driver "fix" it. > > > > drivers/power/supply/qcom_smbb.c exposes the otg feature as > > regulator. I think in this case it could be exposed as > > gpio-regulator. > > Hans is doing that here: > https://patchwork.kernel.org/patch/9883717/ > > The datasheet labels one pin "OTG" but that's misleading; it really > enables negotiation of 500mA input current, but does not turn on OTG > mode. If this pin is low, it only prevents the driver from starting > OTG mode via I2C msg. Yeah so before the device has enumerated this pin keeps the max current at 100mA as required by the USB spec. This pin should be only toggled after enumerating in bootloader or by the kernel driver. I tink the USB PHY driver can also be wired to control this line. Probably best to set it up as just a GPIO that the bq24190 driver controls optionally. Then later on we should have some Linux generic way for USB gadget subsystem to tell the charger that we have enumerated, and then bq24190 driver can toggle this GPIO to enable higher charge rates. Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger 2017-08-16 15:47 ` Tony Lindgren @ 2017-08-16 20:11 ` Liam Breck [not found] ` <CAKvHMgTvVMsvmyi0o89m1SfS9A4U1GbNuU05Tkt6C0ARR9NyWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 17+ messages in thread From: Liam Breck @ 2017-08-16 20:11 UTC (permalink / raw) To: Tony Lindgren Cc: Sebastian Reichel, Rob Herring, linux-pm, Hans de Goede, devicetree, Liam Breck On Wed, Aug 16, 2017 at 8:47 AM, Tony Lindgren <tony@atomide.com> wrote: > * Liam Breck <liam@networkimprov.net> [170812 12:00]: >> On Sat, Aug 12, 2017 at 9:42 AM, Sebastian Reichel <sre@kernel.org> wrote: >> > On Fri, Aug 11, 2017 at 02:57:10PM -0700, Liam Breck wrote: >> >> >> +Other features: >> >> >> +- Use gpio-hog to set the OTG pin high to enable 500mA charge current on USB SDP port. >> >> > >> >> > Why doesn't the charger driver control this? >> >> >> >> This pin/gpio has to be high when USB is plugged in to make the >> >> charger chip negotiate 500mA from a SDP port. It should generally be >> >> configured that way even if the driver is not loaded, as the chip does >> >> not require a driver to function. Some boards may do that with a >> >> pull-up. Also the user may want to change this via sysfs and not have >> >> the driver "fix" it. >> > >> > drivers/power/supply/qcom_smbb.c exposes the otg feature as >> > regulator. I think in this case it could be exposed as >> > gpio-regulator. >> >> Hans is doing that here: >> https://patchwork.kernel.org/patch/9883717/ >> >> The datasheet labels one pin "OTG" but that's misleading; it really >> enables negotiation of 500mA input current, but does not turn on OTG >> mode. If this pin is low, it only prevents the driver from starting >> OTG mode via I2C msg. > > Yeah so before the device has enumerated this pin keeps the > max current at 100mA as required by the USB spec. This pin > should be only toggled after enumerating in bootloader or > by the kernel driver. I tink the USB PHY driver can also > be wired to control this line. > > Probably best to set it up as just a GPIO that the bq24190 > driver controls optionally. > > Then later on we should have some Linux generic way for > USB gadget subsystem to tell the charger that we have > enumerated, and then bq24190 driver can toggle this GPIO > to enable higher charge rates. I discovered a few months ago that setting this pin high after USB connect has NO effect on iinlim. It has to be high at connect to auto-negotiate 500mA. There is no point in making the driver control this pin; we already tried that. Here we are just documenting how the DT can enable this pin via gpio-hog. I believe the only way to defer 500mA negotiation is to leave this pin off and set iinlim via I2C msg to chip. We can do that in a gadget script via sysfs input_current_limit. Hans does not have to enable this pin to start OTG-host on his x86 device, perhaps because it is wired high there. Our script can set the linked gpio high if nec for OTG-host. ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <CAKvHMgTvVMsvmyi0o89m1SfS9A4U1GbNuU05Tkt6C0ARR9NyWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger [not found] ` <CAKvHMgTvVMsvmyi0o89m1SfS9A4U1GbNuU05Tkt6C0ARR9NyWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2017-08-16 21:06 ` Tony Lindgren 2017-08-16 21:16 ` Liam Breck 0 siblings, 1 reply; 17+ messages in thread From: Tony Lindgren @ 2017-08-16 21:06 UTC (permalink / raw) To: Liam Breck Cc: Sebastian Reichel, Rob Herring, linux-pm-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, devicetree-u79uwXL29TY76Z2rM5mHXA, Liam Breck * Liam Breck <liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> [170816 13:11]: > On Wed, Aug 16, 2017 at 8:47 AM, Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> wrote: > > * Liam Breck <liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> [170812 12:00]: > >> On Sat, Aug 12, 2017 at 9:42 AM, Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote: > >> > On Fri, Aug 11, 2017 at 02:57:10PM -0700, Liam Breck wrote: > >> >> >> +Other features: > >> >> >> +- Use gpio-hog to set the OTG pin high to enable 500mA charge current on USB SDP port. > >> >> > > >> >> > Why doesn't the charger driver control this? > >> >> > >> >> This pin/gpio has to be high when USB is plugged in to make the > >> >> charger chip negotiate 500mA from a SDP port. It should generally be > >> >> configured that way even if the driver is not loaded, as the chip does > >> >> not require a driver to function. Some boards may do that with a > >> >> pull-up. Also the user may want to change this via sysfs and not have > >> >> the driver "fix" it. > >> > > >> > drivers/power/supply/qcom_smbb.c exposes the otg feature as > >> > regulator. I think in this case it could be exposed as > >> > gpio-regulator. > >> > >> Hans is doing that here: > >> https://patchwork.kernel.org/patch/9883717/ > >> > >> The datasheet labels one pin "OTG" but that's misleading; it really > >> enables negotiation of 500mA input current, but does not turn on OTG > >> mode. If this pin is low, it only prevents the driver from starting > >> OTG mode via I2C msg. > > > > Yeah so before the device has enumerated this pin keeps the > > max current at 100mA as required by the USB spec. This pin > > should be only toggled after enumerating in bootloader or > > by the kernel driver. I tink the USB PHY driver can also > > be wired to control this line. > > > > Probably best to set it up as just a GPIO that the bq24190 > > driver controls optionally. > > > > Then later on we should have some Linux generic way for > > USB gadget subsystem to tell the charger that we have > > enumerated, and then bq24190 driver can toggle this GPIO > > to enable higher charge rates. > > I discovered a few months ago that setting this pin high after USB > connect has NO effect on iinlim. It has to be high at connect to > auto-negotiate 500mA. There is no point in making the driver control > this pin; we already tried that. > > Here we are just documenting how the DT can enable this pin via gpio-hog. Or in bootloader. Yeah this is mostly for completely empty battery to start charging at 100mA until bootloader can start and enable higher rates. > I believe the only way to defer 500mA negotiation is to leave this pin > off and set iinlim via I2C msg to chip. We can do that in a gadget > script via sysfs input_current_limit. Hans does not have to enable > this pin to start OTG-host on his x86 device, perhaps because it is > wired high there. Our script can set the linked gpio high if nec for > OTG-host. Yeah once something is running? If the kernel does not need to do anything about it, how about just leave it out of the binding docs then? Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger 2017-08-16 21:06 ` Tony Lindgren @ 2017-08-16 21:16 ` Liam Breck [not found] ` <CAKvHMgTJjTxffoP4Kt=KzGvCQ-BihLeQn3i4TaF4OBSXV7i6TA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 17+ messages in thread From: Liam Breck @ 2017-08-16 21:16 UTC (permalink / raw) To: Tony Lindgren Cc: Sebastian Reichel, Rob Herring, linux-pm, Hans de Goede, devicetree, Liam Breck On Wed, Aug 16, 2017 at 2:06 PM, Tony Lindgren <tony@atomide.com> wrote: > * Liam Breck <liam@networkimprov.net> [170816 13:11]: >> On Wed, Aug 16, 2017 at 8:47 AM, Tony Lindgren <tony@atomide.com> wrote: >> > * Liam Breck <liam@networkimprov.net> [170812 12:00]: >> >> On Sat, Aug 12, 2017 at 9:42 AM, Sebastian Reichel <sre@kernel.org> wrote: >> >> > On Fri, Aug 11, 2017 at 02:57:10PM -0700, Liam Breck wrote: >> >> >> >> +Other features: >> >> >> >> +- Use gpio-hog to set the OTG pin high to enable 500mA charge current on USB SDP port. >> >> >> > >> >> >> > Why doesn't the charger driver control this? >> >> >> >> >> >> This pin/gpio has to be high when USB is plugged in to make the >> >> >> charger chip negotiate 500mA from a SDP port. It should generally be >> >> >> configured that way even if the driver is not loaded, as the chip does >> >> >> not require a driver to function. Some boards may do that with a >> >> >> pull-up. Also the user may want to change this via sysfs and not have >> >> >> the driver "fix" it. >> >> > >> >> > drivers/power/supply/qcom_smbb.c exposes the otg feature as >> >> > regulator. I think in this case it could be exposed as >> >> > gpio-regulator. >> >> >> >> Hans is doing that here: >> >> https://patchwork.kernel.org/patch/9883717/ >> >> >> >> The datasheet labels one pin "OTG" but that's misleading; it really >> >> enables negotiation of 500mA input current, but does not turn on OTG >> >> mode. If this pin is low, it only prevents the driver from starting >> >> OTG mode via I2C msg. >> > >> > Yeah so before the device has enumerated this pin keeps the >> > max current at 100mA as required by the USB spec. This pin >> > should be only toggled after enumerating in bootloader or >> > by the kernel driver. I tink the USB PHY driver can also >> > be wired to control this line. >> > >> > Probably best to set it up as just a GPIO that the bq24190 >> > driver controls optionally. >> > >> > Then later on we should have some Linux generic way for >> > USB gadget subsystem to tell the charger that we have >> > enumerated, and then bq24190 driver can toggle this GPIO >> > to enable higher charge rates. >> >> I discovered a few months ago that setting this pin high after USB >> connect has NO effect on iinlim. It has to be high at connect to >> auto-negotiate 500mA. There is no point in making the driver control >> this pin; we already tried that. >> >> Here we are just documenting how the DT can enable this pin via gpio-hog. > > Or in bootloader. Yeah this is mostly for completely empty > battery to start charging at 100mA until bootloader can start > and enable higher rates. > >> I believe the only way to defer 500mA negotiation is to leave this pin >> off and set iinlim via I2C msg to chip. We can do that in a gadget >> script via sysfs input_current_limit. Hans does not have to enable >> this pin to start OTG-host on his x86 device, perhaps because it is >> wired high there. Our script can set the linked gpio high if nec for >> OTG-host. > > Yeah once something is running? I haven't tried OTG-host on the anvl yet since it requires a special cable. > If the kernel does not need to do anything about it, how about > just leave it out of the binding docs then? It seemed useful to document the OTG pin DT config for boards that have it wired to a gpio... Is that not wise? ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <CAKvHMgTJjTxffoP4Kt=KzGvCQ-BihLeQn3i4TaF4OBSXV7i6TA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger [not found] ` <CAKvHMgTJjTxffoP4Kt=KzGvCQ-BihLeQn3i4TaF4OBSXV7i6TA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2017-08-18 0:16 ` Tony Lindgren 2017-08-25 20:29 ` Tony Lindgren 1 sibling, 0 replies; 17+ messages in thread From: Tony Lindgren @ 2017-08-18 0:16 UTC (permalink / raw) To: Liam Breck Cc: Sebastian Reichel, Rob Herring, linux-pm-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, devicetree-u79uwXL29TY76Z2rM5mHXA, Liam Breck * Liam Breck <liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> [170816 14:16]: > On Wed, Aug 16, 2017 at 2:06 PM, Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> wrote: > > > If the kernel does not need to do anything about it, how about > > just leave it out of the binding docs then? > > It seemed useful to document the OTG pin DT config for boards that > have it wired to a gpio... Is that not wise? Well maybe just add a comment to the driver about it until we know how we want to handle it? Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger [not found] ` <CAKvHMgTJjTxffoP4Kt=KzGvCQ-BihLeQn3i4TaF4OBSXV7i6TA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2017-08-18 0:16 ` Tony Lindgren @ 2017-08-25 20:29 ` Tony Lindgren 1 sibling, 0 replies; 17+ messages in thread From: Tony Lindgren @ 2017-08-25 20:29 UTC (permalink / raw) To: Liam Breck Cc: Sebastian Reichel, Rob Herring, linux-pm-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, devicetree-u79uwXL29TY76Z2rM5mHXA, Liam Breck * Liam Breck <liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org> [170816 14:16]: > On Wed, Aug 16, 2017 at 2:06 PM, Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> wrote: > > If the kernel does not need to do anything about it, how about > > just leave it out of the binding docs then? > > It seemed useful to document the OTG pin DT config for boards that > have it wired to a gpio... Is that not wise? Well maybe add it as a note to the description rather than a binding. It might be actually best to document it in both places. Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 3/5] power: bq24190_charger: Enable devicetree config 2017-08-07 19:54 [PATCH v2 0/5] BQ24190 devicetree config Liam Breck 2017-08-07 19:54 ` [PATCH v2 1/5] power: bq24190_charger: Add ti,bq24192i to devicetree table Liam Breck 2017-08-07 19:54 ` [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger Liam Breck @ 2017-08-07 19:54 ` Liam Breck 2017-08-07 19:54 ` [PATCH v2 4/5] power: bq24190_charger: Add property system-minimum-microvolt Liam Breck 2017-08-07 19:54 ` [PATCH v2 5/5] power: bq24190_charger: Add power_supply_battery_info support Liam Breck 4 siblings, 0 replies; 17+ messages in thread From: Liam Breck @ 2017-08-07 19:54 UTC (permalink / raw) To: Sebastian Reichel, linux-pm; +Cc: Tony Lindgren, Hans de Goede, Liam Breck From: Liam Breck <kernel@networkimprov.net> Add get_config(). Rename set_mode_host() to set_config(). Call get_config() and hw_init() after power_supply_register(). No functional changes. Cc: Tony Lindgren <tony@atomide.com> Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Liam Breck <kernel@networkimprov.net> --- drivers/power/supply/bq24190_charger.c | 63 +++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index 3340ffa2..2ab580bf 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -504,15 +504,7 @@ static int bq24190_sysfs_create_group(struct bq24190_dev_info *bdi) static inline void bq24190_sysfs_remove_group(struct bq24190_dev_info *bdi) {} #endif -/* - * According to the "Host Mode and default Mode" section of the - * manual, a write to any register causes the bq24190 to switch - * from default mode to host mode. It will switch back to default - * mode after a WDT timeout unless the WDT is turned off as well. - * So, by simply turning off the WDT, we accomplish both with the - * same write. - */ -static int bq24190_set_mode_host(struct bq24190_dev_info *bdi) +static int bq24190_set_config(struct bq24190_dev_info *bdi) { int ret; u8 v; @@ -523,9 +515,22 @@ static int bq24190_set_mode_host(struct bq24190_dev_info *bdi) bdi->watchdog = ((v & BQ24190_REG_CTTC_WATCHDOG_MASK) >> BQ24190_REG_CTTC_WATCHDOG_SHIFT); + + /* + * According to the "Host Mode and default Mode" section of the + * manual, a write to any register causes the bq24190 to switch + * from default mode to host mode. It will switch back to default + * mode after a WDT timeout unless the WDT is turned off as well. + * So, by simply turning off the WDT, we accomplish both with the + * same write. + */ v &= ~BQ24190_REG_CTTC_WATCHDOG_MASK; - return bq24190_write(bdi, BQ24190_REG_CTTC, v); + ret = bq24190_write(bdi, BQ24190_REG_CTTC, v); + if (ret < 0) + return ret; + + return 0; } static int bq24190_register_reset(struct bq24190_dev_info *bdi) @@ -1456,13 +1461,25 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi) if (ret < 0) return ret; - ret = bq24190_set_mode_host(bdi); + ret = bq24190_set_config(bdi); if (ret < 0) return ret; return bq24190_read(bdi, BQ24190_REG_SS, &bdi->ss_reg); } +static int bq24190_get_config(struct bq24190_dev_info *bdi) +{ +#ifdef CONFIG_OF + int v; + + if (!bdi->dev->of_node) + return -EINVAL; + +#endif + return 0; +} + static int bq24190_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1493,7 +1510,7 @@ static int bq24190_probe(struct i2c_client *client, i2c_set_clientdata(client, bdi); - if (!client->irq) { + if (client->irq <= 0) { dev_err(dev, "Can't get irq info\n"); return -EINVAL; } @@ -1526,12 +1543,6 @@ static int bq24190_probe(struct i2c_client *client, goto out_pmrt; } - ret = bq24190_hw_init(bdi); - if (ret < 0) { - dev_err(dev, "Hardware init failed\n"); - goto out_pmrt; - } - charger_cfg.drv_data = bdi; charger_cfg.supplied_to = bq24190_charger_supplied_to; charger_cfg.num_supplicants = ARRAY_SIZE(bq24190_charger_supplied_to), @@ -1556,8 +1567,20 @@ static int bq24190_probe(struct i2c_client *client, } } + ret = bq24190_get_config(bdi); + if (ret < 0) { + dev_err(dev, "Can't get devicetree config\n"); + goto out_charger; + } + + ret = bq24190_hw_init(bdi); + if (ret < 0) { + dev_err(dev, "Hardware init failed\n"); + goto out_charger; + } + ret = bq24190_sysfs_create_group(bdi); - if (ret) { + if (ret < 0) { dev_err(dev, "Can't create sysfs entries\n"); goto out_charger; } @@ -1700,7 +1723,7 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev) } bq24190_register_reset(bdi); - bq24190_set_mode_host(bdi); + bq24190_set_config(bdi); bq24190_read(bdi, BQ24190_REG_SS, &bdi->ss_reg); if (error >= 0) { -- 2.13.2 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 4/5] power: bq24190_charger: Add property system-minimum-microvolt 2017-08-07 19:54 [PATCH v2 0/5] BQ24190 devicetree config Liam Breck ` (2 preceding siblings ...) 2017-08-07 19:54 ` [PATCH v2 3/5] power: bq24190_charger: Enable devicetree config Liam Breck @ 2017-08-07 19:54 ` Liam Breck 2017-08-07 19:54 ` [PATCH v2 5/5] power: bq24190_charger: Add power_supply_battery_info support Liam Breck 4 siblings, 0 replies; 17+ messages in thread From: Liam Breck @ 2017-08-07 19:54 UTC (permalink / raw) To: Sebastian Reichel, linux-pm; +Cc: Tony Lindgren, Hans de Goede, Liam Breck From: Liam Breck <kernel@networkimprov.net> Set minimum system voltage limit obtained from device property. Cc: Tony Lindgren <tony@atomide.com> Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Liam Breck <kernel@networkimprov.net> --- drivers/power/supply/bq24190_charger.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index 2ab580bf..f20d2c68 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -43,6 +43,8 @@ #define BQ24190_REG_POC_CHG_CONFIG_OTG 0x2 #define BQ24190_REG_POC_SYS_MIN_MASK (BIT(3) | BIT(2) | BIT(1)) #define BQ24190_REG_POC_SYS_MIN_SHIFT 1 +#define BQ24190_REG_POC_SYS_MIN_MIN 3000 +#define BQ24190_REG_POC_SYS_MIN_MAX 3700 #define BQ24190_REG_POC_BOOST_LIM_MASK BIT(0) #define BQ24190_REG_POC_BOOST_LIM_SHIFT 0 @@ -159,6 +161,7 @@ struct bq24190_dev_info { char model_name[I2C_NAME_SIZE]; bool initialized; bool irq_event; + u16 sys_min; struct mutex f_reg_lock; u8 f_reg; u8 ss_reg; @@ -530,6 +533,16 @@ static int bq24190_set_config(struct bq24190_dev_info *bdi) if (ret < 0) return ret; + if (bdi->sys_min) { + v = bdi->sys_min / 100 - 30; // manual section 9.5.1.2, table 9 + ret = bq24190_write_mask(bdi, BQ24190_REG_POC, + BQ24190_REG_POC_SYS_MIN_MASK, + BQ24190_REG_POC_SYS_MIN_SHIFT, + v); + if (ret < 0) + return ret; + } + return 0; } @@ -1471,11 +1484,21 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi) static int bq24190_get_config(struct bq24190_dev_info *bdi) { #ifdef CONFIG_OF + const char * const s = "ti,system-minimum-microvolt"; int v; if (!bdi->dev->of_node) return -EINVAL; + if (device_property_read_u32(bdi->dev, s, &v) == 0) { + v /= 1000; + if (v >= BQ24190_REG_POC_SYS_MIN_MIN + && v <= BQ24190_REG_POC_SYS_MIN_MAX) + bdi->sys_min = v; + else + dev_warn(bdi->dev, "invalid value for %s: %u\n", s, v); + } + #endif return 0; } -- 2.13.2 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 5/5] power: bq24190_charger: Add power_supply_battery_info support 2017-08-07 19:54 [PATCH v2 0/5] BQ24190 devicetree config Liam Breck ` (3 preceding siblings ...) 2017-08-07 19:54 ` [PATCH v2 4/5] power: bq24190_charger: Add property system-minimum-microvolt Liam Breck @ 2017-08-07 19:54 ` Liam Breck 4 siblings, 0 replies; 17+ messages in thread From: Liam Breck @ 2017-08-07 19:54 UTC (permalink / raw) To: Sebastian Reichel, linux-pm; +Cc: Tony Lindgren, Hans de Goede, Liam Breck From: Liam Breck <kernel@networkimprov.net> Set pre-charge and charge-term current, obtained from power_supply_battery_info. Add sysfs attributes precharge_current & charge_term_current. Cc: Tony Lindgren <tony@atomide.com> Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Liam Breck <kernel@networkimprov.net> --- drivers/power/supply/bq24190_charger.c | 86 ++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index f20d2c68..8a2120cc 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -59,9 +59,13 @@ #define BQ24190_REG_PCTCC_IPRECHG_MASK (BIT(7) | BIT(6) | BIT(5) | \ BIT(4)) #define BQ24190_REG_PCTCC_IPRECHG_SHIFT 4 +#define BQ24190_REG_PCTCC_IPRECHG_MIN 128 +#define BQ24190_REG_PCTCC_IPRECHG_MAX 2048 #define BQ24190_REG_PCTCC_ITERM_MASK (BIT(3) | BIT(2) | BIT(1) | \ BIT(0)) #define BQ24190_REG_PCTCC_ITERM_SHIFT 0 +#define BQ24190_REG_PCTCC_ITERM_MIN 128 +#define BQ24190_REG_PCTCC_ITERM_MAX 2048 #define BQ24190_REG_CVC 0x04 /* Charge Voltage Control */ #define BQ24190_REG_CVC_VREG_MASK (BIT(7) | BIT(6) | BIT(5) | \ @@ -162,6 +166,8 @@ struct bq24190_dev_info { bool initialized; bool irq_event; u16 sys_min; + u16 iprechg; + u16 iterm; struct mutex f_reg_lock; u8 f_reg; u8 ss_reg; @@ -543,6 +549,26 @@ static int bq24190_set_config(struct bq24190_dev_info *bdi) return ret; } + if (bdi->iprechg) { + v = bdi->iprechg / 128 - 1; // manual section 9.5.1.4, table 11 + ret = bq24190_write_mask(bdi, BQ24190_REG_PCTCC, + BQ24190_REG_PCTCC_IPRECHG_MASK, + BQ24190_REG_PCTCC_IPRECHG_SHIFT, + v); + if (ret < 0) + return ret; + } + + if (bdi->iterm) { + v = bdi->iterm / 128 - 1; // manual section 9.5.1.4, table 11 + ret = bq24190_write_mask(bdi, BQ24190_REG_PCTCC, + BQ24190_REG_PCTCC_ITERM_MASK, + BQ24190_REG_PCTCC_ITERM_SHIFT, + v); + if (ret < 0) + return ret; + } + return 0; } @@ -787,6 +813,38 @@ static int bq24190_charger_set_temp_alert_max(struct bq24190_dev_info *bdi, return bq24190_battery_set_temp_alert_max(bdi, val); } +static int bq24190_charger_get_precharge(struct bq24190_dev_info *bdi, + union power_supply_propval *val) +{ + u8 v; + int ret; + + ret = bq24190_read_mask(bdi, BQ24190_REG_PCTCC, + BQ24190_REG_PCTCC_IPRECHG_MASK, + BQ24190_REG_PCTCC_IPRECHG_SHIFT, &v); + if (ret < 0) + return ret; + + val->intval = ++v * 128 * 1000; + return 0; +} + +static int bq24190_charger_get_charge_term(struct bq24190_dev_info *bdi, + union power_supply_propval *val) +{ + u8 v; + int ret; + + ret = bq24190_read_mask(bdi, BQ24190_REG_PCTCC, + BQ24190_REG_PCTCC_ITERM_MASK, + BQ24190_REG_PCTCC_ITERM_SHIFT, &v); + if (ret < 0) + return ret; + + val->intval = ++v * 128 * 1000; + return 0; +} + static int bq24190_charger_get_current(struct bq24190_dev_info *bdi, union power_supply_propval *val) { @@ -907,6 +965,12 @@ static int bq24190_charger_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_TEMP_ALERT_MAX: ret = bq24190_charger_get_temp_alert_max(bdi, val); break; + case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: + ret = bq24190_charger_get_precharge(bdi, val); + break; + case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: + ret = bq24190_charger_get_charge_term(bdi, val); + break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: ret = bq24190_charger_get_current(bdi, val); break; @@ -1006,6 +1070,8 @@ static enum power_supply_property bq24190_charger_properties[] = { POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_TEMP_ALERT_MAX, + POWER_SUPPLY_PROP_PRECHARGE_CURRENT, + POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, @@ -1485,6 +1551,7 @@ static int bq24190_get_config(struct bq24190_dev_info *bdi) { #ifdef CONFIG_OF const char * const s = "ti,system-minimum-microvolt"; + struct power_supply_battery_info info = {}; int v; if (!bdi->dev->of_node) @@ -1499,6 +1566,24 @@ static int bq24190_get_config(struct bq24190_dev_info *bdi) dev_warn(bdi->dev, "invalid value for %s: %u\n", s, v); } + if (!power_supply_get_battery_info(bdi->charger, &info)) { + v = info.precharge_current_ua / 1000; + if (v >= BQ24190_REG_PCTCC_IPRECHG_MIN + && v <= BQ24190_REG_PCTCC_IPRECHG_MAX) + bdi->iprechg = v; + else + dev_warn(bdi->dev, "invalid value for battery:precharge-current-microamp: %d\n", + v); + + v = info.charge_term_current_ua / 1000; + if (v >= BQ24190_REG_PCTCC_ITERM_MIN + && v <= BQ24190_REG_PCTCC_ITERM_MAX) + bdi->iterm = v; + else + dev_warn(bdi->dev, "invalid value for battery:charge-term-current-microamp: %d\n", + v); + } + #endif return 0; } @@ -1567,6 +1652,7 @@ static int bq24190_probe(struct i2c_client *client, } charger_cfg.drv_data = bdi; + charger_cfg.of_node = dev->of_node; charger_cfg.supplied_to = bq24190_charger_supplied_to; charger_cfg.num_supplicants = ARRAY_SIZE(bq24190_charger_supplied_to), bdi->charger = power_supply_register(dev, &bq24190_charger_desc, -- 2.13.2 ^ permalink raw reply related [flat|nested] 17+ messages in thread
end of thread, other threads:[~2017-08-25 20:29 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-07 19:54 [PATCH v2 0/5] BQ24190 devicetree config Liam Breck
2017-08-07 19:54 ` [PATCH v2 1/5] power: bq24190_charger: Add ti,bq24192i to devicetree table Liam Breck
2017-08-25 20:28 ` Tony Lindgren
2017-08-07 19:54 ` [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger Liam Breck
[not found] ` <20170807195420.20767-3-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org>
2017-08-11 2:50 ` Rob Herring
2017-08-11 21:57 ` Liam Breck
2017-08-12 16:42 ` Sebastian Reichel
2017-08-12 19:00 ` Liam Breck
[not found] ` <CAKvHMgR+GxSqhy+iwdYmku2600HzoF__oXV7_w72ZJg-aK7O-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-16 15:47 ` Tony Lindgren
2017-08-16 20:11 ` Liam Breck
[not found] ` <CAKvHMgTvVMsvmyi0o89m1SfS9A4U1GbNuU05Tkt6C0ARR9NyWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-16 21:06 ` Tony Lindgren
2017-08-16 21:16 ` Liam Breck
[not found] ` <CAKvHMgTJjTxffoP4Kt=KzGvCQ-BihLeQn3i4TaF4OBSXV7i6TA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-18 0:16 ` Tony Lindgren
2017-08-25 20:29 ` Tony Lindgren
2017-08-07 19:54 ` [PATCH v2 3/5] power: bq24190_charger: Enable devicetree config Liam Breck
2017-08-07 19:54 ` [PATCH v2 4/5] power: bq24190_charger: Add property system-minimum-microvolt Liam Breck
2017-08-07 19:54 ` [PATCH v2 5/5] power: bq24190_charger: Add power_supply_battery_info support Liam Breck
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).