1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef SIU_H
23#define SIU_H
24
25
26
27#define YRAM0_SIZE (0x0040 / 4)
28#define YRAM1_SIZE (0x0080 / 4)
29#define YRAM2_SIZE (0x0040 / 4)
30#define YRAM3_SIZE (0x0080 / 4)
31#define YRAM4_SIZE (0x0080 / 4)
32#define YRAM_DEF_SIZE (YRAM0_SIZE + YRAM1_SIZE + YRAM2_SIZE + \
33 YRAM3_SIZE + YRAM4_SIZE)
34#define YRAM_FIR_SIZE (0x0400 / 4)
35#define YRAM_IIR_SIZE (0x0200 / 4)
36
37#define XRAM0_SIZE (0x0400 / 4)
38#define XRAM1_SIZE (0x0200 / 4)
39#define XRAM2_SIZE (0x0200 / 4)
40
41
42#define PRAM0_SIZE (0x0100 / 4)
43#define PRAM1_SIZE ((0x2000 - 0x0100) / 4)
44
45#include <linux/types.h>
46
47struct siu_spb_param {
48 __u32 ab1a;
49 __u32 ab0a;
50 __u32 dir;
51 __u32 event;
52 __u32 stfifo;
53 __u32 trdat;
54};
55
56struct siu_firmware {
57 __u32 yram_fir_coeff[YRAM_FIR_SIZE];
58 __u32 pram0[PRAM0_SIZE];
59 __u32 pram1[PRAM1_SIZE];
60 __u32 yram0[YRAM0_SIZE];
61 __u32 yram1[YRAM1_SIZE];
62 __u32 yram2[YRAM2_SIZE];
63 __u32 yram3[YRAM3_SIZE];
64 __u32 yram4[YRAM4_SIZE];
65 __u32 spbpar_num;
66 struct siu_spb_param spbpar[32];
67};
68
69#ifdef __KERNEL__
70
71#include <linux/dmaengine.h>
72#include <linux/interrupt.h>
73#include <linux/io.h>
74#include <linux/sh_dma.h>
75
76#include <sound/core.h>
77#include <sound/pcm.h>
78#include <sound/soc.h>
79
80#define SIU_PERIOD_BYTES_MAX 8192
81#define SIU_PERIOD_BYTES_MIN 256
82#define SIU_PERIODS_MAX 64
83#define SIU_PERIODS_MIN 4
84#define SIU_BUFFER_BYTES_MAX (SIU_PERIOD_BYTES_MAX * SIU_PERIODS_MAX)
85
86
87enum {
88 SIU_PORT_A,
89 SIU_PORT_B,
90 SIU_PORT_NUM,
91};
92
93
94enum {
95 SIU_CLKA_PLL,
96 SIU_CLKA_EXT,
97 SIU_CLKB_PLL,
98 SIU_CLKB_EXT
99};
100
101struct device;
102struct siu_info {
103 struct device *dev;
104 int port_id;
105 u32 __iomem *pram;
106 u32 __iomem *xram;
107 u32 __iomem *yram;
108 u32 __iomem *reg;
109 struct siu_firmware fw;
110};
111
112struct siu_stream {
113 struct tasklet_struct tasklet;
114 struct snd_pcm_substream *substream;
115 snd_pcm_format_t format;
116 size_t buf_bytes;
117 size_t period_bytes;
118 int cur_period;
119 u32 volume;
120 snd_pcm_sframes_t xfer_cnt;
121 u8 rw_flg;
122
123 struct dma_chan *chan;
124 struct dma_async_tx_descriptor *tx_desc;
125 dma_cookie_t cookie;
126 struct sh_dmae_slave param;
127};
128
129struct siu_port {
130 unsigned long play_cap;
131 struct snd_pcm *pcm;
132 struct siu_stream playback;
133 struct siu_stream capture;
134 u32 stfifo;
135 u32 trdat;
136};
137
138extern struct siu_port *siu_ports[SIU_PORT_NUM];
139
140static inline struct siu_port *siu_port_info(struct snd_pcm_substream *substream)
141{
142 struct platform_device *pdev =
143 to_platform_device(substream->pcm->card->dev);
144 return siu_ports[pdev->id];
145}
146
147
148static inline void siu_write32(u32 __iomem *addr, u32 val)
149{
150 __raw_writel(val, addr);
151}
152
153static inline u32 siu_read32(u32 __iomem *addr)
154{
155 return __raw_readl(addr);
156}
157
158
159#define SIU_IFCTL (0x000 / sizeof(u32))
160#define SIU_SRCTL (0x004 / sizeof(u32))
161#define SIU_SFORM (0x008 / sizeof(u32))
162#define SIU_CKCTL (0x00c / sizeof(u32))
163#define SIU_TRDAT (0x010 / sizeof(u32))
164#define SIU_STFIFO (0x014 / sizeof(u32))
165#define SIU_DPAK (0x01c / sizeof(u32))
166#define SIU_CKREV (0x020 / sizeof(u32))
167#define SIU_EVNTC (0x028 / sizeof(u32))
168#define SIU_SBCTL (0x040 / sizeof(u32))
169#define SIU_SBPSET (0x044 / sizeof(u32))
170#define SIU_SBFSTS (0x068 / sizeof(u32))
171#define SIU_SBDVCA (0x06c / sizeof(u32))
172#define SIU_SBDVCB (0x070 / sizeof(u32))
173#define SIU_SBACTIV (0x074 / sizeof(u32))
174#define SIU_DMAIA (0x090 / sizeof(u32))
175#define SIU_DMAIB (0x094 / sizeof(u32))
176#define SIU_DMAOA (0x098 / sizeof(u32))
177#define SIU_DMAOB (0x09c / sizeof(u32))
178#define SIU_DMAML (0x0a0 / sizeof(u32))
179#define SIU_SPSTS (0x0cc / sizeof(u32))
180#define SIU_SPCTL (0x0d0 / sizeof(u32))
181#define SIU_BRGASEL (0x100 / sizeof(u32))
182#define SIU_BRRA (0x104 / sizeof(u32))
183#define SIU_BRGBSEL (0x108 / sizeof(u32))
184#define SIU_BRRB (0x10c / sizeof(u32))
185
186extern struct snd_soc_platform_driver siu_platform;
187extern struct siu_info *siu_i2s_data;
188
189int siu_init_port(int port, struct siu_port **port_info, struct snd_card *card);
190void siu_free_port(struct siu_port *port_info);
191
192#endif
193
194#endif
195