board.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifdef CONFIG_USB_GADGET
  25. struct dwc2_plat_otg_data socfpga_otg_data = {
  26. .usb_gusbcfg = 0x1417,
  27. };
  28. int board_usb_init(int index, enum usb_init_type init)
  29. {
  30. int node[2], count;
  31. fdt_addr_t addr;
  32. count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
  33. COMPAT_ALTERA_SOCFPGA_DWC2USB,
  34. node, 2);
  35. if (count <= 0) /* No controller found. */
  36. return 0;
  37. addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
  38. if (addr == FDT_ADDR_T_NONE) {
  39. printf("UDC Controller has no 'reg' property!\n");
  40. return -EINVAL;
  41. }
  42. /* Patch the address from OF into the controller pdata. */
  43. socfpga_otg_data.regs_otg = addr;
  44. return dwc2_udc_probe(&socfpga_otg_data);
  45. }
  46. int g_dnl_board_usb_cable_connected(void)
  47. {
  48. return 1;
  49. }
  50. #endif