Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 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 | |
| 8 | #include <common.h> |
| 9 | #include <netdev.h> |
Michal Simek | 6fe6f13 | 2015-07-23 13:27:40 +0200 | [diff] [blame] | 10 | #include <ahci.h> |
| 11 | #include <scsi.h> |
Michal Simek | 0785dfd | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 12 | #include <asm/arch/clk.h> |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 13 | #include <asm/arch/hardware.h> |
| 14 | #include <asm/arch/sys_proto.h> |
| 15 | #include <asm/io.h> |
Siva Durga Prasad Paladugu | 16fa00a | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 16 | #include <usb.h> |
| 17 | #include <dwc3-uboot.h> |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
| 21 | int board_init(void) |
| 22 | { |
Michal Simek | a0736ef | 2015-06-22 14:31:06 +0200 | [diff] [blame] | 23 | printf("EL Level:\tEL%d\n", current_el()); |
| 24 | |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 25 | return 0; |
| 26 | } |
| 27 | |
| 28 | int board_early_init_r(void) |
| 29 | { |
| 30 | u32 val; |
| 31 | |
Michal Simek | 0785dfd | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 32 | if (current_el() == 3) { |
| 33 | val = readl(&crlapb_base->timestamp_ref_ctrl); |
| 34 | val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; |
| 35 | writel(val, &crlapb_base->timestamp_ref_ctrl); |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 36 | |
Michal Simek | 0785dfd | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 37 | /* Program freq register in System counter */ |
| 38 | writel(zynqmp_get_system_timer_freq(), |
| 39 | &iou_scntr_secure->base_frequency_id_register); |
| 40 | /* And enable system counter */ |
| 41 | writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN, |
| 42 | &iou_scntr_secure->counter_control_register); |
| 43 | } |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 44 | /* Program freq register in System counter and enable system counter */ |
| 45 | writel(gd->cpu_clk, &iou_scntr->base_frequency_id_register); |
| 46 | writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_HDBG | |
| 47 | ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN, |
| 48 | &iou_scntr->counter_control_register); |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | int dram_init(void) |
| 54 | { |
| 55 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | int timer_init(void) |
| 61 | { |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | void reset_cpu(ulong addr) |
| 66 | { |
| 67 | } |
| 68 | |
Michal Simek | 6fe6f13 | 2015-07-23 13:27:40 +0200 | [diff] [blame] | 69 | #ifdef CONFIG_SCSI_AHCI_PLAT |
| 70 | void scsi_init(void) |
| 71 | { |
| 72 | ahci_init((void __iomem *)ZYNQMP_SATA_BASEADDR); |
| 73 | scsi_scan(1); |
| 74 | } |
| 75 | #endif |
| 76 | |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 77 | int board_late_init(void) |
| 78 | { |
| 79 | u32 reg = 0; |
| 80 | u8 bootmode; |
| 81 | |
| 82 | reg = readl(&crlapb_base->boot_mode); |
| 83 | bootmode = reg & BOOT_MODES_MASK; |
| 84 | |
| 85 | switch (bootmode) { |
Siva Durga Prasad Paladugu | 0a5bcc8 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 86 | case JTAG_MODE: |
| 87 | setenv("modeboot", "netboot"); |
| 88 | break; |
| 89 | case QSPI_MODE_24BIT: |
| 90 | case QSPI_MODE_32BIT: |
| 91 | setenv("modeboot", "qspiboot"); |
| 92 | break; |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 93 | case SD_MODE: |
Michal Simek | 39c56f5 | 2015-04-15 15:02:28 +0200 | [diff] [blame] | 94 | case EMMC_MODE: |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 95 | setenv("modeboot", "sdboot"); |
| 96 | break; |
Michal Simek | af813ac | 2015-10-05 10:51:12 +0200 | [diff] [blame^] | 97 | case SD_MODE1: |
| 98 | setenv("modeboot", "sdboot1"); |
| 99 | break; |
| 100 | case NAND_MODE: |
| 101 | setenv("modeboot", "nandboot"); |
| 102 | break; |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 103 | default: |
| 104 | printf("Invalid Boot Mode:0x%x\n", bootmode); |
| 105 | break; |
| 106 | } |
| 107 | |
| 108 | return 0; |
| 109 | } |
Siva Durga Prasad Paladugu | 84696ff | 2015-08-04 13:01:05 +0530 | [diff] [blame] | 110 | |
| 111 | int checkboard(void) |
| 112 | { |
| 113 | puts("Board:\tXilinx ZynqMP\n"); |
| 114 | return 0; |
| 115 | } |
Siva Durga Prasad Paladugu | 16fa00a | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 116 | |
| 117 | #ifdef CONFIG_USB_DWC3 |
| 118 | static struct dwc3_device dwc3_device_data = { |
| 119 | .maximum_speed = USB_SPEED_HIGH, |
| 120 | .base = ZYNQMP_USB0_XHCI_BASEADDR, |
| 121 | .dr_mode = USB_DR_MODE_PERIPHERAL, |
| 122 | .index = 0, |
| 123 | }; |
| 124 | |
| 125 | int usb_gadget_handle_interrupts(void) |
| 126 | { |
| 127 | dwc3_uboot_handle_interrupt(0); |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | int board_usb_init(int index, enum usb_init_type init) |
| 132 | { |
| 133 | return dwc3_uboot_init(&dwc3_device_data); |
| 134 | } |
| 135 | |
| 136 | int board_usb_cleanup(int index, enum usb_init_type init) |
| 137 | { |
| 138 | dwc3_uboot_exit(index); |
| 139 | return 0; |
| 140 | } |
| 141 | #endif |