/* SPDX-License-Identifier: GPL-2.0-only */
/*
* NAU85L40 ALSA SoC audio driver
*
* Copyright 2016 Nuvoton Technology Corp.
* Author: John Hsu <KCHSU0@nuvoton.com>
*/
#ifndef __NAU8540_H__
#define __NAU8540_H__
#define NAU8540_REG_SW_RESET 0 x00
#define NAU8540_REG_POWER_MANAGEMENT 0 x01
#define NAU8540_REG_CLOCK_CTRL 0 x02
#define NAU8540_REG_CLOCK_SRC 0 x03
#define NAU8540_REG_FLL1 0 x04
#define NAU8540_REG_FLL2 0 x05
#define NAU8540_REG_FLL3 0 x06
#define NAU8540_REG_FLL4 0 x07
#define NAU8540_REG_FLL5 0 x08
#define NAU8540_REG_FLL6 0 x09
#define NAU8540_REG_FLL_VCO_RSV 0 x0A
#define NAU8540_REG_PCM_CTRL0 0 x10
#define NAU8540_REG_PCM_CTRL1 0 x11
#define NAU8540_REG_PCM_CTRL2 0 x12
#define NAU8540_REG_PCM_CTRL3 0 x13
#define NAU8540_REG_PCM_CTRL4 0 x14
#define NAU8540_REG_ALC_CONTROL_1 0 x20
#define NAU8540_REG_ALC_CONTROL_2 0 x21
#define NAU8540_REG_ALC_CONTROL_3 0 x22
#define NAU8540_REG_ALC_CONTROL_4 0 x23
#define NAU8540_REG_ALC_CONTROL_5 0 x24
#define NAU8540_REG_ALC_GAIN_CH12 0 x2D
#define NAU8540_REG_ALC_GAIN_CH34 0 x2E
#define NAU8540_REG_ALC_STATUS 0 x2F
#define NAU8540_REG_NOTCH_FIL1_CH1 0 x30
#define NAU8540_REG_NOTCH_FIL2_CH1 0 x31
#define NAU8540_REG_NOTCH_FIL1_CH2 0 x32
#define NAU8540_REG_NOTCH_FIL2_CH2 0 x33
#define NAU8540_REG_NOTCH_FIL1_CH3 0 x34
#define NAU8540_REG_NOTCH_FIL2_CH3 0 x35
#define NAU8540_REG_NOTCH_FIL1_CH4 0 x36
#define NAU8540_REG_NOTCH_FIL2_CH4 0 x37
#define NAU8540_REG_HPF_FILTER_CH12 0 x38
#define NAU8540_REG_HPF_FILTER_CH34 0 x39
#define NAU8540_REG_ADC_SAMPLE_RATE 0 x3A
#define NAU8540_REG_DIGITAL_GAIN_CH1 0 x40
#define NAU8540_REG_DIGITAL_GAIN_CH2 0 x41
#define NAU8540_REG_DIGITAL_GAIN_CH3 0 x42
#define NAU8540_REG_DIGITAL_GAIN_CH4 0 x43
#define NAU8540_REG_DIGITAL_MUX 0 x44
#define NAU8540_REG_P2P_CH1 0 x48
#define NAU8540_REG_P2P_CH2 0 x49
#define NAU8540_REG_P2P_CH3 0 x4A
#define NAU8540_REG_P2P_CH4 0 x4B
#define NAU8540_REG_PEAK_CH1 0 x4C
#define NAU8540_REG_PEAK_CH2 0 x4D
#define NAU8540_REG_PEAK_CH3 0 x4E
#define NAU8540_REG_PEAK_CH4 0 x4F
#define NAU8540_REG_GPIO_CTRL 0 x50
#define NAU8540_REG_MISC_CTRL 0 x51
#define NAU8540_REG_I2C_CTRL 0 x52
#define NAU8540_REG_I2C_DEVICE_ID 0 x58
#define NAU8540_REG_RST 0 x5A
#define NAU8540_REG_VMID_CTRL 0 x60
#define NAU8540_REG_MUTE 0 x61
#define NAU8540_REG_ANALOG_ADC1 0 x64
#define NAU8540_REG_ANALOG_ADC2 0 x65
#define NAU8540_REG_ANALOG_PWR 0 x66
#define NAU8540_REG_MIC_BIAS 0 x67
#define NAU8540_REG_REFERENCE 0 x68
#define NAU8540_REG_FEPGA1 0 x69
#define NAU8540_REG_FEPGA2 0 x6A
#define NAU8540_REG_FEPGA3 0 x6B
#define NAU8540_REG_FEPGA4 0 x6C
#define NAU8540_REG_PWR 0 x6D
#define NAU8540_REG_MAX NAU8540_REG_PWR
/* POWER_MANAGEMENT (0x01) */
#define NAU8540_ADC_ALL_EN 0 xf
#define NAU8540_ADC4_EN (0 x1 << 3 )
#define NAU8540_ADC3_EN (0 x1 << 2 )
#define NAU8540_ADC2_EN (0 x1 << 1 )
#define NAU8540_ADC1_EN 0 x1
/* CLOCK_CTRL (0x02) */
#define NAU8540_CLK_ADC_EN (0 x1 << 15 )
#define NAU8540_CLK_AGC_EN (0 x1 << 3 )
#define NAU8540_CLK_I2S_EN (0 x1 << 1 )
/* CLOCK_SRC (0x03) */
#define NAU8540_CLK_SRC_SFT 15
#define NAU8540_CLK_SRC_MASK (1 << NAU8540_CLK_SRC_SFT)
#define NAU8540_CLK_SRC_VCO (1 << NAU8540_CLK_SRC_SFT)
#define NAU8540_CLK_SRC_MCLK (0 << NAU8540_CLK_SRC_SFT)
#define NAU8540_CLK_ADC_SRC_SFT 6
#define NAU8540_CLK_ADC_SRC_MASK (0 x3 << NAU8540_CLK_ADC_SRC_SFT)
#define NAU8540_CLK_MCLK_SRC_MASK 0 xf
/* FLL1 (0x04) */
#define NAU8540_ICTRL_LATCH_SFT 10
#define NAU8540_ICTRL_LATCH_MASK (0 x7 << NAU8540_ICTRL_LATCH_SFT)
#define NAU8540_FLL_RATIO_MASK 0 x7f
/* FLL3 (0x06) */
#define NAU8540_GAIN_ERR_SFT 12
#define NAU8540_GAIN_ERR_MASK (0 xf << NAU8540_GAIN_ERR_SFT)
#define NAU8540_FLL_CLK_SRC_SFT 10
#define NAU8540_FLL_CLK_SRC_MASK (0 x3 << NAU8540_FLL_CLK_SRC_SFT)
#define NAU8540_FLL_CLK_SRC_MCLK (0 << NAU8540_FLL_CLK_SRC_SFT)
#define NAU8540_FLL_CLK_SRC_BLK (0 x2 << NAU8540_FLL_CLK_SRC_SFT)
#define NAU8540_FLL_CLK_SRC_FS (0 x3 << NAU8540_FLL_CLK_SRC_SFT)
#define NAU8540_FLL_INTEGER_MASK 0 x3ff
/* FLL4 (0x07) */
#define NAU8540_FLL_REF_DIV_SFT 10
#define NAU8540_FLL_REF_DIV_MASK (0 x3 << NAU8540_FLL_REF_DIV_SFT)
/* FLL5 (0x08) */
#define NAU8540_FLL_PDB_DAC_EN (0 x1 << 15 )
#define NAU8540_FLL_LOOP_FTR_EN (0 x1 << 14 )
#define NAU8540_FLL_CLK_SW_MASK (0 x1 << 13 )
#define NAU8540_FLL_CLK_SW_N2 (0 x1 << 13 )
#define NAU8540_FLL_CLK_SW_REF (0 x0 << 13 )
#define NAU8540_FLL_FTR_SW_MASK (0 x1 << 12 )
#define NAU8540_FLL_FTR_SW_ACCU (0 x1 << 12 )
#define NAU8540_FLL_FTR_SW_FILTER (0 x0 << 12 )
/* FLL6 (0x9) */
#define NAU8540_DCO_EN (0 x1 << 15 )
#define NAU8540_SDM_EN (0 x1 << 14 )
#define NAU8540_CUTOFF500 (0 x1 << 13 )
/* PCM_CTRL0 (0x10) */
#define NAU8540_I2S_BP_SFT 7
#define NAU8540_I2S_BP_INV (0 x1 << NAU8540_I2S_BP_SFT)
#define NAU8540_I2S_PCMB_SFT 6
#define NAU8540_I2S_PCMB_EN (0 x1 << NAU8540_I2S_PCMB_SFT)
#define NAU8540_I2S_DL_SFT 2
#define NAU8540_I2S_DL_MASK (0 x3 << NAU8540_I2S_DL_SFT)
#define NAU8540_I2S_DL_16 (0 << NAU8540_I2S_DL_SFT)
#define NAU8540_I2S_DL_20 (0 x1 << NAU8540_I2S_DL_SFT)
#define NAU8540_I2S_DL_24 (0 x2 << NAU8540_I2S_DL_SFT)
#define NAU8540_I2S_DL_32 (0 x3 << NAU8540_I2S_DL_SFT)
#define NAU8540_I2S_DF_MASK 0 x3
#define NAU8540_I2S_DF_RIGTH 0
#define NAU8540_I2S_DF_LEFT 0 x1
#define NAU8540_I2S_DF_I2S 0 x2
#define NAU8540_I2S_DF_PCM_AB 0 x3
/* PCM_CTRL1 (0x11) */
#define NAU8540_I2S_DO12_TRI (0 x1 << 15 )
#define NAU8540_I2S_LRC_DIV_SFT 12
#define NAU8540_I2S_LRC_DIV_MASK (0 x3 << NAU8540_I2S_LRC_DIV_SFT)
#define NAU8540_I2S_DO12_OE (0 x1 << 4 )
#define NAU8540_I2S_MS_SFT 3
#define NAU8540_I2S_MS_MASK (0 x1 << NAU8540_I2S_MS_SFT)
#define NAU8540_I2S_MS_MASTER (0 x1 << NAU8540_I2S_MS_SFT)
#define NAU8540_I2S_MS_SLAVE (0 x0 << NAU8540_I2S_MS_SFT)
#define NAU8540_I2S_BLK_DIV_MASK 0 x7
/* PCM_CTRL1 (0x12) */
#define NAU8540_I2S_DO34_TRI (0 x1 << 15 )
#define NAU8540_I2S_DO34_OE (0 x1 << 11 )
#define NAU8540_I2S_TSLOT_L_MASK 0 x3ff
/* PCM_CTRL4 (0x14) */
#define NAU8540_TDM_MODE (0 x1 << 15 )
#define NAU8540_TDM_OFFSET_EN (0 x1 << 14 )
#define NAU8540_TDM_TX_MASK 0 xf
/* ALC_CONTROL_3 (0x22) */
#define NAU8540_ALC_CH1_EN (0 x1 << 12 )
#define NAU8540_ALC_CH2_EN (0 x1 << 13 )
#define NAU8540_ALC_CH3_EN (0 x1 << 14 )
#define NAU8540_ALC_CH4_EN (0 x1 << 15 )
#define NAU8540_ALC_CH_ALL_EN (0 xf << 12 )
/* ADC_SAMPLE_RATE (0x3A) */
#define NAU8540_CH_SYNC (0 x1 << 14 )
#define NAU8540_ADC_OSR_MASK 0 x3
#define NAU8540_ADC_OSR_256 0 x3
#define NAU8540_ADC_OSR_128 0 x2
#define NAU8540_ADC_OSR_64 0 x1
#define NAU8540_ADC_OSR_32 0 x0
/* VMID_CTRL (0x60) */
#define NAU8540_VMID_EN (1 << 6 )
#define NAU8540_VMID_SEL_SFT 4
#define NAU8540_VMID_SEL_MASK (0 x3 << NAU8540_VMID_SEL_SFT)
/* MUTE (0x61) */
#define NAU8540_PGA_CH1_MUTE 0 x1
#define NAU8540_PGA_CH2_MUTE 0 x2
#define NAU8540_PGA_CH3_MUTE 0 x4
#define NAU8540_PGA_CH4_MUTE 0 x8
#define NAU8540_PGA_CH_ALL_MUTE 0 xf
/* MIC_BIAS (0x67) */
#define NAU8540_PU_PRE (0 x1 << 8 )
/* REFERENCE (0x68) */
#define NAU8540_PRECHARGE_DIS (0 x1 << 13 )
#define NAU8540_GLOBAL_BIAS_EN (0 x1 << 12 )
#define NAU8540_DISCHRG_EN (0 x1 << 11 )
/* FEPGA1 (0x69) */
#define NAU8540_FEPGA1_MODCH2_SHT_SFT 7
#define NAU8540_FEPGA1_MODCH2_SHT (0 x1 << NAU8540_FEPGA1_MODCH2_SHT_SFT)
#define NAU8540_FEPGA1_MODCH1_SHT_SFT 3
#define NAU8540_FEPGA1_MODCH1_SHT (0 x1 << NAU8540_FEPGA1_MODCH1_SHT_SFT)
/* FEPGA2 (0x6A) */
#define NAU8540_FEPGA2_MODCH4_SHT_SFT 7
#define NAU8540_FEPGA2_MODCH4_SHT (0 x1 << NAU8540_FEPGA2_MODCH4_SHT_SFT)
#define NAU8540_FEPGA2_MODCH3_SHT_SFT 3
#define NAU8540_FEPGA2_MODCH3_SHT (0 x1 << NAU8540_FEPGA2_MODCH3_SHT_SFT)
#define NAU8540_ACDC_CTL_SFT 8
#define NAU8540_ACDC_CTL_MASK (0 xff << NAU8540_ACDC_CTL_SFT)
#define NAU8540_ACDC_CTL_MIC4N_VREF (0 x1 << 15 )
#define NAU8540_ACDC_CTL_MIC4P_VREF (0 x1 << 14 )
#define NAU8540_ACDC_CTL_MIC3N_VREF (0 x1 << 13 )
#define NAU8540_ACDC_CTL_MIC3P_VREF (0 x1 << 12 )
#define NAU8540_ACDC_CTL_MIC2N_VREF (0 x1 << 11 )
#define NAU8540_ACDC_CTL_MIC2P_VREF (0 x1 << 10 )
#define NAU8540_ACDC_CTL_MIC1N_VREF (0 x1 << 9 )
#define NAU8540_ACDC_CTL_MIC1P_VREF (0 x1 << 8 )
/* System Clock Source */
enum {
NAU8540_CLK_DIS,
NAU8540_CLK_MCLK,
NAU8540_CLK_INTERNAL,
NAU8540_CLK_FLL_MCLK,
NAU8540_CLK_FLL_BLK,
NAU8540_CLK_FLL_FS,
};
struct nau8540 {
struct device *dev;
struct regmap *regmap;
};
struct nau8540_fll {
int mclk_src;
int ratio;
int fll_frac;
int fll_int;
int clk_ref_div;
};
struct nau8540_fll_attr {
unsigned int param;
unsigned int val;
};
/* over sampling rate */
struct nau8540_osr_attr {
unsigned int osr;
unsigned int clk_src;
};
#endif /* __NAU8540_H__ */
Messung V0.5 in Prozent C=91 H=100 G=95
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-04)
¤
*© Formatika GbR, Deutschland