gpib: Add support for ines pci_xl board
Subsystems (2)
Dave Penkler
maintainercover gpib: Add support for ines pci_xl board
INES have 2 pci boards that both have the same vendor and device ID [16da:0011]. The older board is based on the 72010 chip that has a number of extended registers that are missing in the 72130 based board. This caused random error messages when the 72130 based board was being used. The one extended register in the 72130 chip is the bus status register which is at a different offset and has a different layout.
The proprietary ines driver uses some undocumented heuristics to determine which board is being used. In order to configure the correct behaviour of the linux ines gpib driver for the 72130 based board we introduce a new board type "ines_pci_xl" and rely on user configuration to set the appropriate board type. The chip type is set in the ines_pci_xl_attach() routine and the ines72130_line_status() routine accesses the 72130 bus status register.
Patch 1: Add the chip type enum, the BSR offset and bit mask enums Patch 2: Adds the 72130 specific line_status routine Patch 3: Avoids accessing the extended registers when in 72130 mode Patch 4: Adds the pci_xl gpib_interface initialisation structure Patch 5: Add the attach routine for the 72130 based pci_xl board Patch 6: Adds the common driver register and unregister calls
Dave Penkler (6):
gpib: Add enums for INES 72130 based cards
gpib: Add ines 72130 line_status routine
gpib: Don't use extended registers
gpib: Add ines_pci_xl_interface
gpib: Add attach routine for pci_xl board
gpib; Add register and unregister calls
drivers/gpib/ines/ines.h | 16 +++++++ drivers/gpib/ines/ines_gpib.c | 90 +++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+)
Signature · 1 line
2.53.0
Dave Penkler
maintainerPATCH 1/6 gpib: Add enums for INES 72130 based cards
Add Chip type enum
Add offset for 72130 bus status register
Add bit masks for line state in 72130 bus status register
--- drivers/gpib/ines/ines.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpib/ines/ines.h +16 -0
@@ -21,6 +21,7 @@ enum ines_pci_chip {PCI_CHIP_AMCC5920 ,PCI_CHIP_QUANCOM ,PCI_CHIP_QUICKLOGIC5030 , + PCI_CHIP_INES_72130, }; struct ines_priv {
@@ -162,4 +163,19 @@ enum ines_auxd_bits { INES_T6_50us = 0x10, }; +enum ines72130_regs { +BUS_STATUS_REG =0xc , +}; + +enum ines_72130_bus_status_bits { +BSR_NRFD_BIT =0x1 , +BSR_NDAC_BIT =0x2 , +BSR_DAV_BIT =0x4 , +BSR_EOI_BIT =0x8 , +BSR_SRQ_BIT =0x10 , +BSR_ATN_BIT =0x20 , +BSR_REN_BIT =0x40 , +BSR_IFC_BIT =0x80 , +}; +#endif // _INES_GPIB_H
Signature · 1 line
2.53.0
Dave Penkler
maintainerPATCH 2/6 gpib: Add ines 72130 line_status routine
In reply to Dave PenklerThe 72130 chip has a different bus statue register offset and layout.
--- drivers/gpib/ines/ines_gpib.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpib/ines/ines_gpib.c +28 -0
@@ -57,6 +57,34 @@ static int ines_line_status(const struct gpib_board *board)return status; } +static int ines72130_line_status (const struct gpib_board *board) +{ +int status =VALID_ALL ; +int bsr_bits; +struct ines_priv *ines_priv = board->private_data; + + bsr_bits =ines_inb (ines_priv,BUS_STATUS_REG ); + +if (bsr_bits &BSR_REN_BIT ) + status |=BUS_REN ; +if (bsr_bits &BSR_IFC_BIT ) + status |=BUS_IFC ; +if (bsr_bits &BSR_SRQ_BIT ) + status |=BUS_SRQ ; +if (bsr_bits &BSR_EOI_BIT ) + status |=BUS_EOI ; +if (bsr_bits &BSR_NRFD_BIT ) + status |=BUS_NRFD ; +if (bsr_bits &BSR_NDAC_BIT ) + status |=BUS_NDAC ; +if (bsr_bits &BSR_DAV_BIT ) + status |=BUS_DAV ; +if (bsr_bits &BSR_ATN_BIT ) + status |=BUS_ATN ; + +return status; +} +static void ines_set_xfer_counter (struct ines_priv *priv,unsigned int count) {if (count >0xffff ) {
Signature · 1 line
2.53.0
Dave Penkler
maintainerPATCH 3/6 gpib: Don't use extended registers
In reply to Dave PenklerWhen the chip type is 72310 then avoid accessing extended registers Apart from the BSR the 72310 supports only the standard NEC u7210 registers.
--- drivers/gpib/ines/ines_gpib.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpib/ines/ines_gpib.c +6 -0
@@ -103,6 +103,9 @@ static int ines_t1_delay(struct gpib_board *board, unsigned int nano_sec) retval =nec7210_t1_delay (board, nec_priv, nano_sec); +if (ines_priv->pci_chip_type ==PCI_CHIP_INES_72130 ) +return retval; +if (nano_sec <=250 ) {write_byte (nec_priv,INES_AUXD | INES_FOLLOWING_T1_250ns | INES_INITIAL_T1_2000ns,AUXMR );
@@ -322,6 +325,8 @@ static irqreturn_t ines_interrupt(struct gpib_board *board)spin_lock_irqsave (&board->spinlock, flags);nec7210_interrupt (board, nec_priv); +if (priv->pci_chip_type ==PCI_CHIP_INES_72130 ) + goto out; isr3_bits =ines_inb (priv,ISR3 ); isr4_bits =ines_inb (priv,ISR4 );if (isr3_bits &IFC_ACTIVE_BIT ) {
@@ -339,6 +344,7 @@ static irqreturn_t ines_interrupt(struct gpib_board *board)if (wake)wake_up_interruptible (&board->wait); +out:spin_unlock_irqrestore (&board->spinlock, flags);return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Dave Penkler
maintainerPATCH 4/6 gpib: Add ines_pci_xl_interface
In reply to Dave PenklerAdd new interface initialisation struct for 72130 based boards.
It is basically the same as the ines_pci_interface apart from the name, attach and line_status fields.
--- drivers/gpib/ines/ines_gpib.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpib/ines/ines_gpib.c +28 -0
@@ -603,6 +603,34 @@ static struct gpib_interface ines_pci_unaccel_interface = { .return_to_local = ines_return_to_local, }; +static struct gpib_interface ines_pci_xl_interface = { + .name ="ines_pci_xl" , + .attach = ines_pci_xl_attach, + .detach = ines_pci_detach, + .read = ines_read, + .write = ines_write, + .command = ines_command, + .take_control = ines_take_control, + .go_to_standby = ines_go_to_standby, + .request_system_control = ines_request_system_control, + .interface_clear = ines_interface_clear, + .remote_enable = ines_remote_enable, + .enable_eos = ines_enable_eos, + .disable_eos = ines_disable_eos, + .parallel_poll = ines_parallel_poll, + .parallel_poll_configure = ines_parallel_poll_configure, + .parallel_poll_response = ines_parallel_poll_response, + .local_parallel_poll_mode =NULL ,// XXX + .line_status = ines72130_line_status, + .update_status = ines_update_status, + .primary_address = ines_primary_address, + .secondary_address = ines_secondary_address, + .serial_poll_response = ines_serial_poll_response, + .serial_poll_status = ines_serial_poll_status, + .t1_delay = ines_t1_delay, + .return_to_local = ines_return_to_local, +}; +static struct gpib_interface ines_pci_interface = { .name ="ines_pci" , .attach = ines_pci_accel_attach,
Signature · 1 line
2.53.0
Dave Penkler
maintainerPATCH 5/6 gpib: Add attach routine for pci_xl board
In reply to Dave PenklerAdd new attach routine for 72130 based boards.
--- drivers/gpib/ines/ines_gpib.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/gpib/ines/ines_gpib.c +19 -0
@@ -350,6 +350,7 @@ static irqreturn_t ines_interrupt(struct gpib_board *board) }static int ines_pci_attach (struct gpib_board *board,const struct gpib_board_config *config); +static int ines_pci_xl_attach (struct gpib_board *board,const struct gpib_board_config *config);static int ines_pci_accel_attach (struct gpib_board *board,const struct gpib_board_config *config);static int ines_isa_attach (struct gpib_board *board,const struct gpib_board_config *config);
@@ -932,6 +933,24 @@ static int ines_pci_attach(struct gpib_board *board, const struct gpib_board_conreturn 0 ; } +static int ines_pci_xl_attach (struct gpib_board *board,const struct gpib_board_config *config) +{ +struct ines_priv *ines_priv; +struct nec7210_priv *nec_priv; +int retval; + + retval =ines_common_pci_attach (board, config); +if (retval <0 ) +return retval; + + ines_priv = board->private_data; + ines_priv->pci_chip_type =PCI_CHIP_INES_72130 ; + nec_priv = &ines_priv->nec7210_priv; +nec7210_board_online (nec_priv, board); + +return 0 ; +} +static int ines_pci_accel_attach (struct gpib_board *board,const struct gpib_board_config *config) {struct ines_priv *ines_priv;
Signature · 1 line
2.53.0
Dave Penkler
maintainerPATCH 6/6 gpib; Add register and unregister calls
In reply to Dave PenklerRegister the driver for new 72130 based pci_xl board type with the common driver on module initialisation.
Unregister the driver on registration error and module exit.
--- drivers/gpib/ines/ines_gpib.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpib/ines/ines_gpib.c +9 -0
@@ -1500,6 +1500,12 @@ static int __init ines_init_module(void) goto err_pci_unaccel; } + ret =gpib_register_driver (&ines_pci_xl_interface,THIS_MODULE ); +if (ret) { +pr_err ("gpib_register_driver failed: error = %d\n" , ret); + goto err_pci_xl; + } + ret =gpib_register_driver (&ines_pci_accel_interface,THIS_MODULE );if (ret) {pr_err ("gpib_register_driver failed: error = %d\n" , ret);
@@ -1554,6 +1560,8 @@ static int __init ines_init_module(void)gpib_unregister_driver (&ines_pci_accel_interface); err_pci_accel:gpib_unregister_driver (&ines_pci_unaccel_interface); +err_pci_xl: +gpib_unregister_driver (&ines_pci_xl_interface); err_pci_unaccel:gpib_unregister_driver (&ines_pci_interface); err_pci:
@@ -1566,6 +1574,7 @@ static void __exit ines_exit_module(void) {gpib_unregister_driver (&ines_pci_interface);gpib_unregister_driver (&ines_pci_unaccel_interface); +gpib_unregister_driver (&ines_pci_xl_interface);gpib_unregister_driver (&ines_pci_accel_interface);gpib_unregister_driver (&ines_isa_interface);#ifdef CONFIG_GPIB_PCMCIA
Signature · 1 line
2.53.0