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,8 +1065,9 @@ pcie_rc_initialize(int pcie_port)
48 -static int __init ifx_pcie_bios_init(void)
49 +static int __init ifx_pcie_bios_probe(struct platform_device *pdev)
51 + struct device_node *node = pdev->dev.of_node;
52 void __iomem *io_map_base;
55 @@ -1055,7 +1076,17 @@ static int __init ifx_pcie_bios_init(voi
58 startup_port = IFX_PCIE_PORT0;
61 + pcie_reset_gpio = of_get_named_gpio(node, "gpio-reset", 0);
62 + if (gpio_is_valid(pcie_reset_gpio)) {
63 + int ret = devm_gpio_request(&pdev->dev, pcie_reset_gpio, "pcie-reset");
65 + dev_err(&pdev->dev, "failed to request gpio %d\n", pcie_reset_gpio);
68 + gpio_direction_output(pcie_reset_gpio, 1);
71 for (pcie_port = startup_port; pcie_port < IFX_PCIE_CORE_NR; pcie_port++){
72 if (pcie_rc_initialize(pcie_port) == 0) {
73 IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: ifx_pcie_cfg_base 0x%p\n",
74 @@ -1067,6 +1098,7 @@ static int __init ifx_pcie_bios_init(voi
77 ifx_pcie_controller[pcie_port].pcic.io_map_base = (unsigned long)io_map_base;
78 + pci_load_of_ranges(&ifx_pcie_controller[pcie_port].pcic, node);
80 register_pci_controller(&ifx_pcie_controller[pcie_port].pcic);
81 /* XXX, clear error status */
82 @@ -1083,6 +1115,30 @@ static int __init ifx_pcie_bios_init(voi
87 +static const struct of_device_id ifxmips_pcie_match[] = {
88 + { .compatible = "lantiq,pcie-xrx200" },
91 +MODULE_DEVICE_TABLE(of, ifxmips_pcie_match);
93 +static struct platform_driver ltq_pci_driver = {
94 + .probe = ifx_pcie_bios_probe,
96 + .name = "pcie-xrx200",
97 + .owner = THIS_MODULE,
98 + .of_match_table = ifxmips_pcie_match,
102 +int __init ifx_pcie_bios_init(void)
104 + int ret = platform_driver_register(<q_pci_driver);
106 + pr_info("pcie-xrx200: Error registering platform driver!");
110 arch_initcall(ifx_pcie_bios_init);
112 MODULE_LICENSE("GPL");
113 --- a/arch/mips/pci/ifxmips_pcie_vr9.h
114 +++ b/arch/mips/pci/ifxmips_pcie_vr9.h
116 #include <linux/gpio.h>
117 #include <lantiq_soc.h>
119 -#define IFX_PCIE_GPIO_RESET 494
121 #define IFX_REG_R32 ltq_r32
122 #define IFX_REG_W32 ltq_w32
123 #define CONFIG_IFX_PCIE_HW_SWAP
125 #define OUT ((volatile u32*)(IFX_GPIO + 0x0070))
128 -static inline void pcie_ep_gpio_rst_init(int pcie_port)
131 - gpio_request(IFX_PCIE_GPIO_RESET, "pcie-reset");
132 - gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
133 - gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
135 -/* ifx_gpio_pin_reserve(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
136 - ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
137 - ifx_gpio_dir_out_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
138 - ifx_gpio_altsel0_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
139 - ifx_gpio_altsel1_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
140 - ifx_gpio_open_drain_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);*/
143 static inline void pcie_ahb_pmu_setup(void)
145 /* Enable AHB bus master/slave */
146 @@ -180,20 +163,6 @@ static inline void pcie_phy_rst_deassert
147 IFX_REG_W32(reg, IFX_RCU_RST_REQ);
150 -static inline void pcie_device_rst_assert(int pcie_port)
152 - gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
153 -// ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
156 -static inline void pcie_device_rst_deassert(int pcie_port)
159 - gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
160 -// gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
161 - //ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
164 static inline void pcie_core_pmu_setup(int pcie_port)