board.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Altera SoCFPGA common board code
  3. *
  4. * Copyright (C) 2015 Marek Vasut <marex@denx.de>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <errno.h>
  10. #include <asm/arch/reset_manager.h>
  11. #include <asm/io.h>
  12. #include <usb.h>
  13. #include <usb/dwc2_udc.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. void s_init(void) {}
  16. /*
  17. * Miscellaneous platform dependent initialisations
  18. */
  19. int board_init(void)
  20. {
  21. /* Address of boot parameters for ATAG (if ATAG is used) */
  22. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  23. return 0;
  24. }
  25. #ifdef CONFIG_USB_GADGET
  26. struct dwc2_plat_otg_data socfpga_otg_data = {
  27. .usb_gusbcfg = 0x1417,
  28. };
  29. int board_usb_init(int index, enum usb_init_type init)
  30. {
  31. int node[2], count;
  32. fdt_addr_t addr;
  33. count = fdtdec_find_aliases_for_id(gd->fdt_blob, "udc",
  34. COMPAT_ALTERA_SOCFPGA_DWC2USB,
  35. node, 2);
  36. if (count <= 0) /* No controller found. */
  37. return 0;
  38. addr = fdtdec_get_addr(gd->fdt_blob, node[0], "reg");
  39. if (addr == FDT_ADDR_T_NONE) {
  40. printf("UDC Controller has no 'reg' property!\n");
  41. return -EINVAL;
  42. }
  43. /* Patch the address from OF into the controller pdata. */
  44. socfpga_otg_data.regs_otg = addr;
  45. return dwc2_udc_probe(&socfpga_otg_data);
  46. }
  47. int g_dnl_board_usb_cable_connected(void)
  48. {
  49. return 1;
  50. }
  51. #endif