devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/3] extcon: int3496: Propagate error code of gpiod_to_irq()
@ 2017-02-23 10:31 ` Andy Shevchenko
  2017-02-23 10:31   ` [PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table Andy Shevchenko
       [not found]   ` <20170223103156.109643-1-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-02-23 10:31 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Rob Herring, devicetree,
	David Cohen, Felipe Balbi
  Cc: Andy Shevchenko

gpiod_to_irq() doesn't return 0. Thus, we just adjust condition and
replace -EINVAL by actual error code it returns.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon-intel-int3496.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
index a3131b036de6..38eb6cab938f 100644
--- a/drivers/extcon/extcon-intel-int3496.c
+++ b/drivers/extcon/extcon-intel-int3496.c
@@ -100,9 +100,9 @@ static int int3496_probe(struct platform_device *pdev)
 	}
 
 	data->usb_id_irq = gpiod_to_irq(data->gpio_usb_id);
-	if (data->usb_id_irq <= 0) {
+	if (data->usb_id_irq < 0) {
 		dev_err(dev, "can't get USB ID IRQ: %d\n", data->usb_id_irq);
-		return -EINVAL;
+		return data->usb_id_irq;
 	}
 
 	data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus en",
-- 
2.11.0

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

* [PATCH v1 2/3] extcon: int3496: Rename GPIO pins in accordance with binding
       [not found]   ` <20170223103156.109643-1-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2017-02-23 10:31     ` Andy Shevchenko
  2017-02-24  1:17       ` Chanwoo Choi
  2017-02-24  1:09     ` [PATCH v1 1/3] extcon: int3496: Propagate error code of gpiod_to_irq() Chanwoo Choi
  1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2017-02-23 10:31 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA, David Cohen,
	Felipe Balbi
  Cc: Andy Shevchenko

First of all, add an optional binding for external muxer which might be
used.

Second, update GPIO pin names in extcon-intel-int3496.c driver to follow
the existing binding.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 3 +++
 drivers/extcon/extcon-intel-int3496.c                        | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
index dfc14f71e81f..9d97472ae51d 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
@@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can be present as well.
 - id-gpio: gpio for USB ID pin. See gpio binding.
 - vbus-gpio: gpio for USB VBUS pin.
 
+Optional properties:
+- mux-gpios: gpio for USB external muxer
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
 	extcon_usb1 {
 		compatible = "linux,extcon-usb-gpio";
diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
index 38eb6cab938f..81713bf7487e 100644
--- a/drivers/extcon/extcon-intel-int3496.c
+++ b/drivers/extcon/extcon-intel-int3496.c
@@ -105,13 +105,13 @@ static int int3496_probe(struct platform_device *pdev)
 		return data->usb_id_irq;
 	}
 
-	data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus en",
+	data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus",
 						 INT3496_GPIO_VBUS_EN,
 						 GPIOD_ASIS);
 	if (IS_ERR(data->gpio_vbus_en))
 		dev_info(dev, "can't request VBUS EN GPIO\n");
 
-	data->gpio_usb_mux = devm_gpiod_get_index(dev, "usb mux",
+	data->gpio_usb_mux = devm_gpiod_get_index(dev, "mux",
 						 INT3496_GPIO_USB_MUX,
 						 GPIOD_ASIS);
 	if (IS_ERR(data->gpio_usb_mux))
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table
  2017-02-23 10:31 ` [PATCH v1 1/3] extcon: int3496: Propagate error code of gpiod_to_irq() Andy Shevchenko
@ 2017-02-23 10:31   ` Andy Shevchenko
  2017-02-24  1:30     ` Chanwoo Choi
       [not found]   ` <20170223103156.109643-1-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2017-02-23 10:31 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Rob Herring, devicetree,
	David Cohen, Felipe Balbi
  Cc: Andy Shevchenko

In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/extcon/extcon-intel-int3496.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
index 81713bf7487e..1abe9071d9d0 100644
--- a/drivers/extcon/extcon-intel-int3496.c
+++ b/drivers/extcon/extcon-intel-int3496.c
@@ -45,6 +45,17 @@ static const unsigned int int3496_cable[] = {
 	EXTCON_NONE,
 };
 
+static const struct acpi_gpio_params id_gpios = { INT3496_GPIO_USB_ID, 0, false };
+static const struct acpi_gpio_params vbus_gpios = { INT3496_GPIO_VBUS_EN, 0, false };
+static const struct acpi_gpio_params mux_gpios = { INT3496_GPIO_USB_MUX, 0, false };
+
+static const struct acpi_gpio_mapping acpi_int3496_default_gpios[] = {
+	{ "id-gpios", &id_gpios, 1 },
+	{ "vbus-gpios", &vbus_gpios, 1 },
+	{ "mux-gpios", &mux_gpios, 1 },
+	{ },
+};
+
 static void int3496_do_usb_id(struct work_struct *work)
 {
 	struct int3496_data *data =
@@ -83,6 +94,13 @@ static int int3496_probe(struct platform_device *pdev)
 	struct int3496_data *data;
 	int ret;
 
+	ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
+					acpi_int3496_default_gpios);
+	if (ret) {
+		dev_err(dev, "can't add GPIO ACPI mapping\n");
+		return ret;
+	}
+
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
@@ -154,6 +172,7 @@ static int int3496_remove(struct platform_device *pdev)
 	devm_free_irq(&pdev->dev, data->usb_id_irq, data);
 	cancel_delayed_work_sync(&data->work);
 
+	acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
 	return 0;
 }
 
-- 
2.11.0

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

* Re: [PATCH v1 1/3] extcon: int3496: Propagate error code of gpiod_to_irq()
       [not found]   ` <20170223103156.109643-1-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2017-02-23 10:31     ` [PATCH v1 2/3] extcon: int3496: Rename GPIO pins in accordance with binding Andy Shevchenko
@ 2017-02-24  1:09     ` Chanwoo Choi
  1 sibling, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2017-02-24  1:09 UTC (permalink / raw)
  To: Andy Shevchenko, MyungJoo Ham,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring,
	devicetree-u79uwXL29TY76Z2rM5mHXA, David Cohen, Felipe Balbi

On 2017년 02월 23일 19:31, Andy Shevchenko wrote:
> gpiod_to_irq() doesn't return 0. Thus, we just adjust condition and
> replace -EINVAL by actual error code it returns.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
>  drivers/extcon/extcon-intel-int3496.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
> index a3131b036de6..38eb6cab938f 100644
> --- a/drivers/extcon/extcon-intel-int3496.c
> +++ b/drivers/extcon/extcon-intel-int3496.c
> @@ -100,9 +100,9 @@ static int int3496_probe(struct platform_device *pdev)
>  	}
>  
>  	data->usb_id_irq = gpiod_to_irq(data->gpio_usb_id);
> -	if (data->usb_id_irq <= 0) {
> +	if (data->usb_id_irq < 0) {
>  		dev_err(dev, "can't get USB ID IRQ: %d\n", data->usb_id_irq);
> -		return -EINVAL;
> +		return data->usb_id_irq;
>  	}
>  
>  	data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus en",
> 

Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v1 2/3] extcon: int3496: Rename GPIO pins in accordance with binding
  2017-02-23 10:31     ` [PATCH v1 2/3] extcon: int3496: Rename GPIO pins in accordance with binding Andy Shevchenko
@ 2017-02-24  1:17       ` Chanwoo Choi
       [not found]         ` <58AF8998.5000601-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Chanwoo Choi @ 2017-02-24  1:17 UTC (permalink / raw)
  To: Andy Shevchenko, MyungJoo Ham, linux-kernel, Rob Herring,
	devicetree, David Cohen, Felipe Balbi

Hi,

On 2017년 02월 23일 19:31, Andy Shevchenko wrote:
> First of all, add an optional binding for external muxer which might be
> used.
> 
> Second, update GPIO pin names in extcon-intel-int3496.c driver to follow
> the existing binding.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 3 +++
>  drivers/extcon/extcon-intel-int3496.c                        | 4 ++--
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> index dfc14f71e81f..9d97472ae51d 100644
> --- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> +++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> @@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can be present as well.
>  - id-gpio: gpio for USB ID pin. See gpio binding.
>  - vbus-gpio: gpio for USB VBUS pin.
>  
> +Optional properties:
> +- mux-gpios: gpio for USB external muxer

The Documentation/extcon/intel-int3496.txt includes
already the information for id/vbus/mux pin.

The extcon-usb-gpio.txt is not related with the extcon-int3496 driver.

> +
>  Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
>  	extcon_usb1 {
>  		compatible = "linux,extcon-usb-gpio";
> diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
> index 38eb6cab938f..81713bf7487e 100644
> --- a/drivers/extcon/extcon-intel-int3496.c
> +++ b/drivers/extcon/extcon-intel-int3496.c
> @@ -105,13 +105,13 @@ static int int3496_probe(struct platform_device *pdev)
>  		return data->usb_id_irq;
>  	}
>  
> -	data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus en",
> +	data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus",
>  						 INT3496_GPIO_VBUS_EN,
>  						 GPIOD_ASIS);
>  	if (IS_ERR(data->gpio_vbus_en))
>  		dev_info(dev, "can't request VBUS EN GPIO\n");
>  
> -	data->gpio_usb_mux = devm_gpiod_get_index(dev, "usb mux",
> +	data->gpio_usb_mux = devm_gpiod_get_index(dev, "mux",
>  						 INT3496_GPIO_USB_MUX,
>  						 GPIOD_ASIS);
>  	if (IS_ERR(data->gpio_usb_mux))
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

* Re: [PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table
  2017-02-23 10:31   ` [PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table Andy Shevchenko
@ 2017-02-24  1:30     ` Chanwoo Choi
  0 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2017-02-24  1:30 UTC (permalink / raw)
  To: Andy Shevchenko, MyungJoo Ham, linux-kernel, Rob Herring,
	devicetree, David Cohen, Felipe Balbi

Hi,

On 2017년 02월 23일 19:31, Andy Shevchenko wrote:
> In order to make GPIO ACPI library stricter prepare users of
> gpiod_get_index() to correctly behave when there no mapping is
> provided by firmware.
> 
> Here we add explicit mapping between _CRS GpioIo() resources and
> their names used in the driver.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/extcon/extcon-intel-int3496.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
> index 81713bf7487e..1abe9071d9d0 100644
> --- a/drivers/extcon/extcon-intel-int3496.c
> +++ b/drivers/extcon/extcon-intel-int3496.c
> @@ -45,6 +45,17 @@ static const unsigned int int3496_cable[] = {
>  	EXTCON_NONE,
>  };
>  
> +static const struct acpi_gpio_params id_gpios = { INT3496_GPIO_USB_ID, 0, false };
> +static const struct acpi_gpio_params vbus_gpios = { INT3496_GPIO_VBUS_EN, 0, false };
> +static const struct acpi_gpio_params mux_gpios = { INT3496_GPIO_USB_MUX, 0, false };
> +
> +static const struct acpi_gpio_mapping acpi_int3496_default_gpios[] = {
> +	{ "id-gpios", &id_gpios, 1 },
> +	{ "vbus-gpios", &vbus_gpios, 1 },
> +	{ "mux-gpios", &mux_gpios, 1 },
> +	{ },
> +};
> +
>  static void int3496_do_usb_id(struct work_struct *work)
>  {
>  	struct int3496_data *data =
> @@ -83,6 +94,13 @@ static int int3496_probe(struct platform_device *pdev)
>  	struct int3496_data *data;
>  	int ret;
>  
> +	ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
> +					acpi_int3496_default_gpios);
> +	if (ret) {
> +		dev_err(dev, "can't add GPIO ACPI mapping\n");
> +		return ret;
> +	}
> +
>  	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
>  	if (!data)
>  		return -ENOMEM;
> @@ -154,6 +172,7 @@ static int int3496_remove(struct platform_device *pdev)
>  	devm_free_irq(&pdev->dev, data->usb_id_irq, data);
>  	cancel_delayed_work_sync(&data->work);
>  
> +	acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));

Need to add the one blank line.

>  	return 0;
>  }
>  

Looks good to me.
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>

This patch depends on the patch2. So, after resending the v2,
I'll merge them if there is no problem.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

* Re: [PATCH v1 2/3] extcon: int3496: Rename GPIO pins in accordance with binding
       [not found]         ` <58AF8998.5000601-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2017-02-24 12:08           ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-02-24 12:08 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: Andy Shevchenko, MyungJoo Ham,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Rob Herring,
	devicetree, David Cohen, Felipe Balbi

On Fri, Feb 24, 2017 at 3:17 AM, Chanwoo Choi <cw00.choi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> wrote:
> On 2017년 02월 23일 19:31, Andy Shevchenko wrote:
>> First of all, add an optional binding for external muxer which might be
>> used.

>> --- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
>> +++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
>> @@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can be present as well.
>>  - id-gpio: gpio for USB ID pin. See gpio binding.
>>  - vbus-gpio: gpio for USB VBUS pin.
>>
>> +Optional properties:
>> +- mux-gpios: gpio for USB external muxer
>
> The Documentation/extcon/intel-int3496.txt includes
> already the information for id/vbus/mux pin.

Thanks for pointing this out...

> The extcon-usb-gpio.txt is not related with the extcon-int3496 driver.

...but the bindings is related to ACPI somehow. I dunno why in
extcon-usb-gpio.c we have
        if (!np && !ACPI_HANDLE(dev))

...and thus it means either firmware chooses we better to have
standardized bindings in both cases.

OTOH mux-gpios indeed doesn't make sense for extcon-usb-gpio.c and
would be removed from the bindings.

I'll update patches accordingly.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-02-24 12:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20170223103303epcas3p496d768c3638368e98a9f6d95cb13380b@epcas3p4.samsung.com>
2017-02-23 10:31 ` [PATCH v1 1/3] extcon: int3496: Propagate error code of gpiod_to_irq() Andy Shevchenko
2017-02-23 10:31   ` [PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table Andy Shevchenko
2017-02-24  1:30     ` Chanwoo Choi
     [not found]   ` <20170223103156.109643-1-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-02-23 10:31     ` [PATCH v1 2/3] extcon: int3496: Rename GPIO pins in accordance with binding Andy Shevchenko
2017-02-24  1:17       ` Chanwoo Choi
     [not found]         ` <58AF8998.5000601-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2017-02-24 12:08           ` Andy Shevchenko
2017-02-24  1:09     ` [PATCH v1 1/3] extcon: int3496: Propagate error code of gpiod_to_irq() Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).