blob: f0141659282a8c5ff8ba06e3b94f09933f306868 [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>
Simon Glass97589732020-05-10 11:40:02 -060015#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060016#include <net.h>
Adam Fordb32f5f32017-09-19 20:32:11 -050017#include <ns16550.h>
Simon Glass36736182019-11-14 12:57:24 -070018#include <serial.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060019#include <asm/global_data.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040020#include <asm/io.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000021#include <asm/omap_musb.h>
22#include <asm/arch/am35x_def.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040023#include <asm/arch/mem.h>
24#include <asm/arch/mux.h>
25#include <asm/arch/sys_proto.h>
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -040026#include <asm/arch/mmc_host_def.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000027#include <asm/arch/musb.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040028#include <asm/mach-types.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090029#include <linux/errno.h>
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010030#include <asm/gpio.h>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000031#include <linux/usb/ch9.h>
32#include <linux/usb/gadget.h>
33#include <linux/usb/musb.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040034#include <i2c.h>
35#include "am3517evm.h"
36
37DECLARE_GLOBAL_DATA_PTR;
38
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010039#define AM3517_IP_SW_RESET 0x48002598
40#define CPGMACSS_SW_RST (1 << 1)
Adam Fordb32f5f32017-09-19 20:32:11 -050041#define PHY_GPIO 30
42
Adam Forda55156e2019-03-31 09:18:29 -050043#if defined(CONFIG_SPL_BUILD)
44#if defined(CONFIG_SPL_OS_BOOT)
45int spl_start_uboot(void)
46{
47 /* break into full u-boot on 'c' */
48 return serial_tstc() && serial_getc() == 'c';
49}
50#endif
51#endif
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010052
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040053/*
54 * Routine: board_init
55 * Description: Early hardware init.
56 */
57int board_init(void)
58{
59 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
60 /* board id for Linux */
61 gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
62 /* boot param addr */
63 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
64
65 return 0;
66}
67
Ilya Yanoke484f8e2012-11-06 13:48:28 +000068#ifdef CONFIG_USB_MUSB_AM35X
69static struct musb_hdrc_config musb_config = {
70 .multipoint = 1,
71 .dyn_fifo = 1,
72 .num_eps = 16,
73 .ram_bits = 12,
74};
75
76static struct omap_musb_board_data musb_board_data = {
77 .set_phy_power = am35x_musb_phy_power,
78 .clear_irq = am35x_musb_clear_irq,
79 .reset = am35x_musb_reset,
80};
81
82static struct musb_hdrc_platform_data musb_plat = {
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020083#if defined(CONFIG_USB_MUSB_HOST)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000084 .mode = MUSB_HOST,
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020085#elif defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000086 .mode = MUSB_PERIPHERAL,
87#else
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020088#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
Ilya Yanoke484f8e2012-11-06 13:48:28 +000089#endif
90 .config = &musb_config,
91 .power = 250,
92 .platform_ops = &am35x_ops,
93 .board_data = &musb_board_data,
94};
95
96static void am3517_evm_musb_init(void)
97{
98 /*
99 * Set up USB clock/mode in the DEVCONF2 register.
100 * USB2.0 PHY reference clock is 13 MHz
101 */
102 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
103 CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
104 CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
105 CONF2_VBDTCTEN | CONF2_DATPOL);
106
107 musb_register(&musb_plat, &musb_board_data,
108 (void *)AM35XX_IPSS_USBOTGSS_BASE);
109}
110#else
111#define am3517_evm_musb_init() do {} while (0)
112#endif
113
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400114/*
115 * Routine: misc_init_r
116 * Description: Init i2c, ethernet, etc... (done here so udelay works)
117 */
118int misc_init_r(void)
119{
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100120 u32 reset;
121
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200122 omap_die_id_display();
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400123
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000124 am3517_evm_musb_init();
125
Adam Fordd4c65fa2019-06-23 00:42:14 -0500126 /* ensure that the Ethernet module is out of reset */
127 reset = readl(AM3517_IP_SW_RESET);
128 reset &= (~CPGMACSS_SW_RST);
129 writel(reset, AM3517_IP_SW_RESET);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100130
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400131 return 0;
132}
133
134/*
135 * Routine: set_muxconf_regs
136 * Description: Setting up the configuration Mux registers specific to the
137 * hardware. Many pins need to be moved from protect to primary
138 * mode.
139 */
140void set_muxconf_regs(void)
141{
142 MUX_AM3517EVM();
143}
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400144
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000145
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +0200146#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900147int board_eth_init(struct bd_info *bis)
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000148{
149 int rv, n = 0;
150
151 rv = cpu_eth_init(bis);
152 if (rv > 0)
153 n += rv;
154
155 rv = usb_eth_initialize(bis);
156 if (rv > 0)
157 n += rv;
158
159 return n;
160}
161#endif