More small updates and a driver for the MAX3100. The MAX3100 driver needs kref
bits eventually but its otherwise fine and good enough to merge
---
Adrian Bunk (1):
tty: Correct inline types for tty_driver_kref_get()
Alan Cox (2):
lanana: assign a device name and numbering for MAX3100
serqt: initial clean up pass for tty side
Breno Leitao (1):
Here are some cleanups, mainly removing unused variables and silly
Christian Pellegrin (1):
Add support for the MAX3100 SPI UART.
Claudio Scordino (1):
tty: Use the generic RS485 ioctl on CRIS
Mike Frysinger (3):
Signed-off-by: Mike Frysinger <[email protected]>
Depend on KGDB_SERIAL_CONSOLE being set to N rather than !Y, since it can
Signed-off-by: Mike Frysinger <[email protected]>
Sonic Zhang (2):
Both software emulated and hardware based CTS and RTS are enabled in
Only CTS bit is affected.
Documentation/devices.txt | 4
.../mach-bf518/include/mach/bfin_serial_5xx.h | 10
.../mach-bf527/include/mach/bfin_serial_5xx.h | 36 --
.../mach-bf533/include/mach/bfin_serial_5xx.h | 29 -
.../mach-bf537/include/mach/bfin_serial_5xx.h | 37 --
.../mach-bf538/include/mach/bfin_serial_5xx.h | 10
.../mach-bf548/include/mach/bfin_serial_5xx.h | 117 +----
.../mach-bf561/include/mach/bfin_serial_5xx.h | 29 -
arch/cris/include/asm/ioctls.h | 5
arch/cris/include/asm/rs485.h | 8
arch/cris/include/asm/termios.h | 1
drivers/serial/Kconfig | 47 ++
drivers/serial/Makefile | 1
drivers/serial/bfin_5xx.c | 282 ++++++++-----
drivers/serial/crisv10.c | 79 +++-
drivers/serial/crisv10.h | 2
drivers/serial/jsm/jsm_neo.c | 14 -
drivers/serial/jsm/jsm_tty.c | 19 -
drivers/staging/serqt_usb/serqt_usb.c | 449 +++++++-------------
include/linux/serial_core.h | 3
include/linux/tty_driver.h | 3
21 files changed, 547 insertions(+), 638 deletions(-)
--
From: Adrian Bunk <[email protected]>
tty_driver_kref_get() should be static inline and not extern inline
(the latter even changed it's semantics in gcc >= 4.3).
Signed-off-by: Adrian Bunk <[email protected]>
Signed-off-by: Alan Cox <[email protected]>
---
include/linux/tty_driver.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 8615d66..bcba84e 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -309,7 +309,8 @@ extern void tty_set_operations(struct tty_driver *driver,
extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
extern void tty_driver_kref_put(struct tty_driver *driver);
-extern inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
+
+static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
{
kref_get(&d->kref);
return d;
Avoid using port->tty where possible (makes refcount fixing easier later)
Remove unused code (the ioctl path is not used if the device has mget/mset
functions)
Remove various un-needed typecasts and long names so it could read it to do the
changes
Signed-off-by: Alan Cox <[email protected]>
---
drivers/staging/serqt_usb/serqt_usb.c | 449 ++++++++++++---------------------
1 files changed, 163 insertions(+), 286 deletions(-)
diff --git a/drivers/staging/serqt_usb/serqt_usb.c b/drivers/staging/serqt_usb/serqt_usb.c
index 1781510..234f332 100644
--- a/drivers/staging/serqt_usb/serqt_usb.c
+++ b/drivers/staging/serqt_usb/serqt_usb.c
@@ -289,7 +289,8 @@ static void serial_unthrottle(struct tty_struct *tty);
static int serial_break(struct tty_struct *tty, int break_state);
static int serial_chars_in_buffer(struct tty_struct *tty);
-static int qt_open(struct usb_serial_port *port, struct file *filp);
+static int qt_open(struct tty_struct *tty, struct usb_serial_port *port,
+ struct file *filp);
static int BoxSetPrebufferLevel(struct usb_serial *serial);
static int BoxSetATC(struct usb_serial *serial, __u16 n_Mode);
@@ -300,24 +301,26 @@ static int BoxSetUart(struct usb_serial *serial, unsigned short Uart_Number,
static int BoxOPenCloseChannel(struct usb_serial *serial, __u16 Uart_Number,
__u16 OpenClose,
struct qt_open_channel_data *pDeviceData);
-static void qt_close(struct usb_serial_port *port, struct file *filp);
+static void qt_close(struct tty_struct *tty, struct usb_serial_port *port,
+ struct file *filp);
static int BoxGetRegister(struct usb_serial *serial, unsigned short Uart_Number,
unsigned short Register_Num, __u8 *pValue);
static int BoxSetRegister(struct usb_serial *serial, unsigned short Uart_Number,
unsigned short Register_Num, unsigned short Value);
static void qt_write_bulk_callback(struct urb *urb);
-static int qt_write(struct usb_serial_port *port, int from_user,
+static int qt_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count);
static void port_softint(struct work_struct *work);
static int qt_write_room(struct usb_serial_port *port);
static int qt_chars_in_buffer(struct usb_serial_port *port);
-static int qt_ioctl(struct usb_serial_port *port, struct file *file,
- unsigned int cmd, unsigned long arg);
-static void qt_set_termios(struct usb_serial_port *port,
+static int qt_ioctl(struct tty_struct *tty, struct usb_serial_port *port,
+ struct file *file, unsigned int cmd, unsigned long arg);
+static void qt_set_termios(struct tty_struct *tty,
+ struct usb_serial_port *port,
struct ktermios *old_termios);
-static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int UartNumber,
+static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int index,
int bSet);
-static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber);
+static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 index);
static int EmulateWriteQMCR_Reg(int index, unsigned uc_value);
static int EmulateReadQMCR_Reg(int index, unsigned *uc_value);
static struct usb_serial *find_the_box(unsigned int index);
@@ -336,10 +339,11 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear);
static int serial_tiocmget(struct tty_struct *tty, struct file *file);
-static int qt_tiocmset(struct usb_serial_port *port, struct file *file,
- unsigned int value);
+static int qt_tiocmset(struct tty_struct *tty, struct usb_serial_port *port,
+ struct file *file, unsigned int value);
-static int qt_tiocmget(struct usb_serial_port *port, struct file *file);
+static int qt_tiocmget(struct tty_struct *tty, struct usb_serial_port *port,
+ struct file *file);
/* Version Information */
#define DRIVER_VERSION "v2.14"
@@ -818,7 +822,7 @@ static struct usb_serial *get_free_serial(int num_ports, int *minor)
return NULL;
}
-static int flip_that(struct tty_struct *tty, __u16 UartNumber,
+static int flip_that(struct tty_struct *tty, __u16 index,
struct usb_serial *serial)
{
tty_flip_buffer_push(tty);
@@ -829,18 +833,18 @@ static int flip_that(struct tty_struct *tty, __u16 UartNumber,
/* Handles processing and moving data to the tty layer */
static void port_sofrint(void *private)
{
- struct usb_serial_port *port = (struct usb_serial_port *)private;
+ struct usb_serial_port *port = private;
struct usb_serial *serial = get_usb_serial(port, __func__);
struct tty_struct *tty = port->tty;
unsigned char *data = port->read_urb->transfer_buffer;
- unsigned int UartNumber;
+ unsigned int index;
struct urb *urb = port->read_urb;
unsigned int RxCount = urb->actual_length;
int i, result;
int flag, flag_data;
- /* UartNumber = MINOR(port->tty->device) - serial->minor; */
- UartNumber = tty->index - serial->minor;
+ /* index = MINOR(port->tty->device) - serial->minor; */
+ index = tty->index - serial->minor;
mydbg("%s - port %d\n", __func__, port->number);
mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding);
@@ -948,7 +952,7 @@ static void port_sofrint(void *private)
__func__, result);
else {
if (tty && RxCount)
- flip_that(tty, UartNumber, serial);
+ flip_that(tty, index, serial);
}
return;
@@ -1097,7 +1101,7 @@ static int serial_open(struct tty_struct *tty, struct file *filp)
port->RxHolding = 0;
mydbg("%s port->RxHolding = 0\n", __func__);
- retval = qt_open(port, filp);
+ retval = qt_open(tty, port, filp);
}
if (retval)
@@ -1112,11 +1116,12 @@ static int serial_open(struct tty_struct *tty, struct file *filp)
/*****************************************************************************
*device's specific driver functions
*****************************************************************************/
-static int qt_open(struct usb_serial_port *port, struct file *filp)
+static int qt_open(struct tty_struct *tty, struct usb_serial_port *port,
+ struct file *filp)
{
struct usb_serial *serial = port->serial;
int result = 0;
- unsigned int UartNumber;
+ unsigned int index;
struct qt_get_device_data DeviceData;
struct qt_open_channel_data ChannelData;
unsigned short default_divisor = 0x30; /* gives 9600 baud rate */
@@ -1128,13 +1133,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
mydbg("%s - port %d\n", __func__, port->number);
- /* force low_latency on so that our tty_push actually forces the data through,
- otherwise it is scheduled, and with high data rates (like with OHCI) data
- can get lost. */
- if (port->tty)
- port->tty->low_latency = 0;
-
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
status = box_get_device(serial, &DeviceData);
if (status < 0) {
@@ -1147,7 +1146,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
/* Open uart channel */
/* Port specific setups */
- status = BoxOPenCloseChannel(serial, UartNumber, 1, &ChannelData);
+ status = BoxOPenCloseChannel(serial, index, 1, &ChannelData);
if (status < 0) {
mydbg(__FILE__ "BoxOPenCloseChannel failed\n");
return status;
@@ -1161,7 +1160,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
(SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_CD);
/* Set Baud rate to default and turn off (default)flow control here */
- status = BoxSetUart(serial, UartNumber, default_divisor, default_LCR);
+ status = BoxSetUart(serial, index, default_divisor, default_LCR);
if (status < 0) {
mydbg(__FILE__ "BoxSetUart failed\n");
return status;
@@ -1169,7 +1168,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
mydbg(__FILE__ "BoxSetUart completed.\n");
/* Put this here to make it responsive to stty and defauls set by the tty layer */
- qt_set_termios(port, NULL);
+ qt_set_termios(tty, port, NULL);
/* Initialize the wait que head */
init_waitqueue_head(&(port->wait));
@@ -1203,7 +1202,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
static void serial_close(struct tty_struct *tty, struct file *filp)
{
struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
if (!serial)
@@ -1226,7 +1225,7 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
mydbg("%s - port->closePending = 1\n", __func__);
if (serial->dev) {
- qt_close(port, filp);
+ qt_close(tty, port, filp);
port->open_count = 0;
}
}
@@ -1240,20 +1239,21 @@ exit:
}
-static void qt_close(struct usb_serial_port *port, struct file *filp)
+static void qt_close(struct tty_struct *tty, struct usb_serial_port *port,
+ struct file *filp)
{
unsigned long jift = jiffies + 10 * HZ;
- __u8 LSR_Value, MCR_Value;
+ u8 lsr, mcr;
struct usb_serial *serial = port->serial;
int status;
- unsigned int UartNumber;
+ unsigned int index;
struct qt_open_channel_data ChannelData;
status = 0;
- LSR_Value = 0;
+ lsr = 0;
mydbg("%s - port %d\n", __func__, port->number);
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
/* shutdown any bulk reads that might be going on */
if (serial->num_bulk_out)
@@ -1263,20 +1263,19 @@ static void qt_close(struct usb_serial_port *port, struct file *filp)
/* wait up to 30 seconds for transmitter to empty */
do {
- status = BoxGetRegister(serial, UartNumber, LINE_STATUS_REGISTER, &LSR_Value);
+ status = BoxGetRegister(serial, index, LINE_STATUS_REGISTER, &lsr);
if (status < 0) {
mydbg(__FILE__ "box_get_device failed\n");
break;
}
- if ((LSR_Value & SERIAL_LSR_TEMT)
+ if ((lsr & SERIAL_LSR_TEMT)
&& (port->ReadBulkStopped == 1))
break;
schedule();
}
- while (jiffies <= jift)
- ;
+ while (jiffies <= jift);
if (jiffies > jift)
mydbg("%s - port %d timout of checking transmitter empty\n",
@@ -1286,17 +1285,17 @@ static void qt_close(struct usb_serial_port *port, struct file *filp)
__func__, port->number);
status =
- BoxGetRegister(serial, UartNumber, MODEM_CONTROL_REGISTER,
- &MCR_Value);
- mydbg(__FILE__ "BoxGetRegister MCR = 0x%x.\n", MCR_Value);
+ BoxGetRegister(serial, index, MODEM_CONTROL_REGISTER,
+ &mcr);
+ mydbg(__FILE__ "BoxGetRegister MCR = 0x%x.\n", mcr);
if (status >= 0) {
- MCR_Value &= ~(SERIAL_MCR_DTR | SERIAL_MCR_RTS);
- /* status = BoxSetRegister(serial, UartNumber, MODEM_CONTROL_REGISTER, MCR_Value); */
+ mcr &= ~(SERIAL_MCR_DTR | SERIAL_MCR_RTS);
+ /* status = BoxSetRegister(serial, index, MODEM_CONTROL_REGISTER, mcr); */
}
/* Close uart channel */
- status = BoxOPenCloseChannel(serial, UartNumber, 0, &ChannelData);
+ status = BoxOPenCloseChannel(serial, index, 0, &ChannelData);
if (status < 0)
mydbg("%s - port %d BoxOPenCloseChannel failed.\n",
__func__, port->number);
@@ -1308,12 +1307,10 @@ static void qt_close(struct usb_serial_port *port, struct file *filp)
static int serial_write(struct tty_struct *tty, const unsigned char *buf,
int count)
{
- struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial;
int retval = -EINVAL;
- unsigned int UartNumber;
- int from_user = 0;
+ unsigned int index;
serial = get_usb_serial(port, __func__);
if (serial == NULL)
@@ -1321,7 +1318,7 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf,
/* This can happen if we get disconnected a */
if (port->open_count == 0)
return -ENODEV;
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
mydbg("%s - port %d, %d byte(s)\n", __func__, port->number, count);
mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding);
@@ -1331,19 +1328,19 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf,
goto exit;
}
- retval = qt_write(port, from_user, buf, count);
+ retval = qt_write(tty, port, buf, count);
exit:
return retval;
}
-static int qt_write(struct usb_serial_port *port, int from_user,
- const unsigned char *buf, int count)
+static int qt_write(struct tty_struct *tty, struct usb_serial_port *port,
+ const unsigned char *buf, int count)
{
int result;
- unsigned int UartNumber;
-
+ unsigned int index;
struct usb_serial *serial = get_usb_serial(port, __func__);
+
if (serial == NULL)
return -ENODEV;
@@ -1354,7 +1351,7 @@ static int qt_write(struct usb_serial_port *port, int from_user,
return 0;
}
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
/* only do something if we have a bulk out endpoint */
if (serial->num_bulk_out) {
if (port->write_urb->status == -EINPROGRESS) {
@@ -1364,14 +1361,7 @@ static int qt_write(struct usb_serial_port *port, int from_user,
count =
(count > port->bulk_out_size) ? port->bulk_out_size : count;
-
- if (from_user) {
- if (copy_from_user
- (port->write_urb->transfer_buffer, buf, count))
- return -EFAULT;
- } else {
- memcpy(port->write_urb->transfer_buffer, buf, count);
- }
+ memcpy(port->write_urb->transfer_buffer, buf, count);
/* usb_serial_debug_data(__FILE__, __func__, count, port->write_urb->transfer_buffer); */
@@ -1449,8 +1439,7 @@ static void port_softint(struct work_struct *work)
}
static int serial_write_room(struct tty_struct *tty)
{
- struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
int retval = -EINVAL;
@@ -1493,8 +1482,7 @@ static int qt_write_room(struct usb_serial_port *port)
}
static int serial_chars_in_buffer(struct tty_struct *tty)
{
- struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
int retval = -EINVAL;
@@ -1537,17 +1525,16 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear)
{
- struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
int retval = -ENODEV;
- unsigned int UartNumber;
+ unsigned int index;
mydbg("In %s \n", __func__);
if (!serial)
return -ENODEV;
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
down(&port->sem);
@@ -1559,22 +1546,22 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file,
goto exit;
}
- retval = qt_tiocmset(port, file, set);
+ retval = qt_tiocmset(tty, port, file, set);
exit:
up(&port->sem);
return retval;
}
-static int qt_tiocmset(struct usb_serial_port *port, struct file *file,
- unsigned int value)
+static int qt_tiocmset(struct tty_struct *tty, struct usb_serial_port *port,
+ struct file *file, unsigned int value)
{
- __u8 MCR_Value;
+ u8 mcr;
int status;
- unsigned int UartNumber;
-
+ unsigned int index;
struct usb_serial *serial = get_usb_serial(port, __func__);
+
if (serial == NULL)
return -ENODEV;
@@ -1583,10 +1570,10 @@ static int qt_tiocmset(struct usb_serial_port *port, struct file *file,
/**************************************************************************************/
/** TIOCMGET
*/
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
status =
- BoxGetRegister(port->serial, UartNumber, MODEM_CONTROL_REGISTER,
- &MCR_Value);
+ BoxGetRegister(port->serial, index, MODEM_CONTROL_REGISTER,
+ &mcr);
if (status < 0)
return -ESPIPE;
@@ -1594,17 +1581,17 @@ static int qt_tiocmset(struct usb_serial_port *port, struct file *file,
* Turn off the RTS and DTR and loopbcck and then only turn on what was
* asked for
*/
- MCR_Value &= ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | SERIAL_MCR_LOOP);
+ mcr &= ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | SERIAL_MCR_LOOP);
if (value & TIOCM_RTS)
- MCR_Value |= SERIAL_MCR_RTS;
+ mcr |= SERIAL_MCR_RTS;
if (value & TIOCM_DTR)
- MCR_Value |= SERIAL_MCR_DTR;
+ mcr |= SERIAL_MCR_DTR;
if (value & TIOCM_LOOP)
- MCR_Value |= SERIAL_MCR_LOOP;
+ mcr |= SERIAL_MCR_LOOP;
status =
- BoxSetRegister(port->serial, UartNumber, MODEM_CONTROL_REGISTER,
- MCR_Value);
+ BoxSetRegister(port->serial, index, MODEM_CONTROL_REGISTER,
+ mcr);
if (status < 0)
return -ESPIPE;
else
@@ -1614,18 +1601,16 @@ static int qt_tiocmset(struct usb_serial_port *port, struct file *file,
static int serial_tiocmget(struct tty_struct *tty, struct file *file)
{
- struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
-
+ struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
int retval = -ENODEV;
- unsigned int UartNumber;
+ unsigned int index;
mydbg("In %s \n", __func__);
if (!serial)
return -ENODEV;
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
down(&port->sem);
@@ -1637,56 +1622,55 @@ static int serial_tiocmget(struct tty_struct *tty, struct file *file)
goto exit;
}
- retval = qt_tiocmget(port, file);
+ retval = qt_tiocmget(tty, port, file);
exit:
up(&port->sem);
return retval;
}
-static int qt_tiocmget(struct usb_serial_port *port, struct file *file)
+static int qt_tiocmget(struct tty_struct *tty,
+ struct usb_serial_port *port, struct file *file)
{
- __u8 MCR_Value;
- __u8 MSR_Value;
+ u8 mcr;
+ u8 msr;
unsigned int result = 0;
int status;
- unsigned int UartNumber;
- struct tty_struct *tty;
+ unsigned int index;
struct usb_serial *serial = get_usb_serial(port, __func__);
if (serial == NULL)
return -ENODEV;
- tty = port->tty;
mydbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty);
/**************************************************************************************/
/** TIOCMGET
*/
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
status =
- BoxGetRegister(port->serial, UartNumber, MODEM_CONTROL_REGISTER,
- &MCR_Value);
+ BoxGetRegister(port->serial, index, MODEM_CONTROL_REGISTER,
+ &mcr);
if (status >= 0) {
status =
- BoxGetRegister(port->serial, UartNumber,
- MODEM_STATUS_REGISTER, &MSR_Value);
+ BoxGetRegister(port->serial, index,
+ MODEM_STATUS_REGISTER, &msr);
}
if (status >= 0) {
- result = ((MCR_Value & SERIAL_MCR_DTR) ? TIOCM_DTR : 0)
+ result = ((mcr & SERIAL_MCR_DTR) ? TIOCM_DTR : 0)
/* DTR IS SET */
- | ((MCR_Value & SERIAL_MCR_RTS) ? TIOCM_RTS : 0)
+ | ((mcr & SERIAL_MCR_RTS) ? TIOCM_RTS : 0)
/* RTS IS SET */
- | ((MSR_Value & SERIAL_MSR_CTS) ? TIOCM_CTS : 0)
+ | ((msr & SERIAL_MSR_CTS) ? TIOCM_CTS : 0)
/* CTS is set */
- | ((MSR_Value & SERIAL_MSR_CD) ? TIOCM_CAR : 0)
+ | ((msr & SERIAL_MSR_CD) ? TIOCM_CAR : 0)
/* Carrier detect is set */
- | ((MSR_Value & SERIAL_MSR_RI) ? TIOCM_RI : 0)
+ | ((msr & SERIAL_MSR_RI) ? TIOCM_RI : 0)
/* Ring indicator set */
- | ((MSR_Value & SERIAL_MSR_DSR) ? TIOCM_DSR : 0);
+ | ((msr & SERIAL_MSR_DSR) ? TIOCM_DSR : 0);
/* DSR is set */
return result;
@@ -1698,17 +1682,16 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg)
{
- struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
int retval = -ENODEV;
- unsigned int UartNumber;
+ unsigned int index;
mydbg("In %s \n", __func__);
if (!serial)
return -ENODEV;
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
down(&port->sem);
@@ -1720,125 +1703,34 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file,
goto exit;
}
- retval = qt_ioctl(port, file, cmd, arg);
+ retval = qt_ioctl(tty, port, file, cmd, arg);
exit:
up(&port->sem);
return retval;
}
-static int qt_ioctl(struct usb_serial_port *port, struct file *file,
- unsigned int cmd, unsigned long arg)
+static int qt_ioctl(struct tty_struct *tty, struct usb_serial_port *port,
+ struct file *file, unsigned int cmd, unsigned long arg)
{
- __u8 MCR_Value;
- __u8 MSR_Value;
- unsigned short Prev_MSR_Value;
+ __u8 mcr;
+ __u8 msr;
+ unsigned short prev_msr;
unsigned int value, result = 0;
int status;
- unsigned int UartNumber;
- struct tty_struct *tty;
+ unsigned int index;
struct usb_serial *serial = get_usb_serial(port, __func__);
if (serial == NULL)
return -ENODEV;
- tty = port->tty;
mydbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty);
/* TIOCMGET */
- UartNumber = port->tty->index - serial->minor;
-
- if (cmd == TIOCMGET) {
- MCR_Value = port->shadowMCR;
- MSR_Value = port->shadowMSR;
-
- {
- result = ((MCR_Value & SERIAL_MCR_DTR) ? TIOCM_DTR : 0)
- /* DTR IS SET */
- | ((MCR_Value & SERIAL_MCR_RTS) ? TIOCM_RTS : 0)
- /* RTS IS SET */
- | ((MSR_Value & SERIAL_MSR_CTS) ? TIOCM_CTS : 0)
- /* CTS is set */
- | ((MSR_Value & SERIAL_MSR_CD) ? TIOCM_CAR : 0)
- /* Carrier detect is set */
- | ((MSR_Value & SERIAL_MSR_RI) ? TIOCM_RI : 0)
- /* Ring indicator set */
- | ((MSR_Value & SERIAL_MSR_DSR) ? TIOCM_DSR : 0);
- /* DSR is set */
- if (copy_to_user
- ((unsigned int *)arg, &result,
- sizeof(unsigned int)))
- return -EFAULT;
- return 0;
-
- }
- }
-
- /* TIOCMBIS, TIOCMBIC, AND TIOCMSET */
- if (cmd == TIOCMBIS || cmd == TIOCMBIC || cmd == TIOCMSET) {
- status =
- BoxGetRegister(port->serial, UartNumber,
- MODEM_CONTROL_REGISTER, &MCR_Value);
- if (status < 0)
- return -ESPIPE;
- if (copy_from_user
- (&value, (unsigned int *)arg, sizeof(unsigned int)))
- return -EFAULT;
-
- switch (cmd) {
- case TIOCMBIS:
- if (value & TIOCM_RTS)
- MCR_Value |= SERIAL_MCR_RTS;
- if (value & TIOCM_DTR)
- MCR_Value |= SERIAL_MCR_DTR;
- if (value & TIOCM_LOOP)
- MCR_Value |= SERIAL_MCR_LOOP;
- break;
- case TIOCMBIC:
- if (value & TIOCM_RTS)
- MCR_Value &= ~SERIAL_MCR_RTS;
- if (value & TIOCM_DTR)
- MCR_Value &= ~SERIAL_MCR_DTR;
- if (value & TIOCM_LOOP)
- MCR_Value &= ~SERIAL_MCR_LOOP;
- break;
- case TIOCMSET:
- /*
- * Turn off the RTS and DTR and loopbcck and then only
- * turn on what was asked for
- */
- MCR_Value &=
- ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR |
- SERIAL_MCR_LOOP);
- if (value & TIOCM_RTS)
- MCR_Value |= SERIAL_MCR_RTS;
- if (value & TIOCM_DTR)
- MCR_Value |= SERIAL_MCR_DTR;
- if (value & TIOCM_LOOP)
- MCR_Value |= SERIAL_MCR_LOOP;
- break;
- default:
- break;
-
- }
- status =
- BoxSetRegister(port->serial, UartNumber,
- MODEM_CONTROL_REGISTER, MCR_Value);
- if (status < 0)
- return -ESPIPE;
- else {
- port->shadowMCR = MCR_Value;
- return 0;
- }
-
- }
- /**************************************************************************************/
- /** TIOCMBIS, TIOCMBIC, AND TIOCMSET end
- */
- /**************************************************************************************/
+ index = tty->index - serial->minor;
if (cmd == TIOCMIWAIT) {
DECLARE_WAITQUEUE(wait, current);
- Prev_MSR_Value = port->shadowMSR & SERIAL_MSR_MASK;
+ prev_msr = port->shadowMSR & SERIAL_MSR_MASK;
while (1) {
add_wait_queue(&port->wait, &wait);
set_current_state(TASK_INTERRUPTIBLE);
@@ -1847,22 +1739,22 @@ static int qt_ioctl(struct usb_serial_port *port, struct file *file,
/* see if a signal woke us up */
if (signal_pending(current))
return -ERESTARTSYS;
- MSR_Value = port->shadowMSR & SERIAL_MSR_MASK;
- if (MSR_Value == Prev_MSR_Value)
+ msr = port->shadowMSR & SERIAL_MSR_MASK;
+ if (msr == prev_msr)
return -EIO; /* no change error */
if ((arg & TIOCM_RNG
- && ((Prev_MSR_Value & SERIAL_MSR_RI) ==
- (MSR_Value & SERIAL_MSR_RI)))
+ && ((prev_msr & SERIAL_MSR_RI) ==
+ (msr & SERIAL_MSR_RI)))
|| (arg & TIOCM_DSR
- && ((Prev_MSR_Value & SERIAL_MSR_DSR) ==
- (MSR_Value & SERIAL_MSR_DSR)))
+ && ((prev_msr & SERIAL_MSR_DSR) ==
+ (msr & SERIAL_MSR_DSR)))
|| (arg & TIOCM_CD
- && ((Prev_MSR_Value & SERIAL_MSR_CD) ==
- (MSR_Value & SERIAL_MSR_CD)))
+ && ((prev_msr & SERIAL_MSR_CD) ==
+ (msr & SERIAL_MSR_CD)))
|| (arg & TIOCM_CTS
- && ((Prev_MSR_Value & SERIAL_MSR_CTS) ==
- (MSR_Value & SERIAL_MSR_CTS)))) {
+ && ((prev_msr & SERIAL_MSR_CTS) ==
+ (msr & SERIAL_MSR_CTS)))) {
return 0;
}
@@ -1878,7 +1770,7 @@ static int qt_ioctl(struct usb_serial_port *port, struct file *file,
static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
{
struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
if (!serial)
@@ -1894,22 +1786,22 @@ static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
}
/* pass on to the driver specific version of this function if it is available */
- qt_set_termios(port, old);
+ qt_set_termios(tty, port, old);
exit:
up(&port->sem);
}
-static void qt_set_termios(struct usb_serial_port *port,
+static void qt_set_termios(struct tty_struct *tty,
+ struct usb_serial_port *port,
struct ktermios *old_termios)
{
unsigned int cflag;
int baud, divisor, remainder;
- unsigned char LCR_change_to = 0;
- struct tty_struct *tty;
+ unsigned char new_LCR = 0;
int status;
struct usb_serial *serial;
- __u16 UartNumber;
+ __u16 index;
__u16 tmp, tmp2;
mydbg("%s - port %d\n", __func__, port->number);
@@ -1921,59 +1813,46 @@ static void qt_set_termios(struct usb_serial_port *port,
tmp2 = serial->minor;
mydbg("%s - serial->minor = %d\n", __func__, tmp2);
- UartNumber = port->tty->index - serial->minor;
-
- tty = port->tty;
+ index = port->tty->index - serial->minor;
cflag = tty->termios->c_cflag;
- if (old_termios) {
- if ((cflag == old_termios->c_cflag)
- && (RELEVANT_IFLAG(tty->termios->c_iflag) ==
- RELEVANT_IFLAG(old_termios->c_iflag))) {
- mydbg("%s - Nothing to change\n", __func__);
- return;
- }
-
- }
-
mydbg("%s - 3\n", __func__);
switch (cflag) {
case CS5:
- LCR_change_to |= SERIAL_5_DATA;
+ new_LCR |= SERIAL_5_DATA;
break;
case CS6:
- LCR_change_to |= SERIAL_6_DATA;
+ new_LCR |= SERIAL_6_DATA;
break;
case CS7:
- LCR_change_to |= SERIAL_7_DATA;
+ new_LCR |= SERIAL_7_DATA;
break;
default:
case CS8:
- LCR_change_to |= SERIAL_8_DATA;
+ new_LCR |= SERIAL_8_DATA;
break;
}
/* Parity stuff */
if (cflag & PARENB) {
if (cflag & PARODD)
- LCR_change_to |= SERIAL_ODD_PARITY;
+ new_LCR |= SERIAL_ODD_PARITY;
else
- LCR_change_to |= SERIAL_EVEN_PARITY;
+ new_LCR |= SERIAL_EVEN_PARITY;
}
if (cflag & CSTOPB)
- LCR_change_to |= SERIAL_TWO_STOPB;
+ new_LCR |= SERIAL_TWO_STOPB;
else
- LCR_change_to |= SERIAL_TWO_STOPB;
+ new_LCR |= SERIAL_TWO_STOPB;
mydbg("%s - 4\n", __func__);
/* Thats the LCR stuff, go ahead and set it */
baud = tty_get_baud_rate(tty);
- if (!baud) {
+ if (!baud)
/* pick a default, any default... */
baud = 9600;
- }
mydbg("%s - got baud = %d\n", __func__, baud);
@@ -1986,9 +1865,7 @@ static void qt_set_termios(struct usb_serial_port *port,
/*
* Set Baud rate to default and turn off (default)flow control here
*/
- status =
- BoxSetUart(serial, UartNumber, (unsigned short)divisor,
- LCR_change_to);
+ status = BoxSetUart(serial, index, (unsigned short)divisor, new_LCR);
if (status < 0) {
mydbg(__FILE__ "BoxSetUart failed\n");
return;
@@ -2000,7 +1877,7 @@ static void qt_set_termios(struct usb_serial_port *port,
port->number);
/* Enable RTS/CTS flow control */
- status = BoxSetHW_FlowCtrl(serial, UartNumber, 1);
+ status = BoxSetHW_FlowCtrl(serial, index, 1);
if (status < 0) {
mydbg(__FILE__ "BoxSetHW_FlowCtrl failed\n");
@@ -2011,7 +1888,7 @@ static void qt_set_termios(struct usb_serial_port *port,
mydbg("%s - disabling HW flow control port %d\n", __func__,
port->number);
- status = BoxSetHW_FlowCtrl(serial, UartNumber, 0);
+ status = BoxSetHW_FlowCtrl(serial, index, 0);
if (status < 0) {
mydbg(__FILE__ "BoxSetHW_FlowCtrl failed\n");
return;
@@ -2025,19 +1902,20 @@ static void qt_set_termios(struct usb_serial_port *port,
unsigned char stop_char = STOP_CHAR(tty);
unsigned char start_char = START_CHAR(tty);
status =
- BoxSetSW_FlowCtrl(serial, UartNumber, stop_char,
+ BoxSetSW_FlowCtrl(serial, index, stop_char,
start_char);
if (status < 0)
mydbg(__FILE__ "BoxSetSW_FlowCtrl (enabled) failed\n");
} else {
/* disable SW flow control */
- status = BoxDisable_SW_FlowCtrl(serial, UartNumber);
+ status = BoxDisable_SW_FlowCtrl(serial, index);
if (status < 0)
mydbg(__FILE__ "BoxSetSW_FlowCtrl (diabling) failed\n");
}
-
+ tty->termios->c_cflag &= ~CMSPAR;
+ /* FIXME: Error cases should be returning the actual bits changed only */
}
/****************************************************************************
@@ -2237,11 +2115,11 @@ static int BoxSetUart(struct usb_serial *serial, unsigned short Uart_Number,
return result;
}
-static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int UartNumber,
+static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int index,
int bSet)
{
- __u8 MCR_Value = 0;
- __u8 MSR_Value = 0, MOUT_Value = 0;
+ __u8 mcr = 0;
+ __u8 msr = 0, MOUT_Value = 0;
struct usb_serial_port *port;
unsigned int status;
@@ -2249,34 +2127,34 @@ static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int UartNumber,
if (bSet == 1) {
/* flow control, box will clear RTS line to prevent remote */
- MCR_Value = SERIAL_MCR_RTS;
+ mcr = SERIAL_MCR_RTS;
} /* device from xmitting more chars */
else {
/* no flow control to remote device */
- MCR_Value = 0;
+ mcr = 0;
}
- MOUT_Value = MCR_Value << 8;
+ MOUT_Value = mcr << 8;
if (bSet == 1) {
/* flow control, box will inhibit xmit data if CTS line is
* asserted */
- MSR_Value = SERIAL_MSR_CTS;
+ msr = SERIAL_MSR_CTS;
} else {
/* Box will not inhimbe xmit data due to CTS line */
- MSR_Value = 0;
+ msr = 0;
}
- MOUT_Value |= MSR_Value;
+ MOUT_Value |= msr;
status =
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
QT_HW_FLOW_CONTROL_MASK, 0x40, MOUT_Value,
- UartNumber, NULL, 0, 300);
+ index, NULL, 0, 300);
return status;
}
-static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber,
+static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 index,
unsigned char stop_char, unsigned char start_char)
{
__u16 nSWflowout;
@@ -2288,17 +2166,17 @@ static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber,
result =
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
QT_SW_FLOW_CONTROL_MASK, 0x40, nSWflowout,
- UartNumber, NULL, 0, 300);
+ index, NULL, 0, 300);
return result;
}
-static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber)
+static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 index)
{
int result;
result =
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT_SW_FLOW_CONTROL_DISABLE, 0x40, 0, UartNumber,
+ QT_SW_FLOW_CONTROL_DISABLE, 0x40, 0, index,
NULL, 0, 300);
return result;
@@ -2307,7 +2185,7 @@ static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber)
static void serial_throttle(struct tty_struct *tty)
{
struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
mydbg("%s - port %d\n", __func__, port->number);
@@ -2334,7 +2212,7 @@ exit:
static void serial_unthrottle(struct tty_struct *tty)
{
struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
unsigned int result;
@@ -2380,20 +2258,19 @@ exit:
static int serial_break(struct tty_struct *tty, int break_state)
{
- struct usb_serial_port *port =
- (struct usb_serial_port *)tty->driver_data;
+ struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = get_usb_serial(port, __func__);
- __u16 UartNumber, Break_Value;
+ u16 index, onoff;
unsigned int result;
- UartNumber = port->tty->index - serial->minor;
+ index = tty->index - serial->minor;
if (!serial)
return -ENODEV;
if (break_state == -1)
- Break_Value = 1;
+ onoff = 1;
else
- Break_Value = 0;
+ onoff = 0;
down(&port->sem);
@@ -2406,7 +2283,7 @@ static int serial_break(struct tty_struct *tty, int break_state)
result =
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT_BREAK_CONTROL, 0x40, Break_Value, UartNumber,
+ QT_BREAK_CONTROL, 0x40, onoff, index,
NULL, 0, 300);
exit:
From: Claudio Scordino <[email protected]>
Use the new general RS485 Linux data structure (introduced by Alan with
commit number c26c56c0f40e200e61d1390629c806f6adaffbcc) in the Cris
architecture too (currently, Cris still uses the old private data
structure instead of the new one).
Signed-off-by: Claudio Scordino <[email protected]>
Tested-by: Hinko Kocevar <[email protected]>
Tested-by: Janez Cufer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Alan Cox <[email protected]>
---
arch/cris/include/asm/ioctls.h | 5 +-
arch/cris/include/asm/rs485.h | 8 +---
arch/cris/include/asm/termios.h | 1
drivers/serial/crisv10.c | 79 +++++++++++++++++++++++++++++----------
drivers/serial/crisv10.h | 2 -
5 files changed, 66 insertions(+), 29 deletions(-)
diff --git a/arch/cris/include/asm/ioctls.h b/arch/cris/include/asm/ioctls.h
index 4f4e525..35bbc18 100644
--- a/arch/cris/include/asm/ioctls.h
+++ b/arch/cris/include/asm/ioctls.h
@@ -74,8 +74,9 @@
#define TIOCSHAYESESP 0x545F /* Set Hayes ESP configuration */
#define FIOQSIZE 0x5460
-#define TIOCSERSETRS485 0x5461 /* enable rs-485 */
-#define TIOCSERWRRS485 0x5462 /* write rs-485 */
+#define TIOCSERSETRS485 0x5461 /* enable rs-485 (deprecated) */
+#define TIOCSERWRRS485 0x5462 /* write rs-485 */
+#define TIOCSRS485 0x5463 /* enable rs-485 */
/* Used for packet mode */
#define TIOCPKT_DATA 0
diff --git a/arch/cris/include/asm/rs485.h b/arch/cris/include/asm/rs485.h
index c331c51..ad40f9f 100644
--- a/arch/cris/include/asm/rs485.h
+++ b/arch/cris/include/asm/rs485.h
@@ -1,15 +1,13 @@
/* RS-485 structures */
-/* RS-485 support */
-/* Used with ioctl() TIOCSERSETRS485 */
+/* Used with ioctl() TIOCSERSETRS485 for backward compatibility!
+ * XXX: Do not use it for new code!
+ */
struct rs485_control {
unsigned short rts_on_send;
unsigned short rts_after_sent;
unsigned long delay_rts_before_send;
unsigned short enabled;
-#ifdef __KERNEL__
- int disable_serial_loopback;
-#endif
};
/* Used with ioctl() TIOCSERWRRS485 */
diff --git a/arch/cris/include/asm/termios.h b/arch/cris/include/asm/termios.h
index b0124e6..1265109 100644
--- a/arch/cris/include/asm/termios.h
+++ b/arch/cris/include/asm/termios.h
@@ -4,6 +4,7 @@
#include <asm/termbits.h>
#include <asm/ioctls.h>
#include <asm/rs485.h>
+#include <linux/serial.h>
struct winsize {
unsigned short ws_row;
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index e642c22..7ba7d70 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -1391,7 +1391,7 @@ static inline void e100_disable_rx_irq(struct e100_serial *info)
#if defined(CONFIG_ETRAX_RS485)
/* Enable RS-485 mode on selected port. This is UGLY. */
static int
-e100_enable_rs485(struct tty_struct *tty,struct rs485_control *r)
+e100_enable_rs485(struct tty_struct *tty, struct serial_rs485 *r)
{
struct e100_serial * info = (struct e100_serial *)tty->driver_data;
@@ -1409,13 +1409,11 @@ e100_enable_rs485(struct tty_struct *tty,struct rs485_control *r)
CONFIG_ETRAX_RS485_LTC1387_RXEN_PORT_G_BIT, 1);
#endif
- info->rs485.rts_on_send = 0x01 & r->rts_on_send;
- info->rs485.rts_after_sent = 0x01 & r->rts_after_sent;
+ info->rs485.flags = r->flags;
if (r->delay_rts_before_send >= 1000)
info->rs485.delay_rts_before_send = 1000;
else
info->rs485.delay_rts_before_send = r->delay_rts_before_send;
- info->rs485.enabled = r->enabled;
/* printk("rts: on send = %i, after = %i, enabled = %i",
info->rs485.rts_on_send,
info->rs485.rts_after_sent,
@@ -1430,17 +1428,18 @@ e100_write_rs485(struct tty_struct *tty,
const unsigned char *buf, int count)
{
struct e100_serial * info = (struct e100_serial *)tty->driver_data;
- int old_enabled = info->rs485.enabled;
+ int old_value = (info->rs485.flags) & SER_RS485_ENABLED;
/* rs485 is always implicitly enabled if we're using the ioctl()
- * but it doesn't have to be set in the rs485_control
+ * but it doesn't have to be set in the serial_rs485
* (to be backward compatible with old apps)
* So we store, set and restore it.
*/
- info->rs485.enabled = 1;
+ info->rs485.flags |= SER_RS485_ENABLED;
/* rs_write now deals with RS485 if enabled */
count = rs_write(tty, buf, count);
- info->rs485.enabled = old_enabled;
+ if (!old_value)
+ info->rs485.flags &= ~(SER_RS485_ENABLED);
return count;
}
@@ -1451,7 +1450,7 @@ static void rs485_toggle_rts_timer_function(unsigned long data)
struct e100_serial *info = (struct e100_serial *)data;
fast_timers_rs485[info->line].function = NULL;
- e100_rts(info, info->rs485.rts_after_sent);
+ e100_rts(info, (info->rs485.flags & SER_RS485_RTS_AFTER_SEND));
#if defined(CONFIG_ETRAX_RS485_DISABLE_RECEIVER)
e100_enable_rx(info);
e100_enable_rx_irq(info);
@@ -1647,7 +1646,7 @@ transmit_chars_dma(struct e100_serial *info)
info->tr_running = 0;
#if defined(CONFIG_ETRAX_RS485) && defined(CONFIG_ETRAX_FAST_TIMER)
- if (info->rs485.enabled) {
+ if (info->rs485.flags & SER_RS485_ENABLED) {
/* Set a short timer to toggle RTS */
start_one_shot_timer(&fast_timers_rs485[info->line],
rs485_toggle_rts_timer_function,
@@ -2577,7 +2576,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
info->icount.tx++;
if (info->xmit.head == info->xmit.tail) {
#if defined(CONFIG_ETRAX_RS485) && defined(CONFIG_ETRAX_FAST_TIMER)
- if (info->rs485.enabled) {
+ if (info->rs485.flags & SER_RS485_ENABLED) {
/* Set a short timer to toggle RTS */
start_one_shot_timer(&fast_timers_rs485[info->line],
rs485_toggle_rts_timer_function,
@@ -3218,7 +3217,7 @@ rs_write(struct tty_struct *tty,
#if defined(CONFIG_ETRAX_RS485)
struct e100_serial *info = (struct e100_serial *)tty->driver_data;
- if (info->rs485.enabled)
+ if (info->rs485.flags & SER_RS485_ENABLED)
{
/* If we are in RS-485 mode, we need to toggle RTS and disable
* the receiver before initiating a DMA transfer
@@ -3228,7 +3227,7 @@ rs_write(struct tty_struct *tty,
fast_timers_rs485[info->line].function = NULL;
del_fast_timer(&fast_timers_rs485[info->line]);
#endif
- e100_rts(info, info->rs485.rts_on_send);
+ e100_rts(info, (info->rs485.flags & SER_RS485_RTS_ON_SEND));
#if defined(CONFIG_ETRAX_RS485_DISABLE_RECEIVER)
e100_disable_rx(info);
e100_enable_rx_irq(info);
@@ -3242,7 +3241,7 @@ rs_write(struct tty_struct *tty,
count = rs_raw_write(tty, buf, count);
#if defined(CONFIG_ETRAX_RS485)
- if (info->rs485.enabled)
+ if (info->rs485.flags & SER_RS485_ENABLED)
{
unsigned int val;
/* If we are in RS-485 mode the following has to be done:
@@ -3263,7 +3262,7 @@ rs_write(struct tty_struct *tty,
get_lsr_info(info, &val);
}while (!(val & TIOCSER_TEMT));
- e100_rts(info, info->rs485.rts_after_sent);
+ e100_rts(info, (info->rs485.flags & SER_RS485_RTS_AFTER_SEND));
#if defined(CONFIG_ETRAX_RS485_DISABLE_RECEIVER)
e100_enable_rx(info);
@@ -3678,14 +3677,52 @@ rs_ioctl(struct tty_struct *tty, struct file * file,
#if defined(CONFIG_ETRAX_RS485)
case TIOCSERSETRS485:
{
+ /* In this ioctl we still use the old structure
+ * rs485_control for backward compatibility
+ * (if we use serial_rs485, then old user-level code
+ * wouldn't work anymore...).
+ * The use of this ioctl is deprecated: use TIOCSRS485
+ * instead.*/
struct rs485_control rs485ctrl;
+ struct serial_rs485 rs485data;
+ printk(KERN_DEBUG "The use of this ioctl is deprecated. Use TIOCSRS485 instead\n");
if (copy_from_user(&rs485ctrl, (struct rs485_control *)arg,
sizeof(rs485ctrl)))
return -EFAULT;
- return e100_enable_rs485(tty, &rs485ctrl);
+ rs485data.delay_rts_before_send = rs485ctrl.delay_rts_before_send;
+ rs485data.flags = 0;
+ if (rs485ctrl.enabled)
+ rs485data.flags |= SER_RS485_ENABLED;
+ else
+ rs485data.flags &= ~(SER_RS485_ENABLED);
+
+ if (rs485ctrl.rts_on_send)
+ rs485data.flags |= SER_RS485_RTS_ON_SEND;
+ else
+ rs485data.flags &= ~(SER_RS485_RTS_ON_SEND);
+
+ if (rs485ctrl.rts_after_sent)
+ rs485data.flags |= SER_RS485_RTS_AFTER_SEND;
+ else
+ rs485data.flags &= ~(SER_RS485_RTS_AFTER_SEND);
+
+ return e100_enable_rs485(tty, &rs485data);
}
+ case TIOCSRS485:
+ {
+ /* This is the new version of TIOCSRS485, with new
+ * data structure serial_rs485 */
+ struct serial_rs485 rs485data;
+ if (copy_from_user(&rs485data, (struct rs485_control *)arg,
+ sizeof(rs485data)))
+ return -EFAULT;
+
+ return e100_enable_rs485(tty, &rs485data);
+ }
+
+
case TIOCSERWRRS485:
{
struct rs485_write rs485wr;
@@ -3827,8 +3864,8 @@ rs_close(struct tty_struct *tty, struct file * filp)
/* port closed */
#if defined(CONFIG_ETRAX_RS485)
- if (info->rs485.enabled) {
- info->rs485.enabled = 0;
+ if (info->rs485.flags & SER_RS485_ENABLED) {
+ info->rs485.flags &= ~(SER_RS485_ENABLED);
#if defined(CONFIG_ETRAX_RS485_ON_PA)
*R_PORT_PA_DATA = port_pa_data_shadow &= ~(1 << rs485_pa_bit);
#endif
@@ -4493,10 +4530,10 @@ rs_init(void)
#if defined(CONFIG_ETRAX_RS485)
/* Set sane defaults */
- info->rs485.rts_on_send = 0;
- info->rs485.rts_after_sent = 1;
+ info->rs485.flags &= ~(SER_RS485_RTS_ON_SEND);
+ info->rs485.flags |= SER_RS485_RTS_AFTER_SEND;
info->rs485.delay_rts_before_send = 0;
- info->rs485.enabled = 0;
+ info->rs485.flags &= ~(SER_RS485_ENABLED);
#endif
INIT_WORK(&info->work, do_softint);
diff --git a/drivers/serial/crisv10.h b/drivers/serial/crisv10.h
index f36a729..ea0beb4 100644
--- a/drivers/serial/crisv10.h
+++ b/drivers/serial/crisv10.h
@@ -125,7 +125,7 @@ struct e100_serial {
int errorcode;
#ifdef CONFIG_ETRAX_RS485
- struct rs485_control rs485; /* RS-485 support */
+ struct serial_rs485 rs485; /* RS-485 support */
#endif
};
From: Sonic Zhang <[email protected]>
Signed-off-by: Sonic Zhang <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Alan Cox <[email protected]>
---
.../mach-bf527/include/mach/bfin_serial_5xx.h | 26 ----
.../mach-bf533/include/mach/bfin_serial_5xx.h | 20 ---
.../mach-bf537/include/mach/bfin_serial_5xx.h | 27 ----
.../mach-bf548/include/mach/bfin_serial_5xx.h | 45 -------
.../mach-bf561/include/mach/bfin_serial_5xx.h | 20 ---
drivers/serial/bfin_5xx.c | 131 +++++++++++++-------
6 files changed, 82 insertions(+), 187 deletions(-)
diff --git a/arch/blackfin/mach-bf527/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf527/include/mach/bfin_serial_5xx.h
index e8c41fd..d2b160c 100644
--- a/arch/blackfin/mach-bf527/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf527/include/mach/bfin_serial_5xx.h
@@ -167,29 +167,3 @@ struct bfin_serial_res bfin_serial_resource[] = {
};
#define DRIVER_NAME "bfin-uart"
-
-static void bfin_serial_hw_init(struct bfin_serial_port *uart)
-{
-
-#ifdef CONFIG_SERIAL_BFIN_UART0
- peripheral_request(P_UART0_TX, DRIVER_NAME);
- peripheral_request(P_UART0_RX, DRIVER_NAME);
-#endif
-
-#ifdef CONFIG_SERIAL_BFIN_UART1
- peripheral_request(P_UART1_TX, DRIVER_NAME);
- peripheral_request(P_UART1_RX, DRIVER_NAME);
-#endif
-
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- if (uart->cts_pin >= 0) {
- gpio_request(uart->cts_pin, DRIVER_NAME);
- gpio_direction_input(uart->cts_pin);
- }
-
- if (uart->rts_pin >= 0) {
- gpio_request(uart->rts_pin, DRIVER_NAME);
- gpio_direction_output(uart->rts_pin, 0);
- }
-#endif
-}
diff --git a/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h
index 5f517f5..70356dd 100644
--- a/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h
@@ -142,23 +142,3 @@ struct bfin_serial_res bfin_serial_resource[] = {
};
#define DRIVER_NAME "bfin-uart"
-
-static void bfin_serial_hw_init(struct bfin_serial_port *uart)
-{
-
-#ifdef CONFIG_SERIAL_BFIN_UART0
- peripheral_request(P_UART0_TX, DRIVER_NAME);
- peripheral_request(P_UART0_RX, DRIVER_NAME);
-#endif
-
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- if (uart->cts_pin >= 0) {
- gpio_request(uart->cts_pin, DRIVER_NAME);
- gpio_direction_input(uart->cts_pin);
- }
- if (uart->rts_pin >= 0) {
- gpio_request(uart->rts_pin, DRIVER_NAME);
- gpio_direction_output(uart->rts_pin, 0);
- }
-#endif
-}
diff --git a/arch/blackfin/mach-bf537/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf537/include/mach/bfin_serial_5xx.h
index 9e34700..d46fc4f 100644
--- a/arch/blackfin/mach-bf537/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf537/include/mach/bfin_serial_5xx.h
@@ -99,7 +99,6 @@ struct bfin_serial_port {
struct work_struct tx_dma_workqueue;
#endif
#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- struct timer_list cts_timer;
int cts_pin;
int rts_pin;
#endif
@@ -167,29 +166,3 @@ struct bfin_serial_res bfin_serial_resource[] = {
};
#define DRIVER_NAME "bfin-uart"
-
-static void bfin_serial_hw_init(struct bfin_serial_port *uart)
-{
-
-#ifdef CONFIG_SERIAL_BFIN_UART0
- peripheral_request(P_UART0_TX, DRIVER_NAME);
- peripheral_request(P_UART0_RX, DRIVER_NAME);
-#endif
-
-#ifdef CONFIG_SERIAL_BFIN_UART1
- peripheral_request(P_UART1_TX, DRIVER_NAME);
- peripheral_request(P_UART1_RX, DRIVER_NAME);
-#endif
-
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- if (uart->cts_pin >= 0) {
- gpio_request(uart->cts_pin, DRIVER_NAME);
- gpio_direction_input(uart->cts_pin);
- }
-
- if (uart->rts_pin >= 0) {
- gpio_request(uart->rts_pin, DRIVER_NAME);
- gpio_direction_output(uart->rts_pin, 0);
- }
-#endif
-}
diff --git a/arch/blackfin/mach-bf548/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf548/include/mach/bfin_serial_5xx.h
index c05e79c..388e232 100644
--- a/arch/blackfin/mach-bf548/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf548/include/mach/bfin_serial_5xx.h
@@ -181,48 +181,3 @@ struct bfin_serial_res bfin_serial_resource[] = {
};
#define DRIVER_NAME "bfin-uart"
-
-static void bfin_serial_hw_init(struct bfin_serial_port *uart)
-{
-#ifdef CONFIG_SERIAL_BFIN_UART0
- peripheral_request(P_UART0_TX, DRIVER_NAME);
- peripheral_request(P_UART0_RX, DRIVER_NAME);
-#endif
-
-#ifdef CONFIG_SERIAL_BFIN_UART1
- peripheral_request(P_UART1_TX, DRIVER_NAME);
- peripheral_request(P_UART1_RX, DRIVER_NAME);
-
-#ifdef CONFIG_BFIN_UART1_CTSRTS
- peripheral_request(P_UART1_RTS, DRIVER_NAME);
- peripheral_request(P_UART1_CTS, DRIVER_NAME);
-#endif
-#endif
-
-#ifdef CONFIG_SERIAL_BFIN_UART2
- peripheral_request(P_UART2_TX, DRIVER_NAME);
- peripheral_request(P_UART2_RX, DRIVER_NAME);
-#endif
-
-#ifdef CONFIG_SERIAL_BFIN_UART3
- peripheral_request(P_UART3_TX, DRIVER_NAME);
- peripheral_request(P_UART3_RX, DRIVER_NAME);
-
-#ifdef CONFIG_BFIN_UART3_CTSRTS
- peripheral_request(P_UART3_RTS, DRIVER_NAME);
- peripheral_request(P_UART3_CTS, DRIVER_NAME);
-#endif
-#endif
- SSYNC();
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- if (uart->cts_pin >= 0) {
- gpio_request(uart->cts_pin, DRIVER_NAME);
- gpio_direction_input(uart->cts_pin);
- }
-
- if (uart->rts_pin >= 0) {
- gpio_request(uart->rts_pin, DRIVER_NAME);
- gpio_direction_output(uart->rts_pin, 0);
- }
-#endif
-}
diff --git a/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h
index ca8c5f6..d0469e3 100644
--- a/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h
@@ -142,23 +142,3 @@ struct bfin_serial_res bfin_serial_resource[] = {
};
#define DRIVER_NAME "bfin-uart"
-
-static void bfin_serial_hw_init(struct bfin_serial_port *uart)
-{
-
-#ifdef CONFIG_SERIAL_BFIN_UART0
- peripheral_request(P_UART0_TX, DRIVER_NAME);
- peripheral_request(P_UART0_RX, DRIVER_NAME);
-#endif
-
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- if (uart->cts_pin >= 0) {
- gpio_request(uart->cts_pin, DRIVER_NAME);
- gpio_direction_input(uart->cts_pin);
- }
- if (uart->rts_pin >= 0) {
- gpio_request(uart->rts_pin, DRIVER_NAME);
- gpio_direction_output(uart->rts_pin, 0);
- }
-#endif
-}
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index f9b5a72..fbbddb9 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -63,7 +63,6 @@ static int kgdboc_break_enabled;
#define DMA_RX_YCOUNT (PAGE_SIZE / DMA_RX_XCOUNT)
#define DMA_RX_FLUSH_JIFFIES (HZ / 50)
-#define CTS_CHECK_JIFFIES (HZ / 50)
#ifdef CONFIG_SERIAL_BFIN_DMA
static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart);
@@ -71,8 +70,6 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart);
static void bfin_serial_tx_chars(struct bfin_serial_port *uart);
#endif
-static void bfin_serial_mctrl_check(struct bfin_serial_port *uart);
-
static void bfin_serial_reset_irda(struct uart_port *port);
/*
@@ -264,12 +261,6 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart)
{
struct circ_buf *xmit = &uart->port.info->xmit;
- /*
- * Check the modem control lines before
- * transmitting anything.
- */
- bfin_serial_mctrl_check(uart);
-
if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) {
#ifdef CONFIG_BF54x
/* Clear TFI bit */
@@ -328,12 +319,6 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
uart->tx_done = 0;
- /*
- * Check the modem control lines before
- * transmitting anything.
- */
- bfin_serial_mctrl_check(uart);
-
if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) {
uart->tx_count = 0;
uart->tx_done = 1;
@@ -524,29 +509,21 @@ static void bfin_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
#endif
}
+#ifdef CONFIG_SERIAL_BFIN_CTSRTS
/*
- * Handle any change of modem status signal since we were last called.
+ * Handle any change of modem status signal.
*/
-static void bfin_serial_mctrl_check(struct bfin_serial_port *uart)
+static irqreturn_t bfin_serial_mctrl_cts_int(int irq, void *dev_id)
{
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
+ struct bfin_serial_port *uart = dev_id;
unsigned int status;
- struct uart_info *info = uart->port.info;
- struct tty_struct *tty = info->port.tty;
status = bfin_serial_get_mctrl(&uart->port);
uart_handle_cts_change(&uart->port, status & TIOCM_CTS);
- if (!(status & TIOCM_CTS)) {
- tty->hw_stopped = 1;
- uart->cts_timer.data = (unsigned long)(uart);
- uart->cts_timer.function = (void *)bfin_serial_mctrl_check;
- uart->cts_timer.expires = jiffies + CTS_CHECK_JIFFIES;
- add_timer(&(uart->cts_timer));
- } else {
- tty->hw_stopped = 0;
- }
-#endif
+
+ return IRQ_HANDLED;
}
+#endif
/*
* Interrupts are always disabled.
@@ -606,7 +583,7 @@ static int bfin_serial_startup(struct uart_port *port)
uart->rx_dma_timer.expires = jiffies + DMA_RX_FLUSH_JIFFIES;
add_timer(&(uart->rx_dma_timer));
#else
-#if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \
+# if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \
defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE)
if (kgdboc_port_line == uart->port.line && kgdboc_break_enabled)
kgdboc_break_enabled = 0;
@@ -661,11 +638,28 @@ static int bfin_serial_startup(struct uart_port *port)
}
}
# endif
-#if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \
+# if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \
defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE)
}
# endif
#endif
+
+#ifdef CONFIG_SERIAL_BFIN_CTSRTS
+ if (uart->cts_pin >= 0) {
+ if (request_irq(gpio_to_irq(uart->cts_pin),
+ bfin_serial_mctrl_cts_int,
+ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
+ IRQF_DISABLED, "BFIN_UART_CTS", uart)) {
+ uart->cts_pin = -1;
+ pr_info("Unable to attach BlackFin UART CTS interrupt.\
+ So, disable it.\n");
+ }
+ }
+ if (uart->rts_pin >= 0) {
+ gpio_request(uart->rts_pin, DRIVER_NAME);
+ gpio_direction_output(uart->rts_pin, 0);
+ }
+#endif
UART_SET_IER(uart, ERBFI);
return 0;
}
@@ -699,6 +693,13 @@ static void bfin_serial_shutdown(struct uart_port *port)
free_irq(uart->port.irq, uart);
free_irq(uart->port.irq+1, uart);
#endif
+
+# ifdef CONFIG_SERIAL_BFIN_CTSRTS
+ if (uart->cts_pin >= 0)
+ free_irq(gpio_to_irq(uart->cts_pin), uart);
+ if (uart->rts_pin >= 0)
+ gpio_free(uart->rts_pin);
+# endif
}
static void
@@ -864,6 +865,20 @@ static void bfin_serial_set_ldisc(struct uart_port *port)
}
}
+static void bfin_serial_reset_irda(struct uart_port *port)
+{
+ int line = port->line;
+ unsigned short val;
+
+ val = UART_GET_GCTL(&bfin_serial_ports[line]);
+ val &= ~(IREN | RPOLC);
+ UART_PUT_GCTL(&bfin_serial_ports[line], val);
+ SSYNC();
+ val |= (IREN | RPOLC);
+ UART_PUT_GCTL(&bfin_serial_ports[line], val);
+ SSYNC();
+}
+
#ifdef CONFIG_CONSOLE_POLL
static void bfin_serial_poll_put_char(struct uart_port *port, unsigned char chr)
{
@@ -909,20 +924,6 @@ static int bfin_kgdboc_port_startup(struct uart_port *port)
}
#endif
-static void bfin_serial_reset_irda(struct uart_port *port)
-{
- int line = port->line;
- unsigned short val;
-
- val = UART_GET_GCTL(&bfin_serial_ports[line]);
- val &= ~(IREN | RPOLC);
- UART_PUT_GCTL(&bfin_serial_ports[line], val);
- SSYNC();
- val |= (IREN | RPOLC);
- UART_PUT_GCTL(&bfin_serial_ports[line], val);
- SSYNC();
-}
-
static struct uart_ops bfin_serial_pops = {
.tx_empty = bfin_serial_tx_empty,
.set_mctrl = bfin_serial_set_mctrl,
@@ -952,6 +953,39 @@ static struct uart_ops bfin_serial_pops = {
#endif
};
+static void __init bfin_serial_hw_init(void)
+{
+#ifdef CONFIG_SERIAL_BFIN_UART0
+ peripheral_request(P_UART0_TX, DRIVER_NAME);
+ peripheral_request(P_UART0_RX, DRIVER_NAME);
+#endif
+
+#ifdef CONFIG_SERIAL_BFIN_UART1
+ peripheral_request(P_UART1_TX, DRIVER_NAME);
+ peripheral_request(P_UART1_RX, DRIVER_NAME);
+
+# if defined(CONFIG_BFIN_UART1_CTSRTS) && defined(CONFIG_BF54x)
+ peripheral_request(P_UART1_RTS, DRIVER_NAME);
+ peripheral_request(P_UART1_CTS, DRIVER_NAME);
+# endif
+#endif
+
+#ifdef CONFIG_SERIAL_BFIN_UART2
+ peripheral_request(P_UART2_TX, DRIVER_NAME);
+ peripheral_request(P_UART2_RX, DRIVER_NAME);
+#endif
+
+#ifdef CONFIG_SERIAL_BFIN_UART3
+ peripheral_request(P_UART3_TX, DRIVER_NAME);
+ peripheral_request(P_UART3_RX, DRIVER_NAME);
+
+# if defined(CONFIG_BFIN_UART3_CTSRTS) && defined(CONFIG_BF54x)
+ peripheral_request(P_UART3_RTS, DRIVER_NAME);
+ peripheral_request(P_UART3_CTS, DRIVER_NAME);
+# endif
+#endif
+}
+
static void __init bfin_serial_init_ports(void)
{
static int first = 1;
@@ -961,6 +995,8 @@ static void __init bfin_serial_init_ports(void)
return;
first = 0;
+ bfin_serial_hw_init();
+
for (i = 0; i < nr_active_ports; i++) {
bfin_serial_ports[i].port.uartclk = get_sclk();
bfin_serial_ports[i].port.fifosize = BFIN_UART_TX_FIFO_SIZE;
@@ -984,15 +1020,12 @@ static void __init bfin_serial_init_ports(void)
init_timer(&(bfin_serial_ports[i].rx_dma_timer));
#endif
#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- init_timer(&(bfin_serial_ports[i].cts_timer));
bfin_serial_ports[i].cts_pin =
bfin_serial_resource[i].uart_cts_pin;
bfin_serial_ports[i].rts_pin =
bfin_serial_resource[i].uart_rts_pin;
#endif
- bfin_serial_hw_init(&bfin_serial_ports[i]);
}
-
}
#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
This is a low density serial port so needs a real major/minor
Signed-off-by: Alan Cox <[email protected]>
---
Documentation/devices.txt | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index 4d70df6..53d64d3 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -2797,6 +2797,10 @@ Your cooperation is appreciated.
206 = /dev/ttySC1 SC26xx serial port 1
207 = /dev/ttySC2 SC26xx serial port 2
208 = /dev/ttySC3 SC26xx serial port 3
+ 209 = /dev/ttyMAX0 MAX3100 serial port 0
+ 210 = /dev/ttyMAX1 MAX3100 serial port 1
+ 211 = /dev/ttyMAX2 MAX3100 serial port 2
+ 212 = /dev/ttyMAX3 MAX3100 serial port 3
205 char Low-density serial ports (alternate device)
0 = /dev/culu0 Callout device for ttyLU0
From: Christian Pellegrin <[email protected]>
(akpm: queued pending confirmation of the new major number)
[[email protected]: select SERIAL_CORE]
Signed-off-by: Christian Pellegrin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Alan Cox <[email protected]>
---
drivers/serial/Kconfig | 7 +++++++
drivers/serial/Makefile | 1 +
include/linux/serial_core.h | 3 +++
3 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 07c03b9..d89972b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -533,6 +533,13 @@ config SERIAL_S3C6400
Serial port support for the Samsung S3C6400 and S3C6410
SoCs
+config SERIAL_MAX3100
+ tristate "MAX3100 support"
+ depends on SPI
+ select SERIAL_CORE
+ help
+ MAX3100 chip support
+
config SERIAL_DZ
bool "DECstation DZ serial driver"
depends on MACH_DECSTATION && 32BIT
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 8844c0a..d438eb2 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -43,6 +43,7 @@ obj-$(CONFIG_SERIAL_S3C2412) += s3c2412.o
obj-$(CONFIG_SERIAL_S3C2440) += s3c2440.o
obj-$(CONFIG_SERIAL_S3C24A0) += s3c24a0.o
obj-$(CONFIG_SERIAL_S3C6400) += s3c6400.o
+obj-$(CONFIG_SERIAL_MAX3100) += max3100.o
obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o
obj-$(CONFIG_SERIAL_MUX) += mux.o
obj-$(CONFIG_SERIAL_68328) += 68328serial.o
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 83e4b3f..57a97e5 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -164,6 +164,9 @@
/* NWPSERIAL */
#define PORT_NWPSERIAL 85
+/* MAX3100 */
+#define PORT_MAX3100 86
+
#ifdef __KERNEL__
#include <linux/compiler.h>
From: Sonic Zhang <[email protected]>
serial driver.
The CTS RTS PIN connection on BF548 UART port is defined as a modem device
not as a host device. In order to test it under Linux, please nake a
cross UART cable to exchange CTS and RTS signal.
Signed-off-by: Sonic Zhang <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Alan Cox <[email protected]>
---
.../mach-bf518/include/mach/bfin_serial_5xx.h | 10 +
.../mach-bf527/include/mach/bfin_serial_5xx.h | 10 +
.../mach-bf533/include/mach/bfin_serial_5xx.h | 9 +
.../mach-bf537/include/mach/bfin_serial_5xx.h | 10 +
.../mach-bf538/include/mach/bfin_serial_5xx.h | 10 +
.../mach-bf548/include/mach/bfin_serial_5xx.h | 72 ++++-----
.../mach-bf561/include/mach/bfin_serial_5xx.h | 9 +
drivers/serial/Kconfig | 26 ++-
drivers/serial/bfin_5xx.c | 169 ++++++++++++++------
9 files changed, 209 insertions(+), 116 deletions(-)
diff --git a/arch/blackfin/mach-bf518/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf518/include/mach/bfin_serial_5xx.h
index e21c1c3..0fb2ce5 100644
--- a/arch/blackfin/mach-bf518/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf518/include/mach/bfin_serial_5xx.h
@@ -53,9 +53,9 @@
#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
-#define UART_GET_CTS(x) gpio_get_value(x->cts_pin)
-#define UART_SET_RTS(x) gpio_set_value(x->rts_pin, 1)
-#define UART_CLEAR_RTS(x) gpio_set_value(x->rts_pin, 0)
+#define UART_GET_CTS(x) (!gpio_get_value(x->cts_pin))
+#define UART_DISABLE_RTS(x) gpio_set_value(x->rts_pin, 1)
+#define UART_ENABLE_RTS(x) gpio_set_value(x->rts_pin, 0)
#define UART_ENABLE_INTS(x, v) UART_PUT_IER(x, v)
#define UART_DISABLE_INTS(x) UART_PUT_IER(x, 0)
@@ -87,6 +87,7 @@
struct bfin_serial_port {
struct uart_port port;
unsigned int old_status;
+ int status_irq;
unsigned int lsr;
#ifdef CONFIG_SERIAL_BFIN_DMA
int tx_done;
@@ -125,6 +126,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
struct bfin_serial_res {
unsigned long uart_base_addr;
int uart_irq;
+ int uart_status_irq;
#ifdef CONFIG_SERIAL_BFIN_DMA
unsigned int uart_tx_dma_channel;
unsigned int uart_rx_dma_channel;
@@ -140,6 +142,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC00400,
IRQ_UART0_RX,
+ IRQ_UART0_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART0_TX,
CH_UART0_RX,
@@ -154,6 +157,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC02000,
IRQ_UART1_RX,
+ IRQ_UART1_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART1_TX,
CH_UART1_RX,
diff --git a/arch/blackfin/mach-bf527/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf527/include/mach/bfin_serial_5xx.h
index d2b160c..a625659 100644
--- a/arch/blackfin/mach-bf527/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf527/include/mach/bfin_serial_5xx.h
@@ -53,9 +53,9 @@
#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
-#define UART_GET_CTS(x) gpio_get_value(x->cts_pin)
-#define UART_SET_RTS(x) gpio_set_value(x->rts_pin, 1)
-#define UART_CLEAR_RTS(x) gpio_set_value(x->rts_pin, 0)
+#define UART_GET_CTS(x) (!gpio_get_value(x->cts_pin))
+#define UART_DISABLE_RTS(x) gpio_set_value(x->rts_pin, 1)
+#define UART_ENABLE_RTS(x) gpio_set_value(x->rts_pin, 0)
#define UART_ENABLE_INTS(x, v) UART_PUT_IER(x, v)
#define UART_DISABLE_INTS(x) UART_PUT_IER(x, 0)
@@ -87,6 +87,7 @@
struct bfin_serial_port {
struct uart_port port;
unsigned int old_status;
+ int status_irq;
unsigned int lsr;
#ifdef CONFIG_SERIAL_BFIN_DMA
int tx_done;
@@ -125,6 +126,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
struct bfin_serial_res {
unsigned long uart_base_addr;
int uart_irq;
+ int uart_status_irq;
#ifdef CONFIG_SERIAL_BFIN_DMA
unsigned int uart_tx_dma_channel;
unsigned int uart_rx_dma_channel;
@@ -140,6 +142,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC00400,
IRQ_UART0_RX,
+ IRQ_UART0_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART0_TX,
CH_UART0_RX,
@@ -154,6 +157,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC02000,
IRQ_UART1_RX,
+ IRQ_UART1_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART1_TX,
CH_UART1_RX,
diff --git a/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h
index 70356dd..a3789d7 100644
--- a/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf533/include/mach/bfin_serial_5xx.h
@@ -53,9 +53,9 @@
#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
-#define UART_GET_CTS(x) gpio_get_value(x->cts_pin)
-#define UART_SET_RTS(x) gpio_set_value(x->rts_pin, 1)
-#define UART_CLEAR_RTS(x) gpio_set_value(x->rts_pin, 0)
+#define UART_GET_CTS(x) (!gpio_get_value(x->cts_pin))
+#define UART_DISABLE_RTS(x) gpio_set_value(x->rts_pin, 1)
+#define UART_ENABLE_RTS(x) gpio_set_value(x->rts_pin, 0)
#define UART_ENABLE_INTS(x, v) UART_PUT_IER(x, v)
#define UART_DISABLE_INTS(x) UART_PUT_IER(x, 0)
@@ -74,6 +74,7 @@
struct bfin_serial_port {
struct uart_port port;
unsigned int old_status;
+ int status_irq;
unsigned int lsr;
#ifdef CONFIG_SERIAL_BFIN_DMA
int tx_done;
@@ -116,6 +117,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
struct bfin_serial_res {
unsigned long uart_base_addr;
int uart_irq;
+ int uart_status_irq;
#ifdef CONFIG_SERIAL_BFIN_DMA
unsigned int uart_tx_dma_channel;
unsigned int uart_rx_dma_channel;
@@ -130,6 +132,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC00400,
IRQ_UART_RX,
+ IRQ_UART_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART_TX,
CH_UART_RX,
diff --git a/arch/blackfin/mach-bf537/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf537/include/mach/bfin_serial_5xx.h
index d46fc4f..b86662f 100644
--- a/arch/blackfin/mach-bf537/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf537/include/mach/bfin_serial_5xx.h
@@ -53,9 +53,9 @@
#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
-#define UART_GET_CTS(x) gpio_get_value(x->cts_pin)
-#define UART_SET_RTS(x) gpio_set_value(x->rts_pin, 1)
-#define UART_CLEAR_RTS(x) gpio_set_value(x->rts_pin, 0)
+#define UART_GET_CTS(x) (!gpio_get_value(x->cts_pin))
+#define UART_DISABLE_RTS(x) gpio_set_value(x->rts_pin, 1)
+#define UART_ENABLE_RTS(x) gpio_set_value(x->rts_pin, 0)
#define UART_ENABLE_INTS(x, v) UART_PUT_IER(x, v)
#define UART_DISABLE_INTS(x) UART_PUT_IER(x, 0)
@@ -87,6 +87,7 @@
struct bfin_serial_port {
struct uart_port port;
unsigned int old_status;
+ int status_irq;
unsigned int lsr;
#ifdef CONFIG_SERIAL_BFIN_DMA
int tx_done;
@@ -124,6 +125,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
struct bfin_serial_res {
unsigned long uart_base_addr;
int uart_irq;
+ int uart_status_irq;
#ifdef CONFIG_SERIAL_BFIN_DMA
unsigned int uart_tx_dma_channel;
unsigned int uart_rx_dma_channel;
@@ -139,6 +141,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC00400,
IRQ_UART0_RX,
+ IRQ_UART0_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART0_TX,
CH_UART0_RX,
@@ -153,6 +156,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC02000,
IRQ_UART1_RX,
+ IRQ_UART1_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART1_TX,
CH_UART1_RX,
diff --git a/arch/blackfin/mach-bf538/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf538/include/mach/bfin_serial_5xx.h
index 3c2811e..c536551 100644
--- a/arch/blackfin/mach-bf538/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf538/include/mach/bfin_serial_5xx.h
@@ -53,9 +53,9 @@
#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
-#define UART_GET_CTS(x) gpio_get_value(x->cts_pin)
-#define UART_SET_RTS(x) gpio_set_value(x->rts_pin, 1)
-#define UART_CLEAR_RTS(x) gpio_set_value(x->rts_pin, 0)
+#define UART_GET_CTS(x) (!gpio_get_value(x->cts_pin))
+#define UART_DISABLE_RTS(x) gpio_set_value(x->rts_pin, 1)
+#define UART_ENABLE_RTS(x) gpio_set_value(x->rts_pin, 0)
#define UART_ENABLE_INTS(x, v) UART_PUT_IER(x, v)
#define UART_DISABLE_INTS(x) UART_PUT_IER(x, 0)
@@ -87,6 +87,7 @@
struct bfin_serial_port {
struct uart_port port;
unsigned int old_status;
+ int status_irq;
unsigned int lsr;
#ifdef CONFIG_SERIAL_BFIN_DMA
int tx_done;
@@ -125,6 +126,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
struct bfin_serial_res {
unsigned long uart_base_addr;
int uart_irq;
+ int uart_status_irq;
#ifdef CONFIG_SERIAL_BFIN_DMA
unsigned int uart_tx_dma_channel;
unsigned int uart_rx_dma_channel;
@@ -140,6 +142,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC00400,
IRQ_UART0_RX,
+ IRQ_UART0_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART0_TX,
CH_UART0_RX,
@@ -154,6 +157,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC02000,
IRQ_UART1_RX,
+ IRQ_UART1_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART1_TX,
CH_UART1_RX,
diff --git a/arch/blackfin/mach-bf548/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf548/include/mach/bfin_serial_5xx.h
index 388e232..2d1b5fa 100644
--- a/arch/blackfin/mach-bf548/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf548/include/mach/bfin_serial_5xx.h
@@ -46,41 +46,27 @@
#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v)
#define UART_SET_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER_SET),v)
-#define UART_CLEAR_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER_CLEAR),v)
+#define UART_CLEAR_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER_CLEAR),v)
#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v)
#define UART_PUT_LSR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LSR),v)
#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
#define UART_CLEAR_LSR(uart) bfin_write16(((uart)->port.membase + OFFSET_LSR), -1)
#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
#define UART_PUT_MCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_MCR),v)
+#define UART_CLEAR_SCTS(uart) bfin_write16(((uart)->port.membase + OFFSET_MSR),SCTS)
#define UART_SET_DLAB(uart) /* MMRs not muxed on BF54x */
#define UART_CLEAR_DLAB(uart) /* MMRs not muxed on BF54x */
#define UART_GET_CTS(x) (UART_GET_MSR(x) & CTS)
-#define UART_SET_RTS(x) (UART_PUT_MCR(x, UART_GET_MCR(x) | MRTS))
-#define UART_CLEAR_RTS(x) (UART_PUT_MCR(x, UART_GET_MCR(x) & ~MRTS))
+#define UART_DISABLE_RTS(x) UART_PUT_MCR(x, UART_GET_MCR(x) & ~(ARTS|MRTS))
+#define UART_ENABLE_RTS(x) UART_PUT_MCR(x, UART_GET_MCR(x) | MRTS | ARTS)
#define UART_ENABLE_INTS(x, v) UART_SET_IER(x, v)
#define UART_DISABLE_INTS(x) UART_CLEAR_IER(x, 0xF)
-#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART2_CTSRTS)
-# define CONFIG_SERIAL_BFIN_CTSRTS
-
-# ifndef CONFIG_UART0_CTS_PIN
-# define CONFIG_UART0_CTS_PIN -1
-# endif
-
-# ifndef CONFIG_UART0_RTS_PIN
-# define CONFIG_UART0_RTS_PIN -1
-# endif
-
-# ifndef CONFIG_UART2_CTS_PIN
-# define CONFIG_UART2_CTS_PIN -1
-# endif
-
-# ifndef CONFIG_UART2_RTS_PIN
-# define CONFIG_UART2_RTS_PIN -1
-# endif
+#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS) || \
+ defined(CONFIG_BFIN_UART2_CTSRTS) || defined(CONFIG_BFIN_UART3_CTSRTS)
+# define CONFIG_SERIAL_BFIN_HARD_CTSRTS
#endif
#define BFIN_UART_TX_FIFO_SIZE 2
@@ -91,6 +77,7 @@
struct bfin_serial_port {
struct uart_port port;
unsigned int old_status;
+ int status_irq;
#ifdef CONFIG_SERIAL_BFIN_DMA
int tx_done;
int tx_count;
@@ -101,23 +88,24 @@ struct bfin_serial_port {
unsigned int rx_dma_channel;
struct work_struct tx_dma_workqueue;
#endif
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- struct timer_list cts_timer;
- int cts_pin;
- int rts_pin;
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ int scts;
+ int cts_pin;
+ int rts_pin;
#endif
};
struct bfin_serial_res {
unsigned long uart_base_addr;
int uart_irq;
+ int uart_status_irq;
#ifdef CONFIG_SERIAL_BFIN_DMA
unsigned int uart_tx_dma_channel;
unsigned int uart_rx_dma_channel;
#endif
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- int uart_cts_pin;
- int uart_rts_pin;
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ int uart_cts_pin;
+ int uart_rts_pin;
#endif
};
@@ -126,13 +114,14 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC00400,
IRQ_UART0_RX,
+ IRQ_UART0_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART0_TX,
CH_UART0_RX,
#endif
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- CONFIG_UART0_CTS_PIN,
- CONFIG_UART0_RTS_PIN,
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ 0,
+ 0,
#endif
},
#endif
@@ -140,13 +129,14 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC02000,
IRQ_UART1_RX,
+ IRQ_UART1_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART1_TX,
CH_UART1_RX,
#endif
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- 0,
- 0,
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ GPIO_PE10,
+ GPIO_PE9,
#endif
},
#endif
@@ -154,13 +144,14 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC02100,
IRQ_UART2_RX,
+ IRQ_UART2_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART2_TX,
CH_UART2_RX,
#endif
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- CONFIG_UART2_CTS_PIN,
- CONFIG_UART2_RTS_PIN,
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ 0,
+ 0,
#endif
},
#endif
@@ -168,13 +159,14 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC03100,
IRQ_UART3_RX,
+ IRQ_UART3_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART3_TX,
CH_UART3_RX,
#endif
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- 0,
- 0,
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ GPIO_PB3,
+ GPIO_PB2,
#endif
},
#endif
diff --git a/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h b/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h
index d0469e3..a1b5087 100644
--- a/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h
+++ b/arch/blackfin/mach-bf561/include/mach/bfin_serial_5xx.h
@@ -53,9 +53,9 @@
#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
-#define UART_GET_CTS(x) gpio_get_value(x->cts_pin)
-#define UART_SET_RTS(x) gpio_set_value(x->rts_pin, 1)
-#define UART_CLEAR_RTS(x) gpio_set_value(x->rts_pin, 0)
+#define UART_GET_CTS(x) (!gpio_get_value(x->cts_pin))
+#define UART_DISABLE_RTS(x) gpio_set_value(x->rts_pin, 1)
+#define UART_ENABLE_RTS(x) gpio_set_value(x->rts_pin, 0)
#define UART_ENABLE_INTS(x, v) UART_PUT_IER(x, v)
#define UART_DISABLE_INTS(x) UART_PUT_IER(x, 0)
@@ -74,6 +74,7 @@
struct bfin_serial_port {
struct uart_port port;
unsigned int old_status;
+ int status_irq;
unsigned int lsr;
#ifdef CONFIG_SERIAL_BFIN_DMA
int tx_done;
@@ -116,6 +117,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
struct bfin_serial_res {
unsigned long uart_base_addr;
int uart_irq;
+ int uart_status_irq;
#ifdef CONFIG_SERIAL_BFIN_DMA
unsigned int uart_tx_dma_channel;
unsigned int uart_rx_dma_channel;
@@ -130,6 +132,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
{
0xFFC00400,
IRQ_UART_RX,
+ IRQ_UART_ERROR,
#ifdef CONFIG_SERIAL_BFIN_DMA
CH_UART_TX,
CH_UART_RX,
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index d89972b..f2e5736 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -734,7 +734,7 @@ config BFIN_UART0_CTSRTS
config UART0_CTS_PIN
int "UART0 CTS pin"
- depends on BFIN_UART0_CTSRTS
+ depends on BFIN_UART0_CTSRTS && !BF548
default 23
help
The default pin is GPIO_GP7.
@@ -742,7 +742,7 @@ config UART0_CTS_PIN
config UART0_RTS_PIN
int "UART0 RTS pin"
- depends on BFIN_UART0_CTSRTS
+ depends on BFIN_UART0_CTSRTS && !BF548
default 22
help
The default pin is GPIO_GP6.
@@ -763,14 +763,14 @@ config BFIN_UART1_CTSRTS
config UART1_CTS_PIN
int "UART1 CTS pin"
- depends on BFIN_UART1_CTSRTS && !BF54x
+ depends on BFIN_UART1_CTSRTS && !BF548
default -1
help
Refer to ./include/asm-blackfin/gpio.h to see the GPIO map.
config UART1_RTS_PIN
int "UART1 RTS pin"
- depends on BFIN_UART1_CTSRTS && !BF54x
+ depends on BFIN_UART1_CTSRTS && !BF548
default -1
help
Refer to ./include/asm-blackfin/gpio.h to see the GPIO map.
@@ -790,14 +790,14 @@ config BFIN_UART2_CTSRTS
config UART2_CTS_PIN
int "UART2 CTS pin"
- depends on BFIN_UART2_CTSRTS
+ depends on BFIN_UART2_CTSRTS && !BF548
default -1
help
Refer to ./include/asm-blackfin/gpio.h to see the GPIO map.
config UART2_RTS_PIN
int "UART2 RTS pin"
- depends on BFIN_UART2_CTSRTS
+ depends on BFIN_UART2_CTSRTS && !BF548
default -1
help
Refer to ./include/asm-blackfin/gpio.h to see the GPIO map.
@@ -815,6 +815,20 @@ config BFIN_UART3_CTSRTS
Enable hardware flow control in the driver. Using GPIO emulate the CTS/RTS
signal.
+config UART3_CTS_PIN
+ int "UART3 CTS pin"
+ depends on BFIN_UART3_CTSRTS && !BF548
+ default -1
+ help
+ Refer to ./include/asm-blackfin/gpio.h to see the GPIO map.
+
+config UART3_RTS_PIN
+ int "UART3 RTS pin"
+ depends on BFIN_UART3_CTSRTS && !BF548
+ default -1
+ help
+ Refer to ./include/asm-blackfin/gpio.h to see the GPIO map.
+
config SERIAL_IMX
bool "IMX serial port support"
depends on ARM && (ARCH_IMX || ARCH_MXC)
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index fbbddb9..18ba812 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -72,6 +72,63 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart);
static void bfin_serial_reset_irda(struct uart_port *port);
+#if defined(CONFIG_SERIAL_BFIN_CTSRTS) || \
+ defined(CONFIG_SERIAL_BFIN_HARD_CTSRTS)
+static unsigned int bfin_serial_get_mctrl(struct uart_port *port)
+{
+ struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
+ if (uart->cts_pin < 0)
+ return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+
+ /* CTS PIN is negative assertive. */
+ if (UART_GET_CTS(uart))
+ return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+ else
+ return TIOCM_DSR | TIOCM_CAR;
+}
+
+static void bfin_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+ struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
+ if (uart->rts_pin < 0)
+ return;
+
+ /* RTS PIN is negative assertive. */
+ if (mctrl & TIOCM_RTS)
+ UART_ENABLE_RTS(uart);
+ else
+ UART_DISABLE_RTS(uart);
+}
+
+/*
+ * Handle any change of modem status signal.
+ */
+static irqreturn_t bfin_serial_mctrl_cts_int(int irq, void *dev_id)
+{
+ struct bfin_serial_port *uart = dev_id;
+ unsigned int status;
+
+ status = bfin_serial_get_mctrl(&uart->port);
+ uart_handle_cts_change(&uart->port, status & TIOCM_CTS);
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ uart->scts = 1;
+ UART_CLEAR_SCTS(uart);
+ UART_CLEAR_IER(uart, EDSSI);
+#endif
+
+ return IRQ_HANDLED;
+}
+#else
+static unsigned int bfin_serial_get_mctrl(struct uart_port *port)
+{
+ return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+}
+
+static void bfin_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+}
+#endif
+
/*
* interrupts are disabled on entry
*/
@@ -108,6 +165,13 @@ static void bfin_serial_start_tx(struct uart_port *port)
struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
struct tty_struct *tty = uart->port.info->port.tty;
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ if (uart->scts && (!bfin_serial_get_mctrl(&uart->port)&TIOCM_CTS)) {
+ uart->scts = 0;
+ uart_handle_cts_change(&uart->port, uart->scts);
+ }
+#endif
+
/*
* To avoid losting RX interrupt, we reset IR function
* before sending data.
@@ -303,6 +367,12 @@ static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id)
{
struct bfin_serial_port *uart = dev_id;
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ if (uart->scts && (!bfin_serial_get_mctrl(&uart->port)&TIOCM_CTS)) {
+ uart->scts = 0;
+ uart_handle_cts_change(&uart->port, uart->scts);
+ }
+#endif
spin_lock(&uart->port.lock);
if (UART_GET_LSR(uart) & THRE)
bfin_serial_tx_chars(uart);
@@ -433,6 +503,13 @@ static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id)
struct bfin_serial_port *uart = dev_id;
struct circ_buf *xmit = &uart->port.info->xmit;
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ if (uart->scts && (!bfin_serial_get_mctrl(&uart->port)&TIOCM_CTS)) {
+ uart->scts = 0;
+ uart_handle_cts_change(&uart->port, uart->scts);
+ }
+#endif
+
spin_lock(&uart->port.lock);
if (!(get_dma_curr_irqstat(uart->tx_dma_channel)&DMA_RUN)) {
disable_dma(uart->tx_dma_channel);
@@ -481,53 +558,6 @@ static unsigned int bfin_serial_tx_empty(struct uart_port *port)
return 0;
}
-static unsigned int bfin_serial_get_mctrl(struct uart_port *port)
-{
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
- if (uart->cts_pin < 0)
- return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
-
- if (UART_GET_CTS(uart))
- return TIOCM_DSR | TIOCM_CAR;
- else
-#endif
- return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
-}
-
-static void bfin_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
-{
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
- struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
- if (uart->rts_pin < 0)
- return;
-
- if (mctrl & TIOCM_RTS)
- UART_CLEAR_RTS(uart);
- else
- UART_SET_RTS(uart);
-#endif
-}
-
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
-/*
- * Handle any change of modem status signal.
- */
-static irqreturn_t bfin_serial_mctrl_cts_int(int irq, void *dev_id)
-{
- struct bfin_serial_port *uart = dev_id;
- unsigned int status;
-
- status = bfin_serial_get_mctrl(&uart->port);
- uart_handle_cts_change(&uart->port, status & TIOCM_CTS);
-
- return IRQ_HANDLED;
-}
-#endif
-
-/*
- * Interrupts are always disabled.
- */
static void bfin_serial_break_ctl(struct uart_port *port, int break_state)
{
struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
@@ -660,6 +690,28 @@ static int bfin_serial_startup(struct uart_port *port)
gpio_direction_output(uart->rts_pin, 0);
}
#endif
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ if (request_irq(uart->status_irq,
+ bfin_serial_mctrl_cts_int,
+ IRQF_DISABLED, "BFIN_UART_MODEM_STATUS", uart)) {
+ pr_info("Unable to attach BlackFin UART Modem \
+ Status interrupt.\n");
+ }
+
+ if (uart->cts_pin >= 0) {
+ gpio_request(uart->cts_pin, DRIVER_NAME);
+ gpio_direction_output(uart->cts_pin, 1);
+ }
+ if (uart->rts_pin >= 0) {
+ gpio_request(uart->rts_pin, DRIVER_NAME);
+ gpio_direction_output(uart->rts_pin, 0);
+ }
+
+ /* CTS RTS PINs are negative assertive. */
+ UART_PUT_MCR(uart, ACTS);
+ UART_SET_IER(uart, EDSSI);
+#endif
+
UART_SET_IER(uart, ERBFI);
return 0;
}
@@ -694,12 +746,20 @@ static void bfin_serial_shutdown(struct uart_port *port)
free_irq(uart->port.irq+1, uart);
#endif
-# ifdef CONFIG_SERIAL_BFIN_CTSRTS
+#ifdef CONFIG_SERIAL_BFIN_CTSRTS
if (uart->cts_pin >= 0)
free_irq(gpio_to_irq(uart->cts_pin), uart);
if (uart->rts_pin >= 0)
gpio_free(uart->rts_pin);
-# endif
+#endif
+#ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS
+ if (uart->cts_pin >= 0)
+ gpio_free(uart->cts_pin);
+ if (uart->rts_pin >= 0)
+ gpio_free(uart->rts_pin);
+ if (UART_GET_IER(uart) && EDSSI)
+ free_irq(uart->status_irq, uart);
+#endif
}
static void
@@ -1009,6 +1069,8 @@ static void __init bfin_serial_init_ports(void)
bfin_serial_resource[i].uart_base_addr;
bfin_serial_ports[i].port.irq =
bfin_serial_resource[i].uart_irq;
+ bfin_serial_ports[i].status_irq =
+ bfin_serial_resource[i].uart_status_irq;
bfin_serial_ports[i].port.flags = UPF_BOOT_AUTOCONF;
#ifdef CONFIG_SERIAL_BFIN_DMA
bfin_serial_ports[i].tx_done = 1;
@@ -1019,7 +1081,8 @@ static void __init bfin_serial_init_ports(void)
bfin_serial_resource[i].uart_rx_dma_channel;
init_timer(&(bfin_serial_ports[i].rx_dma_timer));
#endif
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
+#if defined(CONFIG_SERIAL_BFIN_CTSRTS) || \
+ defined(CONFIG_SERIAL_BFIN_HARD_CTSRTS)
bfin_serial_ports[i].cts_pin =
bfin_serial_resource[i].uart_cts_pin;
bfin_serial_ports[i].rts_pin =
@@ -1082,7 +1145,8 @@ bfin_serial_console_setup(struct console *co, char *options)
int baud = 57600;
int bits = 8;
int parity = 'n';
-# ifdef CONFIG_SERIAL_BFIN_CTSRTS
+# if defined(CONFIG_SERIAL_BFIN_CTSRTS) || \
+ defined(CONFIG_SERIAL_BFIN_HARD_CTSRTS)
int flow = 'r';
# else
int flow = 'n';
@@ -1279,7 +1343,8 @@ static int bfin_serial_remove(struct platform_device *dev)
continue;
uart_remove_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port);
bfin_serial_ports[i].port.dev = NULL;
-#ifdef CONFIG_SERIAL_BFIN_CTSRTS
+#if defined(CONFIG_SERIAL_BFIN_CTSRTS) || \
+ defined(CONFIG_SERIAL_BFIN_HARD_CTSRTS)
gpio_free(bfin_serial_ports[i].cts_pin);
gpio_free(bfin_serial_ports[i].rts_pin);
#endif
From: Mike Frysinger <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Alan Cox <[email protected]>
---
drivers/serial/Kconfig | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index f2e5736..1e2dd6f 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -707,7 +707,7 @@ choice
config SERIAL_BFIN_DMA
bool "DMA mode"
- depends on !DMA_UNCACHED_NONE && !KGDB_UART
+ depends on !DMA_UNCACHED_NONE && !KGDB_SERIAL_CONSOLE
help
This driver works under DMA mode. If this option is selected, the
blackfin simple dma driver is also enabled.
Subject: Kconfig check tighten
This is needed as it can be built as a module.
Signed-off-by: Mike Frysinger <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Alan Cox <[email protected]>
---
drivers/serial/Kconfig | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 1e2dd6f..1537e0d 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -707,7 +707,7 @@ choice
config SERIAL_BFIN_DMA
bool "DMA mode"
- depends on !DMA_UNCACHED_NONE && !KGDB_SERIAL_CONSOLE
+ depends on !DMA_UNCACHED_NONE && KGDB_SERIAL_CONSOLE=n
help
This driver works under DMA mode. If this option is selected, the
blackfin simple dma driver is also enabled.