mantis_evm.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. Mantis PCI bridge driver
  3. Copyright (C) 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 <linux/kernel.h>
  17. #include <linux/signal.h>
  18. #include <linux/sched.h>
  19. #include <linux/interrupt.h>
  20. #include <asm/io.h>
  21. #include "dmxdev.h"
  22. #include "dvbdev.h"
  23. #include "dvb_demux.h"
  24. #include "dvb_frontend.h"
  25. #include "dvb_net.h"
  26. #include "mantis_common.h"
  27. #include "mantis_link.h"
  28. #include "mantis_hif.h"
  29. #include "mantis_reg.h"
  30. static void mantis_hifevm_work(struct work_struct *work)
  31. {
  32. struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work);
  33. struct mantis_pci *mantis = ca->ca_priv;
  34. u32 gpif_stat, gpif_mask;
  35. gpif_stat = mmread(MANTIS_GPIF_STATUS);
  36. gpif_mask = mmread(MANTIS_GPIF_IRQCFG);
  37. if (gpif_stat & MANTIS_GPIF_DETSTAT) {
  38. if (gpif_stat & MANTIS_CARD_PLUGIN) {
  39. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
  40. mmwrite(0xdada0000, MANTIS_CARD_RESET);
  41. mantis_event_cam_plugin(ca);
  42. dvb_ca_en50221_camchange_irq(&ca->en50221,
  43. 0,
  44. DVB_CA_EN50221_CAMCHANGE_INSERTED);
  45. }
  46. } else {
  47. if (gpif_stat & MANTIS_CARD_PLUGOUT) {
  48. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);
  49. mmwrite(0xdada0000, MANTIS_CARD_RESET);
  50. mantis_event_cam_unplug(ca);
  51. dvb_ca_en50221_camchange_irq(&ca->en50221,
  52. 0,
  53. DVB_CA_EN50221_CAMCHANGE_REMOVED);
  54. }
  55. }
  56. if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ)
  57. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
  58. if (mantis->gpif_status & MANTIS_SBUF_WSTO)
  59. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
  60. if (mantis->gpif_status & MANTIS_GPIF_OTHERR)
  61. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
  62. if (gpif_stat & MANTIS_SBUF_OVFLW)
  63. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);
  64. if (gpif_stat & MANTIS_GPIF_BRRDY)
  65. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
  66. if (gpif_stat & MANTIS_GPIF_INTSTAT)
  67. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);
  68. if (gpif_stat & MANTIS_SBUF_EMPTY)
  69. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);
  70. if (gpif_stat & MANTIS_SBUF_OPDONE) {
  71. dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);
  72. ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL;
  73. ca->hif_event = MANTIS_SBUF_OPDONE;
  74. wake_up(&ca->hif_opdone_wq);
  75. }
  76. }
  77. int mantis_evmgr_init(struct mantis_ca *ca)
  78. {
  79. struct mantis_pci *mantis = ca->ca_priv;
  80. dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
  81. INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work);
  82. mantis_pcmcia_init(ca);
  83. schedule_work(&ca->hif_evm_work);
  84. mantis_hif_init(ca);
  85. return 0;
  86. }
  87. void mantis_evmgr_exit(struct mantis_ca *ca)
  88. {
  89. struct mantis_pci *mantis = ca->ca_priv;
  90. dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
  91. flush_work_sync(&ca->hif_evm_work);
  92. mantis_hif_exit(ca);
  93. mantis_pcmcia_exit(ca);
  94. }