aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2013-01-08 11:02:06 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-01-08 15:47:30 -0500
commit45b9ee72d0e70c11a01152ef4bec92718b55906b (patch)
treee66e9509baf83ef400a879d077076edd8ca0b1cb /sound/soc
parentdb40517c75e1a33a886c8cadfa2d95f0fe5f5f4c (diff)
ASoC: wm_adsp: Factor out calculation of memory base addresses
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/wm_adsp.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 990403b162fe..bcc0d0ffe72e 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -156,6 +156,26 @@ static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp,
156 return NULL; 156 return NULL;
157} 157}
158 158
159static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *region,
160 unsigned int offset)
161{
162 switch (region->type) {
163 case WMFW_ADSP1_PM:
164 return region->base + (offset * 3);
165 case WMFW_ADSP1_DM:
166 return region->base + (offset * 2);
167 case WMFW_ADSP2_XM:
168 return region->base + (offset * 2);
169 case WMFW_ADSP2_YM:
170 return region->base + (offset * 2);
171 case WMFW_ADSP1_ZM:
172 return region->base + (offset * 2);
173 default:
174 WARN_ON(NULL != "Unknown memory region type");
175 return offset;
176 }
177}
178
159static int wm_adsp_load(struct wm_adsp *dsp) 179static int wm_adsp_load(struct wm_adsp *dsp)
160{ 180{
161 const struct firmware *firmware; 181 const struct firmware *firmware;
@@ -282,27 +302,27 @@ static int wm_adsp_load(struct wm_adsp *dsp)
282 case WMFW_ADSP1_PM: 302 case WMFW_ADSP1_PM:
283 BUG_ON(!mem); 303 BUG_ON(!mem);
284 region_name = "PM"; 304 region_name = "PM";
285 reg = mem->base + (offset * 3); 305 reg = wm_adsp_region_to_reg(mem, offset);
286 break; 306 break;
287 case WMFW_ADSP1_DM: 307 case WMFW_ADSP1_DM:
288 BUG_ON(!mem); 308 BUG_ON(!mem);
289 region_name = "DM"; 309 region_name = "DM";
290 reg = mem->base + (offset * 2); 310 reg = wm_adsp_region_to_reg(mem, offset);
291 break; 311 break;
292 case WMFW_ADSP2_XM: 312 case WMFW_ADSP2_XM:
293 BUG_ON(!mem); 313 BUG_ON(!mem);
294 region_name = "XM"; 314 region_name = "XM";
295 reg = mem->base + (offset * 2); 315 reg = wm_adsp_region_to_reg(mem, offset);
296 break; 316 break;
297 case WMFW_ADSP2_YM: 317 case WMFW_ADSP2_YM:
298 BUG_ON(!mem); 318 BUG_ON(!mem);
299 region_name = "YM"; 319 region_name = "YM";
300 reg = mem->base + (offset * 2); 320 reg = wm_adsp_region_to_reg(mem, offset);
301 break; 321 break;
302 case WMFW_ADSP1_ZM: 322 case WMFW_ADSP1_ZM:
303 BUG_ON(!mem); 323 BUG_ON(!mem);
304 region_name = "ZM"; 324 region_name = "ZM";
305 reg = mem->base + (offset * 2); 325 reg = wm_adsp_region_to_reg(mem, offset);
306 break; 326 break;
307 default: 327 default:
308 adsp_warn(dsp, 328 adsp_warn(dsp,