Commit ee0bb666 authored by Russell King's avatar Russell King

Merge flint.arm.linux.org.uk:/usr/src/bk/linux-2.6

into flint.arm.linux.org.uk:/usr/src/bk/linux-2.6-serial
parents cedc5632 67db702a
...@@ -18,18 +18,33 @@ ...@@ -18,18 +18,33 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/serial.h> #include <asm/serial.h>
static void acpi_serial_address(struct serial_struct *req, static acpi_status acpi_serial_mmio(struct serial_struct *req,
struct acpi_resource_address32 *addr32) struct acpi_resource_address64 *addr)
{ {
unsigned long size; unsigned long size;
size = addr32->max_address_range - addr32->min_address_range + 1; size = addr->max_address_range - addr->min_address_range + 1;
req->iomap_base = addr32->min_address_range; req->iomap_base = addr->min_address_range;
req->iomem_base = ioremap(req->iomap_base, size); req->iomem_base = ioremap(req->iomap_base, size);
if (!req->iomem_base) {
printk(KERN_ERR "%s: couldn't ioremap 0x%lx-0x%lx\n",
__FUNCTION__, addr->min_address_range,
addr->max_address_range);
return AE_ERROR;
}
req->io_type = SERIAL_IO_MEM; req->io_type = SERIAL_IO_MEM;
return AE_OK;
} }
static void acpi_serial_irq(struct serial_struct *req, static acpi_status acpi_serial_port(struct serial_struct *req,
struct acpi_resource_io *io)
{
req->port = io->min_base_address;
req->io_type = SERIAL_IO_PORT;
return AE_OK;
}
static acpi_status acpi_serial_ext_irq(struct serial_struct *req,
struct acpi_resource_ext_irq *ext_irq) struct acpi_resource_ext_irq *ext_irq)
{ {
if (ext_irq->number_of_interrupts > 0) { if (ext_irq->number_of_interrupts > 0) {
...@@ -40,45 +55,71 @@ static void acpi_serial_irq(struct serial_struct *req, ...@@ -40,45 +55,71 @@ static void acpi_serial_irq(struct serial_struct *req,
req->irq = ext_irq->interrupts[0]; req->irq = ext_irq->interrupts[0];
#endif #endif
} }
return AE_OK;
}
static acpi_status acpi_serial_irq(struct serial_struct *req,
struct acpi_resource_irq *irq)
{
if (irq->number_of_interrupts > 0) {
#ifdef CONFIG_IA64
req->irq = acpi_register_irq(irq->interrupts[0],
irq->active_high_low, irq->edge_level);
#else
req->irq = irq->interrupts[0];
#endif
}
return AE_OK;
}
static acpi_status acpi_serial_resource(struct acpi_resource *res, void *data)
{
struct serial_struct *serial_req = (struct serial_struct *) data;
struct acpi_resource_address64 addr;
acpi_status status;
status = acpi_resource_to_address64(res, &addr);
if (ACPI_SUCCESS(status))
return acpi_serial_mmio(serial_req, &addr);
else if (res->id == ACPI_RSTYPE_IO)
return acpi_serial_port(serial_req, &res->data.io);
else if (res->id == ACPI_RSTYPE_EXT_IRQ)
return acpi_serial_ext_irq(serial_req, &res->data.extended_irq);
else if (res->id == ACPI_RSTYPE_IRQ)
return acpi_serial_irq(serial_req, &res->data.irq);
return AE_OK;
} }
static int acpi_serial_add(struct acpi_device *device) static int acpi_serial_add(struct acpi_device *device)
{ {
acpi_status result; acpi_status status;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct serial_struct serial_req; struct serial_struct serial_req;
int line, offset = 0; int line;
memset(&serial_req, 0, sizeof(serial_req)); memset(&serial_req, 0, sizeof(serial_req));
result = acpi_get_current_resources(device->handle, &buffer);
if (ACPI_FAILURE(result)) {
result = -ENODEV;
goto out;
}
while (offset <= buffer.length) { status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
struct acpi_resource *res = buffer.pointer + offset; acpi_serial_resource, &serial_req);
if (res->length == 0) if (ACPI_FAILURE(status))
break; return -ENODEV;
offset += res->length;
if (res->id == ACPI_RSTYPE_ADDRESS32) { if (!serial_req.iomem_base && !serial_req.port) {
acpi_serial_address(&serial_req, &res->data.address32); printk(KERN_ERR "%s: no iomem or port address in %s _CRS\n",
} else if (res->id == ACPI_RSTYPE_EXT_IRQ) { __FUNCTION__, device->pnp.bus_id);
acpi_serial_irq(&serial_req, &res->data.extended_irq); return -ENODEV;
}
} }
serial_req.baud_base = BASE_BAUD; serial_req.baud_base = BASE_BAUD;
serial_req.flags = ASYNC_SKIP_TEST|ASYNC_BOOT_AUTOCONF|ASYNC_AUTO_IRQ; serial_req.flags = ASYNC_SKIP_TEST|ASYNC_BOOT_AUTOCONF|ASYNC_AUTO_IRQ;
result = 0;
line = register_serial(&serial_req); line = register_serial(&serial_req);
if (line < 0) if (line < 0) {
result = -ENODEV; printk(KERN_WARNING "Couldn't register serial port %s: %d",
device->pnp.bus_id, line);
return -ENODEV;
}
out: return 0;
acpi_os_free(buffer.pointer);
return result;
} }
static int acpi_serial_remove(struct acpi_device *device, int type) static int acpi_serial_remove(struct acpi_device *device, int type)
......
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