blob: 8c7dc51b1c4fd8a767a5717a651faed17e68234a [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
106void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod,
107 enum rsnd_reg reg, u32 mask, u32 data)
108{
Kuninori Morimoto4f8f86a2014-07-30 23:52:50 -0700109 struct device *dev = rsnd_priv_to_dev(priv);
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -0700110 struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
111
Kuninori Morimoto42ee5d22013-11-28 18:43:13 -0800112 if (!rsnd_is_accessible_reg(priv, gen, reg))
113 return;
114
Kuninori Morimoto30cc4fa2014-11-09 20:00:30 -0800115 dev_dbg(dev, "b %s[%d] - %4d : %08x/%08x\n",
Kuninori Morimotoace0eb12014-10-21 18:13:46 -0700116 rsnd_mod_name(mod), rsnd_mod_id(mod), reg, data, mask);
117
Kuninori Morimoto55e5b6f2013-09-23 23:12:27 -0700118 regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod),
119 mask, data);
120}
121
Kuninori Morimotoc5212b42015-02-20 10:25:27 +0000122phys_addr_t rsnd_gen_get_phy_addr(struct rsnd_priv *priv, int reg_id)
123{
124 struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
125
126 return gen->res[reg_id];
127}
128
Kuninori Morimoto72779112015-02-20 10:24:52 +0000129#define rsnd_gen_regmap_init(priv, id_size, reg_id, name, conf) \
130 _rsnd_gen_regmap_init(priv, id_size, reg_id, name, conf, ARRAY_SIZE(conf))
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700131static int _rsnd_gen_regmap_init(struct rsnd_priv *priv,
132 int id_size,
133 int reg_id,
Kuninori Morimoto72779112015-02-20 10:24:52 +0000134 const char *name,
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700135 struct rsnd_regmap_field_conf *conf,
136 int conf_size)
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800137{
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700138 struct platform_device *pdev = rsnd_priv_to_pdev(priv);
139 struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800140 struct device *dev = rsnd_priv_to_dev(priv);
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700141 struct resource *res;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800142 struct regmap_config regc;
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700143 struct regmap_field *regs;
144 struct regmap *regmap;
145 struct reg_field regf;
146 void __iomem *base;
147 int i;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800148
149 memset(&regc, 0, sizeof(regc));
150 regc.reg_bits = 32;
151 regc.val_bits = 32;
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700152 regc.reg_stride = 4;
Kuninori Morimoto530b7b42015-03-10 01:25:36 +0000153 regc.name = name;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800154
Kuninori Morimoto72779112015-02-20 10:24:52 +0000155 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
156 if (!res)
157 res = platform_get_resource(pdev, IORESOURCE_MEM, reg_id);
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700158 if (!res)
159 return -ENODEV;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800160
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700161 base = devm_ioremap_resource(dev, res);
162 if (IS_ERR(base))
163 return PTR_ERR(base);
Kuninori Morimoto42ee5d22013-11-28 18:43:13 -0800164
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700165 regmap = devm_regmap_init_mmio(dev, base, &regc);
166 if (IS_ERR(regmap))
167 return PTR_ERR(regmap);
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800168
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700169 gen->base[reg_id] = base;
170 gen->regmap[reg_id] = regmap;
Kuninori Morimotoc5212b42015-02-20 10:25:27 +0000171 gen->res[reg_id] = res->start;
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700172
173 for (i = 0; i < conf_size; i++) {
174
175 regf.reg = conf[i].reg_offset;
176 regf.id_offset = conf[i].id_offset;
177 regf.lsb = 0;
178 regf.msb = 31;
179 regf.id_size = id_size;
180
181 regs = devm_regmap_field_alloc(dev, regmap, regf);
182 if (IS_ERR(regs))
183 return PTR_ERR(regs);
184
185 gen->regs[conf[i].idx] = regs;
Kuninori Morimotoc1e6cc52013-11-28 18:43:01 -0800186 }
187
188 return 0;
189}
Kuninori Morimoto33377442013-07-21 21:36:21 -0700190
Kuninori Morimoto994a9df2013-11-28 18:43:23 -0800191/*
192 * Gen2
Kuninori Morimoto994a9df2013-11-28 18:43:23 -0800193 */
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800194static int rsnd_gen2_probe(struct platform_device *pdev,
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800195 struct rsnd_priv *priv)
196{
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700197 struct rsnd_regmap_field_conf conf_ssiu[] = {
198 RSND_GEN_S_REG(SSI_MODE0, 0x800),
199 RSND_GEN_S_REG(SSI_MODE1, 0x804),
200 /* FIXME: it needs SSI_MODE2/3 in the future */
201 RSND_GEN_M_REG(SSI_BUSIF_MODE, 0x0, 0x80),
202 RSND_GEN_M_REG(SSI_BUSIF_ADINR, 0x4, 0x80),
Kuninori Morimoto1cc71952014-07-30 23:52:26 -0700203 RSND_GEN_M_REG(BUSIF_DALIGN, 0x8, 0x80),
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700204 RSND_GEN_M_REG(SSI_CTRL, 0x10, 0x80),
205 RSND_GEN_M_REG(INT_ENABLE, 0x18, 0x80),
206 };
207 struct rsnd_regmap_field_conf conf_scu[] = {
208 RSND_GEN_M_REG(SRC_BUSIF_MODE, 0x0, 0x20),
209 RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0xc, 0x20),
210 RSND_GEN_M_REG(SRC_CTRL, 0x10, 0x20),
Kuninori Morimotocfcefe02015-01-08 01:52:36 +0000211 RSND_GEN_M_REG(SRC_INT_ENABLE0, 0x18, 0x20),
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700212 RSND_GEN_M_REG(CMD_ROUTE_SLCT, 0x18c, 0x20),
213 RSND_GEN_M_REG(CMD_CTRL, 0x190, 0x20),
Kuninori Morimotocfcefe02015-01-08 01:52:36 +0000214 RSND_GEN_S_REG(SCU_SYS_STATUS0, 0x1c8),
215 RSND_GEN_S_REG(SCU_SYS_INT_EN0, 0x1cc),
216 RSND_GEN_S_REG(SCU_SYS_STATUS1, 0x1d0),
217 RSND_GEN_S_REG(SCU_SYS_INT_EN1, 0x1c4),
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700218 RSND_GEN_M_REG(SRC_SWRSR, 0x200, 0x40),
219 RSND_GEN_M_REG(SRC_SRCIR, 0x204, 0x40),
220 RSND_GEN_M_REG(SRC_ADINR, 0x214, 0x40),
221 RSND_GEN_M_REG(SRC_IFSCR, 0x21c, 0x40),
222 RSND_GEN_M_REG(SRC_IFSVR, 0x220, 0x40),
223 RSND_GEN_M_REG(SRC_SRCCR, 0x224, 0x40),
224 RSND_GEN_M_REG(SRC_BSDSR, 0x22c, 0x40),
225 RSND_GEN_M_REG(SRC_BSISR, 0x238, 0x40),
226 RSND_GEN_M_REG(DVC_SWRSR, 0xe00, 0x100),
227 RSND_GEN_M_REG(DVC_DVUIR, 0xe04, 0x100),
228 RSND_GEN_M_REG(DVC_ADINR, 0xe08, 0x100),
229 RSND_GEN_M_REG(DVC_DVUCR, 0xe10, 0x100),
230 RSND_GEN_M_REG(DVC_ZCMCR, 0xe14, 0x100),
Kuninori Morimoto3539cac2014-11-09 19:52:06 -0800231 RSND_GEN_M_REG(DVC_VRCTR, 0xe18, 0x100),
232 RSND_GEN_M_REG(DVC_VRPDR, 0xe1c, 0x100),
233 RSND_GEN_M_REG(DVC_VRDBR, 0xe20, 0x100),
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700234 RSND_GEN_M_REG(DVC_VOL0R, 0xe28, 0x100),
235 RSND_GEN_M_REG(DVC_VOL1R, 0xe2c, 0x100),
236 RSND_GEN_M_REG(DVC_DVUER, 0xe48, 0x100),
237 };
238 struct rsnd_regmap_field_conf conf_adg[] = {
239 RSND_GEN_S_REG(BRRA, 0x00),
240 RSND_GEN_S_REG(BRRB, 0x04),
241 RSND_GEN_S_REG(SSICKR, 0x08),
242 RSND_GEN_S_REG(AUDIO_CLK_SEL0, 0x0c),
243 RSND_GEN_S_REG(AUDIO_CLK_SEL1, 0x10),
244 RSND_GEN_S_REG(AUDIO_CLK_SEL2, 0x14),
245 RSND_GEN_S_REG(DIV_EN, 0x30),
246 RSND_GEN_S_REG(SRCIN_TIMSEL0, 0x34),
247 RSND_GEN_S_REG(SRCIN_TIMSEL1, 0x38),
248 RSND_GEN_S_REG(SRCIN_TIMSEL2, 0x3c),
249 RSND_GEN_S_REG(SRCIN_TIMSEL3, 0x40),
250 RSND_GEN_S_REG(SRCIN_TIMSEL4, 0x44),
251 RSND_GEN_S_REG(SRCOUT_TIMSEL0, 0x48),
252 RSND_GEN_S_REG(SRCOUT_TIMSEL1, 0x4c),
253 RSND_GEN_S_REG(SRCOUT_TIMSEL2, 0x50),
254 RSND_GEN_S_REG(SRCOUT_TIMSEL3, 0x54),
255 RSND_GEN_S_REG(SRCOUT_TIMSEL4, 0x58),
256 RSND_GEN_S_REG(CMDOUT_TIMSEL, 0x5c),
257 };
258 struct rsnd_regmap_field_conf conf_ssi[] = {
259 RSND_GEN_M_REG(SSICR, 0x00, 0x40),
260 RSND_GEN_M_REG(SSISR, 0x04, 0x40),
261 RSND_GEN_M_REG(SSITDR, 0x08, 0x40),
262 RSND_GEN_M_REG(SSIRDR, 0x0c, 0x40),
263 RSND_GEN_M_REG(SSIWSR, 0x20, 0x40),
264 };
265 int ret_ssiu;
266 int ret_scu;
267 int ret_adg;
268 int ret_ssi;
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800269
Kuninori Morimoto72779112015-02-20 10:24:52 +0000270 ret_ssiu = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SSIU, "ssiu", conf_ssiu);
271 ret_scu = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SCU, "scu", conf_scu);
272 ret_adg = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_ADG, "adg", conf_adg);
273 ret_ssi = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SSI, "ssi", conf_ssi);
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700274 if (ret_ssiu < 0 ||
275 ret_scu < 0 ||
276 ret_adg < 0 ||
277 ret_ssi < 0)
278 return ret_ssiu | ret_scu | ret_adg | ret_ssi;
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800279
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800280 return 0;
281}
282
Kuninori Morimoto994a9df2013-11-28 18:43:23 -0800283/*
284 * Gen1
285 */
286
Kuninori Morimoto33377442013-07-21 21:36:21 -0700287static int rsnd_gen1_probe(struct platform_device *pdev,
Kuninori Morimoto33377442013-07-21 21:36:21 -0700288 struct rsnd_priv *priv)
289{
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700290 struct rsnd_regmap_field_conf conf_sru[] = {
291 RSND_GEN_S_REG(SRC_ROUTE_SEL, 0x00),
292 RSND_GEN_S_REG(SRC_TMG_SEL0, 0x08),
293 RSND_GEN_S_REG(SRC_TMG_SEL1, 0x0c),
294 RSND_GEN_S_REG(SRC_TMG_SEL2, 0x10),
295 RSND_GEN_S_REG(SRC_ROUTE_CTRL, 0xc0),
296 RSND_GEN_S_REG(SSI_MODE0, 0xD0),
297 RSND_GEN_S_REG(SSI_MODE1, 0xD4),
298 RSND_GEN_M_REG(SRC_BUSIF_MODE, 0x20, 0x4),
299 RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0x50, 0x8),
300 RSND_GEN_M_REG(SRC_SWRSR, 0x200, 0x40),
301 RSND_GEN_M_REG(SRC_SRCIR, 0x204, 0x40),
302 RSND_GEN_M_REG(SRC_ADINR, 0x214, 0x40),
303 RSND_GEN_M_REG(SRC_IFSCR, 0x21c, 0x40),
304 RSND_GEN_M_REG(SRC_IFSVR, 0x220, 0x40),
305 RSND_GEN_M_REG(SRC_SRCCR, 0x224, 0x40),
306 RSND_GEN_M_REG(SRC_MNFSR, 0x228, 0x40),
Kuninori Morimotocfcefe02015-01-08 01:52:36 +0000307 /*
308 * ADD US
309 *
310 * SRC_STATUS
311 * SRC_INT_EN
312 * SCU_SYS_STATUS0
313 * SCU_SYS_STATUS1
314 * SCU_SYS_INT_EN0
315 * SCU_SYS_INT_EN1
316 */
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700317 };
318 struct rsnd_regmap_field_conf conf_adg[] = {
319 RSND_GEN_S_REG(BRRA, 0x00),
320 RSND_GEN_S_REG(BRRB, 0x04),
321 RSND_GEN_S_REG(SSICKR, 0x08),
322 RSND_GEN_S_REG(AUDIO_CLK_SEL0, 0x0c),
323 RSND_GEN_S_REG(AUDIO_CLK_SEL1, 0x10),
324 RSND_GEN_S_REG(AUDIO_CLK_SEL3, 0x18),
325 RSND_GEN_S_REG(AUDIO_CLK_SEL4, 0x1c),
326 RSND_GEN_S_REG(AUDIO_CLK_SEL5, 0x20),
327 };
328 struct rsnd_regmap_field_conf conf_ssi[] = {
329 RSND_GEN_M_REG(SSICR, 0x00, 0x40),
330 RSND_GEN_M_REG(SSISR, 0x04, 0x40),
331 RSND_GEN_M_REG(SSITDR, 0x08, 0x40),
332 RSND_GEN_M_REG(SSIRDR, 0x0c, 0x40),
333 RSND_GEN_M_REG(SSIWSR, 0x20, 0x40),
334 };
335 int ret_sru;
336 int ret_adg;
337 int ret_ssi;
Kuninori Morimoto07539c12013-07-21 21:36:35 -0700338
Kuninori Morimoto72779112015-02-20 10:24:52 +0000339 ret_sru = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_SRU, "sru", conf_sru);
340 ret_adg = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_ADG, "adg", conf_adg);
341 ret_ssi = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_SSI, "ssi", conf_ssi);
Kuninori Morimotob8c63782014-07-29 00:37:31 -0700342 if (ret_sru < 0 ||
343 ret_adg < 0 ||
344 ret_ssi < 0)
345 return ret_sru | ret_adg | ret_ssi;
Kuninori Morimoto07539c12013-07-21 21:36:35 -0700346
Kuninori Morimoto33377442013-07-21 21:36:21 -0700347 return 0;
Kuninori Morimoto33377442013-07-21 21:36:21 -0700348}
349
Kuninori Morimoto33377442013-07-21 21:36:21 -0700350/*
351 * Gen
352 */
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700353static void rsnd_of_parse_gen(struct platform_device *pdev,
354 const struct rsnd_of_data *of_data,
355 struct rsnd_priv *priv)
356{
357 struct rcar_snd_info *info = priv->info;
358
359 if (!of_data)
360 return;
361
362 info->flags = of_data->flags;
363}
364
Kuninori Morimoto33377442013-07-21 21:36:21 -0700365int rsnd_gen_probe(struct platform_device *pdev,
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700366 const struct rsnd_of_data *of_data,
Kuninori Morimoto33377442013-07-21 21:36:21 -0700367 struct rsnd_priv *priv)
368{
369 struct device *dev = rsnd_priv_to_dev(priv);
370 struct rsnd_gen *gen;
Kuninori Morimoto531eaf42013-11-28 18:43:34 -0800371 int ret;
Kuninori Morimoto33377442013-07-21 21:36:21 -0700372
Kuninori Morimoto90e8e502014-03-17 19:29:55 -0700373 rsnd_of_parse_gen(pdev, of_data, priv);
374
Kuninori Morimoto33377442013-07-21 21:36:21 -0700375 gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL);
376 if (!gen) {
377 dev_err(dev, "GEN allocate failed\n");
378 return -ENOMEM;
379 }
380
Kuninori Morimoto531eaf42013-11-28 18:43:34 -0800381 priv->gen = gen;
Kuninori Morimoto072188b2013-09-01 20:31:16 -0700382
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800383 ret = -ENODEV;
384 if (rsnd_is_gen1(priv))
Kuninori Morimoto5da39cf2014-02-24 22:15:00 -0800385 ret = rsnd_gen1_probe(pdev, priv);
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800386 else if (rsnd_is_gen2(priv))
Kuninori Morimoto5da39cf2014-02-24 22:15:00 -0800387 ret = rsnd_gen2_probe(pdev, priv);
Kuninori Morimoto507d4662013-11-28 18:43:45 -0800388
389 if (ret < 0)
Kuninori Morimoto072188b2013-09-01 20:31:16 -0700390 dev_err(dev, "unknown generation R-Car sound device\n");
Kuninori Morimoto072188b2013-09-01 20:31:16 -0700391
Kuninori Morimoto531eaf42013-11-28 18:43:34 -0800392 return ret;
Kuninori Morimoto33377442013-07-21 21:36:21 -0700393}