Changeset 192565b in mainline for kernel/genarch/src/drivers/omap/uart.c
- Timestamp:
- 2013-05-27T13:18:13Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f2c19b0
- Parents:
- d120133 (diff), c90aed4 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/drivers/omap/uart.c
rd120133 r192565b 32 32 /** 33 33 * @file 34 * @brief Texas Instruments AM335xon-chip uart serial line driver.34 * @brief Texas Instruments OMAP on-chip uart serial line driver. 35 35 */ 36 36 37 #include <genarch/drivers/ am335x/uart.h>37 #include <genarch/drivers/omap/uart.h> 38 38 #include <ddi/device.h> 39 39 #include <str.h> 40 40 #include <mm/km.h> 41 41 42 static void am335x_uart_txb(am335x_uart_t *uart, uint8_t b)42 static void omap_uart_txb(omap_uart_t *uart, uint8_t b) 43 43 { 44 44 /* Wait for buffer */ 45 while (uart->regs->ssr & AM335x_UART_SSR_TX_FIFO_FULL_FLAG);45 while (uart->regs->ssr & OMAP_UART_SSR_TX_FIFO_FULL_FLAG); 46 46 /* Write to the outgoing fifo */ 47 47 uart->regs->thr = b; 48 48 } 49 49 50 static void am335x_uart_putchar(outdev_t *dev, wchar_t ch)50 static void omap_uart_putchar(outdev_t *dev, wchar_t ch) 51 51 { 52 am335x_uart_t *uart = dev->data;52 omap_uart_t *uart = dev->data; 53 53 if (!ascii_check(ch)) { 54 am335x_uart_txb(uart, U_SPECIAL);54 omap_uart_txb(uart, U_SPECIAL); 55 55 } else { 56 56 if (ch == '\n') 57 am335x_uart_txb(uart, '\r');58 am335x_uart_txb(uart, ch);57 omap_uart_txb(uart, '\r'); 58 omap_uart_txb(uart, ch); 59 59 } 60 60 } 61 61 62 static outdev_operations_t am335x_uart_ops = {62 static outdev_operations_t omap_uart_ops = { 63 63 .redraw = NULL, 64 .write = am335x_uart_putchar,64 .write = omap_uart_putchar, 65 65 }; 66 66 67 static irq_ownership_t am335x_uart_claim(irq_t *irq)67 static irq_ownership_t omap_uart_claim(irq_t *irq) 68 68 { 69 69 return IRQ_ACCEPT; 70 70 } 71 71 72 static void am335x_uart_handler(irq_t *irq)72 static void omap_uart_handler(irq_t *irq) 73 73 { 74 am335x_uart_t *uart = irq->instance;74 omap_uart_t *uart = irq->instance; 75 75 while ((uart->regs->rx_fifo_lvl)) { 76 76 const uint8_t val = uart->regs->rhr; … … 81 81 } 82 82 83 bool am335x_uart_init(84 am335x_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) 85 85 { 86 86 ASSERT(uart); … … 90 90 91 91 /* Soft reset the port */ 92 uart->regs->sysc = AM335x_UART_SYSC_SOFTRESET_FLAG;93 while (!(uart->regs->syss & AM335x_UART_SYSS_RESETDONE_FLAG));92 uart->regs->sysc = OMAP_UART_SYSC_SOFTRESET_FLAG; 93 while (!(uart->regs->syss & OMAP_UART_SYSS_RESETDONE_FLAG)); 94 94 95 95 /* Disable the UART module */ 96 uart->regs->mdr1 |= AM335x_UART_MDR_MS_DISABLE;96 uart->regs->mdr1 |= OMAP_UART_MDR_MS_DISABLE; 97 97 98 98 /* Enable access to EFR register */ … … 100 100 101 101 /* Enable access to TCL_TLR register */ 102 const bool enhanced = uart->regs->efr & AM335x_UART_EFR_ENH_FLAG;103 uart->regs->efr |= AM335x_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 & AM335x_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 |= AM335x_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 = AM335x_UART_FCR_FIFO_EN_FLAG;112 uart->regs->fcr = OMAP_UART_FCR_FIFO_EN_FLAG; 113 113 114 114 /* Enable fine granularity for RX FIFO and set trigger level to 1, 115 115 * TX FIFO, trigger level is irrelevant*/ 116 116 uart->regs->lcr = 0xBF; /* Sets config mode B */ 117 uart->regs->scr = AM335x_UART_SCR_RX_TRIG_GRANU1_FLAG;118 uart->regs->tlr = 1 << AM335x_UART_TLR_RX_FIFO_TRIG_SHIFT;117 uart->regs->scr = OMAP_UART_SCR_RX_TRIG_GRANU1_FLAG; 118 uart->regs->tlr = 1 << OMAP_UART_TLR_RX_FIFO_TRIG_SHIFT; 119 119 120 120 /* Sets config mode A */ … … 122 122 /* Restore tcl_tlr access flag */ 123 123 if (!tcl_tlr) 124 uart->regs->mcr &= ~ AM335x_UART_MCR_TCR_TLR_FLAG;124 uart->regs->mcr &= ~OMAP_UART_MCR_TCR_TLR_FLAG; 125 125 /* Sets config mode B */ 126 126 uart->regs->lcr = 0xBF; … … 132 132 /* Restore enhanced */ 133 133 if (!enhanced) 134 uart->regs->efr &= ~ AM335x_UART_EFR_ENH_FLAG;134 uart->regs->efr &= ~OMAP_UART_EFR_ENH_FLAG; 135 135 136 136 /* Set the DIV_EN bit to 0 */ 137 uart->regs->lcr &= ~ AM335x_UART_LCR_DIV_EN_FLAG;137 uart->regs->lcr &= ~OMAP_UART_LCR_DIV_EN_FLAG; 138 138 /* Set the BREAK_EN bit to 0 */ 139 uart->regs->lcr &= ~ AM335x_UART_LCR_BREAK_EN_FLAG;139 uart->regs->lcr &= ~OMAP_UART_LCR_BREAK_EN_FLAG; 140 140 /* No parity */ 141 uart->regs->lcr &= ~ AM335x_UART_LCR_PARITY_EN_FLAG;141 uart->regs->lcr &= ~OMAP_UART_LCR_PARITY_EN_FLAG; 142 142 /* Stop = 1 bit */ 143 uart->regs->lcr &= ~ AM335x_UART_LCR_NB_STOP_FLAG;143 uart->regs->lcr &= ~OMAP_UART_LCR_NB_STOP_FLAG; 144 144 /* Char length = 8 bits */ 145 uart->regs->lcr |= AM335x_UART_LCR_CHAR_LENGTH_8BITS;145 uart->regs->lcr |= OMAP_UART_LCR_CHAR_LENGTH_8BITS; 146 146 147 147 /* Enable the UART module */ 148 uart->regs->mdr1 &= ( AM335x_UART_MDR_MS_UART16 &149 ~ AM335x_UART_MDR_MS_MASK);148 uart->regs->mdr1 &= (OMAP_UART_MDR_MS_UART16 & 149 ~OMAP_UART_MDR_MS_MASK); 150 150 151 151 /* Disable interrupts */ … … 153 153 154 154 /* Setup outdev */ 155 outdev_initialize(" am335x_uart_dev", &uart->outdev, &am335x_uart_ops);155 outdev_initialize("omap_uart_dev", &uart->outdev, &omap_uart_ops); 156 156 uart->outdev.data = uart; 157 157 … … 160 160 uart->irq.devno = device_assign_devno(); 161 161 uart->irq.inr = interrupt; 162 uart->irq.claim = am335x_uart_claim;163 uart->irq.handler = am335x_uart_handler;162 uart->irq.claim = omap_uart_claim; 163 uart->irq.handler = omap_uart_handler; 164 164 uart->irq.instance = uart; 165 165 … … 167 167 } 168 168 169 void am335x_uart_input_wire(am335x_uart_t *uart, indev_t *indev)169 void omap_uart_input_wire(omap_uart_t *uart, indev_t *indev) 170 170 { 171 171 ASSERT(uart); … … 175 175 irq_register(&uart->irq); 176 176 /* Enable interrupt on receive */ 177 uart->regs->ier |= AM335x_UART_IER_RHR_IRQ_FLAG;177 uart->regs->ier |= OMAP_UART_IER_RHR_IRQ_FLAG; 178 178 } 179 179
Note:
See TracChangeset
for help on using the changeset viewer.