lantiq: fix section mismatch in PCIe driver
[openwrt/staging/chunkeey.git] / target / linux / lantiq / patches-4.9 / 0151-lantiq-ifxmips_pcie-use-of.patch
1 --- a/arch/mips/pci/ifxmips_pcie.c
2 +++ b/arch/mips/pci/ifxmips_pcie.c
3 @@ -18,6 +18,9 @@
4 #include <linux/pci_regs.h>
5 #include <linux/module.h>
6
7 +#include <linux/of_gpio.h>
8 +#include <linux/of_platform.h>
9 +
10 #include "ifxmips_pcie.h"
11 #include "ifxmips_pcie_reg.h"
12
13 @@ -40,6 +43,7 @@
14 static DEFINE_SPINLOCK(ifx_pcie_lock);
15
16 u32 g_pcie_debug_flag = PCIE_MSG_ANY & (~PCIE_MSG_CFG);
17 +static int pcie_reset_gpio;
18
19 static ifx_pcie_irq_t pcie_irqs[IFX_PCIE_CORE_NR] = {
20 {
21 @@ -82,6 +86,22 @@ void ifx_pcie_debug(const char *fmt, ...
22 printk("%s", buf);
23 }
24
25 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
26 +{
27 + gpio_direction_output(pcie_reset_gpio, 1);
28 + gpio_set_value(pcie_reset_gpio, 1);
29 +}
30 +
31 +static inline void pcie_device_rst_assert(int pcie_port)
32 +{
33 + gpio_set_value(pcie_reset_gpio, 0);
34 +}
35 +
36 +static inline void pcie_device_rst_deassert(int pcie_port)
37 +{
38 + mdelay(100);
39 + gpio_direction_output(pcie_reset_gpio, 1);
40 +}
41
42 static inline int pcie_ltssm_enable(int pcie_port)
43 {
44 @@ -1045,8 +1065,9 @@ pcie_rc_initialize(int pcie_port)
45 return 0;
46 }
47
48 -static int __init ifx_pcie_bios_init(void)
49 +static int ifx_pcie_bios_probe(struct platform_device *pdev)
50 {
51 + struct device_node *node = pdev->dev.of_node;
52 void __iomem *io_map_base;
53 int pcie_port;
54 int startup_port;
55 @@ -1055,7 +1076,17 @@ static int __init ifx_pcie_bios_init(voi
56 pcie_ahb_pmu_setup();
57
58 startup_port = IFX_PCIE_PORT0;
59 -
60 +
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");
64 + if (ret) {
65 + dev_err(&pdev->dev, "failed to request gpio %d\n", pcie_reset_gpio);
66 + return ret;
67 + }
68 + gpio_direction_output(pcie_reset_gpio, 1);
69 + }
70 +
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
75 return -ENOMEM;
76 }
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);
79
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
83
84 return 0;
85 }
86 +
87 +static const struct of_device_id ifxmips_pcie_match[] = {
88 + { .compatible = "lantiq,pcie-xrx200" },
89 + {},
90 +};
91 +MODULE_DEVICE_TABLE(of, ifxmips_pcie_match);
92 +
93 +static struct platform_driver ltq_pci_driver = {
94 + .probe = ifx_pcie_bios_probe,
95 + .driver = {
96 + .name = "pcie-xrx200",
97 + .owner = THIS_MODULE,
98 + .of_match_table = ifxmips_pcie_match,
99 + },
100 +};
101 +
102 +int __init ifx_pcie_bios_init(void)
103 +{
104 + int ret = platform_driver_register(&ltq_pci_driver);
105 + if (ret)
106 + pr_info("pcie-xrx200: Error registering platform driver!");
107 + return ret;
108 +}
109 +
110 arch_initcall(ifx_pcie_bios_init);
111
112 MODULE_LICENSE("GPL");
113 --- a/arch/mips/pci/ifxmips_pcie_vr9.h
114 +++ b/arch/mips/pci/ifxmips_pcie_vr9.h
115 @@ -22,8 +22,6 @@
116 #include <linux/gpio.h>
117 #include <lantiq_soc.h>
118
119 -#define IFX_PCIE_GPIO_RESET 494
120 -
121 #define IFX_REG_R32 ltq_r32
122 #define IFX_REG_W32 ltq_w32
123 #define CONFIG_IFX_PCIE_HW_SWAP
124 @@ -53,21 +51,6 @@
125 #define OUT ((volatile u32*)(IFX_GPIO + 0x0070))
126
127
128 -static inline void pcie_ep_gpio_rst_init(int pcie_port)
129 -{
130 -
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);
134 -
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);*/
141 -}
142 -
143 static inline void pcie_ahb_pmu_setup(void)
144 {
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);
148 }
149
150 -static inline void pcie_device_rst_assert(int pcie_port)
151 -{
152 - gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
153 -// ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
154 -}
155 -
156 -static inline void pcie_device_rst_deassert(int pcie_port)
157 -{
158 - mdelay(100);
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);
162 -}
163 -
164 static inline void pcie_core_pmu_setup(int pcie_port)
165 {
166 struct clk *clk;