Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Altera Corporation <www.altera.com> |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Marek Vasut | b935326 | 2015-12-05 19:24:22 +0100 | [diff] [blame^] | 8 | #include <errno.h> |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 9 | #include <asm/arch/reset_manager.h> |
| 10 | #include <asm/io.h> |
| 11 | |
Marek Vasut | 40f1d6b | 2014-11-04 04:25:09 +0100 | [diff] [blame] | 12 | #include <usb.h> |
Marek Vasut | f1be9cb | 2015-12-04 02:51:20 +0100 | [diff] [blame] | 13 | #include <usb/dwc2_udc.h> |
Marek Vasut | 40f1d6b | 2014-11-04 04:25:09 +0100 | [diff] [blame] | 14 | |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
Dinh Nguyen | 571c9e0 | 2015-04-15 16:44:31 -0500 | [diff] [blame] | 17 | void s_init(void) {} |
| 18 | |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 19 | /* |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 20 | * Miscellaneous platform dependent initialisations |
| 21 | */ |
| 22 | int board_init(void) |
| 23 | { |
Pavel Machek | 26ea1d9 | 2014-09-08 14:08:45 +0200 | [diff] [blame] | 24 | /* Address of boot parameters for ATAG (if ATAG is used) */ |
| 25 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
| 26 | |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 27 | return 0; |
| 28 | } |
Dinh Nguyen | f2b845e | 2014-11-13 11:23:41 -0600 | [diff] [blame] | 29 | |
Marek Vasut | 40f1d6b | 2014-11-04 04:25:09 +0100 | [diff] [blame] | 30 | #ifdef CONFIG_USB_GADGET |
Marek Vasut | 6939aca | 2015-12-04 02:23:29 +0100 | [diff] [blame] | 31 | struct dwc2_plat_otg_data socfpga_otg_data = { |
Marek Vasut | 40f1d6b | 2014-11-04 04:25:09 +0100 | [diff] [blame] | 32 | .usb_gusbcfg = 0x1417, |
| 33 | }; |
| 34 | |
| 35 | int board_usb_init(int index, enum usb_init_type init) |
| 36 | { |
Marek Vasut | b935326 | 2015-12-05 19:24:22 +0100 | [diff] [blame^] | 37 | int node[2], count; |
| 38 | fdt_addr_t addr; |
| 39 | |
| 40 | count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc", |
| 41 | COMPAT_ALTERA_SOCFPGA_DWC2USB, |
| 42 | node, 2); |
| 43 | if (count <= 0) /* No controller found. */ |
| 44 | return 0; |
| 45 | |
| 46 | addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg"); |
| 47 | if (addr == FDT_ADDR_T_NONE) { |
| 48 | printf("UDC Controller has no 'reg' property!\n"); |
| 49 | return -EINVAL; |
| 50 | } |
| 51 | |
| 52 | /* Patch the address from OF into the controller pdata. */ |
| 53 | socfpga_otg_data.regs_otg = addr; |
| 54 | |
Marek Vasut | 01b61fa | 2015-12-04 02:26:33 +0100 | [diff] [blame] | 55 | return dwc2_udc_probe(&socfpga_otg_data); |
Marek Vasut | 40f1d6b | 2014-11-04 04:25:09 +0100 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | int g_dnl_board_usb_cable_connected(void) |
| 59 | { |
| 60 | return 1; |
| 61 | } |
| 62 | #endif |