board.c 1.8 KB

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