1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2013 Keymile AG
4 * Valentin Longchamp <valentin.longchamp@keymile.com>
6 * Copyright 2007-2011 Freescale Semiconductor, Inc.
13 #include <asm/fsl_pci.h>
14 #include <linux/libfdt.h>
15 #include <fdt_support.h>
16 #include <asm/fsl_serdes.h>
17 #include <linux/errno.h>
19 #include "../common/qrio.h"
23 /* control the PROM_SEL_L signal*/
24 static void toggle_fpga_eeprom_bus(bool cpu_own)
26 qrio_gpio_direction_output(QRIO_GPIO_A, PROM_SEL_L, !cpu_own);
30 #define FPGA_PROG_L 19
32 #define FPGA_INIT_L 17
34 int trigger_fpga_config(void)
40 /* make sure the FPGA_can access the EEPROM */
41 toggle_fpga_eeprom_bus(false);
43 /* assert CONF_SEL_L to be able to drive FPGA_PROG_L */
44 qrio_gpio_direction_output(QRIO_GPIO_A, CONF_SEL_L, 0);
46 /* trigger the config start */
47 qrio_gpio_direction_output(QRIO_GPIO_A, FPGA_PROG_L, 0);
49 /* small delay for INIT_L line */
52 /* wait for FPGA_INIT to be asserted */
54 init_l = qrio_get_gpio(QRIO_GPIO_A, FPGA_INIT_L);
56 printf("FPGA_INIT timeout\n");
63 /* deassert FPGA_PROG, config should start */
64 qrio_set_gpio(QRIO_GPIO_A, FPGA_PROG_L, 1);
69 /* poll the FPGA_DONE signal and give the EEPROM back to the QorIQ */
70 static int wait_for_fpga_config(void)
76 printf("PCIe FPGA config:");
78 done = qrio_get_gpio(QRIO_GPIO_A, FPGA_DONE);
80 printf(" FPGA_DONE timeout\n");
90 /* deactive CONF_SEL and give the CPU conf EEPROM access */
91 qrio_set_gpio(QRIO_GPIO_A, CONF_SEL_L, 1);
92 toggle_fpga_eeprom_bus(true);
97 #define PCIE_SW_RST 14
101 void pci_init_board(void)
103 qrio_prstcfg(PCIE_SW_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
104 qrio_prstcfg(PEXHC_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
105 qrio_prstcfg(HOOPER_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
107 /* wait for the PCIe FPGA to be configured
108 * it has been triggered earlier in board_early_init_r */
109 if (wait_for_fpga_config())
110 printf("error finishing PCIe FPGA config\n");
112 qrio_prst(PCIE_SW_RST, false, false);
113 qrio_prst(PEXHC_RST, false, false);
114 qrio_prst(HOOPER_RST, false, false);
115 /* Hooper is not direcly PCIe capable */
118 fsl_pcie_init_board(0);
121 void pci_of_setup(void *blob, bd_t *bd)