board.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
  41. /* configuring the clock based on handoff */
  42. cm_basic_init(gd->fdt_blob);
  43. /* Add device descriptor to FPGA device table */
  44. socfpga_fpga_add();
  45. #endif
  46. return 0;
  47. }
  48. int dram_init_banksize(void)
  49. {
  50. fdtdec_setup_memory_banksize();
  51. return 0;
  52. }
  53. #ifdef CONFIG_USB_GADGET
  54. struct dwc2_plat_otg_data socfpga_otg_data = {
  55. .usb_gusbcfg = 0x1417,
  56. };
  57. int board_usb_init(int index, enum usb_init_type init)
  58. {
  59. int node[2], count;
  60. fdt_addr_t addr;
  61. count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
  62. COMPAT_ALTERA_SOCFPGA_DWC2USB,
  63. node, 2);
  64. if (count <= 0) /* No controller found. */
  65. return 0;
  66. addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
  67. if (addr == FDT_ADDR_T_NONE) {
  68. printf("UDC Controller has no 'reg' property!\n");
  69. return -EINVAL;
  70. }
  71. /* Patch the address from OF into the controller pdata. */
  72. socfpga_otg_data.regs_otg = addr;
  73. return dwc2_udc_probe(&socfpga_otg_data);
  74. }
  75. int g_dnl_board_usb_cable_connected(void)
  76. {
  77. return 1;
  78. }
  79. #endif