uboot/board/technexion/tao3530/tao3530.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0+
   2/*
   3 * Maintainer :
   4 *      Tapani Utriainen <linuxfae@technexion.com>
   5 */
   6#include <common.h>
   7#include <bootstage.h>
   8#include <init.h>
   9#include <malloc.h>
  10#include <netdev.h>
  11#include <twl4030.h>
  12#include <asm/io.h>
  13#include <asm/arch/mmc_host_def.h>
  14#include <asm/arch/mem.h>
  15#include <asm/arch/mux.h>
  16#include <asm/arch/sys_proto.h>
  17#include <asm/arch/gpio.h>
  18#include <asm/gpio.h>
  19#include <asm/mach-types.h>
  20
  21#include <usb.h>
  22#include <asm/ehci-omap.h>
  23
  24#include "tao3530.h"
  25
  26DECLARE_GLOBAL_DATA_PTR;
  27
  28int tao3530_revision(void)
  29{
  30        int ret = 0;
  31
  32        /* char *label argument is unused in gpio_request() */
  33        ret = gpio_request(65, "");
  34        if (ret) {
  35                puts("Error: GPIO 65 not available\n");
  36                goto out;
  37        }
  38        MUX_VAL(CP(GPMC_WAIT3), (IEN  | PTU | EN  | M4));
  39
  40        ret = gpio_request(1, "");
  41        if (ret) {
  42                puts("Error: GPIO 1 not available\n");
  43                goto out2;
  44        }
  45        MUX_VAL(CP(SYS_CLKREQ), (IEN  | PTU | EN | M4));
  46
  47        ret = gpio_direction_input(65);
  48        if (ret) {
  49                puts("Error: GPIO 65 not available for input\n");
  50                goto out3;
  51        }
  52
  53        ret =  gpio_direction_input(1);
  54        if (ret) {
  55                puts("Error: GPIO 1 not available for input\n");
  56                goto out3;
  57        }
  58
  59        ret = gpio_get_value(65) << 1 | gpio_get_value(1);
  60
  61out3:
  62        MUX_VAL(CP(SYS_CLKREQ), (IEN  | PTU | EN | M0));
  63        gpio_free(1);
  64out2:
  65        MUX_VAL(CP(GPMC_WAIT3), (IEN  | PTU | EN  | M0));
  66        gpio_free(65);
  67out:
  68
  69        return ret;
  70}
  71
  72#ifdef CONFIG_SPL_BUILD
  73/*
  74 * Routine: get_board_mem_timings
  75 * Description: If we use SPL then there is no x-loader nor config header
  76 * so we have to setup the DDR timings ourself on both banks.
  77 */
  78void get_board_mem_timings(struct board_sdrc_timings *timings)
  79{
  80#if defined(CONFIG_SYS_BOARD_OMAP3_HA)
  81        /*
  82         * Switch baseboard LED to red upon power-on
  83         */
  84        MUX_OMAP3_HA();
  85
  86        /* Request a gpio before using it */
  87        gpio_request(111, "");
  88        /* Sets the gpio as output and its value to 1, switch LED to red */
  89        gpio_direction_output(111, 1);
  90#endif
  91
  92        if (tao3530_revision() < 3) {
  93                /* 256MB / Bank */
  94                timings->mcfg = MCFG(256 << 20, 14);    /* RAS-width 14 */
  95                timings->ctrla = HYNIX_V_ACTIMA_165;
  96                timings->ctrlb = HYNIX_V_ACTIMB_165;
  97        } else {
  98                /* 128MB / Bank */
  99                timings->mcfg = MCFG(128 << 20, 13);    /* RAS-width 13 */
 100                timings->ctrla = MICRON_V_ACTIMA_165;
 101                timings->ctrlb = MICRON_V_ACTIMB_165;
 102        }
 103
 104        timings->mr = MICRON_V_MR_165;
 105        timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
 106}
 107#endif
 108
 109/*
 110 * Routine: board_init
 111 * Description: Early hardware init.
 112 */
 113int board_init(void)
 114{
 115        gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
 116        /* board id for Linux */
 117        gd->bd->bi_arch_number = MACH_TYPE_OMAP3_TAO3530;
 118        /* boot param addr */
 119        gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
 120
 121        return 0;
 122}
 123
 124/*
 125 * Routine: misc_init_r
 126 * Description: Configure board specific parts
 127 */
 128int misc_init_r(void)
 129{
 130        struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
 131        struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
 132
 133        twl4030_power_init();
 134        twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
 135
 136        /* Configure GPIOs to output */
 137        /* GPIO23 */
 138        writel(~(GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
 139        writel(~(GPIO31 | GPIO30 | GPIO22 | GPIO21 |
 140                 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
 141
 142        /* Set GPIOs */
 143        writel(GPIO10 | GPIO8 | GPIO2 | GPIO1,
 144               &gpio6_base->setdataout);
 145        writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
 146               GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
 147
 148        switch (tao3530_revision()) {
 149        case 0:
 150                puts("TAO-3530 REV Reserve 1\n");
 151                break;
 152        case 1:
 153                puts("TAO-3530 REV Reserve 2\n");
 154                break;
 155        case 2:
 156                puts("TAO-3530 REV Cx\n");
 157                break;
 158        case 3:
 159                puts("TAO-3530 REV Ax/Bx\n");
 160                break;
 161        default:
 162                puts("Unknown board revision\n");
 163        }
 164
 165        omap_die_id_display();
 166
 167        return 0;
 168}
 169
 170/*
 171 * Routine: set_muxconf_regs
 172 * Description: Setting up the configuration Mux registers specific to the
 173 *              hardware. Many pins need to be moved from protect to primary
 174 *              mode.
 175 */
 176void set_muxconf_regs(void)
 177{
 178        MUX_TAO3530();
 179#if defined(CONFIG_SYS_BOARD_OMAP3_HA)
 180        MUX_OMAP3_HA();
 181#endif
 182}
 183
 184#if defined(CONFIG_MMC)
 185int board_mmc_init(struct bd_info *bis)
 186{
 187        omap_mmc_init(0, 0, 0, -1, -1);
 188
 189        return 0;
 190}
 191#endif
 192
 193#if defined(CONFIG_MMC)
 194void board_mmc_power_init(void)
 195{
 196        twl4030_power_mmc_init(0);
 197}
 198#endif
 199
 200#if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
 201/* Call usb_stop() before starting the kernel */
 202void show_boot_progress(int val)
 203{
 204        if (val == BOOTSTAGE_ID_RUN_OS)
 205                usb_stop();
 206}
 207
 208static struct omap_usbhs_board_data usbhs_bdata = {
 209        .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
 210        .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
 211        .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
 212};
 213
 214int ehci_hcd_init(int index, enum usb_init_type init,
 215                  struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 216{
 217        return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
 218}
 219
 220int ehci_hcd_stop(int index)
 221{
 222        return omap_ehci_hcd_stop();
 223}
 224#endif /* CONFIG_USB_EHCI_HCD */
 225