[U-Boot] [PATCH] mmc: access mxcmmc from mx31 boards

Helmut Raiger helmut.raiger at hale.at
Mon Oct 24 18:45:45 CEST 2011


This patch modifies mxcmmc.c to be used
not only by i.MX27 but also by i.MX31 boards.
Both use the same SD controller, but have different
clock set-ups.
The clock access was renamed to imx_get_mmcclk() to
allow both architectures to provide their respective
clock. Pins, base address and prototypes for board_init_mmc()
are provided.

Signed-off-by: Helmut Raiger <helmut.raiger at hale.at>
---
 arch/arm/cpu/arm1136/mx31/generic.c        |    5 +++++
 arch/arm/include/asm/arch-mx27/clock.h     |    1 +
 arch/arm/include/asm/arch-mx31/clock.h     |    1 +
 arch/arm/include/asm/arch-mx31/imx-regs.h  |   11 +++++++++++
 arch/arm/include/asm/arch-mx31/sys_proto.h |    3 ++-
 drivers/mmc/mxcmmc.c                       |    8 +++-----
 6 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/arm1136/mx31/generic.c b/arch/arm/cpu/arm1136/mx31/generic.c
index 7ab5631..3008099 100644
--- a/arch/arm/cpu/arm1136/mx31/generic.c
+++ b/arch/arm/cpu/arm1136/mx31/generic.c
@@ -99,6 +99,11 @@ u32 imx_get_uartclk(void)
 	return mxc_get_clock(MXC_UART_CLK);
 }
 
+u32 imx_get_mmcclk(void)
+{
+	return mxc_get_clock(MXC_IPG_PERCLK);
+}
+
 void mx31_gpio_mux(unsigned long mode)
 {
 	unsigned long reg, shift, tmp;
diff --git a/arch/arm/include/asm/arch-mx27/clock.h b/arch/arm/include/asm/arch-mx27/clock.h
index 7e9c7aa..2c078d5 100644
--- a/arch/arm/include/asm/arch-mx27/clock.h
+++ b/arch/arm/include/asm/arch-mx27/clock.h
@@ -38,5 +38,6 @@ ulong imx_get_ahbclk(void);
 
 #define imx_get_uartclk imx_get_perclk1
 #define imx_get_fecclk imx_get_ahbclk
+#define imx_get_mmcclk imx_get_perclk2
 
 #endif /* __ASM_ARCH_CLOCK_H */
diff --git a/arch/arm/include/asm/arch-mx31/clock.h b/arch/arm/include/asm/arch-mx31/clock.h
index 0270d96..c420d63 100644
--- a/arch/arm/include/asm/arch-mx31/clock.h
+++ b/arch/arm/include/asm/arch-mx31/clock.h
@@ -34,6 +34,7 @@ enum mxc_clock {
 
 unsigned int mxc_get_clock(enum mxc_clock clk);
 extern u32 imx_get_uartclk(void);
+extern u32 imx_get_mmcclk(void);
 extern void mx31_gpio_mux(unsigned long mode);
 extern void mx31_set_pad(enum iomux_pins pin, u32 config);
 
diff --git a/arch/arm/include/asm/arch-mx31/imx-regs.h b/arch/arm/include/asm/arch-mx31/imx-regs.h
index f7a39f1..448a2c8 100644
--- a/arch/arm/include/asm/arch-mx31/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx31/imx-regs.h
@@ -646,6 +646,13 @@ struct esdc_regs {
 #define MUX_CTL_CSPI3_SPI_RDY	0x0e
 #define MUX_CTL_CSPI3_MOSI		0x13
 
+#define MUX_CTL_SD1_DATA1	0x18
+#define MUX_CTL_SD1_DATA2	0x19
+#define MUX_CTL_SD1_DATA3	0x1a
+#define MUX_CTL_SD1_CMD		0x1d
+#define MUX_CTL_SD1_CLK		0x1e
+#define MUX_CTL_SD1_DATA0	0x1f
+
 #define MUX_CTL_USBH2_DATA1	0x40
 #define MUX_CTL_USBH2_DIR	0x44
 #define MUX_CTL_USBH2_STP	0x45
@@ -792,6 +799,10 @@ struct esdc_regs {
  */
 #define NFC_BASE_ADDR	0xB8000000
 
+/* SD card controller */
+#define SDHC1_BASE_ADDR	0x50004000
+#define SDHC2_BASE_ADDR	0x50008000
+
 /*
  * Internal RAM (16KB)
  */
diff --git a/arch/arm/include/asm/arch-mx31/sys_proto.h b/arch/arm/include/asm/arch-mx31/sys_proto.h
index 7600303..bdce074 100644
--- a/arch/arm/include/asm/arch-mx31/sys_proto.h
+++ b/arch/arm/include/asm/arch-mx31/sys_proto.h
@@ -31,5 +31,6 @@ struct mxc_weimcs {
 };
 
 void mxc_setup_weimcs(int cs, const struct mxc_weimcs *weimcs);
-
+/* for mx27 in mxcmmc.h, but another file for a single prototype ? */
+int mxc_mmc_init(bd_t *bis);
 #endif
diff --git a/drivers/mmc/mxcmmc.c b/drivers/mmc/mxcmmc.c
index ab1fc82..fbceb46 100644
--- a/drivers/mmc/mxcmmc.c
+++ b/drivers/mmc/mxcmmc.c
@@ -25,9 +25,7 @@
 #include <mmc.h>
 #include <asm/errno.h>
 #include <asm/io.h>
-#ifdef CONFIG_MX27
 #include <asm/arch/clock.h>
-#endif
 
 #define DRIVER_NAME "mxc-mmc"
 
@@ -422,7 +420,7 @@ static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios)
 {
 	unsigned int divider;
 	int prescaler = 0;
-	unsigned long clk_in = imx_get_perclk2();
+	unsigned long clk_in = imx_get_mmcclk();
 
 	while (prescaler <= 0x800) {
 		for (divider = 1; divider <= 0xF; divider++) {
@@ -508,8 +506,8 @@ static int mxcmci_initialize(bd_t *bis)
 
 	mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
 
-	mmc->f_min = imx_get_perclk2() >> 7;
-	mmc->f_max = imx_get_perclk2() >> 1;
+	mmc->f_min = imx_get_mmcclk() >> 7;
+	mmc->f_max = imx_get_mmcclk() >> 1;
 
 	mmc->b_max = 0;
 
-- 
1.7.4.4



--
Scanned by MailScanner.



More information about the U-Boot mailing list