Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

BCM1480 HT support PCI support code for PLX 7250 PCI-X tunnel on BCM91480B BigSur board. Signed-Off-By: Andy Isaacson <adi@broadcom.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Andrew Isaacson and committed by
Ralf Baechle
8a1417de dc41f94f

+253 -17
+1
arch/mips/Kconfig
··· 554 554 select SWAP_IO_SPACE 555 555 select SYS_SUPPORTS_BIG_ENDIAN 556 556 select SYS_SUPPORTS_LITTLE_ENDIAN 557 + select PCI_DOMAINS 557 558 558 559 config SIBYTE_SWARM 559 560 bool "Support for Sibyte BCM91250A-SWARM"
+1 -1
arch/mips/pci/Makefile
··· 46 46 obj-$(CONFIG_SGI_IP27) += pci-ip27.o 47 47 obj-$(CONFIG_SGI_IP32) += fixup-ip32.o ops-mace.o pci-ip32.o 48 48 obj-$(CONFIG_SIBYTE_SB1250) += fixup-sb1250.o pci-sb1250.o 49 - obj-$(CONFIG_SIBYTE_BCM1x80) += pci-bcm1480.o 49 + obj-$(CONFIG_SIBYTE_BCM1x80) += pci-bcm1480.o pci-bcm1480ht.o 50 50 obj-$(CONFIG_SNI_RM200_PCI) += fixup-sni.o ops-sni.o 51 51 obj-$(CONFIG_TANBAC_TB0219) += fixup-tb0219.o 52 52 obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o
+11 -10
arch/mips/pci/pci-bcm1480.c
··· 56 56 static void *cfg_space; 57 57 58 58 #define PCI_BUS_ENABLED 1 59 - #define LDT_BUS_ENABLED 2 60 - #define PCI_DEVICE_MODE 4 59 + #define PCI_DEVICE_MODE 2 61 60 62 61 static int bcm1480_bus_status = 0; 63 62 64 63 #define PCI_BRIDGE_DEVICE 0 65 - #define LDT_BRIDGE_DEVICE 1 66 64 67 65 /* 68 66 * Read/write 32-bit values in config space. ··· 93 95 */ 94 96 static int bcm1480_pci_can_access(struct pci_bus *bus, int devfn) 95 97 { 98 + u32 devno; 99 + 96 100 if (!(bcm1480_bus_status & (PCI_BUS_ENABLED | PCI_DEVICE_MODE))) 97 101 return 0; 98 102 99 103 if (bus->number == 0) { 104 + devno = PCI_SLOT(devfn); 100 105 if (bcm1480_bus_status & PCI_DEVICE_MODE) 101 106 return 0; 102 107 else ··· 176 175 177 176 static struct resource bcm1480_mem_resource = { 178 177 .name = "BCM1480 PCI MEM", 179 - .start = 0x40000000UL, 180 - .end = 0x5fffffffUL, 178 + .start = 0x30000000UL, 179 + .end = 0x3fffffffUL, 181 180 .flags = IORESOURCE_MEM, 182 181 }; 183 182 184 183 static struct resource bcm1480_io_resource = { 185 184 .name = "BCM1480 PCI I/O", 186 - .start = 0x00000000UL, 187 - .end = 0x01ffffffUL, 185 + .start = 0x2c000000UL, 186 + .end = 0x2dffffffUL, 188 187 .flags = IORESOURCE_IO, 189 188 }; 190 189 ··· 208 207 PCIBIOS_MIN_IO = 0x00008000UL; 209 208 PCIBIOS_MIN_MEM = 0x01000000UL; 210 209 211 - /* Set I/O resource limits. */ 212 - ioport_resource.end = 0x01ffffffUL; /* 32MB accessible by bcm1480 */ 213 - iomem_resource.end = 0xffffffffUL; /* no HT support yet */ 210 + /* Set I/O resource limits. - unlimited for now to accomodate HT */ 211 + ioport_resource.end = 0xffffffffUL; 212 + iomem_resource.end = 0xffffffffUL; 214 213 215 214 cfg_space = ioremap(A_BCM1480_PHYS_PCI_CFG_MATCH_BITS, 16*1024*1024); 216 215
+224
arch/mips/pci/pci-bcm1480ht.c
··· 1 + /* 2 + * Copyright (C) 2001,2002,2005 Broadcom Corporation 3 + * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org) 4 + * 5 + * This program is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU General Public License 7 + * as published by the Free Software Foundation; either version 2 8 + * of the License, or (at your option) any later version. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, write to the Free Software 17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 + */ 19 + 20 + /* 21 + * BCM1480/1455-specific HT support (looking like PCI) 22 + * 23 + * This module provides the glue between Linux's PCI subsystem 24 + * and the hardware. We basically provide glue for accessing 25 + * configuration space, and set up the translation for I/O 26 + * space accesses. 27 + * 28 + * To access configuration space, we use ioremap. In the 32-bit 29 + * kernel, this consumes either 4 or 8 page table pages, and 16MB of 30 + * kernel mapped memory. Hopefully neither of these should be a huge 31 + * problem. 32 + * 33 + */ 34 + #include <linux/config.h> 35 + #include <linux/types.h> 36 + #include <linux/pci.h> 37 + #include <linux/kernel.h> 38 + #include <linux/init.h> 39 + #include <linux/mm.h> 40 + #include <linux/console.h> 41 + #include <linux/tty.h> 42 + 43 + #include <asm/sibyte/bcm1480_regs.h> 44 + #include <asm/sibyte/bcm1480_scd.h> 45 + #include <asm/sibyte/board.h> 46 + #include <asm/io.h> 47 + 48 + /* 49 + * Macros for calculating offsets into config space given a device 50 + * structure or dev/fun/reg 51 + */ 52 + #define CFGOFFSET(bus,devfn,where) (((bus)<<16)+((devfn)<<8)+(where)) 53 + #define CFGADDR(bus,devfn,where) CFGOFFSET((bus)->number,(devfn),where) 54 + 55 + static void *ht_cfg_space; 56 + 57 + #define PCI_BUS_ENABLED 1 58 + #define PCI_DEVICE_MODE 2 59 + 60 + static int bcm1480ht_bus_status = 0; 61 + 62 + #define PCI_BRIDGE_DEVICE 0 63 + #define HT_BRIDGE_DEVICE 1 64 + 65 + /* 66 + * HT's level-sensitive interrupts require EOI, which is generated 67 + * through a 4MB memory-mapped region 68 + */ 69 + unsigned long ht_eoi_space; 70 + 71 + /* 72 + * Read/write 32-bit values in config space. 73 + */ 74 + static inline u32 READCFG32(u32 addr) 75 + { 76 + return *(u32 *)(ht_cfg_space + (addr&~3)); 77 + } 78 + 79 + static inline void WRITECFG32(u32 addr, u32 data) 80 + { 81 + *(u32 *)(ht_cfg_space + (addr & ~3)) = data; 82 + } 83 + 84 + /* 85 + * Some checks before doing config cycles: 86 + * In PCI Device Mode, hide everything on bus 0 except the LDT host 87 + * bridge. Otherwise, access is controlled by bridge MasterEn bits. 88 + */ 89 + static int bcm1480ht_can_access(struct pci_bus *bus, int devfn) 90 + { 91 + u32 devno; 92 + 93 + if (!(bcm1480ht_bus_status & (PCI_BUS_ENABLED | PCI_DEVICE_MODE))) 94 + return 0; 95 + 96 + if (bus->number == 0) { 97 + devno = PCI_SLOT(devfn); 98 + if (bcm1480ht_bus_status & PCI_DEVICE_MODE) 99 + return 0; 100 + } 101 + return 1; 102 + } 103 + 104 + /* 105 + * Read/write access functions for various sizes of values 106 + * in config space. Return all 1's for disallowed accesses 107 + * for a kludgy but adequate simulation of master aborts. 108 + */ 109 + 110 + static int bcm1480ht_pcibios_read(struct pci_bus *bus, unsigned int devfn, 111 + int where, int size, u32 * val) 112 + { 113 + u32 data = 0; 114 + 115 + if ((size == 2) && (where & 1)) 116 + return PCIBIOS_BAD_REGISTER_NUMBER; 117 + else if ((size == 4) && (where & 3)) 118 + return PCIBIOS_BAD_REGISTER_NUMBER; 119 + 120 + if (bcm1480ht_can_access(bus, devfn)) 121 + data = READCFG32(CFGADDR(bus, devfn, where)); 122 + else 123 + data = 0xFFFFFFFF; 124 + 125 + if (size == 1) 126 + *val = (data >> ((where & 3) << 3)) & 0xff; 127 + else if (size == 2) 128 + *val = (data >> ((where & 3) << 3)) & 0xffff; 129 + else 130 + *val = data; 131 + 132 + return PCIBIOS_SUCCESSFUL; 133 + } 134 + 135 + static int bcm1480ht_pcibios_write(struct pci_bus *bus, unsigned int devfn, 136 + int where, int size, u32 val) 137 + { 138 + u32 cfgaddr = CFGADDR(bus, devfn, where); 139 + u32 data = 0; 140 + 141 + if ((size == 2) && (where & 1)) 142 + return PCIBIOS_BAD_REGISTER_NUMBER; 143 + else if ((size == 4) && (where & 3)) 144 + return PCIBIOS_BAD_REGISTER_NUMBER; 145 + 146 + if (!bcm1480ht_can_access(bus, devfn)) 147 + return PCIBIOS_BAD_REGISTER_NUMBER; 148 + 149 + data = READCFG32(cfgaddr); 150 + 151 + if (size == 1) 152 + data = (data & ~(0xff << ((where & 3) << 3))) | 153 + (val << ((where & 3) << 3)); 154 + else if (size == 2) 155 + data = (data & ~(0xffff << ((where & 3) << 3))) | 156 + (val << ((where & 3) << 3)); 157 + else 158 + data = val; 159 + 160 + WRITECFG32(cfgaddr, data); 161 + 162 + return PCIBIOS_SUCCESSFUL; 163 + } 164 + 165 + static int bcm1480ht_pcibios_get_busno(void) 166 + { 167 + return 0; 168 + } 169 + 170 + struct pci_ops bcm1480ht_pci_ops = { 171 + .read = bcm1480ht_pcibios_read, 172 + .write = bcm1480ht_pcibios_write, 173 + }; 174 + 175 + static struct resource bcm1480ht_mem_resource = { 176 + .name = "BCM1480 HT MEM", 177 + .start = 0x40000000UL, 178 + .end = 0x5fffffffUL, 179 + .flags = IORESOURCE_MEM, 180 + }; 181 + 182 + static struct resource bcm1480ht_io_resource = { 183 + .name = "BCM1480 HT I/O", 184 + .start = 0x00000000UL, 185 + .end = 0x01ffffffUL, 186 + .flags = IORESOURCE_IO, 187 + }; 188 + 189 + struct pci_controller bcm1480ht_controller = { 190 + .pci_ops = &bcm1480ht_pci_ops, 191 + .mem_resource = &bcm1480ht_mem_resource, 192 + .io_resource = &bcm1480ht_io_resource, 193 + .index = 1, 194 + .get_busno = bcm1480ht_pcibios_get_busno, 195 + }; 196 + 197 + static int __init bcm1480ht_pcibios_init(void) 198 + { 199 + uint32_t cmdreg; 200 + 201 + ht_cfg_space = ioremap(A_BCM1480_PHYS_HT_CFG_MATCH_BITS, 16*1024*1024); 202 + 203 + /* 204 + * See if the PCI bus has been configured by the firmware. 205 + */ 206 + cmdreg = READCFG32(CFGOFFSET(0, PCI_DEVFN(PCI_BRIDGE_DEVICE, 0), 207 + PCI_COMMAND)); 208 + if (!(cmdreg & PCI_COMMAND_MASTER)) { 209 + printk("HT: Skipping HT probe. Bus is not initialized.\n"); 210 + iounmap(ht_cfg_space); 211 + return 1; /* XXX */ 212 + } 213 + bcm1480ht_bus_status |= PCI_BUS_ENABLED; 214 + 215 + ht_eoi_space = (unsigned long) 216 + ioremap(A_BCM1480_PHYS_HT_SPECIAL_MATCH_BYTES, 217 + 4 * 1024 * 1024); 218 + 219 + register_pci_controller(&bcm1480ht_controller); 220 + 221 + return 0; 222 + } 223 + 224 + arch_initcall(bcm1480ht_pcibios_init);
+11 -6
arch/mips/pci/pci.c
··· 127 127 if (!hose->iommu) 128 128 PCI_DMA_BUS_IS_PHYS = 1; 129 129 130 + if (hose->get_busno && pci_probe_only) 131 + next_busno = (*hose->get_busno)(); 132 + 130 133 bus = pci_scan_bus(next_busno, hose->pci_ops, hose); 131 134 hose->bus = bus; 132 135 hose->need_domain_info = need_domain_info; 133 - next_busno = bus->subordinate + 1; 134 - /* Don't allow 8-bit bus number overflow inside the hose - 135 - reserve some space for bridges. */ 136 - if (next_busno > 224) { 137 - next_busno = 0; 138 - need_domain_info = 1; 136 + if (bus) { 137 + next_busno = bus->subordinate + 1; 138 + /* Don't allow 8-bit bus number overflow inside the hose - 139 + reserve some space for bridges. */ 140 + if (next_busno > 224) { 141 + next_busno = 0; 142 + need_domain_info = 1; 143 + } 139 144 } 140 145 continue; 141 146
+5
include/asm-mips/pci.h
··· 40 40 unsigned int need_domain_info; 41 41 42 42 int iommu; 43 + 44 + /* Optional access methods for reading/writing the bus number 45 + of the PCI controller */ 46 + int (*get_busno)(void); 47 + void (*set_busno)(int busno); 43 48 }; 44 49 45 50 /*