zynqmp.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * (C) Copyright 2014 - 2015 Xilinx, Inc.
  3. * Michal Simek <michal.simek@xilinx.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <netdev.h>
  9. #include <ahci.h>
  10. #include <scsi.h>
  11. #include <asm/arch/hardware.h>
  12. #include <asm/arch/sys_proto.h>
  13. #include <asm/io.h>
  14. #include <usb.h>
  15. #include <dwc3-uboot.h>
  16. DECLARE_GLOBAL_DATA_PTR;
  17. int board_init(void)
  18. {
  19. printf("EL Level:\tEL%d\n", current_el());
  20. return 0;
  21. }
  22. int board_early_init_r(void)
  23. {
  24. u32 val;
  25. val = readl(&crlapb_base->timestamp_ref_ctrl);
  26. val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT;
  27. writel(val, &crlapb_base->timestamp_ref_ctrl);
  28. /* Program freq register in System counter and enable system counter */
  29. writel(gd->cpu_clk, &iou_scntr->base_frequency_id_register);
  30. writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_HDBG |
  31. ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN,
  32. &iou_scntr->counter_control_register);
  33. return 0;
  34. }
  35. int dram_init(void)
  36. {
  37. gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
  38. return 0;
  39. }
  40. int timer_init(void)
  41. {
  42. return 0;
  43. }
  44. void reset_cpu(ulong addr)
  45. {
  46. }
  47. #ifdef CONFIG_SCSI_AHCI_PLAT
  48. void scsi_init(void)
  49. {
  50. ahci_init((void __iomem *)ZYNQMP_SATA_BASEADDR);
  51. scsi_scan(1);
  52. }
  53. #endif
  54. int board_late_init(void)
  55. {
  56. u32 reg = 0;
  57. u8 bootmode;
  58. reg = readl(&crlapb_base->boot_mode);
  59. bootmode = reg & BOOT_MODES_MASK;
  60. switch (bootmode) {
  61. case SD_MODE:
  62. case EMMC_MODE:
  63. setenv("modeboot", "sdboot");
  64. break;
  65. default:
  66. printf("Invalid Boot Mode:0x%x\n", bootmode);
  67. break;
  68. }
  69. return 0;
  70. }
  71. int checkboard(void)
  72. {
  73. puts("Board:\tXilinx ZynqMP\n");
  74. return 0;
  75. }
  76. #ifdef CONFIG_USB_DWC3
  77. static struct dwc3_device dwc3_device_data = {
  78. .maximum_speed = USB_SPEED_HIGH,
  79. .base = ZYNQMP_USB0_XHCI_BASEADDR,
  80. .dr_mode = USB_DR_MODE_PERIPHERAL,
  81. .index = 0,
  82. };
  83. int usb_gadget_handle_interrupts(void)
  84. {
  85. dwc3_uboot_handle_interrupt(0);
  86. return 0;
  87. }
  88. int board_usb_init(int index, enum usb_init_type init)
  89. {
  90. return dwc3_uboot_init(&dwc3_device_data);
  91. }
  92. int board_usb_cleanup(int index, enum usb_init_type init)
  93. {
  94. dwc3_uboot_exit(index);
  95. return 0;
  96. }
  97. #endif