aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pnp.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 14:52:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 14:52:52 -0400
commit08acd4f8af42affd8cbed81cc1b69fa12ddb213f (patch)
tree988d15db6233b20db6a500cd5f590c6d2041462d /include/linux/pnp.h
parentccf2779544eecfcc5447e2028d1029b6d4ff7bb6 (diff)
parent008238b54ac2350babf195084ecedbcf7851a202 (diff)
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (179 commits) ACPI: Fix acpi_processor_idle and idle= boot parameters interaction acpi: fix section mismatch warning in pnpacpi intel_menlo: fix build warning ACPI: Cleanup: Remove unneeded, multiple local dummy variables ACPI: video - fix permissions on some proc entries ACPI: video - properly handle errors when registering proc elements ACPI: video - do not store invalid entries in attached_array list ACPI: re-name acpi_pm_ops to acpi_suspend_ops ACER_WMI/ASUS_LAPTOP: fix build bug thinkpad_acpi: fix possible NULL pointer dereference if kstrdup failed ACPI: check a return value correctly in acpi_power_get_context() #if 0 acpi/bay.c:eject_removable_drive() eeepc-laptop: add hwmon fan control eeepc-laptop: add backlight eeepc-laptop: add base driver ACPI: thinkpad-acpi: bump up version to 0.20 ACPI: thinkpad-acpi: fix selects in Kconfig ACPI: thinkpad-acpi: use a private workqueue ACPI: thinkpad-acpi: fluff really minor fix ACPI: thinkpad-acpi: use uppercase for "LED" on user documentation ... Fixed conflicts in drivers/acpi/video.c and drivers/misc/intel_menlow.c manually.
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 2f3bcf73052c..63b128d512fb 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -11,59 +11,122 @@
11#include <linux/errno.h> 11#include <linux/errno.h>
12#include <linux/mod_devicetable.h> 12#include <linux/mod_devicetable.h>
13 13
14#define PNP_MAX_PORT 40
15#define PNP_MAX_MEM 24
16#define PNP_MAX_IRQ 2
17#define PNP_MAX_DMA 2
18#define PNP_NAME_LEN 50 14#define PNP_NAME_LEN 50
19 15
20struct pnp_protocol; 16struct pnp_protocol;
21struct pnp_dev; 17struct pnp_dev;
18struct pnp_resource_table;
22 19
23/* 20/*
24 * Resource Management 21 * Resource Management
25 */ 22 */
23struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int);
24
25static inline int pnp_resource_valid(struct resource *res)
26{
27 if (res && !(res->flags & IORESOURCE_UNSET))
28 return 1;
29 return 0;
30}
31
32static 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
40static 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
46static 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
52static 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
58static 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
63static 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
70static 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
76static 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
82static 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
87static 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
92static 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
99static 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
104static 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
109static 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
115static 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
120static 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
125static 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}
26 129
27/* Use these instead of directly reading pnp_dev to get resource information */
28#define pnp_port_start(dev,bar) ((dev)->res.port_resource[(bar)].start)
29#define pnp_port_end(dev,bar) ((dev)->res.port_resource[(bar)].end)
30#define pnp_port_flags(dev,bar) ((dev)->res.port_resource[(bar)].flags)
31#define pnp_port_valid(dev,bar) \
32 ((pnp_port_flags((dev),(bar)) & (IORESOURCE_IO | IORESOURCE_UNSET)) \
33 == IORESOURCE_IO)
34#define pnp_port_len(dev,bar) \
35 ((pnp_port_start((dev),(bar)) == 0 && \
36 pnp_port_end((dev),(bar)) == \
37 pnp_port_start((dev),(bar))) ? 0 : \
38 \
39 (pnp_port_end((dev),(bar)) - \
40 pnp_port_start((dev),(bar)) + 1))
41
42#define pnp_mem_start(dev,bar) ((dev)->res.mem_resource[(bar)].start)
43#define pnp_mem_end(dev,bar) ((dev)->res.mem_resource[(bar)].end)
44#define pnp_mem_flags(dev,bar) ((dev)->res.mem_resource[(bar)].flags)
45#define pnp_mem_valid(dev,bar) \
46 ((pnp_mem_flags((dev),(bar)) & (IORESOURCE_MEM | IORESOURCE_UNSET)) \
47 == IORESOURCE_MEM)
48#define pnp_mem_len(dev,bar) \
49 ((pnp_mem_start((dev),(bar)) == 0 && \
50 pnp_mem_end((dev),(bar)) == \
51 pnp_mem_start((dev),(bar))) ? 0 : \
52 \
53 (pnp_mem_end((dev),(bar)) - \
54 pnp_mem_start((dev),(bar)) + 1))
55
56#define pnp_irq(dev,bar) ((dev)->res.irq_resource[(bar)].start)
57#define pnp_irq_flags(dev,bar) ((dev)->res.irq_resource[(bar)].flags)
58#define pnp_irq_valid(dev,bar) \
59 ((pnp_irq_flags((dev),(bar)) & (IORESOURCE_IRQ | IORESOURCE_UNSET)) \
60 == IORESOURCE_IRQ)
61
62#define pnp_dma(dev,bar) ((dev)->res.dma_resource[(bar)].start)
63#define pnp_dma_flags(dev,bar) ((dev)->res.dma_resource[(bar)].flags)
64#define pnp_dma_valid(dev,bar) \
65 ((pnp_dma_flags((dev),(bar)) & (IORESOURCE_DMA | IORESOURCE_UNSET)) \
66 == IORESOURCE_DMA)
67 130
68#define PNP_PORT_FLAG_16BITADDR (1<<0) 131#define PNP_PORT_FLAG_16BITADDR (1<<0)
69#define PNP_PORT_FLAG_FIXED (1<<1) 132#define PNP_PORT_FLAG_FIXED (1<<1)
@@ -116,13 +179,6 @@ struct pnp_option {
116 struct pnp_option *next; /* used to chain dependent resources */ 179 struct pnp_option *next; /* used to chain dependent resources */
117}; 180};
118 181
119struct pnp_resource_table {
120 struct resource port_resource[PNP_MAX_PORT];
121 struct resource mem_resource[PNP_MAX_MEM];
122 struct resource dma_resource[PNP_MAX_DMA];
123 struct resource irq_resource[PNP_MAX_IRQ];
124};
125
126/* 182/*
127 * Device Management 183 * Device Management
128 */ 184 */
@@ -192,10 +248,9 @@ struct pnp_dev {
192 int capabilities; 248 int capabilities;
193 struct pnp_option *independent; 249 struct pnp_option *independent;
194 struct pnp_option *dependent; 250 struct pnp_option *dependent;
195 struct pnp_resource_table res; 251 struct pnp_resource_table *res;
196 252
197 char name[PNP_NAME_LEN]; /* contains a human-readable name */ 253 char name[PNP_NAME_LEN]; /* contains a human-readable name */
198 unsigned short regs; /* ISAPnP: supported registers */
199 int flags; /* used by protocols */ 254 int flags; /* used by protocols */
200 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */ 255 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */
201 void *data; 256 void *data;
@@ -326,8 +381,8 @@ struct pnp_protocol {
326 char *name; 381 char *name;
327 382
328 /* resource control functions */ 383 /* resource control functions */
329 int (*get) (struct pnp_dev *dev, struct pnp_resource_table *res); 384 int (*get) (struct pnp_dev *dev);
330 int (*set) (struct pnp_dev *dev, struct pnp_resource_table *res); 385 int (*set) (struct pnp_dev *dev);
331 int (*disable) (struct pnp_dev *dev); 386 int (*disable) (struct pnp_dev *dev);
332 387
333 /* protocol specific suspend/resume */ 388 /* protocol specific suspend/resume */
@@ -356,20 +411,12 @@ extern struct bus_type pnp_bus_type;
356#if defined(CONFIG_PNP) 411#if defined(CONFIG_PNP)
357 412
358/* device management */ 413/* device management */
359int pnp_register_protocol(struct pnp_protocol *protocol);
360void pnp_unregister_protocol(struct pnp_protocol *protocol);
361int pnp_add_device(struct pnp_dev *dev);
362int pnp_device_attach(struct pnp_dev *pnp_dev); 414int pnp_device_attach(struct pnp_dev *pnp_dev);
363void pnp_device_detach(struct pnp_dev *pnp_dev); 415void pnp_device_detach(struct pnp_dev *pnp_dev);
364extern struct list_head pnp_global; 416extern struct list_head pnp_global;
365extern int pnp_platform_devices; 417extern int pnp_platform_devices;
366 418
367/* multidevice card support */ 419/* multidevice card support */
368int pnp_add_card(struct pnp_card *card);
369void pnp_remove_card(struct pnp_card *card);
370int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
371void pnp_remove_card_device(struct pnp_dev *dev);
372int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card);
373struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, 420struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
374 const char *id, struct pnp_dev *from); 421 const char *id, struct pnp_dev *from);
375void pnp_release_card_device(struct pnp_dev *dev); 422void pnp_release_card_device(struct pnp_dev *dev);
@@ -378,77 +425,42 @@ void pnp_unregister_card_driver(struct pnp_card_driver *drv);
378extern struct list_head pnp_cards; 425extern struct list_head pnp_cards;
379 426
380/* resource management */ 427/* resource management */
381struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
382struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
383 int priority);
384int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data);
385int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data);
386int pnp_register_port_resource(struct pnp_option *option,
387 struct pnp_port *data);
388int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data);
389void pnp_init_resource_table(struct pnp_resource_table *table);
390int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
391 int mode);
392int pnp_auto_config_dev(struct pnp_dev *dev); 428int pnp_auto_config_dev(struct pnp_dev *dev);
393int pnp_validate_config(struct pnp_dev *dev);
394int pnp_start_dev(struct pnp_dev *dev); 429int pnp_start_dev(struct pnp_dev *dev);
395int pnp_stop_dev(struct pnp_dev *dev); 430int pnp_stop_dev(struct pnp_dev *dev);
396int pnp_activate_dev(struct pnp_dev *dev); 431int pnp_activate_dev(struct pnp_dev *dev);
397int pnp_disable_dev(struct pnp_dev *dev); 432int pnp_disable_dev(struct pnp_dev *dev);
398void pnp_resource_change(struct resource *resource, resource_size_t start,
399 resource_size_t size);
400 433
401/* protocol helpers */ 434/* protocol helpers */
402int pnp_is_active(struct pnp_dev *dev); 435int pnp_is_active(struct pnp_dev *dev);
403int compare_pnp_id(struct pnp_id *pos, const char *id); 436int compare_pnp_id(struct pnp_id *pos, const char *id);
404int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
405int pnp_register_driver(struct pnp_driver *drv); 437int pnp_register_driver(struct pnp_driver *drv);
406void pnp_unregister_driver(struct pnp_driver *drv); 438void pnp_unregister_driver(struct pnp_driver *drv);
407 439
408#else 440#else
409 441
410/* device management */ 442/* device management */
411static inline int pnp_register_protocol(struct pnp_protocol *protocol) { return -ENODEV; }
412static inline void pnp_unregister_protocol(struct pnp_protocol *protocol) { }
413static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; }
414static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; }
415static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; } 443static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
416static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { } 444static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { }
417 445
418#define pnp_platform_devices 0 446#define pnp_platform_devices 0
419 447
420/* multidevice card support */ 448/* multidevice card support */
421static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; }
422static inline void pnp_remove_card(struct pnp_card *card) { }
423static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; }
424static inline void pnp_remove_card_device(struct pnp_dev *dev) { }
425static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; }
426static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; } 449static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
427static inline void pnp_release_card_device(struct pnp_dev *dev) { } 450static inline void pnp_release_card_device(struct pnp_dev *dev) { }
428static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; } 451static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }
429static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { } 452static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }
430 453
431/* resource management */ 454/* resource management */
432static inline struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev) { return NULL; }
433static inline struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, int priority) { return NULL; }
434static inline int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; }
435static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; }
436static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; }
437static inline int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; }
438static inline void pnp_init_resource_table(struct pnp_resource_table *table) { }
439static inline int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode) { return -ENODEV; }
440static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; } 455static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
441static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; }
442static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; } 456static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
443static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; } 457static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
444static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; } 458static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
445static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; } 459static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
446static inline void pnp_resource_change(struct resource *resource, resource_size_t start, resource_size_t size) { }
447 460
448/* protocol helpers */ 461/* protocol helpers */
449static inline int pnp_is_active(struct pnp_dev *dev) { return 0; } 462static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
450static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; } 463static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
451static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; }
452static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; } 464static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
453static inline void pnp_unregister_driver(struct pnp_driver *drv) { } 465static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
454 466