drivers/scsi/fdomain.c
Source file repositories/reference/linux-study-clean/drivers/scsi/fdomain.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/fdomain.c- Extension
.c- Size
- 16698 bytes
- Lines
- 609
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/interrupt.hlinux/delay.hlinux/pci.hlinux/workqueue.hscsi/scsicam.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hfdomain.h
Detected Declarations
struct fdomainenum chip_typefunction fdomain_make_bus_idlefunction fdomain_identifyfunction fdomain_test_loopbackfunction fdomain_resetfunction fdomain_selectfunction fdomain_finish_cmdfunction fdomain_read_datafunction fdomain_write_datafunction fdomain_workfunction fdomain_irqfunction fdomain_queuefunction fdomain_abortfunction fdomain_host_resetfunction fdomain_biosparamfunction fdomain_destroyfunction fdomain_resumeexport fdomain_createexport fdomain_destroy
Annotated Snippet
struct fdomain {
int base;
struct scsi_cmnd *cur_cmd;
enum chip_type chip;
struct work_struct work;
};
static struct scsi_pointer *fdomain_scsi_pointer(struct scsi_cmnd *cmd)
{
return scsi_cmd_priv(cmd);
}
static inline void fdomain_make_bus_idle(struct fdomain *fd)
{
outb(0, fd->base + REG_BCTL);
outb(0, fd->base + REG_MCTL);
if (fd->chip == tmc18c50 || fd->chip == tmc18c30)
/* Clear forced intr. */
outb(ACTL_RESET | ACTL_CLRFIRQ | PARITY_MASK,
fd->base + REG_ACTL);
else
outb(ACTL_RESET | PARITY_MASK, fd->base + REG_ACTL);
}
static enum chip_type fdomain_identify(int port)
{
u16 id = inb(port + REG_ID_LSB) | inb(port + REG_ID_MSB) << 8;
switch (id) {
case 0x6127:
return tmc1800;
case 0x60e9: /* 18c50 or 18c30 */
break;
default:
return unknown;
}
/* Try to toggle 32-bit mode. This only works on an 18c30 chip. */
outb(CFG2_32BIT, port + REG_CFG2);
if ((inb(port + REG_CFG2) & CFG2_32BIT)) {
outb(0, port + REG_CFG2);
if ((inb(port + REG_CFG2) & CFG2_32BIT) == 0)
return tmc18c30;
}
/* If that failed, we are an 18c50. */
return tmc18c50;
}
static int fdomain_test_loopback(int base)
{
int i;
for (i = 0; i < 255; i++) {
outb(i, base + REG_LOOPBACK);
if (inb(base + REG_LOOPBACK) != i)
return 1;
}
return 0;
}
static void fdomain_reset(int base)
{
outb(BCTL_RST, base + REG_BCTL);
mdelay(20);
outb(0, base + REG_BCTL);
mdelay(1150);
outb(0, base + REG_MCTL);
outb(PARITY_MASK, base + REG_ACTL);
}
static int fdomain_select(struct Scsi_Host *sh, int target)
{
int status;
unsigned long timeout;
struct fdomain *fd = shost_priv(sh);
outb(BCTL_BUSEN | BCTL_SEL, fd->base + REG_BCTL);
outb(BIT(sh->this_id) | BIT(target), fd->base + REG_SCSI_DATA_NOACK);
/* Stop arbitration and enable parity */
outb(PARITY_MASK, fd->base + REG_ACTL);
timeout = 350; /* 350 msec */
do {
status = inb(fd->base + REG_BSTAT);
if (status & BSTAT_BSY) {
/* Enable SCSI Bus */
/* (on error, should make bus idle with 0) */
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/pci.h`, `linux/workqueue.h`, `scsi/scsicam.h`, `scsi/scsi_cmnd.h`, `scsi/scsi_device.h`.
- Detected declarations: `struct fdomain`, `enum chip_type`, `function fdomain_make_bus_idle`, `function fdomain_identify`, `function fdomain_test_loopback`, `function fdomain_reset`, `function fdomain_select`, `function fdomain_finish_cmd`, `function fdomain_read_data`, `function fdomain_write_data`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.