162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  skl-i2s.h - i2s blob mapping
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *  Copyright (C) 2017 Intel Corp
662306a36Sopenharmony_ci *  Author: Subhransu S. Prusty < subhransu.s.prusty@intel.com>
762306a36Sopenharmony_ci * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef __SOUND_SOC_SKL_I2S_H
1362306a36Sopenharmony_ci#define __SOUND_SOC_SKL_I2S_H
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define SKL_I2S_MAX_TIME_SLOTS		8
1662306a36Sopenharmony_ci#define SKL_MCLK_DIV_CLK_SRC_MASK	GENMASK(17, 16)
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define SKL_MNDSS_DIV_CLK_SRC_MASK	GENMASK(21, 20)
1962306a36Sopenharmony_ci#define SKL_SHIFT(x)			(ffs(x) - 1)
2062306a36Sopenharmony_ci#define SKL_MCLK_DIV_RATIO_MASK		GENMASK(11, 0)
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define is_legacy_blob(x) (x.signature != 0xEE)
2362306a36Sopenharmony_ci#define ext_to_legacy_blob(i2s_config_blob_ext) \
2462306a36Sopenharmony_ci	((struct skl_i2s_config_blob_legacy *) i2s_config_blob_ext)
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#define get_clk_src(mclk, mask) \
2762306a36Sopenharmony_ci		((mclk.mdivctrl & mask) >> SKL_SHIFT(mask))
2862306a36Sopenharmony_cistruct skl_i2s_config {
2962306a36Sopenharmony_ci	u32 ssc0;
3062306a36Sopenharmony_ci	u32 ssc1;
3162306a36Sopenharmony_ci	u32 sscto;
3262306a36Sopenharmony_ci	u32 sspsp;
3362306a36Sopenharmony_ci	u32 sstsa;
3462306a36Sopenharmony_ci	u32 ssrsa;
3562306a36Sopenharmony_ci	u32 ssc2;
3662306a36Sopenharmony_ci	u32 sspsp2;
3762306a36Sopenharmony_ci	u32 ssc3;
3862306a36Sopenharmony_ci	u32 ssioc;
3962306a36Sopenharmony_ci} __packed;
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_cistruct skl_i2s_config_mclk {
4262306a36Sopenharmony_ci	u32 mdivctrl;
4362306a36Sopenharmony_ci	u32 mdivr;
4462306a36Sopenharmony_ci};
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_cistruct skl_i2s_config_mclk_ext {
4762306a36Sopenharmony_ci	u32 mdivctrl;
4862306a36Sopenharmony_ci	u32 mdivr_count;
4962306a36Sopenharmony_ci	u32 mdivr[];
5062306a36Sopenharmony_ci} __packed;
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_cistruct skl_i2s_config_blob_signature {
5362306a36Sopenharmony_ci	u32 minor_ver : 8;
5462306a36Sopenharmony_ci	u32 major_ver : 8;
5562306a36Sopenharmony_ci	u32 resvdz : 8;
5662306a36Sopenharmony_ci	u32 signature : 8;
5762306a36Sopenharmony_ci} __packed;
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_cistruct skl_i2s_config_blob_header {
6062306a36Sopenharmony_ci	struct skl_i2s_config_blob_signature sig;
6162306a36Sopenharmony_ci	u32 size;
6262306a36Sopenharmony_ci};
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci/**
6562306a36Sopenharmony_ci * struct skl_i2s_config_blob_legacy - Structure defines I2S Gateway
6662306a36Sopenharmony_ci * configuration legacy blob
6762306a36Sopenharmony_ci *
6862306a36Sopenharmony_ci * @gtw_attr:		Gateway attribute for the I2S Gateway
6962306a36Sopenharmony_ci * @tdm_ts_group:	TDM slot mapping against channels in the Gateway.
7062306a36Sopenharmony_ci * @i2s_cfg:		I2S HW registers
7162306a36Sopenharmony_ci * @mclk:		MCLK clock source and divider values
7262306a36Sopenharmony_ci */
7362306a36Sopenharmony_cistruct skl_i2s_config_blob_legacy {
7462306a36Sopenharmony_ci	u32 gtw_attr;
7562306a36Sopenharmony_ci	u32 tdm_ts_group[SKL_I2S_MAX_TIME_SLOTS];
7662306a36Sopenharmony_ci	struct skl_i2s_config i2s_cfg;
7762306a36Sopenharmony_ci	struct skl_i2s_config_mclk mclk;
7862306a36Sopenharmony_ci};
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_cistruct skl_i2s_config_blob_ext {
8162306a36Sopenharmony_ci	u32 gtw_attr;
8262306a36Sopenharmony_ci	struct skl_i2s_config_blob_header hdr;
8362306a36Sopenharmony_ci	u32 tdm_ts_group[SKL_I2S_MAX_TIME_SLOTS];
8462306a36Sopenharmony_ci	struct skl_i2s_config i2s_cfg;
8562306a36Sopenharmony_ci	struct skl_i2s_config_mclk_ext mclk;
8662306a36Sopenharmony_ci} __packed;
8762306a36Sopenharmony_ci#endif /* __SOUND_SOC_SKL_I2S_H */
88