Skip to contentSkip to conversation

extcon-usb-gpio: add enable pin support

PATCH In review Sergei Shtylyov 3 participants 5 messages Dec 10, 2015 – Dec 11, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extcon-usb-gpio: add enable pin support

Sometimes there's a real OTG chip behind the USB ID signal mapped to a GPIO
pin: in my case it's Maxim Integrated MAX3355E which integrates Vbus charge pump and comparators and passes thru the ID signal from an OTG connector. This chip also has the SHDN# pin which should be driven high for the normal operation and low to save power; it is connected to a GPIO pin as well on, hence we'll have to teach the driver to parse the new optional device tree property, "enable-gpio"...

---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.

 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt |    3 +++
 drivers/extcon/extcon-usb-gpio.c                             |    5 +++++
 2 files changed, 8 insertions(+)
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +3 -0
Index: extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
===================================================================
@@ -7,6 +7,9 @@ Required properties:
 - compatible: Should be "linux,extcon-usb-gpio"
 - id-gpio: gpio for USB ID pin. See gpio binding.
 
+Optional properties:
+- enable-gpio: gpio for the enable pin. See gpio binding.
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
 	extcon_usb1 {
 		compatible = "linux,extcon-usb-gpio";
drivers/extcon/extcon-usb-gpio.c +5 -0
Index: extcon/drivers/extcon/extcon-usb-gpio.c
===================================================================
@@ -33,6 +33,7 @@ struct usb_extcon_info {
 	struct device *dev;
 	struct extcon_dev *edev;
 
+	struct gpio_desc *enable_gpiod;
 	struct gpio_desc *id_gpiod;
 	int id_irq;
 
@@ -99,6 +100,8 @@ static int usb_extcon_probe(struct platf
 		return -ENOMEM;
 
 	info->dev = dev;
+	info->enable_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable",
+						     GPIOD_OUT_HIGH);
 	info->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN);
 	if (IS_ERR(info->id_gpiod)) {
 		dev_err(dev, "failed to get ID GPIO\n");
@@ -155,6 +158,8 @@ static int usb_extcon_remove(struct plat
 
 	cancel_delayed_work_sync(&info->wq_detcable);
 
+	gpiod_set_value_cansleep(info->enable_gpiod, 0);
+
 	return 0;
 }
 
maintainer
#1 lore raw
Quoted 7 lines · Sergei Shtylyov

Sometimes there's a real OTG chip behind the USB ID signal mapped to a GPIO
pin: in my case it's Maxim Integrated MAX3355E which integrates Vbus charge pump and comparators and passes thru the ID signal from an OTG connector. This chip also has the SHDN# pin which should be driven high for the normal operation and low to save power; it is connected to a GPIO pin as well on, hence we'll have to teach the driver to parse the new optional device tree property, "enable-gpio"...

Some wierd spacing going on here.

Quoted 15 lines

---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.

 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt |    3 +++
 drivers/extcon/extcon-usb-gpio.c                             |    5 +++++
 2 files changed, 8 insertions(+)

Index: extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
===================================================================

Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt Required properties: · line 11

Quoted 5 lines
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +2 -0
@@ -7,6 +7,9 @@ Required properties:
 - compatible: Should be "linux,extcon-usb-gpio"
 - id-gpio: gpio for USB ID pin. See gpio binding.
 
+Optional properties:
+- enable-gpio: gpio for the enable pin. See gpio binding.

Use -gpios as -gpio is deprecated.

Quoted 26 lines
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +1 -0
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
 	extcon_usb1 {
 		compatible = "linux,extcon-usb-gpio";

Index: extcon/drivers/extcon/extcon-usb-gpio.c
===================================================================

drivers/extcon/extcon-usb-gpio.c +3 -0
@@ -33,6 +33,7 @@ struct usb_extcon_info {
 	struct device *dev;
 	struct extcon_dev *edev;
 
+	struct gpio_desc *enable_gpiod;
 	struct gpio_desc *id_gpiod;
 	int id_irq;
 
@@ -99,6 +100,8 @@ static int usb_extcon_probe(struct platf
 		return -ENOMEM;
 
 	info->dev = dev;
+	info->enable_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable",
+						     GPIOD_OUT_HIGH);
 	info->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN);
 	if (IS_ERR(info->id_gpiod)) {
 		dev_err(dev, "failed to get ID GPIO\n");

drivers/extcon/extcon-usb-gpio.c static int usb_extcon_remove(struct plat · line 161

Quoted 4 lines
drivers/extcon/extcon-usb-gpio.c +1 -0
@@ -155,6 +158,8 @@ static int usb_extcon_remove(struct plat
 
 	cancel_delayed_work_sync(&info->wq_detcable);
 
+	gpiod_set_value_cansleep(info->enable_gpiod, 0);

Shouldn't you support either polarity?

Rob

#2 lore raw

Hello.

Quoted 9 lines · Rob Herring
Quoted 7 lines

Sometimes there's a real OTG chip behind the USB ID signal mapped to a GPIO
pin: in my case it's Maxim Integrated MAX3355E which integrates Vbus charge pump and comparators and passes thru the ID signal from an OTG connector. This chip also has the SHDN# pin which should be driven high for the normal operation and low to save power; it is connected to a GPIO pin as well on, hence we'll have to teach the driver to parse the new optional device tree property, "enable-gpio"...

Some wierd spacing going on here.

I like my text properly filling up the given columns. What's the problem? :-)

Quoted 17 lines
Quoted 17 lines

---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.

  Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt |    3 +++
  drivers/extcon/extcon-usb-gpio.c                             |    5 +++++
  2 files changed, 8 insertions(+)

Index: extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
===================================================================

Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +0 -0
@@ -7,6 +7,9 @@ Required properties:
  - compatible: Should be "linux,extcon-usb-gpio"
  - id-gpio: gpio for USB ID pin. See gpio binding.
 
Quoted 4 lines

Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt Required properties: · line 11

Quoted 2 lines
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +2 -0
+Optional properties:
+- enable-gpio: gpio for the enable pin. See gpio binding.

Use -gpios as -gpio is deprecated.

Didn't know, thanks.

[...]

Quoted 4 lines
Quoted 4 lines

Index: extcon/drivers/extcon/extcon-usb-gpio.c
===================================================================

drivers/extcon/extcon-usb-gpio.c +0 -0

[...]

Quoted 11 lines
Quoted 11 lines
drivers/extcon/extcon-usb-gpio.c +2 -0
@@ -99,6 +100,8 @@ static int usb_extcon_probe(struct platf
  		return -ENOMEM;
 
  	info->dev = dev;
+	info->enable_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable",
+						     GPIOD_OUT_HIGH);
  	info->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN);
  	if (IS_ERR(info->id_gpiod)) {
  		dev_err(dev, "failed to get ID GPIO\n");
@@ -155,6 +158,8 @@ static int usb_extcon_remove(struct plat
 
Quoted 5 lines

drivers/extcon/extcon-usb-gpio.c static int usb_extcon_remove(struct plat · line 161

Quoted 3 lines
drivers/extcon/extcon-usb-gpio.c +1 -0
  	cancel_delayed_work_sync(&info->wq_detcable);
 
+	gpiod_set_value_cansleep(info->enable_gpiod, 0);

Shouldn't you support either polarity?

The gpiolib does that for me -- devm_gpiod_get_optional() should read the
polarity from DT.

Quoted 1 line

Rob

MBR, Sergei

maintainer
#3 lore raw
In reply to Sergei Shtylyov

Hi Sergei,

Quoted 3 lines · Sergei Shtylyov

Sometimes there's a real OTG chip behind the USB ID signal mapped to a GPIO
pin: in my case it's Maxim Integrated MAX3355E which integrates Vbus charge pump and comparators and passes thru the ID signal from an OTG connector.

s/thru/through ?

Quoted 4 lines

This chip also has the SHDN# pin which should be driven high for the normal operation and low to save power; it is connected to a GPIO pin as well on, hence we'll have to teach the driver to parse the new optional device tree property, "enable-gpio"...

This patch description includes the double space between words. Also, I think you need to write the patch description again for formal style.

This patch adds the specific 'enable-gpio' pin to express the SHDN#pin for MAX3355E. I think it is not regular and standard case because maybe USB specification don't include the SHDN#pin information. I think it not appropriate way. Instead, you better to make the MAX3355 extcon driver to support this case.

Thanks,
Chanwoo

Quoted 62 lines

---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.

 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt |    3 +++
 drivers/extcon/extcon-usb-gpio.c                             |    5 +++++
 2 files changed, 8 insertions(+)

Index: extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
===================================================================

Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +3 -0
@@ -7,6 +7,9 @@ Required properties:
 - compatible: Should be "linux,extcon-usb-gpio"
 - id-gpio: gpio for USB ID pin. See gpio binding.
 
+Optional properties:
+- enable-gpio: gpio for the enable pin. See gpio binding.
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
 	extcon_usb1 {
 		compatible = "linux,extcon-usb-gpio";

Index: extcon/drivers/extcon/extcon-usb-gpio.c
===================================================================

drivers/extcon/extcon-usb-gpio.c +5 -1
@@ -33,6 +33,7 @@ struct usb_extcon_info {
 	struct device *dev;
 	struct extcon_dev *edev;
 
+	struct gpio_desc *enable_gpiod;
 	struct gpio_desc *id_gpiod;
 	int id_irq;
 
@@ -99,6 +100,8 @@ static int usb_extcon_probe(struct platf
 		return -ENOMEM;
 
 	info->dev = dev;
+	info->enable_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable",
+						     GPIOD_OUT_HIGH);
 	info->id_gpiod = devm_gpiod_get(&pdev->dev, "id", GPIOD_IN);
 	if (IS_ERR(info->id_gpiod)) {
 		dev_err(dev, "failed to get ID GPIO\n");
@@ -155,6 +158,8 @@ static int usb_extcon_remove(struct plat
 
 	cancel_delayed_work_sync(&info->wq_detcable);
 
+	gpiod_set_value_cansleep(info->enable_gpiod, 0);
+
 	return 0;
 }
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw

Hello.

Quoted 5 lines · Chanwoo Choi
Quoted 3 lines

Sometimes there's a real OTG chip behind the USB ID signal mapped to a GPIO
pin: in my case it's Maxim Integrated MAX3355E which integrates Vbus charge pump and comparators and passes thru the ID signal from an OTG connector.

s/thru/through ?

"Thru" is valid English.

Quoted 6 lines
Quoted 4 lines

This chip also has the SHDN# pin which should be driven high for the normal operation and low to save power; it is connected to a GPIO pin as well on, hence we'll have to teach the driver to parse the new optional device tree property, "enable-gpio"...

This patch description includes the double space between words. Also, I think

So what?

Quoted 1 line

you need to write the patch description again for formal style.

Not sure I understand you.

Quoted 3 lines

This patch adds the specific 'enable-gpio' pin to express the SHDN#pin for MAX3355E. I think it is not regular and standard case because maybe USB specification don't include the SHDN#pin information.

Certainly, it's not a USB pin.

Quoted 2 lines

I think it not appropriate way.
Instead, you better to make the MAX3355 extcon driver to support this case.

OK, just didn't want to duplicate most of this driver there...

Quoted 2 lines

Thanks,
Chanwoo

MBR, Sergei