sedlbauer_cs.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*======================================================================
  2. A Sedlbauer PCMCIA client driver
  3. This driver is for the Sedlbauer Speed Star and Speed Star II,
  4. which are ISDN PCMCIA Cards.
  5. The contents of this file are subject to the Mozilla Public
  6. License Version 1.1 (the "License"); you may not use this file
  7. except in compliance with the License. You may obtain a copy of
  8. the License at http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS
  10. IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  11. implied. See the License for the specific language governing
  12. rights and limitations under the License.
  13. The initial developer of the original code is David A. Hinds
  14. <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
  15. are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
  16. Modifications from dummy_cs.c are Copyright (C) 1999-2001 Marcus Niemann
  17. <maniemann@users.sourceforge.net>. All Rights Reserved.
  18. Alternatively, the contents of this file may be used under the
  19. terms of the GNU General Public License version 2 (the "GPL"), in
  20. which case the provisions of the GPL are applicable instead of the
  21. above. If you wish to allow the use of your version of this file
  22. only under the terms of the GPL and not to allow others to use
  23. your version of this file under the MPL, indicate your decision
  24. by deleting the provisions above and replace them with the notice
  25. and other provisions required by the GPL. If you do not delete
  26. the provisions above, a recipient may use your version of this
  27. file under either the MPL or the GPL.
  28. ======================================================================*/
  29. #include <linux/kernel.h>
  30. #include <linux/module.h>
  31. #include <linux/init.h>
  32. #include <linux/ptrace.h>
  33. #include <linux/slab.h>
  34. #include <linux/string.h>
  35. #include <linux/timer.h>
  36. #include <linux/ioport.h>
  37. #include <asm/io.h>
  38. #include <pcmcia/cistpl.h>
  39. #include <pcmcia/cisreg.h>
  40. #include <pcmcia/ds.h>
  41. #include "hisax_cfg.h"
  42. MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for Sedlbauer cards");
  43. MODULE_AUTHOR("Marcus Niemann");
  44. MODULE_LICENSE("Dual MPL/GPL");
  45. /*====================================================================*/
  46. /* Parameters that can be set with 'insmod' */
  47. static int protocol = 2; /* EURO-ISDN Default */
  48. module_param(protocol, int, 0);
  49. static int sedlbauer_config(struct pcmcia_device *link);
  50. static void sedlbauer_release(struct pcmcia_device *link);
  51. static void sedlbauer_detach(struct pcmcia_device *p_dev);
  52. typedef struct local_info_t {
  53. struct pcmcia_device *p_dev;
  54. int stop;
  55. int cardnr;
  56. } local_info_t;
  57. static int sedlbauer_probe(struct pcmcia_device *link)
  58. {
  59. local_info_t *local;
  60. dev_dbg(&link->dev, "sedlbauer_attach()\n");
  61. /* Allocate space for private device-specific data */
  62. local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
  63. if (!local) return -ENOMEM;
  64. local->cardnr = -1;
  65. local->p_dev = link;
  66. link->priv = local;
  67. return sedlbauer_config(link);
  68. } /* sedlbauer_attach */
  69. static void sedlbauer_detach(struct pcmcia_device *link)
  70. {
  71. dev_dbg(&link->dev, "sedlbauer_detach(0x%p)\n", link);
  72. ((local_info_t *)link->priv)->stop = 1;
  73. sedlbauer_release(link);
  74. /* This points to the parent local_info_t struct */
  75. kfree(link->priv);
  76. } /* sedlbauer_detach */
  77. static int sedlbauer_config_check(struct pcmcia_device *p_dev, void *priv_data)
  78. {
  79. if (p_dev->config_index == 0)
  80. return -EINVAL;
  81. p_dev->io_lines = 3;
  82. return pcmcia_request_io(p_dev);
  83. }
  84. static int sedlbauer_config(struct pcmcia_device *link)
  85. {
  86. int ret;
  87. IsdnCard_t icard;
  88. dev_dbg(&link->dev, "sedlbauer_config(0x%p)\n", link);
  89. link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC |
  90. CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
  91. ret = pcmcia_loop_config(link, sedlbauer_config_check, NULL);
  92. if (ret)
  93. goto failed;
  94. ret = pcmcia_enable_device(link);
  95. if (ret)
  96. goto failed;
  97. icard.para[0] = link->irq;
  98. icard.para[1] = link->resource[0]->start;
  99. icard.protocol = protocol;
  100. icard.typ = ISDN_CTYPE_SEDLBAUER_PCMCIA;
  101. ret = hisax_init_pcmcia(link,
  102. &(((local_info_t *)link->priv)->stop), &icard);
  103. if (ret < 0) {
  104. printk(KERN_ERR "sedlbauer_cs: failed to initialize SEDLBAUER PCMCIA %d with %pR\n",
  105. ret, link->resource[0]);
  106. sedlbauer_release(link);
  107. return -ENODEV;
  108. } else
  109. ((local_info_t *)link->priv)->cardnr = ret;
  110. return 0;
  111. failed:
  112. sedlbauer_release(link);
  113. return -ENODEV;
  114. } /* sedlbauer_config */
  115. static void sedlbauer_release(struct pcmcia_device *link)
  116. {
  117. local_info_t *local = link->priv;
  118. dev_dbg(&link->dev, "sedlbauer_release(0x%p)\n", link);
  119. if (local) {
  120. if (local->cardnr >= 0) {
  121. /* no unregister function with hisax */
  122. HiSax_closecard(local->cardnr);
  123. }
  124. }
  125. pcmcia_disable_device(link);
  126. } /* sedlbauer_release */
  127. static int sedlbauer_suspend(struct pcmcia_device *link)
  128. {
  129. local_info_t *dev = link->priv;
  130. dev->stop = 1;
  131. return 0;
  132. }
  133. static int sedlbauer_resume(struct pcmcia_device *link)
  134. {
  135. local_info_t *dev = link->priv;
  136. dev->stop = 0;
  137. return 0;
  138. }
  139. static const struct pcmcia_device_id sedlbauer_ids[] = {
  140. PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "speed star II", "V 3.1", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a),
  141. PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", "4D67", 0x81fb79f5, 0xe4e9bc12, 0x397b7e90),
  142. PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", "4D98", 0x81fb79f5, 0xe4e9bc12, 0x2e5c7fce),
  143. PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", " (C) 93-94 VK", 0x81fb79f5, 0xe4e9bc12, 0x8db143fe),
  144. PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", " (c) 93-95 VK", 0x81fb79f5, 0xe4e9bc12, 0xb391ab4c),
  145. PCMCIA_DEVICE_PROD_ID12("HST High Soft Tech GmbH", "Saphir II B", 0xd79e0b84, 0x21d083ae),
  146. /* PCMCIA_DEVICE_PROD_ID1234("SEDLBAUER", 0x81fb79f5), */ /* too generic*/
  147. PCMCIA_DEVICE_NULL
  148. };
  149. MODULE_DEVICE_TABLE(pcmcia, sedlbauer_ids);
  150. static struct pcmcia_driver sedlbauer_driver = {
  151. .owner = THIS_MODULE,
  152. .name = "sedlbauer_cs",
  153. .probe = sedlbauer_probe,
  154. .remove = sedlbauer_detach,
  155. .id_table = sedlbauer_ids,
  156. .suspend = sedlbauer_suspend,
  157. .resume = sedlbauer_resume,
  158. };
  159. module_pcmcia_driver(sedlbauer_driver);