diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2013-07-28 21:59:12 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-06 12:56:13 -0400 |
commit | 374a528111fa07878090bd9694a3e153814de39c (patch) | |
tree | a9af99a7d5a419f7ee7d92b4205e8274a731c566 /sound/soc/sh/rcar/scu.c | |
parent | 849fc82a6f4f32b4c8c502bb7c4a68df51170232 (diff) |
ASoC: rsnd: SSI supports DMA transfer via BUSIF
This patch adds BUSIF support for R-Car sound DMAEngine transfer.
The sound data will be transferred via FIFO which can cover blank time
which will happen when DMA channel is switching.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/sh/rcar/scu.c')
-rw-r--r-- | sound/soc/sh/rcar/scu.c | 154 |
1 files changed, 152 insertions, 2 deletions
diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c index c12e65f240a1..29837e326bc5 100644 --- a/sound/soc/sh/rcar/scu.c +++ b/sound/soc/sh/rcar/scu.c | |||
@@ -15,6 +15,18 @@ struct rsnd_scu { | |||
15 | struct rsnd_mod mod; | 15 | struct rsnd_mod mod; |
16 | }; | 16 | }; |
17 | 17 | ||
18 | #define rsnd_scu_mode_flags(p) ((p)->info->flags) | ||
19 | |||
20 | /* | ||
21 | * ADINR | ||
22 | */ | ||
23 | #define OTBL_24 (0 << 16) | ||
24 | #define OTBL_22 (2 << 16) | ||
25 | #define OTBL_20 (4 << 16) | ||
26 | #define OTBL_18 (6 << 16) | ||
27 | #define OTBL_16 (8 << 16) | ||
28 | |||
29 | |||
18 | #define rsnd_mod_to_scu(_mod) \ | 30 | #define rsnd_mod_to_scu(_mod) \ |
19 | container_of((_mod), struct rsnd_scu, mod) | 31 | container_of((_mod), struct rsnd_scu, mod) |
20 | 32 | ||
@@ -24,6 +36,116 @@ struct rsnd_scu { | |||
24 | ((pos) = (struct rsnd_scu *)(priv)->scu + i); \ | 36 | ((pos) = (struct rsnd_scu *)(priv)->scu + i); \ |
25 | i++) | 37 | i++) |
26 | 38 | ||
39 | static int rsnd_scu_set_route(struct rsnd_priv *priv, | ||
40 | struct rsnd_mod *mod, | ||
41 | struct rsnd_dai *rdai, | ||
42 | struct rsnd_dai_stream *io) | ||
43 | { | ||
44 | struct scu_route_config { | ||
45 | u32 mask; | ||
46 | int shift; | ||
47 | } routes[] = { | ||
48 | { 0xF, 0, }, /* 0 */ | ||
49 | { 0xF, 4, }, /* 1 */ | ||
50 | { 0xF, 8, }, /* 2 */ | ||
51 | { 0x7, 12, }, /* 3 */ | ||
52 | { 0x7, 16, }, /* 4 */ | ||
53 | { 0x7, 20, }, /* 5 */ | ||
54 | { 0x7, 24, }, /* 6 */ | ||
55 | { 0x3, 28, }, /* 7 */ | ||
56 | { 0x3, 30, }, /* 8 */ | ||
57 | }; | ||
58 | |||
59 | u32 mask; | ||
60 | u32 val; | ||
61 | int shift; | ||
62 | int id; | ||
63 | |||
64 | /* | ||
65 | * Gen1 only | ||
66 | */ | ||
67 | if (!rsnd_is_gen1(priv)) | ||
68 | return 0; | ||
69 | |||
70 | id = rsnd_mod_id(mod); | ||
71 | if (id < 0 || id > ARRAY_SIZE(routes)) | ||
72 | return -EIO; | ||
73 | |||
74 | /* | ||
75 | * SRC_ROUTE_SELECT | ||
76 | */ | ||
77 | val = rsnd_dai_is_play(rdai, io) ? 0x1 : 0x2; | ||
78 | val = val << routes[id].shift; | ||
79 | mask = routes[id].mask << routes[id].shift; | ||
80 | |||
81 | rsnd_mod_bset(mod, SRC_ROUTE_SEL, mask, val); | ||
82 | |||
83 | /* | ||
84 | * SRC_TIMING_SELECT | ||
85 | */ | ||
86 | shift = (id % 4) * 8; | ||
87 | mask = 0x1F << shift; | ||
88 | if (8 == id) /* SRU8 is very special */ | ||
89 | val = id << shift; | ||
90 | else | ||
91 | val = (id + 1) << shift; | ||
92 | |||
93 | switch (id / 4) { | ||
94 | case 0: | ||
95 | rsnd_mod_bset(mod, SRC_TMG_SEL0, mask, val); | ||
96 | break; | ||
97 | case 1: | ||
98 | rsnd_mod_bset(mod, SRC_TMG_SEL1, mask, val); | ||
99 | break; | ||
100 | case 2: | ||
101 | rsnd_mod_bset(mod, SRC_TMG_SEL2, mask, val); | ||
102 | break; | ||
103 | } | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | static int rsnd_scu_set_mode(struct rsnd_priv *priv, | ||
109 | struct rsnd_mod *mod, | ||
110 | struct rsnd_dai *rdai, | ||
111 | struct rsnd_dai_stream *io) | ||
112 | { | ||
113 | int id = rsnd_mod_id(mod); | ||
114 | u32 val; | ||
115 | |||
116 | if (rsnd_is_gen1(priv)) { | ||
117 | val = (1 << id); | ||
118 | rsnd_mod_bset(mod, SRC_CTRL, val, val); | ||
119 | } | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static int rsnd_scu_set_hpbif(struct rsnd_priv *priv, | ||
125 | struct rsnd_mod *mod, | ||
126 | struct rsnd_dai *rdai, | ||
127 | struct rsnd_dai_stream *io) | ||
128 | { | ||
129 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); | ||
130 | u32 adinr = runtime->channels; | ||
131 | |||
132 | switch (runtime->sample_bits) { | ||
133 | case 16: | ||
134 | adinr |= OTBL_16; | ||
135 | break; | ||
136 | case 32: | ||
137 | adinr |= OTBL_24; | ||
138 | break; | ||
139 | default: | ||
140 | return -EIO; | ||
141 | } | ||
142 | |||
143 | rsnd_mod_write(mod, BUSIF_MODE, 1); | ||
144 | rsnd_mod_write(mod, BUSIF_ADINR, adinr); | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | |||
27 | static int rsnd_scu_init(struct rsnd_mod *mod, | 149 | static int rsnd_scu_init(struct rsnd_mod *mod, |
28 | struct rsnd_dai *rdai, | 150 | struct rsnd_dai *rdai, |
29 | struct rsnd_dai_stream *io) | 151 | struct rsnd_dai_stream *io) |
@@ -53,9 +175,36 @@ static int rsnd_scu_start(struct rsnd_mod *mod, | |||
53 | struct rsnd_dai_stream *io) | 175 | struct rsnd_dai_stream *io) |
54 | { | 176 | { |
55 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | 177 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); |
178 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
56 | struct device *dev = rsnd_priv_to_dev(priv); | 179 | struct device *dev = rsnd_priv_to_dev(priv); |
180 | u32 flags = rsnd_scu_mode_flags(scu); | ||
181 | int ret; | ||
182 | |||
183 | /* | ||
184 | * SCU will be used if it has RSND_SCU_USB_HPBIF flags | ||
185 | */ | ||
186 | if (!(flags & RSND_SCU_USB_HPBIF)) { | ||
187 | /* it use PIO transter */ | ||
188 | dev_dbg(dev, "%s%d is not used\n", | ||
189 | rsnd_mod_name(mod), rsnd_mod_id(mod)); | ||
190 | |||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | /* it use DMA transter */ | ||
195 | ret = rsnd_scu_set_route(priv, mod, rdai, io); | ||
196 | if (ret < 0) | ||
197 | return ret; | ||
198 | |||
199 | ret = rsnd_scu_set_mode(priv, mod, rdai, io); | ||
200 | if (ret < 0) | ||
201 | return ret; | ||
57 | 202 | ||
58 | dev_dbg(dev, "%s.%d start\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); | 203 | ret = rsnd_scu_set_hpbif(priv, mod, rdai, io); |
204 | if (ret < 0) | ||
205 | return ret; | ||
206 | |||
207 | dev_dbg(dev, "%s%d start\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); | ||
59 | 208 | ||
60 | return 0; | 209 | return 0; |
61 | } | 210 | } |
@@ -112,8 +261,9 @@ int rsnd_scu_probe(struct platform_device *pdev, | |||
112 | rsnd_mod_init(priv, &scu->mod, | 261 | rsnd_mod_init(priv, &scu->mod, |
113 | &rsnd_scu_ops, i); | 262 | &rsnd_scu_ops, i); |
114 | scu->info = &info->scu_info[i]; | 263 | scu->info = &info->scu_info[i]; |
115 | } | ||
116 | 264 | ||
265 | dev_dbg(dev, "SCU%d probed\n", i); | ||
266 | } | ||
117 | dev_dbg(dev, "scu probed\n"); | 267 | dev_dbg(dev, "scu probed\n"); |
118 | 268 | ||
119 | return 0; | 269 | return 0; |