board.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
  4. * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics.
  5. */
  6. #include <common.h>
  7. #include <linux/usb/otg.h>
  8. #include <dwc3-sti-glue.h>
  9. #include <dwc3-uboot.h>
  10. #include <usb.h>
  11. DECLARE_GLOBAL_DATA_PTR;
  12. int dram_init(void)
  13. {
  14. gd->ram_size = PHYS_SDRAM_1_SIZE;
  15. return 0;
  16. }
  17. int dram_init_banksize(void)
  18. {
  19. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  20. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  21. return 0;
  22. }
  23. #ifndef CONFIG_SYS_DCACHE_OFF
  24. void enable_caches(void)
  25. {
  26. /* Enable D-cache. I-cache is already enabled in start.S */
  27. dcache_enable();
  28. }
  29. #endif
  30. int board_init(void)
  31. {
  32. return 0;
  33. }
  34. #ifdef CONFIG_USB_DWC3
  35. static struct dwc3_device dwc3_device_data = {
  36. .maximum_speed = USB_SPEED_HIGH,
  37. .dr_mode = USB_DR_MODE_PERIPHERAL,
  38. .index = 0,
  39. };
  40. int usb_gadget_handle_interrupts(int index)
  41. {
  42. dwc3_uboot_handle_interrupt(index);
  43. return 0;
  44. }
  45. int board_usb_init(int index, enum usb_init_type init)
  46. {
  47. int node;
  48. const void *blob = gd->fdt_blob;
  49. /* find the snps,dwc3 node */
  50. node = fdt_node_offset_by_compatible(blob, -1, "snps,dwc3");
  51. dwc3_device_data.base = fdtdec_get_addr(blob, node, "reg");
  52. return dwc3_uboot_init(&dwc3_device_data);
  53. }
  54. int board_usb_cleanup(int index, enum usb_init_type init)
  55. {
  56. dwc3_uboot_exit(index);
  57. return 0;
  58. }
  59. int g_dnl_board_usb_cable_connected(void)
  60. {
  61. return 1;
  62. }
  63. #endif