pci_v3.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /*
  2. * linux/arch/arm/mach-integrator/pci_v3.c
  3. *
  4. * PCI functions for V3 host PCI bridge
  5. *
  6. * Copyright (C) 1999 ARM Limited
  7. * Copyright (C) 2000-2001 Deep Blue Solutions Ltd
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/pci.h>
  25. #include <linux/slab.h>
  26. #include <linux/ioport.h>
  27. #include <linux/interrupt.h>
  28. #include <linux/spinlock.h>
  29. #include <linux/init.h>
  30. #include <asm/hardware.h>
  31. #include <asm/io.h>
  32. #include <asm/irq.h>
  33. #include <asm/system.h>
  34. #include <asm/mach/pci.h>
  35. #include <asm/hardware/pci_v3.h>
  36. /*
  37. * The V3 PCI interface chip in Integrator provides several windows from
  38. * local bus memory into the PCI memory areas. Unfortunately, there
  39. * are not really enough windows for our usage, therefore we reuse
  40. * one of the windows for access to PCI configuration space. The
  41. * memory map is as follows:
  42. *
  43. * Local Bus Memory Usage
  44. *
  45. * 40000000 - 4FFFFFFF PCI memory. 256M non-prefetchable
  46. * 50000000 - 5FFFFFFF PCI memory. 256M prefetchable
  47. * 60000000 - 60FFFFFF PCI IO. 16M
  48. * 61000000 - 61FFFFFF PCI Configuration. 16M
  49. *
  50. * There are three V3 windows, each described by a pair of V3 registers.
  51. * These are LB_BASE0/LB_MAP0, LB_BASE1/LB_MAP1 and LB_BASE2/LB_MAP2.
  52. * Base0 and Base1 can be used for any type of PCI memory access. Base2
  53. * can be used either for PCI I/O or for I20 accesses. By default, uHAL
  54. * uses this only for PCI IO space.
  55. *
  56. * Normally these spaces are mapped using the following base registers:
  57. *
  58. * Usage Local Bus Memory Base/Map registers used
  59. *
  60. * Mem 40000000 - 4FFFFFFF LB_BASE0/LB_MAP0
  61. * Mem 50000000 - 5FFFFFFF LB_BASE1/LB_MAP1
  62. * IO 60000000 - 60FFFFFF LB_BASE2/LB_MAP2
  63. * Cfg 61000000 - 61FFFFFF
  64. *
  65. * This means that I20 and PCI configuration space accesses will fail.
  66. * When PCI configuration accesses are needed (via the uHAL PCI
  67. * configuration space primitives) we must remap the spaces as follows:
  68. *
  69. * Usage Local Bus Memory Base/Map registers used
  70. *
  71. * Mem 40000000 - 4FFFFFFF LB_BASE0/LB_MAP0
  72. * Mem 50000000 - 5FFFFFFF LB_BASE0/LB_MAP0
  73. * IO 60000000 - 60FFFFFF LB_BASE2/LB_MAP2
  74. * Cfg 61000000 - 61FFFFFF LB_BASE1/LB_MAP1
  75. *
  76. * To make this work, the code depends on overlapping windows working.
  77. * The V3 chip translates an address by checking its range within
  78. * each of the BASE/MAP pairs in turn (in ascending register number
  79. * order). It will use the first matching pair. So, for example,
  80. * if the same address is mapped by both LB_BASE0/LB_MAP0 and
  81. * LB_BASE1/LB_MAP1, the V3 will use the translation from
  82. * LB_BASE0/LB_MAP0.
  83. *
  84. * To allow PCI Configuration space access, the code enlarges the
  85. * window mapped by LB_BASE0/LB_MAP0 from 256M to 512M. This occludes
  86. * the windows currently mapped by LB_BASE1/LB_MAP1 so that it can
  87. * be remapped for use by configuration cycles.
  88. *
  89. * At the end of the PCI Configuration space accesses,
  90. * LB_BASE1/LB_MAP1 is reset to map PCI Memory. Finally the window
  91. * mapped by LB_BASE0/LB_MAP0 is reduced in size from 512M to 256M to
  92. * reveal the now restored LB_BASE1/LB_MAP1 window.
  93. *
  94. * NOTE: We do not set up I2O mapping. I suspect that this is only
  95. * for an intelligent (target) device. Using I2O disables most of
  96. * the mappings into PCI memory.
  97. */
  98. // V3 access routines
  99. #define v3_writeb(o,v) __raw_writeb(v, PCI_V3_VADDR + (unsigned int)(o))
  100. #define v3_readb(o) (__raw_readb(PCI_V3_VADDR + (unsigned int)(o)))
  101. #define v3_writew(o,v) __raw_writew(v, PCI_V3_VADDR + (unsigned int)(o))
  102. #define v3_readw(o) (__raw_readw(PCI_V3_VADDR + (unsigned int)(o)))
  103. #define v3_writel(o,v) __raw_writel(v, PCI_V3_VADDR + (unsigned int)(o))
  104. #define v3_readl(o) (__raw_readl(PCI_V3_VADDR + (unsigned int)(o)))
  105. /*============================================================================
  106. *
  107. * routine: uHALir_PCIMakeConfigAddress()
  108. *
  109. * parameters: bus = which bus
  110. * device = which device
  111. * function = which function
  112. * offset = configuration space register we are interested in
  113. *
  114. * description: this routine will generate a platform dependent config
  115. * address.
  116. *
  117. * calls: none
  118. *
  119. * returns: configuration address to play on the PCI bus
  120. *
  121. * To generate the appropriate PCI configuration cycles in the PCI
  122. * configuration address space, you present the V3 with the following pattern
  123. * (which is very nearly a type 1 (except that the lower two bits are 00 and
  124. * not 01). In order for this mapping to work you need to set up one of
  125. * the local to PCI aperatures to 16Mbytes in length translating to
  126. * PCI configuration space starting at 0x0000.0000.
  127. *
  128. * PCI configuration cycles look like this:
  129. *
  130. * Type 0:
  131. *
  132. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  133. * 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
  134. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  135. * | | |D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|0|
  136. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  137. *
  138. * 31:11 Device select bit.
  139. * 10:8 Function number
  140. * 7:2 Register number
  141. *
  142. * Type 1:
  143. *
  144. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  145. * 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
  146. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  147. * | | | | | | | | | | |B|B|B|B|B|B|B|B|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|1|
  148. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  149. *
  150. * 31:24 reserved
  151. * 23:16 bus number (8 bits = 128 possible buses)
  152. * 15:11 Device number (5 bits)
  153. * 10:8 function number
  154. * 7:2 register number
  155. *
  156. */
  157. static DEFINE_SPINLOCK(v3_lock);
  158. #define PCI_BUS_NONMEM_START 0x00000000
  159. #define PCI_BUS_NONMEM_SIZE SZ_256M
  160. #define PCI_BUS_PREMEM_START PCI_BUS_NONMEM_START + PCI_BUS_NONMEM_SIZE
  161. #define PCI_BUS_PREMEM_SIZE SZ_256M
  162. #if PCI_BUS_NONMEM_START & 0x000fffff
  163. #error PCI_BUS_NONMEM_START must be megabyte aligned
  164. #endif
  165. #if PCI_BUS_PREMEM_START & 0x000fffff
  166. #error PCI_BUS_PREMEM_START must be megabyte aligned
  167. #endif
  168. #undef V3_LB_BASE_PREFETCH
  169. #define V3_LB_BASE_PREFETCH 0
  170. static unsigned long v3_open_config_window(struct pci_bus *bus,
  171. unsigned int devfn, int offset)
  172. {
  173. unsigned int address, mapaddress, busnr;
  174. busnr = bus->number;
  175. /*
  176. * Trap out illegal values
  177. */
  178. if (offset > 255)
  179. BUG();
  180. if (busnr > 255)
  181. BUG();
  182. if (devfn > 255)
  183. BUG();
  184. if (busnr == 0) {
  185. int slot = PCI_SLOT(devfn);
  186. /*
  187. * local bus segment so need a type 0 config cycle
  188. *
  189. * build the PCI configuration "address" with one-hot in
  190. * A31-A11
  191. *
  192. * mapaddress:
  193. * 3:1 = config cycle (101)
  194. * 0 = PCI A1 & A0 are 0 (0)
  195. */
  196. address = PCI_FUNC(devfn) << 8;
  197. mapaddress = V3_LB_MAP_TYPE_CONFIG;
  198. if (slot > 12)
  199. /*
  200. * high order bits are handled by the MAP register
  201. */
  202. mapaddress |= 1 << (slot - 5);
  203. else
  204. /*
  205. * low order bits handled directly in the address
  206. */
  207. address |= 1 << (slot + 11);
  208. } else {
  209. /*
  210. * not the local bus segment so need a type 1 config cycle
  211. *
  212. * address:
  213. * 23:16 = bus number
  214. * 15:11 = slot number (7:3 of devfn)
  215. * 10:8 = func number (2:0 of devfn)
  216. *
  217. * mapaddress:
  218. * 3:1 = config cycle (101)
  219. * 0 = PCI A1 & A0 from host bus (1)
  220. */
  221. mapaddress = V3_LB_MAP_TYPE_CONFIG | V3_LB_MAP_AD_LOW_EN;
  222. address = (busnr << 16) | (devfn << 8);
  223. }
  224. /*
  225. * Set up base0 to see all 512Mbytes of memory space (not
  226. * prefetchable), this frees up base1 for re-use by
  227. * configuration memory
  228. */
  229. v3_writel(V3_LB_BASE0, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE) |
  230. V3_LB_BASE_ADR_SIZE_512MB | V3_LB_BASE_ENABLE);
  231. /*
  232. * Set up base1/map1 to point into configuration space.
  233. */
  234. v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(PHYS_PCI_CONFIG_BASE) |
  235. V3_LB_BASE_ADR_SIZE_16MB | V3_LB_BASE_ENABLE);
  236. v3_writew(V3_LB_MAP1, mapaddress);
  237. return PCI_CONFIG_VADDR + address + offset;
  238. }
  239. static void v3_close_config_window(void)
  240. {
  241. /*
  242. * Reassign base1 for use by prefetchable PCI memory
  243. */
  244. v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE + SZ_256M) |
  245. V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_PREFETCH |
  246. V3_LB_BASE_ENABLE);
  247. v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(PCI_BUS_PREMEM_START) |
  248. V3_LB_MAP_TYPE_MEM_MULTIPLE);
  249. /*
  250. * And shrink base0 back to a 256M window (NOTE: MAP0 already correct)
  251. */
  252. v3_writel(V3_LB_BASE0, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE) |
  253. V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_ENABLE);
  254. }
  255. static int v3_read_config(struct pci_bus *bus, unsigned int devfn, int where,
  256. int size, u32 *val)
  257. {
  258. unsigned long addr;
  259. unsigned long flags;
  260. u32 v;
  261. spin_lock_irqsave(&v3_lock, flags);
  262. addr = v3_open_config_window(bus, devfn, where);
  263. switch (size) {
  264. case 1:
  265. v = __raw_readb(addr);
  266. break;
  267. case 2:
  268. v = __raw_readw(addr);
  269. break;
  270. default:
  271. v = __raw_readl(addr);
  272. break;
  273. }
  274. v3_close_config_window();
  275. spin_unlock_irqrestore(&v3_lock, flags);
  276. *val = v;
  277. return PCIBIOS_SUCCESSFUL;
  278. }
  279. static int v3_write_config(struct pci_bus *bus, unsigned int devfn, int where,
  280. int size, u32 val)
  281. {
  282. unsigned long addr;
  283. unsigned long flags;
  284. spin_lock_irqsave(&v3_lock, flags);
  285. addr = v3_open_config_window(bus, devfn, where);
  286. switch (size) {
  287. case 1:
  288. __raw_writeb((u8)val, addr);
  289. __raw_readb(addr);
  290. break;
  291. case 2:
  292. __raw_writew((u16)val, addr);
  293. __raw_readw(addr);
  294. break;
  295. case 4:
  296. __raw_writel(val, addr);
  297. __raw_readl(addr);
  298. break;
  299. }
  300. v3_close_config_window();
  301. spin_unlock_irqrestore(&v3_lock, flags);
  302. return PCIBIOS_SUCCESSFUL;
  303. }
  304. static struct pci_ops pci_v3_ops = {
  305. .read = v3_read_config,
  306. .write = v3_write_config,
  307. };
  308. static struct resource non_mem = {
  309. .name = "PCI non-prefetchable",
  310. .start = PHYS_PCI_MEM_BASE + PCI_BUS_NONMEM_START,
  311. .end = PHYS_PCI_MEM_BASE + PCI_BUS_NONMEM_START + PCI_BUS_NONMEM_SIZE - 1,
  312. .flags = IORESOURCE_MEM,
  313. };
  314. static struct resource pre_mem = {
  315. .name = "PCI prefetchable",
  316. .start = PHYS_PCI_MEM_BASE + PCI_BUS_PREMEM_START,
  317. .end = PHYS_PCI_MEM_BASE + PCI_BUS_PREMEM_START + PCI_BUS_PREMEM_SIZE - 1,
  318. .flags = IORESOURCE_MEM | IORESOURCE_PREFETCH,
  319. };
  320. static int __init pci_v3_setup_resources(struct resource **resource)
  321. {
  322. if (request_resource(&iomem_resource, &non_mem)) {
  323. printk(KERN_ERR "PCI: unable to allocate non-prefetchable "
  324. "memory region\n");
  325. return -EBUSY;
  326. }
  327. if (request_resource(&iomem_resource, &pre_mem)) {
  328. release_resource(&non_mem);
  329. printk(KERN_ERR "PCI: unable to allocate prefetchable "
  330. "memory region\n");
  331. return -EBUSY;
  332. }
  333. /*
  334. * bus->resource[0] is the IO resource for this bus
  335. * bus->resource[1] is the mem resource for this bus
  336. * bus->resource[2] is the prefetch mem resource for this bus
  337. */
  338. resource[0] = &ioport_resource;
  339. resource[1] = &non_mem;
  340. resource[2] = &pre_mem;
  341. return 1;
  342. }
  343. /*
  344. * These don't seem to be implemented on the Integrator I have, which
  345. * means I can't get additional information on the reason for the pm2fb
  346. * problems. I suppose I'll just have to mind-meld with the machine. ;)
  347. */
  348. #define SC_PCI (IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_PCIENABLE_OFFSET)
  349. #define SC_LBFADDR (IO_ADDRESS(INTEGRATOR_SC_BASE) + 0x20)
  350. #define SC_LBFCODE (IO_ADDRESS(INTEGRATOR_SC_BASE) + 0x24)
  351. static int
  352. v3_pci_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  353. {
  354. unsigned long pc = instruction_pointer(regs);
  355. unsigned long instr = *(unsigned long *)pc;
  356. #if 0
  357. char buf[128];
  358. sprintf(buf, "V3 fault: addr 0x%08lx, FSR 0x%03x, PC 0x%08lx [%08lx] LBFADDR=%08x LBFCODE=%02x ISTAT=%02x\n",
  359. addr, fsr, pc, instr, __raw_readl(SC_LBFADDR), __raw_readl(SC_LBFCODE) & 255,
  360. v3_readb(V3_LB_ISTAT));
  361. printk(KERN_DEBUG "%s", buf);
  362. printascii(buf);
  363. #endif
  364. v3_writeb(V3_LB_ISTAT, 0);
  365. __raw_writel(3, SC_PCI);
  366. /*
  367. * If the instruction being executed was a read,
  368. * make it look like it read all-ones.
  369. */
  370. if ((instr & 0x0c100000) == 0x04100000) {
  371. int reg = (instr >> 12) & 15;
  372. unsigned long val;
  373. if (instr & 0x00400000)
  374. val = 255;
  375. else
  376. val = -1;
  377. regs->uregs[reg] = val;
  378. regs->ARM_pc += 4;
  379. return 0;
  380. }
  381. if ((instr & 0x0e100090) == 0x00100090) {
  382. int reg = (instr >> 12) & 15;
  383. regs->uregs[reg] = -1;
  384. regs->ARM_pc += 4;
  385. return 0;
  386. }
  387. return 1;
  388. }
  389. static irqreturn_t v3_irq(int irq, void *devid)
  390. {
  391. #ifdef CONFIG_DEBUG_LL
  392. struct pt_regs *regs = get_irq_regs();
  393. unsigned long pc = instruction_pointer(regs);
  394. unsigned long instr = *(unsigned long *)pc;
  395. char buf[128];
  396. sprintf(buf, "V3 int %d: pc=0x%08lx [%08lx] LBFADDR=%08x LBFCODE=%02x ISTAT=%02x\n", irq,
  397. pc, instr, __raw_readl(SC_LBFADDR), __raw_readl(SC_LBFCODE) & 255,
  398. v3_readb(V3_LB_ISTAT));
  399. printascii(buf);
  400. #endif
  401. v3_writew(V3_PCI_STAT, 0xf000);
  402. v3_writeb(V3_LB_ISTAT, 0);
  403. __raw_writel(3, SC_PCI);
  404. #ifdef CONFIG_DEBUG_LL
  405. /*
  406. * If the instruction being executed was a read,
  407. * make it look like it read all-ones.
  408. */
  409. if ((instr & 0x0c100000) == 0x04100000) {
  410. int reg = (instr >> 16) & 15;
  411. sprintf(buf, " reg%d = %08lx\n", reg, regs->uregs[reg]);
  412. printascii(buf);
  413. }
  414. #endif
  415. return IRQ_HANDLED;
  416. }
  417. int __init pci_v3_setup(int nr, struct pci_sys_data *sys)
  418. {
  419. int ret = 0;
  420. if (nr == 0) {
  421. sys->mem_offset = PHYS_PCI_MEM_BASE;
  422. ret = pci_v3_setup_resources(sys->resource);
  423. }
  424. return ret;
  425. }
  426. struct pci_bus *pci_v3_scan_bus(int nr, struct pci_sys_data *sys)
  427. {
  428. return pci_scan_bus(sys->busnr, &pci_v3_ops, sys);
  429. }
  430. /*
  431. * V3_LB_BASE? - local bus address
  432. * V3_LB_MAP? - pci bus address
  433. */
  434. void __init pci_v3_preinit(void)
  435. {
  436. unsigned long flags;
  437. unsigned int temp;
  438. int ret;
  439. /*
  440. * Hook in our fault handler for PCI errors
  441. */
  442. hook_fault_code(4, v3_pci_fault, SIGBUS, "external abort on linefetch");
  443. hook_fault_code(6, v3_pci_fault, SIGBUS, "external abort on linefetch");
  444. hook_fault_code(8, v3_pci_fault, SIGBUS, "external abort on non-linefetch");
  445. hook_fault_code(10, v3_pci_fault, SIGBUS, "external abort on non-linefetch");
  446. spin_lock_irqsave(&v3_lock, flags);
  447. /*
  448. * Unlock V3 registers, but only if they were previously locked.
  449. */
  450. if (v3_readw(V3_SYSTEM) & V3_SYSTEM_M_LOCK)
  451. v3_writew(V3_SYSTEM, 0xa05f);
  452. /*
  453. * Setup window 0 - PCI non-prefetchable memory
  454. * Local: 0x40000000 Bus: 0x00000000 Size: 256MB
  455. */
  456. v3_writel(V3_LB_BASE0, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE) |
  457. V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_ENABLE);
  458. v3_writew(V3_LB_MAP0, v3_addr_to_lb_map(PCI_BUS_NONMEM_START) |
  459. V3_LB_MAP_TYPE_MEM);
  460. /*
  461. * Setup window 1 - PCI prefetchable memory
  462. * Local: 0x50000000 Bus: 0x10000000 Size: 256MB
  463. */
  464. v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(PHYS_PCI_MEM_BASE + SZ_256M) |
  465. V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_PREFETCH |
  466. V3_LB_BASE_ENABLE);
  467. v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(PCI_BUS_PREMEM_START) |
  468. V3_LB_MAP_TYPE_MEM_MULTIPLE);
  469. /*
  470. * Setup window 2 - PCI IO
  471. */
  472. v3_writel(V3_LB_BASE2, v3_addr_to_lb_base2(PHYS_PCI_IO_BASE) |
  473. V3_LB_BASE_ENABLE);
  474. v3_writew(V3_LB_MAP2, v3_addr_to_lb_map2(0));
  475. /*
  476. * Disable PCI to host IO cycles
  477. */
  478. temp = v3_readw(V3_PCI_CFG) & ~V3_PCI_CFG_M_I2O_EN;
  479. temp |= V3_PCI_CFG_M_IO_REG_DIS | V3_PCI_CFG_M_IO_DIS;
  480. v3_writew(V3_PCI_CFG, temp);
  481. printk(KERN_DEBUG "FIFO_CFG: %04x FIFO_PRIO: %04x\n",
  482. v3_readw(V3_FIFO_CFG), v3_readw(V3_FIFO_PRIORITY));
  483. /*
  484. * Set the V3 FIFO such that writes have higher priority than
  485. * reads, and local bus write causes local bus read fifo flush.
  486. * Same for PCI.
  487. */
  488. v3_writew(V3_FIFO_PRIORITY, 0x0a0a);
  489. /*
  490. * Re-lock the system register.
  491. */
  492. temp = v3_readw(V3_SYSTEM) | V3_SYSTEM_M_LOCK;
  493. v3_writew(V3_SYSTEM, temp);
  494. /*
  495. * Clear any error conditions, and enable write errors.
  496. */
  497. v3_writeb(V3_LB_ISTAT, 0);
  498. v3_writew(V3_LB_CFG, v3_readw(V3_LB_CFG) | (1 << 10));
  499. v3_writeb(V3_LB_IMASK, 0x28);
  500. __raw_writel(3, SC_PCI);
  501. /*
  502. * Grab the PCI error interrupt.
  503. */
  504. ret = request_irq(IRQ_AP_V3INT, v3_irq, 0, "V3", NULL);
  505. if (ret)
  506. printk(KERN_ERR "PCI: unable to grab PCI error "
  507. "interrupt: %d\n", ret);
  508. spin_unlock_irqrestore(&v3_lock, flags);
  509. }
  510. void __init pci_v3_postinit(void)
  511. {
  512. unsigned int pci_cmd;
  513. pci_cmd = PCI_COMMAND_MEMORY |
  514. PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE;
  515. v3_writew(V3_PCI_CMD, pci_cmd);
  516. v3_writeb(V3_LB_ISTAT, ~0x40);
  517. v3_writeb(V3_LB_IMASK, 0x68);
  518. #if 0
  519. ret = request_irq(IRQ_AP_LBUSTIMEOUT, lb_timeout, 0, "bus timeout", NULL);
  520. if (ret)
  521. printk(KERN_ERR "PCI: unable to grab local bus timeout "
  522. "interrupt: %d\n", ret);
  523. #endif
  524. register_isa_ports(PHYS_PCI_MEM_BASE, PHYS_PCI_IO_BASE, 0);
  525. }