hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/codecs/rt5677.h
....@@ -1,12 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * rt5677.h -- RT5677 ALSA SoC audio driver
34 *
45 * Copyright 2013 Realtek Semiconductor Corp.
56 * Author: Oder Chiou <oder_chiou@realtek.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #ifndef __RT5677_H__
....@@ -1339,6 +1336,8 @@
13391336 #define RT5677_PLL_M_SFT 12
13401337 #define RT5677_PLL_M_BP (0x1 << 11)
13411338 #define RT5677_PLL_M_BP_SFT 11
1339
+#define RT5677_PLL_UPDATE_PLL1 (0x1 << 1)
1340
+#define RT5677_PLL_UPDATE_PLL1_SFT 1
13421341
13431342 /* Global Clock Control 1 (0x80) */
13441343 #define RT5677_SCLK_SRC_MASK (0x3 << 14)
....@@ -1456,9 +1455,37 @@
14561455 #define RT5677_I2S4_CLK_SEL_MASK (0xf)
14571456 #define RT5677_I2S4_CLK_SEL_SFT 0
14581457
1458
+/* VAD Function Control 1 (0x9c) */
1459
+#define RT5677_VAD_MIN_DUR_MASK (0x3 << 13)
1460
+#define RT5677_VAD_MIN_DUR_SFT 13
1461
+#define RT5677_VAD_ADPCM_BYPASS (1 << 10)
1462
+#define RT5677_VAD_ADPCM_BYPASS_BIT 10
1463
+#define RT5677_VAD_FG2ENC (1 << 9)
1464
+#define RT5677_VAD_FG2ENC_BIT 9
1465
+#define RT5677_VAD_BUF_OW (1 << 8)
1466
+#define RT5677_VAD_BUF_OW_BIT 8
1467
+#define RT5677_VAD_CLR_FLAG (1 << 7)
1468
+#define RT5677_VAD_CLR_FLAG_BIT 7
1469
+#define RT5677_VAD_BUF_POP (1 << 6)
1470
+#define RT5677_VAD_BUF_POP_BIT 6
1471
+#define RT5677_VAD_BUF_PUSH (1 << 5)
1472
+#define RT5677_VAD_BUF_PUSH_BIT 5
1473
+#define RT5677_VAD_DET_ENABLE (1 << 4)
1474
+#define RT5677_VAD_DET_ENABLE_BIT 4
1475
+#define RT5677_VAD_FUNC_ENABLE (1 << 3)
1476
+#define RT5677_VAD_FUNC_ENABLE_BIT 3
1477
+#define RT5677_VAD_FUNC_RESET (1 << 2)
1478
+#define RT5677_VAD_FUNC_RESET_BIT 2
1479
+
14591480 /* VAD Function Control 4 (0x9f) */
1460
-#define RT5677_VAD_SRC_MASK (0x7 << 8)
1481
+#define RT5677_VAD_OUT_SRC_RATE_MASK (0x1 << 11)
1482
+#define RT5677_VAD_OUT_SRC_RATE_SFT 11
1483
+#define RT5677_VAD_OUT_SRC_MASK (0x1 << 10)
1484
+#define RT5677_VAD_OUT_SRC_SFT 10
1485
+#define RT5677_VAD_SRC_MASK (0x3 << 8)
14611486 #define RT5677_VAD_SRC_SFT 8
1487
+#define RT5677_VAD_LV_DIFF_MASK (0xff << 0)
1488
+#define RT5677_VAD_LV_DIFF_SFT 0
14621489
14631490 /* DSP InBound Control (0xa3) */
14641491 #define RT5677_IB01_SRC_MASK (0x7 << 12)
....@@ -1636,6 +1663,12 @@
16361663 #define RT5677_GPIO6_P_NOR (0x0 << 0)
16371664 #define RT5677_GPIO6_P_INV (0x1 << 0)
16381665
1666
+/* General Control (0xfa) */
1667
+#define RT5677_IRQ_DEBOUNCE_SEL_MASK (0x3 << 3)
1668
+#define RT5677_IRQ_DEBOUNCE_SEL_MCLK (0x0 << 3)
1669
+#define RT5677_IRQ_DEBOUNCE_SEL_RC (0x1 << 3)
1670
+#define RT5677_IRQ_DEBOUNCE_SEL_SLIM (0x2 << 3)
1671
+
16391672 /* Virtual DSP Mixer Control (0xf7 0xf8 0xf9) */
16401673 #define RT5677_DSP_IB_01_H (0x1 << 15)
16411674 #define RT5677_DSP_IB_01_H_SFT 15
....@@ -1674,6 +1707,8 @@
16741707 #define RT5677_FIRMWARE1 "rt5677_dsp_fw1.bin"
16751708 #define RT5677_FIRMWARE2 "rt5677_dsp_fw2.bin"
16761709
1710
+#define RT5677_DRV_NAME "rt5677"
1711
+
16771712 /* System Clock Source */
16781713 enum {
16791714 RT5677_SCLK_S_MCLK,
....@@ -1697,6 +1732,7 @@
16971732 RT5677_AIF4,
16981733 RT5677_AIF5,
16991734 RT5677_AIFS,
1735
+ RT5677_DSPBUFF,
17001736 };
17011737
17021738 enum {
....@@ -1713,6 +1749,7 @@
17131749 RT5677_IRQ_JD1,
17141750 RT5677_IRQ_JD2,
17151751 RT5677_IRQ_JD3,
1752
+ RT5677_IRQ_NUM,
17161753 };
17171754
17181755 enum rt5677_type {
....@@ -1791,6 +1828,7 @@
17911828
17921829 struct rt5677_priv {
17931830 struct snd_soc_component *component;
1831
+ struct device *dev;
17941832 struct rt5677_platform_data pdata;
17951833 struct regmap *regmap, *regmap_physical;
17961834 const struct firmware *fw1, *fw2;
....@@ -1810,10 +1848,20 @@
18101848 #ifdef CONFIG_GPIOLIB
18111849 struct gpio_chip gpio_chip;
18121850 #endif
1813
- bool dsp_vad_en;
1814
- struct regmap_irq_chip_data *irq_data;
1851
+ bool dsp_vad_en_request; /* DSP VAD enable/disable request */
1852
+ bool dsp_vad_en; /* dsp_work parameter */
18151853 bool is_dsp_mode;
18161854 bool is_vref_slow;
1855
+ struct delayed_work dsp_work;
1856
+
1857
+ /* Interrupt handling */
1858
+ struct irq_domain *domain;
1859
+ struct mutex irq_lock;
1860
+ unsigned int irq_en;
1861
+ struct delayed_work resume_irq_check;
1862
+ int irq;
1863
+
1864
+ int (*set_dsp_vad)(struct snd_soc_component *component, bool on);
18171865 };
18181866
18191867 int rt5677_sel_asrc_clk_src(struct snd_soc_component *component,