drivers/comedi/drivers/ssv_dnp.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ssv_dnp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/ssv_dnp.c- Extension
.c- Size
- 4969 bytes
- Lines
- 181
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/comedi/comedidev.h
Detected Declarations
function Copyrightfunction dnp_dio_insn_configfunction dnp_attachfunction dnp_detach
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* ssv_dnp.c
* generic comedi driver for SSV Embedded Systems' DIL/Net-PCs
* Copyright (C) 2001 Robert Schwebel <robert@schwebel.de>
*
* COMEDI - Linux Control and Measurement Device Interface
* Copyright (C) 2000 David A. Schleef <ds@schleef.org>
*/
/*
* Driver: ssv_dnp
* Description: SSV Embedded Systems DIL/Net-PC
* Author: Robert Schwebel <robert@schwebel.de>
* Devices: [SSV Embedded Systems] DIL/Net-PC 1486 (dnp-1486)
* Status: unknown
*/
/* include files ----------------------------------------------------------- */
#include <linux/module.h>
#include <linux/comedi/comedidev.h>
/* Some global definitions: the registers of the DNP ----------------------- */
/* */
/* For port A and B the mode register has bits corresponding to the output */
/* pins, where Bit-N = 0 -> input, Bit-N = 1 -> output. Note that bits */
/* 4 to 7 correspond to pin 0..3 for port C data register. Ensure that bits */
/* 0..3 remain unchanged! For details about Port C Mode Register see */
/* the remarks in dnp_insn_config() below. */
#define CSCIR 0x22 /* Chip Setup and Control Index Register */
#define CSCDR 0x23 /* Chip Setup and Control Data Register */
#define PAMR 0xa5 /* Port A Mode Register */
#define PADR 0xa9 /* Port A Data Register */
#define PBMR 0xa4 /* Port B Mode Register */
#define PBDR 0xa8 /* Port B Data Register */
#define PCMR 0xa3 /* Port C Mode Register */
#define PCDR 0xa7 /* Port C Data Register */
static int dnp_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask;
unsigned int val;
/*
* Ports A and B are straight forward: each bit corresponds to an
* output pin with the same order. Port C is different: bits 0...3
* correspond to bits 4...7 of the output register (PCDR).
*/
mask = comedi_dio_update_state(s, data);
if (mask) {
outb(PADR, CSCIR);
outb(s->state & 0xff, CSCDR);
outb(PBDR, CSCIR);
outb((s->state >> 8) & 0xff, CSCDR);
outb(PCDR, CSCIR);
val = inb(CSCDR) & 0x0f;
outb(((s->state >> 12) & 0xf0) | val, CSCDR);
}
outb(PADR, CSCIR);
val = inb(CSCDR);
outb(PBDR, CSCIR);
val |= (inb(CSCDR) << 8);
outb(PCDR, CSCIR);
val |= ((inb(CSCDR) & 0xf0) << 12);
data[1] = val;
return insn->n;
}
static int dnp_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int mask;
unsigned int val;
int ret;
ret = comedi_dio_insn_config(dev, s, insn, data, 0);
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`.
- Detected declarations: `function Copyright`, `function dnp_dio_insn_config`, `function dnp_attach`, `function dnp_detach`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.