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 irq_domain; 15 struct platform_device; 16 struct xe_device; 17 struct xe_mmio; 18 19 #define XE_I2C_MAX_CLIENTS 3 20 21 #define XE_I2C_EP_COOKIE_DEVICE 0xde 22 23 /* Endpoint Capabilities */ 24 #define XE_I2C_EP_CAP_IRQ BIT(0) 25 26 struct xe_i2c_endpoint { 27 u8 cookie; 28 u8 capabilities; 29 u16 addr[XE_I2C_MAX_CLIENTS]; 30 }; 31 32 struct xe_i2c { 33 struct fwnode_handle *adapter_node; 34 struct platform_device *pdev; 35 struct i2c_adapter *adapter; 36 struct i2c_client *client[XE_I2C_MAX_CLIENTS]; 37 38 struct notifier_block bus_notifier; 39 struct work_struct work; 40 41 struct irq_domain *irqdomain; 42 int adapter_irq; 43 44 struct xe_i2c_endpoint ep; 45 struct device *drm_dev; 46 47 struct xe_mmio *mmio; 48 }; 49 50 #if IS_ENABLED(CONFIG_I2C) 51 int xe_i2c_probe(struct xe_device *xe); 52 void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl); 53 void xe_i2c_pm_suspend(struct xe_device *xe); 54 void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold); 55 #else xe_i2c_probe(struct xe_device * xe)56static inline int xe_i2c_probe(struct xe_device *xe) { return 0; } xe_i2c_irq_handler(struct xe_device * xe,u32 master_ctl)57static inline void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl) { } xe_i2c_pm_suspend(struct xe_device * xe)58static inline void xe_i2c_pm_suspend(struct xe_device *xe) { } xe_i2c_pm_resume(struct xe_device * xe,bool d3cold)59static inline void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold) { } 60 #endif 61 62 #endif 63