blob: ea63b2bc761c4014ca71ca75a1024e9cdd353388 [file] [log] [blame]
Govindraj.Rb6126332010-09-27 20:20:49 +05301/*
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>
21#include <linux/platform_device.h>
22
Govindraj.Rb6126332010-09-27 20:20:49 +053023#include <plat/mux.h>
24
Benoit Cousson374b8cf2010-12-09 14:24:17 +000025#define DRIVER_NAME "omap_uart"
Govindraj.Rb6126332010-09-27 20:20:49 +053026
27/*
28 * Use tty device name as ttyO, [O -> OMAP]
29 * in bootargs we specify as console=ttyO0 if uart1
30 * is used as console uart.
31 */
32#define OMAP_SERIAL_NAME "ttyO"
33
Govindraj.Rb6126332010-09-27 20:20:49 +053034#define OMAP_MODE13X_SPEED 230400
35
Govindraj.R32212892011-11-07 18:58:55 +053036#define OMAP_UART_SCR_TX_EMPTY 0x08
37
Govindraj.Rb6126332010-09-27 20:20:49 +053038/* WER = 0x7F
39 * Enable module level wakeup in WER reg
40 */
41#define OMAP_UART_WER_MOD_WKUP 0X7F
42
43/* Enable XON/XOFF flow control on output */
44#define OMAP_UART_SW_TX 0x04
45
46/* Enable XON/XOFF flow control on input */
47#define OMAP_UART_SW_RX 0x04
48
49#define OMAP_UART_SYSC_RESET 0X07
50#define OMAP_UART_TCR_TRIG 0X0F
51#define OMAP_UART_SW_CLR 0XF0
52#define OMAP_UART_FIFO_CLR 0X06
53
54#define OMAP_UART_DMA_CH_FREE -1
55
Govindraj.Rb6126332010-09-27 20:20:49 +053056#define OMAP_MAX_HSUART_PORTS 4
57
58#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
59
Govindraj.R94734742011-11-07 19:00:33 +053060#define UART_ERRATA_i202_MDR1_ACCESS BIT(0)
61#define UART_ERRATA_i291_DMA_FORCEIDLE BIT(1)
62
Govindraj.Rb6126332010-09-27 20:20:49 +053063struct omap_uart_port_info {
64 bool dma_enabled; /* To specify DMA Mode */
65 unsigned int uartclk; /* UART clock rate */
Govindraj.Rb6126332010-09-27 20:20:49 +053066 upf_t flags; /* UPF_* flags */
Govindraj.R94734742011-11-07 19:00:33 +053067 u32 errata;
Deepak Kc86845db2011-11-09 17:33:38 +053068 unsigned int dma_rx_buf_size;
69 unsigned int dma_rx_timeout;
70 unsigned int autosuspend_timeout;
Jon Huntera9e210e2011-11-09 17:34:49 +053071 unsigned int dma_rx_poll_rate;
Govindraj.Rec3bebc2011-10-11 19:11:27 +053072
73 int (*get_context_loss_count)(struct device *);
Govindraj.R94734742011-11-07 19:00:33 +053074 void (*set_forceidle)(struct platform_device *);
75 void (*set_noidle)(struct platform_device *);
Govindraj.R62f3ec5f2011-10-13 14:11:09 +053076 void (*enable_wakeup)(struct platform_device *, bool);
Govindraj.Rb6126332010-09-27 20:20:49 +053077};
78
79struct uart_omap_dma {
80 u8 uart_dma_tx;
81 u8 uart_dma_rx;
82 int rx_dma_channel;
83 int tx_dma_channel;
84 dma_addr_t rx_buf_dma_phys;
85 dma_addr_t tx_buf_dma_phys;
86 unsigned int uart_base;
87 /*
88 * Buffer for rx dma.It is not required for tx because the buffer
89 * comes from port structure.
90 */
91 unsigned char *rx_buf;
92 unsigned int prev_rx_dma_pos;
93 int tx_buf_size;
94 int tx_dma_used;
95 int rx_dma_used;
96 spinlock_t tx_lock;
97 spinlock_t rx_lock;
98 /* timer to poll activity on rx dma */
99 struct timer_list rx_timer;
Deepak Kc86845db2011-11-09 17:33:38 +0530100 unsigned int rx_buf_size;
Jon Huntera9e210e2011-11-09 17:34:49 +0530101 unsigned int rx_poll_rate;
Deepak Kc86845db2011-11-09 17:33:38 +0530102 unsigned int rx_timeout;
Govindraj.Rb6126332010-09-27 20:20:49 +0530103};
104
105struct uart_omap_port {
106 struct uart_port port;
107 struct uart_omap_dma uart_dma;
108 struct platform_device *pdev;
109
110 unsigned char ier;
111 unsigned char lcr;
112 unsigned char mcr;
113 unsigned char fcr;
114 unsigned char efr;
Govindraj.Rc538d202011-11-07 18:57:03 +0530115 unsigned char dll;
116 unsigned char dlh;
117 unsigned char mdr1;
118 unsigned char scr;
Govindraj.Rb6126332010-09-27 20:20:49 +0530119
120 int use_dma;
121 /*
122 * Some bits in registers are cleared on a read, so they must
123 * be saved whenever the register is read but the bits will not
124 * be immediately processed.
125 */
126 unsigned int lsr_break_flag;
127 unsigned char msr_saved_flags;
128 char name[20];
129 unsigned long port_activity;
Govindraj.Rec3bebc2011-10-11 19:11:27 +0530130 u32 context_loss_cnt;
Govindraj.R94734742011-11-07 19:00:33 +0530131 u32 errata;
Govindraj.R62f3ec5f2011-10-13 14:11:09 +0530132 u8 wakeups_enabled;
Govindraj.Rb6126332010-09-27 20:20:49 +0530133};
134
135#endif /* __OMAP_SERIAL_H__ */