Subject: using drivers/serial/8250.c with platform bus (Virtex 2 Pro and 85xx/83xx)

From: Andrei Konovalov <[email-masked]>
Date: Mon, 04 Apr 2005 14:53:34 +0400

Hi,

Inspired by 85xx, 83xx, and 52xx ports, I've tried to make Xilinx ML300 board to initialize
the 16x50 UART as a platfrom device.
This happened to work after quite a lot of code relying on hard #defines was thrown away
(e.g. arch/ppc/boot/common/ns16550.c needs SERIAL_PORT_DFNS).

Another problem was that serial8250_probe(struct device *dev) from 8250.c walks through the
dev->platform_data[] until the flags field is zero. So I've had to replace

   static struct plat_serial8250_port serial_platform_data = {
         .mapbase        = XPAR_UARTNS550_0_BASEADDR + 3,
         .irq            = XPAR_INTC_0_UARTNS550_0_VEC_ID,
         .uartclk        = XPAR_UARTNS550_0_CLOCK_FREQ_HZ,
         .regshift       = 2,
         .iotype         = UPIO_MEM,
         .flags          = UPF_BOOT_AUTOCONF,
   };

   struct platform_device v2pro_platform_devices[] = {
   #ifdef CONFIG_SERIAL_8250
         {
                 .name = "serial8250",
                 .id     = 0,
                 .dev.platform_data = &serial_platform_data,
         }
   #endif /* CONFIG_SERIAL_8250 */
   };

used originally with

   static struct plat_serial8250_port serial_platform_data[] = {
         {
                 .mapbase        = XPAR_UARTNS550_0_BASEADDR + 3,
                 .irq            = XPAR_INTC_0_UARTNS550_0_VEC_ID,
                 .uartclk        = XPAR_UARTNS550_0_CLOCK_FREQ_HZ,
                 .regshift       = 2,
                 .iotype         = UPIO_MEM,
                 .flags          = UPF_BOOT_AUTOCONF,
         },
         {
                 .flags = 0
         }
   };

   struct platform_device v2pro_platform_devices[] = {
   #ifdef CONFIG_SERIAL_8250
         {
                 .name = "serial8250",
                 .id     = 0,
                 .dev.platform_data = serial_platform_data,
         }
   #endif /* CONFIG_SERIAL_8250 */
   };

That { .flags = 0 }
is missing from 85xx / 83xx code, and my guess is that in that case
the data following serial_platform_data[2] array look like something
with .flags = 0 to the 8250.c.
But wouldn't it be safer to add the { .flags = 0 } terminator
to serial_platform_data[] for 85xx/83xx as well?

Thanks,
Andrei

P.S.
All these XPAR_*'s will be removed when the OF device tree come into play.