lasi.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * LASI Device Driver
  3. *
  4. * (c) Copyright 1999 Red Hat Software
  5. * Portions (c) Copyright 1999 The Puffin Group Inc.
  6. * Portions (c) Copyright 1999 Hewlett-Packard
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * by Alan Cox <alan@redhat.com> and
  14. * Alex deVries <alex@onefishtwo.ca>
  15. */
  16. #include <linux/errno.h>
  17. #include <linux/init.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/slab.h>
  20. #include <linux/module.h>
  21. #include <linux/pm.h>
  22. #include <linux/types.h>
  23. #include <asm/io.h>
  24. #include <asm/hardware.h>
  25. #include <asm/led.h>
  26. #include "gsc.h"
  27. #define LASI_VER 0xC008 /* LASI Version */
  28. #define LASI_IO_CONF 0x7FFFE /* LASI primary configuration register */
  29. #define LASI_IO_CONF2 0x7FFFF /* LASI secondary configuration register */
  30. static void lasi_choose_irq(struct parisc_device *dev, void *ctrl)
  31. {
  32. int irq;
  33. switch (dev->id.sversion) {
  34. case 0x74: irq = 7; break; /* Centronics */
  35. case 0x7B: irq = 13; break; /* Audio */
  36. case 0x81: irq = 14; break; /* Lasi itself */
  37. case 0x82: irq = 9; break; /* SCSI */
  38. case 0x83: irq = 20; break; /* Floppy */
  39. case 0x84: irq = 26; break; /* PS/2 Keyboard */
  40. case 0x87: irq = 18; break; /* ISDN */
  41. case 0x8A: irq = 8; break; /* LAN */
  42. case 0x8C: irq = 5; break; /* RS232 */
  43. case 0x8D: irq = (dev->hw_path == 13) ? 16 : 17; break;
  44. /* Telephone */
  45. default: return; /* unknown */
  46. }
  47. gsc_asic_assign_irq(ctrl, irq, &dev->irq);
  48. }
  49. static void __init
  50. lasi_init_irq(struct gsc_asic *this_lasi)
  51. {
  52. unsigned long lasi_base = this_lasi->hpa;
  53. /* Stop LASI barking for a bit */
  54. gsc_writel(0x00000000, lasi_base+OFFSET_IMR);
  55. /* clear pending interrupts */
  56. gsc_readl(lasi_base+OFFSET_IRR);
  57. /* We're not really convinced we want to reset the onboard
  58. * devices. Firmware does it for us...
  59. */
  60. /* Resets */
  61. /* gsc_writel(0xFFFFFFFF, lasi_base+0x2000);*/ /* Parallel */
  62. if(pdc_add_valid(lasi_base+0x4004) == PDC_OK)
  63. gsc_writel(0xFFFFFFFF, lasi_base+0x4004); /* Audio */
  64. /* gsc_writel(0xFFFFFFFF, lasi_base+0x5000);*/ /* Serial */
  65. /* gsc_writel(0xFFFFFFFF, lasi_base+0x6000);*/ /* SCSI */
  66. gsc_writel(0xFFFFFFFF, lasi_base+0x7000); /* LAN */
  67. gsc_writel(0xFFFFFFFF, lasi_base+0x8000); /* Keyboard */
  68. gsc_writel(0xFFFFFFFF, lasi_base+0xA000); /* FDC */
  69. /* Ok we hit it on the head with a hammer, our Dog is now
  70. ** comatose and muzzled. Devices will now unmask LASI
  71. ** interrupts as they are registered as irq's in the LASI range.
  72. */
  73. /* XXX: I thought it was `awks that got `it on the `ead with an
  74. * `ammer. -- willy
  75. */
  76. }
  77. /*
  78. ** lasi_led_init()
  79. **
  80. ** lasi_led_init() initializes the LED controller on the LASI.
  81. **
  82. ** Since Mirage and Electra machines use a different LED
  83. ** address register, we need to check for these machines
  84. ** explicitly.
  85. */
  86. #ifndef CONFIG_CHASSIS_LCD_LED
  87. #define lasi_led_init(x) /* nothing */
  88. #else
  89. static void __init lasi_led_init(unsigned long lasi_hpa)
  90. {
  91. unsigned long datareg;
  92. switch (CPU_HVERSION) {
  93. /* Gecko machines have only one single LED, which can be permanently
  94. turned on by writing a zero into the power control register. */
  95. case 0x600: /* Gecko (712/60) */
  96. case 0x601: /* Gecko (712/80) */
  97. case 0x602: /* Gecko (712/100) */
  98. case 0x603: /* Anole 64 (743/64) */
  99. case 0x604: /* Anole 100 (743/100) */
  100. case 0x605: /* Gecko (712/120) */
  101. datareg = lasi_hpa + 0x0000C000;
  102. gsc_writeb(0, datareg);
  103. return; /* no need to register the LED interrupt-function */
  104. /* Mirage and Electra machines need special offsets */
  105. case 0x60A: /* Mirage Jr (715/64) */
  106. case 0x60B: /* Mirage 100 */
  107. case 0x60C: /* Mirage 100+ */
  108. case 0x60D: /* Electra 100 */
  109. case 0x60E: /* Electra 120 */
  110. datareg = lasi_hpa - 0x00020000;
  111. break;
  112. default:
  113. datareg = lasi_hpa + 0x0000C000;
  114. break;
  115. }
  116. register_led_driver(DISPLAY_MODEL_LASI, LED_CMD_REG_NONE, datareg);
  117. }
  118. #endif
  119. /*
  120. * lasi_power_off
  121. *
  122. * Function for lasi to turn off the power. This is accomplished by setting a
  123. * 1 to PWR_ON_L in the Power Control Register
  124. *
  125. */
  126. static unsigned long lasi_power_off_hpa __read_mostly;
  127. static void lasi_power_off(void)
  128. {
  129. unsigned long datareg;
  130. /* calculate addr of the Power Control Register */
  131. datareg = lasi_power_off_hpa + 0x0000C000;
  132. /* Power down the machine */
  133. gsc_writel(0x02, datareg);
  134. }
  135. static int __init lasi_init_chip(struct parisc_device *dev)
  136. {
  137. extern void (*chassis_power_off)(void);
  138. struct gsc_asic *lasi;
  139. struct gsc_irq gsc_irq;
  140. int ret;
  141. lasi = kzalloc(sizeof(*lasi), GFP_KERNEL);
  142. if (!lasi)
  143. return -ENOMEM;
  144. lasi->name = "Lasi";
  145. lasi->hpa = dev->hpa.start;
  146. /* Check the 4-bit (yes, only 4) version register */
  147. lasi->version = gsc_readl(lasi->hpa + LASI_VER) & 0xf;
  148. printk(KERN_INFO "%s version %d at 0x%lx found.\n",
  149. lasi->name, lasi->version, lasi->hpa);
  150. /* initialize the chassis LEDs really early */
  151. lasi_led_init(lasi->hpa);
  152. /* Stop LASI barking for a bit */
  153. lasi_init_irq(lasi);
  154. /* the IRQ lasi should use */
  155. dev->irq = gsc_alloc_irq(&gsc_irq);
  156. if (dev->irq < 0) {
  157. printk(KERN_ERR "%s(): cannot get GSC irq\n",
  158. __func__);
  159. kfree(lasi);
  160. return -EBUSY;
  161. }
  162. lasi->eim = ((u32) gsc_irq.txn_addr) | gsc_irq.txn_data;
  163. ret = request_irq(gsc_irq.irq, gsc_asic_intr, 0, "lasi", lasi);
  164. if (ret < 0) {
  165. kfree(lasi);
  166. return ret;
  167. }
  168. /* enable IRQ's for devices below LASI */
  169. gsc_writel(lasi->eim, lasi->hpa + OFFSET_IAR);
  170. /* Done init'ing, register this driver */
  171. ret = gsc_common_setup(dev, lasi);
  172. if (ret) {
  173. kfree(lasi);
  174. return ret;
  175. }
  176. gsc_fixup_irqs(dev, lasi, lasi_choose_irq);
  177. /* initialize the power off function */
  178. /* FIXME: Record the LASI HPA for the power off function. This should
  179. * ensure that only the first LASI (the one controlling the power off)
  180. * should set the HPA here */
  181. lasi_power_off_hpa = lasi->hpa;
  182. chassis_power_off = lasi_power_off;
  183. return ret;
  184. }
  185. static struct parisc_device_id lasi_tbl[] = {
  186. { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00081 },
  187. { 0, }
  188. };
  189. struct parisc_driver lasi_driver = {
  190. .name = "lasi",
  191. .id_table = lasi_tbl,
  192. .probe = lasi_init_chip,
  193. };