From patchwork Tue Jul 26 08:12:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinhard Meyer X-Patchwork-Id: 106795 X-Patchwork-Delegate: info@emk-elektronik.de 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 D545AB70C3 for ; Tue, 26 Jul 2011 18:26:34 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 838282809E; Tue, 26 Jul 2011 10:26:33 +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 YhbgJE2uDUxW; Tue, 26 Jul 2011 10:26:33 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 78C0D28099; Tue, 26 Jul 2011 10:26:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 095EA28099 for ; Tue, 26 Jul 2011 10:26:28 +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 5nrSf7gYkRQC for ; Tue, 26 Jul 2011 10:26:26 +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 moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by theia.denx.de (Postfix) with ESMTP id 117C328096 for ; Tue, 26 Jul 2011 10:26:25 +0200 (CEST) Received: from ubuntu.fritz.box (p54828532.dip0.t-ipconnect.de [84.130.133.50]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0MDPjh-1Qe9F61dqH-00GsW0; Tue, 26 Jul 2011 10:26:25 +0200 From: Reinhard Meyer To: u-boot@lists.denx.de Date: Tue, 26 Jul 2011 08:12:44 +0000 Message-Id: <1311667964-13186-1-git-send-email-u-boot@emk-elektronik.de> X-Mailer: git-send-email 1.7.4.1 X-Provags-ID: V02:K0:qiMAlhSQtTby9iinQate5nkXgpA/Xu8ZrWFQ2+6Uo4U O7cGQp9DEjlS8JApRL5kmlHyMMJIOJ9DO5G5VJlfhaVReY6Zqc 7driniomcf9GL49HxB3vKoZEzBHOGcDNvJKnUBpjs1vc5gpnkg CRZn/u1aQgf+nsDIkYXj1csfRnF1AQBAUb+9TIkRlGA7lT7Rkx DnF/sxinzjGDyM863Y7Lp5iN3tIMTmRGSQymX0/bgc= Subject: [U-Boot] [PATCH V2] AT91: EMK/TOP9000 board actualization X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This is a general update of all projects involving the TOP9000 CPU module. Changes: Enable the /RESET input Add more ARCH numbers Add EAN13 checksum routine Add reading of VPD EEPROM Remove obsolete reset_phy() Add boot progress LEDs Signed-off-by: Reinhard Meyer --- board/emk/top9000/top9000.c | 131 ++++++++++++++++++++++++++++++++++++++----- 1 files changed, 116 insertions(+), 15 deletions(-) diff --git a/board/emk/top9000/top9000.c b/board/emk/top9000/top9000.c index 61dee62..92e8a9d 100644 --- a/board/emk/top9000/top9000.c +++ b/board/emk/top9000/top9000.c @@ -126,6 +126,7 @@ int board_mmc_getcd(u8 *cd, struct mmc *mmc) int board_early_init_f(void) { struct at91_shdwn *shdwn = (struct at91_shdwn *)ATMEL_BASE_SHDWN; + struct at91_rstc *rstc = (struct at91_rstc *)ATMEL_BASE_RSTC; struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; /* @@ -135,6 +136,13 @@ int board_early_init_f(void) writel(AT91_SHDW_MR_WKMODE0H2L | AT91_SHDW_MR_WKMODE0L2H, &shdwn->mr); + /* + * make sure the board can be reset by + * low level on nRST + */ + writel(AT91_RSTC_KEY | AT91_RSTC_MR_URSTEN, + &rstc->mr); + /* Enable clocks for all PIOs */ writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) | (1 << ATMEL_ID_PIOC), @@ -160,8 +168,14 @@ int board_early_init_f(void) int board_init(void) { - /* arch number of TOP9000 Board */ - gd->bd->bi_arch_number = MACH_TYPE_TOP9000; + /* arch numbers of TOP9000 and baseboards */ +#if defined(CONFIG_EVAL9000) + gd->bd->bi_arch_number = MACH_TYPE_TOP9000_EVAL; +#elif defined(CONFIG_SU9000) + gd->bd->bi_arch_number = MACH_TYPE_TOP9000_SU; +#else + gd->bd->bi_arch_number = MACH_TYPE_TOP9000; +#endif /* adress of boot parameters */ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; @@ -183,10 +197,97 @@ int board_init(void) } #ifdef CONFIG_MISC_INIT_R +static int checksum(char *p) +{ + int sum = 0; + int i = 13; + + while (i > 0) { + if (*p < '0' || *p > '9') + return -1; + sum += *p; + if (!(i & 1)) + sum += 2 * *p; + --i; + ++p; + } + return sum % 10; +} + int misc_init_r(void) { /* read 'factory' part of EEPROM */ - read_factory_r(); + char buf[32]; + char tag[4]; + uint addr = CONFIG_SYS_FACT_OFFSET; + uint len = CONFIG_SYS_FACT_SIZE; + int have_top = 0; + + /* read entries */ + while (len >= 16) { + /* read one entry */ + if (eeprom_read(CONFIG_SYS_I2C_FACT_ADDR, + addr, (uchar *)buf, 16)) + goto bailout; + addr += 16; + len -= 16; + /* get tag field */ + tag[0] = buf[0]; + tag[1] = buf[1]; + tag[2] = buf[2]; + tag[3] = 0; + /* skip entries with bad checksum */ + if (checksum(buf + 3)) + continue; + /* test for specific entries */ + if (!strcmp(tag, "TOP")) { + unsigned serialno; + /* retrieve serialnumber */ + buf[15] = 0; + serialno = simple_strtoul(buf + 10, NULL, 10); + buf[10] = 0; + setenv("board_id", buf); + sprintf(buf, "%05d", serialno); + setenv("serial#", buf); + sprintf(buf, "00:80:d9:0d:%02x:%02x", + serialno / 256, + serialno % 256); + setenv("ethaddr", buf); + have_top = 1; + } else if (!strcmp(tag, "MA2")) { + unsigned serialno; + /* retrieve serialnumber */ + buf[15] = 0; + serialno = simple_strtoul(buf + 10, NULL, 10); + sprintf(buf, "00:80:d9:0e:%02x:%02x", + serialno / 256, + serialno % 256); + setenv("eth2addr", buf); + } else if (!strcmp(tag, "MA3")) { + unsigned serialno; + /* retrieve serialnumber */ + buf[15] = 0; + serialno = simple_strtoul(buf + 10, NULL, 10); + sprintf(buf, "00:80:d9:0e:%02x:%02x", + serialno / 256, + serialno % 256); + setenv("eth3addr", buf); + } else if (!strcmp(tag, "MA4")) { + unsigned serialno; + /* retrieve serialnumber */ + buf[15] = 0; + serialno = simple_strtoul(buf + 10, NULL, 10); + sprintf(buf, "00:80:d9:0e:%02x:%02x", + serialno / 256, + serialno % 256); + setenv("eth4addr", buf); + } + } +bailout: + if (!have_top) { + printf("cannot read factory configuration\n"); + printf("be sure to set ethaddr yourself!\n"); + } return 0; } #endif @@ -199,18 +300,6 @@ int dram_init(void) return 0; } -#ifdef CONFIG_RESET_PHY_R -void reset_phy(void) -{ - /* - * Initialize ethernet HW addresses prior to starting Linux, - * needed for nfsroot. - * TODO: We need to investigate if that is really necessary. - */ - eth_init(gd->bd); -} -#endif - int board_eth_init(bd_t *bis) { int rc = 0; @@ -292,5 +381,17 @@ void iic_scl(int bit) break; } } +#endif +void show_boot_progress(int status) +{ +#if defined(CONFIG_SU9000) + at91_set_pio_output(LED_PORT, LED1_PIN, status & 1); + at91_set_pio_output(LED_PORT, LED2_PIN, status & 2); + at91_set_pio_output(LED_PORT, LED3_PIN, status & 4); + at91_set_pio_output(LED_PORT, LED4_PIN, status & 8); + at91_set_pio_output(LED_PORT, LED5_PIN, status & 16); + at91_set_pio_output(LED_PORT, LED6_PIN, status & 32); #endif +} +