blob: 6f728398c38dff1c6b8301574b2c9e6fb0cc225b [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>
Ilya Yanoke484f8e2012-11-06 13:48:28 +000031#include <netdev.h>
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040032#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
Yegor Yefremovd7ac7962013-12-11 15:41:11 +010040
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -040041/*
42 * Routine: board_init
43 * Description: Early hardware init.
44 */
45int board_init(void)
46{
47 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
48 /* board id for Linux */
49 gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
50 /* boot param addr */
51 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
52
53 return 0;
54}
55
Ilya Yanoke484f8e2012-11-06 13:48:28 +000056#ifdef CONFIG_USB_MUSB_AM35X
57static struct musb_hdrc_config musb_config = {
58 .multipoint = 1,
59 .dyn_fifo = 1,
60 .num_eps = 16,
61 .ram_bits = 12,
62};
63
64static struct omap_musb_board_data musb_board_data = {
65 .set_phy_power = am35x_musb_phy_power,
66 .clear_irq = am35x_musb_clear_irq,
67 .reset = am35x_musb_reset,
68};
69
70static struct musb_hdrc_platform_data musb_plat = {
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020071#if defined(CONFIG_USB_MUSB_HOST)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000072 .mode = MUSB_HOST,
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020073#elif defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanoke484f8e2012-11-06 13:48:28 +000074 .mode = MUSB_PERIPHERAL,
75#else
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +020076#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
Ilya Yanoke484f8e2012-11-06 13:48:28 +000077#endif
78 .config = &musb_config,
79 .power = 250,
80 .platform_ops = &am35x_ops,
81 .board_data = &musb_board_data,
82};
83
84static void am3517_evm_musb_init(void)
85{
86 /*
87 * Set up USB clock/mode in the DEVCONF2 register.
88 * USB2.0 PHY reference clock is 13 MHz
89 */
90 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
91 CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
92 CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
93 CONF2_VBDTCTEN | CONF2_DATPOL);
94
95 musb_register(&musb_plat, &musb_board_data,
96 (void *)AM35XX_IPSS_USBOTGSS_BASE);
97}
98#else
99#define am3517_evm_musb_init() do {} while (0)
100#endif
101
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400102/*
103 * Routine: misc_init_r
104 * Description: Init i2c, ethernet, etc... (done here so udelay works)
105 */
106int misc_init_r(void)
107{
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100108 volatile unsigned int ctr;
109 u32 reset;
110
Adam Ford8553e892018-08-19 11:11:03 -0500111#if !defined(CONFIG_DM_I2C)
Adam Ford49e96f22017-08-07 13:11:19 -0500112#ifdef CONFIG_SYS_I2C_OMAP24XX
Heiko Schocherf53f2b82013-10-22 11:03:18 +0200113 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400114#endif
Adam Ford8553e892018-08-19 11:11:03 -0500115#endif
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200116 omap_die_id_display();
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400117
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000118 am3517_evm_musb_init();
119
Adam Fordb32f5f32017-09-19 20:32:11 -0500120 if (gpio_request(PHY_GPIO, "gpio_30") == 0) {
121 /* activate PHY reset */
122 gpio_direction_output(PHY_GPIO, 0);
123 gpio_set_value(PHY_GPIO, 0);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100124
Adam Fordb32f5f32017-09-19 20:32:11 -0500125 ctr = 0;
126 do {
127 udelay(1000);
128 ctr++;
129 } while (ctr < 300);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100130
Adam Fordb32f5f32017-09-19 20:32:11 -0500131 /* deactivate PHY reset */
132 gpio_set_value(PHY_GPIO, 1);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100133
Adam Fordb32f5f32017-09-19 20:32:11 -0500134 /* allow the PHY to stabilize and settle down */
135 ctr = 0;
136 do {
137 udelay(1000);
138 ctr++;
139 } while (ctr < 300);
140
141 /* ensure that the module is out of reset */
142 reset = readl(AM3517_IP_SW_RESET);
143 reset &= (~CPGMACSS_SW_RST);
144 writel(reset, AM3517_IP_SW_RESET);
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100145
Adam Fordb32f5f32017-09-19 20:32:11 -0500146 /* Free requested GPIO */
147 gpio_free(PHY_GPIO);
148 }
Yegor Yefremovd7ac7962013-12-11 15:41:11 +0100149
Vaibhav Hiremathdb5c5582010-06-07 15:20:43 -0400150 return 0;
151}
152
153/*
154 * Routine: set_muxconf_regs
155 * Description: Setting up the configuration Mux registers specific to the
156 * hardware. Many pins need to be moved from protect to primary
157 * mode.
158 */
159void set_muxconf_regs(void)
160{
161 MUX_AM3517EVM();
162}
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400163
Masahiro Yamada0a780172017-05-09 20:31:39 +0900164#if defined(CONFIG_MMC)
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400165int board_mmc_init(bd_t *bis)
166{
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000167 return omap_mmc_init(0, 0, 0, -1, -1);
Vaibhav Hiremath1e05ff82011-09-03 21:47:44 -0400168}
169#endif
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000170
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +0200171#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanoke484f8e2012-11-06 13:48:28 +0000172int board_eth_init(bd_t *bis)
173{
174 int rv, n = 0;
175
176 rv = cpu_eth_init(bis);
177 if (rv > 0)
178 n += rv;
179
180 rv = usb_eth_initialize(bis);
181 if (rv > 0)
182 n += rv;
183
184 return n;
185}
186#endif