Skip to contentSkip to conversation

MX51 Support V2

U-Boot Superseded Stefano Babic 5 participants 20 messages Jan 13, 2010 – Jan 20, 2010

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

Hi,

This is the second version of patchset to support the Freescale i.MX51 processor and the MX51EVK board, after fixing comments from first review. Thanks everybody for comments !

Stefano Babic

#1 lore raw

PATCH v2 1/9 mkimage: Add Freescale imx Boot Image support (imximage)

This patch adds support for "imximage" (MX Boot Image) to the mkimage utility. The imximage is used on the Freescales's MX.51 processors.

Further details under doc/README.imximage.

This patch was tested on a Freescale mx51evk board.

---
 common/image.c      |    1 +
 doc/README.imximage |   73 +++++++++++++
 include/image.h     |    1 +
 tools/Makefile      |    2 +
 tools/imximage.c    |  293 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/imximage.h    |  105 ++++++++++++++++++
 tools/mkimage.c     |    2 +
 tools/mkimage.h     |    1 +
 8 files changed, 478 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.imximage
 create mode 100644 tools/imximage.c
 create mode 100644 tools/imximage.h
common/image.c +1 -0
index 82e7aa4..9e49713 100644
@@ -140,6 +140,7 @@ static table_entry_t uimage_type[] = {
 	{	IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
 	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
 	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
+	{	IH_TYPE_IMXIMAGE,   "imximage",   "Freescale i.MX Boot Image",},
 	{	-1,		    "",		  "",			},
 };
 
doc/README.imximage new file +73 -0

73 lines not on this page · raw message

include/image.h +1 -0
index d2e78fe..3e959de 100644
@@ -156,6 +156,7 @@
 #define IH_TYPE_FILESYSTEM	7	/* Filesystem Image (any type)	*/
 #define IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
 #define IH_TYPE_KWBIMAGE	9	/* Kirkwood Boot Image		*/
+#define IH_TYPE_IMXIMAGE	10	/* Freescale IMXBoot Image	*/
 
 /*
  * Compression Types
tools/Makefile +2 -0
index 5b8c3c3..afc1d44 100644
@@ -73,6 +73,7 @@ OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
 OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
 NOPED_OBJ_FILES-y += kwbimage.o
+NOPED_OBJ_FILES-y += imximage.o
 NOPED_OBJ_FILES-y += mkimage.o
 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 NOPED_OBJ_FILES-y += os_support.o
@@ -159,6 +160,7 @@ $(obj)mkimage$(SFX):	$(obj)crc32.o \
 			$(obj)fit_image.o \
 			$(obj)image.o \
 			$(obj)kwbimage.o \
+			$(obj)imximage.o \
 			$(obj)md5.o \
 			$(obj)mkimage.o \
 			$(obj)os_support.o \
tools/imximage.c new file +293 -0

293 lines not on this page · raw message

tools/imximage.h new file +105 -0

105 lines not on this page · raw message

tools/mkimage.c +2 -0
index 1bed933..8b5d7f5 100644
@@ -150,6 +150,8 @@ main (int argc, char **argv)
 
 	/* Init Kirkwood Boot image generation/list support */
 	init_kwb_image_type ();
+	/* Init Freescale imx.51 Boot image generation/list support */
+	init_imx_image_type ();
 	/* Init FIT image generation/list support */
 	init_fit_image_type ();
 	/* Init Default image generation/list support */
tools/mkimage.h +1 -0
index ec67336..9033a7d 100644
@@ -140,6 +140,7 @@ void mkimage_register (struct image_type_params *tparams);
  * Supported image types init functions
  */
 void init_kwb_image_type (void);
+void init_imx_image_type (void);
 void init_default_image_type (void);
 void init_fit_image_type (void);
 
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH v2 2/9 MX51: Add initial support for the Freescale MX51

The patch add initial support for the Freescale i.MX51 processor (family arm cortex_a8).

---
 cpu/arm_cortexa8/mx51/Makefile        |   48 +++++
 cpu/arm_cortexa8/mx51/clock.c         |  287 +++++++++++++++++++++++++++++
 cpu/arm_cortexa8/mx51/iomux.c         |  201 +++++++++++++++++++++
 cpu/arm_cortexa8/mx51/lowlevel_init.S |  320 +++++++++++++++++++++++++++++++++
 cpu/arm_cortexa8/mx51/soc.c           |   78 ++++++++
 cpu/arm_cortexa8/mx51/timer.c         |  122 +++++++++++++
 cpu/arm_cortexa8/mx51/u-boot.lds      |   61 +++++++
 7 files changed, 1117 insertions(+), 0 deletions(-)
 create mode 100644 cpu/arm_cortexa8/mx51/Makefile
 create mode 100644 cpu/arm_cortexa8/mx51/clock.c
 create mode 100644 cpu/arm_cortexa8/mx51/iomux.c
 create mode 100644 cpu/arm_cortexa8/mx51/lowlevel_init.S
 create mode 100644 cpu/arm_cortexa8/mx51/soc.c
 create mode 100644 cpu/arm_cortexa8/mx51/timer.c
 create mode 100644 cpu/arm_cortexa8/mx51/u-boot.lds
cpu/arm_cortexa8/mx51/Makefile new file +48 -0
new file mode 100644
index 0000000..4d82293
@@ -0,0 +1,48 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2009 Freescale Semiconductor, Inc.
+#
+# 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
+
+LIB	= $(obj)lib$(SOC).a
+
+COBJS	= soc.o clock.o iomux.o timer.o
+SOBJS = lowlevel_init.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
cpu/arm_cortexa8/mx51/clock.c new file +287 -0

287 lines not on this page · raw message

cpu/arm_cortexa8/mx51/iomux.c new file +201 -0

201 lines not on this page · raw message

cpu/arm_cortexa8/mx51/lowlevel_init.S new file +320 -0

320 lines not on this page · raw message

cpu/arm_cortexa8/mx51/soc.c new file +78 -0

78 lines not on this page · raw message

cpu/arm_cortexa8/mx51/timer.c new file +122 -0

122 lines not on this page · raw message

cpu/arm_cortexa8/mx51/u-boot.lds new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#3 lore raw

PATCH v2 3/9 MX51: Add register definitions

The patch add header files to support the Freescale i.MX51 processor, setting definitions for internal registers.

---
 include/asm-arm/arch-mx51/crm_regs.h |  192 +++++++++++++++++++++
 include/asm-arm/arch-mx51/imx-regs.h |  308 ++++++++++++++++++++++++++++++++++
 2 files changed, 500 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-arm/arch-mx51/crm_regs.h
 create mode 100644 include/asm-arm/arch-mx51/imx-regs.h
include/asm-arm/arch-mx51/crm_regs.h new file +192 -0
new file mode 100644
index 0000000..38dcbc4
@@ -0,0 +1,192 @@
+/*
+ * (C) Copyright 2009 Freescale Semiconductor, Inc.
+ *
+ * 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 __ARCH_ARM_MACH_MX51_CRM_REGS_H__
+#define __ARCH_ARM_MACH_MX51_CRM_REGS_H__
+
+#define MXC_CCM_BASE	CCM_BASE_ADDR
+
+/* DPLL register mapping structure */
+struct mxc_pll_reg {
+	u32 ctrl;
+	u32 config;
+	u32 op;
+	u32 mfd;
+	u32 mfn;
+	u32 mfn_minus;
+	u32 mfn_plus;
+	u32 hfs_op;
+	u32 hfs_mfd;
+	u32 hfs_mfn;
+	u32 mfn_togc;
+	u32 destat;
+};
+
+/* Register maping of CCM*/
+struct mxc_ccm_reg {
+	u32 ccr;	/* 0x0000 */
+	u32 ccdr;
+	u32 csr;
+	u32 ccsr;
+	u32 cacrr;	/* 0x0010*/
+	u32 cbcdr;
+	u32 cbcmr;
+	u32 cscmr1;
+	u32 cscmr2;	/* 0x0020 */
+	u32 cscdr1;
+	u32 cs1cdr;
+	u32 cs2cdr;
+	u32 cdcdr;	/* 0x0030 */
+	u32 chscdr;
+	u32 cscdr2;
+	u32 cscdr3;
+	u32 cscdr4;	/* 0x0040 */
+	u32 cwdr;
+	u32 cdhipr;
+	u32 cdcr;
+	u32 ctor;	/* 0x0050 */
+	u32 clpcr;
+	u32 cisr;
+	u32 cimr;
+	u32 ccosr;	/* 0x0060 */
+	u32 cgpr;
+	u32 CCGR0;
+	u32 CCGR1;
+	u32 CCGR2;	/* 0x0070 */
+	u32 CCGR3;
+	u32 CCGR4;
+	u32 CCGR5;
+	u32 CCGR6;	/* 0x0080 */
+	u32 cmeor;
+};
+
+/* Define the bits in register CACRR */
+#define MXC_CCM_CACRR_ARM_PODF_OFFSET	(0)
+#define MXC_CCM_CACRR_ARM_PODF_MASK		(0x7)
+
+/* Define the bits in register CBCDR */
+#define MXC_CCM_CBCDR_EMI_CLK_SEL			(0x1 << 26)
+#define MXC_CCM_CBCDR_PERIPH_CLK_SEL			(0x1 << 25)
+#define MXC_CCM_CBCDR_EMI_PODF_OFFSET		(22)
+#define MXC_CCM_CBCDR_EMI_PODF_MASK			(0x7 << 22)
+#define MXC_CCM_CBCDR_AXI_B_PODF_OFFSET		(19)
+#define MXC_CCM_CBCDR_AXI_B_PODF_MASK		(0x7 << 19)
+#define MXC_CCM_CBCDR_AXI_A_PODF_OFFSET		(16)
+#define MXC_CCM_CBCDR_AXI_A_PODF_MASK		(0x7 << 16)
+#define MXC_CCM_CBCDR_NFC_PODF_OFFSET		(13)
+#define MXC_CCM_CBCDR_NFC_PODF_MASK			(0x7 << 13)
+#define MXC_CCM_CBCDR_AHB_PODF_OFFSET		(10)
+#define MXC_CCM_CBCDR_AHB_PODF_MASK			(0x7 << 10)
+#define MXC_CCM_CBCDR_IPG_PODF_OFFSET		(8)
+#define MXC_CCM_CBCDR_IPG_PODF_MASK			(0x3 << 8)
+#define MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET		(6)
+#define MXC_CCM_CBCDR_PERCLK_PRED1_MASK		(0x3 << 6)
+#define MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET		(3)
+#define MXC_CCM_CBCDR_PERCLK_PRED2_MASK		(0x7 << 3)
+#define MXC_CCM_CBCDR_PERCLK_PODF_OFFSET		(0)
+#define MXC_CCM_CBCDR_PERCLK_PODF_MASK		(0x7)
+
+/* Define the bits in register CSCMR1 */
+#define MXC_CCM_CSCMR1_SSI_EXT2_CLK_SEL_OFFSET		(30)
+#define MXC_CCM_CSCMR1_SSI_EXT2_CLK_SEL_MASK		(0x3 << 30)
+#define MXC_CCM_CSCMR1_SSI_EXT1_CLK_SEL_OFFSET		(28)
+#define MXC_CCM_CSCMR1_SSI_EXT1_CLK_SEL_MASK		(0x3 << 28)
+#define MXC_CCM_CSCMR1_USB_PHY_CLK_SEL_OFFSET		(26)
+#define MXC_CCM_CSCMR1_USB_PHY_CLK_SEL			(0x1 << 26)
+#define MXC_CCM_CSCMR1_UART_CLK_SEL_OFFSET			(24)
+#define MXC_CCM_CSCMR1_UART_CLK_SEL_MASK			(0x3 << 24)
+#define MXC_CCM_CSCMR1_USBOH3_CLK_SEL_OFFSET		(22)
+#define MXC_CCM_CSCMR1_USBOH3_CLK_SEL_MASK			(0x3 << 22)
+#define MXC_CCM_CSCMR1_ESDHC1_MSHC1_CLK_SEL_OFFSET	(20)
+#define MXC_CCM_CSCMR1_ESDHC1_MSHC1_CLK_SEL_MASK		(0x3 << 20)
+#define MXC_CCM_CSCMR1_ESDHC3_CLK_SEL			(0x1 << 19)
+#define MXC_CCM_CSCMR1_ESDHC4_CLK_SEL			(0x1 << 18)
+#define MXC_CCM_CSCMR1_ESDHC2_MSHC2_CLK_SEL_OFFSET	(16)
+#define MXC_CCM_CSCMR1_ESDHC2_MSHC2_CLK_SEL_MASK		(0x3 << 16)
+#define MXC_CCM_CSCMR1_SSI1_CLK_SEL_OFFSET			(14)
+#define MXC_CCM_CSCMR1_SSI1_CLK_SEL_MASK			(0x3 << 14)
+#define MXC_CCM_CSCMR1_SSI2_CLK_SEL_OFFSET			(12)
+#define MXC_CCM_CSCMR1_SSI2_CLK_SEL_MASK			(0x3 << 12)
+#define MXC_CCM_CSCMR1_SSI3_CLK_SEL				(0x1 << 11)
+#define MXC_CCM_CSCMR1_VPU_RCLK_SEL				(0x1 << 10)
+#define MXC_CCM_CSCMR1_SSI_APM_CLK_SEL_OFFSET		(8)
+#define MXC_CCM_CSCMR1_SSI_APM_CLK_SEL_MASK		(0x3 << 8)
+#define MXC_CCM_CSCMR1_TVE_CLK_SEL				(0x1 << 7)
+#define MXC_CCM_CSCMR1_TVE_EXT_CLK_SEL			(0x1 << 6)
+#define MXC_CCM_CSCMR1_CSPI_CLK_SEL_OFFSET			(4)
+#define MXC_CCM_CSCMR1_CSPI_CLK_SEL_MASK			(0x3 << 4)
+#define MXC_CCM_CSCMR1_SPDIF_CLK_SEL_OFFSET			(2)
+#define MXC_CCM_CSCMR1_SPDIF_CLK_SEL_MASK			(0x3 << 2)
+#define MXC_CCM_CSCMR1_SSI_EXT2_COM_CLK_SEL			(0x1 << 1)
+#define MXC_CCM_CSCMR1_SSI_EXT1_COM_CLK_SEL			(0x1)
+
+/* Define the bits in register CSCDR2 */
+#define MXC_CCM_CSCDR2_CSPI_CLK_PRED_OFFSET		(25)
+#define MXC_CCM_CSCDR2_CSPI_CLK_PRED_MASK		(0x7 << 25)
+#define MXC_CCM_CSCDR2_CSPI_CLK_PODF_OFFSET		(19)
+#define MXC_CCM_CSCDR2_CSPI_CLK_PODF_MASK		(0x3F << 19)
+#define MXC_CCM_CSCDR2_SIM_CLK_PRED_OFFSET		(16)
+#define MXC_CCM_CSCDR2_SIM_CLK_PRED_MASK		(0x7 << 16)
+#define MXC_CCM_CSCDR2_SIM_CLK_PODF_OFFSET		(9)
+#define MXC_CCM_CSCDR2_SIM_CLK_PODF_MASK		(0x3F << 9)
+#define MXC_CCM_CSCDR2_SLIMBUS_CLK_PRED_OFFSET	(6)
+#define MXC_CCM_CSCDR2_SLIMBUS_PRED_MASK		(0x7 << 6)
+#define MXC_CCM_CSCDR2_SLIMBUS_PODF_OFFSET		(0)
+#define MXC_CCM_CSCDR2_SLIMBUS_PODF_MASK		(0x3F)
+
+/* Define the bits in register CBCMR */
+#define MXC_CCM_CBCMR_VPU_AXI_CLK_SEL_OFFSET	(14)
+#define MXC_CCM_CBCMR_VPU_AXI_CLK_SEL_MASK		(0x3 << 14)
+#define MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET		(12)
+#define MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK		(0x3 << 12)
+#define MXC_CCM_CBCMR_DDR_CLK_SEL_OFFSET		(10)
+#define MXC_CCM_CBCMR_DDR_CLK_SEL_MASK		(0x3 << 10)
+#define MXC_CCM_CBCMR_ARM_AXI_CLK_SEL_OFFSET	(8)
+#define MXC_CCM_CBCMR_ARM_AXI_CLK_SEL_MASK		(0x3 << 8)
+#define MXC_CCM_CBCMR_IPU_HSP_CLK_SEL_OFFSET	(6)
+#define MXC_CCM_CBCMR_IPU_HSP_CLK_SEL_MASK		(0x3 << 6)
+#define MXC_CCM_CBCMR_GPU_CLK_SEL_OFFSET		(4)
+#define MXC_CCM_CBCMR_GPU_CLK_SEL_MASK		(0x3 << 4)
+#define MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL		(0x1 << 1)
+#define MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL		(0x1 << 0)
+
+/* Define the bits in register CSCDR1 */
+#define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PRED_OFFSET	(22)
+#define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PRED_MASK		(0x7 << 22)
+#define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PODF_OFFSET	(19)
+#define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PODF_MASK		(0x7 << 19)
+#define MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PRED_OFFSET	(16)
+#define MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PRED_MASK		(0x7 << 16)
+#define MXC_CCM_CSCDR1_PGC_CLK_PODF_OFFSET			(14)
+#define MXC_CCM_CSCDR1_PGC_CLK_PODF_MASK			(0x3 << 14)
+#define MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PODF_OFFSET	(11)
+#define MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PODF_MASK		(0x7 << 11)
+#define MXC_CCM_CSCDR1_USBOH3_CLK_PRED_OFFSET		(8)
+#define MXC_CCM_CSCDR1_USBOH3_CLK_PRED_MASK		(0x7 << 8)
+#define MXC_CCM_CSCDR1_USBOH3_CLK_PODF_OFFSET		(6)
+#define MXC_CCM_CSCDR1_USBOH3_CLK_PODF_MASK		(0x3 << 6)
+#define MXC_CCM_CSCDR1_UART_CLK_PRED_OFFSET		(3)
+#define MXC_CCM_CSCDR1_UART_CLK_PRED_MASK			(0x7 << 3)
+#define MXC_CCM_CSCDR1_UART_CLK_PODF_OFFSET		(0)
+#define MXC_CCM_CSCDR1_UART_CLK_PODF_MASK			(0x7)
+
+#endif				/* __ARCH_ARM_MACH_MX51_CRM_REGS_H__ */
include/asm-arm/arch-mx51/imx-regs.h new file +308 -0

308 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#4 lore raw

PATCH v2 4/9 MX51: Add pin and multiplexer definitions.

The patch add header files to support the pin multiplexer of the the Freescale i.MX51 processor.

---
 include/asm-arm/arch-mx51/iomux.h     |  250 ++++++++++++++++++++++
 include/asm-arm/arch-mx51/mx51_pins.h |  376 +++++++++++++++++++++++++++++++++
 2 files changed, 626 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-arm/arch-mx51/iomux.h
 create mode 100644 include/asm-arm/arch-mx51/mx51_pins.h
include/asm-arm/arch-mx51/iomux.h new file +250 -0
new file mode 100644
index 0000000..c898908
@@ -0,0 +1,250 @@
+/*
+ * (C) Copyright 2008-2009 Freescale Semiconductor, Inc.
+ *
+ * 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 __MACH_MX51_IOMUX_H__
+#define __MACH_MX51_IOMUX_H__
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/mx51_pins.h>
+
+/*!
+ * @file iomux.h
+ *
+ * @brief I/O Muxing control definitions and functions
+ *
+ * @ingroup GPIO_MX51
+ */
+
+typedef unsigned int iomux_pin_name_t;
+
+/*!
+ * various IOMUX output functions
+ */
+typedef enum iomux_config {
+	IOMUX_CONFIG_ALT0,	/*!< used as alternate function 0 */
+	IOMUX_CONFIG_ALT1,	/*!< used as alternate function 1 */
+	IOMUX_CONFIG_ALT2,	/*!< used as alternate function 2 */
+	IOMUX_CONFIG_ALT3,	/*!< used as alternate function 3 */
+	IOMUX_CONFIG_ALT4,	/*!< used as alternate function 4 */
+	IOMUX_CONFIG_ALT5,	/*!< used as alternate function 5 */
+	IOMUX_CONFIG_ALT6,	/*!< used as alternate function 6 */
+	IOMUX_CONFIG_ALT7,	/*!< used as alternate function 7 */
+	IOMUX_CONFIG_GPIO,	/*!< added to help user use GPIO mode */
+	IOMUX_CONFIG_SION = 0x1 << 4,	/*!< used as LOOPBACK:MUX SION bit */
+} iomux_pin_cfg_t;
+
+/*!
+ * various IOMUX pad functions
+ */
+typedef enum iomux_pad_config {
+	PAD_CTL_SRE_SLOW = 0x0 << 0,
+	PAD_CTL_SRE_FAST = 0x1 << 0,
+	PAD_CTL_DRV_LOW = 0x0 << 1,
+	PAD_CTL_DRV_MEDIUM = 0x1 << 1,
+	PAD_CTL_DRV_HIGH = 0x2 << 1,
+	PAD_CTL_DRV_MAX = 0x3 << 1,
+	PAD_CTL_ODE_OPENDRAIN_NONE = 0x0 << 3,
+	PAD_CTL_ODE_OPENDRAIN_ENABLE = 0x1 << 3,
+	PAD_CTL_100K_PD = 0x0 << 4,
+	PAD_CTL_47K_PU = 0x1 << 4,
+	PAD_CTL_100K_PU = 0x2 << 4,
+	PAD_CTL_22K_PU = 0x3 << 4,
+	PAD_CTL_PUE_KEEPER = 0x0 << 6,
+	PAD_CTL_PUE_PULL = 0x1 << 6,
+	PAD_CTL_PKE_NONE = 0x0 << 7,
+	PAD_CTL_PKE_ENABLE = 0x1 << 7,
+	PAD_CTL_HYS_NONE = 0x0 << 8,
+	PAD_CTL_HYS_ENABLE = 0x1 << 8,
+	PAD_CTL_DDR_INPUT_CMOS = 0x0 << 9,
+	PAD_CTL_DDR_INPUT_DDR = 0x1 << 9,
+	PAD_CTL_DRV_VOT_LOW = 0x0 << 13,
+	PAD_CTL_DRV_VOT_HIGH = 0x1 << 13,
+} iomux_pad_config_t;
+
+/*!
+ * various IOMUX input select register index
+ */
+typedef enum iomux_input_select {
+	MUX_IN_AUDMUX_P4_INPUT_DA_AMX_SELECT_I = 0,
+	MUX_IN_AUDMUX_P4_INPUT_DB_AMX_SELECT_I,
+	MUX_IN_AUDMUX_P4_INPUT_TXCLK_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P4_INPUT_TXFS_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P5_INPUT_DA_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P5_INPUT_DB_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P5_INPUT_RXCLK_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P5_INPUT_RXFS_AMX_SELECT,
+	MUX_IN_AUDMUX_P5_INPUT_TXCLK_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P5_INPUT_TXFS_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P6_INPUT_DA_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P6_INPUT_DB_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P6_INPUT_RXCLK_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P6_INPUT_RXFS_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P6_INPUT_TXCLK_AMX_SELECT_INPUT,
+	MUX_IN_AUDMUX_P6_INPUT_TXFS_AMX_SELECT_INPUT,
+	MUX_IN_CCM_IPP_DI_CLK_SELECT_INPUT,
+	/* TO2 */
+	MUX_IN_CCM_IPP_DI1_CLK_SELECT_INPUT,
+	MUX_IN_CCM_PLL1_BYPASS_CLK_SELECT_INPUT,
+	MUX_IN_CCM_PLL2_BYPASS_CLK_SELECT_INPUT,
+	MUX_IN_CSPI_IPP_CSPI_CLK_IN_SELECT_INPUT,
+	MUX_IN_CSPI_IPP_IND_MISO_SELECT_INPUT,
+	MUX_IN_CSPI_IPP_IND_MOSI_SELECT_INPUT,
+	MUX_IN_CSPI_IPP_IND_SS_B_1_SELECT_INPUT,
+	MUX_IN_CSPI_IPP_IND_SS_B_2_SELECT_INPUT,
+	MUX_IN_CSPI_IPP_IND_SS_B_3_SELECT_INPUT,
+	MUX_IN_DPLLIP1_L1T_TOG_EN_SELECT_INPUT,
+	/* TO2 */
+	MUX_IN_ECSPI2_IPP_IND_SS_B_1_SELECT_INPUT,
+	MUX_IN_ECSPI2_IPP_IND_SS_B_3_SELECT_INPUT,
+	MUX_IN_EMI_IPP_IND_RDY_INT_SELECT_INPUT,
+	MUX_IN_ESDHC3_IPP_DAT0_IN_SELECT_INPUT,
+	MUX_IN_ESDHC3_IPP_DAT1_IN_SELECT_INPUT,
+	MUX_IN_ESDHC3_IPP_DAT2_IN_SELECT_INPUT,
+	MUX_IN_ESDHC3_IPP_DAT3_IN_SELECT_INPUT,
+	MUX_IN_FEC_FEC_COL_SELECT_INPUT,
+	MUX_IN_FEC_FEC_CRS_SELECT_INPUT,
+	MUX_IN_FEC_FEC_MDI_SELECT_INPUT,
+	MUX_IN_FEC_FEC_RDATA_0_SELECT_INPUT,
+	MUX_IN_FEC_FEC_RDATA_1_SELECT_INPUT,
+	MUX_IN_FEC_FEC_RDATA_2_SELECT_INPUT,
+	MUX_IN_FEC_FEC_RDATA_3_SELECT_INPUT,
+	MUX_IN_FEC_FEC_RX_CLK_SELECT_INPUT,
+	MUX_IN_FEC_FEC_RX_DV_SELECT_INPUT,
+	MUX_IN_FEC_FEC_RX_ER_SELECT_INPUT,
+	MUX_IN_FEC_FEC_TX_CLK_SELECT_INPUT,
+	MUX_IN_GPIO3_IPP_IND_G_IN_1_SELECT_INPUT,
+	MUX_IN_GPIO3_IPP_IND_G_IN_2_SELECT_INPUT,
+	MUX_IN_GPIO3_IPP_IND_G_IN_3_SELECT_INPUT,
+	MUX_IN_GPIO3_IPP_IND_G_IN_4_SELECT_INPUT,
+	MUX_IN_GPIO3_IPP_IND_G_IN_5_SELECT_INPUT,
+	MUX_IN_GPIO3_IPP_IND_G_IN_6_SELECT_INPUT,
+	MUX_IN_GPIO3_IPP_IND_G_IN_7_SELECT_INPUT,
+	MUX_IN_GPIO3_IPP_IND_G_IN_8_SELECT_INPUT,
+	/* TO2 */
+	MUX_IN_GPIO3_IPP_IND_G_IN_12_SELECT_INPUT,
+	MUX_IN_HSC_MIPI_MIX_IPP_IND_SENS1_DATA_EN_SELECT_INPUT,
+	MUX_IN_HSC_MIPI_MIX_IPP_IND_SENS2_DATA_EN_SELECT_INPUT,
+	/* TO2 */
+	MUX_IN_HSC_MIPI_MIX_PAR_VSYNC_SELECT_INPUT,
+	/* TO2 */
+	MUX_IN_HSC_MIPI_MIX_PAR_DI_WAIT_SELECT_INPUT,
+	MUX_IN_HSC_MIPI_MIX_PAR_SISG_TRIG_SELECT_INPUT,
+	MUX_IN_I2C1_IPP_SCL_IN_SELECT_INPUT,
+	MUX_IN_I2C1_IPP_SDA_IN_SELECT_INPUT,
+	MUX_IN_I2C2_IPP_SCL_IN_SELECT_INPUT,
+	MUX_IN_I2C2_IPP_SDA_IN_SELECT_INPUT,
+
+	MUX_IN_IPU_IPP_DI_0_IND_DISPB_SD_D_SELECT_INPUT,
+
+	MUX_IN_IPU_IPP_DI_1_IND_DISPB_SD_D_SELECT_INPUT,
+
+	MUX_IN_KPP_IPP_IND_COL_6_SELECT_INPUT,
+	MUX_IN_KPP_IPP_IND_COL_7_SELECT_INPUT,
+	MUX_IN_KPP_IPP_IND_ROW_4_SELECT_INPUT,
+	MUX_IN_KPP_IPP_IND_ROW_5_SELECT_INPUT,
+	MUX_IN_KPP_IPP_IND_ROW_6_SELECT_INPUT,
+	MUX_IN_KPP_IPP_IND_ROW_7_SELECT_INPUT,
+	MUX_IN_UART1_IPP_UART_RTS_B_SELECT_INPUT,
+	MUX_IN_UART1_IPP_UART_RXD_MUX_SELECT_INPUT,
+	MUX_IN_UART2_IPP_UART_RTS_B_SELECT_INPUT,
+	MUX_IN_UART2_IPP_UART_RXD_MUX_SELECT_INPUT,
+	MUX_IN_UART3_IPP_UART_RTS_B_SELECT_INPUT,
+	MUX_IN_UART3_IPP_UART_RXD_MUX_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_CLK_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_DATA_0_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_DATA_1_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_DATA_2_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_DATA_3_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_DATA_4_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_DATA_5_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_DATA_6_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_DATA_7_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_DIR_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_NXT_SELECT_INPUT,
+	MUX_IN_USBOH3_IPP_IND_UH3_STP_SELECT_INPUT,
+	MUX_INPUT_NUM_MUX,
+} iomux_input_select_t;
+
+/*!
+ * various IOMUX input functions
+ */
+typedef enum iomux_input_config {
+	INPUT_CTL_PATH0 = 0x0,
+	INPUT_CTL_PATH1,
+	INPUT_CTL_PATH2,
+	INPUT_CTL_PATH3,
+	INPUT_CTL_PATH4,
+	INPUT_CTL_PATH5,
+	INPUT_CTL_PATH6,
+	INPUT_CTL_PATH7,
+} iomux_input_config_t;
+
+/*!
+ * Request ownership for an IO pin. This function has to be the first one
+ * being called before that pin is used. The caller has to check the
+ * return value to make sure it returns 0.
+ *
+ * @param  pin		a name defined by \b iomux_pin_name_t
+ * @param  config	config as defined in \b #iomux_pin_ocfg_t
+ *
+ * @return		0 if successful; Non-zero otherwise
+ */
+void mxc_request_iomux(iomux_pin_name_t pin, iomux_pin_cfg_t config);
+
+/*!
+ * Release ownership for an IO pin
+ *
+ * @param  pin		a name defined by \b iomux_pin_name_t
+ * @param  config	config as defined in \b #iomux_pin_ocfg_t
+ */
+void mxc_free_iomux(iomux_pin_name_t pin, iomux_pin_cfg_t config);
+
+/*!
+ * This function configures the pad value for a IOMUX pin.
+ *
+ * @param  pin          a pin number as defined in \b #iomux_pin_name_t
+ * @param  config      the ORed value of elements defined in
+ *                             \b #iomux_pad_config_t
+ */
+void mxc_iomux_set_pad(iomux_pin_name_t pin, u32 config);
+
+/*!
+ * This function gets the current pad value for a IOMUX pin.
+ *
+ * @param  pin          a pin number as defined in \b #iomux_pin_name_t
+ * @return		current pad value
+ */
+unsigned int mxc_iomux_get_pad(iomux_pin_name_t pin);
+
+/*!
+ * This function configures input path.
+ *
+ * @param  input        index of input select register as defined in
+ *                              \b #iomux_input_select_t
+ * @param  config       the binary value of elements defined in
+ *				\b #iomux_input_config_t
+ */
+void mxc_iomux_set_input(iomux_input_select_t input, u32 config);
+
+#endif				/*  __MACH_MX51_IOMUX_H__ */
include/asm-arm/arch-mx51/mx51_pins.h new file +376 -0

376 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#5 lore raw

PATCH v2 5/9 serial_mxc: add support for MX51 processor

The patch adds support for the Freescale mx51 processor.

---
 drivers/serial/serial_mxc.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
drivers/serial/serial_mxc.c +11 -1
index acc5b7d..4718775 100644
@@ -20,6 +20,8 @@
 #include <common.h>
 #ifdef CONFIG_MX31
 #include <asm/arch/mx31.h>
+#elif defined(CONFIG_MX51)
+#include <asm/arch/imx-regs.h>
 #else
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
@@ -49,8 +51,14 @@
 #define UART_PHYS 0x1001b000
 #elif defined(CONFIG_SYS_MX27_UART6)
 #define UART_PHYS 0x1001c000
+#elif defined(CONFIG_SYS_MX51_UART1)
+#define UART_PHYS UART1_BASE_ADDR
+#elif defined(CONFIG_SYS_MX51_UART2)
+#define UART_PHYS UART2_BASE_ADDR
+#elif defined(CONFIG_SYS_MX51_UART3)
+#define UART_PHYS UART3_BASE_ADDR
 #else
-#error "define CONFIG_SYS_MX31_UARTx to use the mx31 UART driver"
+#error "define CONFIG_SYS_MXxx_UARTx to use the mxxx UART driver"
 #endif
 
 /* Register definitions */
@@ -168,6 +176,8 @@ void serial_setbrg (void)
 {
 #ifdef CONFIG_MX31
 	u32 clk = mx31_get_ipg_clk();
+#elif defined(CONFIG_MX51)
+	u32 clk = imx_get_uartclk();
 #else
 	u32 clk = imx_get_perclk1();
 #endif
Signature · 1 line
1.6.3.3
#6 lore raw

PATCH v2 6/9 fec_mxc: add support for MX51 processor

The patch add support for the Freescale mx51 processor to the FEC ethernet driver.

---
 drivers/net/fec_mxc.c |   57 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 35 insertions(+), 22 deletions(-)
drivers/net/fec_mxc.c +35 -22
index 19116f2..203832e 100644
@@ -27,8 +27,10 @@
 #include <miiphy.h>
 #include "fec_mxc.h"
 
-#include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
+#ifndef CONFIG_MX51
+#include <asm/arch/clock.h>
+#endif
 #include <asm/io.h>
 #include <asm/errno.h>
 
@@ -108,6 +110,23 @@ static int fec_miiphy_read(char *dev, uint8_t phyAddr, uint8_t regAddr,
 	return 0;
 }
 
+static void fec_mii_setspeed(struct fec_priv *fec)
+{
+#ifdef CONFIG_MX51
+	writel((((mxc_get_clock(MXC_IPG_CLK) + 499999) / 5000000) << 1),
+			&fec->eth->mii_speed);
+#else
+	/*
+	 * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
+	 * and do not drop the Preamble.
+	 */
+	writel((((imx_get_ahbclk() / 1000000) + 2) / 5) << 1,
+			&fec->eth->mii_speed);
+	debug("fec_init: mii_speed %#lx\n",
+			(((imx_get_ahbclk() / 1000000) + 2) / 5) << 1);
+#endif
+
+}
 static int fec_miiphy_write(char *dev, uint8_t phyAddr, uint8_t regAddr,
 		uint16_t data)
 {
@@ -236,7 +255,7 @@ static int fec_rbd_init(struct fec_priv *fec, int count, int size)
 		fec->rdb_ptr = malloc(size * count + DB_DATA_ALIGNMENT);
 	p = (uint32_t)fec->rdb_ptr;
 	if (!p) {
-		puts("fec_imx27: not enough malloc memory!\n");
+		puts("fec_mxc: not enough malloc memory!\n");
 		return -ENOMEM;
 	}
 	memset((void *)p, 0, size * count + DB_DATA_ALIGNMENT);
@@ -299,6 +318,7 @@ static void fec_rbd_clean(int last, struct fec_bd *pRbd)
 
 static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
 {
+#ifndef CONFIG_MX51
 	struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
 	int i;
 
@@ -306,6 +326,9 @@ static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
 		mac[6-1-i] = readl(&iim->iim_bank_area0[IIM0_MAC + i]);
 
 	return is_valid_ether_addr(mac);
+#else
+	return -1;
+#endif
 }
 
 static int fec_set_hwaddr(struct eth_device *dev, unsigned char *mac)
@@ -373,7 +396,7 @@ static int fec_init(struct eth_device *dev, bd_t* bd)
 				sizeof(struct fec_bd) + DB_ALIGNMENT);
 	base = (uint32_t)fec->base_ptr;
 	if (!base) {
-		puts("fec_imx27: not enough malloc memory!\n");
+		puts("fec_mxc: not enough malloc memory!\n");
 		return -ENOMEM;
 	}
 	memset((void *)base, 0, (2 + FEC_RBD_NUM) *
@@ -411,14 +434,8 @@ static int fec_init(struct eth_device *dev, bd_t* bd)
 		 * Frame length=1518; MII mode;
 		 */
 		writel(0x05ee0024, &fec->eth->r_cntrl);	/* FIXME 0x05ee0004 */
-		/*
-		 * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
-		 * and do not drop the Preamble.
-		 */
-		writel((((imx_get_ahbclk() / 1000000) + 2) / 5) << 1,
-				&fec->eth->mii_speed);
-		debug("fec_init: mii_speed %#lx\n",
-				(((imx_get_ahbclk() / 1000000) + 2) / 5) << 1);
+
+		fec_mii_setspeed(fec);
 	}
 	/*
 	 * Set Opcode/Pause Duration Register
@@ -651,22 +668,24 @@ static int fec_recv(struct eth_device *dev)
 
 static int fec_probe(bd_t *bd)
 {
-	struct pll_regs *pll = (struct pll_regs *)IMX_PLL_BASE;
 	struct eth_device *edev;
 	struct fec_priv *fec = &gfec;
 	unsigned char ethaddr_str[20];
 	unsigned char ethaddr[6];
-	char *tmp = getenv("ethaddr");
+	char *tmp;
 	char *end;
+#ifndef CONFIG_MX51
+	struct pll_regs *pll = (struct pll_regs *)IMX_PLL_BASE;
 
 	/* enable FEC clock */
 	writel(readl(&pll->pccr1) | PCCR1_HCLK_FEC, &pll->pccr1);
 	writel(readl(&pll->pccr0) | PCCR0_FEC_EN, &pll->pccr0);
+#endif
 
 	/* create and fill edev struct */
 	edev = (struct eth_device *)malloc(sizeof(struct eth_device));
 	if (!edev) {
-		puts("fec_imx27: not enough malloc memory!\n");
+		puts("fec_mxc: not enough malloc memory!\n");
 		return -ENOMEM;
 	}
 	edev->priv = fec;
@@ -702,14 +721,7 @@ static int fec_probe(bd_t *bd)
 	 * Frame length=1518; MII mode;
 	 */
 	writel(0x05ee0024, &fec->eth->r_cntrl);	/* FIXME 0x05ee0004 */
-	/*
-	 * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
-	 * and do not drop the Preamble.
-	 */
-	writel((((imx_get_ahbclk() / 1000000) + 2) / 5) << 1,
-			&fec->eth->mii_speed);
-	debug("fec_init: mii_speed %#lx\n",
-			(((imx_get_ahbclk() / 1000000) + 2) / 5) << 1);
+	fec_mii_setspeed(fec);
 
 	sprintf(edev->name, "FEC_MXC");
 
@@ -717,6 +729,7 @@ static int fec_probe(bd_t *bd)
 
 	eth_register(edev);
 
+	tmp = getenv("ethaddr");
 	if ((NULL != tmp) && (12 <= strlen(tmp))) {
 		int i;
 		/* convert MAC from string to int */
Signature · 1 line
1.6.3.3
#7 lore raw

PATCH v2 7/9 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.

---
 drivers/mmc/fsl_esdhc.c |   72 +++++++++++++++++++++++++++++++++++++++-------
 include/asm-arm/io.h    |   21 +++++++++++++
 include/fsl_esdhc.h     |    6 +++-
 include/mmc.h           |    1 +
 4 files changed, 88 insertions(+), 12 deletions(-)
drivers/mmc/fsl_esdhc.c +61 -11
index c6e9e6e..d9574d0 100644
@@ -37,6 +37,10 @@
 #include <fdt_support.h>
 #include <asm/io.h>
 
+#ifndef CONFIG_PPC
+#define out_be32(a, v)	writel(v, a)
+#define in_be32(a)	__raw_readl(a)
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -129,7 +133,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 	out_be32(&regs->blkattr, data->blocks << 16 | data->blocksize);
 
 	/* Calculate the timeout period for data transactions */
-	timeout = __ilog2(mmc->tran_speed/10);
+	timeout = fls(mmc->tran_speed/10) - 1;
 	timeout -= 13;
 
 	if (timeout > 14)
@@ -236,11 +240,18 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 
 void set_sysctl(struct mmc *mmc, uint clock)
 {
+#ifdef CONFIG_PPC
 	int sdhc_clk = gd->sdhc_clk;
+#else
+	int sdhc_clk = mxc_get_clock(MXC_IPG_PERCLK);
+#endif
 	int div, pre_div;
 	volatile struct fsl_esdhc *regs = mmc->priv;
 	uint clk;
 
+	if (clock < mmc->f_min)
+		clock = mmc->f_min;
+
 	if (sdhc_clk / 16 > clock) {
 		for (pre_div = 2; pre_div < 256; pre_div *= 2)
 			if ((sdhc_clk / pre_div) <= (clock * 16))
@@ -257,11 +268,14 @@ void set_sysctl(struct mmc *mmc, uint clock)
 
 	clk = (pre_div << 8) | (div << 4);
 
+	/* On imx the clock must be stopped before changing frequency */
+	clrbits_be32(&regs->sysctl, SYSCTL_CKEN);
+
 	clrsetbits_be32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
 	udelay(10000);
 
-	setbits_be32(&regs->sysctl, SYSCTL_PEREN);
+	setbits_be32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
 }
 
 static void esdhc_set_ios(struct mmc *mmc)
@@ -278,15 +292,26 @@ static void esdhc_set_ios(struct mmc *mmc)
 		setbits_be32(&regs->proctl, PROCTL_DTW_4);
 	else if (mmc->bus_width == 8)
 		setbits_be32(&regs->proctl, PROCTL_DTW_8);
+
 }
 
 static int esdhc_init(struct mmc *mmc)
 {
 	struct fsl_esdhc *regs = mmc->priv;
 	int timeout = 1000;
+	int ret = 0;
 
+#ifdef CONFIG_PPC
 	/* Enable cache snooping */
 	out_be32(&regs->scr, 0x00000040);
+#endif
+
+	/* Reset the entire host controller */
+	out_be32(&regs->sysctl, SYSCTL_RSTA);
+
+	/* Wait until the controller is available */
+	while ((in_be32(&regs->sysctl) & SYSCTL_RSTA) && --timeout)
+		udelay(1000);
 
 	out_be32(&regs->sysctl, SYSCTL_HCKEN | SYSCTL_IPGEN);
 
@@ -299,24 +324,44 @@ static int esdhc_init(struct mmc *mmc)
 	/* Put the PROCTL reg back to the default */
 	out_be32(&regs->proctl, PROCTL_INIT);
 
-	while (!(in_be32(&regs->prsstat) & PRSSTAT_CINS) && --timeout)
-		udelay(1000);
+	/* Set timout to the maximum value */
+	clrsetbits_be32(&regs->sysctl, SYSCTL_TIMEOUT_MASK, 14 << 16);
 
-	if (timeout <= 0)
-		return NO_CARD_ERR;
+	/* Check if there is a callback for detecting the card */
+	if (!mmc->getcd) {
+		timeout = 1000;
+		while (!(in_be32(&regs->prsstat) & PRSSTAT_CINS) && --timeout)
+			udelay(1000);
 
-	return 0;
+		if (timeout <= 0)
+			ret = NO_CARD_ERR;
+	} else {
+		if (mmc->getcd(mmc))
+			ret = NO_CARD_ERR;
+	}
+
+	return ret;
 }
 
-static int esdhc_initialize(bd_t *bis)
+int fsl_esdhc_initialize(bd_t *bis, uint32_t esdhc_addr,
+			int (*getcd)(struct mmc *mmc))
 {
-	struct fsl_esdhc *regs = (struct fsl_esdhc *)CONFIG_SYS_FSL_ESDHC_ADDR;
+#ifdef CONFIG_PPC
+	int sdhc_clk = gd->sdhc_clk;
+#else
+	int sdhc_clk = mxc_get_clock(MXC_IPG_PERCLK);
+#endif
+	struct fsl_esdhc *regs;
 	struct mmc *mmc;
 	u32 caps;
 
 	mmc = malloc(sizeof(struct mmc));
 
 	sprintf(mmc->name, "FSL_ESDHC");
+	regs = (struct fsl_esdhc *)CONFIG_SYS_FSL_ESDHC_ADDR;
+	if (esdhc_addr)
+		regs = (struct fsl_esdhc *)esdhc_addr;
+
 	mmc->priv = regs;
 	mmc->send_cmd = esdhc_send_cmd;
 	mmc->set_ios = esdhc_set_ios;
@@ -337,7 +382,10 @@ static int esdhc_initialize(bd_t *bis)
 		mmc->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
 	mmc->f_min = 400000;
-	mmc->f_max = MIN(gd->sdhc_clk, 50000000);
+	mmc->f_max = MIN(sdhc_clk, 50000000);
+
+	if (getcd)
+		mmc->getcd = getcd;
 
 	mmc_register(mmc);
 
@@ -346,9 +394,10 @@ static int esdhc_initialize(bd_t *bis)
 
 int fsl_esdhc_mmc_init(bd_t *bis)
 {
-	return esdhc_initialize(bis);
+	return fsl_esdhc_initialize(bis, 0, NULL);
 }
 
+#ifdef CONFIG_PPC
 void fdt_fixup_esdhc(void *blob, bd_t *bd)
 {
 	const char *compat = "fsl,esdhc";
@@ -365,3 +414,4 @@ out:
 	do_fixup_by_compat(blob, compat, "status", status,
 			   strlen(status) + 1, 1);
 }
+#endif
include/asm-arm/io.h +21 -0
index fec3a7e..fb104aa 100644
@@ -33,6 +33,27 @@ static inline void sync(void)
 {
 }
 
+/* Clear and set bits in one shot. These macros can be used to clear and
+ * set multiple bits in a register using a single call. These macros can
+ * also be used to set a multiple-bit bit pattern using a mask, by
+ * specifying the mask in the 'clear' parameter and the new bit pattern
+ * in the 'set' parameter.
+ */
+
+#define clrbits(type, addr, clear) \
+	write##type(__raw_read##type(addr) & ~(clear), (addr))
+
+#define setbits(type, addr, set) \
+	write##type(__raw_read##type(addr) | (set), (addr))
+
+#define clrsetbits(type, addr, clear, set) \
+	write##type((__raw_read##type(addr) & ~(clear)) | (set), (addr))
+
+#define clrbits_be32(addr, clear) clrbits(l, addr, clear)
+#define setbits_be32(addr, set) setbits(l, addr, set)
+#define clrsetbits_be32(addr, clear, set) clrsetbits(l, addr, clear, set)
+
+
 /*
  * Given a physical address and a length, return a virtual address
  * that can be used to access the memory range with the caching
include/fsl_esdhc.h +5 -1
index 89b8304..605e065 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	0x0000ffff
+#define SYSCTL_RSTA		0x01000000
+#define SYSCTL_CKEN		0x00000008
 #define SYSCTL_PEREN		0x00000004
 #define SYSCTL_HCKEN		0x00000002
 #define SYSCTL_IPGEN		0x00000001
@@ -144,6 +146,8 @@
 
 #ifdef CONFIG_FSL_ESDHC
 int fsl_esdhc_mmc_init(bd_t *bis);
+int fsl_esdhc_initialize(bd_t *bis, uint32_t esdhc_addr,
+	int (*getcd)(struct mmc *mmc));
 void fdt_fixup_esdhc(void *blob, bd_t *bd);
 #else
 static inline int fsl_esdhc_mmc_init(bd_t *bis) { return -ENOSYS; }
include/mmc.h +1 -0
index 2dc69ab..bc29953 100644
@@ -264,6 +264,7 @@ struct mmc {
 			struct mmc_cmd *cmd, struct mmc_data *data);
 	void (*set_ios)(struct mmc *mmc);
 	int (*init)(struct mmc *mmc);
+	int (*getcd)(struct mmc *mmc);
 };
 
 int mmc_register(struct mmc *mmc);
Signature · 1 line
1.6.3.3
#8 lore raw

PATCH v2 8/9 mmc: check correctness of the voltage mask in ocr

Most cards do not answer if some reserved bits in the ocr are set. However, some controllers can set bit 7 (reserved for low voltages), but how to manage low voltages SD card is not yet specified.

---
 drivers/mmc/mmc.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/mmc/mmc.c +9 -1
index b69ce15..d91b9b7 100644
@@ -273,7 +273,15 @@ sd_send_op_cond(struct mmc *mmc)
 
 		cmd.cmdidx = SD_CMD_APP_SEND_OP_COND;
 		cmd.resp_type = MMC_RSP_R3;
-		cmd.cmdarg = mmc->voltages;
+
+		/*
+		 * Most cards do not answer if some reserved bits
+		 * in the ocr are set. However, Some controller
+		 * can set bit 7 (reserved for low voltages), but
+		 * how to manage low voltages SD card is not yet
+		 * specified.
+		 */
+		cmd.cmdarg = mmc->voltages & 0xff8000;
 
 		if (mmc->version == SD_VERSION_2)
 			cmd.cmdarg |= OCR_HCS;
Signature · 1 line
1.6.3.3
#9 lore raw

PATCH v2 9/9 Add initial support for Freescale mx51evk board

The patch adds initial support for the Freescale mx51evk board. Network (FEC) and SD controller (fsl_esdhc) are supported.

---
 MAINTAINERS                          |    4 +
 MAKEALL                              |    1 +
 Makefile                             |    8 +
 board/freescale/mx51evk/Makefile     |   48 ++++
 board/freescale/mx51evk/config.mk    |   25 ++
 board/freescale/mx51evk/imximage.cfg |  119 ++++++++++
 board/freescale/mx51evk/mx51evk.c    |  432 ++++++++++++++++++++++++++++++++++
 board/freescale/mx51evk/mx51evk.h    |   51 ++++
 include/configs/mx51evk.h            |  175 ++++++++++++++
 9 files changed, 863 insertions(+), 0 deletions(-)
 create mode 100644 board/freescale/mx51evk/Makefile
 create mode 100644 board/freescale/mx51evk/config.mk
 create mode 100644 board/freescale/mx51evk/imximage.cfg
 create mode 100644 board/freescale/mx51evk/mx51evk.c
 create mode 100644 board/freescale/mx51evk/mx51evk.h
 create mode 100644 include/configs/mx51evk.h
MAINTAINERS +4 -0
index 9734b1d..8637550 100644
@@ -151,6 +151,10 @@ Dave Ellis <[email protected]>
 
 	SXNI855T	MPC8xx
 
+Fred Fan <[email protected]>
+
+	mx51evk		i.MX51
+
 Thomas Frieden <[email protected]>
 
 	AmigaOneG3SE	MPC7xx
MAKEALL +1 -0
index ab1bb6f..485107a 100755
@@ -617,6 +617,7 @@ LIST_ARM11="			\
 #########################################################################
 LIST_ARM_CORTEX_A8="		\
 	devkit8000		\
+	mx51evk			\
 	omap3_beagle		\
 	omap3_overo		\
 	omap3_evm		\
Makefile +8 -0
index ed6156f..01bf9a2 100644
@@ -324,6 +324,10 @@ $(obj)u-boot.img:	$(obj)u-boot.bin
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
 
+$(obj)u-boot.imx:       $(obj)u-boot.bin
+		$(obj)tools/mkimage -n $(IMX_CONFIG) -T imximage \
+		-e $(TEXT_BASE) -d $< $@
+
 $(obj)u-boot.kwb:       $(obj)u-boot.bin
 		$(obj)tools/mkimage -n $(KWD_CONFIG) -T kwbimage \
 		-a $(TEXT_BASE) -e $(TEXT_BASE) -d $< $@
@@ -3263,6 +3267,9 @@ mx31pdk_nand_config	: unconfig
 	fi
 	@$(MKCONFIG) -a mx31pdk arm arm1136 mx31pdk freescale mx31
 
+mx51evk_config	: unconfig
+	@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 mx51evk freescale mx51
+
 omap2420h4_config	: unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm1136 omap2420h4 ti omap24xx
 
@@ -3729,6 +3736,7 @@ clobber:	clean
 		$(obj)cscope.* $(obj)*.*~
 	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
 	@rm -f $(obj)u-boot.kwb
+	@rm -f $(obj)u-boot.imx
 	@rm -f $(obj)tools/{env/crc32.c,inca-swap-bytes}
 	@rm -f $(obj)cpu/mpc824x/bedbug_603e.c
 	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
board/freescale/mx51evk/Makefile new file +48 -0

48 lines not on this page · raw message

board/freescale/mx51evk/config.mk new file +25 -0
new file mode 100644
index 0000000..c8279ec
@@ -0,0 +1,25 @@
+#
+# Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
+#
+# 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
+#
+
+LDSCRIPT = cpu/$(CPU)/$(SOC)/u-boot.lds
+TEXT_BASE = 0x97800000
+IMX_CONFIG = $(SRCTREE)/board/$(BOARDDIR)/imximage.cfg
board/freescale/mx51evk/imximage.cfg new file +119 -0

119 lines not on this page · raw message

board/freescale/mx51evk/mx51evk.c new file +432 -0

432 lines not on this page · raw message

board/freescale/mx51evk/mx51evk.h new file +51 -0

51 lines not on this page · raw message

include/configs/mx51evk.h new file +175 -0

175 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#10 lore raw

PATCH v2 7/9 fsl_esdhc: add support for mx51 processor

In reply to Stefano Babic

Wolfgang has already covered most of this, but I have a few other comments (plus a couple of redundant ones)

Quoted 21 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.

---

?drivers/mmc/fsl_esdhc.c | ? 72 +++++++++++++++++++++++++++++++++++++++-------
?include/asm-arm/io.h ? ?| ? 21 +++++++++++++
?include/fsl_esdhc.h ? ? | ? ?6 +++-
?include/mmc.h ? ? ? ? ? | ? ?1 +

?4 files changed, 88 insertions(+), 12 deletions(-)

drivers/mmc/fsl_esdhc.c +0 -0
index c6e9e6e..d9574d0 100644
@@ -37,6 +37,10 @@

?#include <fdt_support.h>
?#include <asm/io.h>

drivers/mmc/fsl_esdhc.c line 43

Quoted 4 lines
drivers/mmc/fsl_esdhc.c +4 -0
+#ifndef CONFIG_PPC
+#define out_be32(a, v) writel(v, a)
+#define in_be32(a) ? ? __raw_readl(a)
+#endif

I know why you did this, but I really think it's a bad idea to "trick" the driver into doing the right thing. It's more painful, but we need to change all of the out_be32/in_be32 commands into something generic, and then add support for big and little endian accesses. This is just a hack. :(

Quoted 13 lines

?DECLARE_GLOBAL_DATA_PTR;

drivers/mmc/fsl_esdhc.c +0 -0
@@ -129,7 +133,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
 ? ? ? ?out_be32(&regs->blkattr, data->blocks << 16 | data->blocksize);
 

? ? ? ?/* Calculate the timeout period for data transactions */
- ? ? ? timeout = __ilog2(mmc->tran_speed/10);
+ ? ? ? timeout = fls(mmc->tran_speed/10) - 1;
? ? ? ?timeout -= 13;

? ? ? ?if (timeout > 14)

drivers/mmc/fsl_esdhc.c esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) · line 247

Quoted 8 lines
drivers/mmc/fsl_esdhc.c +4 -0
@@ -236,11 +240,18 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 
 ?void set_sysctl(struct mmc *mmc, uint clock)
 ?{
+#ifdef CONFIG_PPC
 ? ? ? ?int sdhc_clk = gd->sdhc_clk;
+#else
+ ? ? ? int sdhc_clk = mxc_get_clock(MXC_IPG_PERCLK);
+#endif

Let's try to use #ifdefs sparingly, and definitely have them trigger on constants that are directly related to the difference. This isn't a PPC/ARM problem. I see you've already agreed to use gd->sdhc_clk, though, so that's good.

Quoted 40 lines
drivers/mmc/fsl_esdhc.c +10 -1
 ? ? ? ?int div, pre_div;
 ? ? ? ?volatile struct fsl_esdhc *regs = mmc->priv;
 ? ? ? ?uint clk;
 
+ ? ? ? if (clock < mmc->f_min)
+ ? ? ? ? ? ? ? clock = mmc->f_min;
+
 ? ? ? ?if (sdhc_clk / 16 > clock) {
 ? ? ? ? ? ? ? ?for (pre_div = 2; pre_div < 256; pre_div *= 2)
 ? ? ? ? ? ? ? ? ? ? ? ?if ((sdhc_clk / pre_div) <= (clock * 16))
@@ -257,11 +268,14 @@ void set_sysctl(struct mmc *mmc, uint clock)
 
 ? ? ? ?clk = (pre_div << 8) | (div << 4);
 
+ ? ? ? /* On imx the clock must be stopped before changing frequency */
+ ? ? ? clrbits_be32(&regs->sysctl, SYSCTL_CKEN);
+
 ? ? ? ?clrsetbits_be32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
 ? ? ? ?udelay(10000);
 
- ? ? ? setbits_be32(&regs->sysctl, SYSCTL_PEREN);
+ ? ? ? setbits_be32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
 ?}
 
 ?static void esdhc_set_ios(struct mmc *mmc)
@@ -278,15 +292,26 @@ static void esdhc_set_ios(struct mmc *mmc)
 ? ? ? ? ? ? ? ?setbits_be32(&regs->proctl, PROCTL_DTW_4);
 ? ? ? ?else if (mmc->bus_width == 8)
 ? ? ? ? ? ? ? ?setbits_be32(&regs->proctl, PROCTL_DTW_8);
+
 ?}
 
 ?static int esdhc_init(struct mmc *mmc)
 ?{
 ? ? ? ?struct fsl_esdhc *regs = mmc->priv;
 ? ? ? ?int timeout = 1000;
+ ? ? ? int ret = 0;
 
+#ifdef CONFIG_PPC
Quoted 3 lines

? ? ? ?/* Enable cache snooping */
? ? ? ?out_be32(&regs->scr, 0x00000040); +#endif

You have two choices, here. Either create a new CONFIG_SYS option that declares the existence of this register for platforms that have it, OR (my preference) design a configuration mechanism which allows board/cpu code to declare such things. Ideally, the driver could detect this based on a version register, but I'm well aware that FSL's hardware designers frequently forget to increment their version numbers for such "small" changes. What is certain is that CONFIG_PPC is wrong.

Quoted 54 lines
drivers/mmc/fsl_esdhc.c +7 -0
+
+ ? ? ? /* Reset the entire host controller */
+ ? ? ? out_be32(&regs->sysctl, SYSCTL_RSTA);
+
+ ? ? ? /* Wait until the controller is available */
+ ? ? ? while ((in_be32(&regs->sysctl) & SYSCTL_RSTA) && --timeout)
+ ? ? ? ? ? ? ? udelay(1000);

? ? ? ?out_be32(&regs->sysctl, SYSCTL_HCKEN | SYSCTL_IPGEN);

drivers/mmc/fsl_esdhc.c +0 -0
@@ -299,24 +324,44 @@ static int esdhc_init(struct mmc *mmc)

? ? ? ?/* Put the PROCTL reg back to the default */ ? ? ? ?out_be32(&regs->proctl, PROCTL_INIT);

- ? ? ? while (!(in_be32(&regs->prsstat) & PRSSTAT_CINS) && --timeout)
- ? ? ? ? ? ? ? udelay(1000);
+ ? ? ? /* Set timout to the maximum value */
+ ? ? ? clrsetbits_be32(&regs->sysctl, SYSCTL_TIMEOUT_MASK, 14 << 16);

- ? ? ? if (timeout <= 0)
- ? ? ? ? ? ? ? return NO_CARD_ERR;
+ ? ? ? /* Check if there is a callback for detecting the card */
+ ? ? ? if (!mmc->getcd) {
+ ? ? ? ? ? ? ? timeout = 1000;
+ ? ? ? ? ? ? ? while (!(in_be32(&regs->prsstat) & PRSSTAT_CINS) && --timeout)
+ ? ? ? ? ? ? ? ? ? ? ? udelay(1000);

- ? ? ? return 0;
+ ? ? ? ? ? ? ? if (timeout <= 0)
+ ? ? ? ? ? ? ? ? ? ? ? ret = NO_CARD_ERR;
+ ? ? ? } else {
+ ? ? ? ? ? ? ? if (mmc->getcd(mmc))
+ ? ? ? ? ? ? ? ? ? ? ? ret = NO_CARD_ERR;
+ ? ? ? }
+
+ ? ? ? return ret;
?}

drivers/mmc/fsl_esdhc.c +2 -1
-static int esdhc_initialize(bd_t *bis)
+int fsl_esdhc_initialize(bd_t *bis, uint32_t esdhc_addr,
+ ? ? ? ? ? ? ? ? ? ? ? int (*getcd)(struct mmc *mmc))

?{
- ? ? ? struct fsl_esdhc *regs = (struct fsl_esdhc *)CONFIG_SYS_FSL_ESDHC_ADDR;

drivers/mmc/fsl_esdhc.c +6 -0
+#ifdef CONFIG_PPC
+ ? ? ? int sdhc_clk = gd->sdhc_clk;
+#else
+ ? ? ? int sdhc_clk = mxc_get_clock(MXC_IPG_PERCLK);
+#endif
+ ? ? ? struct fsl_esdhc *regs;

? ? ? ?struct mmc *mmc;
? ? ? ?u32 caps;

Quoted 7 lines

? ? ? ?mmc = malloc(sizeof(struct mmc));

? ? ? ?sprintf(mmc->name, "FSL_ESDHC");
+ ? ? ? regs = (struct fsl_esdhc *)CONFIG_SYS_FSL_ESDHC_ADDR;
+ ? ? ? if (esdhc_addr)
+ ? ? ? ? ? ? ? regs = (struct fsl_esdhc *)esdhc_addr; +

I agree with Wolfgang, here. Also, it's a bit iffy to set it, then optionally overwrite it.

drivers/mmc/fsl_esdhc.c static int esdhc_initialize(bd_t *bis) · line 388

Quoted 12 lines

? ? ? ?mmc->priv = regs;
? ? ? ?mmc->send_cmd = esdhc_send_cmd;
? ? ? ?mmc->set_ios = esdhc_set_ios;

drivers/mmc/fsl_esdhc.c +4 -1
@@ -337,7 +382,10 @@ static int esdhc_initialize(bd_t *bis)
 ? ? ? ? ? ? ? ?mmc->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
 ? ? ? ?mmc->f_min = 400000;
- ? ? ? mmc->f_max = MIN(gd->sdhc_clk, 50000000);
+ ? ? ? mmc->f_max = MIN(sdhc_clk, 50000000);
+
+ ? ? ? if (getcd)
+ ? ? ? ? ? ? ? mmc->getcd = getcd;

I don't fundamentally object to this change, but I have more comments on it later.

Quoted 16 lines
drivers/mmc/fsl_esdhc.c +2 -1
 ? ? ? ?mmc_register(mmc);
 
@@ -346,9 +394,10 @@ static int esdhc_initialize(bd_t *bis)
 
 ?int fsl_esdhc_mmc_init(bd_t *bis)
 ?{
- ? ? ? return esdhc_initialize(bis);
+ ? ? ? return fsl_esdhc_initialize(bis, 0, NULL);
 ?}
 
+#ifdef CONFIG_PPC
 ?void fdt_fixup_esdhc(void *blob, bd_t *bd)
 ?{
 ? ? ? ?const char *compat = "fsl,esdhc";

drivers/mmc/fsl_esdhc.c out: · line 417

Quoted 4 lines
drivers/mmc/fsl_esdhc.c +1 -0
@@ -365,3 +414,4 @@ out:
 ? ? ? ?do_fixup_by_compat(blob, compat, "status", status,
 ? ? ? ? ? ? ? ? ? ? ? ? ? strlen(status) + 1, 1);
 ?}
+#endif

Use the OF config option, here.

Quoted 19 lines
include/asm-arm/io.h +11 -0
index fec3a7e..fb104aa 100644
@@ -33,6 +33,27 @@ static inline void sync(void)
 ?{
 ?}
 
+/* Clear and set bits in one shot. These macros can be used to clear and
+ * set multiple bits in a register using a single call. These macros can
+ * also be used to set a multiple-bit bit pattern using a mask, by
+ * specifying the mask in the 'clear' parameter and the new bit pattern
+ * in the 'set' parameter.
+ */
+
+#define clrbits(type, addr, clear) \
+ ? ? ? write##type(__raw_read##type(addr) & ~(clear), (addr))
+
+#define setbits(type, addr, set) \

include/asm-arm/io.h static inline void sync(void) · line 56

Quoted 10 lines
include/asm-arm/io.h +10 -0
+ ? ? ? write##type(__raw_read##type(addr) | (set), (addr))
+
+#define clrsetbits(type, addr, clear, set) \
+ ? ? ? write##type((__raw_read##type(addr) & ~(clear)) | (set), (addr))
+
+#define clrbits_be32(addr, clear) clrbits(l, addr, clear)
+#define setbits_be32(addr, set) setbits(l, addr, set)
+#define clrsetbits_be32(addr, clear, set) clrsetbits(l, addr, clear, set)
+
+

This should be part of a completely different patch. Also, I'm positive that it's completely wrong. setbits_be32 is big endian, writel is little endian.

Quoted 20 lines

?/*
?* Given a physical address and a length, return a virtual address ?* that can be used to access the memory range with the caching

include/fsl_esdhc.h +0 -0
index 89b8304..605e065 100644
@@ -32,7 +32,9 @@

?#define SYSCTL ? ? ? ? ? ? ? ? 0x0002e02c ?#define SYSCTL_INITA ? ? ? ? ? 0x08000000 ?#define SYSCTL_TIMEOUT_MASK ? ?0x000f0000

include/fsl_esdhc.h +3 -1
-#define SYSCTL_CLOCK_MASK ? ? ?0x00000fff
+#define SYSCTL_CLOCK_MASK ? ? ?0x0000ffff
+#define SYSCTL_RSTA ? ? ? ? ? ?0x01000000
+#define SYSCTL_CKEN ? ? ? ? ? ?0x00000008

?#define SYSCTL_PEREN ? ? ? ? ? 0x00000004 ?#define SYSCTL_HCKEN ? ? ? ? ? 0x00000002 ?#define SYSCTL_IPGEN ? ? ? ? ? 0x00000001

include/fsl_esdhc.h +0 -0
@@ -144,6 +146,8 @@
 
Quoted 4 lines

?#ifdef CONFIG_FSL_ESDHC
?int fsl_esdhc_mmc_init(bd_t *bis);
+int fsl_esdhc_initialize(bd_t *bis, uint32_t esdhc_addr,
+ ? ? ? int (*getcd)(struct mmc *mmc));

Hmmm....this doesn't scale well. Rather than pass in an address and a function pointer, create a structure with that information, and then pass *that* in. That way, when we discover we want some other information/functions, we can add them without having to modify the API.

Also, I'm not entirely sold on the idea that getcd should be a function pointer. It might be more appropriate as a weakly defined function that a board can choose to implement.

Quoted 8 lines

?void fdt_fixup_esdhc(void *blob, bd_t *bd);
?#else
?static inline int fsl_esdhc_mmc_init(bd_t *bis) { return -ENOSYS; }

include/mmc.h +0 -0
index 2dc69ab..bc29953 100644

include/mmc.h struct mmc { · line 270

Quoted 7 lines
include/mmc.h +1 -0
@@ -264,6 +264,7 @@ struct mmc {
 ? ? ? ? ? ? ? ? ? ? ? ?struct mmc_cmd *cmd, struct mmc_data *data);
 ? ? ? ?void (*set_ios)(struct mmc *mmc);
 ? ? ? ?int (*init)(struct mmc *mmc);
+ ? ? ? int (*getcd)(struct mmc *mmc);
 ?};
 
 ?int mmc_register(struct mmc *mmc);

I think getcd needs more discussion, but even if it doesn't, this clearly belongs in a separate patch. You are modifying the U-Boot MMC API, here, not just the fsl_esdhc driver.

Andy

#11 lore raw

PATCH v2 7/9 fsl_esdhc: add support for mx51 processor

Quoted 2 lines · Andy Fleming

Wolfgang has already covered most of this, but I have a few other comments (plus a couple of redundant ones)

Hi Andy,

Quoted 2 lines

I know why you did this, but I really think it's a bad idea to "trick" the driver into doing the right thing.

I agree, I wanted only to point out why I need to do this ;)

Quoted 4 lines

It's more painful, but we need
to change all of the out_be32/in_be32 commands into something generic, and then add support for big and little endian accesses. This is just a hack. :(

Ok, let's see if I have really understood and I can proceed with the modifications. I start to change the driver replacing all _be32 functions with a more neutral name (write_register/read_register or something like that). I will define these functions then in asm-ppc/io.h and asm-arm/io.h, setting them to the desired function.

Quoted 4 lines

Let's try to use #ifdefs sparingly, and definitely have them trigger on constants that are directly related to the difference. This isn't a PPC/ARM problem. I see you've already agreed to use gd->sdhc_clk, though, so that's good.

I agree, using global data is a good idea.

Quoted 3 lines

You have two choices, here. Either create a new CONFIG_SYS option that declares the existence of this register for platforms that have it,

In this case we will probably get a lot of CONFIG_SYS options when Freescale changes version or uses this controller on other processors. There are some different registers, not only for snooping. In most cases, some further bits are added. At least I need to know if the SDCLK_EN bit is present in the control register (present in the MX.51 implementation, absent in PowerQuick).

Quoted 2 lines

OR (my preference) design a configuration mechanism which allows board/cpu code to declare such things.

I agree with you. I have already changed the initialization procedure and I can pass (as you suggest later) a configuration structure that describe the feature of the controller. The board can set this structure in board_mmc_init(). If it is not set, the driver should work as now (powerpc), so the structure must be filled only by arm boards.

Quoted 4 lines

Ideally, the driver could
detect this based on a version register, but I'm well aware that FSL's hardware designers frequently forget to increment their version numbers for such "small" changes.

I know, the version register is not reliable enough...

Quoted 2 lines

What is certain is that CONFIG_PPC
is wrong.

Absolutely agree, I get rid of it.

Quoted 8 lines

drivers/mmc/fsl_esdhc.c out: · line 417

Quoted 6 lines
       const char *compat = "fsl,esdhc";
drivers/mmc/fsl_esdhc.c +1 -0
@@ -365,3 +414,4 @@ out:
       do_fixup_by_compat(blob, compat, "status", status,
                          strlen(status) + 1, 1);
 }
+#endif

Use the OF config option, here.

Ok, thanks.

Quoted 9 lines

include/asm-arm/io.h static inline void sync(void) · line 56

Quoted 5 lines
include/asm-arm/io.h +5 -0
+#define clrbits_be32(addr, clear) clrbits(l, addr, clear)
+#define setbits_be32(addr, set) setbits(l, addr, set)
+#define clrsetbits_be32(addr, clear, set) clrsetbits(l, addr, clear, set)
+
+

This should be part of a completely different patch. Also, I'm positive that it's completely wrong. setbits_be32 is big endian, writel is little endian.

Agree. I will set a separate patch to setup the newer functions to access the registers.

Quoted 11 lines

include/fsl_esdhc.h line 150

Quoted 4 lines

#ifdef CONFIG_FSL_ESDHC
int fsl_esdhc_mmc_init(bd_t *bis);

include/fsl_esdhc.h +2 -0
+int fsl_esdhc_initialize(bd_t *bis, uint32_t esdhc_addr,
+       int (*getcd)(struct mmc *mmc));

Hmmm....this doesn't scale well. Rather than pass in an address and a function pointer, create a structure with that information, and then pass *that* in. That way, when we discover we want some other information/functions, we can add them without having to modify the API.

You are right. I will create a structure that I can use to describe the feature of the controller, as you already suggested.

Quoted 3 lines

I think getcd needs more discussion, but even if it doesn't, this clearly belongs in a separate patch. You are modifying the U-Boot MMC API, here, not just the fsl_esdhc driver.

Probably I do not need anymore. I can implement as you suggest a weakly defined function, something like:

int board_mmc_getcd(u8 *cd, struct mmc *mmc)__attribute__((weak, alias("__board_mmc_getcd")))

If this failed, I can use the internal bits of the controller to check the presence of the card.

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
=====================================================================
#12 lore raw

PATCH v2 1/9 mkimage: Add Freescale imx Boot Image support (imximage)

In reply to Stefano Babic

Hi Stefano,

Quoted 9 lines · Stefano Babic

From: Stefano Babic <[email protected]>
Subject: [U-Boot] [PATCH V2 1/9] mkimage: Add Freescale imx Boot Image support (imximage)
To: u-boot at lists.denx.de
Date: Wednesday, January 13, 2010, 7:50 AM
This patch adds support for
"imximage" (MX Boot Image)
to the mkimage utility. The imximage is used on the
Freescales's
MX.51 processors.

I like the way you handle the internal boot on the MX51. Very smart approach ;-)

MX25 and MX35 can also benefit from the imximage utility that you proposed, so please change the description to make it more generic, such as:

"The imximage can be used on MX25, MX35 and MX51 processors for handling internal boot mode."

....

doc/README.imximage line 6

Quoted 6 lines

+---------------------------------------------

doc/README.imximage new file +5 -0
+Imximage Boot Image generation using mkimage
+---------------------------------------------
+
+This document describes how to set up a U-Boot image
+that can be booted by the Freescale i.MX51 processor.

You could write: "... that can be booted by Freescale MX25, MX35 and MX51 processors via internal boot mode"

...

Quoted 2 lines

+#define MAX_HW_CFG_SIZE 60??? /* Max number
of registers imx.51 can set */

MX25, MX35, MX51 can set

...

Quoted 2 lines

+??? /* Init Freescale imx.51 Boot image
generation/list support */

MX25, MX35 and MX51 Boot image ...

Regards,

Fabio Estevam

#13 lore raw

PATCH v2 1/9 mkimage: Add Freescale imx Boot Image support (imximage)

Quoted 2 lines · Fabio Estevam

Hi Stefano,

Hi Fabio,

Quoted 4 lines

I like the way you handle the internal boot on the MX51. Very smart approach ;-)

Thanks !

Quoted 6 lines

MX25 and MX35 can also benefit from the imximage utility that you proposed, so please change the description to make it more generic, such as:

"The imximage can be used on MX25, MX35 and MX51 processors for handling internal boot mode."

Understood. I will change this point. I will add to the description a short "how to" to set up a SD card with an IMX image for booting, too.

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
=====================================================================
#14 lore raw

PATCH v2 1/9 mkimage: Add Freescale imx Boot Image support (imximage)

In reply to Stefano Babic

Hi Stefano,

--- On Wed, 1/13/10, Stefano Babic <[email protected]> wrote:

...

Quoted 4 lines

+2. Following are the valid command strings and associated data strings:-
+??? Command string???
??? data string

I think that the BOOT_FROM command can be removed, right?

We can flash the same binary on a SD or NAND flash.

Regards,

Fabio Estevam

Quoted 10 lines

+??? --------------???
??? -----------
+??? BOOT_FROM???
??? nand/spi/sd/onenand
+??? ??? ???
??? Example:
+??? ??? ???
??? BOOT_FROM spi
+??? DATA???
??? ??? type address value

I think that the BOOT_FROM command is not needed.

We can flash the same binary on an SD or NAND flash.

The boot pins configure the media boot type.

Regards,

Fabio Estevam

#15 lore raw

PATCH v2 1/9 mkimage: Add Freescale imx Boot Image support (imximage)

Quoting Fabio Estevam <[email protected]>:

Quoted 2 lines

Hi Stefano,

Hi Fabio,

Quoted 1 line

I think that the BOOT_FROM command can be removed, right?

No, we can't if the processor boots from OneNand device. According to the manual,
the offset must be set to 0x100 instead of 0x400.

Quoted 2 lines

We can flash the same binary on a SD or NAND flash.

Correct,but there is still the OneNand case.

Stefano

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

#16 lore raw

PATCH v2 1/9 mkimage: Add Freescale imx Boot Image support (imximage)

Hi Stefano,

...

Quoted 6 lines
Quoted 1 line

I think that the BOOT_FROM command can be removed,

right?

No, we can't if the processor boots from OneNand device. According to?
the manual,

Yes, it is still the same binary, but just needs a different offset.

Quoted 6 lines

? the offset must be set to 0x100 instead of 0x400.

Quoted 2 lines

We can flash the same binary on a SD or NAND flash.

Correct,but there is still the OneNand case.

BTW, I don't see the following offset defines used anywhere in the code:

+#define FLASH_OFFSET_STANDARD 0x400
+#define FLASH_OFFSET_NAND FLASH_OFFSET_STANDARD
+#define FLASH_OFFSET_SD FLASH_OFFSET_STANDARD
+#define FLASH_OFFSET_SPI FLASH_OFFSET_STANDARD
+#define FLASH_OFFSET_ONENAND 0x100

Regards,

Fabio Estevam

#17 lore raw

PATCH v2 1/9 mkimage: Add Freescale imx Boot Image support (imximage)

Quoted 2 lines · Fabio Estevam

Hi Stefano,

Hi Fabio,

Quoted 2 lines

Yes, it is still the same binary, but just needs a different offset.

This is not what I have understood from the manual. In the chapter regarding the flash header ("Flash header structure", figure 2.9), there is the field "app_dest_ptr". This pointer must be set to the start address of the flash/storage media. This means we have different binaries due only to the value of this field. To set this field we need to know the media where the system boots.

tools/imximage.h line 39

Quoted 7 lines

BTW, I don't see the following offset defines used anywhere in the code:

tools/imximage.h new file +5 -0
+#define FLASH_OFFSET_STANDARD    0x400
+#define FLASH_OFFSET_NAND    FLASH_OFFSET_STANDARD
+#define FLASH_OFFSET_SD        FLASH_OFFSET_STANDARD
+#define FLASH_OFFSET_SPI    FLASH_OFFSET_STANDARD
+#define FLASH_OFFSET_ONENAND    0x100

They are used in the imximage_bootops structure in imximage.c. This field is later used to set the app_dest_ptr field:

239 fhdr->app_dest_ptr = params->ep - hdr->flash_offset -
240 sizeof(struct imx_header);

Regards,
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
=====================================================================
#18 lore raw

PATCH v2 1/9 mkimage: Add Freescale imx Boot Image support (imximage)

In reply to Stefano Babic

Dear Stefano Babic,

Quoted 7 lines · In message <[email protected]> you wrote:

This patch adds support for "imximage" (MX Boot Image) to the mkimage utility. The imximage is used on the Freescales's MX.51 processors.

Further details under doc/README.imximage.

This patch was tested on a Freescale mx51evk board.

...

Quoted 13 lines
tools/Makefile +1 -0
index 5b8c3c3..afc1d44 100644
@@ -73,6 +73,7 @@ OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
 OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
 NOPED_OBJ_FILES-y += kwbimage.o
+NOPED_OBJ_FILES-y += imximage.o
 NOPED_OBJ_FILES-y += mkimage.o
 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
 NOPED_OBJ_FILES-y += os_support.o

tools/Makefile $(obj)mkimage$(SFX): $(obj)crc32.o \ · line 166

Quoted 7 lines
tools/Makefile +1 -0
@@ -159,6 +160,7 @@ $(obj)mkimage$(SFX):	$(obj)crc32.o \
 			$(obj)fit_image.o \
 			$(obj)image.o \
 			$(obj)kwbimage.o \
+			$(obj)imximage.o \
 			$(obj)md5.o \
 			$(obj)mkimage.o \
 			$(obj)os_support.o \

Please keep lists sorted.

tools/Makefile

Quoted 5 lines
tools/Makefile +5 -0
+			case CFG_COMMAND:
+				cmd = get_table_entry_id(imximage_cmds,
+					"imximage commands", token);
+				if (cmd < 0) {
+					fprintf(stderr, "Error: %s[%d] - Invalid command (%s)\n",

Line to long. And please try to stick with a consistent error message format.

tools/Makefile

Quoted 5 lines
tools/Makefile +5 -0
+			case CFG_REG_SIZE:
+				switch (cmd) {
+				case CMD_BOOT_FROM:
+					/* Get flash header offset */
+					imxhdr->flash_offset = get_table_entry_id(imximage_bootops,

Ditto, and so on. Please fix globally.

Quoted 4 lines
tools/Makefile +4 -0
+int imximage_check_params(struct mkimage_params *params)
+{
+	if (!params)
+		return CFG_INVALID;

tools/Makefile

Quoted 10 lines
tools/Makefile +10 -0
+	if (!strlen(params->imagename)) {
+		fprintf(stderr, "Error:%s - Configuration file not specified, "
+			"it is needed for imximage generation\n",
+			params->cmdname);
+		return CFG_INVALID;
+	}
+	return	(params->dflag && (params->fflag || params->lflag)) ||
+		(params->fflag && (params->dflag || params->lflag)) ||
+		(params->lflag && (params->dflag || params->fflag)) ||
+		(params->xflag) || !(strlen(params->imagename));

I cannot understand this code.

tools/Makefile

Quoted 10 lines
tools/Makefile +10 -0
+static struct image_type_params imximage_params = {
+	.name = "Freescale i.MX 51 Boot Image support",
+	.header_size = sizeof(struct imx_header),
+	.hdr = (void *)&imximage_header,
+	.check_image_type = imximage_check_image_types,
+	.verify_header = imximage_verify_header,
+	.print_header = imximage_print_header,
+	.set_header = imximage_set_header,
+	.check_params = imximage_check_params,
+};

How about using TABs to make this easier to read, say:

static struct image_type_params imximage_params = {
.name = "Freescale i.MX 51 Boot Image support",
.header_size = sizeof(struct imx_header),
.hdr = (void *)&imximage_header,
.check_image_type = imximage_check_image_types,
.verify_header = imximage_verify_header,
.print_header = imximage_print_header,
.set_header = imximage_set_header,
.check_params = imximage_check_params,
};

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Brontosaurus Principle: Organizations  can  grow  faster  than  their
brains  can manage them in relation to their environment and to their
own physiology: when this occurs, they are an endangered species.
                                                - Thomas K. Connellan
#19 lore raw

PATCH v2 1/9 mkimage: Add Freescale imx Boot Image support (imximage)

Quoted 2 lines · Wolfgang Denk

Dear Stefano Babic,

Hi Wolfgang,

Quoted 3 lines

Line to long. And please try to stick with a consistent error message format.

I see I have too long lines in all patches I have sent. I check this issue for all of them.

Quoted 6 lines

tools/imximage.c line 273

Quoted 4 lines
tools/imximage.c new file +4 -0
+	return	(params->dflag && (params->fflag || params->lflag)) ||
+		(params->fflag && (params->dflag || params->lflag)) ||
+		(params->lflag && (params->dflag || params->fflag)) ||
+		(params->xflag) || !(strlen(params->imagename));

I cannot understand this code.

Well, I will try to simplify this check and, if not possible, I add comments to explain what the code is doing.

Best regards,
Stefano Babic

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