162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * rt1016.h -- RT1016 ALSA SoC audio amplifier driver 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright 2020 Realtek Semiconductor Corp. 662306a36Sopenharmony_ci * Author: Oder Chiou <oder_chiou@realtek.com> 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 962306a36Sopenharmony_ci * it under the terms of the GNU General Public License version 2 as 1062306a36Sopenharmony_ci * published by the Free Software Foundation. 1162306a36Sopenharmony_ci */ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#ifndef __RT1016_H__ 1462306a36Sopenharmony_ci#define __RT1016_H__ 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define RT1016_DEVICE_ID_VAL 0x6595 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#define RT1016_RESET 0x00 1962306a36Sopenharmony_ci#define RT1016_PADS_CTRL_1 0x01 2062306a36Sopenharmony_ci#define RT1016_PADS_CTRL_2 0x02 2162306a36Sopenharmony_ci#define RT1016_I2C_CTRL 0x03 2262306a36Sopenharmony_ci#define RT1016_VOL_CTRL_1 0x04 2362306a36Sopenharmony_ci#define RT1016_VOL_CTRL_2 0x05 2462306a36Sopenharmony_ci#define RT1016_VOL_CTRL_3 0x06 2562306a36Sopenharmony_ci#define RT1016_ANA_CTRL_1 0x07 2662306a36Sopenharmony_ci#define RT1016_MUX_SEL 0x08 2762306a36Sopenharmony_ci#define RT1016_RX_I2S_CTRL 0x09 2862306a36Sopenharmony_ci#define RT1016_ANA_FLAG 0x0a 2962306a36Sopenharmony_ci#define RT1016_VERSION2_ID 0x0c 3062306a36Sopenharmony_ci#define RT1016_VERSION1_ID 0x0d 3162306a36Sopenharmony_ci#define RT1016_VENDER_ID 0x0e 3262306a36Sopenharmony_ci#define RT1016_DEVICE_ID 0x0f 3362306a36Sopenharmony_ci#define RT1016_ANA_CTRL_2 0x11 3462306a36Sopenharmony_ci#define RT1016_TEST_SIGNAL 0x1c 3562306a36Sopenharmony_ci#define RT1016_TEST_CTRL_1 0x1d 3662306a36Sopenharmony_ci#define RT1016_TEST_CTRL_2 0x1e 3762306a36Sopenharmony_ci#define RT1016_TEST_CTRL_3 0x1f 3862306a36Sopenharmony_ci#define RT1016_CLOCK_1 0x20 3962306a36Sopenharmony_ci#define RT1016_CLOCK_2 0x21 4062306a36Sopenharmony_ci#define RT1016_CLOCK_3 0x22 4162306a36Sopenharmony_ci#define RT1016_CLOCK_4 0x23 4262306a36Sopenharmony_ci#define RT1016_CLOCK_5 0x24 4362306a36Sopenharmony_ci#define RT1016_CLOCK_6 0x25 4462306a36Sopenharmony_ci#define RT1016_CLOCK_7 0x26 4562306a36Sopenharmony_ci#define RT1016_I2S_CTRL 0x40 4662306a36Sopenharmony_ci#define RT1016_DAC_CTRL_1 0x60 4762306a36Sopenharmony_ci#define RT1016_SC_CTRL_1 0x80 4862306a36Sopenharmony_ci#define RT1016_SC_CTRL_2 0x81 4962306a36Sopenharmony_ci#define RT1016_SC_CTRL_3 0x82 5062306a36Sopenharmony_ci#define RT1016_SC_CTRL_4 0x83 5162306a36Sopenharmony_ci#define RT1016_SIL_DET 0xa0 5262306a36Sopenharmony_ci#define RT1016_SYS_CLK 0xc0 5362306a36Sopenharmony_ci#define RT1016_BIAS_CUR 0xc1 5462306a36Sopenharmony_ci#define RT1016_DAC_CTRL_2 0xc2 5562306a36Sopenharmony_ci#define RT1016_LDO_CTRL 0xc3 5662306a36Sopenharmony_ci#define RT1016_CLASSD_1 0xc4 5762306a36Sopenharmony_ci#define RT1016_PLL1 0xc5 5862306a36Sopenharmony_ci#define RT1016_PLL2 0xc6 5962306a36Sopenharmony_ci#define RT1016_PLL3 0xc7 6062306a36Sopenharmony_ci#define RT1016_CLASSD_2 0xc8 6162306a36Sopenharmony_ci#define RT1016_CLASSD_OUT 0xc9 6262306a36Sopenharmony_ci#define RT1016_CLASSD_3 0xca 6362306a36Sopenharmony_ci#define RT1016_CLASSD_4 0xcb 6462306a36Sopenharmony_ci#define RT1016_CLASSD_5 0xcc 6562306a36Sopenharmony_ci#define RT1016_PWR_CTRL 0xcf 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci/* global definition */ 6862306a36Sopenharmony_ci#define RT1016_L_VOL_MASK (0xff << 8) 6962306a36Sopenharmony_ci#define RT1016_L_VOL_SFT 8 7062306a36Sopenharmony_ci#define RT1016_R_VOL_MASK (0xff) 7162306a36Sopenharmony_ci#define RT1016_R_VOL_SFT 0 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci/* 0x04 */ 7462306a36Sopenharmony_ci#define RT1016_DA_MUTE_L_SFT 7 7562306a36Sopenharmony_ci#define RT1016_DA_MUTE_R_SFT 6 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci/* 0x20 */ 7862306a36Sopenharmony_ci#define RT1016_CLK_SYS_SEL_MASK (0x1 << 15) 7962306a36Sopenharmony_ci#define RT1016_CLK_SYS_SEL_SFT 15 8062306a36Sopenharmony_ci#define RT1016_CLK_SYS_SEL_MCLK (0x0 << 15) 8162306a36Sopenharmony_ci#define RT1016_CLK_SYS_SEL_PLL (0x1 << 15) 8262306a36Sopenharmony_ci#define RT1016_PLL_SEL_MASK (0x1 << 13) 8362306a36Sopenharmony_ci#define RT1016_PLL_SEL_SFT 13 8462306a36Sopenharmony_ci#define RT1016_PLL_SEL_MCLK (0x0 << 13) 8562306a36Sopenharmony_ci#define RT1016_PLL_SEL_BCLK (0x1 << 13) 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci/* 0x21 */ 8862306a36Sopenharmony_ci#define RT1016_FS_PD_MASK (0x7 << 13) 8962306a36Sopenharmony_ci#define RT1016_FS_PD_SFT 13 9062306a36Sopenharmony_ci#define RT1016_OSR_PD_MASK (0x3 << 10) 9162306a36Sopenharmony_ci#define RT1016_OSR_PD_SFT 10 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci/* 0x22 */ 9462306a36Sopenharmony_ci#define RT1016_PWR_DAC_FILTER (0x1 << 11) 9562306a36Sopenharmony_ci#define RT1016_PWR_DAC_FILTER_BIT 11 9662306a36Sopenharmony_ci#define RT1016_PWR_DACMOD (0x1 << 10) 9762306a36Sopenharmony_ci#define RT1016_PWR_DACMOD_BIT 10 9862306a36Sopenharmony_ci#define RT1016_PWR_CLK_FIFO (0x1 << 9) 9962306a36Sopenharmony_ci#define RT1016_PWR_CLK_FIFO_BIT 9 10062306a36Sopenharmony_ci#define RT1016_PWR_CLK_PUREDC (0x1 << 8) 10162306a36Sopenharmony_ci#define RT1016_PWR_CLK_PUREDC_BIT 8 10262306a36Sopenharmony_ci#define RT1016_PWR_SIL_DET (0x1 << 7) 10362306a36Sopenharmony_ci#define RT1016_PWR_SIL_DET_BIT 7 10462306a36Sopenharmony_ci#define RT1016_PWR_RC_25M (0x1 << 6) 10562306a36Sopenharmony_ci#define RT1016_PWR_RC_25M_BIT 6 10662306a36Sopenharmony_ci#define RT1016_PWR_PLL1 (0x1 << 5) 10762306a36Sopenharmony_ci#define RT1016_PWR_PLL1_BIT 5 10862306a36Sopenharmony_ci#define RT1016_PWR_ANA_CTRL (0x1 << 4) 10962306a36Sopenharmony_ci#define RT1016_PWR_ANA_CTRL_BIT 4 11062306a36Sopenharmony_ci#define RT1016_PWR_CLK_SYS (0x1 << 3) 11162306a36Sopenharmony_ci#define RT1016_PWR_CLK_SYS_BIT 3 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci/* 0x23 */ 11462306a36Sopenharmony_ci#define RT1016_PWR_LRCK_DET (0x1 << 15) 11562306a36Sopenharmony_ci#define RT1016_PWR_LRCK_DET_BIT 15 11662306a36Sopenharmony_ci#define RT1016_PWR_BCLK_DET (0x1 << 11) 11762306a36Sopenharmony_ci#define RT1016_PWR_BCLK_DET_BIT 11 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci/* 0x40 */ 12062306a36Sopenharmony_ci#define RT1016_I2S_BCLK_MS_MASK (0x1 << 15) 12162306a36Sopenharmony_ci#define RT1016_I2S_BCLK_MS_SFT 15 12262306a36Sopenharmony_ci#define RT1016_I2S_BCLK_MS_32 (0x0 << 15) 12362306a36Sopenharmony_ci#define RT1016_I2S_BCLK_MS_64 (0x1 << 15) 12462306a36Sopenharmony_ci#define RT1016_I2S_BCLK_POL_MASK (0x1 << 13) 12562306a36Sopenharmony_ci#define RT1016_I2S_BCLK_POL_SFT 13 12662306a36Sopenharmony_ci#define RT1016_I2S_BCLK_POL_NOR (0x0 << 13) 12762306a36Sopenharmony_ci#define RT1016_I2S_BCLK_POL_INV (0x1 << 13) 12862306a36Sopenharmony_ci#define RT1016_I2S_DATA_SWAP_MASK (0x1 << 10) 12962306a36Sopenharmony_ci#define RT1016_I2S_DATA_SWAP_SFT 10 13062306a36Sopenharmony_ci#define RT1016_I2S_DL_MASK (0x7 << 4) 13162306a36Sopenharmony_ci#define RT1016_I2S_DL_SFT 4 13262306a36Sopenharmony_ci#define RT1016_I2S_DL_16 (0x1 << 4) 13362306a36Sopenharmony_ci#define RT1016_I2S_DL_20 (0x2 << 4) 13462306a36Sopenharmony_ci#define RT1016_I2S_DL_24 (0x3 << 4) 13562306a36Sopenharmony_ci#define RT1016_I2S_DL_32 (0x4 << 4) 13662306a36Sopenharmony_ci#define RT1016_I2S_MS_MASK (0x1 << 3) 13762306a36Sopenharmony_ci#define RT1016_I2S_MS_SFT 3 13862306a36Sopenharmony_ci#define RT1016_I2S_MS_M (0x0 << 3) 13962306a36Sopenharmony_ci#define RT1016_I2S_MS_S (0x1 << 3) 14062306a36Sopenharmony_ci#define RT1016_I2S_DF_MASK (0x7 << 0) 14162306a36Sopenharmony_ci#define RT1016_I2S_DF_SFT 0 14262306a36Sopenharmony_ci#define RT1016_I2S_DF_I2S (0x0) 14362306a36Sopenharmony_ci#define RT1016_I2S_DF_LEFT (0x1) 14462306a36Sopenharmony_ci#define RT1016_I2S_DF_PCM_A (0x2) 14562306a36Sopenharmony_ci#define RT1016_I2S_DF_PCM_B (0x3) 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ci/* 0xa0 */ 14862306a36Sopenharmony_ci#define RT1016_SIL_DET_EN (0x1 << 15) 14962306a36Sopenharmony_ci#define RT1016_SIL_DET_EN_BIT 15 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ci/* 0xc2 */ 15262306a36Sopenharmony_ci#define RT1016_CKGEN_DAC (0x1 << 13) 15362306a36Sopenharmony_ci#define RT1016_CKGEN_DAC_BIT 13 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci/* 0xc4 */ 15662306a36Sopenharmony_ci#define RT1016_VCM_SLOW (0x1 << 6) 15762306a36Sopenharmony_ci#define RT1016_VCM_SLOW_BIT 6 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci/* 0xc5 */ 16062306a36Sopenharmony_ci#define RT1016_PLL_M_MAX 0xf 16162306a36Sopenharmony_ci#define RT1016_PLL_M_MASK (RT1016_PLL_M_MAX << 12) 16262306a36Sopenharmony_ci#define RT1016_PLL_M_SFT 12 16362306a36Sopenharmony_ci#define RT1016_PLL_M_BP (0x1 << 11) 16462306a36Sopenharmony_ci#define RT1016_PLL_M_BP_SFT 11 16562306a36Sopenharmony_ci#define RT1016_PLL_N_MAX 0x1ff 16662306a36Sopenharmony_ci#define RT1016_PLL_N_MASK (RT1016_PLL_N_MAX << 0) 16762306a36Sopenharmony_ci#define RT1016_PLL_N_SFT 0 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci/* 0xc6 */ 17062306a36Sopenharmony_ci#define RT1016_PLL2_EN (0x1 << 15) 17162306a36Sopenharmony_ci#define RT1016_PLL2_EN_BIT 15 17262306a36Sopenharmony_ci#define RT1016_PLL_K_BP (0x1 << 5) 17362306a36Sopenharmony_ci#define RT1016_PLL_K_BP_SFT 5 17462306a36Sopenharmony_ci#define RT1016_PLL_K_MAX 0x1f 17562306a36Sopenharmony_ci#define RT1016_PLL_K_MASK (RT1016_PLL_K_MAX) 17662306a36Sopenharmony_ci#define RT1016_PLL_K_SFT 0 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci/* 0xcf */ 17962306a36Sopenharmony_ci#define RT1016_PWR_BG_1_2 (0x1 << 12) 18062306a36Sopenharmony_ci#define RT1016_PWR_BG_1_2_BIT 12 18162306a36Sopenharmony_ci#define RT1016_PWR_MBIAS_BG (0x1 << 11) 18262306a36Sopenharmony_ci#define RT1016_PWR_MBIAS_BG_BIT 11 18362306a36Sopenharmony_ci#define RT1016_PWR_PLL (0x1 << 9) 18462306a36Sopenharmony_ci#define RT1016_PWR_PLL_BIT 9 18562306a36Sopenharmony_ci#define RT1016_PWR_BASIC (0x1 << 8) 18662306a36Sopenharmony_ci#define RT1016_PWR_BASIC_BIT 8 18762306a36Sopenharmony_ci#define RT1016_PWR_CLSD (0x1 << 7) 18862306a36Sopenharmony_ci#define RT1016_PWR_CLSD_BIT 7 18962306a36Sopenharmony_ci#define RT1016_PWR_25M (0x1 << 6) 19062306a36Sopenharmony_ci#define RT1016_PWR_25M_BIT 6 19162306a36Sopenharmony_ci#define RT1016_PWR_DACL (0x1 << 4) 19262306a36Sopenharmony_ci#define RT1016_PWR_DACL_BIT 4 19362306a36Sopenharmony_ci#define RT1016_PWR_DACR (0x1 << 3) 19462306a36Sopenharmony_ci#define RT1016_PWR_DACR_BIT 3 19562306a36Sopenharmony_ci#define RT1016_PWR_LDO2 (0x1 << 2) 19662306a36Sopenharmony_ci#define RT1016_PWR_LDO2_BIT 2 19762306a36Sopenharmony_ci#define RT1016_PWR_VREF (0x1 << 1) 19862306a36Sopenharmony_ci#define RT1016_PWR_VREF_BIT 1 19962306a36Sopenharmony_ci#define RT1016_PWR_MBIAS (0x1 << 0) 20062306a36Sopenharmony_ci#define RT1016_PWR_MBIAS_BIT 0 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci/* System Clock Source */ 20362306a36Sopenharmony_cienum { 20462306a36Sopenharmony_ci RT1016_SCLK_S_MCLK, 20562306a36Sopenharmony_ci RT1016_SCLK_S_PLL, 20662306a36Sopenharmony_ci}; 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci/* PLL1 Source */ 20962306a36Sopenharmony_cienum { 21062306a36Sopenharmony_ci RT1016_PLL_S_MCLK, 21162306a36Sopenharmony_ci RT1016_PLL_S_BCLK, 21262306a36Sopenharmony_ci}; 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_cienum { 21562306a36Sopenharmony_ci RT1016_AIF1, 21662306a36Sopenharmony_ci RT1016_AIFS, 21762306a36Sopenharmony_ci}; 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_cistruct rt1016_priv { 22062306a36Sopenharmony_ci struct snd_soc_component *component; 22162306a36Sopenharmony_ci struct regmap *regmap; 22262306a36Sopenharmony_ci int sysclk; 22362306a36Sopenharmony_ci int sysclk_src; 22462306a36Sopenharmony_ci int lrck; 22562306a36Sopenharmony_ci int bclk; 22662306a36Sopenharmony_ci int master; 22762306a36Sopenharmony_ci int pll_src; 22862306a36Sopenharmony_ci int pll_in; 22962306a36Sopenharmony_ci int pll_out; 23062306a36Sopenharmony_ci}; 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci#endif /* __RT1016_H__ */ 233