提交 84d727a1 编写于 作者: B Benjamin Herrenschmidt 提交者: Josh Boyer

powerpc/4xx: Add support for ISA holes on 4xx PCI/X/E

This adds support for ISA memory holes on the PCI, PCI-X and
PCI-E busses of the 4xx platforms. The patch includes changes
to the Bamboo and Canyonlands device-trees to add such a hole,
others can be updated separately.

The ISA memory hole is an additional outbound window configured
in the bridge to generate PCI cycles in the low memory addresses,
thus allowing to access things such as the hard-decoded VGA
aperture at 0xa0000..0xbffff or other similar things. It's made
accessible to userspace via the new legacy_mem file in sysfs for
which support was added by a previous patch.
Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: NJosh Boyer <jwboyer@linux.vnet.ibm.com>
上级 9d2421e8
...@@ -269,7 +269,8 @@ ...@@ -269,7 +269,8 @@
* later cannot be changed. Chip supports a second * later cannot be changed. Chip supports a second
* IO range but we don't use it for now * IO range but we don't use it for now
*/ */
ranges = <0x02000000 0x00000000 0xa0000000 0x00000000 0xa0000000 0x00000000 0x20000000 ranges = <0x02000000 0x00000000 0xa0000000 0x00000000 0xa0000000 0x00000000 0x40000000
0x02000000 0x00000000 0x00000000 0x00000000 0xe0000000 0x00000000 0x00100000
0x01000000 0x00000000 0x00000000 0x00000000 0xe8000000 0x00000000 0x00010000>; 0x01000000 0x00000000 0x00000000 0x00000000 0xe8000000 0x00000000 0x00010000>;
/* Inbound 2GB range starting at 0 */ /* Inbound 2GB range starting at 0 */
......
...@@ -343,6 +343,7 @@ ...@@ -343,6 +343,7 @@
* later cannot be changed * later cannot be changed
*/ */
ranges = <0x02000000 0x00000000 0x80000000 0x0000000d 0x80000000 0x00000000 0x80000000 ranges = <0x02000000 0x00000000 0x80000000 0x0000000d 0x80000000 0x00000000 0x80000000
0x02000000 0x00000000 0x00000000 0x0000000c 0x0ee00000 0x00000000 0x00100000
0x01000000 0x00000000 0x00000000 0x0000000c 0x08000000 0x00000000 0x00010000>; 0x01000000 0x00000000 0x00000000 0x0000000c 0x08000000 0x00000000 0x00010000>;
/* Inbound 2GB range starting at 0 */ /* Inbound 2GB range starting at 0 */
...@@ -373,6 +374,7 @@ ...@@ -373,6 +374,7 @@
* later cannot be changed * later cannot be changed
*/ */
ranges = <0x02000000 0x00000000 0x80000000 0x0000000e 0x00000000 0x00000000 0x80000000 ranges = <0x02000000 0x00000000 0x80000000 0x0000000e 0x00000000 0x00000000 0x80000000
0x02000000 0x00000000 0x00000000 0x0000000f 0x00000000 0x00000000 0x00100000
0x01000000 0x00000000 0x00000000 0x0000000f 0x80000000 0x00000000 0x00010000>; 0x01000000 0x00000000 0x00000000 0x0000000f 0x80000000 0x00000000 0x00010000>;
/* Inbound 2GB range starting at 0 */ /* Inbound 2GB range starting at 0 */
...@@ -414,6 +416,7 @@ ...@@ -414,6 +416,7 @@
* later cannot be changed * later cannot be changed
*/ */
ranges = <0x02000000 0x00000000 0x80000000 0x0000000e 0x80000000 0x00000000 0x80000000 ranges = <0x02000000 0x00000000 0x80000000 0x0000000e 0x80000000 0x00000000 0x80000000
0x02000000 0x00000000 0x00000000 0x0000000f 0x00100000 0x00000000 0x00100000
0x01000000 0x00000000 0x00000000 0x0000000f 0x80010000 0x00000000 0x00010000>; 0x01000000 0x00000000 0x00000000 0x0000000f 0x80010000 0x00000000 0x00010000>;
/* Inbound 2GB range starting at 0 */ /* Inbound 2GB range starting at 0 */
......
...@@ -194,11 +194,41 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose, ...@@ -194,11 +194,41 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
* 4xx PCI 2.x part * 4xx PCI 2.x part
*/ */
static int __init ppc4xx_setup_one_pci_PMM(struct pci_controller *hose,
void __iomem *reg,
u64 plb_addr,
u64 pci_addr,
u64 size,
unsigned int flags,
int index)
{
u32 ma, pcila, pciha;
if ((plb_addr + size) > 0xffffffffull || !is_power_of_2(size) ||
size < 0x1000 || (plb_addr & (size - 1)) != 0) {
printk(KERN_WARNING "%s: Resource out of range\n",
hose->dn->full_name);
return -1;
}
ma = (0xffffffffu << ilog2(size)) | 1;
if (flags & IORESOURCE_PREFETCH)
ma |= 2;
pciha = RES_TO_U32_HIGH(pci_addr);
pcila = RES_TO_U32_LOW(pci_addr);
writel(plb_addr, reg + PCIL0_PMM0LA + (0x10 * index));
writel(pcila, reg + PCIL0_PMM0PCILA + (0x10 * index));
writel(pciha, reg + PCIL0_PMM0PCIHA + (0x10 * index));
writel(ma, reg + PCIL0_PMM0MA + (0x10 * index));
return 0;
}
static void __init ppc4xx_configure_pci_PMMs(struct pci_controller *hose, static void __init ppc4xx_configure_pci_PMMs(struct pci_controller *hose,
void __iomem *reg) void __iomem *reg)
{ {
u32 la, ma, pcila, pciha; int i, j, found_isa_hole = 0;
int i, j;
/* Setup outbound memory windows */ /* Setup outbound memory windows */
for (i = j = 0; i < 3; i++) { for (i = j = 0; i < 3; i++) {
...@@ -213,28 +243,29 @@ static void __init ppc4xx_configure_pci_PMMs(struct pci_controller *hose, ...@@ -213,28 +243,29 @@ static void __init ppc4xx_configure_pci_PMMs(struct pci_controller *hose,
break; break;
} }
/* Calculate register values */ /* Configure the resource */
la = res->start; if (ppc4xx_setup_one_pci_PMM(hose, reg,
pciha = RES_TO_U32_HIGH(res->start - hose->pci_mem_offset); res->start,
pcila = RES_TO_U32_LOW(res->start - hose->pci_mem_offset); res->start - hose->pci_mem_offset,
res->end + 1 - res->start,
ma = res->end + 1 - res->start; res->flags,
if (!is_power_of_2(ma) || ma < 0x1000 || ma > 0xffffffffu) { j) == 0) {
printk(KERN_WARNING "%s: Resource out of range\n", j++;
hose->dn->full_name);
continue; /* If the resource PCI address is 0 then we have our
* ISA memory hole
*/
if (res->start == hose->pci_mem_offset)
found_isa_hole = 1;
} }
ma = (0xffffffffu << ilog2(ma)) | 0x1;
if (res->flags & IORESOURCE_PREFETCH)
ma |= 0x2;
/* Program register values */
writel(la, reg + PCIL0_PMM0LA + (0x10 * j));
writel(pcila, reg + PCIL0_PMM0PCILA + (0x10 * j));
writel(pciha, reg + PCIL0_PMM0PCIHA + (0x10 * j));
writel(ma, reg + PCIL0_PMM0MA + (0x10 * j));
j++;
} }
/* Handle ISA memory hole if not already covered */
if (j <= 2 && !found_isa_hole && hose->isa_mem_size)
if (ppc4xx_setup_one_pci_PMM(hose, reg, hose->isa_mem_phys, 0,
hose->isa_mem_size, 0, j) == 0)
printk(KERN_INFO "%s: Legacy ISA memory support enabled\n",
hose->dn->full_name);
} }
static void __init ppc4xx_configure_pci_PTMs(struct pci_controller *hose, static void __init ppc4xx_configure_pci_PTMs(struct pci_controller *hose,
...@@ -352,11 +383,52 @@ static void __init ppc4xx_probe_pci_bridge(struct device_node *np) ...@@ -352,11 +383,52 @@ static void __init ppc4xx_probe_pci_bridge(struct device_node *np)
* 4xx PCI-X part * 4xx PCI-X part
*/ */
static int __init ppc4xx_setup_one_pcix_POM(struct pci_controller *hose,
void __iomem *reg,
u64 plb_addr,
u64 pci_addr,
u64 size,
unsigned int flags,
int index)
{
u32 lah, lal, pciah, pcial, sa;
if (!is_power_of_2(size) || size < 0x1000 ||
(plb_addr & (size - 1)) != 0) {
printk(KERN_WARNING "%s: Resource out of range\n",
hose->dn->full_name);
return -1;
}
/* Calculate register values */
lah = RES_TO_U32_HIGH(plb_addr);
lal = RES_TO_U32_LOW(plb_addr);
pciah = RES_TO_U32_HIGH(pci_addr);
pcial = RES_TO_U32_LOW(pci_addr);
sa = (0xffffffffu << ilog2(size)) | 0x1;
/* Program register values */
if (index == 0) {
writel(lah, reg + PCIX0_POM0LAH);
writel(lal, reg + PCIX0_POM0LAL);
writel(pciah, reg + PCIX0_POM0PCIAH);
writel(pcial, reg + PCIX0_POM0PCIAL);
writel(sa, reg + PCIX0_POM0SA);
} else {
writel(lah, reg + PCIX0_POM1LAH);
writel(lal, reg + PCIX0_POM1LAL);
writel(pciah, reg + PCIX0_POM1PCIAH);
writel(pcial, reg + PCIX0_POM1PCIAL);
writel(sa, reg + PCIX0_POM1SA);
}
return 0;
}
static void __init ppc4xx_configure_pcix_POMs(struct pci_controller *hose, static void __init ppc4xx_configure_pcix_POMs(struct pci_controller *hose,
void __iomem *reg) void __iomem *reg)
{ {
u32 lah, lal, pciah, pcial, sa; int i, j, found_isa_hole = 0;
int i, j;
/* Setup outbound memory windows */ /* Setup outbound memory windows */
for (i = j = 0; i < 3; i++) { for (i = j = 0; i < 3; i++) {
...@@ -371,36 +443,29 @@ static void __init ppc4xx_configure_pcix_POMs(struct pci_controller *hose, ...@@ -371,36 +443,29 @@ static void __init ppc4xx_configure_pcix_POMs(struct pci_controller *hose,
break; break;
} }
/* Calculate register values */ /* Configure the resource */
lah = RES_TO_U32_HIGH(res->start); if (ppc4xx_setup_one_pcix_POM(hose, reg,
lal = RES_TO_U32_LOW(res->start); res->start,
pciah = RES_TO_U32_HIGH(res->start - hose->pci_mem_offset); res->start - hose->pci_mem_offset,
pcial = RES_TO_U32_LOW(res->start - hose->pci_mem_offset); res->end + 1 - res->start,
sa = res->end + 1 - res->start; res->flags,
if (!is_power_of_2(sa) || sa < 0x100000 || j) == 0) {
sa > 0xffffffffu) { j++;
printk(KERN_WARNING "%s: Resource out of range\n",
hose->dn->full_name); /* If the resource PCI address is 0 then we have our
continue; * ISA memory hole
*/
if (res->start == hose->pci_mem_offset)
found_isa_hole = 1;
} }
sa = (0xffffffffu << ilog2(sa)) | 0x1;
/* Program register values */
if (j == 0) {
writel(lah, reg + PCIX0_POM0LAH);
writel(lal, reg + PCIX0_POM0LAL);
writel(pciah, reg + PCIX0_POM0PCIAH);
writel(pcial, reg + PCIX0_POM0PCIAL);
writel(sa, reg + PCIX0_POM0SA);
} else {
writel(lah, reg + PCIX0_POM1LAH);
writel(lal, reg + PCIX0_POM1LAL);
writel(pciah, reg + PCIX0_POM1PCIAH);
writel(pcial, reg + PCIX0_POM1PCIAL);
writel(sa, reg + PCIX0_POM1SA);
}
j++;
} }
/* Handle ISA memory hole if not already covered */
if (j <= 1 && !found_isa_hole && hose->isa_mem_size)
if (ppc4xx_setup_one_pcix_POM(hose, reg, hose->isa_mem_phys, 0,
hose->isa_mem_size, 0, j) == 0)
printk(KERN_INFO "%s: Legacy ISA memory support enabled\n",
hose->dn->full_name);
} }
static void __init ppc4xx_configure_pcix_PIMs(struct pci_controller *hose, static void __init ppc4xx_configure_pcix_PIMs(struct pci_controller *hose,
...@@ -1317,12 +1382,72 @@ static struct pci_ops ppc4xx_pciex_pci_ops = ...@@ -1317,12 +1382,72 @@ static struct pci_ops ppc4xx_pciex_pci_ops =
.write = ppc4xx_pciex_write_config, .write = ppc4xx_pciex_write_config,
}; };
static int __init ppc4xx_setup_one_pciex_POM(struct ppc4xx_pciex_port *port,
struct pci_controller *hose,
void __iomem *mbase,
u64 plb_addr,
u64 pci_addr,
u64 size,
unsigned int flags,
int index)
{
u32 lah, lal, pciah, pcial, sa;
if (!is_power_of_2(size) ||
(index < 2 && size < 0x100000) ||
(index == 2 && size < 0x100) ||
(plb_addr & (size - 1)) != 0) {
printk(KERN_WARNING "%s: Resource out of range\n",
hose->dn->full_name);
return -1;
}
/* Calculate register values */
lah = RES_TO_U32_HIGH(plb_addr);
lal = RES_TO_U32_LOW(plb_addr);
pciah = RES_TO_U32_HIGH(pci_addr);
pcial = RES_TO_U32_LOW(pci_addr);
sa = (0xffffffffu << ilog2(size)) | 0x1;
/* Program register values */
switch (index) {
case 0:
out_le32(mbase + PECFG_POM0LAH, pciah);
out_le32(mbase + PECFG_POM0LAL, pcial);
dcr_write(port->dcrs, DCRO_PEGPL_OMR1BAH, lah);
dcr_write(port->dcrs, DCRO_PEGPL_OMR1BAL, lal);
dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKH, 0x7fffffff);
/* Note that 3 here means enabled | single region */
dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKL, sa | 3);
break;
case 1:
out_le32(mbase + PECFG_POM1LAH, pciah);
out_le32(mbase + PECFG_POM1LAL, pcial);
dcr_write(port->dcrs, DCRO_PEGPL_OMR2BAH, lah);
dcr_write(port->dcrs, DCRO_PEGPL_OMR2BAL, lal);
dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKH, 0x7fffffff);
/* Note that 3 here means enabled | single region */
dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKL, sa | 3);
break;
case 2:
out_le32(mbase + PECFG_POM2LAH, pciah);
out_le32(mbase + PECFG_POM2LAL, pcial);
dcr_write(port->dcrs, DCRO_PEGPL_OMR3BAH, lah);
dcr_write(port->dcrs, DCRO_PEGPL_OMR3BAL, lal);
dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKH, 0x7fffffff);
/* Note that 3 here means enabled | IO space !!! */
dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKL, sa | 3);
break;
}
return 0;
}
static void __init ppc4xx_configure_pciex_POMs(struct ppc4xx_pciex_port *port, static void __init ppc4xx_configure_pciex_POMs(struct ppc4xx_pciex_port *port,
struct pci_controller *hose, struct pci_controller *hose,
void __iomem *mbase) void __iomem *mbase)
{ {
u32 lah, lal, pciah, pcial, sa; int i, j, found_isa_hole = 0;
int i, j;
/* Setup outbound memory windows */ /* Setup outbound memory windows */
for (i = j = 0; i < 3; i++) { for (i = j = 0; i < 3; i++) {
...@@ -1337,53 +1462,38 @@ static void __init ppc4xx_configure_pciex_POMs(struct ppc4xx_pciex_port *port, ...@@ -1337,53 +1462,38 @@ static void __init ppc4xx_configure_pciex_POMs(struct ppc4xx_pciex_port *port,
break; break;
} }
/* Calculate register values */ /* Configure the resource */
lah = RES_TO_U32_HIGH(res->start); if (ppc4xx_setup_one_pciex_POM(port, hose, mbase,
lal = RES_TO_U32_LOW(res->start); res->start,
pciah = RES_TO_U32_HIGH(res->start - hose->pci_mem_offset); res->start - hose->pci_mem_offset,
pcial = RES_TO_U32_LOW(res->start - hose->pci_mem_offset); res->end + 1 - res->start,
sa = res->end + 1 - res->start; res->flags,
if (!is_power_of_2(sa) || sa < 0x100000 || j) == 0) {
sa > 0xffffffffu) { j++;
printk(KERN_WARNING "%s: Resource out of range\n",
port->node->full_name); /* If the resource PCI address is 0 then we have our
continue; * ISA memory hole
} */
sa = (0xffffffffu << ilog2(sa)) | 0x1; if (res->start == hose->pci_mem_offset)
found_isa_hole = 1;
/* Program register values */
switch (j) {
case 0:
out_le32(mbase + PECFG_POM0LAH, pciah);
out_le32(mbase + PECFG_POM0LAL, pcial);
dcr_write(port->dcrs, DCRO_PEGPL_OMR1BAH, lah);
dcr_write(port->dcrs, DCRO_PEGPL_OMR1BAL, lal);
dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKH, 0x7fffffff);
dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKL, sa | 3);
break;
case 1:
out_le32(mbase + PECFG_POM1LAH, pciah);
out_le32(mbase + PECFG_POM1LAL, pcial);
dcr_write(port->dcrs, DCRO_PEGPL_OMR2BAH, lah);
dcr_write(port->dcrs, DCRO_PEGPL_OMR2BAL, lal);
dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKH, 0x7fffffff);
dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKL, sa | 3);
break;
} }
j++;
} }
/* Configure IO, always 64K starting at 0 */ /* Handle ISA memory hole if not already covered */
if (hose->io_resource.flags & IORESOURCE_IO) { if (j <= 1 && !found_isa_hole && hose->isa_mem_size)
lah = RES_TO_U32_HIGH(hose->io_base_phys); if (ppc4xx_setup_one_pciex_POM(port, hose, mbase,
lal = RES_TO_U32_LOW(hose->io_base_phys); hose->isa_mem_phys, 0,
out_le32(mbase + PECFG_POM2LAH, 0); hose->isa_mem_size, 0, j) == 0)
out_le32(mbase + PECFG_POM2LAL, 0); printk(KERN_INFO "%s: Legacy ISA memory support enabled\n",
dcr_write(port->dcrs, DCRO_PEGPL_OMR3BAH, lah); hose->dn->full_name);
dcr_write(port->dcrs, DCRO_PEGPL_OMR3BAL, lal);
dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKH, 0x7fffffff); /* Configure IO, always 64K starting at 0. We hard wire it to 64K !
dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKL, 0xffff0000 | 3); * Note also that it -has- to be region index 2 on this HW
} */
if (hose->io_resource.flags & IORESOURCE_IO)
ppc4xx_setup_one_pciex_POM(port, hose, mbase,
hose->io_base_phys, 0,
0x10000, IORESOURCE_IO, 2);
} }
static void __init ppc4xx_configure_pciex_PIMs(struct ppc4xx_pciex_port *port, static void __init ppc4xx_configure_pciex_PIMs(struct ppc4xx_pciex_port *port,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册