Ignore:
Timestamp:
2013-07-24T17:42:25Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
69b264a9
Parents:
52f1882 (diff), cffa14e6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge mainline changes.

usb hc macro changes from mainline were reverted, too many conflicts

File:
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/drivers/omap/uart.c

    r52f1882 rdb71e2a  
    11/*
    22 * Copyright (c) 2012 Jan Vesely
     3 * Copyright (c) 2013 Maurizio Lombardi
    34 * All rights reserved.
    45 *
     
    3132/**
    3233 * @file
    33  * @brief Texas Instruments AMDM37x on-chip uart serial line driver.
     34 * @brief Texas Instruments OMAP on-chip uart serial line driver.
    3435 */
    3536
    36 #include <genarch/drivers/amdm37x_uart/amdm37x_uart.h>
     37#include <genarch/drivers/omap/uart.h>
    3738#include <ddi/device.h>
    3839#include <str.h>
    3940#include <mm/km.h>
    4041
    41 static void amdm37x_uart_txb(amdm37x_uart_t *uart, uint8_t b)
     42static void omap_uart_txb(omap_uart_t *uart, uint8_t b)
    4243{
    4344        /* Wait for buffer */
    44         while (uart->regs->ssr & AMDM37x_UART_SSR_TX_FIFO_FULL_FLAG);
     45        while (uart->regs->ssr & OMAP_UART_SSR_TX_FIFO_FULL_FLAG);
    4546        /* Write to the outgoing fifo */
    4647        uart->regs->thr = b;
    4748}
    4849
    49 static void amdm37x_uart_putchar(outdev_t *dev, wchar_t ch)
     50static void omap_uart_putchar(outdev_t *dev, wchar_t ch)
    5051{
    51         amdm37x_uart_t *uart = dev->data;
     52        omap_uart_t *uart = dev->data;
    5253        if (!ascii_check(ch)) {
    53                 amdm37x_uart_txb(uart, U_SPECIAL);
     54                omap_uart_txb(uart, U_SPECIAL);
    5455        } else {
    5556                if (ch == '\n')
    56                         amdm37x_uart_txb(uart, '\r');
    57                 amdm37x_uart_txb(uart, ch);
     57                        omap_uart_txb(uart, '\r');
     58                omap_uart_txb(uart, ch);
    5859        }
    5960}
    6061
    61 static outdev_operations_t amdm37x_uart_ops = {
     62static outdev_operations_t omap_uart_ops = {
    6263        .redraw = NULL,
    63         .write = amdm37x_uart_putchar,
     64        .write = omap_uart_putchar,
    6465};
    6566
    66 static irq_ownership_t amdm37x_uart_claim(irq_t *irq)
     67static irq_ownership_t omap_uart_claim(irq_t *irq)
    6768{
    6869        return IRQ_ACCEPT;
    6970}
    7071
    71 static void amdm37x_uart_handler(irq_t *irq)
     72static void omap_uart_handler(irq_t *irq)
    7273{
    73         amdm37x_uart_t *uart = irq->instance;
     74        omap_uart_t *uart = irq->instance;
    7475        while ((uart->regs->rx_fifo_lvl)) {
    7576                const uint8_t val = uart->regs->rhr;
     
    8081}
    8182
    82 bool amdm37x_uart_init(
    83     amdm37x_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size)
     83bool omap_uart_init(
     84    omap_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size)
    8485{
    8586        ASSERT(uart);
     
    8889        ASSERT(uart->regs);
    8990
    90         /* See TI OMAP35X TRM ch 17.5.1.1 p. 2732 for startup routine */
    91 #if 0
    9291        /* Soft reset the port */
    93         uart->regs->sysc = AMDM37x_UART_SYSC_SOFTRESET_FLAG;
    94         while (!(uart->regs->syss & AMDM37x_UART_SYSS_RESETDONE_FLAG)) ;
    95 #endif
     92        uart->regs->sysc = OMAP_UART_SYSC_SOFTRESET_FLAG;
     93        while (!(uart->regs->syss & OMAP_UART_SYSS_RESETDONE_FLAG));
     94
     95        /* Disable the UART module */
     96        uart->regs->mdr1 |= OMAP_UART_MDR_MS_DISABLE;
    9697
    9798        /* Enable access to EFR register */
    98         const uint8_t lcr = uart->regs->lcr; /* Save old value */
    9999        uart->regs->lcr = 0xbf;              /* Sets config mode B */
    100100
    101101        /* Enable access to TCL_TLR register */
    102         const bool enhanced = uart->regs->efr & AMDM37x_UART_EFR_ENH_FLAG;
    103         uart->regs->efr |= AMDM37x_UART_EFR_ENH_FLAG; /* Turn on enh. */
     102        const bool enhanced = uart->regs->efr & OMAP_UART_EFR_ENH_FLAG;
     103        uart->regs->efr |= OMAP_UART_EFR_ENH_FLAG; /* Turn on enh. */
    104104        uart->regs->lcr = 0x80;              /* Config mode A */
    105105
    106106        /* Set default (val 0) triggers, disable DMA enable FIFOs */
    107         const bool tcl_tlr = uart->regs->mcr & AMDM37x_UART_MCR_TCR_TLR_FLAG;
     107        const bool tcl_tlr = uart->regs->mcr & OMAP_UART_MCR_TCR_TLR_FLAG;
    108108        /* Enable access to tcr and tlr registers */
    109         uart->regs->mcr |= AMDM37x_UART_MCR_TCR_TLR_FLAG;
     109        uart->regs->mcr |= OMAP_UART_MCR_TCR_TLR_FLAG;
    110110
    111111        /* Enable FIFOs */
    112         uart->regs->fcr = AMDM37x_UART_FCR_FIFO_EN_FLAG;
     112        uart->regs->fcr = OMAP_UART_FCR_FIFO_EN_FLAG;
    113113
    114         /* Eneble fine granularity for RX FIFO and set trigger level to 1,
    115          * TX FIFO, trigger level is irelevant*/
    116         uart->regs->lcr = 0xbf;              /* Sets config mode B */
    117         uart->regs->scr = AMDM37x_UART_SCR_RX_TRIG_GRANU1_FLAG;
    118         uart->regs->tlr = 1 << AMDM37x_UART_TLR_RX_FIFO_TRIG_SHIFT;
     114        /* Enable fine granularity for RX FIFO and set trigger level to 1,
     115         * TX FIFO, trigger level is irrelevant*/
     116        uart->regs->lcr = 0xBF;              /* Sets config mode B */
     117        uart->regs->scr = OMAP_UART_SCR_RX_TRIG_GRANU1_FLAG;
     118        uart->regs->tlr = 1 << OMAP_UART_TLR_RX_FIFO_TRIG_SHIFT;
     119
     120        /* Sets config mode A */
     121        uart->regs->lcr = 0x80;
     122        /* Restore tcl_tlr access flag */
     123        if (!tcl_tlr)
     124                uart->regs->mcr &= ~OMAP_UART_MCR_TCR_TLR_FLAG;
     125        /* Sets config mode B */
     126        uart->regs->lcr = 0xBF;
     127
     128        /* Set the divisor value to get a baud rate of 115200 bps */
     129        uart->regs->dll = 0x1A;
     130        uart->regs->dlh = 0x00;
    119131
    120132        /* Restore enhanced */
    121133        if (!enhanced)
    122                 uart->regs->efr &= ~AMDM37x_UART_EFR_ENH_FLAG;
     134                uart->regs->efr &= ~OMAP_UART_EFR_ENH_FLAG;
    123135
    124         uart->regs->lcr = 0x80;              /* Config mode A */
    125         /* Restore tcl_lcr access flag*/
    126         if (!tcl_tlr)
    127                 uart->regs->mcr &= ~AMDM37x_UART_MCR_TCR_TLR_FLAG;
     136        /* Set the DIV_EN bit to 0 */
     137        uart->regs->lcr &= ~OMAP_UART_LCR_DIV_EN_FLAG;
     138        /* Set the BREAK_EN bit to 0 */
     139        uart->regs->lcr &= ~OMAP_UART_LCR_BREAK_EN_FLAG;
     140        /* No parity */
     141        uart->regs->lcr &= ~OMAP_UART_LCR_PARITY_EN_FLAG;
     142        /* Stop = 1 bit */
     143        uart->regs->lcr &= ~OMAP_UART_LCR_NB_STOP_FLAG;
     144        /* Char length = 8 bits */
     145        uart->regs->lcr |= OMAP_UART_LCR_CHAR_LENGTH_8BITS;
    128146
    129         /* Restore lcr */
    130         uart->regs->lcr = lcr;
     147        /* Enable the UART module */
     148        uart->regs->mdr1 &= (OMAP_UART_MDR_MS_UART16 &
     149            ~OMAP_UART_MDR_MS_MASK);
    131150
    132151        /* Disable interrupts */
     
    134153
    135154        /* Setup outdev */
    136         outdev_initialize("amdm37x_uart_dev", &uart->outdev, &amdm37x_uart_ops);
     155        outdev_initialize("omap_uart_dev", &uart->outdev, &omap_uart_ops);
    137156        uart->outdev.data = uart;
    138157
     
    141160        uart->irq.devno = device_assign_devno();
    142161        uart->irq.inr = interrupt;
    143         uart->irq.claim = amdm37x_uart_claim;
    144         uart->irq.handler = amdm37x_uart_handler;
     162        uart->irq.claim = omap_uart_claim;
     163        uart->irq.handler = omap_uart_handler;
    145164        uart->irq.instance = uart;
    146165
     
    148167}
    149168
    150 void amdm37x_uart_input_wire(amdm37x_uart_t *uart, indev_t *indev)
     169void omap_uart_input_wire(omap_uart_t *uart, indev_t *indev)
    151170{
    152171        ASSERT(uart);
     
    156175        irq_register(&uart->irq);
    157176        /* Enable interrupt on receive */
    158         uart->regs->ier |= AMDM37x_UART_IER_RHR_IRQ_FLAG;
     177        uart->regs->ier |= OMAP_UART_IER_RHR_IRQ_FLAG;
    159178}
    160179
     
    162181 * @}
    163182 */
     183
Note: See TracChangeset for help on using the changeset viewer.