| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * rt5677.h -- RT5677 ALSA SoC audio driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2013 Realtek Semiconductor Corp. |
|---|
| 5 | 6 | * 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. |
|---|
| 10 | 7 | */ |
|---|
| 11 | 8 | |
|---|
| 12 | 9 | #ifndef __RT5677_H__ |
|---|
| .. | .. |
|---|
| 1339 | 1336 | #define RT5677_PLL_M_SFT 12 |
|---|
| 1340 | 1337 | #define RT5677_PLL_M_BP (0x1 << 11) |
|---|
| 1341 | 1338 | #define RT5677_PLL_M_BP_SFT 11 |
|---|
| 1339 | +#define RT5677_PLL_UPDATE_PLL1 (0x1 << 1) |
|---|
| 1340 | +#define RT5677_PLL_UPDATE_PLL1_SFT 1 |
|---|
| 1342 | 1341 | |
|---|
| 1343 | 1342 | /* Global Clock Control 1 (0x80) */ |
|---|
| 1344 | 1343 | #define RT5677_SCLK_SRC_MASK (0x3 << 14) |
|---|
| .. | .. |
|---|
| 1456 | 1455 | #define RT5677_I2S4_CLK_SEL_MASK (0xf) |
|---|
| 1457 | 1456 | #define RT5677_I2S4_CLK_SEL_SFT 0 |
|---|
| 1458 | 1457 | |
|---|
| 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 | + |
|---|
| 1459 | 1480 | /* 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) |
|---|
| 1461 | 1486 | #define RT5677_VAD_SRC_SFT 8 |
|---|
| 1487 | +#define RT5677_VAD_LV_DIFF_MASK (0xff << 0) |
|---|
| 1488 | +#define RT5677_VAD_LV_DIFF_SFT 0 |
|---|
| 1462 | 1489 | |
|---|
| 1463 | 1490 | /* DSP InBound Control (0xa3) */ |
|---|
| 1464 | 1491 | #define RT5677_IB01_SRC_MASK (0x7 << 12) |
|---|
| .. | .. |
|---|
| 1636 | 1663 | #define RT5677_GPIO6_P_NOR (0x0 << 0) |
|---|
| 1637 | 1664 | #define RT5677_GPIO6_P_INV (0x1 << 0) |
|---|
| 1638 | 1665 | |
|---|
| 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 | + |
|---|
| 1639 | 1672 | /* Virtual DSP Mixer Control (0xf7 0xf8 0xf9) */ |
|---|
| 1640 | 1673 | #define RT5677_DSP_IB_01_H (0x1 << 15) |
|---|
| 1641 | 1674 | #define RT5677_DSP_IB_01_H_SFT 15 |
|---|
| .. | .. |
|---|
| 1674 | 1707 | #define RT5677_FIRMWARE1 "rt5677_dsp_fw1.bin" |
|---|
| 1675 | 1708 | #define RT5677_FIRMWARE2 "rt5677_dsp_fw2.bin" |
|---|
| 1676 | 1709 | |
|---|
| 1710 | +#define RT5677_DRV_NAME "rt5677" |
|---|
| 1711 | + |
|---|
| 1677 | 1712 | /* System Clock Source */ |
|---|
| 1678 | 1713 | enum { |
|---|
| 1679 | 1714 | RT5677_SCLK_S_MCLK, |
|---|
| .. | .. |
|---|
| 1697 | 1732 | RT5677_AIF4, |
|---|
| 1698 | 1733 | RT5677_AIF5, |
|---|
| 1699 | 1734 | RT5677_AIFS, |
|---|
| 1735 | + RT5677_DSPBUFF, |
|---|
| 1700 | 1736 | }; |
|---|
| 1701 | 1737 | |
|---|
| 1702 | 1738 | enum { |
|---|
| .. | .. |
|---|
| 1713 | 1749 | RT5677_IRQ_JD1, |
|---|
| 1714 | 1750 | RT5677_IRQ_JD2, |
|---|
| 1715 | 1751 | RT5677_IRQ_JD3, |
|---|
| 1752 | + RT5677_IRQ_NUM, |
|---|
| 1716 | 1753 | }; |
|---|
| 1717 | 1754 | |
|---|
| 1718 | 1755 | enum rt5677_type { |
|---|
| .. | .. |
|---|
| 1791 | 1828 | |
|---|
| 1792 | 1829 | struct rt5677_priv { |
|---|
| 1793 | 1830 | struct snd_soc_component *component; |
|---|
| 1831 | + struct device *dev; |
|---|
| 1794 | 1832 | struct rt5677_platform_data pdata; |
|---|
| 1795 | 1833 | struct regmap *regmap, *regmap_physical; |
|---|
| 1796 | 1834 | const struct firmware *fw1, *fw2; |
|---|
| .. | .. |
|---|
| 1810 | 1848 | #ifdef CONFIG_GPIOLIB |
|---|
| 1811 | 1849 | struct gpio_chip gpio_chip; |
|---|
| 1812 | 1850 | #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 */ |
|---|
| 1815 | 1853 | bool is_dsp_mode; |
|---|
| 1816 | 1854 | 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); |
|---|
| 1817 | 1865 | }; |
|---|
| 1818 | 1866 | |
|---|
| 1819 | 1867 | int rt5677_sel_asrc_clk_src(struct snd_soc_component *component, |
|---|