summaryrefslogtreecommitdiffstats
path: root/target/linux/cns3xxx/patches-3.3/480-cns3xxx_pcie_early_init.patch
blob: dba0da84386861ec9d3611d16e0e3f14d867cdd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
--- a/arch/arm/mach-cns3xxx/cns3420vb.c
+++ b/arch/arm/mach-cns3xxx/cns3420vb.c
@@ -203,7 +203,6 @@ static void __init cns3420_init(void)
 		NR_IRQS_CNS3XXX);
 	cns3xxx_gpio_init(32, 32, CNS3XXX_GPIOB_BASE_VIRT, IRQ_CNS3XXX_GPIOB,
 		NR_IRQS_CNS3XXX + 32);
-	cns3xxx_pcie_init(0x3);
 
 	pm_power_off = cns3xxx_power_off;
 }
@@ -220,11 +219,21 @@ static struct map_desc cns3420_io_desc[]
 static void __init cns3420_map_io(void)
 {
 	cns3xxx_common_init();
+	cns3xxx_pcie_iotable_init();
 	iotable_init(cns3420_io_desc, ARRAY_SIZE(cns3420_io_desc));
 
 	cns3420_early_serial_setup();
 }
 
+static int __init cns3420vb_pcie_init(void)
+{
+	if (!machine_is_cns3420vb())
+		return 0;
+
+	return cns3xxx_pcie_init();
+}
+subsys_initcall(cns3420vb_pcie_init);
+
 MACHINE_START(CNS3420VB, "Cavium Networks CNS3420 Validation Board")
 	.atag_offset	= 0x100,
 	.map_io		= cns3420_map_io,
--- a/arch/arm/mach-cns3xxx/core.h
+++ b/arch/arm/mach-cns3xxx/core.h
@@ -12,8 +12,8 @@
 #define __CNS3XXX_CORE_H
 
 extern struct sys_timer cns3xxx_timer;
-extern int cns3xxx_pcie_init(u8 bitmap);
-extern void cns3xxx_pcie_iotable_init(u8 bitmap);
+extern void cns3xxx_pcie_iotable_init(void);
+
 
 #ifdef CONFIG_CACHE_L2X0
 void __init cns3xxx_l2x0_init(void);
@@ -23,6 +23,7 @@ static inline void cns3xxx_l2x0_init(voi
 
 void __init cns3xxx_common_init(void);
 void __init cns3xxx_init_irq(void);
+int  __init cns3xxx_pcie_init(void);
 void cns3xxx_power_off(void);
 void cns3xxx_restart(char, const char *);
 
--- a/arch/arm/mach-cns3xxx/pcie.c
+++ b/arch/arm/mach-cns3xxx/pcie.c
@@ -456,23 +456,18 @@ static int cns3xxx_pcie_abort_handler(un
 	return 0;
 }
 
-void __init cns3xxx_pcie_iotable_init(u8 bitmap)
+
+void __init cns3xxx_pcie_iotable_init()
 {
-	static int _iotable_init = 0;
 	int i;
 
-	bitmap &= ~_iotable_init;
 	for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) {
-		if (!(bitmap & (1 << i)))
-			continue;
-
 		iotable_init(cns3xxx_pcie[i].cfg_bases,
 			     ARRAY_SIZE(cns3xxx_pcie[i].cfg_bases));
 	}
-	_iotable_init |= bitmap;
 }
 
-int __init cns3xxx_pcie_init(u8 bitmap)
+int __init cns3xxx_pcie_init(void)
 {
 	int i;
 
@@ -482,14 +477,12 @@ int __init cns3xxx_pcie_init(u8 bitmap)
 	hook_fault_code(16 + 6, cns3xxx_pcie_abort_handler, SIGBUS, 0,
 			"imprecise external abort");
 
-	cns3xxx_pcie_iotable_init(bitmap);
 	for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) {
-		if (!(bitmap & (1 << i)))
-			continue;
-
 		cns3xxx_pcie_check_link(&cns3xxx_pcie[i]);
-		cns3xxx_pcie_hw_init(&cns3xxx_pcie[i]);
-		pci_common_init(&cns3xxx_pcie[i].hw_pci);
+		if (cns3xxx_pcie[i].linked) {
+			cns3xxx_pcie_hw_init(&cns3xxx_pcie[i]);
+			pci_common_init(&cns3xxx_pcie[i].hw_pci);
+		}
 	}
 
 	pci_assign_unassigned_resources();