@@ -1,1091 +0,0 @@
1−diff --git a/arch/arm/include/asm/arch-kirkwood/config.h b/arch/arm/include/asm/arch-kirkwood/config.h
2−index a9499b7..1294d7f 100644
3−--- a/arch/arm/include/asm/arch-kirkwood/config.h
4−+++ b/arch/arm/include/asm/arch-kirkwood/config.h
6− #define MV_SATA_BASE KW_SATA_BASE
7− #define MV_SATA_PORT0_OFFSET KW_SATA_PORT0_OFFSET
8− #define MV_SATA_PORT1_OFFSET KW_SATA_PORT1_OFFSET
9−+#define MV_SDIO_BASE KW_SDIO_BASE
14− #endif /* CONFIG_CMD_NET */
17−+ * SDIO/MMC Card Configuration
19−+#ifdef CONFIG_CMD_MMC
21−+#define CONFIG_MV_SDIO
22−+#endif /* CONFIG_CMD_MMC */
27− #ifdef CONFIG_CMD_USB
28−diff --git a/arch/arm/include/asm/arch-kirkwood/kirkwood.h b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
29−index 47771d5..343214b 100644
30−--- a/arch/arm/include/asm/arch-kirkwood/kirkwood.h
31−+++ b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
33− #define KW_EGIGA0_BASE (KW_REGISTER(0x72000))
34− #define KW_EGIGA1_BASE (KW_REGISTER(0x76000))
35− #define KW_SATA_BASE (KW_REGISTER(0x80000))
36−+#define KW_SDIO_BASE (KW_REGISTER(0x90000))
38− /* Kirkwood Sata controller has two ports */
39− #define KW_SATA_PORT0_OFFSET 0x2000
40−diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
41−index c567737..081d5f4 100644
42−--- a/drivers/mmc/Makefile
43−+++ b/drivers/mmc/Makefile
44−@@ -34,6 +34,7 @@ COBJS-$(CONFIG_GENERIC_ATMEL_MCI) += gen_atmel_mci.o
45− COBJS-$(CONFIG_MMC_SPI) += mmc_spi.o
46− COBJS-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
47− COBJS-$(CONFIG_MV_SDHCI) += mv_sdhci.o
48−+COBJS-$(CONFIG_MV_SDIO) += mv_sdio.o
49− COBJS-$(CONFIG_MXC_MMC) += mxcmmc.o
50− COBJS-$(CONFIG_MXS_MMC) += mxsmmc.o
51− COBJS-$(CONFIG_OMAP_HSMMC) += omap_hsmmc.o
52−diff --git a/drivers/mmc/mv_sdio.c b/drivers/mmc/mv_sdio.c
54−index 0000000..35969d3
56−+++ b/drivers/mmc/mv_sdio.c
59−+ * (C) Copyright 2009
60−+ * Marvell Semiconductor <www.marvell.com>
61−+ * Written-by: Gérald Kerma <geraker@gmail.com>
63−+ * (C) Copyright 2003
64−+ * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
66−+ * See file CREDITS for list of people who contributed to this
69−+ * This program is free software; you can redistribute it and/or
70−+ * modify it under the terms of the GNU General Public License as
71−+ * published by the Free Software Foundation; either version 2 of
72−+ * the License, or (at your option) any later version.
74−+ * This program is distributed in the hope that it will be useful,
75−+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
76−+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77−+ * GNU General Public License for more details.
79−+ * You should have received a copy of the GNU General Public License
80−+ * along with this program; if not, write to the Free Software
81−+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
89−+#include <asm/errno.h>
92−+#ifdef CONFIG_KIRKWOOD
93−+#include <asm/arch/kirkwood.h>
99−+#define DRIVER_NAME "mv-sdio"
102−+#define pr_debug(fmt, args...) printf(fmt, ##args)
104−+#define pr_debug(...) do { } while(0)
107−+//static mv_sdio_t *mvsd = (mv_sdio_t *)mmc->priv;
108−+static mv_sdio_t *mvsd = (mv_sdio_t *)MV_SDIO_BASE;
111−+extern int fat_register_device(block_dev_desc_t *dev_desc, int part_no);
112−+static block_dev_desc_t mmc_dev;
113−+block_dev_desc_t * mmc_get_dev(int dev)
115−+ return ((block_dev_desc_t *)&mmc_dev);
119−+ * FIXME needs to read cid and csd info to determine block size
120−+ * and other parameters
122−+static uchar mmc_buf[MMC_BLOCK_SIZE];
123−+static mv_mmc_csd_t mv_mmc_csd;
124−+static int mmc_ready = 0;
126−+/* MMC_DEFAULT_RCA should probably be just 1, but this may break other code
127−+ that expects it to be shifted. */
128−+static u_int16_t rca = 0;
130−+/* used for debug */
131−+static u_int32_t mv_mmc_size(const struct mv_mmc_csd *csd)
133−+ u_int32_t block_len, mult, blocknr;
135−+ block_len = csd->read_bl_len << 12;
136−+ mult = csd->c_size_mult1 << 8;
137−+ blocknr = (csd->c_size+1) * mult;
139−+ return blocknr * block_len;
142−+static int isprint (unsigned char ch)
144−+ if (ch >= 32 && ch < 127)
150−+static int toprint(char *dst, char c)
157−+ return sprintf(dst,"\\x%02x", c);
161−+static void print_mmc_cid(mv_mmc_cid_t *cid)
163−+ printf("MMC found. Card desciption is:\n");
164−+ printf("Manufacturer ID = %02x%02x%02x\n",
165−+ cid->id[0], cid->id[1], cid->id[2]);
166−+ printf("HW/FW Revision = %x %x\n",cid->hwrev, cid->fwrev);
167−+ cid->hwrev = cid->fwrev = 0; /* null terminate string */
168−+ printf("Product Name = %s\n",cid->name);
169−+ printf("Serial Number = %02x%02x%02x\n",
170−+ cid->sn[0], cid->sn[1], cid->sn[2]);
171−+ printf("Month = %d\n",cid->month);
172−+ printf("Year = %d\n",1997 + cid->year);
175−+static void print_sd_cid(mv_sd_cid_t *cid)
180−+ printf("SD%s found. Card desciption is:\n", is_sdhc?"HC":"");
183−+ len += toprint(&tbuf[len], cid->oid_0);
184−+ len += toprint(&tbuf[len], cid->oid_1);
187−+ printf("Manufacturer: 0x%02x, OEM \"%s\"\n",
191−+ len += toprint(&tbuf[len], cid->pnm_0);
192−+ len += toprint(&tbuf[len], cid->pnm_1);
193−+ len += toprint(&tbuf[len], cid->pnm_2);
194−+ len += toprint(&tbuf[len], cid->pnm_3);
195−+ len += toprint(&tbuf[len], cid->pnm_4);
198−+ printf("Product name: \"%s\", revision %d.%d\n",
200−+ cid->prv >> 4, cid->prv & 15);
202−+ printf("Serial number: %u\n",
203−+ cid->psn_0 << 24 | cid->psn_1 << 16 | cid->psn_2 << 8 |
205−+ printf("Manufacturing date: %d/%d\n",
207−+ 2000+((cid->mdt_0 & 15) << 4)+((cid->mdt_1 & 0xf0) >> 4));
209−+ printf("CRC: 0x%02x, b0 = %d\n",
210−+ cid->crc >> 1, cid->crc & 1);
213−+static void mvsdio_set_clock(unsigned int clock)
217−+ m = MVSDMMC_BASE_FAST_CLOCK/(2*clock) - 1;
219−+ pr_debug("mvsdio_set_clock: dividor = 0x%x clock=%d\n",
223−+ writew(m & 0x7ff, &mvsd->CLK_DIV);
229−+/****************************************************/
230−+static ulong * mv_mmc_cmd(ulong cmd, ulong arg, ushort xfermode, ushort resptype, ushort waittype)
231−+/****************************************************/
233−+ static ulong resp[4];
236−+ ulong curr, start, diff, hz;
237−+ ushort response[8];
239−+ pr_debug("mv_mmc_cmd %x, arg: %x,xfer: %x,resp: %x, wait : %x\n"
240−+ , (unsigned int)cmd, (unsigned int)arg, xfermode, resptype, waittype);
244−+ writew(0xffff, &mvsd->NOR_INTR_STATUS);
245−+ writew(0xffff, &mvsd->ERR_INTR_STATUS);
247−+ start = get_timer(0);
248−+ hz = CONFIG_SYS_HZ;
250−+ while((readw(&mvsd->PRESENT_STATE0) & CARD_BUSY)) {
251−+ curr = get_timer(0);
252−+ diff = (long) curr - (long) start;
255−+ /* 3 seconds timeout, card busy, can't sent cmd */
256−+ printf("card too busy \n");
261−+ writew((ushort)(arg&0xffff), &mvsd->ARG_LOW);
262−+ writew((ushort)(arg>>16), &mvsd->ARG_HI);
263−+ writew(xfermode, &mvsd->XFER_MODE);
264−+ if( (cmd == MMC_CMD_READ_BLOCK) || (cmd == 25) )
266−+ writew(((cmd << 8) | resptype | 0x3c ) , &mvsd->CMD);
267−+ pr_debug("cmd reg : %x\n", readw(&mvsd->CMD)) ;
272−+ writew(((cmd << 8) | resptype ), &mvsd->CMD);
275−+ done = readw(&mvsd->NOR_INTR_STATUS) & waittype;
276−+ start = get_timer(0);
278−+ while( done!=waittype)
280−+ done = readw(&mvsd->NOR_INTR_STATUS) & waittype;
282−+ if( readw(&mvsd->NOR_INTR_STATUS) & 0x8000 )
284−+ pr_debug("Error! cmd : %d, err : %04x\n", (unsigned int)cmd, readw(&mvsd->ERR_INTR_STATUS)) ;
286−+ return 0 ; /* error happen */
289−+ curr = get_timer(0);
290−+ diff = (long) curr - (long) start;
293−+ pr_debug("cmd timeout, status : %04x\n", readw(&mvsd->NOR_INTR_STATUS));
294−+ pr_debug("xfer mode : %04x\n", readw(&mvsd->XFER_MODE));
301−+ response[0] = readw(&mvsd->RSP0);
302−+ response[1] = readw(&mvsd->RSP1);
303−+ response[2] = readw(&mvsd->RSP2);
304−+ response[3] = readw(&mvsd->RSP3);
305−+ response[4] = readw(&mvsd->RSP4);
306−+ response[5] = readw(&mvsd->RSP5);
307−+ response[6] = readw(&mvsd->RSP6);
308−+ response[7] = readw(&mvsd->RSP7);
310−+ memset(resp, 0, sizeof(resp));
312−+ switch (resptype & 0x3) {
313−+ case SDIO_CMD_RSP_48:
314−+ case SDIO_CMD_RSP_48BUSY:
315−+ resp[0] = ((response[2] & 0x3f) << (8 - 8)) |
316−+ ((response[1] & 0xffff) << (14 - 8)) |
317−+ ((response[0] & 0x3ff) << (30 - 8));
318−+ resp[1] = ((response[0] & 0xfc00) >> 10);
321−+ case SDIO_CMD_RSP_136:
322−+ resp[3] = ((response[7] & 0x3fff) << 8) |
323−+ ((response[6] & 0x3ff) << 22);
324−+ resp[2] = ((response[6] & 0xfc00) >> 10) |
325−+ ((response[5] & 0xffff) << 6) |
326−+ ((response[4] & 0x3ff) << 22);
327−+ resp[1] = ((response[4] & 0xfc00) >> 10) |
328−+ ((response[3] & 0xffff) << 6) |
329−+ ((response[2] & 0x3ff) << 22);
330−+ resp[0] = ((response[2] & 0xfc00) >> 10) |
331−+ ((response[1] & 0xffff) << 6) |
332−+ ((response[0] & 0x3ff) << 22);
338−+ pr_debug("MMC resp :");
339−+ for (i=0; i<4; ++i ) {
340−+ pr_debug(" %08x", (unsigned int)resp[i]);
349−+/****************************************************/
350−+static int mv_mmc_block_read(uchar *dst, ulong src, ulong len)
351−+/****************************************************/
360−+ /* SDHC: use block address */
364−+ pr_debug("mmc_block_rd dst %lx src %lx len %d\n", (ulong)dst, src, (int)len);
366−+ /* prepare for dma transfer */
367−+ writew(((ulong)(dst))&0xffff,&mvsd->SYS_ADDR_LOW);
368−+ writew(((ulong)(dst)>>16)&0xffff,&mvsd->SYS_ADDR_HI);
369−+ writew(len,&mvsd->BLK_SIZE);
370−+ writew(1,&mvsd->BLK_COUNT);
372−+ /* send read command */
373−+ resp = mv_mmc_cmd(MMC_CMD_READ_BLOCK, src, 0x10 ,
374−+ SDIO_CMD_RSP_48, SDIO_NOR_XFER_DONE);
376−+ pr_debug("mv_mmc_block_read: mmc read block cmd fails\n");
383−+/****************************************************/
384−+int mv_mmc_read(ulong src, uchar *dst, int size)
385−+/****************************************************/
387−+ ulong end, part_start, part_end, part_len, aligned_start, aligned_end;
388−+ ulong mmc_block_size, mmc_block_address;
395−+ printf("Please initial the MMC first\n");
399−+ mmc_block_size = MMC_BLOCK_SIZE;
400−+ mmc_block_address = ~(mmc_block_size - 1);
403−+ part_start = ~mmc_block_address & src;
404−+ part_end = ~mmc_block_address & end;
405−+ aligned_start = mmc_block_address & src;
406−+ aligned_end = mmc_block_address & end;
408−+ /* all block aligned accesses */
409−+ pr_debug("src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
410−+ (long unsigned int)src,(ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
413−+ part_len = mmc_block_size - part_start;
414−+ pr_debug("ps src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
415−+ (long unsigned int)src,(ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
417−+ if ((mv_mmc_block_read(mmc_buf, aligned_start, mmc_block_size)) < 0) {
420−+ memcpy(dst, mmc_buf+part_start, part_len);
424−+ pr_debug("src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
425−+ (long unsigned int)src,(ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
427−+ for (; src < aligned_end; aligned_start +=mmc_block_size, src += mmc_block_size, dst += mmc_block_size) {
428−+ pr_debug("al src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
429−+ (long unsigned int)src,(ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
431−+ if ((mv_mmc_block_read(mmc_buf, aligned_start, mmc_block_size)) < 0) {
432−+ printf("mmc block read error\n");
435−+ memcpy(dst, mmc_buf, mmc_block_size);
437−+ pr_debug("src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
438−+ (long unsigned int)src,(ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
440−+ if (part_end && src < end) {
441−+ pr_debug("pe src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
442−+ (long unsigned int)src,(ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
444−+ if ((mv_mmc_block_read(mmc_buf, aligned_end, mmc_block_size)) < 0) {
447−+ memcpy(dst, mmc_buf, part_end);
452−+/****************************************************/
453−+static ulong mv_mmc_bread(int dev_num, ulong blknr, ulong blkcnt, ulong *dst)
454−+/****************************************************/
456−+ int mmc_block_size = MMC_BLOCK_SIZE;
457−+ ulong src = blknr * mmc_block_size;
459−+ mv_mmc_read(src, (uchar *)dst, blkcnt*mmc_block_size);
463−+/****************************************************/
464−+int mmc_legacy_init(int verbose)
465−+/****************************************************/
467−+ int retries, rc = -ENODEV;
478−+ /* Initial Host Ctrl : Timeout : max , Normal Speed mode, 4-bit data mode */
479−+ /* Big Endian, SD memory Card, Push_pull CMD Line */
480−+ writew( SDIO_HOST_CTRL_TMOUT(0xf) |
481−+ SDIO_HOST_CTRL_DATA_WIDTH_4_BITS |
482−+ SDIO_HOST_CTRL_BIG_ENDIAN |
483−+ SDIO_HOST_CTRL_PUSH_PULL_EN |
484−+ SDIO_HOST_CTRL_CARD_TYPE_MEM_ONLY ,
487−+ writew( 0, &mvsd->CLK_CTRL);
489−+ /* enable status */
490−+ writew( 0xffff, &mvsd->NOR_STATUS_EN);
491−+ writew( 0xffff, &mvsd->ERR_STATUS_EN);
493−+ /* disable interrupts */
494−+ writew( 0, &mvsd->NOR_INTR_EN);
495−+ writew( 0, &mvsd->ERR_INTR_EN);
497−+ writew( 0x100, &mvsd->SW_RESET);
500−+ mv_mmc_csd.c_size = 0;
504−+ resp = mv_mmc_cmd(0, 0, 0, SDIO_CMD_RSP_NONE, SDIO_NOR_CMD_DONE );
505−+ pr_debug("cmd 0 resp : %08x %08x %08x %08x\n",
506−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3] );
509−+ pr_debug ("trying to detect SD card version\n");
511−+ resp = mv_mmc_cmd(8, 0x000001aa, 0, SDIO_CMD_RSP_48, SDIO_NOR_CMD_DONE );
512−+ pr_debug("cmd 8 resp : %08x %08x %08x %08x\n",
513−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3] );
515−+ if (resp && (resp[0] & 0x1ff)==0x1aa) {
516−+ pr_debug ("SD version 2.0 card detected\n");
526−+ while (retries--) {
527−+ resp = mv_mmc_cmd(55, 0, 0, SDIO_CMD_RSP_48, SDIO_NOR_CMD_DONE );
528−+ pr_debug("cmd 55 resp : %08x %08x %08x %08x\n",
529−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3] );
533−+ resp = mv_mmc_cmd(41, 0x40300000, 0, SDIO_CMD_RSP_48, SDIO_NOR_CMD_DONE );
535−+ resp = mv_mmc_cmd(41, 0x00300000, 0, SDIO_CMD_RSP_48, SDIO_NOR_CMD_DONE );
537−+ pr_debug("cmd 41 resp : %08x %08x %08x %08x\n",
538−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3] );
541−+ if (resp && (resp[0] & 0x80000000)) {
542−+ pr_debug ("detected SD card\n");
551−+ if (retries <= 0 && !is_sd) {
552−+ pr_debug ("failed to detect SD card, trying MMC\n");
555−+ while (retries--) {
556−+ resp = mv_mmc_cmd(1, 0, 0, SDIO_CMD_RSP_48, SDIO_NOR_CMD_DONE );
557−+ pr_debug("cmd 01 resp : %08x %08x %08x %08x\n",
558−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3] );
561−+ if (resp && (resp[0] & 0x80000000)) {
562−+ printf ("detected MMC card\n");
563−+ reg = readw(&mvsd->HOST_CTRL);
565−+ reg |= SDIO_HOST_CTRL_CARD_TYPE_IO_MMC;
566−+ writew( reg, &mvsd->HOST_CTRL);
574−+ if (retries <= 0) {
575−+ pr_debug ("detect fails\n");
580−+ /* try to get card id */
581−+ resp = mv_mmc_cmd(2, 0, 0, SDIO_CMD_RSP_136, SDIO_NOR_CMD_DONE );
582−+ pr_debug("cmd 2 resp : %08x %08x %08x %08x\n",
583−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3] );
586−+ if (resp == NULL) {
587−+ pr_debug ("read cid fails\n");
593−+ mv_sd_cid_t *cid = (mv_sd_cid_t *) resp;
595−+ memcpy(cidbuf, resp, sizeof(mv_sd_cid_t));
597−+ sprintf((char *) mmc_dev.vendor,
598−+ "Man %02x OEM %c%c \"%c%c%c%c%c\"",
599−+ cid->mid, cid->oid_0, cid->oid_1,
600−+ cid->pnm_0, cid->pnm_1, cid->pnm_2, cid->pnm_3, cid->pnm_4);
602−+ sprintf((char *) mmc_dev.product, "%d",
603−+ (cid->psn_0 << 24) | (cid->psn_1 <<16) | (cid->psn_2 << 8) | (cid->psn_3 << 8));
605−+ sprintf((char *) mmc_dev.revision, "%d.%d", cid->prv>>4, cid->prv & 0xff);
608−+ /* TODO configure mmc driver depending on card attributes */
609−+ mv_mmc_cid_t *cid = (mv_mmc_cid_t *) resp;
611−+ memcpy(cidbuf, resp, sizeof(mv_sd_cid_t));
614−+ sprintf((char *) mmc_dev.vendor,
615−+ "Man %02x%02x%02x Snr %02x%02x%02x",
616−+ cid->id[0], cid->id[1], cid->id[2],
617−+ cid->sn[0], cid->sn[1], cid->sn[2]);
618−+ sprintf((char *) mmc_dev.product, "%s", cid->name);
619−+ sprintf((char *) mmc_dev.revision, "%x %x", cid->hwrev, cid->fwrev);
622−+ /* fill in device description */
623−+ mmc_dev.if_type = IF_TYPE_MMC;
624−+ mmc_dev.part_type = PART_TYPE_DOS;
629−+ /* FIXME fill in the correct size (is set to 128MByte) */
630−+ mmc_dev.blksz = MMC_BLOCK_SIZE;
631−+ mmc_dev.lba = 0x10000;
633−+ mmc_dev.removable = 0;
634−+ mmc_dev.block_read = (unsigned long) mv_mmc_bread;
636−+ /* MMC exists, get CSD too */
637−+ resp = mv_mmc_cmd(MMC_CMD_SET_RCA, 0, 0, SDIO_CMD_RSP_48, SDIO_NOR_CMD_DONE );
638−+ if (resp == NULL) {
639−+ pr_debug ("set rca fails\n");
643−+ pr_debug("cmd3 resp : 0x%08x 0x%08x 0x%08x 0x%08x\n",
644−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3]);
648−+ rca = resp[0] >> 16;
652−+ resp = mv_mmc_cmd(MMC_CMD_SEND_CSD, rca<<16, 0, SDIO_CMD_RSP_136,SDIO_NOR_CMD_DONE );
653−+ pr_debug("cmd 9 resp : %08x %08x %08x %08x\n",
654−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3] );
656−+ if (resp == NULL) {
657−+ pr_debug ("read csd fails\n");
662−+ memcpy(&mv_mmc_csd, (mv_mmc_csd_t *) resp, sizeof(mv_mmc_csd_t));
666−+ /* FIXME add verbose printout for csd */
667−+ pr_debug ("size = %u\n", mv_mmc_size(&mv_mmc_csd));
670−+ resp = mv_mmc_cmd(7, rca<<16, 0, SDIO_CMD_RSP_48BUSY, SDIO_NOR_CMD_DONE);
671−+ if (resp == NULL) {
672−+ pr_debug ("select card fails\n");
676−+ pr_debug("cmd 7 resp : %08x %08x %08x %08x\n",
677−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3] );
681−+ resp = mv_mmc_cmd(55, rca<<16, 0, SDIO_CMD_RSP_48, SDIO_NOR_CMD_DONE );
682−+ if (resp == NULL) {
683−+ pr_debug ("cmd55 fails\n");
687−+ pr_debug("cmd55 resp : 0x%08x 0x%08x 0x%08x 0x%08x\n",
688−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3]);
691−+ resp = mv_mmc_cmd(6, (rca<<16) | 0x2 , 0, SDIO_CMD_RSP_48, SDIO_NOR_CMD_DONE );
692−+ if (resp == NULL) {
693−+ pr_debug ("cmd55 fails\n");
697−+ pr_debug("cmd6 resp : 0x%08x 0x%08x 0x%08x 0x%08x\n",
698−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3]);
702−+ resp = (ulong *) &mv_mmc_csd;
703−+ pr_debug("csd: 0x%08x 0x%08x 0x%08x 0x%08x\n",
704−+ (unsigned int)resp[0], (unsigned int)resp[1], (unsigned int)resp[2], (unsigned int)resp[3]);
708−+ if ((resp[0]&0xf0000000)==0x40000000)
711−+ /* set block len */
712−+ resp = mv_mmc_cmd(MMC_CMD_SET_BLOCKLEN, MMC_BLOCK_SIZE, 0, SDIO_CMD_RSP_48, SDIO_NOR_CMD_DONE );
714−+ pr_debug("mv_mmc_block_read: set blk len fails\n");
720−+ print_sd_cid((mv_sd_cid_t *) cidbuf);
722−+ print_mmc_cid((mv_mmc_cid_t *) cidbuf);
725−+ mvsdio_set_clock(CONFIG_SYS_MMC_CLK_PP);
727−+ fat_register_device(&mmc_dev,1); /* partitions start counting with 1 */
732−+#endif /* CONFIG_MMC */
733−diff --git a/drivers/mmc/mv_sdio.h b/drivers/mmc/mv_sdio.h
735−index 0000000..9707000
737−+++ b/drivers/mmc/mv_sdio.h
740−+ * (C) Copyright 2009
741−+ * Marvell Semiconductor <www.marvell.com>
742−+ * Written-by: Gérald Kerma <geraker@gmail.com>
744−+ * See file CREDITS for list of people who contributed to this
747−+ * This program is free software; you can redistribute it and/or
748−+ * modify it under the terms of the GNU General Public License as
749−+ * published by the Free Software Foundation; either version 2 of
750−+ * the License, or (at your option) any later version.
752−+ * This program is distributed in the hope that it will be useful,
753−+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
754−+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
755−+ * GNU General Public License for more details.
757−+ * You should have received a copy of the GNU General Public License
758−+ * along with this program; if not, write to the Free Software
759−+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
760−+ * MA 02110-1301 USA
763−+#ifndef _MVSDIO_INCLUDE
764−+#define _MVSDIO_INCLUDE
766−+//#define SDIO_REG(x) (MV_SDIO_BASE + (x))
768−+#define MVSDMMC_DMA_SIZE 65536
769−+#define MVSDMMC_CMD_TIMEOUT 2 /* 100 usec*/
775−+#define MVSD_CLOCKRATE_MAX 50000000
776−+#define MVSD_BASE_DIV_MAX 0x7ff
778−+#define CONFIG_SYS_MMC_CLK_PP 25000000
781−+ * The base MMC clock rate
784−+#define MVSDMMC_CLOCKRATE_MIN 100000
785−+#define MVSDMMC_CLOCKRATE_MAX MVSD_CLOCKRATE_MAX
786−+#define MVSDMMC_BASE_FAST_CLOCK CONFIG_SYS_TCLK
792−+#ifndef __ASSEMBLY__
795−+ * Structure for struct SoC access.
796−+ * Names starting with '_' are fillers.
798−+typedef struct mv_sdio {
800−+ u32 SYS_ADDR_LOW; /* 0x00 */
801−+ u32 SYS_ADDR_HI; /* 0x04 */
802−+ u32 BLK_SIZE; /* 0x08 */
803−+ u32 BLK_COUNT; /* 0x0c */
804−+ u32 ARG_LOW; /* 0x10 */
805−+ u32 ARG_HI; /* 0x14 */
806−+ u32 XFER_MODE; /* 0x18 */
807−+ u32 CMD; /* 0x1c */
808−+ u32 RSP0; /* 0x20 */
809−+ u32 RSP1; /* 0x24 */
810−+ u32 RSP2; /* 0x28 */
811−+ u32 RSP3; /* 0x2c */
812−+ u32 RSP4; /* 0x30 */
813−+ u32 RSP5; /* 0x34 */
814−+ u32 RSP6; /* 0x38 */
815−+ u32 RSP7; /* 0x3c */
816−+ u32 BUF_DATA_PORT; /* 0x40 */
817−+ u32 RSVED; /* 0x44 */
818−+ u32 PRESENT_STATE0; /* 0x48 */
819−+ u32 PRESENT_STATE1; /* 0x4c */
820−+ u32 HOST_CTRL; /* 0x50 */
821−+ u32 BLK_GAP_CTRL; /* 0x54 */
822−+ u32 CLK_CTRL; /* 0x58 */
823−+ u32 SW_RESET; /* 0x5c */
824−+ u32 NOR_INTR_STATUS; /* 0x60 */
825−+ u32 ERR_INTR_STATUS; /* 0x64 */
826−+ u32 NOR_STATUS_EN; /* 0x68 */
827−+ u32 ERR_STATUS_EN; /* 0x6c */
828−+ u32 NOR_INTR_EN; /* 0x70 */
829−+ u32 ERR_INTR_EN; /* 0x74 */
830−+ u32 AUTOCMD12_ERR_STATUS; /* 0x78 */
831−+ u32 CURR_BYTE_LEFT; /* 0x7c */
832−+ u32 CURR_BLK_LEFT; /* 0x80 */
833−+ u32 AUTOCMD12_ARG_LOW; /* 0x84 */
834−+ u32 AUTOCMD12_ARG_HI; /* 0x88 */
835−+ u32 AUTOCMD12_INDEX; /* 0x8c */
836−+ u32 AUTO_RSP0; /* 0x90 */
837−+ u32 AUTO_RSP1; /* 0x94 */
838−+ u32 AUTO_RSP2; /* 0x98 */
839−+ u32 _9c; /* 0x9c */
840−+ u32 _a0[0x78]; /* 0xa0 */
841−+ u32 CLK_DIV; /* 0x128 */
845−+#endif /* __ASSEMBLY__ */
848−+ * SDIO_PRESENT_STATE
851−+#define CARD_BUSY (1 << 1)
852−+#define CMD_INHIBIT (1 << 0)
853−+#define CMD_TXACTIVE (1 << 8)
854−+#define CMD_RXACTIVE (1 << 9)
855−+#define CMD_AUTOCMD12ACTIVE (1 << 14)
857−+#define CMD_BUS_BUSY (CMD_AUTOCMD12ACTIVE| \
867−+#define SDIO_CMD_RSP_NONE (0 << 0)
868−+#define SDIO_CMD_RSP_136 (1 << 0)
869−+#define SDIO_CMD_RSP_48 (2 << 0)
870−+#define SDIO_CMD_RSP_48BUSY (3 << 0)
872−+#define SDIO_CMD_CHECK_DATACRC16 (1 << 2)
873−+#define SDIO_CMD_CHECK_CMDCRC (1 << 3)
874−+#define SDIO_CMD_INDX_CHECK (1 << 4)
875−+#define SDIO_CMD_DATA_PRESENT (1 << 5)
876−+#define SDIO_UNEXPECTED_RESP (1 << 7)
883−+#define SDIO_XFER_MODE_STOP_CLK (1 << 5)
884−+#define SDIO_XFER_MODE_HW_WR_DATA_EN (1 << 1)
885−+#define SDIO_XFER_MODE_AUTO_CMD12 (1 << 2)
886−+#define SDIO_XFER_MODE_INT_CHK_EN (1 << 3)
887−+#define SDIO_XFER_MODE_TO_HOST (1 << 4)
894−+#define SDIO_HOST_CTRL_PUSH_PULL_EN (1 << 0)
896−+#define SDIO_HOST_CTRL_CARD_TYPE_MEM_ONLY (0 << 1)
897−+#define SDIO_HOST_CTRL_CARD_TYPE_IO_ONLY (1 << 1)
898−+#define SDIO_HOST_CTRL_CARD_TYPE_IO_MEM_COMBO (2 << 1)
899−+#define SDIO_HOST_CTRL_CARD_TYPE_IO_MMC (3 << 1)
900−+#define SDIO_HOST_CTRL_CARD_TYPE_MASK (3 << 1)
902−+#define SDIO_HOST_CTRL_BIG_ENDIAN (1 << 3)
903−+#define SDIO_HOST_CTRL_LSB_FIRST (1 << 4)
904−+#define SDIO_HOST_CTRL_ID_MODE_LOW_FREQ (1 << 5)
905−+#define SDIO_HOST_CTRL_HALF_SPEED (1 << 6)
906−+#define SDIO_HOST_CTRL_DATA_WIDTH_4_BITS (1 << 9)
907−+#define SDIO_HOST_CTRL_HI_SPEED_EN (1 << 10)
910−+#define SDIO_HOST_CTRL_TMOUT_MASK (0xf << 11)
911−+#define SDIO_HOST_CTRL_TMOUT_MAX (0xf << 11)
912−+#define SDIO_HOST_CTRL_TMOUT(x) ((x) << 11)
913−+#define SDIO_HOST_CTRL_TMOUT_EN (1 << 15)
915−+#define SDIO_HOST_CTRL_DFAULT_OPEN_DRAIN \
916−+ (SDIO_HOST_CTRL_TMOUT(x)(0xf))
917−+#define SDIO_HOST_CTRL_DFAULT_PUSH_PULL \
918−+ (SDIO_HOST_CTRL_TMOUT(x)(0xf) | SDIO_HOST_CTRL_PUSH_PULL_EN)
925−+#define SDIO_NOR_ERROR (1 << 15)
926−+#define SDIO_NOR_UNEXP_RSP (1 << 14)
927−+#define SDIO_NOR_AUTOCMD12_DONE (1 << 13)
928−+#define SDIO_NOR_SUSPEND_ON (1 << 12)
929−+#define SDIO_NOR_LMB_FF_8W_AVAIL (1 << 11)
930−+#define SDIO_NOR_LMB_FF_8W_FILLED (1 << 10)
931−+#define SDIO_NOR_READ_WAIT_ON (1 << 9)
932−+#define SDIO_NOR_CARD_INT (1 << 8)
933−+#define SDIO_NOR_READ_READY (1 << 5)
934−+#define SDIO_NOR_WRITE_READY (1 << 4)
935−+#define SDIO_NOR_DMA_INI (1 << 3)
936−+#define SDIO_NOR_BLK_GAP_EVT (1 << 2)
937−+#define SDIO_NOR_XFER_DONE (1 << 1)
938−+#define SDIO_NOR_CMD_DONE (1 << 0)
945−+#define SDIO_ERR_CRC_STATUS (1 << 14)
946−+#define SDIO_ERR_CRC_STARTBIT (1 << 13)
947−+#define SDIO_ERR_CRC_ENDBIT (1 << 12)
948−+#define SDIO_ERR_RESP_TBIT (1 << 11)
949−+#define SDIO_ERR_SIZE (1 << 10)
950−+#define SDIO_ERR_CMD_STARTBIT (1 << 9)
951−+#define SDIO_ERR_AUTOCMD12 (1 << 8)
952−+#define SDIO_ERR_DATA_ENDBIT (1 << 6)
953−+#define SDIO_ERR_DATA_CRC (1 << 5)
954−+#define SDIO_ERR_DATA_TIMEOUT (1 << 4)
955−+#define SDIO_ERR_CMD_INDEX (1 << 3)
956−+#define SDIO_ERR_CMD_ENDBIT (1 << 2)
957−+#define SDIO_ERR_CMD_CRC (1 << 1)
958−+#define SDIO_ERR_CMD_TIMEOUT (1 << 0)
960−+#define SDIO_ERR_INTR_MASK 0xFFFF
963−+#define MMC_BLOCK_SIZE 512
964−+#define MMC_CMD_RESET 0
965−+#define MMC_CMD_SEND_OP_COND 1
966−+#define MMC_CMD_ALL_SEND_CID 2
967−+#define MMC_CMD_SET_RCA 3
968−+#define MMC_CMD_SELECT_CARD 7
969−+#define MMC_CMD_SEND_CSD 9
970−+#define MMC_CMD_SEND_CID 10
971−+#define MMC_CMD_SEND_STATUS 13
972−+#define MMC_CMD_SET_BLOCKLEN 16
973−+#define MMC_CMD_READ_BLOCK 17
974−+#define MMC_CMD_RD_BLK_MULTI 18
975−+#define MMC_CMD_WRITE_BLOCK 24
976−+#define MMC_MAX_BLOCK_SIZE 512
978−+typedef struct mv_mmc_cid
980−+ /* FIXME: BYTE_ORDER */
990−+typedef struct mv_mmc_csd
994−+ tmp_write_protect:1,
995−+ perm_write_protect:1,
998−+ uint64_t content_prot_app:1,
1000−+ write_bl_partial:1,
1016−+ read_blk_misalign:1,
1017−+ write_blk_misalign:1,
1018−+ read_bl_partial:1;
1019−+ ushort read_bl_len:4,
1030−+ char pnm_0; /* product name */
1031−+ char oid_1; /* OEM/application ID */
1033−+ uint8_t mid; /* manufacturer ID */
1038−+ uint8_t psn_2; /* product serial number */
1040−+ uint8_t psn_0; /* MSB */
1041−+ uint8_t prv; /* product revision */
1042−+ uint8_t crc; /* CRC7 checksum, b0 is unused and set to 1 */
1043−+ uint8_t mdt_1; /* manufacturing date, LSB, RRRRyyyy yyyymmmm */
1044−+ uint8_t mdt_0; /* MSB */
1045−+ uint8_t psn_3; /* LSB */
1048−+#endif /* _MVSDIO_INCLUDE */
1049−diff --git a/include/configs/sheevaplug.h b/include/configs/sheevaplug.h
1050−index 83dd8ff..7c8497c 100644
1051−--- a/include/configs/sheevaplug.h
1052−+++ b/include/configs/sheevaplug.h
1056− * (C) Copyright 2009
1057− * Marvell Semiconductor <www.marvell.com>
1059− #define CONFIG_CMD_DHCP
1060− #define CONFIG_CMD_ENV
1061− #define CONFIG_CMD_MII
1062−+#define CONFIG_CMD_MMC
1063− #define CONFIG_CMD_NAND
1064−+#define CONFIG_JFFS2_NAND
1065− #define CONFIG_CMD_PING
1066− #define CONFIG_CMD_USB
1069− * it has to be rounded to sector size
1071− #define CONFIG_ENV_SIZE 0x20000 /* 128k */
1072−-#define CONFIG_ENV_ADDR 0x60000
1073−-#define CONFIG_ENV_OFFSET 0x60000 /* env starts here */
1074−+#define CONFIG_ENV_ADDR 0xa0000
1075−+#define CONFIG_ENV_OFFSET 0xa0000 /* env starts here */
1078− * Default environment variables
1080− "${x_bootcmd_usb}; bootm 0x6400000;"
1082− #define CONFIG_MTDPARTS "orion_nand:512k(uboot)," \
1083−- "3m@1m(kernel),1m@4m(psm),13m@5m(rootfs) rw\0"
1084−+ "0x1ff00000@512k(rootfs) rw\0"
1086− #define CONFIG_EXTRA_ENV_SETTINGS "x_bootargs=console" \
1087− "=ttyS0,115200 mtdparts="CONFIG_MTDPARTS \
1088−+ "mtdids=nand0=orion_nand\0" \
1089− "x_bootcmd_kernel=nand read 0x6400000 0x100000 0x300000\0" \
1090− "x_bootcmd_usb=usb start\0" \
1091− "x_bootargs_root=root=/dev/mtdblock3 rw rootfstype=jffs2\0"