drivers/i2c/busses/i2c-amd-mp2.h

Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-amd-mp2.h

File Facts

System
Linux kernel
Corpus path
drivers/i2c/busses/i2c-amd-mp2.h
Extension
.h
Size
5564 bytes
Lines
214
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct amd_i2c_common {
	union i2c_event eventval;
	struct amd_mp2_dev *mp2_dev;
	struct i2c_msg *msg;
	void (*cmd_completion)(struct amd_i2c_common *i2c_common);
	enum i2c_cmd reqcmd;
	u8 cmd_success;
	u8 bus_id;
	enum speed_enum i2c_speed;
	u8 *dma_buf;
	dma_addr_t dma_addr;
#ifdef CONFIG_PM
	int (*suspend)(struct amd_i2c_common *i2c_common);
	int (*resume)(struct amd_i2c_common *i2c_common);
#endif /* CONFIG_PM */
};

/**
 * struct amd_mp2_dev - per PCI device context
 * @pci_dev: PCI driver node
 * @busses: MP2 devices may have up to two busses,
 *	    each bus corresponding to an i2c adapter
 * @mmio: iommapped registers
 * @c2p_lock: controls access to the C2P mailbox shared between
 *	      the two adapters
 * @c2p_lock_busid: id of the adapter which locked c2p_lock
 */
struct amd_mp2_dev {
	struct pci_dev *pci_dev;
	struct amd_i2c_common *busses[2];
	void __iomem *mmio;
	struct mutex c2p_lock;
	u8 c2p_lock_busid;
	unsigned int probed;
	int dev_irq;
};

/* PCIe communication driver */

int amd_mp2_rw(struct amd_i2c_common *i2c_common, enum i2c_cmd reqcmd);
int amd_mp2_bus_enable_set(struct amd_i2c_common *i2c_common, bool enable);

void amd_mp2_process_event(struct amd_i2c_common *i2c_common);

void amd_mp2_rw_timeout(struct amd_i2c_common *i2c_common);

int amd_mp2_register_cb(struct amd_i2c_common *i2c_common);
int amd_mp2_unregister_cb(struct amd_i2c_common *i2c_common);

struct amd_mp2_dev *amd_mp2_find_device(void);

static inline void amd_mp2_pm_runtime_get(struct amd_mp2_dev *mp2_dev)
{
	pm_runtime_get_sync(&mp2_dev->pci_dev->dev);
}

static inline void amd_mp2_pm_runtime_put(struct amd_mp2_dev *mp2_dev)
{
	pm_runtime_put_autosuspend(&mp2_dev->pci_dev->dev);
}

#endif

Annotation

Implementation Notes