aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/boot')
-rw-r--r--arch/powerpc/boot/cuboot-pq2.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/arch/powerpc/boot/cuboot-pq2.c b/arch/powerpc/boot/cuboot-pq2.c
index f56ac6cae9f3..9c7d13428293 100644
--- a/arch/powerpc/boot/cuboot-pq2.c
+++ b/arch/powerpc/boot/cuboot-pq2.c
@@ -128,7 +128,7 @@ static void fixup_pci(void)
128 u8 *soc_regs; 128 u8 *soc_regs;
129 int i, len; 129 int i, len;
130 void *node, *parent_node; 130 void *node, *parent_node;
131 u32 naddr, nsize, mem_log2; 131 u32 naddr, nsize, mem_pow2, mem_mask;
132 132
133 node = finddevice("/pci"); 133 node = finddevice("/pci");
134 if (!node || !dt_is_compatible(node, "fsl,pq2-pci")) 134 if (!node || !dt_is_compatible(node, "fsl,pq2-pci"))
@@ -141,7 +141,7 @@ static void fixup_pci(void)
141 141
142 soc_regs = (u8 *)fsl_get_immr(); 142 soc_regs = (u8 *)fsl_get_immr();
143 if (!soc_regs) 143 if (!soc_regs)
144 goto err; 144 goto unhandled;
145 145
146 dt_get_reg_format(node, &naddr, &nsize); 146 dt_get_reg_format(node, &naddr, &nsize);
147 if (naddr != 3 || nsize != 2) 147 if (naddr != 3 || nsize != 2)
@@ -153,7 +153,7 @@ static void fixup_pci(void)
153 153
154 dt_get_reg_format(parent_node, &naddr, &nsize); 154 dt_get_reg_format(parent_node, &naddr, &nsize);
155 if (naddr != 1 || nsize != 1) 155 if (naddr != 1 || nsize != 1)
156 goto err; 156 goto unhandled;
157 157
158 len = getprop(node, "ranges", pci_ranges_buf, 158 len = getprop(node, "ranges", pci_ranges_buf,
159 sizeof(pci_ranges_buf)); 159 sizeof(pci_ranges_buf));
@@ -170,14 +170,20 @@ static void fixup_pci(void)
170 } 170 }
171 171
172 if (!mem || !mmio || !io) 172 if (!mem || !mmio || !io)
173 goto err; 173 goto unhandled;
174 if (mem->size[1] != mmio->size[1])
175 goto unhandled;
176 if (mem->size[1] & (mem->size[1] - 1))
177 goto unhandled;
178 if (io->size[1] & (io->size[1] - 1))
179 goto unhandled;
174 180
175 if (mem->phys_addr + mem->size[1] == mmio->phys_addr) 181 if (mem->phys_addr + mem->size[1] == mmio->phys_addr)
176 mem_base = mem; 182 mem_base = mem;
177 else if (mmio->phys_addr + mmio->size[1] == mem->phys_addr) 183 else if (mmio->phys_addr + mmio->size[1] == mem->phys_addr)
178 mem_base = mmio; 184 mem_base = mmio;
179 else 185 else
180 goto err; 186 goto unhandled;
181 187
182 out_be32(&pci_regs[1][0], mem_base->phys_addr | 1); 188 out_be32(&pci_regs[1][0], mem_base->phys_addr | 1);
183 out_be32(&pci_regs[2][0], ~(mem->size[1] + mmio->size[1] - 1)); 189 out_be32(&pci_regs[2][0], ~(mem->size[1] + mmio->size[1] - 1));
@@ -201,8 +207,9 @@ static void fixup_pci(void)
201 out_le32(&pci_regs[0][58], 0); 207 out_le32(&pci_regs[0][58], 0);
202 out_le32(&pci_regs[0][60], 0); 208 out_le32(&pci_regs[0][60], 0);
203 209
204 mem_log2 = 1 << (__ilog2_u32(bd.bi_memsize - 1) + 1); 210 mem_pow2 = 1 << (__ilog2_u32(bd.bi_memsize - 1) + 1);
205 out_le32(&pci_regs[0][62], 0xa0000000 | ~((1 << (mem_log2 - 12)) - 1)); 211 mem_mask = ~(mem_pow2 - 1) >> 12;
212 out_le32(&pci_regs[0][62], 0xa0000000 | mem_mask);
206 213
207 /* If PCI is disabled, drive RST high to enable. */ 214 /* If PCI is disabled, drive RST high to enable. */
208 if (!(in_le32(&pci_regs[0][32]) & 1)) { 215 if (!(in_le32(&pci_regs[0][32]) & 1)) {
@@ -228,7 +235,11 @@ static void fixup_pci(void)
228 return; 235 return;
229 236
230err: 237err:
231 printf("Bad PCI node\r\n"); 238 printf("Bad PCI node -- using existing firmware setup.\r\n");
239 return;
240
241unhandled:
242 printf("Unsupported PCI node -- using existing firmware setup.\r\n");
232} 243}
233 244
234static void pq2_platform_fixups(void) 245static void pq2_platform_fixups(void)