blob: 195aafc6cd07c691e37e7d0247538dbd63ff5360 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Linux Plug and Play Support
3 * Copyright by Adam Belay <ambx1@neo.rr.com>
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -06004 * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
5 * Bjorn Helgaas <bjorn.helgaas@hp.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7
8#ifndef _LINUX_PNP_H
9#define _LINUX_PNP_H
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/device.h>
12#include <linux/list.h>
13#include <linux/errno.h>
14#include <linux/mod_devicetable.h>
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#define PNP_NAME_LEN 50
17
18struct pnp_protocol;
19struct pnp_dev;
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021/*
22 * Resource Management
23 */
David Milleref3d7712008-09-16 15:00:11 -070024#ifdef CONFIG_PNP
Rene Hermanb563cf52008-10-15 22:03:58 -070025struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned long type,
26 unsigned int num);
David Milleref3d7712008-09-16 15:00:11 -070027#else
Rene Hermanb563cf52008-10-15 22:03:58 -070028static inline struct resource *pnp_get_resource(struct pnp_dev *dev,
29 unsigned long type, unsigned int num)
David Milleref3d7712008-09-16 15:00:11 -070030{
31 return NULL;
32}
33#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Bjorn Helgaas13575e812008-04-28 16:34:16 -060035static inline int pnp_resource_valid(struct resource *res)
36{
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -060037 if (res)
38 return 1;
39 return 0;
40}
41
42static inline int pnp_resource_enabled(struct resource *res)
43{
44 if (res && !(res->flags & IORESOURCE_DISABLED))
Bjorn Helgaas13575e812008-04-28 16:34:16 -060045 return 1;
46 return 0;
47}
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Bjorn Helgaas13575e812008-04-28 16:34:16 -060049static inline resource_size_t pnp_resource_len(struct resource *res)
50{
51 if (res->start == 0 && res->end == 0)
52 return 0;
Joe Perches28f65c112011-06-09 09:13:32 -070053 return resource_size(res);
Bjorn Helgaas13575e812008-04-28 16:34:16 -060054}
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Bjorn Helgaas13575e812008-04-28 16:34:16 -060057static inline resource_size_t pnp_port_start(struct pnp_dev *dev,
58 unsigned int bar)
59{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -060060 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
61
62 if (pnp_resource_valid(res))
63 return res->start;
64 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -060065}
66
67static inline resource_size_t pnp_port_end(struct pnp_dev *dev,
68 unsigned int bar)
69{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -060070 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
71
72 if (pnp_resource_valid(res))
73 return res->end;
74 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -060075}
76
77static inline unsigned long pnp_port_flags(struct pnp_dev *dev,
78 unsigned int bar)
79{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -060080 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
81
82 if (pnp_resource_valid(res))
83 return res->flags;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -060084 return IORESOURCE_IO | IORESOURCE_AUTO;
Bjorn Helgaas13575e812008-04-28 16:34:16 -060085}
86
87static inline int pnp_port_valid(struct pnp_dev *dev, unsigned int bar)
88{
89 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IO, bar));
90}
91
92static inline resource_size_t pnp_port_len(struct pnp_dev *dev,
93 unsigned int bar)
94{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -060095 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
96
97 if (pnp_resource_valid(res))
98 return pnp_resource_len(res);
99 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600100}
101
102
103static inline resource_size_t pnp_mem_start(struct pnp_dev *dev,
104 unsigned int bar)
105{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600106 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
107
108 if (pnp_resource_valid(res))
109 return res->start;
110 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600111}
112
113static inline resource_size_t pnp_mem_end(struct pnp_dev *dev,
114 unsigned int bar)
115{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600116 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
117
118 if (pnp_resource_valid(res))
119 return res->end;
120 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600121}
122
123static inline unsigned long pnp_mem_flags(struct pnp_dev *dev, unsigned int bar)
124{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600125 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
126
127 if (pnp_resource_valid(res))
128 return res->flags;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600129 return IORESOURCE_MEM | IORESOURCE_AUTO;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600130}
131
132static inline int pnp_mem_valid(struct pnp_dev *dev, unsigned int bar)
133{
134 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_MEM, bar));
135}
136
137static inline resource_size_t pnp_mem_len(struct pnp_dev *dev,
138 unsigned int bar)
139{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600140 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
141
142 if (pnp_resource_valid(res))
143 return pnp_resource_len(res);
144 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600145}
146
147
148static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar)
149{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600150 struct resource *res = pnp_get_resource(dev, IORESOURCE_IRQ, bar);
151
152 if (pnp_resource_valid(res))
153 return res->start;
154 return -1;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600155}
156
157static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar)
158{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600159 struct resource *res = pnp_get_resource(dev, IORESOURCE_IRQ, bar);
160
161 if (pnp_resource_valid(res))
162 return res->flags;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600163 return IORESOURCE_IRQ | IORESOURCE_AUTO;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600164}
165
166static inline int pnp_irq_valid(struct pnp_dev *dev, unsigned int bar)
167{
168 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IRQ, bar));
169}
170
171
172static inline resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar)
173{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600174 struct resource *res = pnp_get_resource(dev, IORESOURCE_DMA, bar);
175
176 if (pnp_resource_valid(res))
177 return res->start;
178 return -1;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600179}
180
181static inline unsigned long pnp_dma_flags(struct pnp_dev *dev, unsigned int bar)
182{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600183 struct resource *res = pnp_get_resource(dev, IORESOURCE_DMA, bar);
184
185 if (pnp_resource_valid(res))
186 return res->flags;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600187 return IORESOURCE_DMA | IORESOURCE_AUTO;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600188}
189
190static inline int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar)
191{
192 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_DMA, bar));
193}
194
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196/*
Joe Perchesfd3f8982008-02-03 17:45:46 +0200197 * Device Management
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 */
199
200struct pnp_card {
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700201 struct device dev; /* Driver Model device interface */
202 unsigned char number; /* used as an index, must be unique */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 struct list_head global_list; /* node in global list of cards */
204 struct list_head protocol_list; /* node in protocol's list of cards */
205 struct list_head devices; /* devices attached to the card */
206
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700207 struct pnp_protocol *protocol;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700208 struct pnp_id *id; /* contains supported EISA IDs */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210 char name[PNP_NAME_LEN]; /* contains a human-readable name */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700211 unsigned char pnpver; /* Plug & Play version */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700212 unsigned char productver; /* product version */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700213 unsigned int serial; /* serial number */
214 unsigned char checksum; /* if zero - checksum passed */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/isapnp */
216};
217
218#define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list)
219#define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list)
220#define to_pnp_card(n) container_of(n, struct pnp_card, dev)
221#define pnp_for_each_card(card) \
222 for((card) = global_to_pnp_card(pnp_cards.next); \
223 (card) != global_to_pnp_card(&pnp_cards); \
224 (card) = global_to_pnp_card((card)->global_list.next))
225
226struct pnp_card_link {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700227 struct pnp_card *card;
228 struct pnp_card_driver *driver;
229 void *driver_data;
Takashi Iwai4c98cfe2005-11-29 09:09:32 +0100230 pm_message_t pm_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231};
232
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700233static inline void *pnp_get_card_drvdata(struct pnp_card_link *pcard)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234{
235 return pcard->driver_data;
236}
237
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700238static inline void pnp_set_card_drvdata(struct pnp_card_link *pcard, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239{
240 pcard->driver_data = data;
241}
242
243struct pnp_dev {
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700244 struct device dev; /* Driver Model device interface */
David Brownell2e17c552007-05-08 00:25:29 -0700245 u64 dma_mask;
Bjorn Helgaas544451a2008-04-10 21:29:28 -0700246 unsigned int number; /* used as an index, must be unique */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 int status;
248
249 struct list_head global_list; /* node in global list of devices */
250 struct list_head protocol_list; /* node in list of device's protocol */
251 struct list_head card_list; /* node in card's list of devices */
252 struct list_head rdev_list; /* node in cards list of requested devices */
253
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700254 struct pnp_protocol *protocol;
255 struct pnp_card *card; /* card the device is attached to, none if NULL */
256 struct pnp_driver *driver;
257 struct pnp_card_link *card_link;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700259 struct pnp_id *id; /* supported EISA IDs */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261 int active;
262 int capabilities;
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -0600263 unsigned int num_dependent_sets;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600264 struct list_head resources;
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -0600265 struct list_head options;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
267 char name[PNP_NAME_LEN]; /* contains a human-readable name */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700268 int flags; /* used by protocols */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */
270 void *data;
271};
272
273#define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list)
274#define card_to_pnp_dev(n) list_entry(n, struct pnp_dev, card_list)
275#define protocol_to_pnp_dev(n) list_entry(n, struct pnp_dev, protocol_list)
276#define to_pnp_dev(n) container_of(n, struct pnp_dev, dev)
277#define pnp_for_each_dev(dev) \
278 for((dev) = global_to_pnp_dev(pnp_global.next); \
279 (dev) != global_to_pnp_dev(&pnp_global); \
280 (dev) = global_to_pnp_dev((dev)->global_list.next))
281#define card_for_each_dev(card,dev) \
282 for((dev) = card_to_pnp_dev((card)->devices.next); \
283 (dev) != card_to_pnp_dev(&(card)->devices); \
284 (dev) = card_to_pnp_dev((dev)->card_list.next))
285#define pnp_dev_name(dev) (dev)->name
286
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700287static inline void *pnp_get_drvdata(struct pnp_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288{
289 return dev_get_drvdata(&pdev->dev);
290}
291
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700292static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293{
294 dev_set_drvdata(&pdev->dev, data);
295}
296
297struct pnp_fixup {
298 char id[7];
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700299 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300};
301
302/* config parameters */
303#define PNP_CONFIG_NORMAL 0x0001
304#define PNP_CONFIG_FORCE 0x0002 /* disables validity checking */
305
306/* capabilities */
307#define PNP_READ 0x0001
308#define PNP_WRITE 0x0002
309#define PNP_DISABLE 0x0004
310#define PNP_CONFIGURABLE 0x0008
311#define PNP_REMOVABLE 0x0010
312
Bjorn Helgaas402b3102007-10-16 23:31:09 -0700313#define pnp_can_read(dev) (((dev)->protocol->get) && \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 ((dev)->capabilities & PNP_READ))
Bjorn Helgaas402b3102007-10-16 23:31:09 -0700315#define pnp_can_write(dev) (((dev)->protocol->set) && \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 ((dev)->capabilities & PNP_WRITE))
Bjorn Helgaas402b3102007-10-16 23:31:09 -0700317#define pnp_can_disable(dev) (((dev)->protocol->disable) && \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 ((dev)->capabilities & PNP_DISABLE))
319#define pnp_can_configure(dev) ((!(dev)->active) && \
320 ((dev)->capabilities & PNP_CONFIGURABLE))
321
322#ifdef CONFIG_ISAPNP
323extern struct pnp_protocol isapnp_protocol;
324#define pnp_device_is_isapnp(dev) ((dev)->protocol == (&isapnp_protocol))
325#else
326#define pnp_device_is_isapnp(dev) 0
327#endif
Daniel Walkerb3bd86e2008-02-06 01:40:04 -0800328extern struct mutex pnp_res_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330#ifdef CONFIG_PNPBIOS
331extern struct pnp_protocol pnpbios_protocol;
332#define pnp_device_is_pnpbios(dev) ((dev)->protocol == (&pnpbios_protocol))
333#else
334#define pnp_device_is_pnpbios(dev) 0
335#endif
336
Bjorn Helgaas9065ce42009-11-17 17:05:19 -0700337#ifdef CONFIG_PNPACPI
338extern struct pnp_protocol pnpacpi_protocol;
339
340static inline struct acpi_device *pnp_acpi_device(struct pnp_dev *dev)
341{
342 if (dev->protocol == &pnpacpi_protocol)
343 return dev->data;
344 return NULL;
345}
346#else
347#define pnp_acpi_device(dev) 0
348#endif
349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350/* status */
351#define PNP_READY 0x0000
352#define PNP_ATTACHED 0x0001
353#define PNP_BUSY 0x0002
354#define PNP_FAULTY 0x0004
355
356/* isapnp specific macros */
357
358#define isapnp_card_number(dev) ((dev)->card ? (dev)->card->number : -1)
359#define isapnp_csn_number(dev) ((dev)->number)
360
361/*
362 * Driver Management
363 */
364
365struct pnp_id {
366 char id[PNP_ID_LEN];
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700367 struct pnp_id *next;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368};
369
370struct pnp_driver {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700371 char *name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 const struct pnp_device_id *id_table;
373 unsigned int flags;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700374 int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id);
375 void (*remove) (struct pnp_dev *dev);
David Härdemanabd66332009-09-21 17:04:52 -0700376 void (*shutdown) (struct pnp_dev *dev);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700377 int (*suspend) (struct pnp_dev *dev, pm_message_t state);
378 int (*resume) (struct pnp_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 struct device_driver driver;
380};
381
382#define to_pnp_driver(drv) container_of(drv, struct pnp_driver, driver)
383
384struct pnp_card_driver {
385 struct list_head global_list;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700386 char *name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 const struct pnp_card_device_id *id_table;
388 unsigned int flags;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700389 int (*probe) (struct pnp_card_link *card,
390 const struct pnp_card_device_id *card_id);
391 void (*remove) (struct pnp_card_link *card);
392 int (*suspend) (struct pnp_card_link *card, pm_message_t state);
393 int (*resume) (struct pnp_card_link *card);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 struct pnp_driver link;
395};
396
397#define to_pnp_card_driver(drv) container_of(drv, struct pnp_card_driver, link)
398
399/* pnp driver flags */
400#define PNP_DRIVER_RES_DO_NOT_CHANGE 0x0001 /* do not change the state of the device */
401#define PNP_DRIVER_RES_DISABLE 0x0003 /* ensure the device is disabled */
402
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403/*
404 * Protocol Management
405 */
406
407struct pnp_protocol {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700408 struct list_head protocol_list;
409 char *name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
411 /* resource control functions */
Bjorn Helgaas59284cb2008-04-28 16:34:05 -0600412 int (*get) (struct pnp_dev *dev);
413 int (*set) (struct pnp_dev *dev);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700414 int (*disable) (struct pnp_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415
Shaohua Lifc30e682007-07-20 10:03:20 +0800416 /* protocol specific suspend/resume */
Alan Sternb14e0332010-06-29 22:49:24 +0200417 bool (*can_wakeup) (struct pnp_dev *dev);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700418 int (*suspend) (struct pnp_dev * dev, pm_message_t state);
419 int (*resume) (struct pnp_dev * dev);
Shaohua Lifc30e682007-07-20 10:03:20 +0800420
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 /* used by pnp layer only (look but don't touch) */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700422 unsigned char number; /* protocol number */
423 struct device dev; /* link to driver model */
424 struct list_head cards;
425 struct list_head devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426};
427
428#define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list)
429#define protocol_for_each_card(protocol,card) \
430 for((card) = protocol_to_pnp_card((protocol)->cards.next); \
431 (card) != protocol_to_pnp_card(&(protocol)->cards); \
432 (card) = protocol_to_pnp_card((card)->protocol_list.next))
433#define protocol_for_each_dev(protocol,dev) \
434 for((dev) = protocol_to_pnp_dev((protocol)->devices.next); \
435 (dev) != protocol_to_pnp_dev(&(protocol)->devices); \
436 (dev) = protocol_to_pnp_dev((dev)->protocol_list.next))
437
David Brownellcbcdc1d2007-02-10 01:45:13 -0800438extern struct bus_type pnp_bus_type;
439
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440#if defined(CONFIG_PNP)
441
442/* device management */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443int pnp_device_attach(struct pnp_dev *pnp_dev);
444void pnp_device_detach(struct pnp_dev *pnp_dev);
445extern struct list_head pnp_global;
Bjorn Helgaas8f81dd12007-05-08 00:35:54 -0700446extern int pnp_platform_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447
448/* multidevice card support */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700449struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
450 const char *id, struct pnp_dev *from);
451void pnp_release_card_device(struct pnp_dev *dev);
452int pnp_register_card_driver(struct pnp_card_driver *drv);
453void pnp_unregister_card_driver(struct pnp_card_driver *drv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454extern struct list_head pnp_cards;
455
456/* resource management */
Bjorn Helgaas57fd51a2008-06-27 16:57:01 -0600457int pnp_possible_config(struct pnp_dev *dev, int type, resource_size_t base,
458 resource_size_t size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459int pnp_auto_config_dev(struct pnp_dev *dev);
Pierre Ossman68094e32005-11-29 09:09:32 +0100460int pnp_start_dev(struct pnp_dev *dev);
461int pnp_stop_dev(struct pnp_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462int pnp_activate_dev(struct pnp_dev *dev);
463int pnp_disable_dev(struct pnp_dev *dev);
Bjorn Helgaas1b8e6962009-06-05 14:37:23 +0000464int pnp_range_reserved(resource_size_t start, resource_size_t end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465
466/* protocol helpers */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700467int pnp_is_active(struct pnp_dev *dev);
468int compare_pnp_id(struct pnp_id *pos, const char *id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469int pnp_register_driver(struct pnp_driver *drv);
470void pnp_unregister_driver(struct pnp_driver *drv);
471
472#else
473
474/* device management */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700475static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
476static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700477
Bjorn Helgaas8f81dd12007-05-08 00:35:54 -0700478#define pnp_platform_devices 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
480/* multidevice card support */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700481static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
482static inline void pnp_release_card_device(struct pnp_dev *dev) { }
483static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }
484static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
486/* resource management */
Bjorn Helgaas57fd51a2008-06-27 16:57:01 -0600487static inline int pnp_possible_config(struct pnp_dev *dev, int type,
488 resource_size_t base,
489 resource_size_t size) { return 0; }
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700490static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700491static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
492static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
493static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
494static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
Bjorn Helgaas1b8e6962009-06-05 14:37:23 +0000495static inline int pnp_range_reserved(resource_size_t start, resource_size_t end) { return 0;}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496
497/* protocol helpers */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700498static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
499static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700500static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
501static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502
503#endif /* CONFIG_PNP */
504
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505#endif /* _LINUX_PNP_H */