162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * rk3328 ALSA SoC Audio driver 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd All rights reserved. 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef _RK3328_CODEC_H 962306a36Sopenharmony_ci#define _RK3328_CODEC_H 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <linux/bitfield.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/* codec register */ 1462306a36Sopenharmony_ci#define CODEC_RESET (0x00 << 2) 1562306a36Sopenharmony_ci#define DAC_INIT_CTRL1 (0x03 << 2) 1662306a36Sopenharmony_ci#define DAC_INIT_CTRL2 (0x04 << 2) 1762306a36Sopenharmony_ci#define DAC_INIT_CTRL3 (0x05 << 2) 1862306a36Sopenharmony_ci#define DAC_PRECHARGE_CTRL (0x22 << 2) 1962306a36Sopenharmony_ci#define DAC_PWR_CTRL (0x23 << 2) 2062306a36Sopenharmony_ci#define DAC_CLK_CTRL (0x24 << 2) 2162306a36Sopenharmony_ci#define HPMIX_CTRL (0x25 << 2) 2262306a36Sopenharmony_ci#define DAC_SELECT (0x26 << 2) 2362306a36Sopenharmony_ci#define HPOUT_CTRL (0x27 << 2) 2462306a36Sopenharmony_ci#define HPOUTL_GAIN_CTRL (0x28 << 2) 2562306a36Sopenharmony_ci#define HPOUTR_GAIN_CTRL (0x29 << 2) 2662306a36Sopenharmony_ci#define HPOUT_POP_CTRL (0x2a << 2) 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci/* REG00: CODEC_RESET */ 2962306a36Sopenharmony_ci#define PWR_RST_BYPASS_DIS (0x0 << 6) 3062306a36Sopenharmony_ci#define PWR_RST_BYPASS_EN (0x1 << 6) 3162306a36Sopenharmony_ci#define DIG_CORE_RST (0x0 << 1) 3262306a36Sopenharmony_ci#define DIG_CORE_WORK (0x1 << 1) 3362306a36Sopenharmony_ci#define SYS_RST (0x0 << 0) 3462306a36Sopenharmony_ci#define SYS_WORK (0x1 << 0) 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci/* REG03: DAC_INIT_CTRL1 */ 3762306a36Sopenharmony_ci#define PIN_DIRECTION_MASK BIT(5) 3862306a36Sopenharmony_ci#define PIN_DIRECTION_IN (0x0 << 5) 3962306a36Sopenharmony_ci#define PIN_DIRECTION_OUT (0x1 << 5) 4062306a36Sopenharmony_ci#define DAC_I2S_MODE_MASK BIT(4) 4162306a36Sopenharmony_ci#define DAC_I2S_MODE_SLAVE (0x0 << 4) 4262306a36Sopenharmony_ci#define DAC_I2S_MODE_MASTER (0x1 << 4) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/* REG04: DAC_INIT_CTRL2 */ 4562306a36Sopenharmony_ci#define DAC_I2S_LRP_MASK BIT(7) 4662306a36Sopenharmony_ci#define DAC_I2S_LRP_NORMAL (0x0 << 7) 4762306a36Sopenharmony_ci#define DAC_I2S_LRP_REVERSAL (0x1 << 7) 4862306a36Sopenharmony_ci#define DAC_VDL_MASK GENMASK(6, 5) 4962306a36Sopenharmony_ci#define DAC_VDL_16BITS (0x0 << 5) 5062306a36Sopenharmony_ci#define DAC_VDL_20BITS (0x1 << 5) 5162306a36Sopenharmony_ci#define DAC_VDL_24BITS (0x2 << 5) 5262306a36Sopenharmony_ci#define DAC_VDL_32BITS (0x3 << 5) 5362306a36Sopenharmony_ci#define DAC_MODE_MASK GENMASK(4, 3) 5462306a36Sopenharmony_ci#define DAC_MODE_RJM (0x0 << 3) 5562306a36Sopenharmony_ci#define DAC_MODE_LJM (0x1 << 3) 5662306a36Sopenharmony_ci#define DAC_MODE_I2S (0x2 << 3) 5762306a36Sopenharmony_ci#define DAC_MODE_PCM (0x3 << 3) 5862306a36Sopenharmony_ci#define DAC_LR_SWAP_MASK BIT(2) 5962306a36Sopenharmony_ci#define DAC_LR_SWAP_DIS (0x0 << 2) 6062306a36Sopenharmony_ci#define DAC_LR_SWAP_EN (0x1 << 2) 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* REG05: DAC_INIT_CTRL3 */ 6362306a36Sopenharmony_ci#define DAC_WL_MASK GENMASK(3, 2) 6462306a36Sopenharmony_ci#define DAC_WL_16BITS (0x0 << 2) 6562306a36Sopenharmony_ci#define DAC_WL_20BITS (0x1 << 2) 6662306a36Sopenharmony_ci#define DAC_WL_24BITS (0x2 << 2) 6762306a36Sopenharmony_ci#define DAC_WL_32BITS (0x3 << 2) 6862306a36Sopenharmony_ci#define DAC_RST_MASK BIT(1) 6962306a36Sopenharmony_ci#define DAC_RST_EN (0x0 << 1) 7062306a36Sopenharmony_ci#define DAC_RST_DIS (0x1 << 1) 7162306a36Sopenharmony_ci#define DAC_BCP_MASK BIT(0) 7262306a36Sopenharmony_ci#define DAC_BCP_NORMAL (0x0 << 0) 7362306a36Sopenharmony_ci#define DAC_BCP_REVERSAL (0x1 << 0) 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/* REG22: DAC_PRECHARGE_CTRL */ 7662306a36Sopenharmony_ci#define DAC_CHARGE_XCHARGE_MASK BIT(7) 7762306a36Sopenharmony_ci#define DAC_CHARGE_DISCHARGE (0x0 << 7) 7862306a36Sopenharmony_ci#define DAC_CHARGE_PRECHARGE (0x1 << 7) 7962306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_64I_MASK BIT(6) 8062306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_64I (0x1 << 6) 8162306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_32I_MASK BIT(5) 8262306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_32I (0x1 << 5) 8362306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_16I_MASK BIT(4) 8462306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_16I (0x1 << 4) 8562306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_08I_MASK BIT(3) 8662306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_08I (0x1 << 3) 8762306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_04I_MASK BIT(2) 8862306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_04I (0x1 << 2) 8962306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_02I_MASK BIT(1) 9062306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_02I (0x1 << 1) 9162306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_I_MASK BIT(0) 9262306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_I (0x1 << 0) 9362306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_ALL_MASK GENMASK(6, 0) 9462306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_ALL_OFF 0x00 9562306a36Sopenharmony_ci#define DAC_CHARGE_CURRENT_ALL_ON 0x7f 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci/* REG23: DAC_PWR_CTRL */ 9862306a36Sopenharmony_ci#define DAC_PWR_MASK BIT(6) 9962306a36Sopenharmony_ci#define DAC_PWR_OFF (0x0 << 6) 10062306a36Sopenharmony_ci#define DAC_PWR_ON (0x1 << 6) 10162306a36Sopenharmony_ci#define DACL_PATH_REFV_MASK BIT(5) 10262306a36Sopenharmony_ci#define DACL_PATH_REFV_OFF (0x0 << 5) 10362306a36Sopenharmony_ci#define DACL_PATH_REFV_ON (0x1 << 5) 10462306a36Sopenharmony_ci#define HPOUTL_ZERO_CROSSING_MASK BIT(4) 10562306a36Sopenharmony_ci#define HPOUTL_ZERO_CROSSING_OFF (0x0 << 4) 10662306a36Sopenharmony_ci#define HPOUTL_ZERO_CROSSING_ON (0x1 << 4) 10762306a36Sopenharmony_ci#define DACR_PATH_REFV_MASK BIT(1) 10862306a36Sopenharmony_ci#define DACR_PATH_REFV_OFF (0x0 << 1) 10962306a36Sopenharmony_ci#define DACR_PATH_REFV_ON (0x1 << 1) 11062306a36Sopenharmony_ci#define HPOUTR_ZERO_CROSSING_MASK BIT(0) 11162306a36Sopenharmony_ci#define HPOUTR_ZERO_CROSSING_OFF (0x0 << 0) 11262306a36Sopenharmony_ci#define HPOUTR_ZERO_CROSSING_ON (0x1 << 0) 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci/* REG24: DAC_CLK_CTRL */ 11562306a36Sopenharmony_ci#define DACL_REFV_MASK BIT(7) 11662306a36Sopenharmony_ci#define DACL_REFV_OFF (0x0 << 7) 11762306a36Sopenharmony_ci#define DACL_REFV_ON (0x1 << 7) 11862306a36Sopenharmony_ci#define DACL_CLK_MASK BIT(6) 11962306a36Sopenharmony_ci#define DACL_CLK_OFF (0x0 << 6) 12062306a36Sopenharmony_ci#define DACL_CLK_ON (0x1 << 6) 12162306a36Sopenharmony_ci#define DACL_MASK BIT(5) 12262306a36Sopenharmony_ci#define DACL_OFF (0x0 << 5) 12362306a36Sopenharmony_ci#define DACL_ON (0x1 << 5) 12462306a36Sopenharmony_ci#define DACL_INIT_MASK BIT(4) 12562306a36Sopenharmony_ci#define DACL_INIT_OFF (0x0 << 4) 12662306a36Sopenharmony_ci#define DACL_INIT_ON (0x1 << 4) 12762306a36Sopenharmony_ci#define DACR_REFV_MASK BIT(3) 12862306a36Sopenharmony_ci#define DACR_REFV_OFF (0x0 << 3) 12962306a36Sopenharmony_ci#define DACR_REFV_ON (0x1 << 3) 13062306a36Sopenharmony_ci#define DACR_CLK_MASK BIT(2) 13162306a36Sopenharmony_ci#define DACR_CLK_OFF (0x0 << 2) 13262306a36Sopenharmony_ci#define DACR_CLK_ON (0x1 << 2) 13362306a36Sopenharmony_ci#define DACR_MASK BIT(1) 13462306a36Sopenharmony_ci#define DACR_OFF (0x0 << 1) 13562306a36Sopenharmony_ci#define DACR_ON (0x1 << 1) 13662306a36Sopenharmony_ci#define DACR_INIT_MASK BIT(0) 13762306a36Sopenharmony_ci#define DACR_INIT_OFF (0x0 << 0) 13862306a36Sopenharmony_ci#define DACR_INIT_ON (0x1 << 0) 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci/* REG25: HPMIX_CTRL*/ 14162306a36Sopenharmony_ci#define HPMIXL_MASK BIT(6) 14262306a36Sopenharmony_ci#define HPMIXL_DIS (0x0 << 6) 14362306a36Sopenharmony_ci#define HPMIXL_EN (0x1 << 6) 14462306a36Sopenharmony_ci#define HPMIXL_INIT_MASK BIT(5) 14562306a36Sopenharmony_ci#define HPMIXL_INIT_DIS (0x0 << 5) 14662306a36Sopenharmony_ci#define HPMIXL_INIT_EN (0x1 << 5) 14762306a36Sopenharmony_ci#define HPMIXL_INIT2_MASK BIT(4) 14862306a36Sopenharmony_ci#define HPMIXL_INIT2_DIS (0x0 << 4) 14962306a36Sopenharmony_ci#define HPMIXL_INIT2_EN (0x1 << 4) 15062306a36Sopenharmony_ci#define HPMIXR_MASK BIT(2) 15162306a36Sopenharmony_ci#define HPMIXR_DIS (0x0 << 2) 15262306a36Sopenharmony_ci#define HPMIXR_EN (0x1 << 2) 15362306a36Sopenharmony_ci#define HPMIXR_INIT_MASK BIT(1) 15462306a36Sopenharmony_ci#define HPMIXR_INIT_DIS (0x0 << 1) 15562306a36Sopenharmony_ci#define HPMIXR_INIT_EN (0x1 << 1) 15662306a36Sopenharmony_ci#define HPMIXR_INIT2_MASK BIT(0) 15762306a36Sopenharmony_ci#define HPMIXR_INIT2_DIS (0x0 << 0) 15862306a36Sopenharmony_ci#define HPMIXR_INIT2_EN (0x1 << 0) 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci/* REG26: DAC_SELECT */ 16162306a36Sopenharmony_ci#define DACL_SELECT_MASK BIT(4) 16262306a36Sopenharmony_ci#define DACL_UNSELECT (0x0 << 4) 16362306a36Sopenharmony_ci#define DACL_SELECT (0x1 << 4) 16462306a36Sopenharmony_ci#define DACR_SELECT_MASK BIT(0) 16562306a36Sopenharmony_ci#define DACR_UNSELECT (0x0 << 0) 16662306a36Sopenharmony_ci#define DACR_SELECT (0x1 << 0) 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci/* REG27: HPOUT_CTRL */ 16962306a36Sopenharmony_ci#define HPOUTL_MASK BIT(7) 17062306a36Sopenharmony_ci#define HPOUTL_DIS (0x0 << 7) 17162306a36Sopenharmony_ci#define HPOUTL_EN (0x1 << 7) 17262306a36Sopenharmony_ci#define HPOUTL_INIT_MASK BIT(6) 17362306a36Sopenharmony_ci#define HPOUTL_INIT_DIS (0x0 << 6) 17462306a36Sopenharmony_ci#define HPOUTL_INIT_EN (0x1 << 6) 17562306a36Sopenharmony_ci#define HPOUTL_MUTE_MASK BIT(5) 17662306a36Sopenharmony_ci#define HPOUTL_MUTE (0x0 << 5) 17762306a36Sopenharmony_ci#define HPOUTL_UNMUTE (0x1 << 5) 17862306a36Sopenharmony_ci#define HPOUTR_MASK BIT(4) 17962306a36Sopenharmony_ci#define HPOUTR_DIS (0x0 << 4) 18062306a36Sopenharmony_ci#define HPOUTR_EN (0x1 << 4) 18162306a36Sopenharmony_ci#define HPOUTR_INIT_MASK BIT(3) 18262306a36Sopenharmony_ci#define HPOUTR_INIT_DIS (0x0 << 3) 18362306a36Sopenharmony_ci#define HPOUTR_INIT_EN (0x1 << 3) 18462306a36Sopenharmony_ci#define HPOUTR_MUTE_MASK BIT(2) 18562306a36Sopenharmony_ci#define HPOUTR_MUTE (0x0 << 2) 18662306a36Sopenharmony_ci#define HPOUTR_UNMUTE (0x1 << 2) 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci/* REG28: HPOUTL_GAIN_CTRL */ 18962306a36Sopenharmony_ci#define HPOUTL_GAIN_MASK GENMASK(4, 0) 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci/* REG29: HPOUTR_GAIN_CTRL */ 19262306a36Sopenharmony_ci#define HPOUTR_GAIN_MASK GENMASK(4, 0) 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci/* REG2a: HPOUT_POP_CTRL */ 19562306a36Sopenharmony_ci#define HPOUTR_POP_MASK GENMASK(5, 4) 19662306a36Sopenharmony_ci#define HPOUTR_POP_XCHARGE (0x1 << 4) 19762306a36Sopenharmony_ci#define HPOUTR_POP_WORK (0x2 << 4) 19862306a36Sopenharmony_ci#define HPOUTL_POP_MASK GENMASK(1, 0) 19962306a36Sopenharmony_ci#define HPOUTL_POP_XCHARGE (0x1 << 0) 20062306a36Sopenharmony_ci#define HPOUTL_POP_WORK (0x2 << 0) 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci#define RK3328_HIFI 0 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_cistruct rk3328_reg_msk_val { 20562306a36Sopenharmony_ci unsigned int reg; 20662306a36Sopenharmony_ci unsigned int msk; 20762306a36Sopenharmony_ci unsigned int val; 20862306a36Sopenharmony_ci}; 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci#endif 211