Linux Audio

Check our new training course

Loading...
v6.8
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * Copyright (C) 2008-2010
  4 *
  5 * - Kurt Van Dijck, EIA Electronics
 
 
 
 
 
 
 
 
 
 
 
 
 
  6 */
  7
  8#include <linux/module.h>
  9#include <linux/kernel.h>
 10#include <linux/slab.h>
 11
 12#include <pcmcia/cistpl.h>
 13#include <pcmcia/ds.h>
 14
 15#include "softing_platform.h"
 16
 17static int softingcs_index;
 18static DEFINE_SPINLOCK(softingcs_index_lock);
 19
 20static int softingcs_reset(struct platform_device *pdev, int v);
 21static int softingcs_enable_irq(struct platform_device *pdev, int v);
 22
 23/*
 24 * platform_data descriptions
 25 */
 26#define MHZ (1000*1000)
 27static const struct softing_platform_data softingcs_platform_data[] = {
 28{
 29	.name = "CANcard",
 30	.manf = 0x0168, .prod = 0x001,
 31	.generation = 1,
 32	.nbus = 2,
 33	.freq = 16 * MHZ, .max_brp = 32, .max_sjw = 4,
 34	.dpram_size = 0x0800,
 35	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
 36	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
 37	.app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
 38	.reset = softingcs_reset,
 39	.enable_irq = softingcs_enable_irq,
 40}, {
 41	.name = "CANcard-NEC",
 42	.manf = 0x0168, .prod = 0x002,
 43	.generation = 1,
 44	.nbus = 2,
 45	.freq = 16 * MHZ, .max_brp = 32, .max_sjw = 4,
 46	.dpram_size = 0x0800,
 47	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
 48	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
 49	.app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
 50	.reset = softingcs_reset,
 51	.enable_irq = softingcs_enable_irq,
 52}, {
 53	.name = "CANcard-SJA",
 54	.manf = 0x0168, .prod = 0x004,
 55	.generation = 1,
 56	.nbus = 2,
 57	.freq = 20 * MHZ, .max_brp = 32, .max_sjw = 4,
 58	.dpram_size = 0x0800,
 59	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
 60	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
 61	.app = {0x0010, 0x0d0000, fw_dir "cansja.bin",},
 62	.reset = softingcs_reset,
 63	.enable_irq = softingcs_enable_irq,
 64}, {
 65	.name = "CANcard-2",
 66	.manf = 0x0168, .prod = 0x005,
 67	.generation = 2,
 68	.nbus = 2,
 69	.freq = 24 * MHZ, .max_brp = 64, .max_sjw = 4,
 70	.dpram_size = 0x1000,
 71	.boot = {0x0000, 0x000000, fw_dir "bcard2.bin",},
 72	.load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",},
 73	.app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",},
 74	.reset = softingcs_reset,
 75	.enable_irq = NULL,
 76}, {
 77	.name = "Vector-CANcard",
 78	.manf = 0x0168, .prod = 0x081,
 79	.generation = 1,
 80	.nbus = 2,
 81	.freq = 16 * MHZ, .max_brp = 64, .max_sjw = 4,
 82	.dpram_size = 0x0800,
 83	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
 84	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
 85	.app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
 86	.reset = softingcs_reset,
 87	.enable_irq = softingcs_enable_irq,
 88}, {
 89	.name = "Vector-CANcard-SJA",
 90	.manf = 0x0168, .prod = 0x084,
 91	.generation = 1,
 92	.nbus = 2,
 93	.freq = 20 * MHZ, .max_brp = 32, .max_sjw = 4,
 94	.dpram_size = 0x0800,
 95	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
 96	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
 97	.app = {0x0010, 0x0d0000, fw_dir "cansja.bin",},
 98	.reset = softingcs_reset,
 99	.enable_irq = softingcs_enable_irq,
100}, {
101	.name = "Vector-CANcard-2",
102	.manf = 0x0168, .prod = 0x085,
103	.generation = 2,
104	.nbus = 2,
105	.freq = 24 * MHZ, .max_brp = 64, .max_sjw = 4,
106	.dpram_size = 0x1000,
107	.boot = {0x0000, 0x000000, fw_dir "bcard2.bin",},
108	.load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",},
109	.app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",},
110	.reset = softingcs_reset,
111	.enable_irq = NULL,
112}, {
113	.name = "EDICcard-NEC",
114	.manf = 0x0168, .prod = 0x102,
115	.generation = 1,
116	.nbus = 2,
117	.freq = 16 * MHZ, .max_brp = 64, .max_sjw = 4,
118	.dpram_size = 0x0800,
119	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
120	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
121	.app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
122	.reset = softingcs_reset,
123	.enable_irq = softingcs_enable_irq,
124}, {
125	.name = "EDICcard-2",
126	.manf = 0x0168, .prod = 0x105,
127	.generation = 2,
128	.nbus = 2,
129	.freq = 24 * MHZ, .max_brp = 64, .max_sjw = 4,
130	.dpram_size = 0x1000,
131	.boot = {0x0000, 0x000000, fw_dir "bcard2.bin",},
132	.load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",},
133	.app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",},
134	.reset = softingcs_reset,
135	.enable_irq = NULL,
136}, {
137	0, 0,
138},
139};
140
141MODULE_FIRMWARE(fw_dir "bcard.bin");
142MODULE_FIRMWARE(fw_dir "ldcard.bin");
143MODULE_FIRMWARE(fw_dir "cancard.bin");
144MODULE_FIRMWARE(fw_dir "cansja.bin");
145
146MODULE_FIRMWARE(fw_dir "bcard2.bin");
147MODULE_FIRMWARE(fw_dir "ldcard2.bin");
148MODULE_FIRMWARE(fw_dir "cancrd2.bin");
149
150static const struct softing_platform_data
151*softingcs_find_platform_data(unsigned int manf, unsigned int prod)
152{
153	const struct softing_platform_data *lp;
154
155	for (lp = softingcs_platform_data; lp->manf; ++lp) {
156		if ((lp->manf == manf) && (lp->prod == prod))
157			return lp;
158	}
159	return NULL;
160}
161
162/*
163 * platformdata callbacks
164 */
165static int softingcs_reset(struct platform_device *pdev, int v)
166{
167	struct pcmcia_device *pcmcia = to_pcmcia_dev(pdev->dev.parent);
168
169	dev_dbg(&pdev->dev, "pcmcia config [2] %02x\n", v ? 0 : 0x20);
170	return pcmcia_write_config_byte(pcmcia, 2, v ? 0 : 0x20);
171}
172
173static int softingcs_enable_irq(struct platform_device *pdev, int v)
174{
175	struct pcmcia_device *pcmcia = to_pcmcia_dev(pdev->dev.parent);
176
177	dev_dbg(&pdev->dev, "pcmcia config [0] %02x\n", v ? 0x60 : 0);
178	return pcmcia_write_config_byte(pcmcia, 0, v ? 0x60 : 0);
179}
180
181/*
182 * pcmcia check
183 */
184static int softingcs_probe_config(struct pcmcia_device *pcmcia, void *priv_data)
 
185{
186	struct softing_platform_data *pdat = priv_data;
187	struct resource *pres;
188	int memspeed = 0;
189
190	WARN_ON(!pdat);
191	pres = pcmcia->resource[PCMCIA_IOMEM_0];
192	if (resource_size(pres) < 0x1000)
193		return -ERANGE;
194
195	pres->flags |= WIN_MEMORY_TYPE_CM | WIN_ENABLE;
196	if (pdat->generation < 2) {
197		pres->flags |= WIN_USE_WAIT | WIN_DATA_WIDTH_8;
198		memspeed = 3;
199	} else {
200		pres->flags |= WIN_DATA_WIDTH_16;
201	}
202	return pcmcia_request_window(pcmcia, pres, memspeed);
203}
204
205static void softingcs_remove(struct pcmcia_device *pcmcia)
206{
207	struct platform_device *pdev = pcmcia->priv;
208
209	/* free bits */
210	platform_device_unregister(pdev);
211	/* release pcmcia stuff */
212	pcmcia_disable_device(pcmcia);
213}
214
215/*
216 * platform_device wrapper
217 * pdev->resource has 2 entries: io & irq
218 */
219static void softingcs_pdev_release(struct device *dev)
220{
221	struct platform_device *pdev = to_platform_device(dev);
222	kfree(pdev);
223}
224
225static int softingcs_probe(struct pcmcia_device *pcmcia)
226{
227	int ret;
228	struct platform_device *pdev;
229	const struct softing_platform_data *pdat;
230	struct resource *pres;
231	struct dev {
232		struct platform_device pdev;
233		struct resource res[2];
234	} *dev;
235
236	/* find matching platform_data */
237	pdat = softingcs_find_platform_data(pcmcia->manf_id, pcmcia->card_id);
238	if (!pdat)
239		return -ENOTTY;
240
241	/* setup pcmcia device */
242	pcmcia->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IOMEM |
243		CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC;
244	ret = pcmcia_loop_config(pcmcia, softingcs_probe_config, (void *)pdat);
245	if (ret)
246		goto pcmcia_failed;
247
248	ret = pcmcia_enable_device(pcmcia);
249	if (ret < 0)
250		goto pcmcia_failed;
251
252	pres = pcmcia->resource[PCMCIA_IOMEM_0];
253	if (!pres) {
254		ret = -EBADF;
255		goto pcmcia_bad;
256	}
257
258	/* create softing platform device */
259	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
260	if (!dev) {
261		ret = -ENOMEM;
262		goto mem_failed;
263	}
264	dev->pdev.resource = dev->res;
265	dev->pdev.num_resources = ARRAY_SIZE(dev->res);
266	dev->pdev.dev.release = softingcs_pdev_release;
267
268	pdev = &dev->pdev;
269	pdev->dev.platform_data = (void *)pdat;
270	pdev->dev.parent = &pcmcia->dev;
271	pcmcia->priv = pdev;
272
273	/* platform device resources */
274	pdev->resource[0].flags = IORESOURCE_MEM;
275	pdev->resource[0].start = pres->start;
276	pdev->resource[0].end = pres->end;
277
278	pdev->resource[1].flags = IORESOURCE_IRQ;
279	pdev->resource[1].start = pcmcia->irq;
280	pdev->resource[1].end = pdev->resource[1].start;
281
282	/* platform device setup */
283	spin_lock(&softingcs_index_lock);
284	pdev->id = softingcs_index++;
285	spin_unlock(&softingcs_index_lock);
286	pdev->name = "softing";
287	dev_set_name(&pdev->dev, "softingcs.%i", pdev->id);
288	ret = platform_device_register(pdev);
289	if (ret < 0)
290		goto platform_failed;
291
292	dev_info(&pcmcia->dev, "created %s\n", dev_name(&pdev->dev));
293	return 0;
294
295platform_failed:
296	platform_device_put(pdev);
297mem_failed:
298pcmcia_bad:
299pcmcia_failed:
300	pcmcia_disable_device(pcmcia);
301	pcmcia->priv = NULL;
302	return ret;
303}
304
305static const struct pcmcia_device_id softingcs_ids[] = {
306	/* softing */
307	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0001),
308	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0002),
309	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0004),
310	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0005),
311	/* vector, manufacturer? */
312	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0081),
313	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0084),
314	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0085),
315	/* EDIC */
316	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0102),
317	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0105),
318	PCMCIA_DEVICE_NULL,
319};
320
321MODULE_DEVICE_TABLE(pcmcia, softingcs_ids);
322
323static struct pcmcia_driver softingcs_driver = {
324	.owner		= THIS_MODULE,
325	.name		= "softingcs",
326	.id_table	= softingcs_ids,
327	.probe		= softingcs_probe,
328	.remove		= softingcs_remove,
329};
330
331module_pcmcia_driver(softingcs_driver);
 
 
 
 
 
 
 
 
 
 
 
 
332
333MODULE_DESCRIPTION("softing CANcard driver"
334		", links PCMCIA card to softing driver");
335MODULE_LICENSE("GPL v2");
v3.1
 
  1/*
  2 * Copyright (C) 2008-2010
  3 *
  4 * - Kurt Van Dijck, EIA Electronics
  5 *
  6 * This program is free software; you can redistribute it and/or modify
  7 * it under the terms of the version 2 of the GNU General Public License
  8 * as published by the Free Software Foundation
  9 *
 10 * This program is distributed in the hope that it will be useful,
 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 13 * GNU General Public License for more details.
 14 *
 15 * You should have received a copy of the GNU General Public License
 16 * along with this program; if not, write to the Free Software
 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 18 */
 19
 20#include <linux/module.h>
 21#include <linux/kernel.h>
 22#include <linux/slab.h>
 23
 24#include <pcmcia/cistpl.h>
 25#include <pcmcia/ds.h>
 26
 27#include "softing_platform.h"
 28
 29static int softingcs_index;
 30static spinlock_t softingcs_index_lock;
 31
 32static int softingcs_reset(struct platform_device *pdev, int v);
 33static int softingcs_enable_irq(struct platform_device *pdev, int v);
 34
 35/*
 36 * platform_data descriptions
 37 */
 38#define MHZ (1000*1000)
 39static const struct softing_platform_data softingcs_platform_data[] = {
 40{
 41	.name = "CANcard",
 42	.manf = 0x0168, .prod = 0x001,
 43	.generation = 1,
 44	.nbus = 2,
 45	.freq = 16 * MHZ, .max_brp = 32, .max_sjw = 4,
 46	.dpram_size = 0x0800,
 47	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
 48	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
 49	.app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
 50	.reset = softingcs_reset,
 51	.enable_irq = softingcs_enable_irq,
 52}, {
 53	.name = "CANcard-NEC",
 54	.manf = 0x0168, .prod = 0x002,
 55	.generation = 1,
 56	.nbus = 2,
 57	.freq = 16 * MHZ, .max_brp = 32, .max_sjw = 4,
 58	.dpram_size = 0x0800,
 59	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
 60	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
 61	.app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
 62	.reset = softingcs_reset,
 63	.enable_irq = softingcs_enable_irq,
 64}, {
 65	.name = "CANcard-SJA",
 66	.manf = 0x0168, .prod = 0x004,
 67	.generation = 1,
 68	.nbus = 2,
 69	.freq = 20 * MHZ, .max_brp = 32, .max_sjw = 4,
 70	.dpram_size = 0x0800,
 71	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
 72	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
 73	.app = {0x0010, 0x0d0000, fw_dir "cansja.bin",},
 74	.reset = softingcs_reset,
 75	.enable_irq = softingcs_enable_irq,
 76}, {
 77	.name = "CANcard-2",
 78	.manf = 0x0168, .prod = 0x005,
 79	.generation = 2,
 80	.nbus = 2,
 81	.freq = 24 * MHZ, .max_brp = 64, .max_sjw = 4,
 82	.dpram_size = 0x1000,
 83	.boot = {0x0000, 0x000000, fw_dir "bcard2.bin",},
 84	.load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",},
 85	.app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",},
 86	.reset = softingcs_reset,
 87	.enable_irq = NULL,
 88}, {
 89	.name = "Vector-CANcard",
 90	.manf = 0x0168, .prod = 0x081,
 91	.generation = 1,
 92	.nbus = 2,
 93	.freq = 16 * MHZ, .max_brp = 64, .max_sjw = 4,
 94	.dpram_size = 0x0800,
 95	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
 96	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
 97	.app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
 98	.reset = softingcs_reset,
 99	.enable_irq = softingcs_enable_irq,
100}, {
101	.name = "Vector-CANcard-SJA",
102	.manf = 0x0168, .prod = 0x084,
103	.generation = 1,
104	.nbus = 2,
105	.freq = 20 * MHZ, .max_brp = 32, .max_sjw = 4,
106	.dpram_size = 0x0800,
107	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
108	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
109	.app = {0x0010, 0x0d0000, fw_dir "cansja.bin",},
110	.reset = softingcs_reset,
111	.enable_irq = softingcs_enable_irq,
112}, {
113	.name = "Vector-CANcard-2",
114	.manf = 0x0168, .prod = 0x085,
115	.generation = 2,
116	.nbus = 2,
117	.freq = 24 * MHZ, .max_brp = 64, .max_sjw = 4,
118	.dpram_size = 0x1000,
119	.boot = {0x0000, 0x000000, fw_dir "bcard2.bin",},
120	.load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",},
121	.app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",},
122	.reset = softingcs_reset,
123	.enable_irq = NULL,
124}, {
125	.name = "EDICcard-NEC",
126	.manf = 0x0168, .prod = 0x102,
127	.generation = 1,
128	.nbus = 2,
129	.freq = 16 * MHZ, .max_brp = 64, .max_sjw = 4,
130	.dpram_size = 0x0800,
131	.boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
132	.load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
133	.app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
134	.reset = softingcs_reset,
135	.enable_irq = softingcs_enable_irq,
136}, {
137	.name = "EDICcard-2",
138	.manf = 0x0168, .prod = 0x105,
139	.generation = 2,
140	.nbus = 2,
141	.freq = 24 * MHZ, .max_brp = 64, .max_sjw = 4,
142	.dpram_size = 0x1000,
143	.boot = {0x0000, 0x000000, fw_dir "bcard2.bin",},
144	.load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",},
145	.app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",},
146	.reset = softingcs_reset,
147	.enable_irq = NULL,
148}, {
149	0, 0,
150},
151};
152
153MODULE_FIRMWARE(fw_dir "bcard.bin");
154MODULE_FIRMWARE(fw_dir "ldcard.bin");
155MODULE_FIRMWARE(fw_dir "cancard.bin");
156MODULE_FIRMWARE(fw_dir "cansja.bin");
157
158MODULE_FIRMWARE(fw_dir "bcard2.bin");
159MODULE_FIRMWARE(fw_dir "ldcard2.bin");
160MODULE_FIRMWARE(fw_dir "cancrd2.bin");
161
162static __devinit const struct softing_platform_data
163*softingcs_find_platform_data(unsigned int manf, unsigned int prod)
164{
165	const struct softing_platform_data *lp;
166
167	for (lp = softingcs_platform_data; lp->manf; ++lp) {
168		if ((lp->manf == manf) && (lp->prod == prod))
169			return lp;
170	}
171	return NULL;
172}
173
174/*
175 * platformdata callbacks
176 */
177static int softingcs_reset(struct platform_device *pdev, int v)
178{
179	struct pcmcia_device *pcmcia = to_pcmcia_dev(pdev->dev.parent);
180
181	dev_dbg(&pdev->dev, "pcmcia config [2] %02x\n", v ? 0 : 0x20);
182	return pcmcia_write_config_byte(pcmcia, 2, v ? 0 : 0x20);
183}
184
185static int softingcs_enable_irq(struct platform_device *pdev, int v)
186{
187	struct pcmcia_device *pcmcia = to_pcmcia_dev(pdev->dev.parent);
188
189	dev_dbg(&pdev->dev, "pcmcia config [0] %02x\n", v ? 0x60 : 0);
190	return pcmcia_write_config_byte(pcmcia, 0, v ? 0x60 : 0);
191}
192
193/*
194 * pcmcia check
195 */
196static __devinit int softingcs_probe_config(struct pcmcia_device *pcmcia,
197		void *priv_data)
198{
199	struct softing_platform_data *pdat = priv_data;
200	struct resource *pres;
201	int memspeed = 0;
202
203	WARN_ON(!pdat);
204	pres = pcmcia->resource[PCMCIA_IOMEM_0];
205	if (resource_size(pres) < 0x1000)
206		return -ERANGE;
207
208	pres->flags |= WIN_MEMORY_TYPE_CM | WIN_ENABLE;
209	if (pdat->generation < 2) {
210		pres->flags |= WIN_USE_WAIT | WIN_DATA_WIDTH_8;
211		memspeed = 3;
212	} else {
213		pres->flags |= WIN_DATA_WIDTH_16;
214	}
215	return pcmcia_request_window(pcmcia, pres, memspeed);
216}
217
218static __devexit void softingcs_remove(struct pcmcia_device *pcmcia)
219{
220	struct platform_device *pdev = pcmcia->priv;
221
222	/* free bits */
223	platform_device_unregister(pdev);
224	/* release pcmcia stuff */
225	pcmcia_disable_device(pcmcia);
226}
227
228/*
229 * platform_device wrapper
230 * pdev->resource has 2 entries: io & irq
231 */
232static void softingcs_pdev_release(struct device *dev)
233{
234	struct platform_device *pdev = to_platform_device(dev);
235	kfree(pdev);
236}
237
238static __devinit int softingcs_probe(struct pcmcia_device *pcmcia)
239{
240	int ret;
241	struct platform_device *pdev;
242	const struct softing_platform_data *pdat;
243	struct resource *pres;
244	struct dev {
245		struct platform_device pdev;
246		struct resource res[2];
247	} *dev;
248
249	/* find matching platform_data */
250	pdat = softingcs_find_platform_data(pcmcia->manf_id, pcmcia->card_id);
251	if (!pdat)
252		return -ENOTTY;
253
254	/* setup pcmcia device */
255	pcmcia->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IOMEM |
256		CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC;
257	ret = pcmcia_loop_config(pcmcia, softingcs_probe_config, (void *)pdat);
258	if (ret)
259		goto pcmcia_failed;
260
261	ret = pcmcia_enable_device(pcmcia);
262	if (ret < 0)
263		goto pcmcia_failed;
264
265	pres = pcmcia->resource[PCMCIA_IOMEM_0];
266	if (!pres) {
267		ret = -EBADF;
268		goto pcmcia_bad;
269	}
270
271	/* create softing platform device */
272	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
273	if (!dev) {
274		ret = -ENOMEM;
275		goto mem_failed;
276	}
277	dev->pdev.resource = dev->res;
278	dev->pdev.num_resources = ARRAY_SIZE(dev->res);
279	dev->pdev.dev.release = softingcs_pdev_release;
280
281	pdev = &dev->pdev;
282	pdev->dev.platform_data = (void *)pdat;
283	pdev->dev.parent = &pcmcia->dev;
284	pcmcia->priv = pdev;
285
286	/* platform device resources */
287	pdev->resource[0].flags = IORESOURCE_MEM;
288	pdev->resource[0].start = pres->start;
289	pdev->resource[0].end = pres->end;
290
291	pdev->resource[1].flags = IORESOURCE_IRQ;
292	pdev->resource[1].start = pcmcia->irq;
293	pdev->resource[1].end = pdev->resource[1].start;
294
295	/* platform device setup */
296	spin_lock(&softingcs_index_lock);
297	pdev->id = softingcs_index++;
298	spin_unlock(&softingcs_index_lock);
299	pdev->name = "softing";
300	dev_set_name(&pdev->dev, "softingcs.%i", pdev->id);
301	ret = platform_device_register(pdev);
302	if (ret < 0)
303		goto platform_failed;
304
305	dev_info(&pcmcia->dev, "created %s\n", dev_name(&pdev->dev));
306	return 0;
307
308platform_failed:
309	kfree(dev);
310mem_failed:
311pcmcia_bad:
312pcmcia_failed:
313	pcmcia_disable_device(pcmcia);
314	pcmcia->priv = NULL;
315	return ret ?: -ENODEV;
316}
317
318static const struct pcmcia_device_id softingcs_ids[] = {
319	/* softing */
320	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0001),
321	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0002),
322	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0004),
323	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0005),
324	/* vector, manufacturer? */
325	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0081),
326	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0084),
327	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0085),
328	/* EDIC */
329	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0102),
330	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0105),
331	PCMCIA_DEVICE_NULL,
332};
333
334MODULE_DEVICE_TABLE(pcmcia, softingcs_ids);
335
336static struct pcmcia_driver softingcs_driver = {
337	.owner		= THIS_MODULE,
338	.name		= "softingcs",
339	.id_table	= softingcs_ids,
340	.probe		= softingcs_probe,
341	.remove		= __devexit_p(softingcs_remove),
342};
343
344static int __init softingcs_start(void)
345{
346	spin_lock_init(&softingcs_index_lock);
347	return pcmcia_register_driver(&softingcs_driver);
348}
349
350static void __exit softingcs_stop(void)
351{
352	pcmcia_unregister_driver(&softingcs_driver);
353}
354
355module_init(softingcs_start);
356module_exit(softingcs_stop);
357
358MODULE_DESCRIPTION("softing CANcard driver"
359		", links PCMCIA card to softing driver");
360MODULE_LICENSE("GPL v2");