Skip to contentSkip to conversation

Eliminate support for using MMC as memory

PATCH New Andy Fleming 2 participants 9 messages Jan 30, 2009 – Jan 31, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/8 Eliminate support for using MMC as memory

MMC cards are not memory, so we stop treating them that way.

---
 common/cmd_mem.c          |   43 -------------------------------------------
 cpu/arm720t/lpc2292/mmc.c |   26 --------------------------
 cpu/pxa/mmc.c             |   14 --------------
 drivers/mmc/atmel_mci.c   |   15 ---------------
 include/mmc.h             |    1 -
 5 files changed, 0 insertions(+), 99 deletions(-)
common/cmd_mem.c +0 -43
index a203e0d..2d4fc2a 100644
@@ -29,9 +29,6 @@
 
 #include <common.h>
 #include <command.h>
-#if defined(CONFIG_CMD_MMC)
-#include <mmc.h>
-#endif
 #ifdef CONFIG_HAS_DATAFLASH
 #include <dataflash.h>
 #endif
@@ -404,46 +401,6 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	}
 #endif
 
-#if defined(CONFIG_CMD_MMC)
-	if (mmc2info(dest)) {
-		int rc;
-
-		puts ("Copy to MMC... ");
-		switch (rc = mmc_write ((uchar *)addr, dest, count*size)) {
-		case 0:
-			putc ('\n');
-			return 1;
-		case -1:
-			puts ("failed\n");
-			return 1;
-		default:
-			printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
-			return 1;
-		}
-		puts ("done\n");
-		return 0;
-	}
-
-	if (mmc2info(addr)) {
-		int rc;
-
-		puts ("Copy from MMC... ");
-		switch (rc = mmc_read (addr, (uchar *)dest, count*size)) {
-		case 0:
-			putc ('\n');
-			return 1;
-		case -1:
-			puts ("failed\n");
-			return 1;
-		default:
-			printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
-			return 1;
-		}
-		puts ("done\n");
-		return 0;
-	}
-#endif
-
 #ifdef CONFIG_HAS_DATAFLASH
 	/* Check if we are copying from RAM or Flash to DataFlash */
 	if (addr_dataflash(dest) && !addr_dataflash(addr)){
cpu/arm720t/lpc2292/mmc.c +0 -26
index fd7f149..792a884 100644
@@ -128,30 +128,4 @@ int mmc_init(int verbose)
 	return ret;
 }
 
-int mmc_write(uchar * src, ulong dst, int size)
-{
-#ifdef MMC_DEBUG
-	printf("mmc_write: src=%p, dst=%lu, size=%u\n", src, dst, size);
-#endif
-	/* Since mmc2info always returns 0 this function will never be called */
-	return 0;
-}
-
-int mmc_read(ulong src, uchar * dst, int size)
-{
-#ifdef MMC_DEBUG
-	printf("mmc_read: src=%lu, dst=%p, size=%u\n", src, dst, size);
-#endif
-	/* Since mmc2info always returns 0 this function will never be called */
-	return 0;
-}
-
-int mmc2info(ulong addr)
-{
-	/* This function is used by cmd_cp to determine if source or destination
-	 address resides on MMC-card or not. We do not support copy to and from
-	 MMC-card so we always return 0. */
-	return 0;
-}
-
 #endif /* CONFIG_MMC */
cpu/pxa/mmc.c +0 -14
index d735c8d..1f0d488 100644
@@ -645,18 +645,4 @@ mmc_init(int verbose)
 	return rc;
 }
 
-int mmc_ident(block_dev_desc_t * dev)
-{
-	return 0;
-}
-
-int mmc2info(ulong addr)
-{
-	if (addr >= CONFIG_SYS_MMC_BASE
-	    && addr < CONFIG_SYS_MMC_BASE + (mmc_dev.lba * mmc_dev.blksz)) {
-		return 1;
-	}
-	return 0;
-}
-
 #endif /* CONFIG_MMC */
drivers/mmc/atmel_mci.c +0 -15
index 3aa92f2..4028256 100644
@@ -531,18 +531,3 @@ int mmc_init(int verbose)
 
 	return 0;
 }
-
-int mmc_read(ulong src, uchar *dst, int size)
-{
-	return -ENOSYS;
-}
-
-int mmc_write(uchar *src, ulong dst, int size)
-{
-	return -ENOSYS;
-}
-
-int mmc2info(ulong addr)
-{
-	return 0;
-}
include/mmc.h +0 -1
index 19c76fe..26b9553 100644
@@ -52,6 +52,5 @@
 int mmc_init(int verbose);
 int mmc_read(ulong src, uchar *dst, int size);
 int mmc_write(uchar *src, ulong dst, int size);
-int mmc2info(ulong addr);
 
 #endif /* _MMC_H_ */
Signature · 1 line
1.5.4.GIT
#1 lore raw

PATCH 2/8 Convert mmc_init to mmc_legacy_init

This is to get it out of the way of incoming MMC framework

---
 common/cmd_mmc.c          |    2 +-
 cpu/arm720t/lpc2292/mmc.c |    4 ++--
 cpu/pxa/mmc.c             |    2 +-
 drivers/mmc/atmel_mci.c   |    2 +-
 include/mmc.h             |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)
common/cmd_mmc.c +1 -1
index 473825e..75a75e5 100644
@@ -27,7 +27,7 @@
 
 int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-	if (mmc_init (1) != 0) {
+	if (mmc_legacy_init (1) != 0) {
 		printf ("No MMC card found\n");
 		return 1;
 	}
cpu/arm720t/lpc2292/mmc.c +2 -2
index 792a884..beaffe9 100644
@@ -93,12 +93,12 @@ static int mmc_hw_get_parameters(void)
 	return 0;
 }
 
-int mmc_init(int verbose)
+int mmc_legacy_init(int verbose)
 {
 	int ret = -ENODEV;
 
 	if (verbose)
-		printf("mmc_init\n");
+		printf("mmc_legacy_init\n");
 
 	spi_init();
 	/* this meeds to be done twice */
cpu/pxa/mmc.c +1 -1
index 1f0d488..7199e89 100644
@@ -543,7 +543,7 @@ static void mmc_decode_csd(uint32_t * resp)
 
 int
 /****************************************************/
-mmc_init(int verbose)
+mmc_legacy_init(int verbose)
 /****************************************************/
 {
 	int retries, rc = -ENODEV;
drivers/mmc/atmel_mci.c +1 -1
index 4028256..3946ffe 100644
@@ -463,7 +463,7 @@ static void mci_set_data_timeout(struct mmc_csd *csd)
 	       dtocyc << shift, dtor);
 }
 
-int mmc_init(int verbose)
+int mmc_legacy_init(int verbose)
 {
 	struct mmc_cid cid;
 	struct mmc_csd csd;
include/mmc.h +1 -1
index 26b9553..47cc053 100644
@@ -49,7 +49,7 @@
 #define SD_CMD_APP_SET_BUS_WIDTH	6
 #define SD_CMD_APP_SEND_OP_COND		41
 
-int mmc_init(int verbose);
+int mmc_legacy_init(int verbose);
 int mmc_read(ulong src, uchar *dst, int size);
 int mmc_write(uchar *src, ulong dst, int size);
 
Signature · 1 line
1.5.4.GIT
#2 lore raw

PATCH 3/8 Eliminated arch-specific mmc header requirement

The current MMC infrastructure relies on the existence of an arch-specific header file. This isn't necessary, and a couple drivers were forced to implement dummy files to meet this requirement. Instead, we move the stuff in those header files into a more appropriate place, and eliminate the stubs and the #include of asm/arch/mmc.h

---
 cpu/pxa/mmc.c                           |    2 +
 cpu/pxa/mmc.h                           |  189 +++++++++++++++++++++++++++++++
 include/asm-arm/arch-lpc2292/mmc.h      |   22 ----
 include/asm-arm/arch-pxa/mmc.h          |  189 -------------------------------
 include/asm-avr32/arch-at32ap700x/mmc.h |   77 -------------
 include/mmc.h                           |   53 +++++++++-
 6 files changed, 243 insertions(+), 289 deletions(-)
 create mode 100644 cpu/pxa/mmc.h
 delete mode 100644 include/asm-arm/arch-lpc2292/mmc.h
 delete mode 100644 include/asm-arm/arch-pxa/mmc.h
 delete mode 100644 include/asm-avr32/arch-at32ap700x/mmc.h
cpu/pxa/mmc.c +2 -0
index 7199e89..8f5277e 100644
@@ -28,6 +28,8 @@
 #include <asm/arch/hardware.h>
 #include <part.h>
 
+#include "mmc.h"
+
 #ifdef CONFIG_MMC
 
 extern int fat_register_device(block_dev_desc_t * dev_desc, int part_no);
cpu/pxa/mmc.h new file +189 -0

189 lines not on this page · raw message

include/asm-arm/arch-lpc2292/mmc.h deleted +0 -22
deleted file mode 100644
index e664a5f..0000000
@@ -1,22 +0,0 @@
-/*
- * A dummy header file for use with the LPC2292 port to keep the
- * compiler happy.
- *
- * 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 _MMC_ARM_TDM_H_
-#define _MMC_ARM_TDM_H_
-#endif /* _MMC_ARM_TDM_H_ */
include/asm-arm/arch-pxa/mmc.h deleted +0 -189

189 lines not on this page · raw message

include/asm-avr32/arch-at32ap700x/mmc.h deleted +0 -77

77 lines not on this page · raw message

include/mmc.h +52 -1

67 lines not on this page · raw message

Signature · 1 line
1.5.4.GIT
#3 lore raw

PATCH 4/8 Reduce the scope of PXA's mmc_read/mmc_write/mmc_bread functions

These names are being taken over by the new MMC framework. Hopefuly the PXA can be easily ported, and these functions will go away entirely.

---
 cpu/pxa/mmc.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
cpu/pxa/mmc.c +4 -4
index 8f5277e..de77c12 100644
@@ -218,7 +218,7 @@ mmc_block_write(ulong dst, uchar * src, int len)
 
 int
 /****************************************************/
-mmc_read(ulong src, uchar * dst, int size)
+pxa_mmc_read(long src, uchar * dst, int size)
 /****************************************************/
 {
 	ulong end, part_start, part_end, part_len, aligned_start, aligned_end;
@@ -294,7 +294,7 @@ mmc_read(ulong src, uchar * dst, int size)
 
 int
 /****************************************************/
-mmc_write(uchar * src, ulong dst, int size)
+pxa_mmc_write(uchar * src, ulong dst, int size)
 /****************************************************/
 {
 	ulong end, part_start, part_end, part_len, aligned_start, aligned_end;
@@ -375,7 +375,7 @@ mmc_write(uchar * src, ulong dst, int size)
 	return 0;
 }
 
-ulong
+static ulong
 /****************************************************/
 mmc_bread(int dev_num, ulong blknr, lbaint_t blkcnt, void *dst)
 /****************************************************/
@@ -383,7 +383,7 @@ mmc_bread(int dev_num, ulong blknr, lbaint_t blkcnt, void *dst)
 	int mmc_block_size = MMC_BLOCK_SIZE;
 	ulong src = blknr * mmc_block_size + CONFIG_SYS_MMC_BASE;
 
-	mmc_read(src, (uchar *) dst, blkcnt * mmc_block_size);
+	pxa_mmc_read(src, (uchar *) dst, blkcnt * mmc_block_size);
 	return blkcnt;
 }
 
Signature · 1 line
1.5.4.GIT
#4 lore raw

PATCH 5/8 Add MMC Framework

Here's a new framework (based roughly off the linux one) for managing MMC controllers. It handles all of the standard SD/MMC transactions, leaving the host drivers to implement only what is necessary to deal with their specific hardware.

This also hooks the infrastructure into the PowerPC board code (similar to how the ethernet infrastructure now hooks in)

Some of this code was contributed by Dave Liu <[email protected]>

---
 common/cmd_mmc.c     |  132 +++++++
 drivers/mmc/Makefile |    1 +
 drivers/mmc/mmc.c    |  930 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/mmc.h        |  190 ++++++++++-
 lib_ppc/board.c      |    9 +
 5 files changed, 1253 insertions(+), 9 deletions(-)
 create mode 100644 drivers/mmc/mmc.c
common/cmd_mmc.c +132 -0
index 75a75e5..71f4971 100644
@@ -25,6 +25,7 @@
 #include <command.h>
 #include <mmc.h>
 
+#ifndef CONFIG_GENERIC_MMC
 int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	if (mmc_legacy_init (1) != 0) {
@@ -39,3 +40,134 @@ U_BOOT_CMD(
 	"init mmc card",
 	NULL
 );
+#endif /* !CONFIG_GENERIC_MMC */
+
+static void print_mmcinfo(struct mmc *mmc)
+{
+	printf("Device: %s\n", mmc->name);
+	printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24);
+	printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff);
+	printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff,
+			(mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff,
+			(mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff);
+
+	printf("Tran Speed: %d\n", mmc->tran_speed);
+	printf("Rd Block Len: %d\n", mmc->read_bl_len);
+
+	printf("%s version %d.%d\n", IS_SD(mmc) ? "SD" : "MMC",
+			(mmc->version >> 4) & 0xf, mmc->version & 0xf);
+
+	printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No");
+	printf("Capacity: %lld\n", mmc->capacity);
+
+	printf("Bus Width: %d-bit\n", mmc->bus_width);
+}
+
+int do_mmcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	struct mmc *mmc;
+	int dev_num;
+
+	if (argc < 2)
+		dev_num = 0;
+	else
+		dev_num = simple_strtoul(argv[1], NULL, 0);
+
+	mmc = find_mmc_device(dev_num);
+
+	if (mmc) {
+		mmc_init(mmc);
+
+		print_mmcinfo(mmc);
+	}
+
+	return 0;
+}
+
+U_BOOT_CMD(mmcinfo, 2, 0, do_mmcinfo, "mmcinfo <dev num>-- display MMC info\n",
+		NULL);
+
+int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	int rc = 0;
+
+	switch (argc) {
+	case 3:
+		if (strcmp(argv[1], "rescan") == 0) {
+			int dev = simple_strtoul(argv[2], NULL, 10);
+			struct mmc *mmc = find_mmc_device(dev);
+
+			mmc_init(mmc);
+
+			return 0;
+		}
+
+	case 0:
+	case 1:
+	case 4:
+		printf("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+
+	case 2:
+		if (!strcmp(argv[1], "list")) {
+			print_mmc_devices('\n');
+			return 0;
+		}
+		return 1;
+	default: /* at least 5 args */
+		if (strcmp(argv[1], "read") == 0) {
+			int dev = simple_strtoul(argv[2], NULL, 10);
+			void *addr = (void *)simple_strtoul(argv[3], NULL, 16);
+			u32 cnt = simple_strtoul(argv[5], NULL, 16);
+			u32 n;
+			u32 blk = simple_strtoul(argv[4], NULL, 16);
+			struct mmc *mmc = find_mmc_device(dev);
+
+			printf("\nMMC read: dev # %d, block # %d, count %d ... ",
+				dev, blk, cnt);
+
+			mmc_init(mmc);
+
+			n = mmc->block_dev.block_read(dev, blk, cnt, addr);
+
+			/* flush cache after read */
+			flush_cache((ulong)addr, cnt * 512); //FIXME
+
+			printf("%d blocks read: %s\n",
+				n, (n==cnt) ? "OK" : "ERROR");
+			return (n == cnt) ? 0 : 1;
+		} else if (strcmp(argv[1], "write") == 0) {
+			int dev = simple_strtoul(argv[2], NULL, 10);
+			void *addr = (void *)simple_strtoul(argv[3], NULL, 16);
+			u32 cnt = simple_strtoul(argv[5], NULL, 16);
+			u32 n;
+			struct mmc *mmc = find_mmc_device(dev);
+
+			int blk = simple_strtoul(argv[4], NULL, 16);
+
+			printf("\nMMC write: dev # %d, block # %d, count %d ... ",
+				dev, blk, cnt);
+
+			mmc_init(mmc);
+
+			n = mmc->block_dev.block_write(dev, blk, cnt, addr);
+
+			printf("%d blocks written: %s\n",
+				n, (n == cnt) ? "OK" : "ERROR");
+			return (n == cnt) ? 0 : 1;
+		} else {
+			printf("Usage:\n%s\n", cmdtp->usage);
+			rc = 1;
+		}
+
+		return rc;
+	}
+}
+
+U_BOOT_CMD(
+	mmc, 6, 1, do_mmcops,
+	"mmc	- MMC sub system\n",
+	"mmc read <device num> addr blk# cnt\n"
+	"mmc write <device num> addr blk# cnt\n"
+	"mmc rescan <device num>\n"
+	"mmc list - lists available devices\n");
drivers/mmc/Makefile +1 -0
index 3dc031b..d5a969c 100644
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	:= $(obj)libmmc.a
 
+COBJS-$(CONFIG_GENERIC_MMC) += mmc.o
 COBJS-$(CONFIG_ATMEL_MCI) += atmel_mci.o
 
 COBJS	:= $(COBJS-y)
drivers/mmc/mmc.c new file +930 -0

930 lines not on this page · raw message

include/mmc.h +181 -9

227 lines not on this page · raw message

lib_ppc/board.c +9 -0
index df1cf13..65bcb4b 100644
@@ -48,6 +48,9 @@
 #include <status_led.h>
 #endif
 #include <net.h>
+#ifdef CONFIG_GENERIC_MMC
+#include <mmc.h>
+#endif
 #include <serial.h>
 #ifdef CONFIG_SYS_ALLOC_DPRAM
 #if !defined(CONFIG_CPM2)
@@ -1078,6 +1081,12 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	scsi_init ();
 #endif
 
+#ifdef CONFIG_GENERIC_MMC
+	WATCHDOG_RESET ();
+	puts ("MMC:  ");
+	mmc_initialize (bd);
+#endif
+
 #if defined(CONFIG_CMD_DOC)
 	WATCHDOG_RESET ();
 	puts ("DOC:   ");
Signature · 1 line
1.5.4.GIT
#5 lore raw

PATCH 6/8 Add support for the Freescale eSDHC found on 8379 and 8536 SoCs

This uses the new MMC framework

Some contributions by Dave Liu <[email protected]>

---
 drivers/mmc/Makefile    |    1 +
 drivers/mmc/fsl_esdhc.c |  358 +++++++++++++++++++++++++++++++++++++++++++++++
 include/fsl_esdhc.h     |  143 +++++++++++++++++++
 3 files changed, 502 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mmc/fsl_esdhc.c
 create mode 100644 include/fsl_esdhc.h
drivers/mmc/Makefile +1 -0
index d5a969c..040be8d 100644
@@ -27,6 +27,7 @@ LIB	:= $(obj)libmmc.a
 
 COBJS-$(CONFIG_GENERIC_MMC) += mmc.o
 COBJS-$(CONFIG_ATMEL_MCI) += atmel_mci.o
+COBJS-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/mmc/fsl_esdhc.c new file +358 -0

358 lines not on this page · raw message

include/fsl_esdhc.h new file +143 -0

143 lines not on this page · raw message

Signature · 1 line
1.5.4.GIT
#6 lore raw

PATCH 7/8 85xx: Add eSDHC support for 8536 DS

---
 board/freescale/mpc8536ds/mpc8536ds.c |   12 ++++++++++++
 cpu/mpc85xx/cpu.c                     |   15 +++++++++++++++
 include/configs/MPC8536DS.h           |   14 ++++++++++++++
 3 files changed, 41 insertions(+), 0 deletions(-)
board/freescale/mpc8536ds/mpc8536ds.c +12 -0
index eb80500..0522f2f 100644
@@ -44,6 +44,18 @@
 
 phys_size_t fixed_sdram(void);
 
+int board_early_init_f (void)
+{
+	volatile u32 *pmuxcr = (u32 *)(CONFIG_SYS_IMMR + 0xe0060);
+	u32 val;
+
+	val = *pmuxcr;
+	val |= 0x60000000;
+	*pmuxcr = val;
+
+	return 0;
+}
+
 int checkboard (void)
 {
 	printf ("Board: MPC8536DS, System ID: 0x%02x, "
cpu/mpc85xx/cpu.c +15 -0
index bbea50f..fa1c0e1 100644
@@ -31,6 +31,7 @@
 #include <command.h>
 #include <tsec.h>
 #include <netdev.h>
+#include <fsl_esdhc.h>
 #include <asm/cache.h>
 #include <asm/io.h>
 
@@ -392,5 +393,19 @@ int cpu_eth_init(bd_t *bis)
 #if defined(CONFIG_TSEC_ENET) || defined(CONFIG_MPC85XX_FEC)
 	tsec_standard_init(bis);
 #endif
+
 	return 0;
 }
+
+/*
+ * Initializes on-chip MMC controllers.
+ * to override, implement board_mmc_init()
+ */
+int cpu_mmc_init(bd_t *bis)
+{
+#ifdef CONFIG_FSL_ESDHC
+	return fsl_esdhc_mmc_init(bis);
+#else
+	return 0;
+#endif
+}
include/configs/MPC8536DS.h +14 -0
index e379d53..43c1528 100644
@@ -72,6 +72,8 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define CONFIG_L2_CACHE			/* toggle L2 cache */
 #define CONFIG_BTB			/* toggle branch predition */
 
+#define CONFIG_BOARD_EARLY_INIT_F	1	/* Call board_pre_init */
+
 #define CONFIG_ENABLE_36BIT_PHYS	1
 
 #define CONFIG_SYS_MEMTEST_START	0x00000000	/* memtest works on */
@@ -528,6 +530,18 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 
 #undef CONFIG_WATCHDOG			/* watchdog disabled */
 
+#define CONFIG_MMC     1
+
+#ifdef CONFIG_MMC
+#define CONFIG_FSL_ESDHC
+#define CFG_FSL_ESDHC_ADDR	CONFIG_SYS_MPC85xx_ESDHC_ADDR
+#define CONFIG_CMD_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+#endif
+
 /*
  * Miscellaneous configurable options
  */
Signature · 1 line
1.5.4.GIT
#7 lore raw

PATCH 8/8 83xx: Add eSDHC support on 8379 EMDS board

---
 board/freescale/mpc837xemds/mpc837xemds.c |   19 +++++++++++++++++++
 cpu/mpc83xx/cpu.c                         |   14 ++++++++++++++
 include/asm-ppc/immap_83xx.h              |    2 ++
 include/configs/MPC837XEMDS.h             |   15 +++++++++++++++
 4 files changed, 50 insertions(+), 0 deletions(-)
board/freescale/mpc837xemds/mpc837xemds.c +19 -0
index 156d808..299dfab 100644
@@ -23,6 +23,7 @@
 
 int board_early_init_f(void)
 {
+	struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR;
 	u8 *bcsr = (u8 *)CONFIG_SYS_BCSR;
 
 	/* Enable flash write */
@@ -30,6 +31,24 @@ int board_early_init_f(void)
 	/* Clear all of the interrupt of BCSR */
 	bcsr[0xe] = 0xff;
 
+#ifdef CONFIG_MMC
+       bcsr[0xc] |= 0x4c;
+
+#define SICRL_USB_B_MASK       0x30000000
+#define SICRL_USB_B_SD         0x20000000
+#define SICRH_GPIO2_E_MASK     0x00000c00
+#define SICRH_GPIO2_E_SD       0x00000800
+#define SICRH_SPI_MASK         0x00000003
+#define SICRH_SPI_SD           0x00000001
+
+       im->sysconf.sicrl &= ~SICRL_USB_B_MASK;
+       im->sysconf.sicrl |= SICRL_USB_B_SD;
+
+       im->sysconf.sicrh &= ~(SICRH_GPIO2_E_MASK | SICRH_SPI_MASK);
+       im->sysconf.sicrh |= SICRH_GPIO2_E_SD | SICRH_SPI_SD;
+
+#endif
+
 #ifdef CONFIG_FSL_SERDES
 	immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 	u32 spridr = in_be32(&immr->sysconf.spridr);
cpu/mpc83xx/cpu.c +14 -0
index 587fca3..9e0a05d 100644
@@ -34,6 +34,7 @@
 #include <libfdt.h>
 #include <tsec.h>
 #include <netdev.h>
+#include <fsl_esdhc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -385,3 +386,16 @@ int cpu_eth_init(bd_t *bis)
 #endif
 	return 0;
 }
+
+/*
+ * Initializes on-chip MMC controllers.
+ * to override, implement board_mmc_init()
+ */
+int cpu_mmc_init(bd_t *bis)
+{
+#ifdef CONFIG_FSL_ESDHC
+	return fsl_esdhc_mmc_init(bis);
+#else
+	return 0;
+#endif
+}
include/asm-ppc/immap_83xx.h +2 -0
index 77c09db..7b847f8 100644
@@ -895,4 +895,6 @@ typedef struct immap {
 } immap_t;
 #endif
 
+#define CONFIG_SYS_MPC83xx_ESDHC_OFFSET	(0x2e000)
+#define CONFIG_SYS_MPC83xx_ESDHC_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC83xx_ESDHC_OFFSET)
 #endif				/* __IMMAP_83xx__ */
include/configs/MPC837XEMDS.h +15 -0
index 0dd6ef5..da50c14 100644
@@ -319,6 +319,9 @@
 #define CONFIG_OF_BOARD_SETUP	1
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
+#define CONFIG_SYS_64BIT_STRTOUL		1
+#define CONFIG_SYS_64BIT_VSPRINTF		1
+
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
 #undef CONFIG_SOFT_I2C		/* I2C bit-banged */
@@ -502,6 +505,18 @@ extern int board_pci_host_broken(void);
 
 #undef CONFIG_WATCHDOG		/* watchdog disabled */
 
+#define CONFIG_MMC     1
+
+#ifdef CONFIG_MMC
+#define CONFIG_FSL_ESDHC
+#define CFG_FSL_ESDHC_ADDR	CONFIG_SYS_MPC83xx_ESDHC_ADDR
+#define CONFIG_CMD_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+#endif
+
 /*
  * Miscellaneous configurable options
  */
Signature · 1 line
1.5.4.GIT
#8 lore raw

PATCH 8/8 83xx: Add eSDHC support on 8379 EMDS board

board/freescale/mpc837xemds/mpc837xemds.c int board_early_init_f(void) · line 35

Quoted 6 lines · On Fri, 30 Jan 2009 15:45:44 -0600 Andy Fleming <[email protected]> wrote:
board/freescale/mpc837xemds/mpc837xemds.c +2 -0
@@ -30,6 +31,24 @@ int board_early_init_f(void)
 	/* Clear all of the interrupt of BCSR */
 	bcsr[0xe] = 0xff;
 
+#ifdef CONFIG_MMC
+       bcsr[0xc] |= 0x4c;

magic - at least add a comment

board/freescale/mpc837xemds/mpc837xemds.c int board_early_init_f(void) · line 42

Quoted 7 lines
board/freescale/mpc837xemds/mpc837xemds.c +7 -0
+
+#define SICRL_USB_B_MASK       0x30000000
+#define SICRL_USB_B_SD         0x20000000
+#define SICRH_GPIO2_E_MASK     0x00000c00
+#define SICRH_GPIO2_E_SD       0x00000800
+#define SICRH_SPI_MASK         0x00000003
+#define SICRH_SPI_SD           0x00000001

we already have some of these defined in include/mpc83xx.h

board/freescale/mpc837xemds/mpc837xemds.c int board_early_init_f(void) · line 48

Quoted 5 lines
board/freescale/mpc837xemds/mpc837xemds.c +5 -0
+       im->sysconf.sicrl &= ~SICRL_USB_B_MASK;
+       im->sysconf.sicrl |= SICRL_USB_B_SD;
+
+       im->sysconf.sicrh &= ~(SICRH_GPIO2_E_MASK | SICRH_SPI_MASK);
+       im->sysconf.sicrh |= SICRH_GPIO2_E_SD | SICRH_SPI_SD;

use clrsetbits

include/asm-ppc/immap_83xx.h typedef struct immap { · line 898

Quoted 5 lines
include/asm-ppc/immap_83xx.h +1 -0
@@ -895,4 +895,6 @@ typedef struct immap {
 } immap_t;
 #endif
 
+#define CONFIG_SYS_MPC83xx_ESDHC_OFFSET	(0x2e000)

use offsetof

include/asm-ppc/immap_83xx.h extern int board_pci_host_broken(void); · line 512

Quoted 11 lines
include/asm-ppc/immap_83xx.h +6 -0
+#define CONFIG_SYS_MPC83xx_ESDHC_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC83xx_ESDHC_OFFSET)
 #endif				/* __IMMAP_83xx__ */
@@ -502,6 +505,18 @@ extern int board_pci_host_broken(void);
 
 #undef CONFIG_WATCHDOG		/* watchdog disabled */
 
+#define CONFIG_MMC     1
+
+#ifdef CONFIG_MMC
+#define CONFIG_FSL_ESDHC
+#define CFG_FSL_ESDHC_ADDR	CONFIG_SYS_MPC83xx_ESDHC_ADDR

this should be a CONFIG_SYS_ (this comment probably applies to your some other patches in this series).

Kim