Re: [U-Boot-Users] drivers MMCplus for at91sam9x

Pierre Savary wrote:
Thanks a lot for your patch. I will test it next week.
I found it useful to modify common/cmd_mmc.c drastically to facilitate easier testing of the AT91SAM9 MCI driver. It replaces mmcinit with "mmc init" and adds raw read ("mmc read") and write ("mmc write") functions. To use it, just apply the (ancillary) patch below.
Sincerely,
Ken Fuchs
------
u-boot-at91sam9261-cmd-mmc-for-testing.patch ============================================
svn diff -r21 common/cmd_mmc.c Index: common/cmd_mmc.c =================================================================== --- common/cmd_mmc.c (revision 21) +++ common/cmd_mmc.c (working copy) @@ -1,4 +1,8 @@ /* + * (C) Copyright 2007-2008 + * Benchmark Electronics, Inc. + * Split mmcinit into mmc init, mmc read and mmc write + * * (C) Copyright 2003 * Kyle Harris, kharris@nexus-tech.net * @@ -28,19 +32,100 @@
#include <mmc.h>
+static unsigned int subcmd; +static unsigned int bstart; +static unsigned int noblocks; +static unsigned int address; + int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - if (mmc_init (1) != 0) { - printf ("No MMC card found\n"); - return 1; + unsigned int compblocks; + + if ((flag & CMD_FLAG_REPEAT) == 0) { + if (argc >= 2) { + if ((argv[1][0] == 'I' && argv[1][1] == 'N' + && argv[1][2] == 'I' && argv[1][3] == 'T') || + (argv[1][0] == 'i' && argv[1][1] == 'n' + && argv[1][2] == 'i' && argv[1][3] == 't')) { + subcmd = 0; /* init */ + } else if ((argv[1][0] == 'R') || + (argv[1][0] == 'r')) { + subcmd = 1; /* block read */ + } else if ((argv[1][0] == 'W') || + (argv[1][0] == 'w')) { + subcmd = 2; /* block write */ + } else if ((argv[1][0] == 'M') || + (argv[1][0] == 'm')) { + subcmd = 3; /* multiple block write */ + } else { + printf("Subcommand must be "); + printf("init, r[ead] or w[rite]\n"); + return 1; + } + } + if (argc >= 3) { + bstart = simple_strtoul(argv[2], NULL, 16); + } + if (argc >= 4) { + noblocks = simple_strtoul(argv[3], NULL, 16); + } + if (argc >= 5) { + address = simple_strtoul(argv[4], NULL, 16); + } } - return 0; + switch (subcmd) { + case 0: + if (mmc_init(1) != 0) { + printf ("No MMC card found\n"); + return 1; + } + return 0; + break; + case 1: + compblocks = mmc_bread(0, bstart, noblocks, (ulong *)address); + if (compblocks < noblocks) { + printf("Error reading block#: 0x%08lx\n", + bstart + compblocks); + } + break; + case 2: + compblocks = + mmc_bwrite(0, bstart, noblocks, (ulong *)address); + if (compblocks < noblocks) { + printf("Error writing block#: 0x%08lx\n", + bstart + compblocks); + } + break; + case 3: + compblocks = + mmc_mbwrite(0, bstart, noblocks, (ulong *)address); + if (compblocks < noblocks) { + printf("Error writing block#: 0x%08lx\n", + bstart + compblocks); + } + break; + } }
U_BOOT_CMD( - mmcinit, 1, 0, do_mmc, - "mmcinit - init mmc card\n", - NULL + mmc, 5, 1, do_mmc, + "mmc - init, read & write to the MMC NAND device\n", + "\n\nmmc init - initialize the MMC NAND device\n" + "\nmmc r <block#> <#blocks> <address> - block read MMC NAND blocks\n" + " <block#> - starting block # (hexidecimal) to read\n" + " <#blocks> - no. of (512) blocks (hexidecimal) to read\n" + " <address> - SDRAM/SRAM address (hex.) for read data\n" + "\nmmc w <block#> <#blocks> <address> - block write MMC NAND blocks\n" + " <block#> - starting block # (hexidecimal) to write\n" + " <#blocks> - no. of (512) blocks (hexidecimal) to write\n" + " <address> - SDRAM/SRAM address (hex.) of data to write\n" +#if 0 /* Not working yet, so documentation is removed. */ + "\nmmc m <block#> <#blocks> <address> - multiple block write mode\n" + " <block#> - starting block # (hexidecimal) to write\n" + " <#blocks> - no. of (512) blocks (hexidecimal) to write\n" + " <address> - SDRAM/SRAM address (hex.) of data to write\n" +#endif /* 0 */ + "\nA period (.) is displayed after each full MB is read or written.\n" );
#endif /* CFG_CMD_MMC */
participants (1)
-
Ken.Fuchs@bench.com