]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/tty/serial/sh-sci.c
Merge tag 'tty-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[linux.git] / drivers / tty / serial / sh-sci.c
index b74a644e4b044b8ba29d335cfc852be84f2ce27c..1b2f894bdc9e0e6ed15cf93feb405337b1d0d07b 100644 (file)
@@ -85,7 +85,7 @@ struct sci_port {
        unsigned int            overrun_mask;
        unsigned int            error_mask;
        unsigned int            sampling_rate;
-
+       resource_size_t         reg_size;
 
        /* Break timer */
        struct timer_list       break_timer;
@@ -2077,23 +2077,9 @@ static const char *sci_type(struct uart_port *port)
        return NULL;
 }
 
-static inline unsigned long sci_port_size(struct uart_port *port)
-{
-       /*
-        * Pick an arbitrary size that encapsulates all of the base
-        * registers by default. This can be optimized later, or derived
-        * from platform resource data at such a time that ports begin to
-        * behave more erratically.
-        */
-       if (port->type == PORT_HSCIF)
-               return 96;
-       else
-               return 64;
-}
-
 static int sci_remap_port(struct uart_port *port)
 {
-       unsigned long size = sci_port_size(port);
+       struct sci_port *sport = to_sci_port(port);
 
        /*
         * Nothing to do if there's already an established membase.
@@ -2102,7 +2088,7 @@ static int sci_remap_port(struct uart_port *port)
                return 0;
 
        if (port->flags & UPF_IOREMAP) {
-               port->membase = ioremap_nocache(port->mapbase, size);
+               port->membase = ioremap_nocache(port->mapbase, sport->reg_size);
                if (unlikely(!port->membase)) {
                        dev_err(port->dev, "can't remap port#%d\n", port->line);
                        return -ENXIO;
@@ -2121,23 +2107,28 @@ static int sci_remap_port(struct uart_port *port)
 
 static void sci_release_port(struct uart_port *port)
 {
+       struct sci_port *sport = to_sci_port(port);
+
        if (port->flags & UPF_IOREMAP) {
                iounmap(port->membase);
                port->membase = NULL;
        }
 
-       release_mem_region(port->mapbase, sci_port_size(port));
+       release_mem_region(port->mapbase, sport->reg_size);
 }
 
 static int sci_request_port(struct uart_port *port)
 {
-       unsigned long size = sci_port_size(port);
        struct resource *res;
+       struct sci_port *sport = to_sci_port(port);
        int ret;
 
-       res = request_mem_region(port->mapbase, size, dev_name(port->dev));
-       if (unlikely(res == NULL))
+       res = request_mem_region(port->mapbase, sport->reg_size,
+                                dev_name(port->dev));
+       if (unlikely(res == NULL)) {
+               dev_err(port->dev, "request_mem_region failed.");
                return -EBUSY;
+       }
 
        ret = sci_remap_port(port);
        if (unlikely(ret != 0)) {
@@ -2211,6 +2202,7 @@ static int sci_init_single(struct platform_device *dev,
                return -ENOMEM;
 
        port->mapbase = res->start;
+       sci_port->reg_size = resource_size(res);
 
        for (i = 0; i < ARRAY_SIZE(sci_port->irqs); ++i)
                sci_port->irqs[i] = platform_get_irq(dev, i);
@@ -2541,6 +2533,12 @@ static const struct of_device_id of_sci_match[] = {
                        .type = PORT_HSCIF,
                        .regtype = SCIx_HSCIF_REGTYPE,
                },
+       }, {
+               .compatible = "renesas,sci",
+               .data = &(const struct sci_port_info) {
+                       .type = PORT_SCI,
+                       .regtype = SCIx_SCI_REGTYPE,
+               },
        }, {
                /* Terminator */
        },