1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2013 Keymile AG
6 * Copyright 2007-2011 Freescale Semiconductor, Inc.
13 #include <asm/fsl_pci.h>
14 #include <linux/delay.h>
15 #include <linux/libfdt.h>
16 #include <fdt_support.h>
17 #include <asm/fsl_serdes.h>
18 #include <linux/errno.h>
20 #include "../common/qrio.h"
24 /* control the PROM_SEL_L signal*/
25 static void toggle_fpga_eeprom_bus(bool cpu_own)
27 qrio_gpio_direction_output(QRIO_GPIO_A, PROM_SEL_L, !cpu_own);
31 #define FPGA_PROG_L 19
33 #define FPGA_INIT_L 17
35 int trigger_fpga_config(void)
41 /* make sure the FPGA_can access the EEPROM */
42 toggle_fpga_eeprom_bus(false);
44 /* assert CONF_SEL_L to be able to drive FPGA_PROG_L */
45 qrio_gpio_direction_output(QRIO_GPIO_A, CONF_SEL_L, 0);
47 /* trigger the config start */
48 qrio_gpio_direction_output(QRIO_GPIO_A, FPGA_PROG_L, 0);
50 /* small delay for INIT_L line */
53 /* wait for FPGA_INIT to be asserted */
55 init_l = qrio_get_gpio(QRIO_GPIO_A, FPGA_INIT_L);
57 printf("FPGA_INIT timeout\n");
64 /* deassert FPGA_PROG, config should start */
65 qrio_set_gpio(QRIO_GPIO_A, FPGA_PROG_L, 1);
70 /* poll the FPGA_DONE signal and give the EEPROM back to the QorIQ */
71 static int wait_for_fpga_config(void)
77 printf("PCIe FPGA config:");
79 done = qrio_get_gpio(QRIO_GPIO_A, FPGA_DONE);
81 printf(" FPGA_DONE timeout\n");
91 /* deactive CONF_SEL and give the CPU conf EEPROM access */
92 qrio_set_gpio(QRIO_GPIO_A, CONF_SEL_L, 1);
93 toggle_fpga_eeprom_bus(true);
98 #define PCIE_SW_RST 14
100 #define HOOPER_RST 12
102 void pci_init_board(void)
104 qrio_prstcfg(PCIE_SW_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
105 qrio_prstcfg(PEXHC_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
106 qrio_prstcfg(HOOPER_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
108 /* wait for the PCIe FPGA to be configured
109 * it has been triggered earlier in board_early_init_r */
110 if (wait_for_fpga_config())
111 printf("error finishing PCIe FPGA config\n");
113 qrio_prst(PCIE_SW_RST, false, false);
114 qrio_prst(PEXHC_RST, false, false);
115 qrio_prst(HOOPER_RST, false, false);
116 /* Hooper is not direcly PCIe capable */
119 fsl_pcie_init_board(0);
122 void pci_of_setup(void *blob, struct bd_info *bd)