board.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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, make sure Write Full Line of Zeroes is disabled.
  21. * This is optional on CycloneV / ArriaV.
  22. * This is mandatory on Arria10, otherwise Linux refuses to boot.
  23. */
  24. asm volatile(
  25. "mcr p15, 0, %0, c1, c0, 1\n"
  26. "isb\n"
  27. "dsb\n"
  28. ::"r"(0x0));
  29. #endif
  30. }
  31. /*
  32. * Miscellaneous platform dependent initialisations
  33. */
  34. int board_init(void)
  35. {
  36. /* Address of boot parameters for ATAG (if ATAG is used) */
  37. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  38. #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
  39. /* configuring the clock based on handoff */
  40. cm_basic_init(gd->fdt_blob);
  41. /* Add device descriptor to FPGA device table */
  42. socfpga_fpga_add();
  43. #endif
  44. return 0;
  45. }
  46. int dram_init_banksize(void)
  47. {
  48. fdtdec_setup_memory_banksize();
  49. return 0;
  50. }
  51. #ifdef CONFIG_USB_GADGET
  52. struct dwc2_plat_otg_data socfpga_otg_data = {
  53. .usb_gusbcfg = 0x1417,
  54. };
  55. int board_usb_init(int index, enum usb_init_type init)
  56. {
  57. int node[2], count;
  58. fdt_addr_t addr;
  59. count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
  60. COMPAT_ALTERA_SOCFPGA_DWC2USB,
  61. node, 2);
  62. if (count <= 0) /* No controller found. */
  63. return 0;
  64. addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
  65. if (addr == FDT_ADDR_T_NONE) {
  66. printf("UDC Controller has no 'reg' property!\n");
  67. return -EINVAL;
  68. }
  69. /* Patch the address from OF into the controller pdata. */
  70. socfpga_otg_data.regs_otg = addr;
  71. return dwc2_udc_probe(&socfpga_otg_data);
  72. }
  73. int g_dnl_board_usb_cable_connected(void)
  74. {
  75. return 1;
  76. }
  77. #endif