]> git.sur5r.net Git - u-boot/commitdiff
tricorder: panic() on unknown board
authorAndreas Bießmann <andreas.biessmann@corscience.de>
Fri, 6 Sep 2013 13:04:53 +0000 (15:04 +0200)
committerTom Rini <trini@ti.com>
Fri, 1 Nov 2013 19:55:59 +0000 (15:55 -0400)
Also hang() the board on panic().

Signed-off-by: Andreas Bießmann <andreas.biessmann@corscience.de>
board/corscience/tricorder/tricorder.c
include/configs/tricorder.h

index c7099e5e3a05cbd550a6dcfb5133fec81917c3e5..b8129168b9fa7641203a757105f979e5bed96745 100644 (file)
 #include <common.h>
 #include <twl4030.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mem.h>
 #include "tricorder.h"
+#include "tricorder-eeprom.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,12 +36,87 @@ int board_init(void)
        return 0;
 }
 
+/**
+ * get_eeprom - read the eeprom
+ *
+ * @eeprom - pointer to a eeprom struct to fill
+ *
+ * This function will panic() on wrong EEPROM content
+ */
+static void get_eeprom(struct tricorder_eeprom *eeprom)
+{
+       int ret;
+
+       if (!eeprom)
+               panic("No eeprom given!\n");
+
+       ret = gpio_request(7, "BMS");
+       if (ret)
+               panic("gpio: requesting BMS pin failed\n");
+
+       ret = gpio_direction_input(7);
+       if (ret)
+               panic("gpio: set BMS as input failed\n");
+
+       ret = gpio_get_value(7);
+       if (ret < 0)
+               panic("gpio: get BMS pin state failed\n");
+
+       gpio_free(7);
+
+       if (ret == 0) {
+               /* BMS is _not_ set, do the EEPROM check */
+               ret = tricorder_get_eeprom(0x51, eeprom);
+               if (!ret) {
+                       if (strncmp(eeprom->board_name, "CS10411", 7) != 0)
+                               panic("Wrong board name '%.*s'\n",
+                                     sizeof(eeprom->board_name),
+                                               eeprom->board_name);
+                       if (eeprom->board_version[0] < 'D')
+                               panic("Wrong board version '%.*s'\n",
+                                     sizeof(eeprom->board_version),
+                                               eeprom->board_version);
+               } else {
+                       panic("Could not get board revision\n");
+               }
+       }
+}
+
+/**
+ * print_hwversion - print out a HW version string
+ *
+ * @eeprom - pointer to the eeprom
+ */
+static void print_hwversion(struct tricorder_eeprom *eeprom)
+{
+       size_t len;
+       if (!eeprom)
+               panic("No eeprom given!");
+
+       printf("Board %.*s:%.*s serial %.*s",
+              sizeof(eeprom->board_name), eeprom->board_name,
+              sizeof(eeprom->board_version), eeprom->board_version,
+              sizeof(eeprom->board_serial), eeprom->board_serial);
+
+       len = strnlen(eeprom->interface_version,
+                     sizeof(eeprom->interface_version));
+       if (len > 0)
+               printf(" HW interface version %.*s",
+                      sizeof(eeprom->interface_version),
+                      eeprom->interface_version);
+       puts("\n");
+}
+
 /*
  * Routine: misc_init_r
  * Description: Configure board specific parts
  */
 int misc_init_r(void)
 {
+       struct tricorder_eeprom eeprom;
+       get_eeprom(&eeprom);
+       print_hwversion(&eeprom);
+
        twl4030_power_init();
 #ifdef CONFIG_TWL4030_LED
        twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
index a3d8f12f9765a1e79089a35a4bda4001160f1a03..087c44ca513f4e89130b45528ec1abb143bc4178 100644 (file)
@@ -57,6 +57,9 @@
 
 /* Hardware drivers */
 
+/* GPIO support */
+#define CONFIG_OMAP_GPIO
+
 /* NS16550 Configuration */
 #define CONFIG_SYS_NS16550
 #define CONFIG_SYS_NS16550_SERIAL
 
 #define CONFIG_BOOTDELAY               3
 
+/* hang() the board on panic() */
+#define CONFIG_PANIC_HANG
+
 /* environment placement (for NAND), is different for FLASHCARD but does not
  * harm there */
 #define CONFIG_ENV_OFFSET              0x120000    /* env start */
 #define CONFIG_SPL_NAND_SIMPLE
 
 #define CONFIG_SPL_BOARD_INIT
+#define CONFIG_SPL_GPIO_SUPPORT
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
 #define CONFIG_SPL_I2C_SUPPORT