blob: f4a4cd014795d676d85ffdc05622a4ac3e889a5c [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>
Felipe Balbid8ee4ea2012-09-06 15:45:20 +030021#include <linux/device.h>
Govindraj.R2fd14962011-11-09 17:41:21 +053022#include <linux/pm_qos.h>
Govindraj.Rb6126332010-09-27 20:20:49 +053023
Benoit Cousson374b8cf2010-12-09 14:24:17 +000024#define DRIVER_NAME "omap_uart"
Govindraj.Rb6126332010-09-27 20:20:49 +053025
26/*
27 * Use tty device name as ttyO, [O -> OMAP]
28 * in bootargs we specify as console=ttyO0 if uart1
29 * is used as console uart.
30 */
31#define OMAP_SERIAL_NAME "ttyO"
32
Govindraj.Rb6126332010-09-27 20:20:49 +053033#define OMAP_MODE13X_SPEED 230400
34
Govindraj.R32212892011-11-07 18:58:55 +053035#define OMAP_UART_SCR_TX_EMPTY 0x08
36
Govindraj.Rb6126332010-09-27 20:20:49 +053037/* WER = 0x7F
38 * Enable module level wakeup in WER reg
39 */
40#define OMAP_UART_WER_MOD_WKUP 0X7F
41
42/* Enable XON/XOFF flow control on output */
Vikram Pandita957ee722012-09-06 15:45:37 +030043#define OMAP_UART_SW_TX 0x8
Govindraj.Rb6126332010-09-27 20:20:49 +053044
45/* Enable XON/XOFF flow control on input */
Vikram Pandita957ee722012-09-06 15:45:37 +030046#define OMAP_UART_SW_RX 0x2
Govindraj.Rb6126332010-09-27 20:20:49 +053047
48#define OMAP_UART_SYSC_RESET 0X07
49#define OMAP_UART_TCR_TRIG 0X0F
50#define OMAP_UART_SW_CLR 0XF0
51#define OMAP_UART_FIFO_CLR 0X06
52
53#define OMAP_UART_DMA_CH_FREE -1
54
AnilKumar Chcfc55bc2012-06-20 14:19:29 +053055#define OMAP_MAX_HSUART_PORTS 6
Govindraj.Rb6126332010-09-27 20:20:49 +053056
57#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
58
Govindraj.R94734742011-11-07 19:00:33 +053059#define UART_ERRATA_i202_MDR1_ACCESS BIT(0)
60#define UART_ERRATA_i291_DMA_FORCEIDLE BIT(1)
61
Govindraj.Rb6126332010-09-27 20:20:49 +053062struct omap_uart_port_info {
63 bool dma_enabled; /* To specify DMA Mode */
64 unsigned int uartclk; /* UART clock rate */
Govindraj.Rb6126332010-09-27 20:20:49 +053065 upf_t flags; /* UPF_* flags */
Deepak Kc86845db2011-11-09 17:33:38 +053066 unsigned int dma_rx_buf_size;
67 unsigned int dma_rx_timeout;
68 unsigned int autosuspend_timeout;
Jon Huntera9e210e2011-11-09 17:34:49 +053069 unsigned int dma_rx_poll_rate;
NeilBrown9574f362012-07-30 10:30:26 +100070 int DTR_gpio;
71 int DTR_inverted;
72 int DTR_present;
Govindraj.Rec3bebc2011-10-11 19:11:27 +053073
74 int (*get_context_loss_count)(struct device *);
Felipe Balbid8ee4ea2012-09-06 15:45:20 +030075 void (*set_forceidle)(struct device *);
76 void (*set_noidle)(struct device *);
77 void (*enable_wakeup)(struct device *, bool);
Govindraj.Rb6126332010-09-27 20:20:49 +053078};
79
80struct uart_omap_dma {
81 u8 uart_dma_tx;
82 u8 uart_dma_rx;
83 int rx_dma_channel;
84 int tx_dma_channel;
85 dma_addr_t rx_buf_dma_phys;
86 dma_addr_t tx_buf_dma_phys;
87 unsigned int uart_base;
88 /*
89 * Buffer for rx dma.It is not required for tx because the buffer
90 * comes from port structure.
91 */
92 unsigned char *rx_buf;
93 unsigned int prev_rx_dma_pos;
94 int tx_buf_size;
95 int tx_dma_used;
96 int rx_dma_used;
97 spinlock_t tx_lock;
98 spinlock_t rx_lock;
99 /* timer to poll activity on rx dma */
100 struct timer_list rx_timer;
Deepak Kc86845db2011-11-09 17:33:38 +0530101 unsigned int rx_buf_size;
Jon Huntera9e210e2011-11-09 17:34:49 +0530102 unsigned int rx_poll_rate;
Deepak Kc86845db2011-11-09 17:33:38 +0530103 unsigned int rx_timeout;
Govindraj.Rb6126332010-09-27 20:20:49 +0530104};
105
Govindraj.Rb6126332010-09-27 20:20:49 +0530106#endif /* __OMAP_SERIAL_H__ */