drivers/comedi/drivers/ii_pci20kc.c

Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ii_pci20kc.c

File Facts

System
Linux kernel
Corpus path
drivers/comedi/drivers/ii_pci20kc.c
Extension
.c
Size
14032 bytes
Lines
525
Domain
Driver Families
Bucket
drivers/comedi
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * ii_pci20kc.c
 * Driver for Intelligent Instruments PCI-20001C carrier board and modules.
 *
 * Copyright (C) 2000 Markus Kempf <kempf@matsci.uni-sb.de>
 * with suggestions from David Schleef		16.06.2000
 */

/*
 * Driver: ii_pci20kc
 * Description: Intelligent Instruments PCI-20001C carrier board
 * Devices: [Intelligent Instrumentation] PCI-20001C (ii_pci20kc)
 * Author: Markus Kempf <kempf@matsci.uni-sb.de>
 * Status: works
 *
 * Supports the PCI-20001C-1a and PCI-20001C-2a carrier boards. The
 * -2a version has 32 on-board DIO channels. Three add-on modules
 * can be added to the carrier board for additional functionality.
 *
 * Supported add-on modules:
 *	PCI-20006M-1   1 channel, 16-bit analog output module
 *	PCI-20006M-2   2 channel, 16-bit analog output module
 *	PCI-20341M-1A  4 channel, 16-bit analog input module
 *
 * Options:
 *   0   Board base address
 *   1   IRQ (not-used)
 */

#include <linux/module.h>
#include <linux/io.h>
#include <linux/comedi/comedidev.h>

/*
 * Register I/O map
 */
#define II20K_SIZE			0x400
#define II20K_MOD_OFFSET		0x100
#define II20K_ID_REG			0x00
#define II20K_ID_MOD1_EMPTY		BIT(7)
#define II20K_ID_MOD2_EMPTY		BIT(6)
#define II20K_ID_MOD3_EMPTY		BIT(5)
#define II20K_ID_MASK			0x1f
#define II20K_ID_PCI20001C_1A		0x1b	/* no on-board DIO */
#define II20K_ID_PCI20001C_2A		0x1d	/* on-board DIO */
#define II20K_MOD_STATUS_REG		0x40
#define II20K_MOD_STATUS_IRQ_MOD1	BIT(7)
#define II20K_MOD_STATUS_IRQ_MOD2	BIT(6)
#define II20K_MOD_STATUS_IRQ_MOD3	BIT(5)
#define II20K_DIO0_REG			0x80
#define II20K_DIO1_REG			0x81
#define II20K_DIR_ENA_REG		0x82
#define II20K_DIR_DIO3_OUT		BIT(7)
#define II20K_DIR_DIO2_OUT		BIT(6)
#define II20K_BUF_DISAB_DIO3		BIT(5)
#define II20K_BUF_DISAB_DIO2		BIT(4)
#define II20K_DIR_DIO1_OUT		BIT(3)
#define II20K_DIR_DIO0_OUT		BIT(2)
#define II20K_BUF_DISAB_DIO1		BIT(1)
#define II20K_BUF_DISAB_DIO0		BIT(0)
#define II20K_CTRL01_REG		0x83
#define II20K_CTRL01_SET		BIT(7)
#define II20K_CTRL01_DIO0_IN		BIT(4)
#define II20K_CTRL01_DIO1_IN		BIT(1)
#define II20K_DIO2_REG			0xc0
#define II20K_DIO3_REG			0xc1
#define II20K_CTRL23_REG		0xc3
#define II20K_CTRL23_SET		BIT(7)
#define II20K_CTRL23_DIO2_IN		BIT(4)
#define II20K_CTRL23_DIO3_IN		BIT(1)

#define II20K_ID_PCI20006M_1		0xe2	/* 1 AO channels */
#define II20K_ID_PCI20006M_2		0xe3	/* 2 AO channels */
#define II20K_AO_STRB_REG(x)		(0x0b + ((x) * 0x08))
#define II20K_AO_LSB_REG(x)		(0x0d + ((x) * 0x08))
#define II20K_AO_MSB_REG(x)		(0x0e + ((x) * 0x08))
#define II20K_AO_STRB_BOTH_REG		0x1b

#define II20K_ID_PCI20341M_1		0x77	/* 4 AI channels */
#define II20K_AI_STATUS_CMD_REG		0x01
#define II20K_AI_STATUS_CMD_BUSY	BIT(7)
#define II20K_AI_STATUS_CMD_HW_ENA	BIT(1)
#define II20K_AI_STATUS_CMD_EXT_START	BIT(0)
#define II20K_AI_LSB_REG		0x02
#define II20K_AI_MSB_REG		0x03
#define II20K_AI_PACER_RESET_REG	0x04
#define II20K_AI_16BIT_DATA_REG		0x06
#define II20K_AI_CONF_REG		0x10
#define II20K_AI_CONF_ENA		BIT(2)

Annotation

Implementation Notes