blob: 8143c05353cc615a2802e33619b555ea314cfd34 [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>
Igor Grinbergd2367bc2011-04-18 17:54:33 -040016#include <status_led.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050017#include <netdev.h>
18#include <net.h>
19#include <i2c.h>
Nikita Kiryanov9f957be2012-12-02 13:59:19 +020020#include <usb.h>
Nikita Kiryanov4459e762012-12-03 02:19:45 +000021#include <mmc.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050022#include <twl4030.h>
Nikita Kiryanovb47cb9d2012-01-12 03:26:30 +000023#include <linux/compiler.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050024
25#include <asm/io.h>
Igor Grinbergfd6cd352014-11-03 11:32:21 +020026#include <asm/errno.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050027#include <asm/arch/mem.h>
28#include <asm/arch/mux.h>
29#include <asm/arch/mmc_host_def.h>
30#include <asm/arch/sys_proto.h>
31#include <asm/mach-types.h>
Nikita Kiryanov9f957be2012-12-02 13:59:19 +020032#include <asm/ehci-omap.h>
33#include <asm/gpio.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050034
Igor Grinberg3c5dc282014-11-03 11:32:18 +020035#include "../common/common.h"
Igor Grinberg3394be82013-09-16 21:49:58 +030036#include "../common/eeprom.h"
Nikita Kiryanovf1ef8692012-01-12 03:28:09 +000037
Igor Grinberg8bd1b192011-04-18 17:43:26 -040038DECLARE_GLOBAL_DATA_PTR;
39
Mike Rapoport8abe7302010-12-18 17:43:19 -050040const omap3_sysinfo sysinfo = {
41 DDR_DISCRETE,
Igor Grinberg05a96a42011-04-18 17:55:21 -040042 "CM-T3x board",
Mike Rapoport8abe7302010-12-18 17:43:19 -050043 "NAND",
44};
45
Stefan Roese8ef10bd2013-12-04 13:54:18 +010046#ifdef CONFIG_SPL_BUILD
47/*
48 * Routine: get_board_mem_timings
49 * Description: If we use SPL then there is no x-loader nor config header
50 * so we have to setup the DDR timings ourself on both banks.
51 */
52void get_board_mem_timings(struct board_sdrc_timings *timings)
53{
54 timings->mr = MICRON_V_MR_165;
55 timings->mcfg = MICRON_V_MCFG_200(256 << 20); /* raswidth 14 needed */
56 timings->ctrla = MICRON_V_ACTIMA_165;
57 timings->ctrlb = MICRON_V_ACTIMB_165;
58 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
59}
60#endif
61
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +020062struct splash_location splash_locations[] = {
63 {
64 .name = "nand",
65 .storage = SPLASH_STORAGE_NAND,
66 .offset = 0x100000,
67 },
68};
Igor Grinberg86ec16b2014-11-03 11:32:20 +020069
Robert Winkler2abfe362013-06-17 11:31:31 -070070int splash_screen_prepare(void)
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000071{
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +020072 return cl_splash_screen_prepare(splash_locations,
73 ARRAY_SIZE(splash_locations));
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000074}
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000075
Mike Rapoport8abe7302010-12-18 17:43:19 -050076/*
77 * Routine: board_init
Igor Grinberg7e741ff2012-06-13 19:41:40 +000078 * Description: hardware init.
Mike Rapoport8abe7302010-12-18 17:43:19 -050079 */
80int board_init(void)
81{
Mike Rapoport8abe7302010-12-18 17:43:19 -050082 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
83
Mike Rapoport8abe7302010-12-18 17:43:19 -050084 /* board id for Linux */
Igor Grinberg05a96a42011-04-18 17:55:21 -040085 if (get_cpu_family() == CPU_OMAP34XX)
86 gd->bd->bi_arch_number = MACH_TYPE_CM_T35;
87 else
88 gd->bd->bi_arch_number = MACH_TYPE_CM_T3730;
89
Mike Rapoport8abe7302010-12-18 17:43:19 -050090 /* boot param addr */
91 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
92
Igor Grinbergd2367bc2011-04-18 17:54:33 -040093#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
94 status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
95#endif
96
Mike Rapoport8abe7302010-12-18 17:43:19 -050097 return 0;
98}
99
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000100/*
101 * Routine: get_board_rev
102 * Description: read system revision
103 */
104u32 get_board_rev(void)
105{
Igor Grinberg3c5dc282014-11-03 11:32:18 +0200106 return cl_eeprom_get_board_rev();
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000107};
108
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000109int misc_init_r(void)
110{
Igor Grinberg3c5dc282014-11-03 11:32:18 +0200111 cl_print_pcb_info();
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000112 dieid_num_r();
113
114 return 0;
115}
116
Mike Rapoport8abe7302010-12-18 17:43:19 -0500117/*
Mike Rapoport8abe7302010-12-18 17:43:19 -0500118 * Routine: set_muxconf_regs
119 * Description: Setting up the configuration Mux registers specific to the
120 * hardware. Many pins need to be moved from protect to primary
121 * mode.
122 */
Igor Grinberg05a96a42011-04-18 17:55:21 -0400123static void cm_t3x_set_common_muxconf(void)
Mike Rapoport8abe7302010-12-18 17:43:19 -0500124{
125 /* SDRC */
126 MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0)); /*SDRC_D0*/
127 MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0)); /*SDRC_D1*/
128 MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0)); /*SDRC_D2*/
129 MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0)); /*SDRC_D3*/
130 MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0)); /*SDRC_D4*/
131 MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0)); /*SDRC_D5*/
132 MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0)); /*SDRC_D6*/
133 MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0)); /*SDRC_D7*/
134 MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0)); /*SDRC_D8*/
135 MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0)); /*SDRC_D9*/
136 MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0)); /*SDRC_D10*/
137 MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0)); /*SDRC_D11*/
138 MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0)); /*SDRC_D12*/
139 MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0)); /*SDRC_D13*/
140 MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0)); /*SDRC_D14*/
141 MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0)); /*SDRC_D15*/
142 MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0)); /*SDRC_D16*/
143 MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0)); /*SDRC_D17*/
144 MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0)); /*SDRC_D18*/
145 MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0)); /*SDRC_D19*/
146 MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0)); /*SDRC_D20*/
147 MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0)); /*SDRC_D21*/
148 MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0)); /*SDRC_D22*/
149 MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0)); /*SDRC_D23*/
150 MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0)); /*SDRC_D24*/
151 MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0)); /*SDRC_D25*/
152 MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0)); /*SDRC_D26*/
153 MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0)); /*SDRC_D27*/
154 MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0)); /*SDRC_D28*/
155 MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0)); /*SDRC_D29*/
156 MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0)); /*SDRC_D30*/
157 MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0)); /*SDRC_D31*/
158 MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0)); /*SDRC_CLK*/
159 MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0)); /*SDRC_DQS0*/
160 MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0)); /*SDRC_DQS1*/
161 MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0)); /*SDRC_DQS2*/
162 MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0)); /*SDRC_DQS3*/
163 MUX_VAL(CP(SDRC_CKE0), (IDIS | PTU | EN | M0)); /*SDRC_CKE0*/
164 MUX_VAL(CP(SDRC_CKE1), (IDIS | PTD | DIS | M7)); /*SDRC_CKE1*/
165
166 /* GPMC */
167 MUX_VAL(CP(GPMC_A1), (IDIS | PTU | EN | M0)); /*GPMC_A1*/
168 MUX_VAL(CP(GPMC_A2), (IDIS | PTU | EN | M0)); /*GPMC_A2*/
169 MUX_VAL(CP(GPMC_A3), (IDIS | PTU | EN | M0)); /*GPMC_A3*/
170 MUX_VAL(CP(GPMC_A4), (IDIS | PTU | EN | M0)); /*GPMC_A4*/
171 MUX_VAL(CP(GPMC_A5), (IDIS | PTU | EN | M0)); /*GPMC_A5*/
172 MUX_VAL(CP(GPMC_A6), (IDIS | PTU | EN | M0)); /*GPMC_A6*/
173 MUX_VAL(CP(GPMC_A7), (IDIS | PTU | EN | M0)); /*GPMC_A7*/
174 MUX_VAL(CP(GPMC_A8), (IDIS | PTU | EN | M0)); /*GPMC_A8*/
175 MUX_VAL(CP(GPMC_A9), (IDIS | PTU | EN | M0)); /*GPMC_A9*/
176 MUX_VAL(CP(GPMC_A10), (IDIS | PTU | EN | M0)); /*GPMC_A10*/
177 MUX_VAL(CP(GPMC_D0), (IEN | PTU | EN | M0)); /*GPMC_D0*/
178 MUX_VAL(CP(GPMC_D1), (IEN | PTU | EN | M0)); /*GPMC_D1*/
179 MUX_VAL(CP(GPMC_D2), (IEN | PTU | EN | M0)); /*GPMC_D2*/
180 MUX_VAL(CP(GPMC_D3), (IEN | PTU | EN | M0)); /*GPMC_D3*/
181 MUX_VAL(CP(GPMC_D4), (IEN | PTU | EN | M0)); /*GPMC_D4*/
182 MUX_VAL(CP(GPMC_D5), (IEN | PTU | EN | M0)); /*GPMC_D5*/
183 MUX_VAL(CP(GPMC_D6), (IEN | PTU | EN | M0)); /*GPMC_D6*/
184 MUX_VAL(CP(GPMC_D7), (IEN | PTU | EN | M0)); /*GPMC_D7*/
185 MUX_VAL(CP(GPMC_D8), (IEN | PTU | EN | M0)); /*GPMC_D8*/
186 MUX_VAL(CP(GPMC_D9), (IEN | PTU | EN | M0)); /*GPMC_D9*/
187 MUX_VAL(CP(GPMC_D10), (IEN | PTU | EN | M0)); /*GPMC_D10*/
188 MUX_VAL(CP(GPMC_D11), (IEN | PTU | EN | M0)); /*GPMC_D11*/
189 MUX_VAL(CP(GPMC_D12), (IEN | PTU | EN | M0)); /*GPMC_D12*/
190 MUX_VAL(CP(GPMC_D13), (IEN | PTU | EN | M0)); /*GPMC_D13*/
191 MUX_VAL(CP(GPMC_D14), (IEN | PTU | EN | M0)); /*GPMC_D14*/
192 MUX_VAL(CP(GPMC_D15), (IEN | PTU | EN | M0)); /*GPMC_D15*/
193 MUX_VAL(CP(GPMC_NCS0), (IDIS | PTU | EN | M0)); /*GPMC_nCS0*/
194
195 /* SB-T35 Ethernet */
196 MUX_VAL(CP(GPMC_NCS4), (IEN | PTU | EN | M0)); /*GPMC_nCS4*/
197
Nikita Kiryanov2247eb42013-01-30 21:39:58 +0000198 /* DVI enable */
199 MUX_VAL(CP(GPMC_NCS3), (IDIS | PTU | DIS | M4));/*GPMC_nCS3*/
200
Nikita Kiryanov25da1522013-10-16 17:23:29 +0300201 /* DataImage backlight */
202 MUX_VAL(CP(GPMC_NCS7), (IDIS | PTU | DIS | M4));/*GPIO_58*/
203
Igor Grinberg05a96a42011-04-18 17:55:21 -0400204 /* CM-T3x Ethernet */
Mike Rapoport8abe7302010-12-18 17:43:19 -0500205 MUX_VAL(CP(GPMC_NCS5), (IDIS | PTU | DIS | M0)); /*GPMC_nCS5*/
206 MUX_VAL(CP(GPMC_CLK), (IEN | PTD | DIS | M4)); /*GPIO_59*/
207 MUX_VAL(CP(GPMC_NADV_ALE), (IDIS | PTD | DIS | M0)); /*nADV_ALE*/
208 MUX_VAL(CP(GPMC_NOE), (IDIS | PTD | DIS | M0)); /*nOE*/
209 MUX_VAL(CP(GPMC_NWE), (IDIS | PTD | DIS | M0)); /*nWE*/
210 MUX_VAL(CP(GPMC_NBE0_CLE), (IDIS | PTU | EN | M0)); /*nBE0_CLE*/
211 MUX_VAL(CP(GPMC_NBE1), (IDIS | PTD | DIS | M4)); /*GPIO_61*/
212 MUX_VAL(CP(GPMC_NWP), (IEN | PTD | DIS | M0)); /*nWP*/
213 MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0)); /*WAIT0*/
214
215 /* DSS */
216 MUX_VAL(CP(DSS_PCLK), (IDIS | PTD | DIS | M0)); /*DSS_PCLK*/
217 MUX_VAL(CP(DSS_HSYNC), (IDIS | PTD | DIS | M0)); /*DSS_HSYNC*/
218 MUX_VAL(CP(DSS_VSYNC), (IDIS | PTD | DIS | M0)); /*DSS_VSYNC*/
219 MUX_VAL(CP(DSS_ACBIAS), (IDIS | PTD | DIS | M0)); /*DSS_ACBIAS*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500220 MUX_VAL(CP(DSS_DATA6), (IDIS | PTD | DIS | M0)); /*DSS_DATA6*/
221 MUX_VAL(CP(DSS_DATA7), (IDIS | PTD | DIS | M0)); /*DSS_DATA7*/
222 MUX_VAL(CP(DSS_DATA8), (IDIS | PTD | DIS | M0)); /*DSS_DATA8*/
223 MUX_VAL(CP(DSS_DATA9), (IDIS | PTD | DIS | M0)); /*DSS_DATA9*/
224 MUX_VAL(CP(DSS_DATA10), (IDIS | PTD | DIS | M0)); /*DSS_DATA10*/
225 MUX_VAL(CP(DSS_DATA11), (IDIS | PTD | DIS | M0)); /*DSS_DATA11*/
226 MUX_VAL(CP(DSS_DATA12), (IDIS | PTD | DIS | M0)); /*DSS_DATA12*/
227 MUX_VAL(CP(DSS_DATA13), (IDIS | PTD | DIS | M0)); /*DSS_DATA13*/
228 MUX_VAL(CP(DSS_DATA14), (IDIS | PTD | DIS | M0)); /*DSS_DATA14*/
229 MUX_VAL(CP(DSS_DATA15), (IDIS | PTD | DIS | M0)); /*DSS_DATA15*/
230 MUX_VAL(CP(DSS_DATA16), (IDIS | PTD | DIS | M0)); /*DSS_DATA16*/
231 MUX_VAL(CP(DSS_DATA17), (IDIS | PTD | DIS | M0)); /*DSS_DATA17*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500232
233 /* serial interface */
234 MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M0)); /*UART3_RX*/
235 MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M0)); /*UART3_TX*/
236
237 /* mUSB */
238 MUX_VAL(CP(HSUSB0_CLK), (IEN | PTD | DIS | M0)); /*HSUSB0_CLK*/
239 MUX_VAL(CP(HSUSB0_STP), (IDIS | PTU | EN | M0)); /*HSUSB0_STP*/
240 MUX_VAL(CP(HSUSB0_DIR), (IEN | PTD | DIS | M0)); /*HSUSB0_DIR*/
241 MUX_VAL(CP(HSUSB0_NXT), (IEN | PTD | DIS | M0)); /*HSUSB0_NXT*/
242 MUX_VAL(CP(HSUSB0_DATA0), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA0*/
243 MUX_VAL(CP(HSUSB0_DATA1), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA1*/
244 MUX_VAL(CP(HSUSB0_DATA2), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA2*/
245 MUX_VAL(CP(HSUSB0_DATA3), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA3*/
246 MUX_VAL(CP(HSUSB0_DATA4), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA4*/
247 MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA5*/
248 MUX_VAL(CP(HSUSB0_DATA6), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA6*/
249 MUX_VAL(CP(HSUSB0_DATA7), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA7*/
250
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200251 /* USB EHCI */
252 MUX_VAL(CP(ETK_D0_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT0*/
253 MUX_VAL(CP(ETK_D1_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT1*/
254 MUX_VAL(CP(ETK_D2_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT2*/
255 MUX_VAL(CP(ETK_D7_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT3*/
256 MUX_VAL(CP(ETK_D4_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT4*/
257 MUX_VAL(CP(ETK_D5_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT5*/
258 MUX_VAL(CP(ETK_D6_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT6*/
259 MUX_VAL(CP(ETK_D3_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT7*/
260 MUX_VAL(CP(ETK_D8_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DIR*/
261 MUX_VAL(CP(ETK_D9_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_NXT*/
262 MUX_VAL(CP(ETK_CTL_ES2), (IDIS | PTD | DIS | M3)); /*HSUSB1_CLK*/
263 MUX_VAL(CP(ETK_CLK_ES2), (IDIS | PTU | DIS | M3)); /*HSUSB1_STP*/
264
265 MUX_VAL(CP(ETK_D14_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_DT0*/
266 MUX_VAL(CP(ETK_D15_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_DT1*/
267 MUX_VAL(CP(MCSPI1_CS3), (IEN | PTD | EN | M3)); /*HSUSB2_DT2*/
268 MUX_VAL(CP(MCSPI2_CS1), (IEN | PTD | EN | M3)); /*HSUSB2_DT3*/
269 MUX_VAL(CP(MCSPI2_SIMO), (IEN | PTD | EN | M3)); /*HSUSB2_DT4*/
270 MUX_VAL(CP(MCSPI2_SOMI), (IEN | PTD | EN | M3)); /*HSUSB2_DT5*/
271 MUX_VAL(CP(MCSPI2_CS0), (IEN | PTD | EN | M3)); /*HSUSB2_DT6*/
272 MUX_VAL(CP(MCSPI2_CLK), (IEN | PTD | EN | M3)); /*HSUSB2_DT7*/
273 MUX_VAL(CP(ETK_D12_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_DIR*/
274 MUX_VAL(CP(ETK_D13_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_NXT*/
275 MUX_VAL(CP(ETK_D10_ES2), (IDIS | PTD | DIS | M3)); /*HSUSB2_CLK*/
276 MUX_VAL(CP(ETK_D11_ES2), (IDIS | PTU | DIS | M3)); /*HSUSB2_STP*/
277
278 /* SB_T35_USB_HUB_RESET_GPIO */
279 MUX_VAL(CP(CAM_WEN), (IDIS | PTD | DIS | M4)); /*GPIO_167*/
280
Mike Rapoport8abe7302010-12-18 17:43:19 -0500281 /* I2C1 */
282 MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0)); /*I2C1_SCL*/
283 MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0)); /*I2C1_SDA*/
Nikita Kiryanovda4da302012-04-02 02:29:31 +0000284 /* I2C2 */
285 MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M0)); /*I2C2_SCL*/
286 MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M0)); /*I2C2_SDA*/
287 /* I2C3 */
288 MUX_VAL(CP(I2C3_SCL), (IEN | PTU | EN | M0)); /*I2C3_SCL*/
289 MUX_VAL(CP(I2C3_SDA), (IEN | PTU | EN | M0)); /*I2C3_SDA*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500290
291 /* control and debug */
292 MUX_VAL(CP(SYS_32K), (IEN | PTD | DIS | M0)); /*SYS_32K*/
293 MUX_VAL(CP(SYS_CLKREQ), (IEN | PTD | DIS | M0)); /*SYS_CLKREQ*/
294 MUX_VAL(CP(SYS_NIRQ), (IEN | PTU | EN | M0)); /*SYS_nIRQ*/
295 MUX_VAL(CP(SYS_OFF_MODE), (IEN | PTD | DIS | M0)); /*OFF_MODE*/
296 MUX_VAL(CP(SYS_CLKOUT1), (IEN | PTD | DIS | M0)); /*CLKOUT1*/
Igor Grinbergd2367bc2011-04-18 17:54:33 -0400297 MUX_VAL(CP(SYS_CLKOUT2), (IDIS | PTU | DIS | M4)); /*green LED*/
Igor Grinberg165808d2014-10-21 18:25:30 +0300298 MUX_VAL(CP(JTAG_NTRST), (IEN | PTD | DIS | M0)); /*JTAG_NTRST*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500299 MUX_VAL(CP(JTAG_TCK), (IEN | PTD | DIS | M0)); /*JTAG_TCK*/
300 MUX_VAL(CP(JTAG_TMS), (IEN | PTD | DIS | M0)); /*JTAG_TMS*/
301 MUX_VAL(CP(JTAG_TDI), (IEN | PTD | DIS | M0)); /*JTAG_TDI*/
Igor Grinberga704ce02011-04-18 17:50:07 -0400302
303 /* MMC1 */
304 MUX_VAL(CP(MMC1_CLK), (IDIS | PTU | EN | M0)); /*MMC1_CLK*/
305 MUX_VAL(CP(MMC1_CMD), (IEN | PTU | EN | M0)); /*MMC1_CMD*/
306 MUX_VAL(CP(MMC1_DAT0), (IEN | PTU | EN | M0)); /*MMC1_DAT0*/
307 MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0)); /*MMC1_DAT1*/
308 MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0)); /*MMC1_DAT2*/
309 MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0)); /*MMC1_DAT3*/
Nikita Kiryanov25da1522013-10-16 17:23:29 +0300310
311 /* SPI */
312 MUX_VAL(CP(MCBSP1_CLKR), (IEN | PTD | DIS | M1)); /*MCSPI4_CLK*/
313 MUX_VAL(CP(MCBSP1_DX), (IEN | PTD | DIS | M1)); /*MCSPI4_SIMO*/
314 MUX_VAL(CP(MCBSP1_DR), (IEN | PTD | DIS | M1)); /*MCSPI4_SOMI*/
315 MUX_VAL(CP(MCBSP1_FSX), (IEN | PTU | EN | M1)); /*MCSPI4_CS0*/
316
317 /* display controls */
318 MUX_VAL(CP(MCBSP1_FSR), (IDIS | PTU | DIS | M4)); /*GPIO_157*/
Igor Grinberg05a96a42011-04-18 17:55:21 -0400319}
320
321static void cm_t35_set_muxconf(void)
322{
323 /* DSS */
324 MUX_VAL(CP(DSS_DATA0), (IDIS | PTD | DIS | M0)); /*DSS_DATA0*/
325 MUX_VAL(CP(DSS_DATA1), (IDIS | PTD | DIS | M0)); /*DSS_DATA1*/
326 MUX_VAL(CP(DSS_DATA2), (IDIS | PTD | DIS | M0)); /*DSS_DATA2*/
327 MUX_VAL(CP(DSS_DATA3), (IDIS | PTD | DIS | M0)); /*DSS_DATA3*/
328 MUX_VAL(CP(DSS_DATA4), (IDIS | PTD | DIS | M0)); /*DSS_DATA4*/
329 MUX_VAL(CP(DSS_DATA5), (IDIS | PTD | DIS | M0)); /*DSS_DATA5*/
330
331 MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M0)); /*DSS_DATA18*/
332 MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M0)); /*DSS_DATA19*/
333 MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M0)); /*DSS_DATA20*/
334 MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M0)); /*DSS_DATA21*/
335 MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M0)); /*DSS_DATA22*/
336 MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M0)); /*DSS_DATA23*/
337
338 /* MMC1 */
Igor Grinberga704ce02011-04-18 17:50:07 -0400339 MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M0)); /*MMC1_DAT4*/
340 MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M0)); /*MMC1_DAT5*/
341 MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M0)); /*MMC1_DAT6*/
342 MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M0)); /*MMC1_DAT7*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500343}
344
Igor Grinberg05a96a42011-04-18 17:55:21 -0400345static void cm_t3730_set_muxconf(void)
346{
347 /* DSS */
348 MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M3)); /*DSS_DATA0*/
349 MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M3)); /*DSS_DATA1*/
350 MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M3)); /*DSS_DATA2*/
351 MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M3)); /*DSS_DATA3*/
352 MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M3)); /*DSS_DATA4*/
353 MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M3)); /*DSS_DATA5*/
354
355 MUX_VAL(CP(SYS_BOOT0), (IDIS | PTD | DIS | M3)); /*DSS_DATA18*/
356 MUX_VAL(CP(SYS_BOOT1), (IDIS | PTD | DIS | M3)); /*DSS_DATA19*/
357 MUX_VAL(CP(SYS_BOOT3), (IDIS | PTD | DIS | M3)); /*DSS_DATA20*/
358 MUX_VAL(CP(SYS_BOOT4), (IDIS | PTD | DIS | M3)); /*DSS_DATA21*/
359 MUX_VAL(CP(SYS_BOOT5), (IDIS | PTD | DIS | M3)); /*DSS_DATA22*/
360 MUX_VAL(CP(SYS_BOOT6), (IDIS | PTD | DIS | M3)); /*DSS_DATA23*/
361}
362
363void set_muxconf_regs(void)
364{
365 cm_t3x_set_common_muxconf();
366
367 if (get_cpu_family() == CPU_OMAP34XX)
368 cm_t35_set_muxconf();
369 else
370 cm_t3730_set_muxconf();
371}
372
Stefan Roese8ef10bd2013-12-04 13:54:18 +0100373#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
Igor Grinbergde25e2d2014-10-21 16:39:46 +0300374#define SB_T35_WP_GPIO 59
375
Nikita Kiryanov4459e762012-12-03 02:19:45 +0000376int board_mmc_getcd(struct mmc *mmc)
377{
378 u8 val;
379
Nishanth Menon5d9d6f72013-03-26 05:20:50 +0000380 if (twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO, &val))
Nikita Kiryanov4459e762012-12-03 02:19:45 +0000381 return -1;
382
383 return !(val & 1);
384}
385
Tom Rinid0974a82011-09-03 21:49:24 -0400386int board_mmc_init(bd_t *bis)
387{
Igor Grinbergde25e2d2014-10-21 16:39:46 +0300388 return omap_mmc_init(0, 0, 0, -1, SB_T35_WP_GPIO);
Tom Rinid0974a82011-09-03 21:49:24 -0400389}
390#endif
391
Paul Kocialkowski69559892014-11-08 20:55:47 +0100392#if defined(CONFIG_GENERIC_MMC)
393void board_mmc_power_init(void)
394{
395 twl4030_power_mmc_init(0);
396}
397#endif
398
Heiko Schocherf53f2b82013-10-22 11:03:18 +0200399#ifdef CONFIG_SYS_I2C_OMAP34XX
Mike Rapoport8abe7302010-12-18 17:43:19 -0500400/*
401 * Routine: reset_net_chip
402 * Description: reset the Ethernet controller via TPS65930 GPIO
403 */
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200404static int cm_t3x_reset_net_chip(int gpio)
Mike Rapoport8abe7302010-12-18 17:43:19 -0500405{
406 /* Set GPIO1 of TPS65930 as output */
Nishanth Menond26a1062013-03-26 05:20:49 +0000407 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x03,
408 0x02);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500409 /* Send a pulse on the GPIO pin */
Nishanth Menond26a1062013-03-26 05:20:49 +0000410 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x0C,
411 0x02);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500412 udelay(1);
Nishanth Menond26a1062013-03-26 05:20:49 +0000413 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x09,
414 0x02);
Igor Grinberge4d26a22012-04-02 20:12:58 +0000415 mdelay(40);
Nishanth Menond26a1062013-03-26 05:20:49 +0000416 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x0C,
417 0x02);
Igor Grinberge4d26a22012-04-02 20:12:58 +0000418 mdelay(1);
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200419 return 0;
Mike Rapoport8abe7302010-12-18 17:43:19 -0500420}
421#else
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200422static inline int cm_t3x_reset_net_chip(int gpio) { return 0; }
Mike Rapoport8abe7302010-12-18 17:43:19 -0500423#endif
424
Nikita Kiryanovb7792f02012-01-02 04:01:31 +0000425#ifdef CONFIG_SMC911X
Mike Rapoport8abe7302010-12-18 17:43:19 -0500426/*
427 * Routine: handle_mac_address
428 * Description: prepare MAC address for on-board Ethernet.
429 */
430static int handle_mac_address(void)
431{
432 unsigned char enetaddr[6];
433 int rc;
434
435 rc = eth_getenv_enetaddr("ethaddr", enetaddr);
436 if (rc)
437 return 0;
438
Nikita Kiryanovb2c55472015-01-14 10:42:43 +0200439 rc = cl_eeprom_read_mac_addr(enetaddr, CONFIG_SYS_I2C_EEPROM_BUS);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500440 if (rc)
441 return rc;
Mike Rapoport8abe7302010-12-18 17:43:19 -0500442
443 if (!is_valid_ether_addr(enetaddr))
444 return -1;
445
446 return eth_setenv_enetaddr("ethaddr", enetaddr);
447}
448
Mike Rapoport8abe7302010-12-18 17:43:19 -0500449/*
450 * Routine: board_eth_init
451 * Description: initialize module and base-board Ethernet chips
452 */
453int board_eth_init(bd_t *bis)
454{
455 int rc = 0, rc1 = 0;
456
Mike Rapoport8abe7302010-12-18 17:43:19 -0500457 rc1 = handle_mac_address();
458 if (rc1)
Igor Grinberg7e741ff2012-06-13 19:41:40 +0000459 printf("No MAC address found! ");
Mike Rapoport8abe7302010-12-18 17:43:19 -0500460
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200461 rc1 = cl_omap3_smc911x_init(0, 5, CM_T3X_SMC911X_BASE,
462 cm_t3x_reset_net_chip, -EINVAL);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500463 if (rc1 > 0)
464 rc++;
465
Igor Grinbergfd6cd352014-11-03 11:32:21 +0200466 rc1 = cl_omap3_smc911x_init(1, 4, SB_T35_SMC911X_BASE, NULL, -EINVAL);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500467 if (rc1 > 0)
468 rc++;
Mike Rapoport8abe7302010-12-18 17:43:19 -0500469
470 return rc;
471}
Nikita Kiryanovb7792f02012-01-02 04:01:31 +0000472#endif
Nikita Kiryanovb47cb9d2012-01-12 03:26:30 +0000473
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200474#ifdef CONFIG_USB_EHCI_OMAP
475struct omap_usbhs_board_data usbhs_bdata = {
476 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
477 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
478 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
479};
480
481#define SB_T35_USB_HUB_RESET_GPIO 167
Troy Kisky7d6bbb92013-10-10 15:27:57 -0700482int ehci_hcd_init(int index, enum usb_init_type init,
Igor Grinberg9c687fd2014-11-03 11:32:19 +0200483 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200484{
485 u8 val;
486 int offset;
487
Igor Grinberg9c687fd2014-11-03 11:32:19 +0200488 cl_usb_hub_init(SB_T35_USB_HUB_RESET_GPIO, "sb-t35 hub rst");
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200489
490 offset = TWL4030_BASEADD_GPIO + TWL4030_GPIO_GPIODATADIR1;
Nishanth Menon5d9d6f72013-03-26 05:20:50 +0000491 twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, offset, &val);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200492 /* Set GPIO6 and GPIO7 of TPS65930 as output */
493 val |= 0xC0;
Nishanth Menond26a1062013-03-26 05:20:49 +0000494 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, val);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200495 offset = TWL4030_BASEADD_GPIO + TWL4030_GPIO_SETGPIODATAOUT1;
496 /* Take both PHYs out of reset */
Nishanth Menond26a1062013-03-26 05:20:49 +0000497 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, 0xC0);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200498 udelay(1);
499
Mateusz Zalegad862f892013-10-04 19:22:26 +0200500 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200501}
502
503int ehci_hcd_stop(void)
504{
Igor Grinberg9c687fd2014-11-03 11:32:19 +0200505 cl_usb_hub_deinit(SB_T35_USB_HUB_RESET_GPIO);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200506 return omap_ehci_hcd_stop();
507}
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200508#endif /* CONFIG_USB_EHCI_OMAP */