wax.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * WAX Device Driver
  4. *
  5. * (c) Copyright 2000 The Puffin Group Inc.
  6. *
  7. * by Helge Deller <deller@gmx.de>
  8. */
  9. #include <linux/errno.h>
  10. #include <linux/init.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/ioport.h>
  13. #include <linux/slab.h>
  14. #include <linux/module.h>
  15. #include <linux/types.h>
  16. #include <asm/io.h>
  17. #include <asm/hardware.h>
  18. #include "gsc.h"
  19. #define WAX_GSC_IRQ 7 /* Hardcoded Interrupt for GSC */
  20. static void wax_choose_irq(struct parisc_device *dev, void *ctrl)
  21. {
  22. int irq;
  23. switch (dev->id.sversion) {
  24. case 0x73: irq = 1; break; /* i8042 General */
  25. case 0x8c: irq = 6; break; /* Serial */
  26. case 0x90: irq = 10; break; /* EISA */
  27. default: return; /* Unknown */
  28. }
  29. gsc_asic_assign_irq(ctrl, irq, &dev->irq);
  30. switch (dev->id.sversion) {
  31. case 0x73: irq = 2; break; /* i8042 High-priority */
  32. case 0x90: irq = 0; break; /* EISA NMI */
  33. default: return; /* No secondary IRQ */
  34. }
  35. gsc_asic_assign_irq(ctrl, irq, &dev->aux_irq);
  36. }
  37. static void __init
  38. wax_init_irq(struct gsc_asic *wax)
  39. {
  40. unsigned long base = wax->hpa;
  41. /* Wax-off */
  42. gsc_writel(0x00000000, base+OFFSET_IMR);
  43. /* clear pending interrupts */
  44. gsc_readl(base+OFFSET_IRR);
  45. /* We're not really convinced we want to reset the onboard
  46. * devices. Firmware does it for us...
  47. */
  48. /* Resets */
  49. // gsc_writel(0xFFFFFFFF, base+0x1000); /* HIL */
  50. // gsc_writel(0xFFFFFFFF, base+0x2000); /* RS232-B on Wax */
  51. }
  52. static int __init wax_init_chip(struct parisc_device *dev)
  53. {
  54. struct gsc_asic *wax;
  55. struct parisc_device *parent;
  56. int ret;
  57. wax = kzalloc(sizeof(*wax), GFP_KERNEL);
  58. if (!wax)
  59. return -ENOMEM;
  60. wax->name = "wax";
  61. wax->hpa = dev->hpa.start;
  62. wax->version = 0; /* gsc_readb(wax->hpa+WAX_VER); */
  63. printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa);
  64. /* Stop wax hissing for a bit */
  65. wax_init_irq(wax);
  66. /* the IRQ wax should use */
  67. dev->irq = gsc_claim_irq(&wax->gsc_irq, WAX_GSC_IRQ);
  68. if (dev->irq < 0) {
  69. printk(KERN_ERR "%s(): cannot get GSC irq\n",
  70. __func__);
  71. kfree(wax);
  72. return -EBUSY;
  73. }
  74. wax->eim = ((u32) wax->gsc_irq.txn_addr) | wax->gsc_irq.txn_data;
  75. ret = request_irq(wax->gsc_irq.irq, gsc_asic_intr, 0, "wax", wax);
  76. if (ret < 0) {
  77. kfree(wax);
  78. return ret;
  79. }
  80. /* enable IRQ's for devices below WAX */
  81. gsc_writel(wax->eim, wax->hpa + OFFSET_IAR);
  82. /* Done init'ing, register this driver */
  83. ret = gsc_common_setup(dev, wax);
  84. if (ret) {
  85. kfree(wax);
  86. return ret;
  87. }
  88. gsc_fixup_irqs(dev, wax, wax_choose_irq);
  89. /* On 715-class machines, Wax EISA is a sibling of Wax, not a child. */
  90. parent = parisc_parent(dev);
  91. if (parent->id.hw_type != HPHW_IOA) {
  92. gsc_fixup_irqs(parent, wax, wax_choose_irq);
  93. }
  94. return ret;
  95. }
  96. static const struct parisc_device_id wax_tbl[] __initconst = {
  97. { HPHW_BA, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008e },
  98. { 0, }
  99. };
  100. MODULE_DEVICE_TABLE(parisc, wax_tbl);
  101. struct parisc_driver wax_driver __refdata = {
  102. .name = "wax",
  103. .id_table = wax_tbl,
  104. .probe = wax_init_chip,
  105. };