Changeset dff90fa7 in mainline for kernel/genarch
- Timestamp:
- 2013-06-05T19:41:12Z (12 years ago)
- 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. - Location:
- kernel/genarch
- Files:
-
- 15 added
- 1 deleted
- 2 edited
- 43 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/Makefile.inc
rf288d85 rdff90fa7 66 66 GENARCH_SOURCES += \ 67 67 genarch/src/fb/font-8x16.c \ 68 genarch/src/fb/logo-196x66.c \69 68 genarch/src/fb/fb.c \ 70 69 genarch/src/fb/bfb.c … … 106 105 endif 107 106 108 ifeq ($(CONFIG_ AMDM37X_UART),y)107 ifeq ($(CONFIG_OMAP_UART),y) 109 108 GENARCH_SOURCES += \ 110 genarch/src/drivers/amdm37x_uart/amdm37x_uart.c 109 genarch/src/drivers/omap/uart.c 110 endif 111 112 ifeq ($(CONFIG_AM335X_TIMERS),y) 113 GENARCH_SOURCES += \ 114 genarch/src/drivers/am335x/timer.c 111 115 endif 112 116 -
kernel/genarch/src/drivers/omap/uart.c
rf288d85 rdff90fa7 1 1 /* 2 2 * Copyright (c) 2012 Jan Vesely 3 * Copyright (c) 2013 Maurizio Lombardi 3 4 * All rights reserved. 4 5 * … … 31 32 /** 32 33 * @file 33 * @brief Texas Instruments AMDM37xon-chip uart serial line driver.34 * @brief Texas Instruments OMAP on-chip uart serial line driver. 34 35 */ 35 36 36 #include <genarch/drivers/ amdm37x_uart/amdm37x_uart.h>37 #include <genarch/drivers/omap/uart.h> 37 38 #include <ddi/device.h> 38 39 #include <str.h> 39 40 #include <mm/km.h> 40 41 41 static void amdm37x_uart_txb(amdm37x_uart_t *uart, uint8_t b)42 static void omap_uart_txb(omap_uart_t *uart, uint8_t b) 42 43 { 43 44 /* 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); 45 46 /* Write to the outgoing fifo */ 46 47 uart->regs->thr = b; 47 48 } 48 49 49 static void amdm37x_uart_putchar(outdev_t *dev, wchar_t ch)50 static void omap_uart_putchar(outdev_t *dev, wchar_t ch) 50 51 { 51 amdm37x_uart_t *uart = dev->data;52 omap_uart_t *uart = dev->data; 52 53 if (!ascii_check(ch)) { 53 amdm37x_uart_txb(uart, U_SPECIAL);54 omap_uart_txb(uart, U_SPECIAL); 54 55 } else { 55 56 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); 58 59 } 59 60 } 60 61 61 static outdev_operations_t amdm37x_uart_ops = {62 static outdev_operations_t omap_uart_ops = { 62 63 .redraw = NULL, 63 .write = amdm37x_uart_putchar,64 .write = omap_uart_putchar, 64 65 }; 65 66 66 static irq_ownership_t amdm37x_uart_claim(irq_t *irq)67 static irq_ownership_t omap_uart_claim(irq_t *irq) 67 68 { 68 69 return IRQ_ACCEPT; 69 70 } 70 71 71 static void amdm37x_uart_handler(irq_t *irq)72 static void omap_uart_handler(irq_t *irq) 72 73 { 73 amdm37x_uart_t *uart = irq->instance;74 omap_uart_t *uart = irq->instance; 74 75 while ((uart->regs->rx_fifo_lvl)) { 75 76 const uint8_t val = uart->regs->rhr; … … 80 81 } 81 82 82 bool amdm37x_uart_init(83 amdm37x_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size)83 bool omap_uart_init( 84 omap_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size) 84 85 { 85 86 ASSERT(uart); … … 88 89 ASSERT(uart->regs); 89 90 90 /* See TI OMAP35X TRM ch 17.5.1.1 p. 2732 for startup routine */91 #if 092 91 /* 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; 96 97 97 98 /* Enable access to EFR register */ 98 const uint8_t lcr = uart->regs->lcr; /* Save old value */99 99 uart->regs->lcr = 0xbf; /* Sets config mode B */ 100 100 101 101 /* 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. */ 104 104 uart->regs->lcr = 0x80; /* Config mode A */ 105 105 106 106 /* 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; 108 108 /* 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; 110 110 111 111 /* Enable FIFOs */ 112 uart->regs->fcr = AMDM37x_UART_FCR_FIFO_EN_FLAG;112 uart->regs->fcr = OMAP_UART_FCR_FIFO_EN_FLAG; 113 113 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; 119 131 120 132 /* Restore enhanced */ 121 133 if (!enhanced) 122 uart->regs->efr &= ~ AMDM37x_UART_EFR_ENH_FLAG;134 uart->regs->efr &= ~OMAP_UART_EFR_ENH_FLAG; 123 135 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; 128 146 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); 131 150 132 151 /* Disable interrupts */ … … 134 153 135 154 /* Setup outdev */ 136 outdev_initialize(" amdm37x_uart_dev", &uart->outdev, &amdm37x_uart_ops);155 outdev_initialize("omap_uart_dev", &uart->outdev, &omap_uart_ops); 137 156 uart->outdev.data = uart; 138 157 … … 141 160 uart->irq.devno = device_assign_devno(); 142 161 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; 145 164 uart->irq.instance = uart; 146 165 … … 148 167 } 149 168 150 void amdm37x_uart_input_wire(amdm37x_uart_t *uart, indev_t *indev)169 void omap_uart_input_wire(omap_uart_t *uart, indev_t *indev) 151 170 { 152 171 ASSERT(uart); … … 156 175 irq_register(&uart->irq); 157 176 /* Enable interrupt on receive */ 158 uart->regs->ier |= AMDM37x_UART_IER_RHR_IRQ_FLAG;177 uart->regs->ier |= OMAP_UART_IER_RHR_IRQ_FLAG; 159 178 } 160 179 … … 162 181 * @} 163 182 */ 183 -
kernel/genarch/src/fb/fb.c
rf288d85 rdff90fa7 35 35 36 36 #include <genarch/fb/font-8x16.h> 37 #include <genarch/fb/logo-196x66.h>38 37 #include <genarch/fb/fb.h> 39 38 #include <console/chardev.h> … … 53 52 #include <byteorder.h> 54 53 55 #define BG_COLOR 0x00 008056 #define FG_COLOR 0xf fff0054 #define BG_COLOR 0x001620 55 #define FG_COLOR 0xf3cf65 57 56 #define INV_COLOR 0xaaaaaa 58 57 … … 93 92 unsigned int yres; 94 93 95 unsigned int ylogo;96 unsigned int ytrim;97 94 unsigned int rowtrim; 98 95 … … 213 210 } 214 211 215 /** Hide logo and refresh screen216 *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 228 212 /** Draw character at given position 229 213 * … … 236 220 unsigned int yd; 237 221 238 if (y >= instance->ytrim)239 logo_hide(instance);240 241 222 if (!overlay) 242 223 instance->backbuf[BB_POS(instance, col, row)] = glyph; … … 244 225 if ((!instance->parea.mapped) || (console_override)) { 245 226 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)], 247 228 &instance->glyphs[GLYPH_POS(instance, glyph, yd)], 248 229 instance->glyphscanline); … … 256 237 static void screen_scroll(fb_instance_t *instance) 257 238 { 258 if (instance->ylogo > 0) {259 logo_hide(instance);260 return;261 }262 263 239 if ((!instance->parea.mapped) || (console_override)) { 264 240 unsigned int row; … … 412 388 static void fb_redraw_internal(fb_instance_t *instance) 413 389 { 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 428 390 unsigned int row; 429 391 430 392 for (row = 0; row < instance->rowtrim; row++) { 431 unsigned int y = instance->ylogo +ROW2Y(row);393 unsigned int y = ROW2Y(row); 432 394 unsigned int yd; 433 395 … … 452 414 (instance->xres - COL2X(instance->cols)) * instance->pixelbytes; 453 415 454 for (y = instance->ylogo; y < instance->yres; y++)416 for (y = 0; y < instance->yres; y++) 455 417 memcpy(&instance->addr[FB_POS(instance, COL2X(instance->cols), y)], 456 418 instance->bgscan, size); 457 419 } 458 420 459 if (ROW2Y(instance->rowtrim) + instance->ylogo< instance->yres) {421 if (ROW2Y(instance->rowtrim) < instance->yres) { 460 422 unsigned int y; 461 423 462 for (y = ROW2Y(instance->rowtrim) + instance->ylogo; 463 y < instance->yres; y++) 424 for (y = ROW2Y(instance->rowtrim); y < instance->yres; y++) 464 425 memcpy(&instance->addr[FB_POS(instance, 0, y)], 465 426 instance->bgscan, instance->bgscanbytes); … … 567 528 instance->rows = Y2ROW(instance->yres); 568 529 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; 580 531 581 532 instance->glyphscanline = FONT_WIDTH * instance->pixelbytes;
Note:
See TracChangeset
for help on using the changeset viewer.