mantis_pcmcia.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 "dmxdev.h"
  21. #include "dvbdev.h"
  22. #include "dvb_demux.h"
  23. #include "dvb_frontend.h"
  24. #include "dvb_net.h"
  25. #include "mantis_common.h"
  26. #include "mantis_link.h" /* temporary due to physical layer stuff */
  27. #include "mantis_reg.h"
  28. /*
  29. * If Slot state is already PLUG_IN event and we are called
  30. * again, definitely it is jitter alone
  31. */
  32. void mantis_event_cam_plugin(struct mantis_ca *ca)
  33. {
  34. struct mantis_pci *mantis = ca->ca_priv;
  35. u32 gpif_irqcfg;
  36. if (ca->slot_state == MODULE_XTRACTED) {
  37. dprintk(MANTIS_DEBUG, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis->num);
  38. udelay(50);
  39. mmwrite(0xda000000, MANTIS_CARD_RESET);
  40. gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG);
  41. gpif_irqcfg |= MANTIS_MASK_PLUGOUT;
  42. gpif_irqcfg &= ~MANTIS_MASK_PLUGIN;
  43. mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG);
  44. udelay(500);
  45. ca->slot_state = MODULE_INSERTED;
  46. }
  47. udelay(100);
  48. }
  49. /*
  50. * If Slot state is already UN_PLUG event and we are called
  51. * again, definitely it is jitter alone
  52. */
  53. void mantis_event_cam_unplug(struct mantis_ca *ca)
  54. {
  55. struct mantis_pci *mantis = ca->ca_priv;
  56. u32 gpif_irqcfg;
  57. if (ca->slot_state == MODULE_INSERTED) {
  58. dprintk(MANTIS_DEBUG, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis->num);
  59. udelay(50);
  60. mmwrite(0x00da0000, MANTIS_CARD_RESET);
  61. gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG);
  62. gpif_irqcfg |= MANTIS_MASK_PLUGIN;
  63. gpif_irqcfg &= ~MANTIS_MASK_PLUGOUT;
  64. mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG);
  65. udelay(500);
  66. ca->slot_state = MODULE_XTRACTED;
  67. }
  68. udelay(100);
  69. }
  70. int mantis_pcmcia_init(struct mantis_ca *ca)
  71. {
  72. struct mantis_pci *mantis = ca->ca_priv;
  73. u32 gpif_stat, card_stat;
  74. mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_IRQ0, MANTIS_INT_MASK);
  75. gpif_stat = mmread(MANTIS_GPIF_STATUS);
  76. card_stat = mmread(MANTIS_GPIF_IRQCFG);
  77. if (gpif_stat & MANTIS_GPIF_DETSTAT) {
  78. dprintk(MANTIS_DEBUG, 1, "CAM found on Adapter(%d) Slot(0)", mantis->num);
  79. mmwrite(card_stat | MANTIS_MASK_PLUGOUT, MANTIS_GPIF_IRQCFG);
  80. ca->slot_state = MODULE_INSERTED;
  81. dvb_ca_en50221_camchange_irq(&ca->en50221,
  82. 0,
  83. DVB_CA_EN50221_CAMCHANGE_INSERTED);
  84. } else {
  85. dprintk(MANTIS_DEBUG, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis->num);
  86. mmwrite(card_stat | MANTIS_MASK_PLUGIN, MANTIS_GPIF_IRQCFG);
  87. ca->slot_state = MODULE_XTRACTED;
  88. dvb_ca_en50221_camchange_irq(&ca->en50221,
  89. 0,
  90. DVB_CA_EN50221_CAMCHANGE_REMOVED);
  91. }
  92. return 0;
  93. }
  94. void mantis_pcmcia_exit(struct mantis_ca *ca)
  95. {
  96. struct mantis_pci *mantis = ca->ca_priv;
  97. mmwrite(mmread(MANTIS_GPIF_STATUS) & (~MANTIS_CARD_PLUGOUT | ~MANTIS_CARD_PLUGIN), MANTIS_GPIF_STATUS);
  98. mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ0, MANTIS_INT_MASK);
  99. }