drivers/i2c/busses/i2c-designware-amdisp.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-designware-amdisp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-designware-amdisp.c- Extension
.c- Size
- 5130 bytes
- Lines
- 196
- Domain
- Driver Families
- Bucket
- drivers/i2c
- 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/module.hlinux/platform_device.hlinux/pm_domain.hlinux/pm_runtime.hlinux/soc/amd/isp4_misc.hi2c-designware-core.h
Detected Declarations
function Copyrightfunction amd_isp_dw_i2c_get_clk_ratefunction amd_isp_dw_i2c_plat_probefunction amd_isp_dw_i2c_plat_removefunction amd_isp_dw_i2c_plat_preparefunction amd_isp_dw_i2c_plat_runtime_suspendfunction amd_isp_dw_i2c_plat_suspendfunction amd_isp_dw_i2c_plat_runtime_resumefunction amd_isp_dw_i2c_plat_resume
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Based on Synopsys DesignWare I2C adapter driver.
*
* Copyright (C) 2025 Advanced Micro Devices, Inc.
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
#include <linux/soc/amd/isp4_misc.h>
#include "i2c-designware-core.h"
#define DRV_NAME "amd_isp_i2c_designware"
#define AMD_ISP_I2C_INPUT_CLK 100 /* Mhz */
static void amd_isp_dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *i2c_dev)
{
pm_runtime_disable(i2c_dev->dev);
}
static inline u32 amd_isp_dw_i2c_get_clk_rate(struct dw_i2c_dev *i2c_dev)
{
return AMD_ISP_I2C_INPUT_CLK * 1000;
}
static int amd_isp_dw_i2c_plat_probe(struct platform_device *pdev)
{
struct dw_i2c_dev *isp_i2c_dev;
struct i2c_adapter *adap;
int ret;
isp_i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*isp_i2c_dev), GFP_KERNEL);
if (!isp_i2c_dev)
return -ENOMEM;
isp_i2c_dev->dev = &pdev->dev;
pdev->dev.init_name = DRV_NAME;
/*
* Use the polling mode to send/receive the data, because
* no IRQ connection from ISP I2C
*/
isp_i2c_dev->flags |= ACCESS_POLLING;
platform_set_drvdata(pdev, isp_i2c_dev);
isp_i2c_dev->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(isp_i2c_dev->base))
return dev_err_probe(&pdev->dev, PTR_ERR(isp_i2c_dev->base),
"failed to get IOMEM resource\n");
isp_i2c_dev->get_clk_rate_khz = amd_isp_dw_i2c_get_clk_rate;
ret = i2c_dw_fw_parse_and_configure(isp_i2c_dev);
if (ret)
return dev_err_probe(&pdev->dev, ret,
"failed to parse i2c dw fwnode and configure\n");
i2c_dw_configure(isp_i2c_dev);
adap = &isp_i2c_dev->adapter;
adap->owner = THIS_MODULE;
scnprintf(adap->name, sizeof(adap->name), AMDISP_I2C_ADAP_NAME);
ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev));
adap->dev.of_node = pdev->dev.of_node;
/* use dynamically allocated adapter id */
adap->nr = -1;
if (isp_i2c_dev->flags & ACCESS_NO_IRQ_SUSPEND)
dev_pm_set_driver_flags(&pdev->dev,
DPM_FLAG_SMART_PREPARE);
else
dev_pm_set_driver_flags(&pdev->dev,
DPM_FLAG_SMART_PREPARE |
DPM_FLAG_SMART_SUSPEND);
device_enable_async_suspend(&pdev->dev);
dev_pm_genpd_resume(&pdev->dev);
ret = i2c_dw_probe(isp_i2c_dev);
if (ret) {
dev_err_probe(&pdev->dev, ret, "i2c_dw_probe failed\n");
goto error_release_rpm;
}
dev_pm_genpd_suspend(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
pm_runtime_enable(&pdev->dev);
return 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/pm_domain.h`, `linux/pm_runtime.h`, `linux/soc/amd/isp4_misc.h`, `i2c-designware-core.h`.
- Detected declarations: `function Copyright`, `function amd_isp_dw_i2c_get_clk_rate`, `function amd_isp_dw_i2c_plat_probe`, `function amd_isp_dw_i2c_plat_remove`, `function amd_isp_dw_i2c_plat_prepare`, `function amd_isp_dw_i2c_plat_runtime_suspend`, `function amd_isp_dw_i2c_plat_suspend`, `function amd_isp_dw_i2c_plat_runtime_resume`, `function amd_isp_dw_i2c_plat_resume`.
- Atlas domain: Driver Families / drivers/i2c.
- 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.