2017-11-07 01:11:51 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* icom.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 IBM Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* Serial device driver.
|
|
|
|
*
|
|
|
|
* Based on code from serial.c
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/termios.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/tty_flip.h>
|
|
|
|
#include <linux/serial.h>
|
2022-04-21 16:58:03 +08:00
|
|
|
#include <linux/serial_core.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/serial_reg.h>
|
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/spinlock.h>
|
2007-12-04 12:16:20 +08:00
|
|
|
#include <linux/kref.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
|
2021-05-13 11:01:35 +08:00
|
|
|
#include <linux/io.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/irq.h>
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*#define ICOM_TRACE enable port trace capabilities */
|
|
|
|
|
|
|
|
#define ICOM_DRIVER_NAME "icom"
|
|
|
|
#define NR_PORTS 128
|
|
|
|
|
2022-04-21 16:58:05 +08:00
|
|
|
static const unsigned int icom_acfg_baud[] = {
|
2022-04-21 16:58:03 +08:00
|
|
|
300,
|
|
|
|
600,
|
|
|
|
900,
|
|
|
|
1200,
|
|
|
|
1800,
|
|
|
|
2400,
|
|
|
|
3600,
|
|
|
|
4800,
|
|
|
|
7200,
|
|
|
|
9600,
|
|
|
|
14400,
|
|
|
|
19200,
|
|
|
|
28800,
|
|
|
|
38400,
|
|
|
|
57600,
|
|
|
|
76800,
|
|
|
|
115200,
|
|
|
|
153600,
|
|
|
|
230400,
|
|
|
|
307200,
|
|
|
|
460800,
|
|
|
|
};
|
2022-04-21 16:58:04 +08:00
|
|
|
#define BAUD_TABLE_LIMIT (ARRAY_SIZE(icom_acfg_baud) - 1)
|
2022-04-21 16:58:03 +08:00
|
|
|
|
|
|
|
struct icom_regs {
|
|
|
|
u32 control; /* Adapter Control Register */
|
|
|
|
u32 interrupt; /* Adapter Interrupt Register */
|
|
|
|
u32 int_mask; /* Adapter Interrupt Mask Reg */
|
|
|
|
u32 int_pri; /* Adapter Interrupt Priority r */
|
|
|
|
u32 int_reg_b; /* Adapter non-masked Interrupt */
|
|
|
|
u32 resvd01;
|
|
|
|
u32 resvd02;
|
|
|
|
u32 resvd03;
|
|
|
|
u32 control_2; /* Adapter Control Register 2 */
|
|
|
|
u32 interrupt_2; /* Adapter Interrupt Register 2 */
|
|
|
|
u32 int_mask_2; /* Adapter Interrupt Mask 2 */
|
|
|
|
u32 int_pri_2; /* Adapter Interrupt Prior 2 */
|
|
|
|
u32 int_reg_2b; /* Adapter non-masked 2 */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct func_dram {
|
|
|
|
u32 reserved[108]; /* 0-1B0 reserved by personality code */
|
|
|
|
u32 RcvStatusAddr; /* 1B0-1B3 Status Address for Next rcv */
|
|
|
|
u8 RcvStnAddr; /* 1B4 Receive Station Addr */
|
|
|
|
u8 IdleState; /* 1B5 Idle State */
|
|
|
|
u8 IdleMonitor; /* 1B6 Idle Monitor */
|
|
|
|
u8 FlagFillIdleTimer; /* 1B7 Flag Fill Idle Timer */
|
|
|
|
u32 XmitStatusAddr; /* 1B8-1BB Transmit Status Address */
|
|
|
|
u8 StartXmitCmd; /* 1BC Start Xmit Command */
|
|
|
|
u8 HDLCConfigReg; /* 1BD Reserved */
|
|
|
|
u8 CauseCode; /* 1BE Cause code for fatal error */
|
|
|
|
u8 xchar; /* 1BF High priority send */
|
|
|
|
u32 reserved3; /* 1C0-1C3 Reserved */
|
|
|
|
u8 PrevCmdReg; /* 1C4 Reserved */
|
|
|
|
u8 CmdReg; /* 1C5 Command Register */
|
|
|
|
u8 async_config2; /* 1C6 Async Config Byte 2 */
|
|
|
|
u8 async_config3; /* 1C7 Async Config Byte 3 */
|
|
|
|
u8 dce_resvd[20]; /* 1C8-1DB DCE Rsvd */
|
|
|
|
u8 dce_resvd21; /* 1DC DCE Rsvd (21st byte */
|
|
|
|
u8 misc_flags; /* 1DD misc flags */
|
|
|
|
#define V2_HARDWARE 0x40
|
|
|
|
#define ICOM_HDW_ACTIVE 0x01
|
|
|
|
u8 call_length; /* 1DE Phone #/CFI buff ln */
|
|
|
|
u8 call_length2; /* 1DF Upper byte (unused) */
|
|
|
|
u32 call_addr; /* 1E0-1E3 Phn #/CFI buff addr */
|
|
|
|
u16 timer_value; /* 1E4-1E5 general timer value */
|
|
|
|
u8 timer_command; /* 1E6 general timer cmd */
|
|
|
|
u8 dce_command; /* 1E7 dce command reg */
|
|
|
|
u8 dce_cmd_status; /* 1E8 dce command stat */
|
|
|
|
u8 x21_r1_ioff; /* 1E9 dce ready counter */
|
|
|
|
u8 x21_r0_ioff; /* 1EA dce not ready ctr */
|
|
|
|
u8 x21_ralt_ioff; /* 1EB dce CNR counter */
|
|
|
|
u8 x21_r1_ion; /* 1EC dce ready I on ctr */
|
|
|
|
u8 rsvd_ier; /* 1ED Rsvd for IER (if ne */
|
|
|
|
u8 ier; /* 1EE Interrupt Enable */
|
|
|
|
u8 isr; /* 1EF Input Signal Reg */
|
|
|
|
u8 osr; /* 1F0 Output Signal Reg */
|
|
|
|
u8 reset; /* 1F1 Reset/Reload Reg */
|
|
|
|
u8 disable; /* 1F2 Disable Reg */
|
|
|
|
u8 sync; /* 1F3 Sync Reg */
|
|
|
|
u8 error_stat; /* 1F4 Error Status */
|
|
|
|
u8 cable_id; /* 1F5 Cable ID */
|
|
|
|
u8 cs_length; /* 1F6 CS Load Length */
|
|
|
|
u8 mac_length; /* 1F7 Mac Load Length */
|
|
|
|
u32 cs_load_addr; /* 1F8-1FB Call Load PCI Addr */
|
|
|
|
u32 mac_load_addr; /* 1FC-1FF Mac Load PCI Addr */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* adapter defines and structures
|
|
|
|
*/
|
|
|
|
#define ICOM_CONTROL_START_A 0x00000008
|
|
|
|
#define ICOM_CONTROL_STOP_A 0x00000004
|
|
|
|
#define ICOM_CONTROL_START_B 0x00000002
|
|
|
|
#define ICOM_CONTROL_STOP_B 0x00000001
|
|
|
|
#define ICOM_CONTROL_START_C 0x00000008
|
|
|
|
#define ICOM_CONTROL_STOP_C 0x00000004
|
|
|
|
#define ICOM_CONTROL_START_D 0x00000002
|
|
|
|
#define ICOM_CONTROL_STOP_D 0x00000001
|
|
|
|
#define ICOM_IRAM_OFFSET 0x1000
|
|
|
|
#define ICOM_IRAM_SIZE 0x0C00
|
|
|
|
#define ICOM_DCE_IRAM_OFFSET 0x0A00
|
|
|
|
#define ICOM_CABLE_ID_VALID 0x01
|
|
|
|
#define ICOM_CABLE_ID_MASK 0xF0
|
|
|
|
#define ICOM_DISABLE 0x80
|
|
|
|
#define CMD_XMIT_RCV_ENABLE 0xC0
|
|
|
|
#define CMD_XMIT_ENABLE 0x40
|
|
|
|
#define CMD_RCV_DISABLE 0x00
|
|
|
|
#define CMD_RCV_ENABLE 0x80
|
|
|
|
#define CMD_RESTART 0x01
|
|
|
|
#define CMD_HOLD_XMIT 0x02
|
|
|
|
#define CMD_SND_BREAK 0x04
|
|
|
|
#define RS232_CABLE 0x06
|
|
|
|
#define V24_CABLE 0x0E
|
|
|
|
#define V35_CABLE 0x0C
|
|
|
|
#define V36_CABLE 0x02
|
|
|
|
#define NO_CABLE 0x00
|
|
|
|
#define START_DOWNLOAD 0x80
|
|
|
|
#define ICOM_INT_MASK_PRC_A 0x00003FFF
|
|
|
|
#define ICOM_INT_MASK_PRC_B 0x3FFF0000
|
|
|
|
#define ICOM_INT_MASK_PRC_C 0x00003FFF
|
|
|
|
#define ICOM_INT_MASK_PRC_D 0x3FFF0000
|
|
|
|
#define INT_RCV_COMPLETED 0x1000
|
|
|
|
#define INT_XMIT_COMPLETED 0x2000
|
|
|
|
#define INT_IDLE_DETECT 0x0800
|
|
|
|
#define INT_RCV_DISABLED 0x0400
|
|
|
|
#define INT_XMIT_DISABLED 0x0200
|
|
|
|
#define INT_RCV_XMIT_SHUTDOWN 0x0100
|
|
|
|
#define INT_FATAL_ERROR 0x0080
|
|
|
|
#define INT_CABLE_PULL 0x0020
|
|
|
|
#define INT_SIGNAL_CHANGE 0x0010
|
|
|
|
#define HDLC_PPP_PURE_ASYNC 0x02
|
|
|
|
#define HDLC_FF_FILL 0x00
|
|
|
|
#define HDLC_HDW_FLOW 0x01
|
|
|
|
#define START_XMIT 0x80
|
|
|
|
#define ICOM_ACFG_DRIVE1 0x20
|
|
|
|
#define ICOM_ACFG_NO_PARITY 0x00
|
|
|
|
#define ICOM_ACFG_PARITY_ENAB 0x02
|
|
|
|
#define ICOM_ACFG_PARITY_ODD 0x01
|
|
|
|
#define ICOM_ACFG_8BPC 0x00
|
|
|
|
#define ICOM_ACFG_7BPC 0x04
|
|
|
|
#define ICOM_ACFG_6BPC 0x08
|
|
|
|
#define ICOM_ACFG_5BPC 0x0C
|
|
|
|
#define ICOM_ACFG_1STOP_BIT 0x00
|
|
|
|
#define ICOM_ACFG_2STOP_BIT 0x10
|
|
|
|
#define ICOM_DTR 0x80
|
|
|
|
#define ICOM_RTS 0x40
|
|
|
|
#define ICOM_RI 0x08
|
|
|
|
#define ICOM_DSR 0x80
|
|
|
|
#define ICOM_DCD 0x20
|
|
|
|
#define ICOM_CTS 0x40
|
|
|
|
|
|
|
|
#define NUM_XBUFFS 1
|
|
|
|
#define NUM_RBUFFS 2
|
|
|
|
#define RCV_BUFF_SZ 0x0200
|
|
|
|
#define XMIT_BUFF_SZ 0x1000
|
|
|
|
struct statusArea {
|
|
|
|
/**********************************************/
|
|
|
|
/* Transmit Status Area */
|
|
|
|
/**********************************************/
|
|
|
|
struct xmit_status_area{
|
|
|
|
__le32 leNext; /* Next entry in Little Endian on Adapter */
|
|
|
|
__le32 leNextASD;
|
|
|
|
__le32 leBuffer; /* Buffer for entry in LE for Adapter */
|
|
|
|
__le16 leLengthASD;
|
|
|
|
__le16 leOffsetASD;
|
|
|
|
__le16 leLength; /* Length of data in segment */
|
|
|
|
__le16 flags;
|
|
|
|
#define SA_FLAGS_DONE 0x0080 /* Done with Segment */
|
|
|
|
#define SA_FLAGS_CONTINUED 0x8000 /* More Segments */
|
|
|
|
#define SA_FLAGS_IDLE 0x4000 /* Mark IDLE after frm */
|
|
|
|
#define SA_FLAGS_READY_TO_XMIT 0x0800
|
|
|
|
#define SA_FLAGS_STAT_MASK 0x007F
|
|
|
|
} xmit[NUM_XBUFFS];
|
|
|
|
|
|
|
|
/**********************************************/
|
|
|
|
/* Receive Status Area */
|
|
|
|
/**********************************************/
|
|
|
|
struct {
|
|
|
|
__le32 leNext; /* Next entry in Little Endian on Adapter */
|
|
|
|
__le32 leNextASD;
|
|
|
|
__le32 leBuffer; /* Buffer for entry in LE for Adapter */
|
|
|
|
__le16 WorkingLength; /* size of segment */
|
|
|
|
__le16 reserv01;
|
|
|
|
__le16 leLength; /* Length of data in segment */
|
|
|
|
__le16 flags;
|
|
|
|
#define SA_FL_RCV_DONE 0x0010 /* Data ready */
|
|
|
|
#define SA_FLAGS_OVERRUN 0x0040
|
|
|
|
#define SA_FLAGS_PARITY_ERROR 0x0080
|
|
|
|
#define SA_FLAGS_FRAME_ERROR 0x0001
|
|
|
|
#define SA_FLAGS_FRAME_TRUNC 0x0002
|
|
|
|
#define SA_FLAGS_BREAK_DET 0x0004 /* set conditionally by device driver, not hardware */
|
|
|
|
#define SA_FLAGS_RCV_MASK 0xFFE6
|
|
|
|
} rcv[NUM_RBUFFS];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct icom_adapter;
|
|
|
|
|
|
|
|
|
|
|
|
#define ICOM_MAJOR 243
|
|
|
|
#define ICOM_MINOR_START 0
|
|
|
|
|
|
|
|
struct icom_port {
|
|
|
|
struct uart_port uart_port;
|
|
|
|
unsigned char cable_id;
|
|
|
|
unsigned char read_status_mask;
|
|
|
|
unsigned char ignore_status_mask;
|
|
|
|
void __iomem * int_reg;
|
|
|
|
struct icom_regs __iomem *global_reg;
|
|
|
|
struct func_dram __iomem *dram;
|
|
|
|
int port;
|
|
|
|
struct statusArea *statStg;
|
|
|
|
dma_addr_t statStg_pci;
|
|
|
|
__le32 *xmitRestart;
|
|
|
|
dma_addr_t xmitRestart_pci;
|
|
|
|
unsigned char *xmit_buf;
|
|
|
|
dma_addr_t xmit_buf_pci;
|
|
|
|
unsigned char *recv_buf;
|
|
|
|
dma_addr_t recv_buf_pci;
|
|
|
|
int next_rcv;
|
|
|
|
int status;
|
|
|
|
#define ICOM_PORT_ACTIVE 1 /* Port exists. */
|
|
|
|
#define ICOM_PORT_OFF 0 /* Port does not exist. */
|
|
|
|
struct icom_adapter *adapter;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct icom_adapter {
|
|
|
|
void __iomem * base_addr;
|
|
|
|
unsigned long base_addr_pci;
|
|
|
|
struct pci_dev *pci_dev;
|
|
|
|
struct icom_port port_info[4];
|
|
|
|
int index;
|
|
|
|
int version;
|
|
|
|
#define ADAPTER_V1 0x0001
|
|
|
|
#define ADAPTER_V2 0x0002
|
|
|
|
u32 subsystem_id;
|
|
|
|
#define FOUR_PORT_MODEL 0x0252
|
|
|
|
#define V2_TWO_PORTS_RVX 0x021A
|
|
|
|
#define V2_ONE_PORT_RVX_ONE_PORT_IMBED_MDM 0x0251
|
|
|
|
int numb_ports;
|
|
|
|
struct list_head icom_adapter_entry;
|
|
|
|
struct kref kref;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* prototype */
|
|
|
|
extern void iCom_sercons_init(void);
|
|
|
|
|
|
|
|
struct lookup_proc_table {
|
|
|
|
u32 __iomem *global_control_reg;
|
|
|
|
unsigned long processor_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lookup_int_table {
|
|
|
|
u32 __iomem *global_int_mask;
|
|
|
|
unsigned long processor_id;
|
|
|
|
};
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
static inline struct icom_port *to_icom_port(struct uart_port *port)
|
|
|
|
{
|
|
|
|
return container_of(port, struct icom_port, uart_port);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static const struct pci_device_id icom_pci_table[] = {
|
|
|
|
{
|
2007-05-17 13:11:16 +08:00
|
|
|
.vendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1,
|
|
|
|
.subvendor = PCI_ANY_ID,
|
|
|
|
.subdevice = PCI_ANY_ID,
|
|
|
|
.driver_data = ADAPTER_V1,
|
|
|
|
},
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-05-17 13:11:16 +08:00
|
|
|
.vendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2,
|
|
|
|
.subvendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.subdevice = PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX,
|
|
|
|
.driver_data = ADAPTER_V2,
|
|
|
|
},
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-05-17 13:11:16 +08:00
|
|
|
.vendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2,
|
|
|
|
.subvendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.subdevice = PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM,
|
|
|
|
.driver_data = ADAPTER_V2,
|
|
|
|
},
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-05-17 13:11:16 +08:00
|
|
|
.vendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2,
|
|
|
|
.subvendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.subdevice = PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL,
|
|
|
|
.driver_data = ADAPTER_V2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.vendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.device = PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2,
|
|
|
|
.subvendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.subdevice = PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM_PCIE,
|
|
|
|
.driver_data = ADAPTER_V2,
|
|
|
|
},
|
2005-04-17 06:20:36 +08:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2013-08-08 16:34:03 +08:00
|
|
|
static struct lookup_proc_table start_proc[4] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{NULL, ICOM_CONTROL_START_A},
|
|
|
|
{NULL, ICOM_CONTROL_START_B},
|
|
|
|
{NULL, ICOM_CONTROL_START_C},
|
|
|
|
{NULL, ICOM_CONTROL_START_D}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-08-08 16:34:03 +08:00
|
|
|
static struct lookup_proc_table stop_proc[4] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{NULL, ICOM_CONTROL_STOP_A},
|
|
|
|
{NULL, ICOM_CONTROL_STOP_B},
|
|
|
|
{NULL, ICOM_CONTROL_STOP_C},
|
|
|
|
{NULL, ICOM_CONTROL_STOP_D}
|
|
|
|
};
|
|
|
|
|
2013-08-08 16:34:03 +08:00
|
|
|
static struct lookup_int_table int_mask_tbl[4] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{NULL, ICOM_INT_MASK_PRC_A},
|
|
|
|
{NULL, ICOM_INT_MASK_PRC_B},
|
|
|
|
{NULL, ICOM_INT_MASK_PRC_C},
|
|
|
|
{NULL, ICOM_INT_MASK_PRC_D},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, icom_pci_table);
|
|
|
|
|
|
|
|
static LIST_HEAD(icom_adapter_head);
|
|
|
|
|
|
|
|
/* spinlock for adapter initialization and changing adapter operations */
|
2020-12-23 22:14:38 +08:00
|
|
|
static DEFINE_SPINLOCK(icom_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifdef ICOM_TRACE
|
2009-06-11 20:20:09 +08:00
|
|
|
static inline void trace(struct icom_port *icom_port, char *trace_pt,
|
|
|
|
unsigned long trace_data)
|
|
|
|
{
|
|
|
|
dev_info(&icom_port->adapter->pci_dev->dev, ":%d:%s - %lx\n",
|
|
|
|
icom_port->port, trace_pt, trace_data);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
#else
|
|
|
|
static inline void trace(struct icom_port *icom_port, char *trace_pt, unsigned long trace_data) {};
|
|
|
|
#endif
|
2007-12-04 12:16:20 +08:00
|
|
|
static void icom_kref_release(struct kref *kref);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void free_port_memory(struct icom_port *icom_port)
|
|
|
|
{
|
|
|
|
struct pci_dev *dev = icom_port->adapter->pci_dev;
|
|
|
|
|
|
|
|
trace(icom_port, "RET_PORT_MEM", 0);
|
|
|
|
if (icom_port->recv_buf) {
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
dma_free_coherent(&dev->dev, 4096, icom_port->recv_buf,
|
|
|
|
icom_port->recv_buf_pci);
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port->recv_buf = NULL;
|
|
|
|
}
|
|
|
|
if (icom_port->xmit_buf) {
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
dma_free_coherent(&dev->dev, 4096, icom_port->xmit_buf,
|
|
|
|
icom_port->xmit_buf_pci);
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port->xmit_buf = NULL;
|
|
|
|
}
|
|
|
|
if (icom_port->statStg) {
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
dma_free_coherent(&dev->dev, 4096, icom_port->statStg,
|
|
|
|
icom_port->statStg_pci);
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port->statStg = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (icom_port->xmitRestart) {
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
dma_free_coherent(&dev->dev, 4096, icom_port->xmitRestart,
|
|
|
|
icom_port->xmitRestart_pci);
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port->xmitRestart = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-20 02:21:50 +08:00
|
|
|
static int get_port_memory(struct icom_port *icom_port)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int index;
|
|
|
|
unsigned long stgAddr;
|
|
|
|
unsigned long startStgAddr;
|
|
|
|
unsigned long offset;
|
|
|
|
struct pci_dev *dev = icom_port->adapter->pci_dev;
|
|
|
|
|
|
|
|
icom_port->xmit_buf =
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
dma_alloc_coherent(&dev->dev, 4096, &icom_port->xmit_buf_pci,
|
|
|
|
GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!icom_port->xmit_buf) {
|
|
|
|
dev_err(&dev->dev, "Can not allocate Transmit buffer\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
trace(icom_port, "GET_PORT_MEM",
|
|
|
|
(unsigned long) icom_port->xmit_buf);
|
|
|
|
|
|
|
|
icom_port->recv_buf =
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
dma_alloc_coherent(&dev->dev, 4096, &icom_port->recv_buf_pci,
|
|
|
|
GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!icom_port->recv_buf) {
|
|
|
|
dev_err(&dev->dev, "Can not allocate Receive buffer\n");
|
|
|
|
free_port_memory(icom_port);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
trace(icom_port, "GET_PORT_MEM",
|
|
|
|
(unsigned long) icom_port->recv_buf);
|
|
|
|
|
|
|
|
icom_port->statStg =
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
dma_alloc_coherent(&dev->dev, 4096, &icom_port->statStg_pci,
|
|
|
|
GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!icom_port->statStg) {
|
|
|
|
dev_err(&dev->dev, "Can not allocate Status buffer\n");
|
|
|
|
free_port_memory(icom_port);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
trace(icom_port, "GET_PORT_MEM",
|
|
|
|
(unsigned long) icom_port->statStg);
|
|
|
|
|
|
|
|
icom_port->xmitRestart =
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
dma_alloc_coherent(&dev->dev, 4096, &icom_port->xmitRestart_pci,
|
|
|
|
GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!icom_port->xmitRestart) {
|
|
|
|
dev_err(&dev->dev,
|
|
|
|
"Can not allocate xmit Restart buffer\n");
|
|
|
|
free_port_memory(icom_port);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FODs: Frame Out Descriptor Queue, this is a FIFO queue that
|
|
|
|
indicates that frames are to be transmitted
|
|
|
|
*/
|
|
|
|
|
|
|
|
stgAddr = (unsigned long) icom_port->statStg;
|
|
|
|
for (index = 0; index < NUM_XBUFFS; index++) {
|
|
|
|
trace(icom_port, "FOD_ADDR", stgAddr);
|
|
|
|
stgAddr = stgAddr + sizeof(icom_port->statStg->xmit[0]);
|
|
|
|
if (index < (NUM_XBUFFS - 1)) {
|
|
|
|
memset(&icom_port->statStg->xmit[index], 0, sizeof(struct xmit_status_area));
|
|
|
|
icom_port->statStg->xmit[index].leLengthASD =
|
2022-04-21 16:58:02 +08:00
|
|
|
cpu_to_le16(XMIT_BUFF_SZ);
|
2005-04-17 06:20:36 +08:00
|
|
|
trace(icom_port, "FOD_ADDR", stgAddr);
|
|
|
|
trace(icom_port, "FOD_XBUFF",
|
|
|
|
(unsigned long) icom_port->xmit_buf);
|
|
|
|
icom_port->statStg->xmit[index].leBuffer =
|
|
|
|
cpu_to_le32(icom_port->xmit_buf_pci);
|
|
|
|
} else if (index == (NUM_XBUFFS - 1)) {
|
|
|
|
memset(&icom_port->statStg->xmit[index], 0, sizeof(struct xmit_status_area));
|
|
|
|
icom_port->statStg->xmit[index].leLengthASD =
|
2022-04-21 16:58:02 +08:00
|
|
|
cpu_to_le16(XMIT_BUFF_SZ);
|
2005-04-17 06:20:36 +08:00
|
|
|
trace(icom_port, "FOD_XBUFF",
|
|
|
|
(unsigned long) icom_port->xmit_buf);
|
|
|
|
icom_port->statStg->xmit[index].leBuffer =
|
|
|
|
cpu_to_le32(icom_port->xmit_buf_pci);
|
|
|
|
} else {
|
|
|
|
memset(&icom_port->statStg->xmit[index], 0, sizeof(struct xmit_status_area));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* FIDs */
|
|
|
|
startStgAddr = stgAddr;
|
|
|
|
|
|
|
|
/* fill in every entry, even if no buffer */
|
|
|
|
for (index = 0; index < NUM_RBUFFS; index++) {
|
|
|
|
trace(icom_port, "FID_ADDR", stgAddr);
|
|
|
|
stgAddr = stgAddr + sizeof(icom_port->statStg->rcv[0]);
|
|
|
|
icom_port->statStg->rcv[index].leLength = 0;
|
|
|
|
icom_port->statStg->rcv[index].WorkingLength =
|
2022-04-21 16:58:02 +08:00
|
|
|
cpu_to_le16(RCV_BUFF_SZ);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (index < (NUM_RBUFFS - 1) ) {
|
|
|
|
offset = stgAddr - (unsigned long) icom_port->statStg;
|
|
|
|
icom_port->statStg->rcv[index].leNext =
|
|
|
|
cpu_to_le32(icom_port-> statStg_pci + offset);
|
|
|
|
trace(icom_port, "FID_RBUFF",
|
|
|
|
(unsigned long) icom_port->recv_buf);
|
|
|
|
icom_port->statStg->rcv[index].leBuffer =
|
|
|
|
cpu_to_le32(icom_port->recv_buf_pci);
|
|
|
|
} else if (index == (NUM_RBUFFS -1) ) {
|
|
|
|
offset = startStgAddr - (unsigned long) icom_port->statStg;
|
|
|
|
icom_port->statStg->rcv[index].leNext =
|
|
|
|
cpu_to_le32(icom_port-> statStg_pci + offset);
|
|
|
|
trace(icom_port, "FID_RBUFF",
|
|
|
|
(unsigned long) icom_port->recv_buf + 2048);
|
|
|
|
icom_port->statStg->rcv[index].leBuffer =
|
|
|
|
cpu_to_le32(icom_port->recv_buf_pci + 2048);
|
|
|
|
} else {
|
|
|
|
icom_port->statStg->rcv[index].leNext = 0;
|
|
|
|
icom_port->statStg->rcv[index].leBuffer = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stop_processor(struct icom_port *icom_port)
|
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
unsigned long flags;
|
|
|
|
int port;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&icom_lock, flags);
|
|
|
|
|
|
|
|
port = icom_port->port;
|
2013-08-26 23:10:01 +08:00
|
|
|
if (port >= ARRAY_SIZE(stop_proc)) {
|
|
|
|
dev_err(&icom_port->adapter->pci_dev->dev,
|
|
|
|
"Invalid port assignment\n");
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (port == 0 || port == 1)
|
|
|
|
stop_proc[port].global_control_reg = &icom_port->global_reg->control;
|
|
|
|
else
|
|
|
|
stop_proc[port].global_control_reg = &icom_port->global_reg->control_2;
|
|
|
|
|
2013-08-26 23:10:01 +08:00
|
|
|
temp = readl(stop_proc[port].global_control_reg);
|
|
|
|
temp = (temp & ~start_proc[port].processor_id) | stop_proc[port].processor_id;
|
|
|
|
writel(temp, stop_proc[port].global_control_reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-08-26 23:10:01 +08:00
|
|
|
/* write flush */
|
|
|
|
readl(stop_proc[port].global_control_reg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-08-26 23:10:01 +08:00
|
|
|
unlock:
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&icom_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void start_processor(struct icom_port *icom_port)
|
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
unsigned long flags;
|
|
|
|
int port;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&icom_lock, flags);
|
|
|
|
|
|
|
|
port = icom_port->port;
|
2013-08-26 23:10:01 +08:00
|
|
|
if (port >= ARRAY_SIZE(start_proc)) {
|
|
|
|
dev_err(&icom_port->adapter->pci_dev->dev,
|
|
|
|
"Invalid port assignment\n");
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (port == 0 || port == 1)
|
|
|
|
start_proc[port].global_control_reg = &icom_port->global_reg->control;
|
|
|
|
else
|
|
|
|
start_proc[port].global_control_reg = &icom_port->global_reg->control_2;
|
|
|
|
|
2013-08-26 23:10:01 +08:00
|
|
|
temp = readl(start_proc[port].global_control_reg);
|
|
|
|
temp = (temp & ~stop_proc[port].processor_id) | start_proc[port].processor_id;
|
|
|
|
writel(temp, start_proc[port].global_control_reg);
|
|
|
|
|
|
|
|
/* write flush */
|
|
|
|
readl(start_proc[port].global_control_reg);
|
|
|
|
|
|
|
|
unlock:
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&icom_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void load_code(struct icom_port *icom_port)
|
|
|
|
{
|
|
|
|
const struct firmware *fw;
|
|
|
|
char __iomem *iram_ptr;
|
|
|
|
int index;
|
|
|
|
int status = 0;
|
|
|
|
void __iomem *dram_ptr = icom_port->dram;
|
|
|
|
dma_addr_t temp_pci;
|
|
|
|
unsigned char *new_page = NULL;
|
|
|
|
unsigned char cable_id = NO_CABLE;
|
|
|
|
struct pci_dev *dev = icom_port->adapter->pci_dev;
|
|
|
|
|
|
|
|
/* Clear out any pending interrupts */
|
|
|
|
writew(0x3FFF, icom_port->int_reg);
|
|
|
|
|
|
|
|
trace(icom_port, "CLEAR_INTERRUPTS", 0);
|
|
|
|
|
|
|
|
/* Stop processor */
|
|
|
|
stop_processor(icom_port);
|
|
|
|
|
|
|
|
/* Zero out DRAM */
|
|
|
|
memset_io(dram_ptr, 0, 512);
|
|
|
|
|
|
|
|
/* Load Call Setup into Adapter */
|
|
|
|
if (request_firmware(&fw, "icom_call_setup.bin", &dev->dev) < 0) {
|
|
|
|
dev_err(&dev->dev,"Unable to load icom_call_setup.bin firmware image\n");
|
|
|
|
status = -1;
|
|
|
|
goto load_code_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fw->size > ICOM_DCE_IRAM_OFFSET) {
|
|
|
|
dev_err(&dev->dev, "Invalid firmware image for icom_call_setup.bin found.\n");
|
|
|
|
release_firmware(fw);
|
|
|
|
status = -1;
|
|
|
|
goto load_code_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
iram_ptr = (char __iomem *)icom_port->dram + ICOM_IRAM_OFFSET;
|
|
|
|
for (index = 0; index < fw->size; index++)
|
|
|
|
writeb(fw->data[index], &iram_ptr[index]);
|
|
|
|
|
|
|
|
release_firmware(fw);
|
|
|
|
|
|
|
|
/* Load Resident DCE portion of Adapter */
|
|
|
|
if (request_firmware(&fw, "icom_res_dce.bin", &dev->dev) < 0) {
|
|
|
|
dev_err(&dev->dev,"Unable to load icom_res_dce.bin firmware image\n");
|
|
|
|
status = -1;
|
|
|
|
goto load_code_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fw->size > ICOM_IRAM_SIZE) {
|
|
|
|
dev_err(&dev->dev, "Invalid firmware image for icom_res_dce.bin found.\n");
|
|
|
|
release_firmware(fw);
|
|
|
|
status = -1;
|
|
|
|
goto load_code_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
iram_ptr = (char __iomem *) icom_port->dram + ICOM_IRAM_OFFSET;
|
|
|
|
for (index = ICOM_DCE_IRAM_OFFSET; index < fw->size; index++)
|
|
|
|
writeb(fw->data[index], &iram_ptr[index]);
|
|
|
|
|
|
|
|
release_firmware(fw);
|
|
|
|
|
|
|
|
/* Set Hardware level */
|
2009-06-11 20:02:59 +08:00
|
|
|
if (icom_port->adapter->version == ADAPTER_V2)
|
2005-04-17 06:20:36 +08:00
|
|
|
writeb(V2_HARDWARE, &(icom_port->dram->misc_flags));
|
|
|
|
|
|
|
|
/* Start the processor in Adapter */
|
|
|
|
start_processor(icom_port);
|
|
|
|
|
|
|
|
writeb((HDLC_PPP_PURE_ASYNC | HDLC_FF_FILL),
|
|
|
|
&(icom_port->dram->HDLCConfigReg));
|
|
|
|
writeb(0x04, &(icom_port->dram->FlagFillIdleTimer)); /* 0.5 seconds */
|
|
|
|
writeb(0x00, &(icom_port->dram->CmdReg));
|
|
|
|
writeb(0x10, &(icom_port->dram->async_config3));
|
|
|
|
writeb((ICOM_ACFG_DRIVE1 | ICOM_ACFG_NO_PARITY | ICOM_ACFG_8BPC |
|
|
|
|
ICOM_ACFG_1STOP_BIT), &(icom_port->dram->async_config2));
|
|
|
|
|
|
|
|
/*Set up data in icom DRAM to indicate where personality
|
|
|
|
*code is located and its length.
|
|
|
|
*/
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
new_page = dma_alloc_coherent(&dev->dev, 4096, &temp_pci, GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (!new_page) {
|
|
|
|
dev_err(&dev->dev, "Can not allocate DMA buffer\n");
|
|
|
|
status = -1;
|
|
|
|
goto load_code_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (request_firmware(&fw, "icom_asc.bin", &dev->dev) < 0) {
|
|
|
|
dev_err(&dev->dev,"Unable to load icom_asc.bin firmware image\n");
|
|
|
|
status = -1;
|
|
|
|
goto load_code_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fw->size > ICOM_DCE_IRAM_OFFSET) {
|
|
|
|
dev_err(&dev->dev, "Invalid firmware image for icom_asc.bin found.\n");
|
|
|
|
release_firmware(fw);
|
|
|
|
status = -1;
|
|
|
|
goto load_code_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (index = 0; index < fw->size; index++)
|
|
|
|
new_page[index] = fw->data[index];
|
|
|
|
|
|
|
|
writeb((char) ((fw->size + 16)/16), &icom_port->dram->mac_length);
|
|
|
|
writel(temp_pci, &icom_port->dram->mac_load_addr);
|
|
|
|
|
2013-11-08 17:53:48 +08:00
|
|
|
release_firmware(fw);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*Setting the syncReg to 0x80 causes adapter to start downloading
|
|
|
|
the personality code into adapter instruction RAM.
|
|
|
|
Once code is loaded, it will begin executing and, based on
|
|
|
|
information provided above, will start DMAing data from
|
|
|
|
shared memory to adapter DRAM.
|
|
|
|
*/
|
|
|
|
/* the wait loop below verifies this write operation has been done
|
|
|
|
and processed
|
|
|
|
*/
|
|
|
|
writeb(START_DOWNLOAD, &icom_port->dram->sync);
|
|
|
|
|
|
|
|
/* Wait max 1 Sec for data download and processor to start */
|
|
|
|
for (index = 0; index < 10; index++) {
|
|
|
|
msleep(100);
|
|
|
|
if (readb(&icom_port->dram->misc_flags) & ICOM_HDW_ACTIVE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index == 10)
|
|
|
|
status = -1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check Cable ID
|
|
|
|
*/
|
|
|
|
cable_id = readb(&icom_port->dram->cable_id);
|
|
|
|
|
|
|
|
if (cable_id & ICOM_CABLE_ID_VALID) {
|
|
|
|
/* Get cable ID into the lower 4 bits (standard form) */
|
|
|
|
cable_id = (cable_id & ICOM_CABLE_ID_MASK) >> 4;
|
|
|
|
icom_port->cable_id = cable_id;
|
|
|
|
} else {
|
|
|
|
dev_err(&dev->dev,"Invalid or no cable attached\n");
|
|
|
|
icom_port->cable_id = NO_CABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
load_code_exit:
|
|
|
|
|
|
|
|
if (status != 0) {
|
|
|
|
/* Clear out any pending interrupts */
|
|
|
|
writew(0x3FFF, icom_port->int_reg);
|
|
|
|
|
|
|
|
/* Turn off port */
|
|
|
|
writeb(ICOM_DISABLE, &(icom_port->dram->disable));
|
|
|
|
|
|
|
|
/* Stop processor */
|
|
|
|
stop_processor(icom_port);
|
|
|
|
|
2012-10-24 22:29:41 +08:00
|
|
|
dev_err(&icom_port->adapter->pci_dev->dev,"Port not operational\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-10-02 06:44:23 +08:00
|
|
|
if (new_page != NULL)
|
tty: serial: icom: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'get_port_memory()', GFP_KERNEL can be used
because it is only called from a probe function and no lock is acquired.
The call chain is:
icom_probe (the probe function)
--> icom_load_ports
--> get_port_memory
When memory is allocated in 'load_code()', GFP_KERNEL can be used because
it is only called from a .startup function.
icom_open (the .startup function of struct uart_ops)
--> startup
--> load_code
.startup functions are protected using a semaphore and no spinlock is
taken.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20200806060507.730142-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-06 14:05:07 +08:00
|
|
|
dma_free_coherent(&dev->dev, 4096, new_page, temp_pci);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int startup(struct icom_port *icom_port)
|
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
unsigned char cable_id, raw_cable_id;
|
|
|
|
unsigned long flags;
|
|
|
|
int port;
|
|
|
|
|
|
|
|
trace(icom_port, "STARTUP", 0);
|
|
|
|
|
|
|
|
if (!icom_port->dram) {
|
|
|
|
/* should NEVER be NULL */
|
|
|
|
dev_err(&icom_port->adapter->pci_dev->dev,
|
|
|
|
"Unusable Port, port configuration missing\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check Cable ID
|
|
|
|
*/
|
|
|
|
raw_cable_id = readb(&icom_port->dram->cable_id);
|
|
|
|
trace(icom_port, "CABLE_ID", raw_cable_id);
|
|
|
|
|
|
|
|
/* Get cable ID into the lower 4 bits (standard form) */
|
|
|
|
cable_id = (raw_cable_id & ICOM_CABLE_ID_MASK) >> 4;
|
|
|
|
|
|
|
|
/* Check for valid Cable ID */
|
|
|
|
if (!(raw_cable_id & ICOM_CABLE_ID_VALID) ||
|
|
|
|
(cable_id != icom_port->cable_id)) {
|
|
|
|
|
|
|
|
/* reload adapter code, pick up any potential changes in cable id */
|
|
|
|
load_code(icom_port);
|
|
|
|
|
|
|
|
/* still no sign of cable, error out */
|
|
|
|
raw_cable_id = readb(&icom_port->dram->cable_id);
|
|
|
|
cable_id = (raw_cable_id & ICOM_CABLE_ID_MASK) >> 4;
|
|
|
|
if (!(raw_cable_id & ICOM_CABLE_ID_VALID) ||
|
|
|
|
(icom_port->cable_id == NO_CABLE))
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finally, clear and enable interrupts
|
|
|
|
*/
|
|
|
|
spin_lock_irqsave(&icom_lock, flags);
|
|
|
|
port = icom_port->port;
|
2013-08-26 23:10:01 +08:00
|
|
|
if (port >= ARRAY_SIZE(int_mask_tbl)) {
|
|
|
|
dev_err(&icom_port->adapter->pci_dev->dev,
|
|
|
|
"Invalid port assignment\n");
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (port == 0 || port == 1)
|
|
|
|
int_mask_tbl[port].global_int_mask = &icom_port->global_reg->int_mask;
|
|
|
|
else
|
|
|
|
int_mask_tbl[port].global_int_mask = &icom_port->global_reg->int_mask_2;
|
|
|
|
|
|
|
|
if (port == 0 || port == 2)
|
|
|
|
writew(0x00FF, icom_port->int_reg);
|
|
|
|
else
|
|
|
|
writew(0x3F00, icom_port->int_reg);
|
|
|
|
|
2013-08-26 23:10:01 +08:00
|
|
|
temp = readl(int_mask_tbl[port].global_int_mask);
|
|
|
|
writel(temp & ~int_mask_tbl[port].processor_id, int_mask_tbl[port].global_int_mask);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-08-26 23:10:01 +08:00
|
|
|
/* write flush */
|
|
|
|
readl(int_mask_tbl[port].global_int_mask);
|
|
|
|
|
|
|
|
unlock:
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&icom_lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shutdown(struct icom_port *icom_port)
|
|
|
|
{
|
|
|
|
unsigned long temp;
|
|
|
|
unsigned char cmdReg;
|
|
|
|
unsigned long flags;
|
|
|
|
int port;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&icom_lock, flags);
|
|
|
|
trace(icom_port, "SHUTDOWN", 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* disable all interrupts
|
|
|
|
*/
|
|
|
|
port = icom_port->port;
|
2013-08-26 23:10:01 +08:00
|
|
|
if (port >= ARRAY_SIZE(int_mask_tbl)) {
|
|
|
|
dev_err(&icom_port->adapter->pci_dev->dev,
|
|
|
|
"Invalid port assignment\n");
|
|
|
|
goto unlock;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
if (port == 0 || port == 1)
|
|
|
|
int_mask_tbl[port].global_int_mask = &icom_port->global_reg->int_mask;
|
|
|
|
else
|
|
|
|
int_mask_tbl[port].global_int_mask = &icom_port->global_reg->int_mask_2;
|
|
|
|
|
2013-08-26 23:10:01 +08:00
|
|
|
temp = readl(int_mask_tbl[port].global_int_mask);
|
|
|
|
writel(temp | int_mask_tbl[port].processor_id, int_mask_tbl[port].global_int_mask);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-08-26 23:10:01 +08:00
|
|
|
/* write flush */
|
|
|
|
readl(int_mask_tbl[port].global_int_mask);
|
|
|
|
|
|
|
|
unlock:
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&icom_lock, flags);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* disable break condition
|
|
|
|
*/
|
|
|
|
cmdReg = readb(&icom_port->dram->CmdReg);
|
2009-08-14 20:02:34 +08:00
|
|
|
if (cmdReg & CMD_SND_BREAK) {
|
2005-04-17 06:20:36 +08:00
|
|
|
writeb(cmdReg & ~CMD_SND_BREAK, &icom_port->dram->CmdReg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int icom_write(struct uart_port *port)
|
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long data_count;
|
|
|
|
unsigned char cmdReg;
|
|
|
|
unsigned long offset;
|
2009-09-20 04:13:28 +08:00
|
|
|
int temp_tail = port->state->xmit.tail;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "WRITE", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2022-04-21 16:58:02 +08:00
|
|
|
if (le16_to_cpu(icom_port->statStg->xmit[0].flags) &
|
2005-04-17 06:20:36 +08:00
|
|
|
SA_FLAGS_READY_TO_XMIT) {
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "WRITE_FULL", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
data_count = 0;
|
2009-09-20 04:13:28 +08:00
|
|
|
while ((port->state->xmit.head != temp_tail) &&
|
2005-04-17 06:20:36 +08:00
|
|
|
(data_count <= XMIT_BUFF_SZ)) {
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->xmit_buf[data_count++] =
|
2009-09-20 04:13:28 +08:00
|
|
|
port->state->xmit.buf[temp_tail];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
temp_tail++;
|
|
|
|
temp_tail &= (UART_XMIT_SIZE - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data_count) {
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->statStg->xmit[0].flags =
|
2005-04-17 06:20:36 +08:00
|
|
|
cpu_to_le16(SA_FLAGS_READY_TO_XMIT);
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->statStg->xmit[0].leLength =
|
2005-04-17 06:20:36 +08:00
|
|
|
cpu_to_le16(data_count);
|
|
|
|
offset =
|
2022-04-21 16:58:00 +08:00
|
|
|
(unsigned long) &icom_port->statStg->xmit[0] -
|
|
|
|
(unsigned long) icom_port->statStg;
|
|
|
|
*icom_port->xmitRestart =
|
|
|
|
cpu_to_le32(icom_port->statStg_pci + offset);
|
|
|
|
cmdReg = readb(&icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
writeb(cmdReg | CMD_XMIT_RCV_ENABLE,
|
2022-04-21 16:58:00 +08:00
|
|
|
&icom_port->dram->CmdReg);
|
|
|
|
writeb(START_XMIT, &icom_port->dram->StartXmitCmd);
|
|
|
|
trace(icom_port, "WRITE_START", data_count);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* write flush */
|
2022-04-21 16:58:00 +08:00
|
|
|
readb(&icom_port->dram->StartXmitCmd);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return data_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void check_modem_status(struct icom_port *icom_port)
|
|
|
|
{
|
|
|
|
static char old_status = 0;
|
|
|
|
char delta_status;
|
|
|
|
unsigned char status;
|
|
|
|
|
|
|
|
spin_lock(&icom_port->uart_port.lock);
|
|
|
|
|
|
|
|
/*modem input register */
|
|
|
|
status = readb(&icom_port->dram->isr);
|
|
|
|
trace(icom_port, "CHECK_MODEM", status);
|
|
|
|
delta_status = status ^ old_status;
|
|
|
|
if (delta_status) {
|
|
|
|
if (delta_status & ICOM_RI)
|
|
|
|
icom_port->uart_port.icount.rng++;
|
|
|
|
if (delta_status & ICOM_DSR)
|
|
|
|
icom_port->uart_port.icount.dsr++;
|
|
|
|
if (delta_status & ICOM_DCD)
|
|
|
|
uart_handle_dcd_change(&icom_port->uart_port,
|
|
|
|
delta_status & ICOM_DCD);
|
|
|
|
if (delta_status & ICOM_CTS)
|
|
|
|
uart_handle_cts_change(&icom_port->uart_port,
|
|
|
|
delta_status & ICOM_CTS);
|
|
|
|
|
2009-09-20 04:13:28 +08:00
|
|
|
wake_up_interruptible(&icom_port->uart_port.state->
|
2009-09-20 04:13:31 +08:00
|
|
|
port.delta_msr_wait);
|
2005-04-17 06:20:36 +08:00
|
|
|
old_status = status;
|
|
|
|
}
|
|
|
|
spin_unlock(&icom_port->uart_port.lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xmit_interrupt(u16 port_int_reg, struct icom_port *icom_port)
|
|
|
|
{
|
2022-04-21 16:58:02 +08:00
|
|
|
u16 count, i;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (port_int_reg & (INT_XMIT_COMPLETED)) {
|
|
|
|
trace(icom_port, "XMIT_COMPLETE", 0);
|
|
|
|
|
|
|
|
/* clear buffer in use bit */
|
|
|
|
icom_port->statStg->xmit[0].flags &=
|
|
|
|
cpu_to_le16(~SA_FLAGS_READY_TO_XMIT);
|
|
|
|
|
2022-04-21 16:58:02 +08:00
|
|
|
count = le16_to_cpu(icom_port->statStg->xmit[0].leLength);
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port->uart_port.icount.tx += count;
|
|
|
|
|
|
|
|
for (i=0; i<count &&
|
2009-09-20 04:13:28 +08:00
|
|
|
!uart_circ_empty(&icom_port->uart_port.state->xmit); i++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-09-20 04:13:28 +08:00
|
|
|
icom_port->uart_port.state->xmit.tail++;
|
|
|
|
icom_port->uart_port.state->xmit.tail &=
|
2005-04-17 06:20:36 +08:00
|
|
|
(UART_XMIT_SIZE - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!icom_write(&icom_port->uart_port))
|
|
|
|
/* activate write queue */
|
|
|
|
uart_write_wakeup(&icom_port->uart_port);
|
|
|
|
} else
|
|
|
|
trace(icom_port, "XMIT_DISABLED", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port)
|
|
|
|
{
|
|
|
|
short int count, rcv_buff;
|
2013-01-03 22:53:03 +08:00
|
|
|
struct tty_port *port = &icom_port->uart_port.state->port;
|
2022-04-21 16:58:02 +08:00
|
|
|
u16 status;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct uart_icount *icount;
|
|
|
|
unsigned long offset;
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
unsigned char flag;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
trace(icom_port, "RCV_COMPLETE", 0);
|
|
|
|
rcv_buff = icom_port->next_rcv;
|
|
|
|
|
2022-04-21 16:58:02 +08:00
|
|
|
status = le16_to_cpu(icom_port->statStg->rcv[rcv_buff].flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
while (status & SA_FL_RCV_DONE) {
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
int first = -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
trace(icom_port, "FID_STATUS", status);
|
2022-04-21 16:58:02 +08:00
|
|
|
count = le16_to_cpu(icom_port->statStg->rcv[rcv_buff].leLength);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
trace(icom_port, "RCV_COUNT", count);
|
|
|
|
|
|
|
|
trace(icom_port, "REAL_COUNT", count);
|
|
|
|
|
2022-04-21 16:58:02 +08:00
|
|
|
offset = le32_to_cpu(icom_port->statStg->rcv[rcv_buff].leBuffer) -
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port->recv_buf_pci;
|
|
|
|
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
/* Block copy all but the last byte as this may have status */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (count > 0) {
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
first = icom_port->recv_buf[offset];
|
2013-01-03 22:53:04 +08:00
|
|
|
tty_insert_flip_string(port, icom_port->recv_buf + offset, count - 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
icount = &icom_port->uart_port.icount;
|
|
|
|
icount->rx += count;
|
|
|
|
|
|
|
|
/* Break detect logic */
|
|
|
|
if ((status & SA_FLAGS_FRAME_ERROR)
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
&& first == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
status &= ~SA_FLAGS_FRAME_ERROR;
|
|
|
|
status |= SA_FLAGS_BREAK_DET;
|
|
|
|
trace(icom_port, "BREAK_DET", 0);
|
|
|
|
}
|
|
|
|
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
flag = TTY_NORMAL;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (status &
|
|
|
|
(SA_FLAGS_BREAK_DET | SA_FLAGS_PARITY_ERROR |
|
|
|
|
SA_FLAGS_FRAME_ERROR | SA_FLAGS_OVERRUN)) {
|
|
|
|
|
|
|
|
if (status & SA_FLAGS_BREAK_DET)
|
|
|
|
icount->brk++;
|
|
|
|
if (status & SA_FLAGS_PARITY_ERROR)
|
|
|
|
icount->parity++;
|
|
|
|
if (status & SA_FLAGS_FRAME_ERROR)
|
|
|
|
icount->frame++;
|
|
|
|
if (status & SA_FLAGS_OVERRUN)
|
|
|
|
icount->overrun++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now check to see if character should be
|
|
|
|
* ignored, and mask off conditions which
|
|
|
|
* should be ignored.
|
|
|
|
*/
|
|
|
|
if (status & icom_port->ignore_status_mask) {
|
|
|
|
trace(icom_port, "IGNORE_CHAR", 0);
|
|
|
|
goto ignore_char;
|
|
|
|
}
|
|
|
|
|
|
|
|
status &= icom_port->read_status_mask;
|
|
|
|
|
|
|
|
if (status & SA_FLAGS_BREAK_DET) {
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
flag = TTY_BREAK;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (status & SA_FLAGS_PARITY_ERROR) {
|
|
|
|
trace(icom_port, "PARITY_ERROR", 0);
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
flag = TTY_PARITY;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (status & SA_FLAGS_FRAME_ERROR)
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
flag = TTY_FRAME;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-01-03 22:53:03 +08:00
|
|
|
tty_insert_flip_char(port, *(icom_port->recv_buf + offset + count - 1), flag);
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
|
|
|
|
if (status & SA_FLAGS_OVERRUN)
|
|
|
|
/*
|
|
|
|
* Overrun is special, since it's
|
|
|
|
* reported immediately, and doesn't
|
|
|
|
* affect the current character
|
|
|
|
*/
|
2013-01-03 22:53:03 +08:00
|
|
|
tty_insert_flip_char(port, 0, TTY_OVERRUN);
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 12:54:13 +08:00
|
|
|
ignore_char:
|
|
|
|
icom_port->statStg->rcv[rcv_buff].flags = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port->statStg->rcv[rcv_buff].leLength = 0;
|
|
|
|
icom_port->statStg->rcv[rcv_buff].WorkingLength =
|
2022-04-21 16:58:02 +08:00
|
|
|
cpu_to_le16(RCV_BUFF_SZ);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
rcv_buff++;
|
|
|
|
if (rcv_buff == NUM_RBUFFS)
|
|
|
|
rcv_buff = 0;
|
|
|
|
|
2022-04-21 16:58:02 +08:00
|
|
|
status = le16_to_cpu(icom_port->statStg->rcv[rcv_buff].flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
icom_port->next_rcv = rcv_buff;
|
2013-08-19 22:44:13 +08:00
|
|
|
|
2013-01-03 22:53:06 +08:00
|
|
|
tty_flip_buffer_push(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void process_interrupt(u16 port_int_reg,
|
|
|
|
struct icom_port *icom_port)
|
|
|
|
{
|
|
|
|
|
|
|
|
spin_lock(&icom_port->uart_port.lock);
|
|
|
|
trace(icom_port, "INTERRUPT", port_int_reg);
|
|
|
|
|
|
|
|
if (port_int_reg & (INT_XMIT_COMPLETED | INT_XMIT_DISABLED))
|
|
|
|
xmit_interrupt(port_int_reg, icom_port);
|
|
|
|
|
|
|
|
if (port_int_reg & INT_RCV_COMPLETED)
|
|
|
|
recv_interrupt(port_int_reg, icom_port);
|
|
|
|
|
|
|
|
spin_unlock(&icom_port->uart_port.lock);
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static irqreturn_t icom_interrupt(int irq, void *dev_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
void __iomem * int_reg;
|
|
|
|
u32 adapter_interrupts;
|
|
|
|
u16 port_int_reg;
|
|
|
|
struct icom_adapter *icom_adapter;
|
|
|
|
struct icom_port *icom_port;
|
|
|
|
|
|
|
|
/* find icom_port for this interrupt */
|
|
|
|
icom_adapter = (struct icom_adapter *) dev_id;
|
|
|
|
|
2009-06-11 20:02:59 +08:00
|
|
|
if (icom_adapter->version == ADAPTER_V2) {
|
2005-04-17 06:20:36 +08:00
|
|
|
int_reg = icom_adapter->base_addr + 0x8024;
|
|
|
|
|
|
|
|
adapter_interrupts = readl(int_reg);
|
|
|
|
|
|
|
|
if (adapter_interrupts & 0x00003FFF) {
|
|
|
|
/* port 2 interrupt, NOTE: for all ADAPTER_V2, port 2 will be active */
|
|
|
|
icom_port = &icom_adapter->port_info[2];
|
|
|
|
port_int_reg = (u16) adapter_interrupts;
|
|
|
|
process_interrupt(port_int_reg, icom_port);
|
|
|
|
check_modem_status(icom_port);
|
|
|
|
}
|
|
|
|
if (adapter_interrupts & 0x3FFF0000) {
|
|
|
|
/* port 3 interrupt */
|
|
|
|
icom_port = &icom_adapter->port_info[3];
|
|
|
|
if (icom_port->status == ICOM_PORT_ACTIVE) {
|
|
|
|
port_int_reg =
|
|
|
|
(u16) (adapter_interrupts >> 16);
|
|
|
|
process_interrupt(port_int_reg, icom_port);
|
|
|
|
check_modem_status(icom_port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear out any pending interrupts */
|
|
|
|
writel(adapter_interrupts, int_reg);
|
|
|
|
|
|
|
|
int_reg = icom_adapter->base_addr + 0x8004;
|
|
|
|
} else {
|
|
|
|
int_reg = icom_adapter->base_addr + 0x4004;
|
|
|
|
}
|
|
|
|
|
|
|
|
adapter_interrupts = readl(int_reg);
|
|
|
|
|
|
|
|
if (adapter_interrupts & 0x00003FFF) {
|
|
|
|
/* port 0 interrupt, NOTE: for all adapters, port 0 will be active */
|
|
|
|
icom_port = &icom_adapter->port_info[0];
|
|
|
|
port_int_reg = (u16) adapter_interrupts;
|
|
|
|
process_interrupt(port_int_reg, icom_port);
|
|
|
|
check_modem_status(icom_port);
|
|
|
|
}
|
|
|
|
if (adapter_interrupts & 0x3FFF0000) {
|
|
|
|
/* port 1 interrupt */
|
|
|
|
icom_port = &icom_adapter->port_info[1];
|
|
|
|
if (icom_port->status == ICOM_PORT_ACTIVE) {
|
|
|
|
port_int_reg = (u16) (adapter_interrupts >> 16);
|
|
|
|
process_interrupt(port_int_reg, icom_port);
|
|
|
|
check_modem_status(icom_port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear out any pending interrupts */
|
|
|
|
writel(adapter_interrupts, int_reg);
|
|
|
|
|
|
|
|
/* flush the write */
|
|
|
|
adapter_interrupts = readl(int_reg);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ------------------------------------------------------------------
|
|
|
|
* Begin serial-core API
|
|
|
|
* ------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static unsigned int icom_tx_empty(struct uart_port *port)
|
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
int ret;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2022-04-21 16:58:02 +08:00
|
|
|
if (le16_to_cpu(icom_port->statStg->xmit[0].flags) &
|
2005-04-17 06:20:36 +08:00
|
|
|
SA_FLAGS_READY_TO_XMIT)
|
|
|
|
ret = TIOCSER_TEMT;
|
|
|
|
else
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void icom_set_mctrl(struct uart_port *port, unsigned int mctrl)
|
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned char local_osr;
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "SET_MODEM", 0);
|
|
|
|
local_osr = readb(&icom_port->dram->osr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (mctrl & TIOCM_RTS) {
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "RAISE_RTS", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
local_osr |= ICOM_RTS;
|
|
|
|
} else {
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "LOWER_RTS", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
local_osr &= ~ICOM_RTS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mctrl & TIOCM_DTR) {
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "RAISE_DTR", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
local_osr |= ICOM_DTR;
|
|
|
|
} else {
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "LOWER_DTR", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
local_osr &= ~ICOM_DTR;
|
|
|
|
}
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
writeb(local_osr, &icom_port->dram->osr);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int icom_get_mctrl(struct uart_port *port)
|
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned char status;
|
|
|
|
unsigned int result;
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "GET_MODEM", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
status = readb(&icom_port->dram->isr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
result = ((status & ICOM_DCD) ? TIOCM_CAR : 0)
|
|
|
|
| ((status & ICOM_RI) ? TIOCM_RNG : 0)
|
|
|
|
| ((status & ICOM_DSR) ? TIOCM_DSR : 0)
|
|
|
|
| ((status & ICOM_CTS) ? TIOCM_CTS : 0);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-08-31 17:12:14 +08:00
|
|
|
static void icom_stop_tx(struct uart_port *port)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned char cmdReg;
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "STOP", 0);
|
|
|
|
cmdReg = readb(&icom_port->dram->CmdReg);
|
|
|
|
writeb(cmdReg | CMD_HOLD_XMIT, &icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-08-31 17:12:14 +08:00
|
|
|
static void icom_start_tx(struct uart_port *port)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned char cmdReg;
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "START", 0);
|
|
|
|
cmdReg = readb(&icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
if ((cmdReg & CMD_HOLD_XMIT) == CMD_HOLD_XMIT)
|
|
|
|
writeb(cmdReg & ~CMD_HOLD_XMIT,
|
2022-04-21 16:58:00 +08:00
|
|
|
&icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
icom_write(port);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void icom_send_xchar(struct uart_port *port, char ch)
|
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned char xdata;
|
|
|
|
int index;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "SEND_XCHAR", ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* wait .1 sec to send char */
|
|
|
|
for (index = 0; index < 10; index++) {
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2022-04-21 16:58:00 +08:00
|
|
|
xdata = readb(&icom_port->dram->xchar);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (xdata == 0x00) {
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "QUICK_WRITE", 0);
|
|
|
|
writeb(ch, &icom_port->dram->xchar);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* flush write operation */
|
2022-04-21 16:58:00 +08:00
|
|
|
xdata = readb(&icom_port->dram->xchar);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
msleep(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void icom_stop_rx(struct uart_port *port)
|
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned char cmdReg;
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
cmdReg = readb(&icom_port->dram->CmdReg);
|
|
|
|
writeb(cmdReg & ~CMD_RCV_ENABLE, &icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void icom_break(struct uart_port *port, int break_state)
|
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned char cmdReg;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "BREAK", 0);
|
|
|
|
cmdReg = readb(&icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (break_state == -1) {
|
2022-04-21 16:58:00 +08:00
|
|
|
writeb(cmdReg | CMD_SND_BREAK, &icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2022-04-21 16:58:00 +08:00
|
|
|
writeb(cmdReg & ~CMD_SND_BREAK, &icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int icom_open(struct uart_port *port)
|
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
int retval;
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
kref_get(&icom_port->adapter->kref);
|
|
|
|
retval = startup(icom_port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (retval) {
|
2022-04-21 16:58:00 +08:00
|
|
|
kref_put(&icom_port->adapter->kref, icom_kref_release);
|
|
|
|
trace(icom_port, "STARTUP_ERROR", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void icom_close(struct uart_port *port)
|
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned char cmdReg;
|
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "CLOSE", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* stop receiver */
|
2022-04-21 16:58:00 +08:00
|
|
|
cmdReg = readb(&icom_port->dram->CmdReg);
|
|
|
|
writeb(cmdReg & ~CMD_RCV_ENABLE, &icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
shutdown(icom_port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2022-04-21 16:58:00 +08:00
|
|
|
kref_put(&icom_port->adapter->kref, icom_kref_release);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2022-08-16 19:57:37 +08:00
|
|
|
static void icom_set_termios(struct uart_port *port, struct ktermios *termios,
|
|
|
|
const struct ktermios *old_termios)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2022-04-21 16:58:00 +08:00
|
|
|
struct icom_port *icom_port = to_icom_port(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
int baud;
|
|
|
|
unsigned cflag, iflag;
|
|
|
|
char new_config2;
|
|
|
|
char new_config3 = 0;
|
|
|
|
char tmp_byte;
|
|
|
|
int index;
|
|
|
|
int rcv_buff, xmit_buff;
|
|
|
|
unsigned long offset;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "CHANGE_SPEED", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
cflag = termios->c_cflag;
|
|
|
|
iflag = termios->c_iflag;
|
|
|
|
|
|
|
|
new_config2 = ICOM_ACFG_DRIVE1;
|
|
|
|
|
|
|
|
/* byte size and parity */
|
|
|
|
switch (cflag & CSIZE) {
|
|
|
|
case CS5: /* 5 bits/char */
|
|
|
|
new_config2 |= ICOM_ACFG_5BPC;
|
|
|
|
break;
|
|
|
|
case CS6: /* 6 bits/char */
|
|
|
|
new_config2 |= ICOM_ACFG_6BPC;
|
|
|
|
break;
|
|
|
|
case CS7: /* 7 bits/char */
|
|
|
|
new_config2 |= ICOM_ACFG_7BPC;
|
|
|
|
break;
|
|
|
|
case CS8: /* 8 bits/char */
|
|
|
|
new_config2 |= ICOM_ACFG_8BPC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (cflag & CSTOPB) {
|
|
|
|
/* 2 stop bits */
|
|
|
|
new_config2 |= ICOM_ACFG_2STOP_BIT;
|
|
|
|
}
|
|
|
|
if (cflag & PARENB) {
|
|
|
|
/* parity bit enabled */
|
|
|
|
new_config2 |= ICOM_ACFG_PARITY_ENAB;
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "PARENB", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (cflag & PARODD) {
|
|
|
|
/* odd parity */
|
|
|
|
new_config2 |= ICOM_ACFG_PARITY_ODD;
|
2022-04-21 16:58:00 +08:00
|
|
|
trace(icom_port, "PARODD", 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine divisor based on baud rate */
|
|
|
|
baud = uart_get_baud_rate(port, termios, old_termios,
|
|
|
|
icom_acfg_baud[0],
|
|
|
|
icom_acfg_baud[BAUD_TABLE_LIMIT]);
|
|
|
|
if (!baud)
|
|
|
|
baud = 9600; /* B0 transition handled in rs_set_termios */
|
|
|
|
|
|
|
|
for (index = 0; index < BAUD_TABLE_LIMIT; index++) {
|
|
|
|
if (icom_acfg_baud[index] == baud) {
|
|
|
|
new_config3 = index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uart_update_timeout(port, cflag, baud);
|
|
|
|
|
|
|
|
/* CTS flow control flag and modem status interrupts */
|
2022-04-21 16:58:00 +08:00
|
|
|
tmp_byte = readb(&(icom_port->dram->HDLCConfigReg));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (cflag & CRTSCTS)
|
|
|
|
tmp_byte |= HDLC_HDW_FLOW;
|
|
|
|
else
|
|
|
|
tmp_byte &= ~HDLC_HDW_FLOW;
|
2022-04-21 16:58:00 +08:00
|
|
|
writeb(tmp_byte, &(icom_port->dram->HDLCConfigReg));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up parity check flag
|
|
|
|
*/
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->read_status_mask = SA_FLAGS_OVERRUN | SA_FL_RCV_DONE;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (iflag & INPCK)
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->read_status_mask |=
|
2005-04-17 06:20:36 +08:00
|
|
|
SA_FLAGS_FRAME_ERROR | SA_FLAGS_PARITY_ERROR;
|
|
|
|
|
|
|
|
if ((iflag & BRKINT) || (iflag & PARMRK))
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->read_status_mask |= SA_FLAGS_BREAK_DET;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Characters to ignore
|
|
|
|
*/
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->ignore_status_mask = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (iflag & IGNPAR)
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->ignore_status_mask |=
|
2005-04-17 06:20:36 +08:00
|
|
|
SA_FLAGS_PARITY_ERROR | SA_FLAGS_FRAME_ERROR;
|
|
|
|
if (iflag & IGNBRK) {
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->ignore_status_mask |= SA_FLAGS_BREAK_DET;
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* If we're ignore parity and break indicators, ignore
|
|
|
|
* overruns too. (For real raw support).
|
|
|
|
*/
|
|
|
|
if (iflag & IGNPAR)
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->ignore_status_mask |= SA_FLAGS_OVERRUN;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* !!! ignore all characters if CREAD is not set
|
|
|
|
*/
|
|
|
|
if ((cflag & CREAD) == 0)
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->ignore_status_mask |= SA_FL_RCV_DONE;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Turn off Receiver to prepare for reset */
|
2022-04-21 16:58:00 +08:00
|
|
|
writeb(CMD_RCV_DISABLE, &icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (index = 0; index < 10; index++) {
|
2022-04-21 16:58:00 +08:00
|
|
|
if (readb(&icom_port->dram->PrevCmdReg) == 0x00) {
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear all current buffers of data */
|
|
|
|
for (rcv_buff = 0; rcv_buff < NUM_RBUFFS; rcv_buff++) {
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->statStg->rcv[rcv_buff].flags = 0;
|
|
|
|
icom_port->statStg->rcv[rcv_buff].leLength = 0;
|
|
|
|
icom_port->statStg->rcv[rcv_buff].WorkingLength =
|
2022-04-21 16:58:02 +08:00
|
|
|
cpu_to_le16(RCV_BUFF_SZ);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (xmit_buff = 0; xmit_buff < NUM_XBUFFS; xmit_buff++) {
|
2022-04-21 16:58:00 +08:00
|
|
|
icom_port->statStg->xmit[xmit_buff].flags = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* activate changes and start xmit and receiver here */
|
|
|
|
/* Enable the receiver */
|
2022-04-21 16:58:00 +08:00
|
|
|
writeb(new_config3, &(icom_port->dram->async_config3));
|
|
|
|
writeb(new_config2, &(icom_port->dram->async_config2));
|
|
|
|
tmp_byte = readb(&(icom_port->dram->HDLCConfigReg));
|
2005-04-17 06:20:36 +08:00
|
|
|
tmp_byte |= HDLC_PPP_PURE_ASYNC | HDLC_FF_FILL;
|
2022-04-21 16:58:00 +08:00
|
|
|
writeb(tmp_byte, &(icom_port->dram->HDLCConfigReg));
|
|
|
|
writeb(0x04, &(icom_port->dram->FlagFillIdleTimer)); /* 0.5 seconds */
|
|
|
|
writeb(0xFF, &(icom_port->dram->ier)); /* enable modem signal interrupts */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* reset processor */
|
2022-04-21 16:58:00 +08:00
|
|
|
writeb(CMD_RESTART, &icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (index = 0; index < 10; index++) {
|
2022-04-21 16:58:00 +08:00
|
|
|
if (readb(&icom_port->dram->CmdReg) == 0x00) {
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-31 09:57:33 +08:00
|
|
|
/* Enable Transmitter and Receiver */
|
2005-04-17 06:20:36 +08:00
|
|
|
offset =
|
2022-04-21 16:58:00 +08:00
|
|
|
(unsigned long) &icom_port->statStg->rcv[0] -
|
|
|
|
(unsigned long) icom_port->statStg;
|
|
|
|
writel(icom_port->statStg_pci + offset,
|
|
|
|
&icom_port->dram->RcvStatusAddr);
|
|
|
|
icom_port->next_rcv = 0;
|
|
|
|
*icom_port->xmitRestart = 0;
|
|
|
|
writel(icom_port->xmitRestart_pci,
|
|
|
|
&icom_port->dram->XmitStatusAddr);
|
|
|
|
trace(icom_port, "XR_ENAB", 0);
|
|
|
|
writeb(CMD_XMIT_RCV_ENABLE, &icom_port->dram->CmdReg);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *icom_type(struct uart_port *port)
|
|
|
|
{
|
|
|
|
return "icom";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void icom_config_port(struct uart_port *port, int flags)
|
|
|
|
{
|
|
|
|
port->type = PORT_ICOM;
|
|
|
|
}
|
|
|
|
|
2017-01-26 01:48:52 +08:00
|
|
|
static const struct uart_ops icom_ops = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.tx_empty = icom_tx_empty,
|
|
|
|
.set_mctrl = icom_set_mctrl,
|
|
|
|
.get_mctrl = icom_get_mctrl,
|
|
|
|
.stop_tx = icom_stop_tx,
|
|
|
|
.start_tx = icom_start_tx,
|
|
|
|
.send_xchar = icom_send_xchar,
|
|
|
|
.stop_rx = icom_stop_rx,
|
|
|
|
.break_ctl = icom_break,
|
|
|
|
.startup = icom_open,
|
|
|
|
.shutdown = icom_close,
|
|
|
|
.set_termios = icom_set_termios,
|
|
|
|
.type = icom_type,
|
|
|
|
.config_port = icom_config_port,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ICOM_CONSOLE NULL
|
|
|
|
|
|
|
|
static struct uart_driver icom_uart_driver = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.driver_name = ICOM_DRIVER_NAME,
|
|
|
|
.dev_name = "ttyA",
|
|
|
|
.major = ICOM_MAJOR,
|
|
|
|
.minor = ICOM_MINOR_START,
|
|
|
|
.nr = NR_PORTS,
|
|
|
|
.cons = ICOM_CONSOLE,
|
|
|
|
};
|
|
|
|
|
2012-11-20 02:21:50 +08:00
|
|
|
static int icom_init_ports(struct icom_adapter *icom_adapter)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
u32 subsystem_id = icom_adapter->subsystem_id;
|
|
|
|
int i;
|
|
|
|
struct icom_port *icom_port;
|
|
|
|
|
|
|
|
if (icom_adapter->version == ADAPTER_V1) {
|
|
|
|
icom_adapter->numb_ports = 2;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
icom_port = &icom_adapter->port_info[i];
|
|
|
|
icom_port->port = i;
|
|
|
|
icom_port->status = ICOM_PORT_ACTIVE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (subsystem_id == PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL) {
|
|
|
|
icom_adapter->numb_ports = 4;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
icom_port = &icom_adapter->port_info[i];
|
|
|
|
|
|
|
|
icom_port->port = i;
|
|
|
|
icom_port->status = ICOM_PORT_ACTIVE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
icom_adapter->numb_ports = 4;
|
|
|
|
|
|
|
|
icom_adapter->port_info[0].port = 0;
|
|
|
|
icom_adapter->port_info[0].status = ICOM_PORT_ACTIVE;
|
|
|
|
icom_adapter->port_info[1].status = ICOM_PORT_OFF;
|
|
|
|
icom_adapter->port_info[2].port = 2;
|
|
|
|
icom_adapter->port_info[2].status = ICOM_PORT_ACTIVE;
|
|
|
|
icom_adapter->port_info[3].status = ICOM_PORT_OFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:34:53 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void icom_port_active(struct icom_port *icom_port, struct icom_adapter *icom_adapter, int port_num)
|
|
|
|
{
|
|
|
|
if (icom_adapter->version == ADAPTER_V1) {
|
|
|
|
icom_port->global_reg = icom_adapter->base_addr + 0x4000;
|
|
|
|
icom_port->int_reg = icom_adapter->base_addr +
|
|
|
|
0x4004 + 2 - 2 * port_num;
|
|
|
|
} else {
|
|
|
|
icom_port->global_reg = icom_adapter->base_addr + 0x8000;
|
|
|
|
if (icom_port->port < 2)
|
|
|
|
icom_port->int_reg = icom_adapter->base_addr +
|
|
|
|
0x8004 + 2 - 2 * icom_port->port;
|
|
|
|
else
|
|
|
|
icom_port->int_reg = icom_adapter->base_addr +
|
|
|
|
0x8024 + 2 - 2 * (icom_port->port - 2);
|
|
|
|
}
|
|
|
|
}
|
2012-11-20 02:21:50 +08:00
|
|
|
static int icom_load_ports(struct icom_adapter *icom_adapter)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct icom_port *icom_port;
|
|
|
|
int port_num;
|
|
|
|
|
|
|
|
for (port_num = 0; port_num < icom_adapter->numb_ports; port_num++) {
|
|
|
|
|
|
|
|
icom_port = &icom_adapter->port_info[port_num];
|
|
|
|
|
|
|
|
if (icom_port->status == ICOM_PORT_ACTIVE) {
|
|
|
|
icom_port_active(icom_port, icom_adapter, port_num);
|
|
|
|
icom_port->dram = icom_adapter->base_addr +
|
|
|
|
0x2000 * icom_port->port;
|
|
|
|
|
|
|
|
icom_port->adapter = icom_adapter;
|
|
|
|
|
|
|
|
/* get port memory */
|
2009-04-07 00:34:53 +08:00
|
|
|
if (get_port_memory(icom_port) != 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dev_err(&icom_port->adapter->pci_dev->dev,
|
|
|
|
"Memory allocation for port FAILED\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-20 02:21:50 +08:00
|
|
|
static int icom_alloc_adapter(struct icom_adapter
|
2005-04-17 06:20:36 +08:00
|
|
|
**icom_adapter_ref)
|
|
|
|
{
|
|
|
|
int adapter_count = 0;
|
|
|
|
struct icom_adapter *icom_adapter;
|
|
|
|
struct icom_adapter *cur_adapter_entry;
|
|
|
|
|
2013-03-12 13:27:29 +08:00
|
|
|
icom_adapter = kzalloc(sizeof(struct icom_adapter), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (!icom_adapter) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-04-21 16:58:06 +08:00
|
|
|
list_for_each_entry(cur_adapter_entry, &icom_adapter_head,
|
|
|
|
icom_adapter_entry) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (cur_adapter_entry->index != adapter_count) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
adapter_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
icom_adapter->index = adapter_count;
|
2022-04-21 16:58:06 +08:00
|
|
|
list_add_tail(&icom_adapter->icom_adapter_entry,
|
|
|
|
&cur_adapter_entry->icom_adapter_entry);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
*icom_adapter_ref = icom_adapter;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void icom_free_adapter(struct icom_adapter *icom_adapter)
|
|
|
|
{
|
|
|
|
list_del(&icom_adapter->icom_adapter_entry);
|
|
|
|
kfree(icom_adapter);
|
|
|
|
}
|
|
|
|
|
2022-04-21 16:58:01 +08:00
|
|
|
static void icom_kref_release(struct kref *kref)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2022-04-21 16:58:01 +08:00
|
|
|
struct icom_adapter *icom_adapter = container_of(kref,
|
|
|
|
struct icom_adapter, kref);
|
2005-04-17 06:20:36 +08:00
|
|
|
struct icom_port *icom_port;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
for (index = 0; index < icom_adapter->numb_ports; index++) {
|
|
|
|
icom_port = &icom_adapter->port_info[index];
|
|
|
|
|
|
|
|
if (icom_port->status == ICOM_PORT_ACTIVE) {
|
|
|
|
dev_info(&icom_adapter->pci_dev->dev,
|
|
|
|
"Device removed\n");
|
|
|
|
|
|
|
|
uart_remove_one_port(&icom_uart_driver,
|
|
|
|
&icom_port->uart_port);
|
|
|
|
|
|
|
|
/* be sure that DTR and RTS are dropped */
|
|
|
|
writeb(0x00, &icom_port->dram->osr);
|
|
|
|
|
|
|
|
/* Wait 0.1 Sec for simple Init to complete */
|
|
|
|
msleep(100);
|
|
|
|
|
|
|
|
/* Stop proccessor */
|
|
|
|
stop_processor(icom_port);
|
|
|
|
|
|
|
|
free_port_memory(icom_port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-24 05:41:15 +08:00
|
|
|
free_irq(icom_adapter->pci_dev->irq, (void *) icom_adapter);
|
2005-04-17 06:20:36 +08:00
|
|
|
iounmap(icom_adapter->base_addr);
|
|
|
|
pci_release_regions(icom_adapter->pci_dev);
|
2009-05-23 08:30:39 +08:00
|
|
|
icom_free_adapter(icom_adapter);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-11-20 02:21:50 +08:00
|
|
|
static int icom_probe(struct pci_dev *dev,
|
2005-04-17 06:20:36 +08:00
|
|
|
const struct pci_device_id *ent)
|
|
|
|
{
|
|
|
|
int index;
|
2009-10-02 06:44:23 +08:00
|
|
|
unsigned int command_reg;
|
|
|
|
int retval;
|
|
|
|
struct icom_adapter *icom_adapter;
|
|
|
|
struct icom_port *icom_port;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-10-02 06:44:23 +08:00
|
|
|
retval = pci_enable_device(dev);
|
|
|
|
if (retval) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dev_err(&dev->dev, "Device enable FAILED\n");
|
2009-10-02 06:44:23 +08:00
|
|
|
return retval;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2015-04-30 17:22:10 +08:00
|
|
|
retval = pci_request_regions(dev, "icom");
|
|
|
|
if (retval) {
|
2006-12-13 02:20:35 +08:00
|
|
|
dev_err(&dev->dev, "pci_request_regions FAILED\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_disable_device(dev);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2009-10-02 06:44:23 +08:00
|
|
|
pci_set_master(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-04-30 17:22:10 +08:00
|
|
|
retval = pci_read_config_dword(dev, PCI_COMMAND, &command_reg);
|
|
|
|
if (retval) {
|
2005-04-17 06:20:36 +08:00
|
|
|
dev_err(&dev->dev, "PCI Config read FAILED\n");
|
2022-03-31 17:10:05 +08:00
|
|
|
goto probe_exit0;
|
2009-10-02 06:44:23 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
pci_write_config_dword(dev, PCI_COMMAND,
|
|
|
|
command_reg | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
|
|
|
|
| PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
|
|
|
|
|
2009-10-02 06:44:23 +08:00
|
|
|
if (ent->driver_data == ADAPTER_V1) {
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_write_config_dword(dev, 0x44, 0x8300830A);
|
2009-10-02 06:44:23 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_write_config_dword(dev, 0x44, 0x42004200);
|
|
|
|
pci_write_config_dword(dev, 0x48, 0x42004200);
|
2009-10-02 06:44:23 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
retval = icom_alloc_adapter(&icom_adapter);
|
|
|
|
if (retval) {
|
|
|
|
dev_err(&dev->dev, "icom_alloc_adapter FAILED\n");
|
|
|
|
retval = -EIO;
|
|
|
|
goto probe_exit0;
|
|
|
|
}
|
|
|
|
|
2009-10-02 06:44:23 +08:00
|
|
|
icom_adapter->base_addr_pci = pci_resource_start(dev, 0);
|
|
|
|
icom_adapter->pci_dev = dev;
|
|
|
|
icom_adapter->version = ent->driver_data;
|
|
|
|
icom_adapter->subsystem_id = ent->subdevice;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
retval = icom_init_ports(icom_adapter);
|
|
|
|
if (retval) {
|
|
|
|
dev_err(&dev->dev, "Port configuration failed\n");
|
|
|
|
goto probe_exit1;
|
|
|
|
}
|
|
|
|
|
2009-10-02 06:44:23 +08:00
|
|
|
icom_adapter->base_addr = pci_ioremap_bar(dev, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-11-21 01:33:59 +08:00
|
|
|
if (!icom_adapter->base_addr) {
|
|
|
|
retval = -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
goto probe_exit1;
|
2014-11-21 01:33:59 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* save off irq and request irq line */
|
2015-04-30 17:22:10 +08:00
|
|
|
retval = request_irq(dev->irq, icom_interrupt, IRQF_SHARED, ICOM_DRIVER_NAME, (void *)icom_adapter);
|
|
|
|
if (retval) {
|
2005-04-17 06:20:36 +08:00
|
|
|
goto probe_exit2;
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = icom_load_ports(icom_adapter);
|
|
|
|
|
2009-10-02 06:44:23 +08:00
|
|
|
for (index = 0; index < icom_adapter->numb_ports; index++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port = &icom_adapter->port_info[index];
|
|
|
|
|
|
|
|
if (icom_port->status == ICOM_PORT_ACTIVE) {
|
2007-04-24 05:41:15 +08:00
|
|
|
icom_port->uart_port.irq = icom_port->adapter->pci_dev->irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port->uart_port.type = PORT_ICOM;
|
|
|
|
icom_port->uart_port.iotype = UPIO_MEM;
|
|
|
|
icom_port->uart_port.membase =
|
2013-08-08 16:34:03 +08:00
|
|
|
(unsigned char __iomem *)icom_adapter->base_addr_pci;
|
2005-04-17 06:20:36 +08:00
|
|
|
icom_port->uart_port.fifosize = 16;
|
|
|
|
icom_port->uart_port.ops = &icom_ops;
|
|
|
|
icom_port->uart_port.line =
|
|
|
|
icom_port->port + icom_adapter->index * 4;
|
|
|
|
if (uart_add_one_port (&icom_uart_driver, &icom_port->uart_port)) {
|
|
|
|
icom_port->status = ICOM_PORT_OFF;
|
|
|
|
dev_err(&dev->dev, "Device add failed\n");
|
|
|
|
} else
|
2009-10-02 06:44:23 +08:00
|
|
|
dev_info(&dev->dev, "Device added\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-04 12:16:20 +08:00
|
|
|
kref_init(&icom_adapter->kref);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
probe_exit2:
|
|
|
|
iounmap(icom_adapter->base_addr);
|
|
|
|
probe_exit1:
|
|
|
|
icom_free_adapter(icom_adapter);
|
|
|
|
|
|
|
|
probe_exit0:
|
|
|
|
pci_release_regions(dev);
|
|
|
|
pci_disable_device(dev);
|
|
|
|
|
2009-10-02 06:44:23 +08:00
|
|
|
return retval;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-11-20 02:26:18 +08:00
|
|
|
static void icom_remove(struct pci_dev *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct icom_adapter *icom_adapter;
|
|
|
|
|
2022-04-21 16:58:06 +08:00
|
|
|
list_for_each_entry(icom_adapter, &icom_adapter_head,
|
|
|
|
icom_adapter_entry) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (icom_adapter->pci_dev == dev) {
|
2007-12-04 12:16:20 +08:00
|
|
|
kref_put(&icom_adapter->kref, icom_kref_release);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_err(&dev->dev, "Unable to find device to remove\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pci_driver icom_pci_driver = {
|
|
|
|
.name = ICOM_DRIVER_NAME,
|
|
|
|
.id_table = icom_pci_table,
|
|
|
|
.probe = icom_probe,
|
2012-11-20 02:21:34 +08:00
|
|
|
.remove = icom_remove,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init icom_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uart_register_driver(&icom_uart_driver);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = pci_register_driver(&icom_pci_driver);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
uart_unregister_driver(&icom_uart_driver);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit icom_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&icom_pci_driver);
|
|
|
|
uart_unregister_driver(&icom_uart_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(icom_init);
|
|
|
|
module_exit(icom_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Michael Anderson <mjanders@us.ibm.com>");
|
|
|
|
MODULE_DESCRIPTION("IBM iSeries Serial IOA driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
2010-01-14 07:34:18 +08:00
|
|
|
MODULE_FIRMWARE("icom_call_setup.bin");
|
|
|
|
MODULE_FIRMWARE("icom_res_dce.bin");
|
|
|
|
MODULE_FIRMWARE("icom_asc.bin");
|