blob: 5453942202d5a3cb8b2d925a57a9cee26e4a9cf3 [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>
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000022#include <nand.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050023#include <twl4030.h>
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000024#include <bmp_layout.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>
28#include <asm/arch/mem.h>
29#include <asm/arch/mux.h>
30#include <asm/arch/mmc_host_def.h>
31#include <asm/arch/sys_proto.h>
32#include <asm/mach-types.h>
Nikita Kiryanov9f957be2012-12-02 13:59:19 +020033#include <asm/ehci-omap.h>
34#include <asm/gpio.h>
Mike Rapoport8abe7302010-12-18 17:43:19 -050035
Igor Grinberg3c5dc282014-11-03 11:32:18 +020036#include "../common/common.h"
Igor Grinberg3394be82013-09-16 21:49:58 +030037#include "../common/eeprom.h"
Nikita Kiryanovf1ef8692012-01-12 03:28:09 +000038
Igor Grinberg8bd1b192011-04-18 17:43:26 -040039DECLARE_GLOBAL_DATA_PTR;
40
Mike Rapoport8abe7302010-12-18 17:43:19 -050041const omap3_sysinfo sysinfo = {
42 DDR_DISCRETE,
Igor Grinberg05a96a42011-04-18 17:55:21 -040043 "CM-T3x board",
Mike Rapoport8abe7302010-12-18 17:43:19 -050044 "NAND",
45};
46
47static u32 gpmc_net_config[GPMC_MAX_REG] = {
48 NET_GPMC_CONFIG1,
49 NET_GPMC_CONFIG2,
50 NET_GPMC_CONFIG3,
51 NET_GPMC_CONFIG4,
52 NET_GPMC_CONFIG5,
53 NET_GPMC_CONFIG6,
54 0
55};
56
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000057#ifdef CONFIG_LCD
58#ifdef CONFIG_CMD_NAND
59static int splash_load_from_nand(u32 bmp_load_addr)
60{
61 struct bmp_header *bmp_hdr;
62 int res, splash_screen_nand_offset = 0x100000;
63 size_t bmp_size, bmp_header_size = sizeof(struct bmp_header);
64
65 if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp)
66 goto splash_address_too_high;
67
68 res = nand_read_skip_bad(&nand_info[nand_curr_device],
69 splash_screen_nand_offset, &bmp_header_size,
Tom Rini32d96182013-03-14 05:32:50 +000070 NULL, nand_info[nand_curr_device].size,
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000071 (u_char *)bmp_load_addr);
72 if (res < 0)
73 return res;
74
75 bmp_hdr = (struct bmp_header *)bmp_load_addr;
76 bmp_size = le32_to_cpu(bmp_hdr->file_size);
77
78 if (bmp_load_addr + bmp_size >= gd->start_addr_sp)
79 goto splash_address_too_high;
80
81 return nand_read_skip_bad(&nand_info[nand_curr_device],
82 splash_screen_nand_offset, &bmp_size,
Tom Rini32d96182013-03-14 05:32:50 +000083 NULL, nand_info[nand_curr_device].size,
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +000084 (u_char *)bmp_load_addr);
85
86splash_address_too_high:
87 printf("Error: splashimage address too high. Data overwrites U-Boot "
88 "and/or placed beyond DRAM boundaries.\n");
89
90 return -1;
91}
92#else
93static inline int splash_load_from_nand(void)
94{
95 return -1;
96}
97#endif /* CONFIG_CMD_NAND */
98
Stefan Roese8ef10bd2013-12-04 13:54:18 +010099#ifdef CONFIG_SPL_BUILD
100/*
101 * Routine: get_board_mem_timings
102 * Description: If we use SPL then there is no x-loader nor config header
103 * so we have to setup the DDR timings ourself on both banks.
104 */
105void get_board_mem_timings(struct board_sdrc_timings *timings)
106{
107 timings->mr = MICRON_V_MR_165;
108 timings->mcfg = MICRON_V_MCFG_200(256 << 20); /* raswidth 14 needed */
109 timings->ctrla = MICRON_V_ACTIMA_165;
110 timings->ctrlb = MICRON_V_ACTIMB_165;
111 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
112}
113#endif
114
Robert Winkler2abfe362013-06-17 11:31:31 -0700115int splash_screen_prepare(void)
Nikita Kiryanovc4a295a2012-12-22 21:03:48 +0000116{
117 char *env_splashimage_value;
118 u32 bmp_load_addr;
119
120 env_splashimage_value = getenv("splashimage");
121 if (env_splashimage_value == NULL)
122 return -1;
123
124 bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16);
125 if (bmp_load_addr == 0) {
126 printf("Error: bad splashimage address specified\n");
127 return -1;
128 }
129
130 return splash_load_from_nand(bmp_load_addr);
131}
132#endif /* CONFIG_LCD */
133
Mike Rapoport8abe7302010-12-18 17:43:19 -0500134/*
135 * Routine: board_init
Igor Grinberg7e741ff2012-06-13 19:41:40 +0000136 * Description: hardware init.
Mike Rapoport8abe7302010-12-18 17:43:19 -0500137 */
138int board_init(void)
139{
Mike Rapoport8abe7302010-12-18 17:43:19 -0500140 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
141
Mike Rapoport8abe7302010-12-18 17:43:19 -0500142 /* board id for Linux */
Igor Grinberg05a96a42011-04-18 17:55:21 -0400143 if (get_cpu_family() == CPU_OMAP34XX)
144 gd->bd->bi_arch_number = MACH_TYPE_CM_T35;
145 else
146 gd->bd->bi_arch_number = MACH_TYPE_CM_T3730;
147
Mike Rapoport8abe7302010-12-18 17:43:19 -0500148 /* boot param addr */
149 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
150
Igor Grinbergd2367bc2011-04-18 17:54:33 -0400151#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
152 status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
153#endif
154
Mike Rapoport8abe7302010-12-18 17:43:19 -0500155 return 0;
156}
157
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000158/*
159 * Routine: get_board_rev
160 * Description: read system revision
161 */
162u32 get_board_rev(void)
163{
Igor Grinberg3c5dc282014-11-03 11:32:18 +0200164 return cl_eeprom_get_board_rev();
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000165};
166
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000167int misc_init_r(void)
168{
Igor Grinberg3c5dc282014-11-03 11:32:18 +0200169 cl_print_pcb_info();
Nikita Kiryanovcc935c62012-05-24 04:01:24 +0000170 dieid_num_r();
171
172 return 0;
173}
174
Mike Rapoport8abe7302010-12-18 17:43:19 -0500175/*
Mike Rapoport8abe7302010-12-18 17:43:19 -0500176 * Routine: set_muxconf_regs
177 * Description: Setting up the configuration Mux registers specific to the
178 * hardware. Many pins need to be moved from protect to primary
179 * mode.
180 */
Igor Grinberg05a96a42011-04-18 17:55:21 -0400181static void cm_t3x_set_common_muxconf(void)
Mike Rapoport8abe7302010-12-18 17:43:19 -0500182{
183 /* SDRC */
184 MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0)); /*SDRC_D0*/
185 MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0)); /*SDRC_D1*/
186 MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0)); /*SDRC_D2*/
187 MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0)); /*SDRC_D3*/
188 MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0)); /*SDRC_D4*/
189 MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0)); /*SDRC_D5*/
190 MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0)); /*SDRC_D6*/
191 MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0)); /*SDRC_D7*/
192 MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0)); /*SDRC_D8*/
193 MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0)); /*SDRC_D9*/
194 MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0)); /*SDRC_D10*/
195 MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0)); /*SDRC_D11*/
196 MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0)); /*SDRC_D12*/
197 MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0)); /*SDRC_D13*/
198 MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0)); /*SDRC_D14*/
199 MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0)); /*SDRC_D15*/
200 MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0)); /*SDRC_D16*/
201 MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0)); /*SDRC_D17*/
202 MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0)); /*SDRC_D18*/
203 MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0)); /*SDRC_D19*/
204 MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0)); /*SDRC_D20*/
205 MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0)); /*SDRC_D21*/
206 MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0)); /*SDRC_D22*/
207 MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0)); /*SDRC_D23*/
208 MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0)); /*SDRC_D24*/
209 MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0)); /*SDRC_D25*/
210 MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0)); /*SDRC_D26*/
211 MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0)); /*SDRC_D27*/
212 MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0)); /*SDRC_D28*/
213 MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0)); /*SDRC_D29*/
214 MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0)); /*SDRC_D30*/
215 MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0)); /*SDRC_D31*/
216 MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0)); /*SDRC_CLK*/
217 MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0)); /*SDRC_DQS0*/
218 MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0)); /*SDRC_DQS1*/
219 MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0)); /*SDRC_DQS2*/
220 MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0)); /*SDRC_DQS3*/
221 MUX_VAL(CP(SDRC_CKE0), (IDIS | PTU | EN | M0)); /*SDRC_CKE0*/
222 MUX_VAL(CP(SDRC_CKE1), (IDIS | PTD | DIS | M7)); /*SDRC_CKE1*/
223
224 /* GPMC */
225 MUX_VAL(CP(GPMC_A1), (IDIS | PTU | EN | M0)); /*GPMC_A1*/
226 MUX_VAL(CP(GPMC_A2), (IDIS | PTU | EN | M0)); /*GPMC_A2*/
227 MUX_VAL(CP(GPMC_A3), (IDIS | PTU | EN | M0)); /*GPMC_A3*/
228 MUX_VAL(CP(GPMC_A4), (IDIS | PTU | EN | M0)); /*GPMC_A4*/
229 MUX_VAL(CP(GPMC_A5), (IDIS | PTU | EN | M0)); /*GPMC_A5*/
230 MUX_VAL(CP(GPMC_A6), (IDIS | PTU | EN | M0)); /*GPMC_A6*/
231 MUX_VAL(CP(GPMC_A7), (IDIS | PTU | EN | M0)); /*GPMC_A7*/
232 MUX_VAL(CP(GPMC_A8), (IDIS | PTU | EN | M0)); /*GPMC_A8*/
233 MUX_VAL(CP(GPMC_A9), (IDIS | PTU | EN | M0)); /*GPMC_A9*/
234 MUX_VAL(CP(GPMC_A10), (IDIS | PTU | EN | M0)); /*GPMC_A10*/
235 MUX_VAL(CP(GPMC_D0), (IEN | PTU | EN | M0)); /*GPMC_D0*/
236 MUX_VAL(CP(GPMC_D1), (IEN | PTU | EN | M0)); /*GPMC_D1*/
237 MUX_VAL(CP(GPMC_D2), (IEN | PTU | EN | M0)); /*GPMC_D2*/
238 MUX_VAL(CP(GPMC_D3), (IEN | PTU | EN | M0)); /*GPMC_D3*/
239 MUX_VAL(CP(GPMC_D4), (IEN | PTU | EN | M0)); /*GPMC_D4*/
240 MUX_VAL(CP(GPMC_D5), (IEN | PTU | EN | M0)); /*GPMC_D5*/
241 MUX_VAL(CP(GPMC_D6), (IEN | PTU | EN | M0)); /*GPMC_D6*/
242 MUX_VAL(CP(GPMC_D7), (IEN | PTU | EN | M0)); /*GPMC_D7*/
243 MUX_VAL(CP(GPMC_D8), (IEN | PTU | EN | M0)); /*GPMC_D8*/
244 MUX_VAL(CP(GPMC_D9), (IEN | PTU | EN | M0)); /*GPMC_D9*/
245 MUX_VAL(CP(GPMC_D10), (IEN | PTU | EN | M0)); /*GPMC_D10*/
246 MUX_VAL(CP(GPMC_D11), (IEN | PTU | EN | M0)); /*GPMC_D11*/
247 MUX_VAL(CP(GPMC_D12), (IEN | PTU | EN | M0)); /*GPMC_D12*/
248 MUX_VAL(CP(GPMC_D13), (IEN | PTU | EN | M0)); /*GPMC_D13*/
249 MUX_VAL(CP(GPMC_D14), (IEN | PTU | EN | M0)); /*GPMC_D14*/
250 MUX_VAL(CP(GPMC_D15), (IEN | PTU | EN | M0)); /*GPMC_D15*/
251 MUX_VAL(CP(GPMC_NCS0), (IDIS | PTU | EN | M0)); /*GPMC_nCS0*/
252
253 /* SB-T35 Ethernet */
254 MUX_VAL(CP(GPMC_NCS4), (IEN | PTU | EN | M0)); /*GPMC_nCS4*/
255
Nikita Kiryanov2247eb42013-01-30 21:39:58 +0000256 /* DVI enable */
257 MUX_VAL(CP(GPMC_NCS3), (IDIS | PTU | DIS | M4));/*GPMC_nCS3*/
258
Nikita Kiryanov25da1522013-10-16 17:23:29 +0300259 /* DataImage backlight */
260 MUX_VAL(CP(GPMC_NCS7), (IDIS | PTU | DIS | M4));/*GPIO_58*/
261
Igor Grinberg05a96a42011-04-18 17:55:21 -0400262 /* CM-T3x Ethernet */
Mike Rapoport8abe7302010-12-18 17:43:19 -0500263 MUX_VAL(CP(GPMC_NCS5), (IDIS | PTU | DIS | M0)); /*GPMC_nCS5*/
264 MUX_VAL(CP(GPMC_CLK), (IEN | PTD | DIS | M4)); /*GPIO_59*/
265 MUX_VAL(CP(GPMC_NADV_ALE), (IDIS | PTD | DIS | M0)); /*nADV_ALE*/
266 MUX_VAL(CP(GPMC_NOE), (IDIS | PTD | DIS | M0)); /*nOE*/
267 MUX_VAL(CP(GPMC_NWE), (IDIS | PTD | DIS | M0)); /*nWE*/
268 MUX_VAL(CP(GPMC_NBE0_CLE), (IDIS | PTU | EN | M0)); /*nBE0_CLE*/
269 MUX_VAL(CP(GPMC_NBE1), (IDIS | PTD | DIS | M4)); /*GPIO_61*/
270 MUX_VAL(CP(GPMC_NWP), (IEN | PTD | DIS | M0)); /*nWP*/
271 MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0)); /*WAIT0*/
272
273 /* DSS */
274 MUX_VAL(CP(DSS_PCLK), (IDIS | PTD | DIS | M0)); /*DSS_PCLK*/
275 MUX_VAL(CP(DSS_HSYNC), (IDIS | PTD | DIS | M0)); /*DSS_HSYNC*/
276 MUX_VAL(CP(DSS_VSYNC), (IDIS | PTD | DIS | M0)); /*DSS_VSYNC*/
277 MUX_VAL(CP(DSS_ACBIAS), (IDIS | PTD | DIS | M0)); /*DSS_ACBIAS*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500278 MUX_VAL(CP(DSS_DATA6), (IDIS | PTD | DIS | M0)); /*DSS_DATA6*/
279 MUX_VAL(CP(DSS_DATA7), (IDIS | PTD | DIS | M0)); /*DSS_DATA7*/
280 MUX_VAL(CP(DSS_DATA8), (IDIS | PTD | DIS | M0)); /*DSS_DATA8*/
281 MUX_VAL(CP(DSS_DATA9), (IDIS | PTD | DIS | M0)); /*DSS_DATA9*/
282 MUX_VAL(CP(DSS_DATA10), (IDIS | PTD | DIS | M0)); /*DSS_DATA10*/
283 MUX_VAL(CP(DSS_DATA11), (IDIS | PTD | DIS | M0)); /*DSS_DATA11*/
284 MUX_VAL(CP(DSS_DATA12), (IDIS | PTD | DIS | M0)); /*DSS_DATA12*/
285 MUX_VAL(CP(DSS_DATA13), (IDIS | PTD | DIS | M0)); /*DSS_DATA13*/
286 MUX_VAL(CP(DSS_DATA14), (IDIS | PTD | DIS | M0)); /*DSS_DATA14*/
287 MUX_VAL(CP(DSS_DATA15), (IDIS | PTD | DIS | M0)); /*DSS_DATA15*/
288 MUX_VAL(CP(DSS_DATA16), (IDIS | PTD | DIS | M0)); /*DSS_DATA16*/
289 MUX_VAL(CP(DSS_DATA17), (IDIS | PTD | DIS | M0)); /*DSS_DATA17*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500290
291 /* serial interface */
292 MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M0)); /*UART3_RX*/
293 MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M0)); /*UART3_TX*/
294
295 /* mUSB */
296 MUX_VAL(CP(HSUSB0_CLK), (IEN | PTD | DIS | M0)); /*HSUSB0_CLK*/
297 MUX_VAL(CP(HSUSB0_STP), (IDIS | PTU | EN | M0)); /*HSUSB0_STP*/
298 MUX_VAL(CP(HSUSB0_DIR), (IEN | PTD | DIS | M0)); /*HSUSB0_DIR*/
299 MUX_VAL(CP(HSUSB0_NXT), (IEN | PTD | DIS | M0)); /*HSUSB0_NXT*/
300 MUX_VAL(CP(HSUSB0_DATA0), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA0*/
301 MUX_VAL(CP(HSUSB0_DATA1), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA1*/
302 MUX_VAL(CP(HSUSB0_DATA2), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA2*/
303 MUX_VAL(CP(HSUSB0_DATA3), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA3*/
304 MUX_VAL(CP(HSUSB0_DATA4), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA4*/
305 MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA5*/
306 MUX_VAL(CP(HSUSB0_DATA6), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA6*/
307 MUX_VAL(CP(HSUSB0_DATA7), (IEN | PTD | DIS | M0)); /*HSUSB0_DATA7*/
308
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200309 /* USB EHCI */
310 MUX_VAL(CP(ETK_D0_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT0*/
311 MUX_VAL(CP(ETK_D1_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT1*/
312 MUX_VAL(CP(ETK_D2_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT2*/
313 MUX_VAL(CP(ETK_D7_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT3*/
314 MUX_VAL(CP(ETK_D4_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT4*/
315 MUX_VAL(CP(ETK_D5_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT5*/
316 MUX_VAL(CP(ETK_D6_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT6*/
317 MUX_VAL(CP(ETK_D3_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DT7*/
318 MUX_VAL(CP(ETK_D8_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_DIR*/
319 MUX_VAL(CP(ETK_D9_ES2), (IEN | PTD | EN | M3)); /*HSUSB1_NXT*/
320 MUX_VAL(CP(ETK_CTL_ES2), (IDIS | PTD | DIS | M3)); /*HSUSB1_CLK*/
321 MUX_VAL(CP(ETK_CLK_ES2), (IDIS | PTU | DIS | M3)); /*HSUSB1_STP*/
322
323 MUX_VAL(CP(ETK_D14_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_DT0*/
324 MUX_VAL(CP(ETK_D15_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_DT1*/
325 MUX_VAL(CP(MCSPI1_CS3), (IEN | PTD | EN | M3)); /*HSUSB2_DT2*/
326 MUX_VAL(CP(MCSPI2_CS1), (IEN | PTD | EN | M3)); /*HSUSB2_DT3*/
327 MUX_VAL(CP(MCSPI2_SIMO), (IEN | PTD | EN | M3)); /*HSUSB2_DT4*/
328 MUX_VAL(CP(MCSPI2_SOMI), (IEN | PTD | EN | M3)); /*HSUSB2_DT5*/
329 MUX_VAL(CP(MCSPI2_CS0), (IEN | PTD | EN | M3)); /*HSUSB2_DT6*/
330 MUX_VAL(CP(MCSPI2_CLK), (IEN | PTD | EN | M3)); /*HSUSB2_DT7*/
331 MUX_VAL(CP(ETK_D12_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_DIR*/
332 MUX_VAL(CP(ETK_D13_ES2), (IEN | PTD | EN | M3)); /*HSUSB2_NXT*/
333 MUX_VAL(CP(ETK_D10_ES2), (IDIS | PTD | DIS | M3)); /*HSUSB2_CLK*/
334 MUX_VAL(CP(ETK_D11_ES2), (IDIS | PTU | DIS | M3)); /*HSUSB2_STP*/
335
336 /* SB_T35_USB_HUB_RESET_GPIO */
337 MUX_VAL(CP(CAM_WEN), (IDIS | PTD | DIS | M4)); /*GPIO_167*/
338
Mike Rapoport8abe7302010-12-18 17:43:19 -0500339 /* I2C1 */
340 MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0)); /*I2C1_SCL*/
341 MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0)); /*I2C1_SDA*/
Nikita Kiryanovda4da302012-04-02 02:29:31 +0000342 /* I2C2 */
343 MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M0)); /*I2C2_SCL*/
344 MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M0)); /*I2C2_SDA*/
345 /* I2C3 */
346 MUX_VAL(CP(I2C3_SCL), (IEN | PTU | EN | M0)); /*I2C3_SCL*/
347 MUX_VAL(CP(I2C3_SDA), (IEN | PTU | EN | M0)); /*I2C3_SDA*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500348
349 /* control and debug */
350 MUX_VAL(CP(SYS_32K), (IEN | PTD | DIS | M0)); /*SYS_32K*/
351 MUX_VAL(CP(SYS_CLKREQ), (IEN | PTD | DIS | M0)); /*SYS_CLKREQ*/
352 MUX_VAL(CP(SYS_NIRQ), (IEN | PTU | EN | M0)); /*SYS_nIRQ*/
353 MUX_VAL(CP(SYS_OFF_MODE), (IEN | PTD | DIS | M0)); /*OFF_MODE*/
354 MUX_VAL(CP(SYS_CLKOUT1), (IEN | PTD | DIS | M0)); /*CLKOUT1*/
Igor Grinbergd2367bc2011-04-18 17:54:33 -0400355 MUX_VAL(CP(SYS_CLKOUT2), (IDIS | PTU | DIS | M4)); /*green LED*/
Igor Grinberg165808d2014-10-21 18:25:30 +0300356 MUX_VAL(CP(JTAG_NTRST), (IEN | PTD | DIS | M0)); /*JTAG_NTRST*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500357 MUX_VAL(CP(JTAG_TCK), (IEN | PTD | DIS | M0)); /*JTAG_TCK*/
358 MUX_VAL(CP(JTAG_TMS), (IEN | PTD | DIS | M0)); /*JTAG_TMS*/
359 MUX_VAL(CP(JTAG_TDI), (IEN | PTD | DIS | M0)); /*JTAG_TDI*/
Igor Grinberga704ce02011-04-18 17:50:07 -0400360
361 /* MMC1 */
362 MUX_VAL(CP(MMC1_CLK), (IDIS | PTU | EN | M0)); /*MMC1_CLK*/
363 MUX_VAL(CP(MMC1_CMD), (IEN | PTU | EN | M0)); /*MMC1_CMD*/
364 MUX_VAL(CP(MMC1_DAT0), (IEN | PTU | EN | M0)); /*MMC1_DAT0*/
365 MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0)); /*MMC1_DAT1*/
366 MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0)); /*MMC1_DAT2*/
367 MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0)); /*MMC1_DAT3*/
Nikita Kiryanov25da1522013-10-16 17:23:29 +0300368
369 /* SPI */
370 MUX_VAL(CP(MCBSP1_CLKR), (IEN | PTD | DIS | M1)); /*MCSPI4_CLK*/
371 MUX_VAL(CP(MCBSP1_DX), (IEN | PTD | DIS | M1)); /*MCSPI4_SIMO*/
372 MUX_VAL(CP(MCBSP1_DR), (IEN | PTD | DIS | M1)); /*MCSPI4_SOMI*/
373 MUX_VAL(CP(MCBSP1_FSX), (IEN | PTU | EN | M1)); /*MCSPI4_CS0*/
374
375 /* display controls */
376 MUX_VAL(CP(MCBSP1_FSR), (IDIS | PTU | DIS | M4)); /*GPIO_157*/
Igor Grinberg05a96a42011-04-18 17:55:21 -0400377}
378
379static void cm_t35_set_muxconf(void)
380{
381 /* DSS */
382 MUX_VAL(CP(DSS_DATA0), (IDIS | PTD | DIS | M0)); /*DSS_DATA0*/
383 MUX_VAL(CP(DSS_DATA1), (IDIS | PTD | DIS | M0)); /*DSS_DATA1*/
384 MUX_VAL(CP(DSS_DATA2), (IDIS | PTD | DIS | M0)); /*DSS_DATA2*/
385 MUX_VAL(CP(DSS_DATA3), (IDIS | PTD | DIS | M0)); /*DSS_DATA3*/
386 MUX_VAL(CP(DSS_DATA4), (IDIS | PTD | DIS | M0)); /*DSS_DATA4*/
387 MUX_VAL(CP(DSS_DATA5), (IDIS | PTD | DIS | M0)); /*DSS_DATA5*/
388
389 MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M0)); /*DSS_DATA18*/
390 MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M0)); /*DSS_DATA19*/
391 MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M0)); /*DSS_DATA20*/
392 MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M0)); /*DSS_DATA21*/
393 MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M0)); /*DSS_DATA22*/
394 MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M0)); /*DSS_DATA23*/
395
396 /* MMC1 */
Igor Grinberga704ce02011-04-18 17:50:07 -0400397 MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M0)); /*MMC1_DAT4*/
398 MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M0)); /*MMC1_DAT5*/
399 MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M0)); /*MMC1_DAT6*/
400 MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M0)); /*MMC1_DAT7*/
Mike Rapoport8abe7302010-12-18 17:43:19 -0500401}
402
Igor Grinberg05a96a42011-04-18 17:55:21 -0400403static void cm_t3730_set_muxconf(void)
404{
405 /* DSS */
406 MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M3)); /*DSS_DATA0*/
407 MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M3)); /*DSS_DATA1*/
408 MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M3)); /*DSS_DATA2*/
409 MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M3)); /*DSS_DATA3*/
410 MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M3)); /*DSS_DATA4*/
411 MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M3)); /*DSS_DATA5*/
412
413 MUX_VAL(CP(SYS_BOOT0), (IDIS | PTD | DIS | M3)); /*DSS_DATA18*/
414 MUX_VAL(CP(SYS_BOOT1), (IDIS | PTD | DIS | M3)); /*DSS_DATA19*/
415 MUX_VAL(CP(SYS_BOOT3), (IDIS | PTD | DIS | M3)); /*DSS_DATA20*/
416 MUX_VAL(CP(SYS_BOOT4), (IDIS | PTD | DIS | M3)); /*DSS_DATA21*/
417 MUX_VAL(CP(SYS_BOOT5), (IDIS | PTD | DIS | M3)); /*DSS_DATA22*/
418 MUX_VAL(CP(SYS_BOOT6), (IDIS | PTD | DIS | M3)); /*DSS_DATA23*/
419}
420
421void set_muxconf_regs(void)
422{
423 cm_t3x_set_common_muxconf();
424
425 if (get_cpu_family() == CPU_OMAP34XX)
426 cm_t35_set_muxconf();
427 else
428 cm_t3730_set_muxconf();
429}
430
Stefan Roese8ef10bd2013-12-04 13:54:18 +0100431#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
Igor Grinbergde25e2d2014-10-21 16:39:46 +0300432#define SB_T35_WP_GPIO 59
433
Nikita Kiryanov4459e762012-12-03 02:19:45 +0000434int board_mmc_getcd(struct mmc *mmc)
435{
436 u8 val;
437
Nishanth Menon5d9d6f72013-03-26 05:20:50 +0000438 if (twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO, &val))
Nikita Kiryanov4459e762012-12-03 02:19:45 +0000439 return -1;
440
441 return !(val & 1);
442}
443
Tom Rinid0974a82011-09-03 21:49:24 -0400444int board_mmc_init(bd_t *bis)
445{
Igor Grinbergde25e2d2014-10-21 16:39:46 +0300446 return omap_mmc_init(0, 0, 0, -1, SB_T35_WP_GPIO);
Tom Rinid0974a82011-09-03 21:49:24 -0400447}
448#endif
449
Mike Rapoport8abe7302010-12-18 17:43:19 -0500450/*
451 * Routine: setup_net_chip_gmpc
452 * Description: Setting up the configuration GPMC registers specific to the
453 * Ethernet hardware.
454 */
455static void setup_net_chip_gmpc(void)
456{
457 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
458
459 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[5],
Igor Grinberg05a96a42011-04-18 17:55:21 -0400460 CM_T3X_SMC911X_BASE, GPMC_SIZE_16M);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500461 enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[4],
462 SB_T35_SMC911X_BASE, GPMC_SIZE_16M);
463
464 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
465 writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
466
467 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
468 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
469
470 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
471 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
472 &ctrl_base->gpmc_nadv_ale);
473}
474
Heiko Schocherf53f2b82013-10-22 11:03:18 +0200475#ifdef CONFIG_SYS_I2C_OMAP34XX
Mike Rapoport8abe7302010-12-18 17:43:19 -0500476/*
477 * Routine: reset_net_chip
478 * Description: reset the Ethernet controller via TPS65930 GPIO
479 */
480static void reset_net_chip(void)
481{
482 /* Set GPIO1 of TPS65930 as output */
Nishanth Menond26a1062013-03-26 05:20:49 +0000483 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x03,
484 0x02);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500485 /* Send a pulse on the GPIO pin */
Nishanth Menond26a1062013-03-26 05:20:49 +0000486 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x0C,
487 0x02);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500488 udelay(1);
Nishanth Menond26a1062013-03-26 05:20:49 +0000489 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x09,
490 0x02);
Igor Grinberge4d26a22012-04-02 20:12:58 +0000491 mdelay(40);
Nishanth Menond26a1062013-03-26 05:20:49 +0000492 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, TWL4030_BASEADD_GPIO + 0x0C,
493 0x02);
Igor Grinberge4d26a22012-04-02 20:12:58 +0000494 mdelay(1);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500495}
496#else
497static inline void reset_net_chip(void) {}
498#endif
499
Nikita Kiryanovb7792f02012-01-02 04:01:31 +0000500#ifdef CONFIG_SMC911X
Mike Rapoport8abe7302010-12-18 17:43:19 -0500501/*
502 * Routine: handle_mac_address
503 * Description: prepare MAC address for on-board Ethernet.
504 */
505static int handle_mac_address(void)
506{
507 unsigned char enetaddr[6];
508 int rc;
509
510 rc = eth_getenv_enetaddr("ethaddr", enetaddr);
511 if (rc)
512 return 0;
513
Igor Grinberg3394be82013-09-16 21:49:58 +0300514 rc = cl_eeprom_read_mac_addr(enetaddr);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500515 if (rc)
516 return rc;
Mike Rapoport8abe7302010-12-18 17:43:19 -0500517
518 if (!is_valid_ether_addr(enetaddr))
519 return -1;
520
521 return eth_setenv_enetaddr("ethaddr", enetaddr);
522}
523
524
525/*
526 * Routine: board_eth_init
527 * Description: initialize module and base-board Ethernet chips
528 */
529int board_eth_init(bd_t *bis)
530{
531 int rc = 0, rc1 = 0;
532
Mike Rapoport8abe7302010-12-18 17:43:19 -0500533 setup_net_chip_gmpc();
534 reset_net_chip();
535
536 rc1 = handle_mac_address();
537 if (rc1)
Igor Grinberg7e741ff2012-06-13 19:41:40 +0000538 printf("No MAC address found! ");
Mike Rapoport8abe7302010-12-18 17:43:19 -0500539
Igor Grinberg05a96a42011-04-18 17:55:21 -0400540 rc1 = smc911x_initialize(0, CM_T3X_SMC911X_BASE);
Mike Rapoport8abe7302010-12-18 17:43:19 -0500541 if (rc1 > 0)
542 rc++;
543
544 rc1 = smc911x_initialize(1, SB_T35_SMC911X_BASE);
545 if (rc1 > 0)
546 rc++;
Mike Rapoport8abe7302010-12-18 17:43:19 -0500547
548 return rc;
549}
Nikita Kiryanovb7792f02012-01-02 04:01:31 +0000550#endif
Nikita Kiryanovb47cb9d2012-01-12 03:26:30 +0000551
552void __weak get_board_serial(struct tag_serialnr *serialnr)
553{
554 /*
555 * This corresponds to what happens when we can communicate with the
556 * eeprom but don't get a valid board serial value.
557 */
558 serialnr->low = 0;
559 serialnr->high = 0;
560};
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200561
562#ifdef CONFIG_USB_EHCI_OMAP
563struct omap_usbhs_board_data usbhs_bdata = {
564 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
565 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
566 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
567};
568
569#define SB_T35_USB_HUB_RESET_GPIO 167
Troy Kisky7d6bbb92013-10-10 15:27:57 -0700570int ehci_hcd_init(int index, enum usb_init_type init,
571 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200572{
573 u8 val;
574 int offset;
575
576 if (gpio_request(SB_T35_USB_HUB_RESET_GPIO, "SB-T35 usb hub reset")) {
577 printf("Error: can't obtain GPIO %d for SB-T35 usb hub reset",
578 SB_T35_USB_HUB_RESET_GPIO);
579 return -1;
580 }
581
582 gpio_direction_output(SB_T35_USB_HUB_RESET_GPIO, 0);
583 udelay(10);
584 gpio_set_value(SB_T35_USB_HUB_RESET_GPIO, 1);
585 udelay(1000);
586
587 offset = TWL4030_BASEADD_GPIO + TWL4030_GPIO_GPIODATADIR1;
Nishanth Menon5d9d6f72013-03-26 05:20:50 +0000588 twl4030_i2c_read_u8(TWL4030_CHIP_GPIO, offset, &val);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200589 /* Set GPIO6 and GPIO7 of TPS65930 as output */
590 val |= 0xC0;
Nishanth Menond26a1062013-03-26 05:20:49 +0000591 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, val);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200592 offset = TWL4030_BASEADD_GPIO + TWL4030_GPIO_SETGPIODATAOUT1;
593 /* Take both PHYs out of reset */
Nishanth Menond26a1062013-03-26 05:20:49 +0000594 twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, offset, 0xC0);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200595 udelay(1);
596
Mateusz Zalegad862f892013-10-04 19:22:26 +0200597 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200598}
599
600int ehci_hcd_stop(void)
601{
602 return omap_ehci_hcd_stop();
603}
Nikita Kiryanov9f957be2012-12-02 13:59:19 +0200604#endif /* CONFIG_USB_EHCI_OMAP */