diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/serial/sh-sci.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 7b2760be0260..c55cec5ba992 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
| @@ -1602,6 +1602,34 @@ static inline unsigned long sci_port_size(struct uart_port *port) | |||
| 1602 | return 64; | 1602 | return 64; |
| 1603 | } | 1603 | } |
| 1604 | 1604 | ||
| 1605 | static int sci_remap_port(struct uart_port *port) | ||
| 1606 | { | ||
| 1607 | unsigned long size = sci_port_size(port); | ||
| 1608 | |||
| 1609 | /* | ||
| 1610 | * Nothing to do if there's already an established membase. | ||
| 1611 | */ | ||
| 1612 | if (port->membase) | ||
| 1613 | return 0; | ||
| 1614 | |||
| 1615 | if (port->flags & UPF_IOREMAP) { | ||
| 1616 | port->membase = ioremap_nocache(port->mapbase, size); | ||
| 1617 | if (unlikely(!port->membase)) { | ||
| 1618 | dev_err(port->dev, "can't remap port#%d\n", port->line); | ||
| 1619 | return -ENXIO; | ||
| 1620 | } | ||
| 1621 | } else { | ||
| 1622 | /* | ||
| 1623 | * For the simple (and majority of) cases where we don't | ||
| 1624 | * need to do any remapping, just cast the cookie | ||
| 1625 | * directly. | ||
| 1626 | */ | ||
| 1627 | port->membase = (void __iomem *)port->mapbase; | ||
| 1628 | } | ||
| 1629 | |||
| 1630 | return 0; | ||
| 1631 | } | ||
| 1632 | |||
| 1605 | static void sci_release_port(struct uart_port *port) | 1633 | static void sci_release_port(struct uart_port *port) |
| 1606 | { | 1634 | { |
| 1607 | if (port->flags & UPF_IOREMAP) { | 1635 | if (port->flags & UPF_IOREMAP) { |
| @@ -1616,25 +1644,16 @@ static int sci_request_port(struct uart_port *port) | |||
| 1616 | { | 1644 | { |
| 1617 | unsigned long size = sci_port_size(port); | 1645 | unsigned long size = sci_port_size(port); |
| 1618 | struct resource *res; | 1646 | struct resource *res; |
| 1647 | int ret; | ||
| 1619 | 1648 | ||
| 1620 | res = request_mem_region(port->mapbase, size, sci_type(port)); | 1649 | res = request_mem_region(port->mapbase, size, sci_type(port)); |
| 1621 | if (unlikely(res == NULL)) | 1650 | if (unlikely(res == NULL)) |
| 1622 | return -EBUSY; | 1651 | return -EBUSY; |
| 1623 | 1652 | ||
| 1624 | if (port->flags & UPF_IOREMAP) { | 1653 | ret = sci_remap_port(port); |
| 1625 | port->membase = ioremap_nocache(port->mapbase, size); | 1654 | if (unlikely(ret != 0)) { |
| 1626 | if (unlikely(!port->membase)) { | 1655 | release_resource(res); |
| 1627 | dev_err(port->dev, "can't remap port#%d\n", port->line); | 1656 | return ret; |
| 1628 | release_resource(res); | ||
| 1629 | return -ENXIO; | ||
| 1630 | } | ||
| 1631 | } else { | ||
| 1632 | /* | ||
| 1633 | * For the simple (and majority of) cases where we don't | ||
| 1634 | * need to do any remapping, just cast the cookie | ||
| 1635 | * directly. | ||
| 1636 | */ | ||
| 1637 | port->membase = (void __iomem *)port->mapbase; | ||
| 1638 | } | 1657 | } |
| 1639 | 1658 | ||
| 1640 | return 0; | 1659 | return 0; |
| @@ -1835,7 +1854,9 @@ static int __devinit serial_console_setup(struct console *co, char *options) | |||
| 1835 | if (!port->type) | 1854 | if (!port->type) |
| 1836 | return -ENODEV; | 1855 | return -ENODEV; |
| 1837 | 1856 | ||
| 1838 | sci_config_port(port, 0); | 1857 | ret = sci_remap_port(port); |
| 1858 | if (unlikely(ret != 0)) | ||
| 1859 | return ret; | ||
| 1839 | 1860 | ||
| 1840 | if (sci_port->enable) | 1861 | if (sci_port->enable) |
| 1841 | sci_port->enable(port); | 1862 | sci_port->enable(port); |
