board.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 <init.h>
  11. #include <asm/arch/reset_manager.h>
  12. #include <asm/arch/clock_manager.h>
  13. #include <asm/arch/misc.h>
  14. #include <asm/io.h>
  15. #include <log.h>
  16. #include <usb.h>
  17. #include <usb/dwc2_udc.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. void s_init(void) {
  20. #ifndef CONFIG_ARM64
  21. /*
  22. * Preconfigure ACTLR and CPACR, make sure Write Full Line of Zeroes
  23. * is disabled in ACTLR.
  24. * This is optional on CycloneV / ArriaV.
  25. * This is mandatory on Arria10, otherwise Linux refuses to boot.
  26. */
  27. asm volatile(
  28. "mcr p15, 0, %0, c1, c0, 1\n"
  29. "mcr p15, 0, %0, c1, c0, 2\n"
  30. "isb\n"
  31. "dsb\n"
  32. ::"r"(0x0));
  33. #endif
  34. }
  35. /*
  36. * Miscellaneous platform dependent initialisations
  37. */
  38. int board_init(void)
  39. {
  40. /* Address of boot parameters for ATAG (if ATAG is used) */
  41. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  42. return 0;
  43. }
  44. int dram_init_banksize(void)
  45. {
  46. fdtdec_setup_memory_banksize();
  47. return 0;
  48. }
  49. #ifdef CONFIG_USB_GADGET
  50. struct dwc2_plat_otg_data socfpga_otg_data = {
  51. .usb_gusbcfg = 0x1417,
  52. };
  53. int board_usb_init(int index, enum usb_init_type init)
  54. {
  55. int node[2], count;
  56. fdt_addr_t addr;
  57. count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
  58. COMPAT_ALTERA_SOCFPGA_DWC2USB,
  59. node, 2);
  60. if (count <= 0) /* No controller found. */
  61. return 0;
  62. addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
  63. if (addr == FDT_ADDR_T_NONE) {
  64. printf("UDC Controller has no 'reg' property!\n");
  65. return -EINVAL;
  66. }
  67. /* Patch the address from OF into the controller pdata. */
  68. socfpga_otg_data.regs_otg = addr;
  69. return dwc2_udc_probe(&socfpga_otg_data);
  70. }
  71. int g_dnl_board_usb_cable_connected(void)
  72. {
  73. return 1;
  74. }
  75. #endif
  76. #ifdef CONFIG_SPL_BUILD
  77. __weak int board_fit_config_name_match(const char *name)
  78. {
  79. /* Just empty function now - can't decide what to choose */
  80. debug("%s: %s\n", __func__, name);
  81. return 0;
  82. }
  83. #endif