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

2011-10-25 Thread Stefano Babic
On 10/24/2011 06:45 PM, Helmut Raiger wrote:
> 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 
> ---
>  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);
> +}

This introduces a new function and does not use the mxc_get_clock() that
hides the specific implementation for each SOC (if any).

The common way to get a clock for a i.MX SOC is to call the
mxc_get_clock() passing as parameter the peripheral (in this case, the
MMC) you need. In this way we hide if a SOC is using perclk and another
one perclk2 or maybe something else. We have MXC_CSPI_CLK, MXC_UART_CLK,
MXC_FEC_CLK,MXC_USB_CLK.

There is already MXC_ESDHC_CLK (check in the mx35 directory). Please use
the same interface and add only the case for MXC_ESDHC_CLK to the SOC
you requires.

> +
>  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

also for i.mx27 we should call mxc_get_clk()

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: off...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2011-10-24 Thread Helmut Raiger
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 
---
 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_CMD0x1d
+#define MUX_CTL_SD1_CLK0x1e
+#define MUX_CTL_SD1_DATA0  0x1f
+
 #define MUX_CTL_USBH2_DATA10x40
 #define MUX_CTL_USBH2_DIR  0x44
 #define MUX_CTL_USBH2_STP  0x45
@@ -792,6 +799,10 @@ struct esdc_regs {
  */
 #define NFC_BASE_ADDR  0xB800
 
+/* SD card controller */
+#define SDHC1_BASE_ADDR0x50004000
+#define SDHC2_BASE_ADDR0x50008000
+
 /*
  * 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 
 #include 
 #include 
-#ifdef CONFIG_MX27
 #include 
-#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.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot