blob: 24be6eabfcd2d2b09d93db8ab70ce0df8057e97b [file] [log] [blame]
Googlere00b8eb2019-07-08 16:37:07 -07001/*
2 * am3517evm.c - board file for TI's AM3517 family of devices.
3 *
4 * Author: Vaibhav Hiremath <hvaibhav@ti.com>
5 *
6 * Based on ti/evm/evm.c
7 *
8 * Copyright (C) 2010
9 * Texas Instruments Incorporated - http://www.ti.com/
Googler695f9d92023-09-11 15:38:29 +080010 *
11 * SPDX-License-Identifier: GPL-2.0+
Googlere00b8eb2019-07-08 16:37:07 -070012 */
13
14#include <common.h>
Googlere00b8eb2019-07-08 16:37:07 -070015#include <asm/io.h>
16#include <asm/omap_musb.h>
17#include <asm/arch/am35x_def.h>
18#include <asm/arch/mem.h>
19#include <asm/arch/mux.h>
20#include <asm/arch/sys_proto.h>
21#include <asm/arch/mmc_host_def.h>
22#include <asm/arch/musb.h>
23#include <asm/mach-types.h>
Googler695f9d92023-09-11 15:38:29 +080024#include <asm/errno.h>
Googlere00b8eb2019-07-08 16:37:07 -070025#include <asm/gpio.h>
26#include <linux/usb/ch9.h>
27#include <linux/usb/gadget.h>
28#include <linux/usb/musb.h>
29#include <i2c.h>
30#include <netdev.h>
31#include "am3517evm.h"
32
33DECLARE_GLOBAL_DATA_PTR;
34
35#define AM3517_IP_SW_RESET 0x48002598
36#define CPGMACSS_SW_RST (1 << 1)
Googlere00b8eb2019-07-08 16:37:07 -070037
38/*
39 * Routine: board_init
40 * Description: Early hardware init.
41 */
42int board_init(void)
43{
44 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
45 /* board id for Linux */
46 gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
47 /* boot param addr */
48 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
49
50 return 0;
51}
52
53#ifdef CONFIG_USB_MUSB_AM35X
54static struct musb_hdrc_config musb_config = {
55 .multipoint = 1,
56 .dyn_fifo = 1,
57 .num_eps = 16,
58 .ram_bits = 12,
59};
60
61static struct omap_musb_board_data musb_board_data = {
62 .set_phy_power = am35x_musb_phy_power,
63 .clear_irq = am35x_musb_clear_irq,
64 .reset = am35x_musb_reset,
65};
66
67static struct musb_hdrc_platform_data musb_plat = {
Googler695f9d92023-09-11 15:38:29 +080068#if defined(CONFIG_MUSB_HOST)
Googlere00b8eb2019-07-08 16:37:07 -070069 .mode = MUSB_HOST,
Googler695f9d92023-09-11 15:38:29 +080070#elif defined(CONFIG_MUSB_GADGET)
Googlere00b8eb2019-07-08 16:37:07 -070071 .mode = MUSB_PERIPHERAL,
72#else
Googler695f9d92023-09-11 15:38:29 +080073#error "Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET"
Googlere00b8eb2019-07-08 16:37:07 -070074#endif
75 .config = &musb_config,
76 .power = 250,
77 .platform_ops = &am35x_ops,
78 .board_data = &musb_board_data,
79};
80
81static void am3517_evm_musb_init(void)
82{
83 /*
84 * Set up USB clock/mode in the DEVCONF2 register.
85 * USB2.0 PHY reference clock is 13 MHz
86 */
87 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
88 CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
89 CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
90 CONF2_VBDTCTEN | CONF2_DATPOL);
91
92 musb_register(&musb_plat, &musb_board_data,
93 (void *)AM35XX_IPSS_USBOTGSS_BASE);
94}
95#else
96#define am3517_evm_musb_init() do {} while (0)
97#endif
98
99/*
100 * Routine: misc_init_r
101 * Description: Init i2c, ethernet, etc... (done here so udelay works)
102 */
103int misc_init_r(void)
104{
105 volatile unsigned int ctr;
106 u32 reset;
107
Googler695f9d92023-09-11 15:38:29 +0800108#ifdef CONFIG_SYS_I2C_OMAP34XX
Googlere00b8eb2019-07-08 16:37:07 -0700109 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
110#endif
Googler695f9d92023-09-11 15:38:29 +0800111
112 dieid_num_r();
Googlere00b8eb2019-07-08 16:37:07 -0700113
114 am3517_evm_musb_init();
115
Googler695f9d92023-09-11 15:38:29 +0800116 /* activate PHY reset */
117 gpio_direction_output(30, 0);
118 gpio_set_value(30, 0);
Googlere00b8eb2019-07-08 16:37:07 -0700119
Googler695f9d92023-09-11 15:38:29 +0800120 ctr = 0;
121 do {
122 udelay(1000);
123 ctr++;
124 } while (ctr < 300);
Googlere00b8eb2019-07-08 16:37:07 -0700125
Googler695f9d92023-09-11 15:38:29 +0800126 /* deactivate PHY reset */
127 gpio_set_value(30, 1);
Googlere00b8eb2019-07-08 16:37:07 -0700128
Googler695f9d92023-09-11 15:38:29 +0800129 /* allow the PHY to stabilize and settle down */
130 ctr = 0;
131 do {
132 udelay(1000);
133 ctr++;
134 } while (ctr < 300);
Googlere00b8eb2019-07-08 16:37:07 -0700135
Googler695f9d92023-09-11 15:38:29 +0800136 /* ensure that the module is out of reset */
137 reset = readl(AM3517_IP_SW_RESET);
138 reset &= (~CPGMACSS_SW_RST);
139 writel(reset,AM3517_IP_SW_RESET);
Googlere00b8eb2019-07-08 16:37:07 -0700140
141 return 0;
142}
143
144/*
145 * Routine: set_muxconf_regs
146 * Description: Setting up the configuration Mux registers specific to the
147 * hardware. Many pins need to be moved from protect to primary
148 * mode.
149 */
150void set_muxconf_regs(void)
151{
152 MUX_AM3517EVM();
153}
154
Googler695f9d92023-09-11 15:38:29 +0800155#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
Googlere00b8eb2019-07-08 16:37:07 -0700156int board_mmc_init(bd_t *bis)
157{
158 return omap_mmc_init(0, 0, 0, -1, -1);
159}
160#endif
161
Googler695f9d92023-09-11 15:38:29 +0800162#if defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)
Googlere00b8eb2019-07-08 16:37:07 -0700163int board_eth_init(bd_t *bis)
164{
165 int rv, n = 0;
166
167 rv = cpu_eth_init(bis);
168 if (rv > 0)
169 n += rv;
170
171 rv = usb_eth_initialize(bis);
172 if (rv > 0)
173 n += rv;
174
175 return n;
176}
177#endif