lantiq: ifxmips_pcie: use platform_get_irq to get irqs from dts
[openwrt/openwrt.git] / target / linux / lantiq / patches-6.1 / 0151-lantiq-ifxmips_pcie-use-of.patch
index 0ab929b2e2c978649973ae6d8b632e7fe72d3819..b83bf992a6ef50f1ab59bf060b752d39feadd5d9 100644 (file)
@@ -39,7 +39,19 @@ Signed-off-by: Eddi De Pieri <eddi@depieri.net>
  #include "ifxmips_pcie.h"
  #include "ifxmips_pcie_reg.h"
  
-@@ -40,6 +47,11 @@
+@@ -25,11 +32,6 @@
+ #define IFX_PCIE_ERROR_INT
+ #define IFX_PCIE_IO_32BIT
+-#define IFX_PCIE_IR                     (INT_NUM_IM4_IRL0 + 25)
+-#define IFX_PCIE_INTA                   (INT_NUM_IM4_IRL0 + 8)
+-#define IFX_PCIE_INTB                   (INT_NUM_IM4_IRL0 + 9)
+-#define IFX_PCIE_INTC                   (INT_NUM_IM4_IRL0 + 10)
+-#define IFX_PCIE_INTD                   (INT_NUM_IM4_IRL0 + 11)
+ #define MS(_v, _f)  (((_v) & (_f)) >> _f##_S)
+ #define SM(_v, _f)  (((_v) << _f##_S) & (_f))
+ #define IFX_REG_SET_BIT(_f, _r) \
+@@ -40,30 +42,30 @@
  static DEFINE_SPINLOCK(ifx_pcie_lock);
  
  u32 g_pcie_debug_flag = PCIE_MSG_ANY & (~PCIE_MSG_CFG);
@@ -51,7 +63,31 @@ Signed-off-by: Eddi De Pieri <eddi@depieri.net>
  
  static ifx_pcie_irq_t pcie_irqs[IFX_PCIE_CORE_NR] = {
      {
-@@ -82,6 +94,22 @@ void ifx_pcie_debug(const char *fmt, ...
+         .ir_irq = {
+-            .irq  = IFX_PCIE_IR,
+             .name = "ifx_pcie_rc0",
+         },
+         .legacy_irq = {
+             {
+                 .irq_bit = PCIE_IRN_INTA,
+-                .irq     = IFX_PCIE_INTA,
+             },
+             {
+                 .irq_bit = PCIE_IRN_INTB,
+-                .irq     = IFX_PCIE_INTB,
+             },
+             {
+                 .irq_bit = PCIE_IRN_INTC,
+-                .irq     = IFX_PCIE_INTC,
+             },
+             {
+                 .irq_bit = PCIE_IRN_INTD,
+-                .irq     = IFX_PCIE_INTD,
+             },
+         },
+     },
+@@ -82,6 +84,22 @@ void ifx_pcie_debug(const char *fmt, ...
        printk("%s", buf);
  }
  
@@ -74,7 +110,17 @@ Signed-off-by: Eddi De Pieri <eddi@depieri.net>
  
  static inline int pcie_ltssm_enable(int pcie_port)
  {
-@@ -988,10 +1016,26 @@ int  ifx_pcie_bios_plat_dev_init(struct
+@@ -857,7 +875,8 @@ pcie_rc_core_int_init(int pcie_port)
+       ret = request_irq(pcie_irqs[pcie_port].ir_irq.irq, pcie_rc_core_isr, 0,
+               pcie_irqs[pcie_port].ir_irq.name, &ifx_pcie_controller[pcie_port]);
+       if (ret)
+-              printk(KERN_ERR "%s request irq %d failed\n", __func__, IFX_PCIE_IR);
++              printk(KERN_ERR "%s request irq %d failed\n", __func__,
++                     pcie_irqs[pcie_port].ir_irq.irq);
+       return ret;
+ }
+@@ -988,10 +1007,26 @@ int  ifx_pcie_bios_plat_dev_init(struct
  static int
  pcie_rc_initialize(int pcie_port)
  {
@@ -103,7 +149,7 @@ Signed-off-by: Eddi De Pieri <eddi@depieri.net>
  
        pcie_ep_gpio_rst_init(pcie_port);
  
-@@ -1000,26 +1044,21 @@ pcie_rc_initialize(int pcie_port)
+@@ -1000,26 +1035,21 @@ pcie_rc_initialize(int pcie_port)
        * reset PCIe PHY will solve this issue 
        */
        for (i = 0; i < IFX_PCIE_PHY_LOOP_CNT; i++) {
@@ -140,7 +186,7 @@ Signed-off-by: Eddi De Pieri <eddi@depieri.net>
  
                /* Enable PCIe PHY and Clock */
                pcie_core_pmu_setup(pcie_port);
-@@ -1035,6 +1074,10 @@ pcie_rc_initialize(int pcie_port)
+@@ -1035,6 +1065,10 @@ pcie_rc_initialize(int pcie_port)
                /* Once link is up, break out */
                if (pcie_app_loigc_setup(pcie_port) == 0)
                        break;
@@ -151,7 +197,7 @@ Signed-off-by: Eddi De Pieri <eddi@depieri.net>
        }
        if (i >= IFX_PCIE_PHY_LOOP_CNT) {
                printk(KERN_ERR "%s link up failed!!!!!\n", __func__);
-@@ -1045,17 +1088,73 @@ pcie_rc_initialize(int pcie_port)
+@@ -1045,17 +1079,73 @@ pcie_rc_initialize(int pcie_port)
        return 0;
  }
  
@@ -227,15 +273,27 @@ Signed-off-by: Eddi De Pieri <eddi@depieri.net>
      for (pcie_port = startup_port; pcie_port < IFX_PCIE_CORE_NR; pcie_port++){
        if (pcie_rc_initialize(pcie_port) == 0) {
            IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: ifx_pcie_cfg_base 0x%p\n", 
-@@ -1067,6 +1166,7 @@ static int __init ifx_pcie_bios_init(voi
+@@ -1066,7 +1156,19 @@ static int __init ifx_pcie_bios_init(voi
+                 IFX_PCIE_PRINT(PCIE_MSG_ERR, "%s io space ioremap failed\n", __func__);
                  return -ENOMEM;
              }
++            pcie_irqs[pcie_port].ir_irq.irq = platform_get_irq(pdev, 0);
++            if (pcie_irqs[pcie_port].ir_irq.irq < 0)
++                return pcie_irqs[pcie_port].ir_irq.irq;
++
++            for (int i = 0; i <= 3; i++){
++                pcie_irqs[pcie_port].legacy_irq[i].irq = platform_get_irq(pdev, i + 1);
++
++                if (pcie_irqs[pcie_port].legacy_irq[i].irq < 0)
++                    return pcie_irqs[pcie_port].legacy_irq[i].irq;
++            }
++
              ifx_pcie_controller[pcie_port].pcic.io_map_base = (unsigned long)io_map_base;
 +            pci_load_of_ranges(&ifx_pcie_controller[pcie_port].pcic, node);
  
              register_pci_controller(&ifx_pcie_controller[pcie_port].pcic);
              /* XXX, clear error status */
-@@ -1083,6 +1183,30 @@ static int __init ifx_pcie_bios_init(voi
+@@ -1083,6 +1185,30 @@ static int __init ifx_pcie_bios_init(voi
  
      return 0;
  }
@@ -408,3 +466,21 @@ Signed-off-by: Eddi De Pieri <eddi@depieri.net>
  static inline void pcie_core_pmu_setup(int pcie_port)
  {
        struct clk *clk;
+--- a/arch/mips/pci/ifxmips_pcie.h
++++ b/arch/mips/pci/ifxmips_pcie.h
+@@ -96,13 +96,13 @@ struct ifx_pci_controller {
+ };
+ typedef struct ifx_pcie_ir_irq {
+-    const unsigned int irq;
++    unsigned int irq;
+     const char name[16];
+ }ifx_pcie_ir_irq_t;
+ typedef struct ifx_pcie_legacy_irq{
+     const u32 irq_bit;
+-    const int irq;
++    int irq;
+ }ifx_pcie_legacy_irq_t;
+ typedef struct ifx_pcie_irq {