10 #include <linux/errno.h>
11 #include <linux/module.h>
13 #include <linux/kernel.h>
15 #include <linux/bitmap.h>
27 pnp_dbg(&dev->
dev,
" io %d already set to %#llx-%#llx "
28 "flags %#lx\n", idx, (
unsigned long long) res->
start,
29 (
unsigned long long) res->
end, res->
flags);
52 "(min %#llx max %#llx)\n", idx,
53 (
unsigned long long) rule->
min,
54 (
unsigned long long) rule->
max);
64 static int pnp_assign_mem(
struct pnp_dev *dev,
struct pnp_mem *rule,
int idx)
70 pnp_dbg(&dev->
dev,
" mem %d already set to %#llx-%#llx "
71 "flags %#lx\n", idx, (
unsigned long long) res->
start,
72 (
unsigned long long) res->
end, res->
flags);
104 "(min %#llx max %#llx)\n", idx,
105 (
unsigned long long) rule->
min,
106 (
unsigned long long) rule->
max);
116 static int pnp_assign_irq(
struct pnp_dev *dev,
struct pnp_irq *rule,
int idx)
122 static unsigned short xtab[16] = {
123 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2
128 pnp_dbg(&dev->
dev,
" irq %d already set to %d flags %#lx\n",
140 pnp_dbg(&dev->
dev,
" irq %d disabled\n", idx);
150 for (i = 0; i < 16; i++) {
162 pnp_dbg(&dev->
dev,
" irq %d disabled (optional)\n", idx);
166 pnp_dbg(&dev->
dev,
" couldn't assign irq %d\n", idx);
174 #ifdef CONFIG_ISA_DMA_API
175 static int pnp_assign_dma(
struct pnp_dev *dev,
struct pnp_dma *rule,
int idx)
181 static unsigned short xtab[8] = {
182 1, 3, 5, 6, 7, 0, 2, 4
187 pnp_dbg(&dev->
dev,
" dma %d already set to %d flags %#lx\n",
197 for (i = 0; i < 8; i++) {
198 if (rule->
map & (1 << xtab[i])) {
200 if (pnp_check_dma(dev, res))
204 #ifdef MAX_DMA_CHANNELS
221 static void pnp_clean_resource_table(
struct pnp_dev *dev)
236 static int pnp_assign_resources(
struct pnp_dev *dev,
int set)
239 int nport = 0, nmem = 0, nirq = 0;
243 pnp_dbg(&dev->
dev,
"pnp_assign_resources, try dependent set %d\n",
set);
245 pnp_clean_resource_table(dev);
248 if (pnp_option_is_dependent(option) &&
249 pnp_option_set(option) !=
set)
252 switch (option->
type) {
254 ret = pnp_assign_port(dev, &option->
u.
port, nport++);
257 ret = pnp_assign_mem(dev, &option->
u.
mem, nmem++);
260 ret = pnp_assign_irq(dev, &option->
u.
irq, nirq++);
262 #ifdef CONFIG_ISA_DMA_API
264 ret = pnp_assign_dma(dev, &option->
u.
dma, ndma++);
277 pnp_dbg(&dev->
dev,
"pnp_assign_resources failed (%d)\n", ret);
278 pnp_clean_resource_table(dev);
293 pnp_dbg(&dev->
dev,
"configuration not supported\n");
297 ret = pnp_assign_resources(dev, 0);
302 ret = pnp_assign_resources(dev, i);
307 dev_err(&dev->
dev,
"unable to assign resources\n");
320 pnp_dbg(&dev->
dev,
"activation not supported\n");
343 pnp_dbg(&dev->
dev,
"disabling not supported\n");
346 if (dev->
protocol->disable(dev) < 0) {
401 pnp_clean_resource_table(dev);