Re: [PATCH v3 5/5] OMAP: adapt hsmmc to hwmod framework

2011-02-24 Thread Cousson, Benoit

On 2/24/2011 2:55 PM, Kadiyala, Kishore wrote:

On Thu, Feb 24, 2011 at 5:19 PM, Cousson, Benoit  wrote:

On 2/23/2011 6:47 PM, Kadiyala, Kishore wrote:


[...]


  static struct hsmmc_controller {
 charname[HSMMC_NAME_LEN + 1];
-} hsmmc[OMAP34XX_NR_MMC];
+} hsmmc[OMAP44XX_NR_MMC];


I do not know the details of that driver, so this comment might be
completely irrelevant, but in theory, such static table should not be
necessary since the driver core already maintain a list of all instances
bound to it.


I agree, but this is used in slot data for the controller and is used
in the driver
to create a /sys entry.


I guess the sysfs should be able to use only the device instance.


I will try to avoid the "OMAP44XX_NR_MMC" dependency.


[...]


+static struct omap_mmc_platform_data *hsmmc_data[OMAP44XX_NR_MMC]
__initdata;


Same concern than for hsmmc, why do you need static table here?


Agree, will remove static declaration.


And why do you need another structure? The omap2_hsmmc_info should already
be in a pdata kind of structure.
The board file should just populate a table of pdata that you will use
during init.


No, omap2_hsmmc_info is intermediate structure used by the boards
files to update
some basic info of the controller, based on which the pdata is
populated in hsmmc.c.


This is the point, I guess you can potentially directly fill partially a 
pdata with controller information in the board file to avoid that 
intermediate structure.


[...]


+   name = "mmci-omap-hs";


Could you please rename the device to have something in the form: omap_?
In that case "omap_mmc" should be good. The "hs" is just a indication of one
of the mmc instance capability and does not have to be in the device name
since there is no none-hs instance.


I understood your concern but omap1,omap2420 uses mmc driver while
omap2430, omap3 , omap4 has hsmmc driver.


OK, it makes sense then.


omap1, omap2420 boards have device name as "mmci-omap" currently, but
if they undergo
the similar change as proposed above then it looks like "omap_mmc"

Therefore for hsmmc driver, I will be happy to have something like "omap_hsmmc"

please let me know if this is fine.


Excellent, that's fine for me.

Thanks,
Benoit
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 5/5] OMAP: adapt hsmmc to hwmod framework

2011-02-24 Thread Kadiyala, Kishore
On Thu, Feb 24, 2011 at 11:58 AM, Varadarajan, Charulatha  wrote:
> Kishore,
>
> On Wed, Feb 23, 2011 at 23:17, Kishore Kadiyala  
> wrote:
>> Changes involves:
>> 1) Remove controller reset in devices.c which is taken care of
>>   by hwmod framework.
>> 2) Removing all base address macro defines except keeping one for OMAP2420.
>
> why?

Will  mention the details in the log

>
>> 3) Using omap-device layer to register device and utilizing data from
>>   hwmod data file for base address, dma channel number, Irq_number,
>>   device attribute.
>>
>> Signed-off-by: Paul Walmsley 
>> Signed-off-by: Kishore Kadiyala 
>> Cc: Benoit Cousson 
>> CC: Kevin Hilman 
>> ---
>>  arch/arm/mach-omap2/devices.c         |  251 
>> -
>>  arch/arm/mach-omap2/hsmmc.c           |  153 ++--
>>  arch/arm/plat-omap/include/plat/mmc.h |   14 --
>>  3 files changed, 141 insertions(+), 277 deletions(-)
>>
>
> <>
>
>> diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
>> index 34272e4..b6e1eae 100644
>> --- a/arch/arm/mach-omap2/hsmmc.c
>> +++ b/arch/arm/mach-omap2/hsmmc.c
>> @@ -16,7 +16,11 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>> +#include 
>> +#include 
>>
>> +#include "mux.h"
>>  #include "hsmmc.h"
>>  #include "control.h"
>>
>> @@ -30,7 +34,7 @@ static u16 control_mmc1;
>>
>>  static struct hsmmc_controller {
>>        char                            name[HSMMC_NAME_LEN + 1];
>> -} hsmmc[OMAP34XX_NR_MMC];
>> +} hsmmc[OMAP44XX_NR_MMC];
>
> Why do you have a dependency on OMAP44XX_NR_MMC? You should get
> this kind of information using number of iterations in *_hwmod_each_by_class.

Ok , will remove

>
>>
>>  #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
>>
>> @@ -204,7 +208,141 @@ static int nop_mmc_set_power(struct device *dev, int 
>> slot, int power_on,
>>        return 0;
>>  }
>>
>> -static struct omap_mmc_platform_data *hsmmc_data[OMAP34XX_NR_MMC] 
>> __initdata;
>> +static inline void omap2_mmc_mux(struct omap_mmc_platform_data 
>> *mmc_controller,
>> +                       int controller_nr)
>> +{
>> +       if ((mmc_controller->slots[0].switch_pin > 0) && \
>> +               (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
>> +               omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
>> +                                       OMAP_PIN_INPUT_PULLUP);
>> +       if ((mmc_controller->slots[0].gpio_wp > 0) && \
>> +               (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
>> +               omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
>> +                                       OMAP_PIN_INPUT_PULLUP);
>> +       if (cpu_is_omap34xx()) {
>> +               if (controller_nr == 0) {
>> +                       omap_mux_init_signal("sdmmc1_clk",
>> +                               OMAP_PIN_INPUT_PULLUP);
>> +                       omap_mux_init_signal("sdmmc1_cmd",
>> +                               OMAP_PIN_INPUT_PULLUP);
>> +                       omap_mux_init_signal("sdmmc1_dat0",
>> +                               OMAP_PIN_INPUT_PULLUP);
>> +                       if (mmc_controller->slots[0].caps &
>> +                               (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
>> +                               omap_mux_init_signal("sdmmc1_dat1",
>> +                                       OMAP_PIN_INPUT_PULLUP);
>> +                               omap_mux_init_signal("sdmmc1_dat2",
>> +                                       OMAP_PIN_INPUT_PULLUP);
>> +                               omap_mux_init_signal("sdmmc1_dat3",
>> +                                       OMAP_PIN_INPUT_PULLUP);
>> +                       }
>> +                       if (mmc_controller->slots[0].caps &
>> +                                               MMC_CAP_8_BIT_DATA) {
>> +                               omap_mux_init_signal("sdmmc1_dat4",
>> +                                       OMAP_PIN_INPUT_PULLUP);
>> +                               omap_mux_init_signal("sdmmc1_dat5",
>> +                                       OMAP_PIN_INPUT_PULLUP);
>> +                               omap_mux_init_signal("sdmmc1_dat6",
>> +                                       OMAP_PIN_INPUT_PULLUP);
>> +                               omap_mux_init_signal("sdmmc1_dat7",
>> +                                       OMAP_PIN_INPUT_PULLUP);
>> +                       }
>> +               }
>> +               if (controller_nr == 1) {
>> +                       /* MMC2 */
>> +                       omap_mux_init_signal("sdmmc2_clk",
>> +                               OMAP_PIN_INPUT_PULLUP);
>> +                       omap_mux_init_signal("sdmmc2_cmd",
>> +                               OMAP_PIN_INPUT_PULLUP);
>> +                       omap_mux_init_signal("sdmmc2_dat0",
>> +                               OMAP_PIN_INPUT_PULLUP);
>> +
>> +                       /*
>> +                        * For 8 wire configurations, Lines DAT4, 5, 6 a

Re: [PATCH v3 5/5] OMAP: adapt hsmmc to hwmod framework

2011-02-24 Thread Kadiyala, Kishore
On Thu, Feb 24, 2011 at 5:19 PM, Cousson, Benoit  wrote:
> On 2/23/2011 6:47 PM, Kadiyala, Kishore wrote:
>>
>> Changes involves:
>> 1) Remove controller reset in devices.c which is taken care of
>>    by hwmod framework.
>> 2) Removing all base address macro defines except keeping one for
>> OMAP2420.
>> 3) Using omap-device layer to register device and utilizing data from
>>    hwmod data file for base address, dma channel number, Irq_number,
>>    device attribute.
>>
>> Signed-off-by: Paul Walmsley
>> Signed-off-by: Kishore Kadiyala
>> Cc: Benoit Cousson
>> CC: Kevin Hilman
>> ---
>>  arch/arm/mach-omap2/devices.c         |  251
>> -
>>  arch/arm/mach-omap2/hsmmc.c           |  153 ++--
>>  arch/arm/plat-omap/include/plat/mmc.h |   14 --
>>  3 files changed, 141 insertions(+), 277 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
>> index 7b35c87..2d2deb6 100644
>> --- a/arch/arm/mach-omap2/devices.c
>> +++ b/arch/arm/mach-omap2/devices.c
>> @@ -503,112 +503,6 @@ static inline void omap_init_aes(void) { }
>>
>>
>>  /*-*/
>>
>> -#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
>> -
>> -#define MMCHS_SYSCONFIG                        0x0010
>> -#define MMCHS_SYSCONFIG_SWRESET                (1<<  1)
>> -#define MMCHS_SYSSTATUS                        0x0014
>> -#define MMCHS_SYSSTATUS_RESETDONE      (1<<  0)
>> -
>> -static struct platform_device dummy_pdev = {
>> -       .dev = {
>> -               .bus =&platform_bus_type,
>> -       },
>> -};
>> -
>> -/**
>> - * omap_hsmmc_reset() - Full reset of each HS-MMC controller
>> - *
>> - * Ensure that each MMC controller is fully reset.  Controllers
>> - * left in an unknown state (by bootloader) may prevent retention
>> - * or OFF-mode.  This is especially important in cases where the
>> - * MMC driver is not enabled, _or_ built as a module.
>> - *
>> - * In order for reset to work, interface, functional and debounce
>> - * clocks must be enabled.  The debounce clock comes from func_32k_clk
>> - * and is not under SW control, so we only enable i- and f-clocks.
>> - **/
>> -static void __init omap_hsmmc_reset(void)
>> -{
>> -       u32 i, nr_controllers;
>> -       struct clk *iclk, *fclk;
>> -
>> -       if (cpu_is_omap242x())
>> -               return;
>> -
>> -       nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
>> -               (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
>> -
>> -       for (i = 0; i<  nr_controllers; i++) {
>> -               u32 v, base = 0;
>> -               struct device *dev =&dummy_pdev.dev;
>> -
>> -               switch (i) {
>> -               case 0:
>> -                       base = OMAP2_MMC1_BASE;
>> -                       break;
>> -               case 1:
>> -                       base = OMAP2_MMC2_BASE;
>> -                       break;
>> -               case 2:
>> -                       base = OMAP3_MMC3_BASE;
>> -                       break;
>> -               case 3:
>> -                       if (!cpu_is_omap44xx())
>> -                               return;
>> -                       base = OMAP4_MMC4_BASE;
>> -                       break;
>> -               case 4:
>> -                       if (!cpu_is_omap44xx())
>> -                               return;
>> -                       base = OMAP4_MMC5_BASE;
>> -                       break;
>> -               }
>> -
>> -               if (cpu_is_omap44xx())
>> -                       base += OMAP4_MMC_REG_OFFSET;
>> -
>> -               dummy_pdev.id = i;
>> -               dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
>> -               iclk = clk_get(dev, "ick");
>> -               if (IS_ERR(iclk))
>> -                       goto err1;
>> -               if (clk_enable(iclk))
>> -                       goto err2;
>> -
>> -               fclk = clk_get(dev, "fck");
>> -               if (IS_ERR(fclk))
>> -                       goto err3;
>> -               if (clk_enable(fclk))
>> -                       goto err4;
>> -
>> -               omap_writel(MMCHS_SYSCONFIG_SWRESET, base +
>> MMCHS_SYSCONFIG);
>> -               v = omap_readl(base + MMCHS_SYSSTATUS);
>> -               while (!(omap_readl(base + MMCHS_SYSSTATUS)&
>> -                        MMCHS_SYSSTATUS_RESETDONE))
>> -                       cpu_relax();
>> -
>> -               clk_disable(fclk);
>> -               clk_put(fclk);
>> -               clk_disable(iclk);
>> -               clk_put(iclk);
>> -       }
>> -       return;
>> -
>> -err4:
>> -       clk_put(fclk);
>> -err3:
>> -       clk_disable(iclk);
>> -err2:
>> -       clk_put(iclk);
>> -err1:
>> -       printk(KERN_WARNING "%s: Unable to enable clocks for MMC%d, "
>> -                           "cannot reset.\n",  __func__, i);
>> -}
>> -#else
>> -static inline void omap_hsmmc_reset(void) {}
>> -#endif
>> -
>>  #if defined(CONFIG

Re: [PATCH v3 5/5] OMAP: adapt hsmmc to hwmod framework

2011-02-24 Thread Cousson, Benoit

On 2/23/2011 6:47 PM, Kadiyala, Kishore wrote:

Changes involves:
1) Remove controller reset in devices.c which is taken care of
by hwmod framework.
2) Removing all base address macro defines except keeping one for OMAP2420.
3) Using omap-device layer to register device and utilizing data from
hwmod data file for base address, dma channel number, Irq_number,
device attribute.

Signed-off-by: Paul Walmsley
Signed-off-by: Kishore Kadiyala
Cc: Benoit Cousson
CC: Kevin Hilman
---
  arch/arm/mach-omap2/devices.c |  251 -
  arch/arm/mach-omap2/hsmmc.c   |  153 ++--
  arch/arm/plat-omap/include/plat/mmc.h |   14 --
  3 files changed, 141 insertions(+), 277 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 7b35c87..2d2deb6 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -503,112 +503,6 @@ static inline void omap_init_aes(void) { }

  /*-*/

-#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
-
-#define MMCHS_SYSCONFIG0x0010
-#define MMCHS_SYSCONFIG_SWRESET(1<<  1)
-#define MMCHS_SYSSTATUS0x0014
-#define MMCHS_SYSSTATUS_RESETDONE  (1<<  0)
-
-static struct platform_device dummy_pdev = {
-   .dev = {
-   .bus =&platform_bus_type,
-   },
-};
-
-/**
- * omap_hsmmc_reset() - Full reset of each HS-MMC controller
- *
- * Ensure that each MMC controller is fully reset.  Controllers
- * left in an unknown state (by bootloader) may prevent retention
- * or OFF-mode.  This is especially important in cases where the
- * MMC driver is not enabled, _or_ built as a module.
- *
- * In order for reset to work, interface, functional and debounce
- * clocks must be enabled.  The debounce clock comes from func_32k_clk
- * and is not under SW control, so we only enable i- and f-clocks.
- **/
-static void __init omap_hsmmc_reset(void)
-{
-   u32 i, nr_controllers;
-   struct clk *iclk, *fclk;
-
-   if (cpu_is_omap242x())
-   return;
-
-   nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
-   (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
-
-   for (i = 0; i<  nr_controllers; i++) {
-   u32 v, base = 0;
-   struct device *dev =&dummy_pdev.dev;
-
-   switch (i) {
-   case 0:
-   base = OMAP2_MMC1_BASE;
-   break;
-   case 1:
-   base = OMAP2_MMC2_BASE;
-   break;
-   case 2:
-   base = OMAP3_MMC3_BASE;
-   break;
-   case 3:
-   if (!cpu_is_omap44xx())
-   return;
-   base = OMAP4_MMC4_BASE;
-   break;
-   case 4:
-   if (!cpu_is_omap44xx())
-   return;
-   base = OMAP4_MMC5_BASE;
-   break;
-   }
-
-   if (cpu_is_omap44xx())
-   base += OMAP4_MMC_REG_OFFSET;
-
-   dummy_pdev.id = i;
-   dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
-   iclk = clk_get(dev, "ick");
-   if (IS_ERR(iclk))
-   goto err1;
-   if (clk_enable(iclk))
-   goto err2;
-
-   fclk = clk_get(dev, "fck");
-   if (IS_ERR(fclk))
-   goto err3;
-   if (clk_enable(fclk))
-   goto err4;
-
-   omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
-   v = omap_readl(base + MMCHS_SYSSTATUS);
-   while (!(omap_readl(base + MMCHS_SYSSTATUS)&
-MMCHS_SYSSTATUS_RESETDONE))
-   cpu_relax();
-
-   clk_disable(fclk);
-   clk_put(fclk);
-   clk_disable(iclk);
-   clk_put(iclk);
-   }
-   return;
-
-err4:
-   clk_put(fclk);
-err3:
-   clk_disable(iclk);
-err2:
-   clk_put(iclk);
-err1:
-   printk(KERN_WARNING "%s: Unable to enable clocks for MMC%d, "
-   "cannot reset.\n",  __func__, i);
-}
-#else
-static inline void omap_hsmmc_reset(void) {}
-#endif
-
  #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)

  static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
@@ -665,150 +559,6 @@ void __init omap242x_init_mmc(struct 
omap_mmc_platform_data **mmc_data)

  #endif

-#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
-
-static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
-   int controller_nr)
-{
-   if ((mmc_controller->slots[0]

Re: [PATCH v3 5/5] OMAP: adapt hsmmc to hwmod framework

2011-02-23 Thread Varadarajan, Charulatha
Kishore,

On Wed, Feb 23, 2011 at 23:17, Kishore Kadiyala  wrote:
> Changes involves:
> 1) Remove controller reset in devices.c which is taken care of
>   by hwmod framework.
> 2) Removing all base address macro defines except keeping one for OMAP2420.

why?

> 3) Using omap-device layer to register device and utilizing data from
>   hwmod data file for base address, dma channel number, Irq_number,
>   device attribute.
>
> Signed-off-by: Paul Walmsley 
> Signed-off-by: Kishore Kadiyala 
> Cc: Benoit Cousson 
> CC: Kevin Hilman 
> ---
>  arch/arm/mach-omap2/devices.c         |  251 
> -
>  arch/arm/mach-omap2/hsmmc.c           |  153 ++--
>  arch/arm/plat-omap/include/plat/mmc.h |   14 --
>  3 files changed, 141 insertions(+), 277 deletions(-)
>

<>

> diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
> index 34272e4..b6e1eae 100644
> --- a/arch/arm/mach-omap2/hsmmc.c
> +++ b/arch/arm/mach-omap2/hsmmc.c
> @@ -16,7 +16,11 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
> +#include 
>
> +#include "mux.h"
>  #include "hsmmc.h"
>  #include "control.h"
>
> @@ -30,7 +34,7 @@ static u16 control_mmc1;
>
>  static struct hsmmc_controller {
>        char                            name[HSMMC_NAME_LEN + 1];
> -} hsmmc[OMAP34XX_NR_MMC];
> +} hsmmc[OMAP44XX_NR_MMC];

Why do you have a dependency on OMAP44XX_NR_MMC? You should get
this kind of information using number of iterations in *_hwmod_each_by_class.

>
>  #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
>
> @@ -204,7 +208,141 @@ static int nop_mmc_set_power(struct device *dev, int 
> slot, int power_on,
>        return 0;
>  }
>
> -static struct omap_mmc_platform_data *hsmmc_data[OMAP34XX_NR_MMC] __initdata;
> +static inline void omap2_mmc_mux(struct omap_mmc_platform_data 
> *mmc_controller,
> +                       int controller_nr)
> +{
> +       if ((mmc_controller->slots[0].switch_pin > 0) && \
> +               (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
> +               omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
> +                                       OMAP_PIN_INPUT_PULLUP);
> +       if ((mmc_controller->slots[0].gpio_wp > 0) && \
> +               (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
> +               omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
> +                                       OMAP_PIN_INPUT_PULLUP);
> +       if (cpu_is_omap34xx()) {
> +               if (controller_nr == 0) {
> +                       omap_mux_init_signal("sdmmc1_clk",
> +                               OMAP_PIN_INPUT_PULLUP);
> +                       omap_mux_init_signal("sdmmc1_cmd",
> +                               OMAP_PIN_INPUT_PULLUP);
> +                       omap_mux_init_signal("sdmmc1_dat0",
> +                               OMAP_PIN_INPUT_PULLUP);
> +                       if (mmc_controller->slots[0].caps &
> +                               (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
> +                               omap_mux_init_signal("sdmmc1_dat1",
> +                                       OMAP_PIN_INPUT_PULLUP);
> +                               omap_mux_init_signal("sdmmc1_dat2",
> +                                       OMAP_PIN_INPUT_PULLUP);
> +                               omap_mux_init_signal("sdmmc1_dat3",
> +                                       OMAP_PIN_INPUT_PULLUP);
> +                       }
> +                       if (mmc_controller->slots[0].caps &
> +                                               MMC_CAP_8_BIT_DATA) {
> +                               omap_mux_init_signal("sdmmc1_dat4",
> +                                       OMAP_PIN_INPUT_PULLUP);
> +                               omap_mux_init_signal("sdmmc1_dat5",
> +                                       OMAP_PIN_INPUT_PULLUP);
> +                               omap_mux_init_signal("sdmmc1_dat6",
> +                                       OMAP_PIN_INPUT_PULLUP);
> +                               omap_mux_init_signal("sdmmc1_dat7",
> +                                       OMAP_PIN_INPUT_PULLUP);
> +                       }
> +               }
> +               if (controller_nr == 1) {
> +                       /* MMC2 */
> +                       omap_mux_init_signal("sdmmc2_clk",
> +                               OMAP_PIN_INPUT_PULLUP);
> +                       omap_mux_init_signal("sdmmc2_cmd",
> +                               OMAP_PIN_INPUT_PULLUP);
> +                       omap_mux_init_signal("sdmmc2_dat0",
> +                               OMAP_PIN_INPUT_PULLUP);
> +
> +                       /*
> +                        * For 8 wire configurations, Lines DAT4, 5, 6 and 7
> +                        * need to be muxed in the board-*.c files
> +                        */
> +                       if (mmc_controller->slots[0].caps &
> +                               (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
> +    

[PATCH v3 5/5] OMAP: adapt hsmmc to hwmod framework

2011-02-23 Thread Kishore Kadiyala
Changes involves:
1) Remove controller reset in devices.c which is taken care of
   by hwmod framework.
2) Removing all base address macro defines except keeping one for OMAP2420.
3) Using omap-device layer to register device and utilizing data from
   hwmod data file for base address, dma channel number, Irq_number,
   device attribute.

Signed-off-by: Paul Walmsley 
Signed-off-by: Kishore Kadiyala 
Cc: Benoit Cousson 
CC: Kevin Hilman 
---
 arch/arm/mach-omap2/devices.c |  251 -
 arch/arm/mach-omap2/hsmmc.c   |  153 ++--
 arch/arm/plat-omap/include/plat/mmc.h |   14 --
 3 files changed, 141 insertions(+), 277 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 7b35c87..2d2deb6 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -503,112 +503,6 @@ static inline void omap_init_aes(void) { }
 
 /*-*/
 
-#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
-
-#define MMCHS_SYSCONFIG0x0010
-#define MMCHS_SYSCONFIG_SWRESET(1 << 1)
-#define MMCHS_SYSSTATUS0x0014
-#define MMCHS_SYSSTATUS_RESETDONE  (1 << 0)
-
-static struct platform_device dummy_pdev = {
-   .dev = {
-   .bus = &platform_bus_type,
-   },
-};
-
-/**
- * omap_hsmmc_reset() - Full reset of each HS-MMC controller
- *
- * Ensure that each MMC controller is fully reset.  Controllers
- * left in an unknown state (by bootloader) may prevent retention
- * or OFF-mode.  This is especially important in cases where the
- * MMC driver is not enabled, _or_ built as a module.
- *
- * In order for reset to work, interface, functional and debounce
- * clocks must be enabled.  The debounce clock comes from func_32k_clk
- * and is not under SW control, so we only enable i- and f-clocks.
- **/
-static void __init omap_hsmmc_reset(void)
-{
-   u32 i, nr_controllers;
-   struct clk *iclk, *fclk;
-
-   if (cpu_is_omap242x())
-   return;
-
-   nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
-   (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
-
-   for (i = 0; i < nr_controllers; i++) {
-   u32 v, base = 0;
-   struct device *dev = &dummy_pdev.dev;
-
-   switch (i) {
-   case 0:
-   base = OMAP2_MMC1_BASE;
-   break;
-   case 1:
-   base = OMAP2_MMC2_BASE;
-   break;
-   case 2:
-   base = OMAP3_MMC3_BASE;
-   break;
-   case 3:
-   if (!cpu_is_omap44xx())
-   return;
-   base = OMAP4_MMC4_BASE;
-   break;
-   case 4:
-   if (!cpu_is_omap44xx())
-   return;
-   base = OMAP4_MMC5_BASE;
-   break;
-   }
-
-   if (cpu_is_omap44xx())
-   base += OMAP4_MMC_REG_OFFSET;
-
-   dummy_pdev.id = i;
-   dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
-   iclk = clk_get(dev, "ick");
-   if (IS_ERR(iclk))
-   goto err1;
-   if (clk_enable(iclk))
-   goto err2;
-
-   fclk = clk_get(dev, "fck");
-   if (IS_ERR(fclk))
-   goto err3;
-   if (clk_enable(fclk))
-   goto err4;
-
-   omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
-   v = omap_readl(base + MMCHS_SYSSTATUS);
-   while (!(omap_readl(base + MMCHS_SYSSTATUS) &
-MMCHS_SYSSTATUS_RESETDONE))
-   cpu_relax();
-
-   clk_disable(fclk);
-   clk_put(fclk);
-   clk_disable(iclk);
-   clk_put(iclk);
-   }
-   return;
-
-err4:
-   clk_put(fclk);
-err3:
-   clk_disable(iclk);
-err2:
-   clk_put(iclk);
-err1:
-   printk(KERN_WARNING "%s: Unable to enable clocks for MMC%d, "
-   "cannot reset.\n",  __func__, i);
-}
-#else
-static inline void omap_hsmmc_reset(void) {}
-#endif
-
 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
 
 static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
@@ -665,150 +559,6 @@ void __init omap242x_init_mmc(struct 
omap_mmc_platform_data **mmc_data)
 
 #endif
 
-#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
-
-static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
-   int controller_nr)
-{
-   if ((mmc_controller->slots[0].switch_pin > 0) && \
-   (mmc_contr