Subject: Re: include/asm-ppc/platforms/

From: Frank Rowand <[email-masked]>
Date: Thu, 29 Nov 2001 09:57:02 -0800

Adrian Cox wrote:
>
> Paul Mackerras wrote:
>
> > Perfectly reasonable - I wish all the platforms used early_serial_setup.
> > Would you mind posting your code that does the early_serial_setup calls?
>
> Mangled by Mozilla below. This is a 7400 board with a memory mapped
> uart. It is important to zero out the entries for serial ports that
> aren't present, otherwise the serial driver will attempt to use the
> traditional locations.
>
> static void __init
> tpe3_setup_arch(void)
> {
>         struct serial_struct req;
>
>         ...
>
>         memset(&req, 0, sizeof (req));
>         req.line = 0;
>         req.io_type = SERIAL_IO_MEM;
>         req.iomem_base = (void *) (tpe3_uart_base + 0x10);
>         req.baud_base = 6144000 / 16;
>         req.irq = 3;
>         req.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
>         early_serial_setup(&req);
>         memset(&req, 0, sizeof (req));
>         req.line = 1;
>         early_serial_setup(&req);
>         req.line = 2;
>         early_serial_setup(&req);
>         req.line = 3;
>         early_serial_setup(&req);
>
>         ...
> }

And a more generic approach (that can pull the port definitions from
a header file) is attached...

-Frank
--
Frank Rowand <[email-masked]>
MontaVista Software, Inc

Date: Wed, 27 Jun 2001 17:55:06 -0700
From: Frank Rowand <[email-masked]>
Reply-To: [email-masked]
Subject: Paulus, Trini: here's how to dynamically register serial port

You guys were discussing how to get rid of all the #ifdef ... includes for
the serial ports, and wondering how to dynamically register ports.  The
interface the serial driver provides for this is early_serial_setup().
Here's an example of using it (this example uses the SERIAL_PORT_DFNS from
ppc4xx_serial.h just because it was already defined there):

        {
#include <linux/serialP.h>

                int k;
                struct serial_struct req;
                struct serial_state tmp_rs_table[RS_TABLE_SIZE] = {
                        SERIAL_PORT_DFNS   /* Defined in ppc4xx_serial.h */
                };

                for (k = 0; k < RS_TABLE_SIZE; k++) {
                        if (tmp_rs_table[k].iomem_base != 0) {

        req.baud_base       = tmp_rs_table[k].baud_base;
        req.port            = tmp_rs_table[k].port;
        req.port_high       = 0;
        req.irq             = tmp_rs_table[k].irq;
        req.flags           = tmp_rs_table[k].flags;
        req.close_delay     = tmp_rs_table[k].close_delay;
        req.io_type         = tmp_rs_table[k].io_type;
        req.hub6            = tmp_rs_table[k].hub6;
        req.iomem_base      = ioremap((int)tmp_rs_table[k].iomem_base, PAGE_SIZE);
        req.iomem_reg_shift = tmp_rs_table[k].iomem_reg_shift;
        req.type            = tmp_rs_table[k].type;
        req.xmit_fifo_size  = tmp_rs_table[k].xmit_fifo_size;
        req.custom_divisor  = tmp_rs_table[k].custom_divisor;
        req.closing_wait    = tmp_rs_table[k].closing_wait;

                                early_serial_setup(&req);
                        }
                }
        }

-Frank
--
Frank Rowand <[email-masked]>
MontaVista Software, Inc