drivers/comedi/drivers/fl512.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/fl512.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/fl512.c- Extension
.c- Size
- 3443 bytes
- Lines
- 149
- 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.hlinux/delay.h
Detected Declarations
function fl512_ai_insn_readfunction fl512_ao_insn_writefunction fl512_attach
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* fl512.c
* Anders Gnistrup <ex18@kalman.iau.dtu.dk>
*
* COMEDI - Linux Control and Measurement Device Interface
* Copyright (C) 2000 David A. Schleef <ds@schleef.org>
*/
/*
* Driver: fl512
* Description: unknown
* Author: Anders Gnistrup <ex18@kalman.iau.dtu.dk>
* Devices: [unknown] FL512 (fl512)
* Status: unknown
*
* Digital I/O is not supported.
*
* Configuration options:
* [0] - I/O port base address
*/
#include <linux/module.h>
#include <linux/comedi/comedidev.h>
#include <linux/delay.h>
/*
* Register I/O map
*/
#define FL512_AI_LSB_REG 0x02
#define FL512_AI_MSB_REG 0x03
#define FL512_AI_MUX_REG 0x02
#define FL512_AI_START_CONV_REG 0x03
#define FL512_AO_DATA_REG(x) (0x04 + ((x) * 2))
#define FL512_AO_TRIG_REG(x) (0x04 + ((x) * 2))
static const struct comedi_lrange range_fl512 = {
4, {
BIP_RANGE(0.5),
BIP_RANGE(1),
BIP_RANGE(5),
BIP_RANGE(10),
UNI_RANGE(1),
UNI_RANGE(5),
UNI_RANGE(10)
}
};
static int fl512_ai_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int val;
int i;
outb(chan, dev->iobase + FL512_AI_MUX_REG);
for (i = 0; i < insn->n; i++) {
outb(0, dev->iobase + FL512_AI_START_CONV_REG);
/* XXX should test "done" flag instead of delay */
usleep_range(30, 100);
val = inb(dev->iobase + FL512_AI_LSB_REG);
val |= (inb(dev->iobase + FL512_AI_MSB_REG) << 8);
val &= s->maxdata;
data[i] = val;
}
return insn->n;
}
static int fl512_ao_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int val = s->readback[chan];
int i;
for (i = 0; i < insn->n; i++) {
val = data[i];
/* write LSB, MSB then trigger conversion */
outb(val & 0x0ff, dev->iobase + FL512_AO_DATA_REG(chan));
outb((val >> 8) & 0xf, dev->iobase + FL512_AO_DATA_REG(chan));
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`, `linux/delay.h`.
- Detected declarations: `function fl512_ai_insn_read`, `function fl512_ao_insn_write`, `function fl512_attach`.
- 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.