From patchwork Sun Nov 15 18:58:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 71682 X-Patchwork-Delegate: s-paulraj@ti.com Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 3B457EC8100 for ; Sun, 15 Nov 2009 20:01:38 +0100 (CET) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 2BAC8C7FA5DD for ; Sun, 15 Nov 2009 20:01:38 +0100 (MET) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.9) for (single-drop); Sun, 15 Nov 2009 20:01:38 +0100 (MET) Received: from murder (svr19.m-online.net [192.168.3.147]) by backend2 (Cyrus v2.2.12) with LMTPA; Sun, 15 Nov 2009 19:58:40 +0100 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend3.pop.m-online.net (Cyrus v2.2.13) with LMTPA; Sun, 15 Nov 2009 19:58:40 +0100 Received: from scanner-1.m-online.net (scanner-1.m-online.net [192.168.2.221]) by mail.m-online.net (Postfix) with ESMTP id 95EEB200161; Sun, 15 Nov 2009 19:58:40 +0100 (CET) Received: from mxin-1.m-online.net ([192.168.1.21]) by scanner-1.m-online.net (scanner-1.m-online.net [192.168.2.221]) (amavisd-new, port 10026) with ESMTP id 02130-02; Sun, 15 Nov 2009 19:58:39 +0100 (CET) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-2.m-online.net (Postfix) with ESMTP id 3EA0646C0AB; Sun, 15 Nov 2009 19:58:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B654A280E9; Sun, 15 Nov 2009 19:58:33 +0100 (CET) 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 an0b4OsoSO8B; Sun, 15 Nov 2009 19:58:33 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B1AF3280EB; Sun, 15 Nov 2009 19:58:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B3D13280DC for ; Sun, 15 Nov 2009 19:58:26 +0100 (CET) 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 ci73OCM7i8ws for ; Sun, 15 Nov 2009 19:58:26 +0100 (CET) Received: from mail-fx0-f228.google.com (mail-fx0-f228.google.com [209.85.220.228]) by theia.denx.de (Postfix) with ESMTP id 06D80280DB for ; Sun, 15 Nov 2009 19:58:24 +0100 (CET) Received: by fxm28 with SMTP id 28so5297742fxm.25 for ; Sun, 15 Nov 2009 10:58:24 -0800 (PST) Received: by 10.204.154.216 with SMTP id p24mr2587165bkw.16.1258311504037; Sun, 15 Nov 2009 10:58:24 -0800 (PST) Received: from localhost.localdomain (p5B04068B.dip0.t-ipconnect.de [91.4.6.139]) by mx.google.com with ESMTPS id 2sm6460879fks.18.2009.11.15.10.58.22 (version=SSLv3 cipher=RC4-MD5); Sun, 15 Nov 2009 10:58:23 -0800 (PST) From: Dirk Behme To: u-boot@lists.denx.de Date: Sun, 15 Nov 2009 19:58:14 +0100 Message-Id: <1258311494-10895-1-git-send-email-dirk.behme@googlemail.com> X-Mailer: git-send-email 1.6.1 Subject: [U-Boot] [PATCH] OMAP3: BeagleBoard: Add expansion board auto detection 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 X-Virus-Scanned: by amavisd-new at m-online.net At BeagleBoard's expansion header various expansion boards can be attached. To be able to auto detect these boards, it was agreed to put a serial EEPROM at I2C bus 1 which contains some vendor and device specific information in it's first four bytes. Add logic to read the content of this serial EEPROM, set pin mux based on this information and print the info found. See http://elinux.org/BeagleBoardPinMux#Expansion_boards for details. Signed-off-by: Dirk Behme --- Notes: - This patch depends on OMAP3 I2C bus switch patch in I2C next http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=commit;h=5656176c23a91bcc88d020bee2be0d9d0c70ce3e - This patch is intended to be applied in next merge window as soon as I2C next is merged. - This patch is tested on BeagleBoard with and without TinCanTools Zippy expansion board attached. - Could anybody additionally test it on Beagle *without* Zippy attached? It seems that i2c_probe() sometimes returns 0 even without Zippy (??). This results in scan of non-existent devices and some "timed out in xxx" message which can be ignored, but are annoying. board/ti/beagle/beagle.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++ board/ti/beagle/beagle.h | 31 +++++++++++++++++++ 2 files changed, 105 insertions(+) Index: u-boot-main/board/ti/beagle/beagle.c =================================================================== --- u-boot-main.orig/board/ti/beagle/beagle.c +++ u-boot-main/board/ti/beagle/beagle.c @@ -40,6 +40,12 @@ static int beagle_revision_c; +static struct { + unsigned int device_vendor; + unsigned char revision; + unsigned char content; +} expansion_config; + /* * Routine: board_init * Description: Early hardware init. @@ -57,6 +63,66 @@ int board_init(void) return 0; } +#define EXPANSION_EEPROM_I2C_BUS 1 +#define EXPANSION_EEPROM_I2C_ADDRESS 0x50 + +#define TINCANTOOLS_ZIPPY 0x01000100 +#define TINCANTOOLS_ZIPPY2 0x02000100 +#define TINCANTOOLS_TRAINER 0x03000100 +#define TINCANTOOLS_SHOWDOG 0x04000100 + +/* + * Routine: print_expansion_config + * Description: Print info about board connected to expansion header. + * It uses the information from scan_expansion(), + */ +void print_expansion_config(void) { + + switch(expansion_config.device_vendor) { + case TINCANTOOLS_ZIPPY: + printf("TinCanTools Zippy "); + break; + case TINCANTOOLS_ZIPPY2: + printf("TinCanTools Zippy2 "); + break; + case TINCANTOOLS_TRAINER: + printf("TinCanTools Trainer "); + break; + case TINCANTOOLS_SHOWDOG: + printf("TinCanTools ShowDog "); + break; + default: + return; + } + printf("board, revision 0x%02x, content code 0x%02x, found\n", + expansion_config.revision, expansion_config.content); +} + + /* + * Routine: scan_expansion + * Description: This function checks for expansion board connected to + * Beagle's expansion header. This done by checking I2C + * bus 1 for the availability of an AT24C01B serial EEPROM. + */ +void scan_expansion(void) +{ + /* Set pin mux and switch to I2C bus 1 */ + MUX_I2C2(); + i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS); + + /* Check if expansion EEPROM is there*/ + if(i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 0) { + /* EEPROM found, read configuration data */ + i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, + (u8 *)&expansion_config, sizeof(expansion_config)); + } + + /* Switch back to default bus and pin mux */ + i2c_set_bus_num(0); + MUX_I2C2_DEFAULT(); +} + + /* * Routine: beagle_get_revision * Description: Return the revision of the BeagleBoard this code is running on. @@ -124,6 +190,14 @@ int misc_init_r(void) dieid_num_r(); + scan_expansion(); + + if (expansion_config.device_vendor == TINCANTOOLS_ZIPPY) { + MUX_ZIPPY(); + } + + print_expansion_config(); + return 0; } Index: u-boot-main/board/ti/beagle/beagle.h =================================================================== --- u-boot-main.orig/board/ti/beagle/beagle.h +++ u-boot-main/board/ti/beagle/beagle.h @@ -381,4 +381,35 @@ const omap3_sysinfo sysinfo = { MUX_VAL(CP(UART2_RTS), (IDIS | PTD | DIS | M0)) /*UART2_RTS*/\ MUX_VAL(CP(UART2_TX), (IDIS | PTD | DIS | M0)) /*UART2_TX*/ +#define MUX_I2C2() \ + MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M0)) /*I2C2_SCL*/\ + MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M0)) /*I2C2_SDA*/ + +#define MUX_I2C2_DEFAULT() \ + MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M4)) /*GPIO_168*/\ + MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M4)) /*GPIO_183*/ + +#define MUX_ZIPPY() \ + MUX_VAL(CP(MMC2_CLK), (IEN | PTU | EN | M0)) /*MMC2_CLK*/\ + MUX_VAL(CP(MMC2_CMD), (IEN | PTU | EN | M0)) /*MMC2_CMD*/\ + MUX_VAL(CP(MMC2_DAT0), (IEN | PTU | EN | M0)) /*MMC2_DAT0*/\ + MUX_VAL(CP(MMC2_DAT1), (IEN | PTU | EN | M0)) /*MMC2_DAT1*/\ + MUX_VAL(CP(MMC2_DAT2), (IEN | PTU | EN | M0)) /*MMC2_DAT2*/\ + MUX_VAL(CP(MMC2_DAT3), (IEN | PTU | EN | M0)) /*MMC2_DAT3*/\ + MUX_VAL(CP(MMC2_DAT4), (IEN | PTU | EN | M1)) /*MMC2_DIR_DAT0*/\ + MUX_VAL(CP(MMC2_DAT5), (IEN | PTU | EN | M1)) /*MMC2_DIR_DAT1*/\ + MUX_VAL(CP(MMC2_DAT6), (IEN | PTU | EN | M1)) /*MMC2_DIR_CMD*/\ + MUX_VAL(CP(MMC2_DAT7), (IEN | PTU | EN | M1)) /*MMC2_CLKIN*/\ + MUX_VAL(CP(MCBSP1_CLKR), (IEN | PTU | EN | M1)) /*MCSPI4_CLK*/\ + MUX_VAL(CP(MCBSP1_FSR), (IEN | PTU | EN | M4)) /*GPIO_157*/\ + MUX_VAL(CP(MCBSP1_DX), (IEN | PTD | EN | M1)) /*MCSPI4_SIMO*/\ + MUX_VAL(CP(MCBSP1_DR), (IEN | PTD | DIS | M1)) /*MCSPI4_SOMI*/\ + MUX_VAL(CP(MCBSP1_FSX), (IEN | PTD | EN | M1)) /*MCSPI4_CS0*/ \ + MUX_VAL(CP(MCBSP1_CLKX), (IEN | PTD | DIS | M4)) /*GPIO_162*/\ + MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M0)) /*I2C2_SCL*/\ + MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M0)) /*I2C2_SDA*/\ + MUX_VAL(CP(MCBSP3_DX), (IEN | PTD | DIS | M4)) /*GPIO_140*/\ + MUX_VAL(CP(MCBSP3_DR), (IEN | PTD | DIS | M4)) /*GPIO_142*/\ + MUX_VAL(CP(MCBSP3_CLKX), (IEN | PTD | DIS | M4)) /*GPIO_141*/ + #endif