Commit 008238b5 authored by Len Brown's avatar Len Brown

Merge branch 'pnp' into release

parents 96916090 dfd2e1b4
extern spinlock_t pnp_lock; extern spinlock_t pnp_lock;
void *pnp_alloc(long size); void *pnp_alloc(long size);
int pnp_register_protocol(struct pnp_protocol *protocol);
void pnp_unregister_protocol(struct pnp_protocol *protocol);
#define PNP_EISA_ID_MASK 0x7fffffff
void pnp_eisa_id_to_string(u32 id, char *str);
struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid);
struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid);
int pnp_add_device(struct pnp_dev *dev);
struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
int pnp_interface_attach_device(struct pnp_dev *dev); int pnp_interface_attach_device(struct pnp_dev *dev);
int pnp_add_card(struct pnp_card *card);
struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id);
void pnp_remove_card(struct pnp_card *card);
int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
void pnp_remove_card_device(struct pnp_dev *dev);
struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
int priority);
int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option,
struct pnp_irq *data);
int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option,
struct pnp_dma *data);
int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option,
struct pnp_port *data);
int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option,
struct pnp_mem *data);
void pnp_init_resources(struct pnp_dev *dev);
void pnp_fixup_device(struct pnp_dev *dev); void pnp_fixup_device(struct pnp_dev *dev);
void pnp_free_option(struct pnp_option *option); void pnp_free_option(struct pnp_option *option);
int __pnp_add_device(struct pnp_dev *dev); int __pnp_add_device(struct pnp_dev *dev);
void __pnp_remove_device(struct pnp_dev *dev); void __pnp_remove_device(struct pnp_dev *dev);
int pnp_check_port(struct pnp_dev * dev, int idx); int pnp_check_port(struct pnp_dev *dev, struct resource *res);
int pnp_check_mem(struct pnp_dev * dev, int idx); int pnp_check_mem(struct pnp_dev *dev, struct resource *res);
int pnp_check_irq(struct pnp_dev * dev, int idx); int pnp_check_irq(struct pnp_dev *dev, struct resource *res);
int pnp_check_dma(struct pnp_dev * dev, int idx); int pnp_check_dma(struct pnp_dev *dev, struct resource *res);
void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
void pnp_init_resource(struct resource *res);
struct pnp_resource *pnp_get_pnp_resource(struct pnp_dev *dev,
unsigned int type, unsigned int num);
#define PNP_MAX_PORT 40
#define PNP_MAX_MEM 24
#define PNP_MAX_IRQ 2
#define PNP_MAX_DMA 2
struct pnp_resource {
struct resource res;
unsigned int index; /* ISAPNP config register index */
};
struct pnp_resource_table {
struct pnp_resource port[PNP_MAX_PORT];
struct pnp_resource mem[PNP_MAX_MEM];
struct pnp_resource dma[PNP_MAX_DMA];
struct pnp_resource irq[PNP_MAX_IRQ];
};
struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
int flags);
struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma,
int flags);
struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev,
resource_size_t start,
resource_size_t end, int flags);
struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev,
resource_size_t start,
resource_size_t end, int flags);
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/ctype.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pnp.h> #include <linux/pnp.h>
#include "base.h" #include "base.h"
...@@ -100,19 +101,33 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv) ...@@ -100,19 +101,33 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
* @id: pointer to a pnp_id structure * @id: pointer to a pnp_id structure
* @card: pointer to the desired card * @card: pointer to the desired card
*/ */
int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id)
{ {
struct pnp_id *ptr; struct pnp_id *dev_id, *ptr;
id->next = NULL; dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
if (!dev_id)
return NULL;
dev_id->id[0] = id[0];
dev_id->id[1] = id[1];
dev_id->id[2] = id[2];
dev_id->id[3] = tolower(id[3]);
dev_id->id[4] = tolower(id[4]);
dev_id->id[5] = tolower(id[5]);
dev_id->id[6] = tolower(id[6]);
dev_id->id[7] = '\0';
dev_id->next = NULL;
ptr = card->id; ptr = card->id;
while (ptr && ptr->next) while (ptr && ptr->next)
ptr = ptr->next; ptr = ptr->next;
if (ptr) if (ptr)
ptr->next = id; ptr->next = dev_id;
else else
card->id = id; card->id = dev_id;
return 0;
return dev_id;
} }
static void pnp_free_card_ids(struct pnp_card *card) static void pnp_free_card_ids(struct pnp_card *card)
...@@ -136,6 +151,31 @@ static void pnp_release_card(struct device *dmdev) ...@@ -136,6 +151,31 @@ static void pnp_release_card(struct device *dmdev)
kfree(card); kfree(card);
} }
struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnpid)
{
struct pnp_card *card;
struct pnp_id *dev_id;
card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL);
if (!card)
return NULL;
card->protocol = protocol;
card->number = id;
card->dev.parent = &card->protocol->dev;
sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
card->number);
dev_id = pnp_add_card_id(card, pnpid);
if (!dev_id) {
kfree(card);
return NULL;
}
return card;
}
static ssize_t pnp_show_card_name(struct device *dmdev, static ssize_t pnp_show_card_name(struct device *dmdev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -191,9 +231,6 @@ int pnp_add_card(struct pnp_card *card) ...@@ -191,9 +231,6 @@ int pnp_add_card(struct pnp_card *card)
int error; int error;
struct list_head *pos, *temp; struct list_head *pos, *temp;
sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
card->number);
card->dev.parent = &card->protocol->dev;
card->dev.bus = NULL; card->dev.bus = NULL;
card->dev.release = &pnp_release_card; card->dev.release = &pnp_release_card;
error = device_register(&card->dev); error = device_register(&card->dev);
......
...@@ -106,18 +106,53 @@ static void pnp_release_device(struct device *dmdev) ...@@ -106,18 +106,53 @@ static void pnp_release_device(struct device *dmdev)
pnp_free_option(dev->independent); pnp_free_option(dev->independent);
pnp_free_option(dev->dependent); pnp_free_option(dev->dependent);
pnp_free_ids(dev); pnp_free_ids(dev);
kfree(dev->res);
kfree(dev); kfree(dev);
} }
int __pnp_add_device(struct pnp_dev *dev) struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid)
{ {
int ret; struct pnp_dev *dev;
struct pnp_id *dev_id;
pnp_fixup_device(dev); dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
if (!dev)
return NULL;
dev->res = kzalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
if (!dev->res) {
kfree(dev);
return NULL;
}
dev->protocol = protocol;
dev->number = id;
dev->dma_mask = DMA_24BIT_MASK;
dev->dev.parent = &dev->protocol->dev;
dev->dev.bus = &pnp_bus_type; dev->dev.bus = &pnp_bus_type;
dev->dev.dma_mask = &dev->dma_mask; dev->dev.dma_mask = &dev->dma_mask;
dev->dma_mask = dev->dev.coherent_dma_mask = DMA_24BIT_MASK; dev->dev.coherent_dma_mask = dev->dma_mask;
dev->dev.release = &pnp_release_device; dev->dev.release = &pnp_release_device;
sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number,
dev->number);
dev_id = pnp_add_id(dev, pnpid);
if (!dev_id) {
kfree(dev->res);
kfree(dev);
return NULL;
}
return dev;
}
int __pnp_add_device(struct pnp_dev *dev)
{
int ret;
pnp_fixup_device(dev);
dev->status = PNP_READY; dev->status = PNP_READY;
spin_lock(&pnp_lock); spin_lock(&pnp_lock);
list_add_tail(&dev->global_list, &pnp_global); list_add_tail(&dev->global_list, &pnp_global);
...@@ -145,9 +180,6 @@ int pnp_add_device(struct pnp_dev *dev) ...@@ -145,9 +180,6 @@ int pnp_add_device(struct pnp_dev *dev)
if (dev->card) if (dev->card)
return -EINVAL; return -EINVAL;
dev->dev.parent = &dev->protocol->dev;
sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number,
dev->number);
ret = __pnp_add_device(dev); ret = __pnp_add_device(dev);
if (ret) if (ret)
return ret; return ret;
......
...@@ -226,22 +226,36 @@ void pnp_unregister_driver(struct pnp_driver *drv) ...@@ -226,22 +226,36 @@ void pnp_unregister_driver(struct pnp_driver *drv)
/** /**
* pnp_add_id - adds an EISA id to the specified device * pnp_add_id - adds an EISA id to the specified device
* @id: pointer to a pnp_id structure
* @dev: pointer to the desired device * @dev: pointer to the desired device
* @id: pointer to an EISA id string
*/ */
int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id)
{ {
struct pnp_id *ptr; struct pnp_id *dev_id, *ptr;
id->next = NULL; dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
if (!dev_id)
return NULL;
dev_id->id[0] = id[0];
dev_id->id[1] = id[1];
dev_id->id[2] = id[2];
dev_id->id[3] = tolower(id[3]);
dev_id->id[4] = tolower(id[4]);
dev_id->id[5] = tolower(id[5]);
dev_id->id[6] = tolower(id[6]);
dev_id->id[7] = '\0';
dev_id->next = NULL;
ptr = dev->id; ptr = dev->id;
while (ptr && ptr->next) while (ptr && ptr->next)
ptr = ptr->next; ptr = ptr->next;
if (ptr) if (ptr)
ptr->next = id; ptr->next = dev_id;
else else
dev->id = id; dev->id = dev_id;
return 0;
return dev_id;
} }
EXPORT_SYMBOL(pnp_register_driver); EXPORT_SYMBOL(pnp_register_driver);
......
...@@ -248,6 +248,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, ...@@ -248,6 +248,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev,
char *buf) char *buf)
{ {
struct pnp_dev *dev = to_pnp_dev(dmdev); struct pnp_dev *dev = to_pnp_dev(dmdev);
struct resource *res;
int i, ret; int i, ret;
pnp_info_buffer_t *buffer; pnp_info_buffer_t *buffer;
...@@ -267,50 +268,46 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, ...@@ -267,50 +268,46 @@ static ssize_t pnp_show_current_resources(struct device *dmdev,
else else
pnp_printf(buffer, "disabled\n"); pnp_printf(buffer, "disabled\n");
for (i = 0; i < PNP_MAX_PORT; i++) { for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
if (pnp_port_valid(dev, i)) { if (pnp_resource_valid(res)) {
pnp_printf(buffer, "io"); pnp_printf(buffer, "io");
if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) if (res->flags & IORESOURCE_DISABLED)
pnp_printf(buffer, " disabled\n"); pnp_printf(buffer, " disabled\n");
else else
pnp_printf(buffer, " 0x%llx-0x%llx\n", pnp_printf(buffer, " 0x%llx-0x%llx\n",
(unsigned long long) (unsigned long long) res->start,
pnp_port_start(dev, i), (unsigned long long) res->end);
(unsigned long long)pnp_port_end(dev,
i));
} }
} }
for (i = 0; i < PNP_MAX_MEM; i++) { for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
if (pnp_mem_valid(dev, i)) { if (pnp_resource_valid(res)) {
pnp_printf(buffer, "mem"); pnp_printf(buffer, "mem");
if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) if (res->flags & IORESOURCE_DISABLED)
pnp_printf(buffer, " disabled\n"); pnp_printf(buffer, " disabled\n");
else else
pnp_printf(buffer, " 0x%llx-0x%llx\n", pnp_printf(buffer, " 0x%llx-0x%llx\n",
(unsigned long long) (unsigned long long) res->start,
pnp_mem_start(dev, i), (unsigned long long) res->end);
(unsigned long long)pnp_mem_end(dev,
i));
} }
} }
for (i = 0; i < PNP_MAX_IRQ; i++) { for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
if (pnp_irq_valid(dev, i)) { if (pnp_resource_valid(res)) {
pnp_printf(buffer, "irq"); pnp_printf(buffer, "irq");
if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) if (res->flags & IORESOURCE_DISABLED)
pnp_printf(buffer, " disabled\n"); pnp_printf(buffer, " disabled\n");
else else
pnp_printf(buffer, " %lld\n", pnp_printf(buffer, " %lld\n",
(unsigned long long)pnp_irq(dev, i)); (unsigned long long) res->start);
} }
} }
for (i = 0; i < PNP_MAX_DMA; i++) { for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
if (pnp_dma_valid(dev, i)) { if (pnp_resource_valid(res)) {
pnp_printf(buffer, "dma"); pnp_printf(buffer, "dma");
if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) if (res->flags & IORESOURCE_DISABLED)
pnp_printf(buffer, " disabled\n"); pnp_printf(buffer, " disabled\n");
else else
pnp_printf(buffer, " %lld\n", pnp_printf(buffer, " %lld\n",
(unsigned long long)pnp_dma(dev, i)); (unsigned long long) res->start);
} }
} }
ret = (buffer->curr - buf); ret = (buffer->curr - buf);
...@@ -323,8 +320,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, ...@@ -323,8 +320,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
const char *ubuf, size_t count) const char *ubuf, size_t count)
{ {
struct pnp_dev *dev = to_pnp_dev(dmdev); struct pnp_dev *dev = to_pnp_dev(dmdev);
struct pnp_resource *pnp_res;
char *buf = (void *)ubuf; char *buf = (void *)ubuf;
int retval = 0; int retval = 0;
resource_size_t start, end;
if (dev->status & PNP_ATTACHED) { if (dev->status & PNP_ATTACHED) {
retval = -EBUSY; retval = -EBUSY;
...@@ -351,20 +350,20 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, ...@@ -351,20 +350,20 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
if (!strnicmp(buf, "auto", 4)) { if (!strnicmp(buf, "auto", 4)) {
if (dev->active) if (dev->active)
goto done; goto done;
pnp_init_resource_table(&dev->res); pnp_init_resources(dev);
retval = pnp_auto_config_dev(dev); retval = pnp_auto_config_dev(dev);
goto done; goto done;
} }
if (!strnicmp(buf, "clear", 5)) { if (!strnicmp(buf, "clear", 5)) {
if (dev->active) if (dev->active)
goto done; goto done;
pnp_init_resource_table(&dev->res); pnp_init_resources(dev);
goto done; goto done;
} }
if (!strnicmp(buf, "get", 3)) { if (!strnicmp(buf, "get", 3)) {
mutex_lock(&pnp_res_mutex); mutex_lock(&pnp_res_mutex);
if (pnp_can_read(dev)) if (pnp_can_read(dev))
dev->protocol->get(dev, &dev->res); dev->protocol->get(dev);
mutex_unlock(&pnp_res_mutex); mutex_unlock(&pnp_res_mutex);
goto done; goto done;
} }
...@@ -373,7 +372,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, ...@@ -373,7 +372,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
if (dev->active) if (dev->active)
goto done; goto done;
buf += 3; buf += 3;
pnp_init_resource_table(&dev->res); pnp_init_resources(dev);
mutex_lock(&pnp_res_mutex); mutex_lock(&pnp_res_mutex);
while (1) { while (1) {
while (isspace(*buf)) while (isspace(*buf))
...@@ -382,76 +381,60 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, ...@@ -382,76 +381,60 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
buf += 2; buf += 2;
while (isspace(*buf)) while (isspace(*buf))
++buf; ++buf;
dev->res.port_resource[nport].start = start = simple_strtoul(buf, &buf, 0);
simple_strtoul(buf, &buf, 0);
while (isspace(*buf)) while (isspace(*buf))
++buf; ++buf;
if (*buf == '-') { if (*buf == '-') {
buf += 1; buf += 1;
while (isspace(*buf)) while (isspace(*buf))
++buf; ++buf;
dev->res.port_resource[nport].end = end = simple_strtoul(buf, &buf, 0);
simple_strtoul(buf, &buf, 0);
} else } else
dev->res.port_resource[nport].end = end = start;
dev->res.port_resource[nport].start; pnp_res = pnp_add_io_resource(dev, start, end,
dev->res.port_resource[nport].flags = 0);
IORESOURCE_IO; if (pnp_res)
nport++; pnp_res->index = nport++;
if (nport >= PNP_MAX_PORT)
break;
continue; continue;
} }
if (!strnicmp(buf, "mem", 3)) { if (!strnicmp(buf, "mem", 3)) {
buf += 3; buf += 3;
while (isspace(*buf)) while (isspace(*buf))
++buf; ++buf;
dev->res.mem_resource[nmem].start = start = simple_strtoul(buf, &buf, 0);
simple_strtoul(buf, &buf, 0);
while (isspace(*buf)) while (isspace(*buf))
++buf; ++buf;
if (*buf == '-') { if (*buf == '-') {
buf += 1; buf += 1;
while (isspace(*buf)) while (isspace(*buf))
++buf; ++buf;
dev->res.mem_resource[nmem].end = end = simple_strtoul(buf, &buf, 0);
simple_strtoul(buf, &buf, 0);
} else } else
dev->res.mem_resource[nmem].end = end = start;
dev->res.mem_resource[nmem].start; pnp_res = pnp_add_mem_resource(dev, start, end,
dev->res.mem_resource[nmem].flags = 0);
IORESOURCE_MEM; if (pnp_res)
nmem++; pnp_res->index = nmem++;
if (nmem >= PNP_MAX_MEM)
break;
continue; continue;
} }
if (!strnicmp(buf, "irq", 3)) { if (!strnicmp(buf, "irq", 3)) {
buf += 3; buf += 3;
while (isspace(*buf)) while (isspace(*buf))
++buf; ++buf;
dev->res.irq_resource[nirq].start = start = simple_strtoul(buf, &buf, 0);
dev->res.irq_resource[nirq].end = pnp_res = pnp_add_irq_resource(dev, start, 0);
simple_strtoul(buf, &buf, 0); if (pnp_res)
dev->res.irq_resource[nirq].flags = nirq++;
IORESOURCE_IRQ;
nirq++;
if (nirq >= PNP_MAX_IRQ)
break;
continue; continue;
} }
if (!strnicmp(buf, "dma", 3)) { if (!strnicmp(buf, "dma", 3)) {
buf += 3; buf += 3;
while (isspace(*buf)) while (isspace(*buf))
++buf; ++buf;
dev->res.dma_resource[ndma].start = start = simple_strtoul(buf, &buf, 0);
dev->res.dma_resource[ndma].end = pnp_res = pnp_add_dma_resource(dev, start, 0);
simple_strtoul(buf, &buf, 0); if (pnp_res)
dev->res.dma_resource[ndma].flags = pnp_res->index = ndma++;
IORESOURCE_DMA;
ndma++;
if (ndma >= PNP_MAX_DMA)
break;
continue; continue;
} }
break; break;
......
...@@ -5,3 +5,7 @@ ...@@ -5,3 +5,7 @@
isapnp-proc-$(CONFIG_PROC_FS) = proc.o isapnp-proc-$(CONFIG_PROC_FS) = proc.o
obj-y := core.o compat.o $(isapnp-proc-y) obj-y := core.o compat.o $(isapnp-proc-y)
ifeq ($(CONFIG_PNP_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
This diff is collapsed.
This diff is collapsed.
...@@ -3,3 +3,7 @@ ...@@ -3,3 +3,7 @@
# #
obj-y := core.o rsparser.o obj-y := core.o rsparser.o
ifeq ($(CONFIG_PNP_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
#include <acpi/actypes.h> #include <acpi/actypes.h>
#include "../base.h"
#include "pnpacpi.h" #include "pnpacpi.h"
static int num = 0; static int num = 0;
...@@ -72,40 +73,24 @@ static int __init ispnpidacpi(char *id) ...@@ -72,40 +73,24 @@ static int __init ispnpidacpi(char *id)
return 1; return 1;
} }
static void __init pnpidacpi_to_pnpid(char *id, char *str) static int pnpacpi_get_resources(struct pnp_dev *dev)
{ {
str[0] = id[0]; dev_dbg(&dev->dev, "get resources\n");
str[1] = id[1]; return pnpacpi_parse_allocated_resource(dev);
str[2] = id[2];
str[3] = tolower(id[3]);
str[4] = tolower(id[4]);
str[5] = tolower(id[5]);
str[6] = tolower(id[6]);
str[7] = '\0';
} }
static int pnpacpi_get_resources(struct pnp_dev *dev, static int pnpacpi_set_resources(struct pnp_dev *dev)
struct pnp_resource_table *res)
{
acpi_status status;
status = pnpacpi_parse_allocated_resource((acpi_handle) dev->data,
&dev->res);
return ACPI_FAILURE(status) ? -ENODEV : 0;
}
static int pnpacpi_set_resources(struct pnp_dev *dev,
struct pnp_resource_table *res)
{ {
acpi_handle handle = dev->data; acpi_handle handle = dev->data;
struct acpi_buffer buffer; struct acpi_buffer buffer;
int ret = 0; int ret;
acpi_status status; acpi_status status;
ret = pnpacpi_build_resource_template(handle, &buffer); dev_dbg(&dev->dev, "set resources\n");
ret = pnpacpi_build_resource_template(dev, &buffer);
if (ret) if (ret)
return ret; return ret;
ret = pnpacpi_encode_resources(res, &buffer); ret = pnpacpi_encode_resources(dev, &buffer);
if (ret) { if (ret) {
kfree(buffer.pointer); kfree(buffer.pointer);
return ret; return ret;
...@@ -163,7 +148,6 @@ static int __init pnpacpi_add_device(struct acpi_device *device) ...@@ -163,7 +148,6 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
{ {
acpi_handle temp = NULL; acpi_handle temp = NULL;
acpi_status status; acpi_status status;
struct pnp_id *dev_id;
struct pnp_dev *dev; struct pnp_dev *dev;
status = acpi_get_handle(device->handle, "_CRS", &temp); status = acpi_get_handle(device->handle, "_CRS", &temp);
...@@ -171,11 +155,10 @@ static int __init pnpacpi_add_device(struct acpi_device *device) ...@@ -171,11 +155,10 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
is_exclusive_device(device)) is_exclusive_device(device))
return 0; return 0;
dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device));
if (!dev) { if (!dev)
pnp_err("Out of memory");
return -ENOMEM; return -ENOMEM;
}
dev->data = device->handle; dev->data = device->handle;
/* .enabled means the device can decode the resources */ /* .enabled means the device can decode the resources */
dev->active = device->status.enabled; dev->active = device->status.enabled;
...@@ -191,44 +174,17 @@ static int __init pnpacpi_add_device(struct acpi_device *device) ...@@ -191,44 +174,17 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
if (ACPI_SUCCESS(status)) if (ACPI_SUCCESS(status))
dev->capabilities |= PNP_DISABLE; dev->capabilities |= PNP_DISABLE;
dev->protocol = &pnpacpi_protocol;
if (strlen(acpi_device_name(device))) if (strlen(acpi_device_name(device)))
strncpy(dev->name, acpi_device_name(device), sizeof(dev->name)); strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
else else
strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name)); strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
dev->number = num; if (dev->active)
pnpacpi_parse_allocated_resource(dev);
/* set the initial values for the PnP device */
dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
if (!dev_id)
goto err;
pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id);
pnp_add_id(dev_id, dev);
if (dev->active) {
/* parse allocated resource */
status = pnpacpi_parse_allocated_resource(device->handle,
&dev->res);
if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s",
dev_id->id);
goto err1;
}
}
if (dev->capabilities & PNP_CONFIGURABLE) { if (dev->capabilities & PNP_CONFIGURABLE)
status = pnpacpi_parse_resource_option_data(device->handle, pnpacpi_parse_resource_option_data(dev);
dev);
if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s",
dev_id->id);
goto err1;
}
}
/* parse compatible ids */
if (device->flags.compatible_ids) { if (device->flags.compatible_ids) {
struct acpi_compatible_id_list *cid_list = device->pnp.cid_list; struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
int i; int i;
...@@ -236,27 +192,17 @@ static int __init pnpacpi_add_device(struct acpi_device *device) ...@@ -236,27 +192,17 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
for (i = 0; i < cid_list->count; i++) { for (i = 0; i < cid_list->count; i++) {
if (!ispnpidacpi(cid_list->id[i].value)) if (!ispnpidacpi(cid_list->id[i].value))
continue; continue;
dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); pnp_add_id(dev, cid_list->id[i].value);
if (!dev_id)
continue;
pnpidacpi_to_pnpid(cid_list->id[i].value, dev_id->id);
pnp_add_id(dev_id, dev);
} }
} }
/* clear out the damaged flags */ /* clear out the damaged flags */
if (!dev->active) if (!dev->active)
pnp_init_resource_table(&dev->res); pnp_init_resources(dev);
pnp_add_device(dev); pnp_add_device(dev);
num++; num++;
return AE_OK; return AE_OK;
err1:
kfree(dev_id);
err:
kfree(dev);
return -EINVAL;
} }
static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/pnp.h> #include <linux/pnp.h>
acpi_status pnpacpi_parse_allocated_resource(acpi_handle, struct pnp_resource_table*); int pnpacpi_parse_allocated_resource(struct pnp_dev *);
acpi_status pnpacpi_parse_resource_option_data(acpi_handle, struct pnp_dev*); int pnpacpi_parse_resource_option_data(struct pnp_dev *);
int pnpacpi_encode_resources(struct pnp_resource_table *, struct acpi_buffer *); int pnpacpi_encode_resources(struct pnp_dev *, struct acpi_buffer *);
int pnpacpi_build_resource_template(acpi_handle, struct acpi_buffer*); int pnpacpi_build_resource_template(struct pnp_dev *, struct acpi_buffer *);
#endif #endif
This diff is collapsed.
...@@ -5,3 +5,7 @@ ...@@ -5,3 +5,7 @@
pnpbios-proc-$(CONFIG_PNPBIOS_PROC_FS) = proc.o pnpbios-proc-$(CONFIG_PNPBIOS_PROC_FS) = proc.o
obj-y := core.o bioscalls.o rsparser.o $(pnpbios-proc-y) obj-y := core.o bioscalls.o rsparser.o $(pnpbios-proc-y)
ifeq ($(CONFIG_PNP_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pnpbios.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/pnp.h> #include <linux/pnp.h>
#include <linux/mm.h> #include <linux/mm.h>
......
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pnpbios.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/pnp.h> #include <linux/pnp.h>
#include <linux/mm.h> #include <linux/mm.h>
...@@ -69,6 +68,7 @@ ...@@ -69,6 +68,7 @@
#include <asm/system.h> #include <asm/system.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include "../base.h"
#include "pnpbios.h" #include "pnpbios.h"
/* /*
...@@ -203,8 +203,7 @@ static int pnp_dock_thread(void *unused) ...@@ -203,8 +203,7 @@ static int pnp_dock_thread(void *unused)
#endif /* CONFIG_HOTPLUG */ #endif /* CONFIG_HOTPLUG */
static int pnpbios_get_resources(struct pnp_dev *dev, static int pnpbios_get_resources(struct pnp_dev *dev)
struct pnp_resource_table *res)
{ {
u8 nodenum = dev->number; u8 nodenum = dev->number;
struct pnp_bios_node *node; struct pnp_bios_node *node;
...@@ -212,6 +211,7 @@ static int pnpbios_get_resources(struct pnp_dev *dev, ...@@ -212,6 +211,7 @@ static int pnpbios_get_resources(struct pnp_dev *dev,
if (!pnpbios_is_dynamic(dev)) if (!pnpbios_is_dynamic(dev))
return -EPERM; return -EPERM;
dev_dbg(&dev->dev, "get resources\n");
node = kzalloc(node_info.max_node_size, GFP_KERNEL); node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return -1; return -1;
...@@ -219,14 +219,13 @@ static int pnpbios_get_resources(struct pnp_dev *dev, ...@@ -219,14 +219,13 @@ static int pnpbios_get_resources(struct pnp_dev *dev,
kfree(node); kfree(node);
return -ENODEV; return -ENODEV;
} }
pnpbios_read_resources_from_node(res, node); pnpbios_read_resources_from_node(dev, node);
dev->active = pnp_is_active(dev); dev->active = pnp_is_active(dev);
kfree(node); kfree(node);
return 0; return 0;
} }
static int pnpbios_set_resources(struct pnp_dev *dev, static int pnpbios_set_resources(struct pnp_dev *dev)
struct pnp_resource_table *res)
{ {
u8 nodenum = dev->number; u8 nodenum = dev->number;
struct pnp_bios_node *node; struct pnp_bios_node *node;
...@@ -235,6 +234,7 @@ static int pnpbios_set_resources(struct pnp_dev *dev, ...@@ -235,6 +234,7 @@ static int pnpbios_set_resources(struct pnp_dev *dev,
if (!pnpbios_is_dynamic(dev)) if (!pnpbios_is_dynamic(dev))
return -EPERM; return -EPERM;
dev_dbg(&dev->dev, "set resources\n");
node = kzalloc(node_info.max_node_size, GFP_KERNEL); node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return -1; return -1;
...@@ -242,7 +242,7 @@ static int pnpbios_set_resources(struct pnp_dev *dev, ...@@ -242,7 +242,7 @@ static int pnpbios_set_resources(struct pnp_dev *dev,
kfree(node); kfree(node);
return -ENODEV; return -ENODEV;
} }
if (pnpbios_write_resources_to_node(res, node) < 0) { if (pnpbios_write_resources_to_node(dev, node) < 0) {
kfree(node); kfree(node);
return -1; return -1;
} }
...@@ -317,7 +317,6 @@ static int __init insert_device(struct pnp_bios_node *node) ...@@ -317,7 +317,6 @@ static int __init insert_device(struct pnp_bios_node *node)
{ {
struct list_head *pos; struct list_head *pos;
struct pnp_dev *dev; struct pnp_dev *dev;
struct pnp_id *dev_id;
char id[8]; char id[8];
/* check if the device is already added */ /* check if the device is already added */
...@@ -327,20 +326,11 @@ static int __init insert_device(struct pnp_bios_node *node) ...@@ -327,20 +326,11 @@ static int __init insert_device(struct pnp_bios_node *node)
return -1; return -1;
} }
dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); pnp_eisa_id_to_string(node->eisa_id & PNP_EISA_ID_MASK, id);
dev = pnp_alloc_dev(&pnpbios_protocol, node->handle, id);
if (!dev) if (!dev)
return -1; return -1;
dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
if (!dev_id) {
kfree(dev);
return -1;
}
dev->number = node->handle;
pnpid32_to_pnpid(node->eisa_id, id);
memcpy(dev_id->id, id, 7);
pnp_add_id(dev_id, dev);
pnpbios_parse_data_stream(dev, node); pnpbios_parse_data_stream(dev, node);
dev->active = pnp_is_active(dev); dev->active = pnp_is_active(dev);
dev->flags = node->flags; dev->flags = node->flags;
...@@ -353,11 +343,10 @@ static int __init insert_device(struct pnp_bios_node *node) ...@@ -353,11 +343,10 @@ static int __init insert_device(struct pnp_bios_node *node)
dev->capabilities |= PNP_WRITE; dev->capabilities |= PNP_WRITE;
if (dev->flags & PNPBIOS_REMOVABLE) if (dev->flags & PNPBIOS_REMOVABLE)
dev->capabilities |= PNP_REMOVABLE; dev->capabilities |= PNP_REMOVABLE;
dev->protocol = &pnpbios_protocol;
/* clear out the damaged flags */ /* clear out the damaged flags */
if (!dev->active) if (!dev->active)
pnp_init_resource_table(&dev->res); pnp_init_resources(dev);
pnp_add_device(dev); pnp_add_device(dev);
pnpbios_interface_attach_device(node); pnpbios_interface_attach_device(node);
......
...@@ -2,6 +2,142 @@ ...@@ -2,6 +2,142 @@
* pnpbios.h - contains local definitions * pnpbios.h - contains local definitions
*/ */
/*
* Include file for the interface to a PnP BIOS
*
* Original BIOS code (C) 1998 Christian Schmidt (chr.schmidt@tu-bs.de)
* PnP handler parts (c) 1998 Tom Lees <tom@lpsg.demon.co.uk>
* Minor reorganizations by David Hinds <dahinds@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Return codes
*/
#define PNP_SUCCESS 0x00
#define PNP_NOT_SET_STATICALLY 0x7f
#define PNP_UNKNOWN_FUNCTION 0x81
#define PNP_FUNCTION_NOT_SUPPORTED 0x82
#define PNP_INVALID_HANDLE 0x83
#define PNP_BAD_PARAMETER 0x84
#define PNP_SET_FAILED 0x85
#define PNP_EVENTS_NOT_PENDING 0x86
#define PNP_SYSTEM_NOT_DOCKED 0x87
#define PNP_NO_ISA_PNP_CARDS 0x88
#define PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES 0x89
#define PNP_CONFIG_CHANGE_FAILED_NO_BATTERY 0x8a
#define PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT 0x8b
#define PNP_BUFFER_TOO_SMALL 0x8c
#define PNP_USE_ESCD_SUPPORT 0x8d
#define PNP_MESSAGE_NOT_SUPPORTED 0x8e
#define PNP_HARDWARE_ERROR 0x8f
#define ESCD_SUCCESS 0x00
#define ESCD_IO_ERROR_READING 0x55
#define ESCD_INVALID 0x56
#define ESCD_BUFFER_TOO_SMALL 0x59
#define ESCD_NVRAM_TOO_SMALL 0x5a
#define ESCD_FUNCTION_NOT_SUPPORTED 0x81
/*
* Events that can be received by "get event"
*/
#define PNPEV_ABOUT_TO_CHANGE_CONFIG 0x0001
#define PNPEV_DOCK_CHANGED 0x0002
#define PNPEV_SYSTEM_DEVICE_CHANGED 0x0003
#define PNPEV_CONFIG_CHANGED_FAILED 0x0004
#define PNPEV_UNKNOWN_SYSTEM_EVENT 0xffff
/* 0x8000 through 0xfffe are OEM defined */
/*
* Messages that should be sent through "send message"
*/
#define PNPMSG_OK 0x00
#define PNPMSG_ABORT 0x01
#define PNPMSG_UNDOCK_DEFAULT_ACTION 0x40
#define PNPMSG_POWER_OFF 0x41
#define PNPMSG_PNP_OS_ACTIVE 0x42
#define PNPMSG_PNP_OS_INACTIVE 0x43
/*
* Plug and Play BIOS flags
*/
#define PNPBIOS_NO_DISABLE 0x0001
#define PNPBIOS_NO_CONFIG 0x0002
#define PNPBIOS_OUTPUT 0x0004
#define PNPBIOS_INPUT 0x0008
#define PNPBIOS_BOOTABLE 0x0010
#define PNPBIOS_DOCK 0x0020
#define PNPBIOS_REMOVABLE 0x0040
#define pnpbios_is_static(x) (((x)->flags & 0x0100) == 0x0000)
#define pnpbios_is_dynamic(x) ((x)->flags & 0x0080)
/*
* Function Parameters
*/
#define PNPMODE_STATIC 1
#define PNPMODE_DYNAMIC 0
/* 0x8000 through 0xffff are OEM defined */
#pragma pack(1)
struct pnp_dev_node_info {
__u16 no_nodes;
__u16 max_node_size;
};
struct pnp_docking_station_info {
__u32 location_id;
__u32 serial;
__u16 capabilities;
};
struct pnp_isa_config_struc {
__u8 revision;
__u8 no_csns;
__u16 isa_rd_data_port;
__u16 reserved;
};
struct escd_info_struc {
__u16 min_escd_write_size;
__u16 escd_size;
__u32 nv_storage_base;
};
struct pnp_bios_node {
__u16 size;
__u8 handle;
__u32 eisa_id;
__u8 type_code[3];
__u16 flags;
__u8 data[0];
};
#pragma pack()
/* non-exported */
extern struct pnp_dev_node_info node_info;
extern int pnp_bios_dev_node_info(struct pnp_dev_node_info *data);
extern int pnp_bios_get_dev_node(u8 *nodenum, char config,
struct pnp_bios_node *data);
extern int pnp_bios_set_dev_node(u8 nodenum, char config,
struct pnp_bios_node *data);
extern int pnp_bios_get_stat_res(char *info);
extern int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data);
extern int pnp_bios_escd_info(struct escd_info_struc *data);
extern int pnp_bios_read_escd(char *data, u32 nvram_base);
extern int pnp_bios_dock_station_info(struct pnp_docking_station_info *data);
#pragma pack(1) #pragma pack(1)
union pnp_bios_install_struct { union pnp_bios_install_struct {
struct { struct {
...@@ -28,8 +164,8 @@ extern int pnp_bios_present(void); ...@@ -28,8 +164,8 @@ extern int pnp_bios_present(void);
extern int pnpbios_dont_use_current_config; extern int pnpbios_dont_use_current_config;
extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node); extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node);
extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node); extern int pnpbios_read_resources_from_node(struct pnp_dev *dev, struct pnp_bios_node *node);
extern int pnpbios_write_resources_to_node(struct pnp_resource_table *res, struct pnp_bios_node * node); extern int pnpbios_write_resources_to_node(struct pnp_dev *dev, struct pnp_bios_node *node);
extern void pnpid32_to_pnpid(u32 id, char *str); extern void pnpid32_to_pnpid(u32 id, char *str);
extern void pnpbios_print_status(const char * module, u16 status); extern void pnpbios_print_status(const char * module, u16 status);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/pnpbios.h> #include <linux/pnp.h>
#include <linux/init.h> #include <linux/init.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
......
This diff is collapsed.
...@@ -117,6 +117,7 @@ static void quirk_sb16audio_resources(struct pnp_dev *dev) ...@@ -117,6 +117,7 @@ static void quirk_sb16audio_resources(struct pnp_dev *dev)
static void quirk_system_pci_resources(struct pnp_dev *dev) static void quirk_system_pci_resources(struct pnp_dev *dev)
{ {
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
struct resource *res;
resource_size_t pnp_start, pnp_end, pci_start, pci_end; resource_size_t pnp_start, pnp_end, pci_start, pci_end;
int i, j; int i, j;
...@@ -137,13 +138,15 @@ static void quirk_system_pci_resources(struct pnp_dev *dev) ...@@ -137,13 +138,15 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
pci_start = pci_resource_start(pdev, i); pci_start = pci_resource_start(pdev, i);
pci_end = pci_resource_end(pdev, i); pci_end = pci_resource_end(pdev, i);
for (j = 0; j < PNP_MAX_MEM; j++) { for (j = 0;
if (!pnp_mem_valid(dev, j) || (res = pnp_get_resource(dev, IORESOURCE_MEM, j));
pnp_mem_len(dev, j) == 0) j++) {
if (res->flags & IORESOURCE_UNSET ||
(res->start == 0 && res->end == 0))
continue; continue;
pnp_start = pnp_mem_start(dev, j); pnp_start = res->start;
pnp_end = pnp_mem_end(dev, j); pnp_end = res->end;
/* /*
* If the PNP region doesn't overlap the PCI * If the PNP region doesn't overlap the PCI
...@@ -176,7 +179,7 @@ static void quirk_system_pci_resources(struct pnp_dev *dev) ...@@ -176,7 +179,7 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
pci_name(pdev), i, pci_name(pdev), i,
(unsigned long long) pci_start, (unsigned long long) pci_start,
(unsigned long long) pci_end); (unsigned long long) pci_end);
pnp_mem_flags(dev, j) = 0; res->flags = 0;
} }
} }
} }
......
This diff is collapsed.
...@@ -25,3 +25,66 @@ int pnp_is_active(struct pnp_dev *dev) ...@@ -25,3 +25,66 @@ int pnp_is_active(struct pnp_dev *dev)
} }
EXPORT_SYMBOL(pnp_is_active); EXPORT_SYMBOL(pnp_is_active);
/*
* Functionally similar to acpi_ex_eisa_id_to_string(), but that's
* buried in the ACPI CA, and we can't depend on it being present.
*/
void pnp_eisa_id_to_string(u32 id, char *str)
{
id = be32_to_cpu(id);
/*
* According to the specs, the first three characters are five-bit
* compressed ASCII, and the left-over high order bit should be zero.
* However, the Linux ISAPNP code historically used six bits for the
* first character, and there seem to be IDs that depend on that,
* e.g., "nEC8241" in the Linux 8250_pnp serial driver and the
* FreeBSD sys/pc98/cbus/sio_cbus.c driver.
*/
str[0] = 'A' + ((id >> 26) & 0x3f) - 1;
str[1] = 'A' + ((id >> 21) & 0x1f) - 1;
str[2] = 'A' + ((id >> 16) & 0x1f) - 1;
str[3] = hex_asc((id >> 12) & 0xf);
str[4] = hex_asc((id >> 8) & 0xf);
str[5] = hex_asc((id >> 4) & 0xf);
str[6] = hex_asc((id >> 0) & 0xf);
str[7] = '\0';
}
void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc)
{
#ifdef DEBUG
struct resource *res;
int i;
dev_dbg(&dev->dev, "current resources: %s\n", desc);
for (i = 0; i < PNP_MAX_IRQ; i++) {
res = pnp_get_resource(dev, IORESOURCE_IRQ, i);
if (res && !(res->flags & IORESOURCE_UNSET))
dev_dbg(&dev->dev, " irq %lld flags %#lx\n",
(unsigned long long) res->start, res->flags);
}
for (i = 0; i < PNP_MAX_DMA; i++) {
res = pnp_get_resource(dev, IORESOURCE_DMA, i);
if (res && !(res->flags & IORESOURCE_UNSET))
dev_dbg(&dev->dev, " dma %lld flags %#lx\n",
(unsigned long long) res->start, res->flags);
}
for (i = 0; i < PNP_MAX_PORT; i++) {
res = pnp_get_resource(dev, IORESOURCE_IO, i);
if (res && !(res->flags & IORESOURCE_UNSET))
dev_dbg(&dev->dev, " io %#llx-%#llx flags %#lx\n",
(unsigned long long) res->start,
(unsigned long long) res->end, res->flags);
}
for (i = 0; i < PNP_MAX_MEM; i++) {
res = pnp_get_resource(dev, IORESOURCE_MEM, i);
if (res && !(res->flags & IORESOURCE_UNSET))
dev_dbg(&dev->dev, " mem %#llx-%#llx flags %#lx\n",
(unsigned long long) res->start,
(unsigned long long) res->end, res->flags);
}
#endif
}
...@@ -56,14 +56,15 @@ static void reserve_range(struct pnp_dev *dev, resource_size_t start, ...@@ -56,14 +56,15 @@ static void reserve_range(struct pnp_dev *dev, resource_size_t start,
static void reserve_resources_of_dev(struct pnp_dev *dev) static void reserve_resources_of_dev(struct pnp_dev *dev)
{ {
struct resource *res;
int i; int i;
for (i = 0; i < PNP_MAX_PORT; i++) { for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
if (!pnp_port_valid(dev, i)) if (res->flags & IORESOURCE_UNSET)
continue; continue;
if (pnp_port_start(dev, i) == 0) if (res->start == 0)
continue; /* disabled */ continue; /* disabled */
if (pnp_port_start(dev, i) < 0x100) if (res->start < 0x100)
/* /*
* Below 0x100 is only standard PC hardware * Below 0x100 is only standard PC hardware
* (pics, kbd, timer, dma, ...) * (pics, kbd, timer, dma, ...)
...@@ -73,19 +74,17 @@ static void reserve_resources_of_dev(struct pnp_dev *dev) ...@@ -73,19 +74,17 @@ static void reserve_resources_of_dev(struct pnp_dev *dev)
* So, do nothing * So, do nothing
*/ */
continue; continue;
if (pnp_port_end(dev, i) < pnp_port_start(dev, i)) if (res->end < res->start)
continue; /* invalid */ continue; /* invalid */
reserve_range(dev, pnp_port_start(dev, i), reserve_range(dev, res->start, res->end, 1);
pnp_port_end(dev, i), 1);
} }
for (i = 0; i < PNP_MAX_MEM; i++) { for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
if (!pnp_mem_valid(dev, i)) if (res->flags & IORESOURCE_UNSET)
continue; continue;
reserve_range(dev, pnp_mem_start(dev, i), reserve_range(dev, res->start, res->end, 0);
pnp_mem_end(dev, i), 0);
} }
} }
......
...@@ -854,11 +854,12 @@ cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) ...@@ -854,11 +854,12 @@ cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
* don't define the IRQ. It should always be safe to * don't define the IRQ. It should always be safe to
* hardcode it in these cases * hardcode it in these cases
*/ */
return cmos_do_probe(&pnp->dev, &pnp->res.port_resource[0], 8); return cmos_do_probe(&pnp->dev,
pnp_get_resource(pnp, IORESOURCE_IO, 0), 8);
else else
return cmos_do_probe(&pnp->dev, return cmos_do_probe(&pnp->dev,
&pnp->res.port_resource[0], pnp_get_resource(pnp, IORESOURCE_IO, 0),
pnp->res.irq_resource[0].start); pnp_irq(pnp, 0));
} }
static void __exit cmos_pnp_remove(struct pnp_dev *pnp) static void __exit cmos_pnp_remove(struct pnp_dev *pnp)
......
...@@ -25,16 +25,6 @@ ...@@ -25,16 +25,6 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/pnp.h> #include <linux/pnp.h>
/*
* Configuration registers (TODO: change by specification)
*/
#define ISAPNP_CFG_ACTIVATE 0x30 /* byte */
#define ISAPNP_CFG_MEM 0x40 /* 4 * dword */
#define ISAPNP_CFG_PORT 0x60 /* 8 * word */
#define ISAPNP_CFG_IRQ 0x70 /* 2 * word */
#define ISAPNP_CFG_DMA 0x74 /* 2 * byte */
/* /*
* *
*/ */
......
This diff is collapsed.
/*
* Include file for the interface to a PnP BIOS
*
* Original BIOS code (C) 1998 Christian Schmidt (chr.schmidt@tu-bs.de)
* PnP handler parts (c) 1998 Tom Lees <tom@lpsg.demon.co.uk>
* Minor reorganizations by David Hinds <dahinds@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LINUX_PNPBIOS_H
#define _LINUX_PNPBIOS_H
#ifdef __KERNEL__
#include <linux/types.h>
#include <linux/pnp.h>
/*
* Return codes
*/
#define PNP_SUCCESS 0x00
#define PNP_NOT_SET_STATICALLY 0x7f
#define PNP_UNKNOWN_FUNCTION 0x81
#define PNP_FUNCTION_NOT_SUPPORTED 0x82
#define PNP_INVALID_HANDLE 0x83
#define PNP_BAD_PARAMETER 0x84
#define PNP_SET_FAILED 0x85
#define PNP_EVENTS_NOT_PENDING 0x86
#define PNP_SYSTEM_NOT_DOCKED 0x87
#define PNP_NO_ISA_PNP_CARDS 0x88
#define PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES 0x89
#define PNP_CONFIG_CHANGE_FAILED_NO_BATTERY 0x8a
#define PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT 0x8b
#define PNP_BUFFER_TOO_SMALL 0x8c
#define PNP_USE_ESCD_SUPPORT 0x8d
#define PNP_MESSAGE_NOT_SUPPORTED 0x8e
#define PNP_HARDWARE_ERROR 0x8f
#define ESCD_SUCCESS 0x00
#define ESCD_IO_ERROR_READING 0x55
#define ESCD_INVALID 0x56
#define ESCD_BUFFER_TOO_SMALL 0x59
#define ESCD_NVRAM_TOO_SMALL 0x5a
#define ESCD_FUNCTION_NOT_SUPPORTED 0x81
/*
* Events that can be received by "get event"
*/
#define PNPEV_ABOUT_TO_CHANGE_CONFIG 0x0001
#define PNPEV_DOCK_CHANGED 0x0002
#define PNPEV_SYSTEM_DEVICE_CHANGED 0x0003
#define PNPEV_CONFIG_CHANGED_FAILED 0x0004
#define PNPEV_UNKNOWN_SYSTEM_EVENT 0xffff
/* 0x8000 through 0xfffe are OEM defined */
/*
* Messages that should be sent through "send message"
*/
#define PNPMSG_OK 0x00
#define PNPMSG_ABORT 0x01
#define PNPMSG_UNDOCK_DEFAULT_ACTION 0x40
#define PNPMSG_POWER_OFF 0x41
#define PNPMSG_PNP_OS_ACTIVE 0x42
#define PNPMSG_PNP_OS_INACTIVE 0x43
/*
* Plug and Play BIOS flags
*/
#define PNPBIOS_NO_DISABLE 0x0001
#define PNPBIOS_NO_CONFIG 0x0002
#define PNPBIOS_OUTPUT 0x0004
#define PNPBIOS_INPUT 0x0008
#define PNPBIOS_BOOTABLE 0x0010
#define PNPBIOS_DOCK 0x0020
#define PNPBIOS_REMOVABLE 0x0040
#define pnpbios_is_static(x) (((x)->flags & 0x0100) == 0x0000)
#define pnpbios_is_dynamic(x) ((x)->flags & 0x0080)
/*
* Function Parameters
*/
#define PNPMODE_STATIC 1
#define PNPMODE_DYNAMIC 0
/* 0x8000 through 0xffff are OEM defined */
#pragma pack(1)
struct pnp_dev_node_info {
__u16 no_nodes;
__u16 max_node_size;
};
struct pnp_docking_station_info {
__u32 location_id;
__u32 serial;
__u16 capabilities;
};
struct pnp_isa_config_struc {
__u8 revision;
__u8 no_csns;
__u16 isa_rd_data_port;
__u16 reserved;
};
struct escd_info_struc {
__u16 min_escd_write_size;
__u16 escd_size;
__u32 nv_storage_base;
};
struct pnp_bios_node {
__u16 size;
__u8 handle;
__u32 eisa_id;
__u8 type_code[3];
__u16 flags;
__u8 data[0];
};
#pragma pack()
#ifdef CONFIG_PNPBIOS
/* non-exported */
extern struct pnp_dev_node_info node_info;
extern int pnp_bios_dev_node_info(struct pnp_dev_node_info *data);
extern int pnp_bios_get_dev_node(u8 *nodenum, char config,
struct pnp_bios_node *data);
extern int pnp_bios_set_dev_node(u8 nodenum, char config,
struct pnp_bios_node *data);
extern int pnp_bios_get_stat_res(char *info);
extern int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data);
extern int pnp_bios_escd_info(struct escd_info_struc *data);
extern int pnp_bios_read_escd(char *data, u32 nvram_base);
extern int pnp_bios_dock_station_info(struct pnp_docking_station_info *data);
#endif /* CONFIG_PNPBIOS */
#endif /* __KERNEL__ */
#endif /* _LINUX_PNPBIOS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment