xref: /linux/drivers/gpu/drm/xe/xe_i2c.h (revision 3a2c4d55e32ad65efebdb6de44eef3bfa08bb49d)
1 /* SPDX-License-Identifier: MIT */
2 #ifndef _XE_I2C_H_
3 #define _XE_I2C_H_
4 
5 #include <linux/bits.h>
6 #include <linux/notifier.h>
7 #include <linux/types.h>
8 #include <linux/workqueue.h>
9 
10 struct device;
11 struct fwnode_handle;
12 struct i2c_adapter;
13 struct i2c_client;
14 struct platform_device;
15 struct xe_amc;
16 struct xe_device;
17 struct xe_mmio;
18 
19 #define XE_I2C_EP_COOKIE_DEVICE		0xde
20 
21 /* Endpoint Capabilities */
22 #define XE_I2C_EP_CAP_IRQ		BIT(0)
23 
24 enum XE_I2C_CLIENT {
25 	XE_I2C_CLIENT_AMC = 1,
26 	XE_I2C_MAX_CLIENTS = 3,
27 };
28 
29 struct xe_i2c_endpoint {
30 	u8 cookie;
31 	u8 capabilities;
32 	u16 addr[XE_I2C_MAX_CLIENTS];
33 };
34 
35 struct xe_i2c {
36 	struct platform_device *pdev;
37 	struct i2c_adapter *adapter;
38 	struct i2c_client *client[XE_I2C_MAX_CLIENTS];
39 	unsigned int ic_enable;
40 
41 	struct notifier_block bus_notifier;
42 	struct work_struct work;
43 
44 	struct xe_i2c_endpoint ep;
45 	struct device *drm_dev;
46 
47 	struct xe_mmio *mmio;
48 	struct xe_amc *amc;
49 };
50 
51 #if IS_ENABLED(CONFIG_I2C)
52 int xe_i2c_probe(struct xe_device *xe);
53 bool xe_i2c_present(struct xe_device *xe);
54 void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl);
55 void xe_i2c_irq_postinstall(struct xe_device *xe);
56 void xe_i2c_irq_reset(struct xe_device *xe);
57 void xe_i2c_pm_suspend(struct xe_device *xe);
58 void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold);
59 #else
60 static inline int xe_i2c_probe(struct xe_device *xe) { return 0; }
61 static inline bool xe_i2c_present(struct xe_device *xe) { return false; }
62 static inline void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl) { }
63 static inline void xe_i2c_irq_postinstall(struct xe_device *xe) { }
64 static inline void xe_i2c_irq_reset(struct xe_device *xe) { }
65 static inline void xe_i2c_pm_suspend(struct xe_device *xe) { }
66 static inline void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold) { }
67 #endif
68 
69 #endif
70