linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] tty: serial: make of_serial work on Ralink SoC
@ 2013-04-13  9:33 John Crispin
  2013-04-13  9:33 ` [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF John Crispin
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: John Crispin @ 2013-04-13  9:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-mips, linux-serial, John Crispin

Ralink SoC uses the same 8250 iotype as AU1x00. In order to make this work form
a devicetree, the correct iotype needs to be probed inside
of_platform_serial_setup().

Ralink SoC has a different iosize than AU1x00, which causes
serial8250_port_size() to return 0x1000 instead of the correct 0x100. Instead of
adding another static if statement we probe the real iosize from the resource
inside the devicetree.

Gabor Juhos (2):
  tty: serial: add iosize field to struct uart_port
  tty: of_serial: initialize port.iosize from resource

John Crispin (1):
  tty: of_serial: allow rt288x-uart to load from OF

 drivers/tty/serial/8250/8250_core.c |    3 +++
 drivers/tty/serial/of_serial.c      |   11 +++++++++--
 include/linux/serial_core.h         |    1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

-- 
1.7.10.4


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

* [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF
  2013-04-13  9:33 [PATCH 0/3] tty: serial: make of_serial work on Ralink SoC John Crispin
@ 2013-04-13  9:33 ` John Crispin
  2013-04-15 18:14   ` Greg Kroah-Hartman
  2013-04-13  9:33 ` [PATCH 2/3] tty: serial: add iosize field to struct uart_port John Crispin
  2013-04-13  9:33 ` [PATCH 3/3] tty: of_serial: initialize port.iosize from resource John Crispin
  2 siblings, 1 reply; 9+ messages in thread
From: John Crispin @ 2013-04-13  9:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-mips, linux-serial, John Crispin

In order to make serial_8250 loadable via OF on Ralink WiSoC we need to default
the iotype to UPIO_RT.

Signed-off-by: John Crispin <blogic@openwrt.org>
---
 drivers/tty/serial/of_serial.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index b025d54..42f8550 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -98,7 +98,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
 		port->regshift = prop;
 
 	port->irq = irq_of_parse_and_map(np, 0);
-	port->iotype = UPIO_MEM;
+	if (of_device_is_compatible(np, "ralink,rt2880-uart"))
+		port->iotype = UPIO_AU;
+	else
+		port->iotype = UPIO_MEM;
 	if (of_property_read_u32(np, "reg-io-width", &prop) == 0) {
 		switch (prop) {
 		case 1:
-- 
1.7.10.4


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

* [PATCH 2/3] tty: serial: add iosize field to struct uart_port
  2013-04-13  9:33 [PATCH 0/3] tty: serial: make of_serial work on Ralink SoC John Crispin
  2013-04-13  9:33 ` [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF John Crispin
@ 2013-04-13  9:33 ` John Crispin
  2013-04-15 18:10   ` Greg Kroah-Hartman
  2013-04-13  9:33 ` [PATCH 3/3] tty: of_serial: initialize port.iosize from resource John Crispin
  2 siblings, 1 reply; 9+ messages in thread
From: John Crispin @ 2013-04-13  9:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-mips, linux-serial, Gabor Juhos

From: Gabor Juhos <juhosg@openwrt.org>

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/tty/serial/8250/8250_core.c |    3 +++
 include/linux/serial_core.h         |    1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 35f9c96..25b917a 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -2498,6 +2498,8 @@ serial8250_pm(struct uart_port *port, unsigned int state,
 
 static unsigned int serial8250_port_size(struct uart_8250_port *pt)
 {
+	if (pt->port.iosize)
+		return pt->port.iosize;
 	if (pt->port.iotype == UPIO_AU)
 		return 0x1000;
 	if (is_omap1_8250(pt))
@@ -3233,6 +3235,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
 
 		uart->port.iobase       = up->port.iobase;
 		uart->port.membase      = up->port.membase;
+		uart->port.iosize       = up->port.iosize;
 		uart->port.irq          = up->port.irq;
 		uart->port.irqflags     = up->port.irqflags;
 		uart->port.uartclk      = up->port.uartclk;
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 87d4bbc..d3aa18b 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -194,6 +194,7 @@ struct uart_port {
 	unsigned char		irq_wake;
 	unsigned char		unused[2];
 	void			*private_data;		/* generic platform data pointer */
+	unsigned int		iosize;			/* for ioremap */
 };
 
 static inline int serial_port_in(struct uart_port *up, int offset)
-- 
1.7.10.4


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

* [PATCH 3/3] tty: of_serial: initialize port.iosize from resource
  2013-04-13  9:33 [PATCH 0/3] tty: serial: make of_serial work on Ralink SoC John Crispin
  2013-04-13  9:33 ` [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF John Crispin
  2013-04-13  9:33 ` [PATCH 2/3] tty: serial: add iosize field to struct uart_port John Crispin
@ 2013-04-13  9:33 ` John Crispin
  2 siblings, 0 replies; 9+ messages in thread
From: John Crispin @ 2013-04-13  9:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-mips, linux-serial, Gabor Juhos

From: Gabor Juhos <juhosg@openwrt.org>

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/tty/serial/of_serial.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 42f8550..e4be45b 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -88,10 +88,14 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
 
 	spin_lock_init(&port->lock);
 	port->mapbase = resource.start;
+	port->iosize = resource_size(&resource);
 
 	/* Check for shifted address mapping */
-	if (of_property_read_u32(np, "reg-offset", &prop) == 0)
+	if (of_property_read_u32(np, "reg-offset", &prop) == 0) {
 		port->mapbase += prop;
+		if (prop > port->iosize)
+			port->iosize -= prop;
+	}
 
 	/* Check for registers offset within the devices address range */
 	if (of_property_read_u32(np, "reg-shift", &prop) == 0)
-- 
1.7.10.4


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

* Re: [PATCH 2/3] tty: serial: add iosize field to struct uart_port
  2013-04-13  9:33 ` [PATCH 2/3] tty: serial: add iosize field to struct uart_port John Crispin
@ 2013-04-15 18:10   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 9+ messages in thread
From: Greg Kroah-Hartman @ 2013-04-15 18:10 UTC (permalink / raw)
  To: John Crispin; +Cc: linux-mips, linux-serial, Gabor Juhos

On Sat, Apr 13, 2013 at 11:33:37AM +0200, John Crispin wrote:
> From: Gabor Juhos <juhosg@openwrt.org>
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

Why?  You provide no justification for this patch here, so I guess I
can't accept it.

sorry,

greg k-h

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

* Re: [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF
  2013-04-13  9:33 ` [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF John Crispin
@ 2013-04-15 18:14   ` Greg Kroah-Hartman
  2013-04-16  3:55     ` John Crispin
  0 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2013-04-15 18:14 UTC (permalink / raw)
  To: John Crispin; +Cc: linux-mips, linux-serial

On Sat, Apr 13, 2013 at 11:33:36AM +0200, John Crispin wrote:
> In order to make serial_8250 loadable via OF on Ralink WiSoC we need to default
> the iotype to UPIO_RT.
> 
> Signed-off-by: John Crispin <blogic@openwrt.org>
> ---
>  drivers/tty/serial/of_serial.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
> index b025d54..42f8550 100644
> --- a/drivers/tty/serial/of_serial.c
> +++ b/drivers/tty/serial/of_serial.c
> @@ -98,7 +98,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
>  		port->regshift = prop;
>  
>  	port->irq = irq_of_parse_and_map(np, 0);
> -	port->iotype = UPIO_MEM;
> +	if (of_device_is_compatible(np, "ralink,rt2880-uart"))
> +		port->iotype = UPIO_AU;
> +	else
> +		port->iotype = UPIO_MEM;

Why are you putting device-specific things into a generic driver?
Shouldn't this be able to be described in device tree without relying on
an vendor-specific test in this driver?

greg k-h

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

* Re: [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF
  2013-04-15 18:14   ` Greg Kroah-Hartman
@ 2013-04-16  3:55     ` John Crispin
  2013-04-16  4:05       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 9+ messages in thread
From: John Crispin @ 2013-04-16  3:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-mips, linux-serial

On 15/04/13 20:14, Greg Kroah-Hartman wrote:
> On Sat, Apr 13, 2013 at 11:33:36AM +0200, John Crispin wrote:
>> In order to make serial_8250 loadable via OF on Ralink WiSoC we need to default
>> the iotype to UPIO_RT.
>>
>> Signed-off-by: John Crispin<blogic@openwrt.org>
>> ---
>>   drivers/tty/serial/of_serial.c |    5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
>> index b025d54..42f8550 100644
>> --- a/drivers/tty/serial/of_serial.c
>> +++ b/drivers/tty/serial/of_serial.c
>> @@ -98,7 +98,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
>>   		port->regshift = prop;
>>
>>   	port->irq = irq_of_parse_and_map(np, 0);
>> -	port->iotype = UPIO_MEM;
>> +	if (of_device_is_compatible(np, "ralink,rt2880-uart"))
>> +		port->iotype = UPIO_AU;
>> +	else
>> +		port->iotype = UPIO_MEM;
> Why are you putting device-specific things into a generic driver?
> Shouldn't this be able to be described in device tree without relying on
> an vendor-specific test in this driver?
>
> greg k-h
>
>
Hi Greg,

would 'reg-io-type = "au";' sound better to you ?

     John

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

* Re: [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF
  2013-04-16  4:05       ` Greg Kroah-Hartman
@ 2013-04-16  4:04         ` John Crispin
  0 siblings, 0 replies; 9+ messages in thread
From: John Crispin @ 2013-04-16  4:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-mips, linux-serial

On 16/04/13 06:05, Greg Kroah-Hartman wrote:
> On Tue, Apr 16, 2013 at 05:55:38AM +0200, John Crispin wrote:
>> On 15/04/13 20:14, Greg Kroah-Hartman wrote:
>>> On Sat, Apr 13, 2013 at 11:33:36AM +0200, John Crispin wrote:
>>>> In order to make serial_8250 loadable via OF on Ralink WiSoC we need to default
>>>> the iotype to UPIO_RT.
>>>>
>>>> Signed-off-by: John Crispin<blogic@openwrt.org>
>>>> ---
>>>>   drivers/tty/serial/of_serial.c |    5 ++++-
>>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
>>>> index b025d54..42f8550 100644
>>>> --- a/drivers/tty/serial/of_serial.c
>>>> +++ b/drivers/tty/serial/of_serial.c
>>>> @@ -98,7 +98,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
>>>>   		port->regshift = prop;
>>>>
>>>>   	port->irq = irq_of_parse_and_map(np, 0);
>>>> -	port->iotype = UPIO_MEM;
>>>> +	if (of_device_is_compatible(np, "ralink,rt2880-uart"))
>>>> +		port->iotype = UPIO_AU;
>>>> +	else
>>>> +		port->iotype = UPIO_MEM;
>>> Why are you putting device-specific things into a generic driver?
>>> Shouldn't this be able to be described in device tree without relying on
>>> an vendor-specific test in this driver?
>>>
>>> greg k-h
>>>
>>>
>> Hi Greg,
>>
>> would 'reg-io-type = "au";' sound better to you ?
> I don't know, run it by the device tree people, they know this stuff, I
> don't :(
>
> greg k-h
>
OK ... i don't know either, both proposals look crappy

     John

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

* Re: [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF
  2013-04-16  3:55     ` John Crispin
@ 2013-04-16  4:05       ` Greg Kroah-Hartman
  2013-04-16  4:04         ` John Crispin
  0 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2013-04-16  4:05 UTC (permalink / raw)
  To: John Crispin; +Cc: linux-mips, linux-serial

On Tue, Apr 16, 2013 at 05:55:38AM +0200, John Crispin wrote:
> On 15/04/13 20:14, Greg Kroah-Hartman wrote:
> >On Sat, Apr 13, 2013 at 11:33:36AM +0200, John Crispin wrote:
> >>In order to make serial_8250 loadable via OF on Ralink WiSoC we need to default
> >>the iotype to UPIO_RT.
> >>
> >>Signed-off-by: John Crispin<blogic@openwrt.org>
> >>---
> >>  drivers/tty/serial/of_serial.c |    5 ++++-
> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >>diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
> >>index b025d54..42f8550 100644
> >>--- a/drivers/tty/serial/of_serial.c
> >>+++ b/drivers/tty/serial/of_serial.c
> >>@@ -98,7 +98,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
> >>  		port->regshift = prop;
> >>
> >>  	port->irq = irq_of_parse_and_map(np, 0);
> >>-	port->iotype = UPIO_MEM;
> >>+	if (of_device_is_compatible(np, "ralink,rt2880-uart"))
> >>+		port->iotype = UPIO_AU;
> >>+	else
> >>+		port->iotype = UPIO_MEM;
> >Why are you putting device-specific things into a generic driver?
> >Shouldn't this be able to be described in device tree without relying on
> >an vendor-specific test in this driver?
> >
> >greg k-h
> >
> >
> Hi Greg,
> 
> would 'reg-io-type = "au";' sound better to you ?

I don't know, run it by the device tree people, they know this stuff, I
don't :(

greg k-h

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

end of thread, other threads:[~2013-04-16  4:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-13  9:33 [PATCH 0/3] tty: serial: make of_serial work on Ralink SoC John Crispin
2013-04-13  9:33 ` [PATCH 1/3] tty: of_serial: allow rt288x-uart to load from OF John Crispin
2013-04-15 18:14   ` Greg Kroah-Hartman
2013-04-16  3:55     ` John Crispin
2013-04-16  4:05       ` Greg Kroah-Hartman
2013-04-16  4:04         ` John Crispin
2013-04-13  9:33 ` [PATCH 2/3] tty: serial: add iosize field to struct uart_port John Crispin
2013-04-15 18:10   ` Greg Kroah-Hartman
2013-04-13  9:33 ` [PATCH 3/3] tty: of_serial: initialize port.iosize from resource John Crispin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).