linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: tegra186: Add ACPI support
@ 2021-06-17 10:05 Akhil R
  2021-06-17 14:54 ` Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Akhil R @ 2021-06-17 10:05 UTC (permalink / raw)
  To: akhilrajeev, Linus Walleij, Bartosz Golaszewski, Thierry Reding,
	Jonathan Hunter
  Cc: linux-gpio, linux-tegra, linux-kernel, Mikko Perttunen,
	Laxman Dewangan, Suresh Mangipudi, Krishna Yarlagadda

From: Akhil Rajeev <akhilrajeev@nvidia.com>

Add ACPI module ID to probe the driver from the ACPI based bootloader
firmware.

Signed-off-by: Akhil Rajeev <akhilrajeev@nvidia.com>
---

 drivers/gpio/gpio-tegra186.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
index 1bd9e44..c8051be 100644
--- a/drivers/gpio/gpio-tegra186.c
+++ b/drivers/gpio/gpio-tegra186.c
@@ -5,6 +5,7 @@
  * Author: Thierry Reding <treding@nvidia.com>
  */
 
+#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,
-- 
2.7.4


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

end of thread, other threads:[~2021-08-05 19:31 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 10:05 [PATCH] gpio: tegra186: Add ACPI support Akhil R
2021-06-17 14:54 ` Linus Walleij
2021-06-17 15:21 ` Andy Shevchenko
2021-06-18 13:39   ` [PATCH v2] " Akhil R
2021-06-18 14:31     ` Andy Shevchenko
2021-06-21 15:08       ` Akhil R
2021-06-29 15:17         ` Akhil R
2021-06-30 16:14         ` Andy Shevchenko
2021-06-30 17:47           ` Akhil R
2021-06-30 18:17             ` [PATCH v3] " Akhil R
2021-06-30 18:23               ` Andy Shevchenko
2021-07-01  5:01                 ` [PATCH v4] " Akhil R
2021-07-01  5:53                   ` Jon Hunter
2021-07-01  9:00                     ` [PATCH v5] " Akhil R
2021-07-08 13:08                       ` Jon Hunter
2021-07-16  8:31                       ` Bartosz Golaszewski
2021-07-19  4:46                         ` [PATCH v6] " Akhil R
2021-08-05 19:30                           ` Bartosz Golaszewski
2021-06-18 19:39 ` [PATCH] " kernel test robot

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).