aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-10-02 15:14:49 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-10-05 15:17:52 -0400
commiteae2328d41322d4206cac980c14e5f66be4ca600 (patch)
treeaf1f900f66e6fa3b87035cf6c1148a6631cff694
parent999e068e4054982be0a3f9bd590bf168669af822 (diff)
ASoC: wm2200: Map DSPs into regmap
Use the regmap ranges support to add the WM2200 DSP core memory pages into the "register map" beyond the end of the real register map. We don't extend beyond 16 bits since the regmap API will iterate over every register doing diagnostics. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/codecs/wm2200.c85
1 files changed, 84 insertions, 1 deletions
diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
index 367d1e57c86a..1eafaae7d589 100644
--- a/sound/soc/codecs/wm2200.c
+++ b/sound/soc/codecs/wm2200.c
@@ -64,6 +64,66 @@ struct wm2200_priv {
64 int sysclk; 64 int sysclk;
65}; 65};
66 66
67#define WM2200_DSP_RANGE_BASE (WM2200_MAX_REGISTER + 1)
68#define WM2200_DSP_SPACING 12288
69
70#define WM2200_DSP1_DM_BASE (WM2200_DSP_RANGE_BASE + (0 * WM2200_DSP_SPACING))
71#define WM2200_DSP1_PM_BASE (WM2200_DSP_RANGE_BASE + (1 * WM2200_DSP_SPACING))
72#define WM2200_DSP1_ZM_BASE (WM2200_DSP_RANGE_BASE + (2 * WM2200_DSP_SPACING))
73#define WM2200_DSP2_DM_BASE (WM2200_DSP_RANGE_BASE + (3 * WM2200_DSP_SPACING))
74#define WM2200_DSP2_PM_BASE (WM2200_DSP_RANGE_BASE + (4 * WM2200_DSP_SPACING))
75#define WM2200_DSP2_ZM_BASE (WM2200_DSP_RANGE_BASE + (5 * WM2200_DSP_SPACING))
76
77static const struct regmap_range_cfg wm2200_ranges[] = {
78 /* DSP1 DM */
79 { .range_min = WM2200_DSP1_DM_BASE,
80 .range_max = WM2200_DSP1_DM_BASE + 12287,
81 .selector_reg = WM2200_DSP1_CONTROL_3,
82 .selector_mask = WM2200_DSP1_PAGE_BASE_DM_0_MASK,
83 .selector_shift = WM2200_DSP1_PAGE_BASE_DM_0_SHIFT,
84 .window_start = WM2200_DSP1_DM_0, .window_len = 2048, },
85
86 /* DSP1 PM */
87 { .range_min = WM2200_DSP1_PM_BASE,
88 .range_max = WM2200_DSP1_PM_BASE + 12287,
89 .selector_reg = WM2200_DSP1_CONTROL_2,
90 .selector_mask = WM2200_DSP1_PAGE_BASE_PM_0_MASK,
91 .selector_shift = WM2200_DSP1_PAGE_BASE_PM_0_SHIFT,
92 .window_start = WM2200_DSP1_PM_0, .window_len = 768, },
93
94 /* DSP1 ZM */
95 { .range_min = WM2200_DSP1_ZM_BASE,
96 .range_max = WM2200_DSP1_ZM_BASE + 2047,
97 .selector_reg = WM2200_DSP1_CONTROL_4,
98 .selector_mask = WM2200_DSP1_PAGE_BASE_ZM_0_MASK,
99 .selector_shift = WM2200_DSP1_PAGE_BASE_ZM_0_SHIFT,
100 .window_start = WM2200_DSP1_ZM_0, .window_len = 1024, },
101
102 /* DSP2 DM */
103 { .range_min = WM2200_DSP2_DM_BASE,
104 .range_max = WM2200_DSP2_DM_BASE + 4095,
105 .selector_reg = WM2200_DSP2_CONTROL_3,
106 .selector_mask = WM2200_DSP2_PAGE_BASE_DM_0_MASK,
107 .selector_shift = WM2200_DSP2_PAGE_BASE_DM_0_SHIFT,
108 .window_start = WM2200_DSP2_DM_0, .window_len = 2048, },
109
110 /* DSP2 PM */
111 { .range_min = WM2200_DSP2_PM_BASE,
112 .range_max = WM2200_DSP2_PM_BASE + 11287,
113 .selector_reg = WM2200_DSP2_CONTROL_2,
114 .selector_mask = WM2200_DSP2_PAGE_BASE_PM_0_MASK,
115 .selector_shift = WM2200_DSP2_PAGE_BASE_PM_0_SHIFT,
116 .window_start = WM2200_DSP2_PM_0, .window_len = 768, },
117
118 /* DSP2 ZM */
119 { .range_min = WM2200_DSP2_ZM_BASE,
120 .range_max = WM2200_DSP2_ZM_BASE + 2047,
121 .selector_reg = WM2200_DSP2_CONTROL_4,
122 .selector_mask = WM2200_DSP2_PAGE_BASE_ZM_0_MASK,
123 .selector_shift = WM2200_DSP2_PAGE_BASE_ZM_0_SHIFT,
124 .window_start = WM2200_DSP2_ZM_0, .window_len = 1024, },
125};
126
67static struct reg_default wm2200_reg_defaults[] = { 127static struct reg_default wm2200_reg_defaults[] = {
68 { 0x000B, 0x0000 }, /* R11 - Tone Generator 1 */ 128 { 0x000B, 0x0000 }, /* R11 - Tone Generator 1 */
69 { 0x0102, 0x0000 }, /* R258 - Clocking 3 */ 129 { 0x0102, 0x0000 }, /* R258 - Clocking 3 */
@@ -407,6 +467,16 @@ static struct reg_default wm2200_reg_defaults[] = {
407 467
408static bool wm2200_volatile_register(struct device *dev, unsigned int reg) 468static bool wm2200_volatile_register(struct device *dev, unsigned int reg)
409{ 469{
470 int i;
471
472 for (i = 0; i < ARRAY_SIZE(wm2200_ranges); i++)
473 if ((reg >= wm2200_ranges[i].window_start &&
474 reg <= wm2200_ranges[i].window_start +
475 wm2200_ranges[i].window_len) ||
476 (reg >= wm2200_ranges[i].range_min &&
477 reg <= wm2200_ranges[i].range_max))
478 return true;
479
410 switch (reg) { 480 switch (reg) {
411 case WM2200_SOFTWARE_RESET: 481 case WM2200_SOFTWARE_RESET:
412 case WM2200_DEVICE_REVISION: 482 case WM2200_DEVICE_REVISION:
@@ -423,6 +493,16 @@ static bool wm2200_volatile_register(struct device *dev, unsigned int reg)
423 493
424static bool wm2200_readable_register(struct device *dev, unsigned int reg) 494static bool wm2200_readable_register(struct device *dev, unsigned int reg)
425{ 495{
496 int i;
497
498 for (i = 0; i < ARRAY_SIZE(wm2200_ranges); i++)
499 if ((reg >= wm2200_ranges[i].window_start &&
500 reg <= wm2200_ranges[i].window_start +
501 wm2200_ranges[i].window_len) ||
502 (reg >= wm2200_ranges[i].range_min &&
503 reg <= wm2200_ranges[i].range_max))
504 return true;
505
426 switch (reg) { 506 switch (reg) {
427 case WM2200_SOFTWARE_RESET: 507 case WM2200_SOFTWARE_RESET:
428 case WM2200_DEVICE_REVISION: 508 case WM2200_DEVICE_REVISION:
@@ -1991,12 +2071,15 @@ static const struct regmap_config wm2200_regmap = {
1991 .reg_bits = 16, 2071 .reg_bits = 16,
1992 .val_bits = 16, 2072 .val_bits = 16,
1993 2073
1994 .max_register = WM2200_MAX_REGISTER, 2074 .max_register = WM2200_MAX_REGISTER + (ARRAY_SIZE(wm2200_ranges) *
2075 WM2200_DSP_SPACING),
1995 .reg_defaults = wm2200_reg_defaults, 2076 .reg_defaults = wm2200_reg_defaults,
1996 .num_reg_defaults = ARRAY_SIZE(wm2200_reg_defaults), 2077 .num_reg_defaults = ARRAY_SIZE(wm2200_reg_defaults),
1997 .volatile_reg = wm2200_volatile_register, 2078 .volatile_reg = wm2200_volatile_register,
1998 .readable_reg = wm2200_readable_register, 2079 .readable_reg = wm2200_readable_register,
1999 .cache_type = REGCACHE_RBTREE, 2080 .cache_type = REGCACHE_RBTREE,
2081 .ranges = wm2200_ranges,
2082 .num_ranges = ARRAY_SIZE(wm2200_ranges),
2000}; 2083};
2001 2084
2002static const unsigned int wm2200_dig_vu[] = { 2085static const unsigned int wm2200_dig_vu[] = {