drivers/ata/ahci_imx.c
Source file repositories/reference/linux-study-clean/drivers/ata/ahci_imx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ata/ahci_imx.c- Extension
.c- Size
- 27914 bytes
- Lines
- 1045
- 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.
- 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/platform_device.hlinux/property.hlinux/regmap.hlinux/ahci_platform.hlinux/gpio/consumer.hlinux/of.hlinux/mfd/syscon.hlinux/mfd/syscon/imx6q-iomuxc-gpr.hlinux/libata.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/phy/phy.hlinux/thermal.hahci.h
Detected Declarations
struct imx_ahci_privstruct reg_valuestruct reg_propertyenum ahci_imx_typefunction imx_phy_crbit_assertfunction imx_phy_reg_addressingfunction imx_phy_reg_writefunction imx_phy_reg_readfunction imx_sata_phy_resetfunction read_adc_sumfunction __sata_ahci_read_temperaturefunction sata_ahci_read_temperaturefunction sata_ahci_show_tempfunction imx8_sata_enablefunction imx_sata_enablefunction imx_sata_disablefunction ahci_imx_error_handlerfunction ahci_imx_softresetfunction imx_ahci_parse_propsfunction imx8_sata_probefunction imx_ahci_probefunction ahci_imx_host_stopfunction imx_ahci_suspendfunction imx_ahci_resume
Annotated Snippet
struct imx_ahci_priv {
struct platform_device *ahci_pdev;
enum ahci_imx_type type;
struct clk *sata_clk;
struct clk *sata_ref_clk;
struct clk *ahb_clk;
struct regmap *gpr;
struct phy *sata_phy;
struct phy *cali_phy0;
struct phy *cali_phy1;
bool no_device;
bool first_time;
u32 phy_params;
u32 imped_ratio;
};
static int ahci_imx_hotplug;
module_param_named(hotplug, ahci_imx_hotplug, int, 0644);
MODULE_PARM_DESC(hotplug, "AHCI IMX hot-plug support (0=Don't support, 1=support)");
static void ahci_imx_host_stop(struct ata_host *host);
static int imx_phy_crbit_assert(void __iomem *mmio, u32 bit, bool assert)
{
int timeout = 10;
u32 crval;
u32 srval;
/* Assert or deassert the bit */
crval = readl(mmio + IMX_P0PHYCR);
if (assert)
crval |= bit;
else
crval &= ~bit;
writel(crval, mmio + IMX_P0PHYCR);
/* Wait for the cr_ack signal */
do {
srval = readl(mmio + IMX_P0PHYSR);
if ((assert ? srval : ~srval) & IMX_P0PHYSR_CR_ACK)
break;
usleep_range(100, 200);
} while (--timeout);
return timeout ? 0 : -ETIMEDOUT;
}
static int imx_phy_reg_addressing(u16 addr, void __iomem *mmio)
{
u32 crval = addr;
int ret;
/* Supply the address on cr_data_in */
writel(crval, mmio + IMX_P0PHYCR);
/* Assert the cr_cap_addr signal */
ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, true);
if (ret)
return ret;
/* Deassert cr_cap_addr */
ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, false);
if (ret)
return ret;
return 0;
}
static int imx_phy_reg_write(u16 val, void __iomem *mmio)
{
u32 crval = val;
int ret;
/* Supply the data on cr_data_in */
writel(crval, mmio + IMX_P0PHYCR);
/* Assert the cr_cap_data signal */
ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, true);
if (ret)
return ret;
/* Deassert cr_cap_data */
ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, false);
if (ret)
return ret;
if (val & IMX_CLOCK_RESET_RESET) {
/*
* In case we're resetting the phy, it's unable to acknowledge,
* so we return immediately here.
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `linux/property.h`, `linux/regmap.h`, `linux/ahci_platform.h`, `linux/gpio/consumer.h`, `linux/of.h`.
- Detected declarations: `struct imx_ahci_priv`, `struct reg_value`, `struct reg_property`, `enum ahci_imx_type`, `function imx_phy_crbit_assert`, `function imx_phy_reg_addressing`, `function imx_phy_reg_write`, `function imx_phy_reg_read`, `function imx_sata_phy_reset`, `function read_adc_sum`.
- Atlas domain: Driver Families / drivers/ata.
- 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.