blob: e8f604f5db095f4248eea19f6b3ba460ac110c34 [file] [log] [blame]
Mike Rapoport8abe7302010-12-18 17:43:19 -05001/*
Igor Grinberge83d2292013-04-22 01:06:53 +00002 * (C) Copyright 2011 - 2013 CompuLab, Ltd. <www.compulab.co.il>
Mike Rapoport8abe7302010-12-18 17:43:19 -05003 *
Igor Grinbergbebedbf2011-04-18 17:48:31 -04004 * Authors: Mike Rapoport <mike@compulab.co.il>
5 * Igor Grinberg <grinberg@compulab.co.il>
Mike Rapoport8abe7302010-12-18 17:43:19 -05006 *
7 * Derived from omap3evm and Beagle Board by
8 * Manikandan Pillai <mani.pillai@ti.com>
9 * Richard Woodruff <r-woodruff2@ti.com>
10 * Syed Mohammed Khasim <x0khasim@ti.com>
11 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +020012 * SPDX-License-Identifier: GPL-2.0+
Mike Rapoport8abe7302010-12-18 17:43:19 -050013 */
14
15#include <common.h>
Alex Kiernan9c215492018-04-01 09:22:38 +000016#include <environment.h>
Igor Grinbergd2367bc2011-04-18 17:54:33 -040017#include <status_led.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050018#include <netdev.h>
19#include <net.h>
20#include <i2c.h>
Nikita Kiryanov9f957be2012-12-02 13:59:19 +020021#include <usb.h>
Nikita Kiryanov4459e762012-12-03 02:19:45 +000022#include <mmc.h>
Nikita Kiryanov7f9ceea2015-01-14 10:42:54 +020023#include <splash.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050024#include <twl4030.h>
Nikita Kiryanovb47cb9d2012-01-12 03:26:30 +000025#include <linux/compiler.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050026
27#include <asm/io.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090028#include <linux/errno.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050029#include <asm/arch/mem.h>
30#include <asm/arch/mux.h>
31#include <asm/arch/mmc_host_def.h>
32#include <asm/arch/sys_proto.h>
33#include <asm/mach-types.h>
Nikita Kiryanov9f957be2012-12-02 13:59:19 +020034#include <asm/ehci-omap.h>
35#include <asm/gpio.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050036
Igor Grinberg3c5dc282014-11-03 11:32:18 +020037#include "../common/common.h"
Igor Grinberg3394be82013-09-16 21:49:58 +030038#include "../common/eeprom.h"
Nikita Kiryanovf1ef8692012-01-12 03:28:09 +000039
Igor Grinberg8bd1b192011-04-18 17:43:26 -040040DECLARE_GLOBAL_DATA_PTR;
41
Mike Rapoport8abe7302010-12-18 17:43:19 -050042const omap3_sysinfo sysinfo = {
43 DDR_DISCRETE,
Igor Grinberg05a96a42011-04-18 17:55:21 -040044 "CM-T3x board",
Mike Rapoport8abe7302010-12-18 17:43:19 -050045 "NAND",
46};
47
Stefan Roese8ef10bd2013-12-04 13:54:18 +010048#ifdef CONFIG_SPL_BUILD
49/*
50 * Routine: get_board_mem_timings
51 * Description: If we use SPL then there is no x-loader nor config header
52 * so we have to setup the DDR timings ourself on both banks.
53 */
54void get_board_mem_timings(struct board_sdrc_timings *timings)
55{
56 timings->mr = MICRON_V_MR_165;
57 timings->mcfg = MICRON_V_MCFG_200(256 << 20); /* raswidth 14 needed */
58 timings->ctrla = MICRON_V_ACTIMA_165;
59 timings->ctrlb = MICRON_V_ACTIMB_165;
60 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
61}
62#endif
63
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +020064struct splash_location splash_locations[] = {
65 {
66 .name = "nand",
67 .storage = SPLASH_STORAGE_NAND,
Nikita Kiryanov74282712015-10-29 11:54:41 +020068 .flags = SPLASH_STORAGE_RAW,
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +020069 .offset = 0x100000,
70 },
71};
Igor Grinberg86ec16b2014-11-03 11:32:20 +020072
Robert Winkler2abfe362013-06-17 11:31:31 -070073int splash_screen_prepare(void)
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000074{
Nikita Kiryanov7f9ceea2015-01-14 10:42:54 +020075 return splash_source_load(splash_locations,
76 ARRAY_SIZE(splash_locations));
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000077}
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000078
Mike Rapoport8abe7302010-12-18 17:43:19 -050079/*
80 * Routine: board_init
Igor Grinberg7e741ff2012-06-13 19:41:40 +000081 * Description: hardware init.
Mike Rapoport8abe7302010-12-18 17:43:19 -050082 */
83int board_init(void)
84{
Mike Rapoport8abe7302010-12-18 17:43:19 -050085 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
86
Mike Rapoport8abe7302010-12-18 17:43:19 -050087 /* board id for Linux */
Igor Grinberg05a96a42011-04-18 17:55:21 -040088 if (get_cpu_family() == CPU_OMAP34XX)
89 gd->bd->bi_arch_number = MACH_TYPE_CM_T35;
90 else
91 gd->bd->bi_arch_number = MACH_TYPE_CM_T3730;
92
Mike Rapoport8abe7302010-12-18 17:43:19 -050093 /* boot param addr */
94 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
95
Uri Mashiach4892d392017-01-19 10:51:45 +020096#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
97 status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
Igor Grinbergd2367bc2011-04-18 17:54:33 -040098#endif
99
Mike Rapoport8abe7302010-12-18 17:43:19 -0500100 return 0;
101}
102
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000103/*
104 * Routine: get_board_rev
105 * Description: read system revision
106 */
107u32 get_board_rev(void)
108{
Nikita Kiryanov7fa68352015-09-06 11:48:35 +0300109 return cl_eeprom_get_board_rev(CONFIG_SYS_I2C_EEPROM_BUS);
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000110};
111
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000112int misc_init_r(void)
113{
Igor Grinberg3c5dc282014-11-03 11:32:18 +0200114 cl_print_pcb_info();
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200115 omap_die_id_display();
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000116
117 return 0;
118}
119
Mike Rapoport8abe7302010-12-18 17:43:19 -0500120/*
Mike Rapoport8abe7302010-12-18 17:43:19 -0500121 * Routine: set_muxconf_regs
122 * Description: Setting up the configuration Mux registers specific to the
123 * hardware. Many pins need to be moved from protect to primary
124 * mode.
125 */
Igor Grinberg05a96a42011-04-18 17:55:21 -0400126static void cm_t3x_set_common_muxconf(void)
Mike Rapoport8abe7302010-12-18 17:43:19 -0500127{
128 /* SDRC */
129 MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0)); /*SDRC_D0*/
130 MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0)); /*SDRC_D1*/
131 MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0)); /*SDRC_D2*/
132 MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0)); /*SDRC_D3*/
133 MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0)); /*SDRC_D4*/
134 MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0)); /*SDRC_D5*/
135 MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0)); /*SDRC_D6*/
136 MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0)); /*SDRC_D7*/
137 MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0)); /*SDRC_D8*/
138 MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0)); /*SDRC_D9*/
139 MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0)); /*SDRC_D10*/
140 MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0)); /*SDRC_D11*/
141 MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0)); /*SDRC_D12*/
142 MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0)); /*SDRC_D13*/
143 MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0)); /*SDRC_D14*/
144 MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0)); /*SDRC_D15*/
145 MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0)); /*SDRC_D16*/
146 MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0)); /*SDRC_D17*/
147 MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0)); /*SDRC_D18*/
148 MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0)); /*SDRC_D19*/
149 MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0)); /*SDRC_D20*/
150 MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0)); /*SDRC_D21*/
151 MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0)); /*SDRC_D22*/
152 MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0)); /*SDRC_D23*/
153 MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0)); /*SDRC_D24*/
154 MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0)); /*SDRC_D25*/
155 MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0)); /*SDRC_D26*/
156 MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0)); /*SDRC_D27*/
157 MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0)); /*SDRC_D28*/
158 MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0)); /*SDRC_D29*/
159 MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0)); /*SDRC_D30*/
160 MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0)); /*SDRC_D31*/
161 MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0)); /*SDRC_CLK*/
162 MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0)); /*SDRC_DQS0*/
163 MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0)); /*SDRC_DQS1*/
164 MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0)); /*SDRC_DQS2*/
165 MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0)); /*SDRC_DQS3*/
166 MUX_VAL(CP(SDRC_CKE0), (IDIS | PTU | EN | M0)); /*SDRC_CKE0*/
167 MUX_VAL(CP(SDRC_CKE1), (IDIS | PTD | DIS | M7)); /*SDRC_CKE1*/
168
169 /* GPMC */
170 MUX_VAL(CP(GPMC_A1), (IDIS | PTU | EN | M0)); /*GPMC_A1*/
171 MUX_VAL(CP(GPMC_A2), (IDIS | PTU | EN | M0)); /*GPMC_A2*/
172 MUX_VAL(CP(GPMC_A3), (IDIS | PTU | EN | M0)); /*GPMC_A3*/
173 MUX_VAL(CP(GPMC_A4), (IDIS | PTU | EN | M0)); /*GPMC_A4*/
174 MUX_VAL(CP(GPMC_A5), (IDIS | PTU | EN | M0)); /*GPMC_A5*/
175 MUX_VAL(CP(GPMC_A6), (IDIS | PTU | EN | M0)); /*GPMC_A6*/
176 MUX_VAL(CP(GPMC_A7), (IDIS | PTU | EN | M0)); /*GPMC_A7*/
177 MUX_VAL(CP(GPMC_A8), (IDIS | PTU | EN | M0)); /*GPMC_A8*/
178 MUX_VAL(CP(GPMC_A9), (IDIS | PTU | EN | M0)); /*GPMC_A9*/
179 MUX_VAL(CP(GPMC_A10), (IDIS | PTU | EN | M0)); /*GPMC_A10*/
180 MUX_VAL(CP(GPMC_D0), (IEN | PTU | EN | M0)); /*GPMC_D0*/
181 MUX_VAL(CP(GPMC_D1), (IEN | PTU | EN | M0)); /*GPMC_D1*/
182 MUX_VAL(CP(GPMC_D2), (IEN | PTU | EN | M0)); /*GPMC_D2*/
183 MUX_VAL(CP(GPMC_D3), (IEN | PTU | EN | M0)); /*GPMC_D3*/
184 MUX_VAL(CP(GPMC_D4), (IEN | PTU | EN | M0)); /*GPMC_D4*/
185 MUX_VAL(CP(GPMC_D5), (IEN | PTU | EN | M0)); /*GPMC_D5*/
186 MUX_VAL(CP(GPMC_D6), (IEN | PTU | EN | M0)); /*GPMC_D6*/
187 MUX_VAL(CP(GPMC_D7), (IEN | PTU | EN | M0)); /*GPMC_D7*/
188 MUX_VAL(CP(GPMC_D8), (IEN | PTU | EN | M0)); /*GPMC_D8*/
189 MUX_VAL(CP(GPMC_D9), (IEN | PTU | EN | M0)); /*GPMC_D9*/
190 MUX_VAL(CP(GPMC_D10), (IEN | PTU | EN | M0)); /*GPMC_D10*/
191 MUX_VAL(CP(GPMC_D11), (IEN | PTU | EN | M0)); /*GPMC_D11*/
192 MUX_VAL(CP(GPMC_D12), (IEN | PTU | EN | M0)); /*GPMC_D12*/
193 MUX_VAL(CP(GPMC_D13), (IEN | PTU | EN | M0)); /*GPMC_D13*/
194 MUX_VAL(CP(GPMC_D14), (IEN | PTU | EN | M0)); /*GPMC_D14*/
195 MUX_VAL(CP(GPMC_D15), (IEN | PTU | EN | M0)); /*GPMC_D15*/
196 MUX_VAL(CP(GPMC_NCS0), (IDIS | PTU | EN | M0)); /*GPMC_nCS0*/
197
198 /* SB-T35 Ethernet */
199 MUX_VAL(CP(GPMC_NCS4), (IEN | PTU | EN | M0)); /*GPMC_nCS4*/
200
Nikita Kiryanov2247eb42013-01-30 21:39:58 +0000201 /* DVI enable */
202 MUX_VAL(CP(GPMC_NCS3), (IDIS | PTU | DIS | M4));/*GPMC_nCS3*/
203
Nikita Kiryanov25da1522013-10-16 17:23:29 +0300204 /* DataImage backlight */
205 MUX_VAL(CP(GPMC_NCS7), (IDIS | PTU | DIS | M4));/*GPIO_58*/
206
Igor Grinberg05a96a42011-04-18 17:55:21 -0400207 /* CM-T3x Ethernet */
Mike Rapoport8abe7302010-12-18 17:43:19 -0500208 MUX_VAL(CP(GPMC_NCS5), (IDIS | PTU | DIS | M0)); /*GPMC_nCS5*/
209 MUX_VAL(CP(GPMC_CLK), (IEN | PTD | DIS | M4)); /*GPIO_59*/
210 MUX_VAL(CP(GPMC_NADV_ALE), (IDIS | PTD | DIS | M0)); /*nADV_ALE*/
211 MUX_VAL(CP(GPMC_NOE), (IDIS | PTD | DIS | M0)); /*nOE*/
212 MUX_VAL(CP(GPMC_NWE), (IDIS | PTD | DIS | M0)); /*nWE*/
213 MUX_VAL(CP(GPMC_NBE0_CLE), (IDIS | PTU | EN | M0)); /*nBE0_CLE*/
214 MUX_VAL(CP(GPMC_NBE1), (IDIS | PTD | DIS | M4)); /*GPIO_61*/
215 MUX_VAL(CP(GPMC_NWP), (IEN | PTD | DIS | M0)); /*nWP*/
216 MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0)); /*WAIT0*/
217
218 /* DSS */
219 MUX_VAL(CP(DSS_PCLK), (IDIS | PTD | DIS | M0)); /*DSS_PCLK*/
220 MUX_VAL(CP(DSS_HSYNC), (IDIS | PTD | DIS | M0)); /*DSS_HSYNC*/
221 MUX_VAL(CP(DSS_VSYNC), (IDIS | PTD | DIS | M0)); /*DSS_VSYNC*/
222 MUX_VAL(CP(DSS_ACBIAS), (IDIS | PTD | DIS | M0)); /*DSS_ACBIAS*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500223 MUX_VAL(CP(DSS_DATA6), (IDIS | PTD | DIS | M0)); /*DSS_DATA6*/
224 MUX_VAL(CP(DSS_DATA7), (IDIS | PTD | DIS | M0)); /*DSS_DATA7*/
225 MUX_VAL(CP(DSS_DATA8), (IDIS | PTD | DIS | M0)); /*DSS_DATA8*/
226 MUX_VAL(CP(DSS_DATA9), (IDIS | PTD | DIS | M0)); /*DSS_DATA9*/
227 MUX_VAL(CP(DSS_DATA10), (IDIS | PTD | DIS | M0)); /*DSS_DATA10*/
228 MUX_VAL(CP(DSS_DATA11), (IDIS | PTD | DIS | M0)); /*DSS_DATA11*/
229 MUX_VAL(CP(DSS_DATA12), (IDIS | PTD | DIS | M0)); /*DSS_DATA12*/
230 MUX_VAL(CP(DSS_DATA13), (IDIS | PTD | DIS | M0)); /*DSS_DATA13*/
231 MUX_VAL(CP(DSS_DATA14), (IDIS | PTD | DIS | M0)); /*DSS_DATA14*/
232 MUX_VAL(CP(DSS_DATA15), (IDIS | PTD | DIS | M0)); /*DSS_DATA15*/
233 MUX_VAL(CP(DSS_DATA16), (IDIS | PTD | DIS | M0)); /*DSS_DATA16*/
234 MUX_VAL(CP(DSS_DATA17), (IDIS | PTD | DIS | M0)); /*DSS_DATA17*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500235
236 /* serial interface */
237 MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M0)); /*UART3_RX*/
238 MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M0)); /*UART3_TX*/
239
240 /* mUSB */
241 MUX_VAL(CP(HSUSB0_CLK), (IEN | PTD | DIS | M0)); /*HSUSB0_CLK*/
242 MUX_VAL(CP(HSUSB0_STP), (IDIS | PTU | EN | M0)); /*HSUSB0_STP*/
243 MUX_VAL(CP(HSUSB0_DIR), (IEN | PTD | DIS | M0)); /*HSUSB0_DIR*/
244 MUX_VAL(CP(HSUSB0_NXT), (IEN | PTD | DIS | M0)); /*HSUSB0_NXT*/
245 MUX_VAL(CP(HSUSB0_DATA0), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA0*/
246 MUX_VAL(CP(HSUSB0_DATA1), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA1*/
247 MUX_VAL(CP(HSUSB0_DATA2), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA2*/
248 MUX_VAL(CP(HSUSB0_DATA3), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA3*/
249 MUX_VAL(CP(HSUSB0_DATA4), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA4*/
250 MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA5*/
251 MUX_VAL(CP(HSUSB0_DATA6), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA6*/
252 MUX_VAL(CP(HSUSB0_DATA7), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA7*/
253
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200254 /* USB EHCI */
255 MUX_VAL(CP(ETK_D0_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT0*/
256 MUX_VAL(CP(ETK_D1_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT1*/
257 MUX_VAL(CP(ETK_D2_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT2*/
258 MUX_VAL(CP(ETK_D7_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT3*/
259 MUX_VAL(CP(ETK_D4_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT4*/
260 MUX_VAL(CP(ETK_D5_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT5*/
261 MUX_VAL(CP(ETK_D6_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT6*/
262 MUX_VAL(CP(ETK_D3_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT7*/
263 MUX_VAL(CP(ETK_D8_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DIR*/
264 MUX_VAL(CP(ETK_D9_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_NXT*/
265 MUX_VAL(CP(ETK_CTL_ES2), (IDIS | PTD | DIS | M3)); /*HSUSB1_CLK*/
266 MUX_VAL(CP(ETK_CLK_ES2), (IDIS | PTU | DIS | M3)); /*HSUSB1_STP*/
267
268 MUX_VAL(CP(ETK_D14_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_DT0*/
269 MUX_VAL(CP(ETK_D15_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_DT1*/
270 MUX_VAL(CP(MCSPI1_CS3), (IEN | PTD | EN | M3)); /*HSUSB2_DT2*/
271 MUX_VAL(CP(MCSPI2_CS1), (IEN | PTD | EN | M3)); /*HSUSB2_DT3*/
272 MUX_VAL(CP(MCSPI2_SIMO), (IEN | PTD | EN | M3)); /*HSUSB2_DT4*/
273 MUX_VAL(CP(MCSPI2_SOMI), (IEN | PTD | EN | M3)); /*HSUSB2_DT5*/
274 MUX_VAL(CP(MCSPI2_CS0), (IEN | PTD | EN | M3)); /*HSUSB2_DT6*/
275 MUX_VAL(CP(MCSPI2_CLK), (IEN | PTD | EN | M3)); /*HSUSB2_DT7*/
276 MUX_VAL(CP(ETK_D12_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_DIR*/
277 MUX_VAL(CP(ETK_D13_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_NXT*/
278 MUX_VAL(CP(ETK_D10_ES2), (IDIS | PTD | DIS | M3)); /*HSUSB2_CLK*/
279 MUX_VAL(CP(ETK_D11_ES2), (IDIS | PTU | DIS | M3)); /*HSUSB2_STP*/
280
281 /* SB_T35_USB_HUB_RESET_GPIO */
282 MUX_VAL(CP(CAM_WEN), (IDIS | PTD | DIS | M4)); /*GPIO_167*/
283
Mike Rapoport8abe7302010-12-18 17:43:19 -0500284 /* I2C1 */
285 MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0)); /*I2C1_SCL*/
286 MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0)); /*I2C1_SDA*/
Nikita Kiryanovda4da302012-04-02 02:29:31 +0000287 /* I2C2 */
288 MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M0)); /*I2C2_SCL*/
289 MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M0)); /*I2C2_SDA*/
290 /* I2C3 */
291 MUX_VAL(CP(I2C3_SCL), (IEN | PTU | EN | M0)); /*I2C3_SCL*/
292 MUX_VAL(CP(I2C3_SDA), (IEN | PTU | EN | M0)); /*I2C3_SDA*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500293
294 /* control and debug */
295 MUX_VAL(CP(SYS_32K), (IEN | PTD | DIS | M0)); /*SYS_32K*/
296 MUX_VAL(CP(SYS_CLKREQ), (IEN | PTD | DIS | M0)); /*SYS_CLKREQ*/
297 MUX_VAL(CP(SYS_NIRQ), (IEN | PTU | EN | M0)); /*SYS_nIRQ*/
298 MUX_VAL(CP(SYS_OFF_MODE), (IEN | PTD | DIS | M0)); /*OFF_MODE*/
299 MUX_VAL(CP(SYS_CLKOUT1), (IEN | PTD | DIS | M0)); /*CLKOUT1*/
Igor Grinbergd2367bc2011-04-18 17:54:33 -0400300 MUX_VAL(CP(SYS_CLKOUT2), (IDIS | PTU | DIS | M4)); /*green LED*/
Igor Grinberg165808d2014-10-21 18:25:30 +0300301 MUX_VAL(CP(JTAG_NTRST), (IEN | PTD | DIS | M0)); /*JTAG_NTRST*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500302 MUX_VAL(CP(JTAG_TCK), (IEN | PTD | DIS | M0)); /*JTAG_TCK*/
303 MUX_VAL(CP(JTAG_TMS), (IEN | PTD | DIS | M0)); /*JTAG_TMS*/
304 MUX_VAL(CP(JTAG_TDI), (IEN | PTD | DIS | M0)); /*JTAG_TDI*/
Igor Grinberga704ce02011-04-18 17:50:07 -0400305
306 /* MMC1 */
307 MUX_VAL(CP(MMC1_CLK), (IDIS | PTU | EN | M0)); /*MMC1_CLK*/
308 MUX_VAL(CP(MMC1_CMD), (IEN | PTU | EN | M0)); /*MMC1_CMD*/
309 MUX_VAL(CP(MMC1_DAT0), (IEN | PTU | EN | M0)); /*MMC1_DAT0*/
310 MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0)); /*MMC1_DAT1*/
311 MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0)); /*MMC1_DAT2*/
312 MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0)); /*MMC1_DAT3*/
Nikita Kiryanov25da1522013-10-16 17:23:29 +0300313
314 /* SPI */
315 MUX_VAL(CP(MCBSP1_CLKR), (IEN | PTD | DIS | M1)); /*MCSPI4_CLK*/
316 MUX_VAL(CP(MCBSP1_DX), (IEN | PTD | DIS | M1)); /*MCSPI4_SIMO*/
317 MUX_VAL(CP(MCBSP1_DR), (IEN | PTD | DIS | M1)); /*MCSPI4_SOMI*/
318 MUX_VAL(CP(MCBSP1_FSX), (IEN | PTU | EN | M1)); /*MCSPI4_CS0*/
319
320 /* display controls */
321 MUX_VAL(CP(MCBSP1_FSR), (IDIS | PTU | DIS | M4)); /*GPIO_157*/
Igor Grinberg05a96a42011-04-18 17:55:21 -0400322}
323
324static void cm_t35_set_muxconf(void)
325{
326 /* DSS */
327 MUX_VAL(CP(DSS_DATA0), (IDIS | PTD | DIS | M0)); /*DSS_DATA0*/
328 MUX_VAL(CP(DSS_DATA1), (IDIS | PTD | DIS | M0)); /*DSS_DATA1*/
329 MUX_VAL(CP(DSS_DATA2), (IDIS | PTD | DIS | M0)); /*DSS_DATA2*/
330 MUX_VAL(CP(DSS_DATA3), (IDIS | PTD | DIS | M0)); /*DSS_DATA3*/
331 MUX_VAL(CP(DSS_DATA4), (IDIS | PTD | DIS | M0)); /*DSS_DATA4*/
332 MUX_VAL(CP(DSS_DATA5), (IDIS | PTD | DIS | M0)); /*DSS_DATA5*/
333
334 MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M0)); /*DSS_DATA18*/
335 MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M0)); /*DSS_DATA19*/
336 MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M0)); /*DSS_DATA20*/
337 MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M0)); /*DSS_DATA21*/
338 MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M0)); /*DSS_DATA22*/
339 MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M0)); /*DSS_DATA23*/
340
341 /* MMC1 */
Igor Grinberga704ce02011-04-18 17:50:07 -0400342 MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M0)); /*MMC1_DAT4*/
343 MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M0)); /*MMC1_DAT5*/
344 MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M0)); /*MMC1_DAT6*/
345 MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M0)); /*MMC1_DAT7*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500346}
347
Igor Grinberg05a96a42011-04-18 17:55:21 -0400348static void cm_t3730_set_muxconf(void)
349{
350 /* DSS */
351 MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M3)); /*DSS_DATA0*/
352 MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M3)); /*DSS_DATA1*/
353 MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M3)); /*DSS_DATA2*/
354 MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M3)); /*DSS_DATA3*/
355 MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M3)); /*DSS_DATA4*/
356 MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M3)); /*DSS_DATA5*/
357
358 MUX_VAL(CP(SYS_BOOT0), (IDIS | PTD | DIS | M3)); /*DSS_DATA18*/
359 MUX_VAL(CP(SYS_BOOT1), (IDIS | PTD | DIS | M3)); /*DSS_DATA19*/
360 MUX_VAL(CP(SYS_BOOT3), (IDIS | PTD | DIS | M3)); /*DSS_DATA20*/
361 MUX_VAL(CP(SYS_BOOT4), (IDIS | PTD | DIS | M3)); /*DSS_DATA21*/
362 MUX_VAL(CP(SYS_BOOT5), (IDIS | PTD | DIS | M3)); /*DSS_DATA22*/
363 MUX_VAL(CP(SYS_BOOT6), (IDIS | PTD | DIS | M3)); /*DSS_DATA23*/
364}
365
366void set_muxconf_regs(void)
367{
368 cm_t3x_set_common_muxconf();
369
370 if (get_cpu_family() == CPU_OMAP34XX)
371 cm_t35_set_muxconf();
372 else
373 cm_t3730_set_muxconf();
374}
375
Masahiro Yamada0a780172017-05-09 20:31:39 +0900376#if defined(CONFIG_MMC)
Igor Grinbergde25e2d2014-10-21 16:39:46 +0300377#define SB_T35_WP_GPIO 59
378
Nikita Kiryanov4459e762012-12-03 02:19:45 +0000379int board_mmc_getcd(struct mmc *mmc)
380{
381 u8 val;
382
Nishanth Menon5d9d6f72013-03-26 05:20:50 +0000383 if (twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO, &val))
Nikita Kiryanov4459e762012-12-03 02:19:45 +0000384 return -1;
385
386 return !(val & 1);
387}
388
Tom Rinid0974a82011-09-03 21:49:24 -0400389int board_mmc_init(bd_t *bis)
390{
Igor Grinbergde25e2d2014-10-21 16:39:46 +0300391 return omap_mmc_init(0, 0, 0, -1, SB_T35_WP_GPIO);
Tom Rinid0974a82011-09-03 21:49:24 -0400392}
393#endif
394
Masahiro Yamada0a780172017-05-09 20:31:39 +0900395#if defined(CONFIG_MMC)
Paul Kocialkowski69559892014-11-08 20:55:47 +0100396void board_mmc_power_init(void)
397{
398 twl4030_power_mmc_init(0);
399}
400#endif
401
Adam Ford49e96f22017-08-07 13:11:19 -0500402#ifdef CONFIG_SYS_I2C_OMAP24XX
Mike Rapoport8abe7302010-12-18 17:43:19 -0500403/*
404 * Routine: reset_net_chip
405 * Description: reset the Ethernet controller via TPS65930 GPIO
406 */
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200407static int cm_t3x_reset_net_chip(int gpio)
Mike Rapoport8abe7302010-12-18 17:43:19 -0500408{
409 /* Set GPIO1 of TPS65930 as output */
Nishanth Menond26a1062013-03-26 05:20:49 +0000410 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x03,
411 0x02);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500412 /* Send a pulse on the GPIO pin */
Nishanth Menond26a1062013-03-26 05:20:49 +0000413 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x0C,
414 0x02);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500415 udelay(1);
Nishanth Menond26a1062013-03-26 05:20:49 +0000416 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x09,
417 0x02);
Igor Grinberge4d26a22012-04-02 20:12:58 +0000418 mdelay(40);
Nishanth Menond26a1062013-03-26 05:20:49 +0000419 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x0C,
420 0x02);
Igor Grinberge4d26a22012-04-02 20:12:58 +0000421 mdelay(1);
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200422 return 0;
Mike Rapoport8abe7302010-12-18 17:43:19 -0500423}
424#else
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200425static inline int cm_t3x_reset_net_chip(int gpio) { return 0; }
Mike Rapoport8abe7302010-12-18 17:43:19 -0500426#endif
427
Nikita Kiryanovb7792f02012-01-02 04:01:31 +0000428#ifdef CONFIG_SMC911X
Mike Rapoport8abe7302010-12-18 17:43:19 -0500429/*
430 * Routine: handle_mac_address
431 * Description: prepare MAC address for on-board Ethernet.
432 */
433static int handle_mac_address(void)
434{
435 unsigned char enetaddr[6];
436 int rc;
437
Simon Glass399a9ce2017-08-03 12:22:14 -0600438 rc = eth_env_get_enetaddr("ethaddr", enetaddr);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500439 if (rc)
440 return 0;
441
Nikita Kiryanovb2c55472015-01-14 10:42:43 +0200442 rc = cl_eeprom_read_mac_addr(enetaddr, CONFIG_SYS_I2C_EEPROM_BUS);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500443 if (rc)
444 return rc;
Mike Rapoport8abe7302010-12-18 17:43:19 -0500445
Joe Hershberger8ecdbed2015-04-08 01:41:04 -0500446 if (!is_valid_ethaddr(enetaddr))
Mike Rapoport8abe7302010-12-18 17:43:19 -0500447 return -1;
448
Simon Glass8551d552017-08-03 12:22:11 -0600449 return eth_env_set_enetaddr("ethaddr", enetaddr);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500450}
451
Mike Rapoport8abe7302010-12-18 17:43:19 -0500452/*
453 * Routine: board_eth_init
454 * Description: initialize module and base-board Ethernet chips
455 */
Adam Ford0a044f82017-09-05 15:20:44 -0500456#define SB_T35_SMC911X_BASE (CONFIG_SMC911X_BASE + SZ_16M)
Mike Rapoport8abe7302010-12-18 17:43:19 -0500457int board_eth_init(bd_t *bis)
458{
459 int rc = 0, rc1 = 0;
460
Mike Rapoport8abe7302010-12-18 17:43:19 -0500461 rc1 = handle_mac_address();
462 if (rc1)
Igor Grinberg7e741ff2012-06-13 19:41:40 +0000463 printf("No MAC address found! ");
Mike Rapoport8abe7302010-12-18 17:43:19 -0500464
Adam Ford0a044f82017-09-05 15:20:44 -0500465 rc1 = cl_omap3_smc911x_init(0, 5, CONFIG_SMC911X_BASE,
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200466 cm_t3x_reset_net_chip, -EINVAL);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500467 if (rc1 > 0)
468 rc++;
469
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200470 rc1 = cl_omap3_smc911x_init(1, 4, SB_T35_SMC911X_BASE, NULL, -EINVAL);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500471 if (rc1 > 0)
472 rc++;
Mike Rapoport8abe7302010-12-18 17:43:19 -0500473
474 return rc;
475}
Nikita Kiryanovb7792f02012-01-02 04:01:31 +0000476#endif
Nikita Kiryanovb47cb9d2012-01-12 03:26:30 +0000477
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200478#ifdef CONFIG_USB_EHCI_OMAP
479struct omap_usbhs_board_data usbhs_bdata = {
480 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
481 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
482 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
483};
484
485#define SB_T35_USB_HUB_RESET_GPIO 167
Troy Kisky7d6bbb92013-10-10 15:27:57 -0700486int ehci_hcd_init(int index, enum usb_init_type init,
Igor Grinberg9c687fd2014-11-03 11:32:19 +0200487 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200488{
489 u8 val;
490 int offset;
491
Igor Grinberg9c687fd2014-11-03 11:32:19 +0200492 cl_usb_hub_init(SB_T35_USB_HUB_RESET_GPIO, "sb-t35 hub rst");
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200493
494 offset = TWL4030_BASEADD_GPIO + TWL4030_GPIO_GPIODATADIR1;
Nishanth Menon5d9d6f72013-03-26 05:20:50 +0000495 twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, offset, &val);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200496 /* Set GPIO6 and GPIO7 of TPS65930 as output */
497 val |= 0xC0;
Nishanth Menond26a1062013-03-26 05:20:49 +0000498 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, val);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200499 offset = TWL4030_BASEADD_GPIO + TWL4030_GPIO_SETGPIODATAOUT1;
500 /* Take both PHYs out of reset */
Nishanth Menond26a1062013-03-26 05:20:49 +0000501 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, 0xC0);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200502 udelay(1);
503
Mateusz Zalegad862f892013-10-04 19:22:26 +0200504 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200505}
506
507int ehci_hcd_stop(void)
508{
Igor Grinberg9c687fd2014-11-03 11:32:19 +0200509 cl_usb_hub_deinit(SB_T35_USB_HUB_RESET_GPIO);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200510 return omap_ehci_hcd_stop();
511}
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200512#endif /* CONFIG_USB_EHCI_OMAP */