void serial_setbrg (void) { UART_LINE_CTRL ulctrl; UART_CTRL uctrl; UART_BAUD_DIV ubd; serial_flush_output(); serial_flush_input(); /* control register */ uctrl.ui = 0x0; uctrl.bf.rxMode = 0x1; uctrl.bf.rxIrq = 0x0; uctrl.bf.txMode = 0x1; uctrl.bf.DSR = 0x0; uctrl.bf.sendBreak = 0x0; uctrl.bf.loopBack = 0x0; uart->m_ctrl.ui = uctrl.ui; /* line control register */ ulctrl.ui = 0x0; ulctrl.bf.wordLen = 0x3; /* 8 bit data */ ulctrl.bf.nStop = 0x0; /* 1 stop bit */ ulctrl.bf.parity = 0x0; /* no parity */ ulctrl.bf.clk = 0x0; /* internal clock */ ulctrl.bf.infra_red = 0x0; /* no infra_red */ uart->m_lineCtrl.ui = ulctrl.ui; ubd.ui = 0x0; /* see table on page 10-15 in SAMSUNG S3C4510B manual */ /* get correct divisor */ switch(gd->baudrate) { case 1200: ubd.bf.cnt0 = 1301; break; case 2400: ubd.bf.cnt0 = 650; break; case 4800: ubd.bf.cnt0 = 324; break; case 9600: ubd.bf.cnt0 = 162; break; case 19200: ubd.bf.cnt0 = 80; break; case 38400: ubd.bf.cnt0 = 40; break; case 57600: ubd.bf.cnt0 = 26; break; case 115200: ubd.bf.cnt0 = 13; break; } uart->m_baudDiv.ui = ubd.ui; uart->m_baudCnt = 0x0; uart->m_baudClk = 0x0; }
/* This routine is called when an interrupt for timer0 channel0 match occurs It incremnts the system tick counter, which holds global system time since boot This routine sets signal SIG_TIMER. */ void timerIRQ(void){ /* Clear interrupt for Channel 0 Match */ T0IR = 1; signal_set(SIG_TIMER); sys_time++; /* increment the system time */ #ifdef TRACE if (wdt_cnt == 0){ // Watchdog triggered, something bad happened. // Now we can spend some time in IRQ, it does not matter. serial_flush_output(); serial_outs("\nWDT "); serial_out_hex(cur_task); serial_out_hex(trace_flags); serial_outs("\n"); wdt_cnt = 200; } else wdt_cnt--; #endif }
void serial_setbrg (void) { DECLARE_GLOBAL_DATA_PTR; u32 divisor = 0; /* get correct divisor */ switch(gd->baudrate) { case 1200: #if CONFIG_S3C44B0_CLOCK_SPEED==66 divisor = 3124; #elif CONFIG_S3C44B0_CLOCK_SPEED==75 divisor = 3905; #else # error CONFIG_S3C44B0_CLOCK_SPEED undefined #endif break; case 9600: #if CONFIG_S3C44B0_CLOCK_SPEED==66 divisor = 390; #elif CONFIG_S3C44B0_CLOCK_SPEED==75 divisor = 487; #else # error CONFIG_S3C44B0_CLOCK_SPEED undefined #endif break; case 19200: #if CONFIG_S3C44B0_CLOCK_SPEED==66 divisor = 194; #elif CONFIG_S3C44B0_CLOCK_SPEED==75 divisor = 243; #else # error CONFIG_S3C44B0_CLOCK_SPEED undefined #endif break; case 38400: #if CONFIG_S3C44B0_CLOCK_SPEED==66 divisor = 97; #elif CONFIG_S3C44B0_CLOCK_SPEED==75 divisor = 121; #else # error CONFIG_S3C44B0_CLOCK_SPEED undefined #endif /* break; */ case 57600: #if CONFIG_S3C44B0_CLOCK_SPEED==66 divisor = 64; #elif CONFIG_S3C44B0_CLOCK_SPEED==75 divisor = 80; #else # error CONFIG_S3C44B0_CLOCK_SPEED undefined #endif /* break; */ case 115200: #if CONFIG_S3C44B0_CLOCK_SPEED==66 divisor = 32; #elif CONFIG_S3C44B0_CLOCK_SPEED==75 divisor = 40; #else # error CONFIG_S3C44B0_CLOCK_SPEED undefined #endif /* break; */ } serial_flush_output(); serial_flush_input(); UFCON0 = 0x0; ULCON0 = 0x03; UCON0 = 0x05; UBRDIV0 = divisor; UFCON1 = 0x0; ULCON1 = 0x03; UCON1 = 0x05; UBRDIV1 = divisor; for(divisor=0; divisor<100; divisor++) { /* NOP */ } }
/* This is a bit more fancy that need be so that it syncs even in nasty cases. I'be been unable to make it reliably sync up with the change baudrate open command. It likes to sit and say it's been reset, with no more action. So I took all that code out. I'd rather sync reliably at 9600 than wait forever for a possible 19200 connection. */ static void rdp_init (int cold, int tty) { int sync = 0; int type = cold ? RDP_OPEN_TYPE_COLD : RDP_OPEN_TYPE_WARM; int baudtry = 9600; time_t now = time (0); time_t stop_time = now + 10; /* Try and sync for 10 seconds, then give up */ while (time (0) < stop_time && !sync) { int restype; QUIT; serial_flush_input (io); serial_flush_output (io); if (tty) printf_unfiltered ("Trying to connect at %d baud.\n", baudtry); /* ** It seems necessary to reset an EmbeddedICE to get it going. ** This has the side benefit of displaying the startup banner. */ if (cold) { put_byte (RDP_RESET); while ((restype = serial_readchar (io, 1)) > 0) { switch (restype) { case SERIAL_TIMEOUT: break; case RDP_RESET: /* Sent at start of reset process: ignore */ break; default: printf_unfiltered ("%c", isgraph (restype) ? restype : ' '); break; } } if (restype == 0) { /* Got end-of-banner mark */ printf_filtered ("\n"); } } put_byte (RDP_OPEN); put_byte (type | RDP_OPEN_TYPE_RETURN_SEX); put_word (0); while (!sync && (restype = serial_readchar (io, 1)) > 0) { if (remote_debug) fprintf_unfiltered (gdb_stdlog, "[%02x]\n", restype); switch (restype) { case SERIAL_TIMEOUT: break; case RDP_RESET: while ((restype = serial_readchar (io, 1)) == RDP_RESET) ; do { printf_unfiltered ("%c", isgraph (restype) ? restype : ' '); } while ((restype = serial_readchar (io, 1)) > 0); if (tty) { printf_unfiltered ("\nThe board has sent notification that it was reset.\n"); printf_unfiltered ("Waiting for it to settle down...\n"); } sleep (3); if (tty) printf_unfiltered ("\nTrying again.\n"); cold = 0; break; default: break; case RDP_RES_VALUE: { int resval = serial_readchar (io, 1); if (remote_debug) fprintf_unfiltered (gdb_stdlog, "[%02x]\n", resval); switch (resval) { case SERIAL_TIMEOUT: break; case RDP_RES_VALUE_LITTLE_ENDIAN: #if 0 /* FIXME: cagney/2003-11-22: Ever since the ARM was multi-arched (in 2002-02-08), this assignment has had no effect. There needs to be some sort of check/decision based on the current architecture's byte-order vs the remote target's byte order. For the moment disable the assignment to keep things building. */ target_byte_order = BFD_ENDIAN_LITTLE; #endif sync = 1; break; case RDP_RES_VALUE_BIG_ENDIAN: #if 0 /* FIXME: cagney/2003-11-22: Ever since the ARM was multi-arched (in 2002-02-08), this assignment has had no effect. There needs to be some sort of check/decision based on the current architecture's byte-order vs the remote target's byte order. For the moment disable the assignment to keep things building. */ target_byte_order = BFD_ENDIAN_BIG; #endif sync = 1; break; default: break; } } } } } if (!sync) { error ("Couldn't reset the board, try pressing the reset button"); } }