0001
0002
0003
0004 #ifndef __SDW_INTEL_H
0005 #define __SDW_INTEL_H
0006
0007 #include <linux/irqreturn.h>
0008 #include <linux/soundwire/sdw.h>
0009
0010 #define SDW_SHIM_BASE 0x2C000
0011 #define SDW_ALH_BASE 0x2C800
0012 #define SDW_SHIM_BASE_ACE 0x38000
0013 #define SDW_ALH_BASE_ACE 0x24000
0014 #define SDW_LINK_BASE 0x30000
0015 #define SDW_LINK_SIZE 0x10000
0016
0017
0018 #define SDW_SHIM_LCAP 0x0
0019 #define SDW_SHIM_LCTL 0x4
0020 #define SDW_SHIM_IPPTR 0x8
0021 #define SDW_SHIM_SYNC 0xC
0022
0023 #define SDW_SHIM_CTLSCAP(x) (0x010 + 0x60 * (x))
0024 #define SDW_SHIM_CTLS0CM(x) (0x012 + 0x60 * (x))
0025 #define SDW_SHIM_CTLS1CM(x) (0x014 + 0x60 * (x))
0026 #define SDW_SHIM_CTLS2CM(x) (0x016 + 0x60 * (x))
0027 #define SDW_SHIM_CTLS3CM(x) (0x018 + 0x60 * (x))
0028 #define SDW_SHIM_PCMSCAP(x) (0x020 + 0x60 * (x))
0029
0030 #define SDW_SHIM_PCMSYCHM(x, y) (0x022 + (0x60 * (x)) + (0x2 * (y)))
0031 #define SDW_SHIM_PCMSYCHC(x, y) (0x042 + (0x60 * (x)) + (0x2 * (y)))
0032 #define SDW_SHIM_PDMSCAP(x) (0x062 + 0x60 * (x))
0033 #define SDW_SHIM_IOCTL(x) (0x06C + 0x60 * (x))
0034 #define SDW_SHIM_CTMCTL(x) (0x06E + 0x60 * (x))
0035
0036 #define SDW_SHIM_WAKEEN 0x190
0037 #define SDW_SHIM_WAKESTS 0x192
0038
0039 #define SDW_SHIM_LCTL_SPA BIT(0)
0040 #define SDW_SHIM_LCTL_SPA_MASK GENMASK(3, 0)
0041 #define SDW_SHIM_LCTL_CPA BIT(8)
0042 #define SDW_SHIM_LCTL_CPA_MASK GENMASK(11, 8)
0043
0044 #define SDW_SHIM_SYNC_SYNCPRD_VAL_24 (24000 / SDW_CADENCE_GSYNC_KHZ - 1)
0045 #define SDW_SHIM_SYNC_SYNCPRD_VAL_38_4 (38400 / SDW_CADENCE_GSYNC_KHZ - 1)
0046 #define SDW_SHIM_SYNC_SYNCPRD GENMASK(14, 0)
0047 #define SDW_SHIM_SYNC_SYNCCPU BIT(15)
0048 #define SDW_SHIM_SYNC_CMDSYNC_MASK GENMASK(19, 16)
0049 #define SDW_SHIM_SYNC_CMDSYNC BIT(16)
0050 #define SDW_SHIM_SYNC_SYNCGO BIT(24)
0051
0052 #define SDW_SHIM_PCMSCAP_ISS GENMASK(3, 0)
0053 #define SDW_SHIM_PCMSCAP_OSS GENMASK(7, 4)
0054 #define SDW_SHIM_PCMSCAP_BSS GENMASK(12, 8)
0055
0056 #define SDW_SHIM_PCMSYCM_LCHN GENMASK(3, 0)
0057 #define SDW_SHIM_PCMSYCM_HCHN GENMASK(7, 4)
0058 #define SDW_SHIM_PCMSYCM_STREAM GENMASK(13, 8)
0059 #define SDW_SHIM_PCMSYCM_DIR BIT(15)
0060
0061 #define SDW_SHIM_PDMSCAP_ISS GENMASK(3, 0)
0062 #define SDW_SHIM_PDMSCAP_OSS GENMASK(7, 4)
0063 #define SDW_SHIM_PDMSCAP_BSS GENMASK(12, 8)
0064 #define SDW_SHIM_PDMSCAP_CPSS GENMASK(15, 13)
0065
0066 #define SDW_SHIM_IOCTL_MIF BIT(0)
0067 #define SDW_SHIM_IOCTL_CO BIT(1)
0068 #define SDW_SHIM_IOCTL_COE BIT(2)
0069 #define SDW_SHIM_IOCTL_DO BIT(3)
0070 #define SDW_SHIM_IOCTL_DOE BIT(4)
0071 #define SDW_SHIM_IOCTL_BKE BIT(5)
0072 #define SDW_SHIM_IOCTL_WPDD BIT(6)
0073 #define SDW_SHIM_IOCTL_CIBD BIT(8)
0074 #define SDW_SHIM_IOCTL_DIBD BIT(9)
0075
0076 #define SDW_SHIM_CTMCTL_DACTQE BIT(0)
0077 #define SDW_SHIM_CTMCTL_DODS BIT(1)
0078 #define SDW_SHIM_CTMCTL_DOAIS GENMASK(4, 3)
0079
0080 #define SDW_SHIM_WAKEEN_ENABLE BIT(0)
0081 #define SDW_SHIM_WAKESTS_STATUS BIT(0)
0082
0083
0084 #define SDW_ALH_STRMZCFG(x) (0x000 + (0x4 * (x)))
0085 #define SDW_ALH_NUM_STREAMS 64
0086
0087 #define SDW_ALH_STRMZCFG_DMAT_VAL 0x3
0088 #define SDW_ALH_STRMZCFG_DMAT GENMASK(7, 0)
0089 #define SDW_ALH_STRMZCFG_CHN GENMASK(19, 16)
0090
0091
0092
0093
0094
0095
0096 struct sdw_intel_stream_params_data {
0097 int stream;
0098 struct snd_soc_dai *dai;
0099 struct snd_pcm_hw_params *hw_params;
0100 int link_id;
0101 int alh_stream_id;
0102 };
0103
0104
0105
0106
0107
0108
0109 struct sdw_intel_stream_free_data {
0110 int stream;
0111 struct snd_soc_dai *dai;
0112 int link_id;
0113 };
0114
0115
0116
0117
0118
0119 struct sdw_intel_ops {
0120 int (*params_stream)(struct device *dev,
0121 struct sdw_intel_stream_params_data *params_data);
0122 int (*free_stream)(struct device *dev,
0123 struct sdw_intel_stream_free_data *free_data);
0124 int (*trigger)(struct snd_soc_dai *dai, int cmd, int stream);
0125 };
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 struct sdw_intel_acpi_info {
0138 acpi_handle handle;
0139 int count;
0140 u32 link_mask;
0141 };
0142
0143 struct sdw_intel_link_dev;
0144
0145
0146
0147
0148
0149
0150
0151
0152 #define SDW_INTEL_CLK_STOP_NOT_ALLOWED BIT(0)
0153
0154
0155
0156
0157
0158
0159
0160 #define SDW_INTEL_CLK_STOP_TEARDOWN BIT(1)
0161
0162
0163
0164
0165
0166
0167 #define SDW_INTEL_CLK_STOP_WAKE_CAPABLE_ONLY BIT(2)
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 #define SDW_INTEL_CLK_STOP_BUS_RESET BIT(3)
0178
0179 struct sdw_intel_slave_id {
0180 int link_id;
0181 struct sdw_slave_id id;
0182 };
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204 struct sdw_intel_ctx {
0205 int count;
0206 void __iomem *mmio_base;
0207 u32 link_mask;
0208 int num_slaves;
0209 acpi_handle handle;
0210 struct sdw_intel_link_dev **ldev;
0211 struct sdw_intel_slave_id *ids;
0212 struct list_head link_list;
0213 struct mutex shim_lock;
0214 u32 shim_mask;
0215 u32 shim_base;
0216 u32 alh_base;
0217 };
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238 struct sdw_intel_res {
0239 int count;
0240 void __iomem *mmio_base;
0241 int irq;
0242 acpi_handle handle;
0243 struct device *parent;
0244 const struct sdw_intel_ops *ops;
0245 struct device *dev;
0246 u32 link_mask;
0247 u32 clock_stop_quirks;
0248 u32 shim_base;
0249 u32 alh_base;
0250 };
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264 int sdw_intel_acpi_scan(acpi_handle *parent_handle,
0265 struct sdw_intel_acpi_info *info);
0266
0267 void sdw_intel_process_wakeen_event(struct sdw_intel_ctx *ctx);
0268
0269 struct sdw_intel_ctx *
0270 sdw_intel_probe(struct sdw_intel_res *res);
0271
0272 int sdw_intel_startup(struct sdw_intel_ctx *ctx);
0273
0274 void sdw_intel_exit(struct sdw_intel_ctx *ctx);
0275
0276 void sdw_intel_enable_irq(void __iomem *mmio_base, bool enable);
0277
0278 irqreturn_t sdw_intel_thread(int irq, void *dev_id);
0279
0280 #define SDW_INTEL_QUIRK_MASK_BUS_DISABLE BIT(1)
0281
0282 #endif