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 platform_device *pdev; 34 struct i2c_adapter *adapter; 35 struct i2c_client *client[XE_I2C_MAX_CLIENTS]; 36 37 struct notifier_block bus_notifier; 38 struct work_struct work; 39 40 struct irq_domain *irqdomain; 41 int adapter_irq; 42 43 struct xe_i2c_endpoint ep; 44 struct device *drm_dev; 45 46 struct xe_mmio *mmio; 47 }; 48 49 #if IS_ENABLED(CONFIG_I2C) 50 int xe_i2c_probe(struct xe_device *xe); 51 bool xe_i2c_present(struct xe_device *xe); 52 void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl); 53 void xe_i2c_irq_postinstall(struct xe_device *xe); 54 void xe_i2c_irq_reset(struct xe_device *xe); 55 void xe_i2c_pm_suspend(struct xe_device *xe); 56 void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold); 57 #else 58 static inline int xe_i2c_probe(struct xe_device *xe) { return 0; } 59 static inline bool xe_i2c_present(struct xe_device *xe) { return false; } 60 static inline void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl) { } 61 static inline void xe_i2c_irq_postinstall(struct xe_device *xe) { } 62 static inline void xe_i2c_irq_reset(struct xe_device *xe) { } 63 static inline void xe_i2c_pm_suspend(struct xe_device *xe) { } 64 static inline void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold) { } 65 #endif 66 67 #endif 68