[PATCH] [GTA01] Added SDHC support

Paul Fertser fercerpav at gmail.com
Sat May 23 23:16:35 CEST 2009


Implemented and tested on Josch's GTA01Bv4
---
 src/cpu/s3c2410/gta01.c       |    6 +++---
 src/cpu/s3c2410/s3c24xx-mci.c |   20 +++++++++++++++++---
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/cpu/s3c2410/gta01.c b/src/cpu/s3c2410/gta01.c
index 0371505..4686fa2 100644
--- a/src/cpu/s3c2410/gta01.c
+++ b/src/cpu/s3c2410/gta01.c
@@ -280,7 +280,7 @@ const struct board_api board_api_gta01 = {
 			.partition_index = 1,
 			.filesystem = FS_EXT2,
 			.filepath = "boot/uImage-GTA01.bin",
-			.commandline_append = "root=/dev/mmcblk0p1 ",
+			.commandline_append = "root=/dev/mmcblk0p1 rootdelay=1 ",
 		},
 		[1] = {
 			.name = "SD Card EXT2 Kernel p2",
@@ -289,7 +289,7 @@ const struct board_api board_api_gta01 = {
 			.partition_index = 2,
 			.filesystem = FS_EXT2,
 			.filepath = "boot/uImage-GTA01.bin",
-			.commandline_append = "root=/dev/mmcblk0p2 ",
+			.commandline_append = "root=/dev/mmcblk0p2 rootdelay=1 ",
 		},
 		[2] = {
 			.name = "SD Card EXT2 Kernel p3",
@@ -298,7 +298,7 @@ const struct board_api board_api_gta01 = {
 			.partition_index = 3,
 			.filesystem = FS_EXT2,
 			.filepath = "boot/uImage-GTA01.bin",
-			.commandline_append = "root=/dev/mmcblk0p3 ",
+			.commandline_append = "root=/dev/mmcblk0p3 rootdelay=1 ",
 		},
 		[3] = {
 			.name = "NAND Kernel",
diff --git a/src/cpu/s3c2410/s3c24xx-mci.c b/src/cpu/s3c2410/s3c24xx-mci.c
index 7d53b42..dbef90d 100644
--- a/src/cpu/s3c2410/s3c24xx-mci.c
+++ b/src/cpu/s3c2410/s3c24xx-mci.c
@@ -70,6 +70,7 @@ static u8 mmc_buf[MMC_BLOCK_SIZE];
 static mmc_csd_t mmc_csd;
 static int mmc_ready = 0;
 static int wide = 0;
+static int is_sdhc = 0;
 
 
 #define CMD_F_RESP	0x01
@@ -162,7 +163,10 @@ static int mmc_block_read(u8 *dst, u32 src, u32 len)
 	SDIDCON = dcon;
 
 	/* send read command */
-	resp = mmc_cmd(MMC_CMD_READ_BLOCK, src, CMD_F_RESP);
+	if (!is_sdhc)
+		resp = mmc_cmd(MMC_CMD_READ_BLOCK, src, CMD_F_RESP);
+	else
+		resp = mmc_cmd(MMC_CMD_READ_BLOCK, src / MMC_BLOCK_SIZE, CMD_F_RESP);
 
 	while (len > 0) {
 		u32 sdidsta = SDIDSTA;
@@ -449,6 +453,7 @@ int s3c24xx_mmc_init(int verbose)
  	int retries, rc = -2;
 	int is_sd = 0;
 	u32 *resp;
+	u32 hcs = 0;
 
 	SDICON = S3C2410_SDICON_FIFORESET | S3C2410_SDICON_CLOCKTYPE;
 	SDIBSIZE = 512;
@@ -474,11 +479,20 @@ int s3c24xx_mmc_init(int verbose)
 	retries = 10;
 	resp = mmc_cmd(MMC_CMD_RESET, 0, 0);
 
+	resp = mmc_cmd(8, 0x000001aa, CMD_F_RESP);
+	if ((resp[0] & 0xff) == 0xaa) {
+		puts("The card is either SD2.0 or SDHC\n");
+		hcs = 0x40000000;
+	}
+ 
 	puts("trying to detect SD Card...\n");
 	while (retries--) {
 		udelay(1000000);
 		resp = mmc_cmd(55, 0x00000000, CMD_F_RESP);
-		resp = mmc_cmd(41, 0x00300000, CMD_F_RESP);
+		resp = mmc_cmd(41, hcs | 0x00300000, CMD_F_RESP);
+
+		if (resp[0] & (1 << 30))
+			is_sdhc = 1;
 
 		if (resp[0] & (1 << 31)) {
 			is_sd = 1;
@@ -490,7 +504,7 @@ int s3c24xx_mmc_init(int verbose)
 		return -3;
 
 	/* try to get card id */
-	resp = mmc_cmd(MMC_CMD_ALL_SEND_CID, 0, CMD_F_RESP|CMD_F_RESP_LONG);
+	resp = mmc_cmd(MMC_CMD_ALL_SEND_CID, hcs, CMD_F_RESP|CMD_F_RESP_LONG);
 	if (resp) {
 		if (!is_sd) {
 			/* TODO configure mmc driver depending on card
-- 
1.6.0.6




More information about the openmoko-kernel mailing list