s3c2440 uart 初始化
我写了一个简单的启动程序,从Nand Flash启动,然后将代码从Nand Flash搬到RAM中去执行,在RAM中进行UART初始化。可是最终运行时串口没有输出。
UART初始化:
int serial_init(void)
{
volatile struct mini2440_uart *uart = (volatile struct mini2440_uart *)MINI2440_UART0_BASE;
unsigned long reg = 0, pclk;
#ifdef UART_FIFO
/* FIFO enable, Tx/Rx FIFO clear */
uart->ufcon = 0x07;
#else
uart->ufcon = 0x0;
#endif
uart->umcon = 0x0;
/* Normal,No parity,1 stop,8 bit */
uart->ulcon = 0x03;
/*
* tx=level,rx=edge,disable timeout int.,enable rx error int.,
* normal,interrupt or polling
*/
uart->ucon = 0x0245;
pclk = get_pclk();
if (!pclk)
return -1;
/* value is calculated so : (int)(PCLK/(16*baudrate)) -1 */
reg = (int)(pclk / (16*BAUDRATE)) - 1;
uart->ubrdiv = reg;
pll_delay(100);
pll_delay(0x1000000);
leds(1);
PUTC('H');PUTC('e');PUTC('l');PUTC('l');PUTC('o');
//PUTS("serial init ok!!!\r\n");
leds(2);
return (0);
}
start_code:
/*
* set the cpu to SVC32 mode
*/
mrsr0, cpsr
bicr0, r0, #0x1f
orrr0, r0, #0xd3
msrcpsr, r0
#define pWTCON0x53000000
#define INTMSK0x4a000008
#define INTSUBMSK0x4a00001c
/* turn off watchdog */
ldrr0, =pWTCON
movr1, #0x0
strr1, [r0]
/*
* mask all IRQs by setting all bits in the INTMR - default
*/
movr1, #0xffffffff
ldrr0, =INTMSK
strr1, [r0]
ldrr1, =0x7ff
ldrr0, =INTSUBMSK
strr1, [r0]
ldrr0, =0x56000010/* GPBCON */
ldrr1, =0x00015400/* GPB 5,6,7,8 output */
strr1, [r0]
ldrr0, =0x56000014/* GPBDAT */
movr1, #0
mvnr1, r1, lsl #5
strr1, [r0]
bl cpu_init_crit
#define RELOC_ADDR0x30000000
#define RELOC_OFF0x30000000
adrlr, here
ldrr0, =RELOC_OFF
addlr, lr, r0
ldrr0, =RELOC_ADDR
brelocate_code
here:
ldrsp, =CONFIG_SYS_INIT_SP_ADDR
bicsp, sp, #7/* 8-byte alignment */
bl debug
blserial_init
adrr0, current
current:
blafter_relocate