diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_i2c.c | 12 | ||||
-rw-r--r-- | common/cmd_ide.c | 29 | ||||
-rw-r--r-- | common/cmd_mmc_spi.c | 1 | ||||
-rw-r--r-- | common/cmd_nvedit.c | 148 |
4 files changed, 114 insertions, 76 deletions
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index c272b0d..d913e13 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -132,6 +132,14 @@ DECLARE_GLOBAL_DATA_PTR; #define DISP_LINE_LEN 16 +/* implement possible board specific board init */ +void __def_i2c_init_board(void) +{ + return; +} +void i2c_init_board(void) + __attribute__((weak, alias("__def_i2c_init_board"))); + /* TODO: Implement architecture-specific get/set functions */ unsigned int __def_i2c_get_bus_speed(void) { @@ -1541,6 +1549,8 @@ int i2x_mux_select_mux(int bus) mux = dev->mux; while (mux != NULL) { + /* do deblocking on each level of mux, before mux config */ + i2c_init_board(); if (i2c_write(mux->chip, 0, 0, &mux->channel, 1) != 0) { printf ("Error setting Mux: chip:%x channel: \ %x\n", mux->chip, mux->channel); @@ -1548,6 +1558,8 @@ int i2x_mux_select_mux(int bus) } mux = mux->next; } + /* do deblocking on each level of mux and after mux config */ + i2c_init_board(); return 0; } #endif /* CONFIG_I2C_MUX */ diff --git a/common/cmd_ide.c b/common/cmd_ide.c index a1f7e57..e7952ff 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -517,8 +517,20 @@ __ide_outb(int dev, int port, unsigned char val) { debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n", dev, port, val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); + +#if defined(CONFIG_IDE_AHB) + if (port) { + /* write command */ + ide_write_register(dev, port, val); + } else { + /* write data */ + outb(val, (ATA_CURR_BASE(dev))); + } +#else outb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); +#endif } + void ide_outb (int dev, int port, unsigned char val) __attribute__((weak, alias("__ide_outb"))); @@ -526,7 +538,13 @@ unsigned char inline __ide_inb(int dev, int port) { uchar val; + +#if defined(CONFIG_IDE_AHB) + val = ide_read_register(dev, port); +#else val = inb((ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); +#endif + debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n", dev, port, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)), val); return val; @@ -695,6 +713,7 @@ void ide_init (void) ide_dev_desc[i].blksz=0; ide_dev_desc[i].lba=0; ide_dev_desc[i].block_read=ide_read; + ide_dev_desc[i].block_write = ide_write; if (!ide_bus_ok[IDE_BUS(i)]) continue; ide_led (led, 1); /* LED on */ @@ -902,7 +921,11 @@ output_data(int dev, ulong *sect_buf, int words) static void output_data(int dev, ulong *sect_buf, int words) { - outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words<<1); +#if defined(CONFIG_IDE_AHB) + ide_write_data(dev, sect_buf, words); +#else + outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words << 1); +#endif } #endif /* CONFIG_IDE_SWAP_IO */ @@ -960,7 +983,11 @@ input_data(int dev, ulong *sect_buf, int words) static void input_data(int dev, ulong *sect_buf, int words) { +#if defined(CONFIG_IDE_AHB) + ide_read_data(dev, sect_buf, words); +#else insw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words << 1); +#endif } #endif /* CONFIG_IDE_SWAP_IO */ diff --git a/common/cmd_mmc_spi.c b/common/cmd_mmc_spi.c index 63fe313..cfd0fb1 100644 --- a/common/cmd_mmc_spi.c +++ b/common/cmd_mmc_spi.c @@ -74,6 +74,7 @@ static int do_mmc_spi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } printf("%s: %d at %u:%u hz %u mode %u\n", mmc->name, mmc->block_dev.dev, bus, cs, speed, mode); + mmc_init(mmc); return 0; usage: diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 817f39b..aa9de3a 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -56,16 +56,16 @@ DECLARE_GLOBAL_DATA_PTR; -#if !defined(CONFIG_ENV_IS_IN_EEPROM) && \ - !defined(CONFIG_ENV_IS_IN_FLASH) && \ - !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ - !defined(CONFIG_ENV_IS_IN_MG_DISK) && \ - !defined(CONFIG_ENV_IS_IN_MMC) && \ - !defined(CONFIG_ENV_IS_IN_NAND) && \ - !defined(CONFIG_ENV_IS_IN_NVRAM) && \ - !defined(CONFIG_ENV_IS_IN_ONENAND) && \ - !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \ - !defined(CONFIG_ENV_IS_NOWHERE) +#if !defined(CONFIG_ENV_IS_IN_EEPROM) && \ + !defined(CONFIG_ENV_IS_IN_FLASH) && \ + !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ + !defined(CONFIG_ENV_IS_IN_MG_DISK) && \ + !defined(CONFIG_ENV_IS_IN_MMC) && \ + !defined(CONFIG_ENV_IS_IN_NAND) && \ + !defined(CONFIG_ENV_IS_IN_NVRAM) && \ + !defined(CONFIG_ENV_IS_IN_ONENAND) && \ + !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \ + !defined(CONFIG_ENV_IS_NOWHERE) # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\ SPI_FLASH|MG_DISK|NVRAM|MMC} or CONFIG_ENV_IS_NOWHERE #endif @@ -95,7 +95,7 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE; */ static int env_id = 1; -int get_env_id (void) +int get_env_id(void) { return env_id; } @@ -118,7 +118,7 @@ static int env_print(char *name) hsearch_r(e, FIND, &ep, &env_htab); if (ep == NULL) return 0; - len = printf ("%s=%s\n", ep->key, ep->data); + len = printf("%s=%s\n", ep->key, ep->data); return len; } @@ -209,7 +209,7 @@ int _do_env_set (int flag, int argc, char * const argv[]) name = argv[1]; if (strchr(name, '=')) { - printf ("## Error: illegal character '=' in variable name \"%s\"\n", name); + printf("## Error: illegal character '=' in variable name \"%s\"\n", name); return 1; } @@ -222,13 +222,12 @@ int _do_env_set (int flag, int argc, char * const argv[]) hsearch_r(e, FIND, &ep, &env_htab); /* Check for console redirection */ - if (strcmp(name,"stdin") == 0) { + if (strcmp(name, "stdin") == 0) console = stdin; - } else if (strcmp(name,"stdout") == 0) { + else if (strcmp(name, "stdout") == 0) console = stdout; - } else if (strcmp(name,"stderr") == 0) { + else if (strcmp(name, "stderr") == 0) console = stderr; - } if (console != -1) { if (argc < 3) { /* Cannot delete it! */ @@ -242,11 +241,11 @@ int _do_env_set (int flag, int argc, char * const argv[]) return i; #else /* Try assigning specified device */ - if (console_assign (console, argv[2]) < 0) + if (console_assign(console, argv[2]) < 0) return 1; #ifdef CONFIG_SERIAL_MULTI - if (serial_assign (argv[2]) < 0) + if (serial_assign(argv[2]) < 0) return 1; #endif #endif /* CONFIG_CONSOLE_MUX */ @@ -258,28 +257,28 @@ int _do_env_set (int flag, int argc, char * const argv[]) */ if (ep) { /* variable exists */ #ifndef CONFIG_ENV_OVERWRITE - if ((strcmp (name, "serial#") == 0) || - ((strcmp (name, "ethaddr") == 0) + if ((strcmp(name, "serial#") == 0) || + ((strcmp(name, "ethaddr") == 0) #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR) - && (strcmp (ep->data,MK_STR(CONFIG_ETHADDR)) != 0) + && (strcmp(ep->data, MK_STR(CONFIG_ETHADDR)) != 0) #endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */ ) ) { - printf ("Can't overwrite \"%s\"\n", name); + printf("Can't overwrite \"%s\"\n", name); return 1; } #endif /* * Switch to new baudrate if new baudrate is supported */ - if (strcmp(name,"baudrate") == 0) { + if (strcmp(name, "baudrate") == 0) { int baudrate = simple_strtoul(argv[2], NULL, 10); int i; - for (i=0; i<N_BAUDRATES; ++i) { + for (i = 0; i < N_BAUDRATES; ++i) { if (baudrate == baudrate_table[i]) break; } if (i == N_BAUDRATES) { - printf ("## Baudrate %d bps not supported\n", + printf("## Baudrate %d bps not supported\n", baudrate); return 1; } @@ -291,11 +290,11 @@ int _do_env_set (int flag, int argc, char * const argv[]) gd->bd->bi_baudrate = baudrate; #endif - serial_setbrg (); + serial_setbrg(); udelay(50000); for (;;) { if (getc() == '\r') - break; + break; } } } @@ -309,14 +308,15 @@ int _do_env_set (int flag, int argc, char * const argv[]) /* * Insert / replace new value */ - for (i=2,len=0; i<argc; ++i) { + for (i = 2, len = 0; i < argc; ++i) len += strlen(argv[i]) + 1; - } - if ((value = malloc(len)) == NULL) { + + value = malloc(len); + if (value == NULL) { printf("## Can't malloc %d bytes\n", len); return 1; } - for (i=2,s=value; i<argc; ++i) { + for (i = 2, s = value; i < argc; ++i) { char *v = argv[i]; while ((*s++ = *v++) != '\0') @@ -341,12 +341,12 @@ int _do_env_set (int flag, int argc, char * const argv[]) * entry in the environment is changed */ - if (strcmp(name,"ipaddr") == 0) { + if (strcmp(name, "ipaddr") == 0) { char *s = argv[2]; /* always use only one arg */ char *e; unsigned long addr; bd->bi_ip_addr = 0; - for (addr=0, i=0; i<4; ++i) { + for (addr = 0, i = 0; i < 4; ++i) { ulong val = s ? simple_strtoul(s, &e, 10) : 0; addr <<= 8; addr |= (val & 0xFF); @@ -354,20 +354,20 @@ int _do_env_set (int flag, int argc, char * const argv[]) } bd->bi_ip_addr = htonl(addr); return 0; - } else if (strcmp(argv[1],"loadaddr") == 0) { + } else if (strcmp(argv[1], "loadaddr") == 0) { load_addr = simple_strtoul(argv[2], NULL, 16); return 0; } #if defined(CONFIG_CMD_NET) - else if (strcmp(argv[1],"bootfile") == 0) { - copy_filename (BootFile, argv[2], sizeof(BootFile)); + else if (strcmp(argv[1], "bootfile") == 0) { + copy_filename(BootFile, argv[2], sizeof(BootFile)); return 0; } #endif return 0; } -int setenv (char *varname, char *varvalue) +int setenv(char *varname, char *varvalue) { char * const argv[4] = { "setenv", varname, varvalue, NULL }; if ((varvalue == NULL) || (varvalue[0] == '\0')) @@ -376,7 +376,7 @@ int setenv (char *varname, char *varvalue) return _do_env_set(0, 3, argv); } -int do_env_set (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 2) return cmd_usage(cmdtp); @@ -388,7 +388,7 @@ int do_env_set (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * Prompt for environment variable */ #if defined(CONFIG_CMD_ASKENV) -int do_env_ask ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { extern char console_buffer[CONFIG_SYS_CBSIZE]; char message[CONFIG_SYS_CBSIZE]; @@ -416,10 +416,10 @@ int do_env_ask ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; default: /* env_ask envname message1 ... messagen size */ - for (i=2,pos=0; i < argc - 1; i++) { - if (pos) { + for (i = 2, pos = 0; i < argc - 1; i++) { + if (pos) message[pos++] = ' '; - } + strcpy(message+pos, argv[i]); pos += strlen(argv[i]); } @@ -482,7 +482,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * return address of storage for that variable, * or NULL if not found */ -char *getenv (char *name) +char *getenv(char *name) { if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */ ENTRY e, *ep; @@ -493,7 +493,7 @@ char *getenv (char *name) e.data = NULL; hsearch_r(e, FIND, &ep, &env_htab); - return (ep ? ep->data : NULL); + return ep ? ep->data : NULL; } /* restricted capabilities before import */ @@ -507,23 +507,24 @@ char *getenv (char *name) /* * Look up variable from environment for restricted C runtime env. */ -int getenv_f (char *name, char *buf, unsigned len) +int getenv_f(char *name, char *buf, unsigned len) { int i, nxt; - for (i=0; env_get_char(i) != '\0'; i=nxt+1) { + for (i = 0; env_get_char(i) != '\0'; i = nxt+1) { int val, n; - for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) { - if (nxt >= CONFIG_ENV_SIZE) { - return (-1); - } + for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) { + if (nxt >= CONFIG_ENV_SIZE) + return -1; } - if ((val=envmatch((uchar *)name, i)) < 0) + + val = envmatch((uchar *)name, i); + if (val < 0) continue; /* found; copy out */ - for (n=0; n<len; ++n, ++buf) { + for (n = 0; n < len; ++n, ++buf) { if ((*buf = env_get_char(val++)) == '\0') return n; } @@ -535,18 +536,18 @@ int getenv_f (char *name, char *buf, unsigned len) return n; } - return (-1); + return -1; } #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) -int do_env_save (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - extern char * env_name_spec; + extern char *env_name_spec; - printf ("Saving Environment to %s...\n", env_name_spec); + printf("Saving Environment to %s...\n", env_name_spec); - return (saveenv() ? 1 : 0); + return saveenv() ? 1 : 0; } U_BOOT_CMD( @@ -566,27 +567,26 @@ U_BOOT_CMD( * If the names match, return the index for the value2, else NULL. */ -int envmatch (uchar *s1, int i2) +int envmatch(uchar *s1, int i2) { - while (*s1 == env_get_char(i2++)) if (*s1++ == '=') - return(i2); + return i2; if (*s1 == '\0' && env_get_char(i2-1) == '=') - return(i2); - return(-1); + return i2; + return -1; } -static int do_env_default(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static int do_env_default(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - if ((argc != 2) || (strcmp(argv[1], "-f") != 0)) { + if ((argc != 2) || (strcmp(argv[1], "-f") != 0)) return cmd_usage(cmdtp); - } + set_default_env("## Resetting to default environment\n"); return 0; } -static int do_env_delete(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static int do_env_delete(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { printf("Not implemented yet\n"); return 0; @@ -673,9 +673,8 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv } } - if (argc < 1) { + if (argc < 1) return cmd_usage(cmdtp); - } addr = (char *)simple_strtoul(argv[0], NULL, 16); @@ -719,7 +718,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv envp->flags = ACTIVE_FLAG; #endif } - sprintf(buf, "%zX", (size_t)(len + offsetof(env_t,data))); + sprintf(buf, "%zX", (size_t)(len + offsetof(env_t, data))); setenv("filesize", buf); return 0; @@ -744,7 +743,7 @@ sep_err: * size: length of input data; if missing, proper '\0' * termination is mandatory */ -static int do_env_import(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static int do_env_import(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *cmd, *addr; char sep = '\n'; @@ -784,9 +783,8 @@ static int do_env_import(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg } } - if (argc < 1) { + if (argc < 1) return cmd_usage(cmdtp); - } if (!fmt) printf("## Warning: defaulting to text format\n"); @@ -844,7 +842,7 @@ sep_err: #endif #if defined(CONFIG_CMD_RUN) -extern int do_run (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); #endif /* @@ -885,7 +883,7 @@ void env_reloc(void) } #endif -static int do_env (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +static int do_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { cmd_tbl_t *cp; |