uboot/board/ti/beagle/beagle.c
<<
>>
Prefs
   1/*
   2 * (C) Copyright 2004-2008
   3 * Texas Instruments, <www.ti.com>
   4 *
   5 * Author :
   6 *      Sunil Kumar <sunilsaini05@gmail.com>
   7 *      Shashi Ranjan <shashiranjanmca05@gmail.com>
   8 *
   9 * Derived from Beagle Board and 3430 SDP code by
  10 *      Richard Woodruff <r-woodruff2@ti.com>
  11 *      Syed Mohammed Khasim <khasim@ti.com>
  12 *
  13 *
  14 * See file CREDITS for list of people who contributed to this
  15 * project.
  16 *
  17 * This program is free software; you can redistribute it and/or
  18 * modify it under the terms of the GNU General Public License as
  19 * published by the Free Software Foundation; either version 2 of
  20 * the License, or (at your option) any later version.
  21 *
  22 * This program is distributed in the hope that it will be useful,
  23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25 * GNU General Public License for more details.
  26 *
  27 * You should have received a copy of the GNU General Public License
  28 * along with this program; if not, write to the Free Software
  29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30 * MA 02111-1307 USA
  31 */
  32#include <common.h>
  33#include <twl4030.h>
  34#include <asm/io.h>
  35#include <asm/arch/mmc_host_def.h>
  36#include <asm/arch/mux.h>
  37#include <asm/arch/sys_proto.h>
  38#include <asm/arch/gpio.h>
  39#include <asm/mach-types.h>
  40#include "beagle.h"
  41
  42#define TWL4030_I2C_BUS                 0
  43#define EXPANSION_EEPROM_I2C_BUS        1
  44#define EXPANSION_EEPROM_I2C_ADDRESS    0x50
  45
  46#define TINCANTOOLS_ZIPPY               0x01000100
  47#define TINCANTOOLS_ZIPPY2              0x02000100
  48#define TINCANTOOLS_TRAINER             0x04000100
  49#define TINCANTOOLS_SHOWDOG             0x03000100
  50#define KBADC_BEAGLEFPGA                0x01000600
  51
  52#define BEAGLE_NO_EEPROM                0xffffffff
  53
  54DECLARE_GLOBAL_DATA_PTR;
  55
  56static struct {
  57        unsigned int device_vendor;
  58        unsigned char revision;
  59        unsigned char content;
  60        char fab_revision[8];
  61        char env_var[16];
  62        char env_setting[64];
  63} expansion_config;
  64
  65/*
  66 * Routine: board_init
  67 * Description: Early hardware init.
  68 */
  69int board_init(void)
  70{
  71        gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  72        /* board id for Linux */
  73        gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
  74        /* boot param addr */
  75        gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  76
  77        return 0;
  78}
  79
  80/*
  81 * Routine: get_board_revision
  82 * Description: Detect if we are running on a Beagle revision Ax/Bx,
  83 *              C1/2/3, C4 or xM. This can be done by reading
  84 *              the level of GPIO173, GPIO172 and GPIO171. This should
  85 *              result in
  86 *              GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
  87 *              GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
  88 *              GPIO173, GPIO172, GPIO171: 1 0 1 => C4
  89 *              GPIO173, GPIO172, GPIO171: 0 0 0 => xM
  90 */
  91int get_board_revision(void)
  92{
  93        int revision;
  94
  95        if (!omap_request_gpio(171) &&
  96            !omap_request_gpio(172) &&
  97            !omap_request_gpio(173)) {
  98
  99                omap_set_gpio_direction(171, 1);
 100                omap_set_gpio_direction(172, 1);
 101                omap_set_gpio_direction(173, 1);
 102
 103                revision = omap_get_gpio_datain(173) << 2 |
 104                           omap_get_gpio_datain(172) << 1 |
 105                           omap_get_gpio_datain(171);
 106
 107                omap_free_gpio(171);
 108                omap_free_gpio(172);
 109                omap_free_gpio(173);
 110        } else {
 111                printf("Error: unable to acquire board revision GPIOs\n");
 112                revision = -1;
 113        }
 114
 115        return revision;
 116}
 117
 118/*
 119 * Routine: get_expansion_id
 120 * Description: This function checks for expansion board by checking I2C
 121 *              bus 1 for the availability of an AT24C01B serial EEPROM.
 122 *              returns the device_vendor field from the EEPROM
 123 */
 124unsigned int get_expansion_id(void)
 125{
 126        i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
 127
 128        /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
 129        if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
 130                i2c_set_bus_num(TWL4030_I2C_BUS);
 131                return BEAGLE_NO_EEPROM;
 132        }
 133
 134        /* read configuration data */
 135        i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
 136                 sizeof(expansion_config));
 137
 138        i2c_set_bus_num(TWL4030_I2C_BUS);
 139
 140        return expansion_config.device_vendor;
 141}
 142
 143/*
 144 * Routine: misc_init_r
 145 * Description: Configure board specific parts
 146 */
 147int misc_init_r(void)
 148{
 149        struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
 150        struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
 151
 152        switch (get_board_revision()) {
 153        case REVISION_AXBX:
 154                printf("Beagle Rev Ax/Bx\n");
 155                setenv("beaglerev", "AxBx");
 156                setenv("mpurate", "600");
 157                break;
 158        case REVISION_CX:
 159                printf("Beagle Rev C1/C2/C3\n");
 160                setenv("beaglerev", "Cx");
 161                setenv("mpurate", "600");
 162                MUX_BEAGLE_C();
 163                break;
 164        case REVISION_C4:
 165                printf("Beagle Rev C4\n");
 166                setenv("beaglerev", "C4");
 167                setenv("mpurate", "720");
 168                MUX_BEAGLE_C();
 169                /* Set VAUX2 to 1.8V for EHCI PHY */
 170                twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
 171                                        TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
 172                                        TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
 173                                        TWL4030_PM_RECEIVER_DEV_GRP_P1);
 174                break;
 175        case REVISION_XM:
 176                printf("Beagle xM Rev A\n");
 177                setenv("beaglerev", "xMA");
 178                setenv("mpurate", "1000");
 179                MUX_BEAGLE_XM();
 180                /* Set VAUX2 to 1.8V for EHCI PHY */
 181                twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
 182                                        TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
 183                                        TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
 184                                        TWL4030_PM_RECEIVER_DEV_GRP_P1);
 185                break;
 186        default:
 187                printf("Beagle unknown 0x%02x\n", get_board_revision());
 188        }
 189
 190        switch (get_expansion_id()) {
 191        case TINCANTOOLS_ZIPPY:
 192                printf("Recognized Tincantools Zippy board (rev %d %s)\n",
 193                        expansion_config.revision,
 194                        expansion_config.fab_revision);
 195                MUX_TINCANTOOLS_ZIPPY();
 196                setenv("buddy", "zippy");
 197                break;
 198        case TINCANTOOLS_ZIPPY2:
 199                printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
 200                        expansion_config.revision,
 201                        expansion_config.fab_revision);
 202                MUX_TINCANTOOLS_ZIPPY();
 203                setenv("buddy", "zippy2");
 204                break;
 205        case TINCANTOOLS_TRAINER:
 206                printf("Recognized Tincantools Trainer board (rev %d %s)\n",
 207                        expansion_config.revision,
 208                        expansion_config.fab_revision);
 209                MUX_TINCANTOOLS_ZIPPY();
 210                MUX_TINCANTOOLS_TRAINER();
 211                setenv("buddy", "trainer");
 212                break;
 213        case TINCANTOOLS_SHOWDOG:
 214                printf("Recognized Tincantools Showdow board (rev %d %s)\n",
 215                        expansion_config.revision,
 216                        expansion_config.fab_revision);
 217                /* Place holder for DSS2 definition for showdog lcd */
 218                setenv("defaultdisplay", "showdoglcd");
 219                setenv("buddy", "showdog");
 220                break;
 221        case KBADC_BEAGLEFPGA:
 222                printf("Recognized KBADC Beagle FPGA board\n");
 223                MUX_KBADC_BEAGLEFPGA();
 224                setenv("buddy", "beaglefpga");
 225                break;
 226        case BEAGLE_NO_EEPROM:
 227                printf("No EEPROM on expansion board\n");
 228                setenv("buddy", "none");
 229                break;
 230        default:
 231                printf("Unrecognized expansion board: %x\n",
 232                        expansion_config.device_vendor);
 233                setenv("buddy", "unknown");
 234        }
 235
 236        if (expansion_config.content == 1)
 237                setenv(expansion_config.env_var, expansion_config.env_setting);
 238
 239        twl4030_power_init();
 240        twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
 241
 242        /* Configure GPIOs to output */
 243        writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
 244        writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
 245                GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
 246
 247        /* Set GPIOs */
 248        writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
 249                &gpio6_base->setdataout);
 250        writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
 251                GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
 252
 253        dieid_num_r();
 254
 255        return 0;
 256}
 257
 258/*
 259 * Routine: set_muxconf_regs
 260 * Description: Setting up the configuration Mux registers specific to the
 261 *              hardware. Many pins need to be moved from protect to primary
 262 *              mode.
 263 */
 264void set_muxconf_regs(void)
 265{
 266        MUX_BEAGLE();
 267}
 268
 269#ifdef CONFIG_GENERIC_MMC
 270int board_mmc_init(bd_t *bis)
 271{
 272        omap_mmc_init(0);
 273        return 0;
 274}
 275#endif
 276