From 59c9245c9a52954c8c084e257bbe55443201614b Mon Sep 17 00:00:00 2001 From: Steve Sakoman Date: Wed, 10 Feb 2010 14:40:56 -0800 Subject: [PATCH 02/37] OMAP3: add board revision detection for Overo --- board/overo/overo.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++ board/overo/overo.h | 43 +++++++++++++++++++++--- 2 files changed, 127 insertions(+), 6 deletions(-) diff --git a/board/overo/overo.c b/board/overo/overo.c index e85be7d..3df1a12 100644 --- a/board/overo/overo.c +++ b/board/overo/overo.c @@ -61,11 +61,101 @@ int board_init(void) } /* + * Routine: get_sdio2_config + * Description: Return information about the wifi module connection + * Returns 0 if the module connects though a level translator + * Returns 1 if the module connects directly + */ +int get_sdio2_config(void) { + int sdio_direct; + + if (!omap_request_gpio(130) && !omap_request_gpio(139)){ + + omap_set_gpio_direction(130, 0); + omap_set_gpio_direction(139, 1); + + sdio_direct = 1; + omap_set_gpio_dataout(130, 0); + if (omap_get_gpio_datain(139) == 0) { + omap_set_gpio_dataout(130, 1); + if (omap_get_gpio_datain(139) == 1) + sdio_direct = 0; + } + + omap_free_gpio(130); + omap_free_gpio(139); + } else { + printf("Error: unable to acquire sdio2 clk GPIOs\n"); + sdio_direct=-1; + } + + return sdio_direct; +} + +/* + * Routine: get_board_revision + * Description: Returns the board revision + */ +int get_board_revision(void) { + int revision; + + if (!omap_request_gpio(126) && !omap_request_gpio(127) && + !omap_request_gpio(128) && !omap_request_gpio(129)){ + + omap_set_gpio_direction(126, 1); + omap_set_gpio_direction(127, 1); + omap_set_gpio_direction(128, 1); + omap_set_gpio_direction(129, 1); + + revision = 0; + if (omap_get_gpio_datain(126) == 0) + revision += 1; + if (omap_get_gpio_datain(127) == 0) + revision += 2; + if (omap_get_gpio_datain(128) == 0) + revision += 4; + if (omap_get_gpio_datain(129) == 0) + revision += 8; + + omap_free_gpio(126); + omap_free_gpio(127); + omap_free_gpio(128); + omap_free_gpio(129); + } else { + printf("Error: unable to acquire board revision GPIOs\n"); + revision=-1; + } + + return revision; +} + +/* * Routine: misc_init_r * Description: Configure board specific parts */ int misc_init_r(void) { + printf("Board revision: "); + switch (get_board_revision()) { + case 0: + case 1: + switch (get_sdio2_config()) { + case 0: + printf(" 0\n"); + MUX_OVERO_SDIO2_TRANSCEIVER(); + break; + case 1: + printf(" 1\n"); + MUX_OVERO_SDIO2_DIRECT(); + break; + default: + printf(" unknown\n"); + } + break; + default: + printf(" unsupported\n"); + } + twl4030_power_init(); twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); diff --git a/board/overo/overo.h b/board/overo/overo.h index 1873523..e120e09 100644 --- a/board/overo/overo.h +++ b/board/overo/overo.h @@ -206,12 +206,12 @@ const omap3_sysinfo sysinfo = { MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0)) /*MMC1_DAT1*/\ MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0)) /*MMC1_DAT2*/\ MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0)) /*MMC1_DAT3*/\ - MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M0)) /*MMC1_DAT4*/\ - MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M0)) /*MMC1_DAT5*/\ - MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M0)) /*MMC1_DAT6*/\ - MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M0)) /*MMC1_DAT7*/\ + MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M4)) /*GPIO_126*/\ + MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M4)) /*GPIO_127*/\ + MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M4)) /*GPIO_128*/\ + MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M4)) /*GPIO_129*/\ /*Wireless LAN */\ - MUX_VAL(CP(MMC2_CLK), (IEN | PTU | EN | M0)) /*MMC2_CLK*/\ + MUX_VAL(CP(MMC2_CLK), (IEN | PTU | EN | M4)) /*GPIO_130*/\ 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*/\ @@ -220,7 +220,7 @@ const omap3_sysinfo sysinfo = { 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(MMC2_DAT7), (IEN | PTU | EN | M4)) /*GPIO_139*/\ /*Bluetooth*/\ MUX_VAL(CP(MCBSP3_DX), (IEN | PTD | DIS | M1)) /*UART2_CTS*/\ MUX_VAL(CP(MCBSP3_DR), (IDIS | PTD | DIS | M1)) /*UART2_RTS*/\ @@ -387,5 +387,36 @@ const omap3_sysinfo sysinfo = { MUX_VAL(CP(SDRC_CKE0), (IDIS | PTU | EN | M0)) /*sdrc_cke0*/\ MUX_VAL(CP(SDRC_CKE1), (IDIS | PTU | EN | M0)) /*sdrc_cke1*/ +#define MUX_OVERO_SDIO2_DIRECT() \ + 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 | M0)) /*MMC2_DAT4*/\ + MUX_VAL(CP(MMC2_DAT5), (IEN | PTU | EN | M0)) /*MMC2_DAT5*/\ + MUX_VAL(CP(MMC2_DAT6), (IEN | PTU | EN | M0)) /*MMC2_DAT6*/\ + MUX_VAL(CP(MMC2_DAT7), (IEN | PTU | EN | M0)) /*MMC2_DAT7*/\ + MUX_VAL(CP(MMC1_DAT4), (IEN | PTD | EN | M4)) /*GPIO_126*/\ + MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M4)) /*GPIO_127*/\ + MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M4)) /*GPIO_128*/\ + MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M4)) /*GPIO_129*/ + +#define MUX_OVERO_SDIO2_TRANSCEIVER() \ + 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(MMC1_DAT4), (IEN | PTU | EN | M4)) /*GPIO_126*/\ + MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M4)) /*GPIO_127*/\ + MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M4)) /*GPIO_128*/\ + MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M4)) /*GPIO_129*/ #endif -- 1.6.6.1