mos7840: remove loads of bogus assignments to status
Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
4944d40054
commit
880af9db2c
|
@ -33,7 +33,7 @@
|
||||||
#include <linux/serial.h>
|
#include <linux/serial.h>
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/usb/serial.h>
|
#include <linux/usb/serial.h>
|
||||||
#include <asm/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Version Information
|
* Version Information
|
||||||
|
@ -82,8 +82,8 @@
|
||||||
* Defines used for sending commands to port
|
* Defines used for sending commands to port
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WAIT_FOR_EVER (HZ * 0 ) /* timeout urb is wait for ever */
|
#define WAIT_FOR_EVER (HZ * 0) /* timeout urb is wait for ever */
|
||||||
#define MOS_WDR_TIMEOUT (HZ * 5 ) /* default urb timeout */
|
#define MOS_WDR_TIMEOUT (HZ * 5) /* default urb timeout */
|
||||||
|
|
||||||
#define MOS_PORT1 0x0200
|
#define MOS_PORT1 0x0200
|
||||||
#define MOS_PORT2 0x0300
|
#define MOS_PORT2 0x0300
|
||||||
|
@ -102,8 +102,8 @@
|
||||||
|
|
||||||
#define MAX_NAME_LEN 64
|
#define MAX_NAME_LEN 64
|
||||||
|
|
||||||
#define ZLP_REG1 0x3A //Zero_Flag_Reg1 58
|
#define ZLP_REG1 0x3A /* Zero_Flag_Reg1 58 */
|
||||||
#define ZLP_REG5 0x3E //Zero_Flag_Reg5 62
|
#define ZLP_REG5 0x3E /* Zero_Flag_Reg5 62 */
|
||||||
|
|
||||||
/* For higher baud Rates use TIOCEXBAUD */
|
/* For higher baud Rates use TIOCEXBAUD */
|
||||||
#define TIOCEXBAUD 0x5462
|
#define TIOCEXBAUD 0x5462
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
#define MOS_MSR_DELTA_RI 0x40
|
#define MOS_MSR_DELTA_RI 0x40
|
||||||
#define MOS_MSR_DELTA_CD 0x80
|
#define MOS_MSR_DELTA_CD 0x80
|
||||||
|
|
||||||
// Serial Port register Address
|
/* Serial Port register Address */
|
||||||
#define INTERRUPT_ENABLE_REGISTER ((__u16)(0x01))
|
#define INTERRUPT_ENABLE_REGISTER ((__u16)(0x01))
|
||||||
#define FIFO_CONTROL_REGISTER ((__u16)(0x02))
|
#define FIFO_CONTROL_REGISTER ((__u16)(0x02))
|
||||||
#define LINE_CONTROL_REGISTER ((__u16)(0x03))
|
#define LINE_CONTROL_REGISTER ((__u16)(0x03))
|
||||||
|
@ -201,11 +201,11 @@ struct moschip_port {
|
||||||
struct async_icount icount;
|
struct async_icount icount;
|
||||||
struct usb_serial_port *port; /* loop back to the owner of this object */
|
struct usb_serial_port *port; /* loop back to the owner of this object */
|
||||||
|
|
||||||
/*Offsets */
|
/* Offsets */
|
||||||
__u8 SpRegOffset;
|
__u8 SpRegOffset;
|
||||||
__u8 ControlRegOffset;
|
__u8 ControlRegOffset;
|
||||||
__u8 DcrRegOffset;
|
__u8 DcrRegOffset;
|
||||||
//for processing control URBS in interrupt context
|
/* for processing control URBS in interrupt context */
|
||||||
struct urb *control_urb;
|
struct urb *control_urb;
|
||||||
struct usb_ctrlrequest *dr;
|
struct usb_ctrlrequest *dr;
|
||||||
char *ctrl_buf;
|
char *ctrl_buf;
|
||||||
|
@ -244,7 +244,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
|
static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
|
||||||
__u16 * val)
|
__u16 *val)
|
||||||
{
|
{
|
||||||
struct usb_device *dev = port->serial->dev;
|
struct usb_device *dev = port->serial->dev;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -269,16 +269,15 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
|
||||||
|
|
||||||
struct usb_device *dev = port->serial->dev;
|
struct usb_device *dev = port->serial->dev;
|
||||||
val = val & 0x00ff;
|
val = val & 0x00ff;
|
||||||
// For the UART control registers, the application number need to be Or'ed
|
/* For the UART control registers, the application number need
|
||||||
|
to be Or'ed */
|
||||||
if (port->serial->num_ports == 4) {
|
if (port->serial->num_ports == 4) {
|
||||||
val |=
|
val |= (((__u16) port->number -
|
||||||
(((__u16) port->number - (__u16) (port->serial->minor)) +
|
(__u16) (port->serial->minor)) + 1) << 8;
|
||||||
1) << 8;
|
|
||||||
dbg("mos7840_set_uart_reg application number is %x\n", val);
|
dbg("mos7840_set_uart_reg application number is %x\n", val);
|
||||||
} else {
|
} else {
|
||||||
if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
|
if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
|
||||||
val |=
|
val |= (((__u16) port->number -
|
||||||
(((__u16) port->number -
|
|
||||||
(__u16) (port->serial->minor)) + 1) << 8;
|
(__u16) (port->serial->minor)) + 1) << 8;
|
||||||
dbg("mos7840_set_uart_reg application number is %x\n",
|
dbg("mos7840_set_uart_reg application number is %x\n",
|
||||||
val);
|
val);
|
||||||
|
@ -302,14 +301,15 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
|
||||||
* by passing usb_rcvctrlpipe function as parameter.
|
* by passing usb_rcvctrlpipe function as parameter.
|
||||||
*/
|
*/
|
||||||
static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
|
static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
|
||||||
__u16 * val)
|
__u16 *val)
|
||||||
{
|
{
|
||||||
struct usb_device *dev = port->serial->dev;
|
struct usb_device *dev = port->serial->dev;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
__u16 Wval;
|
__u16 Wval;
|
||||||
|
|
||||||
//dbg("application number is %4x \n",(((__u16)port->number - (__u16)(port->serial->minor))+1)<<8);
|
/* dbg("application number is %4x \n",
|
||||||
/*Wval is same as application number */
|
(((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */
|
||||||
|
/* Wval is same as application number */
|
||||||
if (port->serial->num_ports == 4) {
|
if (port->serial->num_ports == 4) {
|
||||||
Wval =
|
Wval =
|
||||||
(((__u16) port->number - (__u16) (port->serial->minor)) +
|
(((__u16) port->number - (__u16) (port->serial->minor)) +
|
||||||
|
@ -317,14 +317,12 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
|
||||||
dbg("mos7840_get_uart_reg application number is %x\n", Wval);
|
dbg("mos7840_get_uart_reg application number is %x\n", Wval);
|
||||||
} else {
|
} else {
|
||||||
if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
|
if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
|
||||||
Wval =
|
Wval = (((__u16) port->number -
|
||||||
(((__u16) port->number -
|
|
||||||
(__u16) (port->serial->minor)) + 1) << 8;
|
(__u16) (port->serial->minor)) + 1) << 8;
|
||||||
dbg("mos7840_get_uart_reg application number is %x\n",
|
dbg("mos7840_get_uart_reg application number is %x\n",
|
||||||
Wval);
|
Wval);
|
||||||
} else {
|
} else {
|
||||||
Wval =
|
Wval = (((__u16) port->number -
|
||||||
(((__u16) port->number -
|
|
||||||
(__u16) (port->serial->minor)) + 2) << 8;
|
(__u16) (port->serial->minor)) + 2) << 8;
|
||||||
dbg("mos7840_get_uart_reg application number is %x\n",
|
dbg("mos7840_get_uart_reg application number is %x\n",
|
||||||
Wval);
|
Wval);
|
||||||
|
@ -406,11 +404,11 @@ static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
|
||||||
dbg("%s - %02x", __func__, new_lsr);
|
dbg("%s - %02x", __func__, new_lsr);
|
||||||
|
|
||||||
if (new_lsr & SERIAL_LSR_BI) {
|
if (new_lsr & SERIAL_LSR_BI) {
|
||||||
//
|
/*
|
||||||
// Parity and Framing errors only count if they
|
* Parity and Framing errors only count if they
|
||||||
// occur exclusive of a break being
|
* occur exclusive of a break being
|
||||||
// received.
|
* received.
|
||||||
//
|
*/
|
||||||
new_lsr &= (__u8) (SERIAL_LSR_OE | SERIAL_LSR_BI);
|
new_lsr &= (__u8) (SERIAL_LSR_OE | SERIAL_LSR_BI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +490,7 @@ exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
|
static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
|
||||||
__u16 * val)
|
__u16 *val)
|
||||||
{
|
{
|
||||||
struct usb_device *dev = mcs->port->serial->dev;
|
struct usb_device *dev = mcs->port->serial->dev;
|
||||||
struct usb_ctrlrequest *dr = mcs->dr;
|
struct usb_ctrlrequest *dr = mcs->dr;
|
||||||
|
@ -501,7 +499,7 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
|
||||||
|
|
||||||
dr->bRequestType = MCS_RD_RTYPE;
|
dr->bRequestType = MCS_RD_RTYPE;
|
||||||
dr->bRequest = MCS_RDREQ;
|
dr->bRequest = MCS_RDREQ;
|
||||||
dr->wValue = cpu_to_le16(Wval); //0;
|
dr->wValue = cpu_to_le16(Wval); /* 0 */
|
||||||
dr->wIndex = cpu_to_le16(reg);
|
dr->wIndex = cpu_to_le16(reg);
|
||||||
dr->wLength = cpu_to_le16(2);
|
dr->wLength = cpu_to_le16(2);
|
||||||
|
|
||||||
|
@ -607,7 +605,8 @@ static void mos7840_interrupt_callback(struct urb *urb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(rv < 0)) /* the completion handler for the control urb will resubmit */
|
if (!(rv < 0))
|
||||||
|
/* the completion handler for the control urb will resubmit */
|
||||||
return;
|
return;
|
||||||
exit:
|
exit:
|
||||||
result = usb_submit_urb(urb, GFP_ATOMIC);
|
result = usb_submit_urb(urb, GFP_ATOMIC);
|
||||||
|
@ -656,8 +655,8 @@ static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port,
|
||||||
if (!port ||
|
if (!port ||
|
||||||
mos7840_port_paranoia_check(port, function) ||
|
mos7840_port_paranoia_check(port, function) ||
|
||||||
mos7840_serial_paranoia_check(port->serial, function)) {
|
mos7840_serial_paranoia_check(port->serial, function)) {
|
||||||
/* then say that we don't have a valid usb_serial thing, which will
|
/* then say that we don't have a valid usb_serial thing,
|
||||||
* end up genrating -ENODEV return values */
|
* which will end up genrating -ENODEV return values */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,8 +740,8 @@ static void mos7840_bulk_in_callback(struct urb *urb)
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* mos7840_bulk_out_data_callback
|
* mos7840_bulk_out_data_callback
|
||||||
* this is the callback function for when we have finished sending serial data
|
* this is the callback function for when we have finished sending
|
||||||
* on the bulk out endpoint.
|
* serial data on the bulk out endpoint.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
static void mos7840_bulk_out_data_callback(struct urb *urb)
|
static void mos7840_bulk_out_data_callback(struct urb *urb)
|
||||||
|
@ -848,7 +847,8 @@ static int mos7840_open(struct tty_struct *tty,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
|
urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
|
||||||
|
GFP_KERNEL);
|
||||||
if (!urb->transfer_buffer) {
|
if (!urb->transfer_buffer) {
|
||||||
usb_free_urb(urb);
|
usb_free_urb(urb);
|
||||||
mos7840_port->write_urb_pool[j] = NULL;
|
mos7840_port->write_urb_pool[j] = NULL;
|
||||||
|
@ -869,9 +869,8 @@ static int mos7840_open(struct tty_struct *tty,
|
||||||
* 0x08 : SP1/2 Control Reg
|
* 0x08 : SP1/2 Control Reg
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//NEED to check the following Block
|
/* NEED to check the following Block */
|
||||||
|
|
||||||
status = 0;
|
|
||||||
Data = 0x0;
|
Data = 0x0;
|
||||||
status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
|
status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
|
@ -891,36 +890,35 @@ static int mos7840_open(struct tty_struct *tty,
|
||||||
dbg("writing Spreg failed\n");
|
dbg("writing Spreg failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//End of block to be checked
|
/* End of block to be checked */
|
||||||
|
|
||||||
status = 0;
|
|
||||||
Data = 0x0;
|
Data = 0x0;
|
||||||
status =
|
status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset,
|
||||||
mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data);
|
&Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Reading Controlreg failed\n");
|
dbg("Reading Controlreg failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Data |= 0x08; //Driver done bit
|
Data |= 0x08; /* Driver done bit */
|
||||||
Data |= 0x20; //rx_disable
|
Data |= 0x20; /* rx_disable */
|
||||||
status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
|
status = mos7840_set_reg_sync(port,
|
||||||
|
mos7840_port->ControlRegOffset, Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("writing Controlreg failed\n");
|
dbg("writing Controlreg failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//do register settings here
|
/* do register settings here */
|
||||||
// Set all regs to the device default values.
|
/* Set all regs to the device default values. */
|
||||||
////////////////////////////////////
|
/***********************************
|
||||||
// First Disable all interrupts.
|
* First Disable all interrupts.
|
||||||
////////////////////////////////////
|
***********************************/
|
||||||
|
|
||||||
Data = 0x00;
|
Data = 0x00;
|
||||||
status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
|
status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("disableing interrupts failed\n");
|
dbg("disableing interrupts failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Set FIFO_CONTROL_REGISTER to the default value
|
/* Set FIFO_CONTROL_REGISTER to the default value */
|
||||||
Data = 0x00;
|
Data = 0x00;
|
||||||
status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
|
status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
|
@ -947,90 +945,73 @@ static int mos7840_open(struct tty_struct *tty,
|
||||||
status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
|
status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
|
||||||
mos7840_port->shadowLCR = Data;
|
mos7840_port->shadowLCR = Data;
|
||||||
|
|
||||||
Data |= SERIAL_LCR_DLAB; //data latch enable in LCR 0x80
|
Data |= SERIAL_LCR_DLAB; /* data latch enable in LCR 0x80 */
|
||||||
status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
||||||
|
|
||||||
Data = 0x0c;
|
Data = 0x0c;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data);
|
status = mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data);
|
||||||
|
|
||||||
Data = 0x0;
|
Data = 0x0;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data);
|
status = mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data);
|
||||||
|
|
||||||
Data = 0x00;
|
Data = 0x00;
|
||||||
status = 0;
|
|
||||||
status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
|
status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
|
||||||
|
|
||||||
Data = Data & ~SERIAL_LCR_DLAB;
|
Data = Data & ~SERIAL_LCR_DLAB;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
||||||
mos7840_port->shadowLCR = Data;
|
mos7840_port->shadowLCR = Data;
|
||||||
|
|
||||||
//clearing Bulkin and Bulkout Fifo
|
/* clearing Bulkin and Bulkout Fifo */
|
||||||
Data = 0x0;
|
Data = 0x0;
|
||||||
status = 0;
|
|
||||||
status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
|
status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
|
||||||
|
|
||||||
Data = Data | 0x0c;
|
Data = Data | 0x0c;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
|
status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
|
||||||
|
|
||||||
Data = Data & ~0x0c;
|
Data = Data & ~0x0c;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
|
status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
|
||||||
//Finally enable all interrupts
|
/* Finally enable all interrupts */
|
||||||
Data = 0x0;
|
|
||||||
Data = 0x0c;
|
Data = 0x0c;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
|
status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
|
||||||
|
|
||||||
//clearing rx_disable
|
/* clearing rx_disable */
|
||||||
Data = 0x0;
|
Data = 0x0;
|
||||||
status = 0;
|
status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset,
|
||||||
status =
|
&Data);
|
||||||
mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data);
|
|
||||||
Data = Data & ~0x20;
|
Data = Data & ~0x20;
|
||||||
status = 0;
|
status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset,
|
||||||
status =
|
Data);
|
||||||
mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
|
|
||||||
|
|
||||||
// rx_negate
|
/* rx_negate */
|
||||||
Data = 0x0;
|
Data = 0x0;
|
||||||
status = 0;
|
status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset,
|
||||||
status =
|
&Data);
|
||||||
mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data);
|
|
||||||
Data = Data | 0x10;
|
Data = Data | 0x10;
|
||||||
status = 0;
|
status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset,
|
||||||
status =
|
Data);
|
||||||
mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
|
|
||||||
|
|
||||||
/* force low_latency on so that our tty_push actually forces *
|
/* force low_latency on so that our tty_push actually forces *
|
||||||
* the data through,otherwise it is scheduled, and with *
|
* the data through,otherwise it is scheduled, and with *
|
||||||
* high data rates (like with OHCI) data can get lost. */
|
* high data rates (like with OHCI) data can get lost. */
|
||||||
|
|
||||||
if (tty)
|
if (tty)
|
||||||
tty->low_latency = 1;
|
tty->low_latency = 1;
|
||||||
/* Check to see if we've set up our endpoint info yet *
|
|
||||||
* (can't set it up in mos7840_startup as the structures *
|
/* Check to see if we've set up our endpoint info yet *
|
||||||
* were not set up at that time.) */
|
* (can't set it up in mos7840_startup as the structures *
|
||||||
|
* were not set up at that time.) */
|
||||||
if (port0->open_ports == 1) {
|
if (port0->open_ports == 1) {
|
||||||
if (serial->port[0]->interrupt_in_buffer == NULL) {
|
if (serial->port[0]->interrupt_in_buffer == NULL) {
|
||||||
|
|
||||||
/* set up interrupt urb */
|
/* set up interrupt urb */
|
||||||
|
|
||||||
usb_fill_int_urb(serial->port[0]->interrupt_in_urb,
|
usb_fill_int_urb(serial->port[0]->interrupt_in_urb,
|
||||||
serial->dev,
|
serial->dev,
|
||||||
usb_rcvintpipe(serial->dev,
|
usb_rcvintpipe(serial->dev,
|
||||||
serial->port[0]->
|
serial->port[0]->interrupt_in_endpointAddress),
|
||||||
interrupt_in_endpointAddress),
|
serial->port[0]->interrupt_in_buffer,
|
||||||
serial->port[0]->interrupt_in_buffer,
|
serial->port[0]->interrupt_in_urb->
|
||||||
serial->port[0]->interrupt_in_urb->
|
transfer_buffer_length,
|
||||||
transfer_buffer_length,
|
mos7840_interrupt_callback,
|
||||||
mos7840_interrupt_callback,
|
serial,
|
||||||
serial,
|
serial->port[0]->interrupt_in_urb->interval);
|
||||||
serial->port[0]->interrupt_in_urb->
|
|
||||||
interval);
|
|
||||||
|
|
||||||
/* start interrupt read for mos7840 *
|
/* start interrupt read for mos7840 *
|
||||||
* will continue as long as mos7840 is connected */
|
* will continue as long as mos7840 is connected */
|
||||||
|
@ -1085,14 +1066,16 @@ static int mos7840_open(struct tty_struct *tty,
|
||||||
memset(&(mos7840_port->icount), 0x00, sizeof(mos7840_port->icount));
|
memset(&(mos7840_port->icount), 0x00, sizeof(mos7840_port->icount));
|
||||||
|
|
||||||
/* initialize our port settings */
|
/* initialize our port settings */
|
||||||
mos7840_port->shadowMCR = MCR_MASTER_IE; /* Must set to enable ints! */
|
/* Must set to enable ints! */
|
||||||
|
mos7840_port->shadowMCR = MCR_MASTER_IE;
|
||||||
/* send a open port command */
|
/* send a open port command */
|
||||||
mos7840_port->open = 1;
|
mos7840_port->open = 1;
|
||||||
//mos7840_change_port_settings(mos7840_port,old_termios);
|
/* mos7840_change_port_settings(mos7840_port,old_termios); */
|
||||||
mos7840_port->icount.tx = 0;
|
mos7840_port->icount.tx = 0;
|
||||||
mos7840_port->icount.rx = 0;
|
mos7840_port->icount.rx = 0;
|
||||||
|
|
||||||
dbg("\n\nusb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p\n\n", serial, mos7840_port, port);
|
dbg("\n\nusb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p\n\n",
|
||||||
|
serial, mos7840_port, port);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1129,11 +1112,11 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&mos7840_port->pool_lock,flags);
|
spin_lock_irqsave(&mos7840_port->pool_lock, flags);
|
||||||
for (i = 0; i < NUM_URBS; ++i)
|
for (i = 0; i < NUM_URBS; ++i)
|
||||||
if (mos7840_port->busy[i])
|
if (mos7840_port->busy[i])
|
||||||
chars += URB_TRANSFER_BUFFER_SIZE;
|
chars += URB_TRANSFER_BUFFER_SIZE;
|
||||||
spin_unlock_irqrestore(&mos7840_port->pool_lock,flags);
|
spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
|
||||||
dbg("%s - returns %d", __func__, chars);
|
dbg("%s - returns %d", __func__, chars);
|
||||||
return chars;
|
return chars;
|
||||||
|
|
||||||
|
@ -1161,9 +1144,8 @@ static void mos7840_block_until_tx_empty(struct tty_struct *tty,
|
||||||
count = mos7840_chars_in_buffer(tty);
|
count = mos7840_chars_in_buffer(tty);
|
||||||
|
|
||||||
/* Check for Buffer status */
|
/* Check for Buffer status */
|
||||||
if (count <= 0) {
|
if (count <= 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* Block the thread for a while */
|
/* Block the thread for a while */
|
||||||
interruptible_sleep_on_timeout(&mos7840_port->wait_chase,
|
interruptible_sleep_on_timeout(&mos7840_port->wait_chase,
|
||||||
|
@ -1245,11 +1227,11 @@ static void mos7840_close(struct tty_struct *tty,
|
||||||
}
|
}
|
||||||
if ((&mos7840_port->control_urb)) {
|
if ((&mos7840_port->control_urb)) {
|
||||||
dbg("%s", "Shutdown control read\n");
|
dbg("%s", "Shutdown control read\n");
|
||||||
// usb_kill_urb (mos7840_port->control_urb);
|
/*/ usb_kill_urb (mos7840_port->control_urb); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if(mos7840_port->ctrl_buf != NULL)
|
/* if(mos7840_port->ctrl_buf != NULL) */
|
||||||
// kfree(mos7840_port->ctrl_buf);
|
/* kfree(mos7840_port->ctrl_buf); */
|
||||||
port0->open_ports--;
|
port0->open_ports--;
|
||||||
dbg("mos7840_num_open_ports in close%d:in port%d\n",
|
dbg("mos7840_num_open_ports in close%d:in port%d\n",
|
||||||
port0->open_ports, port->number);
|
port0->open_ports, port->number);
|
||||||
|
@ -1262,10 +1244,8 @@ static void mos7840_close(struct tty_struct *tty,
|
||||||
|
|
||||||
if (mos7840_port->write_urb) {
|
if (mos7840_port->write_urb) {
|
||||||
/* if this urb had a transfer buffer already (old tx) free it */
|
/* if this urb had a transfer buffer already (old tx) free it */
|
||||||
|
if (mos7840_port->write_urb->transfer_buffer != NULL)
|
||||||
if (mos7840_port->write_urb->transfer_buffer != NULL) {
|
|
||||||
kfree(mos7840_port->write_urb->transfer_buffer);
|
kfree(mos7840_port->write_urb->transfer_buffer);
|
||||||
}
|
|
||||||
usb_free_urb(mos7840_port->write_urb);
|
usb_free_urb(mos7840_port->write_urb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1302,9 +1282,8 @@ static void mos7840_block_until_chase_response(struct tty_struct *tty,
|
||||||
count = mos7840_chars_in_buffer(tty);
|
count = mos7840_chars_in_buffer(tty);
|
||||||
|
|
||||||
/* Check for Buffer status */
|
/* Check for Buffer status */
|
||||||
if (count <= 0) {
|
if (count <= 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* Block the thread for a while */
|
/* Block the thread for a while */
|
||||||
interruptible_sleep_on_timeout(&mos7840_port->wait_chase,
|
interruptible_sleep_on_timeout(&mos7840_port->wait_chase,
|
||||||
|
@ -1349,9 +1328,8 @@ static void mos7840_break(struct tty_struct *tty, int break_state)
|
||||||
|
|
||||||
mos7840_port = mos7840_get_port_private(port);
|
mos7840_port = mos7840_get_port_private(port);
|
||||||
|
|
||||||
if (mos7840_port == NULL) {
|
if (mos7840_port == NULL)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (serial->dev)
|
if (serial->dev)
|
||||||
/* flush and block until tx is empty */
|
/* flush and block until tx is empty */
|
||||||
|
@ -1403,9 +1381,8 @@ static int mos7840_write_room(struct tty_struct *tty)
|
||||||
|
|
||||||
spin_lock_irqsave(&mos7840_port->pool_lock, flags);
|
spin_lock_irqsave(&mos7840_port->pool_lock, flags);
|
||||||
for (i = 0; i < NUM_URBS; ++i) {
|
for (i = 0; i < NUM_URBS; ++i) {
|
||||||
if (!mos7840_port->busy[i]) {
|
if (!mos7840_port->busy[i])
|
||||||
room += URB_TRANSFER_BUFFER_SIZE;
|
room += URB_TRANSFER_BUFFER_SIZE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
|
spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
|
||||||
|
|
||||||
|
@ -1435,45 +1412,41 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
|
||||||
struct moschip_port *mos7840_port;
|
struct moschip_port *mos7840_port;
|
||||||
struct usb_serial *serial;
|
struct usb_serial *serial;
|
||||||
struct urb *urb;
|
struct urb *urb;
|
||||||
//__u16 Data;
|
/* __u16 Data; */
|
||||||
const unsigned char *current_position = data;
|
const unsigned char *current_position = data;
|
||||||
unsigned char *data1;
|
unsigned char *data1;
|
||||||
dbg("%s \n", "entering ...........");
|
dbg("%s \n", "entering ...........");
|
||||||
//dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",mos7840_port->shadowLCR);
|
/* dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
|
||||||
|
mos7840_port->shadowLCR); */
|
||||||
|
|
||||||
#ifdef NOTMOS7840
|
#ifdef NOTMOS7840
|
||||||
Data = 0x00;
|
Data = 0x00;
|
||||||
status = 0;
|
|
||||||
status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
|
status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
|
||||||
mos7840_port->shadowLCR = Data;
|
mos7840_port->shadowLCR = Data;
|
||||||
dbg("mos7840_write: LINE_CONTROL_REGISTER is %x\n", Data);
|
dbg("mos7840_write: LINE_CONTROL_REGISTER is %x\n", Data);
|
||||||
dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
|
dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
|
||||||
mos7840_port->shadowLCR);
|
mos7840_port->shadowLCR);
|
||||||
|
|
||||||
//Data = 0x03;
|
/* Data = 0x03; */
|
||||||
//status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data);
|
/* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */
|
||||||
//mos7840_port->shadowLCR=Data;//Need to add later
|
/* mos7840_port->shadowLCR=Data;//Need to add later */
|
||||||
|
|
||||||
Data |= SERIAL_LCR_DLAB; //data latch enable in LCR 0x80
|
Data |= SERIAL_LCR_DLAB; /* data latch enable in LCR 0x80 */
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
||||||
|
|
||||||
//Data = 0x0c;
|
/* Data = 0x0c; */
|
||||||
//status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data);
|
/* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */
|
||||||
Data = 0x00;
|
Data = 0x00;
|
||||||
status = 0;
|
|
||||||
status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data);
|
status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data);
|
||||||
dbg("mos7840_write:DLL value is %x\n", Data);
|
dbg("mos7840_write:DLL value is %x\n", Data);
|
||||||
|
|
||||||
Data = 0x0;
|
Data = 0x0;
|
||||||
status = 0;
|
|
||||||
status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data);
|
status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data);
|
||||||
dbg("mos7840_write:DLM value is %x\n", Data);
|
dbg("mos7840_write:DLM value is %x\n", Data);
|
||||||
|
|
||||||
Data = Data & ~SERIAL_LCR_DLAB;
|
Data = Data & ~SERIAL_LCR_DLAB;
|
||||||
dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
|
dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
|
||||||
mos7840_port->shadowLCR);
|
mos7840_port->shadowLCR);
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1598,7 +1571,6 @@ static void mos7840_throttle(struct tty_struct *tty)
|
||||||
/* if we are implementing RTS/CTS, toggle that line */
|
/* if we are implementing RTS/CTS, toggle that line */
|
||||||
if (tty->termios->c_cflag & CRTSCTS) {
|
if (tty->termios->c_cflag & CRTSCTS) {
|
||||||
mos7840_port->shadowMCR &= ~MCR_RTS;
|
mos7840_port->shadowMCR &= ~MCR_RTS;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
|
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
|
||||||
mos7840_port->shadowMCR);
|
mos7840_port->shadowMCR);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
|
@ -1610,8 +1582,9 @@ static void mos7840_throttle(struct tty_struct *tty)
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* mos7840_unthrottle
|
* mos7840_unthrottle
|
||||||
* this function is called by the tty driver when it wants to resume the data
|
* this function is called by the tty driver when it wants to resume
|
||||||
* being read from the port (called after SerialThrottle is called)
|
* the data being read from the port (called after mos7840_throttle is
|
||||||
|
* called)
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static void mos7840_unthrottle(struct tty_struct *tty)
|
static void mos7840_unthrottle(struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
|
@ -1645,7 +1618,6 @@ static void mos7840_unthrottle(struct tty_struct *tty)
|
||||||
/* if we are implementing RTS/CTS, toggle that line */
|
/* if we are implementing RTS/CTS, toggle that line */
|
||||||
if (tty->termios->c_cflag & CRTSCTS) {
|
if (tty->termios->c_cflag & CRTSCTS) {
|
||||||
mos7840_port->shadowMCR |= MCR_RTS;
|
mos7840_port->shadowMCR |= MCR_RTS;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
|
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
|
||||||
mos7840_port->shadowMCR);
|
mos7840_port->shadowMCR);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
|
@ -1660,7 +1632,7 @@ static int mos7840_tiocmget(struct tty_struct *tty, struct file *file)
|
||||||
unsigned int result;
|
unsigned int result;
|
||||||
__u16 msr;
|
__u16 msr;
|
||||||
__u16 mcr;
|
__u16 mcr;
|
||||||
int status = 0;
|
int status;
|
||||||
mos7840_port = mos7840_get_port_private(port);
|
mos7840_port = mos7840_get_port_private(port);
|
||||||
|
|
||||||
dbg("%s - port %d", __func__, port->number);
|
dbg("%s - port %d", __func__, port->number);
|
||||||
|
@ -1731,7 +1703,7 @@ static int mos7840_tiocmset(struct tty_struct *tty, struct file *file,
|
||||||
* baud rate.
|
* baud rate.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
|
static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
|
||||||
__u16 * clk_sel_val)
|
__u16 *clk_sel_val)
|
||||||
{
|
{
|
||||||
|
|
||||||
dbg("%s - %d", __func__, baudRate);
|
dbg("%s - %d", __func__, baudRate);
|
||||||
|
@ -1783,9 +1755,8 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
|
||||||
/* Check for round off */
|
/* Check for round off */
|
||||||
round1 = (__u16) (2304000L / baudrate);
|
round1 = (__u16) (2304000L / baudrate);
|
||||||
round = (__u16) (round1 - (custom * 10));
|
round = (__u16) (round1 - (custom * 10));
|
||||||
if (round > 4) {
|
if (round > 4)
|
||||||
custom++;
|
custom++;
|
||||||
}
|
|
||||||
*divisor = custom;
|
*divisor = custom;
|
||||||
|
|
||||||
dbg(" Baud %d = %d\n", baudrate, custom);
|
dbg(" Baud %d = %d\n", baudrate, custom);
|
||||||
|
@ -1833,16 +1804,15 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
|
||||||
|
|
||||||
dbg("%s - port = %d, baud = %d", __func__,
|
dbg("%s - port = %d, baud = %d", __func__,
|
||||||
mos7840_port->port->number, baudRate);
|
mos7840_port->port->number, baudRate);
|
||||||
//reset clk_uart_sel in spregOffset
|
/* reset clk_uart_sel in spregOffset */
|
||||||
if (baudRate > 115200) {
|
if (baudRate > 115200) {
|
||||||
#ifdef HW_flow_control
|
#ifdef HW_flow_control
|
||||||
//NOTE: need to see the pther register to modify
|
/* NOTE: need to see the pther register to modify */
|
||||||
//setting h/w flow control bit to 1;
|
/* setting h/w flow control bit to 1 */
|
||||||
status = 0;
|
|
||||||
Data = 0x2b;
|
Data = 0x2b;
|
||||||
mos7840_port->shadowMCR = Data;
|
mos7840_port->shadowMCR = Data;
|
||||||
status =
|
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
|
||||||
mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
|
Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing spreg failed in set_serial_baud\n");
|
dbg("Writing spreg failed in set_serial_baud\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1851,12 +1821,11 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
#ifdef HW_flow_control
|
#ifdef HW_flow_control
|
||||||
//setting h/w flow control bit to 0;
|
/ *setting h/w flow control bit to 0 */
|
||||||
status = 0;
|
|
||||||
Data = 0xb;
|
Data = 0xb;
|
||||||
mos7840_port->shadowMCR = Data;
|
mos7840_port->shadowMCR = Data;
|
||||||
status =
|
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
|
||||||
mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
|
Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing spreg failed in set_serial_baud\n");
|
dbg("Writing spreg failed in set_serial_baud\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1865,25 +1834,20 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1) //baudRate <= 115200)
|
if (1) { /* baudRate <= 115200) */
|
||||||
{
|
|
||||||
clk_sel_val = 0x0;
|
clk_sel_val = 0x0;
|
||||||
Data = 0x0;
|
Data = 0x0;
|
||||||
status = 0;
|
status = mos7840_calc_baud_rate_divisor(baudRate, &divisor,
|
||||||
status =
|
|
||||||
mos7840_calc_baud_rate_divisor(baudRate, &divisor,
|
|
||||||
&clk_sel_val);
|
&clk_sel_val);
|
||||||
status =
|
status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset,
|
||||||
mos7840_get_reg_sync(port, mos7840_port->SpRegOffset,
|
&Data);
|
||||||
&Data);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("reading spreg failed in set_serial_baud\n");
|
dbg("reading spreg failed in set_serial_baud\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Data = (Data & 0x8f) | clk_sel_val;
|
Data = (Data & 0x8f) | clk_sel_val;
|
||||||
status = 0;
|
status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset,
|
||||||
status =
|
Data);
|
||||||
mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing spreg failed in set_serial_baud\n");
|
dbg("Writing spreg failed in set_serial_baud\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1915,7 +1879,6 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
|
||||||
mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2006,9 +1969,8 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
|
||||||
dbg("%s - parity = none", __func__);
|
dbg("%s - parity = none", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cflag & CMSPAR) {
|
if (cflag & CMSPAR)
|
||||||
lParity = lParity | 0x20;
|
lParity = lParity | 0x20;
|
||||||
}
|
|
||||||
|
|
||||||
/* Change the Stop bit */
|
/* Change the Stop bit */
|
||||||
if (cflag & CSTOPB) {
|
if (cflag & CSTOPB) {
|
||||||
|
@ -2050,16 +2012,13 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
|
||||||
/* set up the MCR register and send it to the mos7840 */
|
/* set up the MCR register and send it to the mos7840 */
|
||||||
|
|
||||||
mos7840_port->shadowMCR = MCR_MASTER_IE;
|
mos7840_port->shadowMCR = MCR_MASTER_IE;
|
||||||
if (cflag & CBAUD) {
|
if (cflag & CBAUD)
|
||||||
mos7840_port->shadowMCR |= (MCR_DTR | MCR_RTS);
|
mos7840_port->shadowMCR |= (MCR_DTR | MCR_RTS);
|
||||||
}
|
|
||||||
|
|
||||||
if (cflag & CRTSCTS) {
|
if (cflag & CRTSCTS)
|
||||||
mos7840_port->shadowMCR |= (MCR_XON_ANY);
|
mos7840_port->shadowMCR |= (MCR_XON_ANY);
|
||||||
|
else
|
||||||
} else {
|
|
||||||
mos7840_port->shadowMCR &= ~(MCR_XON_ANY);
|
mos7840_port->shadowMCR &= ~(MCR_XON_ANY);
|
||||||
}
|
|
||||||
|
|
||||||
Data = mos7840_port->shadowMCR;
|
Data = mos7840_port->shadowMCR;
|
||||||
mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
|
mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
|
||||||
|
@ -2255,7 +2214,6 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
|
||||||
mos7840_port->shadowMCR = mcr;
|
mos7840_port->shadowMCR = mcr;
|
||||||
|
|
||||||
Data = mos7840_port->shadowMCR;
|
Data = mos7840_port->shadowMCR;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
|
status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("setting MODEM_CONTROL_REGISTER Failed\n");
|
dbg("setting MODEM_CONTROL_REGISTER Failed\n");
|
||||||
|
@ -2276,8 +2234,7 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
|
||||||
unsigned int result = 0;
|
unsigned int result = 0;
|
||||||
__u16 msr;
|
__u16 msr;
|
||||||
unsigned int mcr = mos7840_port->shadowMCR;
|
unsigned int mcr = mos7840_port->shadowMCR;
|
||||||
int status = 0;
|
mos7840_get_uart_reg(mos7840_port->port,
|
||||||
status = mos7840_get_uart_reg(mos7840_port->port,
|
|
||||||
MODEM_STATUS_REGISTER, &msr);
|
MODEM_STATUS_REGISTER, &msr);
|
||||||
result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */
|
result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */
|
||||||
|((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */
|
|((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */
|
||||||
|
@ -2389,7 +2346,7 @@ static int mos7840_ioctl(struct tty_struct *tty, struct file *file,
|
||||||
dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
|
dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
|
||||||
cprev = mos7840_port->icount;
|
cprev = mos7840_port->icount;
|
||||||
while (1) {
|
while (1) {
|
||||||
//interruptible_sleep_on(&mos7840_port->delta_msr_wait);
|
/* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */
|
||||||
mos7840_port->delta_msr_cond = 0;
|
mos7840_port->delta_msr_cond = 0;
|
||||||
wait_event_interruptible(mos7840_port->delta_msr_wait,
|
wait_event_interruptible(mos7840_port->delta_msr_wait,
|
||||||
(mos7840_port->
|
(mos7840_port->
|
||||||
|
@ -2494,8 +2451,9 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize all port interrupt end point to port 0 int endpoint *
|
/* Initialize all port interrupt end point to port 0 int
|
||||||
* Our device has only one interrupt end point comman to all port */
|
* endpoint. Our device has only one interrupt end point
|
||||||
|
* common to all port */
|
||||||
|
|
||||||
mos7840_port->port = serial->port[i];
|
mos7840_port->port = serial->port[i];
|
||||||
mos7840_set_port_private(serial->port[i], mos7840_port);
|
mos7840_set_port_private(serial->port[i], mos7840_port);
|
||||||
|
@ -2531,27 +2489,23 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
mos7840_port->DcrRegOffset = 0x1c;
|
mos7840_port->DcrRegOffset = 0x1c;
|
||||||
}
|
}
|
||||||
mos7840_dump_serial_port(mos7840_port);
|
mos7840_dump_serial_port(mos7840_port);
|
||||||
|
|
||||||
mos7840_set_port_private(serial->port[i], mos7840_port);
|
mos7840_set_port_private(serial->port[i], mos7840_port);
|
||||||
|
|
||||||
//enable rx_disable bit in control register
|
/* enable rx_disable bit in control register */
|
||||||
|
status = mos7840_get_reg_sync(serial->port[i],
|
||||||
status =
|
mos7840_port->ControlRegOffset, &Data);
|
||||||
mos7840_get_reg_sync(serial->port[i],
|
|
||||||
mos7840_port->ControlRegOffset, &Data);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Reading ControlReg failed status-0x%x\n", status);
|
dbg("Reading ControlReg failed status-0x%x\n", status);
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
dbg("ControlReg Reading success val is %x, status%d\n",
|
dbg("ControlReg Reading success val is %x, status%d\n",
|
||||||
Data, status);
|
Data, status);
|
||||||
Data |= 0x08; //setting driver done bit
|
Data |= 0x08; /* setting driver done bit */
|
||||||
Data |= 0x04; //sp1_bit to have cts change reflect in modem status reg
|
Data |= 0x04; /* sp1_bit to have cts change reflect in
|
||||||
|
modem status reg */
|
||||||
|
|
||||||
//Data |= 0x20; //rx_disable bit
|
/* Data |= 0x20; //rx_disable bit */
|
||||||
status = 0;
|
status = mos7840_set_reg_sync(serial->port[i],
|
||||||
status =
|
|
||||||
mos7840_set_reg_sync(serial->port[i],
|
|
||||||
mos7840_port->ControlRegOffset, Data);
|
mos7840_port->ControlRegOffset, Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing ControlReg failed(rx_disable) status-0x%x\n", status);
|
dbg("Writing ControlReg failed(rx_disable) status-0x%x\n", status);
|
||||||
|
@ -2560,13 +2514,11 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
dbg("ControlReg Writing success(rx_disable) status%d\n",
|
dbg("ControlReg Writing success(rx_disable) status%d\n",
|
||||||
status);
|
status);
|
||||||
|
|
||||||
//Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 and 0x24 in DCR3
|
/* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2
|
||||||
|
and 0x24 in DCR3 */
|
||||||
Data = 0x01;
|
Data = 0x01;
|
||||||
status = 0;
|
status = mos7840_set_reg_sync(serial->port[i],
|
||||||
status =
|
(__u16) (mos7840_port->DcrRegOffset + 0), Data);
|
||||||
mos7840_set_reg_sync(serial->port[i],
|
|
||||||
(__u16) (mos7840_port->DcrRegOffset +
|
|
||||||
0), Data);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing DCR0 failed status-0x%x\n", status);
|
dbg("Writing DCR0 failed status-0x%x\n", status);
|
||||||
break;
|
break;
|
||||||
|
@ -2574,11 +2526,8 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
dbg("DCR0 Writing success status%d\n", status);
|
dbg("DCR0 Writing success status%d\n", status);
|
||||||
|
|
||||||
Data = 0x05;
|
Data = 0x05;
|
||||||
status = 0;
|
status = mos7840_set_reg_sync(serial->port[i],
|
||||||
status =
|
(__u16) (mos7840_port->DcrRegOffset + 1), Data);
|
||||||
mos7840_set_reg_sync(serial->port[i],
|
|
||||||
(__u16) (mos7840_port->DcrRegOffset +
|
|
||||||
1), Data);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing DCR1 failed status-0x%x\n", status);
|
dbg("Writing DCR1 failed status-0x%x\n", status);
|
||||||
break;
|
break;
|
||||||
|
@ -2586,22 +2535,17 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
dbg("DCR1 Writing success status%d\n", status);
|
dbg("DCR1 Writing success status%d\n", status);
|
||||||
|
|
||||||
Data = 0x24;
|
Data = 0x24;
|
||||||
status = 0;
|
status = mos7840_set_reg_sync(serial->port[i],
|
||||||
status =
|
(__u16) (mos7840_port->DcrRegOffset + 2), Data);
|
||||||
mos7840_set_reg_sync(serial->port[i],
|
|
||||||
(__u16) (mos7840_port->DcrRegOffset +
|
|
||||||
2), Data);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing DCR2 failed status-0x%x\n", status);
|
dbg("Writing DCR2 failed status-0x%x\n", status);
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
dbg("DCR2 Writing success status%d\n", status);
|
dbg("DCR2 Writing success status%d\n", status);
|
||||||
|
|
||||||
// write values in clkstart0x0 and clkmulti 0x20
|
/* write values in clkstart0x0 and clkmulti 0x20 */
|
||||||
Data = 0x0;
|
Data = 0x0;
|
||||||
status = 0;
|
status = mos7840_set_reg_sync(serial->port[i],
|
||||||
status =
|
|
||||||
mos7840_set_reg_sync(serial->port[i],
|
|
||||||
CLK_START_VALUE_REGISTER, Data);
|
CLK_START_VALUE_REGISTER, Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status);
|
dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status);
|
||||||
|
@ -2610,9 +2554,8 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status);
|
dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status);
|
||||||
|
|
||||||
Data = 0x20;
|
Data = 0x20;
|
||||||
status =
|
status = mos7840_set_reg_sync(serial->port[i],
|
||||||
mos7840_set_reg_sync(serial->port[i], CLK_MULTI_REGISTER,
|
CLK_MULTI_REGISTER, Data);
|
||||||
Data);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n",
|
dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n",
|
||||||
status);
|
status);
|
||||||
|
@ -2621,11 +2564,10 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
dbg("CLK_MULTI_REGISTER Writing success status%d\n",
|
dbg("CLK_MULTI_REGISTER Writing success status%d\n",
|
||||||
status);
|
status);
|
||||||
|
|
||||||
//write value 0x0 to scratchpad register
|
/* write value 0x0 to scratchpad register */
|
||||||
Data = 0x00;
|
Data = 0x00;
|
||||||
status =
|
status = mos7840_set_uart_reg(serial->port[i],
|
||||||
mos7840_set_uart_reg(serial->port[i], SCRATCH_PAD_REGISTER,
|
SCRATCH_PAD_REGISTER, Data);
|
||||||
Data);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x\n",
|
dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x\n",
|
||||||
status);
|
status);
|
||||||
|
@ -2634,21 +2576,17 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
dbg("SCRATCH_PAD_REGISTER Writing success status%d\n",
|
dbg("SCRATCH_PAD_REGISTER Writing success status%d\n",
|
||||||
status);
|
status);
|
||||||
|
|
||||||
//Zero Length flag register
|
/* Zero Length flag register */
|
||||||
if ((mos7840_port->port_num != 1)
|
if ((mos7840_port->port_num != 1)
|
||||||
&& (serial->num_ports == 2)) {
|
&& (serial->num_ports == 2)) {
|
||||||
|
|
||||||
Data = 0xff;
|
Data = 0xff;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_reg_sync(serial->port[i],
|
status = mos7840_set_reg_sync(serial->port[i],
|
||||||
(__u16) (ZLP_REG1 +
|
(__u16) (ZLP_REG1 +
|
||||||
((__u16)
|
((__u16)mos7840_port->port_num)), Data);
|
||||||
mos7840_port->
|
|
||||||
port_num)),
|
|
||||||
Data);
|
|
||||||
dbg("ZLIP offset%x\n",
|
dbg("ZLIP offset%x\n",
|
||||||
(__u16) (ZLP_REG1 +
|
(__u16) (ZLP_REG1 +
|
||||||
((__u16) mos7840_port->port_num)));
|
((__u16) mos7840_port->port_num)));
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dbg("Writing ZLP_REG%d failed status-0x%x\n",
|
dbg("Writing ZLP_REG%d failed status-0x%x\n",
|
||||||
i + 2, status);
|
i + 2, status);
|
||||||
|
@ -2658,13 +2596,9 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
i + 2, status);
|
i + 2, status);
|
||||||
} else {
|
} else {
|
||||||
Data = 0xff;
|
Data = 0xff;
|
||||||
status = 0;
|
|
||||||
status = mos7840_set_reg_sync(serial->port[i],
|
status = mos7840_set_reg_sync(serial->port[i],
|
||||||
(__u16) (ZLP_REG1 +
|
(__u16) (ZLP_REG1 +
|
||||||
((__u16)
|
((__u16)mos7840_port->port_num) - 0x1), Data);
|
||||||
mos7840_port->
|
|
||||||
port_num) -
|
|
||||||
0x1), Data);
|
|
||||||
dbg("ZLIP offset%x\n",
|
dbg("ZLIP offset%x\n",
|
||||||
(__u16) (ZLP_REG1 +
|
(__u16) (ZLP_REG1 +
|
||||||
((__u16) mos7840_port->port_num) - 0x1));
|
((__u16) mos7840_port->port_num) - 0x1));
|
||||||
|
@ -2679,14 +2613,16 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
}
|
}
|
||||||
mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL);
|
mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||||
mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
|
mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
|
||||||
mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
|
mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest),
|
||||||
if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf || !mos7840_port->dr) {
|
GFP_KERNEL);
|
||||||
|
if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf ||
|
||||||
|
!mos7840_port->dr) {
|
||||||
status = -ENOMEM;
|
status = -ENOMEM;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Zero Length flag enable
|
/* Zero Length flag enable */
|
||||||
Data = 0x0f;
|
Data = 0x0f;
|
||||||
status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
|
status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
|
@ -2729,7 +2665,7 @@ static void mos7840_shutdown(struct usb_serial *serial)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for the ports to be closed,close the ports and disconnect */
|
/* check for the ports to be closed,close the ports and disconnect */
|
||||||
|
|
||||||
/* free private structure allocated for serial port *
|
/* free private structure allocated for serial port *
|
||||||
* stop reads and writes on all ports */
|
* stop reads and writes on all ports */
|
||||||
|
@ -2810,20 +2746,12 @@ static int __init moschip7840_init(void)
|
||||||
|
|
||||||
/* Register with the usb */
|
/* Register with the usb */
|
||||||
retval = usb_register(&io_driver);
|
retval = usb_register(&io_driver);
|
||||||
|
|
||||||
if (retval)
|
|
||||||
goto failed_usb_register;
|
|
||||||
|
|
||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
dbg("%s\n", "Leaving...");
|
dbg("%s\n", "Leaving...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
failed_usb_register:
|
|
||||||
usb_serial_deregister(&moschip7840_4port_device);
|
usb_serial_deregister(&moschip7840_4port_device);
|
||||||
|
failed_port_device_register:
|
||||||
failed_port_device_register:
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue