diff options
-rw-r--r-- | arch/sh/drivers/pci/pcie-sh7786.c | 35 | ||||
-rw-r--r-- | arch/sh/drivers/pci/pcie-sh7786.h | 7 |
2 files changed, 25 insertions, 17 deletions
diff --git a/arch/sh/drivers/pci/pcie-sh7786.c b/arch/sh/drivers/pci/pcie-sh7786.c index aacd0fc4cdd5..b0ef380eff28 100644 --- a/arch/sh/drivers/pci/pcie-sh7786.c +++ b/arch/sh/drivers/pci/pcie-sh7786.c | |||
@@ -304,24 +304,24 @@ static int pcie_init(struct sh7786_pcie_port *port) | |||
304 | * LAR1/LAMR1. | 304 | * LAR1/LAMR1. |
305 | */ | 305 | */ |
306 | if (memsize > SZ_512M) { | 306 | if (memsize > SZ_512M) { |
307 | __raw_writel(memphys + SZ_512M, chan->reg_base + SH4A_PCIELAR1); | 307 | pci_write_reg(chan, memphys + SZ_512M, SH4A_PCIELAR1); |
308 | __raw_writel(((memsize - SZ_512M) - SZ_256) | 1, | 308 | pci_write_reg(chan, ((memsize - SZ_512M) - SZ_256) | 1, |
309 | chan->reg_base + SH4A_PCIELAMR1); | 309 | SH4A_PCIELAMR1); |
310 | memsize = SZ_512M; | 310 | memsize = SZ_512M; |
311 | } else { | 311 | } else { |
312 | /* | 312 | /* |
313 | * Otherwise just zero it out and disable it. | 313 | * Otherwise just zero it out and disable it. |
314 | */ | 314 | */ |
315 | __raw_writel(0, chan->reg_base + SH4A_PCIELAR1); | 315 | pci_write_reg(chan, 0, SH4A_PCIELAR1); |
316 | __raw_writel(0, chan->reg_base + SH4A_PCIELAMR1); | 316 | pci_write_reg(chan, 0, SH4A_PCIELAMR1); |
317 | } | 317 | } |
318 | 318 | ||
319 | /* | 319 | /* |
320 | * LAR0/LAMR0 covers up to the first 512MB, which is enough to | 320 | * LAR0/LAMR0 covers up to the first 512MB, which is enough to |
321 | * cover all of lowmem on most platforms. | 321 | * cover all of lowmem on most platforms. |
322 | */ | 322 | */ |
323 | __raw_writel(memphys, chan->reg_base + SH4A_PCIELAR0); | 323 | pci_write_reg(chan, memphys, SH4A_PCIELAR0); |
324 | __raw_writel((memsize - SZ_256) | 1, chan->reg_base + SH4A_PCIELAMR0); | 324 | pci_write_reg(chan, (memsize - SZ_256) | 1, SH4A_PCIELAMR0); |
325 | 325 | ||
326 | /* Finish initialization */ | 326 | /* Finish initialization */ |
327 | data = pci_read_reg(chan, SH4A_PCIETCTLR); | 327 | data = pci_read_reg(chan, SH4A_PCIETCTLR); |
@@ -370,7 +370,7 @@ static int pcie_init(struct sh7786_pcie_port *port) | |||
370 | for (i = win = 0; i < chan->nr_resources; i++) { | 370 | for (i = win = 0; i < chan->nr_resources; i++) { |
371 | struct resource *res = chan->resources + i; | 371 | struct resource *res = chan->resources + i; |
372 | resource_size_t size; | 372 | resource_size_t size; |
373 | u32 enable_mask; | 373 | u32 mask; |
374 | 374 | ||
375 | /* | 375 | /* |
376 | * We can't use the 32-bit mode windows in legacy 29-bit | 376 | * We can't use the 32-bit mode windows in legacy 29-bit |
@@ -381,23 +381,24 @@ static int pcie_init(struct sh7786_pcie_port *port) | |||
381 | 381 | ||
382 | pci_write_reg(chan, 0x00000000, SH4A_PCIEPTCTLR(win)); | 382 | pci_write_reg(chan, 0x00000000, SH4A_PCIEPTCTLR(win)); |
383 | 383 | ||
384 | size = resource_size(res); | ||
385 | |||
386 | /* | 384 | /* |
387 | * The PAMR mask is calculated in units of 256kB, which | 385 | * The PAMR mask is calculated in units of 256kB, which |
388 | * keeps things pretty simple. | 386 | * keeps things pretty simple. |
389 | */ | 387 | */ |
390 | __raw_writel(((roundup_pow_of_two(size) / SZ_256K) - 1) << 18, | 388 | size = resource_size(res); |
391 | chan->reg_base + SH4A_PCIEPAMR(win)); | 389 | mask = (roundup_pow_of_two(size) / SZ_256K) - 1; |
390 | pci_write_reg(chan, mask << 18, SH4A_PCIEPAMR(win)); | ||
392 | 391 | ||
393 | pci_write_reg(chan, res->start, SH4A_PCIEPARL(win)); | 392 | pci_write_reg(chan, RES_TO_U32_HIGH(res->start), |
394 | pci_write_reg(chan, 0x00000000, SH4A_PCIEPARH(win)); | 393 | SH4A_PCIEPARH(win)); |
394 | pci_write_reg(chan, RES_TO_U32_LOW(res->start), | ||
395 | SH4A_PCIEPARL(win)); | ||
395 | 396 | ||
396 | enable_mask = MASK_PARE; | 397 | mask = MASK_PARE; |
397 | if (res->flags & IORESOURCE_IO) | 398 | if (res->flags & IORESOURCE_IO) |
398 | enable_mask |= MASK_SPC; | 399 | mask |= MASK_SPC; |
399 | 400 | ||
400 | pci_write_reg(chan, enable_mask, SH4A_PCIEPTCTLR(win)); | 401 | pci_write_reg(chan, mask, SH4A_PCIEPTCTLR(win)); |
401 | 402 | ||
402 | win++; | 403 | win++; |
403 | } | 404 | } |
diff --git a/arch/sh/drivers/pci/pcie-sh7786.h b/arch/sh/drivers/pci/pcie-sh7786.h index 1ee054e47eae..a2a0ca6e7cca 100644 --- a/arch/sh/drivers/pci/pcie-sh7786.h +++ b/arch/sh/drivers/pci/pcie-sh7786.h | |||
@@ -568,6 +568,13 @@ | |||
568 | 568 | ||
569 | #define PCI_REG(x) ((x) + 0x40000) | 569 | #define PCI_REG(x) ((x) + 0x40000) |
570 | 570 | ||
571 | #define U64_TO_U32_LOW(val) ((u32)((val) & 0x00000000ffffffffULL)) | ||
572 | #define U64_TO_U32_HIGH(val) ((u32)((val) >> 32)) | ||
573 | #define RES_TO_U32_LOW(val) \ | ||
574 | ((sizeof(resource_size_t) > sizeof(u32)) ? U64_TO_U32_LOW(val) : (val)) | ||
575 | #define RES_TO_U32_HIGH(val) \ | ||
576 | ((sizeof(resource_size_t) > sizeof(u32)) ? U64_TO_U32_HIGH(val) : (0)) | ||
577 | |||
571 | static inline void | 578 | static inline void |
572 | pci_write_reg(struct pci_channel *chan, unsigned long val, unsigned long reg) | 579 | pci_write_reg(struct pci_channel *chan, unsigned long val, unsigned long reg) |
573 | { | 580 | { |