mantis_evm.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. Mantis PCI bridge driver
  3. Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include "mantis_common.h"
  17. #include "mantis_link.h"
  18. #include "mantis_hif.h"
  19. void mantis_hifevm_tasklet(unsigned long data)
  20. {
  21. struct mantis_ca *ca = (struct mantis_ca *) data;
  22. struct mantis_pci *mantis = ca->ca_priv;
  23. u32 gpif_stat, gpif_mask;
  24. gpif_stat = mmread(MANTIS_GPIF_STATUS);
  25. gpif_mask = mmread(MANTIS_GPIF_IRQCFG);
  26. if (!((gpif_stat & 0xff) & (gpif_mask & 0xff)))
  27. return;
  28. if (gpif_stat & MANTIS_GPIF_DETSTAT) {
  29. if (gpif_stat & MANTIS_CARD_PLUGIN) {
  30. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
  31. mmwrite(0xdada0000, MANTIS_CARD_RESET);
  32. // Plugin call here
  33. gpif_stat = 0; // crude !
  34. }
  35. } else {
  36. if (gpif_stat & MANTIS_CARD_PLUGOUT) {
  37. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);
  38. mmwrite(0xdada0000, MANTIS_CARD_RESET);
  39. // Unplug call here
  40. gpif_stat = 0; // crude !
  41. }
  42. }
  43. if (gpif_stat & MANTIS_GPIF_EXTIRQ)
  44. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
  45. if (gpif_stat & MANTIS_SBUF_WSTO)
  46. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
  47. if (gpif_stat & MANTIS_GPIF_OTHERR)
  48. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
  49. if (gpif_stat & MANTIS_SBUF_OVFLW)
  50. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);
  51. if (gpif_stat & MANTIS_GPIF_BRRDY) {
  52. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
  53. ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL;
  54. if (ca->hif_job_queue & MANTIS_HIF_MEMRD)
  55. wake_up(&ca->hif_brrdyw_wq);
  56. }
  57. if (gpif_stat & MANTIS_GPIF_WRACK)
  58. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Slave Write ACK", mantis->num);
  59. if (gpif_stat & MANTIS_GPIF_INTSTAT)
  60. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);
  61. if (gpif_stat & MANTIS_SBUF_EMPTY)
  62. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);
  63. if (gpif_stat & MANTIS_SBUF_OPDONE) {
  64. dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);
  65. if (ca->hif_job_queue) {
  66. wake_up(&ca->hif_opdone_wq);
  67. ca->hif_event = MANTIS_SBUF_OPDONE;
  68. }
  69. }
  70. }
  71. int mantis_evmgr_init(struct mantis_ca *ca)
  72. {
  73. struct mantis_pci *mantis = ca->ca_priv;
  74. dprintk(verbose, MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
  75. tasklet_init(&ca->hif_evm_tasklet, mantis_hifevm_tasklet, (unsigned long) ca);
  76. mantis_pcmcia_init(ca);
  77. return 0;
  78. }
  79. void mantis_evmgr_exit(struct mantis_ca *ca)
  80. {
  81. struct mantis_pci *mantis = ca->ca_priv;
  82. dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
  83. tasklet_kill(&ca->hif_evm_tasklet);
  84. mantis_pcmcia_exit(ca);
  85. }