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