sys_cabriolet.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*
  2. * linux/arch/alpha/kernel/sys_cabriolet.c
  3. *
  4. * Copyright (C) 1995 David A Rusling
  5. * Copyright (C) 1996 Jay A Estabrook
  6. * Copyright (C) 1998, 1999, 2000 Richard Henderson
  7. *
  8. * Code supporting the Cabriolet (AlphaPC64), EB66+, and EB164,
  9. * PC164 and LX164.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/mm.h>
  14. #include <linux/sched.h>
  15. #include <linux/pci.h>
  16. #include <linux/init.h>
  17. #include <linux/bitops.h>
  18. #include <asm/ptrace.h>
  19. #include <asm/system.h>
  20. #include <asm/dma.h>
  21. #include <asm/irq.h>
  22. #include <asm/mmu_context.h>
  23. #include <asm/io.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/core_apecs.h>
  26. #include <asm/core_cia.h>
  27. #include <asm/core_lca.h>
  28. #include <asm/tlbflush.h>
  29. #include "proto.h"
  30. #include "irq_impl.h"
  31. #include "pci_impl.h"
  32. #include "machvec_impl.h"
  33. #include "pc873xx.h"
  34. /* Note mask bit is true for DISABLED irqs. */
  35. static unsigned long cached_irq_mask = ~0UL;
  36. static inline void
  37. cabriolet_update_irq_hw(unsigned int irq, unsigned long mask)
  38. {
  39. int ofs = (irq - 16) / 8;
  40. outb(mask >> (16 + ofs * 8), 0x804 + ofs);
  41. }
  42. static inline void
  43. cabriolet_enable_irq(struct irq_data *d)
  44. {
  45. cabriolet_update_irq_hw(d->irq, cached_irq_mask &= ~(1UL << d->irq));
  46. }
  47. static void
  48. cabriolet_disable_irq(struct irq_data *d)
  49. {
  50. cabriolet_update_irq_hw(d->irq, cached_irq_mask |= 1UL << d->irq);
  51. }
  52. static struct irq_chip cabriolet_irq_type = {
  53. .name = "CABRIOLET",
  54. .irq_unmask = cabriolet_enable_irq,
  55. .irq_mask = cabriolet_disable_irq,
  56. .irq_mask_ack = cabriolet_disable_irq,
  57. };
  58. static void
  59. cabriolet_device_interrupt(unsigned long v)
  60. {
  61. unsigned long pld;
  62. unsigned int i;
  63. /* Read the interrupt summary registers */
  64. pld = inb(0x804) | (inb(0x805) << 8) | (inb(0x806) << 16);
  65. /*
  66. * Now for every possible bit set, work through them and call
  67. * the appropriate interrupt handler.
  68. */
  69. while (pld) {
  70. i = ffz(~pld);
  71. pld &= pld - 1; /* clear least bit set */
  72. if (i == 4) {
  73. isa_device_interrupt(v);
  74. } else {
  75. handle_irq(16 + i);
  76. }
  77. }
  78. }
  79. static void __init
  80. common_init_irq(void (*srm_dev_int)(unsigned long v))
  81. {
  82. init_i8259a_irqs();
  83. if (alpha_using_srm) {
  84. alpha_mv.device_interrupt = srm_dev_int;
  85. init_srm_irqs(35, 0);
  86. }
  87. else {
  88. long i;
  89. outb(0xff, 0x804);
  90. outb(0xff, 0x805);
  91. outb(0xff, 0x806);
  92. for (i = 16; i < 35; ++i) {
  93. irq_set_chip_and_handler(i, &cabriolet_irq_type,
  94. handle_level_irq);
  95. irq_set_status_flags(i, IRQ_LEVEL);
  96. }
  97. }
  98. common_init_isa_dma();
  99. setup_irq(16+4, &isa_cascade_irqaction);
  100. }
  101. #ifndef CONFIG_ALPHA_PC164
  102. static void __init
  103. cabriolet_init_irq(void)
  104. {
  105. common_init_irq(srm_device_interrupt);
  106. }
  107. #endif
  108. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_PC164)
  109. /* In theory, the PC164 has the same interrupt hardware as the other
  110. Cabriolet based systems. However, something got screwed up late
  111. in the development cycle which broke the interrupt masking hardware.
  112. Repeat, it is not possible to mask and ack interrupts. At all.
  113. In an attempt to work around this, while processing interrupts,
  114. we do not allow the IPL to drop below what it is currently. This
  115. prevents the possibility of recursion.
  116. ??? Another option might be to force all PCI devices to use edge
  117. triggered rather than level triggered interrupts. That might be
  118. too invasive though. */
  119. static void
  120. pc164_srm_device_interrupt(unsigned long v)
  121. {
  122. __min_ipl = getipl();
  123. srm_device_interrupt(v);
  124. __min_ipl = 0;
  125. }
  126. static void
  127. pc164_device_interrupt(unsigned long v)
  128. {
  129. __min_ipl = getipl();
  130. cabriolet_device_interrupt(v);
  131. __min_ipl = 0;
  132. }
  133. static void __init
  134. pc164_init_irq(void)
  135. {
  136. common_init_irq(pc164_srm_device_interrupt);
  137. }
  138. #endif
  139. /*
  140. * The EB66+ is very similar to the EB66 except that it does not have
  141. * the on-board NCR and Tulip chips. In the code below, I have used
  142. * slot number to refer to the id select line and *not* the slot
  143. * number used in the EB66+ documentation. However, in the table,
  144. * I've given the slot number, the id select line and the Jxx number
  145. * that's printed on the board. The interrupt pins from the PCI slots
  146. * are wired into 3 interrupt summary registers at 0x804, 0x805 and
  147. * 0x806 ISA.
  148. *
  149. * In the table, -1 means don't assign an IRQ number. This is usually
  150. * because it is the Saturn IO (SIO) PCI/ISA Bridge Chip.
  151. */
  152. static inline int __init
  153. eb66p_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  154. {
  155. static char irq_tab[5][5] __initdata = {
  156. /*INT INTA INTB INTC INTD */
  157. {16+0, 16+0, 16+5, 16+9, 16+13}, /* IdSel 6, slot 0, J25 */
  158. {16+1, 16+1, 16+6, 16+10, 16+14}, /* IdSel 7, slot 1, J26 */
  159. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  160. {16+2, 16+2, 16+7, 16+11, 16+15}, /* IdSel 9, slot 2, J27 */
  161. {16+3, 16+3, 16+8, 16+12, 16+6} /* IdSel 10, slot 3, J28 */
  162. };
  163. const long min_idsel = 6, max_idsel = 10, irqs_per_slot = 5;
  164. return COMMON_TABLE_LOOKUP;
  165. }
  166. /*
  167. * The AlphaPC64 is very similar to the EB66+ except that its slots
  168. * are numbered differently. In the code below, I have used slot
  169. * number to refer to the id select line and *not* the slot number
  170. * used in the AlphaPC64 documentation. However, in the table, I've
  171. * given the slot number, the id select line and the Jxx number that's
  172. * printed on the board. The interrupt pins from the PCI slots are
  173. * wired into 3 interrupt summary registers at 0x804, 0x805 and 0x806
  174. * ISA.
  175. *
  176. * In the table, -1 means don't assign an IRQ number. This is usually
  177. * because it is the Saturn IO (SIO) PCI/ISA Bridge Chip.
  178. */
  179. static inline int __init
  180. cabriolet_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  181. {
  182. static char irq_tab[5][5] __initdata = {
  183. /*INT INTA INTB INTC INTD */
  184. { 16+2, 16+2, 16+7, 16+11, 16+15}, /* IdSel 5, slot 2, J21 */
  185. { 16+0, 16+0, 16+5, 16+9, 16+13}, /* IdSel 6, slot 0, J19 */
  186. { 16+1, 16+1, 16+6, 16+10, 16+14}, /* IdSel 7, slot 1, J20 */
  187. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  188. { 16+3, 16+3, 16+8, 16+12, 16+16} /* IdSel 9, slot 3, J22 */
  189. };
  190. const long min_idsel = 5, max_idsel = 9, irqs_per_slot = 5;
  191. return COMMON_TABLE_LOOKUP;
  192. }
  193. static inline void __init
  194. cabriolet_enable_ide(void)
  195. {
  196. if (pc873xx_probe() == -1) {
  197. printk(KERN_ERR "Probing for PC873xx Super IO chip failed.\n");
  198. } else {
  199. printk(KERN_INFO "Found %s Super IO chip at 0x%x\n",
  200. pc873xx_get_model(), pc873xx_get_base());
  201. pc873xx_enable_ide();
  202. }
  203. }
  204. static inline void __init
  205. cabriolet_init_pci(void)
  206. {
  207. common_init_pci();
  208. cabriolet_enable_ide();
  209. }
  210. static inline void __init
  211. cia_cab_init_pci(void)
  212. {
  213. cia_init_pci();
  214. cabriolet_enable_ide();
  215. }
  216. /*
  217. * The PC164 and LX164 have 19 PCI interrupts, four from each of the four
  218. * PCI slots, the SIO, PCI/IDE, and USB.
  219. *
  220. * Each of the interrupts can be individually masked. This is
  221. * accomplished by setting the appropriate bit in the mask register.
  222. * A bit is set by writing a "1" to the desired position in the mask
  223. * register and cleared by writing a "0". There are 3 mask registers
  224. * located at ISA address 804h, 805h and 806h.
  225. *
  226. * An I/O read at ISA address 804h, 805h, 806h will return the
  227. * state of the 11 PCI interrupts and not the state of the MASKED
  228. * interrupts.
  229. *
  230. * Note: A write to I/O 804h, 805h, and 806h the mask register will be
  231. * updated.
  232. *
  233. *
  234. * ISA DATA<7:0>
  235. * ISA +--------------------------------------------------------------+
  236. * ADDRESS | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  237. * +==============================================================+
  238. * 0x804 | INTB0 | USB | IDE | SIO | INTA3 |INTA2 | INTA1 | INTA0 |
  239. * +--------------------------------------------------------------+
  240. * 0x805 | INTD0 | INTC3 | INTC2 | INTC1 | INTC0 |INTB3 | INTB2 | INTB1 |
  241. * +--------------------------------------------------------------+
  242. * 0x806 | Rsrv | Rsrv | Rsrv | Rsrv | Rsrv |INTD3 | INTD2 | INTD1 |
  243. * +--------------------------------------------------------------+
  244. * * Rsrv = reserved bits
  245. * Note: The mask register is write-only.
  246. *
  247. * IdSel
  248. * 5 32 bit PCI option slot 2
  249. * 6 64 bit PCI option slot 0
  250. * 7 64 bit PCI option slot 1
  251. * 8 Saturn I/O
  252. * 9 32 bit PCI option slot 3
  253. * 10 USB
  254. * 11 IDE
  255. *
  256. */
  257. static inline int __init
  258. alphapc164_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  259. {
  260. static char irq_tab[7][5] __initdata = {
  261. /*INT INTA INTB INTC INTD */
  262. { 16+2, 16+2, 16+9, 16+13, 16+17}, /* IdSel 5, slot 2, J20 */
  263. { 16+0, 16+0, 16+7, 16+11, 16+15}, /* IdSel 6, slot 0, J29 */
  264. { 16+1, 16+1, 16+8, 16+12, 16+16}, /* IdSel 7, slot 1, J26 */
  265. { -1, -1, -1, -1, -1}, /* IdSel 8, SIO */
  266. { 16+3, 16+3, 16+10, 16+14, 16+18}, /* IdSel 9, slot 3, J19 */
  267. { 16+6, 16+6, 16+6, 16+6, 16+6}, /* IdSel 10, USB */
  268. { 16+5, 16+5, 16+5, 16+5, 16+5} /* IdSel 11, IDE */
  269. };
  270. const long min_idsel = 5, max_idsel = 11, irqs_per_slot = 5;
  271. return COMMON_TABLE_LOOKUP;
  272. }
  273. static inline void __init
  274. alphapc164_init_pci(void)
  275. {
  276. cia_init_pci();
  277. SMC93x_Init();
  278. }
  279. /*
  280. * The System Vector
  281. */
  282. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_CABRIOLET)
  283. struct alpha_machine_vector cabriolet_mv __initmv = {
  284. .vector_name = "Cabriolet",
  285. DO_EV4_MMU,
  286. DO_DEFAULT_RTC,
  287. DO_APECS_IO,
  288. .machine_check = apecs_machine_check,
  289. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  290. .min_io_address = DEFAULT_IO_BASE,
  291. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  292. .nr_irqs = 35,
  293. .device_interrupt = cabriolet_device_interrupt,
  294. .init_arch = apecs_init_arch,
  295. .init_irq = cabriolet_init_irq,
  296. .init_rtc = common_init_rtc,
  297. .init_pci = cabriolet_init_pci,
  298. .pci_map_irq = cabriolet_map_irq,
  299. .pci_swizzle = common_swizzle,
  300. };
  301. #ifndef CONFIG_ALPHA_EB64P
  302. ALIAS_MV(cabriolet)
  303. #endif
  304. #endif
  305. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EB164)
  306. struct alpha_machine_vector eb164_mv __initmv = {
  307. .vector_name = "EB164",
  308. DO_EV5_MMU,
  309. DO_DEFAULT_RTC,
  310. DO_CIA_IO,
  311. .machine_check = cia_machine_check,
  312. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  313. .min_io_address = DEFAULT_IO_BASE,
  314. .min_mem_address = CIA_DEFAULT_MEM_BASE,
  315. .nr_irqs = 35,
  316. .device_interrupt = cabriolet_device_interrupt,
  317. .init_arch = cia_init_arch,
  318. .init_irq = cabriolet_init_irq,
  319. .init_rtc = common_init_rtc,
  320. .init_pci = cia_cab_init_pci,
  321. .kill_arch = cia_kill_arch,
  322. .pci_map_irq = cabriolet_map_irq,
  323. .pci_swizzle = common_swizzle,
  324. };
  325. ALIAS_MV(eb164)
  326. #endif
  327. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EB66P)
  328. struct alpha_machine_vector eb66p_mv __initmv = {
  329. .vector_name = "EB66+",
  330. DO_EV4_MMU,
  331. DO_DEFAULT_RTC,
  332. DO_LCA_IO,
  333. .machine_check = lca_machine_check,
  334. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  335. .min_io_address = DEFAULT_IO_BASE,
  336. .min_mem_address = APECS_AND_LCA_DEFAULT_MEM_BASE,
  337. .nr_irqs = 35,
  338. .device_interrupt = cabriolet_device_interrupt,
  339. .init_arch = lca_init_arch,
  340. .init_irq = cabriolet_init_irq,
  341. .init_rtc = common_init_rtc,
  342. .init_pci = cabriolet_init_pci,
  343. .pci_map_irq = eb66p_map_irq,
  344. .pci_swizzle = common_swizzle,
  345. };
  346. ALIAS_MV(eb66p)
  347. #endif
  348. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_LX164)
  349. struct alpha_machine_vector lx164_mv __initmv = {
  350. .vector_name = "LX164",
  351. DO_EV5_MMU,
  352. DO_DEFAULT_RTC,
  353. DO_PYXIS_IO,
  354. .machine_check = cia_machine_check,
  355. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  356. .min_io_address = DEFAULT_IO_BASE,
  357. .min_mem_address = DEFAULT_MEM_BASE,
  358. .pci_dac_offset = PYXIS_DAC_OFFSET,
  359. .nr_irqs = 35,
  360. .device_interrupt = cabriolet_device_interrupt,
  361. .init_arch = pyxis_init_arch,
  362. .init_irq = cabriolet_init_irq,
  363. .init_rtc = common_init_rtc,
  364. .init_pci = alphapc164_init_pci,
  365. .kill_arch = cia_kill_arch,
  366. .pci_map_irq = alphapc164_map_irq,
  367. .pci_swizzle = common_swizzle,
  368. };
  369. ALIAS_MV(lx164)
  370. #endif
  371. #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_PC164)
  372. struct alpha_machine_vector pc164_mv __initmv = {
  373. .vector_name = "PC164",
  374. DO_EV5_MMU,
  375. DO_DEFAULT_RTC,
  376. DO_CIA_IO,
  377. .machine_check = cia_machine_check,
  378. .max_isa_dma_address = ALPHA_MAX_ISA_DMA_ADDRESS,
  379. .min_io_address = DEFAULT_IO_BASE,
  380. .min_mem_address = CIA_DEFAULT_MEM_BASE,
  381. .nr_irqs = 35,
  382. .device_interrupt = pc164_device_interrupt,
  383. .init_arch = cia_init_arch,
  384. .init_irq = pc164_init_irq,
  385. .init_rtc = common_init_rtc,
  386. .init_pci = alphapc164_init_pci,
  387. .kill_arch = cia_kill_arch,
  388. .pci_map_irq = alphapc164_map_irq,
  389. .pci_swizzle = common_swizzle,
  390. };
  391. ALIAS_MV(pc164)
  392. #endif