bd19ec57c73de62219475cf21746b1aab6ace161
[linux-2.6-microblaze.git] / sound / soc / qcom / lpass.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
4  *
5  * lpass.h - Definitions for the QTi LPASS
6  */
7
8 #ifndef __LPASS_H__
9 #define __LPASS_H__
10
11 #include <linux/clk.h>
12 #include <linux/compiler.h>
13 #include <linux/platform_device.h>
14 #include <linux/regmap.h>
15
16 #define LPASS_AHBIX_CLOCK_FREQUENCY             131072000
17 #define LPASS_MAX_MI2S_PORTS                    (8)
18 #define LPASS_MAX_DMA_CHANNELS                  (8)
19
20 /* Both the CPU DAI and platform drivers will access this data */
21 struct lpass_data {
22
23         /* AHB-I/X bus clocks inside the low-power audio subsystem (LPASS) */
24         struct clk *ahbix_clk;
25
26         /* MI2S system clock */
27         struct clk *mi2s_osr_clk[LPASS_MAX_MI2S_PORTS];
28
29         /* MI2S bit clock (derived from system clock by a divider */
30         struct clk *mi2s_bit_clk[LPASS_MAX_MI2S_PORTS];
31
32         /* MI2S SD lines to use for playback/capture */
33         unsigned int mi2s_playback_sd_mode[LPASS_MAX_MI2S_PORTS];
34         unsigned int mi2s_capture_sd_mode[LPASS_MAX_MI2S_PORTS];
35
36         /* low-power audio interface (LPAIF) registers */
37         void __iomem *lpaif;
38
39         /* regmap backed by the low-power audio interface (LPAIF) registers */
40         struct regmap *lpaif_map;
41
42         /* interrupts from the low-power audio interface (LPAIF) */
43         int lpaif_irq;
44
45         /* SOC specific variations in the LPASS IP integration */
46         struct lpass_variant *variant;
47
48         /* bit map to keep track of static channel allocations */
49         unsigned long dma_ch_bit_map;
50
51         /* used it for handling interrupt per dma channel */
52         struct snd_pcm_substream *substream[LPASS_MAX_DMA_CHANNELS];
53
54         /* 8016 specific */
55         struct clk *pcnoc_mport_clk;
56         struct clk *pcnoc_sway_clk;
57
58 };
59
60 /* Vairant data per each SOC */
61 struct lpass_variant {
62         u32     i2sctrl_reg_base;
63         u32     i2sctrl_reg_stride;
64         u32     i2s_ports;
65         u32     irq_reg_base;
66         u32     irq_reg_stride;
67         u32     irq_ports;
68         u32     rdma_reg_base;
69         u32     rdma_reg_stride;
70         u32     rdma_channels;
71         u32     wrdma_reg_base;
72         u32     wrdma_reg_stride;
73         u32     wrdma_channels;
74
75         /**
76          * on SOCs like APQ8016 the channel control bits start
77          * at different offset to ipq806x
78          **/
79         u32     dmactl_audif_start;
80         u32     wrdma_channel_start;
81         /* SOC specific initialization like clocks */
82         int (*init)(struct platform_device *pdev);
83         int (*exit)(struct platform_device *pdev);
84         int (*alloc_dma_channel)(struct lpass_data *data, int direction);
85         int (*free_dma_channel)(struct lpass_data *data, int ch);
86
87         /* SOC specific dais */
88         struct snd_soc_dai_driver *dai_driver;
89         int num_dai;
90         const char * const *dai_osr_clk_names;
91         const char * const *dai_bit_clk_names;
92 };
93
94 /* register the platform driver from the CPU DAI driver */
95 int asoc_qcom_lpass_platform_register(struct platform_device *);
96 int asoc_qcom_lpass_cpu_platform_remove(struct platform_device *pdev);
97 int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev);
98 int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai);
99 extern const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops;
100
101 #endif /* __LPASS_H__ */