blob: 2f406f509d44d9ec4fd1b7deee382a5338dcda5a [file] [log] [blame]
Bruce Losureff3eb552005-04-25 13:12:02 -07001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#include <linux/module.h>
10#include <linux/kernel.h>
Bruce Losureff3eb552005-04-25 13:12:02 -070011#include <linux/slab.h>
12#include <linux/spinlock.h>
13#include <linux/proc_fs.h>
Randy Dunlapa9415642006-01-11 12:17:48 -080014#include <linux/capability.h>
Bruce Losureff3eb552005-04-25 13:12:02 -070015#include <linux/device.h>
16#include <linux/delay.h>
Jack Steiner21517a52005-07-07 09:14:00 -070017#include <asm/system.h>
Bruce Losureff3eb552005-04-25 13:12:02 -070018#include <asm/uaccess.h>
19#include <asm/sn/sn_sal.h>
20#include <asm/sn/addrs.h>
21#include <asm/sn/io.h>
22#include <asm/sn/types.h>
23#include <asm/sn/shubio.h>
24#include <asm/sn/tiocx.h>
Bruce Losurece0a3952005-04-25 19:41:00 -070025#include <asm/sn/l1.h>
26#include <asm/sn/module.h>
Bruce Losureff3eb552005-04-25 13:12:02 -070027#include "tio.h"
28#include "xtalk/xwidgetdev.h"
29#include "xtalk/hubdev.h"
30
31#define CX_DEV_NONE 0
32#define DEVICE_NAME "tiocx"
33#define WIDGET_ID 0
34#define TIOCX_DEBUG 0
35
36#if TIOCX_DEBUG
37#define DBG(fmt...) printk(KERN_ALERT fmt)
38#else
39#define DBG(fmt...)
40#endif
41
42struct device_attribute dev_attr_cxdev_control;
43
44/**
45 * tiocx_match - Try to match driver id list with device.
46 * @dev: device pointer
47 * @drv: driver pointer
48 *
49 * Returns 1 if match, 0 otherwise.
50 */
51static int tiocx_match(struct device *dev, struct device_driver *drv)
52{
53 struct cx_dev *cx_dev = to_cx_dev(dev);
54 struct cx_drv *cx_drv = to_cx_driver(drv);
55 const struct cx_device_id *ids = cx_drv->id_table;
56
57 if (!ids)
58 return 0;
59
60 while (ids->part_num) {
61 if (ids->part_num == cx_dev->cx_id.part_num)
62 return 1;
63 ids++;
64 }
65 return 0;
66
67}
68
Kay Sievers7eff2e72007-08-14 15:15:12 +020069static int tiocx_uevent(struct device *dev, struct kobj_uevent_env *env)
Bruce Losureff3eb552005-04-25 13:12:02 -070070{
71 return -ENODEV;
72}
73
74static void tiocx_bus_release(struct device *dev)
75{
76 kfree(to_cx_dev(dev));
77}
78
Bruce Losureff3eb552005-04-25 13:12:02 -070079/**
80 * cx_device_match - Find cx_device in the id table.
81 * @ids: id table from driver
82 * @cx_device: part/mfg id for the device
83 *
84 */
85static const struct cx_device_id *cx_device_match(const struct cx_device_id
86 *ids,
87 struct cx_dev *cx_device)
88{
89 /*
90 * NOTES: We may want to check for CX_ANY_ID too.
91 * Do we want to match against nasid too?
92 * CX_DEV_NONE == 0, if the driver tries to register for
93 * part/mfg == 0 we should return no-match (NULL) here.
94 */
95 while (ids->part_num && ids->mfg_num) {
96 if (ids->part_num == cx_device->cx_id.part_num &&
97 ids->mfg_num == cx_device->cx_id.mfg_num)
98 return ids;
99 ids++;
100 }
101
102 return NULL;
103}
104
105/**
106 * cx_device_probe - Look for matching device.
107 * Call driver probe routine if found.
108 * @cx_driver: driver table (cx_drv struct) from driver
109 * @cx_device: part/mfg id for the device
110 */
111static int cx_device_probe(struct device *dev)
112{
113 const struct cx_device_id *id;
114 struct cx_drv *cx_drv = to_cx_driver(dev->driver);
115 struct cx_dev *cx_dev = to_cx_dev(dev);
116 int error = 0;
117
118 if (!cx_dev->driver && cx_drv->probe) {
119 id = cx_device_match(cx_drv->id_table, cx_dev);
120 if (id) {
121 if ((error = cx_drv->probe(cx_dev, id)) < 0)
122 return error;
123 else
124 cx_dev->driver = cx_drv;
125 }
126 }
127
128 return error;
129}
130
131/**
132 * cx_driver_remove - Remove driver from device struct.
133 * @dev: device
134 */
135static int cx_driver_remove(struct device *dev)
136{
137 struct cx_dev *cx_dev = to_cx_dev(dev);
138 struct cx_drv *cx_drv = cx_dev->driver;
139 if (cx_drv->remove)
140 cx_drv->remove(cx_dev);
141 cx_dev->driver = NULL;
142 return 0;
143}
144
Russell King83dfb8b2006-01-05 14:34:06 +0000145struct bus_type tiocx_bus_type = {
146 .name = "tiocx",
147 .match = tiocx_match,
148 .uevent = tiocx_uevent,
149 .probe = cx_device_probe,
150 .remove = cx_driver_remove,
151};
152
Bruce Losureff3eb552005-04-25 13:12:02 -0700153/**
154 * cx_driver_register - Register the driver.
155 * @cx_driver: driver table (cx_drv struct) from driver
156 *
157 * Called from the driver init routine to register a driver.
158 * The cx_drv struct contains the driver name, a pointer to
159 * a table of part/mfg numbers and a pointer to the driver's
160 * probe/attach routine.
161 */
162int cx_driver_register(struct cx_drv *cx_driver)
163{
164 cx_driver->driver.name = cx_driver->name;
165 cx_driver->driver.bus = &tiocx_bus_type;
Bruce Losureff3eb552005-04-25 13:12:02 -0700166
167 return driver_register(&cx_driver->driver);
168}
169
170/**
171 * cx_driver_unregister - Unregister the driver.
172 * @cx_driver: driver table (cx_drv struct) from driver
173 */
174int cx_driver_unregister(struct cx_drv *cx_driver)
175{
176 driver_unregister(&cx_driver->driver);
177 return 0;
178}
179
180/**
181 * cx_device_register - Register a device.
182 * @nasid: device's nasid
183 * @part_num: device's part number
184 * @mfg_num: device's manufacturer number
185 * @hubdev: hub info associated with this device
Bruce Losure25732ad2005-09-02 15:16:35 -0500186 * @bt: board type of the device
Bruce Losureff3eb552005-04-25 13:12:02 -0700187 *
188 */
189int
190cx_device_register(nasid_t nasid, int part_num, int mfg_num,
Bruce Losure25732ad2005-09-02 15:16:35 -0500191 struct hubdev_info *hubdev, int bt)
Bruce Losureff3eb552005-04-25 13:12:02 -0700192{
193 struct cx_dev *cx_dev;
Paul Gortmaker454ca602012-02-26 13:46:07 -0500194 int r;
Bruce Losureff3eb552005-04-25 13:12:02 -0700195
Pekka Enbergf96cb1f2005-09-06 15:18:31 -0700196 cx_dev = kzalloc(sizeof(struct cx_dev), GFP_KERNEL);
Bruce Losureff3eb552005-04-25 13:12:02 -0700197 DBG("cx_dev= 0x%p\n", cx_dev);
198 if (cx_dev == NULL)
199 return -ENOMEM;
200
201 cx_dev->cx_id.part_num = part_num;
202 cx_dev->cx_id.mfg_num = mfg_num;
203 cx_dev->cx_id.nasid = nasid;
204 cx_dev->hubdev = hubdev;
Bruce Losure25732ad2005-09-02 15:16:35 -0500205 cx_dev->bt = bt;
Bruce Losureff3eb552005-04-25 13:12:02 -0700206
207 cx_dev->dev.parent = NULL;
208 cx_dev->dev.bus = &tiocx_bus_type;
209 cx_dev->dev.release = tiocx_bus_release;
Kay Sievers48ef2bb2009-01-06 10:44:40 -0800210 dev_set_name(&cx_dev->dev, "%d", cx_dev->cx_id.nasid);
Paul Gortmaker454ca602012-02-26 13:46:07 -0500211 r = device_register(&cx_dev->dev);
212 if (r) {
213 kfree(cx_dev);
214 return r;
215 }
Bruce Losureff3eb552005-04-25 13:12:02 -0700216 get_device(&cx_dev->dev);
217
218 device_create_file(&cx_dev->dev, &dev_attr_cxdev_control);
219
220 return 0;
221}
222
223/**
224 * cx_device_unregister - Unregister a device.
225 * @cx_dev: part/mfg id for the device
226 */
227int cx_device_unregister(struct cx_dev *cx_dev)
228{
229 put_device(&cx_dev->dev);
230 device_unregister(&cx_dev->dev);
231 return 0;
232}
233
234/**
235 * cx_device_reload - Reload the device.
236 * @nasid: device's nasid
237 * @part_num: device's part number
238 * @mfg_num: device's manufacturer number
239 *
240 * Remove the device associated with 'nasid' from device list and then
241 * call device-register with the given part/mfg numbers.
242 */
243static int cx_device_reload(struct cx_dev *cx_dev)
244{
Bruce Losureff3eb552005-04-25 13:12:02 -0700245 cx_device_unregister(cx_dev);
246 return cx_device_register(cx_dev->cx_id.nasid, cx_dev->cx_id.part_num,
Bruce Losure25732ad2005-09-02 15:16:35 -0500247 cx_dev->cx_id.mfg_num, cx_dev->hubdev,
248 cx_dev->bt);
Bruce Losureff3eb552005-04-25 13:12:02 -0700249}
250
Prarit Bhargava53493dc2006-01-16 19:54:40 -0800251static inline u64 tiocx_intr_alloc(nasid_t nasid, int widget,
Bruce Losureff3eb552005-04-25 13:12:02 -0700252 u64 sn_irq_info,
253 int req_irq, nasid_t req_nasid,
254 int req_slice)
255{
256 struct ia64_sal_retval rv;
257 rv.status = 0;
258 rv.v0 = 0;
259
260 ia64_sal_oemcall_nolock(&rv, SN_SAL_IOIF_INTERRUPT,
261 SAL_INTR_ALLOC, nasid,
262 widget, sn_irq_info, req_irq,
263 req_nasid, req_slice);
264 return rv.status;
265}
266
267static inline void tiocx_intr_free(nasid_t nasid, int widget,
268 struct sn_irq_info *sn_irq_info)
269{
270 struct ia64_sal_retval rv;
271 rv.status = 0;
272 rv.v0 = 0;
273
274 ia64_sal_oemcall_nolock(&rv, SN_SAL_IOIF_INTERRUPT,
275 SAL_INTR_FREE, nasid,
276 widget, sn_irq_info->irq_irq,
277 sn_irq_info->irq_cookie, 0, 0);
278}
279
280struct sn_irq_info *tiocx_irq_alloc(nasid_t nasid, int widget, int irq,
281 nasid_t req_nasid, int slice)
282{
283 struct sn_irq_info *sn_irq_info;
284 int status;
285 int sn_irq_size = sizeof(struct sn_irq_info);
286
287 if ((nasid & 1) == 0)
288 return NULL;
289
Jes Sorensen8ed9b2c2006-02-13 05:29:57 -0500290 sn_irq_info = kzalloc(sn_irq_size, GFP_KERNEL);
Bruce Losureff3eb552005-04-25 13:12:02 -0700291 if (sn_irq_info == NULL)
292 return NULL;
293
Bruce Losureff3eb552005-04-25 13:12:02 -0700294 status = tiocx_intr_alloc(nasid, widget, __pa(sn_irq_info), irq,
295 req_nasid, slice);
296 if (status) {
297 kfree(sn_irq_info);
298 return NULL;
299 } else {
300 return sn_irq_info;
301 }
302}
303
304void tiocx_irq_free(struct sn_irq_info *sn_irq_info)
305{
Prarit Bhargava53493dc2006-01-16 19:54:40 -0800306 u64 bridge = (u64) sn_irq_info->irq_bridge;
Bruce Losureff3eb552005-04-25 13:12:02 -0700307 nasid_t nasid = NASID_GET(bridge);
308 int widget;
309
310 if (nasid & 1) {
311 widget = TIO_SWIN_WIDGETNUM(bridge);
312 tiocx_intr_free(nasid, widget, sn_irq_info);
313 kfree(sn_irq_info);
314 }
315}
316
Prarit Bhargava53493dc2006-01-16 19:54:40 -0800317u64 tiocx_dma_addr(u64 addr)
Bruce Losureff3eb552005-04-25 13:12:02 -0700318{
319 return PHYS_TO_TIODMA(addr);
320}
321
Prarit Bhargava53493dc2006-01-16 19:54:40 -0800322u64 tiocx_swin_base(int nasid)
Bruce Losureff3eb552005-04-25 13:12:02 -0700323{
324 return TIO_SWIN_BASE(nasid, TIOCX_CORELET);
325}
326
327EXPORT_SYMBOL(cx_driver_register);
328EXPORT_SYMBOL(cx_driver_unregister);
329EXPORT_SYMBOL(cx_device_register);
330EXPORT_SYMBOL(cx_device_unregister);
331EXPORT_SYMBOL(tiocx_irq_alloc);
332EXPORT_SYMBOL(tiocx_irq_free);
333EXPORT_SYMBOL(tiocx_bus_type);
334EXPORT_SYMBOL(tiocx_dma_addr);
335EXPORT_SYMBOL(tiocx_swin_base);
336
Bruce Losureff3eb552005-04-25 13:12:02 -0700337static void tio_conveyor_set(nasid_t nasid, int enable_flag)
338{
Prarit Bhargava53493dc2006-01-16 19:54:40 -0800339 u64 ice_frz;
340 u64 disable_cb = (1ull << 61);
Bruce Losureff3eb552005-04-25 13:12:02 -0700341
342 if (!(nasid & 1))
343 return;
344
345 ice_frz = REMOTE_HUB_L(nasid, TIO_ICE_FRZ_CFG);
346 if (enable_flag) {
347 if (!(ice_frz & disable_cb)) /* already enabled */
348 return;
349 ice_frz &= ~disable_cb;
350 } else {
351 if (ice_frz & disable_cb) /* already disabled */
352 return;
353 ice_frz |= disable_cb;
354 }
355 DBG(KERN_ALERT "TIO_ICE_FRZ_CFG= 0x%lx\n", ice_frz);
356 REMOTE_HUB_S(nasid, TIO_ICE_FRZ_CFG, ice_frz);
357}
358
359#define tio_conveyor_enable(nasid) tio_conveyor_set(nasid, 1)
360#define tio_conveyor_disable(nasid) tio_conveyor_set(nasid, 0)
361
362static void tio_corelet_reset(nasid_t nasid, int corelet)
363{
364 if (!(nasid & 1))
365 return;
366
367 REMOTE_HUB_S(nasid, TIO_ICE_PMI_TX_CFG, 1 << corelet);
368 udelay(2000);
369 REMOTE_HUB_S(nasid, TIO_ICE_PMI_TX_CFG, 0);
370 udelay(2000);
371}
372
Bruce Losure25732ad2005-09-02 15:16:35 -0500373static int is_fpga_tio(int nasid, int *bt)
Bruce Losurece0a3952005-04-25 19:41:00 -0700374{
Jes Sorensen256a7e02007-07-11 17:26:30 +0200375 u16 uninitialized_var(ioboard_type); /* GCC be quiet */
Matthew Wilcoxe088a4a2009-05-22 13:49:49 -0700376 long rc;
Bruce Losurece0a3952005-04-25 19:41:00 -0700377
Prarit Bhargavaf90aa8c2006-03-08 13:30:18 -0500378 rc = ia64_sn_sysctl_ioboard_get(nasid, &ioboard_type);
379 if (rc) {
380 printk(KERN_WARNING "ia64_sn_sysctl_ioboard_get failed: %ld\n",
381 rc);
382 return 0;
383 }
Bruce Losurece0a3952005-04-25 19:41:00 -0700384
Bruce Losure25732ad2005-09-02 15:16:35 -0500385 switch (ioboard_type) {
Bruce Losurece0a3952005-04-25 19:41:00 -0700386 case L1_BRICKTYPE_SA:
387 case L1_BRICKTYPE_ATHENA:
Bruce Losure25732ad2005-09-02 15:16:35 -0500388 case L1_BOARDTYPE_DAYTONA:
389 *bt = ioboard_type;
Bruce Losurece0a3952005-04-25 19:41:00 -0700390 return 1;
391 }
Bruce Losure25732ad2005-09-02 15:16:35 -0500392
Bruce Losurece0a3952005-04-25 19:41:00 -0700393 return 0;
394}
395
396static int bitstream_loaded(nasid_t nasid)
Bruce Losureff3eb552005-04-25 13:12:02 -0700397{
Prarit Bhargava53493dc2006-01-16 19:54:40 -0800398 u64 cx_credits;
Bruce Losureff3eb552005-04-25 13:12:02 -0700399
400 cx_credits = REMOTE_HUB_L(nasid, TIO_ICE_PMI_TX_DYN_CREDIT_STAT_CB3);
401 cx_credits &= TIO_ICE_PMI_TX_DYN_CREDIT_STAT_CB3_CREDIT_CNT_MASK;
402 DBG("cx_credits= 0x%lx\n", cx_credits);
403
404 return (cx_credits == 0xf) ? 1 : 0;
405}
406
407static int tiocx_reload(struct cx_dev *cx_dev)
408{
409 int part_num = CX_DEV_NONE;
410 int mfg_num = CX_DEV_NONE;
411 nasid_t nasid = cx_dev->cx_id.nasid;
412
Bruce Losurece0a3952005-04-25 19:41:00 -0700413 if (bitstream_loaded(nasid)) {
Prarit Bhargava53493dc2006-01-16 19:54:40 -0800414 u64 cx_id;
Bruce Losure25732ad2005-09-02 15:16:35 -0500415 int rv;
Bruce Losureff3eb552005-04-25 13:12:02 -0700416
Bruce Losure25732ad2005-09-02 15:16:35 -0500417 rv = ia64_sn_sysctl_tio_clock_reset(nasid);
418 if (rv) {
419 printk(KERN_ALERT "CX port JTAG reset failed.\n");
420 } else {
Prarit Bhargava53493dc2006-01-16 19:54:40 -0800421 cx_id = *(volatile u64 *)
Bruce Losure25732ad2005-09-02 15:16:35 -0500422 (TIO_SWIN_BASE(nasid, TIOCX_CORELET) +
Bruce Losureff3eb552005-04-25 13:12:02 -0700423 WIDGET_ID);
Bruce Losure25732ad2005-09-02 15:16:35 -0500424 part_num = XWIDGET_PART_NUM(cx_id);
425 mfg_num = XWIDGET_MFG_NUM(cx_id);
426 DBG("part= 0x%x, mfg= 0x%x\n", part_num, mfg_num);
427 /* just ignore it if it's a CE */
428 if (part_num == TIO_CE_ASIC_PARTNUM)
429 return 0;
430 }
Bruce Losureff3eb552005-04-25 13:12:02 -0700431 }
432
433 cx_dev->cx_id.part_num = part_num;
434 cx_dev->cx_id.mfg_num = mfg_num;
435
436 /*
437 * Delete old device and register the new one. It's ok if
438 * part_num/mfg_num == CX_DEV_NONE. We want to register
439 * devices in the table even if a bitstream isn't loaded.
440 * That allows use to see that a bitstream isn't loaded via
441 * TIOCX_IOCTL_DEV_LIST.
442 */
443 return cx_device_reload(cx_dev);
444}
445
Yani Ioannouff381d22005-05-17 06:40:51 -0400446static ssize_t show_cxdev_control(struct device *dev, struct device_attribute *attr, char *buf)
Bruce Losureff3eb552005-04-25 13:12:02 -0700447{
448 struct cx_dev *cx_dev = to_cx_dev(dev);
449
Bruce Losure25732ad2005-09-02 15:16:35 -0500450 return sprintf(buf, "0x%x 0x%x 0x%x 0x%x\n",
Bruce Losureff3eb552005-04-25 13:12:02 -0700451 cx_dev->cx_id.nasid,
Bruce Losurece0a3952005-04-25 19:41:00 -0700452 cx_dev->cx_id.part_num, cx_dev->cx_id.mfg_num,
Bruce Losure25732ad2005-09-02 15:16:35 -0500453 cx_dev->bt);
Bruce Losureff3eb552005-04-25 13:12:02 -0700454}
455
Yani Ioannouff381d22005-05-17 06:40:51 -0400456static ssize_t store_cxdev_control(struct device *dev, struct device_attribute *attr, const char *buf,
Bruce Losureff3eb552005-04-25 13:12:02 -0700457 size_t count)
458{
459 int n;
460 struct cx_dev *cx_dev = to_cx_dev(dev);
461
462 if (!capable(CAP_SYS_ADMIN))
463 return -EPERM;
464
465 if (count <= 0)
466 return 0;
467
468 n = simple_strtoul(buf, NULL, 0);
469
470 switch (n) {
471 case 1:
Bruce Losurec1ffb6a2005-05-24 08:30:00 -0700472 tio_corelet_reset(cx_dev->cx_id.nasid, TIOCX_CORELET);
473 tiocx_reload(cx_dev);
474 break;
475 case 2:
Bruce Losureff3eb552005-04-25 13:12:02 -0700476 tiocx_reload(cx_dev);
477 break;
478 case 3:
479 tio_corelet_reset(cx_dev->cx_id.nasid, TIOCX_CORELET);
480 break;
481 default:
482 break;
483 }
484
485 return count;
486}
487
488DEVICE_ATTR(cxdev_control, 0644, show_cxdev_control, store_cxdev_control);
489
490static int __init tiocx_init(void)
491{
492 cnodeid_t cnodeid;
493 int found_tiocx_device = 0;
494
Jack Steiner21517a52005-07-07 09:14:00 -0700495 if (!ia64_platform_is("sn2"))
Bjorn Helgaas6c5e6212006-03-03 15:33:47 -0700496 return 0;
Jack Steiner21517a52005-07-07 09:14:00 -0700497
Bruce Losureff3eb552005-04-25 13:12:02 -0700498 bus_register(&tiocx_bus_type);
499
Jack Steiner24ee0a62005-09-12 12:15:43 -0500500 for (cnodeid = 0; cnodeid < num_cnodes; cnodeid++) {
Bruce Losureff3eb552005-04-25 13:12:02 -0700501 nasid_t nasid;
Bruce Losure25732ad2005-09-02 15:16:35 -0500502 int bt;
Bruce Losureff3eb552005-04-25 13:12:02 -0700503
Jack Steiner24ee0a62005-09-12 12:15:43 -0500504 nasid = cnodeid_to_nasid(cnodeid);
Bruce Losureff3eb552005-04-25 13:12:02 -0700505
Bruce Losure25732ad2005-09-02 15:16:35 -0500506 if ((nasid & 0x1) && is_fpga_tio(nasid, &bt)) {
Bruce Losureff3eb552005-04-25 13:12:02 -0700507 struct hubdev_info *hubdev;
Bruce Losureff3eb552005-04-25 13:12:02 -0700508 struct xwidget_info *widgetp;
509
510 DBG("Found TIO at nasid 0x%x\n", nasid);
511
512 hubdev =
513 (struct hubdev_info *)(NODEPDA(cnodeid)->pdinfo);
Bruce Losureff3eb552005-04-25 13:12:02 -0700514
515 widgetp = &hubdev->hdi_xwidget_info[TIOCX_CORELET];
516
517 /* The CE hangs off of the CX port but is not an FPGA */
518 if (widgetp->xwi_hwid.part_num == TIO_CE_ASIC_PARTNUM)
519 continue;
520
521 tio_corelet_reset(nasid, TIOCX_CORELET);
522 tio_conveyor_enable(nasid);
523
524 if (cx_device_register
525 (nasid, widgetp->xwi_hwid.part_num,
Bruce Losure25732ad2005-09-02 15:16:35 -0500526 widgetp->xwi_hwid.mfg_num, hubdev, bt) < 0)
Bruce Losureff3eb552005-04-25 13:12:02 -0700527 return -ENXIO;
528 else
529 found_tiocx_device++;
530 }
531 }
532
533 /* It's ok if we find zero devices. */
534 DBG("found_tiocx_device= %d\n", found_tiocx_device);
535
536 return 0;
537}
538
Patrick Mochel66234152005-04-28 17:11:52 -0700539static int cx_remove_device(struct device * dev, void * data)
540{
541 struct cx_dev *cx_dev = to_cx_dev(dev);
542 device_remove_file(dev, &dev_attr_cxdev_control);
543 cx_device_unregister(cx_dev);
544 return 0;
545}
546
Bruce Losureff3eb552005-04-25 13:12:02 -0700547static void __exit tiocx_exit(void)
548{
Bruce Losureff3eb552005-04-25 13:12:02 -0700549 DBG("tiocx_exit\n");
550
551 /*
552 * Unregister devices.
553 */
Patrick Mochel66234152005-04-28 17:11:52 -0700554 bus_for_each_dev(&tiocx_bus_type, NULL, NULL, cx_remove_device);
Bruce Losureff3eb552005-04-25 13:12:02 -0700555 bus_unregister(&tiocx_bus_type);
556}
557
John Keller8ea60912006-10-04 16:49:25 -0500558fs_initcall(tiocx_init);
Bruce Losureff3eb552005-04-25 13:12:02 -0700559module_exit(tiocx_exit);
560
561/************************************************************************
562 * Module licensing and description
563 ************************************************************************/
564MODULE_LICENSE("GPL");
565MODULE_AUTHOR("Bruce Losure <blosure@sgi.com>");
566MODULE_DESCRIPTION("TIOCX module");
567MODULE_SUPPORTED_DEVICE(DEVICE_NAME);