blob: 48f704b1d80e37ac9036645bb9a1e8fbb9dffc49 [file] [log] [blame]
Kuninori Morimoto33377442013-07-21 21:36:21 -07001/*
2 * Renesas R-Car Gen1 SRU/SSI support
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 */
Kuninori Morimotoace0eb12014-10-21 18:13:46 -070011
12/*
13 * #define DEBUG
14 *
15 * you can also add below in
16 * ${LINUX}/drivers/base/regmap/regmap.c
17 * for regmap debug
18 *
19 * #define LOG_DEVICE "xxxx.rcar_sound"
20 */
21
Kuninori Morimoto33377442013-07-21 21:36:21 -070022#include "rsnd.h"
23
Kuninori Morimoto33377442013-07-21 21:36:21 -070024struct rsnd_gen {
25 void __iomem *base[RSND_BASE_MAX];
26
Kuninori Morimoto33377442013-07-21 21:36:21 -070027 struct rsnd_gen_ops *ops;
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -070028
Kuninori Morimotob8c63782014-07-29 00:37:31 -070029 struct regmap *regmap[RSND_BASE_MAX];
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -070030 struct regmap_field *regs[RSND_REG_MAX];
Kuninori Morimotoc5212b42015-02-20 10:25:27 +000031 phys_addr_t res[RSND_REG_MAX];
Kuninori Morimoto33377442013-07-21 21:36:21 -070032};
33
34#define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen)
35
Kuninori Morimotob8c63782014-07-29 00:37:31 -070036struct rsnd_regmap_field_conf {
37 int idx;
38 unsigned int reg_offset;
39 unsigned int id_offset;
40};
41
42#define RSND_REG_SET(id, offset, _id_offset) \
43{ \
44 .idx = id, \
45 .reg_offset = offset, \
46 .id_offset = _id_offset, \
47}
48/* single address mapping */
49#define RSND_GEN_S_REG(id, offset) \
50 RSND_REG_SET(RSND_REG_##id, offset, 0)
51
52/* multi address mapping */
53#define RSND_GEN_M_REG(id, offset, _id_offset) \
54 RSND_REG_SET(RSND_REG_##id, offset, _id_offset)
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -070055
56/*
57 * basic function
58 */
Kuninori Morimoto42ee5d22013-11-28 18:43:13 -080059static int rsnd_is_accessible_reg(struct rsnd_priv *priv,
60 struct rsnd_gen *gen, enum rsnd_reg reg)
61{
62 if (!gen->regs[reg]) {
63 struct device *dev = rsnd_priv_to_dev(priv);
64
65 dev_err(dev, "unsupported register access %x\n", reg);
66 return 0;
67 }
68
69 return 1;
70}
71
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -070072u32 rsnd_read(struct rsnd_priv *priv,
73 struct rsnd_mod *mod, enum rsnd_reg reg)
74{
Kuninori Morimotob8c63782014-07-29 00:37:31 -070075 struct device *dev = rsnd_priv_to_dev(priv);
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -070076 struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
77 u32 val;
78
Kuninori Morimoto42ee5d22013-11-28 18:43:13 -080079 if (!rsnd_is_accessible_reg(priv, gen, reg))
80 return 0;
81
Kuninori Morimoto30cc4fa2014-11-09 20:00:30 -080082 dev_dbg(dev, "r %s[%d] - %4d : %08x\n",
Kuninori Morimotoace0eb12014-10-21 18:13:46 -070083 rsnd_mod_name(mod), rsnd_mod_id(mod), reg, val);
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -070084
Kuninori Morimotoace0eb12014-10-21 18:13:46 -070085 regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val);
Kuninori Morimotob8c63782014-07-29 00:37:31 -070086
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -070087 return val;
88}
89
90void rsnd_write(struct rsnd_priv *priv,
91 struct rsnd_mod *mod,
92 enum rsnd_reg reg, u32 data)
93{
Kuninori Morimotob8c63782014-07-29 00:37:31 -070094 struct device *dev = rsnd_priv_to_dev(priv);
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -070095 struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
96
Kuninori Morimoto42ee5d22013-11-28 18:43:13 -080097 if (!rsnd_is_accessible_reg(priv, gen, reg))
98 return;
99
Kuninori Morimoto30cc4fa2014-11-09 20:00:30 -0800100 dev_dbg(dev, "w %s[%d] - %4d : %08x\n",
Kuninori Morimotoace0eb12014-10-21 18:13:46 -0700101 rsnd_mod_name(mod), rsnd_mod_id(mod), reg, data);
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700102
Kuninori Morimotoace0eb12014-10-21 18:13:46 -0700103 regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data);
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -0700104}
105
Kuninori Morimoto7b47ab42015-06-16 08:53:11 +0000106void rsnd_force_write(struct rsnd_priv *priv,
107 struct rsnd_mod *mod,
108 enum rsnd_reg reg, u32 data)
109{
110 struct device *dev = rsnd_priv_to_dev(priv);
111 struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
112
113 if (!rsnd_is_accessible_reg(priv, gen, reg))
114 return;
115
116 dev_dbg(dev, "w %s[%d] - %4d : %08x\n",
117 rsnd_mod_name(mod), rsnd_mod_id(mod), reg, data);
118
119 regmap_fields_force_write(gen->regs[reg], rsnd_mod_id(mod), data);
120}
121
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -0700122void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod,
123 enum rsnd_reg reg, u32 mask, u32 data)
124{
Kuninori Morimoto4f8f86a2014-07-30 23:52:50 -0700125 struct device *dev = rsnd_priv_to_dev(priv);
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -0700126 struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
127
Kuninori Morimoto42ee5d22013-11-28 18:43:13 -0800128 if (!rsnd_is_accessible_reg(priv, gen, reg))
129 return;
130
Kuninori Morimoto30cc4fa2014-11-09 20:00:30 -0800131 dev_dbg(dev, "b %s[%d] - %4d : %08x/%08x\n",
Kuninori Morimotoace0eb12014-10-21 18:13:46 -0700132 rsnd_mod_name(mod), rsnd_mod_id(mod), reg, data, mask);
133
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -0700134 regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod),
135 mask, data);
136}
137
Kuninori Morimotoc5212b42015-02-20 10:25:27 +0000138phys_addr_t rsnd_gen_get_phy_addr(struct rsnd_priv *priv, int reg_id)
139{
140 struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
141
142 return gen->res[reg_id];
143}
144
Kuninori Morimoto72779112015-02-20 10:24:52 +0000145#define rsnd_gen_regmap_init(priv, id_size, reg_id, name, conf) \
146 _rsnd_gen_regmap_init(priv, id_size, reg_id, name, conf, ARRAY_SIZE(conf))
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700147static int _rsnd_gen_regmap_init(struct rsnd_priv *priv,
148 int id_size,
149 int reg_id,
Kuninori Morimoto72779112015-02-20 10:24:52 +0000150 const char *name,
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700151 struct rsnd_regmap_field_conf *conf,
152 int conf_size)
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800153{
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700154 struct platform_device *pdev = rsnd_priv_to_pdev(priv);
155 struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800156 struct device *dev = rsnd_priv_to_dev(priv);
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700157 struct resource *res;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800158 struct regmap_config regc;
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700159 struct regmap_field *regs;
160 struct regmap *regmap;
161 struct reg_field regf;
162 void __iomem *base;
163 int i;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800164
165 memset(&regc, 0, sizeof(regc));
166 regc.reg_bits = 32;
167 regc.val_bits = 32;
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700168 regc.reg_stride = 4;
Kuninori Morimoto530b7b42015-03-10 01:25:36 +0000169 regc.name = name;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800170
Kuninori Morimoto72779112015-02-20 10:24:52 +0000171 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
172 if (!res)
173 res = platform_get_resource(pdev, IORESOURCE_MEM, reg_id);
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700174 if (!res)
175 return -ENODEV;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800176
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700177 base = devm_ioremap_resource(dev, res);
178 if (IS_ERR(base))
179 return PTR_ERR(base);
Kuninori Morimoto42ee5d22013-11-28 18:43:13 -0800180
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700181 regmap = devm_regmap_init_mmio(dev, base, &regc);
182 if (IS_ERR(regmap))
183 return PTR_ERR(regmap);
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800184
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700185 gen->base[reg_id] = base;
186 gen->regmap[reg_id] = regmap;
Kuninori Morimotoc5212b42015-02-20 10:25:27 +0000187 gen->res[reg_id] = res->start;
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700188
189 for (i = 0; i < conf_size; i++) {
190
191 regf.reg = conf[i].reg_offset;
192 regf.id_offset = conf[i].id_offset;
193 regf.lsb = 0;
194 regf.msb = 31;
195 regf.id_size = id_size;
196
197 regs = devm_regmap_field_alloc(dev, regmap, regf);
198 if (IS_ERR(regs))
199 return PTR_ERR(regs);
200
201 gen->regs[conf[i].idx] = regs;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800202 }
203
204 return 0;
205}
Kuninori Morimoto33377442013-07-21 21:36:21 -0700206
Kuninori Morimoto994a9df2013-11-28 18:43:23 -0800207/*
208 * Gen2
Kuninori Morimoto994a9df2013-11-28 18:43:23 -0800209 */
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800210static int rsnd_gen2_probe(struct platform_device *pdev,
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800211 struct rsnd_priv *priv)
212{
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700213 struct rsnd_regmap_field_conf conf_ssiu[] = {
214 RSND_GEN_S_REG(SSI_MODE0, 0x800),
215 RSND_GEN_S_REG(SSI_MODE1, 0x804),
216 /* FIXME: it needs SSI_MODE2/3 in the future */
217 RSND_GEN_M_REG(SSI_BUSIF_MODE, 0x0, 0x80),
218 RSND_GEN_M_REG(SSI_BUSIF_ADINR, 0x4, 0x80),
Kuninori Morimoto1cc71952014-07-30 23:52:26 -0700219 RSND_GEN_M_REG(BUSIF_DALIGN, 0x8, 0x80),
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700220 RSND_GEN_M_REG(SSI_CTRL, 0x10, 0x80),
221 RSND_GEN_M_REG(INT_ENABLE, 0x18, 0x80),
222 };
223 struct rsnd_regmap_field_conf conf_scu[] = {
224 RSND_GEN_M_REG(SRC_BUSIF_MODE, 0x0, 0x20),
225 RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0xc, 0x20),
226 RSND_GEN_M_REG(SRC_CTRL, 0x10, 0x20),
Kuninori Morimotocfcefe02015-01-08 01:52:36 +0000227 RSND_GEN_M_REG(SRC_INT_ENABLE0, 0x18, 0x20),
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700228 RSND_GEN_M_REG(CMD_ROUTE_SLCT, 0x18c, 0x20),
229 RSND_GEN_M_REG(CMD_CTRL, 0x190, 0x20),
Kuninori Morimotocfcefe02015-01-08 01:52:36 +0000230 RSND_GEN_S_REG(SCU_SYS_STATUS0, 0x1c8),
231 RSND_GEN_S_REG(SCU_SYS_INT_EN0, 0x1cc),
232 RSND_GEN_S_REG(SCU_SYS_STATUS1, 0x1d0),
233 RSND_GEN_S_REG(SCU_SYS_INT_EN1, 0x1c4),
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700234 RSND_GEN_M_REG(SRC_SWRSR, 0x200, 0x40),
235 RSND_GEN_M_REG(SRC_SRCIR, 0x204, 0x40),
236 RSND_GEN_M_REG(SRC_ADINR, 0x214, 0x40),
237 RSND_GEN_M_REG(SRC_IFSCR, 0x21c, 0x40),
238 RSND_GEN_M_REG(SRC_IFSVR, 0x220, 0x40),
239 RSND_GEN_M_REG(SRC_SRCCR, 0x224, 0x40),
240 RSND_GEN_M_REG(SRC_BSDSR, 0x22c, 0x40),
241 RSND_GEN_M_REG(SRC_BSISR, 0x238, 0x40),
242 RSND_GEN_M_REG(DVC_SWRSR, 0xe00, 0x100),
243 RSND_GEN_M_REG(DVC_DVUIR, 0xe04, 0x100),
244 RSND_GEN_M_REG(DVC_ADINR, 0xe08, 0x100),
245 RSND_GEN_M_REG(DVC_DVUCR, 0xe10, 0x100),
246 RSND_GEN_M_REG(DVC_ZCMCR, 0xe14, 0x100),
Kuninori Morimoto3539cac2014-11-09 19:52:06 -0800247 RSND_GEN_M_REG(DVC_VRCTR, 0xe18, 0x100),
248 RSND_GEN_M_REG(DVC_VRPDR, 0xe1c, 0x100),
249 RSND_GEN_M_REG(DVC_VRDBR, 0xe20, 0x100),
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700250 RSND_GEN_M_REG(DVC_VOL0R, 0xe28, 0x100),
251 RSND_GEN_M_REG(DVC_VOL1R, 0xe2c, 0x100),
252 RSND_GEN_M_REG(DVC_DVUER, 0xe48, 0x100),
253 };
254 struct rsnd_regmap_field_conf conf_adg[] = {
255 RSND_GEN_S_REG(BRRA, 0x00),
256 RSND_GEN_S_REG(BRRB, 0x04),
257 RSND_GEN_S_REG(SSICKR, 0x08),
258 RSND_GEN_S_REG(AUDIO_CLK_SEL0, 0x0c),
259 RSND_GEN_S_REG(AUDIO_CLK_SEL1, 0x10),
260 RSND_GEN_S_REG(AUDIO_CLK_SEL2, 0x14),
261 RSND_GEN_S_REG(DIV_EN, 0x30),
262 RSND_GEN_S_REG(SRCIN_TIMSEL0, 0x34),
263 RSND_GEN_S_REG(SRCIN_TIMSEL1, 0x38),
264 RSND_GEN_S_REG(SRCIN_TIMSEL2, 0x3c),
265 RSND_GEN_S_REG(SRCIN_TIMSEL3, 0x40),
266 RSND_GEN_S_REG(SRCIN_TIMSEL4, 0x44),
267 RSND_GEN_S_REG(SRCOUT_TIMSEL0, 0x48),
268 RSND_GEN_S_REG(SRCOUT_TIMSEL1, 0x4c),
269 RSND_GEN_S_REG(SRCOUT_TIMSEL2, 0x50),
270 RSND_GEN_S_REG(SRCOUT_TIMSEL3, 0x54),
271 RSND_GEN_S_REG(SRCOUT_TIMSEL4, 0x58),
272 RSND_GEN_S_REG(CMDOUT_TIMSEL, 0x5c),
273 };
274 struct rsnd_regmap_field_conf conf_ssi[] = {
275 RSND_GEN_M_REG(SSICR, 0x00, 0x40),
276 RSND_GEN_M_REG(SSISR, 0x04, 0x40),
277 RSND_GEN_M_REG(SSITDR, 0x08, 0x40),
278 RSND_GEN_M_REG(SSIRDR, 0x0c, 0x40),
279 RSND_GEN_M_REG(SSIWSR, 0x20, 0x40),
280 };
281 int ret_ssiu;
282 int ret_scu;
283 int ret_adg;
284 int ret_ssi;
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800285
Kuninori Morimoto72779112015-02-20 10:24:52 +0000286 ret_ssiu = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SSIU, "ssiu", conf_ssiu);
287 ret_scu = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SCU, "scu", conf_scu);
288 ret_adg = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_ADG, "adg", conf_adg);
289 ret_ssi = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SSI, "ssi", conf_ssi);
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700290 if (ret_ssiu < 0 ||
291 ret_scu < 0 ||
292 ret_adg < 0 ||
293 ret_ssi < 0)
294 return ret_ssiu | ret_scu | ret_adg | ret_ssi;
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800295
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800296 return 0;
297}
298
Kuninori Morimoto994a9df2013-11-28 18:43:23 -0800299/*
300 * Gen1
301 */
302
Kuninori Morimoto33377442013-07-21 21:36:21 -0700303static int rsnd_gen1_probe(struct platform_device *pdev,
Kuninori Morimoto33377442013-07-21 21:36:21 -0700304 struct rsnd_priv *priv)
305{
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700306 struct rsnd_regmap_field_conf conf_sru[] = {
307 RSND_GEN_S_REG(SRC_ROUTE_SEL, 0x00),
308 RSND_GEN_S_REG(SRC_TMG_SEL0, 0x08),
309 RSND_GEN_S_REG(SRC_TMG_SEL1, 0x0c),
310 RSND_GEN_S_REG(SRC_TMG_SEL2, 0x10),
311 RSND_GEN_S_REG(SRC_ROUTE_CTRL, 0xc0),
312 RSND_GEN_S_REG(SSI_MODE0, 0xD0),
313 RSND_GEN_S_REG(SSI_MODE1, 0xD4),
314 RSND_GEN_M_REG(SRC_BUSIF_MODE, 0x20, 0x4),
315 RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0x50, 0x8),
316 RSND_GEN_M_REG(SRC_SWRSR, 0x200, 0x40),
317 RSND_GEN_M_REG(SRC_SRCIR, 0x204, 0x40),
318 RSND_GEN_M_REG(SRC_ADINR, 0x214, 0x40),
319 RSND_GEN_M_REG(SRC_IFSCR, 0x21c, 0x40),
320 RSND_GEN_M_REG(SRC_IFSVR, 0x220, 0x40),
321 RSND_GEN_M_REG(SRC_SRCCR, 0x224, 0x40),
322 RSND_GEN_M_REG(SRC_MNFSR, 0x228, 0x40),
Kuninori Morimotocfcefe02015-01-08 01:52:36 +0000323 /*
324 * ADD US
325 *
326 * SRC_STATUS
327 * SRC_INT_EN
328 * SCU_SYS_STATUS0
329 * SCU_SYS_STATUS1
330 * SCU_SYS_INT_EN0
331 * SCU_SYS_INT_EN1
332 */
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700333 };
334 struct rsnd_regmap_field_conf conf_adg[] = {
335 RSND_GEN_S_REG(BRRA, 0x00),
336 RSND_GEN_S_REG(BRRB, 0x04),
337 RSND_GEN_S_REG(SSICKR, 0x08),
338 RSND_GEN_S_REG(AUDIO_CLK_SEL0, 0x0c),
339 RSND_GEN_S_REG(AUDIO_CLK_SEL1, 0x10),
340 RSND_GEN_S_REG(AUDIO_CLK_SEL3, 0x18),
341 RSND_GEN_S_REG(AUDIO_CLK_SEL4, 0x1c),
342 RSND_GEN_S_REG(AUDIO_CLK_SEL5, 0x20),
343 };
344 struct rsnd_regmap_field_conf conf_ssi[] = {
345 RSND_GEN_M_REG(SSICR, 0x00, 0x40),
346 RSND_GEN_M_REG(SSISR, 0x04, 0x40),
347 RSND_GEN_M_REG(SSITDR, 0x08, 0x40),
348 RSND_GEN_M_REG(SSIRDR, 0x0c, 0x40),
349 RSND_GEN_M_REG(SSIWSR, 0x20, 0x40),
350 };
351 int ret_sru;
352 int ret_adg;
353 int ret_ssi;
Kuninori Morimoto07539c12013-07-21 21:36:35 -0700354
Kuninori Morimoto72779112015-02-20 10:24:52 +0000355 ret_sru = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_SRU, "sru", conf_sru);
356 ret_adg = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_ADG, "adg", conf_adg);
357 ret_ssi = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_SSI, "ssi", conf_ssi);
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700358 if (ret_sru < 0 ||
359 ret_adg < 0 ||
360 ret_ssi < 0)
361 return ret_sru | ret_adg | ret_ssi;
Kuninori Morimoto07539c12013-07-21 21:36:35 -0700362
Kuninori Morimoto33377442013-07-21 21:36:21 -0700363 return 0;
Kuninori Morimoto33377442013-07-21 21:36:21 -0700364}
365
Kuninori Morimoto33377442013-07-21 21:36:21 -0700366/*
367 * Gen
368 */
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700369static void rsnd_of_parse_gen(struct platform_device *pdev,
370 const struct rsnd_of_data *of_data,
371 struct rsnd_priv *priv)
372{
373 struct rcar_snd_info *info = priv->info;
374
375 if (!of_data)
376 return;
377
378 info->flags = of_data->flags;
379}
380
Kuninori Morimoto33377442013-07-21 21:36:21 -0700381int rsnd_gen_probe(struct platform_device *pdev,
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700382 const struct rsnd_of_data *of_data,
Kuninori Morimoto33377442013-07-21 21:36:21 -0700383 struct rsnd_priv *priv)
384{
385 struct device *dev = rsnd_priv_to_dev(priv);
386 struct rsnd_gen *gen;
Kuninori Morimoto531eaf42013-11-28 18:43:34 -0800387 int ret;
Kuninori Morimoto33377442013-07-21 21:36:21 -0700388
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700389 rsnd_of_parse_gen(pdev, of_data, priv);
390
Kuninori Morimoto33377442013-07-21 21:36:21 -0700391 gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL);
392 if (!gen) {
393 dev_err(dev, "GEN allocate failed\n");
394 return -ENOMEM;
395 }
396
Kuninori Morimoto531eaf42013-11-28 18:43:34 -0800397 priv->gen = gen;
Kuninori Morimoto072188b2013-09-01 20:31:16 -0700398
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800399 ret = -ENODEV;
400 if (rsnd_is_gen1(priv))
Kuninori Morimoto5da39cf2014-02-24 22:15:00 -0800401 ret = rsnd_gen1_probe(pdev, priv);
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800402 else if (rsnd_is_gen2(priv))
Kuninori Morimoto5da39cf2014-02-24 22:15:00 -0800403 ret = rsnd_gen2_probe(pdev, priv);
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800404
405 if (ret < 0)
Kuninori Morimoto072188b2013-09-01 20:31:16 -0700406 dev_err(dev, "unknown generation R-Car sound device\n");
Kuninori Morimoto072188b2013-09-01 20:31:16 -0700407
Kuninori Morimoto531eaf42013-11-28 18:43:34 -0800408 return ret;
Kuninori Morimoto33377442013-07-21 21:36:21 -0700409}