/* * Intialise the serial port with given baudrate */ int serial_init_port (int port) { int ret; unsigned port_base = port_base_addrs[port]; // serial_puts_port(port," "); while((readl(P_UART_STATUS(port_base)) & (UART_STAT_MASK_XMIT_BUSY))); writel(0,P_UART_CONTROL(port_base)); ret = serial_set_pin_port(port); if (ret < 0) return -1; serial_setbrg_port(port); #ifndef CONFIG_SERIAL_STP_BITS #define CONFIG_SERIAL_STP_BITS 1 #endif serial_set_stop_port(port,CONFIG_SERIAL_STP_BITS); #ifndef CONFIG_SERIAL_PRTY_TYPE #define CONFIG_SERIAL_PRTY_TYPE 0 #endif serial_set_parity_port(port,CONFIG_SERIAL_PRTY_TYPE); #ifndef CONFIG_SERIAL_CHAR_LEN #define CONFIG_SERIAL_CHAR_LEN 8 #endif serial_set_dlen_port(port,CONFIG_SERIAL_CHAR_LEN); writel(readl(P_UART_CONTROL(port_base)) | UART_CNTL_MASK_TX_EN | UART_CNTL_MASK_RX_EN, P_UART_CONTROL(port_base)); while(!(readl(P_UART_STATUS(port_base)) & UART_STAT_MASK_TFIFO_EMPTY)); serial_reset_port(port); while((readl(P_UART_STATUS(port_base)) & (UART_STAT_MASK_XMIT_BUSY))); serial_putc_port(port,'\n'); return 0; }
static void serial_init(unsigned set,unsigned tag) { if(arc_param->serial_disable) return; /* baud rate */ /*unsigned baud_para=0;*/ if(tag){//reset uart. setbits_le32(P_AO_RTI_GEN_CNTL_REG0,1<<17); clrbits_le32(P_AO_RTI_GEN_CNTL_REG0,1<<17); delay_ms(10); //delay_tick(32*1000); //delay_tick(32*1000); } writel((set&0xfff) | UART_STP_BIT | UART_PRTY_BIT | UART_CHAR_LEN //please do not remove these setting , jerry.yu | UART_CNTL_MASK_TX_EN | UART_CNTL_MASK_RX_EN | UART_CNTL_MASK_RST_TX | UART_CNTL_MASK_RST_RX | UART_CNTL_MASK_CLR_ERR ,P_UART_CONTROL(UART_PORT_CONS)); clrsetbits_le32(P_AO_UART_MISC ,0xf<<20,(set&0xf000)<<8); serial_set_pin_port(UART_PORT_CONS); clrbits_le32(P_UART_CONTROL(UART_PORT_CONS), UART_CNTL_MASK_RST_TX | UART_CNTL_MASK_RST_RX | UART_CNTL_MASK_CLR_ERR); }
SPL_STATIC_FUNC void serial_init(unsigned set) { /* baud rate */ writel(set |UART_CNTL_MASK_RST_TX |UART_CNTL_MASK_RST_RX |UART_CNTL_MASK_CLR_ERR |UART_CNTL_MASK_TX_EN |UART_CNTL_MASK_RX_EN ,P_UART_CONTROL(UART_PORT_CONS)); switch(readl(0xd9040004)) { case 0x74e: //M8B revA case 0xb72: //M8M2 revA writel( (1<<24)|(1 << 23)|((8000000/(CONFIG_BAUDRATE)) -1),0xc81004d4); // set xtal as M8B/M8M2 uart-ao clock source,xtal is 24000000, //new baudrate formula is (24000000/3/baudrate),0xc81004d4 is AO_UART0_REG5 address break; } serial_set_pin_port(UART_PORT_CONS); clrbits_le32(P_UART_CONTROL(UART_PORT_CONS), UART_CNTL_MASK_RST_TX | UART_CNTL_MASK_RST_RX | UART_CNTL_MASK_CLR_ERR); }