drivers/ata/sata_rcar.c
Source file repositories/reference/linux-study-clean/drivers/ata/sata_rcar.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ata/sata_rcar.c- Extension
.c- Size
- 26553 bytes
- Lines
- 1027
- Domain
- Driver Families
- Bucket
- drivers/ata
- 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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/ata.hlinux/libata.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/err.h
Detected Declarations
struct sata_rcar_privenum sata_rcar_typefunction sata_rcar_gen1_phy_preinitfunction sata_rcar_gen1_phy_writefunction sata_rcar_gen1_phy_initfunction sata_rcar_gen2_phy_initfunction sata_rcar_freezefunction sata_rcar_thawfunction sata_rcar_ioread16_repfunction sata_rcar_iowrite16_repfunction sata_rcar_check_statusfunction sata_rcar_check_altstatusfunction sata_rcar_set_devctlfunction sata_rcar_dev_selectfunction sata_rcar_ata_devchkfunction sata_rcar_wait_after_resetfunction sata_rcar_bus_softresetfunction sata_rcar_softresetfunction sata_rcar_tf_loadfunction sata_rcar_tf_readfunction sata_rcar_exec_commandfunction sata_rcar_data_xferfunction sata_rcar_drain_fifofunction sata_rcar_scr_readfunction sata_rcar_scr_writefunction sata_rcar_bmdma_fill_sgfunction for_each_sgfunction sata_rcar_qc_prepfunction sata_rcar_bmdma_setupfunction sata_rcar_bmdma_startfunction sata_rcar_bmdma_stopfunction sata_rcar_bmdma_statusfunction sata_rcar_serr_interruptfunction sata_rcar_ata_interruptfunction sata_rcar_interruptfunction sata_rcar_setup_portfunction sata_rcar_init_modulefunction sata_rcar_init_controllerfunction sata_rcar_probefunction sata_rcar_removefunction sata_rcar_suspendfunction sata_rcar_resumefunction sata_rcar_restore
Annotated Snippet
struct sata_rcar_priv {
void __iomem *base;
u32 sataint_mask;
enum sata_rcar_type type;
};
static void sata_rcar_gen1_phy_preinit(struct sata_rcar_priv *priv)
{
void __iomem *base = priv->base;
/* idle state */
iowrite32(0, base + SATAPHYADDR_REG);
/* reset */
iowrite32(SATAPHYRESET_PHYRST, base + SATAPHYRESET_REG);
udelay(10);
/* deassert reset */
iowrite32(0, base + SATAPHYRESET_REG);
}
static void sata_rcar_gen1_phy_write(struct sata_rcar_priv *priv, u16 reg,
u32 val, int group)
{
void __iomem *base = priv->base;
int timeout;
/* deassert reset */
iowrite32(0, base + SATAPHYRESET_REG);
/* lane 1 */
iowrite32(SATAPHYACCEN_PHYLANE, base + SATAPHYACCEN_REG);
/* write phy register value */
iowrite32(val, base + SATAPHYWDATA_REG);
/* set register group */
if (group)
reg |= SATAPHYADDR_PHYRATEMODE;
/* write command */
iowrite32(SATAPHYADDR_PHYCMD_WRITE | reg, base + SATAPHYADDR_REG);
/* wait for ack */
for (timeout = 0; timeout < 100; timeout++) {
val = ioread32(base + SATAPHYACK_REG);
if (val & SATAPHYACK_PHYACK)
break;
}
if (timeout >= 100)
pr_err("%s timeout\n", __func__);
/* idle state */
iowrite32(0, base + SATAPHYADDR_REG);
}
static void sata_rcar_gen1_phy_init(struct sata_rcar_priv *priv)
{
sata_rcar_gen1_phy_preinit(priv);
sata_rcar_gen1_phy_write(priv, SATAPCTLR1_REG, 0x00200188, 0);
sata_rcar_gen1_phy_write(priv, SATAPCTLR1_REG, 0x00200188, 1);
sata_rcar_gen1_phy_write(priv, SATAPCTLR3_REG, 0x0000A061, 0);
sata_rcar_gen1_phy_write(priv, SATAPCTLR2_REG, 0x20000000, 0);
sata_rcar_gen1_phy_write(priv, SATAPCTLR2_REG, 0x20000000, 1);
sata_rcar_gen1_phy_write(priv, SATAPCTLR4_REG, 0x28E80000, 0);
}
static void sata_rcar_gen2_phy_init(struct sata_rcar_priv *priv)
{
void __iomem *base = priv->base;
iowrite32(RCAR_GEN2_PHY_CTL1, base + RCAR_GEN2_PHY_CTL1_REG);
iowrite32(RCAR_GEN2_PHY_CTL2, base + RCAR_GEN2_PHY_CTL2_REG);
iowrite32(RCAR_GEN2_PHY_CTL3, base + RCAR_GEN2_PHY_CTL3_REG);
iowrite32(RCAR_GEN2_PHY_CTL4, base + RCAR_GEN2_PHY_CTL4_REG);
iowrite32(RCAR_GEN2_PHY_CTL5 | RCAR_GEN2_PHY_CTL5_DC |
RCAR_GEN2_PHY_CTL5_TR, base + RCAR_GEN2_PHY_CTL5_REG);
}
static void sata_rcar_freeze(struct ata_port *ap)
{
struct sata_rcar_priv *priv = ap->host->private_data;
/* mask */
iowrite32(priv->sataint_mask, priv->base + SATAINTMASK_REG);
ata_sff_freeze(ap);
}
static void sata_rcar_thaw(struct ata_port *ap)
{
struct sata_rcar_priv *priv = ap->host->private_data;
void __iomem *base = priv->base;
/* ack */
iowrite32(~(u32)SATA_RCAR_INT_MASK, base + SATAINTSTAT_REG);
ata_sff_thaw(ap);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/ata.h`, `linux/libata.h`, `linux/of.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/err.h`.
- Detected declarations: `struct sata_rcar_priv`, `enum sata_rcar_type`, `function sata_rcar_gen1_phy_preinit`, `function sata_rcar_gen1_phy_write`, `function sata_rcar_gen1_phy_init`, `function sata_rcar_gen2_phy_init`, `function sata_rcar_freeze`, `function sata_rcar_thaw`, `function sata_rcar_ioread16_rep`, `function sata_rcar_iowrite16_rep`.
- Atlas domain: Driver Families / drivers/ata.
- Implementation status: source 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.