Ignore:
Timestamp:
Jun 8, 2001, 1:29:13 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
622a429
Parents:
b7f5447b
Message:

2000-06-08 Eric Valette <valette@…>

  • console/console.c, include/commproc.h, startup/start.S: The printk/printf did not work when loaded by EPPCBUG. They did work when loaded with the BDM debugger. I suspected EPPBUG made some nasty things like patching Communication processor microcode... Anyway, the attached patch: 1) Enables to have printk nearly immediately after boot, 2) Make printf work automagically (I do not know why except I make a different initialization for printk that should be overwritten by console init later ?)

I let the default to be using EPPCBUG embedded firmware to boot and
using this printk early enabler code (LOADED_BY_EPPCBUG and
EARLY_CONSOLE) are on.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/mbx8xx/console/console.c

    rb7f5447b r0eef948f  
    9090
    9191static void _BSP_null_char( char c ) {return;}
     92static void serial_putchar(const char c);
    9293
    9394BSP_output_char_function_type BSP_output_char = _BSP_null_char;
     
    519520};
    520521
    521 
     522#define EARLY_CONSOLE
     523#ifdef EARLY_CONSOLE
     524
     525#define MBX_CSR1        ((volatile unsigned char *)0xfa100000)
     526#define CSR1_COMEN      (unsigned char)0x02
     527#define PROFF_CONS      PROFF_SMC1
     528#define CPM_CR_CH_CONS  CPM_CR_CH_SMC1
     529#define SMC_INDEX       0
     530
     531#include <bsp/commproc.h>
     532
     533static cpm8xx_t *cpmp = (cpm8xx_t *)&(((immap_t *)IMAP_ADDR)->im_cpm);
     534
     535void
     536serial_init()
     537{
     538        volatile smc_t          *sp;
     539        volatile smc_uart_t     *up;
     540        volatile cbd_t  *tbdf,  *rbdf;
     541        volatile cpm8xx_t       *cp;
     542        unsigned int            dpaddr, memaddr;
     543        bd_t    *bd;
     544
     545        bd = eppcbugInfo;
     546       
     547        cp = cpmp;
     548        sp = (smc_t*)&(cp->cp_smc[SMC_INDEX]);
     549        up = (smc_uart_t *)&cp->cp_dparam[PROFF_CONS];
     550
     551        /* Disable transmitter/receiver.
     552        */
     553        sp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
     554
     555        if (*MBX_CSR1 & CSR1_COMEN) {
     556                /* COM1 is enabled.  Initialize SMC1 and use it for
     557                 * the console port.
     558                 */
     559
     560                /* Enable SDMA.
     561                */
     562                ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sdcr = 1;
     563
     564                /* Use Port B for SMCs instead of other functions.
     565                */
     566                cp->cp_pbpar |= 0x00000cc0;
     567                cp->cp_pbdir &= ~0x00000cc0;
     568                cp->cp_pbodr &= ~0x00000cc0;
     569
     570                /* Allocate space for two buffer descriptors in the DP ram.
     571                 * For now, this address seems OK, but it may have to
     572                 * change with newer versions of the firmware.
     573                 */
     574                dpaddr = 0x0800;
     575
     576                /* Grab a few bytes from the top of memory.  EPPC-Bug isn't
     577                 * running any more, so we can do this.
     578                 */
     579                memaddr = (bd->bi_memsize - 32) & ~15;
     580
     581                /* Set the physical address of the host memory buffers in
     582                 * the buffer descriptors.
     583                 */
     584                rbdf = (cbd_t *)&cp->cp_dpmem[dpaddr];
     585                rbdf->cbd_bufaddr = memaddr;
     586                rbdf->cbd_sc = 0;
     587                tbdf = rbdf + 1;
     588                tbdf->cbd_bufaddr = memaddr+4;
     589                tbdf->cbd_sc = 0;
     590
     591                /* Set up the uart parameters in the parameter ram.
     592                */
     593                up->smc_rbase = dpaddr;
     594                up->smc_tbase = dpaddr+sizeof(cbd_t);
     595                up->smc_rfcr = SMC_EB;
     596                up->smc_tfcr = SMC_EB;
     597
     598                /* Set UART mode, 8 bit, no parity, one stop.
     599                 * Enable receive and transmit.
     600                 */
     601                sp->smc_smcmr = smcr_mk_clen(9) |  SMCMR_SM_UART;
     602
     603                /* Mask all interrupts and remove anything pending.
     604                */
     605                sp->smc_smcm = 0;
     606                sp->smc_smce = 0xff;
     607
     608                /* Set up the baud rate generator.
     609                 * See 8xx_io/commproc.c for details.
     610                 */
     611                cp->cp_simode = 0x10000000;
     612                cp->cp_brgc1 =
     613                        ((((bd->bi_intfreq * 1000000)/16) / 9600) << 1) | CPM_BRG_EN;
     614
     615                /* Enable SMC1 for console output.
     616                */
     617                *MBX_CSR1 &= ~CSR1_COMEN;
     618        }
     619        else {
     620                /* SMCx is used as console port.
     621                */
     622                tbdf = (cbd_t *)&cp->cp_dpmem[up->smc_tbase];
     623                rbdf = (cbd_t *)&cp->cp_dpmem[up->smc_rbase];
     624
     625                /* Issue a stop transmit, and wait for it.
     626                */
     627                cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_CONS,
     628                                        CPM_CR_STOP_TX) | CPM_CR_FLG;
     629                while (cp->cp_cpcr & CPM_CR_FLG);
     630        }
     631
     632        /* Make the first buffer the only buffer.
     633        */
     634        tbdf->cbd_sc |= BD_SC_WRAP;
     635        rbdf->cbd_sc |= BD_SC_EMPTY | BD_SC_WRAP;
     636
     637        /* Single character receive.
     638        */
     639        up->smc_mrblr = 1;
     640        up->smc_maxidl = 0;
     641
     642        /* Initialize Tx/Rx parameters.
     643        */
     644        cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_CONS, CPM_CR_INIT_TRX) | CPM_CR_FLG;
     645        while (cp->cp_cpcr & CPM_CR_FLG);
     646
     647        /* Enable transmitter/receiver.
     648        */
     649        sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
     650        BSP_output_char = serial_putchar;
     651}
     652
     653void
     654serial_putchar(const char c)
     655{
     656        volatile cbd_t          *tbdf;
     657        volatile char           *buf;
     658        volatile smc_uart_t     *up;
     659
     660        up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_CONS];
     661        tbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_tbase];
     662
     663        /* Wait for last character to go.
     664        */
     665        buf = (char *)tbdf->cbd_bufaddr;
     666        while (tbdf->cbd_sc & BD_SC_READY);
     667
     668        *buf = c;
     669        tbdf->cbd_datlen = 1;
     670        tbdf->cbd_sc |= BD_SC_READY;
     671}
     672
     673char
     674serial_getc()
     675{
     676        volatile cbd_t          *rbdf;
     677        volatile char           *buf;
     678        volatile smc_uart_t     *up;
     679        char                    c;
     680
     681        up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_CONS];
     682        rbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];
     683
     684        /* Wait for character to show up.
     685        */
     686        buf = (char *)rbdf->cbd_bufaddr;
     687        while (rbdf->cbd_sc & BD_SC_EMPTY);
     688        c = *buf;
     689        rbdf->cbd_sc |= BD_SC_EMPTY;
     690
     691        return(c);
     692}
     693
     694int
     695serial_tstc()
     696{
     697        volatile cbd_t          *rbdf;
     698        volatile smc_uart_t     *up;
     699
     700        up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_CONS];
     701        rbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];
     702
     703        return(!(rbdf->cbd_sc & BD_SC_EMPTY));
     704}
     705
     706#endif
    522707/*
    523708 ***************
Note: See TracChangeset for help on using the changeset viewer.