sedlbauer_cs.c 22 KB

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