]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/ebv/socrates/socfpga.c
arm: socfpga: socrates: Probe DWC2 UDC from OF instead of hard-coded data
[people/ms/u-boot.git] / board / ebv / socrates / socfpga.c
CommitLineData
856b30da
MV
1/*
2 * Copyright (C) 2012 Altera Corporation <www.altera.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
b5a5d2bd 8#include <errno.h>
856b30da
MV
9#include <asm/arch/reset_manager.h>
10#include <asm/io.h>
11
12#include <usb.h>
5d5716ee 13#include <usb/dwc2_udc.h>
856b30da 14
856b30da
MV
15DECLARE_GLOBAL_DATA_PTR;
16
17void s_init(void) {}
18
19/*
20 * Miscellaneous platform dependent initialisations
21 */
22int board_init(void)
23{
24 /* Address of boot parameters for ATAG (if ATAG is used) */
25 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
26
27 return 0;
28}
29
856b30da 30#ifdef CONFIG_USB_GADGET
c0982871 31struct dwc2_plat_otg_data socfpga_otg_data = {
856b30da
MV
32 .usb_gusbcfg = 0x1417,
33};
34
35int board_usb_init(int index, enum usb_init_type init)
36{
b5a5d2bd
MV
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
a4bb9b36 55 return dwc2_udc_probe(&socfpga_otg_data);
856b30da
MV
56}
57
58int g_dnl_board_usb_cable_connected(void)
59{
60 return 1;
61}
62#endif