blob: ff0b3c75f53327faa489afab503fc9d3fce020bd [file] [log] [blame]
Michal Simek04b7e622015-01-15 10:01:51 +01001/*
2 * (C) Copyright 2014 - 2015 Xilinx, Inc.
3 * Michal Simek <michal.simek@xilinx.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
Michal Simekd54b1af2015-09-30 17:26:55 +02009#include <sata.h>
Michal Simekb216cc12015-07-23 13:27:40 +020010#include <ahci.h>
11#include <scsi.h>
Michal Simekecfb6dc2016-04-22 14:28:54 +020012#include <malloc.h>
Michal Simekc23d3f82015-11-05 08:34:35 +010013#include <asm/arch/clk.h>
Michal Simek04b7e622015-01-15 10:01:51 +010014#include <asm/arch/hardware.h>
15#include <asm/arch/sys_proto.h>
Michal Simekf2f08642018-01-10 09:36:09 +010016#include <asm/arch/psu_init_gpl.h>
Michal Simek04b7e622015-01-15 10:01:51 +010017#include <asm/io.h>
Siva Durga Prasad Paladuguba1f68e2015-08-04 13:03:26 +053018#include <usb.h>
19#include <dwc3-uboot.h>
Michal Simek8111aff2016-02-01 15:05:58 +010020#include <zynqmppl.h>
Michal Simekeec32f62016-04-22 11:48:49 +020021#include <i2c.h>
Michal Simek76d0a772016-09-01 11:16:40 +020022#include <g_dnl.h>
Michal Simek04b7e622015-01-15 10:01:51 +010023
24DECLARE_GLOBAL_DATA_PTR;
25
Michal Simek8111aff2016-02-01 15:05:58 +010026#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \
27 !defined(CONFIG_SPL_BUILD)
28static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC;
29
30static const struct {
Michal Simek6908b862017-11-06 12:55:59 +010031 u32 id;
Michal Simek50d8cef2017-08-22 14:58:53 +020032 u32 ver;
Michal Simek8111aff2016-02-01 15:05:58 +010033 char *name;
34} zynqmp_devices[] = {
35 {
36 .id = 0x10,
37 .name = "3eg",
38 },
39 {
Michal Simek50d8cef2017-08-22 14:58:53 +020040 .id = 0x10,
41 .ver = 0x2c,
42 .name = "3cg",
43 },
44 {
Michal Simek8111aff2016-02-01 15:05:58 +010045 .id = 0x11,
46 .name = "2eg",
47 },
48 {
Michal Simek50d8cef2017-08-22 14:58:53 +020049 .id = 0x11,
50 .ver = 0x2c,
51 .name = "2cg",
52 },
53 {
Michal Simek8111aff2016-02-01 15:05:58 +010054 .id = 0x20,
55 .name = "5ev",
56 },
57 {
Michal Simek50d8cef2017-08-22 14:58:53 +020058 .id = 0x20,
59 .ver = 0x100,
60 .name = "5eg",
61 },
62 {
63 .id = 0x20,
64 .ver = 0x12c,
65 .name = "5cg",
66 },
67 {
Michal Simek8111aff2016-02-01 15:05:58 +010068 .id = 0x21,
69 .name = "4ev",
70 },
71 {
Michal Simek50d8cef2017-08-22 14:58:53 +020072 .id = 0x21,
73 .ver = 0x100,
74 .name = "4eg",
75 },
76 {
77 .id = 0x21,
78 .ver = 0x12c,
79 .name = "4cg",
80 },
81 {
Michal Simek8111aff2016-02-01 15:05:58 +010082 .id = 0x30,
83 .name = "7ev",
84 },
85 {
Michal Simek50d8cef2017-08-22 14:58:53 +020086 .id = 0x30,
87 .ver = 0x100,
88 .name = "7eg",
89 },
90 {
91 .id = 0x30,
92 .ver = 0x12c,
93 .name = "7cg",
94 },
95 {
Michal Simek8111aff2016-02-01 15:05:58 +010096 .id = 0x38,
97 .name = "9eg",
98 },
99 {
Michal Simek50d8cef2017-08-22 14:58:53 +0200100 .id = 0x38,
101 .ver = 0x2c,
102 .name = "9cg",
103 },
104 {
Michal Simek8111aff2016-02-01 15:05:58 +0100105 .id = 0x39,
106 .name = "6eg",
107 },
108 {
Michal Simek50d8cef2017-08-22 14:58:53 +0200109 .id = 0x39,
110 .ver = 0x2c,
111 .name = "6cg",
112 },
113 {
Michal Simek8111aff2016-02-01 15:05:58 +0100114 .id = 0x40,
115 .name = "11eg",
116 },
Michal Simek50d8cef2017-08-22 14:58:53 +0200117 { /* For testing purpose only */
118 .id = 0x50,
119 .ver = 0x2c,
120 .name = "15cg",
121 },
Michal Simek8111aff2016-02-01 15:05:58 +0100122 {
123 .id = 0x50,
124 .name = "15eg",
125 },
126 {
127 .id = 0x58,
128 .name = "19eg",
129 },
130 {
131 .id = 0x59,
132 .name = "17eg",
133 },
Michal Simekb510e532017-06-02 08:08:59 +0200134 {
135 .id = 0x61,
136 .name = "21dr",
137 },
138 {
139 .id = 0x63,
140 .name = "23dr",
141 },
142 {
143 .id = 0x65,
144 .name = "25dr",
145 },
146 {
147 .id = 0x64,
148 .name = "27dr",
149 },
150 {
151 .id = 0x60,
152 .name = "28dr",
153 },
154 {
155 .id = 0x62,
156 .name = "29dr",
157 },
Michal Simek8111aff2016-02-01 15:05:58 +0100158};
Siva Durga Prasad Paladugu8d526532017-07-25 11:51:37 +0530159#endif
Michal Simek8111aff2016-02-01 15:05:58 +0100160
Siva Durga Prasad Paladugucd35d522017-07-25 11:51:38 +0530161int chip_id(unsigned char id)
Michal Simek8111aff2016-02-01 15:05:58 +0100162{
163 struct pt_regs regs;
Siva Durga Prasad Paladugu9f0a8e92017-07-25 11:51:36 +0530164 int val = -EINVAL;
Michal Simek8111aff2016-02-01 15:05:58 +0100165
Siva Durga Prasad Paladugu8d526532017-07-25 11:51:37 +0530166 if (current_el() != 3) {
167 regs.regs[0] = ZYNQMP_SIP_SVC_CSU_DMA_CHIPID;
168 regs.regs[1] = 0;
169 regs.regs[2] = 0;
170 regs.regs[3] = 0;
Michal Simek8111aff2016-02-01 15:05:58 +0100171
Siva Durga Prasad Paladugu8d526532017-07-25 11:51:37 +0530172 smc_call(&regs);
173
174 /*
175 * SMC returns:
176 * regs[0][31:0] = status of the operation
177 * regs[0][63:32] = CSU.IDCODE register
178 * regs[1][31:0] = CSU.version register
Michal Simek50d8cef2017-08-22 14:58:53 +0200179 * regs[1][63:32] = CSU.IDCODE2 register
Siva Durga Prasad Paladugu8d526532017-07-25 11:51:37 +0530180 */
181 switch (id) {
182 case IDCODE:
183 regs.regs[0] = upper_32_bits(regs.regs[0]);
184 regs.regs[0] &= ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK |
185 ZYNQMP_CSU_IDCODE_SVD_MASK;
186 regs.regs[0] >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT;
187 val = regs.regs[0];
188 break;
189 case VERSION:
190 regs.regs[1] = lower_32_bits(regs.regs[1]);
191 regs.regs[1] &= ZYNQMP_CSU_SILICON_VER_MASK;
192 val = regs.regs[1];
193 break;
Michal Simek50d8cef2017-08-22 14:58:53 +0200194 case IDCODE2:
195 regs.regs[1] = lower_32_bits(regs.regs[1]);
196 regs.regs[1] >>= ZYNQMP_CSU_VERSION_EMPTY_SHIFT;
197 val = regs.regs[1];
198 break;
Siva Durga Prasad Paladugu8d526532017-07-25 11:51:37 +0530199 default:
200 printf("%s, Invalid Req:0x%x\n", __func__, id);
201 }
202 } else {
203 switch (id) {
204 case IDCODE:
205 val = readl(ZYNQMP_CSU_IDCODE_ADDR);
206 val &= ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK |
207 ZYNQMP_CSU_IDCODE_SVD_MASK;
208 val >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT;
209 break;
210 case VERSION:
211 val = readl(ZYNQMP_CSU_VER_ADDR);
212 val &= ZYNQMP_CSU_SILICON_VER_MASK;
213 break;
214 default:
215 printf("%s, Invalid Req:0x%x\n", __func__, id);
216 }
Siva Durga Prasad Paladugu9f0a8e92017-07-25 11:51:36 +0530217 }
Soren Brinkmannd7696a52016-09-29 11:44:41 -0700218
Siva Durga Prasad Paladugu9f0a8e92017-07-25 11:51:36 +0530219 return val;
Michal Simek8111aff2016-02-01 15:05:58 +0100220}
221
Siva Durga Prasad Paladugu8d526532017-07-25 11:51:37 +0530222#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \
223 !defined(CONFIG_SPL_BUILD)
Michal Simek8111aff2016-02-01 15:05:58 +0100224static char *zynqmp_get_silicon_idcode_name(void)
225{
Michal Simek50d8cef2017-08-22 14:58:53 +0200226 u32 i, id, ver;
Michal Simek8111aff2016-02-01 15:05:58 +0100227
Siva Durga Prasad Paladugu9f0a8e92017-07-25 11:51:36 +0530228 id = chip_id(IDCODE);
Michal Simek50d8cef2017-08-22 14:58:53 +0200229 ver = chip_id(IDCODE2);
230
Michal Simek8111aff2016-02-01 15:05:58 +0100231 for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) {
Michal Simek50d8cef2017-08-22 14:58:53 +0200232 if (zynqmp_devices[i].id == id && zynqmp_devices[i].ver == ver)
Michal Simek8111aff2016-02-01 15:05:58 +0100233 return zynqmp_devices[i].name;
234 }
235 return "unknown";
236}
237#endif
238
Michal Simek8b353302017-02-07 14:32:26 +0100239int board_early_init_f(void)
240{
Michal Simekc8785f22018-01-10 11:48:48 +0100241 int ret = 0;
Michal Simek8b353302017-02-07 14:32:26 +0100242#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_CLK_ZYNQMP)
243 zynqmp_pmufw_version();
244#endif
Michal Simeke0f36102017-07-12 13:08:41 +0200245
Michal Simek1a1ab5a2018-01-15 12:52:59 +0100246#if defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED)
Michal Simekc8785f22018-01-10 11:48:48 +0100247 ret = psu_init();
Michal Simeke0f36102017-07-12 13:08:41 +0200248#endif
249
Michal Simekc8785f22018-01-10 11:48:48 +0100250 return ret;
Michal Simek8b353302017-02-07 14:32:26 +0100251}
252
Michal Simek8111aff2016-02-01 15:05:58 +0100253#define ZYNQMP_VERSION_SIZE 9
254
Michal Simek04b7e622015-01-15 10:01:51 +0100255int board_init(void)
256{
Michal Simekfb7242d2015-06-22 14:31:06 +0200257 printf("EL Level:\tEL%d\n", current_el());
258
Michal Simek8111aff2016-02-01 15:05:58 +0100259#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \
260 !defined(CONFIG_SPL_BUILD) || (defined(CONFIG_SPL_FPGA_SUPPORT) && \
261 defined(CONFIG_SPL_BUILD))
262 if (current_el() != 3) {
263 static char version[ZYNQMP_VERSION_SIZE];
264
Michal Simek54cae482017-12-06 08:33:50 +0100265 strncat(version, "zu", 2);
Michal Simek8111aff2016-02-01 15:05:58 +0100266 zynqmppl.name = strncat(version,
267 zynqmp_get_silicon_idcode_name(),
Michal Simek54cae482017-12-06 08:33:50 +0100268 ZYNQMP_VERSION_SIZE - 3);
Michal Simek8111aff2016-02-01 15:05:58 +0100269 printf("Chip ID:\t%s\n", zynqmppl.name);
270 fpga_init();
271 fpga_add(fpga_xilinx, &zynqmppl);
272 }
273#endif
274
Michal Simek04b7e622015-01-15 10:01:51 +0100275 return 0;
276}
277
278int board_early_init_r(void)
279{
280 u32 val;
281
Siva Durga Prasad Paladugu64d90002017-12-07 15:05:30 +0530282 if (current_el() != 3)
283 return 0;
284
Michal Simek245d5282017-07-12 10:32:18 +0200285 val = readl(&crlapb_base->timestamp_ref_ctrl);
286 val &= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT;
287
Siva Durga Prasad Paladugu64d90002017-12-07 15:05:30 +0530288 if (!val) {
Michal Simekc23d3f82015-11-05 08:34:35 +0100289 val = readl(&crlapb_base->timestamp_ref_ctrl);
290 val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT;
291 writel(val, &crlapb_base->timestamp_ref_ctrl);
Michal Simek04b7e622015-01-15 10:01:51 +0100292
Michal Simekc23d3f82015-11-05 08:34:35 +0100293 /* Program freq register in System counter */
294 writel(zynqmp_get_system_timer_freq(),
295 &iou_scntr_secure->base_frequency_id_register);
296 /* And enable system counter */
297 writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN,
298 &iou_scntr_secure->counter_control_register);
299 }
Michal Simek04b7e622015-01-15 10:01:51 +0100300 return 0;
301}
302
Michal Simekeec32f62016-04-22 11:48:49 +0200303int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
304{
305#if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \
306 defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET) && \
307 defined(CONFIG_ZYNQ_EEPROM_BUS)
308 i2c_set_bus_num(CONFIG_ZYNQ_EEPROM_BUS);
309
310 if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR,
311 CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET,
312 ethaddr, 6))
313 printf("I2C EEPROM MAC address read failed\n");
314#endif
315
316 return 0;
317}
318
Michal Simek8faa66a2016-02-08 09:34:53 +0100319#if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE)
Simon Glass2f949c32017-03-31 08:40:32 -0600320int dram_init_banksize(void)
Michal Simek8faa66a2016-02-08 09:34:53 +0100321{
Michal Simekd5b7de62017-11-03 15:25:51 +0100322 return fdtdec_setup_memory_banksize();
Tom Riniedcfdbd2016-12-09 07:56:54 -0500323}
Michal Simek8faa66a2016-02-08 09:34:53 +0100324
Tom Riniedcfdbd2016-12-09 07:56:54 -0500325int dram_init(void)
326{
Nathan Rossiac04bfa2016-12-19 00:03:34 +1000327 if (fdtdec_setup_memory_size() != 0)
328 return -EINVAL;
Tom Riniedcfdbd2016-12-09 07:56:54 -0500329
330 return 0;
Michal Simek8faa66a2016-02-08 09:34:53 +0100331}
332#else
Michal Simek04b7e622015-01-15 10:01:51 +0100333int dram_init(void)
334{
335 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
336
337 return 0;
338}
Michal Simek8faa66a2016-02-08 09:34:53 +0100339#endif
Michal Simek04b7e622015-01-15 10:01:51 +0100340
Michal Simek04b7e622015-01-15 10:01:51 +0100341void reset_cpu(ulong addr)
342{
343}
344
Michal Simek04b7e622015-01-15 10:01:51 +0100345int board_late_init(void)
346{
347 u32 reg = 0;
348 u8 bootmode;
Michal Simekecfb6dc2016-04-22 14:28:54 +0200349 const char *mode;
350 char *new_targets;
Siva Durga Prasad Paladugu245c5562017-12-20 16:35:06 +0530351 char *env_targets;
Siva Durga Prasad Paladugue6fd3bb2017-02-21 17:58:28 +0530352 int ret;
Michal Simekecfb6dc2016-04-22 14:28:54 +0200353
354 if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
355 debug("Saved variables - Skipping\n");
356 return 0;
357 }
Michal Simek04b7e622015-01-15 10:01:51 +0100358
Siva Durga Prasad Paladugue6fd3bb2017-02-21 17:58:28 +0530359 ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, &reg);
360 if (ret)
361 return -EINVAL;
362
Michal Simek833e0c42016-10-25 11:43:02 +0200363 if (reg >> BOOT_MODE_ALT_SHIFT)
364 reg >>= BOOT_MODE_ALT_SHIFT;
365
Michal Simek04b7e622015-01-15 10:01:51 +0100366 bootmode = reg & BOOT_MODES_MASK;
367
Michal Simekc5d95232015-09-20 17:20:42 +0200368 puts("Bootmode: ");
Michal Simek04b7e622015-01-15 10:01:51 +0100369 switch (bootmode) {
Michal Simek12398ea2016-08-19 14:14:52 +0200370 case USB_MODE:
371 puts("USB_MODE\n");
372 mode = "usb";
Michal Simek43380352017-12-01 15:18:24 +0100373 env_set("modeboot", "usb_dfu_spl");
Michal Simek12398ea2016-08-19 14:14:52 +0200374 break;
Siva Durga Prasad Paladugu30f0fc72015-03-13 11:10:26 +0530375 case JTAG_MODE:
Michal Simekc5d95232015-09-20 17:20:42 +0200376 puts("JTAG_MODE\n");
Michal Simekecfb6dc2016-04-22 14:28:54 +0200377 mode = "pxe dhcp";
Michal Simek43380352017-12-01 15:18:24 +0100378 env_set("modeboot", "jtagboot");
Siva Durga Prasad Paladugu30f0fc72015-03-13 11:10:26 +0530379 break;
380 case QSPI_MODE_24BIT:
381 case QSPI_MODE_32BIT:
Michal Simekecfb6dc2016-04-22 14:28:54 +0200382 mode = "qspi0";
Michal Simekc5d95232015-09-20 17:20:42 +0200383 puts("QSPI_MODE\n");
Michal Simek43380352017-12-01 15:18:24 +0100384 env_set("modeboot", "qspiboot");
Siva Durga Prasad Paladugu30f0fc72015-03-13 11:10:26 +0530385 break;
Michal Simek02d66cd2015-04-15 15:02:28 +0200386 case EMMC_MODE:
Michal Simekdf7ff0a2015-10-05 15:59:38 +0200387 puts("EMMC_MODE\n");
Michal Simekecfb6dc2016-04-22 14:28:54 +0200388 mode = "mmc0";
Michal Simek43380352017-12-01 15:18:24 +0100389 env_set("modeboot", "emmcboot");
Michal Simekdf7ff0a2015-10-05 15:59:38 +0200390 break;
391 case SD_MODE:
Michal Simekc5d95232015-09-20 17:20:42 +0200392 puts("SD_MODE\n");
Michal Simekecfb6dc2016-04-22 14:28:54 +0200393 mode = "mmc0";
Michal Simek43380352017-12-01 15:18:24 +0100394 env_set("modeboot", "sdboot");
Michal Simek04b7e622015-01-15 10:01:51 +0100395 break;
Siva Durga Prasad Paladugu29a77d22016-09-21 11:45:05 +0530396 case SD1_LSHFT_MODE:
397 puts("LVL_SHFT_");
398 /* fall through */
Michal Simek108e1842015-10-05 10:51:12 +0200399 case SD_MODE1:
Michal Simekc5d95232015-09-20 17:20:42 +0200400 puts("SD_MODE1\n");
Michal Simek6d902452015-11-06 10:22:37 +0100401#if defined(CONFIG_ZYNQ_SDHCI0) && defined(CONFIG_ZYNQ_SDHCI1)
Michal Simekecfb6dc2016-04-22 14:28:54 +0200402 mode = "mmc1";
Michal Simek43380352017-12-01 15:18:24 +0100403 env_set("sdbootdev", "1");
Michal Simekecfb6dc2016-04-22 14:28:54 +0200404#else
405 mode = "mmc0";
Michal Simek6d902452015-11-06 10:22:37 +0100406#endif
Michal Simek43380352017-12-01 15:18:24 +0100407 env_set("modeboot", "sdboot");
Michal Simek108e1842015-10-05 10:51:12 +0200408 break;
409 case NAND_MODE:
Michal Simekc5d95232015-09-20 17:20:42 +0200410 puts("NAND_MODE\n");
Michal Simekecfb6dc2016-04-22 14:28:54 +0200411 mode = "nand0";
Michal Simek43380352017-12-01 15:18:24 +0100412 env_set("modeboot", "nandboot");
Michal Simek108e1842015-10-05 10:51:12 +0200413 break;
Michal Simek04b7e622015-01-15 10:01:51 +0100414 default:
Michal Simekecfb6dc2016-04-22 14:28:54 +0200415 mode = "";
Michal Simek04b7e622015-01-15 10:01:51 +0100416 printf("Invalid Boot Mode:0x%x\n", bootmode);
417 break;
418 }
419
Michal Simekecfb6dc2016-04-22 14:28:54 +0200420 /*
421 * One terminating char + one byte for space between mode
422 * and default boot_targets
423 */
Siva Durga Prasad Paladugu245c5562017-12-20 16:35:06 +0530424 env_targets = env_get("boot_targets");
425 if (env_targets) {
426 new_targets = calloc(1, strlen(mode) +
427 strlen(env_targets) + 2);
428 sprintf(new_targets, "%s %s", mode, env_targets);
429 } else {
430 new_targets = calloc(1, strlen(mode) + 2);
431 sprintf(new_targets, "%s", mode);
432 }
Michal Simekecfb6dc2016-04-22 14:28:54 +0200433
Simon Glass6a38e412017-08-03 12:22:09 -0600434 env_set("boot_targets", new_targets);
Michal Simekecfb6dc2016-04-22 14:28:54 +0200435
Michal Simek04b7e622015-01-15 10:01:51 +0100436 return 0;
437}
Siva Durga Prasad Paladugu650e0a32015-08-04 13:01:05 +0530438
439int checkboard(void)
440{
Michal Simek47ce9362016-01-25 11:04:21 +0100441 puts("Board: Xilinx ZynqMP\n");
Siva Durga Prasad Paladugu650e0a32015-08-04 13:01:05 +0530442 return 0;
443}
Siva Durga Prasad Paladuguba1f68e2015-08-04 13:03:26 +0530444
445#ifdef CONFIG_USB_DWC3
Michal Simekea526be2016-08-08 10:11:26 +0200446static struct dwc3_device dwc3_device_data0 = {
Siva Durga Prasad Paladuguba1f68e2015-08-04 13:03:26 +0530447 .maximum_speed = USB_SPEED_HIGH,
448 .base = ZYNQMP_USB0_XHCI_BASEADDR,
449 .dr_mode = USB_DR_MODE_PERIPHERAL,
450 .index = 0,
451};
452
Michal Simekea526be2016-08-08 10:11:26 +0200453static struct dwc3_device dwc3_device_data1 = {
454 .maximum_speed = USB_SPEED_HIGH,
455 .base = ZYNQMP_USB1_XHCI_BASEADDR,
456 .dr_mode = USB_DR_MODE_PERIPHERAL,
457 .index = 1,
458};
459
Michal Simek76d0a772016-09-01 11:16:40 +0200460int usb_gadget_handle_interrupts(int index)
Siva Durga Prasad Paladuguba1f68e2015-08-04 13:03:26 +0530461{
Michal Simek76d0a772016-09-01 11:16:40 +0200462 dwc3_uboot_handle_interrupt(index);
Siva Durga Prasad Paladuguba1f68e2015-08-04 13:03:26 +0530463 return 0;
464}
465
466int board_usb_init(int index, enum usb_init_type init)
467{
Michal Simekea526be2016-08-08 10:11:26 +0200468 debug("%s: index %x\n", __func__, index);
469
Michal Simek7987d2a2016-09-01 11:27:32 +0200470#if defined(CONFIG_USB_GADGET_DOWNLOAD)
471 g_dnl_set_serialnumber(CONFIG_SYS_CONFIG_NAME);
472#endif
473
Michal Simekea526be2016-08-08 10:11:26 +0200474 switch (index) {
475 case 0:
476 return dwc3_uboot_init(&dwc3_device_data0);
477 case 1:
478 return dwc3_uboot_init(&dwc3_device_data1);
479 };
480
481 return -1;
Siva Durga Prasad Paladuguba1f68e2015-08-04 13:03:26 +0530482}
483
484int board_usb_cleanup(int index, enum usb_init_type init)
485{
486 dwc3_uboot_exit(index);
487 return 0;
488}
489#endif