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