pcmcia: Convert pcmcia_device_id declarations to const
[deliverable/linux.git] / drivers / isdn / hisax / avma1_cs.c
CommitLineData
1da177e4
LT
1/*
2 * PCMCIA client driver for AVM A1 / Fritz!PCMCIA
3 *
4 * Author Carsten Paeth
5 * Copyright 1998-2001 by Carsten Paeth <calle@calle.in-berlin.de>
6 *
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
9 *
10 */
11
12#include <linux/module.h>
13
14
15#include <linux/kernel.h>
16#include <linux/init.h>
1da177e4
LT
17#include <linux/ptrace.h>
18#include <linux/slab.h>
19#include <linux/string.h>
20#include <asm/io.h>
21#include <asm/system.h>
22
1da177e4
LT
23#include <pcmcia/cistpl.h>
24#include <pcmcia/ds.h>
25#include "hisax_cfg.h"
26
27MODULE_DESCRIPTION("ISDN4Linux: PCMCIA client driver for AVM A1/Fritz!PCMCIA cards");
28MODULE_AUTHOR("Carsten Paeth");
29MODULE_LICENSE("GPL");
30
1da177e4
LT
31
32/*====================================================================*/
33
34/* Parameters that can be set with 'insmod' */
35
36static int isdnprot = 2;
37
38module_param(isdnprot, int, 0);
39
40/*====================================================================*/
41
a465870a 42static int avma1cs_config(struct pcmcia_device *link) __devinit ;
fba395ee 43static void avma1cs_release(struct pcmcia_device *link);
a465870a 44static void avma1cs_detach(struct pcmcia_device *p_dev) __devexit ;
1da177e4 45
a465870a 46static int __devinit avma1cs_probe(struct pcmcia_device *p_dev)
1da177e4 47{
e773cfe1 48 dev_dbg(&p_dev->dev, "avma1cs_attach()\n");
1da177e4 49
1da177e4 50 /* General socket configuration */
00990e7c 51 p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
7feabb64
DB
52 p_dev->config_index = 1;
53 p_dev->config_regs = PRESENT_OPTION;
f8cfa618 54
15b99ac1 55 return avma1cs_config(p_dev);
1da177e4
LT
56} /* avma1cs_attach */
57
a465870a 58static void __devexit avma1cs_detach(struct pcmcia_device *link)
1da177e4 59{
e773cfe1 60 dev_dbg(&link->dev, "avma1cs_detach(0x%p)\n", link);
e2d40963
DB
61 avma1cs_release(link);
62 kfree(link->priv);
1da177e4
LT
63} /* avma1cs_detach */
64
00990e7c 65static int avma1cs_configcheck(struct pcmcia_device *p_dev, void *priv_data)
1da177e4 66{
00990e7c
DB
67 p_dev->resource[0]->end = 16;
68 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
69 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
90abdc3b 70 p_dev->io_lines = 5;
00990e7c 71
90abdc3b 72 return pcmcia_request_io(p_dev);
1da177e4
LT
73}
74
1da177e4 75
a465870a 76static int __devinit avma1cs_config(struct pcmcia_device *link)
1da177e4 77{
eb14120f 78 int i = -1;
1da177e4
LT
79 char devname[128];
80 IsdnCard_t icard;
81 int busy = 0;
fba395ee 82
e773cfe1 83 dev_dbg(&link->dev, "avma1cs_config(0x%p)\n", link);
1da177e4 84
5fcd4da0
DB
85 devname[0] = 0;
86 if (link->prod_id[1])
87 strlcpy(devname, link->prod_id[1], sizeof(devname));
a9606fd3 88
5fcd4da0
DB
89 if (pcmcia_loop_config(link, avma1cs_configcheck, NULL))
90 return -ENODEV;
1da177e4 91
5fcd4da0 92 do {
1da177e4
LT
93 /*
94 * allocate an interrupt line
95 */
eb14120f 96 if (!link->irq) {
50db3fdb 97 /* undo */
fba395ee 98 pcmcia_disable_device(link);
1da177e4
LT
99 break;
100 }
50db3fdb 101
1da177e4
LT
102 /*
103 * configure the PCMCIA socket
104 */
1ac71e5a 105 i = pcmcia_enable_device(link);
4c89e88b 106 if (i != 0) {
fba395ee 107 pcmcia_disable_device(link);
1da177e4
LT
108 break;
109 }
110
111 } while (0);
112
1da177e4
LT
113 /* If any step failed, release any partially configured state */
114 if (i != 0) {
115 avma1cs_release(link);
15b99ac1 116 return -ENODEV;
1da177e4
LT
117 }
118
eb14120f 119 icard.para[0] = link->irq;
9a017a91 120 icard.para[1] = link->resource[0]->start;
1da177e4
LT
121 icard.protocol = isdnprot;
122 icard.typ = ISDN_CTYPE_A1_PCMCIA;
123
124 i = hisax_init_pcmcia(link, &busy, &icard);
125 if (i < 0) {
9a017a91
DB
126 printk(KERN_ERR "avma1_cs: failed to initialize AVM A1 "
127 "PCMCIA %d at i/o %#x\n", i,
128 (unsigned int) link->resource[0]->start);
1da177e4 129 avma1cs_release(link);
15b99ac1 130 return -ENODEV;
1da177e4 131 }
b498ada6 132 link->priv = (void *) (unsigned long) i;
1da177e4 133
15b99ac1 134 return 0;
1da177e4
LT
135} /* avma1cs_config */
136
fba395ee 137static void avma1cs_release(struct pcmcia_device *link)
1da177e4 138{
b498ada6 139 unsigned long minor = (unsigned long) link->priv;
1da177e4 140
e773cfe1 141 dev_dbg(&link->dev, "avma1cs_release(0x%p)\n", link);
1da177e4 142
5f2a71fc 143 /* now unregister function with hisax */
b498ada6 144 HiSax_closecard(minor);
1da177e4 145
fba395ee 146 pcmcia_disable_device(link);
1da177e4
LT
147} /* avma1cs_release */
148
25f8f54f 149static const struct pcmcia_device_id avma1cs_ids[] = {
c594c12c
DB
150 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb),
151 PCMCIA_DEVICE_PROD_ID12("ISDN", "CARD", 0x8d9761c8, 0x01c5aa7b),
152 PCMCIA_DEVICE_NULL
153};
154MODULE_DEVICE_TABLE(pcmcia, avma1cs_ids);
155
1da177e4
LT
156static struct pcmcia_driver avma1cs_driver = {
157 .owner = THIS_MODULE,
2e9b981a 158 .name = "avma1_cs",
15b99ac1 159 .probe = avma1cs_probe,
a465870a 160 .remove = __devexit_p(avma1cs_detach),
c594c12c 161 .id_table = avma1cs_ids,
1da177e4 162};
8661bb5b 163
1da177e4
LT
164static int __init init_avma1_cs(void)
165{
06b3a1d1 166 return pcmcia_register_driver(&avma1cs_driver);
1da177e4
LT
167}
168
169static void __exit exit_avma1_cs(void)
170{
171 pcmcia_unregister_driver(&avma1cs_driver);
1da177e4
LT
172}
173
174module_init(init_avma1_cs);
175module_exit(exit_avma1_cs);
This page took 1.032506 seconds and 5 git commands to generate.