pcmcia: Convert pcmcia_device_id declarations to const
[deliverable/linux.git] / drivers / isdn / hardware / avm / avm_cs.c
CommitLineData
1da177e4
LT
1/* $Id: avm_cs.c,v 1.4.6.3 2001/09/23 22:24:33 kai Exp $
2 *
3 * A PCMCIA client driver for AVM B1/M1/M2
4 *
5 * Copyright 1999 by Carsten Paeth <calle@calle.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#include <linux/kernel.h>
14#include <linux/init.h>
1da177e4 15#include <linux/ptrace.h>
1da177e4
LT
16#include <linux/string.h>
17#include <linux/tty.h>
18#include <linux/serial.h>
19#include <linux/major.h>
20#include <asm/io.h>
21#include <asm/system.h>
22
1da177e4
LT
23#include <pcmcia/cistpl.h>
24#include <pcmcia/ciscode.h>
25#include <pcmcia/ds.h>
26#include <pcmcia/cisreg.h>
27
28#include <linux/skbuff.h>
29#include <linux/capi.h>
30#include <linux/b1lli.h>
31#include <linux/b1pcmcia.h>
32
33/*====================================================================*/
34
35MODULE_DESCRIPTION("CAPI4Linux: PCMCIA client driver for AVM B1/M1/M2");
36MODULE_AUTHOR("Carsten Paeth");
37MODULE_LICENSE("GPL");
38
39/*====================================================================*/
40
15b99ac1 41static int avmcs_config(struct pcmcia_device *link);
fba395ee 42static void avmcs_release(struct pcmcia_device *link);
cc3b4866 43static void avmcs_detach(struct pcmcia_device *p_dev);
1da177e4 44
15b99ac1 45static int avmcs_probe(struct pcmcia_device *p_dev)
1da177e4 46{
1da177e4 47 /* General socket configuration */
00990e7c 48 p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
7feabb64
DB
49 p_dev->config_index = 1;
50 p_dev->config_regs = PRESENT_OPTION;
1da177e4 51
15b99ac1 52 return avmcs_config(p_dev);
1da177e4
LT
53} /* avmcs_attach */
54
1da177e4 55
fba395ee 56static void avmcs_detach(struct pcmcia_device *link)
1da177e4 57{
cc3b4866 58 avmcs_release(link);
1da177e4
LT
59} /* avmcs_detach */
60
00990e7c 61static int avmcs_configcheck(struct pcmcia_device *p_dev, void *priv_data)
1da177e4 62{
00990e7c
DB
63 p_dev->resource[0]->end = 16;
64 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
65 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
5fcd4da0 66
90abdc3b 67 return pcmcia_request_io(p_dev);
1da177e4
LT
68}
69
15b99ac1 70static int avmcs_config(struct pcmcia_device *link)
1da177e4 71{
eb14120f 72 int i = -1;
1da177e4
LT
73 char devname[128];
74 int cardtype;
75 int (*addcard)(unsigned int port, unsigned irq);
fba395ee 76
5fcd4da0
DB
77 devname[0] = 0;
78 if (link->prod_id[1])
79 strlcpy(devname, link->prod_id[1], sizeof(devname));
a9606fd3 80
5fcd4da0
DB
81 /*
82 * find IO port
83 */
84 if (pcmcia_loop_config(link, avmcs_configcheck, NULL))
85 return -ENODEV;
50db3fdb 86
5fcd4da0 87 do {
eb14120f 88 if (!link->irq) {
50db3fdb 89 /* undo */
fba395ee 90 pcmcia_disable_device(link);
1da177e4
LT
91 break;
92 }
50db3fdb 93
1da177e4
LT
94 /*
95 * configure the PCMCIA socket
96 */
1ac71e5a 97 i = pcmcia_enable_device(link);
4c89e88b 98 if (i != 0) {
fba395ee 99 pcmcia_disable_device(link);
1da177e4
LT
100 break;
101 }
102
103 } while (0);
104
1da177e4
LT
105 if (devname[0]) {
106 char *s = strrchr(devname, ' ');
107 if (!s)
108 s = devname;
109 else s++;
1da177e4
LT
110 if (strcmp("M1", s) == 0) {
111 cardtype = AVM_CARDTYPE_M1;
112 } else if (strcmp("M2", s) == 0) {
113 cardtype = AVM_CARDTYPE_M2;
114 } else {
115 cardtype = AVM_CARDTYPE_B1;
116 }
ded6a1a3 117 } else
1da177e4 118 cardtype = AVM_CARDTYPE_B1;
e2d40963 119
1da177e4
LT
120 /* If any step failed, release any partially configured state */
121 if (i != 0) {
122 avmcs_release(link);
15b99ac1 123 return -ENODEV;
1da177e4
LT
124 }
125
126
127 switch (cardtype) {
128 case AVM_CARDTYPE_M1: addcard = b1pcmcia_addcard_m1; break;
129 case AVM_CARDTYPE_M2: addcard = b1pcmcia_addcard_m2; break;
130 default:
131 case AVM_CARDTYPE_B1: addcard = b1pcmcia_addcard_b1; break;
132 }
9a017a91
DB
133 if ((i = (*addcard)(link->resource[0]->start, link->irq)) < 0) {
134 dev_err(&link->dev,
135 "avm_cs: failed to add AVM-Controller at i/o %#x, irq %d\n",
136 (unsigned int) link->resource[0]->start, link->irq);
ded6a1a3
DB
137 avmcs_release(link);
138 return -ENODEV;
1da177e4 139 }
15b99ac1 140 return 0;
1da177e4
LT
141
142} /* avmcs_config */
143
1da177e4 144
fba395ee 145static void avmcs_release(struct pcmcia_device *link)
1da177e4 146{
9a017a91 147 b1pcmcia_delcard(link->resource[0]->start, link->irq);
fba395ee 148 pcmcia_disable_device(link);
1da177e4
LT
149} /* avmcs_release */
150
1da177e4 151
25f8f54f 152static const struct pcmcia_device_id avmcs_ids[] = {
a13bcf0d
DB
153 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335),
154 PCMCIA_DEVICE_PROD_ID12("AVM", "Mobile ISDN-Controller M1", 0x95d42008, 0x81e10430),
155 PCMCIA_DEVICE_PROD_ID12("AVM", "Mobile ISDN-Controller M2", 0x95d42008, 0x18e8558a),
156 PCMCIA_DEVICE_NULL
157};
158MODULE_DEVICE_TABLE(pcmcia, avmcs_ids);
159
1da177e4
LT
160static struct pcmcia_driver avmcs_driver = {
161 .owner = THIS_MODULE,
2e9b981a 162 .name = "avm_cs",
15b99ac1 163 .probe = avmcs_probe,
cc3b4866 164 .remove = avmcs_detach,
a13bcf0d 165 .id_table = avmcs_ids,
1da177e4
LT
166};
167
168static int __init avmcs_init(void)
169{
170 return pcmcia_register_driver(&avmcs_driver);
171}
172
173static void __exit avmcs_exit(void)
174{
175 pcmcia_unregister_driver(&avmcs_driver);
1da177e4
LT
176}
177
178module_init(avmcs_init);
179module_exit(avmcs_exit);
This page took 0.582724 seconds and 5 git commands to generate.