All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver
@ 2011-10-06 17:53 Stephen Warren
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 2/4] tegra2: Move board_mmc_init into board files Stephen Warren
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Stephen Warren @ 2011-10-06 17:53 UTC (permalink / raw)
  To: u-boot

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

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

* [U-Boot] [PATCH v3 2/4] tegra2: Move board_mmc_init into board files
  2011-10-06 17:53 [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver Stephen Warren
@ 2011-10-06 17:53 ` Stephen Warren
  2011-10-11 23:45   ` Simon Glass
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 3/4] tegra2: Modify MMC driver to handle power and cd GPIOs Stephen Warren
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Stephen Warren @ 2011-10-06 17:53 UTC (permalink / raw)
  To: u-boot

For Seaboard, this is mostly a cut/paste of board_mmc_init() and
pin_mux_mmc() into seaboard.c; pin_mux_mmc() was modified to add some
missing pinmux_tristate_disable calls for the GPIOs.

For Harmony, those functions were modified to configure SDMMC2 (index 2)
instead of SDMMC3 (index 1), since that's what is present on the board.

However, harmony.c is still missing the required GPIO setup, so neither
port is likely to function correctly yet.  This will be fixed in the next
change.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 board/nvidia/common/board.c      |   52 -----------------------------------
 board/nvidia/harmony/harmony.c   |   55 ++++++++++++++++++++++++++++++++++++++
 board/nvidia/seaboard/seaboard.c |   52 +++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+), 52 deletions(-)

diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
index 370a259..0f12de2 100644
--- a/board/nvidia/common/board.c
+++ b/board/nvidia/common/board.c
@@ -33,10 +33,6 @@
 #include <asm/arch/uart.h>
 #include "board.h"
 
-#ifdef CONFIG_TEGRA2_MMC
-#include <mmc.h>
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 const struct tegra2_sysinfo sysinfo = {
@@ -100,33 +96,6 @@ static void pin_mux_uart(void)
 #endif	/* CONFIG_TEGRA2_ENABLE_UARTD */
 }
 
-#ifdef CONFIG_TEGRA2_MMC
-/*
- * Routine: pin_mux_mmc
- * Description: setup the pin muxes/tristate values for the SDMMC(s)
- */
-static void pin_mux_mmc(void)
-{
-	/* SDMMC4: config 3, x8 on 2nd set of pins */
-	pinmux_set_func(PINGRP_ATB, PMUX_FUNC_SDIO4);
-	pinmux_set_func(PINGRP_GMA, PMUX_FUNC_SDIO4);
-	pinmux_set_func(PINGRP_GME, PMUX_FUNC_SDIO4);
-
-	pinmux_tristate_disable(PINGRP_ATB);
-	pinmux_tristate_disable(PINGRP_GMA);
-	pinmux_tristate_disable(PINGRP_GME);
-
-	/* SDMMC3: SDIO3_CLK, SDIO3_CMD, SDIO3_DAT[3:0] */
-	pinmux_set_func(PINGRP_SDB, PMUX_FUNC_SDIO3);
-	pinmux_set_func(PINGRP_SDC, PMUX_FUNC_SDIO3);
-	pinmux_set_func(PINGRP_SDD, PMUX_FUNC_SDIO3);
-
-	pinmux_tristate_disable(PINGRP_SDC);
-	pinmux_tristate_disable(PINGRP_SDD);
-	pinmux_tristate_disable(PINGRP_SDB);
-}
-#endif
-
 /*
  * Routine: board_init
  * Description: Early hardware init.
@@ -142,27 +111,6 @@ int board_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_TEGRA2_MMC
-/* this is a weak define that we are overriding */
-int board_mmc_init(bd_t *bd)
-{
-	debug("board_mmc_init called\n");
-	/* Enable muxes, etc. for SDMMC controllers */
-	pin_mux_mmc();
-	gpio_config_mmc();
-
-	debug("board_mmc_init: init eMMC\n");
-	/* init dev 0, eMMC chip, with 4-bit bus */
-	tegra2_mmc_init(0, 4);
-
-	debug("board_mmc_init: init SD slot\n");
-	/* init dev 1, SD slot, with 4-bit bus */
-	tegra2_mmc_init(1, 4);
-
-	return 0;
-}
-#endif
-
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 int board_early_init_f(void)
 {
diff --git a/board/nvidia/harmony/harmony.c b/board/nvidia/harmony/harmony.c
index cbb30d6..b01302f 100644
--- a/board/nvidia/harmony/harmony.c
+++ b/board/nvidia/harmony/harmony.c
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/tegra2.h>
+#include <asm/arch/pinmux.h>
 #ifdef CONFIG_TEGRA2_MMC
 #include <mmc.h>
 #endif
@@ -38,6 +39,39 @@ void gpio_config_uart(void)
 
 #ifdef CONFIG_TEGRA2_MMC
 /*
+ * Routine: pin_mux_mmc
+ * Description: setup the pin muxes/tristate values for the SDMMC(s)
+ */
+static void pin_mux_mmc(void)
+{
+	/* SDMMC4: config 3, x8 on 2nd set of pins */
+	pinmux_set_func(PINGRP_ATB, PMUX_FUNC_SDIO4);
+	pinmux_set_func(PINGRP_GMA, PMUX_FUNC_SDIO4);
+	pinmux_set_func(PINGRP_GME, PMUX_FUNC_SDIO4);
+
+	pinmux_tristate_disable(PINGRP_ATB);
+	pinmux_tristate_disable(PINGRP_GMA);
+	pinmux_tristate_disable(PINGRP_GME);
+
+	/* For power GPIO PI6 */
+	pinmux_tristate_disable(PINGRP_ATA);
+	/* For CD GPIO PH2 */
+	pinmux_tristate_disable(PINGRP_ATD);
+
+	/* SDMMC2: SDIO2_CLK, SDIO2_CMD, SDIO2_DAT[7:0] */
+	pinmux_set_func(PINGRP_DTA, PMUX_FUNC_SDIO2);
+	pinmux_set_func(PINGRP_DTD, PMUX_FUNC_SDIO2);
+
+	pinmux_tristate_disable(PINGRP_DTA);
+	pinmux_tristate_disable(PINGRP_DTD);
+
+	/* For power GPIO PT3 */
+	pinmux_tristate_disable(PINGRP_DTB);
+	/* For CD GPIO PI5 */
+	pinmux_tristate_disable(PINGRP_ATC);
+}
+
+/*
  * Routine: gpio_config_mmc
  * Description: Set GPIOs for SD card
  */
@@ -47,6 +81,27 @@ void gpio_config_mmc(void)
 }
 
 /* this is a weak define that we are overriding */
+int board_mmc_init(bd_t *bd)
+{
+	debug("board_mmc_init called\n");
+
+	/* Enable muxes, etc. for SDMMC controllers */
+	pin_mux_mmc();
+	gpio_config_mmc();
+
+	debug("board_mmc_init: init SD slot J26\n");
+	/* init dev 0, SD slot J26, with 4-bit bus */
+	/* The board has an 8-bit bus, but 8-bit doesn't work yet */
+	tegra2_mmc_init(0, 4);
+
+	debug("board_mmc_init: init SD slot J5\n");
+	/* init dev 2, SD slot J5, with 4-bit bus */
+	tegra2_mmc_init(2, 4);
+
+	return 0;
+}
+
+/* this is a weak define that we are overriding */
 int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 {
 	debug("board_mmc_getcd called\n");
diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c
index bc67d0f..f8ef865 100644
--- a/board/nvidia/seaboard/seaboard.c
+++ b/board/nvidia/seaboard/seaboard.c
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/tegra2.h>
+#include <asm/arch/pinmux.h>
 #include <asm/gpio.h>
 #ifdef CONFIG_TEGRA2_MMC
 #include <mmc.h>
@@ -56,6 +57,36 @@ void gpio_config_uart(void)
 
 #ifdef CONFIG_TEGRA2_MMC
 /*
+ * Routine: pin_mux_mmc
+ * Description: setup the pin muxes/tristate values for the SDMMC(s)
+ */
+static void pin_mux_mmc(void)
+{
+	/* SDMMC4: config 3, x8 on 2nd set of pins */
+	pinmux_set_func(PINGRP_ATB, PMUX_FUNC_SDIO4);
+	pinmux_set_func(PINGRP_GMA, PMUX_FUNC_SDIO4);
+	pinmux_set_func(PINGRP_GME, PMUX_FUNC_SDIO4);
+
+	pinmux_tristate_disable(PINGRP_ATB);
+	pinmux_tristate_disable(PINGRP_GMA);
+	pinmux_tristate_disable(PINGRP_GME);
+
+	/* SDMMC3: SDIO3_CLK, SDIO3_CMD, SDIO3_DAT[3:0] */
+	pinmux_set_func(PINGRP_SDB, PMUX_FUNC_SDIO3);
+	pinmux_set_func(PINGRP_SDC, PMUX_FUNC_SDIO3);
+	pinmux_set_func(PINGRP_SDD, PMUX_FUNC_SDIO3);
+
+	pinmux_tristate_disable(PINGRP_SDC);
+	pinmux_tristate_disable(PINGRP_SDD);
+	pinmux_tristate_disable(PINGRP_SDB);
+
+	/* For power GPIO PI6 */
+	pinmux_tristate_disable(PINGRP_ATA);
+	/* For CD GPIO PI5 */
+	pinmux_tristate_disable(PINGRP_ATC);
+}
+
+/*
  * Routine: gpio_config_mmc
  * Description: Set GPIOs for SDMMC3 SDIO slot.
  */
@@ -69,6 +100,27 @@ void gpio_config_mmc(void)
 }
 
 /* this is a weak define that we are overriding */
+int board_mmc_init(bd_t *bd)
+{
+	debug("board_mmc_init called\n");
+
+	/* Enable muxes, etc. for SDMMC controllers */
+	pin_mux_mmc();
+	gpio_config_mmc();
+
+	debug("board_mmc_init: init eMMC\n");
+	/* init dev 0, eMMC chip, with 4-bit bus */
+	/* The board has an 8-bit bus, but 8-bit doesn't work yet */
+	tegra2_mmc_init(0, 4);
+
+	debug("board_mmc_init: init SD slot\n");
+	/* init dev 1, SD slot, with 4-bit bus */
+	tegra2_mmc_init(1, 4);
+
+	return 0;
+}
+
+/* this is a weak define that we are overriding */
 int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 {
 	debug("board_mmc_getcd called\n");
-- 
1.7.0.4

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

* [U-Boot] [PATCH v3 3/4] tegra2: Modify MMC driver to handle power and cd GPIOs
  2011-10-06 17:53 [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver Stephen Warren
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 2/4] tegra2: Move board_mmc_init into board files Stephen Warren
@ 2011-10-06 17:53 ` Stephen Warren
  2011-10-11 23:46   ` Simon Glass
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 4/4] tegra2: Add support for Ventana Stephen Warren
  2011-10-08  0:03 ` [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver Simon Glass
  3 siblings, 1 reply; 12+ messages in thread
From: Stephen Warren @ 2011-10-06 17:53 UTC (permalink / raw)
  To: u-boot

Pass the GPIO numbers for power and card detect to tegra2_mmc_init(), and
modify that function to perform all required GPIO initialization. This
removes the need for board files to perform these operations.

Move board_mmc_getcd() into tegra2_mmc.c now that the driver knows which
GPIOs to use.

Update affected call-sites in seaboard.c and harmony.c. Note that this
change should make all SD ports work on Harmony, since the required GPIO
setup is now being performed.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 board/nvidia/harmony/harmony.c   |   27 ++---------------------
 board/nvidia/seaboard/seaboard.c |   33 +----------------------------
 drivers/mmc/tegra2_mmc.c         |   42 ++++++++++++++++++++++++++++++++-----
 drivers/mmc/tegra2_mmc.h         |    4 ++-
 4 files changed, 44 insertions(+), 62 deletions(-)

diff --git a/board/nvidia/harmony/harmony.c b/board/nvidia/harmony/harmony.c
index b01302f..923942c 100644
--- a/board/nvidia/harmony/harmony.c
+++ b/board/nvidia/harmony/harmony.c
@@ -25,6 +25,7 @@
 #include <asm/io.h>
 #include <asm/arch/tegra2.h>
 #include <asm/arch/pinmux.h>
+#include <asm/gpio.h>
 #ifdef CONFIG_TEGRA2_MMC
 #include <mmc.h>
 #endif
@@ -71,15 +72,6 @@ static void pin_mux_mmc(void)
 	pinmux_tristate_disable(PINGRP_ATC);
 }
 
-/*
- * Routine: gpio_config_mmc
- * Description: Set GPIOs for SD card
- */
-void gpio_config_mmc(void)
-{
-	/* Not implemented for now */
-}
-
 /* this is a weak define that we are overriding */
 int board_mmc_init(bd_t *bd)
 {
@@ -87,29 +79,16 @@ int board_mmc_init(bd_t *bd)
 
 	/* Enable muxes, etc. for SDMMC controllers */
 	pin_mux_mmc();
-	gpio_config_mmc();
 
 	debug("board_mmc_init: init SD slot J26\n");
 	/* init dev 0, SD slot J26, with 4-bit bus */
 	/* The board has an 8-bit bus, but 8-bit doesn't work yet */
-	tegra2_mmc_init(0, 4);
+	tegra2_mmc_init(0, 4, GPIO_PI6, GPIO_PH2);
 
 	debug("board_mmc_init: init SD slot J5\n");
 	/* init dev 2, SD slot J5, with 4-bit bus */
-	tegra2_mmc_init(2, 4);
+	tegra2_mmc_init(2, 4, GPIO_PT3, GPIO_PI5);
 
 	return 0;
 }
-
-/* this is a weak define that we are overriding */
-int board_mmc_getcd(u8 *cd, struct mmc *mmc)
-{
-	debug("board_mmc_getcd called\n");
-	/*
-	 * Hard-code CD presence for now. Need to add GPIO inputs
-	 * for Harmony
-	 */
-	*cd = 1;
-	return 0;
-}
 #endif
diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c
index f8ef865..be6ed12 100644
--- a/board/nvidia/seaboard/seaboard.c
+++ b/board/nvidia/seaboard/seaboard.c
@@ -86,19 +86,6 @@ static void pin_mux_mmc(void)
 	pinmux_tristate_disable(PINGRP_ATC);
 }
 
-/*
- * Routine: gpio_config_mmc
- * Description: Set GPIOs for SDMMC3 SDIO slot.
- */
-void gpio_config_mmc(void)
-{
-	/* Set EN_VDDIO_SD (GPIO I6) */
-	gpio_direction_output(GPIO_PI6, 1);
-
-	/* Config pin as GPI for Card Detect (GPIO I5) */
-	gpio_direction_input(GPIO_PI5);
-}
-
 /* this is a weak define that we are overriding */
 int board_mmc_init(bd_t *bd)
 {
@@ -106,31 +93,15 @@ int board_mmc_init(bd_t *bd)
 
 	/* Enable muxes, etc. for SDMMC controllers */
 	pin_mux_mmc();
-	gpio_config_mmc();
 
 	debug("board_mmc_init: init eMMC\n");
 	/* init dev 0, eMMC chip, with 4-bit bus */
 	/* The board has an 8-bit bus, but 8-bit doesn't work yet */
-	tegra2_mmc_init(0, 4);
+	tegra2_mmc_init(0, 4, -1, -1);
 
 	debug("board_mmc_init: init SD slot\n");
 	/* init dev 1, SD slot, with 4-bit bus */
-	tegra2_mmc_init(1, 4);
-
-	return 0;
-}
-
-/* this is a weak define that we are overriding */
-int board_mmc_getcd(u8 *cd, struct mmc *mmc)
-{
-	debug("board_mmc_getcd called\n");
-	*cd = 1;			/* Assume card is inserted, or eMMC */
-
-	if (IS_SD(mmc)) {
-		/* Seaboard SDMMC3 = SDIO3_CD = GPIO_PI5 */
-		if (gpio_get_value(GPIO_PI5))
-			*cd = 0;
-	}
+	tegra2_mmc_init(1, 4, GPIO_PI6, GPIO_PI5);
 
 	return 0;
 }
diff --git a/drivers/mmc/tegra2_mmc.c b/drivers/mmc/tegra2_mmc.c
index 78b1190..3de9c5d 100644
--- a/drivers/mmc/tegra2_mmc.c
+++ b/drivers/mmc/tegra2_mmc.c
@@ -21,6 +21,7 @@
 
 #include <common.h>
 #include <mmc.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clk_rst.h>
 #include <asm/arch/clock.h>
@@ -433,20 +434,37 @@ static int mmc_core_init(struct mmc *mmc)
 	return 0;
 }
 
-static int tegra2_mmc_initialize(int dev_index, int bus_width)
+int tegra2_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio)
 {
 	struct mmc_host *host;
+	char gpusage[12]; /* "SD/MMCn PWR" or "SD/MMCn CD" */
 	struct mmc *mmc;
 
-	debug(" mmc_initialize called\n");
+	debug(" tegra2_mmc_init: index %d, bus width %d "
+		"pwr_gpio %d cd_gpio %d\n",
+		dev_index, bus_width, pwr_gpio, cd_gpio);
 
 	host = &mmc_host[dev_index];
 
 	host->clock = 0;
+	host->pwr_gpio = pwr_gpio;
+	host->cd_gpio = cd_gpio;
 	tegra2_get_setup(host, dev_index);
 
 	clock_start_periph_pll(host->mmc_id, CLOCK_ID_PERIPH, 20000000);
 
+	if (host->pwr_gpio >= 0) {
+		sprintf(gpusage, "SD/MMC%d PWR", dev_index);
+		gpio_request(host->pwr_gpio, gpusage);
+		gpio_direction_output(host->pwr_gpio, 1);
+	}
+
+	if (host->cd_gpio >= 0) {
+		sprintf(gpusage, "SD/MMC%d CD", dev_index);
+		gpio_request(host->cd_gpio, gpusage);
+		gpio_direction_input(host->cd_gpio);
+	}
+
 	mmc = &mmc_dev[dev_index];
 
 	sprintf(mmc->name, "Tegra2 SD/MMC");
@@ -478,9 +496,21 @@ static int tegra2_mmc_initialize(int dev_index, int bus_width)
 	return 0;
 }
 
-int tegra2_mmc_init(int dev_index, int bus_width)
+/* this is a weak define that we are overriding */
+int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 {
-	debug(" tegra2_mmc_init: index %d, bus width %d\n",
-		dev_index, bus_width);
-	return tegra2_mmc_initialize(dev_index, bus_width);
+	struct mmc_host *host = (struct mmc_host *)mmc->priv;
+
+	debug("board_mmc_getcd called\n");
+
+	*cd = 1; /* Assume card is inserted, or eMMC */
+
+	if (IS_SD(mmc)) {
+		if (host->cd_gpio >= 0) {
+			if (gpio_get_value(host->cd_gpio))
+				*cd = 0;
+		}
+	}
+
+	return 0;
 }
diff --git a/drivers/mmc/tegra2_mmc.h b/drivers/mmc/tegra2_mmc.h
index 28698e0..72f587b 100644
--- a/drivers/mmc/tegra2_mmc.h
+++ b/drivers/mmc/tegra2_mmc.h
@@ -74,9 +74,11 @@ struct mmc_host {
 	unsigned int clock;	/* Current clock (MHz) */
 	unsigned int base;	/* Base address, SDMMC1/2/3/4 */
 	enum periph_id mmc_id;	/* Peripheral ID: PERIPH_ID_... */
+	int pwr_gpio;		/* Power GPIO */
+	int cd_gpio;		/* Change Detect GPIO */
 };
 
-int tegra2_mmc_init(int dev_index, int bus_width);
+int tegra2_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio);
 
 #endif	/* __ASSEMBLY__ */
 #endif	/* __TEGRA2_MMC_H_ */
-- 
1.7.0.4

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

* [U-Boot] [PATCH v3 4/4] tegra2: Add support for Ventana
  2011-10-06 17:53 [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver Stephen Warren
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 2/4] tegra2: Move board_mmc_init into board files Stephen Warren
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 3/4] tegra2: Modify MMC driver to handle power and cd GPIOs Stephen Warren
@ 2011-10-06 17:53 ` Stephen Warren
  2011-10-08  0:03   ` Simon Glass
  2011-10-08  0:03 ` [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver Simon Glass
  3 siblings, 1 reply; 12+ messages in thread
From: Stephen Warren @ 2011-10-06 17:53 UTC (permalink / raw)
  To: u-boot

Ventana is a board which is very similar to Seaboard. Support it by
re-using board/nvidia/seaboard/seaboard.c with minor run-time conditionals.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 board/nvidia/seaboard/seaboard.c |   11 ++++++-
 board/nvidia/ventana/Makefile    |   55 ++++++++++++++++++++++++++++++++++++++
 boards.cfg                       |    1 +
 include/configs/ventana.h        |   55 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 120 insertions(+), 2 deletions(-)
 create mode 100644 board/nvidia/ventana/Makefile
 create mode 100644 include/configs/ventana.h

diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c
index be6ed12..260a56d 100644
--- a/board/nvidia/seaboard/seaboard.c
+++ b/board/nvidia/seaboard/seaboard.c
@@ -31,10 +31,10 @@
 #endif
 
 /*
- * Routine: gpio_config_uart
+ * Routine: gpio_config_uart_seaboard
  * Description: Force GPIO_PI3 low on Seaboard so UART4 works.
  */
-void gpio_config_uart(void)
+void gpio_config_uart_seaboard(void)
 {
 	int gp = GPIO_PI3;
 	struct gpio_ctlr *gpio = (struct gpio_ctlr *)NV_PA_GPIO_BASE;
@@ -55,6 +55,13 @@ void gpio_config_uart(void)
 	writel(val, &bank->gpio_dir_out[GPIO_PORT(gp)]);
 }
 
+void gpio_config_uart(void)
+{
+	if (machine_is_ventana())
+		return;
+	gpio_config_uart_seaboard();
+}
+
 #ifdef CONFIG_TEGRA2_MMC
 /*
  * Routine: pin_mux_mmc
diff --git a/board/nvidia/ventana/Makefile b/board/nvidia/ventana/Makefile
new file mode 100644
index 0000000..029673f
--- /dev/null
+++ b/board/nvidia/ventana/Makefile
@@ -0,0 +1,55 @@
+#
+#  (C) Copyright 2010,2011
+#  NVIDIA Corporation <www.nvidia.com>
+#
+#
+#  See file CREDITS for list of people who contributed to this
+#  project.
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License as
+#  published by the Free Software Foundation; either version 2 of
+#  the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+#  MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
+
+LIB	= $(obj)lib$(BOARD).o
+
+COBJS	+= ../seaboard/seaboard.o
+COBJS	+= ../common/board.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+clean:
+	rm -f $(OBJS)
+
+distclean:	clean
+	rm -f $(LIB) core *.bak $(obj).depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/boards.cfg b/boards.cfg
index e5cb91b..e1ab6f9 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -188,6 +188,7 @@ s5pc210_universal            arm         armv7       universal_c210      samsung
 smdkv310		     arm	 armv7	     smdkv310		 samsung	s5pc2xx
 harmony                      arm         armv7       harmony             nvidia         tegra2
 seaboard                     arm         armv7       seaboard            nvidia         tegra2
+ventana                      arm         armv7       ventana             nvidia         tegra2
 u8500_href                   arm         armv7       u8500               st-ericsson    u8500
 actux1_4_16                  arm         ixp         actux1              -              -           actux1:FLASH2X2
 actux1_8_16                  arm         ixp         actux1              -              -           actux1:FLASH1X8
diff --git a/include/configs/ventana.h b/include/configs/ventana.h
new file mode 100644
index 0000000..afd6ff6
--- /dev/null
+++ b/include/configs/ventana.h
@@ -0,0 +1,55 @@
+/*
+ *  (C) Copyright 2010,2011
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#include <asm/sizes.h>
+#include "tegra2-common.h"
+
+/* High-level configuration options */
+#define TEGRA2_SYSMEM		"mem=384M at 0M nvmem=128M at 384M mem=512M at 512M"
+#define V_PROMPT		"Tegra2 (Ventana) # "
+#define CONFIG_TEGRA2_BOARD_STRING	"NVIDIA Ventana"
+
+/* Board-specific serial config */
+#define CONFIG_SERIAL_MULTI
+#define CONFIG_TEGRA2_ENABLE_UARTD
+#define CONFIG_SYS_NS16550_COM1		NV_PA_APB_UARTD_BASE
+
+#define CONFIG_MACH_TYPE		MACH_TYPE_VENTANA
+#define CONFIG_SYS_BOARD_ODMDATA	0x300d8011 /* lp1, 1GB */
+
+#define CONFIG_BOARD_EARLY_INIT_F
+
+/* SD/MMC */
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_TEGRA2_MMC
+#define CONFIG_CMD_MMC
+
+#define CONFIG_DOS_PARTITION
+#define CONFIG_EFI_PARTITION
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_FAT
+#endif /* __CONFIG_H */
-- 
1.7.0.4

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

* [U-Boot] [PATCH v3 4/4] tegra2: Add support for Ventana
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 4/4] tegra2: Add support for Ventana Stephen Warren
@ 2011-10-08  0:03   ` Simon Glass
  2011-10-10 16:00     ` Stephen Warren
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2011-10-08  0:03 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On Thu, Oct 6, 2011 at 10:53 AM, Stephen Warren <swarren@nvidia.com> wrote:
> Ventana is a board which is very similar to Seaboard. Support it by
> re-using board/nvidia/seaboard/seaboard.c with minor run-time conditionals.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> ?board/nvidia/seaboard/seaboard.c | ? 11 ++++++-
> ?board/nvidia/ventana/Makefile ? ?| ? 55 ++++++++++++++++++++++++++++++++++++++
> ?boards.cfg ? ? ? ? ? ? ? ? ? ? ? | ? ?1 +
> ?include/configs/ventana.h ? ? ? ?| ? 55 ++++++++++++++++++++++++++++++++++++++
> ?4 files changed, 120 insertions(+), 2 deletions(-)
> ?create mode 100644 board/nvidia/ventana/Makefile
> ?create mode 100644 include/configs/ventana.h
>
> diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c
> index be6ed12..260a56d 100644
> --- a/board/nvidia/seaboard/seaboard.c
> +++ b/board/nvidia/seaboard/seaboard.c
> @@ -31,10 +31,10 @@
> ?#endif
>
> ?/*
> - * Routine: gpio_config_uart
> + * Routine: gpio_config_uart_seaboard
> ?* Description: Force GPIO_PI3 low on Seaboard so UART4 works.
> ?*/
> -void gpio_config_uart(void)
> +void gpio_config_uart_seaboard(void)
> ?{
> ? ? ? ?int gp = GPIO_PI3;
> ? ? ? ?struct gpio_ctlr *gpio = (struct gpio_ctlr *)NV_PA_GPIO_BASE;
> @@ -55,6 +55,13 @@ void gpio_config_uart(void)
> ? ? ? ?writel(val, &bank->gpio_dir_out[GPIO_PORT(gp)]);
> ?}
>
> +void gpio_config_uart(void)
> +{
> + ? ? ? if (machine_is_ventana())
> + ? ? ? ? ? ? ? return;
> + ? ? ? gpio_config_uart_seaboard();
> +}

Would it not be better to define a new board file ventana.c, as has
been done with harmony? Is it because you are wanting to share
gpio_config_mmc()? But you have written it out again for Harmony.

Regards,
Simon

> +
> ?#ifdef CONFIG_TEGRA2_MMC
> ?/*
> ?* Routine: pin_mux_mmc
> diff --git a/board/nvidia/ventana/Makefile b/board/nvidia/ventana/Makefile
> new file mode 100644
> index 0000000..029673f
> --- /dev/null
> +++ b/board/nvidia/ventana/Makefile
> @@ -0,0 +1,55 @@
> +#
> +# ?(C) Copyright 2010,2011
> +# ?NVIDIA Corporation <www.nvidia.com>
> +#
> +#
> +# ?See file CREDITS for list of people who contributed to this
> +# ?project.
> +#
> +# ?This program is free software; you can redistribute it and/or
> +# ?modify it under the terms of the GNU General Public License as
> +# ?published by the Free Software Foundation; either version 2 of
> +# ?the License, or (at your option) any later version.
> +#
> +# ?This program is distributed in the hope that it will be useful,
> +# ?but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# ?MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ?See the
> +# ?GNU General Public License for more details.
> +#
> +# ?You should have received a copy of the GNU General Public License
> +# ?along with this program; if not, write to the Free Software
> +# ?Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> +# ?MA 02111-1307 USA
> +#
> +
> +include $(TOPDIR)/config.mk
> +
> +ifneq ($(OBJTREE),$(SRCTREE))
> +$(shell mkdir -p $(obj)../common)
> +endif
> +
> +LIB ? ?= $(obj)lib$(BOARD).o
> +
> +COBJS ?+= ../seaboard/seaboard.o
> +COBJS ?+= ../common/board.o
> +
> +SRCS ? := $(COBJS:.o=.c)
> +OBJS ? := $(addprefix $(obj),$(COBJS))
> +
> +$(LIB): ? ? ? ?$(obj).depend $(OBJS)
> + ? ? ? $(AR) $(ARFLAGS) $@ $(OBJS)
> +
> +clean:
> + ? ? ? rm -f $(OBJS)
> +
> +distclean: ? ? clean
> + ? ? ? rm -f $(LIB) core *.bak $(obj).depend
> +
> +#########################################################################
> +
> +# defines $(obj).depend target
> +include $(SRCTREE)/rules.mk
> +
> +sinclude $(obj).depend
> +
> +#########################################################################
> diff --git a/boards.cfg b/boards.cfg
> index e5cb91b..e1ab6f9 100644
> --- a/boards.cfg
> +++ b/boards.cfg
> @@ -188,6 +188,7 @@ s5pc210_universal ? ? ? ? ? ?arm ? ? ? ? armv7 ? ? ? universal_c210 ? ? ?samsung
> ?smdkv310 ? ? ? ? ? ? ? ? ? ?arm ? ? ? ? armv7 ? ? ? smdkv310 ? ? ? ? ? ?samsung ? ? ? ?s5pc2xx
> ?harmony ? ? ? ? ? ? ? ? ? ? ?arm ? ? ? ? armv7 ? ? ? harmony ? ? ? ? ? ? nvidia ? ? ? ? tegra2
> ?seaboard ? ? ? ? ? ? ? ? ? ? arm ? ? ? ? armv7 ? ? ? seaboard ? ? ? ? ? ?nvidia ? ? ? ? tegra2
> +ventana ? ? ? ? ? ? ? ? ? ? ?arm ? ? ? ? armv7 ? ? ? ventana ? ? ? ? ? ? nvidia ? ? ? ? tegra2
> ?u8500_href ? ? ? ? ? ? ? ? ? arm ? ? ? ? armv7 ? ? ? u8500 ? ? ? ? ? ? ? st-ericsson ? ?u8500
> ?actux1_4_16 ? ? ? ? ? ? ? ? ?arm ? ? ? ? ixp ? ? ? ? actux1 ? ? ? ? ? ? ?- ? ? ? ? ? ? ?- ? ? ? ? ? actux1:FLASH2X2
> ?actux1_8_16 ? ? ? ? ? ? ? ? ?arm ? ? ? ? ixp ? ? ? ? actux1 ? ? ? ? ? ? ?- ? ? ? ? ? ? ?- ? ? ? ? ? actux1:FLASH1X8
> diff --git a/include/configs/ventana.h b/include/configs/ventana.h
> new file mode 100644
> index 0000000..afd6ff6
> --- /dev/null
> +++ b/include/configs/ventana.h
> @@ -0,0 +1,55 @@
> +/*
> + * ?(C) Copyright 2010,2011
> + * ?NVIDIA Corporation <www.nvidia.com>
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ?See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#ifndef __CONFIG_H
> +#define __CONFIG_H
> +
> +#include <asm/sizes.h>
> +#include "tegra2-common.h"
> +
> +/* High-level configuration options */
> +#define TEGRA2_SYSMEM ? ? ? ? ?"mem=384M at 0M nvmem=128M at 384M mem=512M at 512M"
> +#define V_PROMPT ? ? ? ? ? ? ? "Tegra2 (Ventana) # "
> +#define CONFIG_TEGRA2_BOARD_STRING ? ? "NVIDIA Ventana"
> +
> +/* Board-specific serial config */
> +#define CONFIG_SERIAL_MULTI
> +#define CONFIG_TEGRA2_ENABLE_UARTD
> +#define CONFIG_SYS_NS16550_COM1 ? ? ? ? ? ? ? ?NV_PA_APB_UARTD_BASE
> +
> +#define CONFIG_MACH_TYPE ? ? ? ? ? ? ? MACH_TYPE_VENTANA
> +#define CONFIG_SYS_BOARD_ODMDATA ? ? ? 0x300d8011 /* lp1, 1GB */
> +
> +#define CONFIG_BOARD_EARLY_INIT_F
> +
> +/* SD/MMC */
> +#define CONFIG_MMC
> +#define CONFIG_GENERIC_MMC
> +#define CONFIG_TEGRA2_MMC
> +#define CONFIG_CMD_MMC
> +
> +#define CONFIG_DOS_PARTITION
> +#define CONFIG_EFI_PARTITION
> +#define CONFIG_CMD_EXT2
> +#define CONFIG_CMD_FAT
> +#endif /* __CONFIG_H */
> --
> 1.7.0.4
>
>

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

* [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver
  2011-10-06 17:53 [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver Stephen Warren
                   ` (2 preceding siblings ...)
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 4/4] tegra2: Add support for Ventana Stephen Warren
@ 2011-10-08  0:03 ` Simon Glass
  2011-10-11 23:41   ` Simon Glass
  3 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2011-10-08  0:03 UTC (permalink / raw)
  To: u-boot

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>

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

* [U-Boot] [PATCH v3 4/4] tegra2: Add support for Ventana
  2011-10-08  0:03   ` Simon Glass
@ 2011-10-10 16:00     ` Stephen Warren
  2011-10-11 23:48       ` Simon Glass
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Warren @ 2011-10-10 16:00 UTC (permalink / raw)
  To: u-boot

Simon Glass wrote at Friday, October 07, 2011 6:03 PM:
> On Thu, Oct 6, 2011 at 10:53 AM, Stephen Warren <swarren@nvidia.com> wrote:
> > Ventana is a board which is very similar to Seaboard. Support it by
> > re-using board/nvidia/seaboard/seaboard.c with minor run-time conditionals.
...
> > diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c
> > index be6ed12..260a56d 100644
> > --- a/board/nvidia/seaboard/seaboard.c
> > +++ b/board/nvidia/seaboard/seaboard.c
> > @@ -31,10 +31,10 @@
> > ?#endif
> >
> > ?/*
> > - * Routine: gpio_config_uart
> > + * Routine: gpio_config_uart_seaboard
> > ?* Description: Force GPIO_PI3 low on Seaboard so UART4 works.
> > ?*/
> > -void gpio_config_uart(void)
> > +void gpio_config_uart_seaboard(void)
> > ?{
> > ? ? ? ?int gp = GPIO_PI3;
> > ? ? ? ?struct gpio_ctlr *gpio = (struct gpio_ctlr *)NV_PA_GPIO_BASE;
> > @@ -55,6 +55,13 @@ void gpio_config_uart(void)
> > ? ? ? ?writel(val, &bank->gpio_dir_out[GPIO_PORT(gp)]);
> > ?}
> >
> > +void gpio_config_uart(void)
> > +{
> > + ? ? ? if (machine_is_ventana())
> > + ? ? ? ? ? ? ? return;
> > + ? ? ? gpio_config_uart_seaboard();
> > +}
> 
> Would it not be better to define a new board file ventana.c, as has
> been done with harmony? Is it because you are wanting to share
> gpio_config_mmc()? But you have written it out again for Harmony.

Ventana and Seaboard are extremely similar boards; even as more features
are supported, I imagine that a separate seaboard.c and ventana.c would
continue to be mostly identical. The Linux kernel board files support
Ventana within the Seaboard board file (alongside a few other similar
boards) for this reason.

Yes, harmony.c has its own copy of pin_mux_mmc()/board_mmc_init(); that's
because Harmony's MMC configuration is at least partially different to
Seaboard/Ventana's.

-- 
nvpublic

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

* [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver
  2011-10-08  0:03 ` [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver Simon Glass
@ 2011-10-11 23:41   ` Simon Glass
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2011-10-11 23:41 UTC (permalink / raw)
  To: u-boot

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>

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

* [U-Boot] [PATCH v3 2/4] tegra2: Move board_mmc_init into board files
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 2/4] tegra2: Move board_mmc_init into board files Stephen Warren
@ 2011-10-11 23:45   ` Simon Glass
  2011-10-12 14:50     ` Stephen Warren
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2011-10-11 23:45 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On Thu, Oct 6, 2011 at 10:53 AM, Stephen Warren <swarren@nvidia.com> wrote:
> For Seaboard, this is mostly a cut/paste of board_mmc_init() and
> pin_mux_mmc() into seaboard.c; pin_mux_mmc() was modified to add some
> missing pinmux_tristate_disable calls for the GPIOs.
>
> For Harmony, those functions were modified to configure SDMMC2 (index 2)
> instead of SDMMC3 (index 1), since that's what is present on the board.
>
> However, harmony.c is still missing the required GPIO setup, so neither
> port is likely to function correctly yet. ?This will be fixed in the next
> change.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

I get a warning - I think you need to include ../common/board.h in
seaboard/harmony.c

seaboard.c:100:2: warning: implicit declaration of function
'tegra2_mmc_init' [-Wimplicit-function-declaration]

Other than that I tested it and it works fine.

Regards,
Simon

> ---
> ?board/nvidia/common/board.c ? ? ?| ? 52 -----------------------------------
> ?board/nvidia/harmony/harmony.c ? | ? 55 ++++++++++++++++++++++++++++++++++++++
> ?board/nvidia/seaboard/seaboard.c | ? 52 +++++++++++++++++++++++++++++++++++
> ?3 files changed, 107 insertions(+), 52 deletions(-)
>
> diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
> index 370a259..0f12de2 100644
> --- a/board/nvidia/common/board.c
> +++ b/board/nvidia/common/board.c
> @@ -33,10 +33,6 @@
> ?#include <asm/arch/uart.h>
> ?#include "board.h"
>
> -#ifdef CONFIG_TEGRA2_MMC
> -#include <mmc.h>
> -#endif
> -
> ?DECLARE_GLOBAL_DATA_PTR;
>
> ?const struct tegra2_sysinfo sysinfo = {
> @@ -100,33 +96,6 @@ static void pin_mux_uart(void)
> ?#endif /* CONFIG_TEGRA2_ENABLE_UARTD */
> ?}
>
> -#ifdef CONFIG_TEGRA2_MMC
> -/*
> - * Routine: pin_mux_mmc
> - * Description: setup the pin muxes/tristate values for the SDMMC(s)
> - */
> -static void pin_mux_mmc(void)
> -{
> - ? ? ? /* SDMMC4: config 3, x8 on 2nd set of pins */
> - ? ? ? pinmux_set_func(PINGRP_ATB, PMUX_FUNC_SDIO4);
> - ? ? ? pinmux_set_func(PINGRP_GMA, PMUX_FUNC_SDIO4);
> - ? ? ? pinmux_set_func(PINGRP_GME, PMUX_FUNC_SDIO4);
> -
> - ? ? ? pinmux_tristate_disable(PINGRP_ATB);
> - ? ? ? pinmux_tristate_disable(PINGRP_GMA);
> - ? ? ? pinmux_tristate_disable(PINGRP_GME);
> -
> - ? ? ? /* SDMMC3: SDIO3_CLK, SDIO3_CMD, SDIO3_DAT[3:0] */
> - ? ? ? pinmux_set_func(PINGRP_SDB, PMUX_FUNC_SDIO3);
> - ? ? ? pinmux_set_func(PINGRP_SDC, PMUX_FUNC_SDIO3);
> - ? ? ? pinmux_set_func(PINGRP_SDD, PMUX_FUNC_SDIO3);
> -
> - ? ? ? pinmux_tristate_disable(PINGRP_SDC);
> - ? ? ? pinmux_tristate_disable(PINGRP_SDD);
> - ? ? ? pinmux_tristate_disable(PINGRP_SDB);
> -}
> -#endif
> -
> ?/*
> ?* Routine: board_init
> ?* Description: Early hardware init.
> @@ -142,27 +111,6 @@ int board_init(void)
> ? ? ? ?return 0;
> ?}
>
> -#ifdef CONFIG_TEGRA2_MMC
> -/* this is a weak define that we are overriding */
> -int board_mmc_init(bd_t *bd)
> -{
> - ? ? ? debug("board_mmc_init called\n");
> - ? ? ? /* Enable muxes, etc. for SDMMC controllers */
> - ? ? ? pin_mux_mmc();
> - ? ? ? gpio_config_mmc();
> -
> - ? ? ? debug("board_mmc_init: init eMMC\n");
> - ? ? ? /* init dev 0, eMMC chip, with 4-bit bus */
> - ? ? ? tegra2_mmc_init(0, 4);
> -
> - ? ? ? debug("board_mmc_init: init SD slot\n");
> - ? ? ? /* init dev 1, SD slot, with 4-bit bus */
> - ? ? ? tegra2_mmc_init(1, 4);
> -
> - ? ? ? return 0;
> -}
> -#endif
> -
> ?#ifdef CONFIG_BOARD_EARLY_INIT_F
> ?int board_early_init_f(void)
> ?{
> diff --git a/board/nvidia/harmony/harmony.c b/board/nvidia/harmony/harmony.c
> index cbb30d6..b01302f 100644
> --- a/board/nvidia/harmony/harmony.c
> +++ b/board/nvidia/harmony/harmony.c
> @@ -24,6 +24,7 @@
> ?#include <common.h>
> ?#include <asm/io.h>
> ?#include <asm/arch/tegra2.h>
> +#include <asm/arch/pinmux.h>
> ?#ifdef CONFIG_TEGRA2_MMC
> ?#include <mmc.h>
> ?#endif
> @@ -38,6 +39,39 @@ void gpio_config_uart(void)
>
> ?#ifdef CONFIG_TEGRA2_MMC
> ?/*
> + * Routine: pin_mux_mmc
> + * Description: setup the pin muxes/tristate values for the SDMMC(s)
> + */
> +static void pin_mux_mmc(void)
> +{
> + ? ? ? /* SDMMC4: config 3, x8 on 2nd set of pins */
> + ? ? ? pinmux_set_func(PINGRP_ATB, PMUX_FUNC_SDIO4);
> + ? ? ? pinmux_set_func(PINGRP_GMA, PMUX_FUNC_SDIO4);
> + ? ? ? pinmux_set_func(PINGRP_GME, PMUX_FUNC_SDIO4);
> +
> + ? ? ? pinmux_tristate_disable(PINGRP_ATB);
> + ? ? ? pinmux_tristate_disable(PINGRP_GMA);
> + ? ? ? pinmux_tristate_disable(PINGRP_GME);
> +
> + ? ? ? /* For power GPIO PI6 */
> + ? ? ? pinmux_tristate_disable(PINGRP_ATA);
> + ? ? ? /* For CD GPIO PH2 */
> + ? ? ? pinmux_tristate_disable(PINGRP_ATD);
> +
> + ? ? ? /* SDMMC2: SDIO2_CLK, SDIO2_CMD, SDIO2_DAT[7:0] */
> + ? ? ? pinmux_set_func(PINGRP_DTA, PMUX_FUNC_SDIO2);
> + ? ? ? pinmux_set_func(PINGRP_DTD, PMUX_FUNC_SDIO2);
> +
> + ? ? ? pinmux_tristate_disable(PINGRP_DTA);
> + ? ? ? pinmux_tristate_disable(PINGRP_DTD);
> +
> + ? ? ? /* For power GPIO PT3 */
> + ? ? ? pinmux_tristate_disable(PINGRP_DTB);
> + ? ? ? /* For CD GPIO PI5 */
> + ? ? ? pinmux_tristate_disable(PINGRP_ATC);
> +}
> +
> +/*
> ?* Routine: gpio_config_mmc
> ?* Description: Set GPIOs for SD card
> ?*/
> @@ -47,6 +81,27 @@ void gpio_config_mmc(void)
> ?}
>
> ?/* this is a weak define that we are overriding */
> +int board_mmc_init(bd_t *bd)
> +{
> + ? ? ? debug("board_mmc_init called\n");
> +
> + ? ? ? /* Enable muxes, etc. for SDMMC controllers */
> + ? ? ? pin_mux_mmc();
> + ? ? ? gpio_config_mmc();
> +
> + ? ? ? debug("board_mmc_init: init SD slot J26\n");
> + ? ? ? /* init dev 0, SD slot J26, with 4-bit bus */
> + ? ? ? /* The board has an 8-bit bus, but 8-bit doesn't work yet */
> + ? ? ? tegra2_mmc_init(0, 4);
> +
> + ? ? ? debug("board_mmc_init: init SD slot J5\n");
> + ? ? ? /* init dev 2, SD slot J5, with 4-bit bus */
> + ? ? ? tegra2_mmc_init(2, 4);
> +
> + ? ? ? return 0;
> +}
> +
> +/* this is a weak define that we are overriding */
> ?int board_mmc_getcd(u8 *cd, struct mmc *mmc)
> ?{
> ? ? ? ?debug("board_mmc_getcd called\n");
> diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c
> index bc67d0f..f8ef865 100644
> --- a/board/nvidia/seaboard/seaboard.c
> +++ b/board/nvidia/seaboard/seaboard.c
> @@ -24,6 +24,7 @@
> ?#include <common.h>
> ?#include <asm/io.h>
> ?#include <asm/arch/tegra2.h>
> +#include <asm/arch/pinmux.h>
> ?#include <asm/gpio.h>
> ?#ifdef CONFIG_TEGRA2_MMC
> ?#include <mmc.h>
> @@ -56,6 +57,36 @@ void gpio_config_uart(void)
>
> ?#ifdef CONFIG_TEGRA2_MMC
> ?/*
> + * Routine: pin_mux_mmc
> + * Description: setup the pin muxes/tristate values for the SDMMC(s)
> + */
> +static void pin_mux_mmc(void)
> +{
> + ? ? ? /* SDMMC4: config 3, x8 on 2nd set of pins */
> + ? ? ? pinmux_set_func(PINGRP_ATB, PMUX_FUNC_SDIO4);
> + ? ? ? pinmux_set_func(PINGRP_GMA, PMUX_FUNC_SDIO4);
> + ? ? ? pinmux_set_func(PINGRP_GME, PMUX_FUNC_SDIO4);
> +
> + ? ? ? pinmux_tristate_disable(PINGRP_ATB);
> + ? ? ? pinmux_tristate_disable(PINGRP_GMA);
> + ? ? ? pinmux_tristate_disable(PINGRP_GME);
> +
> + ? ? ? /* SDMMC3: SDIO3_CLK, SDIO3_CMD, SDIO3_DAT[3:0] */
> + ? ? ? pinmux_set_func(PINGRP_SDB, PMUX_FUNC_SDIO3);
> + ? ? ? pinmux_set_func(PINGRP_SDC, PMUX_FUNC_SDIO3);
> + ? ? ? pinmux_set_func(PINGRP_SDD, PMUX_FUNC_SDIO3);
> +
> + ? ? ? pinmux_tristate_disable(PINGRP_SDC);
> + ? ? ? pinmux_tristate_disable(PINGRP_SDD);
> + ? ? ? pinmux_tristate_disable(PINGRP_SDB);
> +
> + ? ? ? /* For power GPIO PI6 */
> + ? ? ? pinmux_tristate_disable(PINGRP_ATA);
> + ? ? ? /* For CD GPIO PI5 */
> + ? ? ? pinmux_tristate_disable(PINGRP_ATC);
> +}
> +
> +/*
> ?* Routine: gpio_config_mmc
> ?* Description: Set GPIOs for SDMMC3 SDIO slot.
> ?*/
> @@ -69,6 +100,27 @@ void gpio_config_mmc(void)
> ?}
>
> ?/* this is a weak define that we are overriding */
> +int board_mmc_init(bd_t *bd)
> +{
> + ? ? ? debug("board_mmc_init called\n");
> +
> + ? ? ? /* Enable muxes, etc. for SDMMC controllers */
> + ? ? ? pin_mux_mmc();
> + ? ? ? gpio_config_mmc();
> +
> + ? ? ? debug("board_mmc_init: init eMMC\n");
> + ? ? ? /* init dev 0, eMMC chip, with 4-bit bus */
> + ? ? ? /* The board has an 8-bit bus, but 8-bit doesn't work yet */
> + ? ? ? tegra2_mmc_init(0, 4);
> +
> + ? ? ? debug("board_mmc_init: init SD slot\n");
> + ? ? ? /* init dev 1, SD slot, with 4-bit bus */
> + ? ? ? tegra2_mmc_init(1, 4);
> +
> + ? ? ? return 0;
> +}
> +
> +/* this is a weak define that we are overriding */
> ?int board_mmc_getcd(u8 *cd, struct mmc *mmc)
> ?{
> ? ? ? ?debug("board_mmc_getcd called\n");
> --
> 1.7.0.4
>
>

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

* [U-Boot] [PATCH v3 3/4] tegra2: Modify MMC driver to handle power and cd GPIOs
  2011-10-06 17:53 ` [U-Boot] [PATCH v3 3/4] tegra2: Modify MMC driver to handle power and cd GPIOs Stephen Warren
@ 2011-10-11 23:46   ` Simon Glass
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2011-10-11 23:46 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On Thu, Oct 6, 2011 at 10:53 AM, Stephen Warren <swarren@nvidia.com> wrote:
> Pass the GPIO numbers for power and card detect to tegra2_mmc_init(), and
> modify that function to perform all required GPIO initialization. This
> removes the need for board files to perform these operations.
>
> Move board_mmc_getcd() into tegra2_mmc.c now that the driver knows which
> GPIOs to use.
>
> Update affected call-sites in seaboard.c and harmony.c. Note that this
> change should make all SD ports work on Harmony, since the required GPIO
> setup is now being performed.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---

This has the same warning as the patch 3 - can you please fix and resubmit?

Regards,
Simon

> ?board/nvidia/harmony/harmony.c ? | ? 27 ++---------------------
> ?board/nvidia/seaboard/seaboard.c | ? 33 +----------------------------
> ?drivers/mmc/tegra2_mmc.c ? ? ? ? | ? 42 ++++++++++++++++++++++++++++++++-----
> ?drivers/mmc/tegra2_mmc.h ? ? ? ? | ? ?4 ++-
> ?4 files changed, 44 insertions(+), 62 deletions(-)
>
> diff --git a/board/nvidia/harmony/harmony.c b/board/nvidia/harmony/harmony.c
> index b01302f..923942c 100644
> --- a/board/nvidia/harmony/harmony.c
> +++ b/board/nvidia/harmony/harmony.c
> @@ -25,6 +25,7 @@
> ?#include <asm/io.h>
> ?#include <asm/arch/tegra2.h>
> ?#include <asm/arch/pinmux.h>
> +#include <asm/gpio.h>
> ?#ifdef CONFIG_TEGRA2_MMC
> ?#include <mmc.h>
> ?#endif
> @@ -71,15 +72,6 @@ static void pin_mux_mmc(void)
> ? ? ? ?pinmux_tristate_disable(PINGRP_ATC);
> ?}
>
> -/*
> - * Routine: gpio_config_mmc
> - * Description: Set GPIOs for SD card
> - */
> -void gpio_config_mmc(void)
> -{
> - ? ? ? /* Not implemented for now */
> -}
> -
> ?/* this is a weak define that we are overriding */
> ?int board_mmc_init(bd_t *bd)
> ?{
> @@ -87,29 +79,16 @@ int board_mmc_init(bd_t *bd)
>
> ? ? ? ?/* Enable muxes, etc. for SDMMC controllers */
> ? ? ? ?pin_mux_mmc();
> - ? ? ? gpio_config_mmc();
>
> ? ? ? ?debug("board_mmc_init: init SD slot J26\n");
> ? ? ? ?/* init dev 0, SD slot J26, with 4-bit bus */
> ? ? ? ?/* The board has an 8-bit bus, but 8-bit doesn't work yet */
> - ? ? ? tegra2_mmc_init(0, 4);
> + ? ? ? tegra2_mmc_init(0, 4, GPIO_PI6, GPIO_PH2);
>
> ? ? ? ?debug("board_mmc_init: init SD slot J5\n");
> ? ? ? ?/* init dev 2, SD slot J5, with 4-bit bus */
> - ? ? ? tegra2_mmc_init(2, 4);
> + ? ? ? tegra2_mmc_init(2, 4, GPIO_PT3, GPIO_PI5);
>
> ? ? ? ?return 0;
> ?}
> -
> -/* this is a weak define that we are overriding */
> -int board_mmc_getcd(u8 *cd, struct mmc *mmc)
> -{
> - ? ? ? debug("board_mmc_getcd called\n");
> - ? ? ? /*
> - ? ? ? ?* Hard-code CD presence for now. Need to add GPIO inputs
> - ? ? ? ?* for Harmony
> - ? ? ? ?*/
> - ? ? ? *cd = 1;
> - ? ? ? return 0;
> -}
> ?#endif
> diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c
> index f8ef865..be6ed12 100644
> --- a/board/nvidia/seaboard/seaboard.c
> +++ b/board/nvidia/seaboard/seaboard.c
> @@ -86,19 +86,6 @@ static void pin_mux_mmc(void)
> ? ? ? ?pinmux_tristate_disable(PINGRP_ATC);
> ?}
>
> -/*
> - * Routine: gpio_config_mmc
> - * Description: Set GPIOs for SDMMC3 SDIO slot.
> - */
> -void gpio_config_mmc(void)
> -{
> - ? ? ? /* Set EN_VDDIO_SD (GPIO I6) */
> - ? ? ? gpio_direction_output(GPIO_PI6, 1);
> -
> - ? ? ? /* Config pin as GPI for Card Detect (GPIO I5) */
> - ? ? ? gpio_direction_input(GPIO_PI5);
> -}
> -
> ?/* this is a weak define that we are overriding */
> ?int board_mmc_init(bd_t *bd)
> ?{
> @@ -106,31 +93,15 @@ int board_mmc_init(bd_t *bd)
>
> ? ? ? ?/* Enable muxes, etc. for SDMMC controllers */
> ? ? ? ?pin_mux_mmc();
> - ? ? ? gpio_config_mmc();
>
> ? ? ? ?debug("board_mmc_init: init eMMC\n");
> ? ? ? ?/* init dev 0, eMMC chip, with 4-bit bus */
> ? ? ? ?/* The board has an 8-bit bus, but 8-bit doesn't work yet */
> - ? ? ? tegra2_mmc_init(0, 4);
> + ? ? ? tegra2_mmc_init(0, 4, -1, -1);
>
> ? ? ? ?debug("board_mmc_init: init SD slot\n");
> ? ? ? ?/* init dev 1, SD slot, with 4-bit bus */
> - ? ? ? tegra2_mmc_init(1, 4);
> -
> - ? ? ? return 0;
> -}
> -
> -/* this is a weak define that we are overriding */
> -int board_mmc_getcd(u8 *cd, struct mmc *mmc)
> -{
> - ? ? ? debug("board_mmc_getcd called\n");
> - ? ? ? *cd = 1; ? ? ? ? ? ? ? ? ? ? ? ?/* Assume card is inserted, or eMMC */
> -
> - ? ? ? if (IS_SD(mmc)) {
> - ? ? ? ? ? ? ? /* Seaboard SDMMC3 = SDIO3_CD = GPIO_PI5 */
> - ? ? ? ? ? ? ? if (gpio_get_value(GPIO_PI5))
> - ? ? ? ? ? ? ? ? ? ? ? *cd = 0;
> - ? ? ? }
> + ? ? ? tegra2_mmc_init(1, 4, GPIO_PI6, GPIO_PI5);
>
> ? ? ? ?return 0;
> ?}
> diff --git a/drivers/mmc/tegra2_mmc.c b/drivers/mmc/tegra2_mmc.c
> index 78b1190..3de9c5d 100644
> --- a/drivers/mmc/tegra2_mmc.c
> +++ b/drivers/mmc/tegra2_mmc.c
> @@ -21,6 +21,7 @@
>
> ?#include <common.h>
> ?#include <mmc.h>
> +#include <asm/gpio.h>
> ?#include <asm/io.h>
> ?#include <asm/arch/clk_rst.h>
> ?#include <asm/arch/clock.h>
> @@ -433,20 +434,37 @@ static int mmc_core_init(struct mmc *mmc)
> ? ? ? ?return 0;
> ?}
>
> -static int tegra2_mmc_initialize(int dev_index, int bus_width)
> +int tegra2_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio)
> ?{
> ? ? ? ?struct mmc_host *host;
> + ? ? ? char gpusage[12]; /* "SD/MMCn PWR" or "SD/MMCn CD" */
> ? ? ? ?struct mmc *mmc;
>
> - ? ? ? debug(" mmc_initialize called\n");
> + ? ? ? debug(" tegra2_mmc_init: index %d, bus width %d "
> + ? ? ? ? ? ? ? "pwr_gpio %d cd_gpio %d\n",
> + ? ? ? ? ? ? ? dev_index, bus_width, pwr_gpio, cd_gpio);
>
> ? ? ? ?host = &mmc_host[dev_index];
>
> ? ? ? ?host->clock = 0;
> + ? ? ? host->pwr_gpio = pwr_gpio;
> + ? ? ? host->cd_gpio = cd_gpio;
> ? ? ? ?tegra2_get_setup(host, dev_index);
>
> ? ? ? ?clock_start_periph_pll(host->mmc_id, CLOCK_ID_PERIPH, 20000000);
>
> + ? ? ? if (host->pwr_gpio >= 0) {
> + ? ? ? ? ? ? ? sprintf(gpusage, "SD/MMC%d PWR", dev_index);
> + ? ? ? ? ? ? ? gpio_request(host->pwr_gpio, gpusage);
> + ? ? ? ? ? ? ? gpio_direction_output(host->pwr_gpio, 1);
> + ? ? ? }
> +
> + ? ? ? if (host->cd_gpio >= 0) {
> + ? ? ? ? ? ? ? sprintf(gpusage, "SD/MMC%d CD", dev_index);
> + ? ? ? ? ? ? ? gpio_request(host->cd_gpio, gpusage);
> + ? ? ? ? ? ? ? gpio_direction_input(host->cd_gpio);
> + ? ? ? }
> +
> ? ? ? ?mmc = &mmc_dev[dev_index];
>
> ? ? ? ?sprintf(mmc->name, "Tegra2 SD/MMC");
> @@ -478,9 +496,21 @@ static int tegra2_mmc_initialize(int dev_index, int bus_width)
> ? ? ? ?return 0;
> ?}
>
> -int tegra2_mmc_init(int dev_index, int bus_width)
> +/* this is a weak define that we are overriding */
> +int board_mmc_getcd(u8 *cd, struct mmc *mmc)
> ?{
> - ? ? ? debug(" tegra2_mmc_init: index %d, bus width %d\n",
> - ? ? ? ? ? ? ? dev_index, bus_width);
> - ? ? ? return tegra2_mmc_initialize(dev_index, bus_width);
> + ? ? ? struct mmc_host *host = (struct mmc_host *)mmc->priv;
> +
> + ? ? ? debug("board_mmc_getcd called\n");
> +
> + ? ? ? *cd = 1; /* Assume card is inserted, or eMMC */
> +
> + ? ? ? if (IS_SD(mmc)) {
> + ? ? ? ? ? ? ? if (host->cd_gpio >= 0) {
> + ? ? ? ? ? ? ? ? ? ? ? if (gpio_get_value(host->cd_gpio))
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *cd = 0;
> + ? ? ? ? ? ? ? }
> + ? ? ? }
> +
> + ? ? ? return 0;
> ?}
> diff --git a/drivers/mmc/tegra2_mmc.h b/drivers/mmc/tegra2_mmc.h
> index 28698e0..72f587b 100644
> --- a/drivers/mmc/tegra2_mmc.h
> +++ b/drivers/mmc/tegra2_mmc.h
> @@ -74,9 +74,11 @@ struct mmc_host {
> ? ? ? ?unsigned int clock; ? ? /* Current clock (MHz) */
> ? ? ? ?unsigned int base; ? ? ?/* Base address, SDMMC1/2/3/4 */
> ? ? ? ?enum periph_id mmc_id; ?/* Peripheral ID: PERIPH_ID_... */
> + ? ? ? int pwr_gpio; ? ? ? ? ? /* Power GPIO */
> + ? ? ? int cd_gpio; ? ? ? ? ? ?/* Change Detect GPIO */
> ?};
>
> -int tegra2_mmc_init(int dev_index, int bus_width);
> +int tegra2_mmc_init(int dev_index, int bus_width, int pwr_gpio, int cd_gpio);
>
> ?#endif /* __ASSEMBLY__ */
> ?#endif /* __TEGRA2_MMC_H_ */
> --
> 1.7.0.4
>
>

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

* [U-Boot] [PATCH v3 4/4] tegra2: Add support for Ventana
  2011-10-10 16:00     ` Stephen Warren
@ 2011-10-11 23:48       ` Simon Glass
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2011-10-11 23:48 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On Mon, Oct 10, 2011 at 9:00 AM, Stephen Warren <swarren@nvidia.com> wrote:
> Simon Glass wrote at Friday, October 07, 2011 6:03 PM:
>> On Thu, Oct 6, 2011 at 10:53 AM, Stephen Warren <swarren@nvidia.com> wrote:
>> > Ventana is a board which is very similar to Seaboard. Support it by
>> > re-using board/nvidia/seaboard/seaboard.c with minor run-time conditionals.
> ...
>> > diff --git a/board/nvidia/seaboard/seaboard.c b/board/nvidia/seaboard/seaboard.c
>> > index be6ed12..260a56d 100644
>> > --- a/board/nvidia/seaboard/seaboard.c
>> > +++ b/board/nvidia/seaboard/seaboard.c
>> > @@ -31,10 +31,10 @@
>> > ?#endif
>> >
>> > ?/*
>> > - * Routine: gpio_config_uart
>> > + * Routine: gpio_config_uart_seaboard
>> > ?* Description: Force GPIO_PI3 low on Seaboard so UART4 works.
>> > ?*/
>> > -void gpio_config_uart(void)
>> > +void gpio_config_uart_seaboard(void)
>> > ?{
>> > ? ? ? ?int gp = GPIO_PI3;
>> > ? ? ? ?struct gpio_ctlr *gpio = (struct gpio_ctlr *)NV_PA_GPIO_BASE;
>> > @@ -55,6 +55,13 @@ void gpio_config_uart(void)
>> > ? ? ? ?writel(val, &bank->gpio_dir_out[GPIO_PORT(gp)]);
>> > ?}
>> >
>> > +void gpio_config_uart(void)
>> > +{
>> > + ? ? ? if (machine_is_ventana())
>> > + ? ? ? ? ? ? ? return;
>> > + ? ? ? gpio_config_uart_seaboard();
>> > +}
>>
>> Would it not be better to define a new board file ventana.c, as has
>> been done with harmony? Is it because you are wanting to share
>> gpio_config_mmc()? But you have written it out again for Harmony.
>
> Ventana and Seaboard are extremely similar boards; even as more features
> are supported, I imagine that a separate seaboard.c and ventana.c would
> continue to be mostly identical. The Linux kernel board files support
> Ventana within the Seaboard board file (alongside a few other similar
> boards) for this reason.
>
> Yes, harmony.c has its own copy of pin_mux_mmc()/board_mmc_init(); that's
> because Harmony's MMC configuration is at least partially different to
> Seaboard/Ventana's.

OK, that sounds reasonable. We certainly want to avoid lots of duplicated code.

Regards,
Simon

>
> --
> nvpublic
>
>

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

* [U-Boot] [PATCH v3 2/4] tegra2: Move board_mmc_init into board files
  2011-10-11 23:45   ` Simon Glass
@ 2011-10-12 14:50     ` Stephen Warren
  0 siblings, 0 replies; 12+ messages in thread
From: Stephen Warren @ 2011-10-12 14:50 UTC (permalink / raw)
  To: u-boot

Simon Glass wrote at Tuesday, October 11, 2011 5:46 PM:
> Hi Stephen,
> 
> On Thu, Oct 6, 2011 at 10:53 AM, Stephen Warren <swarren@nvidia.com> wrote:
> > For Seaboard, this is mostly a cut/paste of board_mmc_init() and
> > pin_mux_mmc() into seaboard.c; pin_mux_mmc() was modified to add some
> > missing pinmux_tristate_disable calls for the GPIOs.
> >
> > For Harmony, those functions were modified to configure SDMMC2 (index 2)
> > instead of SDMMC3 (index 1), since that's what is present on the board.
> >
> > However, harmony.c is still missing the required GPIO setup, so neither
> > port is likely to function correctly yet. ?This will be fixed in the next
> > change.
> >
> > Signed-off-by: Stephen Warren <swarren@nvidia.com>
> 
> I get a warning - I think you need to include ../common/board.h in
> seaboard/harmony.c
> 
> seaboard.c:100:2: warning: implicit declaration of function
> 'tegra2_mmc_init' [-Wimplicit-function-declaration]
> 
> Other than that I tested it and it works fine.

Yes, I'd already fixed this locally for v4, but hadn't reposted yet
pending your comments; will do soon.

Thanks for testing.

-- 
nvpublic

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

end of thread, other threads:[~2011-10-12 14:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-06 17:53 [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver Stephen Warren
2011-10-06 17:53 ` [U-Boot] [PATCH v3 2/4] tegra2: Move board_mmc_init into board files Stephen Warren
2011-10-11 23:45   ` Simon Glass
2011-10-12 14:50     ` Stephen Warren
2011-10-06 17:53 ` [U-Boot] [PATCH v3 3/4] tegra2: Modify MMC driver to handle power and cd GPIOs Stephen Warren
2011-10-11 23:46   ` Simon Glass
2011-10-06 17:53 ` [U-Boot] [PATCH v3 4/4] tegra2: Add support for Ventana Stephen Warren
2011-10-08  0:03   ` Simon Glass
2011-10-10 16:00     ` Stephen Warren
2011-10-11 23:48       ` Simon Glass
2011-10-08  0:03 ` [U-Boot] [PATCH v3 1/4] tegra2: Move MMC clock initialization into MMC driver Simon Glass
2011-10-11 23:41   ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.