Changeset c91fe327 in mainline


Ignore:
Timestamp:
2012-03-11T03:54:57Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
60a025d
Parents:
13be128d
Message:

amdm37x_uar: Implement simple receive functions.

Disable port setup for now (defaults work nice on qemu)

Location:
kernel/genarch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/include/drivers/amdm37x_uart/amdm37x_uart.h

    r13be128d rc91fe327  
    3939#include <typedefs.h>
    4040#include <console/chardev.h>
     41#include <ddi/irq.h>
    4142
    4243/* AMDM37x TRM p. 2950 */
     
    431432        /** RX/TX empty status */
    432433        ioport32_t isr2;
    433 #define AMDM37x_UART_IER2_RX_FIFO_EMPTY_FLAG  (1 << 0)
    434 #define AMDM37x_UART_IER2_TX_FIFO_EMPTY_FLAG  (1 << 1)
     434#define AMDM37x_UART_ISR2_RX_FIFO_EMPTY_FLAG  (1 << 0)
     435#define AMDM37x_UART_ISR2_TX_FIFO_EMPTY_FLAG  (1 << 1)
    435436
    436437        uint32_t padd2_[3];
     
    445446        indev_t *indev;
    446447        outdev_t outdev;
     448        irq_t irq;
    447449} amdm37x_uart_t;
    448450
  • kernel/genarch/src/drivers/amdm37x_uart/amdm37x_uart.c

    r13be128d rc91fe327  
    3535
    3636#include <genarch/drivers/amdm37x_uart/amdm37x_uart.h>
     37#include <ddi/device.h>
    3738#include <str.h>
    3839#include <mm/km.h>
     
    6364};
    6465
     66static irq_ownership_t amdm37x_uart_claim(irq_t *irq)
     67{
     68        return IRQ_ACCEPT;
     69}
     70
     71static void amdm37x_uart_handler(irq_t *irq)
     72{
     73        amdm37x_uart_t *uart = irq->instance;
     74//TODO enable while checking when RX FIFO is used instead of single char.
     75//      while (!(uart->regs->isr2 & AMDM37x_UART_ISR2_RX_FIFO_EMPTY_FLAG)) {
     76                const uint8_t val = uart->regs->rhr;
     77                if (uart->indev)
     78                        indev_push_character(uart->indev, val);
     79//      }
     80}
     81
    6582bool amdm37x_uart_init(
    6683    amdm37x_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size)
     
    6986        uart->regs = (void *)km_map(addr, size, PAGE_NOT_CACHEABLE);
    7087
     88        ASSERT(uart->regs);
     89
    7190        /* See TI OMAP35X TRM ch 17.5.1.1 p. 2732 for startup routine */
    72 
     91#if 0
    7392        /* Soft reset the port */
    7493        uart->regs->sysc = AMDM37x_UART_SYSC_SOFTRESET_FLAG;
     
    106125        /* Disable interrupts */
    107126        uart->regs->ier = 0;
    108 
     127#endif
    109128        /* Setup outdev */
    110129        outdev_initialize("amdm37x_uart_dev", &uart->outdev, &amdm37x_uart_ops);
    111130        uart->outdev.data = uart;
     131
     132        /* Initialize IRQ */
     133        irq_initialize(&uart->irq);
     134        uart->irq.devno = device_assign_devno();
     135        uart->irq.inr = interrupt;
     136        uart->irq.claim = amdm37x_uart_claim;
     137        uart->irq.handler = amdm37x_uart_handler;
     138        uart->irq.instance = uart;
     139        irq_register(&uart->irq);
    112140
    113141        return true;
     
    116144void amdm37x_uart_input_wire(amdm37x_uart_t *uart, indev_t *indev)
    117145{
    118         // TODO implement
    119         // register interrupt
    120         // set rx fifo
    121         // set rx fifo threshold to 1
     146        ASSERT(uart);
     147        /* Set indev */
     148        uart->indev = indev;
     149        /* Enable interrupt on receive */
     150        uart->regs->ier |= AMDM37x_UART_IER_RHR_IRQ_FLAG;
     151
     152        // TODO set rx fifo
     153        // TODO set rx fifo threshold to 1
    122154}
    123155
Note: See TracChangeset for help on using the changeset viewer.