Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Driver for OMAP-UART controller. |
| 3 | * Based on drivers/serial/8250.c |
| 4 | * |
| 5 | * Copyright (C) 2010 Texas Instruments. |
| 6 | * |
| 7 | * Authors: |
| 8 | * Govindraj R <govindraj.raja@ti.com> |
| 9 | * Thara Gopinath <thara@ti.com> |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __OMAP_SERIAL_H__ |
| 18 | #define __OMAP_SERIAL_H__ |
| 19 | |
| 20 | #include <linux/serial_core.h> |
Felipe Balbi | d8ee4ea | 2012-09-06 15:45:20 +0300 | [diff] [blame^] | 21 | #include <linux/device.h> |
Govindraj.R | 2fd1496 | 2011-11-09 17:41:21 +0530 | [diff] [blame] | 22 | #include <linux/pm_qos.h> |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 23 | |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 24 | #include <plat/mux.h> |
| 25 | |
Benoit Cousson | 374b8cf | 2010-12-09 14:24:17 +0000 | [diff] [blame] | 26 | #define DRIVER_NAME "omap_uart" |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 27 | |
| 28 | /* |
| 29 | * Use tty device name as ttyO, [O -> OMAP] |
| 30 | * in bootargs we specify as console=ttyO0 if uart1 |
| 31 | * is used as console uart. |
| 32 | */ |
| 33 | #define OMAP_SERIAL_NAME "ttyO" |
| 34 | |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 35 | #define OMAP_MODE13X_SPEED 230400 |
| 36 | |
Govindraj.R | 3221289 | 2011-11-07 18:58:55 +0530 | [diff] [blame] | 37 | #define OMAP_UART_SCR_TX_EMPTY 0x08 |
| 38 | |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 39 | /* WER = 0x7F |
| 40 | * Enable module level wakeup in WER reg |
| 41 | */ |
| 42 | #define OMAP_UART_WER_MOD_WKUP 0X7F |
| 43 | |
| 44 | /* Enable XON/XOFF flow control on output */ |
| 45 | #define OMAP_UART_SW_TX 0x04 |
| 46 | |
| 47 | /* Enable XON/XOFF flow control on input */ |
| 48 | #define OMAP_UART_SW_RX 0x04 |
| 49 | |
| 50 | #define OMAP_UART_SYSC_RESET 0X07 |
| 51 | #define OMAP_UART_TCR_TRIG 0X0F |
| 52 | #define OMAP_UART_SW_CLR 0XF0 |
| 53 | #define OMAP_UART_FIFO_CLR 0X06 |
| 54 | |
| 55 | #define OMAP_UART_DMA_CH_FREE -1 |
| 56 | |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 57 | #define OMAP_MAX_HSUART_PORTS 4 |
| 58 | |
| 59 | #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA |
| 60 | |
Govindraj.R | 9473474 | 2011-11-07 19:00:33 +0530 | [diff] [blame] | 61 | #define UART_ERRATA_i202_MDR1_ACCESS BIT(0) |
| 62 | #define UART_ERRATA_i291_DMA_FORCEIDLE BIT(1) |
| 63 | |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 64 | struct omap_uart_port_info { |
| 65 | bool dma_enabled; /* To specify DMA Mode */ |
| 66 | unsigned int uartclk; /* UART clock rate */ |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 67 | upf_t flags; /* UPF_* flags */ |
Deepak K | c86845db | 2011-11-09 17:33:38 +0530 | [diff] [blame] | 68 | unsigned int dma_rx_buf_size; |
| 69 | unsigned int dma_rx_timeout; |
| 70 | unsigned int autosuspend_timeout; |
Jon Hunter | a9e210e | 2011-11-09 17:34:49 +0530 | [diff] [blame] | 71 | unsigned int dma_rx_poll_rate; |
NeilBrown | 9574f36 | 2012-07-30 10:30:26 +1000 | [diff] [blame] | 72 | int DTR_gpio; |
| 73 | int DTR_inverted; |
| 74 | int DTR_present; |
Govindraj.R | ec3bebc | 2011-10-11 19:11:27 +0530 | [diff] [blame] | 75 | |
| 76 | int (*get_context_loss_count)(struct device *); |
Felipe Balbi | d8ee4ea | 2012-09-06 15:45:20 +0300 | [diff] [blame^] | 77 | void (*set_forceidle)(struct device *); |
| 78 | void (*set_noidle)(struct device *); |
| 79 | void (*enable_wakeup)(struct device *, bool); |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | struct uart_omap_dma { |
| 83 | u8 uart_dma_tx; |
| 84 | u8 uart_dma_rx; |
| 85 | int rx_dma_channel; |
| 86 | int tx_dma_channel; |
| 87 | dma_addr_t rx_buf_dma_phys; |
| 88 | dma_addr_t tx_buf_dma_phys; |
| 89 | unsigned int uart_base; |
| 90 | /* |
| 91 | * Buffer for rx dma.It is not required for tx because the buffer |
| 92 | * comes from port structure. |
| 93 | */ |
| 94 | unsigned char *rx_buf; |
| 95 | unsigned int prev_rx_dma_pos; |
| 96 | int tx_buf_size; |
| 97 | int tx_dma_used; |
| 98 | int rx_dma_used; |
| 99 | spinlock_t tx_lock; |
| 100 | spinlock_t rx_lock; |
| 101 | /* timer to poll activity on rx dma */ |
| 102 | struct timer_list rx_timer; |
Deepak K | c86845db | 2011-11-09 17:33:38 +0530 | [diff] [blame] | 103 | unsigned int rx_buf_size; |
Jon Hunter | a9e210e | 2011-11-09 17:34:49 +0530 | [diff] [blame] | 104 | unsigned int rx_poll_rate; |
Deepak K | c86845db | 2011-11-09 17:33:38 +0530 | [diff] [blame] | 105 | unsigned int rx_timeout; |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | struct uart_omap_port { |
| 109 | struct uart_port port; |
| 110 | struct uart_omap_dma uart_dma; |
Felipe Balbi | d8ee4ea | 2012-09-06 15:45:20 +0300 | [diff] [blame^] | 111 | struct device *dev; |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 112 | |
| 113 | unsigned char ier; |
| 114 | unsigned char lcr; |
| 115 | unsigned char mcr; |
| 116 | unsigned char fcr; |
| 117 | unsigned char efr; |
Govindraj.R | c538d20 | 2011-11-07 18:57:03 +0530 | [diff] [blame] | 118 | unsigned char dll; |
| 119 | unsigned char dlh; |
| 120 | unsigned char mdr1; |
| 121 | unsigned char scr; |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 122 | |
| 123 | int use_dma; |
| 124 | /* |
| 125 | * Some bits in registers are cleared on a read, so they must |
| 126 | * be saved whenever the register is read but the bits will not |
| 127 | * be immediately processed. |
| 128 | */ |
| 129 | unsigned int lsr_break_flag; |
| 130 | unsigned char msr_saved_flags; |
| 131 | char name[20]; |
| 132 | unsigned long port_activity; |
Govindraj.R | ec3bebc | 2011-10-11 19:11:27 +0530 | [diff] [blame] | 133 | u32 context_loss_cnt; |
Govindraj.R | 9473474 | 2011-11-07 19:00:33 +0530 | [diff] [blame] | 134 | u32 errata; |
Govindraj.R | 62f3ec5f | 2011-10-13 14:11:09 +0530 | [diff] [blame] | 135 | u8 wakeups_enabled; |
Govindraj.R | 2fd1496 | 2011-11-09 17:41:21 +0530 | [diff] [blame] | 136 | |
NeilBrown | 9574f36 | 2012-07-30 10:30:26 +1000 | [diff] [blame] | 137 | int DTR_gpio; |
| 138 | int DTR_inverted; |
| 139 | int DTR_active; |
| 140 | |
Govindraj.R | 2fd1496 | 2011-11-09 17:41:21 +0530 | [diff] [blame] | 141 | struct pm_qos_request pm_qos_request; |
| 142 | u32 latency; |
| 143 | u32 calc_latency; |
| 144 | struct work_struct qos_work; |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 145 | }; |
| 146 | |
Felipe Balbi | c990f35 | 2012-08-23 13:32:41 +0300 | [diff] [blame] | 147 | #define to_uart_omap_port(p) ((container_of((p), struct uart_omap_port, port))) |
| 148 | |
Govindraj.R | b612633 | 2010-09-27 20:20:49 +0530 | [diff] [blame] | 149 | #endif /* __OMAP_SERIAL_H__ */ |