lasi.c 5.9 KB

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