blob: 24ff9c36a1a1c5548c88eacb4e7af26caf4f2942 [file] [log] [blame]
Vaibhav Hiremathed01e452010-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 Denk1a459662013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Vaibhav Hiremathed01e452010-06-07 15:20:43 -040012 */
13
14#include <common.h>
15#include <asm/io.h>
Ilya Yanok88919ff2012-11-06 13:48:28 +000016#include <asm/omap_musb.h>
17#include <asm/arch/am35x_def.h>
Vaibhav Hiremathed01e452010-06-07 15:20:43 -040018#include <asm/arch/mem.h>
19#include <asm/arch/mux.h>
20#include <asm/arch/sys_proto.h>
Vaibhav Hiremath122e6e02011-09-03 21:47:44 -040021#include <asm/arch/mmc_host_def.h>
Ilya Yanok88919ff2012-11-06 13:48:28 +000022#include <asm/arch/musb.h>
Vaibhav Hiremathed01e452010-06-07 15:20:43 -040023#include <asm/mach-types.h>
Ilya Yanok88919ff2012-11-06 13:48:28 +000024#include <asm/errno.h>
Yegor Yefremov6a1df372013-12-11 15:41:11 +010025#include <asm/gpio.h>
Ilya Yanok88919ff2012-11-06 13:48:28 +000026#include <linux/usb/ch9.h>
27#include <linux/usb/gadget.h>
28#include <linux/usb/musb.h>
Vaibhav Hiremathed01e452010-06-07 15:20:43 -040029#include <i2c.h>
Ilya Yanok88919ff2012-11-06 13:48:28 +000030#include <netdev.h>
Vaibhav Hiremathed01e452010-06-07 15:20:43 -040031#include "am3517evm.h"
32
33DECLARE_GLOBAL_DATA_PTR;
34
Yegor Yefremov6a1df372013-12-11 15:41:11 +010035#define AM3517_IP_SW_RESET 0x48002598
36#define CPGMACSS_SW_RST (1 << 1)
37
Vaibhav Hiremathed01e452010-06-07 15:20:43 -040038/*
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
Ilya Yanok88919ff2012-11-06 13:48:28 +000053#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 = {
Paul Kocialkowski95de1e22015-08-04 17:04:06 +020068#if defined(CONFIG_USB_MUSB_HOST)
Ilya Yanok88919ff2012-11-06 13:48:28 +000069 .mode = MUSB_HOST,
Paul Kocialkowski95de1e22015-08-04 17:04:06 +020070#elif defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanok88919ff2012-11-06 13:48:28 +000071 .mode = MUSB_PERIPHERAL,
72#else
Paul Kocialkowski95de1e22015-08-04 17:04:06 +020073#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
Ilya Yanok88919ff2012-11-06 13:48:28 +000074#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
Vaibhav Hiremathed01e452010-06-07 15:20:43 -040099/*
100 * Routine: misc_init_r
101 * Description: Init i2c, ethernet, etc... (done here so udelay works)
102 */
103int misc_init_r(void)
104{
Yegor Yefremov6a1df372013-12-11 15:41:11 +0100105 volatile unsigned int ctr;
106 u32 reset;
107
Heiko Schocher6789e842013-10-22 11:03:18 +0200108#ifdef CONFIG_SYS_I2C_OMAP34XX
109 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
Vaibhav Hiremathed01e452010-06-07 15:20:43 -0400110#endif
111
112 dieid_num_r();
113
Ilya Yanok88919ff2012-11-06 13:48:28 +0000114 am3517_evm_musb_init();
115
Yegor Yefremov6a1df372013-12-11 15:41:11 +0100116 /* activate PHY reset */
117 gpio_direction_output(30, 0);
118 gpio_set_value(30, 0);
119
120 ctr = 0;
121 do {
122 udelay(1000);
123 ctr++;
124 } while (ctr < 300);
125
126 /* deactivate PHY reset */
127 gpio_set_value(30, 1);
128
129 /* allow the PHY to stabilize and settle down */
130 ctr = 0;
131 do {
132 udelay(1000);
133 ctr++;
134 } while (ctr < 300);
135
136 /* 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);
140
Vaibhav Hiremathed01e452010-06-07 15:20:43 -0400141 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}
Vaibhav Hiremath122e6e02011-09-03 21:47:44 -0400154
Tom Rini5059a2a2011-11-18 12:48:10 +0000155#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
Vaibhav Hiremath122e6e02011-09-03 21:47:44 -0400156int board_mmc_init(bd_t *bis)
157{
Nikita Kiryanove3913f52012-12-03 02:19:47 +0000158 return omap_mmc_init(0, 0, 0, -1, -1);
Vaibhav Hiremath122e6e02011-09-03 21:47:44 -0400159}
160#endif
Ilya Yanok88919ff2012-11-06 13:48:28 +0000161
Paul Kocialkowski95de1e22015-08-04 17:04:06 +0200162#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanok88919ff2012-11-06 13:48:28 +0000163int 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