Changeset dff90fa7 in mainline for kernel/genarch


Ignore:
Timestamp:
2013-06-05T19:41:12Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
74dcc07
Parents:
f288d85 (diff), 6db5d4b (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:

mainline changes

Location:
kernel/genarch
Files:
15 added
1 deleted
2 edited
43 moved

Legend:

Unmodified
Added
Removed
  • kernel/genarch/Makefile.inc

    rf288d85 rdff90fa7  
    6666        GENARCH_SOURCES += \
    6767                genarch/src/fb/font-8x16.c \
    68                 genarch/src/fb/logo-196x66.c \
    6968                genarch/src/fb/fb.c \
    7069                genarch/src/fb/bfb.c
     
    106105endif
    107106
    108 ifeq ($(CONFIG_AMDM37X_UART),y)
     107ifeq ($(CONFIG_OMAP_UART),y)
    109108        GENARCH_SOURCES += \
    110                 genarch/src/drivers/amdm37x_uart/amdm37x_uart.c
     109                genarch/src/drivers/omap/uart.c
     110endif
     111
     112ifeq ($(CONFIG_AM335X_TIMERS),y)
     113        GENARCH_SOURCES += \
     114                genarch/src/drivers/am335x/timer.c
    111115endif
    112116
  • kernel/genarch/src/drivers/omap/uart.c

    rf288d85 rdff90fa7  
    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
  • kernel/genarch/src/fb/fb.c

    rf288d85 rdff90fa7  
    3535
    3636#include <genarch/fb/font-8x16.h>
    37 #include <genarch/fb/logo-196x66.h>
    3837#include <genarch/fb/fb.h>
    3938#include <console/chardev.h>
     
    5352#include <byteorder.h>
    5453
    55 #define BG_COLOR     0x000080
    56 #define FG_COLOR     0xffff00
     54#define BG_COLOR     0x001620
     55#define FG_COLOR     0xf3cf65
    5756#define INV_COLOR    0xaaaaaa
    5857
     
    9392        unsigned int yres;
    9493       
    95         unsigned int ylogo;
    96         unsigned int ytrim;
    9794        unsigned int rowtrim;
    9895       
     
    213210}
    214211
    215 /** Hide logo and refresh screen
    216  *
    217  */
    218 static void logo_hide(fb_instance_t *instance)
    219 {
    220         instance->ylogo = 0;
    221         instance->ytrim = instance->yres;
    222         instance->rowtrim = instance->rows;
    223        
    224         if ((!instance->parea.mapped) || (console_override))
    225                 fb_redraw_internal(instance);
    226 }
    227 
    228212/** Draw character at given position
    229213 *
     
    236220        unsigned int yd;
    237221       
    238         if (y >= instance->ytrim)
    239                 logo_hide(instance);
    240        
    241222        if (!overlay)
    242223                instance->backbuf[BB_POS(instance, col, row)] = glyph;
     
    244225        if ((!instance->parea.mapped) || (console_override)) {
    245226                for (yd = 0; yd < FONT_SCANLINES; yd++)
    246                         memcpy(&instance->addr[FB_POS(instance, x, y + yd + instance->ylogo)],
     227                        memcpy(&instance->addr[FB_POS(instance, x, y + yd)],
    247228                            &instance->glyphs[GLYPH_POS(instance, glyph, yd)],
    248229                            instance->glyphscanline);
     
    256237static void screen_scroll(fb_instance_t *instance)
    257238{
    258         if (instance->ylogo > 0) {
    259                 logo_hide(instance);
    260                 return;
    261         }
    262        
    263239        if ((!instance->parea.mapped) || (console_override)) {
    264240                unsigned int row;
     
    412388static void fb_redraw_internal(fb_instance_t *instance)
    413389{
    414         if (instance->ylogo > 0) {
    415                 unsigned int y;
    416                
    417                 for (y = 0; y < LOGO_HEIGHT; y++) {
    418                         unsigned int x;
    419                        
    420                         for (x = 0; x < instance->xres; x++)
    421                                 instance->rgb_conv(&instance->addr[FB_POS(instance, x, y)],
    422                                     (x < LOGO_WIDTH) ?
    423                                     fb_logo[y * LOGO_WIDTH + x] :
    424                                     LOGO_COLOR);
    425                 }
    426         }
    427        
    428390        unsigned int row;
    429391       
    430392        for (row = 0; row < instance->rowtrim; row++) {
    431                 unsigned int y = instance->ylogo + ROW2Y(row);
     393                unsigned int y = ROW2Y(row);
    432394                unsigned int yd;
    433395               
     
    452414                    (instance->xres - COL2X(instance->cols)) * instance->pixelbytes;
    453415               
    454                 for (y = instance->ylogo; y < instance->yres; y++)
     416                for (y = 0; y < instance->yres; y++)
    455417                        memcpy(&instance->addr[FB_POS(instance, COL2X(instance->cols), y)],
    456418                            instance->bgscan, size);
    457419        }
    458420       
    459         if (ROW2Y(instance->rowtrim) + instance->ylogo < instance->yres) {
     421        if (ROW2Y(instance->rowtrim) < instance->yres) {
    460422                unsigned int y;
    461423               
    462                 for (y = ROW2Y(instance->rowtrim) + instance->ylogo;
    463                     y < instance->yres; y++)
     424                for (y = ROW2Y(instance->rowtrim); y < instance->yres; y++)
    464425                        memcpy(&instance->addr[FB_POS(instance, 0, y)],
    465426                            instance->bgscan, instance->bgscanbytes);
     
    567528        instance->rows = Y2ROW(instance->yres);
    568529       
    569         if (instance->yres > LOGO_HEIGHT) {
    570                 instance->ylogo = LOGO_HEIGHT;
    571                 instance->rowtrim = instance->rows - Y2ROW(instance->ylogo);
    572                 if (instance->ylogo % FONT_SCANLINES > 0)
    573                         instance->rowtrim--;
    574                 instance->ytrim = ROW2Y(instance->rowtrim);
    575         } else {
    576                 instance->ylogo = 0;
    577                 instance->ytrim = instance->yres;
    578                 instance->rowtrim = instance->rows;
    579         }
     530        instance->rowtrim = instance->rows;
    580531       
    581532        instance->glyphscanline = FONT_WIDTH * instance->pixelbytes;
Note: See TracChangeset for help on using the changeset viewer.