Re: [PATCH 6/7 v2] OMAP: devices: Modify McSPI device to adapt to hwmod framework

2010-12-30 Thread Grant Likely
On Wed, Dec 01, 2010 at 07:32:00PM +0530, Govindraj.R wrote:
> From: Charulatha V 
> 
> Cleans up all base address definitions for omap_mcspi
> and adapts the device registration and driver to hwmod framework.
> Changes involves:
> 1) Removing all base address macro defines.
> 2) Using omap-device layer to register device and utilizing data from
>hwmod data file for base address, dma channel number, Irq_number,
>device attribute(number of chipselect).
> 3) Appending base address with pdata reg_offset for omap4 boards.
>For omap4 all regs used in driver deviate with reg_offset_macros
>defined with an value of 0x100. So pass this offset through pdata
>and append the same to base address retrieved from hwmod data file
>and we are not mapping *_HL_* regs which are not used in driver.
> 
> Signed-off-by: Charulatha V 
> Signed-off-by: Govindraj.R 
> Reviewed-by: Partha Basak 
> ---
>  arch/arm/mach-omap2/devices.c   |  189 
> +++
>  arch/arm/plat-omap/include/plat/mcspi.h |3 +
>  drivers/spi/omap2_mcspi.c   |  111 +-
>  3 files changed, 74 insertions(+), 229 deletions(-)

Looks okay to me.  Certainly can't argue with the diffstat.  A few
comments below.

g.

> 
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index 5a0c148..c576532 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -15,6 +15,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #include 
>  #include 
> @@ -279,163 +280,57 @@ static inline void omap_init_audio(void) {}
> 
>  #include 
> 
> -#define OMAP2_MCSPI1_BASE0x48098000
> -#define OMAP2_MCSPI2_BASE0x4809a000
> -#define OMAP2_MCSPI3_BASE0x480b8000
> -#define OMAP2_MCSPI4_BASE0x480ba000
> -
> -#define OMAP4_MCSPI1_BASE0x48098100
> -#define OMAP4_MCSPI2_BASE0x4809a100
> -#define OMAP4_MCSPI3_BASE0x480b8100
> -#define OMAP4_MCSPI4_BASE0x480ba100
> -
> -static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
> - .num_cs = 4,
> -};
> -
> -static struct resource omap2_mcspi1_resources[] = {
> - {
> - .start  = OMAP2_MCSPI1_BASE,
> - .end= OMAP2_MCSPI1_BASE + 0xff,
> - .flags  = IORESOURCE_MEM,
> - },
> -};
> -
> -static struct platform_device omap2_mcspi1 = {
> - .name   = "omap2_mcspi",
> - .id = 1,
> - .num_resources  = ARRAY_SIZE(omap2_mcspi1_resources),
> - .resource   = omap2_mcspi1_resources,
> - .dev= {
> - .platform_data = &omap2_mcspi1_config,
> - },
> -};
> -
> -static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
> - .num_cs = 2,
> -};
> -
> -static struct resource omap2_mcspi2_resources[] = {
> - {
> - .start  = OMAP2_MCSPI2_BASE,
> - .end= OMAP2_MCSPI2_BASE + 0xff,
> - .flags  = IORESOURCE_MEM,
> - },
> -};
> -
> -static struct platform_device omap2_mcspi2 = {
> - .name   = "omap2_mcspi",
> - .id = 2,
> - .num_resources  = ARRAY_SIZE(omap2_mcspi2_resources),
> - .resource   = omap2_mcspi2_resources,
> - .dev= {
> - .platform_data = &omap2_mcspi2_config,
> - },
> -};
> -
> -#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
> - defined(CONFIG_ARCH_OMAP4)
> -static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
> - .num_cs = 2,
> -};
> -
> -static struct resource omap2_mcspi3_resources[] = {
> - {
> - .start  = OMAP2_MCSPI3_BASE,
> - .end= OMAP2_MCSPI3_BASE + 0xff,
> - .flags  = IORESOURCE_MEM,
> - },
> -};
> -
> -static struct platform_device omap2_mcspi3 = {
> - .name   = "omap2_mcspi",
> - .id = 3,
> - .num_resources  = ARRAY_SIZE(omap2_mcspi3_resources),
> - .resource   = omap2_mcspi3_resources,
> - .dev= {
> - .platform_data = &omap2_mcspi3_config,
> - },
> -};
> -#endif
> -
> -#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
> -static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
> - .num_cs = 1,
> -};
> -
> -static struct resource omap2_mcspi4_resources[] = {
> - {
> - .start  = OMAP2_MCSPI4_BASE,
> - .end= OMAP2_MCSPI4_BASE + 0xff,
> - .flags  = IORESOURCE_MEM,
> - },
> -};
> -
> -static struct platform_device omap2_mcspi4 = {
> - .name   = "omap2_mcspi",
> - .id = 4,
> - .num_resources  = ARRAY_SIZE(omap2_mcspi4_resources),
> - .resource   = omap2_mcspi4_resources,
> - .dev= {
> - .platform_data = &omap2_mcspi4_config,
> +struct omap_device_pm_latency o

[PATCH 6/7 v2] OMAP: devices: Modify McSPI device to adapt to hwmod framework

2010-12-01 Thread Govindraj.R
From: Charulatha V 

Cleans up all base address definitions for omap_mcspi
and adapts the device registration and driver to hwmod framework.
Changes involves:
1) Removing all base address macro defines.
2) Using omap-device layer to register device and utilizing data from
   hwmod data file for base address, dma channel number, Irq_number,
   device attribute(number of chipselect).
3) Appending base address with pdata reg_offset for omap4 boards.
   For omap4 all regs used in driver deviate with reg_offset_macros
   defined with an value of 0x100. So pass this offset through pdata
   and append the same to base address retrieved from hwmod data file
   and we are not mapping *_HL_* regs which are not used in driver.

Signed-off-by: Charulatha V 
Signed-off-by: Govindraj.R 
Reviewed-by: Partha Basak 
---
 arch/arm/mach-omap2/devices.c   |  189 +++
 arch/arm/plat-omap/include/plat/mcspi.h |3 +
 drivers/spi/omap2_mcspi.c   |  111 +-
 3 files changed, 74 insertions(+), 229 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 5a0c148..c576532 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -279,163 +280,57 @@ static inline void omap_init_audio(void) {}

 #include 

-#define OMAP2_MCSPI1_BASE  0x48098000
-#define OMAP2_MCSPI2_BASE  0x4809a000
-#define OMAP2_MCSPI3_BASE  0x480b8000
-#define OMAP2_MCSPI4_BASE  0x480ba000
-
-#define OMAP4_MCSPI1_BASE  0x48098100
-#define OMAP4_MCSPI2_BASE  0x4809a100
-#define OMAP4_MCSPI3_BASE  0x480b8100
-#define OMAP4_MCSPI4_BASE  0x480ba100
-
-static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
-   .num_cs = 4,
-};
-
-static struct resource omap2_mcspi1_resources[] = {
-   {
-   .start  = OMAP2_MCSPI1_BASE,
-   .end= OMAP2_MCSPI1_BASE + 0xff,
-   .flags  = IORESOURCE_MEM,
-   },
-};
-
-static struct platform_device omap2_mcspi1 = {
-   .name   = "omap2_mcspi",
-   .id = 1,
-   .num_resources  = ARRAY_SIZE(omap2_mcspi1_resources),
-   .resource   = omap2_mcspi1_resources,
-   .dev= {
-   .platform_data = &omap2_mcspi1_config,
-   },
-};
-
-static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
-   .num_cs = 2,
-};
-
-static struct resource omap2_mcspi2_resources[] = {
-   {
-   .start  = OMAP2_MCSPI2_BASE,
-   .end= OMAP2_MCSPI2_BASE + 0xff,
-   .flags  = IORESOURCE_MEM,
-   },
-};
-
-static struct platform_device omap2_mcspi2 = {
-   .name   = "omap2_mcspi",
-   .id = 2,
-   .num_resources  = ARRAY_SIZE(omap2_mcspi2_resources),
-   .resource   = omap2_mcspi2_resources,
-   .dev= {
-   .platform_data = &omap2_mcspi2_config,
-   },
-};
-
-#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
-   defined(CONFIG_ARCH_OMAP4)
-static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
-   .num_cs = 2,
-};
-
-static struct resource omap2_mcspi3_resources[] = {
-   {
-   .start  = OMAP2_MCSPI3_BASE,
-   .end= OMAP2_MCSPI3_BASE + 0xff,
-   .flags  = IORESOURCE_MEM,
-   },
-};
-
-static struct platform_device omap2_mcspi3 = {
-   .name   = "omap2_mcspi",
-   .id = 3,
-   .num_resources  = ARRAY_SIZE(omap2_mcspi3_resources),
-   .resource   = omap2_mcspi3_resources,
-   .dev= {
-   .platform_data = &omap2_mcspi3_config,
-   },
-};
-#endif
-
-#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
-static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
-   .num_cs = 1,
-};
-
-static struct resource omap2_mcspi4_resources[] = {
-   {
-   .start  = OMAP2_MCSPI4_BASE,
-   .end= OMAP2_MCSPI4_BASE + 0xff,
-   .flags  = IORESOURCE_MEM,
-   },
-};
-
-static struct platform_device omap2_mcspi4 = {
-   .name   = "omap2_mcspi",
-   .id = 4,
-   .num_resources  = ARRAY_SIZE(omap2_mcspi4_resources),
-   .resource   = omap2_mcspi4_resources,
-   .dev= {
-   .platform_data = &omap2_mcspi4_config,
+struct omap_device_pm_latency omap_mcspi_latency[] = {
+   [0] = {
+   .deactivate_func = omap_device_idle_hwmods,
+   .activate_func   = omap_device_enable_hwmods,
+   .flags   = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
},
 };
-#endif

-#ifdef CONFIG_ARCH_OMAP4
-static inline void omap4_mcspi_f