Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | extern spinlock_t pnp_lock; |
| 2 | void *pnp_alloc(long size); |
Bjorn Helgaas | 62cfb29 | 2008-04-28 16:34:40 -0600 | [diff] [blame] | 3 | |
| 4 | int pnp_register_protocol(struct pnp_protocol *protocol); |
| 5 | void pnp_unregister_protocol(struct pnp_protocol *protocol); |
| 6 | |
Bjorn Helgaas | 25eb846 | 2008-04-28 16:33:53 -0600 | [diff] [blame] | 7 | #define PNP_EISA_ID_MASK 0x7fffffff |
| 8 | void pnp_eisa_id_to_string(u32 id, char *str); |
Bjorn Helgaas | bda1e4e | 2008-04-28 16:33:54 -0600 | [diff] [blame] | 9 | struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid); |
Bjorn Helgaas | 6bf2aab | 2008-04-28 16:33:58 -0600 | [diff] [blame] | 10 | struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid); |
Bjorn Helgaas | 62cfb29 | 2008-04-28 16:34:40 -0600 | [diff] [blame] | 11 | |
| 12 | int pnp_add_device(struct pnp_dev *dev); |
Bjorn Helgaas | 772defc | 2008-04-28 16:33:52 -0600 | [diff] [blame] | 13 | struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | int pnp_interface_attach_device(struct pnp_dev *dev); |
Bjorn Helgaas | 62cfb29 | 2008-04-28 16:34:40 -0600 | [diff] [blame] | 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 | |
Bjorn Helgaas | a1802c4 | 2008-06-27 16:57:04 -0600 | [diff] [blame] | 22 | struct pnp_port { |
Bjorn Helgaas | 169aaff | 2008-06-27 16:57:06 -0600 | [diff] [blame^] | 23 | resource_size_t min; /* min base number */ |
| 24 | resource_size_t max; /* max base number */ |
| 25 | resource_size_t align; /* align boundary */ |
| 26 | resource_size_t size; /* size of range */ |
Bjorn Helgaas | a1802c4 | 2008-06-27 16:57:04 -0600 | [diff] [blame] | 27 | unsigned char flags; /* port flags */ |
| 28 | unsigned char pad; /* pad */ |
| 29 | struct pnp_port *next; /* next port */ |
| 30 | }; |
| 31 | |
| 32 | #define PNP_IRQ_NR 256 |
Bjorn Helgaas | 7aefff5 | 2008-06-27 16:57:05 -0600 | [diff] [blame] | 33 | typedef struct { DECLARE_BITMAP(bits, PNP_IRQ_NR); } pnp_irq_mask_t; |
| 34 | |
Bjorn Helgaas | a1802c4 | 2008-06-27 16:57:04 -0600 | [diff] [blame] | 35 | struct pnp_irq { |
Bjorn Helgaas | 7aefff5 | 2008-06-27 16:57:05 -0600 | [diff] [blame] | 36 | pnp_irq_mask_t map; /* bitmap for IRQ lines */ |
Bjorn Helgaas | a1802c4 | 2008-06-27 16:57:04 -0600 | [diff] [blame] | 37 | unsigned char flags; /* IRQ flags */ |
| 38 | unsigned char pad; /* pad */ |
| 39 | struct pnp_irq *next; /* next IRQ */ |
| 40 | }; |
| 41 | |
| 42 | struct pnp_dma { |
| 43 | unsigned char map; /* bitmask for DMA channels */ |
| 44 | unsigned char flags; /* DMA flags */ |
| 45 | struct pnp_dma *next; /* next port */ |
| 46 | }; |
| 47 | |
| 48 | struct pnp_mem { |
Bjorn Helgaas | 169aaff | 2008-06-27 16:57:06 -0600 | [diff] [blame^] | 49 | resource_size_t min; /* min base number */ |
| 50 | resource_size_t max; /* max base number */ |
| 51 | resource_size_t align; /* align boundary */ |
| 52 | resource_size_t size; /* size of range */ |
Bjorn Helgaas | a1802c4 | 2008-06-27 16:57:04 -0600 | [diff] [blame] | 53 | unsigned char flags; /* memory flags */ |
| 54 | unsigned char pad; /* pad */ |
| 55 | struct pnp_mem *next; /* next memory resource */ |
| 56 | }; |
| 57 | |
| 58 | #define PNP_RES_PRIORITY_PREFERRED 0 |
| 59 | #define PNP_RES_PRIORITY_ACCEPTABLE 1 |
| 60 | #define PNP_RES_PRIORITY_FUNCTIONAL 2 |
| 61 | #define PNP_RES_PRIORITY_INVALID 65535 |
| 62 | |
| 63 | struct pnp_option { |
| 64 | unsigned short priority; /* priority */ |
| 65 | struct pnp_port *port; /* first port */ |
| 66 | struct pnp_irq *irq; /* first IRQ */ |
| 67 | struct pnp_dma *dma; /* first DMA */ |
| 68 | struct pnp_mem *mem; /* first memory resource */ |
| 69 | struct pnp_option *next; /* used to chain dependent resources */ |
| 70 | }; |
| 71 | |
Rene Herman | bc033c9 | 2008-05-14 16:05:34 -0700 | [diff] [blame] | 72 | struct pnp_option *pnp_build_option(int priority); |
Bjorn Helgaas | 62cfb29 | 2008-04-28 16:34:40 -0600 | [diff] [blame] | 73 | struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev); |
| 74 | struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, |
| 75 | int priority); |
| 76 | int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option, |
| 77 | struct pnp_irq *data); |
| 78 | int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option, |
| 79 | struct pnp_dma *data); |
| 80 | int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, |
| 81 | struct pnp_port *data); |
| 82 | int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option, |
| 83 | struct pnp_mem *data); |
| 84 | void pnp_init_resources(struct pnp_dev *dev); |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | void pnp_fixup_device(struct pnp_dev *dev); |
| 87 | void pnp_free_option(struct pnp_option *option); |
| 88 | int __pnp_add_device(struct pnp_dev *dev); |
| 89 | void __pnp_remove_device(struct pnp_dev *dev); |
| 90 | |
Bjorn Helgaas | f5d94ff | 2008-04-28 16:34:22 -0600 | [diff] [blame] | 91 | int pnp_check_port(struct pnp_dev *dev, struct resource *res); |
| 92 | int pnp_check_mem(struct pnp_dev *dev, struct resource *res); |
| 93 | int pnp_check_irq(struct pnp_dev *dev, struct resource *res); |
| 94 | int pnp_check_dma(struct pnp_dev *dev, struct resource *res); |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame] | 95 | |
Bjorn Helgaas | 9fdee4e | 2008-06-27 16:56:55 -0600 | [diff] [blame] | 96 | char *pnp_resource_type_name(struct resource *res); |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame] | 97 | void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc); |
Bjorn Helgaas | d948a8d | 2008-04-28 16:34:13 -0600 | [diff] [blame] | 98 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 99 | void pnp_free_resources(struct pnp_dev *dev); |
Bjorn Helgaas | 940e98d | 2008-06-27 16:56:54 -0600 | [diff] [blame] | 100 | int pnp_resource_type(struct resource *res); |
Bjorn Helgaas | 02d83b5 | 2008-04-28 16:34:28 -0600 | [diff] [blame] | 101 | |
Bjorn Helgaas | 784f01d | 2008-04-28 16:34:30 -0600 | [diff] [blame] | 102 | struct pnp_resource { |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 103 | struct list_head list; |
Bjorn Helgaas | 784f01d | 2008-04-28 16:34:30 -0600 | [diff] [blame] | 104 | struct resource res; |
| 105 | }; |
| 106 | |
Bjorn Helgaas | aee3ad8 | 2008-06-27 16:56:57 -0600 | [diff] [blame] | 107 | void pnp_free_resource(struct pnp_resource *pnp_res); |
Bjorn Helgaas | dbddd03 | 2008-04-28 16:34:34 -0600 | [diff] [blame] | 108 | |
| 109 | struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq, |
| 110 | int flags); |
Bjorn Helgaas | dc16f5f | 2008-04-28 16:34:35 -0600 | [diff] [blame] | 111 | struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma, |
| 112 | int flags); |
Bjorn Helgaas | cc8c2e3 | 2008-04-28 16:34:36 -0600 | [diff] [blame] | 113 | struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev, |
| 114 | resource_size_t start, |
| 115 | resource_size_t end, int flags); |
Bjorn Helgaas | d6180f3 | 2008-04-28 16:34:37 -0600 | [diff] [blame] | 116 | struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev, |
| 117 | resource_size_t start, |
| 118 | resource_size_t end, int flags); |