gpio: tegra186: Add ACPI support
Subsystems (2)
PATCH 1/1 gpio: tegra186: Add ACPI support
From: Akhil Rajeev <[email protected]>
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
---
drivers/gpio/gpio-tegra186.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-)
drivers/gpio/gpio-tegra186.c +28 -7
@@ -5,6 +5,7 @@* Author: Thierry Reding <[email protected]> */ +#include <linux/acpi.h> #include <linux/gpio/driver.h> #include <linux/interrupt.h> #include <linux/irq.h>
@@ -620,13 +621,18 @@ static int tegra186_gpio_probe(struct platform_device *pdev)if (!gpio)return -ENOMEM ; - gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev); +if (has_acpi_companion (&pdev->dev)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); + gpio->base =devm_platform_ioremap_resource (pdev,1 ); + }else { + gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); + gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); + } - gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" );if (IS_ERR (gpio->secure))return PTR_ERR (gpio->secure); - gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" );if (IS_ERR (gpio->base))return PTR_ERR (gpio->base);
@@ -690,11 +696,15 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->gpio.names = (const char *const *)names; - gpio->gpio.of_node = pdev->dev.of_node; - gpio->gpio.of_gpio_n_cells =2 ; - gpio->gpio.of_xlate = tegra186_gpio_of_xlate; - gpio->intc.name = pdev->dev.of_node->name; +if (!has_acpi_companion (&pdev->dev)) { + gpio->gpio.of_node = pdev->dev.of_node; + gpio->gpio.of_gpio_n_cells =2 ; + gpio->gpio.of_xlate = tegra186_gpio_of_xlate; + gpio->intc.name = pdev->dev.of_node->name; + }else { + gpio->intc.name = gpio->soc->name; + } gpio->intc.irq_ack = tegra186_irq_ack; gpio->intc.irq_mask = tegra186_irq_mask; gpio->intc.irq_unmask = tegra186_irq_unmask;
@@ -918,10 +928,21 @@ static const struct of_device_id tegra186_gpio_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra186_gpio_of_match); +#ifdef CONFIG_ACPI +static const struct acpi_device_id tegra186_gpio_acpi_match[] = { + { .id ="NVDA0108" , .driver_data = (kernel_ulong_t)&tegra186_main_soc }, + { .id ="NVDA0208" , .driver_data = (kernel_ulong_t)&tegra186_aon_soc }, + { .id ="NVDA0308" , .driver_data = (kernel_ulong_t)&tegra194_main_soc }, + { .id ="NVDA0408" , .driver_data = (kernel_ulong_t)&tegra194_aon_soc }, +}; +MODULE_DEVICE_TABLE (acpi, tegra186_gpio_acpi_match); +#endif +static struct platform_driver tegra186_gpio_driver = { .driver = { .name ="tegra186-gpio" , .of_match_table = tegra186_gpio_of_match, + .acpi_match_table =ACPI_PTR (tegra186_gpio_acpi_match), }, .probe = tegra186_gpio_probe, .remove = tegra186_gpio_remove,
Signature · 1 line
2.7.4
Hi Akhil,
thanks for your patch!
Quoted 6 lines · Akhil R
From: Akhil Rajeev <[email protected]>
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
Signed-off-by Akhil Rajeev <[email protected]>
Please include ACPI GPIO maintainer Andy Shevchenko on subsequent posts, he is looking after ACPI handling in the GPIO subsystem and always provide excellent reviews. (Added on To:)
It looks OK to my untrained eye, but I don't know ACPI details and expected behaviours as well as Andy.
Yours,
Linus Walleij
Quoted 5 lines · Akhil R
From: Akhil Rajeev <[email protected]>
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
...
Quoted 1 line
+#include <
linux/acpi.h>
It probably should be property.h, see below.
...
drivers/gpio/gpio-tegra186.c static int tegra186_gpio_probe(struct platform_device *pdev) · line 631
Quoted 7 lines
drivers/gpio/gpio-tegra186.c +7
-0+if (has_acpi_companion (&pdev->dev)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); + gpio->base =devm_platform_ioremap_resource (pdev,1 ); + }else { + gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); + gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); + }
General comment here.
Can't we rather try named resources first and fallback to indexed ones? (Or other way around)
In this case you don't need to check for ACPI at all.
...
Quoted 1 line
+ .acpi_match_table =
ACPI_PTR(tegra186_gpio_acpi_match),
You can drop ACPI_PTR() along with ugly ifdeffery.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 1/1 gpio: tegra186: Add ACPI support
From: Akhil Rajeev <[email protected]>
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
---
v2 changes:
* fallback to find resource by index if name is not found to support ACPI.
* removed #ifdef and ACPI_PTR.
* Apparently, acpi.h is required to support changes @@ -690,11 +697,15
drivers/gpio/gpio-tegra186.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-)
drivers/gpio/gpio-tegra186.c +30 -10
@@ -5,6 +5,7 @@* Author: Thierry Reding <[email protected]> */ +#include <linux/acpi.h> #include <linux/gpio/driver.h> #include <linux/interrupt.h> #include <linux/irq.h>
@@ -620,15 +621,21 @@ static int tegra186_gpio_probe(struct platform_device *pdev)if (!gpio)return -ENOMEM ; - gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev); gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); - gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base); + +if (IS_ERR (gpio->secure) ||IS_ERR (gpio->base)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); + gpio->base =devm_platform_ioremap_resource (pdev,1 ); + +if (IS_ERR (gpio->secure)) +return PTR_ERR (gpio->secure); + +if (IS_ERR (gpio->base)) +return PTR_ERR (gpio->base); + } err =platform_irq_count (pdev);if (err <0 )
@@ -690,11 +697,15 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->gpio.names = (const char *const *)names; - gpio->gpio.of_node = pdev->dev.of_node; - gpio->gpio.of_gpio_n_cells =2 ; - gpio->gpio.of_xlate = tegra186_gpio_of_xlate; - gpio->intc.name = pdev->dev.of_node->name; +if (!has_acpi_companion (&pdev->dev)) { + gpio->gpio.of_node = pdev->dev.of_node; + gpio->gpio.of_gpio_n_cells =2 ; + gpio->gpio.of_xlate = tegra186_gpio_of_xlate; + gpio->intc.name = pdev->dev.of_node->name; + }else { + gpio->intc.name = gpio->soc->name; + } gpio->intc.irq_ack = tegra186_irq_ack; gpio->intc.irq_mask = tegra186_irq_mask; gpio->intc.irq_unmask = tegra186_irq_unmask;
@@ -918,10 +929,19 @@ static const struct of_device_id tegra186_gpio_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra186_gpio_of_match); +static const struct acpi_device_id tegra186_gpio_acpi_match[] = { + { .id ="NVDA0108" , .driver_data = (kernel_ulong_t)&tegra186_main_soc }, + { .id ="NVDA0208" , .driver_data = (kernel_ulong_t)&tegra186_aon_soc }, + { .id ="NVDA0308" , .driver_data = (kernel_ulong_t)&tegra194_main_soc }, + { .id ="NVDA0408" , .driver_data = (kernel_ulong_t)&tegra194_aon_soc }, +}; +MODULE_DEVICE_TABLE (acpi, tegra186_gpio_acpi_match); +static struct platform_driver tegra186_gpio_driver = { .driver = { .name ="tegra186-gpio" , .of_match_table = tegra186_gpio_of_match, + .acpi_match_table = tegra186_gpio_acpi_match, }, .probe = tegra186_gpio_probe, .remove = tegra186_gpio_remove,
Signature · 1 line
2.7.4
On Fri, Jun 18, 2021 at 4:39 PM Akhil R <[email protected]> wrote:
Thanks for update, my comments below.
Quoted 1 line
From: Akhil Rajeev <[email protected]>
You need to fix your Git configuration so you won't have this header inside the commit message.
Quoted 2 lines
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
...
Quoted 1 line
+#include <
linux/acpi.h>
property.h ? (see below)
...
Quoted 11 lines
drivers/gpio/gpio-tegra186.c +1
-6- gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev); gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); - gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base);
drivers/gpio/gpio-tegra186.c static int tegra186_gpio_probe(struct platform_device *pdev)
Quoted 10 lines
drivers/gpio/gpio-tegra186.c +10
-0+if (IS_ERR (gpio->secure) ||IS_ERR (gpio->base)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); + gpio->base =devm_platform_ioremap_resource (pdev,1 ); + +if (IS_ERR (gpio->secure)) +return PTR_ERR (gpio->secure); + +if (IS_ERR (gpio->base)) +return PTR_ERR (gpio->base); + }
What about doing like
gpio->secure = devm_platform_ioremap_resource_byname(pdev, "security");
if (IS_ERR(gpio->secure))
gpio->secure = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(gpio->secure))
return PTR_ERR(gpio->secure);and similar for gpio->base?
...
Quoted 4 lines
drivers/gpio/gpio-tegra186.c +0
-3- gpio->gpio.of_node = pdev->dev.of_node; - gpio->gpio.of_gpio_n_cells =2 ; - gpio->gpio.of_xlate = tegra186_gpio_of_xlate;
drivers/gpio/gpio-tegra186.c static int tegra186_gpio_probe(struct platform_device *pdev) · line 708
Quoted 10 lines
drivers/gpio/gpio-tegra186.c +8
-1- gpio->intc.name = pdev->dev.of_node->name; +if (!has_acpi_companion (&pdev->dev)) { + gpio->gpio.of_node = pdev->dev.of_node; + gpio->gpio.of_gpio_n_cells =2 ; + gpio->gpio.of_xlate = tegra186_gpio_of_xlate; + gpio->intc.name = pdev->dev.of_node->name; + }else { + gpio->intc.name = gpio->soc->name; + }
Wouldn't the following be enough?
- gpio->intc.name = pdev->dev.of_node->name;
+ gpio->intc.name = devm_kasprintf(&pdev->dev, "%pfw",dev_fwnode(&pdev->dev));
+ if (!gpio->intc.name)
+ return -ENOMEM;
Note, all above are questions and you know better which direction to take. In either way, please test and look at the result.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Thanks Andy for the suggestions. Few thoughts I have below.
Quoted 9 lines
What about doing like
gpio->secure = devm_platform_ioremap_resource_byname(pdev, "security"); if (IS_ERR(gpio->secure)) gpio->secure = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(gpio->secure)) return PTR_ERR(gpio->secure);and similar for
gpio->base?
Wouldn't this cause a redundant check if it had already succeeded in getting the resource by name? Also, could it happen that if the device tree is incorrect, then one of the resource is fetched by name and other by the index, which I guess, would mess things up. Just my random thoughts, not sure if it is valid enough.
Review
Quoted 7 lines
Wouldn't the following be enough?
(quoted diff) +1
-1- gpio->intc.name = pdev->dev.of_node->name; + gpio->intc.name = devm_kasprintf(&pdev->dev, "%pfw",
dev_fwnode(&pdev->dev));(quoted diff) +2
-0+ if (!gpio->intc.name) +
How about this way? I feel it would be right to add the OF functions conditionally.
+ if (pdev->dev.of_node) {
+ gpio->gpio.of_node = pdev->dev.of_node; + gpio->gpio.of_gpio_n_cells = 2; + gpio->gpio.of_xlate = tegra186_gpio_of_xlate;
+ }
+ gpio->intc.name = gpio->soc->name;
--
Best Regards,
Akhil
Hi Andy,
Please let me know if you have any inputs regarding the changes.
--
Best Regards,
Akhil
Quoted 18 lines · Akhil R
Quoted 9 lines
What about doing like
gpio->secure = devm_platform_ioremap_resource_byname(pdev, "security"); if (IS_ERR(gpio->secure)) gpio->secure = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(gpio->secure)) return PTR_ERR(gpio->secure);and similar for
gpio->base?Wouldn't this cause a redundant check if it had already succeeded in getting the resource by name? Also, could it happen that if the device tree is incorrect, then one of the resource is fetched by name and other by the index, which I guess, would mess things up. Just my random thoughts, not sure if it is valid enough.
Quoted 2 lines
Wouldn't the following be enough?
Quoted 7 lines
Review
Quoted 5 lines
(quoted diff) +1
-1- gpio->intc.name = pdev->dev.of_node->name; + gpio->intc.name = devm_kasprintf(&pdev->dev, "%pfw",
dev_fwnode(&pdev->dev));(quoted diff) +2
-0+ if (!gpio->intc.name) +How about this way? I feel it would be right to add the OF functions conditionally.
Looks okay, although I have a question here.
Quoted 1 line
+ if (
pdev->dev.of_node) {
Do we really need this check at all? If the OF-node is NULL then it doesn't matter if other fields are filled or not, correct?
What you need is #ifdef CONFIG_OF_GPIO (IIRC the name correctly).
Quoted 6 lines
drivers/gpio/gpio-tegra186.c +5
-0+ gpio->gpio.of_node = pdev->dev.of_node; + gpio->gpio.of_gpio_n_cells =2 ; + gpio->gpio.of_xlate = tegra186_gpio_of_xlate; + } + gpio->intc.name = gpio->soc->name;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 26 lines
Quoted 18 lines
Quoted 1 line
What about doing like
gpio->secure = devm_platform_ioremap_resource_byname(pdev, "security");Quoted 6 lines
if (IS_ERR(gpio->secure)) gpio->secure = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(gpio->secure)) return PTR_ERR(gpio->secure);and similar for
gpio->base?Wouldn't this cause a redundant check if it had already succeeded in getting the resource by name? Also, could it happen that if the device tree is incorrect, then one of the resource is fetched by name and other by the index, which I guess, would mess things up. Just my random thoughts, not sure if it is valid enough.
Quoted 2 lines
Wouldn't the following be enough?
Quoted 7 lines
Review
Quoted 5 lines
(quoted diff) +1
-1- gpio->intc.name = pdev->dev.of_node->name; + gpio->intc.name = devm_kasprintf(&pdev->dev, "%pfw",
dev_fwnode(&pdev->dev));(quoted diff) +2
-0+ if (!gpio->intc.name) +How about this way? I feel it would be right to add the OF functions conditionally.
Quoted 15 lines
Looks okay, although I have a question here.
+ if (
pdev->dev.of_node) {Do we really need this check at all? If the OF-node is NULL then it doesn't matter if other fields are filled or not, correct?
What you need is #ifdef
CONFIG_OF_GPIO(IIRC the name correctly).Quoted 6 lines
drivers/gpio/gpio-tegra186.c +5
-0+ gpio->gpio.of_node = pdev->dev.of_node; + gpio->gpio.of_gpio_n_cells =2 ; + gpio->gpio.of_xlate = tegra186_gpio_of_xlate; + } + gpio->intc.name = gpio->soc->name;
Okay. It makes sense. Thanks Andy. I would make the changes and send out an updated patch.
--
Best Regards,
Akhil
PATCH v3 1/1 gpio: tegra186: Add ACPI support
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
--- drivers/gpio/gpio-tegra186.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
drivers/gpio/gpio-tegra186.c +25 -7
@@ -620,15 +620,21 @@ static int tegra186_gpio_probe(struct platform_device *pdev)if (!gpio)return -ENOMEM ; - gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev); gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); - gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base); + +if (IS_ERR (gpio->secure) ||IS_ERR (gpio->base)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); + gpio->base =devm_platform_ioremap_resource (pdev,1 ); + +if (IS_ERR (gpio->secure)) +return PTR_ERR (gpio->secure); + +if (IS_ERR (gpio->base)) +return PTR_ERR (gpio->base); + } err =platform_irq_count (pdev);if (err <0 )
@@ -690,11 +696,13 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->gpio.names = (const char *const *)names; +#if defined(CONFIG_OF_GPIO ) gpio->gpio.of_node = pdev->dev.of_node; gpio->gpio.of_gpio_n_cells =2 ; gpio->gpio.of_xlate = tegra186_gpio_of_xlate; +#endif /* CONFIG_OF_GPIO */ - gpio->intc.name = pdev->dev.of_node->name; + gpio->intc.name =dev_name (&pdev->dev); gpio->intc.irq_ack = tegra186_irq_ack; gpio->intc.irq_mask = tegra186_irq_mask; gpio->intc.irq_unmask = tegra186_irq_unmask;
@@ -918,10 +926,20 @@ static const struct of_device_id tegra186_gpio_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra186_gpio_of_match); +static const struct acpi_device_id tegra186_gpio_acpi_match[] = { + { .id ="NVDA0108" , .driver_data = (kernel_ulong_t)&tegra186_main_soc }, + { .id ="NVDA0208" , .driver_data = (kernel_ulong_t)&tegra186_aon_soc }, + { .id ="NVDA0308" , .driver_data = (kernel_ulong_t)&tegra194_main_soc }, + { .id ="NVDA0408" , .driver_data = (kernel_ulong_t)&tegra194_aon_soc }, + {}, +}; +MODULE_DEVICE_TABLE (acpi, tegra186_gpio_acpi_match); +static struct platform_driver tegra186_gpio_driver = { .driver = { .name ="tegra186-gpio" , .of_match_table = tegra186_gpio_of_match, + .acpi_match_table = tegra186_gpio_acpi_match, }, .probe = tegra186_gpio_probe, .remove = tegra186_gpio_remove,
Signature · 1 line
2.7.4
Quoted 3 lines · Akhil R
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
Thanks for an update, my comments below.
After addressing, feel free to add
Quoted 1 line
Change-Id: Id8e892f989e4ccc935b87aa0d84b10a3d1efd8f9
This is not for upstream.
Quoted 1 line
Signed-off-by Akhil Rajeev <[email protected]>
...
drivers/gpio/gpio-tegra186.c static const struct of_device_id tegra186_gpio_of_match[] = { · line 934
Quoted 7 lines
drivers/gpio/gpio-tegra186.c +6
-0+static const struct acpi_device_id tegra186_gpio_acpi_match[] = { + { .id ="NVDA0108" , .driver_data = (kernel_ulong_t)&tegra186_main_soc }, + { .id ="NVDA0208" , .driver_data = (kernel_ulong_t)&tegra186_aon_soc }, + { .id ="NVDA0308" , .driver_data = (kernel_ulong_t)&tegra194_main_soc }, + { .id ="NVDA0408" , .driver_data = (kernel_ulong_t)&tegra194_aon_soc }, + {},
Comma is not needed for terminator lines.
Quoted 2 lines
drivers/gpio/gpio-tegra186.c +2
-0+}; +MODULE_DEVICE_TABLE (acpi, tegra186_gpio_acpi_match);
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v4 1/1 gpio: tegra186: Add ACPI support
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
--- drivers/gpio/gpio-tegra186.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
drivers/gpio/gpio-tegra186.c +25 -7
@@ -620,15 +620,21 @@ static int tegra186_gpio_probe(struct platform_device *pdev)if (!gpio)return -ENOMEM ; - gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev); gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); - gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base); + +if (IS_ERR (gpio->secure) ||IS_ERR (gpio->base)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); + gpio->base =devm_platform_ioremap_resource (pdev,1 ); + +if (IS_ERR (gpio->secure)) +return PTR_ERR (gpio->secure); + +if (IS_ERR (gpio->base)) +return PTR_ERR (gpio->base); + } err =platform_irq_count (pdev);if (err <0 )
@@ -690,11 +696,13 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->gpio.names = (const char *const *)names; +#if defined(CONFIG_OF_GPIO ) gpio->gpio.of_node = pdev->dev.of_node; gpio->gpio.of_gpio_n_cells =2 ; gpio->gpio.of_xlate = tegra186_gpio_of_xlate; +#endif /* CONFIG_OF_GPIO */ - gpio->intc.name = pdev->dev.of_node->name; + gpio->intc.name =dev_name (&pdev->dev); gpio->intc.irq_ack = tegra186_irq_ack; gpio->intc.irq_mask = tegra186_irq_mask; gpio->intc.irq_unmask = tegra186_irq_unmask;
@@ -918,10 +926,20 @@ static const struct of_device_id tegra186_gpio_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra186_gpio_of_match); +static const struct acpi_device_id tegra186_gpio_acpi_match[] = { + { .id ="NVDA0108" , .driver_data = (kernel_ulong_t)&tegra186_main_soc }, + { .id ="NVDA0208" , .driver_data = (kernel_ulong_t)&tegra186_aon_soc }, + { .id ="NVDA0308" , .driver_data = (kernel_ulong_t)&tegra194_main_soc }, + { .id ="NVDA0408" , .driver_data = (kernel_ulong_t)&tegra194_aon_soc }, + {} +}; +MODULE_DEVICE_TABLE (acpi, tegra186_gpio_acpi_match); +static struct platform_driver tegra186_gpio_driver = { .driver = { .name ="tegra186-gpio" , .of_match_table = tegra186_gpio_of_match, + .acpi_match_table = tegra186_gpio_acpi_match, }, .probe = tegra186_gpio_probe, .remove = tegra186_gpio_remove,
Signature · 1 line
2.7.4
Jon Hunter
maintainerQuoted 19 lines · Akhil R
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
Signed-off-by Akhil R <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpio-tegra186.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)drivers/gpio/gpio-tegra186.c +1
-1@@ -620,15 +620,21 @@ static int tegra186_gpio_probe(struct platform_device *pdev)if (!gpio)return -ENOMEM ; - gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev);
drivers/gpio/gpio-tegra186.c static int tegra186_gpio_probe(struct platform_device *pdev) · line 628
Quoted 10 lines
drivers/gpio/gpio-tegra186.c +2
-5gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); - gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base); + +if (IS_ERR (gpio->secure) ||IS_ERR (gpio->base)) {
The OR here seems a bit odd, my preference would be how Andy suggested initially ...
gpio->secure = devm_platform_ioremap_resource_byname(pdev, "security");
if (IS_ERR(gpio->secure)) {
gpio->secure = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(gpio->secure))
return PTR_ERR(gpio->secure)
}Cheers
Jon
Signature · 1 line
nvpublic
PATCH v5 1/1 gpio: tegra186: Add ACPI support
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
---
v5 changes:
* Updated ioremap_resource check as per Jon's comments.
drivers/gpio/gpio-tegra186.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
drivers/gpio/gpio-tegra186.c +24 -6
@@ -620,15 +620,21 @@ static int tegra186_gpio_probe(struct platform_device *pdev)if (!gpio)return -ENOMEM ; - gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev); gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); +if (IS_ERR (gpio->secure)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (gpio->secure)) +return PTR_ERR (gpio->secure); + } gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base); +if (IS_ERR (gpio->base)) { + gpio->base =devm_platform_ioremap_resource (pdev,1 ); +if (IS_ERR (gpio->base)) +return PTR_ERR (gpio->base); + } err =platform_irq_count (pdev);if (err <0 )
@@ -690,11 +696,13 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->gpio.names = (const char *const *)names; +#if defined(CONFIG_OF_GPIO ) gpio->gpio.of_node = pdev->dev.of_node; gpio->gpio.of_gpio_n_cells =2 ; gpio->gpio.of_xlate = tegra186_gpio_of_xlate; +#endif /* CONFIG_OF_GPIO */ - gpio->intc.name = pdev->dev.of_node->name; + gpio->intc.name =dev_name (&pdev->dev); gpio->intc.irq_ack = tegra186_irq_ack; gpio->intc.irq_mask = tegra186_irq_mask; gpio->intc.irq_unmask = tegra186_irq_unmask;
@@ -918,10 +926,20 @@ static const struct of_device_id tegra186_gpio_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra186_gpio_of_match); +static const struct acpi_device_id tegra186_gpio_acpi_match[] = { + { .id ="NVDA0108" , .driver_data = (kernel_ulong_t)&tegra186_main_soc }, + { .id ="NVDA0208" , .driver_data = (kernel_ulong_t)&tegra186_aon_soc }, + { .id ="NVDA0308" , .driver_data = (kernel_ulong_t)&tegra194_main_soc }, + { .id ="NVDA0408" , .driver_data = (kernel_ulong_t)&tegra194_aon_soc }, + {} +}; +MODULE_DEVICE_TABLE (acpi, tegra186_gpio_acpi_match); +static struct platform_driver tegra186_gpio_driver = { .driver = { .name ="tegra186-gpio" , .of_match_table = tegra186_gpio_of_match, + .acpi_match_table = tegra186_gpio_acpi_match, }, .probe = tegra186_gpio_probe, .remove = tegra186_gpio_remove,
Signature · 1 line
2.7.4
Quoted 70 lines · Akhil R
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
Signed-off-by Akhil R <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>---
v5 changes:
* Updatedioremap_resourcecheck as per Jon's comments.drivers/gpio/gpio-tegra186.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)drivers/gpio/gpio-tegra186.c +21
-6@@ -620,15 +620,21 @@ static int tegra186_gpio_probe(struct platform_device *pdev)if (!gpio)return -ENOMEM ; - gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev); gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); +if (IS_ERR (gpio->secure)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (gpio->secure)) +return PTR_ERR (gpio->secure); + } gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base); +if (IS_ERR (gpio->base)) { + gpio->base =devm_platform_ioremap_resource (pdev,1 ); +if (IS_ERR (gpio->base)) +return PTR_ERR (gpio->base); + } err =platform_irq_count (pdev);if (err <0 )@@ -690,11 +696,13 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->gpio.names = (const char *const *)names; +#if defined(CONFIG_OF_GPIO ) gpio->gpio.of_node = pdev->dev.of_node; gpio->gpio.of_gpio_n_cells =2 ; gpio->gpio.of_xlate = tegra186_gpio_of_xlate; +#endif /* CONFIG_OF_GPIO */ - gpio->intc.name = pdev->dev.of_node->name; + gpio->intc.name =dev_name (&pdev->dev); gpio->intc.irq_ack = tegra186_irq_ack; gpio->intc.irq_mask = tegra186_irq_mask; gpio->intc.irq_unmask = tegra186_irq_unmask;@@ -918,10 +926,20 @@ static const struct of_device_id tegra186_gpio_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra186_gpio_of_match); +static const struct acpi_device_id tegra186_gpio_acpi_match[] = { + { .id ="NVDA0108" , .driver_data = (kernel_ulong_t)&tegra186_main_soc }, + { .id ="NVDA0208" , .driver_data = (kernel_ulong_t)&tegra186_aon_soc }, + { .id ="NVDA0308" , .driver_data = (kernel_ulong_t)&tegra194_main_soc }, + { .id ="NVDA0408" , .driver_data = (kernel_ulong_t)&tegra194_aon_soc }, + {} +};
drivers/gpio/gpio-tegra186.c static const struct of_device_id tegra186_gpio_of_match[] = { · line 945
Quoted 10 lines
drivers/gpio/gpio-tegra186.c +3
-0+MODULE_DEVICE_TABLE (acpi, tegra186_gpio_acpi_match); +static struct platform_driver tegra186_gpio_driver = { .driver = { .name ="tegra186-gpio" , .of_match_table = tegra186_gpio_of_match, + .acpi_match_table = tegra186_gpio_acpi_match, }, .probe = tegra186_gpio_probe, .remove = tegra186_gpio_remove,
Looks good to me.
Cheers
Jon
Signature · 1 line
nvpublic
Quoted 81 lines · Akhil R
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
Signed-off-by Akhil R <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>---
v5 changes:
* Updatedioremap_resourcecheck as per Jon's comments.drivers/gpio/gpio-tegra186.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)drivers/gpio/gpio-tegra186.c +24
-7@@ -620,15 +620,21 @@ static int tegra186_gpio_probe(struct platform_device *pdev)if (!gpio)return -ENOMEM ; - gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev); gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); +if (IS_ERR (gpio->secure)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (gpio->secure)) +return PTR_ERR (gpio->secure); + } gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base); +if (IS_ERR (gpio->base)) { + gpio->base =devm_platform_ioremap_resource (pdev,1 ); +if (IS_ERR (gpio->base)) +return PTR_ERR (gpio->base); + } err =platform_irq_count (pdev);if (err <0 )@@ -690,11 +696,13 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->gpio.names = (const char *const *)names; +#if defined(CONFIG_OF_GPIO ) gpio->gpio.of_node = pdev->dev.of_node; gpio->gpio.of_gpio_n_cells =2 ; gpio->gpio.of_xlate = tegra186_gpio_of_xlate; +#endif /* CONFIG_OF_GPIO */ - gpio->intc.name = pdev->dev.of_node->name; + gpio->intc.name =dev_name (&pdev->dev); gpio->intc.irq_ack = tegra186_irq_ack; gpio->intc.irq_mask = tegra186_irq_mask; gpio->intc.irq_unmask = tegra186_irq_unmask;@@ -918,10 +926,20 @@ static const struct of_device_id tegra186_gpio_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra186_gpio_of_match); +static const struct acpi_device_id tegra186_gpio_acpi_match[] = { + { .id ="NVDA0108" , .driver_data = (kernel_ulong_t)&tegra186_main_soc }, + { .id ="NVDA0208" , .driver_data = (kernel_ulong_t)&tegra186_aon_soc }, + { .id ="NVDA0308" , .driver_data = (kernel_ulong_t)&tegra194_main_soc }, + { .id ="NVDA0408" , .driver_data = (kernel_ulong_t)&tegra194_aon_soc }, + {} +}; +MODULE_DEVICE_TABLE (acpi, tegra186_gpio_acpi_match); +static struct platform_driver tegra186_gpio_driver = { .driver = { .name ="tegra186-gpio" , .of_match_table = tegra186_gpio_of_match, + .acpi_match_table = tegra186_gpio_acpi_match, }, .probe = tegra186_gpio_probe, .remove = tegra186_gpio_remove, --
Quoted 2 lines
2.7.4
Can you rebase it on top of v5.14-rc1 and resend?
Bart
PATCH v6 1/1 gpio: tegra186: Add ACPI support
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
---
v6 changes:
* Rebased on top of v5.14-rc1
drivers/gpio/gpio-tegra186.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
drivers/gpio/gpio-tegra186.c +24 -6
@@ -610,15 +610,21 @@ static int tegra186_gpio_probe(struct platform_device *pdev)if (!gpio)return -ENOMEM ; - gpio->soc =of_device_get_match_data (&pdev->dev); + gpio->soc =device_get_match_data (&pdev->dev); gpio->secure =devm_platform_ioremap_resource_byname (pdev,"security" ); -if (IS_ERR (gpio->secure)) -return PTR_ERR (gpio->secure); +if (IS_ERR (gpio->secure)) { + gpio->secure =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (gpio->secure)) +return PTR_ERR (gpio->secure); + } gpio->base =devm_platform_ioremap_resource_byname (pdev,"gpio" ); -if (IS_ERR (gpio->base)) -return PTR_ERR (gpio->base); +if (IS_ERR (gpio->base)) { + gpio->base =devm_platform_ioremap_resource (pdev,1 ); +if (IS_ERR (gpio->base)) +return PTR_ERR (gpio->base); + } err =platform_irq_count (pdev);if (err <0 )
@@ -680,11 +686,13 @@ static int tegra186_gpio_probe(struct platform_device *pdev) gpio->gpio.names = (const char *const *)names; +#if defined(CONFIG_OF_GPIO ) gpio->gpio.of_node = pdev->dev.of_node; gpio->gpio.of_gpio_n_cells =2 ; gpio->gpio.of_xlate = tegra186_gpio_of_xlate; +#endif /* CONFIG_OF_GPIO */ - gpio->intc.name = pdev->dev.of_node->name; + gpio->intc.name =dev_name (&pdev->dev); gpio->intc.irq_ack = tegra186_irq_ack; gpio->intc.irq_mask = tegra186_irq_mask; gpio->intc.irq_unmask = tegra186_irq_unmask;
@@ -896,10 +904,20 @@ static const struct of_device_id tegra186_gpio_of_match[] = { };MODULE_DEVICE_TABLE (of, tegra186_gpio_of_match); +static const struct acpi_device_id tegra186_gpio_acpi_match[] = { + { .id ="NVDA0108" , .driver_data = (kernel_ulong_t)&tegra186_main_soc }, + { .id ="NVDA0208" , .driver_data = (kernel_ulong_t)&tegra186_aon_soc }, + { .id ="NVDA0308" , .driver_data = (kernel_ulong_t)&tegra194_main_soc }, + { .id ="NVDA0408" , .driver_data = (kernel_ulong_t)&tegra194_aon_soc }, + {} +}; +MODULE_DEVICE_TABLE (acpi, tegra186_gpio_acpi_match); +static struct platform_driver tegra186_gpio_driver = { .driver = { .name ="tegra186-gpio" , .of_match_table = tegra186_gpio_of_match, + .acpi_match_table = tegra186_gpio_acpi_match, }, .probe = tegra186_gpio_probe, };
Signature · 1 line
2.7.4
Bartosz Golaszewski
AppliedQuoted 7 lines · Akhil R
Add ACPI module ID to probe the driver from the ACPI based bootloader firmware.
Signed-off-by Akhil R <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Jon Hunter <[email protected]>
Quoted 7 lines
---
v6 changes:
* Rebased on top of v5.14-rc1drivers/gpio/gpio-tegra186.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
Applied, thanks!
Bartosz
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Akhil,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on gpio/for-next]
[also build test ERROR on v5.13-rc6 next-20210618]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Akhil-R/gpio-tegra186-Add-ACPI-support/20210617-180601 base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next config: x86_64-randconfig-s022-20210618 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.3-341-g8af24329-dirty # https://github.com/0day-ci/linux/commit/b8c186168bab74f0c9b85d7231fb09f562e10242 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Akhil-R/gpio-tegra186-Add-ACPI-support/20210617-180601 git checkout b8c186168bab74f0c9b85d7231fb09f562e10242 # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>, old ones prefixed by <<):
drivers/gpio/gpio-tegra186: struct acpi_device_id is 32 bytes. The last of 4 is:0x4e 0x56 0x44 0x41 0x30 0x34 0x30 0x38 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
>> FATAL: modpost: drivers/gpio/gpio-tegra186: struct acpi_device_id is not terminated with a NULL entry!
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org