1 --- a/arch/mips/pci/ifxmips_pcie.c
2 +++ b/arch/mips/pci/ifxmips_pcie.c
4 #include <linux/pci_regs.h>
5 #include <linux/module.h>
7 +#include <linux/of_gpio.h>
8 +#include <linux/of_platform.h>
10 #include "ifxmips_pcie.h"
11 #include "ifxmips_pcie_reg.h"
14 static DEFINE_SPINLOCK(ifx_pcie_lock);
16 u32 g_pcie_debug_flag = PCIE_MSG_ANY & (~PCIE_MSG_CFG);
17 +static int pcie_reset_gpio;
19 static ifx_pcie_irq_t pcie_irqs[IFX_PCIE_CORE_NR] = {
21 @@ -82,6 +86,22 @@ void ifx_pcie_debug(const char *fmt, ...
25 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
27 + gpio_direction_output(pcie_reset_gpio, 1);
28 + gpio_set_value(pcie_reset_gpio, 1);
31 +static inline void pcie_device_rst_assert(int pcie_port)
33 + gpio_set_value(pcie_reset_gpio, 0);
36 +static inline void pcie_device_rst_deassert(int pcie_port)
39 + gpio_direction_output(pcie_reset_gpio, 1);
42 static inline int pcie_ltssm_enable(int pcie_port)
44 @@ -1045,17 +1065,52 @@ pcie_rc_initialize(int pcie_port)
48 -static int __init ifx_pcie_bios_init(void)
49 +static int ifx_pcie_bios_probe(struct platform_device *pdev)
51 + struct device_node *node = pdev->dev.of_node;
52 void __iomem *io_map_base;
56 + struct device_node *np;
57 + struct pci_bus *bus;
60 + * In case a PCI device is physical present, the Lantiq PCI driver need
61 + * to be loaded prior to the Lantiq PCIe driver. Otherwise none of them
64 + * In case the lantiq PCI driver is enabled in the device tree, check if
65 + * a PCI bus (hopefully the one of the Lantiq PCI driver one) is already
68 + * It will fail if there is another PCI controller, this controller is
69 + * registered before the Lantiq PCIe driver is probe and the lantiq PCI
71 + np = of_find_compatible_node(NULL, NULL, "lantiq,pci-xway");
73 + if (of_device_is_available(np)) {
74 + bus = pci_find_next_bus(bus);
77 + return -EPROBE_DEFER;
80 /* Enable AHB Master/ Slave */
83 startup_port = IFX_PCIE_PORT0;
86 + pcie_reset_gpio = of_get_named_gpio(node, "gpio-reset", 0);
87 + if (gpio_is_valid(pcie_reset_gpio)) {
88 + int ret = devm_gpio_request(&pdev->dev, pcie_reset_gpio, "pcie-reset");
90 + dev_err(&pdev->dev, "failed to request gpio %d\n", pcie_reset_gpio);
93 + gpio_direction_output(pcie_reset_gpio, 1);
96 for (pcie_port = startup_port; pcie_port < IFX_PCIE_CORE_NR; pcie_port++){
97 if (pcie_rc_initialize(pcie_port) == 0) {
98 IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: ifx_pcie_cfg_base 0x%p\n",
99 @@ -1067,6 +1122,7 @@ static int __init ifx_pcie_bios_init(voi
102 ifx_pcie_controller[pcie_port].pcic.io_map_base = (unsigned long)io_map_base;
103 + pci_load_of_ranges(&ifx_pcie_controller[pcie_port].pcic, node);
105 register_pci_controller(&ifx_pcie_controller[pcie_port].pcic);
106 /* XXX, clear error status */
107 @@ -1083,6 +1139,30 @@ static int __init ifx_pcie_bios_init(voi
112 +static const struct of_device_id ifxmips_pcie_match[] = {
113 + { .compatible = "lantiq,pcie-xrx200" },
116 +MODULE_DEVICE_TABLE(of, ifxmips_pcie_match);
118 +static struct platform_driver ltq_pci_driver = {
119 + .probe = ifx_pcie_bios_probe,
121 + .name = "pcie-xrx200",
122 + .owner = THIS_MODULE,
123 + .of_match_table = ifxmips_pcie_match,
127 +int __init ifx_pcie_bios_init(void)
129 + int ret = platform_driver_register(<q_pci_driver);
131 + pr_info("pcie-xrx200: Error registering platform driver!");
135 arch_initcall(ifx_pcie_bios_init);
137 MODULE_LICENSE("GPL");
138 --- a/arch/mips/pci/ifxmips_pcie_vr9.h
139 +++ b/arch/mips/pci/ifxmips_pcie_vr9.h
141 #include <linux/gpio.h>
142 #include <lantiq_soc.h>
144 -#define IFX_PCIE_GPIO_RESET 494
146 #define IFX_REG_R32 ltq_r32
147 #define IFX_REG_W32 ltq_w32
148 #define CONFIG_IFX_PCIE_HW_SWAP
150 #define OUT ((volatile u32*)(IFX_GPIO + 0x0070))
153 -static inline void pcie_ep_gpio_rst_init(int pcie_port)
156 - gpio_request(IFX_PCIE_GPIO_RESET, "pcie-reset");
157 - gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
158 - gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
160 -/* ifx_gpio_pin_reserve(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
161 - ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
162 - ifx_gpio_dir_out_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
163 - ifx_gpio_altsel0_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
164 - ifx_gpio_altsel1_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
165 - ifx_gpio_open_drain_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);*/
168 static inline void pcie_ahb_pmu_setup(void)
170 /* Enable AHB bus master/slave */
171 @@ -180,20 +163,6 @@ static inline void pcie_phy_rst_deassert
172 IFX_REG_W32(reg, IFX_RCU_RST_REQ);
175 -static inline void pcie_device_rst_assert(int pcie_port)
177 - gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
178 -// ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
181 -static inline void pcie_device_rst_deassert(int pcie_port)
184 - gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
185 -// gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
186 - //ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
189 static inline void pcie_core_pmu_setup(int pcie_port)