drivers/comedi/drivers/s526.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/s526.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/s526.c- Extension
.c- Size
- 19591 bytes
- Lines
- 631
- 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
struct s526_privatefunction s526_gpct_writefunction s526_gpct_readfunction s526_gpct_rinsnfunction s526_gpct_insn_configfunction s526_gpct_winsnfunction s526_eocfunction s526_ai_insn_readfunction s526_ao_insn_writefunction s526_dio_insn_bitsfunction s526_dio_insn_configfunction s526_attach
Annotated Snippet
struct s526_private {
unsigned int gpct_config[4];
unsigned short ai_ctrl;
};
static void s526_gpct_write(struct comedi_device *dev,
unsigned int chan, unsigned int val)
{
/* write high word then low word */
outw((val >> 16) & 0xffff, dev->iobase + S526_GPCT_MSB_REG(chan));
outw(val & 0xffff, dev->iobase + S526_GPCT_LSB_REG(chan));
}
static unsigned int s526_gpct_read(struct comedi_device *dev,
unsigned int chan)
{
unsigned int val;
/* read the low word then high word */
val = inw(dev->iobase + S526_GPCT_LSB_REG(chan)) & 0xffff;
val |= (inw(dev->iobase + S526_GPCT_MSB_REG(chan)) & 0xff) << 16;
return val;
}
static int s526_gpct_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
int i;
for (i = 0; i < insn->n; i++)
data[i] = s526_gpct_read(dev, chan);
return insn->n;
}
static int s526_gpct_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct s526_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int val;
/*
* Check what type of Counter the user requested
* data[0] contains the Application type
*/
switch (data[0]) {
case INSN_CONFIG_GPCT_QUADRATURE_ENCODER:
/*
* data[0]: Application Type
* data[1]: Counter Mode Register Value
* data[2]: Pre-load Register Value
* data[3]: Conter Control Register
*/
devpriv->gpct_config[chan] = data[0];
#if 1
/* Set Counter Mode Register */
val = data[1] & 0xffff;
outw(val, dev->iobase + S526_GPCT_MODE_REG(chan));
/* Reset the counter if it is software preload */
if ((val & S526_GPCT_MODE_AUTOLOAD_MASK) ==
S526_GPCT_MODE_AUTOLOAD_NONE) {
/* Reset the counter */
outw(S526_GPCT_CTRL_CT_RESET,
dev->iobase + S526_GPCT_CTRL_REG(chan));
/*
* Load the counter from PR0
* outw(S526_GPCT_CTRL_CT_LOAD,
* dev->iobase + S526_GPCT_CTRL_REG(chan));
*/
}
#else
val = S526_GPCT_MODE_CTDIR_CTRL_QUAD;
/* data[1] contains GPCT_X1, GPCT_X2 or GPCT_X4 */
if (data[1] == GPCT_X2)
val |= S526_GPCT_MODE_CLK_SRC_QUADX2;
else if (data[1] == GPCT_X4)
val |= S526_GPCT_MODE_CLK_SRC_QUADX4;
else
val |= S526_GPCT_MODE_CLK_SRC_QUADX1;
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`.
- Detected declarations: `struct s526_private`, `function s526_gpct_write`, `function s526_gpct_read`, `function s526_gpct_rinsn`, `function s526_gpct_insn_config`, `function s526_gpct_winsn`, `function s526_eoc`, `function s526_ai_insn_read`, `function s526_ao_insn_write`, `function s526_dio_insn_bits`.
- 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.