board.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 <asm/arch/reset_manager.h>
  10. #include <asm/io.h>
  11. #include <usb.h>
  12. #include <usb/dwc2_udc.h>
  13. DECLARE_GLOBAL_DATA_PTR;
  14. void s_init(void) {}
  15. /*
  16. * Miscellaneous platform dependent initialisations
  17. */
  18. int board_init(void)
  19. {
  20. /* Address of boot parameters for ATAG (if ATAG is used) */
  21. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  22. return 0;
  23. }
  24. int dram_init_banksize(void)
  25. {
  26. fdtdec_setup_memory_banksize();
  27. return 0;
  28. }
  29. #ifdef CONFIG_USB_GADGET
  30. struct dwc2_plat_otg_data socfpga_otg_data = {
  31. .usb_gusbcfg = 0x1417,
  32. };
  33. int board_usb_init(int index, enum usb_init_type init)
  34. {
  35. int node[2], count;
  36. fdt_addr_t addr;
  37. count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
  38. COMPAT_ALTERA_SOCFPGA_DWC2USB,
  39. node, 2);
  40. if (count <= 0) /* No controller found. */
  41. return 0;
  42. addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
  43. if (addr == FDT_ADDR_T_NONE) {
  44. printf("UDC Controller has no 'reg' property!\n");
  45. return -EINVAL;
  46. }
  47. /* Patch the address from OF into the controller pdata. */
  48. socfpga_otg_data.regs_otg = addr;
  49. return dwc2_udc_probe(&socfpga_otg_data);
  50. }
  51. int g_dnl_board_usb_cable_connected(void)
  52. {
  53. return 1;
  54. }
  55. #endif