board.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Altera SoCFPGA common board code
  4. *
  5. * Copyright (C) 2015 Marek Vasut <marex@denx.de>
  6. */
  7. #include <common.h>
  8. #include <errno.h>
  9. #include <fdtdec.h>
  10. #include <asm/arch/reset_manager.h>
  11. #include <asm/arch/clock_manager.h>
  12. #include <asm/arch/misc.h>
  13. #include <asm/io.h>
  14. #include <usb.h>
  15. #include <usb/dwc2_udc.h>
  16. DECLARE_GLOBAL_DATA_PTR;
  17. void s_init(void) {
  18. #ifndef CONFIG_ARM64
  19. /*
  20. * Preconfigure ACTLR and CPACR, make sure Write Full Line of Zeroes
  21. * is disabled in ACTLR.
  22. * This is optional on CycloneV / ArriaV.
  23. * This is mandatory on Arria10, otherwise Linux refuses to boot.
  24. */
  25. asm volatile(
  26. "mcr p15, 0, %0, c1, c0, 1\n"
  27. "mcr p15, 0, %0, c1, c0, 2\n"
  28. "isb\n"
  29. "dsb\n"
  30. ::"r"(0x0));
  31. #endif
  32. }
  33. /*
  34. * Miscellaneous platform dependent initialisations
  35. */
  36. int board_init(void)
  37. {
  38. /* Address of boot parameters for ATAG (if ATAG is used) */
  39. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  40. return 0;
  41. }
  42. int dram_init_banksize(void)
  43. {
  44. fdtdec_setup_memory_banksize();
  45. return 0;
  46. }
  47. #ifdef CONFIG_USB_GADGET
  48. struct dwc2_plat_otg_data socfpga_otg_data = {
  49. .usb_gusbcfg = 0x1417,
  50. };
  51. int board_usb_init(int index, enum usb_init_type init)
  52. {
  53. int node[2], count;
  54. fdt_addr_t addr;
  55. count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
  56. COMPAT_ALTERA_SOCFPGA_DWC2USB,
  57. node, 2);
  58. if (count <= 0) /* No controller found. */
  59. return 0;
  60. addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
  61. if (addr == FDT_ADDR_T_NONE) {
  62. printf("UDC Controller has no 'reg' property!\n");
  63. return -EINVAL;
  64. }
  65. /* Patch the address from OF into the controller pdata. */
  66. socfpga_otg_data.regs_otg = addr;
  67. return dwc2_udc_probe(&socfpga_otg_data);
  68. }
  69. int g_dnl_board_usb_cable_connected(void)
  70. {
  71. return 1;
  72. }
  73. #endif