blob: 215387825e6617547d33f7144adea7227c75ac0f [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>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040016#include <asm/io.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000017#include <asm/omap_musb.h>
18#include <asm/arch/am35x_def.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040019#include <asm/arch/mem.h>
20#include <asm/arch/mux.h>
21#include <asm/arch/sys_proto.h>
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -040022#include <asm/arch/mmc_host_def.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000023#include <asm/arch/musb.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040024#include <asm/mach-types.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090025#include <linux/errno.h>
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010026#include <asm/gpio.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000027#include <linux/usb/ch9.h>
28#include <linux/usb/gadget.h>
29#include <linux/usb/musb.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040030#include <i2c.h>
31#include "am3517evm.h"
32
33DECLARE_GLOBAL_DATA_PTR;
34
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010035#define AM3517_IP_SW_RESET 0x48002598
36#define CPGMACSS_SW_RST (1 << 1)
Adam Fordb32f5f32017-09-19 20:32:11 -050037#define PHY_GPIO 30
38
Adam Forda55156e2019-03-31 09:18:29 -050039#if defined(CONFIG_SPL_BUILD)
40#if defined(CONFIG_SPL_OS_BOOT)
41int spl_start_uboot(void)
42{
43 /* break into full u-boot on 'c' */
44 return serial_tstc() && serial_getc() == 'c';
45}
46#endif
47#endif
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010048
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040049/*
50 * Routine: board_init
51 * Description: Early hardware init.
52 */
53int board_init(void)
54{
55 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
56 /* board id for Linux */
57 gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
58 /* boot param addr */
59 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
60
61 return 0;
62}
63
Ilya Yanoke484f8e2012-11-06 13:48:28 +000064#ifdef CONFIG_USB_MUSB_AM35X
65static struct musb_hdrc_config musb_config = {
66 .multipoint = 1,
67 .dyn_fifo = 1,
68 .num_eps = 16,
69 .ram_bits = 12,
70};
71
72static struct omap_musb_board_data musb_board_data = {
73 .set_phy_power = am35x_musb_phy_power,
74 .clear_irq = am35x_musb_clear_irq,
75 .reset = am35x_musb_reset,
76};
77
78static struct musb_hdrc_platform_data musb_plat = {
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020079#if defined(CONFIG_USB_MUSB_HOST)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000080 .mode = MUSB_HOST,
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020081#elif defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000082 .mode = MUSB_PERIPHERAL,
83#else
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020084#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
Ilya Yanoke484f8e2012-11-06 13:48:28 +000085#endif
86 .config = &musb_config,
87 .power = 250,
88 .platform_ops = &am35x_ops,
89 .board_data = &musb_board_data,
90};
91
92static void am3517_evm_musb_init(void)
93{
94 /*
95 * Set up USB clock/mode in the DEVCONF2 register.
96 * USB2.0 PHY reference clock is 13 MHz
97 */
98 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
99 CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
100 CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
101 CONF2_VBDTCTEN | CONF2_DATPOL);
102
103 musb_register(&musb_plat, &musb_board_data,
104 (void *)AM35XX_IPSS_USBOTGSS_BASE);
105}
106#else
107#define am3517_evm_musb_init() do {} while (0)
108#endif
109
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400110/*
111 * Routine: misc_init_r
112 * Description: Init i2c, ethernet, etc... (done here so udelay works)
113 */
114int misc_init_r(void)
115{
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100116 u32 reset;
117
Adam Ford8553e892018-08-19 11:11:03 -0500118#if !defined(CONFIG_DM_I2C)
Adam Ford49e96f22017-08-07 13:11:19 -0500119#ifdef CONFIG_SYS_I2C_OMAP24XX
Heiko Schocherf53f2b82013-10-22 11:03:18 +0200120 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400121#endif
Adam Ford8553e892018-08-19 11:11:03 -0500122#endif
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200123 omap_die_id_display();
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400124
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000125 am3517_evm_musb_init();
126
Adam Fordd4c65fa2019-06-23 00:42:14 -0500127 /* ensure that the Ethernet module is out of reset */
128 reset = readl(AM3517_IP_SW_RESET);
129 reset &= (~CPGMACSS_SW_RST);
130 writel(reset, AM3517_IP_SW_RESET);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100131
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400132 return 0;
133}
134
135/*
136 * Routine: set_muxconf_regs
137 * Description: Setting up the configuration Mux registers specific to the
138 * hardware. Many pins need to be moved from protect to primary
139 * mode.
140 */
141void set_muxconf_regs(void)
142{
143 MUX_AM3517EVM();
144}
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400145
Masahiro Yamada0a780172017-05-09 20:31:39 +0900146#if defined(CONFIG_MMC)
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400147int board_mmc_init(bd_t *bis)
148{
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000149 return omap_mmc_init(0, 0, 0, -1, -1);
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400150}
151#endif
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000152
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +0200153#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000154int board_eth_init(bd_t *bis)
155{
156 int rv, n = 0;
157
158 rv = cpu_eth_init(bis);
159 if (rv > 0)
160 n += rv;
161
162 rv = usb_eth_initialize(bis);
163 if (rv > 0)
164 n += rv;
165
166 return n;
167}
168#endif