Commit 72af4762 authored by Tobias Klauser's avatar Tobias Klauser Committed by Greg Kroah-Hartman

tty: serial: altera_jtaguart: Support getting mapbase and IRQ from resources

This will make it easier to get the driver to support device tree. The
old platform data method is still supported though.

Also change the driver to use only one platform device per port.
Signed-off-by: default avatarTobias Klauser <tklauser@distanz.ch>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3231f075
......@@ -409,22 +409,45 @@ static int __devinit altera_jtaguart_probe(struct platform_device *pdev)
{
struct altera_jtaguart_platform_uart *platp = pdev->dev.platform_data;
struct uart_port *port;
int i;
struct resource *res_irq, *res_mem;
int i = pdev->id;
for (i = 0; i < ALTERA_JTAGUART_MAXPORTS && platp[i].mapbase; i++) {
port = &altera_jtaguart_ports[i].port;
/* -1 emphasizes that the platform must have one port, no .N suffix */
if (i == -1)
i = 0;
port->line = i;
port->type = PORT_ALTERA_JTAGUART;
port->mapbase = platp[i].mapbase;
port->membase = ioremap(port->mapbase, ALTERA_JTAGUART_SIZE);
port->iotype = SERIAL_IO_MEM;
port->irq = platp[i].irq;
port->ops = &altera_jtaguart_ops;
port->flags = ASYNC_BOOT_AUTOCONF;
if (i >= ALTERA_JTAGUART_MAXPORTS)
return -EINVAL;
uart_add_one_port(&altera_jtaguart_driver, port);
}
port = &altera_jtaguart_ports[i].port;
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res_mem)
port->mapbase = res_mem->start;
else if (platp)
port->mapbase = platp->mapbase;
else
return -ENODEV;
res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (res_irq)
port->irq = res_irq->start;
else if (platp)
port->irq = platp->irq;
else
return -ENODEV;
port->membase = ioremap(port->mapbase, ALTERA_JTAGUART_SIZE);
if (!port->membase)
return -ENOMEM;
port->line = i;
port->type = PORT_ALTERA_JTAGUART;
port->iotype = SERIAL_IO_MEM;
port->ops = &altera_jtaguart_ops;
port->flags = ASYNC_BOOT_AUTOCONF;
uart_add_one_port(&altera_jtaguart_driver, port);
return 0;
}
......@@ -432,13 +455,13 @@ static int __devinit altera_jtaguart_probe(struct platform_device *pdev)
static int __devexit altera_jtaguart_remove(struct platform_device *pdev)
{
struct uart_port *port;
int i;
int i = pdev->id;
for (i = 0; i < ALTERA_JTAGUART_MAXPORTS; i++) {
port = &altera_jtaguart_ports[i].port;
if (port)
uart_remove_one_port(&altera_jtaguart_driver, port);
}
if (i == -1)
i = 0;
port = &altera_jtaguart_ports[i].port;
uart_remove_one_port(&altera_jtaguart_driver, port);
return 0;
}
......
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