Skip to content

Commit 905e75c

Browse files
Jia Hongtaokumargala
authored andcommitted
powerpc/fsl-pci: Unify pci/pcie initialization code
We unified the Freescale pci/pcie initialization by changing the fsl_pci to a platform driver. In previous PCI code architecture the initialization routine is called at board_setup_arch stage. Now the initialization is done in probe function which is architectural better. Also It's convenient for adding PM support for PCI controller in later patch. Now we registered pci controllers as platform devices. So we combine two initialization code as one platform driver. Signed-off-by: Jia Hongtao <B38951@freescale.com> Signed-off-by: Li Yang <leoli@freescale.com> Signed-off-by: Chunhe Lan <Chunhe.Lan@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
1 parent 9e67886 commit 905e75c

33 files changed

Lines changed: 249 additions & 537 deletions

‎arch/powerpc/platforms/85xx/common.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ static struct of_device_id __initdata mpc85xx_common_ids[] = {
2727
{ .compatible = "fsl,mpc8548-guts", },
2828
/* Probably unnecessary? */
2929
{ .compatible = "gpio-leds", },
30+
/* For all PCI controllers */
31+
{ .compatible = "fsl,mpc8540-pci", },
32+
{ .compatible = "fsl,mpc8548-pcie", },
33+
{ .compatible = "fsl,p1022-pcie", },
34+
{ .compatible = "fsl,p1010-pcie", },
35+
{ .compatible = "fsl,p1023-pcie", },
36+
{ .compatible = "fsl,p4080-pcie", },
37+
{ .compatible = "fsl,qoriq-pcie-v2.4", },
38+
{ .compatible = "fsl,qoriq-pcie-v2.3", },
39+
{ .compatible = "fsl,qoriq-pcie-v2.2", },
3040
{},
3141
};
3242

‎arch/powerpc/platforms/85xx/corenet_ds.c‎

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <linux/kdev_t.h>
1717
#include <linux/delay.h>
1818
#include <linux/interrupt.h>
19-
#include <linux/memblock.h>
2019

2120
#include <asm/time.h>
2221
#include <asm/machdep.h>
@@ -52,39 +51,16 @@ void __init corenet_ds_pic_init(void)
5251
*/
5352
void __init corenet_ds_setup_arch(void)
5453
{
55-
#ifdef CONFIG_PCI
56-
struct device_node *np;
57-
struct pci_controller *hose;
58-
#endif
59-
dma_addr_t max = 0xffffffff;
60-
6154
mpc85xx_smp_init();
6255

63-
#ifdef CONFIG_PCI
64-
for_each_node_by_type(np, "pci") {
65-
if (of_device_is_compatible(np, "fsl,p4080-pcie") ||
66-
of_device_is_compatible(np, "fsl,qoriq-pcie-v2.2") ||
67-
of_device_is_compatible(np, "fsl,qoriq-pcie-v2.3") ||
68-
of_device_is_compatible(np, "fsl,qoriq-pcie-v2.4")) {
69-
fsl_add_bridge(np, 0);
70-
hose = pci_find_hose_for_OF_device(np);
71-
max = min(max, hose->dma_window_base_cur +
72-
hose->dma_window_size);
73-
}
74-
}
75-
76-
#ifdef CONFIG_PPC64
56+
#if defined(CONFIG_PCI) && defined(CONFIG_PPC64)
7757
pci_devs_phb_init();
7858
#endif
79-
#endif
8059

81-
#ifdef CONFIG_SWIOTLB
82-
if ((memblock_end_of_DRAM() - 1) > max) {
83-
ppc_swiotlb_enable = 1;
84-
set_pci_dma_ops(&swiotlb_dma_ops);
85-
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
86-
}
87-
#endif
60+
fsl_pci_assign_primary();
61+
62+
swiotlb_detect_4g();
63+
8864
pr_info("%s board from Freescale Semiconductor\n", ppc_md.name);
8965
}
9066

‎arch/powerpc/platforms/85xx/ge_imp3a.c‎

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/seq_file.h>
2323
#include <linux/interrupt.h>
2424
#include <linux/of_platform.h>
25-
#include <linux/memblock.h>
2625

2726
#include <asm/time.h>
2827
#include <asm/machdep.h>
@@ -84,53 +83,39 @@ void __init ge_imp3a_pic_init(void)
8483
of_node_put(cascade_node);
8584
}
8685

87-
#ifdef CONFIG_PCI
88-
static int primary_phb_addr;
89-
#endif /* CONFIG_PCI */
90-
91-
/*
92-
* Setup the architecture
93-
*/
94-
static void __init ge_imp3a_setup_arch(void)
86+
static void ge_imp3a_pci_assign_primary(void)
9587
{
96-
struct device_node *regs;
9788
#ifdef CONFIG_PCI
9889
struct device_node *np;
99-
struct pci_controller *hose;
100-
#endif
101-
dma_addr_t max = 0xffffffff;
90+
struct resource rsrc;
10291

103-
if (ppc_md.progress)
104-
ppc_md.progress("ge_imp3a_setup_arch()", 0);
105-
106-
#ifdef CONFIG_PCI
10792
for_each_node_by_type(np, "pci") {
10893
if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
10994
of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
11095
of_device_is_compatible(np, "fsl,p2020-pcie")) {
111-
struct resource rsrc;
11296
of_address_to_resource(np, 0, &rsrc);
113-
if ((rsrc.start & 0xfffff) == primary_phb_addr)
114-
fsl_add_bridge(np, 1);
115-
else
116-
fsl_add_bridge(np, 0);
117-
118-
hose = pci_find_hose_for_OF_device(np);
119-
max = min(max, hose->dma_window_base_cur +
120-
hose->dma_window_size);
97+
if ((rsrc.start & 0xfffff) == 0x9000)
98+
fsl_pci_primary = np;
12199
}
122100
}
123101
#endif
102+
}
103+
104+
/*
105+
* Setup the architecture
106+
*/
107+
static void __init ge_imp3a_setup_arch(void)
108+
{
109+
struct device_node *regs;
110+
111+
if (ppc_md.progress)
112+
ppc_md.progress("ge_imp3a_setup_arch()", 0);
124113

125114
mpc85xx_smp_init();
126115

127-
#ifdef CONFIG_SWIOTLB
128-
if ((memblock_end_of_DRAM() - 1) > max) {
129-
ppc_swiotlb_enable = 1;
130-
set_pci_dma_ops(&swiotlb_dma_ops);
131-
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
132-
}
133-
#endif
116+
ge_imp3a_pci_assign_primary();
117+
118+
swiotlb_detect_4g();
134119

135120
/* Remap basic board registers */
136121
regs = of_find_compatible_node(NULL, NULL, "ge,imp3a-fpga-regs");
@@ -215,17 +200,10 @@ static int __init ge_imp3a_probe(void)
215200
{
216201
unsigned long root = of_get_flat_dt_root();
217202

218-
if (of_flat_dt_is_compatible(root, "ge,IMP3A")) {
219-
#ifdef CONFIG_PCI
220-
primary_phb_addr = 0x9000;
221-
#endif
222-
return 1;
223-
}
224-
225-
return 0;
203+
return of_flat_dt_is_compatible(root, "ge,IMP3A");
226204
}
227205

228-
machine_device_initcall(ge_imp3a, mpc85xx_common_publish_devices);
206+
machine_arch_initcall(ge_imp3a, mpc85xx_common_publish_devices);
229207

230208
machine_arch_initcall(ge_imp3a, swiotlb_setup_bus_notifier);
231209

‎arch/powerpc/platforms/85xx/mpc8536_ds.c‎

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <linux/seq_file.h>
1818
#include <linux/interrupt.h>
1919
#include <linux/of_platform.h>
20-
#include <linux/memblock.h>
2120

2221
#include <asm/time.h>
2322
#include <asm/machdep.h>
@@ -46,46 +45,17 @@ void __init mpc8536_ds_pic_init(void)
4645
*/
4746
static void __init mpc8536_ds_setup_arch(void)
4847
{
49-
#ifdef CONFIG_PCI
50-
struct device_node *np;
51-
struct pci_controller *hose;
52-
#endif
53-
dma_addr_t max = 0xffffffff;
54-
5548
if (ppc_md.progress)
5649
ppc_md.progress("mpc8536_ds_setup_arch()", 0);
5750

58-
#ifdef CONFIG_PCI
59-
for_each_node_by_type(np, "pci") {
60-
if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
61-
of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
62-
struct resource rsrc;
63-
of_address_to_resource(np, 0, &rsrc);
64-
if ((rsrc.start & 0xfffff) == 0x8000)
65-
fsl_add_bridge(np, 1);
66-
else
67-
fsl_add_bridge(np, 0);
68-
69-
hose = pci_find_hose_for_OF_device(np);
70-
max = min(max, hose->dma_window_base_cur +
71-
hose->dma_window_size);
72-
}
73-
}
74-
75-
#endif
51+
fsl_pci_assign_primary();
7652

77-
#ifdef CONFIG_SWIOTLB
78-
if ((memblock_end_of_DRAM() - 1) > max) {
79-
ppc_swiotlb_enable = 1;
80-
set_pci_dma_ops(&swiotlb_dma_ops);
81-
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
82-
}
83-
#endif
53+
swiotlb_detect_4g();
8454

8555
printk("MPC8536 DS board from Freescale Semiconductor\n");
8656
}
8757

88-
machine_device_initcall(mpc8536_ds, mpc85xx_common_publish_devices);
58+
machine_arch_initcall(mpc8536_ds, mpc85xx_common_publish_devices);
8959

9060
machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);
9161

‎arch/powerpc/platforms/85xx/mpc85xx_ads.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ static void __init init_ioports(void)
137137

138138
static void __init mpc85xx_ads_setup_arch(void)
139139
{
140-
#ifdef CONFIG_PCI
141-
struct device_node *np;
142-
#endif
143-
144140
if (ppc_md.progress)
145141
ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
146142

@@ -150,11 +146,10 @@ static void __init mpc85xx_ads_setup_arch(void)
150146
#endif
151147

152148
#ifdef CONFIG_PCI
153-
for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
154-
fsl_add_bridge(np, 1);
155-
156149
ppc_md.pci_exclude_device = mpc85xx_exclude_device;
157150
#endif
151+
152+
fsl_pci_assign_primary();
158153
}
159154

160155
static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
@@ -173,7 +168,7 @@ static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
173168
seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
174169
}
175170

176-
machine_device_initcall(mpc85xx_ads, mpc85xx_common_publish_devices);
171+
machine_arch_initcall(mpc85xx_ads, mpc85xx_common_publish_devices);
177172

178173
/*
179174
* Called very early, device-tree isn't unflattened

‎arch/powerpc/platforms/85xx/mpc85xx_cds.c‎

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,33 @@ machine_device_initcall(mpc85xx_cds, mpc85xx_cds_8259_attach);
276276

277277
#endif /* CONFIG_PPC_I8259 */
278278

279+
static void mpc85xx_cds_pci_assign_primary(void)
280+
{
281+
#ifdef CONFIG_PCI
282+
struct device_node *np;
283+
284+
if (fsl_pci_primary)
285+
return;
286+
287+
/*
288+
* MPC85xx_CDS has ISA bridge but unfortunately there is no
289+
* isa node in device tree. We now looking for i8259 node as
290+
* a workaround for such a broken device tree. This routine
291+
* is for complying to all device trees.
292+
*/
293+
np = of_find_node_by_name(NULL, "i8259");
294+
while ((fsl_pci_primary = of_get_parent(np))) {
295+
of_node_put(np);
296+
np = fsl_pci_primary;
297+
298+
if ((of_device_is_compatible(np, "fsl,mpc8540-pci") ||
299+
of_device_is_compatible(np, "fsl,mpc8548-pcie")) &&
300+
of_device_is_available(np))
301+
return;
302+
}
303+
#endif
304+
}
305+
279306
/*
280307
* Setup the architecture
281308
*/
@@ -309,21 +336,12 @@ static void __init mpc85xx_cds_setup_arch(void)
309336
}
310337

311338
#ifdef CONFIG_PCI
312-
for_each_node_by_type(np, "pci") {
313-
if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
314-
of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
315-
struct resource rsrc;
316-
of_address_to_resource(np, 0, &rsrc);
317-
if ((rsrc.start & 0xfffff) == 0x8000)
318-
fsl_add_bridge(np, 1);
319-
else
320-
fsl_add_bridge(np, 0);
321-
}
322-
}
323-
324339
ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup;
325340
ppc_md.pci_exclude_device = mpc85xx_exclude_device;
326341
#endif
342+
343+
mpc85xx_cds_pci_assign_primary();
344+
fsl_pci_assign_primary();
327345
}
328346

329347
static void mpc85xx_cds_show_cpuinfo(struct seq_file *m)
@@ -355,7 +373,7 @@ static int __init mpc85xx_cds_probe(void)
355373
return of_flat_dt_is_compatible(root, "MPC85xxCDS");
356374
}
357375

358-
machine_device_initcall(mpc85xx_cds, mpc85xx_common_publish_devices);
376+
machine_arch_initcall(mpc85xx_cds, mpc85xx_common_publish_devices);
359377

360378
define_machine(mpc85xx_cds) {
361379
.name = "MPC85xx CDS",

‎arch/powerpc/platforms/85xx/mpc85xx_ds.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <linux/seq_file.h>
2121
#include <linux/interrupt.h>
2222
#include <linux/of_platform.h>
23-
#include <linux/memblock.h>
2423

2524
#include <asm/time.h>
2625
#include <asm/machdep.h>
@@ -129,13 +128,11 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
129128
}
130129
#endif /* CONFIG_PCI */
131130

132-
static void __init mpc85xx_ds_pci_init(void)
131+
static void __init mpc85xx_ds_uli_init(void)
133132
{
134133
#ifdef CONFIG_PCI
135134
struct device_node *node;
136135

137-
fsl_pci_init();
138-
139136
/* See if we have a ULI under the primary */
140137

141138
node = of_find_node_by_name(NULL, "uli1575");
@@ -160,7 +157,8 @@ static void __init mpc85xx_ds_setup_arch(void)
160157
ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
161158

162159
swiotlb_detect_4g();
163-
mpc85xx_ds_pci_init();
160+
fsl_pci_assign_primary();
161+
mpc85xx_ds_uli_init();
164162
mpc85xx_smp_init();
165163

166164
printk("MPC85xx DS board from Freescale Semiconductor\n");
@@ -176,9 +174,9 @@ static int __init mpc8544_ds_probe(void)
176174
return !!of_flat_dt_is_compatible(root, "MPC8544DS");
177175
}
178176

179-
machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
180-
machine_device_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
181-
machine_device_initcall(p2020_ds, mpc85xx_common_publish_devices);
177+
machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
178+
machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
179+
machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
182180

183181
machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
184182
machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);

0 commit comments

Comments
 (0)