diff options
author | Lily Zhang <r58066@freescale.com> | 2010-04-26 14:47:57 +0800 |
---|---|---|
committer | Alejandro Gonzalez <alex.gonzalez@digi.com> | 2010-06-30 15:35:33 +0200 |
commit | 7875862bcec77102cec2ebaf7a378e0fa5ecc899 (patch) | |
tree | 7efe19ee35fa6068c478247a1be9af0379e77f51 /drivers | |
parent | 56ec0b7ccf3ab22c9db9523dcc88b9a5052089d3 (diff) |
ENGR00122852-1 UART: get mem and irq from platform resources
Get UART mem and irq from platform resources
Signed-off-by: Lily Zhang <r58066@freescale.com>
Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/serial/mxc_uart.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/serial/mxc_uart.c b/drivers/serial/mxc_uart.c index cd373ac9cb9a..a756533781f8 100644 --- a/drivers/serial/mxc_uart.c +++ b/drivers/serial/mxc_uart.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved. */ /* @@ -1476,8 +1476,18 @@ static void mxcuart_release_port(struct uart_port *port) */ static int mxcuart_request_port(struct uart_port *port) { - return request_mem_region(port->mapbase, SZ_4K, "serial_mxc") - != NULL ? 0 : -EBUSY; + struct platform_device *pdev = to_platform_device(port->dev); + struct resource *mmres; + void *ret; + + mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mmres) + return -ENODEV; + + ret = request_mem_region(mmres->start, mmres->end - mmres->start + 1, + "serial_mxc"); + + return ret ? 0 : -EBUSY; } /*! @@ -1867,13 +1877,28 @@ static int mxcuart_resume(struct platform_device *pdev) static int mxcuart_probe(struct platform_device *pdev) { int id = pdev->id; + struct resource *res; + void __iomem *base; mxc_ports[id] = pdev->dev.platform_data; mxc_ports[id]->port.ops = &mxc_ops; /* Do not use UARTs that are disabled during integration */ if (mxc_ports[id]->enabled == 1) { + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + + base = ioremap(res->start, res->end - res->start + 1); + if (!base) + return -ENOMEM; + + mxc_ports[id]->port.membase = base; + mxc_ports[id]->port.mapbase = res->start; mxc_ports[id]->port.dev = &pdev->dev; + mxc_ports[id]->port.irq = platform_get_irq(pdev, 0); + mxc_ports[id]->irqs[0] = platform_get_irq(pdev, 1); + mxc_ports[id]->irqs[1] = platform_get_irq(pdev, 2); spin_lock_init(&mxc_ports[id]->port.lock); /* Enable the low latency flag for DMA UART ports */ if (mxc_ports[id]->dma_enabled == 1) { @@ -1907,6 +1932,7 @@ static int mxcuart_remove(struct platform_device *pdev) if (umxc) { uart_remove_one_port(&mxc_reg, &umxc->port); + iounmap(umxc->port.membase); } return 0; } |