Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1586800 > unrolled thread

[PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table

Started byAndy Shevchenko <andriy.shevchenko@linux.intel.com>
First post2017-02-23 11:40 +0100
Last post2017-02-24 02:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-02-23 11:40 +0100
    Re: [PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table Chanwoo Choi <cw00.choi@samsung.com> - 2017-02-24 02:40 +0100

#1586800 — [PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-02-23 11:40 +0100
Subject[PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table
Message-ID<tdYYx-8q5-3@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1587230

FromChanwoo Choi <cw00.choi@samsung.com>
Date2017-02-24 02:40 +0100
Message-ID<ted1v-18z-1@gated-at.bofh.it>
In reply to#1586800
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web