18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  skl-i2s.h - i2s blob mapping
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2017 Intel Corp
68c2ecf20Sopenharmony_ci *  Author: Subhransu S. Prusty < subhransu.s.prusty@intel.com>
78c2ecf20Sopenharmony_ci * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef __SOUND_SOC_SKL_I2S_H
138c2ecf20Sopenharmony_ci#define __SOUND_SOC_SKL_I2S_H
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define SKL_I2S_MAX_TIME_SLOTS		8
168c2ecf20Sopenharmony_ci#define SKL_MCLK_DIV_CLK_SRC_MASK	GENMASK(17, 16)
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define SKL_MNDSS_DIV_CLK_SRC_MASK	GENMASK(21, 20)
198c2ecf20Sopenharmony_ci#define SKL_SHIFT(x)			(ffs(x) - 1)
208c2ecf20Sopenharmony_ci#define SKL_MCLK_DIV_RATIO_MASK		GENMASK(11, 0)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define is_legacy_blob(x) (x.signature != 0xEE)
238c2ecf20Sopenharmony_ci#define ext_to_legacy_blob(i2s_config_blob_ext) \
248c2ecf20Sopenharmony_ci	((struct skl_i2s_config_blob_legacy *) i2s_config_blob_ext)
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define get_clk_src(mclk, mask) \
278c2ecf20Sopenharmony_ci		((mclk.mdivctrl & mask) >> SKL_SHIFT(mask))
288c2ecf20Sopenharmony_cistruct skl_i2s_config {
298c2ecf20Sopenharmony_ci	u32 ssc0;
308c2ecf20Sopenharmony_ci	u32 ssc1;
318c2ecf20Sopenharmony_ci	u32 sscto;
328c2ecf20Sopenharmony_ci	u32 sspsp;
338c2ecf20Sopenharmony_ci	u32 sstsa;
348c2ecf20Sopenharmony_ci	u32 ssrsa;
358c2ecf20Sopenharmony_ci	u32 ssc2;
368c2ecf20Sopenharmony_ci	u32 sspsp2;
378c2ecf20Sopenharmony_ci	u32 ssc3;
388c2ecf20Sopenharmony_ci	u32 ssioc;
398c2ecf20Sopenharmony_ci} __packed;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistruct skl_i2s_config_mclk {
428c2ecf20Sopenharmony_ci	u32 mdivctrl;
438c2ecf20Sopenharmony_ci	u32 mdivr;
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_cistruct skl_i2s_config_mclk_ext {
478c2ecf20Sopenharmony_ci	u32 mdivctrl;
488c2ecf20Sopenharmony_ci	u32 mdivr_count;
498c2ecf20Sopenharmony_ci	u32 mdivr[];
508c2ecf20Sopenharmony_ci} __packed;
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistruct skl_i2s_config_blob_signature {
538c2ecf20Sopenharmony_ci	u32 minor_ver : 8;
548c2ecf20Sopenharmony_ci	u32 major_ver : 8;
558c2ecf20Sopenharmony_ci	u32 resvdz : 8;
568c2ecf20Sopenharmony_ci	u32 signature : 8;
578c2ecf20Sopenharmony_ci} __packed;
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cistruct skl_i2s_config_blob_header {
608c2ecf20Sopenharmony_ci	struct skl_i2s_config_blob_signature sig;
618c2ecf20Sopenharmony_ci	u32 size;
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/**
658c2ecf20Sopenharmony_ci * struct skl_i2s_config_blob_legacy - Structure defines I2S Gateway
668c2ecf20Sopenharmony_ci * configuration legacy blob
678c2ecf20Sopenharmony_ci *
688c2ecf20Sopenharmony_ci * @gtw_attr:		Gateway attribute for the I2S Gateway
698c2ecf20Sopenharmony_ci * @tdm_ts_group:	TDM slot mapping against channels in the Gateway.
708c2ecf20Sopenharmony_ci * @i2s_cfg:		I2S HW registers
718c2ecf20Sopenharmony_ci * @mclk:		MCLK clock source and divider values
728c2ecf20Sopenharmony_ci */
738c2ecf20Sopenharmony_cistruct skl_i2s_config_blob_legacy {
748c2ecf20Sopenharmony_ci	u32 gtw_attr;
758c2ecf20Sopenharmony_ci	u32 tdm_ts_group[SKL_I2S_MAX_TIME_SLOTS];
768c2ecf20Sopenharmony_ci	struct skl_i2s_config i2s_cfg;
778c2ecf20Sopenharmony_ci	struct skl_i2s_config_mclk mclk;
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistruct skl_i2s_config_blob_ext {
818c2ecf20Sopenharmony_ci	u32 gtw_attr;
828c2ecf20Sopenharmony_ci	struct skl_i2s_config_blob_header hdr;
838c2ecf20Sopenharmony_ci	u32 tdm_ts_group[SKL_I2S_MAX_TIME_SLOTS];
848c2ecf20Sopenharmony_ci	struct skl_i2s_config i2s_cfg;
858c2ecf20Sopenharmony_ci	struct skl_i2s_config_mclk_ext mclk;
868c2ecf20Sopenharmony_ci} __packed;
878c2ecf20Sopenharmony_ci#endif /* __SOUND_SOC_SKL_I2S_H */
88