ASoC: rcar: fix return value check in rsnd_gen1_probe()
[deliverable/linux.git] / sound / soc / sh / rcar / rsnd.h
CommitLineData
1536a968
KM
1/*
2 * Renesas R-Car
3 *
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.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 */
11#ifndef RSND_H
12#define RSND_H
13
14#include <linux/clk.h>
15#include <linux/device.h>
16#include <linux/io.h>
17#include <linux/list.h>
18#include <linux/module.h>
19#include <sound/rcar_snd.h>
20#include <sound/soc.h>
21#include <sound/pcm_params.h>
22
23/*
24 * pseudo register
25 *
26 * The register address offsets SRU/SCU/SSIU on Gen1/Gen2 are very different.
27 * This driver uses pseudo register in order to hide it.
28 * see gen1/gen2 for detail
29 */
3337744a 30enum rsnd_reg {
07539c1d
KM
31 /* SRU/SCU */
32 RSND_REG_SSI_MODE0,
33 RSND_REG_SSI_MODE1,
34
dfc9403b
KM
35 /* ADG */
36 RSND_REG_BRRA,
37 RSND_REG_BRRB,
38 RSND_REG_SSICKR,
39 RSND_REG_AUDIO_CLK_SEL0,
40 RSND_REG_AUDIO_CLK_SEL1,
41 RSND_REG_AUDIO_CLK_SEL2,
42 RSND_REG_AUDIO_CLK_SEL3,
43 RSND_REG_AUDIO_CLK_SEL4,
44 RSND_REG_AUDIO_CLK_SEL5,
45
ae5c3223
KM
46 /* SSI */
47 RSND_REG_SSICR,
48 RSND_REG_SSISR,
49 RSND_REG_SSITDR,
50 RSND_REG_SSIRDR,
51 RSND_REG_SSIWSR,
52
3337744a
KM
53 RSND_REG_MAX,
54};
55
1536a968 56struct rsnd_priv;
cdaa3cdf 57struct rsnd_mod;
1536a968
KM
58struct rsnd_dai;
59struct rsnd_dai_stream;
60
3337744a
KM
61/*
62 * R-Car basic functions
63 */
64#define rsnd_mod_read(m, r) \
65 rsnd_read(rsnd_mod_to_priv(m), m, RSND_REG_##r)
66#define rsnd_mod_write(m, r, d) \
67 rsnd_write(rsnd_mod_to_priv(m), m, RSND_REG_##r, d)
68#define rsnd_mod_bset(m, r, s, d) \
69 rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d)
70
71#define rsnd_priv_read(p, r) rsnd_read(p, NULL, RSND_REG_##r)
72#define rsnd_priv_write(p, r, d) rsnd_write(p, NULL, RSND_REG_##r, d)
73#define rsnd_priv_bset(p, r, s, d) rsnd_bset(p, NULL, RSND_REG_##r, s, d)
74
75u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg);
76void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
77 enum rsnd_reg reg, u32 data);
78void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg,
79 u32 mask, u32 data);
80
cdaa3cdf
KM
81/*
82 * R-Car sound mod
83 */
84
85struct rsnd_mod_ops {
86 char *name;
87 int (*init)(struct rsnd_mod *mod,
88 struct rsnd_dai *rdai,
89 struct rsnd_dai_stream *io);
90 int (*quit)(struct rsnd_mod *mod,
91 struct rsnd_dai *rdai,
92 struct rsnd_dai_stream *io);
93 int (*start)(struct rsnd_mod *mod,
94 struct rsnd_dai *rdai,
95 struct rsnd_dai_stream *io);
96 int (*stop)(struct rsnd_mod *mod,
97 struct rsnd_dai *rdai,
98 struct rsnd_dai_stream *io);
99};
100
101struct rsnd_mod {
102 int id;
103 struct rsnd_priv *priv;
104 struct rsnd_mod_ops *ops;
105 struct list_head list; /* connect to rsnd_dai playback/capture */
106};
107
108#define rsnd_mod_to_priv(mod) ((mod)->priv)
109#define rsnd_mod_id(mod) ((mod)->id)
110#define for_each_rsnd_mod(pos, n, io) \
111 list_for_each_entry_safe(pos, n, &(io)->head, list)
112#define rsnd_mod_call(mod, func, rdai, io) \
113 (!(mod) ? -ENODEV : \
114 !((mod)->ops->func) ? 0 : \
115 (mod)->ops->func(mod, rdai, io))
116
117void rsnd_mod_init(struct rsnd_priv *priv,
118 struct rsnd_mod *mod,
119 struct rsnd_mod_ops *ops,
120 int id);
121char *rsnd_mod_name(struct rsnd_mod *mod);
122
1536a968
KM
123/*
124 * R-Car sound DAI
125 */
126#define RSND_DAI_NAME_SIZE 16
127struct rsnd_dai_stream {
128 struct list_head head; /* head of rsnd_mod list */
129 struct snd_pcm_substream *substream;
130 int byte_pos;
131 int period_pos;
132 int byte_per_period;
133 int next_period_byte;
134};
135
136struct rsnd_dai {
137 char name[RSND_DAI_NAME_SIZE];
138 struct rsnd_dai_platform_info *info; /* rcar_snd.h */
139 struct rsnd_dai_stream playback;
140 struct rsnd_dai_stream capture;
141
142 int clk_master:1;
143 int bit_clk_inv:1;
144 int frm_clk_inv:1;
145 int sys_delay:1;
146 int data_alignment:1;
147};
148
149#define rsnd_dai_nr(priv) ((priv)->dai_nr)
150#define for_each_rsnd_dai(rdai, priv, i) \
151 for (i = 0, (rdai) = rsnd_dai_get(priv, i); \
152 i < rsnd_dai_nr(priv); \
153 i++, (rdai) = rsnd_dai_get(priv, i))
154
155struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id);
cdaa3cdf
KM
156int rsnd_dai_disconnect(struct rsnd_mod *mod);
157int rsnd_dai_connect(struct rsnd_dai *rdai, struct rsnd_mod *mod,
158 struct rsnd_dai_stream *io);
1536a968
KM
159int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io);
160#define rsnd_dai_get_platform_info(rdai) ((rdai)->info)
ae5c3223 161#define rsnd_io_to_runtime(io) ((io)->substream->runtime)
1536a968
KM
162
163void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt);
164int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional);
165
3337744a
KM
166/*
167 * R-Car Gen1/Gen2
168 */
169int rsnd_gen_probe(struct platform_device *pdev,
170 struct rcar_snd_info *info,
171 struct rsnd_priv *priv);
172void rsnd_gen_remove(struct platform_device *pdev,
173 struct rsnd_priv *priv);
174int rsnd_gen_path_init(struct rsnd_priv *priv,
175 struct rsnd_dai *rdai,
176 struct rsnd_dai_stream *io);
177int rsnd_gen_path_exit(struct rsnd_priv *priv,
178 struct rsnd_dai *rdai,
179 struct rsnd_dai_stream *io);
180void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
181 struct rsnd_mod *mod,
182 enum rsnd_reg reg);
183
dfc9403b
KM
184/*
185 * R-Car ADG
186 */
187int rsnd_adg_ssi_clk_stop(struct rsnd_mod *mod);
188int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate);
189int rsnd_adg_probe(struct platform_device *pdev,
190 struct rcar_snd_info *info,
191 struct rsnd_priv *priv);
192void rsnd_adg_remove(struct platform_device *pdev,
193 struct rsnd_priv *priv);
194
1536a968
KM
195/*
196 * R-Car sound priv
197 */
198struct rsnd_priv {
199
200 struct device *dev;
201 struct rcar_snd_info *info;
202 spinlock_t lock;
203
3337744a
KM
204 /*
205 * below value will be filled on rsnd_gen_probe()
206 */
207 void *gen;
208
07539c1d
KM
209 /*
210 * below value will be filled on rsnd_scu_probe()
211 */
212 void *scu;
213 int scu_nr;
214
dfc9403b
KM
215 /*
216 * below value will be filled on rsnd_adg_probe()
217 */
218 void *adg;
219
ae5c3223
KM
220 /*
221 * below value will be filled on rsnd_ssi_probe()
222 */
223 void *ssiu;
224
1536a968
KM
225 /*
226 * below value will be filled on rsnd_dai_probe()
227 */
228 struct snd_soc_dai_driver *daidrv;
229 struct rsnd_dai *rdai;
230 int dai_nr;
231};
232
233#define rsnd_priv_to_dev(priv) ((priv)->dev)
234#define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags)
235#define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags)
236
07539c1d
KM
237/*
238 * R-Car SCU
239 */
240int rsnd_scu_probe(struct platform_device *pdev,
241 struct rcar_snd_info *info,
242 struct rsnd_priv *priv);
243void rsnd_scu_remove(struct platform_device *pdev,
244 struct rsnd_priv *priv);
245struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id);
246#define rsnd_scu_nr(priv) ((priv)->scu_nr)
247
ae5c3223
KM
248/*
249 * R-Car SSI
250 */
251int rsnd_ssi_probe(struct platform_device *pdev,
252 struct rcar_snd_info *info,
253 struct rsnd_priv *priv);
254void rsnd_ssi_remove(struct platform_device *pdev,
255 struct rsnd_priv *priv);
256struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id);
257
1536a968 258#endif
This page took 0.036338 seconds and 5 git commands to generate.