Linux Audio

Check our new training course

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