All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 0/5] treewide: add USB OTG support for hammerhead
@ 2018-10-01  5:30 Brian Masney
  2018-10-01  5:30 ` [PATCH RFC 1/5] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus Brian Masney
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Brian Masney @ 2018-10-01  5:30 UTC (permalink / raw)
  To: andy.gross, sre, robh+dt, mark.rutland, david.brown, linux-pm,
	devicetree, linux-kernel, linux-arm-msm, linux-soc, jonathan

This patch set adds USB OTG support for the LG Nexus 5 (hammerhead)
phone. My only question is related to patch #4 where the GPIO support
is added to bq24190_charger. Based on the information in the device tree
binding Documentation/devicetree/bindings/power/supply/bq24190.txt, I
should be using a gpio-hog. I'm not sure what my input pin would be for
this particular board since I can't find a publicly-available datasheet
for this board.

The USB OTG support works properly with this patch set. I am able to use
USB networking, and I'm also able to plug in a USB hub with a thumb
drive on the phone, and mount the drive.

All of the other msm8974-based boards in upstream use the
qcom,pm8941-charger (via the smbb node) that is defined in
qcom-pm8941.dtsi. USB networking works for me with that driver, however
I'm not able to get any devices connected to my USB hub to show up on
the phone, even when I port the GPIO code into that driver. I can see
the USB hub node with lsusb, but no devices on the hub.

Thanks in advance for any assistance that you can provide.

Brian Masney (1):
  dt-bindings: power: supply: bq24190_charger: add bq24192 and
    usb-otg-vbus

Jonathan Marek (4):
  power: supply: bq24190_charger: add support for bq24192 variant
  power: supply: bq24190_charger: add of_match for usb-otg-vbus
    regulator
  power: supply: bq24190_charger: add support for extcon and GPIO for
    USB OTG support
  ARM: dts: qcom: msm8974-hammerhead: add USB OTG support

 .../bindings/power/supply/bq24190.txt         |  7 +++
 .../qcom-msm8974-lge-nexus5-hammerhead.dts    | 54 +++++++++++++++++++
 arch/arm/boot/dts/qcom-msm8974.dtsi           | 11 ++++
 drivers/power/supply/bq24190_charger.c        | 51 +++++++++++++++++-
 4 files changed, 121 insertions(+), 2 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH RFC 1/5] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus
  2018-10-01  5:30 [PATCH RFC 0/5] treewide: add USB OTG support for hammerhead Brian Masney
@ 2018-10-01  5:30 ` Brian Masney
  2018-10-15 18:52   ` Rob Herring
  2018-10-01  5:30 ` [PATCH RFC 2/5] power: supply: bq24190_charger: add support for bq24192 variant Brian Masney
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Brian Masney @ 2018-10-01  5:30 UTC (permalink / raw)
  To: andy.gross, sre, robh+dt, mark.rutland, david.brown, linux-pm,
	devicetree, linux-kernel, linux-arm-msm, linux-soc, jonathan

Add support for the ti,bq24192 variant and a child node for the
usb-otg-vbus regulator.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 Documentation/devicetree/bindings/power/supply/bq24190.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt
index 9e517d307070..8f2560824a97 100644
--- a/Documentation/devicetree/bindings/power/supply/bq24190.txt
+++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt
@@ -3,6 +3,7 @@ TI BQ24190 Li-Ion Battery Charger
 Required properties:
 - compatible: contains one of the following:
     * "ti,bq24190"
+    * "ti,bq24192"
     * "ti,bq24192i"
 - reg: integer, I2C address of the charger.
 - interrupts[-extended]: configuration for charger INT pin.
@@ -19,6 +20,12 @@ Optional properties:
 - ti,system-minimum-microvolt: when power is connected and the battery is below
   minimum system voltage, the system will be regulated above this setting.
 
+child nodes:
+- usb-otg-vbus:
+  Usage: optional
+  Description: Regulator that is used to control the VBUS voltage direction for
+               either USB host mode or for charging on the OTG port.
+
 Notes:
 - Some circuit boards wire the chip's "OTG" pin high (enabling 500mA default
   charge current on USB SDP ports, among other features). To simulate this on
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH RFC 2/5] power: supply: bq24190_charger: add support for bq24192 variant
  2018-10-01  5:30 [PATCH RFC 0/5] treewide: add USB OTG support for hammerhead Brian Masney
  2018-10-01  5:30 ` [PATCH RFC 1/5] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus Brian Masney
@ 2018-10-01  5:30 ` Brian Masney
  2018-10-21 22:17   ` Sebastian Reichel
  2018-10-01  5:30 ` [PATCH RFC 3/5] power: supply: bq24190_charger: add of_match for usb-otg-vbus regulator Brian Masney
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Brian Masney @ 2018-10-01  5:30 UTC (permalink / raw)
  To: andy.gross, sre, robh+dt, mark.rutland, david.brown, linux-pm,
	devicetree, linux-kernel, linux-arm-msm, linux-soc, jonathan

From: Jonathan Marek <jonathan@marek.ca>

This patch adds support for the bq24192 variant to bq24190_charger.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/power/supply/bq24190_charger.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index b58df04d03b3..e3836145286d 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -1638,7 +1638,8 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi)
 		return ret;
 
 	if (v != BQ24190_REG_VPRS_PN_24190 &&
-	    v != BQ24190_REG_VPRS_PN_24192I) {
+		v != BQ24190_REG_VPRS_PN_24192 &&
+		v != BQ24190_REG_VPRS_PN_24192I) {
 		dev_err(bdi->dev, "Error unknown model: 0x%02x\n", v);
 		return -ENODEV;
 	}
@@ -1931,6 +1932,7 @@ static const struct dev_pm_ops bq24190_pm_ops = {
 
 static const struct i2c_device_id bq24190_i2c_ids[] = {
 	{ "bq24190" },
+	{ "bq24192" },
 	{ "bq24192i" },
 	{ },
 };
@@ -1939,6 +1941,7 @@ MODULE_DEVICE_TABLE(i2c, bq24190_i2c_ids);
 #ifdef CONFIG_OF
 static const struct of_device_id bq24190_of_match[] = {
 	{ .compatible = "ti,bq24190", },
+	{ .compatible = "ti,bq24192", },
 	{ .compatible = "ti,bq24192i", },
 	{ },
 };
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH RFC 3/5] power: supply: bq24190_charger: add of_match for usb-otg-vbus regulator
  2018-10-01  5:30 [PATCH RFC 0/5] treewide: add USB OTG support for hammerhead Brian Masney
  2018-10-01  5:30 ` [PATCH RFC 1/5] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus Brian Masney
  2018-10-01  5:30 ` [PATCH RFC 2/5] power: supply: bq24190_charger: add support for bq24192 variant Brian Masney
@ 2018-10-01  5:30 ` Brian Masney
  2018-10-01  5:30 ` [PATCH RFC 4/5] power: supply: bq24190_charger: add support for extcon and GPIO for USB OTG support Brian Masney
  2018-10-01  5:30 ` [PATCH RFC 5/5] ARM: dts: qcom: msm8974-hammerhead: add " Brian Masney
  4 siblings, 0 replies; 9+ messages in thread
From: Brian Masney @ 2018-10-01  5:30 UTC (permalink / raw)
  To: andy.gross, sre, robh+dt, mark.rutland, david.brown, linux-pm,
	devicetree, linux-kernel, linux-arm-msm, linux-soc, jonathan

From: Jonathan Marek <jonathan@marek.ca>

This patch adds an of_match for the usb-otg-vbus regulator to
bq24190_charger.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/power/supply/bq24190_charger.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index e3836145286d..933d1cded697 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -577,6 +577,7 @@ static const struct regulator_ops bq24190_vbus_ops = {
 
 static const struct regulator_desc bq24190_vbus_desc = {
 	.name = "usb_otg_vbus",
+	.of_match = "usb-otg-vbus",
 	.type = REGULATOR_VOLTAGE,
 	.owner = THIS_MODULE,
 	.ops = &bq24190_vbus_ops,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH RFC 4/5] power: supply: bq24190_charger: add support for extcon and GPIO for USB OTG support
  2018-10-01  5:30 [PATCH RFC 0/5] treewide: add USB OTG support for hammerhead Brian Masney
                   ` (2 preceding siblings ...)
  2018-10-01  5:30 ` [PATCH RFC 3/5] power: supply: bq24190_charger: add of_match for usb-otg-vbus regulator Brian Masney
@ 2018-10-01  5:30 ` Brian Masney
  2018-10-01  5:30 ` [PATCH RFC 5/5] ARM: dts: qcom: msm8974-hammerhead: add " Brian Masney
  4 siblings, 0 replies; 9+ messages in thread
From: Brian Masney @ 2018-10-01  5:30 UTC (permalink / raw)
  To: andy.gross, sre, robh+dt, mark.rutland, david.brown, linux-pm,
	devicetree, linux-kernel, linux-arm-msm, linux-soc, jonathan

From: Jonathan Marek <jonathan@marek.ca>

Add extcon support so that we can notify USB drivers of cable state
changes. This also adds support for an optional GPIO that is changed
depending on the cable state.

This patch makes the USB OTG work correctly on a LG Nexus 5
(hammerhead) phone.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
[masneyb@onstation.org: Fixed EXTCON cable state and USB networking
when the cable is unplugged and plugged back in, checkpatch cleanups.]
Signed-off-by: Brian Masney <masneyb@onstation.org>
Tested-by: Brian Masney <masneyb@onstation.org>
---
See my cover letter for a question about how I can convert patch #5 over
to use a gpio-hog.

 drivers/power/supply/bq24190_charger.c | 45 +++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 933d1cded697..36348668e48a 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -21,6 +21,7 @@
 #include <linux/workqueue.h>
 #include <linux/gpio.h>
 #include <linux/i2c.h>
+#include <linux/extcon-provider.h>
 
 #define	BQ24190_MANUFACTURER	"Texas Instruments"
 
@@ -159,6 +160,8 @@
 struct bq24190_dev_info {
 	struct i2c_client		*client;
 	struct device			*dev;
+	struct extcon_dev		*edev;
+	struct gpio_desc		*gpio_otg;
 	struct power_supply		*charger;
 	struct power_supply		*battery;
 	struct delayed_work		input_current_limit_work;
@@ -174,6 +177,11 @@ struct bq24190_dev_info {
 	u8				watchdog;
 };
 
+static const unsigned int bq24190_usb_extcon_cable[] = {
+	EXTCON_USB,
+	EXTCON_NONE,
+};
+
 /*
  * The tables below provide a 2-way mapping for the value that goes in
  * the register field and the real-world value that it represents.
@@ -1528,6 +1536,23 @@ static const struct power_supply_desc bq24190_battery_desc = {
 	.property_is_writeable	= bq24190_battery_property_is_writeable,
 };
 
+static int bq24190_configure_usb_otg(struct bq24190_dev_info *bdi, u8 ss_reg)
+{
+	bool otg_enabled;
+	int ret;
+
+	otg_enabled = !!(ss_reg & BQ24190_REG_SS_VBUS_STAT_MASK);
+	if (bdi->gpio_otg)
+		gpiod_set_value_cansleep(bdi->gpio_otg, !otg_enabled);
+
+	ret = extcon_set_state_sync(bdi->edev, EXTCON_USB, otg_enabled);
+	if (ret < 0)
+		dev_err(bdi->dev, "Can't set extcon state to %d: %d\n",
+			otg_enabled, ret);
+
+	return ret;
+}
+
 static void bq24190_check_status(struct bq24190_dev_info *bdi)
 {
 	const u8 battery_mask_ss = BQ24190_REG_SS_CHRG_STAT_MASK;
@@ -1597,8 +1622,10 @@ static void bq24190_check_status(struct bq24190_dev_info *bdi)
 		bdi->ss_reg = ss_reg;
 	}
 
-	if (alert_charger || alert_battery)
+	if (alert_charger || alert_battery) {
 		power_supply_changed(bdi->charger);
+		bq24190_configure_usb_otg(bdi, ss_reg);
+	}
 	if (alert_battery && bdi->battery)
 		power_supply_changed(bdi->battery);
 
@@ -1729,6 +1756,18 @@ static int bq24190_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
+	bdi->gpio_otg = devm_gpiod_get_optional(dev, "otg-en", GPIOD_OUT_LOW);
+	if (IS_ERR(bdi->gpio_otg))
+		return PTR_ERR(bdi->gpio_otg);
+
+	bdi->edev = devm_extcon_dev_allocate(dev, bq24190_usb_extcon_cable);
+	if (IS_ERR(bdi->edev))
+		return PTR_ERR(bdi->edev);
+
+	ret = devm_extcon_dev_register(dev, bdi->edev);
+	if (ret < 0)
+		return ret;
+
 	pm_runtime_enable(dev);
 	pm_runtime_use_autosuspend(dev);
 	pm_runtime_set_autosuspend_delay(dev, 600);
@@ -1775,6 +1814,10 @@ static int bq24190_probe(struct i2c_client *client,
 		goto out_charger;
 	}
 
+	ret = bq24190_configure_usb_otg(bdi, bdi->ss_reg);
+	if (ret < 0)
+		goto out_charger;
+
 	ret = bq24190_sysfs_create_group(bdi);
 	if (ret < 0) {
 		dev_err(dev, "Can't create sysfs entries\n");
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH RFC 5/5] ARM: dts: qcom: msm8974-hammerhead: add USB OTG support
  2018-10-01  5:30 [PATCH RFC 0/5] treewide: add USB OTG support for hammerhead Brian Masney
                   ` (3 preceding siblings ...)
  2018-10-01  5:30 ` [PATCH RFC 4/5] power: supply: bq24190_charger: add support for extcon and GPIO for USB OTG support Brian Masney
@ 2018-10-01  5:30 ` Brian Masney
  4 siblings, 0 replies; 9+ messages in thread
From: Brian Masney @ 2018-10-01  5:30 UTC (permalink / raw)
  To: andy.gross, sre, robh+dt, mark.rutland, david.brown, linux-pm,
	devicetree, linux-kernel, linux-arm-msm, linux-soc, jonathan

From: Jonathan Marek <jonathan@marek.ca>

Add the device tree bindings for USB OTG support. Driver was tested
using on a LG Nexus 5 (hammerhead) phone.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Signed-off-by: Brian Masney <masneyb@onstation.org>
Tested-by: Brian Masney <masneyb@onstation.org>
---
See my cover letter for a question about how I can convert this patch
over to use a gpio-hog to get rid of the otg-en-gpios property.

 .../qcom-msm8974-lge-nexus5-hammerhead.dts    | 54 +++++++++++++++++++
 arch/arm/boot/dts/qcom-msm8974.dtsi           | 11 ++++
 2 files changed, 65 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
index e67d61f25a96..71e308d8628d 100644
--- a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
+++ b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
@@ -243,6 +243,16 @@
 			};
 		};
 
+		i2c1_pins: i2c1 {
+			mux {
+				pins = "gpio2", "gpio3";
+				function = "blsp_i2c1";
+
+				drive-strength = <2>;
+				bias-disable;
+			};
+		};
+
 		i2c3_pins: i2c3 {
 			mux {
 				pins = "gpio10", "gpio11";
@@ -382,6 +392,25 @@
 		};
 	};
 
+	i2c@f9923000 {
+		status = "ok";
+		pinctrl-names = "default";
+		pinctrl-0 = <&i2c1_pins>;
+		clock-frequency = <100000>;
+		qcom,src-freq = <50000000>;
+
+		charger: bq24192@6b {
+			compatible = "ti,bq24192";
+			reg = <0x6b>;
+			interrupts-extended = <&spmi_bus 0 0xd5 0 IRQ_TYPE_EDGE_FALLING>;
+
+			omit-battery-class;
+
+			otg-en-gpios = <&pm8941_gpios 35 GPIO_ACTIVE_HIGH>;
+			usb_otg_vbus: usb-otg-vbus { };
+		};
+	};
+
 	i2c@f9925000 {
 		status = "ok";
 		pinctrl-names = "default";
@@ -399,6 +428,31 @@
 			amstaos,proximity-diodes = <0>;
 		};
 	};
+
+	usb@f9a55000 {
+		status = "ok";
+
+		phys = <&usb_hs1_phy>;
+		phy-select = <&tcsr 0xb000 0>;
+
+		extcon = <&charger>, <&usb_id>;
+		vbus-supply = <&usb_otg_vbus>;
+
+		hnp-disable;
+		srp-disable;
+		adp-disable;
+
+		ulpi {
+			phy@a {
+				status = "ok";
+
+				v1p8-supply = <&pm8941_l6>;
+				v3p3-supply = <&pm8941_l24>;
+
+				qcom,init-seq = /bits/ 8 <0x1 0x64>;
+			};
+		};
+	};
 };
 
 &spmi_bus {
diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi b/arch/arm/boot/dts/qcom-msm8974.dtsi
index a808973f9dc7..0bd584695ae8 100644
--- a/arch/arm/boot/dts/qcom-msm8974.dtsi
+++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
@@ -704,6 +704,17 @@
 			interrupts = <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>;
 		};
 
+		i2c@f9923000 {
+			status = "disabled";
+			compatible = "qcom,i2c-qup-v2.1.1";
+			reg = <0xf9923000 0x1000>;
+			interrupts = <0 95 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&gcc GCC_BLSP1_QUP1_I2C_APPS_CLK>, <&gcc GCC_BLSP1_AHB_CLK>;
+			clock-names = "core", "iface";
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
 		i2c@f9924000 {
 			status = "disabled";
 			compatible = "qcom,i2c-qup-v2.1.1";
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC 1/5] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus
  2018-10-01  5:30 ` [PATCH RFC 1/5] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus Brian Masney
@ 2018-10-15 18:52   ` Rob Herring
  2018-10-23  0:04     ` Brian Masney
  0 siblings, 1 reply; 9+ messages in thread
From: Rob Herring @ 2018-10-15 18:52 UTC (permalink / raw)
  To: Brian Masney
  Cc: andy.gross, sre, mark.rutland, david.brown, linux-pm, devicetree,
	linux-kernel, linux-arm-msm, linux-soc, jonathan

On Mon, Oct 01, 2018 at 01:30:01AM -0400, Brian Masney wrote:
> Add support for the ti,bq24192 variant and a child node for the
> usb-otg-vbus regulator.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
> ---
>  Documentation/devicetree/bindings/power/supply/bq24190.txt | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt
> index 9e517d307070..8f2560824a97 100644
> --- a/Documentation/devicetree/bindings/power/supply/bq24190.txt
> +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt
> @@ -3,6 +3,7 @@ TI BQ24190 Li-Ion Battery Charger
>  Required properties:
>  - compatible: contains one of the following:
>      * "ti,bq24190"
> +    * "ti,bq24192"
>      * "ti,bq24192i"
>  - reg: integer, I2C address of the charger.
>  - interrupts[-extended]: configuration for charger INT pin.
> @@ -19,6 +20,12 @@ Optional properties:
>  - ti,system-minimum-microvolt: when power is connected and the battery is below
>    minimum system voltage, the system will be regulated above this setting.
>  
> +child nodes:
> +- usb-otg-vbus:
> +  Usage: optional
> +  Description: Regulator that is used to control the VBUS voltage direction for
> +               either USB host mode or for charging on the OTG port.

What about the regulator properties?

> +
>  Notes:
>  - Some circuit boards wire the chip's "OTG" pin high (enabling 500mA default
>    charge current on USB SDP ports, among other features). To simulate this on
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC 2/5] power: supply: bq24190_charger: add support for bq24192 variant
  2018-10-01  5:30 ` [PATCH RFC 2/5] power: supply: bq24190_charger: add support for bq24192 variant Brian Masney
@ 2018-10-21 22:17   ` Sebastian Reichel
  0 siblings, 0 replies; 9+ messages in thread
From: Sebastian Reichel @ 2018-10-21 22:17 UTC (permalink / raw)
  To: Brian Masney
  Cc: andy.gross, robh+dt, mark.rutland, david.brown, linux-pm,
	devicetree, linux-kernel, linux-arm-msm, linux-soc, jonathan

[-- Attachment #1: Type: text/plain, Size: 1824 bytes --]

Hi,

On Mon, Oct 01, 2018 at 01:30:02AM -0400, Brian Masney wrote:
> From: Jonathan Marek <jonathan@marek.ca>
> 
> This patch adds support for the bq24192 variant to bq24190_charger.
> 
> Signed-off-by: Jonathan Marek <jonathan@marek.ca>
> Signed-off-by: Brian Masney <masneyb@onstation.org>
> ---
>  drivers/power/supply/bq24190_charger.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> index b58df04d03b3..e3836145286d 100644
> --- a/drivers/power/supply/bq24190_charger.c
> +++ b/drivers/power/supply/bq24190_charger.c
> @@ -1638,7 +1638,8 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi)
>  		return ret;
>  
>  	if (v != BQ24190_REG_VPRS_PN_24190 &&
> -	    v != BQ24190_REG_VPRS_PN_24192I) {
> +		v != BQ24190_REG_VPRS_PN_24192 &&
> +		v != BQ24190_REG_VPRS_PN_24192I) {
>  		dev_err(bdi->dev, "Error unknown model: 0x%02x\n", v);
>  		return -ENODEV;
>  	}

This becomes too ugly. Do it like this instead:

switch(v) {
case BQ24190_REG_VPRS_PN_24190:
case BQ24190_REG_VPRS_PN_24192:
case BQ24190_REG_VPRS_PN_24192I:
    break;
default:
    dev_err(bdi->dev, "Error unknown model: 0x%02x\n", v);
    return -ENODEV;
}

-- Sebastian

> @@ -1931,6 +1932,7 @@ static const struct dev_pm_ops bq24190_pm_ops = {
>  
>  static const struct i2c_device_id bq24190_i2c_ids[] = {
>  	{ "bq24190" },
> +	{ "bq24192" },
>  	{ "bq24192i" },
>  	{ },
>  };
> @@ -1939,6 +1941,7 @@ MODULE_DEVICE_TABLE(i2c, bq24190_i2c_ids);
>  #ifdef CONFIG_OF
>  static const struct of_device_id bq24190_of_match[] = {
>  	{ .compatible = "ti,bq24190", },
> +	{ .compatible = "ti,bq24192", },
>  	{ .compatible = "ti,bq24192i", },
>  	{ },
>  };
> -- 
> 2.17.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RFC 1/5] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus
  2018-10-15 18:52   ` Rob Herring
@ 2018-10-23  0:04     ` Brian Masney
  0 siblings, 0 replies; 9+ messages in thread
From: Brian Masney @ 2018-10-23  0:04 UTC (permalink / raw)
  To: Rob Herring
  Cc: andy.gross, sre, mark.rutland, david.brown, linux-pm, devicetree,
	linux-kernel, linux-arm-msm, linux-soc, jonathan

Hi Rob,

On Mon, Oct 15, 2018 at 01:52:52PM -0500, Rob Herring wrote:
> On Mon, Oct 01, 2018 at 01:30:01AM -0400, Brian Masney wrote:
> > Add support for the ti,bq24192 variant and a child node for the
> > usb-otg-vbus regulator.
> > 
> > Signed-off-by: Brian Masney <masneyb@onstation.org>
> > ---
> >  Documentation/devicetree/bindings/power/supply/bq24190.txt | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/power/supply/bq24190.txt b/Documentation/devicetree/bindings/power/supply/bq24190.txt
> > index 9e517d307070..8f2560824a97 100644
> > --- a/Documentation/devicetree/bindings/power/supply/bq24190.txt
> > +++ b/Documentation/devicetree/bindings/power/supply/bq24190.txt
> > @@ -3,6 +3,7 @@ TI BQ24190 Li-Ion Battery Charger
> >  Required properties:
> >  - compatible: contains one of the following:
> >      * "ti,bq24190"
> > +    * "ti,bq24192"
> >      * "ti,bq24192i"
> >  - reg: integer, I2C address of the charger.
> >  - interrupts[-extended]: configuration for charger INT pin.
> > @@ -19,6 +20,12 @@ Optional properties:
> >  - ti,system-minimum-microvolt: when power is connected and the battery is below
> >    minimum system voltage, the system will be regulated above this setting.
> >  
> > +child nodes:
> > +- usb-otg-vbus:
> > +  Usage: optional
> > +  Description: Regulator that is used to control the VBUS voltage direction for
> > +               either USB host mode or for charging on the OTG port.
> 
> What about the regulator properties?

There are no regulator properties underneath this child node. This is a
similar setup to what is described in
Documentation/devicetree/bindings/power/supply/qcom_smbb.txt.

If this is the correct way to do this, then perhaps I can add the
usb_otg_vbus node to the example in v2.

Brian

> > +
> >  Notes:
> >  - Some circuit boards wire the chip's "OTG" pin high (enabling 500mA default
> >    charge current on USB SDP ports, among other features). To simulate this on
> > -- 
> > 2.17.1
> > 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-10-23  0:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01  5:30 [PATCH RFC 0/5] treewide: add USB OTG support for hammerhead Brian Masney
2018-10-01  5:30 ` [PATCH RFC 1/5] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus Brian Masney
2018-10-15 18:52   ` Rob Herring
2018-10-23  0:04     ` Brian Masney
2018-10-01  5:30 ` [PATCH RFC 2/5] power: supply: bq24190_charger: add support for bq24192 variant Brian Masney
2018-10-21 22:17   ` Sebastian Reichel
2018-10-01  5:30 ` [PATCH RFC 3/5] power: supply: bq24190_charger: add of_match for usb-otg-vbus regulator Brian Masney
2018-10-01  5:30 ` [PATCH RFC 4/5] power: supply: bq24190_charger: add support for extcon and GPIO for USB OTG support Brian Masney
2018-10-01  5:30 ` [PATCH RFC 5/5] ARM: dts: qcom: msm8974-hammerhead: add " Brian Masney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.