diff options
author | Mark Brown <broonie@linaro.org> | 2013-10-24 06:24:11 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-24 06:24:11 -0400 |
commit | 5b2ad46d6eb69a7910a02ce32e977b48897b1ff4 (patch) | |
tree | db1f83dd08c939398706639fd3767a3421100b2b /sound/soc/sh | |
parent | c0840b272839eabe7bf23b82d235cfd22d3417a9 (diff) | |
parent | 92eba04e4bcd469518cc759ac1bf1a49acaa5cc1 (diff) |
Merge remote-tracking branch 'asoc/topic/rcar' into asoc-next
Diffstat (limited to 'sound/soc/sh')
-rw-r--r-- | sound/soc/sh/rcar/adg.c | 11 | ||||
-rw-r--r-- | sound/soc/sh/rcar/core.c | 50 | ||||
-rw-r--r-- | sound/soc/sh/rcar/gen.c | 261 | ||||
-rw-r--r-- | sound/soc/sh/rcar/rsnd.h | 5 | ||||
-rw-r--r-- | sound/soc/sh/rcar/scu.c | 12 | ||||
-rw-r--r-- | sound/soc/sh/rcar/ssi.c | 52 |
6 files changed, 207 insertions, 184 deletions
diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index d80deb7ccf13..9430097979a5 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * for more details. | 8 | * for more details. |
9 | */ | 9 | */ |
10 | #include <linux/sh_clk.h> | 10 | #include <linux/sh_clk.h> |
11 | #include <mach/clock.h> | ||
12 | #include "rsnd.h" | 11 | #include "rsnd.h" |
13 | 12 | ||
14 | #define CLKA 0 | 13 | #define CLKA 0 |
@@ -22,6 +21,7 @@ struct rsnd_adg { | |||
22 | 21 | ||
23 | int rate_of_441khz_div_6; | 22 | int rate_of_441khz_div_6; |
24 | int rate_of_48khz_div_6; | 23 | int rate_of_48khz_div_6; |
24 | u32 ckr; | ||
25 | }; | 25 | }; |
26 | 26 | ||
27 | #define for_each_rsnd_clk(pos, adg, i) \ | 27 | #define for_each_rsnd_clk(pos, adg, i) \ |
@@ -116,6 +116,11 @@ int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate) | |||
116 | 116 | ||
117 | found_clock: | 117 | found_clock: |
118 | 118 | ||
119 | /* see rsnd_adg_ssi_clk_init() */ | ||
120 | rsnd_mod_bset(mod, SSICKR, 0x00FF0000, adg->ckr); | ||
121 | rsnd_mod_write(mod, BRRA, 0x00000002); /* 1/6 */ | ||
122 | rsnd_mod_write(mod, BRRB, 0x00000002); /* 1/6 */ | ||
123 | |||
119 | /* | 124 | /* |
120 | * This "mod" = "ssi" here. | 125 | * This "mod" = "ssi" here. |
121 | * we can get "ssi id" from mod | 126 | * we can get "ssi id" from mod |
@@ -182,9 +187,7 @@ static void rsnd_adg_ssi_clk_init(struct rsnd_priv *priv, struct rsnd_adg *adg) | |||
182 | } | 187 | } |
183 | } | 188 | } |
184 | 189 | ||
185 | rsnd_priv_bset(priv, SSICKR, 0x00FF0000, ckr); | 190 | adg->ckr = ckr; |
186 | rsnd_priv_write(priv, BRRA, 0x00000002); /* 1/6 */ | ||
187 | rsnd_priv_write(priv, BRRB, 0x00000002); /* 1/6 */ | ||
188 | } | 191 | } |
189 | 192 | ||
190 | int rsnd_adg_probe(struct platform_device *pdev, | 193 | int rsnd_adg_probe(struct platform_device *pdev, |
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index a35706028514..b234ed663073 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c | |||
@@ -103,54 +103,9 @@ | |||
103 | * rsnd_platform functions | 103 | * rsnd_platform functions |
104 | */ | 104 | */ |
105 | #define rsnd_platform_call(priv, dai, func, param...) \ | 105 | #define rsnd_platform_call(priv, dai, func, param...) \ |
106 | (!(priv->info->func) ? -ENODEV : \ | 106 | (!(priv->info->func) ? 0 : \ |
107 | priv->info->func(param)) | 107 | priv->info->func(param)) |
108 | 108 | ||
109 | |||
110 | /* | ||
111 | * basic function | ||
112 | */ | ||
113 | u32 rsnd_read(struct rsnd_priv *priv, | ||
114 | struct rsnd_mod *mod, enum rsnd_reg reg) | ||
115 | { | ||
116 | void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); | ||
117 | |||
118 | BUG_ON(!base); | ||
119 | |||
120 | return ioread32(base); | ||
121 | } | ||
122 | |||
123 | void rsnd_write(struct rsnd_priv *priv, | ||
124 | struct rsnd_mod *mod, | ||
125 | enum rsnd_reg reg, u32 data) | ||
126 | { | ||
127 | void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); | ||
128 | struct device *dev = rsnd_priv_to_dev(priv); | ||
129 | |||
130 | BUG_ON(!base); | ||
131 | |||
132 | dev_dbg(dev, "w %p : %08x\n", base, data); | ||
133 | |||
134 | iowrite32(data, base); | ||
135 | } | ||
136 | |||
137 | void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, | ||
138 | enum rsnd_reg reg, u32 mask, u32 data) | ||
139 | { | ||
140 | void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); | ||
141 | struct device *dev = rsnd_priv_to_dev(priv); | ||
142 | u32 val; | ||
143 | |||
144 | BUG_ON(!base); | ||
145 | |||
146 | val = ioread32(base); | ||
147 | val &= ~mask; | ||
148 | val |= data & mask; | ||
149 | iowrite32(val, base); | ||
150 | |||
151 | dev_dbg(dev, "s %p : %08x\n", base, val); | ||
152 | } | ||
153 | |||
154 | /* | 109 | /* |
155 | * rsnd_mod functions | 110 | * rsnd_mod functions |
156 | */ | 111 | */ |
@@ -363,6 +318,9 @@ int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai) | |||
363 | 318 | ||
364 | struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id) | 319 | struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id) |
365 | { | 320 | { |
321 | if ((id < 0) || (id >= rsnd_dai_nr(priv))) | ||
322 | return NULL; | ||
323 | |||
366 | return priv->rdai + id; | 324 | return priv->rdai + id; |
367 | } | 325 | } |
368 | 326 | ||
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index babb203b43b7..61212ee97c28 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c | |||
@@ -11,6 +11,11 @@ | |||
11 | #include "rsnd.h" | 11 | #include "rsnd.h" |
12 | 12 | ||
13 | struct rsnd_gen_ops { | 13 | struct rsnd_gen_ops { |
14 | int (*probe)(struct platform_device *pdev, | ||
15 | struct rcar_snd_info *info, | ||
16 | struct rsnd_priv *priv); | ||
17 | void (*remove)(struct platform_device *pdev, | ||
18 | struct rsnd_priv *priv); | ||
14 | int (*path_init)(struct rsnd_priv *priv, | 19 | int (*path_init)(struct rsnd_priv *priv, |
15 | struct rsnd_dai *rdai, | 20 | struct rsnd_dai *rdai, |
16 | struct rsnd_dai_stream *io); | 21 | struct rsnd_dai_stream *io); |
@@ -19,21 +24,97 @@ struct rsnd_gen_ops { | |||
19 | struct rsnd_dai_stream *io); | 24 | struct rsnd_dai_stream *io); |
20 | }; | 25 | }; |
21 | 26 | ||
22 | struct rsnd_gen_reg_map { | ||
23 | int index; /* -1 : not supported */ | ||
24 | u32 offset_id; /* offset of ssi0, ssi1, ssi2... */ | ||
25 | u32 offset_adr; /* offset of SSICR, SSISR, ... */ | ||
26 | }; | ||
27 | |||
28 | struct rsnd_gen { | 27 | struct rsnd_gen { |
29 | void __iomem *base[RSND_BASE_MAX]; | 28 | void __iomem *base[RSND_BASE_MAX]; |
30 | 29 | ||
31 | struct rsnd_gen_reg_map reg_map[RSND_REG_MAX]; | ||
32 | struct rsnd_gen_ops *ops; | 30 | struct rsnd_gen_ops *ops; |
31 | |||
32 | struct regmap *regmap; | ||
33 | struct regmap_field *regs[RSND_REG_MAX]; | ||
33 | }; | 34 | }; |
34 | 35 | ||
35 | #define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen) | 36 | #define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen) |
36 | 37 | ||
38 | #define RSND_REG_SET(gen, id, reg_id, offset, _id_offset, _id_size) \ | ||
39 | [id] = { \ | ||
40 | .reg = (unsigned int)gen->base[reg_id] + offset, \ | ||
41 | .lsb = 0, \ | ||
42 | .msb = 31, \ | ||
43 | .id_size = _id_size, \ | ||
44 | .id_offset = _id_offset, \ | ||
45 | } | ||
46 | |||
47 | /* | ||
48 | * basic function | ||
49 | */ | ||
50 | static int rsnd_regmap_write32(void *context, const void *_data, size_t count) | ||
51 | { | ||
52 | struct rsnd_priv *priv = context; | ||
53 | struct device *dev = rsnd_priv_to_dev(priv); | ||
54 | u32 *data = (u32 *)_data; | ||
55 | u32 val = data[1]; | ||
56 | void __iomem *reg = (void *)data[0]; | ||
57 | |||
58 | iowrite32(val, reg); | ||
59 | |||
60 | dev_dbg(dev, "w %p : %08x\n", reg, val); | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static int rsnd_regmap_read32(void *context, | ||
66 | const void *_data, size_t reg_size, | ||
67 | void *_val, size_t val_size) | ||
68 | { | ||
69 | struct rsnd_priv *priv = context; | ||
70 | struct device *dev = rsnd_priv_to_dev(priv); | ||
71 | u32 *data = (u32 *)_data; | ||
72 | u32 *val = (u32 *)_val; | ||
73 | void __iomem *reg = (void *)data[0]; | ||
74 | |||
75 | *val = ioread32(reg); | ||
76 | |||
77 | dev_dbg(dev, "r %p : %08x\n", reg, *val); | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static struct regmap_bus rsnd_regmap_bus = { | ||
83 | .write = rsnd_regmap_write32, | ||
84 | .read = rsnd_regmap_read32, | ||
85 | .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, | ||
86 | .val_format_endian_default = REGMAP_ENDIAN_NATIVE, | ||
87 | }; | ||
88 | |||
89 | u32 rsnd_read(struct rsnd_priv *priv, | ||
90 | struct rsnd_mod *mod, enum rsnd_reg reg) | ||
91 | { | ||
92 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
93 | u32 val; | ||
94 | |||
95 | regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); | ||
96 | |||
97 | return val; | ||
98 | } | ||
99 | |||
100 | void rsnd_write(struct rsnd_priv *priv, | ||
101 | struct rsnd_mod *mod, | ||
102 | enum rsnd_reg reg, u32 data) | ||
103 | { | ||
104 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
105 | |||
106 | regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); | ||
107 | } | ||
108 | |||
109 | void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, | ||
110 | enum rsnd_reg reg, u32 mask, u32 data) | ||
111 | { | ||
112 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
113 | |||
114 | regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod), | ||
115 | mask, data); | ||
116 | } | ||
117 | |||
37 | /* | 118 | /* |
38 | * Gen2 | 119 | * Gen2 |
39 | * will be filled in the future | 120 | * will be filled in the future |
@@ -98,44 +179,64 @@ static int rsnd_gen1_path_exit(struct rsnd_priv *priv, | |||
98 | return ret; | 179 | return ret; |
99 | } | 180 | } |
100 | 181 | ||
101 | static struct rsnd_gen_ops rsnd_gen1_ops = { | 182 | /* single address mapping */ |
102 | .path_init = rsnd_gen1_path_init, | 183 | #define RSND_GEN1_S_REG(gen, reg, id, offset) \ |
103 | .path_exit = rsnd_gen1_path_exit, | 184 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, 0, 9) |
104 | }; | ||
105 | 185 | ||
106 | #define RSND_GEN1_REG_MAP(g, s, i, oi, oa) \ | 186 | /* multi address mapping */ |
107 | do { \ | 187 | #define RSND_GEN1_M_REG(gen, reg, id, offset, _id_offset) \ |
108 | (g)->reg_map[RSND_REG_##i].index = RSND_GEN1_##s; \ | 188 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, _id_offset, 9) |
109 | (g)->reg_map[RSND_REG_##i].offset_id = oi; \ | ||
110 | (g)->reg_map[RSND_REG_##i].offset_adr = oa; \ | ||
111 | } while (0) | ||
112 | 189 | ||
113 | static void rsnd_gen1_reg_map_init(struct rsnd_gen *gen) | 190 | static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) |
114 | { | 191 | { |
115 | RSND_GEN1_REG_MAP(gen, SRU, SRC_ROUTE_SEL, 0x0, 0x00); | 192 | int i; |
116 | RSND_GEN1_REG_MAP(gen, SRU, SRC_TMG_SEL0, 0x0, 0x08); | 193 | struct device *dev = rsnd_priv_to_dev(priv); |
117 | RSND_GEN1_REG_MAP(gen, SRU, SRC_TMG_SEL1, 0x0, 0x0c); | 194 | struct regmap_config regc; |
118 | RSND_GEN1_REG_MAP(gen, SRU, SRC_TMG_SEL2, 0x0, 0x10); | 195 | struct reg_field regf[RSND_REG_MAX] = { |
119 | RSND_GEN1_REG_MAP(gen, SRU, SRC_CTRL, 0x0, 0xc0); | 196 | RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_SEL, 0x00), |
120 | RSND_GEN1_REG_MAP(gen, SRU, SSI_MODE0, 0x0, 0xD0); | 197 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL0, 0x08), |
121 | RSND_GEN1_REG_MAP(gen, SRU, SSI_MODE1, 0x0, 0xD4); | 198 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL1, 0x0c), |
122 | RSND_GEN1_REG_MAP(gen, SRU, BUSIF_MODE, 0x4, 0x20); | 199 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL2, 0x10), |
123 | RSND_GEN1_REG_MAP(gen, SRU, BUSIF_ADINR, 0x40, 0x214); | 200 | RSND_GEN1_S_REG(gen, SRU, SRC_CTRL, 0xc0), |
124 | 201 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE0, 0xD0), | |
125 | RSND_GEN1_REG_MAP(gen, ADG, BRRA, 0x0, 0x00); | 202 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE1, 0xD4), |
126 | RSND_GEN1_REG_MAP(gen, ADG, BRRB, 0x0, 0x04); | 203 | RSND_GEN1_M_REG(gen, SRU, BUSIF_MODE, 0x20, 0x4), |
127 | RSND_GEN1_REG_MAP(gen, ADG, SSICKR, 0x0, 0x08); | 204 | RSND_GEN1_M_REG(gen, SRU, BUSIF_ADINR, 0x214, 0x40), |
128 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL0, 0x0, 0x0c); | 205 | |
129 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL1, 0x0, 0x10); | 206 | RSND_GEN1_S_REG(gen, ADG, BRRA, 0x00), |
130 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL3, 0x0, 0x18); | 207 | RSND_GEN1_S_REG(gen, ADG, BRRB, 0x04), |
131 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL4, 0x0, 0x1c); | 208 | RSND_GEN1_S_REG(gen, ADG, SSICKR, 0x08), |
132 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL5, 0x0, 0x20); | 209 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL0, 0x0c), |
133 | 210 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL1, 0x10), | |
134 | RSND_GEN1_REG_MAP(gen, SSI, SSICR, 0x40, 0x00); | 211 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL3, 0x18), |
135 | RSND_GEN1_REG_MAP(gen, SSI, SSISR, 0x40, 0x04); | 212 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL4, 0x1c), |
136 | RSND_GEN1_REG_MAP(gen, SSI, SSITDR, 0x40, 0x08); | 213 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL5, 0x20), |
137 | RSND_GEN1_REG_MAP(gen, SSI, SSIRDR, 0x40, 0x0c); | 214 | |
138 | RSND_GEN1_REG_MAP(gen, SSI, SSIWSR, 0x40, 0x20); | 215 | RSND_GEN1_M_REG(gen, SSI, SSICR, 0x00, 0x40), |
216 | RSND_GEN1_M_REG(gen, SSI, SSISR, 0x04, 0x40), | ||
217 | RSND_GEN1_M_REG(gen, SSI, SSITDR, 0x08, 0x40), | ||
218 | RSND_GEN1_M_REG(gen, SSI, SSIRDR, 0x0c, 0x40), | ||
219 | RSND_GEN1_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), | ||
220 | }; | ||
221 | |||
222 | memset(®c, 0, sizeof(regc)); | ||
223 | regc.reg_bits = 32; | ||
224 | regc.val_bits = 32; | ||
225 | |||
226 | gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, ®c); | ||
227 | if (IS_ERR(gen->regmap)) { | ||
228 | dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap)); | ||
229 | return PTR_ERR(gen->regmap); | ||
230 | } | ||
231 | |||
232 | for (i = 0; i < RSND_REG_MAX; i++) { | ||
233 | gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]); | ||
234 | if (IS_ERR(gen->regs[i])) | ||
235 | return PTR_ERR(gen->regs[i]); | ||
236 | |||
237 | } | ||
238 | |||
239 | return 0; | ||
139 | } | 240 | } |
140 | 241 | ||
141 | static int rsnd_gen1_probe(struct platform_device *pdev, | 242 | static int rsnd_gen1_probe(struct platform_device *pdev, |
@@ -147,6 +248,7 @@ static int rsnd_gen1_probe(struct platform_device *pdev, | |||
147 | struct resource *sru_res; | 248 | struct resource *sru_res; |
148 | struct resource *adg_res; | 249 | struct resource *adg_res; |
149 | struct resource *ssi_res; | 250 | struct resource *ssi_res; |
251 | int ret; | ||
150 | 252 | ||
151 | /* | 253 | /* |
152 | * map address | 254 | * map address |
@@ -163,8 +265,9 @@ static int rsnd_gen1_probe(struct platform_device *pdev, | |||
163 | IS_ERR(gen->base[RSND_GEN1_SSI])) | 265 | IS_ERR(gen->base[RSND_GEN1_SSI])) |
164 | return -ENODEV; | 266 | return -ENODEV; |
165 | 267 | ||
166 | gen->ops = &rsnd_gen1_ops; | 268 | ret = rsnd_gen1_regmap_init(priv, gen); |
167 | rsnd_gen1_reg_map_init(gen); | 269 | if (ret < 0) |
270 | return ret; | ||
168 | 271 | ||
169 | dev_dbg(dev, "Gen1 device probed\n"); | 272 | dev_dbg(dev, "Gen1 device probed\n"); |
170 | dev_dbg(dev, "SRU : %08x => %p\n", sru_res->start, | 273 | dev_dbg(dev, "SRU : %08x => %p\n", sru_res->start, |
@@ -183,6 +286,13 @@ static void rsnd_gen1_remove(struct platform_device *pdev, | |||
183 | { | 286 | { |
184 | } | 287 | } |
185 | 288 | ||
289 | static struct rsnd_gen_ops rsnd_gen1_ops = { | ||
290 | .probe = rsnd_gen1_probe, | ||
291 | .remove = rsnd_gen1_remove, | ||
292 | .path_init = rsnd_gen1_path_init, | ||
293 | .path_exit = rsnd_gen1_path_exit, | ||
294 | }; | ||
295 | |||
186 | /* | 296 | /* |
187 | * Gen | 297 | * Gen |
188 | */ | 298 | */ |
@@ -204,46 +314,12 @@ int rsnd_gen_path_exit(struct rsnd_priv *priv, | |||
204 | return gen->ops->path_exit(priv, rdai, io); | 314 | return gen->ops->path_exit(priv, rdai, io); |
205 | } | 315 | } |
206 | 316 | ||
207 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, | ||
208 | struct rsnd_mod *mod, | ||
209 | enum rsnd_reg reg) | ||
210 | { | ||
211 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
212 | struct device *dev = rsnd_priv_to_dev(priv); | ||
213 | int index; | ||
214 | u32 offset_id, offset_adr; | ||
215 | |||
216 | if (reg >= RSND_REG_MAX) { | ||
217 | dev_err(dev, "rsnd_reg reg error\n"); | ||
218 | return NULL; | ||
219 | } | ||
220 | |||
221 | index = gen->reg_map[reg].index; | ||
222 | offset_id = gen->reg_map[reg].offset_id; | ||
223 | offset_adr = gen->reg_map[reg].offset_adr; | ||
224 | |||
225 | if (index < 0) { | ||
226 | dev_err(dev, "unsupported reg access %d\n", reg); | ||
227 | return NULL; | ||
228 | } | ||
229 | |||
230 | if (offset_id && mod) | ||
231 | offset_id *= rsnd_mod_id(mod); | ||
232 | |||
233 | /* | ||
234 | * index/offset were set on gen1/gen2 | ||
235 | */ | ||
236 | |||
237 | return gen->base[index] + offset_id + offset_adr; | ||
238 | } | ||
239 | |||
240 | int rsnd_gen_probe(struct platform_device *pdev, | 317 | int rsnd_gen_probe(struct platform_device *pdev, |
241 | struct rcar_snd_info *info, | 318 | struct rcar_snd_info *info, |
242 | struct rsnd_priv *priv) | 319 | struct rsnd_priv *priv) |
243 | { | 320 | { |
244 | struct device *dev = rsnd_priv_to_dev(priv); | 321 | struct device *dev = rsnd_priv_to_dev(priv); |
245 | struct rsnd_gen *gen; | 322 | struct rsnd_gen *gen; |
246 | int i; | ||
247 | 323 | ||
248 | gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL); | 324 | gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL); |
249 | if (!gen) { | 325 | if (!gen) { |
@@ -251,30 +327,23 @@ int rsnd_gen_probe(struct platform_device *pdev, | |||
251 | return -ENOMEM; | 327 | return -ENOMEM; |
252 | } | 328 | } |
253 | 329 | ||
254 | priv->gen = gen; | ||
255 | |||
256 | /* | ||
257 | * see | ||
258 | * rsnd_reg_get() | ||
259 | * rsnd_gen_probe() | ||
260 | */ | ||
261 | for (i = 0; i < RSND_REG_MAX; i++) | ||
262 | gen->reg_map[i].index = -1; | ||
263 | |||
264 | /* | ||
265 | * init each module | ||
266 | */ | ||
267 | if (rsnd_is_gen1(priv)) | 330 | if (rsnd_is_gen1(priv)) |
268 | return rsnd_gen1_probe(pdev, info, priv); | 331 | gen->ops = &rsnd_gen1_ops; |
269 | 332 | ||
270 | dev_err(dev, "unknown generation R-Car sound device\n"); | 333 | if (!gen->ops) { |
334 | dev_err(dev, "unknown generation R-Car sound device\n"); | ||
335 | return -ENODEV; | ||
336 | } | ||
271 | 337 | ||
272 | return -ENODEV; | 338 | priv->gen = gen; |
339 | |||
340 | return gen->ops->probe(pdev, info, priv); | ||
273 | } | 341 | } |
274 | 342 | ||
275 | void rsnd_gen_remove(struct platform_device *pdev, | 343 | void rsnd_gen_remove(struct platform_device *pdev, |
276 | struct rsnd_priv *priv) | 344 | struct rsnd_priv *priv) |
277 | { | 345 | { |
278 | if (rsnd_is_gen1(priv)) | 346 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); |
279 | rsnd_gen1_remove(pdev, priv); | 347 | |
348 | gen->ops->remove(pdev, priv); | ||
280 | } | 349 | } |
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 5dd87f4c919e..9e463e50e7e6 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
@@ -78,10 +78,6 @@ struct rsnd_dai_stream; | |||
78 | #define rsnd_mod_bset(m, r, s, d) \ | 78 | #define rsnd_mod_bset(m, r, s, d) \ |
79 | rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d) | 79 | rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d) |
80 | 80 | ||
81 | #define rsnd_priv_read(p, r) rsnd_read(p, NULL, RSND_REG_##r) | ||
82 | #define rsnd_priv_write(p, r, d) rsnd_write(p, NULL, RSND_REG_##r, d) | ||
83 | #define rsnd_priv_bset(p, r, s, d) rsnd_bset(p, NULL, RSND_REG_##r, s, d) | ||
84 | |||
85 | u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg); | 81 | u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg); |
86 | void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod, | 82 | void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod, |
87 | enum rsnd_reg reg, u32 data); | 83 | enum rsnd_reg reg, u32 data); |
@@ -285,6 +281,7 @@ int rsnd_scu_probe(struct platform_device *pdev, | |||
285 | void rsnd_scu_remove(struct platform_device *pdev, | 281 | void rsnd_scu_remove(struct platform_device *pdev, |
286 | struct rsnd_priv *priv); | 282 | struct rsnd_priv *priv); |
287 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id); | 283 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id); |
284 | bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod); | ||
288 | #define rsnd_scu_nr(priv) ((priv)->scu_nr) | 285 | #define rsnd_scu_nr(priv) ((priv)->scu_nr) |
289 | 286 | ||
290 | /* | 287 | /* |
diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c index 2df2e9150b89..1ab1bce6be7f 100644 --- a/sound/soc/sh/rcar/scu.c +++ b/sound/soc/sh/rcar/scu.c | |||
@@ -146,20 +146,26 @@ static int rsnd_scu_set_hpbif(struct rsnd_priv *priv, | |||
146 | return 0; | 146 | return 0; |
147 | } | 147 | } |
148 | 148 | ||
149 | bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod) | ||
150 | { | ||
151 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
152 | u32 flags = rsnd_scu_mode_flags(scu); | ||
153 | |||
154 | return !!(flags & RSND_SCU_USE_HPBIF); | ||
155 | } | ||
156 | |||
149 | static int rsnd_scu_start(struct rsnd_mod *mod, | 157 | static int rsnd_scu_start(struct rsnd_mod *mod, |
150 | struct rsnd_dai *rdai, | 158 | struct rsnd_dai *rdai, |
151 | struct rsnd_dai_stream *io) | 159 | struct rsnd_dai_stream *io) |
152 | { | 160 | { |
153 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | 161 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); |
154 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
155 | struct device *dev = rsnd_priv_to_dev(priv); | 162 | struct device *dev = rsnd_priv_to_dev(priv); |
156 | u32 flags = rsnd_scu_mode_flags(scu); | ||
157 | int ret; | 163 | int ret; |
158 | 164 | ||
159 | /* | 165 | /* |
160 | * SCU will be used if it has RSND_SCU_USE_HPBIF flags | 166 | * SCU will be used if it has RSND_SCU_USE_HPBIF flags |
161 | */ | 167 | */ |
162 | if (!(flags & RSND_SCU_USE_HPBIF)) { | 168 | if (!rsnd_scu_hpbif_is_enable(mod)) { |
163 | /* it use PIO transter */ | 169 | /* it use PIO transter */ |
164 | dev_dbg(dev, "%s%d is not used\n", | 170 | dev_dbg(dev, "%s%d is not used\n", |
165 | rsnd_mod_name(mod), rsnd_mod_id(mod)); | 171 | rsnd_mod_name(mod), rsnd_mod_id(mod)); |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index fae26d3f79d2..b71cf9d7dd3f 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
@@ -101,29 +101,30 @@ struct rsnd_ssiu { | |||
101 | #define rsnd_ssi_to_ssiu(ssi)\ | 101 | #define rsnd_ssi_to_ssiu(ssi)\ |
102 | (((struct rsnd_ssiu *)((ssi) - rsnd_mod_id(&(ssi)->mod))) - 1) | 102 | (((struct rsnd_ssiu *)((ssi) - rsnd_mod_id(&(ssi)->mod))) - 1) |
103 | 103 | ||
104 | static void rsnd_ssi_mode_init(struct rsnd_priv *priv, | 104 | static void rsnd_ssi_mode_set(struct rsnd_priv *priv, |
105 | struct rsnd_ssiu *ssiu) | 105 | struct rsnd_dai *rdai, |
106 | struct rsnd_ssi *ssi) | ||
106 | { | 107 | { |
107 | struct device *dev = rsnd_priv_to_dev(priv); | 108 | struct device *dev = rsnd_priv_to_dev(priv); |
108 | struct rsnd_ssi *ssi; | 109 | struct rsnd_mod *scu; |
110 | struct rsnd_ssiu *ssiu = rsnd_ssi_to_ssiu(ssi); | ||
111 | int id = rsnd_mod_id(&ssi->mod); | ||
109 | u32 flags; | 112 | u32 flags; |
110 | u32 val; | 113 | u32 val; |
111 | int i; | 114 | |
115 | scu = rsnd_scu_mod_get(priv, rsnd_mod_id(&ssi->mod)); | ||
112 | 116 | ||
113 | /* | 117 | /* |
114 | * SSI_MODE0 | 118 | * SSI_MODE0 |
115 | */ | 119 | */ |
116 | ssiu->ssi_mode0 = 0; | 120 | |
117 | for_each_rsnd_ssi(ssi, priv, i) { | 121 | /* see also BUSIF_MODE */ |
118 | flags = rsnd_ssi_mode_flags(ssi); | 122 | if (rsnd_scu_hpbif_is_enable(scu)) { |
119 | 123 | ssiu->ssi_mode0 &= ~(1 << id); | |
120 | /* see also BUSIF_MODE */ | 124 | dev_dbg(dev, "SSI%d uses DEPENDENT mode\n", id); |
121 | if (!(flags & RSND_SSI_DEPENDENT)) { | 125 | } else { |
122 | ssiu->ssi_mode0 |= (1 << i); | 126 | ssiu->ssi_mode0 |= (1 << id); |
123 | dev_dbg(dev, "SSI%d uses INDEPENDENT mode\n", i); | 127 | dev_dbg(dev, "SSI%d uses INDEPENDENT mode\n", id); |
124 | } else { | ||
125 | dev_dbg(dev, "SSI%d uses DEPENDENT mode\n", i); | ||
126 | } | ||
127 | } | 128 | } |
128 | 129 | ||
129 | /* | 130 | /* |
@@ -132,7 +133,7 @@ static void rsnd_ssi_mode_init(struct rsnd_priv *priv, | |||
132 | #define ssi_parent_set(p, sync, adg, ext) \ | 133 | #define ssi_parent_set(p, sync, adg, ext) \ |
133 | do { \ | 134 | do { \ |
134 | ssi->parent = ssiu->ssi + p; \ | 135 | ssi->parent = ssiu->ssi + p; \ |
135 | if (flags & RSND_SSI_CLK_FROM_ADG) \ | 136 | if (rsnd_rdai_is_clk_master(rdai)) \ |
136 | val = adg; \ | 137 | val = adg; \ |
137 | else \ | 138 | else \ |
138 | val = ext; \ | 139 | val = ext; \ |
@@ -140,15 +141,11 @@ static void rsnd_ssi_mode_init(struct rsnd_priv *priv, | |||
140 | val |= sync; \ | 141 | val |= sync; \ |
141 | } while (0) | 142 | } while (0) |
142 | 143 | ||
143 | ssiu->ssi_mode1 = 0; | 144 | flags = rsnd_ssi_mode_flags(ssi); |
144 | for_each_rsnd_ssi(ssi, priv, i) { | 145 | if (flags & RSND_SSI_CLK_PIN_SHARE) { |
145 | flags = rsnd_ssi_mode_flags(ssi); | ||
146 | |||
147 | if (!(flags & RSND_SSI_CLK_PIN_SHARE)) | ||
148 | continue; | ||
149 | 146 | ||
150 | val = 0; | 147 | val = 0; |
151 | switch (i) { | 148 | switch (id) { |
152 | case 1: | 149 | case 1: |
153 | ssi_parent_set(0, (1 << 4), (0x2 << 0), (0x1 << 0)); | 150 | ssi_parent_set(0, (1 << 4), (0x2 << 0), (0x1 << 0)); |
154 | break; | 151 | break; |
@@ -165,11 +162,6 @@ static void rsnd_ssi_mode_init(struct rsnd_priv *priv, | |||
165 | 162 | ||
166 | ssiu->ssi_mode1 |= val; | 163 | ssiu->ssi_mode1 |= val; |
167 | } | 164 | } |
168 | } | ||
169 | |||
170 | static void rsnd_ssi_mode_set(struct rsnd_ssi *ssi) | ||
171 | { | ||
172 | struct rsnd_ssiu *ssiu = rsnd_ssi_to_ssiu(ssi); | ||
173 | 165 | ||
174 | rsnd_mod_write(&ssi->mod, SSI_MODE0, ssiu->ssi_mode0); | 166 | rsnd_mod_write(&ssi->mod, SSI_MODE0, ssiu->ssi_mode0); |
175 | rsnd_mod_write(&ssi->mod, SSI_MODE1, ssiu->ssi_mode1); | 167 | rsnd_mod_write(&ssi->mod, SSI_MODE1, ssiu->ssi_mode1); |
@@ -379,7 +371,7 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, | |||
379 | ssi->cr_own = cr; | 371 | ssi->cr_own = cr; |
380 | ssi->err = -1; /* ignore 1st error */ | 372 | ssi->err = -1; /* ignore 1st error */ |
381 | 373 | ||
382 | rsnd_ssi_mode_set(ssi); | 374 | rsnd_ssi_mode_set(priv, rdai, ssi); |
383 | 375 | ||
384 | dev_dbg(dev, "%s.%d init\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); | 376 | dev_dbg(dev, "%s.%d init\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); |
385 | 377 | ||
@@ -706,8 +698,6 @@ int rsnd_ssi_probe(struct platform_device *pdev, | |||
706 | rsnd_mod_init(priv, &ssi->mod, ops, i); | 698 | rsnd_mod_init(priv, &ssi->mod, ops, i); |
707 | } | 699 | } |
708 | 700 | ||
709 | rsnd_ssi_mode_init(priv, ssiu); | ||
710 | |||
711 | dev_dbg(dev, "ssi probed\n"); | 701 | dev_dbg(dev, "ssi probed\n"); |
712 | 702 | ||
713 | return 0; | 703 | return 0; |