704a6f76c90e7c149eca6c9baef474547bd17909
[openwrt.git] / target / linux / cns3xxx / patches-3.3 / 480-cns3xxx_pcie_early_init.patch
1 --- a/arch/arm/mach-cns3xxx/cns3420vb.c
2 +++ b/arch/arm/mach-cns3xxx/cns3420vb.c
3 @@ -203,7 +203,6 @@ static void __init cns3420_init(void)
4                 NR_IRQS_CNS3XXX);
5         cns3xxx_gpio_init(32, 32, CNS3XXX_GPIOB_BASE_VIRT, IRQ_CNS3XXX_GPIOB,
6                 NR_IRQS_CNS3XXX + 32);
7 -       cns3xxx_pcie_init(0x3);
8  
9         pm_power_off = cns3xxx_power_off;
10  }
11 @@ -220,11 +219,21 @@ static struct map_desc cns3420_io_desc[]
12  static void __init cns3420_map_io(void)
13  {
14         cns3xxx_common_init();
15 +       cns3xxx_pcie_iotable_init();
16         iotable_init(cns3420_io_desc, ARRAY_SIZE(cns3420_io_desc));
17  
18         cns3420_early_serial_setup();
19  }
20  
21 +static int __init cns3420vb_pcie_init(void)
22 +{
23 +       if (!machine_is_cns3420vb())
24 +               return 0;
25 +
26 +       return cns3xxx_pcie_init();
27 +}
28 +subsys_initcall(cns3420vb_pcie_init);
29 +
30  MACHINE_START(CNS3420VB, "Cavium Networks CNS3420 Validation Board")
31         .atag_offset    = 0x100,
32         .map_io         = cns3420_map_io,
33 --- a/arch/arm/mach-cns3xxx/core.h
34 +++ b/arch/arm/mach-cns3xxx/core.h
35 @@ -12,8 +12,8 @@
36  #define __CNS3XXX_CORE_H
37  
38  extern struct sys_timer cns3xxx_timer;
39 -extern int cns3xxx_pcie_init(u8 bitmap);
40 -extern void cns3xxx_pcie_iotable_init(u8 bitmap);
41 +extern void cns3xxx_pcie_iotable_init(void);
42 +
43  
44  #ifdef CONFIG_CACHE_L2X0
45  void __init cns3xxx_l2x0_init(void);
46 @@ -23,6 +23,7 @@ static inline void cns3xxx_l2x0_init(voi
47  
48  void __init cns3xxx_common_init(void);
49  void __init cns3xxx_init_irq(void);
50 +int  __init cns3xxx_pcie_init(void);
51  void cns3xxx_power_off(void);
52  void cns3xxx_restart(char, const char *);
53  
54 --- a/arch/arm/mach-cns3xxx/laguna.c
55 +++ b/arch/arm/mach-cns3xxx/laguna.c
56 @@ -729,7 +731,7 @@ static struct map_desc laguna_io_desc[]
57  static void __init laguna_map_io(void)
58  {
59         cns3xxx_common_init();
60 -       cns3xxx_pcie_iotable_init(0x3);
61 +       cns3xxx_pcie_iotable_init();
62         iotable_init(ARRAY_AND_SIZE(laguna_io_desc));
63         laguna_early_serial_setup();
64  }
65 @@ -753,11 +755,19 @@ static int laguna_register_gpio(struct g
66         return ret;
67  }
68  
69 +static int __init laguna_pcie_init(void)
70 +{
71 +       if (!machine_is_gw2388())
72 +               return 0;
73 +
74 +       return cns3xxx_pcie_init();
75 +}
76 +subsys_initcall(laguna_pcie_init);
77 +
78  static int __init laguna_model_setup(void)
79  {
80         u32 __iomem *mem;
81         u32 reg;
82 -       u8 pcie_bitmap = 0;
83  
84         printk("Running on Gateworks Laguna %s\n", laguna_info.model);
85         cns3xxx_gpio_init( 0, 32, CNS3XXX_GPIOA_BASE_VIRT, IRQ_CNS3XXX_GPIOA,
86 @@ -779,14 +789,6 @@ static int __init laguna_model_setup(voi
87                     (laguna_info.config_bitmap & SATA1_LOAD))
88                         cns3xxx_ahci_init();
89  
90 -               if (laguna_info.config_bitmap & (PCIE0_LOAD))
91 -                       pcie_bitmap |= 0x1;
92 -
93 -               if (laguna_info.config_bitmap & (PCIE1_LOAD))
94 -                       pcie_bitmap |= 0x2;
95 -
96 -               cns3xxx_pcie_init(pcie_bitmap);
97 -
98                 if (laguna_info.config_bitmap & (USB0_LOAD)) {
99                         cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB);
100  
101 @@ -926,7 +928,6 @@ static int __init laguna_model_setup(voi
102         }
103         return 0;
104  }
105 -
106  late_initcall(laguna_model_setup);
107  
108  MACHINE_START(GW2388, "Gateworks Corporation Laguna Platform")
109 --- a/arch/arm/mach-cns3xxx/pcie.c
110 +++ b/arch/arm/mach-cns3xxx/pcie.c
111 @@ -456,23 +456,18 @@ static int cns3xxx_pcie_abort_handler(un
112         return 0;
113  }
114  
115 -void __init cns3xxx_pcie_iotable_init(u8 bitmap)
116 +
117 +void __init cns3xxx_pcie_iotable_init()
118  {
119 -       static int _iotable_init = 0;
120         int i;
121  
122 -       bitmap &= ~_iotable_init;
123         for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) {
124 -               if (!(bitmap & (1 << i)))
125 -                       continue;
126 -
127                 iotable_init(cns3xxx_pcie[i].cfg_bases,
128                              ARRAY_SIZE(cns3xxx_pcie[i].cfg_bases));
129         }
130 -       _iotable_init |= bitmap;
131  }
132  
133 -int __init cns3xxx_pcie_init(u8 bitmap)
134 +int __init cns3xxx_pcie_init(void)
135  {
136         int i;
137  
138 @@ -482,14 +477,12 @@ int __init cns3xxx_pcie_init(u8 bitmap)
139         hook_fault_code(16 + 6, cns3xxx_pcie_abort_handler, SIGBUS, 0,
140                         "imprecise external abort");
141  
142 -       cns3xxx_pcie_iotable_init(bitmap);
143         for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) {
144 -               if (!(bitmap & (1 << i)))
145 -                       continue;
146 -
147                 cns3xxx_pcie_check_link(&cns3xxx_pcie[i]);
148 -               cns3xxx_pcie_hw_init(&cns3xxx_pcie[i]);
149 -               pci_common_init(&cns3xxx_pcie[i].hw_pci);
150 +               if (cns3xxx_pcie[i].linked) {
151 +                       cns3xxx_pcie_hw_init(&cns3xxx_pcie[i]);
152 +                       pci_common_init(&cns3xxx_pcie[i].hw_pci);
153 +               }
154         }
155  
156         pci_assign_unassigned_resources();