Commit c9438affcb7ac0dda4c6c6961637fb272f7c32d4

Authored by Kumar Gala
1 parent 2fce1225af

[POWERPC] Use for_each_ matching routinues for pci PHBs

On the Freescale embedded (83xx, 85xx, 86xx) and a few of the discrete
bridges (mpc10x, tsi108) use the new for_each_compatible_node() or
for_each_node_by_type() to provide more exact matching when looking for
PHBs in the device tree.

With the previous code it was possible to match on pci bridges since
we were only matching on device_type.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Showing 13 changed files with 45 additions and 27 deletions Side-by-side Diff

arch/powerpc/platforms/83xx/mpc8313_rdb.c
... ... @@ -43,7 +43,7 @@
43 43 ppc_md.progress("mpc8313_rdb_setup_arch()", 0);
44 44  
45 45 #ifdef CONFIG_PCI
46   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  46 + for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
47 47 mpc83xx_add_bridge(np);
48 48 #endif
49 49 mpc831x_usb_cfg();
arch/powerpc/platforms/83xx/mpc832x_mds.c
... ... @@ -73,7 +73,7 @@
73 73 }
74 74  
75 75 #ifdef CONFIG_PCI
76   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  76 + for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
77 77 mpc83xx_add_bridge(np);
78 78 #endif
79 79  
arch/powerpc/platforms/83xx/mpc832x_rdb.c
... ... @@ -93,7 +93,7 @@
93 93 ppc_md.progress("mpc832x_rdb_setup_arch()", 0);
94 94  
95 95 #ifdef CONFIG_PCI
96   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  96 + for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
97 97 mpc83xx_add_bridge(np);
98 98 #endif
99 99  
arch/powerpc/platforms/83xx/mpc834x_itx.c
... ... @@ -52,7 +52,7 @@
52 52 ppc_md.progress("mpc834x_itx_setup_arch()", 0);
53 53  
54 54 #ifdef CONFIG_PCI
55   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  55 + for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
56 56 mpc83xx_add_bridge(np);
57 57 #endif
58 58  
arch/powerpc/platforms/83xx/mpc834x_mds.c
... ... @@ -83,7 +83,7 @@
83 83 ppc_md.progress("mpc834x_mds_setup_arch()", 0);
84 84  
85 85 #ifdef CONFIG_PCI
86   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  86 + for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
87 87 mpc83xx_add_bridge(np);
88 88 #endif
89 89  
arch/powerpc/platforms/83xx/mpc836x_mds.c
... ... @@ -79,7 +79,7 @@
79 79 }
80 80  
81 81 #ifdef CONFIG_PCI
82   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  82 + for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
83 83 mpc83xx_add_bridge(np);
84 84 #endif
85 85  
arch/powerpc/platforms/85xx/mpc85xx_ads.c
... ... @@ -204,8 +204,9 @@
204 204 #endif
205 205  
206 206 #ifdef CONFIG_PCI
207   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  207 + for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
208 208 fsl_add_bridge(np, 1);
  209 +
209 210 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
210 211 #endif
211 212 }
arch/powerpc/platforms/85xx/mpc85xx_cds.c
... ... @@ -283,14 +283,18 @@
283 283 }
284 284  
285 285 #ifdef CONFIG_PCI
286   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
287   - struct resource rsrc;
288   - of_address_to_resource(np, 0, &rsrc);
289   - if ((rsrc.start & 0xfffff) == 0x8000)
290   - fsl_add_bridge(np, 1);
291   - else
292   - fsl_add_bridge(np, 0);
  286 + for_each_node_by_type(np, "pci") {
  287 + if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  288 + of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  289 + struct resource rsrc;
  290 + of_address_to_resource(np, 0, &rsrc);
  291 + if ((rsrc.start & 0xfffff) == 0x8000)
  292 + fsl_add_bridge(np, 1);
  293 + else
  294 + fsl_add_bridge(np, 0);
  295 + }
293 296 }
  297 +
294 298 ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup;
295 299 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
296 300 #endif
arch/powerpc/platforms/85xx/mpc85xx_ds.c
... ... @@ -149,14 +149,18 @@
149 149 ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
150 150  
151 151 #ifdef CONFIG_PCI
152   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
153   - struct resource rsrc;
154   - of_address_to_resource(np, 0, &rsrc);
155   - if ((rsrc.start & 0xfffff) == primary_phb_addr)
156   - fsl_add_bridge(np, 1);
157   - else
158   - fsl_add_bridge(np, 0);
  152 + for_each_node_by_type(np, "pci") {
  153 + if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  154 + of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  155 + struct resource rsrc;
  156 + of_address_to_resource(np, 0, &rsrc);
  157 + if ((rsrc.start & 0xfffff) == primary_phb_addr)
  158 + fsl_add_bridge(np, 1);
  159 + else
  160 + fsl_add_bridge(np, 0);
  161 + }
159 162 }
  163 +
160 164 uses_fsl_uli_m1575 = 1;
161 165 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
162 166 #endif
arch/powerpc/platforms/85xx/mpc85xx_mds.c
... ... @@ -83,9 +83,17 @@
83 83 }
84 84  
85 85 #ifdef CONFIG_PCI
86   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
87   - fsl_add_bridge(np, 1);
88   - of_node_put(np);
  86 + for_each_node_by_type(np, "pci") {
  87 + if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  88 + of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  89 + struct resource rsrc;
  90 + of_address_to_resource(np, 0, &rsrc);
  91 + if ((rsrc.start & 0xfffff) == 0x8000)
  92 + fsl_add_bridge(np, 1);
  93 + else
  94 + fsl_add_bridge(np, 0);
  95 + }
  96 + }
89 97 #endif
90 98  
91 99 #ifdef CONFIG_QUICC_ENGINE
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
... ... @@ -140,7 +140,7 @@
140 140 ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
141 141  
142 142 #ifdef CONFIG_PCI
143   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
  143 + for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
144 144 struct resource rsrc;
145 145 of_address_to_resource(np, 0, &rsrc);
146 146 if ((rsrc.start & 0xfffff) == 0x8000)
... ... @@ -148,6 +148,7 @@
148 148 else
149 149 fsl_add_bridge(np, 0);
150 150 }
  151 +
151 152 uses_fsl_uli_m1575 = 1;
152 153 ppc_md.pci_exclude_device = mpc86xx_exclude_device;
153 154  
arch/powerpc/platforms/embedded6xx/linkstation.c
... ... @@ -91,7 +91,7 @@
91 91 #endif
92 92  
93 93 /* Lookup PCI host bridges */
94   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  94 + for_each_compatible_node(np, "pci", "mpc10x-pci")
95 95 linkstation_add_bridge(np);
96 96  
97 97 printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
... ... @@ -74,7 +74,7 @@
74 74  
75 75 /* setup PCI host bridge */
76 76 #ifdef CONFIG_PCI
77   - for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  77 + for_each_compatible_node(np, "pci", "tsi108-pci")
78 78 tsi108_setup_pci(np, MPC7448HPC2_PCI_CFG_PHYS, 0);
79 79  
80 80 ppc_md.pci_exclude_device = mpc7448_hpc2_exclude_device;