diff mbox

[U-Boot,v3,1/4] tegra2: Move MMC clock initialization into MMC driver

Message ID 1317923583-32762-1-git-send-email-swarren@nvidia.com
State Accepted
Commit de71fbe468b5531914735c88834187ae4e64202f
Delegated to: Andy Fleming
Headers show

Commit Message

Stephen Warren Oct. 6, 2011, 5:53 p.m. UTC
This centralizes knowledge of MMC clocking into the MMC driver. This also
removes clock setup from the board files, which will simplify later changes
that modify the Harmony board to support the correct set of MMC controllers.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
Note: These patches build on various Tegra2-related patches recently posted
by Simon Glass; see v2 of the 6-entry patchset shown at:
http://patchwork.ozlabs.org/project/uboot/list/?submitter=6170&state=1&q=tegra2

 board/nvidia/common/board.c |   13 +------------
 drivers/mmc/tegra2_mmc.c    |   12 +++++++++---
 2 files changed, 10 insertions(+), 15 deletions(-)

Comments

Simon Glass Oct. 8, 2011, 12:03 a.m. UTC | #1
On Thu, Oct 6, 2011 at 10:53 AM, Stephen Warren <swarren@nvidia.com> wrote:
> This centralizes knowledge of MMC clocking into the MMC driver. This also
> removes clock setup from the board files, which will simplify later changes
> that modify the Harmony board to support the correct set of MMC controllers.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> Note: These patches build on various Tegra2-related patches recently posted
> by Simon Glass; see v2 of the 6-entry patchset shown at:
> http://patchwork.ozlabs.org/project/uboot/list/?submitter=6170&state=1&q=tegra2
>
>  board/nvidia/common/board.c |   13 +------------
>  drivers/mmc/tegra2_mmc.c    |   12 +++++++++---
>  2 files changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
> index d13537d..370a259 100644
> --- a/board/nvidia/common/board.c
> +++ b/board/nvidia/common/board.c
> @@ -102,16 +102,6 @@ static void pin_mux_uart(void)
>
>  #ifdef CONFIG_TEGRA2_MMC
>  /*
> - * Routine: clock_init_mmc
> - * Description: init the PLL and clocks for the SDMMC controllers
> - */
> -static void clock_init_mmc(void)
> -{
> -       clock_start_periph_pll(PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH, 20000000);
> -       clock_start_periph_pll(PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH, 20000000);
> -}
> -
> -/*
>  * Routine: pin_mux_mmc
>  * Description: setup the pin muxes/tristate values for the SDMMC(s)
>  */
> @@ -157,8 +147,7 @@ int board_init(void)
>  int board_mmc_init(bd_t *bd)
>  {
>        debug("board_mmc_init called\n");
> -       /* Enable clocks, muxes, etc. for SDMMC controllers */
> -       clock_init_mmc();
> +       /* Enable muxes, etc. for SDMMC controllers */
>        pin_mux_mmc();
>        gpio_config_mmc();
>
> diff --git a/drivers/mmc/tegra2_mmc.c b/drivers/mmc/tegra2_mmc.c
> index 9e741f2..78b1190 100644
> --- a/drivers/mmc/tegra2_mmc.c
> +++ b/drivers/mmc/tegra2_mmc.c
> @@ -435,14 +435,22 @@ static int mmc_core_init(struct mmc *mmc)
>
>  static int tegra2_mmc_initialize(int dev_index, int bus_width)
>  {
> +       struct mmc_host *host;
>        struct mmc *mmc;
>
>        debug(" mmc_initialize called\n");
>
> +       host = &mmc_host[dev_index];
> +
> +       host->clock = 0;
> +       tegra2_get_setup(host, dev_index);
> +
> +       clock_start_periph_pll(host->mmc_id, CLOCK_ID_PERIPH, 20000000);
> +
>        mmc = &mmc_dev[dev_index];
>
>        sprintf(mmc->name, "Tegra2 SD/MMC");
> -       mmc->priv = &mmc_host[dev_index];
> +       mmc->priv = host;
>        mmc->send_cmd = mmc_send_cmd;
>        mmc->set_ios = mmc_set_ios;
>        mmc->init = mmc_core_init;
> @@ -465,8 +473,6 @@ static int tegra2_mmc_initialize(int dev_index, int bus_width)
>        mmc->f_min = 375000;
>        mmc->f_max = 48000000;
>
> -       mmc_host[dev_index].clock = 0;
> -       tegra2_get_setup(&mmc_host[dev_index], dev_index);
>        mmc_register(mmc);
>
>        return 0;
> --
> 1.7.0.4
>
>

Acked-by: Simon Glass <sjg@chromium.org>
Simon Glass Oct. 11, 2011, 11:41 p.m. UTC | #2
On Fri, Oct 7, 2011 at 5:03 PM, Simon Glass <sjg@chromium.org> wrote:
> On Thu, Oct 6, 2011 at 10:53 AM, Stephen Warren <swarren@nvidia.com> wrote:
>> This centralizes knowledge of MMC clocking into the MMC driver. This also
>> removes clock setup from the board files, which will simplify later changes
>> that modify the Harmony board to support the correct set of MMC controllers.
>>
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>> ---
>> Note: These patches build on various Tegra2-related patches recently posted
>> by Simon Glass; see v2 of the 6-entry patchset shown at:
>> http://patchwork.ozlabs.org/project/uboot/list/?submitter=6170&state=1&q=tegra2
>>
>>  board/nvidia/common/board.c |   13 +------------
>>  drivers/mmc/tegra2_mmc.c    |   12 +++++++++---
>>  2 files changed, 10 insertions(+), 15 deletions(-)
>>
>> diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
>> index d13537d..370a259 100644
>> --- a/board/nvidia/common/board.c
>> +++ b/board/nvidia/common/board.c
>> @@ -102,16 +102,6 @@ static void pin_mux_uart(void)
>>
>>  #ifdef CONFIG_TEGRA2_MMC
>>  /*
>> - * Routine: clock_init_mmc
>> - * Description: init the PLL and clocks for the SDMMC controllers
>> - */
>> -static void clock_init_mmc(void)
>> -{
>> -       clock_start_periph_pll(PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH, 20000000);
>> -       clock_start_periph_pll(PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH, 20000000);
>> -}
>> -
>> -/*
>>  * Routine: pin_mux_mmc
>>  * Description: setup the pin muxes/tristate values for the SDMMC(s)
>>  */
>> @@ -157,8 +147,7 @@ int board_init(void)
>>  int board_mmc_init(bd_t *bd)
>>  {
>>        debug("board_mmc_init called\n");
>> -       /* Enable clocks, muxes, etc. for SDMMC controllers */
>> -       clock_init_mmc();
>> +       /* Enable muxes, etc. for SDMMC controllers */
>>        pin_mux_mmc();
>>        gpio_config_mmc();
>>
>> diff --git a/drivers/mmc/tegra2_mmc.c b/drivers/mmc/tegra2_mmc.c
>> index 9e741f2..78b1190 100644
>> --- a/drivers/mmc/tegra2_mmc.c
>> +++ b/drivers/mmc/tegra2_mmc.c
>> @@ -435,14 +435,22 @@ static int mmc_core_init(struct mmc *mmc)
>>
>>  static int tegra2_mmc_initialize(int dev_index, int bus_width)
>>  {
>> +       struct mmc_host *host;
>>        struct mmc *mmc;
>>
>>        debug(" mmc_initialize called\n");
>>
>> +       host = &mmc_host[dev_index];
>> +
>> +       host->clock = 0;
>> +       tegra2_get_setup(host, dev_index);
>> +
>> +       clock_start_periph_pll(host->mmc_id, CLOCK_ID_PERIPH, 20000000);
>> +
>>        mmc = &mmc_dev[dev_index];
>>
>>        sprintf(mmc->name, "Tegra2 SD/MMC");
>> -       mmc->priv = &mmc_host[dev_index];
>> +       mmc->priv = host;
>>        mmc->send_cmd = mmc_send_cmd;
>>        mmc->set_ios = mmc_set_ios;
>>        mmc->init = mmc_core_init;
>> @@ -465,8 +473,6 @@ static int tegra2_mmc_initialize(int dev_index, int bus_width)
>>        mmc->f_min = 375000;
>>        mmc->f_max = 48000000;
>>
>> -       mmc_host[dev_index].clock = 0;
>> -       tegra2_get_setup(&mmc_host[dev_index], dev_index);
>>        mmc_register(mmc);
>>
>>        return 0;
>> --
>> 1.7.0.4
>>
>>
>
> Acked-by: Simon Glass <sjg@chromium.org>
>

Tested on Seaboard T25

Tested-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
index d13537d..370a259 100644
--- a/board/nvidia/common/board.c
+++ b/board/nvidia/common/board.c
@@ -102,16 +102,6 @@  static void pin_mux_uart(void)
 
 #ifdef CONFIG_TEGRA2_MMC
 /*
- * Routine: clock_init_mmc
- * Description: init the PLL and clocks for the SDMMC controllers
- */
-static void clock_init_mmc(void)
-{
-	clock_start_periph_pll(PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH, 20000000);
-	clock_start_periph_pll(PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH, 20000000);
-}
-
-/*
  * Routine: pin_mux_mmc
  * Description: setup the pin muxes/tristate values for the SDMMC(s)
  */
@@ -157,8 +147,7 @@  int board_init(void)
 int board_mmc_init(bd_t *bd)
 {
 	debug("board_mmc_init called\n");
-	/* Enable clocks, muxes, etc. for SDMMC controllers */
-	clock_init_mmc();
+	/* Enable muxes, etc. for SDMMC controllers */
 	pin_mux_mmc();
 	gpio_config_mmc();
 
diff --git a/drivers/mmc/tegra2_mmc.c b/drivers/mmc/tegra2_mmc.c
index 9e741f2..78b1190 100644
--- a/drivers/mmc/tegra2_mmc.c
+++ b/drivers/mmc/tegra2_mmc.c
@@ -435,14 +435,22 @@  static int mmc_core_init(struct mmc *mmc)
 
 static int tegra2_mmc_initialize(int dev_index, int bus_width)
 {
+	struct mmc_host *host;
 	struct mmc *mmc;
 
 	debug(" mmc_initialize called\n");
 
+	host = &mmc_host[dev_index];
+
+	host->clock = 0;
+	tegra2_get_setup(host, dev_index);
+
+	clock_start_periph_pll(host->mmc_id, CLOCK_ID_PERIPH, 20000000);
+
 	mmc = &mmc_dev[dev_index];
 
 	sprintf(mmc->name, "Tegra2 SD/MMC");
-	mmc->priv = &mmc_host[dev_index];
+	mmc->priv = host;
 	mmc->send_cmd = mmc_send_cmd;
 	mmc->set_ios = mmc_set_ios;
 	mmc->init = mmc_core_init;
@@ -465,8 +473,6 @@  static int tegra2_mmc_initialize(int dev_index, int bus_width)
 	mmc->f_min = 375000;
 	mmc->f_max = 48000000;
 
-	mmc_host[dev_index].clock = 0;
-	tegra2_get_setup(&mmc_host[dev_index], dev_index);
 	mmc_register(mmc);
 
 	return 0;