diff options
Diffstat (limited to 'include/linux/pnp.h')
-rw-r--r-- | include/linux/pnp.h | 212 |
1 files changed, 110 insertions, 102 deletions
diff --git a/include/linux/pnp.h b/include/linux/pnp.h index b2f05c230f4b..63b128d512fb 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h | |||
@@ -6,66 +6,127 @@ | |||
6 | #ifndef _LINUX_PNP_H | 6 | #ifndef _LINUX_PNP_H |
7 | #define _LINUX_PNP_H | 7 | #define _LINUX_PNP_H |
8 | 8 | ||
9 | #ifdef __KERNEL__ | ||
10 | |||
11 | #include <linux/device.h> | 9 | #include <linux/device.h> |
12 | #include <linux/list.h> | 10 | #include <linux/list.h> |
13 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
14 | #include <linux/mod_devicetable.h> | 12 | #include <linux/mod_devicetable.h> |
15 | 13 | ||
16 | #define PNP_MAX_PORT 40 | ||
17 | #define PNP_MAX_MEM 24 | ||
18 | #define PNP_MAX_IRQ 2 | ||
19 | #define PNP_MAX_DMA 2 | ||
20 | #define PNP_NAME_LEN 50 | 14 | #define PNP_NAME_LEN 50 |
21 | 15 | ||
22 | struct pnp_protocol; | 16 | struct pnp_protocol; |
23 | struct pnp_dev; | 17 | struct pnp_dev; |
18 | struct pnp_resource_table; | ||
24 | 19 | ||
25 | /* | 20 | /* |
26 | * Resource Management | 21 | * Resource Management |
27 | */ | 22 | */ |
23 | struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int); | ||
24 | |||
25 | static inline int pnp_resource_valid(struct resource *res) | ||
26 | { | ||
27 | if (res && !(res->flags & IORESOURCE_UNSET)) | ||
28 | return 1; | ||
29 | return 0; | ||
30 | } | ||
31 | |||
32 | static inline resource_size_t pnp_resource_len(struct resource *res) | ||
33 | { | ||
34 | if (res->start == 0 && res->end == 0) | ||
35 | return 0; | ||
36 | return res->end - res->start + 1; | ||
37 | } | ||
38 | |||
39 | |||
40 | static inline resource_size_t pnp_port_start(struct pnp_dev *dev, | ||
41 | unsigned int bar) | ||
42 | { | ||
43 | return pnp_get_resource(dev, IORESOURCE_IO, bar)->start; | ||
44 | } | ||
45 | |||
46 | static inline resource_size_t pnp_port_end(struct pnp_dev *dev, | ||
47 | unsigned int bar) | ||
48 | { | ||
49 | return pnp_get_resource(dev, IORESOURCE_IO, bar)->end; | ||
50 | } | ||
51 | |||
52 | static inline unsigned long pnp_port_flags(struct pnp_dev *dev, | ||
53 | unsigned int bar) | ||
54 | { | ||
55 | return pnp_get_resource(dev, IORESOURCE_IO, bar)->flags; | ||
56 | } | ||
57 | |||
58 | static inline int pnp_port_valid(struct pnp_dev *dev, unsigned int bar) | ||
59 | { | ||
60 | return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IO, bar)); | ||
61 | } | ||
62 | |||
63 | static inline resource_size_t pnp_port_len(struct pnp_dev *dev, | ||
64 | unsigned int bar) | ||
65 | { | ||
66 | return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_IO, bar)); | ||
67 | } | ||
68 | |||
69 | |||
70 | static inline resource_size_t pnp_mem_start(struct pnp_dev *dev, | ||
71 | unsigned int bar) | ||
72 | { | ||
73 | return pnp_get_resource(dev, IORESOURCE_MEM, bar)->start; | ||
74 | } | ||
75 | |||
76 | static inline resource_size_t pnp_mem_end(struct pnp_dev *dev, | ||
77 | unsigned int bar) | ||
78 | { | ||
79 | return pnp_get_resource(dev, IORESOURCE_MEM, bar)->end; | ||
80 | } | ||
81 | |||
82 | static inline unsigned long pnp_mem_flags(struct pnp_dev *dev, unsigned int bar) | ||
83 | { | ||
84 | return pnp_get_resource(dev, IORESOURCE_MEM, bar)->flags; | ||
85 | } | ||
86 | |||
87 | static inline int pnp_mem_valid(struct pnp_dev *dev, unsigned int bar) | ||
88 | { | ||
89 | return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_MEM, bar)); | ||
90 | } | ||
91 | |||
92 | static inline resource_size_t pnp_mem_len(struct pnp_dev *dev, | ||
93 | unsigned int bar) | ||
94 | { | ||
95 | return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_MEM, bar)); | ||
96 | } | ||
97 | |||
98 | |||
99 | static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar) | ||
100 | { | ||
101 | return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->start; | ||
102 | } | ||
103 | |||
104 | static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar) | ||
105 | { | ||
106 | return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->flags; | ||
107 | } | ||
108 | |||
109 | static inline int pnp_irq_valid(struct pnp_dev *dev, unsigned int bar) | ||
110 | { | ||
111 | return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IRQ, bar)); | ||
112 | } | ||
113 | |||
114 | |||
115 | static inline resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar) | ||
116 | { | ||
117 | return pnp_get_resource(dev, IORESOURCE_DMA, bar)->start; | ||
118 | } | ||
119 | |||
120 | static inline unsigned long pnp_dma_flags(struct pnp_dev *dev, unsigned int bar) | ||
121 | { | ||
122 | return pnp_get_resource(dev, IORESOURCE_DMA, bar)->flags; | ||
123 | } | ||
124 | |||
125 | static inline int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar) | ||
126 | { | ||
127 | return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_DMA, bar)); | ||
128 | } | ||
28 | 129 | ||
29 | /* Use these instead of directly reading pnp_dev to get resource information */ | ||
30 | #define pnp_port_start(dev,bar) ((dev)->res.port_resource[(bar)].start) | ||
31 | #define pnp_port_end(dev,bar) ((dev)->res.port_resource[(bar)].end) | ||
32 | #define pnp_port_flags(dev,bar) ((dev)->res.port_resource[(bar)].flags) | ||
33 | #define pnp_port_valid(dev,bar) \ | ||
34 | ((pnp_port_flags((dev),(bar)) & (IORESOURCE_IO | IORESOURCE_UNSET)) \ | ||
35 | == IORESOURCE_IO) | ||
36 | #define pnp_port_len(dev,bar) \ | ||
37 | ((pnp_port_start((dev),(bar)) == 0 && \ | ||
38 | pnp_port_end((dev),(bar)) == \ | ||
39 | pnp_port_start((dev),(bar))) ? 0 : \ | ||
40 | \ | ||
41 | (pnp_port_end((dev),(bar)) - \ | ||
42 | pnp_port_start((dev),(bar)) + 1)) | ||
43 | |||
44 | #define pnp_mem_start(dev,bar) ((dev)->res.mem_resource[(bar)].start) | ||
45 | #define pnp_mem_end(dev,bar) ((dev)->res.mem_resource[(bar)].end) | ||
46 | #define pnp_mem_flags(dev,bar) ((dev)->res.mem_resource[(bar)].flags) | ||
47 | #define pnp_mem_valid(dev,bar) \ | ||
48 | ((pnp_mem_flags((dev),(bar)) & (IORESOURCE_MEM | IORESOURCE_UNSET)) \ | ||
49 | == IORESOURCE_MEM) | ||
50 | #define pnp_mem_len(dev,bar) \ | ||
51 | ((pnp_mem_start((dev),(bar)) == 0 && \ | ||
52 | pnp_mem_end((dev),(bar)) == \ | ||
53 | pnp_mem_start((dev),(bar))) ? 0 : \ | ||
54 | \ | ||
55 | (pnp_mem_end((dev),(bar)) - \ | ||
56 | pnp_mem_start((dev),(bar)) + 1)) | ||
57 | |||
58 | #define pnp_irq(dev,bar) ((dev)->res.irq_resource[(bar)].start) | ||
59 | #define pnp_irq_flags(dev,bar) ((dev)->res.irq_resource[(bar)].flags) | ||
60 | #define pnp_irq_valid(dev,bar) \ | ||
61 | ((pnp_irq_flags((dev),(bar)) & (IORESOURCE_IRQ | IORESOURCE_UNSET)) \ | ||
62 | == IORESOURCE_IRQ) | ||
63 | |||
64 | #define pnp_dma(dev,bar) ((dev)->res.dma_resource[(bar)].start) | ||
65 | #define pnp_dma_flags(dev,bar) ((dev)->res.dma_resource[(bar)].flags) | ||
66 | #define pnp_dma_valid(dev,bar) \ | ||
67 | ((pnp_dma_flags((dev),(bar)) & (IORESOURCE_DMA | IORESOURCE_UNSET)) \ | ||
68 | == IORESOURCE_DMA) | ||
69 | 130 | ||
70 | #define PNP_PORT_FLAG_16BITADDR (1<<0) | 131 | #define PNP_PORT_FLAG_16BITADDR (1<<0) |
71 | #define PNP_PORT_FLAG_FIXED (1<<1) | 132 | #define PNP_PORT_FLAG_FIXED (1<<1) |
@@ -118,13 +179,6 @@ struct pnp_option { | |||
118 | struct pnp_option *next; /* used to chain dependent resources */ | 179 | struct pnp_option *next; /* used to chain dependent resources */ |
119 | }; | 180 | }; |
120 | 181 | ||
121 | struct pnp_resource_table { | ||
122 | struct resource port_resource[PNP_MAX_PORT]; | ||
123 | struct resource mem_resource[PNP_MAX_MEM]; | ||
124 | struct resource dma_resource[PNP_MAX_DMA]; | ||
125 | struct resource irq_resource[PNP_MAX_IRQ]; | ||
126 | }; | ||
127 | |||
128 | /* | 182 | /* |
129 | * Device Management | 183 | * Device Management |
130 | */ | 184 | */ |
@@ -194,10 +248,9 @@ struct pnp_dev { | |||
194 | int capabilities; | 248 | int capabilities; |
195 | struct pnp_option *independent; | 249 | struct pnp_option *independent; |
196 | struct pnp_option *dependent; | 250 | struct pnp_option *dependent; |
197 | struct pnp_resource_table res; | 251 | struct pnp_resource_table *res; |
198 | 252 | ||
199 | char name[PNP_NAME_LEN]; /* contains a human-readable name */ | 253 | char name[PNP_NAME_LEN]; /* contains a human-readable name */ |
200 | unsigned short regs; /* ISAPnP: supported registers */ | ||
201 | int flags; /* used by protocols */ | 254 | int flags; /* used by protocols */ |
202 | struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */ | 255 | struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */ |
203 | void *data; | 256 | void *data; |
@@ -328,8 +381,8 @@ struct pnp_protocol { | |||
328 | char *name; | 381 | char *name; |
329 | 382 | ||
330 | /* resource control functions */ | 383 | /* resource control functions */ |
331 | int (*get) (struct pnp_dev *dev, struct pnp_resource_table *res); | 384 | int (*get) (struct pnp_dev *dev); |
332 | int (*set) (struct pnp_dev *dev, struct pnp_resource_table *res); | 385 | int (*set) (struct pnp_dev *dev); |
333 | int (*disable) (struct pnp_dev *dev); | 386 | int (*disable) (struct pnp_dev *dev); |
334 | 387 | ||
335 | /* protocol specific suspend/resume */ | 388 | /* protocol specific suspend/resume */ |
@@ -358,20 +411,12 @@ extern struct bus_type pnp_bus_type; | |||
358 | #if defined(CONFIG_PNP) | 411 | #if defined(CONFIG_PNP) |
359 | 412 | ||
360 | /* device management */ | 413 | /* device management */ |
361 | int pnp_register_protocol(struct pnp_protocol *protocol); | ||
362 | void pnp_unregister_protocol(struct pnp_protocol *protocol); | ||
363 | int pnp_add_device(struct pnp_dev *dev); | ||
364 | int pnp_device_attach(struct pnp_dev *pnp_dev); | 414 | int pnp_device_attach(struct pnp_dev *pnp_dev); |
365 | void pnp_device_detach(struct pnp_dev *pnp_dev); | 415 | void pnp_device_detach(struct pnp_dev *pnp_dev); |
366 | extern struct list_head pnp_global; | 416 | extern struct list_head pnp_global; |
367 | extern int pnp_platform_devices; | 417 | extern int pnp_platform_devices; |
368 | 418 | ||
369 | /* multidevice card support */ | 419 | /* multidevice card support */ |
370 | int pnp_add_card(struct pnp_card *card); | ||
371 | void pnp_remove_card(struct pnp_card *card); | ||
372 | int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev); | ||
373 | void pnp_remove_card_device(struct pnp_dev *dev); | ||
374 | int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card); | ||
375 | struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, | 420 | struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, |
376 | const char *id, struct pnp_dev *from); | 421 | const char *id, struct pnp_dev *from); |
377 | void pnp_release_card_device(struct pnp_dev *dev); | 422 | void pnp_release_card_device(struct pnp_dev *dev); |
@@ -380,77 +425,42 @@ void pnp_unregister_card_driver(struct pnp_card_driver *drv); | |||
380 | extern struct list_head pnp_cards; | 425 | extern struct list_head pnp_cards; |
381 | 426 | ||
382 | /* resource management */ | 427 | /* resource management */ |
383 | struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev); | ||
384 | struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, | ||
385 | int priority); | ||
386 | int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data); | ||
387 | int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data); | ||
388 | int pnp_register_port_resource(struct pnp_option *option, | ||
389 | struct pnp_port *data); | ||
390 | int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data); | ||
391 | void pnp_init_resource_table(struct pnp_resource_table *table); | ||
392 | int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, | ||
393 | int mode); | ||
394 | int pnp_auto_config_dev(struct pnp_dev *dev); | 428 | int pnp_auto_config_dev(struct pnp_dev *dev); |
395 | int pnp_validate_config(struct pnp_dev *dev); | ||
396 | int pnp_start_dev(struct pnp_dev *dev); | 429 | int pnp_start_dev(struct pnp_dev *dev); |
397 | int pnp_stop_dev(struct pnp_dev *dev); | 430 | int pnp_stop_dev(struct pnp_dev *dev); |
398 | int pnp_activate_dev(struct pnp_dev *dev); | 431 | int pnp_activate_dev(struct pnp_dev *dev); |
399 | int pnp_disable_dev(struct pnp_dev *dev); | 432 | int pnp_disable_dev(struct pnp_dev *dev); |
400 | void pnp_resource_change(struct resource *resource, resource_size_t start, | ||
401 | resource_size_t size); | ||
402 | 433 | ||
403 | /* protocol helpers */ | 434 | /* protocol helpers */ |
404 | int pnp_is_active(struct pnp_dev *dev); | 435 | int pnp_is_active(struct pnp_dev *dev); |
405 | int compare_pnp_id(struct pnp_id *pos, const char *id); | 436 | int compare_pnp_id(struct pnp_id *pos, const char *id); |
406 | int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev); | ||
407 | int pnp_register_driver(struct pnp_driver *drv); | 437 | int pnp_register_driver(struct pnp_driver *drv); |
408 | void pnp_unregister_driver(struct pnp_driver *drv); | 438 | void pnp_unregister_driver(struct pnp_driver *drv); |
409 | 439 | ||
410 | #else | 440 | #else |
411 | 441 | ||
412 | /* device management */ | 442 | /* device management */ |
413 | static inline int pnp_register_protocol(struct pnp_protocol *protocol) { return -ENODEV; } | ||
414 | static inline void pnp_unregister_protocol(struct pnp_protocol *protocol) { } | ||
415 | static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; } | ||
416 | static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; } | ||
417 | static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; } | 443 | static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; } |
418 | static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { } | 444 | static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { } |
419 | 445 | ||
420 | #define pnp_platform_devices 0 | 446 | #define pnp_platform_devices 0 |
421 | 447 | ||
422 | /* multidevice card support */ | 448 | /* multidevice card support */ |
423 | static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; } | ||
424 | static inline void pnp_remove_card(struct pnp_card *card) { } | ||
425 | static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; } | ||
426 | static inline void pnp_remove_card_device(struct pnp_dev *dev) { } | ||
427 | static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; } | ||
428 | static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; } | 449 | static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; } |
429 | static inline void pnp_release_card_device(struct pnp_dev *dev) { } | 450 | static inline void pnp_release_card_device(struct pnp_dev *dev) { } |
430 | static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; } | 451 | static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; } |
431 | static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { } | 452 | static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { } |
432 | 453 | ||
433 | /* resource management */ | 454 | /* resource management */ |
434 | static inline struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev) { return NULL; } | ||
435 | static inline struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, int priority) { return NULL; } | ||
436 | static inline int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; } | ||
437 | static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; } | ||
438 | static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; } | ||
439 | static inline int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; } | ||
440 | static inline void pnp_init_resource_table(struct pnp_resource_table *table) { } | ||
441 | static inline int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode) { return -ENODEV; } | ||
442 | static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; } | 455 | static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; } |
443 | static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; } | ||
444 | static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; } | 456 | static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; } |
445 | static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; } | 457 | static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; } |
446 | static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; } | 458 | static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; } |
447 | static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; } | 459 | static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; } |
448 | static inline void pnp_resource_change(struct resource *resource, resource_size_t start, resource_size_t size) { } | ||
449 | 460 | ||
450 | /* protocol helpers */ | 461 | /* protocol helpers */ |
451 | static inline int pnp_is_active(struct pnp_dev *dev) { return 0; } | 462 | static inline int pnp_is_active(struct pnp_dev *dev) { return 0; } |
452 | static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; } | 463 | static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; } |
453 | static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; } | ||
454 | static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; } | 464 | static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; } |
455 | static inline void pnp_unregister_driver(struct pnp_driver *drv) { } | 465 | static inline void pnp_unregister_driver(struct pnp_driver *drv) { } |
456 | 466 | ||
@@ -466,6 +476,4 @@ static inline void pnp_unregister_driver(struct pnp_driver *drv) { } | |||
466 | #define pnp_dbg(format, arg...) do {} while (0) | 476 | #define pnp_dbg(format, arg...) do {} while (0) |
467 | #endif | 477 | #endif |
468 | 478 | ||
469 | #endif /* __KERNEL__ */ | ||
470 | |||
471 | #endif /* _LINUX_PNP_H */ | 479 | #endif /* _LINUX_PNP_H */ |