pci_v3.c 17 KB

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