linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: support for NXP i2c controller
@ 2019-07-11 10:26 Chuanhua Han
  2019-07-18  8:45 ` Rafael J. Wysocki
  2019-09-02 20:56 ` Rafael J. Wysocki
  0 siblings, 2 replies; 11+ messages in thread
From: Chuanhua Han @ 2019-07-11 10:26 UTC (permalink / raw)
  To: rjw, lenb, shawnguo, s.hauer
  Cc: linux-acpi, linux-kernel, linux-i2c, linux-arm-kernel,
	leoyang.li, Chuanhua Han, Meenakshi Aggarwal, Udit Kumar

Enable NXP i2c controller to boot with ACPI

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
---
 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 = {
 	.fixed_clk_rate = 125000000,
 };
 
+static const struct apd_device_desc nxp_i2c_desc = {
+	.setup = acpi_apd_setup,
+	.fixed_clk_rate = 350000000,
+};
+
 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[] = {
 	{ "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)
 {
 	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)
 
 	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)
 	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));
 
 	/* 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


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

* Re: [PATCH] ACPI: support for NXP i2c controller
  2019-07-11 10:26 [PATCH] ACPI: support for NXP i2c controller Chuanhua Han
@ 2019-07-18  8:45 ` Rafael J. Wysocki
  2019-07-18  8:48   ` [EXT] " Chuanhua Han
  2019-09-02 20:56 ` Rafael J. Wysocki
  1 sibling, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2019-07-18  8:45 UTC (permalink / raw)
  To: Chuanhua Han
  Cc: lenb, shawnguo, s.hauer, linux-acpi, linux-kernel, linux-i2c,
	linux-arm-kernel, leoyang.li, Meenakshi Aggarwal, Udit Kumar

On Thursday, July 11, 2019 12:26:01 PM CEST Chuanhua Han wrote:
> Enable NXP i2c controller to boot with ACPI
> 
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>

In case you want this to go in through the i2c tree:

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

or in case you want me to take it, please let me know, but I will need an ACK
from the i2c side then.

> ---
>  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 = {
>  	.fixed_clk_rate = 125000000,
>  };
>  
> +static const struct apd_device_desc nxp_i2c_desc = {
> +	.setup = acpi_apd_setup,
> +	.fixed_clk_rate = 350000000,
> +};
> +
>  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[] = {
>  	{ "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)
>  {
>  	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)
>  
>  	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)
>  	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));
>  
>  	/* 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,
>  };
> 





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

* RE: [EXT] Re: [PATCH] ACPI: support for NXP i2c controller
  2019-07-18  8:45 ` Rafael J. Wysocki
@ 2019-07-18  8:48   ` Chuanhua Han
  0 siblings, 0 replies; 11+ messages in thread
From: Chuanhua Han @ 2019-07-18  8:48 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: lenb, shawnguo, s.hauer, linux-acpi, linux-kernel, linux-i2c,
	linux-arm-kernel, Leo Li, Meenakshi Aggarwal, Udit Kumar

Hi, Rafael J. Wysocki

> -----Original Message-----
> From: Rafael J. Wysocki <rjw@rjwysocki.net>
> Sent: 2019年7月18日 16:45
> To: Chuanhua Han <chuanhua.han@nxp.com>
> Cc: lenb@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de;
> linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org;
> linux-i2c@vger.kernel.org; linux-arm-kernel@lists.infradead.org; Leo Li
> <leoyang.li@nxp.com>; Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>;
> Udit Kumar <udit.kumar@nxp.com>
> Subject: [EXT] Re: [PATCH] ACPI: support for NXP i2c controller
> 
> Caution: EXT Email
> 
> On Thursday, July 11, 2019 12:26:01 PM CEST Chuanhua Han wrote:
> > Enable NXP i2c controller to boot with ACPI
> >
> > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
> > Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
> 
> In case you want this to go in through the i2c tree:
> 
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> or in case you want me to take it, please let me know, but I will need an ACK
> from the i2c side then.
I'm sorry, I don't quite understand
> 
> > ---
> >  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 = {
> >       .fixed_clk_rate = 125000000,
> >  };
> >
> > +static const struct apd_device_desc nxp_i2c_desc = {
> > +     .setup = acpi_apd_setup,
> > +     .fixed_clk_rate = 350000000,
> > +};
> > +
> >  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[] = {
> >       { "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)  {
> >       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)
> >
> >       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)
> >       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));
> >
> >       /* 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,
> >  };
> >
> 
> 
> 


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

* Re: [PATCH] ACPI: support for NXP i2c controller
  2019-07-11 10:26 [PATCH] ACPI: support for NXP i2c controller Chuanhua Han
  2019-07-18  8:45 ` Rafael J. Wysocki
@ 2019-09-02 20:56 ` Rafael J. Wysocki
  2019-09-02 21:02   ` Wolfram Sang
                     ` (2 more replies)
  1 sibling, 3 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2019-09-02 20:56 UTC (permalink / raw)
  To: Chuanhua Han, Wolfram Sang
  Cc: Rafael J. Wysocki, Len Brown, Shawn Guo, Sascha Hauer,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux-i2c,
	Linux ARM, Leo Li, Meenakshi Aggarwal, Udit Kumar

On Thu, Jul 11, 2019 at 12:35 PM Chuanhua Han <chuanhua.han@nxp.com> wrote:
>
> Enable NXP i2c controller to boot with ACPI
>
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>

Wolfram, any objections to this from the i2c side?

> ---
>  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 = {
>         .fixed_clk_rate = 125000000,
>  };
>
> +static const struct apd_device_desc nxp_i2c_desc = {
> +       .setup = acpi_apd_setup,
> +       .fixed_clk_rate = 350000000,
> +};
> +
>  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[] = {
>         { "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)
>  {
>         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)
>
>         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)
>         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));
>
>         /* 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
>

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

* Re: [PATCH] ACPI: support for NXP i2c controller
  2019-09-02 20:56 ` Rafael J. Wysocki
@ 2019-09-02 21:02   ` Wolfram Sang
  2019-09-02 21:16   ` Andy Shevchenko
  2019-09-03 10:50   ` Oleksij Rempel
  2 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2019-09-02 21:02 UTC (permalink / raw)
  To: Rafael J. Wysocki, Oleksij Rempel
  Cc: Chuanhua Han, Rafael J. Wysocki, Len Brown, Shawn Guo,
	Sascha Hauer, ACPI Devel Maling List, Linux Kernel Mailing List,
	linux-i2c, Linux ARM, Leo Li, Meenakshi Aggarwal, Udit Kumar

[-- Attachment #1: Type: text/plain, Size: 4426 bytes --]

On Mon, Sep 02, 2019 at 10:56:22PM +0200, Rafael J. Wysocki wrote:
> On Thu, Jul 11, 2019 at 12:35 PM Chuanhua Han <chuanhua.han@nxp.com> wrote:
> >
> > Enable NXP i2c controller to boot with ACPI
> >
> > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
> > Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
> 
> Wolfram, any objections to this from the i2c side?

CCing the new maintainer of this driver...

> 
> > ---
> >  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 = {
> >         .fixed_clk_rate = 125000000,
> >  };
> >
> > +static const struct apd_device_desc nxp_i2c_desc = {
> > +       .setup = acpi_apd_setup,
> > +       .fixed_clk_rate = 350000000,
> > +};
> > +
> >  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[] = {
> >         { "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)
> >  {
> >         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)
> >
> >         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)
> >         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));
> >
> >         /* 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
> >

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] ACPI: support for NXP i2c controller
  2019-09-02 20:56 ` Rafael J. Wysocki
  2019-09-02 21:02   ` Wolfram Sang
@ 2019-09-02 21:16   ` Andy Shevchenko
  2019-09-03  5:41     ` Oleksij Rempel
  2019-09-03 10:50   ` Oleksij Rempel
  2 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2019-09-02 21:16 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Chuanhua Han, Wolfram Sang, Rafael J. Wysocki, Len Brown,
	Shawn Guo, Sascha Hauer, ACPI Devel Maling List,
	Linux Kernel Mailing List, linux-i2c, Linux ARM, Leo Li,
	Meenakshi Aggarwal, Udit Kumar

On Mon, Sep 2, 2019 at 11:58 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Thu, Jul 11, 2019 at 12:35 PM Chuanhua Han <chuanhua.han@nxp.com> wrote:
> >
> > Enable NXP i2c controller to boot with ACPI
> >
> > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
> > Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
>
> Wolfram, any objections to this from the i2c side?

May I propose amendment(s)?

> > @@ -44,6 +44,7 @@
> >  #include <linux/pm_runtime.h>
> >  #include <linux/sched.h>
> >  #include <linux/slab.h>

> > +#include <linux/acpi.h>

If it's kept in order, better to go with it. (Yes, it is as I have checked)
However, property.h should be included instead, see below.

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


> >         if (of_id)
> >                 i2c_imx->hwdata = of_id->data;
> > +       else if (acpi_id)
> > +               i2c_imx->hwdata = (struct imx_i2c_hwdata *)
> > +                               acpi_id->driver_data;


The above altogher may be replaced with

const struct imx_i2c_hwdata *match;
...
match = device_get_match_data(&pdev->dev);
if (match)
 i2c_imx->hwdata = match;
else
...

> > +               .acpi_match_table = ACPI_PTR(i2c_imx_acpi_ids),

Since there is no #ifdef guard no need to use ACPI_PTR().

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] ACPI: support for NXP i2c controller
  2019-09-02 21:16   ` Andy Shevchenko
@ 2019-09-03  5:41     ` Oleksij Rempel
       [not found]       ` <AM7PR04MB6885DB03C6B96C7932DDA74B8EB90@AM7PR04MB6885.eurprd04.prod.outlook.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Oleksij Rempel @ 2019-09-03  5:41 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki
  Cc: Chuanhua Han, Wolfram Sang, Rafael J. Wysocki, Len Brown,
	Shawn Guo, Sascha Hauer, ACPI Devel Maling List,
	Linux Kernel Mailing List, linux-i2c, Linux ARM, Leo Li,
	Meenakshi Aggarwal, Udit Kumar

Hi,

On 02.09.19 23:16, Andy Shevchenko wrote:
> On Mon, Sep 2, 2019 at 11:58 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>>
>> On Thu, Jul 11, 2019 at 12:35 PM Chuanhua Han <chuanhua.han@nxp.com> wrote:
>>>
>>> Enable NXP i2c controller to boot with ACPI
>>>
>>> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
>>> Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
>>> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
>>
>> Wolfram, any objections to this from the i2c side?
> 
> May I propose amendment(s)?
> 
>>> @@ -44,6 +44,7 @@
>>>   #include <linux/pm_runtime.h>
>>>   #include <linux/sched.h>
>>>   #include <linux/slab.h>
> 
>>> +#include <linux/acpi.h>
> 
> If it's kept in order, better to go with it. (Yes, it is as I have checked)
> However, property.h should be included instead, see below.
> 
>>>          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);
> 
> 
>>>          if (of_id)
>>>                  i2c_imx->hwdata = of_id->data;
>>> +       else if (acpi_id)
>>> +               i2c_imx->hwdata = (struct imx_i2c_hwdata *)
>>> +                               acpi_id->driver_data;
> 
> 
> The above altogher may be replaced with
> 
> const struct imx_i2c_hwdata *match;
> ...
> match = device_get_match_data(&pdev->dev);
> if (match)
>   i2c_imx->hwdata = match;
> else
> ...

Instead of "may be replaced", I would say: it should be replaced :)

>>> +               .acpi_match_table = ACPI_PTR(i2c_imx_acpi_ids),
> 
> Since there is no #ifdef guard no need to use ACPI_PTR().
> 

What iMX/(other NXP?) SoCs are with ACPI support?  Where I can get one? I would like to 
know more about it.

Kind regards,
Oleksij Rempel

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [PATCH] ACPI: support for NXP i2c controller
  2019-09-02 20:56 ` Rafael J. Wysocki
  2019-09-02 21:02   ` Wolfram Sang
  2019-09-02 21:16   ` Andy Shevchenko
@ 2019-09-03 10:50   ` Oleksij Rempel
  2019-09-03 11:08     ` Meenakshi Aggarwal
  2 siblings, 1 reply; 11+ messages in thread
From: Oleksij Rempel @ 2019-09-03 10:50 UTC (permalink / raw)
  To: Rafael J. Wysocki, Chuanhua Han, Wolfram Sang, Andy Shevchenko
  Cc: Rafael J. Wysocki, Len Brown, Shawn Guo, Sascha Hauer,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux-i2c,
	Linux ARM, Leo Li, Meenakshi Aggarwal, Udit Kumar

One more question,

On 02.09.19 22:56, Rafael J. Wysocki wrote:
> On Thu, Jul 11, 2019 at 12:35 PM Chuanhua Han <chuanhua.han@nxp.com> wrote:
>>
>> Enable NXP i2c controller to boot with ACPI
>>
>> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
>> Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
>> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
> 
> Wolfram, any objections to this from the i2c side?
> 
>> ---
>>   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 = {
>>          .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?


>>   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[] = {
>>          { "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)
>>   {
>>          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)
>>
>>          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)
>>          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));
>>
>>          /* 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                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* RE: [PATCH] ACPI: support for NXP i2c controller
  2019-09-03 10:50   ` Oleksij Rempel
@ 2019-09-03 11:08     ` Meenakshi Aggarwal
  0 siblings, 0 replies; 11+ messages in thread
From: Meenakshi Aggarwal @ 2019-09-03 11:08 UTC (permalink / raw)
  To: Oleksij Rempel, Rafael J. Wysocki, Chuanhua Han, Wolfram Sang,
	Andy Shevchenko, Biwen Li
  Cc: Rafael J. Wysocki, Len Brown, Shawn Guo, Sascha Hauer,
	ACPI Devel Maling List, Linux Kernel Mailing List, linux-i2c,
	Linux ARM, Leo Li, Udit Kumar

+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
> <chuanhua.han@nxp.com>; Wolfram Sang <wsa@the-dreams.de>; Andy
> Shevchenko <andy.shevchenko@gmail.com>
> Cc: Rafael J. Wysocki <rjw@rjwysocki.net>; Len Brown <lenb@kernel.org>;
> Shawn Guo <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
> ACPI Devel Maling List <linux-acpi@vger.kernel.org>; Linux Kernel Mailing List
> <linux-kernel@vger.kernel.org>; linux-i2c <linux-i2c@vger.kernel.org>; Linux
> ARM <linux-arm-kernel@lists.infradead.org>; Leo Li <leoyang.li@nxp.com>;
> Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>; Udit Kumar
> <udit.kumar@nxp.com>
> Subject: Re: [PATCH] ACPI: support for NXP i2c controller
> 
> One more question,
> 
> On 02.09.19 22:56, Rafael J. Wysocki wrote:
> > On Thu, Jul 11, 2019 at 12:35 PM Chuanhua Han <chuanhua.han@nxp.com>
> wrote:
> >>
> >> Enable NXP i2c controller to boot with ACPI
> >>
> >> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> >> Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
> >> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
> >
> > Wolfram, any objections to this from the i2c side?
> >
> >> ---
> >>   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 = {
> >>          .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?
> 
> 
> >>   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[] = {
> >>          { "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)
> >>   {
> >>          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)
> >>
> >>          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)
> >>          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));
> >>
> >>          /* 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 |

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

* RE: [PATCH] ACPI: support for NXP i2c controller
       [not found]       ` <AM7PR04MB6885DB03C6B96C7932DDA74B8EB90@AM7PR04MB6885.eurprd04.prod.outlook.com>
@ 2019-09-05  4:33         ` Biwen Li
  2019-09-05 15:04           ` Biwen Li
  0 siblings, 1 reply; 11+ messages in thread
From: Biwen Li @ 2019-09-05  4:33 UTC (permalink / raw)
  To: 'andy.shevchenko@gmail.com', 'rafael@kernel.org',
	Leo Li, Meenakshi Aggarwal, Udit Kumar,
	'wsa@the-dreams.de', 'rjw@rjwysocki.net'
  Cc: Chuanhua Han, 'shawnguo@kernel.org',
	's.hauer@pengutronix.de',
	'linux-acpi@vger.kernel.org',
	'linux-kernel@vger.kernel.org',
	'linux-i2c@vger.kernel.org',
	'linux-arm-kernel@lists.infradead.org'

> Hi,
> 
> On 02.09.19 23:16, Andy Shevchenko wrote:
> > On Mon, Sep 2, 2019 at 11:58 PM Rafael J. Wysocki <rafael@kernel.org>
> wrote:
> >>
> >> On Thu, Jul 11, 2019 at 12:35 PM Chuanhua Han <chuanhua.han@nxp.com>
> wrote:
> >>>
> >>> Enable NXP i2c controller to boot with ACPI
> >>>
> >>> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> >>> Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
> >>> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
> >>
> >> Wolfram, any objections to this from the i2c side?
> >
> > May I propose amendment(s)?
> >
> >>> @@ -44,6 +44,7 @@
> >>>   #include <linux/pm_runtime.h>
> >>>   #include <linux/sched.h>
> >>>   #include <linux/slab.h>
> >
> >>> +#include <linux/acpi.h>
> >
> > If it's kept in order, better to go with it. (Yes, it is as I have
> > checked) However, property.h should be included instead, see below.
> >
> >>>          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);
> >
> >
> >>>          if (of_id)
> >>>                  i2c_imx->hwdata = of_id->data;
> >>> +       else if (acpi_id)
> >>> +               i2c_imx->hwdata = (struct imx_i2c_hwdata *)
> >>> +                               acpi_id->driver_data;
> >
> >
> > The above altogher may be replaced with
> >
> > const struct imx_i2c_hwdata *match;
> > ...
> > match = device_get_match_data(&pdev->dev);
> > if (match)
> >   i2c_imx->hwdata = match;
> > else
> > ...
> 
> Instead of "may be replaced", I would say: it should be replaced :)
> 
> >>> +               .acpi_match_table = ACPI_PTR(i2c_imx_acpi_ids),
> >
> > Since there is no #ifdef guard no need to use ACPI_PTR().
> >
> 
> What iMX/(other NXP?) SoCs are with ACPI support?  Where I can get one? I
> would like to know more about it.
- Nxp has variety Socs, include i.MX, Layerscape, etc.
- You can get one from here https://www.nxp.com/design/qoriq-developer-resources/qoriq-lx2160a-development-board:LX2160A-RDB

> 
> Kind regards,
> Oleksij Rempel
> 
> --
> Pengutronix e.K.                           |
> |
> Industrial Linux Solutions                 |
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pe
> ngutronix.de%2F&amp;data=02%7C01%7Cmeenakshi.aggarwal%40nxp.com%
> 7C640eb015a91f4959d3b508d7303168fb%7C686ea1d3bc2b4c6fa92cd99c5c
> 301635%7C0%7C0%7C637030861076879938&amp;sdata=sPWtkVtHHDvoRR
> ZmWJuipCO%2BEwG%2BcupgZvcIV1%2BrlEY%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 |

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

* RE: [PATCH] ACPI: support for NXP i2c controller
  2019-09-05  4:33         ` Biwen Li
@ 2019-09-05 15:04           ` Biwen Li
  0 siblings, 0 replies; 11+ messages in thread
From: Biwen Li @ 2019-09-05 15:04 UTC (permalink / raw)
  To: 'andy.shevchenko@gmail.com', 'rafael@kernel.org',
	Leo Li, Meenakshi Aggarwal, Udit Kumar,
	'wsa@the-dreams.de', 'rjw@rjwysocki.net'
  Cc: Chuanhua Han, 'shawnguo@kernel.org',
	's.hauer@pengutronix.de',
	'linux-acpi@vger.kernel.org',
	'linux-kernel@vger.kernel.org',
	'linux-i2c@vger.kernel.org',
	'linux-arm-kernel@lists.infradead.org'

> 
> > Hi,
> >
> > On 02.09.19 23:16, Andy Shevchenko wrote:
> > > On Mon, Sep 2, 2019 at 11:58 PM Rafael J. Wysocki
> > > <rafael@kernel.org>
> > wrote:
> > >>
> > >> On Thu, Jul 11, 2019 at 12:35 PM Chuanhua Han
> > >> <chuanhua.han@nxp.com>
> > wrote:
> > >>>
> > >>> Enable NXP i2c controller to boot with ACPI
> > >>>
> > >>> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > >>> Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
> > >>> Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
> > >>
> > >> Wolfram, any objections to this from the i2c side?
> > >
> > > May I propose amendment(s)?
> > >
> > >>> @@ -44,6 +44,7 @@
> > >>>   #include <linux/pm_runtime.h>
> > >>>   #include <linux/sched.h>
> > >>>   #include <linux/slab.h>
> > >
> > >>> +#include <linux/acpi.h>
> > >
> > > If it's kept in order, better to go with it. (Yes, it is as I have
> > > checked) However, property.h should be included instead, see below.
Ok, got it. I will fix it in v2.
> > >
> > >>>          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);
> > >
> > >
> > >>>          if (of_id)
> > >>>                  i2c_imx->hwdata = of_id->data;
> > >>> +       else if (acpi_id)
> > >>> +               i2c_imx->hwdata = (struct imx_i2c_hwdata *)
> > >>> +                               acpi_id->driver_data;
> > >
> > >
> > > The above altogher may be replaced with
> > >
> > > const struct imx_i2c_hwdata *match;
> > > ...
> > > match = device_get_match_data(&pdev->dev);
> > > if (match)
> > >   i2c_imx->hwdata = match;
> > > else
> > > ...
> >
Ok, I will correct it in v2.
> > Instead of "may be replaced", I would say: it should be replaced :)
> >
> > >>> +               .acpi_match_table = ACPI_PTR(i2c_imx_acpi_ids),
> > >
> > > Since there is no #ifdef guard no need to use ACPI_PTR().
> > >
> >
> > What iMX/(other NXP?) SoCs are with ACPI support?  Where I can get
> > one? I would like to know more about it.
> - Nxp has variety Socs, include i.MX, Layerscape, etc.
> - You can get one from here
> https://www.nxp.com/design/qoriq-developer-resources/qoriq-lx2160a-develo
> pment-board:LX2160A-RDB
> 
> >
> > Kind regards,
> > Oleksij Rempel
> >
> > --
> > Pengutronix e.K.                           |
> > |
> > Industrial Linux Solutions                 |
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.p
> > e
> ngutronix.de%2F&amp;data=02%7C01%7Cmeenakshi.aggarwal%40nxp.com%
> >
> 7C640eb015a91f4959d3b508d7303168fb%7C686ea1d3bc2b4c6fa92cd99c5c
> >
> 301635%7C0%7C0%7C637030861076879938&amp;sdata=sPWtkVtHHDvoRR
> > ZmWJuipCO%2BEwG%2BcupgZvcIV1%2BrlEY%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 |

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

end of thread, other threads:[~2019-09-05 15:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11 10:26 [PATCH] ACPI: support for NXP i2c controller Chuanhua Han
2019-07-18  8:45 ` Rafael J. Wysocki
2019-07-18  8:48   ` [EXT] " Chuanhua Han
2019-09-02 20:56 ` Rafael J. Wysocki
2019-09-02 21:02   ` Wolfram Sang
2019-09-02 21:16   ` Andy Shevchenko
2019-09-03  5:41     ` Oleksij Rempel
     [not found]       ` <AM7PR04MB6885DB03C6B96C7932DDA74B8EB90@AM7PR04MB6885.eurprd04.prod.outlook.com>
2019-09-05  4:33         ` Biwen Li
2019-09-05 15:04           ` Biwen Li
2019-09-03 10:50   ` Oleksij Rempel
2019-09-03 11:08     ` Meenakshi Aggarwal

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