linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* RE: Linux 2.6-10.rc3  8xx: debugging (over-writing)  content of b d_in fo structure  in the kernel booting code
@ 2005-01-18 15:01 Povolotsky, Alexander
  2005-01-18 15:23 ` Linux 2.6-10.rc3 8xx: debugging (over-writing) content of bd_in " Mark Chambers
  0 siblings, 1 reply; 4+ messages in thread
From: Povolotsky, Alexander @ 2005-01-18 15:01 UTC (permalink / raw)
  To: 'linuxppc-embedded@ozlabs.org'

Hi,

my "custom" bd_info structure (passed from my custom bootloader) looks as
following:

typedef struct bd_info {
        unsigned long   bi_memstart;    /* start of DRAM memory */
        unsigned long   bi_memsize;     /* size  of DRAM memory in bytes */
        unsigned long   bi_flashstart;  /* start of FLASH memory */
        unsigned long   bi_flashsize;   /* size  of FLASH memory */
        unsigned long   bi_flashoffset; /* reserved area for startup monitor
*/
        unsigned long   bi_sramstart;   /* start of SRAM memory */
        unsigned long   bi_sramsize;    /* size  of SRAM memory */
        unsigned long   bi_immr_base;   /* base of IMMR register */
        unsigned long   bi_bootflags;   /* boot / reboot flag (for LynxOS)
*/
        unsigned long   bi_ip_addr;     /* IP Address */
        unsigned char   bi_enetaddr[6]; /* Ethernet adress */
        unsigned short  bi_ethspeed;    /* Ethernet speed in Mbps */
        unsigned long   bi_intfreq;     /* Internal Freq, in MHz */
        unsigned long   bi_busfreq;     /* Bus Freq, in MHz */
        unsigned long   bi_baudrate;    /* Console Baudrate */
        unsigned char   bi_run_bank;    /* Running Bank */

} bd_t;

My embed_config(bd_t **bdp) function (in
arch/ppc/boot/simple/embed_config.c)
does the following (using above structure) :

 bd->bi_baudrate = 38400; /* changed from 115200 for debug - Alex */
 bd->bi_memstart = 0;
 bd->bi_memsize = (32 * 1024 * 1024);
 bd->bi_intfreq = 50000000;
 bd->bi_busfreq = 50000000;

Then we have, as Hans noted to me, the cpm_setbrg() function
 (in arch/ppc/8xx_io/commproc.c):

/* Set a baud rate generator.  This needs lots of work.  There are
 * four BRGs, any of which can be wired to any channel.
 * The internal baud rate clock is the system clock divided by 16.
 * This assumes the baudrate is 16x oversampled by the uart.
 */
#define BRG_INT_CLK             (((bd_t *)__res)->bi_intfreq)
#define BRG_UART_CLK            (BRG_INT_CLK/16)
#define BRG_UART_CLK_DIV16      (BRG_UART_CLK/16)

void
cpm_setbrg(uint brg, uint rate)
{
        volatile uint   *bp;

        /* This is good enough to get SMCs running.....
        */
        bp = (uint *)&cpmp->cp_brgc1;
        bp += brg;
        /* The BRG has a 12-bit counter.  For really slow baud rates (or
         * really fast processors), we may have to further divide by 16.
         */
        if (((BRG_UART_CLK / rate) - 1) < 4096)
                *bp = (((BRG_UART_CLK / rate) - 1) << 1) | CPM_BRG_EN;
        else
                *bp = (((BRG_UART_CLK_DIV16 / rate) - 1) << 1) |
                                                CPM_BRG_EN | CPM_BRG_DIV16;
}

So what could go wrong here in terms of setting the baudrate for the serial
uart 
(which "presumably" causes printing 3 good characters and then garbage
during kernel booting) ?

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Linux 2.6-10.rc3  8xx: debugging (over-writing)  content of bd_in fo structure  in the kernel booting code
@ 2005-01-18 11:45 Povolotsky, Alexander
  2005-01-18 12:20 ` Hans Schillstrom
  0 siblings, 1 reply; 4+ messages in thread
From: Povolotsky, Alexander @ 2005-01-18 11:45 UTC (permalink / raw)
  To: 'linuxppc-embedded@ozlabs.org'

I am now suspecting that the content of my bd_info structure is set or is
handled incorrectly,
thus causing incorrect behavior of the serial driver upon kernel booting
(only 3 characters are printed correctly and the rest is the garbage - as I
reported before), 
so I am trying (for debugging purposes) to over-write the values, passed
from bd_info
during the kernel booting, by the hard-coded "correct" values.

So far I tried forcing baud, bits, parity, flow directly in in
cpm_uart_console_setup()
( drivers/serial/cpm_uart/cpm_uar t_core.c ) - see below - it didn't help
...

Where in the kernel booting code the clock speed is handled (it also comes
from the bd_info)
 - so I could try to force set clock speed there ?

Thanks,
Alex
****************************************************************
static int __init cpm_uart_console_setup(struct console *co, char *options)
{
        struct uart_port *port;
        struct uart_cpm_port *pinfo;
        int baud = 38400;
        int bits = 8;
        int parity = 'n';
        int flow = 'n';
        int ret;

        port =
            (struct uart_port
*)&cpm_uart_ports[cpm_uart_port_map[co->index]];
        pinfo = (struct uart_cpm_port *)port;

        pinfo->flags |= FLAG_CONSOLE;

        if (options) {
                uart_parse_options(options, &baud, &parity, &bits, &flow);
        } else {
                bd_t *bd = (bd_t *) __res;

                if (bd->bi_baudrate)
                        baud = bd->bi_baudrate;
                else
                        baud = 9600;
        }
        baud = 38400;
<<===========================================
        parity = 'n';
<<===========================================
        flow = 'n';
<<===========================================
        bits = 8;
<<===========================================
        /*
         * Setup any port IO, connect any baud rate generators,
         * etc.  This is expected to be handled by board
         * dependant code
         */
        if (pinfo->set_lineif)
                pinfo->set_lineif(pinfo);

        if (IS_SMC(pinfo)) {
                pinfo->smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
                pinfo->smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
        } else {
                pinfo->sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
                pinfo->sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
        }

        ret = cpm_uart_allocbuf(pinfo, 1);

        if (ret)
                return ret;

        cpm_uart_initbd(pinfo);

        if (IS_SMC(pinfo))
                cpm_uart_init_smc(pinfo);
        else
                cpm_uart_init_scc(pinfo);

        uart_set_options(port, co, baud, parity, bits, flow);

        return 0;
}

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

end of thread, other threads:[~2005-01-18 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-18 15:01 Linux 2.6-10.rc3 8xx: debugging (over-writing) content of b d_in fo structure in the kernel booting code Povolotsky, Alexander
2005-01-18 15:23 ` Linux 2.6-10.rc3 8xx: debugging (over-writing) content of bd_in " Mark Chambers
  -- strict thread matches above, loose matches on Subject: below --
2005-01-18 11:45 Povolotsky, Alexander
2005-01-18 12:20 ` Hans Schillstrom

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).