u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mmc: access mxcmmc from mx31 boards
@ 2011-10-24 16:45 Helmut Raiger
  2011-10-25  9:43 ` Stefano Babic
  0 siblings, 1 reply; 27+ messages in thread
From: Helmut Raiger @ 2011-10-24 16:45 UTC (permalink / raw)
  To: u-boot

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@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.

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

end of thread, other threads:[~2012-01-30 14:38 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-24 16:45 [U-Boot] [PATCH] mmc: access mxcmmc from mx31 boards Helmut Raiger
2011-10-25  9:43 ` Stefano Babic
2011-10-27 12:19   ` [U-Boot] [PATCH V2] " Helmut Raiger
2011-11-02  7:02     ` [U-Boot] [PATCH V2] imx: " Helmut Raiger
2011-11-07  7:59       ` Helmut Raiger
2011-11-07  9:04         ` Stefano Babic
2011-11-14  9:06           ` Helmut Raiger
2011-11-14 10:55             ` Stefano Babic
2011-11-14 15:37               ` Helmut Raiger
2012-01-11 13:59               ` [U-Boot] [PATCH V3] " Helmut Raiger
2012-01-11 13:59                 ` [U-Boot] [PATCH 1/2] " Helmut Raiger
2012-01-13  8:28                   ` Stefano Babic
2012-01-17  9:56                   ` Stefano Babic
2012-01-11 13:59                 ` [U-Boot] [PATCH 2/2] tt01: add MMC support Helmut Raiger
2012-01-12 10:15                   ` [U-Boot] [PATCH 2/2] imx: " Helmut Raiger
2012-01-13  8:32                   ` [U-Boot] [PATCH 2/2] " Stefano Babic
2012-01-16 11:10                     ` [U-Boot] [PATCH V2] " Helmut Raiger
2012-01-16 11:10                       ` [U-Boot] [PATCH 1/2] fsl_pmic.h: add regulator mode 0 and 1 bits Helmut Raiger
2012-01-17 10:12                         ` Stefano Babic
2012-01-18 10:41                           ` [U-Boot] [PATCH V3 1/2] mc13783.h: create and add regulator mode 0 and 1 Helmut Raiger
2012-01-18 10:41                             ` [U-Boot] [PATCH V3 2/2] tt01: add MMC support Helmut Raiger
2012-01-18 12:37                               ` Stefano Babic
2012-01-19  7:21                                 ` Helmut Raiger
2012-01-19  7:27                                   ` [U-Boot] [PATCH V4] " Helmut Raiger
2012-01-30 14:35                                     ` Stefano Babic
2012-01-30 14:38                             ` [U-Boot] [PATCH V3 1/2] mc13783.h: create and add regulator mode 0 and 1 Stefano Babic
2012-01-16 11:10                       ` [U-Boot] [PATCH 2/2] tt01: add MMC support Helmut Raiger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).