Thread (9 messages) 9 messages, 7 authors, 2019-09-03

RE: [PATCH] ACPI: support for NXP i2c controller

From: Meenakshi Aggarwal <hidden>
Date: 2019-09-03 11:08:15
Also in: linux-acpi, linux-i2c, lkml

+biwen
-----Original Message-----
From: Oleksij Rempel <o.rempel@pengutronix.de>
Sent: Tuesday, September 3, 2019 4:20 PM
To: Rafael J. Wysocki <rafael@kernel.org>; Chuanhua Han
[off-list ref]; Wolfram Sang [off-list ref]; Andy
Shevchenko [off-list ref]
Cc: Rafael J. Wysocki <redacted>; Len Brown <lenb@kernel.org>;
Shawn Guo [off-list ref]; Sascha Hauer [off-list ref];
ACPI Devel Maling List [off-list ref]; Linux Kernel Mailing List
[off-list ref]; linux-i2c [off-list ref]; Linux
ARM [off-list ref]; Leo Li [off-list ref];
Meenakshi Aggarwal [off-list ref]; Udit Kumar
[off-list ref]
Subject: Re: [PATCH] ACPI: support for NXP i2c controller

One more question,

On 02.09.19 22:56, Rafael J. Wysocki wrote:
quoted
On Thu, Jul 11, 2019 at 12:35 PM Chuanhua Han [off-list ref]
wrote:
quoted
quoted
Enable NXP i2c controller to boot with ACPI

Signed-off-by: Meenakshi Aggarwal <redacted>
Signed-off-by: Udit Kumar <redacted>
Signed-off-by: Chuanhua Han <redacted>
Wolfram, any objections to this from the i2c side?
quoted
---
  drivers/acpi/acpi_apd.c      |  6 ++++++
  drivers/i2c/busses/i2c-imx.c | 15 +++++++++++++++
  2 files changed, 21 insertions(+)
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c index
ff47317..cf8566c 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -165,6 +165,11 @@ static const struct apd_device_desc
thunderx2_i2c_desc = {
quoted
quoted
         .fixed_clk_rate = 125000000,
  };

+static const struct apd_device_desc nxp_i2c_desc = {
+       .setup = acpi_apd_setup,
+       .fixed_clk_rate = 350000000,
+};
I'm not ACPI expert, so need here some help for understanding. Here is ACPI
table for
NXP0001 id (found on the internet):
+  Device(I2C0) {
+    Name(_HID, "NXP0001")
+    Name(_UID, 0)
+    Name(_CRS, ResourceTemplate() {
+      Memory32Fixed(ReadWrite, I2C0_BASE, I2C_LEN)
+      Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { I2C0_IT }
+    }) // end of _CRS for i2c0 device
+    Name (_DSD, Package () {
+      ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+      Package () {
+         Package () {"clock-frequency", DEFAULT_PLAT_FREQ}, //This is
+ device specific
data, Need to see how to pass clk stuff
+      }
+    })

Should kernel some how get proper clock-frequency from the ACPI? Or we still
need to use hard coded .fixed_clk_rate in the kernel?

quoted
quoted
  static const struct apd_device_desc hip08_spi_desc = {
         .setup = acpi_apd_setup,
         .fixed_clk_rate = 250000000,
@@ -238,6 +243,7 @@ static const struct acpi_device_id
acpi_apd_device_ids[] = {
quoted
quoted
         { "HISI02A1", APD_ADDR(hip07_i2c_desc) },
         { "HISI02A2", APD_ADDR(hip08_i2c_desc) },
         { "HISI0173", APD_ADDR(hip08_spi_desc) },
+       { "NXP0001", APD_ADDR(nxp_i2c_desc) },
  #endif
         { }
  };
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index b1b8b93..99f9b96 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -44,6 +44,7 @@
  #include <linux/pm_runtime.h>
  #include <linux/sched.h>
  #include <linux/slab.h>
+#include <linux/acpi.h>

  /* This will be the driver name the kernel reports */
  #define DRIVER_NAME "imx-i2c"
@@ -255,6 +256,12 @@ static const struct of_device_id i2c_imx_dt_ids[] = {
  };
  MODULE_DEVICE_TABLE(of, i2c_imx_dt_ids);

+static const struct acpi_device_id i2c_imx_acpi_ids[] = {
+       {"NXP0001", .driver_data = (kernel_ulong_t)&vf610_i2c_hwdata},
+       { }
+};
+MODULE_DEVICE_TABLE(acpi, i2c_imx_acpi_ids);
+
  static inline int is_imx1_i2c(struct imx_i2c_struct *i2c_imx)
  {
         return i2c_imx->hwdata->devtype == IMX1_I2C;
@@ -1052,6 +1059,9 @@ static int i2c_imx_probe(struct platform_device
*pdev)
quoted
quoted
  {
         const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids,
                                                            &pdev->dev);
+       const struct acpi_device_id *acpi_id =
+                       acpi_match_device(i2c_imx_acpi_ids,
+                                         &pdev->dev);
         struct imx_i2c_struct *i2c_imx;
         struct resource *res;
         struct imxi2c_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -1079,6 +1089,9 @@ static int i2c_imx_probe(struct platform_device
*pdev)
quoted
quoted
         if (of_id)
                 i2c_imx->hwdata = of_id->data;
+       else if (acpi_id)
+               i2c_imx->hwdata = (struct imx_i2c_hwdata *)
+                               acpi_id->driver_data;
         else
                 i2c_imx->hwdata = (struct imx_i2c_hwdata *)
                                 platform_get_device_id(pdev)->driver_data;
@@ -1091,6 +1104,7 @@ static int i2c_imx_probe(struct platform_device
*pdev)
quoted
quoted
         i2c_imx->adapter.nr             = pdev->id;
         i2c_imx->adapter.dev.of_node    = pdev->dev.of_node;
         i2c_imx->base                   = base;
+       ACPI_COMPANION_SET(&i2c_imx->adapter.dev,
ACPI_COMPANION(&pdev->dev));
quoted
quoted
         /* Get I2C clock */
         i2c_imx->clk = devm_clk_get(&pdev->dev, NULL);
@@ -1253,6 +1267,7 @@ static struct platform_driver i2c_imx_driver = {
                 .name = DRIVER_NAME,
                 .pm = &i2c_imx_pm_ops,
                 .of_match_table = i2c_imx_dt_ids,
+               .acpi_match_table = ACPI_PTR(i2c_imx_acpi_ids),
         },
         .id_table = imx_i2c_devtype,
  };
--
2.9.5
Kind regards,
Oleksij Rempel

--
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 |
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pen
gutronix.de%2F&amp;data=02%7C01%7Cmeenakshi.aggarwal%40nxp.com%7C
53801e593fbc47606f1d08d7305c8024%7C686ea1d3bc2b4c6fa92cd99c5c30163
5%7C0%7C0%7C637031046148090453&amp;sdata=PkS19Tph5n4gMcAJaG3sKs
ROkOm%2BhoUykGRdYy0PUOc%3D&amp;reserved=0  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help