board.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 <cpu_func.h>
  8. #include <linux/usb/otg.h>
  9. #include <dwc3-sti-glue.h>
  10. #include <dwc3-uboot.h>
  11. #include <usb.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. int dram_init(void)
  14. {
  15. gd->ram_size = PHYS_SDRAM_1_SIZE;
  16. return 0;
  17. }
  18. int dram_init_banksize(void)
  19. {
  20. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  21. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  22. return 0;
  23. }
  24. #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
  25. void enable_caches(void)
  26. {
  27. /* Enable D-cache. I-cache is already enabled in start.S */
  28. dcache_enable();
  29. }
  30. #endif
  31. int board_init(void)
  32. {
  33. return 0;
  34. }
  35. #ifdef CONFIG_USB_DWC3
  36. static struct dwc3_device dwc3_device_data = {
  37. .maximum_speed = USB_SPEED_HIGH,
  38. .dr_mode = USB_DR_MODE_PERIPHERAL,
  39. .index = 0,
  40. };
  41. int usb_gadget_handle_interrupts(int index)
  42. {
  43. dwc3_uboot_handle_interrupt(index);
  44. return 0;
  45. }
  46. int board_usb_init(int index, enum usb_init_type init)
  47. {
  48. int node;
  49. const void *blob = gd->fdt_blob;
  50. /* find the snps,dwc3 node */
  51. node = fdt_node_offset_by_compatible(blob, -1, "snps,dwc3");
  52. dwc3_device_data.base = fdtdec_get_addr(blob, node, "reg");
  53. return dwc3_uboot_init(&dwc3_device_data);
  54. }
  55. int board_usb_cleanup(int index, enum usb_init_type init)
  56. {
  57. dwc3_uboot_exit(index);
  58. return 0;
  59. }
  60. int g_dnl_board_usb_cable_connected(void)
  61. {
  62. return 1;
  63. }
  64. #endif