SUPERH platform development
 help / color / mirror / Atom feed
* [PATCH v3] sh-sci: Get register size from platform device
@ 2015-05-18  4:57 Yoshinori Sato
  2015-05-20  8:40 ` Geert Uytterhoeven
  2015-05-21  1:20 ` Simon Horman
  0 siblings, 2 replies; 3+ messages in thread
From: Yoshinori Sato @ 2015-05-18  4:57 UTC (permalink / raw)
  To: linux-sh

There is much SCI of SoC having within,
and the register size is also different in everyone.
So get from platform device.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 drivers/tty/serial/sh-sci.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 1468ec5..95772cf 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -84,7 +84,7 @@ struct sci_port {
 	int			overrun_bit;
 	unsigned int		error_mask;
 	unsigned int		sampling_rate;
-
+	resource_size_t		reg_size;
 
 	/* Break timer */
 	struct timer_list	break_timer;
@@ -2073,23 +2073,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.
@@ -2098,7 +2084,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;
@@ -2117,23 +2103,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)) {
@@ -2207,6 +2198,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);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] sh-sci: Get register size from platform device
  2015-05-18  4:57 [PATCH v3] sh-sci: Get register size from platform device Yoshinori Sato
@ 2015-05-20  8:40 ` Geert Uytterhoeven
  2015-05-21  1:20 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2015-05-20  8:40 UTC (permalink / raw)
  To: linux-sh

On Mon, May 18, 2015 at 6:57 AM, Yoshinori Sato
<ysato@users.sourceforge.jp> wrote:
> There is much SCI of SoC having within,
> and the register size is also different in everyone.
> So get from platform device.
>
> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

Acked-by: by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] sh-sci: Get register size from platform device
  2015-05-18  4:57 [PATCH v3] sh-sci: Get register size from platform device Yoshinori Sato
  2015-05-20  8:40 ` Geert Uytterhoeven
@ 2015-05-21  1:20 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2015-05-21  1:20 UTC (permalink / raw)
  To: linux-sh

On Mon, May 18, 2015 at 01:57:07PM +0900, Yoshinori Sato wrote:
> There is much SCI of SoC having within,
> and the register size is also different in everyone.
> So get from platform device.
> 
> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/tty/serial/sh-sci.c | 34 +++++++++++++---------------------
>  1 file changed, 13 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 1468ec5..95772cf 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -84,7 +84,7 @@ struct sci_port {
>  	int			overrun_bit;
>  	unsigned int		error_mask;
>  	unsigned int		sampling_rate;
> -
> +	resource_size_t		reg_size;
>  
>  	/* Break timer */
>  	struct timer_list	break_timer;
> @@ -2073,23 +2073,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.
> @@ -2098,7 +2084,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;
> @@ -2117,23 +2103,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)) {
> @@ -2207,6 +2198,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);
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-21  1:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-18  4:57 [PATCH v3] sh-sci: Get register size from platform device Yoshinori Sato
2015-05-20  8:40 ` Geert Uytterhoeven
2015-05-21  1:20 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox