From patchwork Fri Sep 6 13:04:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 273183 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7B2702C00D8 for ; Fri, 6 Sep 2013 23:04:35 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DD7B94A096; Fri, 6 Sep 2013 15:04:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eIoh9IUtfO64; Fri, 6 Sep 2013 15:04:27 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 68FAF4A088; Fri, 6 Sep 2013 15:04:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1A04B4A092 for ; Fri, 6 Sep 2013 15:03:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XST8LPe1XQkf for ; Fri, 6 Sep 2013 15:03:51 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-bk0-f41.google.com (mail-bk0-f41.google.com [209.85.214.41]) by theia.denx.de (Postfix) with ESMTPS id 0D8A14A062 for ; Fri, 6 Sep 2013 15:03:26 +0200 (CEST) Received: by mail-bk0-f41.google.com with SMTP id na10so1317500bkb.28 for ; Fri, 06 Sep 2013 06:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=TUyubXKX2x3qgvJBb/V3D2waWEJWACgQBJMa4oPvwlQ=; b=RGibEpTqA8rAFFagK6G/OKrYsr6lN2sPUQmM2RFkENEKksy4zZXRRKURWx7sPR+HxN ji5k31xIAqCHlddfxbrLW8qvzcSHzjun057ADDVttyEpK7SoK4qK/T/Y8rFXdGCUCpXN 8ARypgvH2N6XgYMBXhJHmZNJWXjMwxa87cPB0u0uXJLJnP6oNpCeUBg1o/I0i5byc5NH 7wcMIJd36Fk2K3cwLPkAN+M3U36rovgGaWLFP4cA2Bh63xu67QVv0TQHK+7hpPJQHlE1 XWUySzaBtIaxEiDcQ4lx9GQXLGe0e9YtQsOrgjGfjo+AQT23O5AILVI7poQ23/WG1ilw W7Cw== X-Received: by 10.204.123.199 with SMTP id q7mr2339939bkr.10.1378472605739; Fri, 06 Sep 2013 06:03:25 -0700 (PDT) Received: from localhost ([2a01:198:47b:1:210:75ff:fe1a:cd1e]) by mx.google.com with ESMTPSA id qx2sm681229bkb.16.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 06 Sep 2013 06:03:25 -0700 (PDT) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: u-boot@lists.denx.de Date: Fri, 6 Sep 2013 15:04:53 +0200 Message-Id: <1378472698-18557-8-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1378472698-18557-1-git-send-email-andreas.devel@googlemail.com> References: <1378472698-18557-1-git-send-email-andreas.devel@googlemail.com> MIME-Version: 1.0 Cc: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= , Thomas Weber Subject: [U-Boot] [PATCH 08/13] tricorder: panic() on unknown board X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Andreas Bießmann Also hang() the board on panic(). Signed-off-by: Andreas Bießmann --- board/corscience/tricorder/tricorder.c | 77 ++++++++++++++++++++++++++++++++ include/configs/tricorder.h | 7 +++ 2 files changed, 84 insertions(+) diff --git a/board/corscience/tricorder/tricorder.c b/board/corscience/tricorder/tricorder.c index c7099e5..b812916 100644 --- a/board/corscience/tricorder/tricorder.c +++ b/board/corscience/tricorder/tricorder.c @@ -13,11 +13,13 @@ #include #include #include +#include #include #include #include #include #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); diff --git a/include/configs/tricorder.h b/include/configs/tricorder.h index 9e4e0f0..26b7a8b 100644 --- a/include/configs/tricorder.h +++ b/include/configs/tricorder.h @@ -57,6 +57,9 @@ /* Hardware drivers */ +/* GPIO support */ +#define CONFIG_OMAP_GPIO + /* NS16550 Configuration */ #define CONFIG_SYS_NS16550 #define CONFIG_SYS_NS16550_SERIAL @@ -150,6 +153,9 @@ #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 */ @@ -311,6 +317,7 @@ #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