uboot/board/logicpd/am3517evm/am3517evm.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0+
   2/*
   3 * am3517evm.c - board file for TI's AM3517 family of devices.
   4 *
   5 * Author: Vaibhav Hiremath <hvaibhav@ti.com>
   6 *
   7 * Based on ti/evm/evm.c
   8 *
   9 * Copyright (C) 2010
  10 * Texas Instruments Incorporated - http://www.ti.com/
  11 */
  12
  13#include <common.h>
  14#include <dm.h>
  15#include <ns16550.h>
  16#include <asm/io.h>
  17#include <asm/omap_musb.h>
  18#include <asm/arch/am35x_def.h>
  19#include <asm/arch/mem.h>
  20#include <asm/arch/mux.h>
  21#include <asm/arch/sys_proto.h>
  22#include <asm/arch/mmc_host_def.h>
  23#include <asm/arch/musb.h>
  24#include <asm/mach-types.h>
  25#include <linux/errno.h>
  26#include <asm/gpio.h>
  27#include <linux/usb/ch9.h>
  28#include <linux/usb/gadget.h>
  29#include <linux/usb/musb.h>
  30#include <i2c.h>
  31#include <netdev.h>
  32#include "am3517evm.h"
  33
  34DECLARE_GLOBAL_DATA_PTR;
  35
  36#define AM3517_IP_SW_RESET      0x48002598
  37#define CPGMACSS_SW_RST         (1 << 1)
  38#define PHY_GPIO                30
  39
  40/* This is only needed until SPL gets OF support */
  41#ifdef CONFIG_SPL_BUILD
  42static const struct ns16550_platdata am3517_serial = {
  43        .base = OMAP34XX_UART3,
  44        .reg_shift = 2,
  45        .clock = V_NS16550_CLK,
  46        .fcr = UART_FCR_DEFVAL,
  47};
  48
  49U_BOOT_DEVICE(am3517_uart) = {
  50        "ns16550_serial",
  51        &am3517_serial
  52};
  53#endif
  54
  55/*
  56 * Routine: board_init
  57 * Description: Early hardware init.
  58 */
  59int board_init(void)
  60{
  61        gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  62        /* board id for Linux */
  63        gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
  64        /* boot param addr */
  65        gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  66
  67        return 0;
  68}
  69
  70#ifdef CONFIG_USB_MUSB_AM35X
  71static struct musb_hdrc_config musb_config = {
  72        .multipoint     = 1,
  73        .dyn_fifo       = 1,
  74        .num_eps        = 16,
  75        .ram_bits       = 12,
  76};
  77
  78static struct omap_musb_board_data musb_board_data = {
  79        .set_phy_power          = am35x_musb_phy_power,
  80        .clear_irq              = am35x_musb_clear_irq,
  81        .reset                  = am35x_musb_reset,
  82};
  83
  84static struct musb_hdrc_platform_data musb_plat = {
  85#if defined(CONFIG_USB_MUSB_HOST)
  86        .mode           = MUSB_HOST,
  87#elif defined(CONFIG_USB_MUSB_GADGET)
  88        .mode           = MUSB_PERIPHERAL,
  89#else
  90#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
  91#endif
  92        .config         = &musb_config,
  93        .power          = 250,
  94        .platform_ops   = &am35x_ops,
  95        .board_data     = &musb_board_data,
  96};
  97
  98static void am3517_evm_musb_init(void)
  99{
 100        /*
 101         * Set up USB clock/mode in the DEVCONF2 register.
 102         * USB2.0 PHY reference clock is 13 MHz
 103         */
 104        clrsetbits_le32(&am35x_scm_general_regs->devconf2,
 105                        CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
 106                        CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
 107                        CONF2_VBDTCTEN | CONF2_DATPOL);
 108
 109        musb_register(&musb_plat, &musb_board_data,
 110                        (void *)AM35XX_IPSS_USBOTGSS_BASE);
 111}
 112#else
 113#define am3517_evm_musb_init() do {} while (0)
 114#endif
 115
 116/*
 117 * Routine: misc_init_r
 118 * Description: Init i2c, ethernet, etc... (done here so udelay works)
 119 */
 120int misc_init_r(void)
 121{
 122        volatile unsigned int ctr;
 123        u32 reset;
 124
 125#ifdef CONFIG_SYS_I2C_OMAP24XX
 126        i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
 127#endif
 128
 129        omap_die_id_display();
 130
 131        am3517_evm_musb_init();
 132
 133        if (gpio_request(PHY_GPIO, "gpio_30") == 0) {
 134                /* activate PHY reset */
 135                gpio_direction_output(PHY_GPIO, 0);
 136                gpio_set_value(PHY_GPIO, 0);
 137
 138                ctr  = 0;
 139                do {
 140                        udelay(1000);
 141                        ctr++;
 142                } while (ctr < 300);
 143
 144                /* deactivate PHY reset */
 145                gpio_set_value(PHY_GPIO, 1);
 146
 147                /* allow the PHY to stabilize and settle down */
 148                ctr = 0;
 149                do {
 150                        udelay(1000);
 151                        ctr++;
 152                } while (ctr < 300);
 153
 154                /* ensure that the module is out of reset */
 155                reset = readl(AM3517_IP_SW_RESET);
 156                reset &= (~CPGMACSS_SW_RST);
 157                writel(reset, AM3517_IP_SW_RESET);
 158
 159                /* Free requested GPIO */
 160                gpio_free(PHY_GPIO);
 161        }
 162
 163        return 0;
 164}
 165
 166/*
 167 * Routine: set_muxconf_regs
 168 * Description: Setting up the configuration Mux registers specific to the
 169 *              hardware. Many pins need to be moved from protect to primary
 170 *              mode.
 171 */
 172void set_muxconf_regs(void)
 173{
 174        MUX_AM3517EVM();
 175}
 176
 177#if defined(CONFIG_MMC)
 178int board_mmc_init(bd_t *bis)
 179{
 180        return omap_mmc_init(0, 0, 0, -1, -1);
 181}
 182#endif
 183
 184#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
 185int board_eth_init(bd_t *bis)
 186{
 187        int rv, n = 0;
 188
 189        rv = cpu_eth_init(bis);
 190        if (rv > 0)
 191                n += rv;
 192
 193        rv = usb_eth_initialize(bis);
 194        if (rv > 0)
 195                n += rv;
 196
 197        return n;
 198}
 199#endif
 200