1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2 /* Copyright(c) 2015-17 Intel Corporation. */
4 #ifndef __SDW_INTEL_LOCAL_H
5 #define __SDW_INTEL_LOCAL_H
8 * struct sdw_intel_link_res - Soundwire Intel link resource structure,
9 * typically populated by the controller driver.
10 * @hw_ops: platform-specific ops
11 * @mmio_base: mmio base of SoundWire registers
12 * @registers: Link IO registers base
13 * @shim: Audio shim pointer
14 * @alh: ALH (Audio Link Hub) pointer
15 * @irq: Interrupt line
16 * @ops: Shim callback ops
17 * @dev: device implementing hw_params and free callbacks
18 * @shim_lock: mutex to handle access to shared SHIM registers
19 * @shim_mask: global pointer to check SHIM register initialization
20 * @clock_stop_quirks: mask defining requested behavior on pm_suspend
21 * @link_mask: global mask needed for power-up/down sequences
22 * @cdns: Cadence master descriptor
23 * @list: used to walk-through all masters exposed by the same controller
25 struct sdw_intel_link_res {
26 const struct sdw_intel_hw_ops *hw_ops;
28 void __iomem *mmio_base; /* not strictly needed, useful for debug */
29 void __iomem *registers;
33 const struct sdw_intel_ops *ops;
35 struct mutex *shim_lock; /* protect shared registers */
37 u32 clock_stop_quirks;
39 struct sdw_cdns *cdns;
40 struct list_head list;
46 struct sdw_intel_link_res *link_res;
48 #ifdef CONFIG_DEBUG_FS
49 struct dentry *debugfs;
53 int intel_link_startup(struct auxiliary_device *auxdev);
54 int intel_link_process_wakeen_event(struct auxiliary_device *auxdev);
56 struct sdw_intel_link_dev {
57 struct auxiliary_device auxdev;
58 struct sdw_intel_link_res link_res;
61 #define auxiliary_dev_to_sdw_intel_link_dev(auxiliary_dev) \
62 container_of(auxiliary_dev, struct sdw_intel_link_dev, auxdev)
64 #define SDW_INTEL_CHECK_OPS(sdw, cb) ((sdw) && (sdw)->link_res && (sdw)->link_res->hw_ops && \
65 (sdw)->link_res->hw_ops->cb)
66 #define SDW_INTEL_OPS(sdw, cb) ((sdw)->link_res->hw_ops->cb)
68 static inline void sdw_intel_debugfs_init(struct sdw_intel *sdw)
70 if (SDW_INTEL_CHECK_OPS(sdw, debugfs_init))
71 SDW_INTEL_OPS(sdw, debugfs_init)(sdw);
74 static inline void sdw_intel_debugfs_exit(struct sdw_intel *sdw)
76 if (SDW_INTEL_CHECK_OPS(sdw, debugfs_exit))
77 SDW_INTEL_OPS(sdw, debugfs_exit)(sdw);
80 static inline int sdw_intel_register_dai(struct sdw_intel *sdw)
82 if (SDW_INTEL_CHECK_OPS(sdw, register_dai))
83 return SDW_INTEL_OPS(sdw, register_dai)(sdw);
87 static inline void sdw_intel_check_clock_stop(struct sdw_intel *sdw)
89 if (SDW_INTEL_CHECK_OPS(sdw, check_clock_stop))
90 SDW_INTEL_OPS(sdw, check_clock_stop)(sdw);
93 static inline int sdw_intel_start_bus(struct sdw_intel *sdw)
95 if (SDW_INTEL_CHECK_OPS(sdw, start_bus))
96 return SDW_INTEL_OPS(sdw, start_bus)(sdw);
100 static inline int sdw_intel_start_bus_after_reset(struct sdw_intel *sdw)
102 if (SDW_INTEL_CHECK_OPS(sdw, start_bus_after_reset))
103 return SDW_INTEL_OPS(sdw, start_bus_after_reset)(sdw);
107 static inline int sdw_intel_start_bus_after_clock_stop(struct sdw_intel *sdw)
109 if (SDW_INTEL_CHECK_OPS(sdw, start_bus_after_clock_stop))
110 return SDW_INTEL_OPS(sdw, start_bus_after_clock_stop)(sdw);
114 static inline int sdw_intel_stop_bus(struct sdw_intel *sdw, bool clock_stop)
116 if (SDW_INTEL_CHECK_OPS(sdw, stop_bus))
117 return SDW_INTEL_OPS(sdw, stop_bus)(sdw, clock_stop);
121 static inline int sdw_intel_link_power_up(struct sdw_intel *sdw)
123 if (SDW_INTEL_CHECK_OPS(sdw, link_power_up))
124 return SDW_INTEL_OPS(sdw, link_power_up)(sdw);
128 static inline int sdw_intel_link_power_down(struct sdw_intel *sdw)
130 if (SDW_INTEL_CHECK_OPS(sdw, link_power_down))
131 return SDW_INTEL_OPS(sdw, link_power_down)(sdw);
135 static inline int sdw_intel_shim_check_wake(struct sdw_intel *sdw)
137 if (SDW_INTEL_CHECK_OPS(sdw, shim_check_wake))
138 return SDW_INTEL_OPS(sdw, shim_check_wake)(sdw);
142 static inline void sdw_intel_shim_wake(struct sdw_intel *sdw, bool wake_enable)
144 if (SDW_INTEL_CHECK_OPS(sdw, shim_wake))
145 SDW_INTEL_OPS(sdw, shim_wake)(sdw, wake_enable);
148 #endif /* __SDW_INTEL_LOCAL_H */