162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci#ifndef __Q6AFE_H__ 462306a36Sopenharmony_ci#define __Q6AFE_H__ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <dt-bindings/sound/qcom,q6afe.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#define AFE_PORT_MAX 129 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#define MSM_AFE_PORT_TYPE_RX 0 1162306a36Sopenharmony_ci#define MSM_AFE_PORT_TYPE_TX 1 1262306a36Sopenharmony_ci#define AFE_MAX_PORTS AFE_PORT_MAX 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#define Q6AFE_MAX_MI2S_LINES 4 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define AFE_MAX_CHAN_COUNT 8 1762306a36Sopenharmony_ci#define AFE_PORT_MAX_AUDIO_CHAN_CNT 0x8 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_SRC_INTERNAL 1 2062306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ROOT_DEFAULT 0 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#define LPAIF_DIG_CLK 1 2362306a36Sopenharmony_ci#define LPAIF_BIT_CLK 2 2462306a36Sopenharmony_ci#define LPAIF_OSR_CLK 3 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* Clock ID for Primary I2S IBIT */ 2762306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT 0x100 2862306a36Sopenharmony_ci/* Clock ID for Primary I2S EBIT */ 2962306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT 0x101 3062306a36Sopenharmony_ci/* Clock ID for Secondary I2S IBIT */ 3162306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT 0x102 3262306a36Sopenharmony_ci/* Clock ID for Secondary I2S EBIT */ 3362306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT 0x103 3462306a36Sopenharmony_ci/* Clock ID for Tertiary I2S IBIT */ 3562306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT 0x104 3662306a36Sopenharmony_ci/* Clock ID for Tertiary I2S EBIT */ 3762306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT 0x105 3862306a36Sopenharmony_ci/* Clock ID for Quartnery I2S IBIT */ 3962306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT 0x106 4062306a36Sopenharmony_ci/* Clock ID for Quartnery I2S EBIT */ 4162306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT 0x107 4262306a36Sopenharmony_ci/* Clock ID for Speaker I2S IBIT */ 4362306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_IBIT 0x108 4462306a36Sopenharmony_ci/* Clock ID for Speaker I2S EBIT */ 4562306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_EBIT 0x109 4662306a36Sopenharmony_ci/* Clock ID for Speaker I2S OSR */ 4762306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SPEAKER_I2S_OSR 0x10A 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* Clock ID for QUINARY I2S IBIT */ 5062306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT 0x10B 5162306a36Sopenharmony_ci/* Clock ID for QUINARY I2S EBIT */ 5262306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUI_MI2S_EBIT 0x10C 5362306a36Sopenharmony_ci/* Clock ID for SENARY I2S IBIT */ 5462306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT 0x10D 5562306a36Sopenharmony_ci/* Clock ID for SENARY I2S EBIT */ 5662306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SEN_MI2S_EBIT 0x10E 5762306a36Sopenharmony_ci/* Clock ID for INT0 I2S IBIT */ 5862306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT 0x10F 5962306a36Sopenharmony_ci/* Clock ID for INT1 I2S IBIT */ 6062306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INT1_MI2S_IBIT 0x110 6162306a36Sopenharmony_ci/* Clock ID for INT2 I2S IBIT */ 6262306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INT2_MI2S_IBIT 0x111 6362306a36Sopenharmony_ci/* Clock ID for INT3 I2S IBIT */ 6462306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INT3_MI2S_IBIT 0x112 6562306a36Sopenharmony_ci/* Clock ID for INT4 I2S IBIT */ 6662306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INT4_MI2S_IBIT 0x113 6762306a36Sopenharmony_ci/* Clock ID for INT5 I2S IBIT */ 6862306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INT5_MI2S_IBIT 0x114 6962306a36Sopenharmony_ci/* Clock ID for INT6 I2S IBIT */ 7062306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INT6_MI2S_IBIT 0x115 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* Clock ID for QUINARY MI2S OSR CLK */ 7362306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUI_MI2S_OSR 0x116 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/* Clock ID for Primary PCM IBIT */ 7662306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT 0x200 7762306a36Sopenharmony_ci/* Clock ID for Primary PCM EBIT */ 7862306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT 0x201 7962306a36Sopenharmony_ci/* Clock ID for Secondary PCM IBIT */ 8062306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT 0x202 8162306a36Sopenharmony_ci/* Clock ID for Secondary PCM EBIT */ 8262306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT 0x203 8362306a36Sopenharmony_ci/* Clock ID for Tertiary PCM IBIT */ 8462306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT 0x204 8562306a36Sopenharmony_ci/* Clock ID for Tertiary PCM EBIT */ 8662306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT 0x205 8762306a36Sopenharmony_ci/* Clock ID for Quartery PCM IBIT */ 8862306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT 0x206 8962306a36Sopenharmony_ci/* Clock ID for Quartery PCM EBIT */ 9062306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT 0x207 9162306a36Sopenharmony_ci/* Clock ID for Quinary PCM IBIT */ 9262306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUIN_PCM_IBIT 0x208 9362306a36Sopenharmony_ci/* Clock ID for Quinary PCM EBIT */ 9462306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUIN_PCM_EBIT 0x209 9562306a36Sopenharmony_ci/* Clock ID for QUINARY PCM OSR */ 9662306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUI_PCM_OSR 0x20A 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci/** Clock ID for Primary TDM IBIT */ 9962306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT 0x200 10062306a36Sopenharmony_ci/** Clock ID for Primary TDM EBIT */ 10162306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT 0x201 10262306a36Sopenharmony_ci/** Clock ID for Secondary TDM IBIT */ 10362306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT 0x202 10462306a36Sopenharmony_ci/** Clock ID for Secondary TDM EBIT */ 10562306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT 0x203 10662306a36Sopenharmony_ci/** Clock ID for Tertiary TDM IBIT */ 10762306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT 0x204 10862306a36Sopenharmony_ci/** Clock ID for Tertiary TDM EBIT */ 10962306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT 0x205 11062306a36Sopenharmony_ci/** Clock ID for Quartery TDM IBIT */ 11162306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT 0x206 11262306a36Sopenharmony_ci/** Clock ID for Quartery TDM EBIT */ 11362306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT 0x207 11462306a36Sopenharmony_ci/** Clock ID for Quinary TDM IBIT */ 11562306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT 0x208 11662306a36Sopenharmony_ci/** Clock ID for Quinary TDM EBIT */ 11762306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT 0x209 11862306a36Sopenharmony_ci/** Clock ID for Quinary TDM OSR */ 11962306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_QUIN_TDM_OSR 0x20A 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci/* Clock ID for MCLK1 */ 12262306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_MCLK_1 0x300 12362306a36Sopenharmony_ci/* Clock ID for MCLK2 */ 12462306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_MCLK_2 0x301 12562306a36Sopenharmony_ci/* Clock ID for MCLK3 */ 12662306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_MCLK_3 0x302 12762306a36Sopenharmony_ci/* Clock ID for MCLK4 */ 12862306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_MCLK_4 0x304 12962306a36Sopenharmony_ci/* Clock ID for Internal Digital Codec Core */ 13062306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INTERNAL_DIGITAL_CODEC_CORE 0x303 13162306a36Sopenharmony_ci/* Clock ID for INT MCLK0 */ 13262306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INT_MCLK_0 0x305 13362306a36Sopenharmony_ci/* Clock ID for INT MCLK1 */ 13462306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_INT_MCLK_1 0x306 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_WSA_CORE_MCLK 0x309 13762306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_WSA_CORE_NPL_MCLK 0x30a 13862306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_TX_CORE_MCLK 0x30c 13962306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_TX_CORE_NPL_MCLK 0x30d 14062306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_RX_CORE_MCLK 0x30e 14162306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_RX_CORE_NPL_MCLK 0x30f 14262306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_VA_CORE_MCLK 0x30b 14362306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ID_VA_CORE_2X_MCLK 0x310 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci#define Q6AFE_LPASS_CORE_AVTIMER_BLOCK 0x2 14662306a36Sopenharmony_ci#define Q6AFE_LPASS_CORE_HW_MACRO_BLOCK 0x3 14762306a36Sopenharmony_ci#define Q6AFE_LPASS_CORE_HW_DCODEC_BLOCK 0x4 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci/* Clock attribute for invalid use (reserved for internal usage) */ 15062306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ATTRIBUTE_INVALID 0x0 15162306a36Sopenharmony_ci/* Clock attribute for no couple case */ 15262306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO 0x1 15362306a36Sopenharmony_ci/* Clock attribute for dividend couple case */ 15462306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_DIVIDEND 0x2 15562306a36Sopenharmony_ci/* Clock attribute for divisor couple case */ 15662306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_DIVISOR 0x3 15762306a36Sopenharmony_ci/* Clock attribute for invert and no couple case */ 15862306a36Sopenharmony_ci#define Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO 0x4 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci#define Q6AFE_CMAP_INVALID 0xFFFF 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_cistruct q6afe_hdmi_cfg { 16362306a36Sopenharmony_ci u16 datatype; 16462306a36Sopenharmony_ci u16 channel_allocation; 16562306a36Sopenharmony_ci u32 sample_rate; 16662306a36Sopenharmony_ci u16 bit_width; 16762306a36Sopenharmony_ci}; 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_cistruct q6afe_slim_cfg { 17062306a36Sopenharmony_ci u32 sample_rate; 17162306a36Sopenharmony_ci u16 bit_width; 17262306a36Sopenharmony_ci u16 data_format; 17362306a36Sopenharmony_ci u16 num_channels; 17462306a36Sopenharmony_ci u8 ch_mapping[AFE_MAX_CHAN_COUNT]; 17562306a36Sopenharmony_ci}; 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_cistruct q6afe_i2s_cfg { 17862306a36Sopenharmony_ci u32 sample_rate; 17962306a36Sopenharmony_ci u16 bit_width; 18062306a36Sopenharmony_ci u16 data_format; 18162306a36Sopenharmony_ci u16 num_channels; 18262306a36Sopenharmony_ci u32 sd_line_mask; 18362306a36Sopenharmony_ci int fmt; 18462306a36Sopenharmony_ci}; 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_cistruct q6afe_tdm_cfg { 18762306a36Sopenharmony_ci u16 num_channels; 18862306a36Sopenharmony_ci u32 sample_rate; 18962306a36Sopenharmony_ci u16 bit_width; 19062306a36Sopenharmony_ci u16 data_format; 19162306a36Sopenharmony_ci u16 sync_mode; 19262306a36Sopenharmony_ci u16 sync_src; 19362306a36Sopenharmony_ci u16 nslots_per_frame; 19462306a36Sopenharmony_ci u16 slot_width; 19562306a36Sopenharmony_ci u16 slot_mask; 19662306a36Sopenharmony_ci u32 data_align_type; 19762306a36Sopenharmony_ci u16 ch_mapping[AFE_MAX_CHAN_COUNT]; 19862306a36Sopenharmony_ci}; 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_cistruct q6afe_cdc_dma_cfg { 20162306a36Sopenharmony_ci u16 sample_rate; 20262306a36Sopenharmony_ci u16 bit_width; 20362306a36Sopenharmony_ci u16 data_format; 20462306a36Sopenharmony_ci u16 num_channels; 20562306a36Sopenharmony_ci u16 active_channels_mask; 20662306a36Sopenharmony_ci}; 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_cistruct q6afe_port_config { 21062306a36Sopenharmony_ci struct q6afe_hdmi_cfg hdmi; 21162306a36Sopenharmony_ci struct q6afe_slim_cfg slim; 21262306a36Sopenharmony_ci struct q6afe_i2s_cfg i2s_cfg; 21362306a36Sopenharmony_ci struct q6afe_tdm_cfg tdm; 21462306a36Sopenharmony_ci struct q6afe_cdc_dma_cfg dma_cfg; 21562306a36Sopenharmony_ci}; 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_cistruct q6afe_port; 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_cistruct q6afe_port *q6afe_port_get_from_id(struct device *dev, int id); 22062306a36Sopenharmony_ciint q6afe_port_start(struct q6afe_port *port); 22162306a36Sopenharmony_ciint q6afe_port_stop(struct q6afe_port *port); 22262306a36Sopenharmony_civoid q6afe_port_put(struct q6afe_port *port); 22362306a36Sopenharmony_ciint q6afe_get_port_id(int index); 22462306a36Sopenharmony_civoid q6afe_hdmi_port_prepare(struct q6afe_port *port, 22562306a36Sopenharmony_ci struct q6afe_hdmi_cfg *cfg); 22662306a36Sopenharmony_civoid q6afe_slim_port_prepare(struct q6afe_port *port, 22762306a36Sopenharmony_ci struct q6afe_slim_cfg *cfg); 22862306a36Sopenharmony_ciint q6afe_i2s_port_prepare(struct q6afe_port *port, struct q6afe_i2s_cfg *cfg); 22962306a36Sopenharmony_civoid q6afe_tdm_port_prepare(struct q6afe_port *port, struct q6afe_tdm_cfg *cfg); 23062306a36Sopenharmony_civoid q6afe_cdc_dma_port_prepare(struct q6afe_port *port, 23162306a36Sopenharmony_ci struct q6afe_cdc_dma_cfg *cfg); 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ciint q6afe_port_set_sysclk(struct q6afe_port *port, int clk_id, 23462306a36Sopenharmony_ci int clk_src, int clk_root, 23562306a36Sopenharmony_ci unsigned int freq, int dir); 23662306a36Sopenharmony_ciint q6afe_set_lpass_clock(struct device *dev, int clk_id, int attri, 23762306a36Sopenharmony_ci int clk_root, unsigned int freq); 23862306a36Sopenharmony_ciint q6afe_vote_lpass_core_hw(struct device *dev, uint32_t hw_block_id, 23962306a36Sopenharmony_ci const char *client_name, uint32_t *client_handle); 24062306a36Sopenharmony_ciint q6afe_unvote_lpass_core_hw(struct device *dev, uint32_t hw_block_id, 24162306a36Sopenharmony_ci uint32_t client_handle); 24262306a36Sopenharmony_ci#endif /* __Q6AFE_H__ */ 243