evb-rk3328.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2016 Rockchip Electronics Co., Ltd
  4. */
  5. #include <common.h>
  6. #include <asm/armv8/mmu.h>
  7. #include <dwc3-uboot.h>
  8. #include <power/regulator.h>
  9. #include <usb.h>
  10. DECLARE_GLOBAL_DATA_PTR;
  11. int board_init(void)
  12. {
  13. int ret;
  14. ret = regulators_enable_boot_on(false);
  15. if (ret)
  16. debug("%s: Cannot enable boot on regulator\n", __func__);
  17. return ret;
  18. }
  19. #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
  20. #include <usb.h>
  21. #include <usb/dwc2_udc.h>
  22. static struct dwc2_plat_otg_data rk3328_otg_data = {
  23. .rx_fifo_sz = 512,
  24. .np_tx_fifo_sz = 16,
  25. .tx_fifo_sz = 128,
  26. };
  27. int board_usb_init(int index, enum usb_init_type init)
  28. {
  29. int node;
  30. const char *mode;
  31. bool matched = false;
  32. const void *blob = gd->fdt_blob;
  33. /* find the usb_otg node */
  34. node = fdt_node_offset_by_compatible(blob, -1,
  35. "rockchip,rk3328-usb");
  36. while (node > 0) {
  37. mode = fdt_getprop(blob, node, "dr_mode", NULL);
  38. if (mode && strcmp(mode, "otg") == 0) {
  39. matched = true;
  40. break;
  41. }
  42. node = fdt_node_offset_by_compatible(blob, node,
  43. "rockchip,rk3328-usb");
  44. }
  45. if (!matched) {
  46. debug("Not found usb_otg device\n");
  47. return -ENODEV;
  48. }
  49. rk3328_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
  50. return dwc2_udc_probe(&rk3328_otg_data);
  51. }
  52. int board_usb_cleanup(int index, enum usb_init_type init)
  53. {
  54. return 0;
  55. }
  56. #endif