sedlbauer_cs.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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/sched.h>
  33. #include <linux/ptrace.h>
  34. #include <linux/slab.h>
  35. #include <linux/string.h>
  36. #include <linux/timer.h>
  37. #include <linux/ioport.h>
  38. #include <asm/io.h>
  39. #include <asm/system.h>
  40. #include <pcmcia/version.h>
  41. #include <pcmcia/cs_types.h>
  42. #include <pcmcia/cs.h>
  43. #include <pcmcia/cistpl.h>
  44. #include <pcmcia/cisreg.h>
  45. #include <pcmcia/ds.h>
  46. #include "hisax_cfg.h"
  47. MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for Sedlbauer cards");
  48. MODULE_AUTHOR("Marcus Niemann");
  49. MODULE_LICENSE("Dual MPL/GPL");
  50. /*
  51. All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
  52. you do not define PCMCIA_DEBUG at all, all the debug code will be
  53. left out. If you compile with PCMCIA_DEBUG=0, the debug code will
  54. be present but disabled -- but it can then be enabled for specific
  55. modules at load time with a 'pc_debug=#' option to insmod.
  56. */
  57. #ifdef PCMCIA_DEBUG
  58. static int pc_debug = PCMCIA_DEBUG;
  59. module_param(pc_debug, int, 0);
  60. #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args);
  61. static char *version =
  62. "sedlbauer_cs.c 1.1a 2001/01/28 15:04:04 (M.Niemann)";
  63. #else
  64. #define DEBUG(n, args...)
  65. #endif
  66. /*====================================================================*/
  67. /* Parameters that can be set with 'insmod' */
  68. static int protocol = 2; /* EURO-ISDN Default */
  69. module_param(protocol, int, 0);
  70. /*====================================================================*/
  71. /*
  72. The event() function is this driver's Card Services event handler.
  73. It will be called by Card Services when an appropriate card status
  74. event is received. The config() and release() entry points are
  75. used to configure or release a socket, in response to card
  76. insertion and ejection events. They are invoked from the sedlbauer
  77. event handler.
  78. */
  79. static void sedlbauer_config(dev_link_t *link);
  80. static void sedlbauer_release(dev_link_t *link);
  81. static int sedlbauer_event(event_t event, int priority,
  82. event_callback_args_t *args);
  83. /*
  84. The attach() and detach() entry points are used to create and destroy
  85. "instances" of the driver, where each instance represents everything
  86. needed to manage one actual PCMCIA card.
  87. */
  88. static dev_link_t *sedlbauer_attach(void);
  89. static void sedlbauer_detach(dev_link_t *);
  90. /*
  91. You'll also need to prototype all the functions that will actually
  92. be used to talk to your device. See 'memory_cs' for a good example
  93. of a fully self-sufficient driver; the other drivers rely more or
  94. less on other parts of the kernel.
  95. */
  96. /*
  97. The dev_info variable is the "key" that is used to match up this
  98. device driver with appropriate cards, through the card configuration
  99. database.
  100. */
  101. static dev_info_t dev_info = "sedlbauer_cs";
  102. /*
  103. A linked list of "instances" of the sedlbauer device. Each actual
  104. PCMCIA card corresponds to one device instance, and is described
  105. by one dev_link_t structure (defined in ds.h).
  106. You may not want to use a linked list for this -- for example, the
  107. memory card driver uses an array of dev_link_t pointers, where minor
  108. device numbers are used to derive the corresponding array index.
  109. */
  110. static dev_link_t *dev_list = NULL;
  111. /*
  112. A dev_link_t structure has fields for most things that are needed
  113. to keep track of a socket, but there will usually be some device
  114. specific information that also needs to be kept track of. The
  115. 'priv' pointer in a dev_link_t structure can be used to point to
  116. a device-specific private data structure, like this.
  117. To simplify the data structure handling, we actually include the
  118. dev_link_t structure in the device's private data structure.
  119. A driver needs to provide a dev_node_t structure for each device
  120. on a card. In some cases, there is only one device per card (for
  121. example, ethernet cards, modems). In other cases, there may be
  122. many actual or logical devices (SCSI adapters, memory cards with
  123. multiple partitions). The dev_node_t structures need to be kept
  124. in a linked list starting at the 'dev' field of a dev_link_t
  125. structure. We allocate them in the card's private data structure,
  126. because they generally shouldn't be allocated dynamically.
  127. In this case, we also provide a flag to indicate if a device is
  128. "stopped" due to a power management event, or card ejection. The
  129. device IO routines can use a flag like this to throttle IO to a
  130. card that is not ready to accept it.
  131. */
  132. typedef struct local_info_t {
  133. dev_link_t link;
  134. dev_node_t node;
  135. int stop;
  136. int cardnr;
  137. } local_info_t;
  138. /*======================================================================
  139. sedlbauer_attach() creates an "instance" of the driver, allocating
  140. local data structures for one device. The device is registered
  141. with Card Services.
  142. The dev_link structure is initialized, but we don't actually
  143. configure the card at this point -- we wait until we receive a
  144. card insertion event.
  145. ======================================================================*/
  146. static dev_link_t *sedlbauer_attach(void)
  147. {
  148. local_info_t *local;
  149. dev_link_t *link;
  150. client_reg_t client_reg;
  151. int ret;
  152. DEBUG(0, "sedlbauer_attach()\n");
  153. /* Allocate space for private device-specific data */
  154. local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
  155. if (!local) return NULL;
  156. memset(local, 0, sizeof(local_info_t));
  157. local->cardnr = -1;
  158. link = &local->link; link->priv = local;
  159. /* Interrupt setup */
  160. link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
  161. link->irq.IRQInfo1 = IRQ_LEVEL_ID;
  162. link->irq.Handler = NULL;
  163. /*
  164. General socket configuration defaults can go here. In this
  165. client, we assume very little, and rely on the CIS for almost
  166. everything. In most clients, many details (i.e., number, sizes,
  167. and attributes of IO windows) are fixed by the nature of the
  168. device, and can be hard-wired here.
  169. */
  170. /* from old sedl_cs
  171. */
  172. /* The io structure describes IO port mapping */
  173. link->io.NumPorts1 = 8;
  174. link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
  175. link->io.IOAddrLines = 3;
  176. link->conf.Attributes = 0;
  177. link->conf.Vcc = 50;
  178. link->conf.IntType = INT_MEMORY_AND_IO;
  179. /* Register with Card Services */
  180. link->next = dev_list;
  181. dev_list = link;
  182. client_reg.dev_info = &dev_info;
  183. client_reg.EventMask =
  184. CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
  185. CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
  186. CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
  187. client_reg.event_handler = &sedlbauer_event;
  188. client_reg.Version = 0x0210;
  189. client_reg.event_callback_args.client_data = link;
  190. ret = pcmcia_register_client(&link->handle, &client_reg);
  191. if (ret != CS_SUCCESS) {
  192. cs_error(link->handle, RegisterClient, ret);
  193. sedlbauer_detach(link);
  194. return NULL;
  195. }
  196. return link;
  197. } /* sedlbauer_attach */
  198. /*======================================================================
  199. This deletes a driver "instance". The device is de-registered
  200. with Card Services. If it has been released, all local data
  201. structures are freed. Otherwise, the structures will be freed
  202. when the device is released.
  203. ======================================================================*/
  204. static void sedlbauer_detach(dev_link_t *link)
  205. {
  206. dev_link_t **linkp;
  207. DEBUG(0, "sedlbauer_detach(0x%p)\n", link);
  208. /* Locate device structure */
  209. for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
  210. if (*linkp == link) break;
  211. if (*linkp == NULL)
  212. return;
  213. /*
  214. If the device is currently configured and active, we won't
  215. actually delete it yet. Instead, it is marked so that when
  216. the release() function is called, that will trigger a proper
  217. detach().
  218. */
  219. if (link->state & DEV_CONFIG) {
  220. #ifdef PCMCIA_DEBUG
  221. printk(KERN_DEBUG "sedlbauer_cs: detach postponed, '%s' "
  222. "still locked\n", link->dev->dev_name);
  223. #endif
  224. link->state |= DEV_STALE_LINK;
  225. return;
  226. }
  227. /* Break the link with Card Services */
  228. if (link->handle)
  229. pcmcia_deregister_client(link->handle);
  230. /* Unlink device structure, and free it */
  231. *linkp = link->next;
  232. /* This points to the parent local_info_t struct */
  233. kfree(link->priv);
  234. } /* sedlbauer_detach */
  235. /*======================================================================
  236. sedlbauer_config() is scheduled to run after a CARD_INSERTION event
  237. is received, to configure the PCMCIA socket, and to make the
  238. device available to the system.
  239. ======================================================================*/
  240. #define CS_CHECK(fn, ret) \
  241. do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
  242. static void sedlbauer_config(dev_link_t *link)
  243. {
  244. client_handle_t handle = link->handle;
  245. local_info_t *dev = link->priv;
  246. tuple_t tuple;
  247. cisparse_t parse;
  248. int last_fn, last_ret;
  249. u8 buf[64];
  250. config_info_t conf;
  251. win_req_t req;
  252. memreq_t map;
  253. IsdnCard_t icard;
  254. DEBUG(0, "sedlbauer_config(0x%p)\n", link);
  255. /*
  256. This reads the card's CONFIG tuple to find its configuration
  257. registers.
  258. */
  259. tuple.DesiredTuple = CISTPL_CONFIG;
  260. tuple.Attributes = 0;
  261. tuple.TupleData = buf;
  262. tuple.TupleDataMax = sizeof(buf);
  263. tuple.TupleOffset = 0;
  264. CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
  265. CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
  266. CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
  267. link->conf.ConfigBase = parse.config.base;
  268. link->conf.Present = parse.config.rmask[0];
  269. /* Configure card */
  270. link->state |= DEV_CONFIG;
  271. /* Look up the current Vcc */
  272. CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
  273. link->conf.Vcc = conf.Vcc;
  274. /*
  275. In this loop, we scan the CIS for configuration table entries,
  276. each of which describes a valid card configuration, including
  277. voltage, IO window, memory window, and interrupt settings.
  278. We make no assumptions about the card to be configured: we use
  279. just the information available in the CIS. In an ideal world,
  280. this would work for any PCMCIA card, but it requires a complete
  281. and accurate CIS. In practice, a driver usually "knows" most of
  282. these things without consulting the CIS, and most client drivers
  283. will only use the CIS to fill in implementation-defined details.
  284. */
  285. tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
  286. CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
  287. while (1) {
  288. cistpl_cftable_entry_t dflt = { 0 };
  289. cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
  290. if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
  291. pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
  292. goto next_entry;
  293. if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
  294. if (cfg->index == 0) goto next_entry;
  295. link->conf.ConfigIndex = cfg->index;
  296. /* Does this card need audio output? */
  297. if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
  298. link->conf.Attributes |= CONF_ENABLE_SPKR;
  299. link->conf.Status = CCSR_AUDIO_ENA;
  300. }
  301. /* Use power settings for Vcc and Vpp if present */
  302. /* Note that the CIS values need to be rescaled */
  303. if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
  304. if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000)
  305. goto next_entry;
  306. } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) {
  307. if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM]/10000)
  308. goto next_entry;
  309. }
  310. if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
  311. link->conf.Vpp1 = link->conf.Vpp2 =
  312. cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
  313. else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
  314. link->conf.Vpp1 = link->conf.Vpp2 =
  315. dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
  316. /* Do we need to allocate an interrupt? */
  317. if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
  318. link->conf.Attributes |= CONF_ENABLE_IRQ;
  319. /* IO window settings */
  320. link->io.NumPorts1 = link->io.NumPorts2 = 0;
  321. if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
  322. cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
  323. link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
  324. if (!(io->flags & CISTPL_IO_8BIT))
  325. link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
  326. if (!(io->flags & CISTPL_IO_16BIT))
  327. link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
  328. /* new in dummy.cs 2001/01/28 MN
  329. link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
  330. */
  331. link->io.BasePort1 = io->win[0].base;
  332. link->io.NumPorts1 = io->win[0].len;
  333. if (io->nwin > 1) {
  334. link->io.Attributes2 = link->io.Attributes1;
  335. link->io.BasePort2 = io->win[1].base;
  336. link->io.NumPorts2 = io->win[1].len;
  337. }
  338. /* This reserves IO space but doesn't actually enable it */
  339. if (pcmcia_request_io(link->handle, &link->io) != 0)
  340. goto next_entry;
  341. }
  342. /*
  343. Now set up a common memory window, if needed. There is room
  344. in the dev_link_t structure for one memory window handle,
  345. but if the base addresses need to be saved, or if multiple
  346. windows are needed, the info should go in the private data
  347. structure for this device.
  348. Note that the memory window base is a physical address, and
  349. needs to be mapped to virtual space with ioremap() before it
  350. is used.
  351. */
  352. if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) {
  353. cistpl_mem_t *mem =
  354. (cfg->mem.nwin) ? &cfg->mem : &dflt.mem;
  355. req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
  356. req.Attributes |= WIN_ENABLE;
  357. req.Base = mem->win[0].host_addr;
  358. req.Size = mem->win[0].len;
  359. /* new in dummy.cs 2001/01/28 MN
  360. if (req.Size < 0x1000)
  361. req.Size = 0x1000;
  362. */
  363. req.AccessSpeed = 0;
  364. if (pcmcia_request_window(&link->handle, &req, &link->win) != 0)
  365. goto next_entry;
  366. map.Page = 0; map.CardOffset = mem->win[0].card_addr;
  367. if (pcmcia_map_mem_page(link->win, &map) != 0)
  368. goto next_entry;
  369. }
  370. /* If we got this far, we're cool! */
  371. break;
  372. next_entry:
  373. /* new in dummy.cs 2001/01/28 MN
  374. if (link->io.NumPorts1)
  375. pcmcia_release_io(link->handle, &link->io);
  376. */
  377. CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
  378. }
  379. /*
  380. Allocate an interrupt line. Note that this does not assign a
  381. handler to the interrupt, unless the 'Handler' member of the
  382. irq structure is initialized.
  383. */
  384. if (link->conf.Attributes & CONF_ENABLE_IRQ)
  385. CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
  386. /*
  387. This actually configures the PCMCIA socket -- setting up
  388. the I/O windows and the interrupt mapping, and putting the
  389. card and host interface into "Memory and IO" mode.
  390. */
  391. CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
  392. /*
  393. At this point, the dev_node_t structure(s) need to be
  394. initialized and arranged in a linked list at link->dev.
  395. */
  396. sprintf(dev->node.dev_name, "sedlbauer");
  397. dev->node.major = dev->node.minor = 0;
  398. link->dev = &dev->node;
  399. /* Finally, report what we've done */
  400. printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d",
  401. dev->node.dev_name, link->conf.ConfigIndex,
  402. link->conf.Vcc/10, link->conf.Vcc%10);
  403. if (link->conf.Vpp1)
  404. printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10);
  405. if (link->conf.Attributes & CONF_ENABLE_IRQ)
  406. printk(", irq %d", link->irq.AssignedIRQ);
  407. if (link->io.NumPorts1)
  408. printk(", io 0x%04x-0x%04x", link->io.BasePort1,
  409. link->io.BasePort1+link->io.NumPorts1-1);
  410. if (link->io.NumPorts2)
  411. printk(" & 0x%04x-0x%04x", link->io.BasePort2,
  412. link->io.BasePort2+link->io.NumPorts2-1);
  413. if (link->win)
  414. printk(", mem 0x%06lx-0x%06lx", req.Base,
  415. req.Base+req.Size-1);
  416. printk("\n");
  417. link->state &= ~DEV_CONFIG_PENDING;
  418. icard.para[0] = link->irq.AssignedIRQ;
  419. icard.para[1] = link->io.BasePort1;
  420. icard.protocol = protocol;
  421. icard.typ = ISDN_CTYPE_SEDLBAUER_PCMCIA;
  422. last_ret = hisax_init_pcmcia(link, &(((local_info_t*)link->priv)->stop), &icard);
  423. if (last_ret < 0) {
  424. printk(KERN_ERR "sedlbauer_cs: failed to initialize SEDLBAUER PCMCIA %d at i/o %#x\n",
  425. last_ret, link->io.BasePort1);
  426. sedlbauer_release(link);
  427. } else
  428. ((local_info_t*)link->priv)->cardnr = last_ret;
  429. return;
  430. cs_failed:
  431. cs_error(link->handle, last_fn, last_ret);
  432. sedlbauer_release(link);
  433. } /* sedlbauer_config */
  434. /*======================================================================
  435. After a card is removed, sedlbauer_release() will unregister the
  436. device, and release the PCMCIA configuration. If the device is
  437. still open, this will be postponed until it is closed.
  438. ======================================================================*/
  439. static void sedlbauer_release(dev_link_t *link)
  440. {
  441. local_info_t *local = link->priv;
  442. DEBUG(0, "sedlbauer_release(0x%p)\n", link);
  443. if (local) {
  444. if (local->cardnr >= 0) {
  445. /* no unregister function with hisax */
  446. HiSax_closecard(local->cardnr);
  447. }
  448. }
  449. /* Unlink the device chain */
  450. link->dev = NULL;
  451. /*
  452. In a normal driver, additional code may be needed to release
  453. other kernel data structures associated with this device.
  454. */
  455. /* Don't bother checking to see if these succeed or not */
  456. if (link->win)
  457. pcmcia_release_window(link->win);
  458. pcmcia_release_configuration(link->handle);
  459. if (link->io.NumPorts1)
  460. pcmcia_release_io(link->handle, &link->io);
  461. if (link->irq.AssignedIRQ)
  462. pcmcia_release_irq(link->handle, &link->irq);
  463. link->state &= ~DEV_CONFIG;
  464. if (link->state & DEV_STALE_LINK)
  465. sedlbauer_detach(link);
  466. } /* sedlbauer_release */
  467. /*======================================================================
  468. The card status event handler. Mostly, this schedules other
  469. stuff to run after an event is received.
  470. When a CARD_REMOVAL event is received, we immediately set a
  471. private flag to block future accesses to this device. All the
  472. functions that actually access the device should check this flag
  473. to make sure the card is still present.
  474. ======================================================================*/
  475. static int sedlbauer_event(event_t event, int priority,
  476. event_callback_args_t *args)
  477. {
  478. dev_link_t *link = args->client_data;
  479. local_info_t *dev = link->priv;
  480. DEBUG(1, "sedlbauer_event(0x%06x)\n", event);
  481. switch (event) {
  482. case CS_EVENT_CARD_REMOVAL:
  483. link->state &= ~DEV_PRESENT;
  484. if (link->state & DEV_CONFIG) {
  485. ((local_info_t *)link->priv)->stop = 1;
  486. sedlbauer_release(link);
  487. }
  488. break;
  489. case CS_EVENT_CARD_INSERTION:
  490. link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
  491. sedlbauer_config(link);
  492. break;
  493. case CS_EVENT_PM_SUSPEND:
  494. link->state |= DEV_SUSPEND;
  495. /* Fall through... */
  496. case CS_EVENT_RESET_PHYSICAL:
  497. /* Mark the device as stopped, to block IO until later */
  498. dev->stop = 1;
  499. if (link->state & DEV_CONFIG)
  500. pcmcia_release_configuration(link->handle);
  501. break;
  502. case CS_EVENT_PM_RESUME:
  503. link->state &= ~DEV_SUSPEND;
  504. /* Fall through... */
  505. case CS_EVENT_CARD_RESET:
  506. if (link->state & DEV_CONFIG)
  507. pcmcia_request_configuration(link->handle, &link->conf);
  508. dev->stop = 0;
  509. /*
  510. In a normal driver, additional code may go here to restore
  511. the device state and restart IO.
  512. */
  513. break;
  514. }
  515. return 0;
  516. } /* sedlbauer_event */
  517. static struct pcmcia_device_id sedlbauer_ids[] = {
  518. PCMCIA_DEVICE_PROD_ID1234("SEDLBAUER", "speed star II", "V 3.1", "(c) 93 - 98 cb ", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a, 0x50d4149c),
  519. PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", "4D67", 0x81fb79f5, 0xe4e9bc12, 0x397b7e90),
  520. PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", "4D98", 0x81fb79f5, 0xe4e9bc12, 0x2e5c7fce),
  521. PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", " (C) 93-94 VK", 0x81fb79f5, 0xe4e9bc12, 0x8db143fe),
  522. PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", " (c) 93-95 VK", 0x81fb79f5, 0xe4e9bc12, 0xb391ab4c),
  523. PCMCIA_DEVICE_PROD_ID12("HST High Soft Tech GmbH", "Saphir II B", 0xd79e0b84, 0x21d083ae),
  524. /* PCMCIA_DEVICE_PROD_ID1234("SEDLBAUER", 0x81fb79f5), */ /* too generic*/
  525. PCMCIA_DEVICE_NULL
  526. };
  527. MODULE_DEVICE_TABLE(pcmcia, sedlbauer_ids);
  528. static struct pcmcia_driver sedlbauer_driver = {
  529. .owner = THIS_MODULE,
  530. .drv = {
  531. .name = "sedlbauer_cs",
  532. },
  533. .attach = sedlbauer_attach,
  534. .detach = sedlbauer_detach,
  535. .id_table = sedlbauer_ids,
  536. };
  537. static int __init init_sedlbauer_cs(void)
  538. {
  539. return pcmcia_register_driver(&sedlbauer_driver);
  540. }
  541. static void __exit exit_sedlbauer_cs(void)
  542. {
  543. pcmcia_unregister_driver(&sedlbauer_driver);
  544. BUG_ON(dev_list != NULL);
  545. }
  546. module_init(init_sedlbauer_cs);
  547. module_exit(exit_sedlbauer_cs);