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.
12 #include <asm/fsl_pci.h>
13 #include <linux/libfdt.h>
14 #include <fdt_support.h>
15 #include <asm/fsl_serdes.h>
16 #include <linux/errno.h>
21 /* control the PROM_SEL_L signal*/
22 static void toggle_fpga_eeprom_bus(bool cpu_own)
24 qrio_gpio_direction_output(GPIO_A, PROM_SEL_L, !cpu_own);
28 #define FPGA_PROG_L 19
30 #define FPGA_INIT_L 17
32 int trigger_fpga_config(void)
38 /* make sure the FPGA_can access the EEPROM */
39 toggle_fpga_eeprom_bus(false);
41 /* assert CONF_SEL_L to be able to drive FPGA_PROG_L */
42 qrio_gpio_direction_output(GPIO_A, CONF_SEL_L, 0);
44 /* trigger the config start */
45 qrio_gpio_direction_output(GPIO_A, FPGA_PROG_L, 0);
47 /* small delay for INIT_L line */
50 /* wait for FPGA_INIT to be asserted */
52 init_l = qrio_get_gpio(GPIO_A, FPGA_INIT_L);
54 printf("FPGA_INIT timeout\n");
61 /* deassert FPGA_PROG, config should start */
62 qrio_set_gpio(GPIO_A, FPGA_PROG_L, 1);
67 /* poll the FPGA_DONE signal and give the EEPROM back to the QorIQ */
68 static int wait_for_fpga_config(void)
74 printf("PCIe FPGA config:");
76 done = qrio_get_gpio(GPIO_A, FPGA_DONE);
78 printf(" FPGA_DONE timeout\n");
88 /* deactive CONF_SEL and give the CPU conf EEPROM access */
89 qrio_set_gpio(GPIO_A, CONF_SEL_L, 1);
90 toggle_fpga_eeprom_bus(true);
95 #define PCIE_SW_RST 14
99 void pci_init_board(void)
101 qrio_prstcfg(PCIE_SW_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
102 qrio_prstcfg(PEXHC_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
103 qrio_prstcfg(HOOPER_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
105 /* wait for the PCIe FPGA to be configured
106 * it has been triggered earlier in board_early_init_r */
107 if (wait_for_fpga_config())
108 printf("error finishing PCIe FPGA config\n");
110 qrio_prst(PCIE_SW_RST, false, false);
111 qrio_prst(PEXHC_RST, false, false);
112 qrio_prst(HOOPER_RST, false, false);
113 /* Hooper is not direcly PCIe capable */
116 fsl_pcie_init_board(0);
119 void pci_of_setup(void *blob, bd_t *bd)