blob: 18f3c3f9d9c7a217545c2c11f4557ff8d218934b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -04002/*
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/
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040011 */
12
13#include <common.h>
Adam Fordb32f5f32017-09-19 20:32:11 -050014#include <dm.h>
15#include <ns16550.h>
Simon Glass36736182019-11-14 12:57:24 -070016#include <serial.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>
32#include "am3517evm.h"
33
34DECLARE_GLOBAL_DATA_PTR;
35
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010036#define AM3517_IP_SW_RESET 0x48002598
37#define CPGMACSS_SW_RST (1 << 1)
Adam Fordb32f5f32017-09-19 20:32:11 -050038#define PHY_GPIO 30
39
Adam Forda55156e2019-03-31 09:18:29 -050040#if defined(CONFIG_SPL_BUILD)
41#if defined(CONFIG_SPL_OS_BOOT)
42int spl_start_uboot(void)
43{
44 /* break into full u-boot on 'c' */
45 return serial_tstc() && serial_getc() == 'c';
46}
47#endif
48#endif
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010049
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040050/*
51 * Routine: board_init
52 * Description: Early hardware init.
53 */
54int board_init(void)
55{
56 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
57 /* board id for Linux */
58 gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
59 /* boot param addr */
60 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
61
62 return 0;
63}
64
Ilya Yanoke484f8e2012-11-06 13:48:28 +000065#ifdef CONFIG_USB_MUSB_AM35X
66static struct musb_hdrc_config musb_config = {
67 .multipoint = 1,
68 .dyn_fifo = 1,
69 .num_eps = 16,
70 .ram_bits = 12,
71};
72
73static struct omap_musb_board_data musb_board_data = {
74 .set_phy_power = am35x_musb_phy_power,
75 .clear_irq = am35x_musb_clear_irq,
76 .reset = am35x_musb_reset,
77};
78
79static struct musb_hdrc_platform_data musb_plat = {
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020080#if defined(CONFIG_USB_MUSB_HOST)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000081 .mode = MUSB_HOST,
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020082#elif defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000083 .mode = MUSB_PERIPHERAL,
84#else
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020085#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
Ilya Yanoke484f8e2012-11-06 13:48:28 +000086#endif
87 .config = &musb_config,
88 .power = 250,
89 .platform_ops = &am35x_ops,
90 .board_data = &musb_board_data,
91};
92
93static void am3517_evm_musb_init(void)
94{
95 /*
96 * Set up USB clock/mode in the DEVCONF2 register.
97 * USB2.0 PHY reference clock is 13 MHz
98 */
99 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
100 CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
101 CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
102 CONF2_VBDTCTEN | CONF2_DATPOL);
103
104 musb_register(&musb_plat, &musb_board_data,
105 (void *)AM35XX_IPSS_USBOTGSS_BASE);
106}
107#else
108#define am3517_evm_musb_init() do {} while (0)
109#endif
110
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400111/*
112 * Routine: misc_init_r
113 * Description: Init i2c, ethernet, etc... (done here so udelay works)
114 */
115int misc_init_r(void)
116{
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100117 u32 reset;
118
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200119 omap_die_id_display();
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400120
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000121 am3517_evm_musb_init();
122
Adam Fordd4c65fa2019-06-23 00:42:14 -0500123 /* ensure that the Ethernet module is out of reset */
124 reset = readl(AM3517_IP_SW_RESET);
125 reset &= (~CPGMACSS_SW_RST);
126 writel(reset, AM3517_IP_SW_RESET);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100127
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400128 return 0;
129}
130
131/*
132 * Routine: set_muxconf_regs
133 * Description: Setting up the configuration Mux registers specific to the
134 * hardware. Many pins need to be moved from protect to primary
135 * mode.
136 */
137void set_muxconf_regs(void)
138{
139 MUX_AM3517EVM();
140}
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400141
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000142
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +0200143#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000144int board_eth_init(bd_t *bis)
145{
146 int rv, n = 0;
147
148 rv = cpu_eth_init(bis);
149 if (rv > 0)
150 n += rv;
151
152 rv = usb_eth_initialize(bis);
153 if (rv > 0)
154 n += rv;
155
156 return n;
157}
158#endif