pcmcia.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. Broadcom B43 wireless driver
  3. Copyright (c) 2007 Michael Buesch <mb@bu3sch.de>
  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; see the file COPYING. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #include <linux/ssb/ssb.h>
  18. #include <pcmcia/cs_types.h>
  19. #include <pcmcia/cs.h>
  20. #include <pcmcia/cistpl.h>
  21. #include <pcmcia/ciscode.h>
  22. #include <pcmcia/ds.h>
  23. #include <pcmcia/cisreg.h>
  24. static /*const */ struct pcmcia_device_id b43_pcmcia_tbl[] = {
  25. PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x448),
  26. PCMCIA_DEVICE_NULL,
  27. };
  28. MODULE_DEVICE_TABLE(pcmcia, b43_pcmcia_tbl);
  29. #ifdef CONFIG_PM
  30. static int b43_pcmcia_suspend(struct pcmcia_device *dev)
  31. {
  32. //TODO
  33. return 0;
  34. }
  35. static int b43_pcmcia_resume(struct pcmcia_device *dev)
  36. {
  37. //TODO
  38. return 0;
  39. }
  40. #else /* CONFIG_PM */
  41. # define b43_pcmcia_suspend NULL
  42. # define b43_pcmcia_resume NULL
  43. #endif /* CONFIG_PM */
  44. static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
  45. {
  46. struct ssb_bus *ssb;
  47. win_req_t win;
  48. memreq_t mem;
  49. tuple_t tuple;
  50. cisparse_t parse;
  51. int err = -ENOMEM;
  52. int res;
  53. unsigned char buf[64];
  54. ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
  55. if (!ssb)
  56. goto out;
  57. err = -ENODEV;
  58. tuple.DesiredTuple = CISTPL_CONFIG;
  59. tuple.Attributes = 0;
  60. tuple.TupleData = buf;
  61. tuple.TupleDataMax = sizeof(buf);
  62. tuple.TupleOffset = 0;
  63. res = pcmcia_get_first_tuple(dev, &tuple);
  64. if (res != CS_SUCCESS)
  65. goto err_kfree_ssb;
  66. res = pcmcia_get_tuple_data(dev, &tuple);
  67. if (res != CS_SUCCESS)
  68. goto err_kfree_ssb;
  69. res = pcmcia_parse_tuple(dev, &tuple, &parse);
  70. if (res != CS_SUCCESS)
  71. goto err_kfree_ssb;
  72. dev->conf.ConfigBase = parse.config.base;
  73. dev->conf.Present = parse.config.rmask[0];
  74. dev->io.BasePort2 = 0;
  75. dev->io.NumPorts2 = 0;
  76. dev->io.Attributes2 = 0;
  77. win.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
  78. win.Base = 0;
  79. win.Size = SSB_CORE_SIZE;
  80. win.AccessSpeed = 1000;
  81. res = pcmcia_request_window(&dev, &win, &dev->win);
  82. if (res != CS_SUCCESS)
  83. goto err_kfree_ssb;
  84. mem.CardOffset = 0;
  85. mem.Page = 0;
  86. res = pcmcia_map_mem_page(dev->win, &mem);
  87. if (res != CS_SUCCESS)
  88. goto err_kfree_ssb;
  89. res = pcmcia_request_configuration(dev, &dev->conf);
  90. if (res != CS_SUCCESS)
  91. goto err_disable;
  92. err = ssb_bus_pcmciabus_register(ssb, dev, win.Base);
  93. dev->priv = ssb;
  94. out:
  95. return err;
  96. err_disable:
  97. pcmcia_disable_device(dev);
  98. err_kfree_ssb:
  99. kfree(ssb);
  100. return err;
  101. }
  102. static void __devexit b43_pcmcia_remove(struct pcmcia_device *dev)
  103. {
  104. struct ssb_bus *ssb = dev->priv;
  105. ssb_bus_unregister(ssb);
  106. pcmcia_release_window(dev->win);
  107. pcmcia_disable_device(dev);
  108. kfree(ssb);
  109. dev->priv = NULL;
  110. }
  111. static struct pcmcia_driver b43_pcmcia_driver = {
  112. .owner = THIS_MODULE,
  113. .drv = {
  114. .name = "b43-pcmcia",
  115. },
  116. .id_table = b43_pcmcia_tbl,
  117. .probe = b43_pcmcia_probe,
  118. .remove = b43_pcmcia_remove,
  119. .suspend = b43_pcmcia_suspend,
  120. .resume = b43_pcmcia_resume,
  121. };
  122. int b43_pcmcia_init(void)
  123. {
  124. return pcmcia_register_driver(&b43_pcmcia_driver);
  125. }
  126. void b43_pcmcia_exit(void)
  127. {
  128. pcmcia_unregister_driver(&b43_pcmcia_driver);
  129. }