blob: 7c8c05cc3194a61f2fbf1efe07f7459eb446d39b [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>
Tien Fong Cheec960ef22017-12-05 15:58:07 +080010#include <fdtdec.h>
Marek Vasut8e535af2015-12-05 21:07:23 +010011#include <asm/arch/reset_manager.h>
Tien Fong Cheec960ef22017-12-05 15:58:07 +080012#include <asm/arch/clock_manager.h>
Tien Fong Chee011fa5f2017-12-05 15:58:08 +080013#include <asm/arch/misc.h>
Marek Vasut8e535af2015-12-05 21:07:23 +010014#include <asm/io.h>
15
16#include <usb.h>
17#include <usb/dwc2_udc.h>
18
19DECLARE_GLOBAL_DATA_PTR;
20
Marek Vasut887a8b62018-05-29 16:16:46 +020021void s_init(void) {
Ley Foon Tan8c9f2472018-07-12 19:13:34 +080022#ifndef CONFIG_ARM64
Marek Vasut887a8b62018-05-29 16:16:46 +020023 /*
Marek Vasut937db712018-07-12 15:07:46 +020024 * Preconfigure ACTLR and CPACR, make sure Write Full Line of Zeroes
25 * is disabled in ACTLR.
Marek Vasut887a8b62018-05-29 16:16:46 +020026 * This is optional on CycloneV / ArriaV.
27 * This is mandatory on Arria10, otherwise Linux refuses to boot.
28 */
29 asm volatile(
30 "mcr p15, 0, %0, c1, c0, 1\n"
Marek Vasut937db712018-07-12 15:07:46 +020031 "mcr p15, 0, %0, c1, c0, 2\n"
Marek Vasut887a8b62018-05-29 16:16:46 +020032 "isb\n"
33 "dsb\n"
34 ::"r"(0x0));
Ley Foon Tan8c9f2472018-07-12 19:13:34 +080035#endif
Marek Vasut887a8b62018-05-29 16:16:46 +020036}
Marek Vasut8e535af2015-12-05 21:07:23 +010037
38/*
39 * Miscellaneous platform dependent initialisations
40 */
41int board_init(void)
42{
43 /* Address of boot parameters for ATAG (if ATAG is used) */
44 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
45
46 return 0;
47}
48
Tien Fong Chee53faef12017-12-05 15:58:01 +080049int dram_init_banksize(void)
50{
51 fdtdec_setup_memory_banksize();
52
53 return 0;
54}
55
Marek Vasut8e535af2015-12-05 21:07:23 +010056#ifdef CONFIG_USB_GADGET
57struct dwc2_plat_otg_data socfpga_otg_data = {
58 .usb_gusbcfg = 0x1417,
59};
60
61int board_usb_init(int index, enum usb_init_type init)
62{
63 int node[2], count;
64 fdt_addr_t addr;
65
66 count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
67 COMPAT_ALTERA_SOCFPGA_DWC2USB,
68 node, 2);
69 if (count <= 0) /* No controller found. */
70 return 0;
71
72 addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
73 if (addr == FDT_ADDR_T_NONE) {
74 printf("UDC Controller has no 'reg' property!\n");
75 return -EINVAL;
76 }
77
78 /* Patch the address from OF into the controller pdata. */
79 socfpga_otg_data.regs_otg = addr;
80
81 return dwc2_udc_probe(&socfpga_otg_data);
82}
83
84int g_dnl_board_usb_cable_connected(void)
85{
86 return 1;
87}
88#endif