This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART at U_BOOT

Hello all,

How to initialize uart at u-boot i have added in the board/ti/evm/evm.h as   MUX_VAL(CP(GPMC_WAIT2),         (IEN  | PTU | EN  | M2))

Also added the Base address in the include/asm/arch-omap3/omap3.h   as #define OMAP34XX_UART4                  0x49042000

do i need to do anything to use the uart port at u-boot level .can any help on this .

Thanks,

Ranjith.

  • Hello Ranjith,

    Apart from selecting serial console console configuration in the u-boot, some changes also need to be incorporated in the x-loader, such as:

    • Enable UART4 Clocks: /board/omap3evm/omap3evm.c
    • Set mux values accordingly: a/board/omap3evm/omap3evm.c
    • Select serial console configuration: include/configs/omap3evm.h

    Hope this helps.

    Regards,

    N.S.SriHarsha

  • Hello SriHarsha,

            I have done the change but i dint find any UART4 related clocks in board/ti/evm/evm.c . actually am working smartcard with UART at u-boot level.

    Do i need to set or get any port attributes because i have a smart card application which is supported at kernel .i am patching the same application in u-boot so i am getting many errors in that .

    Thanks,

    Ranjith.

  • Hello Ranjith,

    UART4 Clocks have to be enabled in the "per_clocks_enable" function of the x-loader sources.

    Below attached is the snapshot.

  • Hey SriHarsha,

    Thanks for your help .have you worked on smart cart on UART.

    Thanks,

    Ranjith.

  • Hey Ranjith,

    I have not worked on it and may not be of any help.

    Regards,

    N.S.SriHarsha

  • Hello SriHarsha,

     i am trying to write and read the data to UART4 at the boot command that is u-boot after HIT any key to stop autoboot .so, can u help me how to write data in to UART4

    actually am calling serial_init(); in common/main.c

    which is calling driver/serial/serial.c

    so,can u help me how to read and write.

    Thanks,

    Ranjith

  • Hello SriHarsha,

    Could you please help UART4 at u-boot level how to write and read in u-boot.

    Thanks,

    Ranjith


  • Hi Ranjith,

    We have used a custom driver for reading and writing. Below attached is the snapshot of the same.

    For some reason, I'm not able to attach the C file.

    /* includes */
    #include <common.h>
    #include "types.h"
    #include "uart_drv.h"
    #include "uart_utils.h"
    #include "omap3530evm.h"

    status_t uart_config(U8 uart_no, U16 baudrate, U8 data, U8 stop, U8 parity)
    {
        U32 b = uart_base_addr[uart_no];

        uart_func_clk_en();

        switch (uart_no) {
        case UART1:
            mux_setup_uart1();
            break;

        case UART2:
            mux_setup_uart2();
            break;

        case UART3:
            /* Use the mux settings already set by the ROM code. */
            break;

        default:
            return FAILURE;
        }

        /* RESET OF UART */
        UART_REG_MDR1(b) = UART_RESET_MODE;
        while (UART_REG_MDR1(b) != UART_RESET_MODE) ;    /* wait for reset */

        /* UART CONFIGURATION */
        UART_REG_LCR(b) = 0xBF;
        UART_REG_EFR(b) |= (1 << 4);
        UART_REG_LCR(b) = (data | (stop << 2) | (parity << 3) | 0x80);
        UART_REG_MCR(b) = (1 << 6);
        UART_REG_TLR(b) = 0x00;
        UART_REG_FCR(b) = 0x87;    /* 56 byte RX FIFO and 8 byte TX FIFO */
        UART_REG_DLL(b) = (0xFF & uart_baudrate[baudrate]);
        UART_REG_DLH(b) = (0xFF & (uart_baudrate[baudrate] >> 8));

        UART_REG_LCR(b) &= 0x7F;
        UART_REG_IIR(b);
        UART_REG_IER(b) = 0x00;

        UART_REG_MDR1(b) = UART_MODE;

        return SUCCESS;
    }

    status_t uart_init(U8 uart_no, U8 parity)
    {
        S32 ret_val = SUCCESS;

        uart_config(uart_no, UART_115200, UART_DATABITS_8, UART_STOPBITS_1, parity);

        return ret_val;
    }

    status_t uart_deinit(U8 uart_no)
    {
        U32 b;

        b = uart_base_addr[uart_no];
        switch (UART_REG_MDR1(b) & 0x7) {    /* Get MDR1[2:0] */
        case UART_16X_MODE:
        case UART_16X_AUTO_BAUD:
        case UART_13X_MODE:
            /*
             ** Wait for the last transmitted bytes to leave the UART HW before
             ** deiniting (needed for reset after download).
             */
            while ((UART_REG_LSR(b) & (1 << 6) /*TX_SR_E */ ) == 0) ;
            break;
        default:
            break;
        }

        return SUCCESS;
    }

    static
    void dg_serial_putc(U32 b, REG_U8 c)
    {
        while ((UART_REG_LSR(b) & LSR_THR_EMPTY) == 0) ;
        UART_REG_THR(b) = c;
    }

    static
    U8 dg_serial_getc(U32 b)
    {
        while ((UART_REG_LSR(b) & LSR_DATA_READY) == 0) ;
        return (UART_REG_RHR(b));
    }

    S32 uart_read(U8 uart_no, U8 * buf, U32 size)
    {
        U32 b = uart_base_addr[uart_no];
        U32 count;
        REG_U8 *pstr = buf;

        DEBUG("UART Num  = %d\n", uart_no);
        DEBUG("UART Base = 0x%X\n", b);

        for (count = 0; count < size; count++) {
            pstr[count] = dg_serial_getc(b);
        }

        return size;
    }

    S32 uart_write(U8 uart_no, U8 * buf, U32 size)
    {
        U32 b = uart_base_addr[uart_no];
        U32 count;
        REG_U8 *pstr = buf;

        DEBUG("UART Num  = %d\n", uart_no);
        DEBUG("UART Base = 0x%X\n", b);

        for (count = 0; count < size; count++) {
            dg_serial_putc(b, pstr[count]);
        }

        return size;
    }

    Hope this helps.

    Regards,

    N.S.SriHarsha

  • Hello SriHarsha,

           Actually i am using the UART 1 for serial console configuration and UART 4 for Another purpose could you tell how use the UART 4 because if i am tring to do anything like

    serial_init_uart()
    {
            int clock_divisor;
            printf("My INITIALIZATION\n");
            #ifdef CONFIG_SYS_NS16550_COM4
            clock_divisor = calc_divisor(serial_ports[3]);
            NS16550_init(serial_ports[3], clock_divisor);
            printf("END OF INIT\N");
            _serial_putc('E',3);
            _serial_getc(3);
            #endif
    }

    Here i am calling my  own function but it is not setting the clock for UART 4 . can you help me out in this.

    Thanks,

    Ranjith.