| 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 | bool xe_i2c_present(struct xe_device *xe); |
| 53 | void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl); |
| 54 | void xe_i2c_irq_postinstall(struct xe_device *xe); |
| 55 | void xe_i2c_irq_reset(struct xe_device *xe); |
| 56 | void xe_i2c_pm_suspend(struct xe_device *xe); |
| 57 | void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold); |
| 58 | #else |
| 59 | static inline int xe_i2c_probe(struct xe_device *xe) { return 0; } |
| 60 | static inline bool xe_i2c_present(struct xe_device *xe) { return false; } |
| 61 | static inline void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl) { } |
| 62 | static inline void xe_i2c_irq_postinstall(struct xe_device *xe) { } |
| 63 | static inline void xe_i2c_irq_reset(struct xe_device *xe) { } |
| 64 | static inline void xe_i2c_pm_suspend(struct xe_device *xe) { } |
| 65 | static inline void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold) { } |
| 66 | #endif |
| 67 | |
| 68 | #endif |
| 69 |
