summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Wu <cooloney@gmail.com>2014-05-18 06:09:42 +0800
committerWinnie Hsu <whsu@nvidia.com>2014-05-20 13:56:08 -0700
commitbd208887dc22085c995b7357f017f44a8e912796 (patch)
tree3266b2fac84faa11bf30d06ebbbdd3fcfef44066
parent21de12a966e52bbe86e91e3ba1df44e398e0ed8c (diff)
downloadu-boot-bd208887dc22085c995b7357f017f44a8e912796.tar.gz
Tegra: common: add ft_board_setup support
ft_board_setup() provides a hook for U-Boot to overwrite some properties in DT file which will be passed to kernel. Tegra version of ft_board_setup() will firstly overwirte board info related serial numbers in DT file. Also update config files for Tegra as well. Bug 200005196 Bug 1482099 Change-Id: Ide208139618cab12d355dcc48a407e5ea62a31ee Signed-off-by: Bryan Wu <pengw@nvidia.com> Reviewed-on: http://git-master/r/411664 Reviewed-by: Winnie Hsu <whsu@nvidia.com>
-rw-r--r--board/nvidia/common/board.c127
-rw-r--r--include/configs/jetson-tk1.h11
2 files changed, 138 insertions, 0 deletions
diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
index d28dbf2144..72023641f5 100644
--- a/board/nvidia/common/board.c
+++ b/board/nvidia/common/board.c
@@ -41,6 +41,7 @@
#include <i2c.h>
#include <spi.h>
#include "emc.h"
+#include <libfdt.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -257,3 +258,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/include/configs/jetson-tk1.h b/include/configs/jetson-tk1.h
index 18e7ca1cf7..3ff9f9ea80 100644
--- a/include/configs/jetson-tk1.h
+++ b/include/configs/jetson-tk1.h
@@ -27,6 +27,17 @@
#define CONFIG_DEFAULT_DEVICE_TREE tegra124-jetson-tk1
#define CONFIG_OF_CONTROL
#define CONFIG_OF_SEPARATE
+#define CONFIG_OF_LIBFDT
+#define CONFIG_OF_BOARD_SETUP
+
+#define CONFIG_SERIAL_TAG
+
+/* The following are used to retrieve the board id from an eeprom */
+#define CONFIG_SERIAL_EEPROM
+#define EEPROM_I2C_BUS 1
+#define EEPROM_I2C_ADDRESS 0x56
+#define EEPROM_SERIAL_OFFSET 0x04
+#define NUM_SERIAL_ID_BYTES 8
/* High-level configuration options */
#define V_PROMPT "Tegra124 (Jetson TK1) # "