diff options
| author | Jonas Gorski <jonas.gorski@gmail.com> | 2012-07-24 10:33:13 -0400 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2012-07-24 10:33:13 -0400 |
| commit | 19c860d932de520017c9b2d88cd9dff90b71ba36 (patch) | |
| tree | 2feb7f7cb1c91f5bdd6ce761ff4e421814237274 | |
| parent | 76f42fe8117c85fced0135b23835890cfa41a47b (diff) | |
MIPS: BCM63XX: Add PCIe Support for BCM6328
Add support for the PCIe port found on BCM6328.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: Maxime Bizon <mbizon@freebox.fr>
Cc: Florian Fainelli <florian@openwrt.org>
Cc: Kevin Cernekee <cernekee@gmail.com>
Patchwork: https://patchwork.linux-mips.org/patch/3956/
Reviewed-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
| -rw-r--r-- | arch/mips/bcm63xx/Kconfig | 1 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | 9 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h | 6 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 54 | ||||
| -rw-r--r-- | arch/mips/pci/ops-bcm63xx.c | 61 | ||||
| -rw-r--r-- | arch/mips/pci/pci-bcm63xx.c | 112 | ||||
| -rw-r--r-- | arch/mips/pci/pci-bcm63xx.h | 5 |
7 files changed, 248 insertions, 0 deletions
diff --git a/arch/mips/bcm63xx/Kconfig b/arch/mips/bcm63xx/Kconfig index 09e93cab37b5..d03e8799d1cf 100644 --- a/arch/mips/bcm63xx/Kconfig +++ b/arch/mips/bcm63xx/Kconfig | |||
| @@ -3,6 +3,7 @@ menu "CPU support" | |||
| 3 | 3 | ||
| 4 | config BCM63XX_CPU_6328 | 4 | config BCM63XX_CPU_6328 |
| 5 | bool "support 6328 CPU" | 5 | bool "support 6328 CPU" |
| 6 | select HW_HAS_PCI | ||
| 6 | 7 | ||
| 7 | config BCM63XX_CPU_6338 | 8 | config BCM63XX_CPU_6338 |
| 8 | bool "support 6338 CPU" | 9 | bool "support 6338 CPU" |
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h index b842b6d2ba5e..e104ddb694a8 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | |||
| @@ -122,6 +122,7 @@ enum bcm63xx_regs_set { | |||
| 122 | RSET_USBH_PRIV, | 122 | RSET_USBH_PRIV, |
| 123 | RSET_MPI, | 123 | RSET_MPI, |
| 124 | RSET_PCMCIA, | 124 | RSET_PCMCIA, |
| 125 | RSET_PCIE, | ||
| 125 | RSET_DSL, | 126 | RSET_DSL, |
| 126 | RSET_ENET0, | 127 | RSET_ENET0, |
| 127 | RSET_ENET1, | 128 | RSET_ENET1, |
| @@ -188,6 +189,7 @@ enum bcm63xx_regs_set { | |||
| 188 | #define BCM_6328_USBH_PRIV_BASE (0xdeadbeef) | 189 | #define BCM_6328_USBH_PRIV_BASE (0xdeadbeef) |
| 189 | #define BCM_6328_MPI_BASE (0xdeadbeef) | 190 | #define BCM_6328_MPI_BASE (0xdeadbeef) |
| 190 | #define BCM_6328_PCMCIA_BASE (0xdeadbeef) | 191 | #define BCM_6328_PCMCIA_BASE (0xdeadbeef) |
| 192 | #define BCM_6328_PCIE_BASE (0xb0e40000) | ||
| 191 | #define BCM_6328_SDRAM_REGS_BASE (0xdeadbeef) | 193 | #define BCM_6328_SDRAM_REGS_BASE (0xdeadbeef) |
| 192 | #define BCM_6328_DSL_BASE (0xb0001900) | 194 | #define BCM_6328_DSL_BASE (0xb0001900) |
| 193 | #define BCM_6328_UBUS_BASE (0xdeadbeef) | 195 | #define BCM_6328_UBUS_BASE (0xdeadbeef) |
| @@ -232,6 +234,7 @@ enum bcm63xx_regs_set { | |||
| 232 | #define BCM_6338_USBH_PRIV_BASE (0xdeadbeef) | 234 | #define BCM_6338_USBH_PRIV_BASE (0xdeadbeef) |
| 233 | #define BCM_6338_MPI_BASE (0xfffe3160) | 235 | #define BCM_6338_MPI_BASE (0xfffe3160) |
| 234 | #define BCM_6338_PCMCIA_BASE (0xdeadbeef) | 236 | #define BCM_6338_PCMCIA_BASE (0xdeadbeef) |
| 237 | #define BCM_6338_PCIE_BASE (0xdeadbeef) | ||
| 235 | #define BCM_6338_SDRAM_REGS_BASE (0xfffe3100) | 238 | #define BCM_6338_SDRAM_REGS_BASE (0xfffe3100) |
| 236 | #define BCM_6338_DSL_BASE (0xfffe1000) | 239 | #define BCM_6338_DSL_BASE (0xfffe1000) |
| 237 | #define BCM_6338_UBUS_BASE (0xdeadbeef) | 240 | #define BCM_6338_UBUS_BASE (0xdeadbeef) |
| @@ -279,6 +282,7 @@ enum bcm63xx_regs_set { | |||
| 279 | #define BCM_6345_ENETSW_BASE (0xdeadbeef) | 282 | #define BCM_6345_ENETSW_BASE (0xdeadbeef) |
| 280 | #define BCM_6345_PCMCIA_BASE (0xfffe2028) | 283 | #define BCM_6345_PCMCIA_BASE (0xfffe2028) |
| 281 | #define BCM_6345_MPI_BASE (0xfffe2000) | 284 | #define BCM_6345_MPI_BASE (0xfffe2000) |
| 285 | #define BCM_6345_PCIE_BASE (0xdeadbeef) | ||
| 282 | #define BCM_6345_OHCI0_BASE (0xfffe2100) | 286 | #define BCM_6345_OHCI0_BASE (0xfffe2100) |
| 283 | #define BCM_6345_OHCI_PRIV_BASE (0xfffe2200) | 287 | #define BCM_6345_OHCI_PRIV_BASE (0xfffe2200) |
| 284 | #define BCM_6345_USBH_PRIV_BASE (0xdeadbeef) | 288 | #define BCM_6345_USBH_PRIV_BASE (0xdeadbeef) |
| @@ -320,6 +324,7 @@ enum bcm63xx_regs_set { | |||
| 320 | #define BCM_6348_USBH_PRIV_BASE (0xdeadbeef) | 324 | #define BCM_6348_USBH_PRIV_BASE (0xdeadbeef) |
| 321 | #define BCM_6348_MPI_BASE (0xfffe2000) | 325 | #define BCM_6348_MPI_BASE (0xfffe2000) |
| 322 | #define BCM_6348_PCMCIA_BASE (0xfffe2054) | 326 | #define BCM_6348_PCMCIA_BASE (0xfffe2054) |
| 327 | #define BCM_6348_PCIE_BASE (0xdeadbeef) | ||
| 323 | #define BCM_6348_SDRAM_REGS_BASE (0xfffe2300) | 328 | #define BCM_6348_SDRAM_REGS_BASE (0xfffe2300) |
| 324 | #define BCM_6348_M2M_BASE (0xfffe2800) | 329 | #define BCM_6348_M2M_BASE (0xfffe2800) |
| 325 | #define BCM_6348_DSL_BASE (0xfffe3000) | 330 | #define BCM_6348_DSL_BASE (0xfffe3000) |
| @@ -362,6 +367,7 @@ enum bcm63xx_regs_set { | |||
| 362 | #define BCM_6358_USBH_PRIV_BASE (0xfffe1500) | 367 | #define BCM_6358_USBH_PRIV_BASE (0xfffe1500) |
| 363 | #define BCM_6358_MPI_BASE (0xfffe1000) | 368 | #define BCM_6358_MPI_BASE (0xfffe1000) |
| 364 | #define BCM_6358_PCMCIA_BASE (0xfffe1054) | 369 | #define BCM_6358_PCMCIA_BASE (0xfffe1054) |
| 370 | #define BCM_6358_PCIE_BASE (0xdeadbeef) | ||
| 365 | #define BCM_6358_SDRAM_REGS_BASE (0xfffe2300) | 371 | #define BCM_6358_SDRAM_REGS_BASE (0xfffe2300) |
| 366 | #define BCM_6358_M2M_BASE (0xdeadbeef) | 372 | #define BCM_6358_M2M_BASE (0xdeadbeef) |
| 367 | #define BCM_6358_DSL_BASE (0xfffe3000) | 373 | #define BCM_6358_DSL_BASE (0xfffe3000) |
| @@ -405,6 +411,7 @@ enum bcm63xx_regs_set { | |||
| 405 | #define BCM_6368_USBH_PRIV_BASE (0xb0001700) | 411 | #define BCM_6368_USBH_PRIV_BASE (0xb0001700) |
| 406 | #define BCM_6368_MPI_BASE (0xb0001000) | 412 | #define BCM_6368_MPI_BASE (0xb0001000) |
| 407 | #define BCM_6368_PCMCIA_BASE (0xb0001054) | 413 | #define BCM_6368_PCMCIA_BASE (0xb0001054) |
| 414 | #define BCM_6368_PCIE_BASE (0xdeadbeef) | ||
| 408 | #define BCM_6368_SDRAM_REGS_BASE (0xdeadbeef) | 415 | #define BCM_6368_SDRAM_REGS_BASE (0xdeadbeef) |
| 409 | #define BCM_6368_M2M_BASE (0xdeadbeef) | 416 | #define BCM_6368_M2M_BASE (0xdeadbeef) |
| 410 | #define BCM_6368_DSL_BASE (0xdeadbeef) | 417 | #define BCM_6368_DSL_BASE (0xdeadbeef) |
| @@ -453,6 +460,7 @@ extern const unsigned long *bcm63xx_regs_base; | |||
| 453 | __GEN_RSET_BASE(__cpu, USBH_PRIV) \ | 460 | __GEN_RSET_BASE(__cpu, USBH_PRIV) \ |
| 454 | __GEN_RSET_BASE(__cpu, MPI) \ | 461 | __GEN_RSET_BASE(__cpu, MPI) \ |
| 455 | __GEN_RSET_BASE(__cpu, PCMCIA) \ | 462 | __GEN_RSET_BASE(__cpu, PCMCIA) \ |
| 463 | __GEN_RSET_BASE(__cpu, PCIE) \ | ||
| 456 | __GEN_RSET_BASE(__cpu, DSL) \ | 464 | __GEN_RSET_BASE(__cpu, DSL) \ |
| 457 | __GEN_RSET_BASE(__cpu, ENET0) \ | 465 | __GEN_RSET_BASE(__cpu, ENET0) \ |
| 458 | __GEN_RSET_BASE(__cpu, ENET1) \ | 466 | __GEN_RSET_BASE(__cpu, ENET1) \ |
| @@ -493,6 +501,7 @@ extern const unsigned long *bcm63xx_regs_base; | |||
| 493 | [RSET_USBH_PRIV] = BCM_## __cpu ##_USBH_PRIV_BASE, \ | 501 | [RSET_USBH_PRIV] = BCM_## __cpu ##_USBH_PRIV_BASE, \ |
| 494 | [RSET_MPI] = BCM_## __cpu ##_MPI_BASE, \ | 502 | [RSET_MPI] = BCM_## __cpu ##_MPI_BASE, \ |
| 495 | [RSET_PCMCIA] = BCM_## __cpu ##_PCMCIA_BASE, \ | 503 | [RSET_PCMCIA] = BCM_## __cpu ##_PCMCIA_BASE, \ |
| 504 | [RSET_PCIE] = BCM_## __cpu ##_PCIE_BASE, \ | ||
| 496 | [RSET_DSL] = BCM_## __cpu ##_DSL_BASE, \ | 505 | [RSET_DSL] = BCM_## __cpu ##_DSL_BASE, \ |
| 497 | [RSET_ENET0] = BCM_## __cpu ##_ENET0_BASE, \ | 506 | [RSET_ENET0] = BCM_## __cpu ##_ENET0_BASE, \ |
| 498 | [RSET_ENET1] = BCM_## __cpu ##_ENET1_BASE, \ | 507 | [RSET_ENET1] = BCM_## __cpu ##_ENET1_BASE, \ |
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h index 6dcd8b23592b..9203d90e610c 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h | |||
| @@ -40,6 +40,10 @@ | |||
| 40 | #define BCM_CB_MEM_END_PA (BCM_CB_MEM_BASE_PA + \ | 40 | #define BCM_CB_MEM_END_PA (BCM_CB_MEM_BASE_PA + \ |
| 41 | BCM_CB_MEM_SIZE - 1) | 41 | BCM_CB_MEM_SIZE - 1) |
| 42 | 42 | ||
| 43 | #define BCM_PCIE_MEM_BASE_PA 0x10f00000 | ||
| 44 | #define BCM_PCIE_MEM_SIZE (16 * 1024 * 1024) | ||
| 45 | #define BCM_PCIE_MEM_END_PA (BCM_PCIE_MEM_BASE_PA + \ | ||
| 46 | BCM_PCIE_MEM_SIZE - 1) | ||
| 43 | 47 | ||
| 44 | /* | 48 | /* |
| 45 | * Internal registers are accessed through KSEG3 | 49 | * Internal registers are accessed through KSEG3 |
| @@ -85,6 +89,8 @@ | |||
| 85 | #define bcm_mpi_writel(v, o) bcm_rset_writel(RSET_MPI, (v), (o)) | 89 | #define bcm_mpi_writel(v, o) bcm_rset_writel(RSET_MPI, (v), (o)) |
| 86 | #define bcm_pcmcia_readl(o) bcm_rset_readl(RSET_PCMCIA, (o)) | 90 | #define bcm_pcmcia_readl(o) bcm_rset_readl(RSET_PCMCIA, (o)) |
| 87 | #define bcm_pcmcia_writel(v, o) bcm_rset_writel(RSET_PCMCIA, (v), (o)) | 91 | #define bcm_pcmcia_writel(v, o) bcm_rset_writel(RSET_PCMCIA, (v), (o)) |
| 92 | #define bcm_pcie_readl(o) bcm_rset_readl(RSET_PCIE, (o)) | ||
| 93 | #define bcm_pcie_writel(v, o) bcm_rset_writel(RSET_PCIE, (v), (o)) | ||
| 88 | #define bcm_sdram_readl(o) bcm_rset_readl(RSET_SDRAM, (o)) | 94 | #define bcm_sdram_readl(o) bcm_rset_readl(RSET_SDRAM, (o)) |
| 89 | #define bcm_sdram_writel(v, o) bcm_rset_writel(RSET_SDRAM, (v), (o)) | 95 | #define bcm_sdram_writel(v, o) bcm_rset_writel(RSET_SDRAM, (v), (o)) |
| 90 | #define bcm_memc_readl(o) bcm_rset_readl(RSET_MEMC, (o)) | 96 | #define bcm_memc_readl(o) bcm_rset_readl(RSET_MEMC, (o)) |
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h index 4fc2ab2c278a..4ccc2a748aff 100644 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | |||
| @@ -1162,6 +1162,9 @@ | |||
| 1162 | /************************************************************************* | 1162 | /************************************************************************* |
| 1163 | * _REG relative to RSET_MISC | 1163 | * _REG relative to RSET_MISC |
| 1164 | *************************************************************************/ | 1164 | *************************************************************************/ |
| 1165 | #define MISC_SERDES_CTRL_REG 0x0 | ||
| 1166 | #define SERDES_PCIE_EN (1 << 0) | ||
| 1167 | #define SERDES_PCIE_EXD_EN (1 << 15) | ||
| 1165 | 1168 | ||
| 1166 | #define MISC_STRAPBUS_6328_REG 0x240 | 1169 | #define MISC_STRAPBUS_6328_REG 0x240 |
| 1167 | #define STRAPBUS_6328_FCVO_SHIFT 7 | 1170 | #define STRAPBUS_6328_FCVO_SHIFT 7 |
| @@ -1169,4 +1172,55 @@ | |||
| 1169 | #define STRAPBUS_6328_BOOT_SEL_SERIAL (1 << 28) | 1172 | #define STRAPBUS_6328_BOOT_SEL_SERIAL (1 << 28) |
| 1170 | #define STRAPBUS_6328_BOOT_SEL_NAND (0 << 28) | 1173 | #define STRAPBUS_6328_BOOT_SEL_NAND (0 << 28) |
| 1171 | 1174 | ||
| 1175 | /************************************************************************* | ||
| 1176 | * _REG relative to RSET_PCIE | ||
| 1177 | *************************************************************************/ | ||
| 1178 | |||
| 1179 | #define PCIE_CONFIG2_REG 0x408 | ||
| 1180 | #define CONFIG2_BAR1_SIZE_EN 1 | ||
| 1181 | #define CONFIG2_BAR1_SIZE_MASK 0xf | ||
| 1182 | |||
| 1183 | #define PCIE_IDVAL3_REG 0x43c | ||
| 1184 | #define IDVAL3_CLASS_CODE_MASK 0xffffff | ||
| 1185 | #define IDVAL3_SUBCLASS_SHIFT 8 | ||
| 1186 | #define IDVAL3_CLASS_SHIFT 16 | ||
| 1187 | |||
| 1188 | #define PCIE_DLSTATUS_REG 0x1048 | ||
| 1189 | #define DLSTATUS_PHYLINKUP (1 << 13) | ||
| 1190 | |||
| 1191 | #define PCIE_BRIDGE_OPT1_REG 0x2820 | ||
| 1192 | #define OPT1_RD_BE_OPT_EN (1 << 7) | ||
| 1193 | #define OPT1_RD_REPLY_BE_FIX_EN (1 << 9) | ||
| 1194 | #define OPT1_PCIE_BRIDGE_HOLE_DET_EN (1 << 11) | ||
| 1195 | #define OPT1_L1_INT_STATUS_MASK_POL (1 << 12) | ||
| 1196 | |||
| 1197 | #define PCIE_BRIDGE_OPT2_REG 0x2824 | ||
| 1198 | #define OPT2_UBUS_UR_DECODE_DIS (1 << 2) | ||
| 1199 | #define OPT2_TX_CREDIT_CHK_EN (1 << 4) | ||
| 1200 | #define OPT2_CFG_TYPE1_BD_SEL (1 << 7) | ||
| 1201 | #define OPT2_CFG_TYPE1_BUS_NO_SHIFT 16 | ||
| 1202 | #define OPT2_CFG_TYPE1_BUS_NO_MASK (0xff << OPT2_CFG_TYPE1_BUS_NO_SHIFT) | ||
| 1203 | |||
| 1204 | #define PCIE_BRIDGE_BAR0_BASEMASK_REG 0x2828 | ||
| 1205 | #define PCIE_BRIDGE_BAR1_BASEMASK_REG 0x2830 | ||
| 1206 | #define BASEMASK_REMAP_EN (1 << 0) | ||
| 1207 | #define BASEMASK_SWAP_EN (1 << 1) | ||
| 1208 | #define BASEMASK_MASK_SHIFT 4 | ||
| 1209 | #define BASEMASK_MASK_MASK (0xfff << BASEMASK_MASK_SHIFT) | ||
| 1210 | #define BASEMASK_BASE_SHIFT 20 | ||
| 1211 | #define BASEMASK_BASE_MASK (0xfff << BASEMASK_BASE_SHIFT) | ||
| 1212 | |||
| 1213 | #define PCIE_BRIDGE_BAR0_REBASE_ADDR_REG 0x282c | ||
| 1214 | #define PCIE_BRIDGE_BAR1_REBASE_ADDR_REG 0x2834 | ||
| 1215 | #define REBASE_ADDR_BASE_SHIFT 20 | ||
| 1216 | #define REBASE_ADDR_BASE_MASK (0xfff << REBASE_ADDR_BASE_SHIFT) | ||
| 1217 | |||
| 1218 | #define PCIE_BRIDGE_RC_INT_MASK_REG 0x2854 | ||
| 1219 | #define PCIE_RC_INT_A (1 << 0) | ||
| 1220 | #define PCIE_RC_INT_B (1 << 1) | ||
| 1221 | #define PCIE_RC_INT_C (1 << 2) | ||
| 1222 | #define PCIE_RC_INT_D (1 << 3) | ||
| 1223 | |||
| 1224 | #define PCIE_DEVICE_OFFSET 0x8000 | ||
| 1225 | |||
| 1172 | #endif /* BCM63XX_REGS_H_ */ | 1226 | #endif /* BCM63XX_REGS_H_ */ |
diff --git a/arch/mips/pci/ops-bcm63xx.c b/arch/mips/pci/ops-bcm63xx.c index 822ae179bc56..4a156629e958 100644 --- a/arch/mips/pci/ops-bcm63xx.c +++ b/arch/mips/pci/ops-bcm63xx.c | |||
| @@ -465,3 +465,64 @@ static void bcm63xx_fixup(struct pci_dev *dev) | |||
| 465 | 465 | ||
| 466 | DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, bcm63xx_fixup); | 466 | DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, bcm63xx_fixup); |
| 467 | #endif | 467 | #endif |
| 468 | |||
| 469 | static int bcm63xx_pcie_can_access(struct pci_bus *bus, int devfn) | ||
| 470 | { | ||
| 471 | switch (bus->number) { | ||
| 472 | case PCIE_BUS_BRIDGE: | ||
| 473 | return (PCI_SLOT(devfn) == 0); | ||
| 474 | case PCIE_BUS_DEVICE: | ||
| 475 | if (PCI_SLOT(devfn) == 0) | ||
| 476 | return bcm_pcie_readl(PCIE_DLSTATUS_REG) | ||
| 477 | & DLSTATUS_PHYLINKUP; | ||
| 478 | default: | ||
| 479 | return false; | ||
| 480 | } | ||
| 481 | } | ||
| 482 | |||
| 483 | static int bcm63xx_pcie_read(struct pci_bus *bus, unsigned int devfn, | ||
| 484 | int where, int size, u32 *val) | ||
| 485 | { | ||
| 486 | u32 data; | ||
| 487 | u32 reg = where & ~3; | ||
| 488 | |||
| 489 | if (!bcm63xx_pcie_can_access(bus, devfn)) | ||
| 490 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 491 | |||
| 492 | if (bus->number == PCIE_BUS_DEVICE) | ||
| 493 | reg += PCIE_DEVICE_OFFSET; | ||
| 494 | |||
| 495 | data = bcm_pcie_readl(reg); | ||
| 496 | |||
| 497 | *val = postprocess_read(data, where, size); | ||
| 498 | |||
| 499 | return PCIBIOS_SUCCESSFUL; | ||
| 500 | |||
| 501 | } | ||
| 502 | |||
| 503 | static int bcm63xx_pcie_write(struct pci_bus *bus, unsigned int devfn, | ||
| 504 | int where, int size, u32 val) | ||
| 505 | { | ||
| 506 | u32 data; | ||
| 507 | u32 reg = where & ~3; | ||
| 508 | |||
| 509 | if (!bcm63xx_pcie_can_access(bus, devfn)) | ||
| 510 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 511 | |||
| 512 | if (bus->number == PCIE_BUS_DEVICE) | ||
| 513 | reg += PCIE_DEVICE_OFFSET; | ||
| 514 | |||
| 515 | |||
| 516 | data = bcm_pcie_readl(reg); | ||
| 517 | |||
| 518 | data = preprocess_write(data, val, where, size); | ||
| 519 | bcm_pcie_writel(data, reg); | ||
| 520 | |||
| 521 | return PCIBIOS_SUCCESSFUL; | ||
| 522 | } | ||
| 523 | |||
| 524 | |||
| 525 | struct pci_ops bcm63xx_pcie_ops = { | ||
| 526 | .read = bcm63xx_pcie_read, | ||
| 527 | .write = bcm63xx_pcie_write | ||
| 528 | }; | ||
diff --git a/arch/mips/pci/pci-bcm63xx.c b/arch/mips/pci/pci-bcm63xx.c index a2b6d55a2492..8a48139d219c 100644 --- a/arch/mips/pci/pci-bcm63xx.c +++ b/arch/mips/pci/pci-bcm63xx.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <linux/pci.h> | 10 | #include <linux/pci.h> |
| 11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
| 13 | #include <linux/delay.h> | ||
| 13 | #include <asm/bootinfo.h> | 14 | #include <asm/bootinfo.h> |
| 14 | 15 | ||
| 15 | #include "pci-bcm63xx.h" | 16 | #include "pci-bcm63xx.h" |
| @@ -71,6 +72,26 @@ struct pci_controller bcm63xx_cb_controller = { | |||
| 71 | }; | 72 | }; |
| 72 | #endif | 73 | #endif |
| 73 | 74 | ||
| 75 | static struct resource bcm_pcie_mem_resource = { | ||
| 76 | .name = "bcm63xx PCIe memory space", | ||
| 77 | .start = BCM_PCIE_MEM_BASE_PA, | ||
| 78 | .end = BCM_PCIE_MEM_END_PA, | ||
| 79 | .flags = IORESOURCE_MEM, | ||
| 80 | }; | ||
| 81 | |||
| 82 | static struct resource bcm_pcie_io_resource = { | ||
| 83 | .name = "bcm63xx PCIe IO space", | ||
| 84 | .start = 0, | ||
| 85 | .end = 0, | ||
| 86 | .flags = 0, | ||
| 87 | }; | ||
| 88 | |||
| 89 | struct pci_controller bcm63xx_pcie_controller = { | ||
| 90 | .pci_ops = &bcm63xx_pcie_ops, | ||
| 91 | .io_resource = &bcm_pcie_io_resource, | ||
| 92 | .mem_resource = &bcm_pcie_mem_resource, | ||
| 93 | }; | ||
| 94 | |||
| 74 | static u32 bcm63xx_int_cfg_readl(u32 reg) | 95 | static u32 bcm63xx_int_cfg_readl(u32 reg) |
| 75 | { | 96 | { |
| 76 | u32 tmp; | 97 | u32 tmp; |
| @@ -94,6 +115,95 @@ static void bcm63xx_int_cfg_writel(u32 val, u32 reg) | |||
| 94 | 115 | ||
| 95 | void __iomem *pci_iospace_start; | 116 | void __iomem *pci_iospace_start; |
| 96 | 117 | ||
| 118 | static void __init bcm63xx_reset_pcie(void) | ||
| 119 | { | ||
| 120 | u32 val; | ||
| 121 | |||
| 122 | /* enable clock */ | ||
| 123 | val = bcm_perf_readl(PERF_CKCTL_REG); | ||
| 124 | val |= CKCTL_6328_PCIE_EN; | ||
| 125 | bcm_perf_writel(val, PERF_CKCTL_REG); | ||
| 126 | |||
| 127 | /* enable SERDES */ | ||
| 128 | val = bcm_misc_readl(MISC_SERDES_CTRL_REG); | ||
| 129 | val |= SERDES_PCIE_EN | SERDES_PCIE_EXD_EN; | ||
| 130 | bcm_misc_writel(val, MISC_SERDES_CTRL_REG); | ||
| 131 | |||
| 132 | /* reset the PCIe core */ | ||
| 133 | val = bcm_perf_readl(PERF_SOFTRESET_6328_REG); | ||
| 134 | |||
| 135 | val &= ~SOFTRESET_6328_PCIE_MASK; | ||
| 136 | val &= ~SOFTRESET_6328_PCIE_CORE_MASK; | ||
| 137 | val &= ~SOFTRESET_6328_PCIE_HARD_MASK; | ||
| 138 | val &= ~SOFTRESET_6328_PCIE_EXT_MASK; | ||
| 139 | bcm_perf_writel(val, PERF_SOFTRESET_6328_REG); | ||
| 140 | mdelay(10); | ||
| 141 | |||
| 142 | val |= SOFTRESET_6328_PCIE_MASK; | ||
| 143 | val |= SOFTRESET_6328_PCIE_CORE_MASK; | ||
| 144 | val |= SOFTRESET_6328_PCIE_HARD_MASK; | ||
| 145 | bcm_perf_writel(val, PERF_SOFTRESET_6328_REG); | ||
| 146 | mdelay(10); | ||
| 147 | |||
| 148 | val |= SOFTRESET_6328_PCIE_EXT_MASK; | ||
| 149 | bcm_perf_writel(val, PERF_SOFTRESET_6328_REG); | ||
| 150 | mdelay(200); | ||
| 151 | } | ||
| 152 | |||
| 153 | static int __init bcm63xx_register_pcie(void) | ||
| 154 | { | ||
| 155 | u32 val; | ||
| 156 | |||
| 157 | bcm63xx_reset_pcie(); | ||
| 158 | |||
| 159 | /* configure the PCIe bridge */ | ||
| 160 | val = bcm_pcie_readl(PCIE_BRIDGE_OPT1_REG); | ||
| 161 | val |= OPT1_RD_BE_OPT_EN; | ||
| 162 | val |= OPT1_RD_REPLY_BE_FIX_EN; | ||
| 163 | val |= OPT1_PCIE_BRIDGE_HOLE_DET_EN; | ||
| 164 | val |= OPT1_L1_INT_STATUS_MASK_POL; | ||
| 165 | bcm_pcie_writel(val, PCIE_BRIDGE_OPT1_REG); | ||
| 166 | |||
| 167 | /* setup the interrupts */ | ||
| 168 | val = bcm_pcie_readl(PCIE_BRIDGE_RC_INT_MASK_REG); | ||
| 169 | val |= PCIE_RC_INT_A | PCIE_RC_INT_B | PCIE_RC_INT_C | PCIE_RC_INT_D; | ||
| 170 | bcm_pcie_writel(val, PCIE_BRIDGE_RC_INT_MASK_REG); | ||
| 171 | |||
| 172 | val = bcm_pcie_readl(PCIE_BRIDGE_OPT2_REG); | ||
| 173 | /* enable credit checking and error checking */ | ||
| 174 | val |= OPT2_TX_CREDIT_CHK_EN; | ||
| 175 | val |= OPT2_UBUS_UR_DECODE_DIS; | ||
| 176 | |||
| 177 | /* set device bus/func for the pcie device */ | ||
| 178 | val |= (PCIE_BUS_DEVICE << OPT2_CFG_TYPE1_BUS_NO_SHIFT); | ||
| 179 | val |= OPT2_CFG_TYPE1_BD_SEL; | ||
| 180 | bcm_pcie_writel(val, PCIE_BRIDGE_OPT2_REG); | ||
| 181 | |||
| 182 | /* setup class code as bridge */ | ||
| 183 | val = bcm_pcie_readl(PCIE_IDVAL3_REG); | ||
| 184 | val &= ~IDVAL3_CLASS_CODE_MASK; | ||
| 185 | val |= (PCI_CLASS_BRIDGE_PCI << IDVAL3_SUBCLASS_SHIFT); | ||
| 186 | bcm_pcie_writel(val, PCIE_IDVAL3_REG); | ||
| 187 | |||
| 188 | /* disable bar1 size */ | ||
| 189 | val = bcm_pcie_readl(PCIE_CONFIG2_REG); | ||
| 190 | val &= ~CONFIG2_BAR1_SIZE_MASK; | ||
| 191 | bcm_pcie_writel(val, PCIE_CONFIG2_REG); | ||
| 192 | |||
| 193 | /* set bar0 to little endian */ | ||
| 194 | val = (BCM_PCIE_MEM_BASE_PA >> 20) << BASEMASK_BASE_SHIFT; | ||
| 195 | val |= (BCM_PCIE_MEM_BASE_PA >> 20) << BASEMASK_MASK_SHIFT; | ||
| 196 | val |= BASEMASK_REMAP_EN; | ||
| 197 | bcm_pcie_writel(val, PCIE_BRIDGE_BAR0_BASEMASK_REG); | ||
| 198 | |||
| 199 | val = (BCM_PCIE_MEM_BASE_PA >> 20) << REBASE_ADDR_BASE_SHIFT; | ||
| 200 | bcm_pcie_writel(val, PCIE_BRIDGE_BAR0_REBASE_ADDR_REG); | ||
| 201 | |||
| 202 | register_pci_controller(&bcm63xx_pcie_controller); | ||
| 203 | |||
| 204 | return 0; | ||
| 205 | } | ||
| 206 | |||
| 97 | static int __init bcm63xx_register_pci(void) | 207 | static int __init bcm63xx_register_pci(void) |
| 98 | { | 208 | { |
| 99 | unsigned int mem_size; | 209 | unsigned int mem_size; |
| @@ -221,6 +331,8 @@ static int __init bcm63xx_pci_init(void) | |||
| 221 | return -ENODEV; | 331 | return -ENODEV; |
| 222 | 332 | ||
| 223 | switch (bcm63xx_get_cpu_id()) { | 333 | switch (bcm63xx_get_cpu_id()) { |
| 334 | case BCM6328_CPU_ID: | ||
| 335 | return bcm63xx_register_pcie(); | ||
| 224 | case BCM6348_CPU_ID: | 336 | case BCM6348_CPU_ID: |
| 225 | case BCM6358_CPU_ID: | 337 | case BCM6358_CPU_ID: |
| 226 | case BCM6368_CPU_ID: | 338 | case BCM6368_CPU_ID: |
diff --git a/arch/mips/pci/pci-bcm63xx.h b/arch/mips/pci/pci-bcm63xx.h index a6e594ef3d6a..e6736d558ac7 100644 --- a/arch/mips/pci/pci-bcm63xx.h +++ b/arch/mips/pci/pci-bcm63xx.h | |||
| @@ -13,11 +13,16 @@ | |||
| 13 | */ | 13 | */ |
| 14 | #define CARDBUS_PCI_IDSEL 0x8 | 14 | #define CARDBUS_PCI_IDSEL 0x8 |
| 15 | 15 | ||
| 16 | |||
| 17 | #define PCIE_BUS_BRIDGE 0 | ||
| 18 | #define PCIE_BUS_DEVICE 1 | ||
| 19 | |||
| 16 | /* | 20 | /* |
| 17 | * defined in ops-bcm63xx.c | 21 | * defined in ops-bcm63xx.c |
| 18 | */ | 22 | */ |
| 19 | extern struct pci_ops bcm63xx_pci_ops; | 23 | extern struct pci_ops bcm63xx_pci_ops; |
| 20 | extern struct pci_ops bcm63xx_cb_ops; | 24 | extern struct pci_ops bcm63xx_cb_ops; |
| 25 | extern struct pci_ops bcm63xx_pcie_ops; | ||
| 21 | 26 | ||
| 22 | /* | 27 | /* |
| 23 | * defined in pci-bcm63xx.c | 28 | * defined in pci-bcm63xx.c |
