blob: d45b9a7e324efb49a5159417232c9f43815ebfed [file] [log] [blame]
Kuninori Morimotoae5c3222013-07-21 21:36:57 -07001/*
2 * Renesas R-Car SSIU/SSI support
3 *
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * Based on fsi.c
8 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14#include <linux/delay.h>
15#include "rsnd.h"
16#define RSND_SSI_NAME_SIZE 16
17
18/*
19 * SSICR
20 */
21#define FORCE (1 << 31) /* Fixed */
Kuninori Morimoto849fc822013-07-28 18:59:02 -070022#define DMEN (1 << 28) /* DMA Enable */
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070023#define UIEN (1 << 27) /* Underflow Interrupt Enable */
24#define OIEN (1 << 26) /* Overflow Interrupt Enable */
25#define IIEN (1 << 25) /* Idle Mode Interrupt Enable */
26#define DIEN (1 << 24) /* Data Interrupt Enable */
27
28#define DWL_8 (0 << 19) /* Data Word Length */
29#define DWL_16 (1 << 19) /* Data Word Length */
30#define DWL_18 (2 << 19) /* Data Word Length */
31#define DWL_20 (3 << 19) /* Data Word Length */
32#define DWL_22 (4 << 19) /* Data Word Length */
33#define DWL_24 (5 << 19) /* Data Word Length */
34#define DWL_32 (6 << 19) /* Data Word Length */
35
36#define SWL_32 (3 << 16) /* R/W System Word Length */
37#define SCKD (1 << 15) /* Serial Bit Clock Direction */
38#define SWSD (1 << 14) /* Serial WS Direction */
39#define SCKP (1 << 13) /* Serial Bit Clock Polarity */
40#define SWSP (1 << 12) /* Serial WS Polarity */
41#define SDTA (1 << 10) /* Serial Data Alignment */
42#define DEL (1 << 8) /* Serial Data Delay */
43#define CKDV(v) (v << 4) /* Serial Clock Division Ratio */
44#define TRMD (1 << 1) /* Transmit/Receive Mode Select */
45#define EN (1 << 0) /* SSI Module Enable */
46
47/*
48 * SSISR
49 */
50#define UIRQ (1 << 27) /* Underflow Error Interrupt Status */
51#define OIRQ (1 << 26) /* Overflow Error Interrupt Status */
52#define IIRQ (1 << 25) /* Idle Mode Interrupt Status */
53#define DIRQ (1 << 24) /* Data Interrupt Status Flag */
54
Kuninori Morimoto849fc822013-07-28 18:59:02 -070055/*
56 * SSIWSR
57 */
58#define CONT (1 << 8) /* WS Continue Function */
59
Kuninori Morimoto8aefda52014-05-22 23:25:43 -070060#define SSI_NAME "ssi"
61
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070062struct rsnd_ssi {
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070063 struct rsnd_ssi_platform_info *info; /* rcar_snd.h */
64 struct rsnd_ssi *parent;
65 struct rsnd_mod mod;
66
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070067 u32 cr_own;
68 u32 cr_clk;
Kuninori Morimoto919567d2015-04-10 08:50:30 +000069 int chan;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070070 int err;
71 unsigned int usrcnt;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070072};
73
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070074#define for_each_rsnd_ssi(pos, priv, i) \
75 for (i = 0; \
76 (i < rsnd_ssi_nr(priv)) && \
Kuninori Morimotodd27d802014-01-23 18:39:40 -080077 ((pos) = ((struct rsnd_ssi *)(priv)->ssi + i)); \
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070078 i++)
79
Kuninori Morimotodd27d802014-01-23 18:39:40 -080080#define rsnd_ssi_nr(priv) ((priv)->ssi_nr)
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070081#define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod)
Kuninori Morimoto849fc822013-07-28 18:59:02 -070082#define rsnd_dma_to_ssi(dma) rsnd_mod_to_ssi(rsnd_dma_to_mod(dma))
Kuninori Morimoto6cfad782014-11-27 08:08:10 +000083#define rsnd_ssi_pio_available(ssi) ((ssi)->info->irq > 0)
Kuninori Morimoto8c5c79a2015-04-10 08:50:12 +000084#define rsnd_ssi_parent(ssi) ((ssi)->parent)
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070085#define rsnd_ssi_mode_flags(p) ((p)->info->flags)
Kuninori Morimoto4b4dab82013-07-28 18:58:29 -070086#define rsnd_ssi_dai_id(ssi) ((ssi)->info->dai_id)
Kuninori Morimoto04e627b2015-02-20 10:30:02 +000087#define rsnd_ssi_of_node(priv) \
88 of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, "rcar_sound,ssi")
Kuninori Morimotoae5c3222013-07-21 21:36:57 -070089
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +000090int rsnd_ssi_use_busif(struct rsnd_dai_stream *io, struct rsnd_mod *mod)
Kuninori Morimotod9288d02014-06-22 17:56:23 -070091{
92 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
Kuninori Morimotod9288d02014-06-22 17:56:23 -070093 int use_busif = 0;
94
Kuninori Morimoto7b466fc2014-11-27 08:05:54 +000095 if (!rsnd_ssi_is_dma_mode(mod))
96 return 0;
97
Kuninori Morimotod9288d02014-06-22 17:56:23 -070098 if (!(rsnd_ssi_mode_flags(ssi) & RSND_SSI_NO_BUSIF))
99 use_busif = 1;
100 if (rsnd_io_to_mod_src(io))
101 use_busif = 1;
102
103 return use_busif;
104}
105
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700106static void rsnd_ssi_status_check(struct rsnd_mod *mod,
107 u32 bit)
108{
109 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
110 struct device *dev = rsnd_priv_to_dev(priv);
111 u32 status;
112 int i;
113
114 for (i = 0; i < 1024; i++) {
115 status = rsnd_mod_read(mod, SSISR);
116 if (status & bit)
117 return;
118
119 udelay(50);
120 }
121
122 dev_warn(dev, "status check failed\n");
123}
124
125static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi,
Kuninori Morimotoadcf7d52013-12-19 19:28:39 -0800126 struct rsnd_dai_stream *io)
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700127{
Kuninori Morimoto1b13d1182015-01-15 08:08:34 +0000128 struct rsnd_priv *priv = rsnd_io_to_priv(io);
Kuninori Morimotoadcf7d52013-12-19 19:28:39 -0800129 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700130 struct device *dev = rsnd_priv_to_dev(priv);
131 int i, j, ret;
132 int adg_clk_div_table[] = {
133 1, 6, /* see adg.c */
134 };
135 int ssi_clk_mul_table[] = {
136 1, 2, 4, 8, 16, 6, 12,
137 };
138 unsigned int main_rate;
Kuninori Morimotoba9c9492014-03-03 20:51:21 -0800139 unsigned int rate = rsnd_src_get_ssi_rate(priv, io, runtime);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700140
141 /*
142 * Find best clock, and try to start ADG
143 */
144 for (i = 0; i < ARRAY_SIZE(adg_clk_div_table); i++) {
145 for (j = 0; j < ARRAY_SIZE(ssi_clk_mul_table); j++) {
146
147 /*
148 * this driver is assuming that
149 * system word is 64fs (= 2 x 32bit)
Kuninori Morimoto729aca52013-12-19 19:26:44 -0800150 * see rsnd_ssi_init()
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700151 */
152 main_rate = rate / adg_clk_div_table[i]
153 * 32 * 2 * ssi_clk_mul_table[j];
154
155 ret = rsnd_adg_ssi_clk_try_start(&ssi->mod, main_rate);
156 if (0 == ret) {
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700157 ssi->cr_clk = FORCE | SWL_32 |
158 SCKD | SWSD | CKDV(j);
159
Kuninori Morimoto30cc4fa2014-11-09 20:00:30 -0800160 dev_dbg(dev, "%s[%d] outputs %u Hz\n",
161 rsnd_mod_name(&ssi->mod),
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700162 rsnd_mod_id(&ssi->mod), rate);
163
164 return 0;
165 }
166 }
167 }
168
169 dev_err(dev, "unsupported clock rate\n");
170 return -EIO;
171}
172
173static void rsnd_ssi_master_clk_stop(struct rsnd_ssi *ssi)
174{
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700175 ssi->cr_clk = 0;
176 rsnd_adg_ssi_clk_stop(&ssi->mod);
177}
178
179static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi,
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700180 struct rsnd_dai_stream *io)
181{
Kuninori Morimoto1b13d1182015-01-15 08:08:34 +0000182 struct rsnd_priv *priv = rsnd_io_to_priv(io);
Kuninori Morimotof708d942015-01-15 08:07:19 +0000183 struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700184 struct device *dev = rsnd_priv_to_dev(priv);
Kuninori Morimoto05795412014-11-27 08:05:01 +0000185 u32 cr_mode;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700186 u32 cr;
187
188 if (0 == ssi->usrcnt) {
Kuninori Morimoto85642952015-01-15 08:03:22 +0000189 rsnd_mod_hw_start(&ssi->mod);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700190
Kuninori Morimoto3ed64482015-01-15 08:04:51 +0000191 if (rsnd_rdai_is_clk_master(rdai)) {
Kuninori Morimoto8c5c79a2015-04-10 08:50:12 +0000192 struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi);
193
194 if (ssi_parent)
195 rsnd_ssi_hw_start(ssi_parent, io);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700196 else
Kuninori Morimotoadcf7d52013-12-19 19:28:39 -0800197 rsnd_ssi_master_clk_start(ssi, io);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700198 }
199 }
200
Kuninori Morimoto12927a82015-06-15 06:20:54 +0000201 if (rsnd_ssi_is_dma_mode(&ssi->mod)) {
202 cr_mode = UIEN | OIEN | /* over/under run */
203 DMEN; /* DMA : enable DMA */
204 } else {
205 cr_mode = DIEN; /* PIO : enable Data interrupt */
206 }
Kuninori Morimoto05795412014-11-27 08:05:01 +0000207
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700208 cr = ssi->cr_own |
209 ssi->cr_clk |
Kuninori Morimoto05795412014-11-27 08:05:01 +0000210 cr_mode |
Kuninori Morimoto12927a82015-06-15 06:20:54 +0000211 EN;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700212
213 rsnd_mod_write(&ssi->mod, SSICR, cr);
214
Kuninori Morimotod1b64052014-11-27 08:05:34 +0000215 /* enable WS continue */
Kuninori Morimoto3ed64482015-01-15 08:04:51 +0000216 if (rsnd_rdai_is_clk_master(rdai))
Kuninori Morimotod1b64052014-11-27 08:05:34 +0000217 rsnd_mod_write(&ssi->mod, SSIWSR, CONT);
218
Kuninori Morimoto3ba84f42014-11-27 08:05:44 +0000219 /* clear error status */
220 rsnd_mod_write(&ssi->mod, SSISR, 0);
221
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700222 ssi->usrcnt++;
223
Kuninori Morimoto30cc4fa2014-11-09 20:00:30 -0800224 dev_dbg(dev, "%s[%d] hw started\n",
225 rsnd_mod_name(&ssi->mod), rsnd_mod_id(&ssi->mod));
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700226}
227
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000228static void rsnd_ssi_hw_stop(struct rsnd_dai_stream *io, struct rsnd_ssi *ssi)
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700229{
230 struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod);
Kuninori Morimotof708d942015-01-15 08:07:19 +0000231 struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700232 struct device *dev = rsnd_priv_to_dev(priv);
233 u32 cr;
234
Kuninori Morimotob8473572015-05-21 03:49:13 +0000235 if (0 == ssi->usrcnt) {
236 dev_err(dev, "%s called without starting\n", __func__);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700237 return;
Kuninori Morimotob8473572015-05-21 03:49:13 +0000238 }
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700239
240 ssi->usrcnt--;
241
242 if (0 == ssi->usrcnt) {
243 /*
244 * disable all IRQ,
245 * and, wait all data was sent
246 */
247 cr = ssi->cr_own |
248 ssi->cr_clk;
249
250 rsnd_mod_write(&ssi->mod, SSICR, cr | EN);
251 rsnd_ssi_status_check(&ssi->mod, DIRQ);
252
253 /*
254 * disable SSI,
255 * and, wait idle state
256 */
257 rsnd_mod_write(&ssi->mod, SSICR, cr); /* disabled all */
258 rsnd_ssi_status_check(&ssi->mod, IIRQ);
259
Kuninori Morimoto3ed64482015-01-15 08:04:51 +0000260 if (rsnd_rdai_is_clk_master(rdai)) {
Kuninori Morimoto8c5c79a2015-04-10 08:50:12 +0000261 struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi);
262
263 if (ssi_parent)
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000264 rsnd_ssi_hw_stop(io, ssi_parent);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700265 else
266 rsnd_ssi_master_clk_stop(ssi);
267 }
268
Kuninori Morimoto85642952015-01-15 08:03:22 +0000269 rsnd_mod_hw_stop(&ssi->mod);
Kuninori Morimoto919567d2015-04-10 08:50:30 +0000270
271 ssi->chan = 0;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700272 }
273
Kuninori Morimoto30cc4fa2014-11-09 20:00:30 -0800274 dev_dbg(dev, "%s[%d] hw stopped\n",
275 rsnd_mod_name(&ssi->mod), rsnd_mod_id(&ssi->mod));
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700276}
277
278/*
279 * SSI mod common functions
280 */
281static int rsnd_ssi_init(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000282 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000283 struct rsnd_priv *priv)
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700284{
285 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000286 struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700287 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
288 u32 cr;
289
290 cr = FORCE;
291
292 /*
293 * always use 32bit system word for easy clock calculation.
294 * see also rsnd_ssi_master_clk_enable()
295 */
296 cr |= SWL_32;
297
298 /*
299 * init clock settings for SSICR
300 */
301 switch (runtime->sample_bits) {
302 case 16:
303 cr |= DWL_16;
304 break;
305 case 32:
306 cr |= DWL_24;
307 break;
308 default:
309 return -EIO;
310 }
311
312 if (rdai->bit_clk_inv)
313 cr |= SCKP;
314 if (rdai->frm_clk_inv)
315 cr |= SWSP;
316 if (rdai->data_alignment)
317 cr |= SDTA;
318 if (rdai->sys_delay)
319 cr |= DEL;
Kuninori Morimoto985a4f62015-01-15 08:06:49 +0000320 if (rsnd_io_is_play(io))
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700321 cr |= TRMD;
322
323 /*
324 * set ssi parameter
325 */
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700326 ssi->cr_own = cr;
327 ssi->err = -1; /* ignore 1st error */
328
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700329 return 0;
330}
331
332static int rsnd_ssi_quit(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000333 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000334 struct rsnd_priv *priv)
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700335{
336 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700337 struct device *dev = rsnd_priv_to_dev(priv);
338
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700339 if (ssi->err > 0)
Kuninori Morimoto337b0b42015-01-15 08:08:57 +0000340 dev_warn(dev, "%s[%d] under/over flow err = %d\n",
341 rsnd_mod_name(mod), rsnd_mod_id(mod), ssi->err);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700342
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700343 ssi->cr_own = 0;
344 ssi->err = 0;
345
346 return 0;
347}
348
Kuninori Morimoto919567d2015-04-10 08:50:30 +0000349static int rsnd_ssi_hw_params(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000350 struct rsnd_dai_stream *io,
Kuninori Morimoto919567d2015-04-10 08:50:30 +0000351 struct snd_pcm_substream *substream,
352 struct snd_pcm_hw_params *params)
353{
354 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
355 struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi);
356 int chan = params_channels(params);
357
358 /*
359 * Already working.
360 * It will happen if SSI has parent/child connection.
361 */
362 if (ssi->usrcnt) {
363 /*
364 * it is error if child <-> parent SSI uses
365 * different channels.
366 */
367 if (ssi->chan != chan)
368 return -EIO;
369 }
370
371 /* It will be removed on rsnd_ssi_hw_stop */
372 ssi->chan = chan;
373 if (ssi_parent)
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000374 return rsnd_ssi_hw_params(&ssi_parent->mod, io,
375 substream, params);
Kuninori Morimoto919567d2015-04-10 08:50:30 +0000376
377 return 0;
378}
379
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700380static void rsnd_ssi_record_error(struct rsnd_ssi *ssi, u32 status)
381{
382 /* under/over flow error */
383 if (status & (UIRQ | OIRQ)) {
384 ssi->err++;
385
386 /* clear error status */
387 rsnd_mod_write(&ssi->mod, SSISR, 0);
388 }
389}
390
Kuninori Morimoto49229852014-11-27 08:07:17 +0000391static int rsnd_ssi_start(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000392 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000393 struct rsnd_priv *priv)
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700394{
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700395 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700396
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000397 rsnd_src_ssiu_start(mod, io, rsnd_ssi_use_busif(io, mod));
Kuninori Morimotod9288d02014-06-22 17:56:23 -0700398
Kuninori Morimotof708d942015-01-15 08:07:19 +0000399 rsnd_ssi_hw_start(ssi, io);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700400
Kuninori Morimotof708d942015-01-15 08:07:19 +0000401 rsnd_src_ssi_irq_enable(mod);
Kuninori Morimotoc17dba82014-11-27 08:05:09 +0000402
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700403 return 0;
404}
405
Kuninori Morimoto49229852014-11-27 08:07:17 +0000406static int rsnd_ssi_stop(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000407 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000408 struct rsnd_priv *priv)
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700409{
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700410 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
411
Kuninori Morimotof708d942015-01-15 08:07:19 +0000412 rsnd_src_ssi_irq_disable(mod);
Kuninori Morimotoc17dba82014-11-27 08:05:09 +0000413
Kuninori Morimoto7b466fc2014-11-27 08:05:54 +0000414 rsnd_ssi_record_error(ssi, rsnd_mod_read(mod, SSISR));
415
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000416 rsnd_ssi_hw_stop(io, ssi);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700417
Kuninori Morimoto4e2639f2015-06-15 06:26:08 +0000418 rsnd_src_ssiu_stop(mod, io);
Kuninori Morimotod9288d02014-06-22 17:56:23 -0700419
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700420 return 0;
421}
422
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000423static void __rsnd_ssi_interrupt(struct rsnd_mod *mod,
424 struct rsnd_dai_stream *io)
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000425{
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000426 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000427 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
Kuninori Morimoto765ae7c2015-01-15 08:09:13 +0000428 int is_dma = rsnd_ssi_is_dma_mode(mod);
Kuninori Morimoto02299d92015-05-21 03:50:23 +0000429 u32 status;
Kuninori Morimoto75defee2015-06-15 06:21:15 +0000430 bool elapsed = false;
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000431
Kuninori Morimoto02299d92015-05-21 03:50:23 +0000432 spin_lock(&priv->lock);
433
434 /* ignore all cases if not working */
Kuninori Morimotod5bbe7d2015-06-15 06:27:47 +0000435 if (!rsnd_io_is_working(io))
Kuninori Morimoto02299d92015-05-21 03:50:23 +0000436 goto rsnd_ssi_interrupt_out;
437
438 status = rsnd_mod_read(mod, SSISR);
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000439
440 /* PIO only */
Kuninori Morimoto765ae7c2015-01-15 08:09:13 +0000441 if (!is_dma && (status & DIRQ)) {
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000442 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
443 u32 *buf = (u32 *)(runtime->dma_area +
444 rsnd_dai_pointer_offset(io, 0));
445
446 /*
447 * 8/16/32 data can be assesse to TDR/RDR register
448 * directly as 32bit data
449 * see rsnd_ssi_init()
450 */
Kuninori Morimoto985a4f62015-01-15 08:06:49 +0000451 if (rsnd_io_is_play(io))
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000452 rsnd_mod_write(mod, SSITDR, *buf);
453 else
454 *buf = rsnd_mod_read(mod, SSIRDR);
455
Kuninori Morimoto75defee2015-06-15 06:21:15 +0000456 elapsed = rsnd_dai_pointer_update(io, sizeof(*buf));
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000457 }
458
Kuninori Morimoto12927a82015-06-15 06:20:54 +0000459 /* DMA only */
460 if (is_dma && (status & (UIRQ | OIRQ))) {
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000461 struct device *dev = rsnd_priv_to_dev(priv);
462
463 /*
464 * restart SSI
465 */
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000466 dev_dbg(dev, "%s[%d] restart\n",
467 rsnd_mod_name(mod), rsnd_mod_id(mod));
Kuninori Morimoto044930b2015-03-19 04:13:47 +0000468
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000469 rsnd_ssi_stop(mod, io, priv);
Kuninori Morimoto044930b2015-03-19 04:13:47 +0000470 if (ssi->err < 1024)
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000471 rsnd_ssi_start(mod, io, priv);
Kuninori Morimoto044930b2015-03-19 04:13:47 +0000472 else
473 dev_warn(dev, "no more SSI restart\n");
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000474 }
475
476 rsnd_ssi_record_error(ssi, status);
477
Kuninori Morimoto02299d92015-05-21 03:50:23 +0000478rsnd_ssi_interrupt_out:
479 spin_unlock(&priv->lock);
480
Kuninori Morimoto75defee2015-06-15 06:21:15 +0000481 if (elapsed)
482 rsnd_dai_period_elapsed(io);
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000483}
484
485static irqreturn_t rsnd_ssi_interrupt(int irq, void *data)
486{
487 struct rsnd_mod *mod = data;
488
489 rsnd_mod_interrupt(mod, __rsnd_ssi_interrupt);
Kuninori Morimoto75defee2015-06-15 06:21:15 +0000490
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000491 return IRQ_HANDLED;
492}
493
Kuninori Morimoto6cfad782014-11-27 08:08:10 +0000494/*
495 * SSI PIO
496 */
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000497static int rsnd_ssi_pio_probe(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000498 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000499 struct rsnd_priv *priv)
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000500{
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000501 struct device *dev = rsnd_priv_to_dev(priv);
502 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000503 int ret;
504
Kuninori Morimoto6cfad782014-11-27 08:08:10 +0000505 ret = devm_request_irq(dev, ssi->info->irq,
506 rsnd_ssi_interrupt,
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000507 IRQF_SHARED,
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000508 dev_name(dev), mod);
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000509
510 return ret;
511}
512
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700513static struct rsnd_mod_ops rsnd_ssi_pio_ops = {
Kuninori Morimoto8aefda52014-05-22 23:25:43 -0700514 .name = SSI_NAME,
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800515 .probe = rsnd_ssi_pio_probe,
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700516 .init = rsnd_ssi_init,
517 .quit = rsnd_ssi_quit,
Kuninori Morimoto49229852014-11-27 08:07:17 +0000518 .start = rsnd_ssi_start,
519 .stop = rsnd_ssi_stop,
Kuninori Morimoto919567d2015-04-10 08:50:30 +0000520 .hw_params = rsnd_ssi_hw_params,
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700521};
522
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800523static int rsnd_ssi_dma_probe(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000524 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000525 struct rsnd_priv *priv)
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800526{
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800527 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800528 struct device *dev = rsnd_priv_to_dev(priv);
529 int dma_id = ssi->info->dma_id;
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800530 int ret;
531
Kuninori Morimoto6cfad782014-11-27 08:08:10 +0000532 ret = devm_request_irq(dev, ssi->info->irq,
533 rsnd_ssi_interrupt,
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000534 IRQF_SHARED,
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000535 dev_name(dev), mod);
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000536 if (ret)
Kuninori Morimotob543b522015-03-26 04:02:32 +0000537 return ret;
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000538
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800539 ret = rsnd_dma_init(
Kuninori Morimoto9b99e9a2015-06-15 06:26:25 +0000540 io, rsnd_mod_to_dma(mod),
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800541 dma_id);
Kuninori Morimoto8aefda52014-05-22 23:25:43 -0700542
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800543 return ret;
544}
545
546static int rsnd_ssi_dma_remove(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000547 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000548 struct rsnd_priv *priv)
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800549{
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000550 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
551 struct device *dev = rsnd_priv_to_dev(priv);
Kuninori Morimoto6cfad782014-11-27 08:08:10 +0000552 int irq = ssi->info->irq;
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000553
Kuninori Morimoto9b99e9a2015-06-15 06:26:25 +0000554 rsnd_dma_quit(io, rsnd_mod_to_dma(mod));
Kuninori Morimoto97463e192014-11-27 08:02:43 +0000555
Kuninori Morimoto4e7d6062014-11-27 08:07:47 +0000556 /* PIO will request IRQ again */
557 devm_free_irq(dev, irq, ssi);
558
Kuninori Morimoto97463e192014-11-27 08:02:43 +0000559 return 0;
560}
561
562static int rsnd_ssi_fallback(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000563 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000564 struct rsnd_priv *priv)
Kuninori Morimoto97463e192014-11-27 08:02:43 +0000565{
Kuninori Morimotod3a76822014-11-09 20:00:58 -0800566 struct device *dev = rsnd_priv_to_dev(priv);
567
Kuninori Morimotod3a76822014-11-09 20:00:58 -0800568 /*
569 * fallback to PIO
570 *
571 * SSI .probe might be called again.
572 * see
573 * rsnd_rdai_continuance_probe()
574 */
575 mod->ops = &rsnd_ssi_pio_ops;
576
577 dev_info(dev, "%s[%d] fallback to PIO mode\n",
578 rsnd_mod_name(mod), rsnd_mod_id(mod));
579
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800580 return 0;
581}
582
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700583static int rsnd_ssi_dma_start(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000584 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000585 struct rsnd_priv *priv)
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700586{
Kuninori Morimoto49229852014-11-27 08:07:17 +0000587 struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700588
Kuninori Morimoto9b99e9a2015-06-15 06:26:25 +0000589 rsnd_dma_start(io, dma);
Kuninori Morimoto7b466fc2014-11-27 08:05:54 +0000590
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000591 rsnd_ssi_start(mod, io, priv);
Kuninori Morimoto1ceeab22015-01-15 08:09:26 +0000592
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700593 return 0;
594}
595
596static int rsnd_ssi_dma_stop(struct rsnd_mod *mod,
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000597 struct rsnd_dai_stream *io,
Kuninori Morimoto690602f2015-01-15 08:07:47 +0000598 struct rsnd_priv *priv)
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700599{
Kuninori Morimoto49229852014-11-27 08:07:17 +0000600 struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700601
Kuninori Morimoto2c0fac192015-06-15 06:25:20 +0000602 rsnd_ssi_stop(mod, io, priv);
Kuninori Morimotod9288d02014-06-22 17:56:23 -0700603
Kuninori Morimoto9b99e9a2015-06-15 06:26:25 +0000604 rsnd_dma_stop(io, dma);
Kuninori Morimoto1ceeab22015-01-15 08:09:26 +0000605
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700606 return 0;
607}
608
Kuninori Morimoto9b99e9a2015-06-15 06:26:25 +0000609static struct dma_chan *rsnd_ssi_dma_req(struct rsnd_dai_stream *io,
610 struct rsnd_mod *mod)
Kuninori Morimotod9288d02014-06-22 17:56:23 -0700611{
Kuninori Morimoto72adc612015-02-20 10:31:23 +0000612 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
Kuninori Morimoto72adc612015-02-20 10:31:23 +0000613 int is_play = rsnd_io_is_play(io);
614 char *name;
615
Kuninori Morimotobfc0cfe2015-06-15 06:26:56 +0000616 if (rsnd_ssi_use_busif(io, mod))
Kuninori Morimoto72adc612015-02-20 10:31:23 +0000617 name = is_play ? "rxu" : "txu";
618 else
619 name = is_play ? "rx" : "tx";
620
621 return rsnd_dma_request_channel(rsnd_ssi_of_node(priv),
622 mod, name);
Kuninori Morimotod9288d02014-06-22 17:56:23 -0700623}
624
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700625static struct rsnd_mod_ops rsnd_ssi_dma_ops = {
Kuninori Morimoto8aefda52014-05-22 23:25:43 -0700626 .name = SSI_NAME,
Kuninori Morimoto72adc612015-02-20 10:31:23 +0000627 .dma_req = rsnd_ssi_dma_req,
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800628 .probe = rsnd_ssi_dma_probe,
629 .remove = rsnd_ssi_dma_remove,
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700630 .init = rsnd_ssi_init,
631 .quit = rsnd_ssi_quit,
632 .start = rsnd_ssi_dma_start,
633 .stop = rsnd_ssi_dma_stop,
Kuninori Morimoto97463e192014-11-27 08:02:43 +0000634 .fallback = rsnd_ssi_fallback,
Kuninori Morimoto919567d2015-04-10 08:50:30 +0000635 .hw_params = rsnd_ssi_hw_params,
Kuninori Morimoto849fc822013-07-28 18:59:02 -0700636};
637
Kuninori Morimoto05795412014-11-27 08:05:01 +0000638int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod)
639{
640 return mod->ops == &rsnd_ssi_dma_ops;
641}
642
643
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700644/*
645 * Non SSI
646 */
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700647static struct rsnd_mod_ops rsnd_ssi_non_ops = {
Kuninori Morimoto8aefda52014-05-22 23:25:43 -0700648 .name = SSI_NAME,
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700649};
650
651/*
652 * ssi mod function
653 */
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700654struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id)
655{
Takashi Iwai8b147192013-11-05 18:40:05 +0100656 if (WARN_ON(id < 0 || id >= rsnd_ssi_nr(priv)))
657 id = 0;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700658
Kuninori Morimotodd27d802014-01-23 18:39:40 -0800659 return &((struct rsnd_ssi *)(priv->ssi) + id)->mod;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700660}
661
Kuninori Morimoto7b5ce972014-01-23 18:39:32 -0800662int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod)
663{
664 struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
665
666 return !!(rsnd_ssi_mode_flags(ssi) & RSND_SSI_CLK_PIN_SHARE);
667}
668
Kuninori Morimoto8c5c79a2015-04-10 08:50:12 +0000669static void rsnd_ssi_parent_setup(struct rsnd_priv *priv, struct rsnd_ssi *ssi)
Kuninori Morimoto7b5ce972014-01-23 18:39:32 -0800670{
671 if (!rsnd_ssi_is_pin_sharing(&ssi->mod))
672 return;
673
674 switch (rsnd_mod_id(&ssi->mod)) {
675 case 1:
676 case 2:
677 ssi->parent = rsnd_mod_to_ssi(rsnd_ssi_mod_get(priv, 0));
678 break;
679 case 4:
680 ssi->parent = rsnd_mod_to_ssi(rsnd_ssi_mod_get(priv, 3));
681 break;
682 case 8:
683 ssi->parent = rsnd_mod_to_ssi(rsnd_ssi_mod_get(priv, 7));
684 break;
685 }
686}
687
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700688
689static void rsnd_of_parse_ssi(struct platform_device *pdev,
690 const struct rsnd_of_data *of_data,
691 struct rsnd_priv *priv)
692{
693 struct device_node *node;
694 struct device_node *np;
695 struct rsnd_ssi_platform_info *ssi_info;
696 struct rcar_snd_info *info = rsnd_priv_to_info(priv);
697 struct device *dev = &pdev->dev;
698 int nr, i;
699
700 if (!of_data)
701 return;
702
Kuninori Morimoto04e627b2015-02-20 10:30:02 +0000703 node = rsnd_ssi_of_node(priv);
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700704 if (!node)
705 return;
706
707 nr = of_get_child_count(node);
708 if (!nr)
Kuninori Morimotof451e482014-05-22 23:24:59 -0700709 goto rsnd_of_parse_ssi_end;
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700710
711 ssi_info = devm_kzalloc(dev,
712 sizeof(struct rsnd_ssi_platform_info) * nr,
713 GFP_KERNEL);
714 if (!ssi_info) {
715 dev_err(dev, "ssi info allocation error\n");
Kuninori Morimotof451e482014-05-22 23:24:59 -0700716 goto rsnd_of_parse_ssi_end;
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700717 }
718
719 info->ssi_info = ssi_info;
720 info->ssi_info_nr = nr;
721
722 i = -1;
723 for_each_child_of_node(node, np) {
724 i++;
725
726 ssi_info = info->ssi_info + i;
727
728 /*
729 * pin settings
730 */
731 if (of_get_property(np, "shared-pin", NULL))
732 ssi_info->flags |= RSND_SSI_CLK_PIN_SHARE;
733
734 /*
735 * irq
736 */
Kuninori Morimoto6cfad782014-11-27 08:08:10 +0000737 ssi_info->irq = irq_of_parse_and_map(np, 0);
Kuninori Morimoto199e76882014-05-22 23:25:49 -0700738
739 /*
740 * DMA
741 */
742 ssi_info->dma_id = of_get_property(np, "pio-transfer", NULL) ?
743 0 : 1;
Kuninori Morimotod9288d02014-06-22 17:56:23 -0700744
745 if (of_get_property(np, "no-busif", NULL))
746 ssi_info->flags |= RSND_SSI_NO_BUSIF;
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700747 }
Kuninori Morimotof451e482014-05-22 23:24:59 -0700748
749rsnd_of_parse_ssi_end:
750 of_node_put(node);
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700751}
752
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700753int rsnd_ssi_probe(struct platform_device *pdev,
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700754 const struct rsnd_of_data *of_data,
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700755 struct rsnd_priv *priv)
756{
Kuninori Morimoto5da39cf2014-02-24 22:15:00 -0800757 struct rcar_snd_info *info = rsnd_priv_to_info(priv);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700758 struct rsnd_ssi_platform_info *pinfo;
759 struct device *dev = rsnd_priv_to_dev(priv);
760 struct rsnd_mod_ops *ops;
761 struct clk *clk;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700762 struct rsnd_ssi *ssi;
763 char name[RSND_SSI_NAME_SIZE];
Kuninori Morimoto2f78dd72015-03-26 04:02:09 +0000764 int i, nr, ret;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700765
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700766 rsnd_of_parse_ssi(pdev, of_data, priv);
767
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700768 /*
769 * init SSI
770 */
771 nr = info->ssi_info_nr;
Kuninori Morimotodd27d802014-01-23 18:39:40 -0800772 ssi = devm_kzalloc(dev, sizeof(*ssi) * nr, GFP_KERNEL);
Kuninori Morimotoafa700722015-07-15 07:08:24 +0000773 if (!ssi)
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700774 return -ENOMEM;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700775
Kuninori Morimotodd27d802014-01-23 18:39:40 -0800776 priv->ssi = ssi;
777 priv->ssi_nr = nr;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700778
779 for_each_rsnd_ssi(ssi, priv, i) {
780 pinfo = &info->ssi_info[i];
781
Kuninori Morimoto8aefda52014-05-22 23:25:43 -0700782 snprintf(name, RSND_SSI_NAME_SIZE, "%s.%d",
783 SSI_NAME, i);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700784
Kuninori Morimoto60dbb4f2013-12-03 22:09:33 -0800785 clk = devm_clk_get(dev, name);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700786 if (IS_ERR(clk))
787 return PTR_ERR(clk);
788
789 ssi->info = pinfo;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700790
791 ops = &rsnd_ssi_non_ops;
Kuninori Morimotoff8f30e2014-03-03 20:50:49 -0800792 if (pinfo->dma_id > 0)
793 ops = &rsnd_ssi_dma_ops;
794 else if (rsnd_ssi_pio_available(ssi))
795 ops = &rsnd_ssi_pio_ops;
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700796
Kuninori Morimoto2099bc82015-06-15 06:24:54 +0000797 ret = rsnd_mod_init(priv, &ssi->mod, ops, clk, RSND_MOD_SSI, i);
Kuninori Morimoto2f78dd72015-03-26 04:02:09 +0000798 if (ret)
799 return ret;
Kuninori Morimoto7b5ce972014-01-23 18:39:32 -0800800
Kuninori Morimoto8c5c79a2015-04-10 08:50:12 +0000801 rsnd_ssi_parent_setup(priv, ssi);
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700802 }
803
Kuninori Morimotoae5c3222013-07-21 21:36:57 -0700804 return 0;
805}
Kuninori Morimoto2f78dd72015-03-26 04:02:09 +0000806
807void rsnd_ssi_remove(struct platform_device *pdev,
808 struct rsnd_priv *priv)
809{
810 struct rsnd_ssi *ssi;
811 int i;
812
813 for_each_rsnd_ssi(ssi, priv, i) {
814 rsnd_mod_quit(&ssi->mod);
815 }
816}