xref: /openbmc/u-boot/arch/arm/mach-socfpga/board.c (revision 730d2544)
1 /*
2  * Altera SoCFPGA common board code
3  *
4  * Copyright (C) 2015 Marek Vasut <marex@denx.de>
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 
9 #include <common.h>
10 #include <errno.h>
11 #include <asm/arch/reset_manager.h>
12 #include <asm/io.h>
13 
14 #include <usb.h>
15 #include <usb/dwc2_udc.h>
16 
17 DECLARE_GLOBAL_DATA_PTR;
18 
19 void s_init(void) {}
20 
21 /*
22  * Miscellaneous platform dependent initialisations
23  */
24 int board_init(void)
25 {
26 	/* Address of boot parameters for ATAG (if ATAG is used) */
27 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
28 
29 	return 0;
30 }
31 
32 #ifdef CONFIG_USB_GADGET
33 struct dwc2_plat_otg_data socfpga_otg_data = {
34 	.usb_gusbcfg	= 0x1417,
35 };
36 
37 int board_usb_init(int index, enum usb_init_type init)
38 {
39 	int node[2], count;
40 	fdt_addr_t addr;
41 
42 	count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
43 					   COMPAT_ALTERA_SOCFPGA_DWC2USB,
44 					   node, 2);
45 	if (count <= 0)	/* No controller found. */
46 		return 0;
47 
48 	addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
49 	if (addr == FDT_ADDR_T_NONE) {
50 		printf("UDC Controller has no 'reg' property!\n");
51 		return -EINVAL;
52 	}
53 
54 	/* Patch the address from OF into the controller pdata. */
55 	socfpga_otg_data.regs_otg = addr;
56 
57 	return dwc2_udc_probe(&socfpga_otg_data);
58 }
59 
60 int g_dnl_board_usb_cable_connected(void)
61 {
62 	return 1;
63 }
64 #endif
65