mantis_pcmcia.c 3.0 KB

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