lasi.c 6.0 KB

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