Skip to contentSkip to conversation

fsl_esdhc: add support for mx51 processor

PATCH New Stefano Babic 3 participants 7 messages Jan 26, 2010 – Mar 19, 2010 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH v4 10/11 fsl_esdhc: add support for mx51 processor

The esdhc controller in the mx51 processor is quite the same as the one in some powerpc processors (MPC83xx, MPC85xx). This patches adapts the driver to support the arm mx51.

---
 cpu/arm_cortexa8/mx51/Makefile |    2 +-
 cpu/arm_cortexa8/mx51/speed.c  |   38 ++++++++++
 drivers/mmc/fsl_esdhc.c        |  153 +++++++++++++++++++++++++++-------------
 include/asm-arm/global_data.h  |    3 +
 include/fsl_esdhc.h            |   11 +++-
 lib_arm/board.c                |    3 +
 6 files changed, 159 insertions(+), 51 deletions(-)
 create mode 100644 cpu/arm_cortexa8/mx51/speed.c
cpu/arm_cortexa8/mx51/Makefile +1 -1
index 4d82293..7cfaa2c 100644
@@ -27,7 +27,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(SOC).a
 
-COBJS	= soc.o clock.o iomux.o timer.o
+COBJS	= soc.o clock.o iomux.o timer.o speed.o
 SOBJS = lowlevel_init.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
cpu/arm_cortexa8/mx51/speed.c new file +38 -0
new file mode 100644
index 0000000..10acbbf
@@ -0,0 +1,38 @@
+/*
+ * (C) Copyright 2000-2003
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
+ * TsiChung Liew (Tsi-Chung.Liew at freescale.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 <common.h>
+#include <asm/arch/imx-regs.h>
+
+int get_clocks(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_FSL_ESDHC
+	gd->sdhc_clk = mxc_get_clock(MXC_IPG_PERCLK);
+#endif
+	return 0;
+}
drivers/mmc/fsl_esdhc.c +104 -49

306 lines not on this page · raw message

include/asm-arm/global_data.h +3 -0
index 8115a24..02cfe45 100644
@@ -44,6 +44,9 @@ typedef	struct	global_data {
 #ifdef CONFIG_VFD
 	unsigned char	vfd_type;	/* display type */
 #endif
+#ifdef CONFIG_FSL_ESDHC
+	unsigned long	sdhc_clk;
+#endif
 #if 0
 	unsigned long	cpu_clk;	/* CPU clock in Hz!		*/
 	unsigned long	bus_clk;
include/fsl_esdhc.h +10 -1
index 89b8304..5fe9946 100644
@@ -32,7 +32,9 @@
 #define SYSCTL			0x0002e02c
 #define SYSCTL_INITA		0x08000000
 #define SYSCTL_TIMEOUT_MASK	0x000f0000
-#define SYSCTL_CLOCK_MASK	0x00000fff
+#define SYSCTL_CLOCK_MASK	0x0000fff0
+#define SYSCTL_RSTA		0x01000000
+#define SYSCTL_CKEN		0x00000008
 #define SYSCTL_PEREN		0x00000004
 #define SYSCTL_HCKEN		0x00000002
 #define SYSCTL_IPGEN		0x00000001
@@ -142,8 +144,15 @@
 #define ESDHC_HOSTCAPBLT_DMAS	0x00400000
 #define ESDHC_HOSTCAPBLT_HSS	0x00200000
 
+struct fsl_esdhc_cfg {
+	u32	esdhc_base;
+	u32	no_snoop;
+	u32	clk_enable;
+};
+
 #ifdef CONFIG_FSL_ESDHC
 int fsl_esdhc_mmc_init(bd_t *bis);
+int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg);
 void fdt_fixup_esdhc(void *blob, bd_t *bd);
 #else
 static inline int fsl_esdhc_mmc_init(bd_t *bis) { return -ENOSYS; }
lib_arm/board.c +3 -0
index e148739..f5660a9 100644
@@ -243,6 +243,9 @@ init_fnc_t *init_sequence[] = {
 	interrupt_init,		/* set up exceptions */
 #endif
 	timer_init,		/* initialize timer */
+#ifdef CONFIG_FSL_ESDHC
+	get_clocks,
+#endif
 	env_init,		/* initialize environment */
 	init_baudrate,		/* initialze baudrate settings */
 	serial_init,		/* serial communications setup */
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH v5 10/11 fsl_esdhc: add support for mx51 processor

The esdhc controller in the mx51 processor is quite the same as the one in some powerpc processors (MPC83xx, MPC85xx). This patches adapts the driver to support the arm mx51.

---

Changes since last version:

added missing prototype in speed.c

 cpu/arm_cortexa8/mx51/Makefile |    2 +-
 cpu/arm_cortexa8/mx51/speed.c  |   39 +++++++++++
 drivers/mmc/fsl_esdhc.c        |  149 +++++++++++++++++++++++++++-------------
 include/asm-arm/global_data.h  |    3 +
 include/fsl_esdhc.h            |   27 +++++++
 lib_arm/board.c                |    3 +
 6 files changed, 174 insertions(+), 49 deletions(-)
 create mode 100644 cpu/arm_cortexa8/mx51/speed.c
cpu/arm_cortexa8/mx51/Makefile +1 -1
index 4d82293..7cfaa2c 100644
@@ -27,7 +27,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(SOC).a
 
-COBJS	= soc.o clock.o iomux.o timer.o
+COBJS	= soc.o clock.o iomux.o timer.o speed.o
 SOBJS = lowlevel_init.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
cpu/arm_cortexa8/mx51/speed.c new file +39 -0
new file mode 100644
index 0000000..a444def
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2000-2003
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
+ * TsiChung Liew (Tsi-Chung.Liew at freescale.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 <common.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/clock.h>
+
+int get_clocks(void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_FSL_ESDHC
+	gd->sdhc_clk = mxc_get_clock(MXC_IPG_PERCLK);
+#endif
+	return 0;
+}
drivers/mmc/fsl_esdhc.c +101 -48

296 lines not on this page · raw message

include/asm-arm/global_data.h +3 -0
index 8115a24..02cfe45 100644
@@ -44,6 +44,9 @@ typedef	struct	global_data {
 #ifdef CONFIG_VFD
 	unsigned char	vfd_type;	/* display type */
 #endif
+#ifdef CONFIG_FSL_ESDHC
+	unsigned long	sdhc_clk;
+#endif
 #if 0
 	unsigned long	cpu_clk;	/* CPU clock in Hz!		*/
 	unsigned long	bus_clk;
include/fsl_esdhc.h +27 -0
index eac6a2b..01b7dec 100644
@@ -27,12 +27,15 @@
 #define	__FSL_ESDHC_H__
 
 #include <asm/errno.h>
+#include <asm/byteorder.h>
 
 /* FSL eSDHC-specific constants */
 #define SYSCTL			0x0002e02c
 #define SYSCTL_INITA		0x08000000
 #define SYSCTL_TIMEOUT_MASK	0x000f0000
 #define SYSCTL_CLOCK_MASK	0x0000fff0
+#define SYSCTL_RSTA		0x01000000
+#define SYSCTL_CKEN		0x00000008
 #define SYSCTL_PEREN		0x00000004
 #define SYSCTL_HCKEN		0x00000002
 #define SYSCTL_IPGEN		0x00000001
@@ -142,8 +145,32 @@
 #define ESDHC_HOSTCAPBLT_DMAS	0x00400000
 #define ESDHC_HOSTCAPBLT_HSS	0x00200000
 
+struct fsl_esdhc_cfg {
+	u32	esdhc_base;
+	u32	no_snoop;
+	u32	clk_enable;
+};
+
+/* Select the correct accessors depending on endianess */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define esdhc_read32		in_le32
+#define esdhc_write32		out_le32
+#define esdhc_clrsetbits32	clrsetbits_le32
+#define esdhc_clrbits32		clrbits_le32
+#define esdhc_setbits32		setbits_le32
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#define esdhc_read32		in_be32
+#define esdhc_write32		out_be32
+#define esdhc_clrsetbits32	clrsetbits_be32
+#define esdhc_clrbits32		clrbits_be32
+#define esdhc_setbits32		setbits_be32
+#else
+#error "Endianess is not defined: please fix to continue"
+#endif
+
 #ifdef CONFIG_FSL_ESDHC
 int fsl_esdhc_mmc_init(bd_t *bis);
+int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg);
 void fdt_fixup_esdhc(void *blob, bd_t *bd);
 #else
 static inline int fsl_esdhc_mmc_init(bd_t *bis) { return -ENOSYS; }
lib_arm/board.c +3 -0
index e148739..f5660a9 100644
@@ -243,6 +243,9 @@ init_fnc_t *init_sequence[] = {
 	interrupt_init,		/* set up exceptions */
 #endif
 	timer_init,		/* initialize timer */
+#ifdef CONFIG_FSL_ESDHC
+	get_clocks,
+#endif
 	env_init,		/* initialize environment */
 	init_baudrate,		/* initialze baudrate settings */
 	serial_init,		/* serial communications setup */
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH v5 10/11 fsl_esdhc: add support for mx51 processor

Quoted 7 lines · Stefano Babic

The esdhc controller in the mx51 processor is quite the same as the one in some powerpc processors (MPC83xx, MPC85xx). This patches adapts the driver to support the arm mx51.

---

Do you have any time to possible test a few patches to fsl_esdhc on mx51?

- k

#3 lore raw

PATCH v5 10/11 fsl_esdhc: add support for mx51 processor

Hi Kumar,

Quoted 11 lines · Stefano Babic
Quoted 8 lines

The esdhc controller in the mx51 processor is quite the same as the one in some powerpc processors (MPC83xx, MPC85xx). This patches adapts the driver to support the arm mx51.

---

Do you have any time to possible test a few patches to fsl_esdhc on mx51?

At the moment Stefano is somewhat under water currently - I hope he will resurface beginning next week. What exactly do you want him to test?

Cheers
Detlev

Signature · 9 lines
... that every year or so they're going to give you a new release full
of 50 000  additional lines of code all  written  by monkeys.  Because
they generally follow  the  ``million monkeys typing,   and eventually
they'll come up with something useful'' school of system development.
	                                    -- Richard M. Stallman
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#4 lore raw

PATCH v5 10/11 fsl_esdhc: add support for mx51 processor

Quoted 9 lines · Detlev Zundel

Hi Kumar,

Quoted 7 lines · Stefano Babic
Quoted 6 lines

The esdhc controller in the mx51 processor is quite the same as the one in some powerpc processors (MPC83xx, MPC85xx). This patches adapts the driver to support the arm mx51.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

---

Do you have any time to possible test a few patches to fsl_esdhc on mx51?

At the moment Stefano is somewhat under water currently - I hope he will resurface beginning next week. What exactly do you want him to test?

I've got a few patches from our internal team for PQ3/eSHDC support and want to make sure they didn't break mx51 support.

I'll post the patches once I clean them up (not 100% sure on the rationale for all of them at this point).

- k

#5 lore raw

PATCH v5 10/11 fsl_esdhc: add support for mx51 processor

In reply to Kumar Gala
Quoted 2 lines · Kumar Gala

Do you have any time to possible test a few patches to fsl_esdhc on mx51?

Hi Kumar,

I could test your patches next week, I have no possibility to access to the imx51evk board before. Should be ok for you ?

Stefano

Signature · 5 lines
=====================================================================
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: office at denx.de
=====================================================================
#6 lore raw

PATCH v5 10/11 fsl_esdhc: add support for mx51 processor

Quoted 8 lines · stefano babic
Quoted 2 lines · Kumar Gala

Do you have any time to possible test a few patches to fsl_esdhc on mx51?

Hi Kumar,

I could test your patches next week, I have no possibility to access to the imx51evk board before. Should be ok for you ?

Next week is fine, I just posted the set of 3. We have another for multi block read support, but I'm waiting on the guys to answer some questions for me about the patch possible having some bugs.

- k