diff options
author | Rob Herring <robh@kernel.org> | 2014-11-17 15:37:26 -0600 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2014-11-17 15:37:26 -0600 |
commit | 43dbf1ec084e8541e9ce088d6d28603b5e53d070 (patch) | |
tree | 8b7ae703644c4a549031474d0b3c1c30196de8c4 /board | |
parent | 9e8ee913228a55458d570028672c6701b2b3f59e (diff) | |
parent | 248084f4fec630cc54d92b0aefcf4a94f6d294ac (diff) |
Merge branches 'v2014.10-pxa1928' and 'v2014.10-jetson' into v2014.10-ara
Diffstat (limited to 'board')
-rw-r--r-- | board/nvidia/common/board.c | 158 | ||||
-rw-r--r-- | board/nvidia/jetson-tk1/jetson-tk1.c | 39 | ||||
-rw-r--r-- | board/nvidia/jetson-tk1/pinmux-config-jetson-tk1.h | 3 |
3 files changed, 196 insertions, 4 deletions
diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index d01abcee13..5306a56aab 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -40,6 +40,7 @@ #include <i2c.h> #include <spi.h> #include "emc.h" +#include <libfdt.h> DECLARE_GLOBAL_DATA_PTR; @@ -164,9 +165,6 @@ int board_init(void) #ifdef CONFIG_TEGRA_LP0 /* save Sdram params to PMC 2, 4, and 24 for WB0 */ warmboot_save_sdram_params(); - - /* prepare the WB code to LP0 location */ - warmboot_prepare_code(TEGRA_LP0_ADDR, TEGRA_LP0_SIZE); #endif return 0; @@ -201,6 +199,34 @@ int board_late_init(void) /* Make sure we finish initing the LCD */ tegra_lcd_check_next_stage(gd->fdt_blob, 1); #endif + +#ifdef CONFIG_TEGRA_LP0 + /* prepare the WB code to LP0 location */ + warmboot_prepare_code(TEGRA_LP0_ADDR, TEGRA_LP0_SIZE); +#endif + +#ifdef CONFIG_TEGRA124 + if (getenv_yesno("recovery") != 1) { + struct pmc_ctlr *pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE; + unsigned int scratch = readl(&pmc->pmc_scratch0); + + writel(scratch & ~(1 << 30) & ~(1 << 31), &pmc->pmc_scratch0); + if (scratch & (1 << 30)) { + printf("Found reboot-mode = bootloader!\n"); + do_fastboot(NULL, 0, 0, NULL); + setenv("recovery", "0"); + } + else if (scratch & (1 << 31)) { + printf("Found reboot-mode = recovery!\n"); + setenv("recovery", "1"); + } + else { + printf("No reboot-mode found\n"); + setenv("recovery", "0"); + } + } +#endif + return 0; } @@ -253,3 +279,129 @@ void pad_init_mmc(struct mmc_host *host) #endif /* T30 */ } #endif /* MMC */ + +#ifdef CONFIG_SERIAL_TAG +void get_board_serial(struct tag_serialnr *serialnr) +{ + /* + * Check if we can read the EEPROM serial number + * and if so, use it instead. + */ +#if defined(CONFIG_SERIAL_EEPROM) + uchar data_buffer[NUM_SERIAL_ID_BYTES]; + + i2c_set_bus_num(EEPROM_I2C_BUS); + + if (i2c_read(EEPROM_I2C_ADDRESS, EEPROM_SERIAL_OFFSET, + 1, data_buffer, NUM_SERIAL_ID_BYTES)) { + printf("%s: I2C read of bus %d chip %d addr %d failed!\n", + __func__, EEPROM_I2C_BUS, EEPROM_I2C_ADDRESS, + EEPROM_SERIAL_OFFSET); + } else { +#ifdef DEBUG + int i; + printf("get_board_serial: Got "); + for (i = 0; i < NUM_SERIAL_ID_BYTES; i++) + printf("%02X:", data_buffer[i]); + printf("\n"); +#endif + serialnr->high = data_buffer[2]; + serialnr->high |= (u32)data_buffer[3] << 8; + serialnr->high |= (u32)data_buffer[0] << 16; + serialnr->high |= (u32)data_buffer[1] << 24; + + serialnr->low = data_buffer[7]; + serialnr->low |= (u32)data_buffer[6] << 8; + serialnr->low |= (u32)data_buffer[5] << 16; + serialnr->low |= (u32)data_buffer[4] << 24; + + printf("SEEPROM serialnr->high = %08X, ->low = %08X\n", + serialnr->high, serialnr->low); + } +#else + debug("No serial EEPROM onboard, using default values\n"); + + /* pass board id to kernel */ + serialnr->high = CONFIG_TEGRA_SERIAL_HIGH; + serialnr->low = CONFIG_TEGRA_SERIAL_LOW; + /* TODO: use FDT */ + + debug("Config file serialnr->high = %08X, ->low = %08X\n", + serialnr->high, serialnr->low); + +#endif /* SERIAL_EEPROM */ +} + +#ifdef CONFIG_OF_BOARD_SETUP +void fdt_serial_tag_setup(void *blob, bd_t *bd) +{ + struct tag_serialnr serialnr; + int offset, ret; + u32 val; + + offset = fdt_path_offset(blob, "/chosen/board_info"); + if (offset < 0) { + int chosen = fdt_path_offset(blob, "/chosen"); + offset = fdt_add_subnode(blob, chosen, "board_info"); + if (offset < 0) { + printf("ERROR: add node /chosen/board_info: %s.\n", + fdt_strerror(offset)); + return; + } + } + + get_board_serial(&serialnr); + + val = (serialnr.high & 0xFF0000) >> 16; + val |= (serialnr.high & 0xFF000000) >> 16; + val = cpu_to_fdt32(val); + ret = fdt_setprop(blob, offset, "id", &val, sizeof(val)); + if (ret < 0) { + printf("ERROR: could not update id property %s.\n", + fdt_strerror(ret)); + } + + val = serialnr.high & 0xFFFF; + val = cpu_to_fdt32(val); + ret = fdt_setprop(blob, offset, "sku", &val, sizeof(val)); + if (ret < 0) { + printf("ERROR: could not update sku property %s.\n", + fdt_strerror(ret)); + } + + val = serialnr.low >> 24; + val = cpu_to_fdt32(val); + ret = fdt_setprop(blob, offset, "fab", &val, sizeof(val)); + if (ret < 0) { + printf("ERROR: could not update fab property %s.\n", + fdt_strerror(ret)); + } + + val = (serialnr.low >> 16) & 0xFF; + val = cpu_to_fdt32(val); + ret = fdt_setprop(blob, offset, "major_revision", &val, sizeof(val)); + if (ret < 0) { + printf("ERROR: could not update major_revision property %s.\n", + fdt_strerror(ret)); + } + + val = (serialnr.low >> 8) & 0xFF; + val = cpu_to_fdt32(val); + ret = fdt_setprop(blob, offset, "minor_revision", &val, sizeof(val)); + if (ret < 0) { + printf("ERROR: could not update minor_revision property %s.\n", + fdt_strerror(ret)); + } +} +#endif /* OF_BOARD_SETUP */ +#endif /* SERIAL_TAG */ + +#ifdef CONFIG_OF_BOARD_SETUP +void ft_board_setup(void *blob, bd_t *bd) +{ + /* Overwrite DT file with right board info properties */ +#ifdef CONFIG_SERIAL_TAG + fdt_serial_tag_setup(blob, bd); +#endif /* SERIAL_TAG */ +} +#endif /* OF_BOARD_SETUP */ diff --git a/board/nvidia/jetson-tk1/jetson-tk1.c b/board/nvidia/jetson-tk1/jetson-tk1.c index 5d37718f3b..9e6c4d4e3d 100644 --- a/board/nvidia/jetson-tk1/jetson-tk1.c +++ b/board/nvidia/jetson-tk1/jetson-tk1.c @@ -8,8 +8,11 @@ #include <common.h> #include <asm/arch/gpio.h> #include <asm/arch/pinmux.h> +#include <asm/gpio.h> #include "pinmux-config-jetson-tk1.h" +#define KEY_RECOVERY_GPIO GPIO_PI1 + /* * Routine: pinmux_init * Description: Do individual peripheral pinmux configs @@ -27,3 +30,39 @@ void pinmux_init(void) pinmux_config_drvgrp_table(jetson_tk1_drvgrps, ARRAY_SIZE(jetson_tk1_drvgrps)); } + +#ifdef CONFIG_MISC_INIT_R +int misc_init_r(void) +{ + int bootdelay = 2; + int abort = 0; + unsigned long ts; + + /* Get GPIOs */ + gpio_request(KEY_RECOVERY_GPIO, "recovery_btn"); + + printf("Checking for recovery ...\n"); + /* delay 1000 ms */ + while ((bootdelay > 0) && (!abort)) { + --bootdelay; + /* delay 1000 ms */ + ts = get_timer(0); + do { + /* check for FORCE_RECOVERY button */ + if (!gpio_get_value(KEY_RECOVERY_GPIO)) { + printf("\n*** RECOVERY BUTTON ***"); + setenv("recovery", "1"); + abort = 1; + } + udelay(10000); + } while (!abort && get_timer(ts) < 1000); + printf("."); + } + printf("\n"); + + /* Free GPIOs */ + gpio_free(KEY_RECOVERY_GPIO); + + return 0; +} +#endif diff --git a/board/nvidia/jetson-tk1/pinmux-config-jetson-tk1.h b/board/nvidia/jetson-tk1/pinmux-config-jetson-tk1.h index d338818a64..eebf5456c1 100644 --- a/board/nvidia/jetson-tk1/pinmux-config-jetson-tk1.h +++ b/board/nvidia/jetson-tk1/pinmux-config-jetson-tk1.h @@ -27,6 +27,7 @@ static const struct tegra_gpio_config jetson_tk1_gpio_inits[] = { GPIO_INIT(H6, IN), GPIO_INIT(H7, OUT0), GPIO_INIT(I0, OUT0), + GPIO_INIT(I1, IN), GPIO_INIT(I2, OUT0), GPIO_INIT(I4, OUT0), GPIO_INIT(I5, IN), @@ -151,7 +152,7 @@ static const struct pmux_pingrp_config jetson_tk1_pingrps[] = { PINCFG(PH6, DEFAULT, UP, NORMAL, INPUT, DEFAULT, DEFAULT), PINCFG(PH7, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT), PINCFG(PI0, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT), - PINCFG(PI1, RSVD1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT), + PINCFG(PI1, DEFAULT, UP, TRISTATE, INPUT, DEFAULT, DEFAULT), PINCFG(PI2, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT), PINCFG(PI3, SPI4, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT), PINCFG(PI4, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT), |