sys_cabriolet.c 12 KB

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