rk3036-board.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2015 Rockchip Electronics Co., Ltd
  4. */
  5. #include <common.h>
  6. #include <clk.h>
  7. #include <dm.h>
  8. #include <ram.h>
  9. #include <asm/gpio.h>
  10. #include <asm/io.h>
  11. #include <asm/arch-rockchip/clock.h>
  12. #include <asm/arch-rockchip/periph.h>
  13. #include <asm/arch-rockchip/grf_rk3036.h>
  14. #include <asm/arch-rockchip/boot_mode.h>
  15. #include <asm/arch-rockchip/sdram_rk3036.h>
  16. #include <dm/pinctrl.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. __weak int rk_board_late_init(void)
  19. {
  20. return 0;
  21. }
  22. int board_late_init(void)
  23. {
  24. setup_boot_mode();
  25. return rk_board_late_init();
  26. }
  27. int board_init(void)
  28. {
  29. return 0;
  30. }
  31. #if !CONFIG_IS_ENABLED(RAM)
  32. /*
  33. * When CONFIG_RAM is enabled, the dram_init() function is implemented
  34. * in sdram_common.c.
  35. */
  36. int dram_init(void)
  37. {
  38. gd->ram_size = sdram_size();
  39. return 0;
  40. }
  41. #endif
  42. #ifndef CONFIG_SYS_DCACHE_OFF
  43. void enable_caches(void)
  44. {
  45. /* Enable D-cache. I-cache is already enabled in start.S */
  46. dcache_enable();
  47. }
  48. #endif
  49. #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
  50. #include <usb.h>
  51. #include <usb/dwc2_udc.h>
  52. static struct dwc2_plat_otg_data rk3036_otg_data = {
  53. .rx_fifo_sz = 512,
  54. .np_tx_fifo_sz = 16,
  55. .tx_fifo_sz = 128,
  56. };
  57. int board_usb_init(int index, enum usb_init_type init)
  58. {
  59. int node;
  60. const char *mode;
  61. bool matched = false;
  62. const void *blob = gd->fdt_blob;
  63. /* find the usb_otg node */
  64. node = fdt_node_offset_by_compatible(blob, -1,
  65. "rockchip,rk3288-usb");
  66. while (node > 0) {
  67. mode = fdt_getprop(blob, node, "dr_mode", NULL);
  68. if (mode && strcmp(mode, "otg") == 0) {
  69. matched = true;
  70. break;
  71. }
  72. node = fdt_node_offset_by_compatible(blob, node,
  73. "rockchip,rk3288-usb");
  74. }
  75. if (!matched) {
  76. debug("Not found usb_otg device\n");
  77. return -ENODEV;
  78. }
  79. rk3036_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
  80. return dwc2_udc_probe(&rk3036_otg_data);
  81. }
  82. int board_usb_cleanup(int index, enum usb_init_type init)
  83. {
  84. return 0;
  85. }
  86. #endif