board.c 1.5 KB

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