Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-27 Thread Ken Xue
On Thu, 2014-11-27 at 13:46 +0200, Mika Westerberg wrote:
> On Wed, Nov 26, 2014 at 06:31:38PM +0800, Ken Xue wrote:
> > On Monday, 2014-11-24 at 02:47 +0100, Rafael J. Wysocki wrote:
> > > On Monday, November 24, 2014 01:02:30 AM Xue, Ken wrote:
> > > > 
> > > > On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
> > > > > This new feature is to interpret AMD specific ACPI device to platform 
> > > > > device such as I2C, UART found on AMD CZ and later chipsets. It is 
> > > > > based on example INTEL LPSS. Now, it can support AMD I2C & UART.
> > > > > 
> > > > > Signed-off-by: Ken Xue 
> > > > > Signed-off-by: Jeff Wu 
> > > > 
> > > > Generally speaking, this seems to duplicate much code from acpi_lpss 
> > > > which should be re-used instead.  What about moving the code that will 
> > > > be common between acpi_lpss and the new driver into a new file (say 
> > > > acpi_soc.c)?
> > > > 
> > > > Also, you need to avoid automatic creation of platform devices when 
> > > > !X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad 
> > > > things will happen.
> > > > 
> > > > [ken] sounds fair enough.  Let me take action to merge drivers to 
> > > > acpi_soc.c ? or you have other plan?
> > > 
> > > I'd prefer the common code to reside in one file (or one .c file and one 
> > > header
> > > file), and the driver-specific code to stay in separate per-driver files.
> > > 
> > [Ken] I wrote a proto type for acpi_soc.c. please help to confirm if it
> > can match your ideal. if yes, i will submit a new patch after do more
> > test and refine codes. I think it will impact lpss driver greatly, even
> > i have taken it into account. below codes is for acpi_soc.c.
> 
> In general looks good. I have few comments though.
[Ken] thanks for your comments.

> > 
> > >From fc323fb7b3b4cbb79bda05ce3b1d6d8dfe5e883b Mon Sep 17 00:00:00 2001
> > From: Ken Xue 
> > Date: Wed, 26 Nov 2014 17:15:30 +0800
> > Subject: [PATCH] This is proto type for acpi_soc.
> > 
> > Signed-off-by: Ken Xue 
> > ---
> >  arch/x86/Kconfig|  11 +++
> >  drivers/acpi/Makefile   |   2 +-
> >  drivers/acpi/acpi_apd.c | 123 
> >  drivers/acpi/acpi_soc.c | 213
> > 
> 
> This is line-wrapped, please make sure when you submit the actual patch
> that it is formatted properly. Also you need proper changelog etc.
[Ken] sure. 

> > +#include "internal.h"
> > +#include "acpi_soc.h"
> > +
> > +struct acpi_soc asoc;
> 
> static?
> 
> Also Is "asoc" good name? That might get confused with Alsa SoC (ASoC).
[Ken] I will use "static", and change name to be a_soc.


> > +
> > +static struct acpi_soc_dev_desc cz_i2c_desc = {
> > +   .setup = acpi_apd_setup;
> > +   .fixed_clk_rate = 13300,
> 
> Oh, good so now we can get rid the hack we did for
> i2c-designware-platdrv.c with this commit:
> 
> a445900c906092f i2c: designware: Add support for AMD I2C controller
> 
> Since now you have means to pass clock to the driver.
> 
> Are you going to handle that driver as well?
[Ken]sure, thanks. this was one of reasons to create AMD APD.

> > +};
> > +
> > +static struct acpi_soc_dev_desc cz_uart_desc = {
> > +   .setup = acpi_apd_setup;
> > +   .fixed_clk_rate = 4800,
> > +};
> > +
> > +#else
> > +
> > +#define APD_ADDR(desc) (0UL)
> > +
> > +#endif /* CONFIG_X86_INTEL_LPSS */
> > +
> > +static struct acpi_device_id acpi_apd_device_ids[] = {
> 
> const?
[ken]No. "acpi_soc_dev_desc" may be modified later.

> > +   /* Generic apd devices */
> > +   { "AMD0010", APD_ADDR(cz_i2c_desc) },
> > +   { "AMD0020", APD_ADDR(cz_uart_desc) },
> > +   { }
> > +};
> > +
> > +#ifdef X86_AMD_PLATFORM_DEVICE
> > +
> > +static ssize_t apd_device_desc_show(struct device *dev,
> > +   struct device_attribute *attr, char *buf)
> > +{
> > +   int ret;
> > +   struct acpi_device *adev;
> > +   struct acpi_soc_dev_private_data *pdata;
> > +   struct acpi_soc_dev_desc *dev_desc;
> > +
> > +   ret = acpi_bus_get_device(ACPI_HANDLE(dev), );
> > +   if (WARN_ON(ret))
> > +   return ret;
> > +
> > +   pdata = acpi_driver_data(adev);
> > +   if (WARN_ON(!pdata || !pdata->dev_desc))
> > +   return -ENODEV;
> > +   
> > +   dev_desc = pdata->dev_desc;
> > +   if (dev_desc->fixed_clk_rate)
> > +   return sprintf(buf, "Required fix rate clk %s: %ld\n",
> > +   dev_desc->clk->name,
> > +   dev_desc->fixed_clk_rate);
> > +   else
> > +   return sprintf(buf, "No need clk\n");
> > +}
> > +
> > +static DEVICE_ATTR(device_desc, S_IRUSR, apd_device_desc_show, NULL);
> > +
> > +static struct attribute *apd_attrs[] = {
> > +   _attr_device_desc.attr,
> > +   NULL,
> > +};
> > +
> > +static struct attribute_group apd_attr_group = {
> > +   .attrs = apd_attrs,
> > +   .name = "apd",
> > +};
> 
> This requires updating sysfs ABI but then again, do you really need the
> above? And does it belong to sysfs in the first place?
[Ken] 

Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-27 Thread Mika Westerberg
On Thu, Nov 27, 2014 at 06:06:35PM +0100, Rafael J. Wysocki wrote:
> On Thursday, November 27, 2014 01:46:37 PM Mika Westerberg wrote:
> > On Wed, Nov 26, 2014 at 06:31:38PM +0800, Ken Xue wrote:
> 
> [cut]
> 
> > > diff --git a/drivers/acpi/acpi_soc.h b/drivers/acpi/acpi_soc.h
> > > new file mode 100755
> > > index 000..96db30e
> > > --- /dev/null
> > > +++ b/drivers/acpi/acpi_soc.h
> > 
> > And all this belongs to drivers/acpi/internal.h.
> 
> I requested the new file.
> 
> I don't really want things specific to SoC drivers to be mixed up with ACPI 
> core
> stuff.  It may even be good to create a separate subdir for the SoC stuff, but
> that can be done later.

I see, thanks for the explanation.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-27 Thread Rafael J. Wysocki
On Thursday, November 27, 2014 01:46:37 PM Mika Westerberg wrote:
> On Wed, Nov 26, 2014 at 06:31:38PM +0800, Ken Xue wrote:

[cut]

> > diff --git a/drivers/acpi/acpi_soc.h b/drivers/acpi/acpi_soc.h
> > new file mode 100755
> > index 000..96db30e
> > --- /dev/null
> > +++ b/drivers/acpi/acpi_soc.h
> 
> And all this belongs to drivers/acpi/internal.h.

I requested the new file.

I don't really want things specific to SoC drivers to be mixed up with ACPI core
stuff.  It may even be good to create a separate subdir for the SoC stuff, but
that can be done later.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-27 Thread Mika Westerberg
On Wed, Nov 26, 2014 at 06:31:38PM +0800, Ken Xue wrote:
> On 一, 2014-11-24 at 02:47 +0100, Rafael J. Wysocki wrote:
> > On Monday, November 24, 2014 01:02:30 AM Xue, Ken wrote:
> > > 
> > > On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
> > > > This new feature is to interpret AMD specific ACPI device to platform 
> > > > device such as I2C, UART found on AMD CZ and later chipsets. It is 
> > > > based on example INTEL LPSS. Now, it can support AMD I2C & UART.
> > > > 
> > > > Signed-off-by: Ken Xue 
> > > > Signed-off-by: Jeff Wu 
> > > 
> > > Generally speaking, this seems to duplicate much code from acpi_lpss 
> > > which should be re-used instead.  What about moving the code that will be 
> > > common between acpi_lpss and the new driver into a new file (say 
> > > acpi_soc.c)?
> > > 
> > > Also, you need to avoid automatic creation of platform devices when 
> > > !X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad 
> > > things will happen.
> > > 
> > > [ken] sounds fair enough.  Let me take action to merge drivers to 
> > > acpi_soc.c ? or you have other plan?
> > 
> > I'd prefer the common code to reside in one file (or one .c file and one 
> > header
> > file), and the driver-specific code to stay in separate per-driver files.
> > 
> [Ken] I wrote a proto type for acpi_soc.c. please help to confirm if it
> can match your ideal. if yes, i will submit a new patch after do more
> test and refine codes. I think it will impact lpss driver greatly, even
> i have taken it into account. below codes is for acpi_soc.c.

In general looks good. I have few comments though.

> 
> >From fc323fb7b3b4cbb79bda05ce3b1d6d8dfe5e883b Mon Sep 17 00:00:00 2001
> From: Ken Xue 
> Date: Wed, 26 Nov 2014 17:15:30 +0800
> Subject: [PATCH] This is proto type for acpi_soc.
> 
> Signed-off-by: Ken Xue 
> ---
>  arch/x86/Kconfig|  11 +++
>  drivers/acpi/Makefile   |   2 +-
>  drivers/acpi/acpi_apd.c | 123 
>  drivers/acpi/acpi_soc.c | 213
> 

This is line-wrapped, please make sure when you submit the actual patch
that it is formatted properly. Also you need proper changelog etc.

>  drivers/acpi/acpi_soc.h |  91 +
>  drivers/acpi/internal.h |   6 ++
>  drivers/acpi/scan.c |   1 +
>  7 files changed, 446 insertions(+), 1 deletion(-)
>  create mode 100755 drivers/acpi/acpi_apd.c
>  create mode 100755 drivers/acpi/acpi_soc.c
>  create mode 100755 drivers/acpi/acpi_soc.h
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index ded8a67..6402c79f 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -495,6 +495,17 @@ config X86_INTEL_LPSS
> things like clock tree (common clock framework) and pincontrol
> which are needed by the LPSS peripheral drivers.
>  
> +config X86_AMD_PLATFORM_DEVICE
> + bool "AMD ACPI2Platform devices support"
> + depends on ACPI
> + select COMMON_CLK
> + select PINCTRL
> + ---help---
> +   Select to interpret AMD specific ACPI device to platform device
> +   such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
> +   this option enables things like clock tree (common clock framework)
> +   and pinctrl.
> +
>  config IOSF_MBI
>   tristate "Intel SoC IOSF Sideband support for SoC platforms"
>   depends on PCI
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index c3b2fcb..b07003a 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -40,7 +40,7 @@ acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) +=
> processor_pdc.o
>  acpi-y   += ec.o
>  acpi-$(CONFIG_ACPI_DOCK) += dock.o
>  acpi-y   += pci_root.o pci_link.o pci_irq.o
> -acpi-y   += acpi_lpss.o
> +acpi-y   += acpi_soc.o acpi_lpss.o acpi_apd.o
>  acpi-y   += acpi_platform.o
>  acpi-y   += acpi_pnp.o
>  acpi-y   += int340x_thermal.o
> diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
> new file mode 100755
> index 000..c7e916b
> --- /dev/null
> +++ b/drivers/acpi/acpi_apd.c
> @@ -0,0 +1,123 @@
> +/*
> + * AMD ACPI support for  ACPI2platform device.
> + *
> + * Copyright (c) 2014, AMD Corporation.
> + * Authors: Ken Xue 
> + *   Wu, Jeff 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "internal.h"
> +#include "acpi_soc.h"
> +
> +struct acpi_soc asoc;

static?

Also Is "asoc" good name? That might get confused with Alsa SoC (ASoC).

> +
> +#ifdef X86_AMD_PLATFORM_DEVICE
> +static int acpi_apd_setup(struct acpi_soc_dev_private_data 

Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-27 Thread Mika Westerberg
On Wed, Nov 26, 2014 at 06:31:38PM +0800, Ken Xue wrote:
 On 一, 2014-11-24 at 02:47 +0100, Rafael J. Wysocki wrote:
  On Monday, November 24, 2014 01:02:30 AM Xue, Ken wrote:
   
   On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
This new feature is to interpret AMD specific ACPI device to platform 
device such as I2C, UART found on AMD CZ and later chipsets. It is 
based on example INTEL LPSS. Now, it can support AMD I2C  UART.

Signed-off-by: Ken Xue ken@amd.com
Signed-off-by: Jeff Wu jeff...@amd.com
   
   Generally speaking, this seems to duplicate much code from acpi_lpss 
   which should be re-used instead.  What about moving the code that will be 
   common between acpi_lpss and the new driver into a new file (say 
   acpi_soc.c)?
   
   Also, you need to avoid automatic creation of platform devices when 
   !X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad 
   things will happen.
   
   [ken] sounds fair enough.  Let me take action to merge drivers to 
   acpi_soc.c ? or you have other plan?
  
  I'd prefer the common code to reside in one file (or one .c file and one 
  header
  file), and the driver-specific code to stay in separate per-driver files.
  
 [Ken] I wrote a proto type for acpi_soc.c. please help to confirm if it
 can match your ideal. if yes, i will submit a new patch after do more
 test and refine codes. I think it will impact lpss driver greatly, even
 i have taken it into account. below codes is for acpi_soc.c.

In general looks good. I have few comments though.

 
 From fc323fb7b3b4cbb79bda05ce3b1d6d8dfe5e883b Mon Sep 17 00:00:00 2001
 From: Ken Xue ken@amd.com
 Date: Wed, 26 Nov 2014 17:15:30 +0800
 Subject: [PATCH] This is proto type for acpi_soc.
 
 Signed-off-by: Ken Xue ken@amd.com
 ---
  arch/x86/Kconfig|  11 +++
  drivers/acpi/Makefile   |   2 +-
  drivers/acpi/acpi_apd.c | 123 
  drivers/acpi/acpi_soc.c | 213
 

This is line-wrapped, please make sure when you submit the actual patch
that it is formatted properly. Also you need proper changelog etc.

  drivers/acpi/acpi_soc.h |  91 +
  drivers/acpi/internal.h |   6 ++
  drivers/acpi/scan.c |   1 +
  7 files changed, 446 insertions(+), 1 deletion(-)
  create mode 100755 drivers/acpi/acpi_apd.c
  create mode 100755 drivers/acpi/acpi_soc.c
  create mode 100755 drivers/acpi/acpi_soc.h
 
 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
 index ded8a67..6402c79f 100644
 --- a/arch/x86/Kconfig
 +++ b/arch/x86/Kconfig
 @@ -495,6 +495,17 @@ config X86_INTEL_LPSS
 things like clock tree (common clock framework) and pincontrol
 which are needed by the LPSS peripheral drivers.
  
 +config X86_AMD_PLATFORM_DEVICE
 + bool AMD ACPI2Platform devices support
 + depends on ACPI
 + select COMMON_CLK
 + select PINCTRL
 + ---help---
 +   Select to interpret AMD specific ACPI device to platform device
 +   such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
 +   this option enables things like clock tree (common clock framework)
 +   and pinctrl.
 +
  config IOSF_MBI
   tristate Intel SoC IOSF Sideband support for SoC platforms
   depends on PCI
 diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
 index c3b2fcb..b07003a 100644
 --- a/drivers/acpi/Makefile
 +++ b/drivers/acpi/Makefile
 @@ -40,7 +40,7 @@ acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) +=
 processor_pdc.o
  acpi-y   += ec.o
  acpi-$(CONFIG_ACPI_DOCK) += dock.o
  acpi-y   += pci_root.o pci_link.o pci_irq.o
 -acpi-y   += acpi_lpss.o
 +acpi-y   += acpi_soc.o acpi_lpss.o acpi_apd.o
  acpi-y   += acpi_platform.o
  acpi-y   += acpi_pnp.o
  acpi-y   += int340x_thermal.o
 diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
 new file mode 100755
 index 000..c7e916b
 --- /dev/null
 +++ b/drivers/acpi/acpi_apd.c
 @@ -0,0 +1,123 @@
 +/*
 + * AMD ACPI support for  ACPI2platform device.
 + *
 + * Copyright (c) 2014, AMD Corporation.
 + * Authors: Ken Xue ken@amd.com
 + *   Wu, Jeff jeff...@amd.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/acpi.h
 +#include linux/clk.h
 +#include linux/clkdev.h
 +#include linux/clk-provider.h
 +#include linux/err.h
 +#include linux/io.h
 +#include linux/platform_device.h
 +#include linux/pm_runtime.h
 +
 +#include internal.h
 +#include acpi_soc.h
 +
 +struct acpi_soc asoc;

static?

Also Is asoc good name? That might get confused with Alsa SoC (ASoC).

 +
 +#ifdef X86_AMD_PLATFORM_DEVICE
 +static int acpi_apd_setup(struct 

Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-27 Thread Rafael J. Wysocki
On Thursday, November 27, 2014 01:46:37 PM Mika Westerberg wrote:
 On Wed, Nov 26, 2014 at 06:31:38PM +0800, Ken Xue wrote:

[cut]

  diff --git a/drivers/acpi/acpi_soc.h b/drivers/acpi/acpi_soc.h
  new file mode 100755
  index 000..96db30e
  --- /dev/null
  +++ b/drivers/acpi/acpi_soc.h
 
 And all this belongs to drivers/acpi/internal.h.

I requested the new file.

I don't really want things specific to SoC drivers to be mixed up with ACPI core
stuff.  It may even be good to create a separate subdir for the SoC stuff, but
that can be done later.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-27 Thread Mika Westerberg
On Thu, Nov 27, 2014 at 06:06:35PM +0100, Rafael J. Wysocki wrote:
 On Thursday, November 27, 2014 01:46:37 PM Mika Westerberg wrote:
  On Wed, Nov 26, 2014 at 06:31:38PM +0800, Ken Xue wrote:
 
 [cut]
 
   diff --git a/drivers/acpi/acpi_soc.h b/drivers/acpi/acpi_soc.h
   new file mode 100755
   index 000..96db30e
   --- /dev/null
   +++ b/drivers/acpi/acpi_soc.h
  
  And all this belongs to drivers/acpi/internal.h.
 
 I requested the new file.
 
 I don't really want things specific to SoC drivers to be mixed up with ACPI 
 core
 stuff.  It may even be good to create a separate subdir for the SoC stuff, but
 that can be done later.

I see, thanks for the explanation.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-27 Thread Ken Xue
On Thu, 2014-11-27 at 13:46 +0200, Mika Westerberg wrote:
 On Wed, Nov 26, 2014 at 06:31:38PM +0800, Ken Xue wrote:
  On Monday, 2014-11-24 at 02:47 +0100, Rafael J. Wysocki wrote:
   On Monday, November 24, 2014 01:02:30 AM Xue, Ken wrote:

On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
 This new feature is to interpret AMD specific ACPI device to platform 
 device such as I2C, UART found on AMD CZ and later chipsets. It is 
 based on example INTEL LPSS. Now, it can support AMD I2C  UART.
 
 Signed-off-by: Ken Xue ken@amd.com
 Signed-off-by: Jeff Wu jeff...@amd.com

Generally speaking, this seems to duplicate much code from acpi_lpss 
which should be re-used instead.  What about moving the code that will 
be common between acpi_lpss and the new driver into a new file (say 
acpi_soc.c)?

Also, you need to avoid automatic creation of platform devices when 
!X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad 
things will happen.

[ken] sounds fair enough.  Let me take action to merge drivers to 
acpi_soc.c ? or you have other plan?
   
   I'd prefer the common code to reside in one file (or one .c file and one 
   header
   file), and the driver-specific code to stay in separate per-driver files.
   
  [Ken] I wrote a proto type for acpi_soc.c. please help to confirm if it
  can match your ideal. if yes, i will submit a new patch after do more
  test and refine codes. I think it will impact lpss driver greatly, even
  i have taken it into account. below codes is for acpi_soc.c.
 
 In general looks good. I have few comments though.
[Ken] thanks for your comments.

  
  From fc323fb7b3b4cbb79bda05ce3b1d6d8dfe5e883b Mon Sep 17 00:00:00 2001
  From: Ken Xue ken@amd.com
  Date: Wed, 26 Nov 2014 17:15:30 +0800
  Subject: [PATCH] This is proto type for acpi_soc.
  
  Signed-off-by: Ken Xue ken@amd.com
  ---
   arch/x86/Kconfig|  11 +++
   drivers/acpi/Makefile   |   2 +-
   drivers/acpi/acpi_apd.c | 123 
   drivers/acpi/acpi_soc.c | 213
  
 
 This is line-wrapped, please make sure when you submit the actual patch
 that it is formatted properly. Also you need proper changelog etc.
[Ken] sure. 

  +#include internal.h
  +#include acpi_soc.h
  +
  +struct acpi_soc asoc;
 
 static?
 
 Also Is asoc good name? That might get confused with Alsa SoC (ASoC).
[Ken] I will use static, and change name to be a_soc.


  +
  +static struct acpi_soc_dev_desc cz_i2c_desc = {
  +   .setup = acpi_apd_setup;
  +   .fixed_clk_rate = 13300,
 
 Oh, good so now we can get rid the hack we did for
 i2c-designware-platdrv.c with this commit:
 
 a445900c906092f i2c: designware: Add support for AMD I2C controller
 
 Since now you have means to pass clock to the driver.
 
 Are you going to handle that driver as well?
[Ken]sure, thanks. this was one of reasons to create AMD APD.

  +};
  +
  +static struct acpi_soc_dev_desc cz_uart_desc = {
  +   .setup = acpi_apd_setup;
  +   .fixed_clk_rate = 4800,
  +};
  +
  +#else
  +
  +#define APD_ADDR(desc) (0UL)
  +
  +#endif /* CONFIG_X86_INTEL_LPSS */
  +
  +static struct acpi_device_id acpi_apd_device_ids[] = {
 
 const?
[ken]No. acpi_soc_dev_desc may be modified later.

  +   /* Generic apd devices */
  +   { AMD0010, APD_ADDR(cz_i2c_desc) },
  +   { AMD0020, APD_ADDR(cz_uart_desc) },
  +   { }
  +};
  +
  +#ifdef X86_AMD_PLATFORM_DEVICE
  +
  +static ssize_t apd_device_desc_show(struct device *dev,
  +   struct device_attribute *attr, char *buf)
  +{
  +   int ret;
  +   struct acpi_device *adev;
  +   struct acpi_soc_dev_private_data *pdata;
  +   struct acpi_soc_dev_desc *dev_desc;
  +
  +   ret = acpi_bus_get_device(ACPI_HANDLE(dev), adev);
  +   if (WARN_ON(ret))
  +   return ret;
  +
  +   pdata = acpi_driver_data(adev);
  +   if (WARN_ON(!pdata || !pdata-dev_desc))
  +   return -ENODEV;
  +   
  +   dev_desc = pdata-dev_desc;
  +   if (dev_desc-fixed_clk_rate)
  +   return sprintf(buf, Required fix rate clk %s: %ld\n,
  +   dev_desc-clk-name,
  +   dev_desc-fixed_clk_rate);
  +   else
  +   return sprintf(buf, No need clk\n);
  +}
  +
  +static DEVICE_ATTR(device_desc, S_IRUSR, apd_device_desc_show, NULL);
  +
  +static struct attribute *apd_attrs[] = {
  +   dev_attr_device_desc.attr,
  +   NULL,
  +};
  +
  +static struct attribute_group apd_attr_group = {
  +   .attrs = apd_attrs,
  +   .name = apd,
  +};
 
 This requires updating sysfs ABI but then again, do you really need the
 above? And does it belong to sysfs in the first place?
[Ken] just want to output some debug information with sysfs. I think i
can add sysfs interface after APD has rich features in the future.

  
  +#include internal.h
  +#include acpi_soc.h
  +
  +
 
 Delete the extra blank line
[ken] got it.

 
  +   pdata-dev_desc = 

Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-26 Thread Ken Xue
On 一, 2014-11-24 at 02:47 +0100, Rafael J. Wysocki wrote:
> On Monday, November 24, 2014 01:02:30 AM Xue, Ken wrote:
> > 
> > On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
> > > This new feature is to interpret AMD specific ACPI device to platform 
> > > device such as I2C, UART found on AMD CZ and later chipsets. It is 
> > > based on example INTEL LPSS. Now, it can support AMD I2C & UART.
> > > 
> > > Signed-off-by: Ken Xue 
> > > Signed-off-by: Jeff Wu 
> > 
> > Generally speaking, this seems to duplicate much code from acpi_lpss which 
> > should be re-used instead.  What about moving the code that will be common 
> > between acpi_lpss and the new driver into a new file (say acpi_soc.c)?
> > 
> > Also, you need to avoid automatic creation of platform devices when 
> > !X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad things 
> > will happen.
> > 
> > [ken] sounds fair enough.  Let me take action to merge drivers to 
> > acpi_soc.c ? or you have other plan?
> 
> I'd prefer the common code to reside in one file (or one .c file and one 
> header
> file), and the driver-specific code to stay in separate per-driver files.
> 
[Ken] I wrote a proto type for acpi_soc.c. please help to confirm if it
can match your ideal. if yes, i will submit a new patch after do more
test and refine codes. I think it will impact lpss driver greatly, even
i have taken it into account. below codes is for acpi_soc.c.


>From fc323fb7b3b4cbb79bda05ce3b1d6d8dfe5e883b Mon Sep 17 00:00:00 2001
From: Ken Xue 
Date: Wed, 26 Nov 2014 17:15:30 +0800
Subject: [PATCH] This is proto type for acpi_soc.

Signed-off-by: Ken Xue 
---
 arch/x86/Kconfig|  11 +++
 drivers/acpi/Makefile   |   2 +-
 drivers/acpi/acpi_apd.c | 123 
 drivers/acpi/acpi_soc.c | 213

 drivers/acpi/acpi_soc.h |  91 +
 drivers/acpi/internal.h |   6 ++
 drivers/acpi/scan.c |   1 +
 7 files changed, 446 insertions(+), 1 deletion(-)
 create mode 100755 drivers/acpi/acpi_apd.c
 create mode 100755 drivers/acpi/acpi_soc.c
 create mode 100755 drivers/acpi/acpi_soc.h

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ded8a67..6402c79f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -495,6 +495,17 @@ config X86_INTEL_LPSS
  things like clock tree (common clock framework) and pincontrol
  which are needed by the LPSS peripheral drivers.
 
+config X86_AMD_PLATFORM_DEVICE
+   bool "AMD ACPI2Platform devices support"
+   depends on ACPI
+   select COMMON_CLK
+   select PINCTRL
+   ---help---
+ Select to interpret AMD specific ACPI device to platform device
+ such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
+ this option enables things like clock tree (common clock framework)
+ and pinctrl.
+
 config IOSF_MBI
tristate "Intel SoC IOSF Sideband support for SoC platforms"
depends on PCI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index c3b2fcb..b07003a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -40,7 +40,7 @@ acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) +=
processor_pdc.o
 acpi-y += ec.o
 acpi-$(CONFIG_ACPI_DOCK)   += dock.o
 acpi-y += pci_root.o pci_link.o pci_irq.o
-acpi-y += acpi_lpss.o
+acpi-y += acpi_soc.o acpi_lpss.o acpi_apd.o
 acpi-y += acpi_platform.o
 acpi-y += acpi_pnp.o
 acpi-y += int340x_thermal.o
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
new file mode 100755
index 000..c7e916b
--- /dev/null
+++ b/drivers/acpi/acpi_apd.c
@@ -0,0 +1,123 @@
+/*
+ * AMD ACPI support for  ACPI2platform device.
+ *
+ * Copyright (c) 2014, AMD Corporation.
+ * Authors: Ken Xue 
+ * Wu, Jeff 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "internal.h"
+#include "acpi_soc.h"
+
+struct acpi_soc asoc;
+
+#ifdef X86_AMD_PLATFORM_DEVICE
+static int acpi_apd_setup(struct acpi_soc_dev_private_data *pdata)
+{
+   struct acpi_soc_dev_desc *dev_desc = pdata->dev_desc;
+   struct clk *clk = ERR_PTR(-ENODEV);
+
+   if (dev_desc->clk)
+   return 0;
+   
+   if (dev_desc->fixed_clk_rate) {
+   clk = clk_register_fixed_rate(>adev->dev, 
+   dev_name(>adev->dev),
+   NULL, CLK_IS_ROOT, dev_desc->rate);
+   dev_desc->clk = clk;
+   clk_register_clkdev(clk, NULL, dev_name(>adev->dev));
+   }
+
+   return 0;
+}
+
+static struct acpi_soc_dev_desc 

Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-26 Thread Ken Xue
On 一, 2014-11-24 at 02:47 +0100, Rafael J. Wysocki wrote:
 On Monday, November 24, 2014 01:02:30 AM Xue, Ken wrote:
  
  On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
   This new feature is to interpret AMD specific ACPI device to platform 
   device such as I2C, UART found on AMD CZ and later chipsets. It is 
   based on example INTEL LPSS. Now, it can support AMD I2C  UART.
   
   Signed-off-by: Ken Xue ken@amd.com
   Signed-off-by: Jeff Wu jeff...@amd.com
  
  Generally speaking, this seems to duplicate much code from acpi_lpss which 
  should be re-used instead.  What about moving the code that will be common 
  between acpi_lpss and the new driver into a new file (say acpi_soc.c)?
  
  Also, you need to avoid automatic creation of platform devices when 
  !X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad things 
  will happen.
  
  [ken] sounds fair enough.  Let me take action to merge drivers to 
  acpi_soc.c ? or you have other plan?
 
 I'd prefer the common code to reside in one file (or one .c file and one 
 header
 file), and the driver-specific code to stay in separate per-driver files.
 
[Ken] I wrote a proto type for acpi_soc.c. please help to confirm if it
can match your ideal. if yes, i will submit a new patch after do more
test and refine codes. I think it will impact lpss driver greatly, even
i have taken it into account. below codes is for acpi_soc.c.


From fc323fb7b3b4cbb79bda05ce3b1d6d8dfe5e883b Mon Sep 17 00:00:00 2001
From: Ken Xue ken@amd.com
Date: Wed, 26 Nov 2014 17:15:30 +0800
Subject: [PATCH] This is proto type for acpi_soc.

Signed-off-by: Ken Xue ken@amd.com
---
 arch/x86/Kconfig|  11 +++
 drivers/acpi/Makefile   |   2 +-
 drivers/acpi/acpi_apd.c | 123 
 drivers/acpi/acpi_soc.c | 213

 drivers/acpi/acpi_soc.h |  91 +
 drivers/acpi/internal.h |   6 ++
 drivers/acpi/scan.c |   1 +
 7 files changed, 446 insertions(+), 1 deletion(-)
 create mode 100755 drivers/acpi/acpi_apd.c
 create mode 100755 drivers/acpi/acpi_soc.c
 create mode 100755 drivers/acpi/acpi_soc.h

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ded8a67..6402c79f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -495,6 +495,17 @@ config X86_INTEL_LPSS
  things like clock tree (common clock framework) and pincontrol
  which are needed by the LPSS peripheral drivers.
 
+config X86_AMD_PLATFORM_DEVICE
+   bool AMD ACPI2Platform devices support
+   depends on ACPI
+   select COMMON_CLK
+   select PINCTRL
+   ---help---
+ Select to interpret AMD specific ACPI device to platform device
+ such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
+ this option enables things like clock tree (common clock framework)
+ and pinctrl.
+
 config IOSF_MBI
tristate Intel SoC IOSF Sideband support for SoC platforms
depends on PCI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index c3b2fcb..b07003a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -40,7 +40,7 @@ acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) +=
processor_pdc.o
 acpi-y += ec.o
 acpi-$(CONFIG_ACPI_DOCK)   += dock.o
 acpi-y += pci_root.o pci_link.o pci_irq.o
-acpi-y += acpi_lpss.o
+acpi-y += acpi_soc.o acpi_lpss.o acpi_apd.o
 acpi-y += acpi_platform.o
 acpi-y += acpi_pnp.o
 acpi-y += int340x_thermal.o
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
new file mode 100755
index 000..c7e916b
--- /dev/null
+++ b/drivers/acpi/acpi_apd.c
@@ -0,0 +1,123 @@
+/*
+ * AMD ACPI support for  ACPI2platform device.
+ *
+ * Copyright (c) 2014, AMD Corporation.
+ * Authors: Ken Xue ken@amd.com
+ * Wu, Jeff jeff...@amd.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/acpi.h
+#include linux/clk.h
+#include linux/clkdev.h
+#include linux/clk-provider.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+
+#include internal.h
+#include acpi_soc.h
+
+struct acpi_soc asoc;
+
+#ifdef X86_AMD_PLATFORM_DEVICE
+static int acpi_apd_setup(struct acpi_soc_dev_private_data *pdata)
+{
+   struct acpi_soc_dev_desc *dev_desc = pdata-dev_desc;
+   struct clk *clk = ERR_PTR(-ENODEV);
+
+   if (dev_desc-clk)
+   return 0;
+   
+   if (dev_desc-fixed_clk_rate) {
+   clk = clk_register_fixed_rate(pdata-adev-dev, 
+   dev_name(pdata-adev-dev),
+   NULL, CLK_IS_ROOT, dev_desc-rate);
+   

RE: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-23 Thread Xue, Ken

On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
> This new feature is to interpret AMD specific ACPI device to platform 
> device such as I2C, UART found on AMD CZ and later chipsets. It is 
> based on example INTEL LPSS. Now, it can support AMD I2C & UART.
> 
> Signed-off-by: Ken Xue 
> Signed-off-by: Jeff Wu 

Generally speaking, this seems to duplicate much code from acpi_lpss which 
should be re-used instead.  What about moving the code that will be common 
between acpi_lpss and the new driver into a new file (say acpi_soc.c)?

Also, you need to avoid automatic creation of platform devices when 
!X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad things 
will happen.

[ken] sounds fair enough.  Let me take action to merge drivers to acpi_soc.c ? 
or you have other plan?

[...]
N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-23 Thread Rafael J. Wysocki
On Monday, November 24, 2014 01:02:30 AM Xue, Ken wrote:
> 
> On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
> > This new feature is to interpret AMD specific ACPI device to platform 
> > device such as I2C, UART found on AMD CZ and later chipsets. It is 
> > based on example INTEL LPSS. Now, it can support AMD I2C & UART.
> > 
> > Signed-off-by: Ken Xue 
> > Signed-off-by: Jeff Wu 
> 
> Generally speaking, this seems to duplicate much code from acpi_lpss which 
> should be re-used instead.  What about moving the code that will be common 
> between acpi_lpss and the new driver into a new file (say acpi_soc.c)?
> 
> Also, you need to avoid automatic creation of platform devices when 
> !X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad things 
> will happen.
> 
> [ken] sounds fair enough.  Let me take action to merge drivers to acpi_soc.c 
> ? or you have other plan?

I'd prefer the common code to reside in one file (or one .c file and one header
file), and the driver-specific code to stay in separate per-driver files.

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-23 Thread Rafael J. Wysocki
On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
> This new feature is to interpret AMD specific ACPI device to platform device
> such as I2C, UART found on AMD CZ and later chipsets. It is based on example
> INTEL LPSS. Now, it can support AMD I2C & UART.
> 
> Signed-off-by: Ken Xue 
> Signed-off-by: Jeff Wu 

Generally speaking, this seems to duplicate much code from acpi_lpss which
should be re-used instead.  What about moving the code that will be common
between acpi_lpss and the new driver into a new file (say acpi_soc.c)?

Also, you need to avoid automatic creation of platform devices when
!X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad things
will happen.


> ---
>  arch/x86/Kconfig|  11 +++
>  drivers/acpi/Makefile   |   1 +
>  drivers/acpi/acpi_apd.c | 245 
> 
>  drivers/acpi/internal.h |   6 ++
>  drivers/acpi/scan.c |   1 +
>  5 files changed, 264 insertions(+)
>  create mode 100644 drivers/acpi/acpi_apd.c
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index ded8a67..6402c79f 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -495,6 +495,17 @@ config X86_INTEL_LPSS
> things like clock tree (common clock framework) and pincontrol
> which are needed by the LPSS peripheral drivers.
>  
> +config X86_AMD_PLATFORM_DEVICE
> + bool "AMD ACPI2Platform devices support"
> + depends on ACPI
> + select COMMON_CLK
> + select PINCTRL
> + ---help---
> +   Select to interpret AMD specific ACPI device to platform device
> +   such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
> +   this option enables things like clock tree (common clock framework)
> +   and pinctrl.
> +
>  config IOSF_MBI
>   tristate "Intel SoC IOSF Sideband support for SoC platforms"
>   depends on PCI
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index c3b2fcb..91fc1c2 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -41,6 +41,7 @@ acpi-y  += ec.o
>  acpi-$(CONFIG_ACPI_DOCK) += dock.o
>  acpi-y   += pci_root.o pci_link.o pci_irq.o
>  acpi-y   += acpi_lpss.o
> +acpi-$(CONFIG_X86_AMD_PLATFORM_DEVICE)   += acpi_apd.o
>  acpi-y   += acpi_platform.o
>  acpi-y   += acpi_pnp.o
>  acpi-y   += int340x_thermal.o
> diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
> new file mode 100644
> index 000..994b7db
> --- /dev/null
> +++ b/drivers/acpi/acpi_apd.c
> @@ -0,0 +1,245 @@
> +/*
> + * AMD ACPI support for ACPI2platform device.
> + *
> + * Copyright (c) 2014, AMD Corporation.
> + * Authors: Ken Xue 
> + *   Jeff Wu 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "internal.h"
> +
> +ACPI_MODULE_NAME("acpi_apd");
> +struct apd_private_data;
> +
> +struct apd_device_desc {
> + bool clk_required;
> + bool fixed_root_clock;
> + const char *clk_name;
> + unsigned long   rate;
> + size_t prv_size_override;
> + void (*setup)(struct apd_private_data *pdata);
> +};
> +
> +struct apd_private_data {
> + void __iomem *mmio_base;
> + resource_size_t mmio_size;
> + struct clk *clk;
> + const struct apd_device_desc *dev_desc;
> +};
> +
> +static struct apd_device_desc amd_i2c_desc = {
> + .clk_required = true,
> + .fixed_root_clock = true,
> + .clk_name = "i2c_clk",
> + .rate = 13300, /*(133 * 1000 * 1000)*/
> +};
> +
> +static struct apd_device_desc amd_uart_desc = {
> + .clk_required = true,
> + .fixed_root_clock = true,
> + .clk_name = "uart_clk",
> + .rate = 4800,
> +};
> +
> +static const struct acpi_device_id acpi_apd_device_ids[] = {
> + /* Generic apd devices */
> + { "AMD0010", (unsigned long)_i2c_desc },
> + { "AMD0020", (unsigned long)_uart_desc },
> + { }
> +};
> +
> +static int is_memory(struct acpi_resource *res, void *not_used)
> +{
> + struct resource r;
> +
> + return !acpi_dev_resource_memory(res, );
> +}
> +
> +static int register_device_clock(struct acpi_device *adev,
> +  struct apd_private_data *pdata)
> +{
> + const struct apd_device_desc *dev_desc = pdata->dev_desc;
> + struct clk *clk = ERR_PTR(-ENODEV);
> +
> + clk = pdata->clk;
> + if (!clk && dev_desc->fixed_root_clock) {
> + clk = clk_register_fixed_rate(>dev, dev_name(>dev),
> +   NULL, CLK_IS_ROOT, dev_desc->rate);
> + pdata->clk = clk;
> + clk_register_clkdev(clk, NULL, 

Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-23 Thread Rafael J. Wysocki
On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
 This new feature is to interpret AMD specific ACPI device to platform device
 such as I2C, UART found on AMD CZ and later chipsets. It is based on example
 INTEL LPSS. Now, it can support AMD I2C  UART.
 
 Signed-off-by: Ken Xue ken@amd.com
 Signed-off-by: Jeff Wu jeff...@amd.com

Generally speaking, this seems to duplicate much code from acpi_lpss which
should be re-used instead.  What about moving the code that will be common
between acpi_lpss and the new driver into a new file (say acpi_soc.c)?

Also, you need to avoid automatic creation of platform devices when
!X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad things
will happen.


 ---
  arch/x86/Kconfig|  11 +++
  drivers/acpi/Makefile   |   1 +
  drivers/acpi/acpi_apd.c | 245 
 
  drivers/acpi/internal.h |   6 ++
  drivers/acpi/scan.c |   1 +
  5 files changed, 264 insertions(+)
  create mode 100644 drivers/acpi/acpi_apd.c
 
 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
 index ded8a67..6402c79f 100644
 --- a/arch/x86/Kconfig
 +++ b/arch/x86/Kconfig
 @@ -495,6 +495,17 @@ config X86_INTEL_LPSS
 things like clock tree (common clock framework) and pincontrol
 which are needed by the LPSS peripheral drivers.
  
 +config X86_AMD_PLATFORM_DEVICE
 + bool AMD ACPI2Platform devices support
 + depends on ACPI
 + select COMMON_CLK
 + select PINCTRL
 + ---help---
 +   Select to interpret AMD specific ACPI device to platform device
 +   such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
 +   this option enables things like clock tree (common clock framework)
 +   and pinctrl.
 +
  config IOSF_MBI
   tristate Intel SoC IOSF Sideband support for SoC platforms
   depends on PCI
 diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
 index c3b2fcb..91fc1c2 100644
 --- a/drivers/acpi/Makefile
 +++ b/drivers/acpi/Makefile
 @@ -41,6 +41,7 @@ acpi-y  += ec.o
  acpi-$(CONFIG_ACPI_DOCK) += dock.o
  acpi-y   += pci_root.o pci_link.o pci_irq.o
  acpi-y   += acpi_lpss.o
 +acpi-$(CONFIG_X86_AMD_PLATFORM_DEVICE)   += acpi_apd.o
  acpi-y   += acpi_platform.o
  acpi-y   += acpi_pnp.o
  acpi-y   += int340x_thermal.o
 diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
 new file mode 100644
 index 000..994b7db
 --- /dev/null
 +++ b/drivers/acpi/acpi_apd.c
 @@ -0,0 +1,245 @@
 +/*
 + * AMD ACPI support for ACPI2platform device.
 + *
 + * Copyright (c) 2014, AMD Corporation.
 + * Authors: Ken Xue ken@amd.com
 + *   Jeff Wu jeff...@amd.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/acpi.h
 +#include linux/clk.h
 +#include linux/clkdev.h
 +#include linux/clk-provider.h
 +#include linux/err.h
 +#include linux/io.h
 +#include linux/platform_device.h
 +#include linux/pm_runtime.h
 +
 +#include internal.h
 +
 +ACPI_MODULE_NAME(acpi_apd);
 +struct apd_private_data;
 +
 +struct apd_device_desc {
 + bool clk_required;
 + bool fixed_root_clock;
 + const char *clk_name;
 + unsigned long   rate;
 + size_t prv_size_override;
 + void (*setup)(struct apd_private_data *pdata);
 +};
 +
 +struct apd_private_data {
 + void __iomem *mmio_base;
 + resource_size_t mmio_size;
 + struct clk *clk;
 + const struct apd_device_desc *dev_desc;
 +};
 +
 +static struct apd_device_desc amd_i2c_desc = {
 + .clk_required = true,
 + .fixed_root_clock = true,
 + .clk_name = i2c_clk,
 + .rate = 13300, /*(133 * 1000 * 1000)*/
 +};
 +
 +static struct apd_device_desc amd_uart_desc = {
 + .clk_required = true,
 + .fixed_root_clock = true,
 + .clk_name = uart_clk,
 + .rate = 4800,
 +};
 +
 +static const struct acpi_device_id acpi_apd_device_ids[] = {
 + /* Generic apd devices */
 + { AMD0010, (unsigned long)amd_i2c_desc },
 + { AMD0020, (unsigned long)amd_uart_desc },
 + { }
 +};
 +
 +static int is_memory(struct acpi_resource *res, void *not_used)
 +{
 + struct resource r;
 +
 + return !acpi_dev_resource_memory(res, r);
 +}
 +
 +static int register_device_clock(struct acpi_device *adev,
 +  struct apd_private_data *pdata)
 +{
 + const struct apd_device_desc *dev_desc = pdata-dev_desc;
 + struct clk *clk = ERR_PTR(-ENODEV);
 +
 + clk = pdata-clk;
 + if (!clk  dev_desc-fixed_root_clock) {
 + clk = clk_register_fixed_rate(adev-dev, dev_name(adev-dev),
 +   NULL, CLK_IS_ROOT, dev_desc-rate);
 + pdata-clk = clk;
 + 

Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-23 Thread Rafael J. Wysocki
On Monday, November 24, 2014 01:02:30 AM Xue, Ken wrote:
 
 On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
  This new feature is to interpret AMD specific ACPI device to platform 
  device such as I2C, UART found on AMD CZ and later chipsets. It is 
  based on example INTEL LPSS. Now, it can support AMD I2C  UART.
  
  Signed-off-by: Ken Xue ken@amd.com
  Signed-off-by: Jeff Wu jeff...@amd.com
 
 Generally speaking, this seems to duplicate much code from acpi_lpss which 
 should be re-used instead.  What about moving the code that will be common 
 between acpi_lpss and the new driver into a new file (say acpi_soc.c)?
 
 Also, you need to avoid automatic creation of platform devices when 
 !X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad things 
 will happen.
 
 [ken] sounds fair enough.  Let me take action to merge drivers to acpi_soc.c 
 ? or you have other plan?

I'd prefer the common code to reside in one file (or one .c file and one header
file), and the driver-specific code to stay in separate per-driver files.

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-23 Thread Xue, Ken

On Tuesday, November 18, 2014 01:58:11 PM Ken Xue wrote:
 This new feature is to interpret AMD specific ACPI device to platform 
 device such as I2C, UART found on AMD CZ and later chipsets. It is 
 based on example INTEL LPSS. Now, it can support AMD I2C  UART.
 
 Signed-off-by: Ken Xue ken@amd.com
 Signed-off-by: Jeff Wu jeff...@amd.com

Generally speaking, this seems to duplicate much code from acpi_lpss which 
should be re-used instead.  What about moving the code that will be common 
between acpi_lpss and the new driver into a new file (say acpi_soc.c)?

Also, you need to avoid automatic creation of platform devices when 
!X86_AMD_PLATFORM_DEVICE in analogy with what acpi_lpss does, or bad things 
will happen.

[ken] sounds fair enough.  Let me take action to merge drivers to acpi_soc.c ? 
or you have other plan?

[...]
N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�j:+v���zZ+��+zf���h���~i���z��w���?��)ߢf��^jǫy�m��@A�a���
0��h���i

Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-21 Thread Rafael J. Wysocki
On Friday, November 21, 2014 05:15:46 AM Xue, Ken wrote:
> Hi Len,  Rafael J & Mika,
>   Please help to review this patch. And tell me any of your concern. 
> Thanks.
> 
>   I understand it is a trend that convert a ACPI device to be a platform 
> device.
>   For AMD, we try to use this patch to match this trend well. The patch 
> based on INTEL LPSS . 
>   But we cannot reuse LPSS, because of specific definition of 
> "lpss_device_desc" for LPSS.


You don't have to resend the patch every day for us to notice it.  We're
actually in the process of reviewing your original submission.

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-21 Thread Rafael J. Wysocki
On Friday, November 21, 2014 05:15:46 AM Xue, Ken wrote:
 Hi Len,  Rafael J  Mika,
   Please help to review this patch. And tell me any of your concern. 
 Thanks.
 
   I understand it is a trend that convert a ACPI device to be a platform 
 device.
   For AMD, we try to use this patch to match this trend well. The patch 
 based on INTEL LPSS . 
   But we cannot reuse LPSS, because of specific definition of 
 lpss_device_desc for LPSS.


You don't have to resend the patch every day for us to notice it.  We're
actually in the process of reviewing your original submission.

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-20 Thread Xue, Ken
Hi Len,  Rafael J & Mika,
Please help to review this patch. And tell me any of your concern. 
Thanks.

I understand it is a trend that convert a ACPI device to be a platform 
device.
For AMD, we try to use this patch to match this trend well. The patch 
based on INTEL LPSS . 
But we cannot reuse LPSS, because of specific definition of 
"lpss_device_desc" for LPSS.

Regards,
Ken


-Original Message-
From: Ken Xue [mailto:ken@amd.com] 
Sent: Tuesday, November 18, 2014 1:58 PM
To: r...@rjwysocki.net; l...@kernel.org
Cc: linux-a...@vger.kernel.org; linux-kernel@vger.kernel.org; Xue, Ken; Wu, Jeff
Subject: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

This new feature is to interpret AMD specific ACPI device to platform device 
such as I2C, UART found on AMD CZ and later chipsets. It is based on example 
INTEL LPSS. Now, it can support AMD I2C & UART.

Signed-off-by: Ken Xue 
Signed-off-by: Jeff Wu 
---
 arch/x86/Kconfig|  11 +++
 drivers/acpi/Makefile   |   1 +
 drivers/acpi/acpi_apd.c | 245 
 drivers/acpi/internal.h |   6 ++
 drivers/acpi/scan.c |   1 +
 5 files changed, 264 insertions(+)
 create mode 100644 drivers/acpi/acpi_apd.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ded8a67..6402c79f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -495,6 +495,17 @@ config X86_INTEL_LPSS
  things like clock tree (common clock framework) and pincontrol
  which are needed by the LPSS peripheral drivers.
 
+config X86_AMD_PLATFORM_DEVICE
+   bool "AMD ACPI2Platform devices support"
+   depends on ACPI
+   select COMMON_CLK
+   select PINCTRL
+   ---help---
+ Select to interpret AMD specific ACPI device to platform device
+ such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
+ this option enables things like clock tree (common clock framework)
+ and pinctrl.
+
 config IOSF_MBI
tristate "Intel SoC IOSF Sideband support for SoC platforms"
depends on PCI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 
c3b2fcb..91fc1c2 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -41,6 +41,7 @@ acpi-y+= ec.o
 acpi-$(CONFIG_ACPI_DOCK)   += dock.o
 acpi-y += pci_root.o pci_link.o pci_irq.o
 acpi-y += acpi_lpss.o
+acpi-$(CONFIG_X86_AMD_PLATFORM_DEVICE) += acpi_apd.o
 acpi-y += acpi_platform.o
 acpi-y += acpi_pnp.o
 acpi-y += int340x_thermal.o
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c new file mode 
100644 index 000..994b7db
--- /dev/null
+++ b/drivers/acpi/acpi_apd.c
@@ -0,0 +1,245 @@
+/*
+ * AMD ACPI support for ACPI2platform device.
+ *
+ * Copyright (c) 2014, AMD Corporation.
+ * Authors: Ken Xue 
+ * Jeff Wu 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "internal.h"
+
+ACPI_MODULE_NAME("acpi_apd");
+struct apd_private_data;
+
+struct apd_device_desc {
+   bool clk_required;
+   bool fixed_root_clock;
+   const char *clk_name;
+   unsigned long   rate;
+   size_t prv_size_override;
+   void (*setup)(struct apd_private_data *pdata); };
+
+struct apd_private_data {
+   void __iomem *mmio_base;
+   resource_size_t mmio_size;
+   struct clk *clk;
+   const struct apd_device_desc *dev_desc; };
+
+static struct apd_device_desc amd_i2c_desc = {
+   .clk_required = true,
+   .fixed_root_clock = true,
+   .clk_name = "i2c_clk",
+   .rate = 13300, /*(133 * 1000 * 1000)*/ };
+
+static struct apd_device_desc amd_uart_desc = {
+   .clk_required = true,
+   .fixed_root_clock = true,
+   .clk_name = "uart_clk",
+   .rate = 4800,
+};
+
+static const struct acpi_device_id acpi_apd_device_ids[] = {
+   /* Generic apd devices */
+   { "AMD0010", (unsigned long)_i2c_desc },
+   { "AMD0020", (unsigned long)_uart_desc },
+   { }
+};
+
+static int is_memory(struct acpi_resource *res, void *not_used) {
+   struct resource r;
+
+   return !acpi_dev_resource_memory(res, ); }
+
+static int register_device_clock(struct acpi_device *adev,
+struct apd_private_data *pdata)
+{
+   const struct apd_device_desc *dev_desc = pdata->dev_desc;
+   struct clk *clk = ERR_PTR(-ENODEV);
+
+   clk = pdata->clk;
+   if (!clk && dev_desc->fixed_root_clock) {
+   clk = clk_register_fixed_rate(&g

RE: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-20 Thread Xue, Ken
Hi Len,  Rafael J  Mika,
Please help to review this patch. And tell me any of your concern. 
Thanks.

I understand it is a trend that convert a ACPI device to be a platform 
device.
For AMD, we try to use this patch to match this trend well. The patch 
based on INTEL LPSS . 
But we cannot reuse LPSS, because of specific definition of 
lpss_device_desc for LPSS.

Regards,
Ken


-Original Message-
From: Ken Xue [mailto:ken@amd.com] 
Sent: Tuesday, November 18, 2014 1:58 PM
To: r...@rjwysocki.net; l...@kernel.org
Cc: linux-a...@vger.kernel.org; linux-kernel@vger.kernel.org; Xue, Ken; Wu, Jeff
Subject: [PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

This new feature is to interpret AMD specific ACPI device to platform device 
such as I2C, UART found on AMD CZ and later chipsets. It is based on example 
INTEL LPSS. Now, it can support AMD I2C  UART.

Signed-off-by: Ken Xue ken@amd.com
Signed-off-by: Jeff Wu jeff...@amd.com
---
 arch/x86/Kconfig|  11 +++
 drivers/acpi/Makefile   |   1 +
 drivers/acpi/acpi_apd.c | 245 
 drivers/acpi/internal.h |   6 ++
 drivers/acpi/scan.c |   1 +
 5 files changed, 264 insertions(+)
 create mode 100644 drivers/acpi/acpi_apd.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ded8a67..6402c79f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -495,6 +495,17 @@ config X86_INTEL_LPSS
  things like clock tree (common clock framework) and pincontrol
  which are needed by the LPSS peripheral drivers.
 
+config X86_AMD_PLATFORM_DEVICE
+   bool AMD ACPI2Platform devices support
+   depends on ACPI
+   select COMMON_CLK
+   select PINCTRL
+   ---help---
+ Select to interpret AMD specific ACPI device to platform device
+ such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
+ this option enables things like clock tree (common clock framework)
+ and pinctrl.
+
 config IOSF_MBI
tristate Intel SoC IOSF Sideband support for SoC platforms
depends on PCI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 
c3b2fcb..91fc1c2 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -41,6 +41,7 @@ acpi-y+= ec.o
 acpi-$(CONFIG_ACPI_DOCK)   += dock.o
 acpi-y += pci_root.o pci_link.o pci_irq.o
 acpi-y += acpi_lpss.o
+acpi-$(CONFIG_X86_AMD_PLATFORM_DEVICE) += acpi_apd.o
 acpi-y += acpi_platform.o
 acpi-y += acpi_pnp.o
 acpi-y += int340x_thermal.o
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c new file mode 
100644 index 000..994b7db
--- /dev/null
+++ b/drivers/acpi/acpi_apd.c
@@ -0,0 +1,245 @@
+/*
+ * AMD ACPI support for ACPI2platform device.
+ *
+ * Copyright (c) 2014, AMD Corporation.
+ * Authors: Ken Xue ken@amd.com
+ * Jeff Wu jeff...@amd.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/acpi.h
+#include linux/clk.h
+#include linux/clkdev.h
+#include linux/clk-provider.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+
+#include internal.h
+
+ACPI_MODULE_NAME(acpi_apd);
+struct apd_private_data;
+
+struct apd_device_desc {
+   bool clk_required;
+   bool fixed_root_clock;
+   const char *clk_name;
+   unsigned long   rate;
+   size_t prv_size_override;
+   void (*setup)(struct apd_private_data *pdata); };
+
+struct apd_private_data {
+   void __iomem *mmio_base;
+   resource_size_t mmio_size;
+   struct clk *clk;
+   const struct apd_device_desc *dev_desc; };
+
+static struct apd_device_desc amd_i2c_desc = {
+   .clk_required = true,
+   .fixed_root_clock = true,
+   .clk_name = i2c_clk,
+   .rate = 13300, /*(133 * 1000 * 1000)*/ };
+
+static struct apd_device_desc amd_uart_desc = {
+   .clk_required = true,
+   .fixed_root_clock = true,
+   .clk_name = uart_clk,
+   .rate = 4800,
+};
+
+static const struct acpi_device_id acpi_apd_device_ids[] = {
+   /* Generic apd devices */
+   { AMD0010, (unsigned long)amd_i2c_desc },
+   { AMD0020, (unsigned long)amd_uart_desc },
+   { }
+};
+
+static int is_memory(struct acpi_resource *res, void *not_used) {
+   struct resource r;
+
+   return !acpi_dev_resource_memory(res, r); }
+
+static int register_device_clock(struct acpi_device *adev,
+struct apd_private_data *pdata)
+{
+   const struct apd_device_desc *dev_desc = pdata-dev_desc;
+   struct clk *clk = ERR_PTR(-ENODEV);
+
+   clk = pdata-clk;
+   if (!clk  dev_desc-fixed_root_clock

[PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-17 Thread Ken Xue
This new feature is to interpret AMD specific ACPI device to platform device
such as I2C, UART found on AMD CZ and later chipsets. It is based on example
INTEL LPSS. Now, it can support AMD I2C & UART.

Signed-off-by: Ken Xue 
Signed-off-by: Jeff Wu 
---
 arch/x86/Kconfig|  11 +++
 drivers/acpi/Makefile   |   1 +
 drivers/acpi/acpi_apd.c | 245 
 drivers/acpi/internal.h |   6 ++
 drivers/acpi/scan.c |   1 +
 5 files changed, 264 insertions(+)
 create mode 100644 drivers/acpi/acpi_apd.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ded8a67..6402c79f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -495,6 +495,17 @@ config X86_INTEL_LPSS
  things like clock tree (common clock framework) and pincontrol
  which are needed by the LPSS peripheral drivers.
 
+config X86_AMD_PLATFORM_DEVICE
+   bool "AMD ACPI2Platform devices support"
+   depends on ACPI
+   select COMMON_CLK
+   select PINCTRL
+   ---help---
+ Select to interpret AMD specific ACPI device to platform device
+ such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
+ this option enables things like clock tree (common clock framework)
+ and pinctrl.
+
 config IOSF_MBI
tristate "Intel SoC IOSF Sideband support for SoC platforms"
depends on PCI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index c3b2fcb..91fc1c2 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -41,6 +41,7 @@ acpi-y+= ec.o
 acpi-$(CONFIG_ACPI_DOCK)   += dock.o
 acpi-y += pci_root.o pci_link.o pci_irq.o
 acpi-y += acpi_lpss.o
+acpi-$(CONFIG_X86_AMD_PLATFORM_DEVICE) += acpi_apd.o
 acpi-y += acpi_platform.o
 acpi-y += acpi_pnp.o
 acpi-y += int340x_thermal.o
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
new file mode 100644
index 000..994b7db
--- /dev/null
+++ b/drivers/acpi/acpi_apd.c
@@ -0,0 +1,245 @@
+/*
+ * AMD ACPI support for ACPI2platform device.
+ *
+ * Copyright (c) 2014, AMD Corporation.
+ * Authors: Ken Xue 
+ * Jeff Wu 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "internal.h"
+
+ACPI_MODULE_NAME("acpi_apd");
+struct apd_private_data;
+
+struct apd_device_desc {
+   bool clk_required;
+   bool fixed_root_clock;
+   const char *clk_name;
+   unsigned long   rate;
+   size_t prv_size_override;
+   void (*setup)(struct apd_private_data *pdata);
+};
+
+struct apd_private_data {
+   void __iomem *mmio_base;
+   resource_size_t mmio_size;
+   struct clk *clk;
+   const struct apd_device_desc *dev_desc;
+};
+
+static struct apd_device_desc amd_i2c_desc = {
+   .clk_required = true,
+   .fixed_root_clock = true,
+   .clk_name = "i2c_clk",
+   .rate = 13300, /*(133 * 1000 * 1000)*/
+};
+
+static struct apd_device_desc amd_uart_desc = {
+   .clk_required = true,
+   .fixed_root_clock = true,
+   .clk_name = "uart_clk",
+   .rate = 4800,
+};
+
+static const struct acpi_device_id acpi_apd_device_ids[] = {
+   /* Generic apd devices */
+   { "AMD0010", (unsigned long)_i2c_desc },
+   { "AMD0020", (unsigned long)_uart_desc },
+   { }
+};
+
+static int is_memory(struct acpi_resource *res, void *not_used)
+{
+   struct resource r;
+
+   return !acpi_dev_resource_memory(res, );
+}
+
+static int register_device_clock(struct acpi_device *adev,
+struct apd_private_data *pdata)
+{
+   const struct apd_device_desc *dev_desc = pdata->dev_desc;
+   struct clk *clk = ERR_PTR(-ENODEV);
+
+   clk = pdata->clk;
+   if (!clk && dev_desc->fixed_root_clock) {
+   clk = clk_register_fixed_rate(>dev, dev_name(>dev),
+ NULL, CLK_IS_ROOT, dev_desc->rate);
+   pdata->clk = clk;
+   clk_register_clkdev(clk, NULL, dev_name(>dev));
+   }
+
+   return 0;
+}
+
+static int acpi_apd_create_device(struct acpi_device *adev,
+  const struct acpi_device_id *id)
+{
+   struct apd_device_desc *dev_desc;
+   struct apd_private_data *pdata;
+   struct resource_list_entry *rentry;
+   struct list_head resource_list;
+   struct platform_device *pdev;
+   int ret;
+
+   dev_desc = (struct apd_device_desc *)id->driver_data;
+   if (!dev_desc) {
+   pdev = acpi_create_platform_device(adev);
+   return IS_ERR_OR_NULL(pdev) ? PTR_ERR(pdev) : 1;
+   }
+
+   pdata = 

[PATCH] acpi:apd:add AMD ACPI2Platform device support for x86 system.

2014-11-17 Thread Ken Xue
This new feature is to interpret AMD specific ACPI device to platform device
such as I2C, UART found on AMD CZ and later chipsets. It is based on example
INTEL LPSS. Now, it can support AMD I2C  UART.

Signed-off-by: Ken Xue ken@amd.com
Signed-off-by: Jeff Wu jeff...@amd.com
---
 arch/x86/Kconfig|  11 +++
 drivers/acpi/Makefile   |   1 +
 drivers/acpi/acpi_apd.c | 245 
 drivers/acpi/internal.h |   6 ++
 drivers/acpi/scan.c |   1 +
 5 files changed, 264 insertions(+)
 create mode 100644 drivers/acpi/acpi_apd.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ded8a67..6402c79f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -495,6 +495,17 @@ config X86_INTEL_LPSS
  things like clock tree (common clock framework) and pincontrol
  which are needed by the LPSS peripheral drivers.
 
+config X86_AMD_PLATFORM_DEVICE
+   bool AMD ACPI2Platform devices support
+   depends on ACPI
+   select COMMON_CLK
+   select PINCTRL
+   ---help---
+ Select to interpret AMD specific ACPI device to platform device
+ such as I2C, UART found on AMD CARRIZO and later chipset. Selecting
+ this option enables things like clock tree (common clock framework)
+ and pinctrl.
+
 config IOSF_MBI
tristate Intel SoC IOSF Sideband support for SoC platforms
depends on PCI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index c3b2fcb..91fc1c2 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -41,6 +41,7 @@ acpi-y+= ec.o
 acpi-$(CONFIG_ACPI_DOCK)   += dock.o
 acpi-y += pci_root.o pci_link.o pci_irq.o
 acpi-y += acpi_lpss.o
+acpi-$(CONFIG_X86_AMD_PLATFORM_DEVICE) += acpi_apd.o
 acpi-y += acpi_platform.o
 acpi-y += acpi_pnp.o
 acpi-y += int340x_thermal.o
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
new file mode 100644
index 000..994b7db
--- /dev/null
+++ b/drivers/acpi/acpi_apd.c
@@ -0,0 +1,245 @@
+/*
+ * AMD ACPI support for ACPI2platform device.
+ *
+ * Copyright (c) 2014, AMD Corporation.
+ * Authors: Ken Xue ken@amd.com
+ * Jeff Wu jeff...@amd.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/acpi.h
+#include linux/clk.h
+#include linux/clkdev.h
+#include linux/clk-provider.h
+#include linux/err.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+
+#include internal.h
+
+ACPI_MODULE_NAME(acpi_apd);
+struct apd_private_data;
+
+struct apd_device_desc {
+   bool clk_required;
+   bool fixed_root_clock;
+   const char *clk_name;
+   unsigned long   rate;
+   size_t prv_size_override;
+   void (*setup)(struct apd_private_data *pdata);
+};
+
+struct apd_private_data {
+   void __iomem *mmio_base;
+   resource_size_t mmio_size;
+   struct clk *clk;
+   const struct apd_device_desc *dev_desc;
+};
+
+static struct apd_device_desc amd_i2c_desc = {
+   .clk_required = true,
+   .fixed_root_clock = true,
+   .clk_name = i2c_clk,
+   .rate = 13300, /*(133 * 1000 * 1000)*/
+};
+
+static struct apd_device_desc amd_uart_desc = {
+   .clk_required = true,
+   .fixed_root_clock = true,
+   .clk_name = uart_clk,
+   .rate = 4800,
+};
+
+static const struct acpi_device_id acpi_apd_device_ids[] = {
+   /* Generic apd devices */
+   { AMD0010, (unsigned long)amd_i2c_desc },
+   { AMD0020, (unsigned long)amd_uart_desc },
+   { }
+};
+
+static int is_memory(struct acpi_resource *res, void *not_used)
+{
+   struct resource r;
+
+   return !acpi_dev_resource_memory(res, r);
+}
+
+static int register_device_clock(struct acpi_device *adev,
+struct apd_private_data *pdata)
+{
+   const struct apd_device_desc *dev_desc = pdata-dev_desc;
+   struct clk *clk = ERR_PTR(-ENODEV);
+
+   clk = pdata-clk;
+   if (!clk  dev_desc-fixed_root_clock) {
+   clk = clk_register_fixed_rate(adev-dev, dev_name(adev-dev),
+ NULL, CLK_IS_ROOT, dev_desc-rate);
+   pdata-clk = clk;
+   clk_register_clkdev(clk, NULL, dev_name(adev-dev));
+   }
+
+   return 0;
+}
+
+static int acpi_apd_create_device(struct acpi_device *adev,
+  const struct acpi_device_id *id)
+{
+   struct apd_device_desc *dev_desc;
+   struct apd_private_data *pdata;
+   struct resource_list_entry *rentry;
+   struct list_head resource_list;
+   struct platform_device *pdev;
+   int ret;
+
+   dev_desc = (struct apd_device_desc *)id-driver_data;
+   if (!dev_desc) {