]> git.ipfire.org Git - thirdparty/u-boot.git/blob - board/logicpd/am3517evm/am3517evm.c
common: Drop net.h from common header
[thirdparty/u-boot.git] / board / logicpd / am3517evm / am3517evm.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
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/
11 */
12
13 #include <common.h>
14 #include <dm.h>
15 #include <net.h>
16 #include <ns16550.h>
17 #include <serial.h>
18 #include <asm/io.h>
19 #include <asm/omap_musb.h>
20 #include <asm/arch/am35x_def.h>
21 #include <asm/arch/mem.h>
22 #include <asm/arch/mux.h>
23 #include <asm/arch/sys_proto.h>
24 #include <asm/arch/mmc_host_def.h>
25 #include <asm/arch/musb.h>
26 #include <asm/mach-types.h>
27 #include <linux/errno.h>
28 #include <asm/gpio.h>
29 #include <linux/usb/ch9.h>
30 #include <linux/usb/gadget.h>
31 #include <linux/usb/musb.h>
32 #include <i2c.h>
33 #include "am3517evm.h"
34
35 DECLARE_GLOBAL_DATA_PTR;
36
37 #define AM3517_IP_SW_RESET 0x48002598
38 #define CPGMACSS_SW_RST (1 << 1)
39 #define PHY_GPIO 30
40
41 #if defined(CONFIG_SPL_BUILD)
42 #if defined(CONFIG_SPL_OS_BOOT)
43 int spl_start_uboot(void)
44 {
45 /* break into full u-boot on 'c' */
46 return serial_tstc() && serial_getc() == 'c';
47 }
48 #endif
49 #endif
50
51 /*
52 * Routine: board_init
53 * Description: Early hardware init.
54 */
55 int board_init(void)
56 {
57 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
58 /* board id for Linux */
59 gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
60 /* boot param addr */
61 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
62
63 return 0;
64 }
65
66 #ifdef CONFIG_USB_MUSB_AM35X
67 static struct musb_hdrc_config musb_config = {
68 .multipoint = 1,
69 .dyn_fifo = 1,
70 .num_eps = 16,
71 .ram_bits = 12,
72 };
73
74 static struct omap_musb_board_data musb_board_data = {
75 .set_phy_power = am35x_musb_phy_power,
76 .clear_irq = am35x_musb_clear_irq,
77 .reset = am35x_musb_reset,
78 };
79
80 static struct musb_hdrc_platform_data musb_plat = {
81 #if defined(CONFIG_USB_MUSB_HOST)
82 .mode = MUSB_HOST,
83 #elif defined(CONFIG_USB_MUSB_GADGET)
84 .mode = MUSB_PERIPHERAL,
85 #else
86 #error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
87 #endif
88 .config = &musb_config,
89 .power = 250,
90 .platform_ops = &am35x_ops,
91 .board_data = &musb_board_data,
92 };
93
94 static void am3517_evm_musb_init(void)
95 {
96 /*
97 * Set up USB clock/mode in the DEVCONF2 register.
98 * USB2.0 PHY reference clock is 13 MHz
99 */
100 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
101 CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
102 CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
103 CONF2_VBDTCTEN | CONF2_DATPOL);
104
105 musb_register(&musb_plat, &musb_board_data,
106 (void *)AM35XX_IPSS_USBOTGSS_BASE);
107 }
108 #else
109 #define am3517_evm_musb_init() do {} while (0)
110 #endif
111
112 /*
113 * Routine: misc_init_r
114 * Description: Init i2c, ethernet, etc... (done here so udelay works)
115 */
116 int misc_init_r(void)
117 {
118 u32 reset;
119
120 omap_die_id_display();
121
122 am3517_evm_musb_init();
123
124 /* ensure that the Ethernet module is out of reset */
125 reset = readl(AM3517_IP_SW_RESET);
126 reset &= (~CPGMACSS_SW_RST);
127 writel(reset, AM3517_IP_SW_RESET);
128
129 return 0;
130 }
131
132 /*
133 * Routine: set_muxconf_regs
134 * Description: Setting up the configuration Mux registers specific to the
135 * hardware. Many pins need to be moved from protect to primary
136 * mode.
137 */
138 void set_muxconf_regs(void)
139 {
140 MUX_AM3517EVM();
141 }
142
143
144 #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
145 int board_eth_init(bd_t *bis)
146 {
147 int rv, n = 0;
148
149 rv = cpu_eth_init(bis);
150 if (rv > 0)
151 n += rv;
152
153 rv = usb_eth_initialize(bis);
154 if (rv > 0)
155 n += rv;
156
157 return n;
158 }
159 #endif