kernel: update kernel 4.4 to version 4.4.3
[openwrt.git] / target / linux / lantiq / patches-4.4 / 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 __init 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 @@ -1083,6 +1114,30 @@ static int __init ifx_pcie_bios_init(voi
75  
76      return 0;
77  }
78 +
79 +static const struct of_device_id ifxmips_pcie_match[] = {
80 +        { .compatible = "lantiq,pcie-xrx200" },
81 +        {},
82 +};
83 +MODULE_DEVICE_TABLE(of, ifxmips_pcie_match);
84 +
85 +static struct platform_driver ltq_pci_driver = {
86 +        .probe = ifx_pcie_bios_probe,
87 +        .driver = {
88 +                .name = "pcie-xrx200",
89 +                .owner = THIS_MODULE,
90 +                .of_match_table = ifxmips_pcie_match,
91 +        },
92 +};
93 +
94 +int __init ifx_pcie_bios_init(void)
95 +{
96 +        int ret = platform_driver_register(&ltq_pci_driver);
97 +        if (ret)
98 +                pr_info("pcie-xrx200: Error registering platform driver!");
99 +        return ret;
100 +}
101 +
102  arch_initcall(ifx_pcie_bios_init);
103  
104  MODULE_LICENSE("GPL");
105 --- a/arch/mips/pci/ifxmips_pcie_vr9.h
106 +++ b/arch/mips/pci/ifxmips_pcie_vr9.h
107 @@ -22,8 +22,6 @@
108  #include <linux/gpio.h>
109  #include <lantiq_soc.h>
110  
111 -#define IFX_PCIE_GPIO_RESET  494
112 -
113  #define IFX_REG_R32    ltq_r32
114  #define IFX_REG_W32    ltq_w32
115  #define CONFIG_IFX_PCIE_HW_SWAP
116 @@ -53,21 +51,6 @@
117  #define OUT                    ((volatile u32*)(IFX_GPIO + 0x0070))
118  
119  
120 -static inline void pcie_ep_gpio_rst_init(int pcie_port)
121 -{
122 -
123 -       gpio_request(IFX_PCIE_GPIO_RESET, "pcie-reset");
124 -       gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
125 -       gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
126 -
127 -/*    ifx_gpio_pin_reserve(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
128 -    ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
129 -    ifx_gpio_dir_out_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
130 -    ifx_gpio_altsel0_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
131 -    ifx_gpio_altsel1_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
132 -    ifx_gpio_open_drain_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);*/
133 -}
134 -
135  static inline void pcie_ahb_pmu_setup(void) 
136  {
137         /* Enable AHB bus master/slave */
138 @@ -180,20 +163,6 @@ static inline void pcie_phy_rst_deassert
139      IFX_REG_W32(reg, IFX_RCU_RST_REQ);
140  }
141  
142 -static inline void pcie_device_rst_assert(int pcie_port)
143 -{
144 -       gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
145 -//    ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
146 -}
147 -
148 -static inline void pcie_device_rst_deassert(int pcie_port)
149 -{
150 -    mdelay(100);
151 -       gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
152 -//    gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
153 -    //ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
154 -}
155 -
156  static inline void pcie_core_pmu_setup(int pcie_port)
157  {
158         struct clk *clk;