extcon: add MAX3355 driver
Subsystems (3)
PATCH 1/1 extcon: add MAX3355 driver
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.
---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.
Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +21 -0
@@ -0,0 +1,21 @@ +MAX3355 USB OTG chip +-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>; + };
drivers/extcon/Kconfig +6 -0
@@ -45,6 +45,12 @@ config EXTCON_MAX14577 Maxim MAX14577/77836. The MAX14577/77836 MUIC is a USB port accessory detector and switch. +config EXTCON_MAX3355 + tristate "MAX3355 USB OTG EXTCON Support" + help + Say Y here to enable support for the USB host detection by MAX3355 + OTG USB chip. + config EXTCON_MAX77693 tristate "MAX77693 EXTCON Support" depends on MFD_MAX77693 && INPUT
drivers/extcon/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_EXTCON_ADC_JACK) += extcon- obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o obj-$(CONFIG_EXTCON_MAX14577) += extcon-max14577.o +obj-$(CONFIG_EXTCON_MAX3355) += extcon-max3355.o obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.o
drivers/extcon/extcon-max3355.c new file +122 -0
122 lines not on this page · raw message
Chanwoo Choi
maintainerHi Sergei,
I reviewed this patch quickly. This driver has just two gpio without any registers for IP. I wonder whether MAX3355E is separate chip to detect external connector or just use gpio of AP.
Could you send the datasheet of MAX3355E to me?
Thanks,
Chanwoo Choi
Quoted 207 lines · Sergei Shtylyov
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.
Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)Index:
extcon/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
===================================================================Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +21
-0@@ -0,0 +1,21 @@ +MAX3355 USB OTG chip +-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>; + };Index: extcon/drivers/extcon/Kconfig
===================================================================drivers/extcon/Kconfig +6
-0@@ -45,6 +45,12 @@ config EXTCON_MAX14577 Maxim MAX14577/77836. The MAX14577/77836 MUIC is a USB port accessory detector and switch. +config EXTCON_MAX3355 + tristate "MAX3355 USB OTG EXTCON Support" + help + Say Y here to enable support for the USB host detection by MAX3355 + OTG USB chip. + config EXTCON_MAX77693 tristate "MAX77693 EXTCON Support" depends on MFD_MAX77693 && INPUTIndex: extcon/drivers/extcon/Makefile
===================================================================drivers/extcon/Makefile +1
-0@@ -7,6 +7,7 @@ obj-$(CONFIG_EXTCON_ADC_JACK) += extcon- obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o obj-$(CONFIG_EXTCON_MAX14577) += extcon-max14577.o +obj-$(CONFIG_EXTCON_MAX3355) += extcon-max3355.o obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.oIndex:
extcon/drivers/extcon/extcon-max3355.c
===================================================================drivers/extcon/extcon-max3355.c new file +122
-0@@ -0,0 +1,122 @@ +/* +* MAX3355 USB OTG chip extcon driver +* +* Copyright (C) 2014 Cogent Embedded, Inc. +* Author: Sergei Shtylyov <[email protected]> +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +*/ + +#include <linux/extcon.h> +#include <linux/gpio.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of_gpio.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/workqueue.h> + +struct max3355_data { +struct extcon_dev *edev; +int id_gpio; +}; + +static const char *max3355_cable[] = { + [0 ] ="USB-HOST" , +NULL , +}; + +static irqreturn_t max3355_id_irq (int irq,void *dev_id) +{ +struct max3355_data *data = dev_id; +int id =gpio_get_value (data->id_gpio); + +extcon_set_cable_state (data->edev,"USB-HOST" , !id); + +return IRQ_HANDLED ; +} + +static int max3355_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +struct max3355_data *data; +int gpio, irq, ret; + + data =devm_kzalloc (&pdev->dev,sizeof (struct max3355_data ), +GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + data->edev =devm_extcon_dev_allocate (&pdev->dev, max3355_cable); +if (IS_ERR (data->edev)) { +dev_err (&pdev->dev,"failed to allocate extcon device\n" ); +return PTR_ERR (data->edev); + } + data->edev->name =kstrdup (np->name,GFP_KERNEL ); + + gpio =of_get_named_gpio (np,"maxim,id-gpio" ,0 ); +if (gpio <0 ) +return gpio; + data->id_gpio = gpio; + + gpio =of_get_named_gpio (np,"maxim,shdn-gpio" ,0 ); +if (gpio <0 ) +return gpio; + + ret =devm_gpio_request_one (&pdev->dev, gpio,GPIOF_DIR_OUT | +GPIOF_INIT_HIGH , pdev->name); +if (ret <0 ) +return ret; + + ret =devm_gpio_request_one (&pdev->dev, data->id_gpio,GPIOF_DIR_IN , + pdev->name); +if (ret <0 ) +return ret; + + ret =devm_extcon_dev_register (&pdev->dev, data->edev); +if (ret <0 ) +return ret; + + irq =gpio_to_irq (data->id_gpio); +if (irq <0 ) +return irq; + + ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , max3355_id_irq, +IRQF_TRIGGER_RISING | +IRQF_TRIGGER_FALLING |IRQF_ONESHOT , + pdev->name, data); +if (ret <0 ) +return ret; + +platform_set_drvdata (pdev, data); + +/* Perform initial detection */ +max3355_id_irq (irq, data); + +return 0 ; +} + +static const struct of_device_id max3355_match_table[] = { + { .compatible ="maxim,max3355" , }, + { } +}; +MODULE_DEVICE_TABLE (of, max3355_match_table); + +static struct platform_driver max3355_driver = { + .probe = max3355_probe, + .driver = { + .name ="extcon-max3355" , + .of_match_table = max3355_match_table, + .owner =THIS_MODULE , + }, +}; + +module_platform_driver (max3355_driver); + +MODULE_AUTHOR ("Sergei Shtylyov <[email protected]>" ); +MODULE_DESCRIPTION ("MAX3355 extcon driver" ); +MODULE_LICENSE ("GPL v2" );
Quoted 1 line · Chanwoo Choi
Could you send the datasheet of MAX3355E to me?
First Google hit:
http://datasheets.maximintegrated.com/en/ds/MAX3355E.pdf
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hello.
Quoted 1 line · Chanwoo Choi
I reviewed this patch quickly. This driver has just two gpio without any registers for IP.
Because there are no registers.
Quoted 1 line
I wonder whether MAX3355E is separate chip to detect external connector
Yes. I thought my description has made that clear...
Quoted 1 line
or just use gpio of AP.
What do you mean by AP?
MAX3355 is indeed partly connected to GPIOs and partly to the USB pins.
Quoted 1 line
Could you send the datasheet of MAX3355E to me?
Looks like Geert has beaten me to it. :-)
Quoted 2 lines
Thanks,
Chanwoo Choi
WBR, Sergei
Chanwoo Choi
maintainerQuoted 12 lines · Sergei Shtylyov
Hello.
Quoted 1 line · Chanwoo Choi
I reviewed this patch quickly. This driver has just two gpio without any registers for IP.
Because there are no registers.
Quoted 1 line
I wonder whether MAX3355E is separate chip to detect external connector
Yes. I thought my description has made that clear...
Quoted 12 lines
Quoted 1 line
or just use gpio of AP.
What do you mean by AP?
MAX3355 is indeed partly connected to GPIOs and partly to the USB pins.Quoted 1 line
Could you send the datasheet of MAX3355E to me?
Looks like Geert has beaten me to it. :-)
Quoted 2 lines
Thanks,
Chanwoo Choi
OK, I'll review it.
Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Chanwoo Choi
maintainerQuoted 28 lines · Sergei Shtylyov
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.
---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)Index:
extcon/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
===================================================================
Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +1
-0@@ -0,0 +1,21 @@ +MAX3355 USB OTG chip
Need manufactor information as following :
-> Maxim MAX3355
Quoted 9 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +9
-0+-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for the GPIO pin
Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +10
-0+ connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>;
Kernel already supported the gpio helper function to get gpio from devicetree.
I prefer use follwoing style by using of_get_gpio()/of_get_gpio_flags() in include/linux/of_gpio.h.
gpios = <&gpio2 4 GPIO_ACTIVE_LOW>, <&gpio5 31 GPIO_ACTIVE_HIGH>;
Quoted 35 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +1
-0+ };Index: extcon/drivers/extcon/Kconfig
===================================================================drivers/extcon/Kconfig +6
-0@@ -45,6 +45,12 @@ config EXTCON_MAX14577 Maxim MAX14577/77836. The MAX14577/77836 MUIC is a USB port accessory detector and switch. +config EXTCON_MAX3355 + tristate "MAX3355 USB OTG EXTCON Support" + help + Say Y here to enable support for the USB host detection by MAX3355 + OTG USB chip. + config EXTCON_MAX77693 tristate "MAX77693 EXTCON Support" depends on MFD_MAX77693 && INPUTIndex: extcon/drivers/extcon/Makefile
===================================================================drivers/extcon/Makefile +1
-0@@ -7,6 +7,7 @@ obj-$(CONFIG_EXTCON_ADC_JACK) += extcon- obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o obj-$(CONFIG_EXTCON_MAX14577) += extcon-max14577.o +obj-$(CONFIG_EXTCON_MAX3355) += extcon-max3355.o obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.oIndex:
extcon/drivers/extcon/extcon-max3355.c
===================================================================
drivers/extcon/extcon-max3355.c line 2
Quoted 2 lines
drivers/extcon/extcon-max3355.c new file +2
-0@@ -0,0 +1,122 @@ +/* +* MAX3355 USB OTG chip extcon driver
ditto.
Quoted 26 lines
drivers/extcon/extcon-max3355.c new file +26
-0+* +* Copyright (C) 2014 Cogent Embedded, Inc. +* Author: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/[email protected]> +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +*/ + +#include <linux/extcon.h> +#include <linux/gpio.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of_gpio.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/workqueue.h> + +struct max3355_data { +struct extcon_dev *edev; +int id_gpio; +}; + +static const char *max3355_cable[] = {
drivers/extcon/extcon-max3355.c line 38
Quoted 10 lines
drivers/extcon/extcon-max3355.c new file +10
-0+ [0 ] ="USB-HOST" , + NULL, +}; + +static irqreturn_t max3355_id_irq (int irq,void *dev_id) +{ +struct max3355_data *data = dev_id; +int id =gpio_get_value (data->id_gpio); + +extcon_set_cable_state (data->edev,"USB-HOST" , !id);
You have to get the gpio flag in the devicetree by using of_get_gpio_flags() function and then you would set the cable state according to gpio state and flag.
Quoted 13 lines
drivers/extcon/extcon-max3355.c new file +13
-0+ +return IRQ_HANDLED ; +} + +static int max3355_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +struct max3355_data *data; +int gpio, irq, ret; + + data =devm_kzalloc (&pdev->dev,sizeof (struct max3355_data ), +GFP_KERNEL ); +if (!data)
drivers/extcon/extcon-max3355.c line 61
Quoted 10 lines
drivers/extcon/extcon-max3355.c new file +10
-0+return -ENOMEM ; + + data->edev =devm_extcon_dev_allocate (&pdev->dev, max3355_cable); +if (IS_ERR (data->edev)) { +dev_err (&pdev->dev,"failed to allocate extcon device\n" ); +return PTR_ERR (data->edev); + } + data->edev->name =kstrdup (np->name,GFP_KERNEL ); + + gpio =of_get_named_gpio (np,"maxim,id-gpio" ,0 );
Use of_get_gpio() or of_get_gpio_flags().
"maxim,id-gpio" property has strong dependency on this driver and it is not standard.
drivers/extcon/extcon-max3355.c line 63
Quoted 2 lines
drivers/extcon/extcon-max3355.c new file +2
-0+if (gpio <0 ) +return gpio;
Need to add error message.
drivers/extcon/extcon-max3355.c line 66
Quoted 3 lines
drivers/extcon/extcon-max3355.c new file +3
-0+ data->id_gpio = gpio; + + gpio =of_get_named_gpio (np,"maxim,shdn-gpio" ,0 );
ditto.
drivers/extcon/extcon-max3355.c line 68
Quoted 2 lines
drivers/extcon/extcon-max3355.c new file +2
-0+if (gpio <0 ) +return gpio;
Need to add error message.
drivers/extcon/extcon-max3355.c line 73
Quoted 5 lines
drivers/extcon/extcon-max3355.c new file +5
-0+ + ret =devm_gpio_request_one (&pdev->dev, gpio,GPIOF_DIR_OUT | +GPIOF_INIT_HIGH , pdev->name); +if (ret <0 ) +return ret;
Need to add error message.
drivers/extcon/extcon-max3355.c line 76
Quoted 3 lines
drivers/extcon/extcon-max3355.c new file +3
-0+ + ret =devm_gpio_request_one (&pdev->dev, data->id_gpio,GPIOF_DIR_IN , + pdev->name);
Why do you use same name for two gpio when devm_gpio_request_one? I prefer to use other name because two gpio is different.
drivers/extcon/extcon-max3355.c line 82
Quoted 6 lines
drivers/extcon/extcon-max3355.c new file +6
-0+if (ret <0 ) +return ret; + + ret =devm_extcon_dev_register (&pdev->dev, data->edev); +if (ret <0 ) +return ret;
Need to add error message.
drivers/extcon/extcon-max3355.c line 86
Quoted 4 lines
drivers/extcon/extcon-max3355.c new file +4
-0+ + irq =gpio_to_irq (data->id_gpio); +if (irq <0 ) +return irq;
Need to add error message.
drivers/extcon/extcon-max3355.c line 90
Quoted 4 lines
drivers/extcon/extcon-max3355.c new file +4
-0+ + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, max3355_id_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
Is it right to add both RISING and FALLING trigger?
and need to add IRQF_NO_SUSPEND to wakeup from suspend state when interrupt happen.
drivers/extcon/extcon-max3355.c line 93
Quoted 3 lines
drivers/extcon/extcon-max3355.c new file +3
-0+ pdev->name, data); +if (ret <0 ) +return ret;
Need to add error message.
Quoted 16 lines
drivers/extcon/extcon-max3355.c new file +16
-0+ +platform_set_drvdata (pdev, data); + +/* Perform initial detection */ +max3355_id_irq (irq, data); + +return 0 ; +} + +static const struct of_device_id max3355_match_table[] = { + { .compatible ="maxim,max3355" , }, + { } +}; +MODULE_DEVICE_TABLE (of, max3355_match_table); + +static struct platform_driver max3355_driver = {
drivers/extcon/extcon-max3355.c line 119
Quoted 10 lines
drivers/extcon/extcon-max3355.c new file +10
-0+ .probe = max3355_probe, + .driver = { + .name = "extcon-max3355", + .of_match_table = max3355_match_table, + .owner = THIS_MODULE, + }, +}; + +module_platform_driver (max3355_driver); +
Don't need un-used blank line.
drivers/extcon/extcon-max3355.c line 121
Quoted 2 lines
drivers/extcon/extcon-max3355.c new file +2
-0+MODULE_AUTHOR ("Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/[email protected]>" ); +MODULE_DESCRIPTION ("MAX3355 extcon driver" );
Maxim MAX3355.
drivers/extcon/extcon-max3355.c line 122
Quoted 3 lines
drivers/extcon/extcon-max3355.c new file +1
-0+MODULE_LICENSE ("GPL v2" );
Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello.
Quoted 31 lines · Chanwoo Choi
Quoted 28 lines
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.
---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)Index:
extcon/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
===================================================================Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +1
-0@@ -0,0 +1,21 @@ +MAX3355 USB OTG chipNeed manufactor information as following :
Quoted 1 line
-> Maxim MAX3355
Would be Maxim enough? Or perhaps I should use Maxim Integrated [Products]?
Quoted 23 lines
Quoted 9 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +9
-0+-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for the GPIO pinDocumentation/devicetree/bindings/extcon/extcon-max3355.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +10
-0+ connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>;Kernel already supported the gpio helper function to get gpio from devicetree.
I prefer use follwoing style by using of_get_gpio()/of_get_gpio_flags() ininclude/linux/of_gpio.h.
Quoted 1 line
gpios = <&gpio2 4 GPIO_ACTIVE_LOW>, <&gpio5 31 GPIO_ACTIVE_HIGH>;
OK, though Documentation/devicetree/bindings/gpio/gpio.txt does not seem
to insist on using this one...
[...]
Quoted 9 lines
drivers/extcon/extcon-max3355.c line 2
Quoted 7 lines
Index:
extcon/drivers/extcon/extcon-max3355.c
===================================================================drivers/extcon/extcon-max3355.c new file +2
-0@@ -0,0 +1,122 @@ +/* +* MAX3355 USB OTG chip extcon driver ditto.
OK, though the other Maxim extcon drivers don't serve as a good example
here...
[...]
Quoted 9 lines
drivers/extcon/extcon-max3355.c line 38
Quoted 6 lines
drivers/extcon/extcon-max3355.c new file +6
-0+static irqreturn_t max3355_id_irq (int irq,void *dev_id) +{ +struct max3355_data *data = dev_id; +int id =gpio_get_value (data->id_gpio); + +extcon_set_cable_state (data->edev,"USB-HOST" , !id);You have to get the gpio flag in the devicetree by using
of_get_gpio_flags()function and then you would set the cable state according to gpio state and flag.
I'm sorry but I just don't see why I have to do it. This is not a generic
GPIO driver, and the polarities of the GPIOs are determined solely by the MAX3355 specs.
[...]
Quoted 13 lines
Quoted 13 lines
drivers/extcon/extcon-max3355.c new file +13
-0+static int max3355_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +struct max3355_data *data; +int gpio, irq, ret; + + data =devm_kzalloc (&pdev->dev,sizeof (struct max3355_data ), +GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + data->edev =devm_extcon_dev_allocate (&pdev->dev, max3355_cable); +if (IS_ERR (data->edev)) {
Quoted 8 lines
drivers/extcon/extcon-max3355.c line 61
Quoted 6 lines
drivers/extcon/extcon-max3355.c new file +6
-0+dev_err (&pdev->dev,"failed to allocate extcon device\n" ); +return PTR_ERR (data->edev); + } + data->edev->name =kstrdup (np->name,GFP_KERNEL ); + + gpio =of_get_named_gpio (np,"maxim,id-gpio" ,0 );Use
of_get_gpio()orof_get_gpio_flags().
OK, I'll use the first one.
Quoted 1 line
"maxim,id-gpio" property has strong dependency on this driver and it is not standard.
I indented it to be Maxim specific. Not sure what using the standard
property buys...
Quoted 4 lines
drivers/extcon/extcon-max3355.c line 29
Quoted 2 lines
drivers/extcon/extcon-max3355.c new file +2
-0+if (gpio <0 ) +return gpio;Need to add error message.
OK for all cases; extcon-gpio.c was probably a bad example...
[...]
Quoted 8 lines
drivers/extcon/extcon-max3355.c line 73
Quoted 5 lines
drivers/extcon/extcon-max3355.c new file +5
-0+ + ret =devm_gpio_request_one (&pdev->dev, gpio,GPIOF_DIR_OUT | +GPIOF_INIT_HIGH , pdev->name); +if (ret <0 ) +return ret;Need to add error message.
Quoted 6 lines
drivers/extcon/extcon-max3355.c line 76
Quoted 3 lines
drivers/extcon/extcon-max3355.c new file +3
-0+ + ret =devm_gpio_request_one (&pdev->dev, data->id_gpio,GPIOF_DIR_IN , + pdev->name);Why do you use same name for two gpio when
devm_gpio_request_one? I prefer to use other name because two gpio is different.
And you're absolutely right here. Mindlessly copy-pasted the code fromextcon-gpio.c...
[...]
Quoted 6 lines
drivers/extcon/extcon-max3355.c line 90
Quoted 4 lines
drivers/extcon/extcon-max3355.c new file +4
-0+ + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, max3355_id_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT,Is it right to add both RISING and FALLING trigger?
How else I'm supposed to know when the OTG ID signal goes low and high?
Quoted 1 line
and need to add
IRQF_NO_SUSPENDto wakeup from suspend state when interrupt happen.
Hm, are you sure we want to wake up on plugging another kind of USB cable?
[...]
Quoted 5 lines
Quoted 5 lines
drivers/extcon/extcon-max3355.c new file +5
-0+static struct platform_driver max3355_driver = { + .probe = max3355_probe, + .driver = { + .name ="extcon-max3355" , + .of_match_table = max3355_match_table,
Quoted 8 lines
drivers/extcon/extcon-max3355.c line 119
Quoted 6 lines
drivers/extcon/extcon-max3355.c new file +6
-0+ .owner = THIS_MODULE, + }, +}; + +module_platform_driver (max3355_driver); +Don't need un-used blank line.
I don't understand. There's empty line in such case in extcon-gpio.c...
Quoted 4 lines
drivers/extcon/extcon-max3355.c line 54
Quoted 2 lines
drivers/extcon/extcon-max3355.c new file +2
-0+MODULE_AUTHOR ("Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/[email protected]>" ); +MODULE_DESCRIPTION ("MAX3355 extcon driver" );Maxim MAX3355.
OK, seeing it in the other Maxim drivers.
Quoted 4 lines
drivers/extcon/extcon-max3355.c line 122
Quoted 1 line
drivers/extcon/extcon-max3355.c new file +1
-0+MODULE_LICENSE ("GPL v2" );Thanks,
Chanwoo Choi
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello.
Quoted 35 lines · Sergei Shtylyov
Quoted 33 lines
Quoted 30 lines
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence
the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)Index:
extcon/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
===================================================================Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +1
-0@@ -0,0 +1,21 @@ +MAX3355 USB OTG chipNeed manufactor information as following :
Quoted 1 line
-> Maxim MAX3355
Quoted 1 line
Would be Maxim enough? Or perhaps I should use Maxim Integrated [Products]?
You haven't replied to my questions.
Quoted 25 lines
Quoted 24 lines
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +9
-0+-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for theGPIO pin
Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +10
-0+ connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>;Kernel already supported the gpio helper function to get gpio from devicetree. I prefer use follwoing style by using of_get_gpio()/of_get_gpio_flags() in
include/linux/of_gpio.h.
Quoted 4 lines
Quoted 1 line
gpios = <&gpio2 4 GPIO_ACTIVE_LOW>, <&gpio5 31 GPIO_ACTIVE_HIGH>;OK, though
Documentation/devicetree/bindings/gpio/gpio.txtdoes not seem
to insist on using this one...
Moreover, it now says "gpios" isn't allowed for the new bindings. So I
have to strongly disagree here...
[...]
Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt
Quoted 6 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +6
-0+static irqreturn_t max3355_id_irq(int irq, void *dev_id) +{ + struct max3355_data *data = dev_id; + int id = gpio_get_value(data->id_gpio); + + extcon_set_cable_state(data->edev, "USB-HOST", !id);You have to get the gpio flag in the devicetree by using
of_get_gpio_flags()function
and then you would set the cable state according to gpio state and flag.
Quoted 3 lines
I'm sorry but I just don't see why I have to do it. This is not a generic
GPIO driver, and the polarities of the GPIOs are determined solely by the MAX3355 specs.
Again, got not reply...
Quoted 23 lines
[...]
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +13
-0+static int max3355_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct max3355_data *data; + int gpio, irq, ret; + + data = devm_kzalloc(&pdev->dev, sizeof(struct max3355_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->edev = devm_extcon_dev_allocate(&pdev->dev, max3355_cable); + if (IS_ERR(data->edev)) {Quoted 8 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt
Quoted 6 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +6
-0+ dev_err(&pdev->dev, "failed to allocate extcon device\n"); + return PTR_ERR(data->edev); + } + data->edev->name = kstrdup(np->name, GFP_KERNEL); + + gpio = of_get_named_gpio(np, "maxim,id-gpio", 0);Use
of_get_gpio()orof_get_gpio_flags().
Quoted 1 line
OK, I'll use the first one.
No, I won't due to not being able to use "gpios" anymore.
[...]
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +4
-0+ + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, max3355_id_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
Quoted 8 lines
Quoted 1 line
Is it right to add both RISING and FALLING trigger?
How else I'm supposed to know when the OTG ID signal goes low and high?
Quoted 2 lines
and need to add
IRQF_NO_SUSPENDto wakeup from suspend state when interrupt happen.Hm, are you sure we want to wake up on plugging another kind of USB cable?
No reply to that as well...
[...]
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +5
-0+static struct platform_driver max3355_driver = { + .probe = max3355_probe, + .driver = { + .name = "extcon-max3355", + .of_match_table = max3355_match_table,Quoted 8 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt
Quoted 6 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +6
-0+ .owner = THIS_MODULE, + }, +}; + +module_platform_driver(max3355_driver); +Don't need un-used blank line.
Quoted 1 line
I don't understand. There's empty line in such case in
extcon-gpio.c...
No reply...
[...]
Quoted 2 lines
Quoted 2 lines
Thanks,
Chanwoo Choi
MBR, Sergei
Chanwoo Choi
maintainerHi Sergei,
I think this patch is too much delay. I recommend you better to develop this driver based on latest extcon-next branch[1].
[1] https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-next
Thanks,
Chanwoo Choi
Quoted 171 lines · Sergei Shtylyov
Hello.
Quoted 35 lines · Sergei Shtylyov
Quoted 33 lines
Quoted 30 lines
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence
the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)Index:
extcon/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
===================================================================Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +1
-0@@ -0,0 +1,21 @@ +MAX3355 USB OTG chipNeed manufactor information as following :
Quoted 1 line
-> Maxim MAX3355Quoted 1 line
Would be Maxim enough? Or perhaps I should use Maxim Integrated [Products]?
You haven't replied to my questions.
Quoted 25 lines
Quoted 24 lines
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +9
-0+-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for theGPIO pin
Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +10
-0+ connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>;Kernel already supported the gpio helper function to get gpio from devicetree. I prefer use follwoing style by using of_get_gpio()/of_get_gpio_flags() in
include/linux/of_gpio.h.Quoted 4 lines
Quoted 1 line
gpios = <&gpio2 4 GPIO_ACTIVE_LOW>, <&gpio5 31 GPIO_ACTIVE_HIGH>;OK, though
Documentation/devicetree/bindings/gpio/gpio.txtdoes not seem
to insist on using this one...Moreover, it now says "gpios" isn't allowed for the new bindings. So I have to strongly disagree here...
[...]
Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt
Quoted 6 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +6
-0+static irqreturn_t max3355_id_irq(int irq, void *dev_id) +{ + struct max3355_data *data = dev_id; + int id = gpio_get_value(data->id_gpio); + + extcon_set_cable_state(data->edev, "USB-HOST", !id);You have to get the gpio flag in the devicetree by using
of_get_gpio_flags()function
and then you would set the cable state according to gpio state and flag.Quoted 3 lines
I'm sorry but I just don't see why I have to do it. This is not a generic
GPIO driver, and the polarities of the GPIOs are determined solely by the MAX3355 specs.Again, got not reply...
Quoted 23 lines
[...]
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +13
-0+static int max3355_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct max3355_data *data; + int gpio, irq, ret; + + data = devm_kzalloc(&pdev->dev, sizeof(struct max3355_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->edev = devm_extcon_dev_allocate(&pdev->dev, max3355_cable); + if (IS_ERR(data->edev)) {Quoted 8 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt
Quoted 6 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +6
-0+ dev_err(&pdev->dev, "failed to allocate extcon device\n"); + return PTR_ERR(data->edev); + } + data->edev->name = kstrdup(np->name, GFP_KERNEL); + + gpio = of_get_named_gpio(np, "maxim,id-gpio", 0);Use
of_get_gpio()orof_get_gpio_flags().Quoted 1 line
OK, I'll use the first one.
No, I won't due to not being able to use "gpios" anymore.
[...]
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +4
-0+ + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, max3355_id_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT,Quoted 8 lines
Quoted 1 line
Is it right to add both RISING and FALLING trigger?
How else I'm supposed to know when the OTG ID signal goes low and high?
Quoted 2 lines
and need to add
IRQF_NO_SUSPENDto wakeup from suspend state when interrupt happen.Hm, are you sure we want to wake up on plugging another kind of USB cable?
No reply to that as well...
[...]
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +5
-0+static struct platform_driver max3355_driver = { + .probe = max3355_probe, + .driver = { + .name = "extcon-max3355", + .of_match_table = max3355_match_table,Quoted 8 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt
Quoted 6 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +6
-0+ .owner = THIS_MODULE, + }, +}; + +module_platform_driver(max3355_driver); +Don't need un-used blank line.
Quoted 1 line
I don't understand. There's empty line in such case in
extcon-gpio.c...No reply...[...]
Quoted 2 lines
Quoted 2 lines
Thanks,
Chanwoo ChoiMBR, Sergei
Signature · 4 lines
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/
Hello.
Quoted 3 lines · Chanwoo Choi
I think this patch is too much delay. I recommend you better to develop this driver based on latest extcon-next branch[1].
[1] https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-next
I would really appreciate if you answer my questions, I think most of them
are still valid...
MBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Chanwoo Choi
maintainerQuoted 68 lines · Sergei Shtylyov
Hello.
Quoted 35 lines · Sergei Shtylyov
Quoted 33 lines
Quoted 30 lines
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence
the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)Index:
extcon/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
===================================================================Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +1
-0@@ -0,0 +1,21 @@ +MAX3355 USB OTG chipNeed manufactor information as following :
Quoted 1 line
-> Maxim MAX3355Quoted 1 line
Would be Maxim enough? Or perhaps I should use Maxim Integrated [Products]?
You haven't replied to my questions.
Quoted 25 lines
Quoted 24 lines
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +9
-0+-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for theGPIO pin
Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +10
-0+ connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>;Kernel already supported the gpio helper function to get gpio from devicetree. I prefer use follwoing style by using of_get_gpio()/of_get_gpio_flags() in
include/linux/of_gpio.h.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
gpios = <&gpio2 4 GPIO_ACTIVE_LOW>, <&gpio5 31 GPIO_ACTIVE_HIGH>;OK, though
Documentation/devicetree/bindings/gpio/gpio.txtdoes not seem
to insist on using this one...Moreover, it now says "gpios" isn't allowed for the new bindings. So I have to strongly disagree here...
OK. But, I recommend you use the 'gpiod' with devm_gpiod_get instead of using devm_gpio_request_one() directly as following:
You can refer drivers/extcon/extcon-usb-gpio.c about using gpiod.
For example,
data->shdn_gpiod = devm_gpiod_get(dev, "maxim,shdn", GPIOD_IN); data->id_gpiod = devm_gpiod_get(dev, "maxim,id", GPIOD_IN);
Quoted 14 lines
[...]
Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt
Quoted 6 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +6
-0+static irqreturn_t max3355_id_irq(int irq, void *dev_id) +{ + struct max3355_data *data = dev_id; + int id = gpio_get_value(data->id_gpio); + + extcon_set_cable_state(data->edev, "USB-HOST", !id);You have to get the gpio flag in the devicetree by using
of_get_gpio_flags()function
and then you would set the cable state according to gpio state and flag.
Quoted 5 lines
Quoted 3 lines
I'm sorry but I just don't see why I have to do it. This is not a generic
GPIO driver, and the polarities of the GPIOs are determined solely by the MAX3355 specs.Again, got not reply...
OK. you don't need to consider the gpio flag from devicetree.
Quoted 22 lines
Quoted 22 lines
[...]
Quoted 19 lines
Quoted 19 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +19
-0+static int max3355_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct max3355_data *data; + int gpio, irq, ret; + + data = devm_kzalloc(&pdev->dev, sizeof(struct max3355_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->edev = devm_extcon_dev_allocate(&pdev->dev, max3355_cable); + if (IS_ERR(data->edev)) { + dev_err(&pdev->dev, "failed to allocate extcon device\n"); + return PTR_ERR(data->edev); + } + data->edev->name = kstrdup(np->name, GFP_KERNEL); + + gpio = of_get_named_gpio(np, "maxim,id-gpio", 0);
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Use
of_get_gpio()orof_get_gpio_flags().OK, I'll use the first one.
No, I won't due to not being able to use "gpios" anymore.
OK. I add the comment on upper. You can use the gpiod API.
Quoted 10 lines
[...]
Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt
Quoted 4 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +4
-0+ + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, max3355_id_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT,Is it right to add both RISING and FALLING trigger?
Quoted 8 lines
Quoted 6 lines
How else I'm supposed to know when the OTG ID signal goes low and high?
Quoted 2 lines
and need to add
IRQF_NO_SUSPENDto wakeup from suspend state when interrupt happen.Hm, are you sure we want to wake up on plugging another kind of USB cable?
No reply to that as well...
I'm sure. If external connector (USB, Charger cable, Earjack etc..) is attached or detached in the suspended state, system should be wake-up from suspended state.
If kernel don't handle the any interrupt in suspended state, after wakeup from suspended state, there is mismatch data
between 'before entering suspend state' and 'after wakeup from suspend state'.
Quoted 14 lines
[...]
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +11
-0+static struct platform_driver max3355_driver = { + .probe = max3355_probe, + .driver = { + .name = "extcon-max3355", + .of_match_table = max3355_match_table, + .owner = THIS_MODULE, + }, +}; + +module_platform_driver(max3355_driver); +
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Don't need un-used blank line.
I don't understand. There's empty line in such case in
extcon-gpio.c...No reply...
OK. No problem. Ignore this comment.
Thanks,
Chanwoo Choi
Hello.
Quoted 71 lines · Chanwoo Choi
Quoted 64 lines
Quoted 35 lines
Quoted 33 lines
Quoted 30 lines
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence
the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)Index:
extcon/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
===================================================================Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +1
-0@@ -0,0 +1,21 @@ +MAX3355 USB OTG chipNeed manufactor information as following :
Quoted 1 line
-> Maxim MAX3355Quoted 1 line
Would be Maxim enough? Or perhaps I should use Maxim Integrated [Products]?
You haven't replied to my questions.
Quoted 25 lines
Quoted 24 lines
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +9
-0+-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for theGPIO pin
Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +10
-0+ connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>;Kernel already supported the gpio helper function to get gpio from devicetree. I prefer use follwoing style by using of_get_gpio()/of_get_gpio_flags() in
include/linux/of_gpio.h.Quoted 6 lines
Quoted 4 lines
Quoted 1 line
gpios = <&gpio2 4 GPIO_ACTIVE_LOW>, <&gpio5 31 GPIO_ACTIVE_HIGH>;OK, though
Documentation/devicetree/bindings/gpio/gpio.txtdoes not seem
to insist on using this one...Moreover, it now says "gpios" isn't allowed for the new bindings. So I have to strongly disagree here...
Quoted 7 lines
OK. But, I recommend you use the 'gpiod' with
devm_gpiod_getinstead of usingdevm_gpio_request_one()directly as following:
You can referdrivers/extcon/extcon-usb-gpio.cabout using gpiod.For example,
data->shdn_gpiod = devm_gpiod_get(dev, "maxim,shdn", GPIOD_IN); data->id_gpiod = devm_gpiod_get(dev, "maxim,id", GPIOD_IN);
Thanks, done now. I just had another idea: how about I add an optional
"enable-gpio" property to the 'extcon-usb-gpio' driver? I wouldn't need my own driver then at all... :-)
MBR, Sergei
Chanwoo Choi
maintainerHello,
I received the reply from you after too long time (17~18day). You better to reply it more a little more quickly if you have the question or new patches.
Quoted 79 lines · Sergei Shtylyov
Hello.
Quoted 75 lines · Chanwoo Choi
Quoted 64 lines
Quoted 35 lines
Quoted 33 lines
Quoted 30 lines
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence
the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)Index:
extcon/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
===================================================================Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +1
-0@@ -0,0 +1,21 @@ +MAX3355 USB OTG chipNeed manufactor information as following :
Quoted 1 line
-> Maxim MAX3355Quoted 1 line
Would be Maxim enough? Or perhaps I should use Maxim Integrated [Products]?
You haven't replied to my questions.
Quoted 25 lines
Quoted 24 lines
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +9
-0+-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for theGPIO pin
Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +10
-0+ connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>;Kernel already supported the gpio helper function to get gpio from devicetree. I prefer use follwoing style by using of_get_gpio()/of_get_gpio_flags() in
include/linux/of_gpio.h.Quoted 6 lines
Quoted 4 lines
Quoted 1 line
gpios = <&gpio2 4 GPIO_ACTIVE_LOW>, <&gpio5 31 GPIO_ACTIVE_HIGH>;OK, though
Documentation/devicetree/bindings/gpio/gpio.txtdoes not seem
to insist on using this one...Moreover, it now says "gpios" isn't allowed for the new bindings. So I have to strongly disagree here...
OK. But, I recommend you use the 'gpiod' with
devm_gpiod_getinstead of usingdevm_gpio_request_one()directly as following:
You can referdrivers/extcon/extcon-usb-gpio.cabout using gpiod.
Quoted 5 lines
Quoted 3 lines
For example,
data->shdn_gpiod = devm_gpiod_get(dev, "maxim,shdn", GPIOD_IN); data->id_gpiod = devm_gpiod_get(dev, "maxim,id", GPIOD_IN);Thanks, done now. I just had another idea: how about I add an optional "enable-gpio" property to the 'extcon-usb-gpio' driver? I wouldn't need my own driver then at all... :-)
What is meaning of 'enable-gpio' property?
You better to explain your goal about 'enable-gpio' property
Also, If you think that it is generic way about adding 'enable-gpio' property to extcon-usb-gpio.c, you can try it.
Thanks,
Chanwoo Choi
Hello.
Quoted 3 lines · Chanwoo Choi
I received the reply from you after too long time (17~18day). You better to reply it more a little more quickly if you have the question or new patches.
I've replied as soon as I had my new idea.
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 64 lines
Quoted 35 lines
Quoted 33 lines
Quoted 30 lines
MAX3355E chip integrates a charge pump and comparators to enable a system with an integrated USB OTG dual-role transceiver to function as a USB OTG dual-role device. In addition to sensing/controlling Vbus, the chip also passes thru the ID signal from the USB OTG connector. On some Renesas boards, this signal is just fed into the SoC thru a GPIO pin -- there's no real OTG controller, only host and gadget USB controllers sharing the same USB bus; however, we'd like to allow host or gadget drivers to be loaded depending on the cable type, hence
the need for the MAX3355 extcon driver. The Vbus status signals are also wired to GPIOs (however, we're not currently intested in them), the OFFVBUS# signal is controlled by the host controllers, there's also the SHDN# signal wired to GPIO, which should be high for normal operation.Signed-off-by Sergei Shtylyov <[email protected]>---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.Documentation/devicetree/bindings/extcon/extcon-max3355.txt | 21 ++ drivers/extcon/Kconfig | 6 drivers/extcon/Makefile | 1 drivers/extcon/extcon-max3355.c | 122 ++++++++++++ 4 files changed, 150 insertions(+)Index:
extcon/Documentation/devicetree/bindings/extcon/extcon-max3355.txt
===================================================================Documentation/devicetree/bindings/extcon/extcon-max3355.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +1
-0@@ -0,0 +1,21 @@ +MAX3355 USB OTG chipNeed manufactor information as following :
Quoted 1 line
-> Maxim MAX3355Quoted 1 line
Would be Maxim enough? Or perhaps I should use Maxim Integrated [Products]?
You haven't replied to my questions.
Quoted 25 lines
Quoted 24 lines
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +9
-0+-------------------- + +MAX3355 integrates a charge pump and comparators to enable a system with an +integrated USB OTG dual-role transceiver to function as a USB OTG dual-role +device. + +Required properties: +- compatible: should be "maxim,max3355"; +- maxim,shdn-gpio: should contain a phandle and GPIO specifier for theGPIO pin
Documentation/devicetree/bindings/extcon/extcon-max3355.txt
Quoted 10 lines
Documentation/devicetree/bindings/extcon/extcon-max3355.txt new file +10
-0+ connected to the MAX3355's SHDN# pin; +- maxim,id-gpio: should contain a phandle and GPIO specifier for the GPIO pin + connected to the MAX3355's ID_OUT pin. + +Example (Koelsch board): + + usb-otg { + compatible = "maxim,max3355"; + maxim,shdn-gpio = <&gpio2 4 GPIO_ACTIVE_LOW>; + maxim,id-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>;Kernel already supported the gpio helper function to get gpio from devicetree. I prefer use follwoing style by using of_get_gpio()/of_get_gpio_flags() in
include/linux/of_gpio.h.Quoted 6 lines
Quoted 4 lines
Quoted 1 line
gpios = <&gpio2 4 GPIO_ACTIVE_LOW>, <&gpio5 31 GPIO_ACTIVE_HIGH>;OK, though
Documentation/devicetree/bindings/gpio/gpio.txtdoes not seem
to insist on using this one...Moreover, it now says "gpios" isn't allowed for the new bindings. So I have to strongly disagree here...
OK. But, I recommend you use the 'gpiod' with
devm_gpiod_getinstead of usingdevm_gpio_request_one()directly as following:
You can referdrivers/extcon/extcon-usb-gpio.cabout using gpiod.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
For example,
data->shdn_gpiod = devm_gpiod_get(dev, "maxim,shdn", GPIOD_IN); data->id_gpiod = devm_gpiod_get(dev, "maxim,id", GPIOD_IN);Thanks, done now. I just had another idea: how about I add an optional "enable-gpio" property to the 'extcon-usb-gpio' driver? I wouldn't need my own driver then at all... :-)
What is meaning of 'enable-gpio' property?
You better to explain your goal about 'enable-gpio' property
This optional property would serve for enabling the valid signal on the ID
GPIO, the same way I'm using the SHDN# GPIO in the MAX3355 driver.
Quoted 3 lines
Also, If you think that it is generic way about adding 'enable-gpio' property to
extcon-usb-gpio.c, you can try it.
Yes, I think it would be generic enough.
Quoted 2 lines
Thanks,
Chanwoo Choi
MBR, Sergei