mantis_pcmcia.c 3.4 KB

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