2 * (C) Copyright 2013 Keymile AG
3 * Valentin Longchamp <valentin.longchamp@keymile.com>
5 * Copyright 2007-2011 Freescale Semiconductor, Inc.
7 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/fsl_pci.h>
15 #include <fdt_support.h>
16 #include <asm/fsl_serdes.h>
17 #include <asm/errno.h>
22 /* control the PROM_SEL_L signal*/
23 static void toggle_fpga_eeprom_bus(bool cpu_own)
25 qrio_gpio_direction_output(GPIO_A, PROM_SEL_L, !cpu_own);
29 #define FPGA_PROG_L 19
31 #define FPGA_INIT_L 17
33 int trigger_fpga_config(void)
39 /* make sure the FPGA_can access the EEPROM */
40 toggle_fpga_eeprom_bus(false);
42 /* assert CONF_SEL_L to be able to drive FPGA_PROG_L */
43 qrio_gpio_direction_output(GPIO_A, CONF_SEL_L, 0);
45 /* trigger the config start */
46 qrio_gpio_direction_output(GPIO_A, FPGA_PROG_L, 0);
48 /* small delay for INIT_L line */
51 /* wait for FPGA_INIT to be asserted */
53 init_l = qrio_get_gpio(GPIO_A, FPGA_INIT_L);
55 printf("FPGA_INIT timeout\n");
62 /* deassert FPGA_PROG, config should start */
63 qrio_set_gpio(GPIO_A, FPGA_PROG_L, 1);
68 /* poll the FPGA_DONE signal and give the EEPROM back to the QorIQ */
69 static int wait_for_fpga_config(void)
75 printf("PCIe FPGA config:");
77 done = qrio_get_gpio(GPIO_A, FPGA_DONE);
79 printf(" FPGA_DONE timeout\n");
89 /* deactive CONF_SEL and give the CPU conf EEPROM access */
90 qrio_set_gpio(GPIO_A, CONF_SEL_L, 1);
91 toggle_fpga_eeprom_bus(true);
96 #define PCIE_SW_RST 14
100 void pci_init_board(void)
102 qrio_prstcfg(PCIE_SW_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
103 qrio_prstcfg(PEXHC_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
104 qrio_prstcfg(HOOPER_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
106 /* wait for the PCIe FPGA to be configured
107 * it has been triggered earlier in board_early_init_r */
108 if (wait_for_fpga_config())
109 printf("error finishing PCIe FPGA config\n");
111 qrio_prst(PCIE_SW_RST, false, false);
112 qrio_prst(PEXHC_RST, false, false);
113 qrio_prst(HOOPER_RST, false, false);
114 /* Hooper is not direcly PCIe capable */
117 fsl_pcie_init_board(0);
120 void pci_of_setup(void *blob, bd_t *bd)