1 /* SPDX-License-Identifier: GPL-2.0
3 * TDM driver for the StarFive JH7110 SoC
5 * Copyright (C) 2021 StarFive Technology Co., Ltd.
7 #ifndef __SND_SOC_STARFIVE_TDM_H
8 #define __SND_SOC_STARFIVE_TDM_H
10 #include <linux/clk.h>
11 #include <linux/device.h>
12 #include <linux/types.h>
13 #include <sound/dmaengine_pcm.h>
14 #include <sound/pcm.h>
15 #include <linux/dmaengine.h>
16 #include <linux/types.h>
18 #define TDM_PCMGBCR 0x00
19 #define PCMGBCR_MASK 0x1e
20 #define PCMGBCR_ENABLE BIT(0)
21 #define PCMGBCR_TRITXEN BIT(4)
27 #define TDM_PCMTXCR 0x04
28 #define PCMTXCR_TXEN BIT(0)
34 #define TDM_PCMRXCR 0x08
35 #define PCMRXCR_RXEN BIT(0)
36 #define PCMRXCR_RXSL_MASK 0xc
37 #define PCMRXCR_RXSL_16BIT 0x4
38 #define PCMRXCR_RXSL_32BIT 0x8
39 #define PCMRXCR_SCALE_MASK 0xf0
40 #define PCMRXCR_SCALE_1CH 0x10
41 #define TDM_PCMDIV 0x0c
44 #define TDM_FIFO 0x170c0000
45 #define TDM_FIFO_DEPTH 32
47 #define ONE_CHANNEL_SUPPORT 1
48 #define TWO_CHANNEL_SUPPORT 2
49 #define FOUR_CHANNEL_SUPPORT 4
50 #define SIX_CHANNEL_SUPPORT 6
51 #define EIGHT_CHANNEL_SUPPORT 8
53 enum TDM_MASTER_SLAVE_MODE {
59 /* tx raising and rx falling */
60 TDM_TX_RASING_RX_FALLING = 0,
61 /* tx falling and rx raising */
62 TDM_TX_FALLING_RX_RASING,
72 /* only work while SYNCM=0 */
78 /* short frame sync */
85 /* FIFO to send or received : half-1/2, Quarter-1/4 */
91 /* send or received word length */
92 TDM_8BIT_WORD_LEN = 0,
100 /* send or received slot length */
101 TDM_8BIT_SLOT_LEN = 0,
107 /* left-justify or right-justify */
108 TDM_RIGHT_JUSTIFY = 0,
112 typedef struct tdm_chan_cfg {
115 unsigned char sscale;
118 unsigned char enable;
122 void __iomem *tdm_base;
124 struct clk *clk_ahb0;
125 struct clk *clk_tdm_ahb;
126 struct clk *clk_apb0;
127 struct clk *clk_tdm_apb;
128 struct clk *clk_tdm_internal;
129 struct clk *clk_tdm_ext;
131 struct clk *clk_mclk_inner;
132 struct reset_control *resets;
135 enum TDM_CLKPOL clkpolity;
137 enum TDM_SYNCM syncm;
138 enum TDM_MASTER_SLAVE_MODE ms_mode;
139 enum TDM_FRAME_MODE frame_mode;
140 unsigned char tritxen;
149 /* data related to DMA transfers b/w tdm and DMAC */
150 struct snd_dmaengine_dai_dma_data play_dma_data;
151 struct snd_dmaengine_dai_dma_data capture_dma_data;
154 #endif /* __SND_SOC_STARFIVE_TDM_H */