blob: 1ce54b63085dd09b1ee5826694294969fe2a1f78 [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 */
Bjorn Helgaasb90eca02008-04-28 16:34:14 -060024struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Bjorn Helgaas13575e812008-04-28 16:34:16 -060026static inline int pnp_resource_valid(struct resource *res)
27{
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -060028 if (res)
29 return 1;
30 return 0;
31}
32
33static inline int pnp_resource_enabled(struct resource *res)
34{
35 if (res && !(res->flags & IORESOURCE_DISABLED))
Bjorn Helgaas13575e812008-04-28 16:34:16 -060036 return 1;
37 return 0;
38}
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Bjorn Helgaas13575e812008-04-28 16:34:16 -060040static inline resource_size_t pnp_resource_len(struct resource *res)
41{
42 if (res->start == 0 && res->end == 0)
43 return 0;
44 return res->end - res->start + 1;
45}
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Bjorn Helgaas13575e812008-04-28 16:34:16 -060048static inline resource_size_t pnp_port_start(struct pnp_dev *dev,
49 unsigned int bar)
50{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -060051 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
52
53 if (pnp_resource_valid(res))
54 return res->start;
55 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -060056}
57
58static inline resource_size_t pnp_port_end(struct pnp_dev *dev,
59 unsigned int bar)
60{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -060061 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
62
63 if (pnp_resource_valid(res))
64 return res->end;
65 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -060066}
67
68static inline unsigned long pnp_port_flags(struct pnp_dev *dev,
69 unsigned int bar)
70{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -060071 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
72
73 if (pnp_resource_valid(res))
74 return res->flags;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -060075 return IORESOURCE_IO | IORESOURCE_AUTO;
Bjorn Helgaas13575e812008-04-28 16:34:16 -060076}
77
78static inline int pnp_port_valid(struct pnp_dev *dev, unsigned int bar)
79{
80 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IO, bar));
81}
82
83static inline resource_size_t pnp_port_len(struct pnp_dev *dev,
84 unsigned int bar)
85{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -060086 struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
87
88 if (pnp_resource_valid(res))
89 return pnp_resource_len(res);
90 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -060091}
92
93
94static inline resource_size_t pnp_mem_start(struct pnp_dev *dev,
95 unsigned int bar)
96{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -060097 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
98
99 if (pnp_resource_valid(res))
100 return res->start;
101 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600102}
103
104static inline resource_size_t pnp_mem_end(struct pnp_dev *dev,
105 unsigned int bar)
106{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600107 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
108
109 if (pnp_resource_valid(res))
110 return res->end;
111 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600112}
113
114static inline unsigned long pnp_mem_flags(struct pnp_dev *dev, 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->flags;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600120 return IORESOURCE_MEM | IORESOURCE_AUTO;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600121}
122
123static inline int pnp_mem_valid(struct pnp_dev *dev, unsigned int bar)
124{
125 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_MEM, bar));
126}
127
128static inline resource_size_t pnp_mem_len(struct pnp_dev *dev,
129 unsigned int bar)
130{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600131 struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
132
133 if (pnp_resource_valid(res))
134 return pnp_resource_len(res);
135 return 0;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600136}
137
138
139static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar)
140{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600141 struct resource *res = pnp_get_resource(dev, IORESOURCE_IRQ, bar);
142
143 if (pnp_resource_valid(res))
144 return res->start;
145 return -1;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600146}
147
148static inline unsigned long pnp_irq_flags(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->flags;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600154 return IORESOURCE_IRQ | IORESOURCE_AUTO;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600155}
156
157static inline int pnp_irq_valid(struct pnp_dev *dev, unsigned int bar)
158{
159 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IRQ, bar));
160}
161
162
163static inline resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar)
164{
Bjorn Helgaas20bfdbb2008-06-27 16:56:56 -0600165 struct resource *res = pnp_get_resource(dev, IORESOURCE_DMA, bar);
166
167 if (pnp_resource_valid(res))
168 return res->start;
169 return -1;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600170}
171
172static inline unsigned long pnp_dma_flags(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->flags;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600178 return IORESOURCE_DMA | IORESOURCE_AUTO;
Bjorn Helgaas13575e812008-04-28 16:34:16 -0600179}
180
181static inline int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar)
182{
183 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_DMA, bar));
184}
185
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187/*
Joe Perchesfd3f8982008-02-03 17:45:46 +0200188 * Device Management
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 */
190
191struct pnp_card {
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700192 struct device dev; /* Driver Model device interface */
193 unsigned char number; /* used as an index, must be unique */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 struct list_head global_list; /* node in global list of cards */
195 struct list_head protocol_list; /* node in protocol's list of cards */
196 struct list_head devices; /* devices attached to the card */
197
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700198 struct pnp_protocol *protocol;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700199 struct pnp_id *id; /* contains supported EISA IDs */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201 char name[PNP_NAME_LEN]; /* contains a human-readable name */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700202 unsigned char pnpver; /* Plug & Play version */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700203 unsigned char productver; /* product version */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700204 unsigned int serial; /* serial number */
205 unsigned char checksum; /* if zero - checksum passed */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/isapnp */
207};
208
209#define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list)
210#define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list)
211#define to_pnp_card(n) container_of(n, struct pnp_card, dev)
212#define pnp_for_each_card(card) \
213 for((card) = global_to_pnp_card(pnp_cards.next); \
214 (card) != global_to_pnp_card(&pnp_cards); \
215 (card) = global_to_pnp_card((card)->global_list.next))
216
217struct pnp_card_link {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700218 struct pnp_card *card;
219 struct pnp_card_driver *driver;
220 void *driver_data;
Takashi Iwai4c98cfe2005-11-29 09:09:32 +0100221 pm_message_t pm_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222};
223
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700224static inline void *pnp_get_card_drvdata(struct pnp_card_link *pcard)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225{
226 return pcard->driver_data;
227}
228
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700229static inline void pnp_set_card_drvdata(struct pnp_card_link *pcard, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230{
231 pcard->driver_data = data;
232}
233
234struct pnp_dev {
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700235 struct device dev; /* Driver Model device interface */
David Brownell2e17c552007-05-08 00:25:29 -0700236 u64 dma_mask;
Bjorn Helgaas544451a2008-04-10 21:29:28 -0700237 unsigned int number; /* used as an index, must be unique */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 int status;
239
240 struct list_head global_list; /* node in global list of devices */
241 struct list_head protocol_list; /* node in list of device's protocol */
242 struct list_head card_list; /* node in card's list of devices */
243 struct list_head rdev_list; /* node in cards list of requested devices */
244
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700245 struct pnp_protocol *protocol;
246 struct pnp_card *card; /* card the device is attached to, none if NULL */
247 struct pnp_driver *driver;
248 struct pnp_card_link *card_link;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700250 struct pnp_id *id; /* supported EISA IDs */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
252 int active;
253 int capabilities;
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -0600254 unsigned int num_dependent_sets;
Bjorn Helgaasaee3ad82008-06-27 16:56:57 -0600255 struct list_head resources;
Bjorn Helgaas1f32ca32008-06-27 16:57:17 -0600256 struct list_head options;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
258 char name[PNP_NAME_LEN]; /* contains a human-readable name */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700259 int flags; /* used by protocols */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */
261 void *data;
262};
263
264#define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list)
265#define card_to_pnp_dev(n) list_entry(n, struct pnp_dev, card_list)
266#define protocol_to_pnp_dev(n) list_entry(n, struct pnp_dev, protocol_list)
267#define to_pnp_dev(n) container_of(n, struct pnp_dev, dev)
268#define pnp_for_each_dev(dev) \
269 for((dev) = global_to_pnp_dev(pnp_global.next); \
270 (dev) != global_to_pnp_dev(&pnp_global); \
271 (dev) = global_to_pnp_dev((dev)->global_list.next))
272#define card_for_each_dev(card,dev) \
273 for((dev) = card_to_pnp_dev((card)->devices.next); \
274 (dev) != card_to_pnp_dev(&(card)->devices); \
275 (dev) = card_to_pnp_dev((dev)->card_list.next))
276#define pnp_dev_name(dev) (dev)->name
277
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700278static inline void *pnp_get_drvdata(struct pnp_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279{
280 return dev_get_drvdata(&pdev->dev);
281}
282
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700283static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284{
285 dev_set_drvdata(&pdev->dev, data);
286}
287
288struct pnp_fixup {
289 char id[7];
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700290 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291};
292
293/* config parameters */
294#define PNP_CONFIG_NORMAL 0x0001
295#define PNP_CONFIG_FORCE 0x0002 /* disables validity checking */
296
297/* capabilities */
298#define PNP_READ 0x0001
299#define PNP_WRITE 0x0002
300#define PNP_DISABLE 0x0004
301#define PNP_CONFIGURABLE 0x0008
302#define PNP_REMOVABLE 0x0010
303
Bjorn Helgaas402b3102007-10-16 23:31:09 -0700304#define pnp_can_read(dev) (((dev)->protocol->get) && \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 ((dev)->capabilities & PNP_READ))
Bjorn Helgaas402b3102007-10-16 23:31:09 -0700306#define pnp_can_write(dev) (((dev)->protocol->set) && \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 ((dev)->capabilities & PNP_WRITE))
Bjorn Helgaas402b3102007-10-16 23:31:09 -0700308#define pnp_can_disable(dev) (((dev)->protocol->disable) && \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 ((dev)->capabilities & PNP_DISABLE))
310#define pnp_can_configure(dev) ((!(dev)->active) && \
311 ((dev)->capabilities & PNP_CONFIGURABLE))
312
313#ifdef CONFIG_ISAPNP
314extern struct pnp_protocol isapnp_protocol;
315#define pnp_device_is_isapnp(dev) ((dev)->protocol == (&isapnp_protocol))
316#else
317#define pnp_device_is_isapnp(dev) 0
318#endif
Daniel Walkerb3bd86e2008-02-06 01:40:04 -0800319extern struct mutex pnp_res_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
321#ifdef CONFIG_PNPBIOS
322extern struct pnp_protocol pnpbios_protocol;
323#define pnp_device_is_pnpbios(dev) ((dev)->protocol == (&pnpbios_protocol))
324#else
325#define pnp_device_is_pnpbios(dev) 0
326#endif
327
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328/* status */
329#define PNP_READY 0x0000
330#define PNP_ATTACHED 0x0001
331#define PNP_BUSY 0x0002
332#define PNP_FAULTY 0x0004
333
334/* isapnp specific macros */
335
336#define isapnp_card_number(dev) ((dev)->card ? (dev)->card->number : -1)
337#define isapnp_csn_number(dev) ((dev)->number)
338
339/*
340 * Driver Management
341 */
342
343struct pnp_id {
344 char id[PNP_ID_LEN];
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700345 struct pnp_id *next;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346};
347
348struct pnp_driver {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700349 char *name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 const struct pnp_device_id *id_table;
351 unsigned int flags;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700352 int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id);
353 void (*remove) (struct pnp_dev *dev);
354 int (*suspend) (struct pnp_dev *dev, pm_message_t state);
355 int (*resume) (struct pnp_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 struct device_driver driver;
357};
358
359#define to_pnp_driver(drv) container_of(drv, struct pnp_driver, driver)
360
361struct pnp_card_driver {
362 struct list_head global_list;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700363 char *name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 const struct pnp_card_device_id *id_table;
365 unsigned int flags;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700366 int (*probe) (struct pnp_card_link *card,
367 const struct pnp_card_device_id *card_id);
368 void (*remove) (struct pnp_card_link *card);
369 int (*suspend) (struct pnp_card_link *card, pm_message_t state);
370 int (*resume) (struct pnp_card_link *card);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 struct pnp_driver link;
372};
373
374#define to_pnp_card_driver(drv) container_of(drv, struct pnp_card_driver, link)
375
376/* pnp driver flags */
377#define PNP_DRIVER_RES_DO_NOT_CHANGE 0x0001 /* do not change the state of the device */
378#define PNP_DRIVER_RES_DISABLE 0x0003 /* ensure the device is disabled */
379
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380/*
381 * Protocol Management
382 */
383
384struct pnp_protocol {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700385 struct list_head protocol_list;
386 char *name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
388 /* resource control functions */
Bjorn Helgaas59284cb2008-04-28 16:34:05 -0600389 int (*get) (struct pnp_dev *dev);
390 int (*set) (struct pnp_dev *dev);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700391 int (*disable) (struct pnp_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
Shaohua Lifc30e682007-07-20 10:03:20 +0800393 /* protocol specific suspend/resume */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700394 int (*suspend) (struct pnp_dev * dev, pm_message_t state);
395 int (*resume) (struct pnp_dev * dev);
Shaohua Lifc30e682007-07-20 10:03:20 +0800396
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 /* used by pnp layer only (look but don't touch) */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700398 unsigned char number; /* protocol number */
399 struct device dev; /* link to driver model */
400 struct list_head cards;
401 struct list_head devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402};
403
404#define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list)
405#define protocol_for_each_card(protocol,card) \
406 for((card) = protocol_to_pnp_card((protocol)->cards.next); \
407 (card) != protocol_to_pnp_card(&(protocol)->cards); \
408 (card) = protocol_to_pnp_card((card)->protocol_list.next))
409#define protocol_for_each_dev(protocol,dev) \
410 for((dev) = protocol_to_pnp_dev((protocol)->devices.next); \
411 (dev) != protocol_to_pnp_dev(&(protocol)->devices); \
412 (dev) = protocol_to_pnp_dev((dev)->protocol_list.next))
413
David Brownellcbcdc1d2007-02-10 01:45:13 -0800414extern struct bus_type pnp_bus_type;
415
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416#if defined(CONFIG_PNP)
417
418/* device management */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419int pnp_device_attach(struct pnp_dev *pnp_dev);
420void pnp_device_detach(struct pnp_dev *pnp_dev);
421extern struct list_head pnp_global;
Bjorn Helgaas8f81dd12007-05-08 00:35:54 -0700422extern int pnp_platform_devices;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
424/* multidevice card support */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700425struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
426 const char *id, struct pnp_dev *from);
427void pnp_release_card_device(struct pnp_dev *dev);
428int pnp_register_card_driver(struct pnp_card_driver *drv);
429void pnp_unregister_card_driver(struct pnp_card_driver *drv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430extern struct list_head pnp_cards;
431
432/* resource management */
Bjorn Helgaas57fd51a2008-06-27 16:57:01 -0600433int pnp_possible_config(struct pnp_dev *dev, int type, resource_size_t base,
434 resource_size_t size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435int pnp_auto_config_dev(struct pnp_dev *dev);
Pierre Ossman68094e32005-11-29 09:09:32 +0100436int pnp_start_dev(struct pnp_dev *dev);
437int pnp_stop_dev(struct pnp_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438int pnp_activate_dev(struct pnp_dev *dev);
439int pnp_disable_dev(struct pnp_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
441/* protocol helpers */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700442int pnp_is_active(struct pnp_dev *dev);
443int compare_pnp_id(struct pnp_id *pos, const char *id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444int pnp_register_driver(struct pnp_driver *drv);
445void pnp_unregister_driver(struct pnp_driver *drv);
446
447#else
448
449/* device management */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700450static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
451static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700452
Bjorn Helgaas8f81dd12007-05-08 00:35:54 -0700453#define pnp_platform_devices 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
455/* multidevice card support */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700456static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
457static inline void pnp_release_card_device(struct pnp_dev *dev) { }
458static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }
459static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460
461/* resource management */
Bjorn Helgaas57fd51a2008-06-27 16:57:01 -0600462static inline int pnp_possible_config(struct pnp_dev *dev, int type,
463 resource_size_t base,
464 resource_size_t size) { return 0; }
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700465static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700466static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
467static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
468static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
469static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
471/* protocol helpers */
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700472static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
473static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700474static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
475static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476
477#endif /* CONFIG_PNP */
478
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479#define pnp_err(format, arg...) printk(KERN_ERR "pnp: " format "\n" , ## arg)
480#define pnp_info(format, arg...) printk(KERN_INFO "pnp: " format "\n" , ## arg)
481#define pnp_warn(format, arg...) printk(KERN_WARNING "pnp: " format "\n" , ## arg)
482
Bjorn Helgaase139aa52005-09-06 15:17:05 -0700483#ifdef CONFIG_PNP_DEBUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484#define pnp_dbg(format, arg...) printk(KERN_DEBUG "pnp: " format "\n" , ## arg)
485#else
486#define pnp_dbg(format, arg...) do {} while (0)
487#endif
488
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489#endif /* _LINUX_PNP_H */