Subject: [PATCH] atmel_serial: keep the platform_device unchanged

specify the port num via platform_data this will allow to match the clock
with the plaform_dev staticly

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Cc: Nicolas Ferre <[email protected]>
Cc: Patrice Vilchez <[email protected]>
Cc: Hans-Christian Egtvedt <[email protected]>
Cc: Alan Cox <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
arch/arm/mach-at91/at572d940hf_devices.c | 4 +++-
arch/arm/mach-at91/at91cap9_devices.c | 4 +++-
arch/arm/mach-at91/at91rm9200_devices.c | 4 +++-
arch/arm/mach-at91/at91sam9260_devices.c | 4 +++-
arch/arm/mach-at91/at91sam9261_devices.c | 4 +++-
arch/arm/mach-at91/at91sam9263_devices.c | 4 +++-
arch/arm/mach-at91/at91sam9g45_devices.c | 4 +++-
arch/arm/mach-at91/at91sam9rl_devices.c | 4 +++-
arch/arm/mach-at91/include/mach/board.h | 1 +
arch/avr32/mach-at32ap/at32ap700x.c | 4 +++-
arch/avr32/mach-at32ap/include/mach/board.h | 1 +
drivers/tty/serial/atmel_serial.c | 2 +-
12 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-at91/at572d940hf_devices.c b/arch/arm/mach-at91/at572d940hf_devices.c
index 6e1b9a3..57ed4b7 100644
--- a/arch/arm/mach-at91/at572d940hf_devices.c
+++ b/arch/arm/mach-at91/at572d940hf_devices.c
@@ -822,6 +822,7 @@ struct platform_device *atmel_default_console_device; /* the serial console devi
void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
{
struct platform_device *pdev;
+ struct atmel_uart_data *pdata;

switch (id) {
case 0: /* DBGU */
@@ -847,7 +848,8 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
default:
return;
}
- pdev->id = portnr; /* update to mapped ID */
+ pdata = pdev->dev.platform_data;
+ pdata->num = portnr; /* update to mapped ID */

if (portnr < ATMEL_MAX_UART)
at91_uarts[portnr] = pdev;
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index e887632..ad41039 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -1199,6 +1199,7 @@ struct platform_device *atmel_default_console_device; /* the serial console devi
void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
{
struct platform_device *pdev;
+ struct atmel_uart_data *pdata;

switch (id) {
case 0: /* DBGU */
@@ -1224,7 +1225,8 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
default:
return;
}
- pdev->id = portnr; /* update to mapped ID */
+ pdata = pdev->dev.platform_data;
+ pdata->num = portnr; /* update to mapped ID */

if (portnr < ATMEL_MAX_UART)
at91_uarts[portnr] = pdev;
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 5f873d5..f65f9d3 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -1109,6 +1109,7 @@ struct platform_device *atmel_default_console_device; /* the serial console devi
void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
{
struct platform_device *pdev;
+ struct atmel_uart_data *pdata;

switch (id) {
case 0: /* DBGU */
@@ -1139,7 +1140,8 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
default:
return;
}
- pdev->id = portnr; /* update to mapped ID */
+ pdata = pdev->dev.platform_data;
+ pdata->num = portnr; /* update to mapped ID */

if (portnr < ATMEL_MAX_UART)
at91_uarts[portnr] = pdev;
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index e172b46..bb74c2a 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -1139,6 +1139,7 @@ struct platform_device *atmel_default_console_device; /* the serial console devi
void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
{
struct platform_device *pdev;
+ struct atmel_uart_data *pdata;

switch (id) {
case 0: /* DBGU */
@@ -1179,7 +1180,8 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
default:
return;
}
- pdev->id = portnr; /* update to mapped ID */
+ pdata = pdev->dev.platform_data;
+ pdata->num = portnr; /* update to mapped ID */

if (portnr < ATMEL_MAX_UART)
at91_uarts[portnr] = pdev;
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 59fc483..8792f9b 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -989,6 +989,7 @@ struct platform_device *atmel_default_console_device; /* the serial console devi
void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
{
struct platform_device *pdev;
+ struct atmel_uart_data *pdata;

switch (id) {
case 0: /* DBGU */
@@ -1014,7 +1015,8 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
default:
return;
}
- pdev->id = portnr; /* update to mapped ID */
+ pdata = pdev->dev.platform_data;
+ pdata->num = portnr; /* update to mapped ID */

if (portnr < ATMEL_MAX_UART)
at91_uarts[portnr] = pdev;
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 416613c..1fc6878 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -1370,6 +1370,7 @@ struct platform_device *atmel_default_console_device; /* the serial console devi
void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
{
struct platform_device *pdev;
+ struct atmel_uart_data *pdata;

switch (id) {
case 0: /* DBGU */
@@ -1395,7 +1396,8 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
default:
return;
}
- pdev->id = portnr; /* update to mapped ID */
+ pdata = pdev->dev.platform_data;
+ pdata->num = portnr; /* update to mapped ID */

if (portnr < ATMEL_MAX_UART)
at91_uarts[portnr] = pdev;
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 0867343..fd031ce 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -1527,6 +1527,7 @@ struct platform_device *atmel_default_console_device; /* the serial console devi
void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
{
struct platform_device *pdev;
+ struct atmel_uart_data *pdata;

switch (id) {
case 0: /* DBGU */
@@ -1557,7 +1558,8 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
default:
return;
}
- pdev->id = portnr; /* update to mapped ID */
+ pdata = pdev->dev.platform_data;
+ pdata->num = portnr; /* update to mapped ID */

if (portnr < ATMEL_MAX_UART)
at91_uarts[portnr] = pdev;
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 53aaa94..2d8d519 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -1141,6 +1141,7 @@ struct platform_device *atmel_default_console_device; /* the serial console devi
void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
{
struct platform_device *pdev;
+ struct atmel_uart_data *pdata;

switch (id) {
case 0: /* DBGU */
@@ -1171,7 +1172,8 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
default:
return;
}
- pdev->id = portnr; /* update to mapped ID */
+ pdata = pdev->dev.platform_data;
+ pdata->num = portnr; /* update to mapped ID */

if (portnr < ATMEL_MAX_UART)
at91_uarts[portnr] = pdev;
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index d970420..ef10f32 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -130,6 +130,7 @@ extern void __init at91_set_serial_console(unsigned portnr);
extern struct platform_device *atmel_default_console_device;

struct atmel_uart_data {
+ int num; /* port num */
short use_dma_tx; /* use transmit DMA? */
short use_dma_rx; /* use receive DMA? */
void __iomem *regs; /* virt. base address, if any */
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index bfc9d07..aa677e2 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -1014,6 +1014,7 @@ static struct platform_device *__initdata at32_usarts[4];
void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
{
struct platform_device *pdev;
+ struct atmel_uart_data *pdata;

switch (hw_id) {
case 0:
@@ -1042,7 +1043,8 @@ void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
data->regs = (void __iomem *)pdev->resource[0].start;
}

- pdev->id = line;
+ pdata = pdev->dev.platform_data;
+ pdata->num = portnr;
at32_usarts[line] = pdev;
}

diff --git a/arch/avr32/mach-at32ap/include/mach/board.h b/arch/avr32/mach-at32ap/include/mach/board.h
index 3d79356..dd61a24 100644
--- a/arch/avr32/mach-at32ap/include/mach/board.h
+++ b/arch/avr32/mach-at32ap/include/mach/board.h
@@ -34,6 +34,7 @@ extern struct platform_device *atmel_default_console_device;
#define ATMEL_USART_CLK 0x04

struct atmel_uart_data {
+ int num; /* port num */
short use_dma_tx; /* use transmit DMA? */
short use_dma_rx; /* use receive DMA? */
void __iomem *regs; /* virtual base address, if any */
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 2dc8a66..57e294c 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1423,7 +1423,7 @@ static int __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
port->flags = UPF_BOOT_AUTOCONF;
port->ops = &atmel_pops;
port->fifosize = 1;
- port->line = pdev->id;
+ port->line = data->num;
port->dev = &pdev->dev;
port->mapbase = pdev->resource[0].start;
port->irq = pdev->resource[1].start;
--
1.7.4.1


2011-04-13 22:15:44

by Alan

[permalink] [raw]
Subject: Re: [PATCH] atmel_serial: keep the platform_device unchanged

On Wed, 13 Apr 2011 21:47:18 +0200
Jean-Christophe PLAGNIOL-VILLARD <[email protected]> wrote:

> specify the port num via platform_data this will allow to match the
> clock with the plaform_dev staticly
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD
> <[email protected]> Cc: Nicolas Ferre <[email protected]>
> Cc: Patrice Vilchez <[email protected]>
> Cc: Hans-Christian Egtvedt <[email protected]>
> Cc: Alan Cox <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>

Ack for the serial side, its really an arch patch though as far as I
can see..

Subject: Re: [PATCH] atmel_serial: keep the platform_device unchanged

On 22:58 Wed 13 Apr , Alan Cox wrote:
> On Wed, 13 Apr 2011 21:47:18 +0200
> Jean-Christophe PLAGNIOL-VILLARD <[email protected]> wrote:
>
> > specify the port num via platform_data this will allow to match the
> > clock with the plaform_dev staticly
> >
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD
> > <[email protected]> Cc: Nicolas Ferre <[email protected]>
> > Cc: Patrice Vilchez <[email protected]>
> > Cc: Hans-Christian Egtvedt <[email protected]>
> > Cc: Alan Cox <[email protected]>
> > Cc: Greg Kroah-Hartman <[email protected]>
>
> Ack for the serial side, its really an arch patch though as far as I
> can see..
applied in at91-l2

Best Regards,
J.

2011-06-08 08:45:34

by Hans-Christian Egtvedt

[permalink] [raw]
Subject: Re: [PATCH] atmel_serial: keep the platform_device unchanged

On Wed, 2011-04-13 at 21:47 +0200, Jean-Christophe PLAGNIOL-VILLARD
wrote:
> specify the port num via platform_data this will allow to match the clock
> with the plaform_dev staticly

Sure this works as intended, now the platform device id is off, and at
least for my 3.0 testing it is no longer able to open the console,
unless I explicit set the id field again.

Example on NGW100 mkII I use USART instance 1 as serial console, if not
setting the platform device id to 0 (re-mapping), then I get a warning
about unable to open console.

Is you clock optimization an additional patch?

<snipp AT91 changes)

> diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
> index bfc9d07..aa677e2 100644
> --- a/arch/avr32/mach-at32ap/at32ap700x.c
> +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> @@ -1014,6 +1014,7 @@ static struct platform_device *__initdata at32_usarts[4];
> void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> {
> struct platform_device *pdev;
> + struct atmel_uart_data *pdata;
>
> switch (hw_id) {
> case 0:
> @@ -1042,7 +1043,8 @@ void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> data->regs = (void __iomem *)pdev->resource[0].start;
> }
>
> - pdev->id = line;

AVR32 needs this to be present to work independent of which USART
peripheral the user chooses to use for console.

> + pdata = pdev->dev.platform_data;
> + pdata->num = portnr;
> at32_usarts[line] = pdev;
> }
>

<snipp>

--
Hans-Christian Egtvedt

Subject: Re: [PATCH] atmel_serial: keep the platform_device unchanged

On 10:45 Wed 08 Jun , Hans-Christian Egtvedt wrote:
> On Wed, 2011-04-13 at 21:47 +0200, Jean-Christophe PLAGNIOL-VILLARD
> wrote:
> > specify the port num via platform_data this will allow to match the clock
> > with the plaform_dev staticly
>
> Sure this works as intended, now the platform device id is off, and at
> least for my 3.0 testing it is no longer able to open the console,
> unless I explicit set the id field again.
>
> Example on NGW100 mkII I use USART instance 1 as serial console, if not
> setting the platform device id to 0 (re-mapping), then I get a warning
> about unable to open console.
>
> Is you clock optimization an additional patch?
no but we can also switch the avr32 to clkdev
>
> <snipp AT91 changes)
>
> > diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
> > index bfc9d07..aa677e2 100644
> > --- a/arch/avr32/mach-at32ap/at32ap700x.c
> > +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> > @@ -1014,6 +1014,7 @@ static struct platform_device *__initdata at32_usarts[4];
> > void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> > {
> > struct platform_device *pdev;
> > + struct atmel_uart_data *pdata;
> >
> > switch (hw_id) {
> > case 0:
> > @@ -1042,7 +1043,8 @@ void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> > data->regs = (void __iomem *)pdev->resource[0].start;
> > }
> >
> > - pdev->id = line;
>
> AVR32 needs this to be present to work independent of which USART
> peripheral the user chooses to use for console.
>
> > + pdata = pdev->dev.platform_data;
> > + pdata->num = portnr;
here supposed to be
pdata->num = line;

Best Regards,
J.

2011-06-08 14:02:55

by Hans-Christian Egtvedt

[permalink] [raw]
Subject: Re: [PATCH] atmel_serial: keep the platform_device unchanged

On Wed, 2011-06-08 at 15:47 +0200, Jean-Christophe PLAGNIOL-VILLARD
wrote:
> On 10:45 Wed 08 Jun , Hans-Christian Egtvedt wrote:
> > On Wed, 2011-04-13 at 21:47 +0200, Jean-Christophe PLAGNIOL-VILLARD
> > wrote:

<snipp>

> > > diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
> > > index bfc9d07..aa677e2 100644
> > > --- a/arch/avr32/mach-at32ap/at32ap700x.c
> > > +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> > > @@ -1014,6 +1014,7 @@ static struct platform_device *__initdata at32_usarts[4];
> > > void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> > > {
> > > struct platform_device *pdev;
> > > + struct atmel_uart_data *pdata;
> > >
> > > switch (hw_id) {
> > > case 0:
> > > @@ -1042,7 +1043,8 @@ void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> > > data->regs = (void __iomem *)pdev->resource[0].start;
> > > }
> > >
> > > - pdev->id = line;
> >
> > AVR32 needs this to be present to work independent of which USART
> > peripheral the user chooses to use for console.
> >
> > > + pdata = pdev->dev.platform_data;
> > > + pdata->num = portnr;
> here supposed to be
> pdata->num = line;

I know, but that doesn't fix the problem about not able to find a
console, the platform data id must also be 0 (if console is on ttyS0)
AFAICT.

--
Hans-Christian Egtvedt

Subject: Re: [PATCH] atmel_serial: keep the platform_device unchanged

On 16:02 Wed 08 Jun , Hans-Christian Egtvedt wrote:
> On Wed, 2011-06-08 at 15:47 +0200, Jean-Christophe PLAGNIOL-VILLARD
> wrote:
> > On 10:45 Wed 08 Jun , Hans-Christian Egtvedt wrote:
> > > On Wed, 2011-04-13 at 21:47 +0200, Jean-Christophe PLAGNIOL-VILLARD
> > > wrote:
>
> <snipp>
>
> > > > diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
> > > > index bfc9d07..aa677e2 100644
> > > > --- a/arch/avr32/mach-at32ap/at32ap700x.c
> > > > +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> > > > @@ -1014,6 +1014,7 @@ static struct platform_device *__initdata at32_usarts[4];
> > > > void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> > > > {
> > > > struct platform_device *pdev;
> > > > + struct atmel_uart_data *pdata;
> > > >
> > > > switch (hw_id) {
> > > > case 0:
> > > > @@ -1042,7 +1043,8 @@ void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> > > > data->regs = (void __iomem *)pdev->resource[0].start;
> > > > }
> > > >
> > > > - pdev->id = line;
> > >
> > > AVR32 needs this to be present to work independent of which USART
> > > peripheral the user chooses to use for console.
> > >
> > > > + pdata = pdev->dev.platform_data;
> > > > + pdata->num = portnr;
> > here supposed to be
> > pdata->num = line;
>
> I know, but that doesn't fix the problem about not able to find a
> console, the platform data id must also be 0 (if console is on ttyS0)
> AFAICT.
will test this weekend on avr32

Best Regards,
J.

Subject: Re: [PATCH] atmel_serial: keep the platform_device unchanged

On 16:02 Wed 08 Jun , Hans-Christian Egtvedt wrote:
> On Wed, 2011-06-08 at 15:47 +0200, Jean-Christophe PLAGNIOL-VILLARD
> wrote:
> > On 10:45 Wed 08 Jun , Hans-Christian Egtvedt wrote:
> > > On Wed, 2011-04-13 at 21:47 +0200, Jean-Christophe PLAGNIOL-VILLARD
> > > wrote:
>
> <snipp>
>
> > > > diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
> > > > index bfc9d07..aa677e2 100644
> > > > --- a/arch/avr32/mach-at32ap/at32ap700x.c
> > > > +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> > > > @@ -1014,6 +1014,7 @@ static struct platform_device *__initdata at32_usarts[4];
> > > > void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> > > > {
> > > > struct platform_device *pdev;
> > > > + struct atmel_uart_data *pdata;
> > > >
> > > > switch (hw_id) {
> > > > case 0:
> > > > @@ -1042,7 +1043,8 @@ void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
> > > > data->regs = (void __iomem *)pdev->resource[0].start;
> > > > }
> > > >
> > > > - pdev->id = line;
> > >
> > > AVR32 needs this to be present to work independent of which USART
> > > peripheral the user chooses to use for console.
> > >
> > > > + pdata = pdev->dev.platform_data;
> > > > + pdata->num = portnr;
> > here supposed to be
> > pdata->num = line;
>
> I know, but that doesn't fix the problem about not able to find a
> console, the platform data id must also be 0 (if console is on ttyS0)
> AFAICT.
I found the issue
on at91 we always use the dbgu as console so I did not see it

please try to repling patch

Best Regards,
J.