PNP: add pnp_resource_type_name() helper function
[linux-2.6.git] / drivers / pnp / base.h
1 extern spinlock_t pnp_lock;
2 void *pnp_alloc(long size);
3
4 int pnp_register_protocol(struct pnp_protocol *protocol);
5 void pnp_unregister_protocol(struct pnp_protocol *protocol);
6
7 #define PNP_EISA_ID_MASK 0x7fffffff
8 void pnp_eisa_id_to_string(u32 id, char *str);
9 struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid);
10 struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid);
11
12 int pnp_add_device(struct pnp_dev *dev);
13 struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
14 int pnp_interface_attach_device(struct pnp_dev *dev);
15
16 int pnp_add_card(struct pnp_card *card);
17 struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id);
18 void pnp_remove_card(struct pnp_card *card);
19 int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
20 void pnp_remove_card_device(struct pnp_dev *dev);
21
22 struct pnp_option *pnp_build_option(int priority);
23 struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
24 struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
25                                                  int priority);
26 int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option,
27                               struct pnp_irq *data);
28 int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option,
29                               struct pnp_dma *data);
30 int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option,
31                                struct pnp_port *data);
32 int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option,
33                               struct pnp_mem *data);
34 void pnp_init_resources(struct pnp_dev *dev);
35
36 void pnp_fixup_device(struct pnp_dev *dev);
37 void pnp_free_option(struct pnp_option *option);
38 int __pnp_add_device(struct pnp_dev *dev);
39 void __pnp_remove_device(struct pnp_dev *dev);
40
41 int pnp_check_port(struct pnp_dev *dev, struct resource *res);
42 int pnp_check_mem(struct pnp_dev *dev, struct resource *res);
43 int pnp_check_irq(struct pnp_dev *dev, struct resource *res);
44 int pnp_check_dma(struct pnp_dev *dev, struct resource *res);
45
46 char *pnp_resource_type_name(struct resource *res);
47 void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
48
49 void pnp_init_resource(struct resource *res);
50 int pnp_resource_type(struct resource *res);
51
52 struct pnp_resource *pnp_get_pnp_resource(struct pnp_dev *dev,
53                                           unsigned int type, unsigned int num);
54
55 #define PNP_MAX_PORT            40
56 #define PNP_MAX_MEM             24
57 #define PNP_MAX_IRQ              2
58 #define PNP_MAX_DMA              2
59
60 struct pnp_resource {
61         struct resource res;
62 };
63
64 struct pnp_resource_table {
65         struct pnp_resource port[PNP_MAX_PORT];
66         struct pnp_resource mem[PNP_MAX_MEM];
67         struct pnp_resource dma[PNP_MAX_DMA];
68         struct pnp_resource irq[PNP_MAX_IRQ];
69 };
70
71 struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
72                                           int flags);
73 struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma,
74                                           int flags);
75 struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev,
76                                          resource_size_t start,
77                                          resource_size_t end, int flags);
78 struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev,
79                                           resource_size_t start,
80                                           resource_size_t end, int flags);