board.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /*
  19. * Miscellaneous platform dependent initialisations
  20. */
  21. int board_init(void)
  22. {
  23. /* Address of boot parameters for ATAG (if ATAG is used) */
  24. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  25. #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
  26. /* configuring the clock based on handoff */
  27. cm_basic_init(gd->fdt_blob);
  28. /* Add device descriptor to FPGA device table */
  29. socfpga_fpga_add();
  30. #endif
  31. return 0;
  32. }
  33. int dram_init_banksize(void)
  34. {
  35. fdtdec_setup_memory_banksize();
  36. return 0;
  37. }
  38. #ifdef CONFIG_USB_GADGET
  39. struct dwc2_plat_otg_data socfpga_otg_data = {
  40. .usb_gusbcfg = 0x1417,
  41. };
  42. int board_usb_init(int index, enum usb_init_type init)
  43. {
  44. int node[2], count;
  45. fdt_addr_t addr;
  46. count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
  47. COMPAT_ALTERA_SOCFPGA_DWC2USB,
  48. node, 2);
  49. if (count <= 0) /* No controller found. */
  50. return 0;
  51. addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
  52. if (addr == FDT_ADDR_T_NONE) {
  53. printf("UDC Controller has no 'reg' property!\n");
  54. return -EINVAL;
  55. }
  56. /* Patch the address from OF into the controller pdata. */
  57. socfpga_otg_data.regs_otg = addr;
  58. return dwc2_udc_probe(&socfpga_otg_data);
  59. }
  60. int g_dnl_board_usb_cable_connected(void)
  61. {
  62. return 1;
  63. }
  64. #endif