27 #include <linux/module.h>
28 #include <linux/string.h>
29 #include <linux/types.h>
30 #include <linux/kernel.h>
33 #include <linux/slab.h>
34 #include <asm/uaccess.h>
40 { .name =
"DIO mem", .start = 0x00600000, .end = 0x007fffff },
42 { .name =
"DIO-II mem", .start = 0x01000000, .end = 0x1fffffff }
48 #define CONFIG_DIO_CONSTANTS
50 #ifdef CONFIG_DIO_CONSTANTS
66 #define DIONAME(x) { DIO_ID_##x, DIO_DESC_##x }
67 #define DIOFBNAME(x) { DIO_ENCODE_ID( DIO_ID_FBUFFER, DIO_ID2_##x), DIO_DESC2_##x }
91 static const char *unknowndioname
94 static const char *dio_getname(
int id)
99 if (names[i].
id ==
id)
100 return names[
i].
name;
102 return unknowndioname;
107 static char dio_no_name[] = { 0 };
108 #define dio_getname(_id) (dio_no_name)
121 for (scode = 0; scode < DIO_SCMAX; scode++) {
125 if (DIO_SCINHOLE(scode))
133 if (scode < DIOII_SCBASE)
134 va = (
void *)(pa + DIO_VIRADDRBASE);
141 if (
get_user(i, (
unsigned char *)va + DIO_IDOFF)) {
143 if (scode >= DIOII_SCBASE)
151 if (DIO_NEEDSSECID(prid)) {
152 secid = DIO_SECID(va);
153 id = DIO_ENCODE_ID(prid, secid);
157 if (
id == deviceid) {
158 if (scode >= DIOII_SCBASE)
170 static int __init dio_init(
void)
184 INIT_LIST_HEAD(&
dio_bus.devices);
188 pr_err(
"DIO: Error registering dio_bus\n");
194 for (i = 0; i <
dio_bus.num_resources; i++)
198 for (scode = 0; scode < DIO_SCMAX; ++scode)
204 if (DIO_SCINHOLE(scode))
212 if (scode < DIOII_SCBASE)
213 va = (
void *)(pa + DIO_VIRADDRBASE);
220 if (
get_user(i, (
unsigned char *)va + DIO_IDOFF)) {
222 if (scode >= DIOII_SCBASE)
230 dev = kzalloc(
sizeof(
struct dio_dev),
GFP_KERNEL);
235 dev->dev.parent = &
dio_bus.dev;
238 dev->resource.start = pa;
239 dev->resource.end = pa + DIO_SIZE(scode, va);
245 if (DIO_NEEDSSECID(prid)) {
246 secid = DIO_SECID(va);
247 dev->id = DIO_ENCODE_ID(prid, secid);
251 dev->ipl = DIO_IPL(va);
252 strcpy(dev->name,dio_getname(dev->id));
253 printk(
KERN_INFO "select code %3d: ipl %d: ID %02X", dev->scode, dev->ipl, prid);
254 if (DIO_NEEDSSECID(prid))
256 printk(
": %s\n", dev->name);
258 if (scode >= DIOII_SCBASE)
262 pr_err(
"DIO: Error registering device %s\n",
268 dev_err(&dev->dev,
"Error creating sysfs files\n");
280 if (scode >= DIOII_SCBASE) {
281 return (DIOII_BASE + (scode - 132) * DIOII_DEVSIZE);
282 }
else if (scode > DIO_SCMAX || scode < 0)
284 else if (DIO_SCINHOLE(scode))
287 return (DIO_BASE + scode * DIO_DEVSIZE);