cns3xxx: use files directory
[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/pcie.c
55 +++ b/arch/arm/mach-cns3xxx/pcie.c
56 @@ -456,23 +456,18 @@ static int cns3xxx_pcie_abort_handler(un
57         return 0;
58  }
59  
60 -void __init cns3xxx_pcie_iotable_init(u8 bitmap)
61 +
62 +void __init cns3xxx_pcie_iotable_init()
63  {
64 -       static int _iotable_init = 0;
65         int i;
66  
67 -       bitmap &= ~_iotable_init;
68         for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) {
69 -               if (!(bitmap & (1 << i)))
70 -                       continue;
71 -
72                 iotable_init(cns3xxx_pcie[i].cfg_bases,
73                              ARRAY_SIZE(cns3xxx_pcie[i].cfg_bases));
74         }
75 -       _iotable_init |= bitmap;
76  }
77  
78 -int __init cns3xxx_pcie_init(u8 bitmap)
79 +int __init cns3xxx_pcie_init(void)
80  {
81         int i;
82  
83 @@ -482,14 +477,12 @@ int __init cns3xxx_pcie_init(u8 bitmap)
84         hook_fault_code(16 + 6, cns3xxx_pcie_abort_handler, SIGBUS, 0,
85                         "imprecise external abort");
86  
87 -       cns3xxx_pcie_iotable_init(bitmap);
88         for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) {
89 -               if (!(bitmap & (1 << i)))
90 -                       continue;
91 -
92                 cns3xxx_pcie_check_link(&cns3xxx_pcie[i]);
93 -               cns3xxx_pcie_hw_init(&cns3xxx_pcie[i]);
94 -               pci_common_init(&cns3xxx_pcie[i].hw_pci);
95 +               if (cns3xxx_pcie[i].linked) {
96 +                       cns3xxx_pcie_hw_init(&cns3xxx_pcie[i]);
97 +                       pci_common_init(&cns3xxx_pcie[i].hw_pci);
98 +               }
99         }
100  
101         pci_assign_unassigned_resources();