blob: 29f136a530686c95c553a0d0e05c4f5a436b2f75 [file] [log] [blame]
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -04001/*
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/
10 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040012 */
13
14#include <common.h>
Adam Fordb32f5f32017-09-19 20:32:11 -050015#include <dm.h>
16#include <ns16550.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040017#include <asm/io.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000018#include <asm/omap_musb.h>
19#include <asm/arch/am35x_def.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040020#include <asm/arch/mem.h>
21#include <asm/arch/mux.h>
22#include <asm/arch/sys_proto.h>
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -040023#include <asm/arch/mmc_host_def.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000024#include <asm/arch/musb.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040025#include <asm/mach-types.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090026#include <linux/errno.h>
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010027#include <asm/gpio.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000028#include <linux/usb/ch9.h>
29#include <linux/usb/gadget.h>
30#include <linux/usb/musb.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040031#include <i2c.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000032#include <netdev.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040033#include "am3517evm.h"
34
35DECLARE_GLOBAL_DATA_PTR;
36
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010037#define AM3517_IP_SW_RESET 0x48002598
38#define CPGMACSS_SW_RST (1 << 1)
Adam Fordb32f5f32017-09-19 20:32:11 -050039#define PHY_GPIO 30
40
41/* This is only needed until SPL gets OF support */
42#ifdef CONFIG_SPL_BUILD
43static const struct ns16550_platdata am3517_serial = {
44 .base = OMAP34XX_UART3,
45 .reg_shift = 2,
46 .clock = V_NS16550_CLK,
47 .fcr = UART_FCR_DEFVAL,
48};
49
50U_BOOT_DEVICE(am3517_uart) = {
51 "ns16550_serial",
52 &am3517_serial
53};
54#endif
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010055
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040056/*
57 * Routine: board_init
58 * Description: Early hardware init.
59 */
60int board_init(void)
61{
62 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
63 /* board id for Linux */
64 gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
65 /* boot param addr */
66 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
67
68 return 0;
69}
70
Ilya Yanoke484f8e2012-11-06 13:48:28 +000071#ifdef CONFIG_USB_MUSB_AM35X
72static struct musb_hdrc_config musb_config = {
73 .multipoint = 1,
74 .dyn_fifo = 1,
75 .num_eps = 16,
76 .ram_bits = 12,
77};
78
79static struct omap_musb_board_data musb_board_data = {
80 .set_phy_power = am35x_musb_phy_power,
81 .clear_irq = am35x_musb_clear_irq,
82 .reset = am35x_musb_reset,
83};
84
85static struct musb_hdrc_platform_data musb_plat = {
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020086#if defined(CONFIG_USB_MUSB_HOST)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000087 .mode = MUSB_HOST,
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020088#elif defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000089 .mode = MUSB_PERIPHERAL,
90#else
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020091#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
Ilya Yanoke484f8e2012-11-06 13:48:28 +000092#endif
93 .config = &musb_config,
94 .power = 250,
95 .platform_ops = &am35x_ops,
96 .board_data = &musb_board_data,
97};
98
99static void am3517_evm_musb_init(void)
100{
101 /*
102 * Set up USB clock/mode in the DEVCONF2 register.
103 * USB2.0 PHY reference clock is 13 MHz
104 */
105 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
106 CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
107 CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
108 CONF2_VBDTCTEN | CONF2_DATPOL);
109
110 musb_register(&musb_plat, &musb_board_data,
111 (void *)AM35XX_IPSS_USBOTGSS_BASE);
112}
113#else
114#define am3517_evm_musb_init() do {} while (0)
115#endif
116
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400117/*
118 * Routine: misc_init_r
119 * Description: Init i2c, ethernet, etc... (done here so udelay works)
120 */
121int misc_init_r(void)
122{
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100123 volatile unsigned int ctr;
124 u32 reset;
125
Adam Ford49e96f22017-08-07 13:11:19 -0500126#ifdef CONFIG_SYS_I2C_OMAP24XX
Heiko Schocherf53f2b82013-10-22 11:03:18 +0200127 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400128#endif
129
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200130 omap_die_id_display();
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400131
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000132 am3517_evm_musb_init();
133
Adam Fordb32f5f32017-09-19 20:32:11 -0500134 if (gpio_request(PHY_GPIO, "gpio_30") == 0) {
135 /* activate PHY reset */
136 gpio_direction_output(PHY_GPIO, 0);
137 gpio_set_value(PHY_GPIO, 0);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100138
Adam Fordb32f5f32017-09-19 20:32:11 -0500139 ctr = 0;
140 do {
141 udelay(1000);
142 ctr++;
143 } while (ctr < 300);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100144
Adam Fordb32f5f32017-09-19 20:32:11 -0500145 /* deactivate PHY reset */
146 gpio_set_value(PHY_GPIO, 1);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100147
Adam Fordb32f5f32017-09-19 20:32:11 -0500148 /* allow the PHY to stabilize and settle down */
149 ctr = 0;
150 do {
151 udelay(1000);
152 ctr++;
153 } while (ctr < 300);
154
155 /* ensure that the module is out of reset */
156 reset = readl(AM3517_IP_SW_RESET);
157 reset &= (~CPGMACSS_SW_RST);
158 writel(reset, AM3517_IP_SW_RESET);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100159
Adam Fordb32f5f32017-09-19 20:32:11 -0500160 /* Free requested GPIO */
161 gpio_free(PHY_GPIO);
162 }
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100163
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400164 return 0;
165}
166
167/*
168 * Routine: set_muxconf_regs
169 * Description: Setting up the configuration Mux registers specific to the
170 * hardware. Many pins need to be moved from protect to primary
171 * mode.
172 */
173void set_muxconf_regs(void)
174{
175 MUX_AM3517EVM();
176}
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400177
Masahiro Yamada0a780172017-05-09 20:31:39 +0900178#if defined(CONFIG_MMC)
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400179int board_mmc_init(bd_t *bis)
180{
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000181 return omap_mmc_init(0, 0, 0, -1, -1);
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400182}
183#endif
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000184
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +0200185#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000186int board_eth_init(bd_t *bis)
187{
188 int rv, n = 0;
189
190 rv = cpu_eth_init(bis);
191 if (rv > 0)
192 n += rv;
193
194 rv = usb_eth_initialize(bis);
195 if (rv > 0)
196 n += rv;
197
198 return n;
199}
200#endif