diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/board_f.c | 84 | ||||
-rw-r--r-- | common/cmd_date.c | 5 | ||||
-rw-r--r-- | common/cmd_led.c | 48 | ||||
-rw-r--r-- | common/cmd_nand.c | 9 | ||||
-rw-r--r-- | common/cmd_scsi.c | 4 | ||||
-rw-r--r-- | common/cmd_unzip.c | 47 | ||||
-rw-r--r-- | common/dlmalloc.c | 11 | ||||
-rw-r--r-- | common/spl/spl.c | 22 |
8 files changed, 131 insertions, 99 deletions
diff --git a/common/board_f.c b/common/board_f.c index 775df14..322e070 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -23,6 +23,7 @@ #include <i2c.h> #include <initcall.h> #include <logbuff.h> +#include <malloc.h> #include <mapmem.h> /* TODO: Can we move these into arch/ headers? */ @@ -282,49 +283,6 @@ __weak int arch_cpu_init(void) return 0; } -#ifdef CONFIG_OF_HOSTFILE - -static int read_fdt_from_file(void) -{ - struct sandbox_state *state = state_get_current(); - const char *fname = state->fdt_fname; - void *blob; - loff_t size; - int err; - int fd; - - blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0); - if (!state->fdt_fname) { - err = fdt_create_empty_tree(blob, 256); - if (!err) - goto done; - printf("Unable to create empty FDT: %s\n", fdt_strerror(err)); - return -EINVAL; - } - - err = os_get_filesize(fname, &size); - if (err < 0) { - printf("Failed to file FDT file '%s'\n", fname); - return err; - } - fd = os_open(fname, OS_O_RDONLY); - if (fd < 0) { - printf("Failed to open FDT file '%s'\n", fname); - return -EACCES; - } - if (os_read(fd, blob, size) != size) { - os_close(fd); - return -EIO; - } - os_close(fd); - -done: - gd->fdt_blob = blob; - - return 0; -} -#endif - #ifdef CONFIG_SANDBOX static int setup_ram_buf(void) { @@ -337,28 +295,6 @@ static int setup_ram_buf(void) } #endif -static int setup_fdt(void) -{ -#ifdef CONFIG_OF_CONTROL -# ifdef CONFIG_OF_EMBED - /* Get a pointer to the FDT */ - gd->fdt_blob = __dtb_dt_begin; -# elif defined CONFIG_OF_SEPARATE - /* FDT is at end of image */ - gd->fdt_blob = (ulong *)&_end; -# elif defined(CONFIG_OF_HOSTFILE) - if (read_fdt_from_file()) { - puts("Failed to read control FDT\n"); - return -1; - } -# endif - /* Allow the early environment to override the fdt address */ - gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16, - (uintptr_t)gd->fdt_blob); -#endif - return 0; -} - /* Get the top of usable RAM */ __weak ulong board_get_usable_ram_top(ulong total_size) { @@ -786,17 +722,6 @@ static int mark_bootstage(void) return 0; } -static int initf_malloc(void) -{ -#ifdef CONFIG_SYS_MALLOC_F_LEN - assert(gd->malloc_base); /* Set up by crt0.S */ - gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN; - gd->malloc_ptr = 0; -#endif - - return 0; -} - static int initf_dm(void) { #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN) @@ -826,7 +751,9 @@ static init_fnc_t init_sequence_f[] = { setup_ram_buf, #endif setup_mon_len, - setup_fdt, +#ifdef CONFIG_OF_CONTROL + fdtdec_setup, +#endif #ifdef CONFIG_TRACE trace_early_init, #endif @@ -837,9 +764,6 @@ static init_fnc_t init_sequence_f[] = { #endif arch_cpu_init, /* basic arch cpu dependent setup */ mark_bootstage, -#ifdef CONFIG_OF_CONTROL - fdtdec_check_fdt, -#endif initf_dm, arch_cpu_init_dm, #if defined(CONFIG_BOARD_EARLY_INIT_F) diff --git a/common/cmd_date.c b/common/cmd_date.c index e349166..4a653e5 100644 --- a/common/cmd_date.c +++ b/common/cmd_date.c @@ -27,6 +27,8 @@ static const char * const weekdays[] = { int mk_date (const char *, struct rtc_time *); +static struct rtc_time default_tm = { 0, 0, 0, 1, 1, 2000, 6, 0, 0 }; + static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { struct rtc_time tm; @@ -47,6 +49,9 @@ static int do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (strcmp(argv[1],"reset") == 0) { puts ("Reset RTC...\n"); rtc_reset (); + rcode = rtc_set(&default_tm); + if (rcode) + puts("## Failed to set date after RTC reset\n"); } else { /* initialize tm with current time */ rcode = rtc_get (&tm); diff --git a/common/cmd_led.c b/common/cmd_led.c index 172bc30..b0f1a61 100644 --- a/common/cmd_led.c +++ b/common/cmd_led.c @@ -39,6 +39,12 @@ static const led_tbl_t led_commands[] = { #ifdef STATUS_LED_BIT3 { "3", STATUS_LED_BIT3, NULL, NULL, NULL }, #endif +#ifdef STATUS_LED_BIT4 + { "4", STATUS_LED_BIT4, NULL, NULL, NULL }, +#endif +#ifdef STATUS_LED_BIT5 + { "5", STATUS_LED_BIT5, NULL, NULL, NULL }, +#endif #endif #ifdef STATUS_LED_GREEN { "green", STATUS_LED_GREEN, green_led_off, green_led_on, NULL }, @@ -55,30 +61,39 @@ static const led_tbl_t led_commands[] = { { NULL, 0, NULL, NULL, NULL } }; -enum led_cmd { LED_ON, LED_OFF, LED_TOGGLE }; +enum led_cmd { LED_ON, LED_OFF, LED_TOGGLE, LED_BLINK }; enum led_cmd get_led_cmd(char *var) { - if (strcmp(var, "off") == 0) { + if (strcmp(var, "off") == 0) return LED_OFF; - } - if (strcmp(var, "on") == 0) { + if (strcmp(var, "on") == 0) return LED_ON; - } if (strcmp(var, "toggle") == 0) return LED_TOGGLE; + if (strcmp(var, "blink") == 0) + return LED_BLINK; + return -1; } +/* + * LED drivers providing a blinking LED functionality, like the + * PCA9551, can override this empty weak function + */ +void __weak __led_blink(led_id_t mask, int freq) +{ +} + int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int i, match = 0; enum led_cmd cmd; + int freq; /* Validate arguments */ - if ((argc != 3)) { + if ((argc < 3) || (argc > 4)) return CMD_RET_USAGE; - } cmd = get_led_cmd(argv[2]); if (cmd < 0) { @@ -109,6 +124,13 @@ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) led_commands[i].toggle(); else __led_toggle(led_commands[i].mask); + break; + case LED_BLINK: + if (argc != 4) + return CMD_RET_USAGE; + + freq = simple_strtoul(argv[3], NULL, 10); + __led_blink(led_commands[i].mask, freq); } /* Need to set only 1 led if led_name wasn't 'all' */ if (strcmp("all", argv[1]) != 0) @@ -125,7 +147,7 @@ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } U_BOOT_CMD( - led, 3, 1, do_led, + led, 4, 1, do_led, "[" #ifdef CONFIG_BOARD_SPECIFIC_LED #ifdef STATUS_LED_BIT @@ -140,6 +162,12 @@ U_BOOT_CMD( #ifdef STATUS_LED_BIT3 "3|" #endif +#ifdef STATUS_LED_BIT4 + "4|" +#endif +#ifdef STATUS_LED_BIT5 + "5|" +#endif #endif #ifdef STATUS_LED_GREEN "green|" @@ -153,6 +181,6 @@ U_BOOT_CMD( #ifdef STATUS_LED_BLUE "blue|" #endif - "all] [on|off|toggle]", - "[led_name] [on|off|toggle] sets or clears led(s)" + "all] [on|off|toggle|blink] [blink-freq in ms]", + "[led_name] [on|off|toggle|blink] sets or clears led(s)" ); diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 17fa7ea..9433c80 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -394,9 +394,12 @@ static void nand_print_and_set_info(int idx) printf("%dx ", chip->numchips); printf("%s, sector size %u KiB\n", nand->name, nand->erasesize >> 10); - printf(" Page size %8d b\n", nand->writesize); - printf(" OOB size %8d b\n", nand->oobsize); - printf(" Erase size %8d b\n", nand->erasesize); + printf(" Page size %8d b\n", nand->writesize); + printf(" OOB size %8d b\n", nand->oobsize); + printf(" Erase size %8d b\n", nand->erasesize); + printf(" subpagesize %8d b\n", chip->subpagesize); + printf(" options 0x%8x\n", chip->options); + printf(" bbt options 0x%8x\n", chip->bbt_options); /* Set geometry info */ setenv_hex("nand_writesize", nand->writesize); diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c index a0a62eb..f80f549 100644 --- a/common/cmd_scsi.c +++ b/common/cmd_scsi.c @@ -37,7 +37,7 @@ #define SCSI_DEV_LIST {SCSI_VEND_ID, SCSI_DEV_ID} #endif -#ifdef CONFIG_PCI +#if defined(CONFIG_PCI) && !defined(CONFIG_SCSI_AHCI_PLAT) const struct pci_device_id scsi_device_list[] = { SCSI_DEV_LIST }; #endif static ccb tempccb; /* temporary scsi command buffer */ @@ -179,7 +179,7 @@ int scsi_get_disk_count(void) return scsi_max_devs; } -#ifdef CONFIG_PCI +#if defined(CONFIG_PCI) && !defined(CONFIG_SCSI_AHCI_PLAT) void scsi_init(void) { int busdevfunc; diff --git a/common/cmd_unzip.c b/common/cmd_unzip.c index b02c69e..0686be6 100644 --- a/common/cmd_unzip.c +++ b/common/cmd_unzip.c @@ -39,3 +39,50 @@ U_BOOT_CMD( "unzip a memory region", "srcaddr dstaddr [dstsize]" ); + +static int do_gzwrite(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + block_dev_desc_t *bdev; + int ret; + unsigned char *addr; + unsigned long length; + unsigned long writebuf = 1<<20; + u64 startoffs = 0; + u64 szexpected = 0; + + if (argc < 5) + return CMD_RET_USAGE; + ret = get_device(argv[1], argv[2], &bdev); + if (ret < 0) + return CMD_RET_FAILURE; + + addr = (unsigned char *)simple_strtoul(argv[3], NULL, 16); + length = simple_strtoul(argv[4], NULL, 16); + + if (5 < argc) { + writebuf = simple_strtoul(argv[5], NULL, 16); + if (6 < argc) { + startoffs = simple_strtoull(argv[6], NULL, 16); + if (7 < argc) + szexpected = simple_strtoull(argv[7], + NULL, 16); + } + } + + ret = gzwrite(addr, length, bdev, writebuf, startoffs, szexpected); + + return ret ? CMD_RET_FAILURE : CMD_RET_SUCCESS; +} + +U_BOOT_CMD( + gzwrite, 8, 0, do_gzwrite, + "unzip and write memory to block device", + "<interface> <dev> <addr> length [wbuf=1M [offs=0 [outsize=0]]]\n" + "\twbuf is the size in bytes (hex) of write buffer\n" + "\t\tand should be padded to erase size for SSDs\n" + "\toffs is the output start offset in bytes (hex)\n" + "\toutsize is the size of the expected output (hex bytes)\n" + "\t\tand is required for files with uncompressed lengths\n" + "\t\t4 GiB or larger\n" +); diff --git a/common/dlmalloc.c b/common/dlmalloc.c index b2ce063..b5bb051 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -3261,6 +3261,17 @@ int mALLOPt(param_number, value) int param_number; int value; } } +int initf_malloc(void) +{ +#ifdef CONFIG_SYS_MALLOC_F_LEN + assert(gd->malloc_base); /* Set up by crt0.S */ + gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN; + gd->malloc_ptr = 0; +#endif + + return 0; +} + /* History: diff --git a/common/spl/spl.c b/common/spl/spl.c index 10b5564..690c9b0 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -151,6 +151,8 @@ static void spl_ram_load_image(void) void board_init_r(gd_t *dummy1, ulong dummy2) { u32 boot_device; + int ret; + debug(">>spl:board_init_r()\n"); #if defined(CONFIG_SYS_SPL_MALLOC_START) @@ -158,12 +160,24 @@ void board_init_r(gd_t *dummy1, ulong dummy2) CONFIG_SYS_SPL_MALLOC_SIZE); gd->flags |= GD_FLG_FULL_MALLOC_INIT; #elif defined(CONFIG_SYS_MALLOC_F_LEN) - gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN; + gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN; gd->malloc_ptr = 0; #endif -#ifdef CONFIG_SPL_DM - dm_init_and_scan(true); -#endif + if (IS_ENABLED(CONFIG_OF_CONTROL) && + !IS_ENABLED(CONFIG_SPL_DISABLE_OF_CONTROL)) { + ret = fdtdec_setup(); + if (ret) { + debug("fdtdec_setup() returned error %d\n", ret); + hang(); + } + } + if (IS_ENABLED(CONFIG_SPL_DM)) { + ret = dm_init_and_scan(true); + if (ret) { + debug("dm_init_and_scan() returned error %d\n", ret); + hang(); + } + } #ifndef CONFIG_PPC /* |