blob: f4a32375c037410d78935033aa047f1ccdb8b2e9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * CTC / LCS ccw_device driver
3 *
4 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
5 * Author(s): Arnd Bergmann <arndb@de.ibm.com>
Cornelia Huck4ce3b302006-01-14 13:21:04 -08006 * Cornelia Huck <cornelia.huck@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
Jeff Garzike82b0f22006-05-26 21:58:38 -040023
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/init.h>
25#include <linux/module.h>
26#include <linux/err.h>
27
Carsten Ottecfb1b552006-01-06 00:19:14 -080028#include <asm/s390_rdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <asm/ccwdev.h>
30#include <asm/ccwgroup.h>
31
32#include "cu3088.h"
33
34const char *cu3088_type[] = {
35 "not a channel",
36 "CTC/A",
37 "ESCON channel",
38 "FICON channel",
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 "OSA LCS card",
Frank Pavlic321de3c2005-05-12 20:17:46 +020040 "CLAW channel device",
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 "unknown channel type",
42 "unsupported channel type",
43};
44
45/* static definitions */
46
47static struct ccw_device_id cu3088_ids[] = {
48 { CCW_DEVICE(0x3088, 0x08), .driver_info = channel_type_parallel },
49 { CCW_DEVICE(0x3088, 0x1f), .driver_info = channel_type_escon },
50 { CCW_DEVICE(0x3088, 0x1e), .driver_info = channel_type_ficon },
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 { CCW_DEVICE(0x3088, 0x60), .driver_info = channel_type_osa2 },
Frank Pavlic321de3c2005-05-12 20:17:46 +020052 { CCW_DEVICE(0x3088, 0x61), .driver_info = channel_type_claw },
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 { /* end of list */ }
54};
55
56static struct ccw_driver cu3088_driver;
57
Heiko Carstens2b67fc42007-02-05 21:16:47 +010058static struct device *cu3088_root_dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60static ssize_t
61group_write(struct device_driver *drv, const char *buf, size_t count)
62{
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 int ret;
64 struct ccwgroup_driver *cdrv;
65
66 cdrv = to_ccwgroupdrv(drv);
67 if (!cdrv)
68 return -EINVAL;
Ursula Braun022b6602008-04-24 10:15:20 +020069 ret = ccwgroup_create_from_string(cu3088_root_dev, cdrv->driver_id,
70 &cu3088_driver, 2, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72 return (ret == 0) ? count : ret;
73}
74
75static DRIVER_ATTR(group, 0200, NULL, group_write);
76
77/* Register-unregister for ctc&lcs */
78int
Jeff Garzike82b0f22006-05-26 21:58:38 -040079register_cu3088_discipline(struct ccwgroup_driver *dcp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080{
81 int rc;
82
83 if (!dcp)
84 return -EINVAL;
85
86 /* Register discipline.*/
87 rc = ccwgroup_driver_register(dcp);
88 if (rc)
89 return rc;
90
91 rc = driver_create_file(&dcp->driver, &driver_attr_group);
92 if (rc)
93 ccwgroup_driver_unregister(dcp);
Jeff Garzike82b0f22006-05-26 21:58:38 -040094
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 return rc;
96
97}
98
99void
100unregister_cu3088_discipline(struct ccwgroup_driver *dcp)
101{
102 if (!dcp)
103 return;
104
105 driver_remove_file(&dcp->driver, &driver_attr_group);
106 ccwgroup_driver_unregister(dcp);
107}
108
109static struct ccw_driver cu3088_driver = {
110 .owner = THIS_MODULE,
111 .ids = cu3088_ids,
112 .name = "cu3088",
113 .probe = ccwgroup_probe_ccwdev,
114 .remove = ccwgroup_remove_ccwdev,
115};
116
117/* module setup */
118static int __init
119cu3088_init (void)
120{
121 int rc;
Jeff Garzike82b0f22006-05-26 21:58:38 -0400122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 cu3088_root_dev = s390_root_dev_register("cu3088");
124 if (IS_ERR(cu3088_root_dev))
125 return PTR_ERR(cu3088_root_dev);
126 rc = ccw_driver_register(&cu3088_driver);
127 if (rc)
128 s390_root_dev_unregister(cu3088_root_dev);
129
130 return rc;
131}
132
133static void __exit
134cu3088_exit (void)
135{
136 ccw_driver_unregister(&cu3088_driver);
137 s390_root_dev_unregister(cu3088_root_dev);
138}
139
140MODULE_DEVICE_TABLE(ccw,cu3088_ids);
141MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
142MODULE_LICENSE("GPL");
143
144module_init(cu3088_init);
145module_exit(cu3088_exit);
146
147EXPORT_SYMBOL_GPL(cu3088_type);
148EXPORT_SYMBOL_GPL(register_cu3088_discipline);
149EXPORT_SYMBOL_GPL(unregister_cu3088_discipline);