aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/pcm512x.c65
-rw-r--r--sound/soc/codecs/pcm512x.h126
2 files changed, 116 insertions, 75 deletions
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 1150381fc373..cdcb51e4c86f 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -66,22 +66,29 @@ PCM512x_REGULATOR_EVENT(1)
66PCM512x_REGULATOR_EVENT(2) 66PCM512x_REGULATOR_EVENT(2)
67 67
68static const struct reg_default pcm512x_reg_defaults[] = { 68static const struct reg_default pcm512x_reg_defaults[] = {
69 { PCM512x_RESET, 0x00 }, 69 { PCM512x_RESET, 0x00 },
70 { PCM512x_POWER, 0x00 }, 70 { PCM512x_POWER, 0x00 },
71 { PCM512x_MUTE, 0x00 }, 71 { PCM512x_MUTE, 0x00 },
72 { PCM512x_DSP, 0x00 }, 72 { PCM512x_DSP, 0x00 },
73 { PCM512x_PLL_REF, 0x00 }, 73 { PCM512x_PLL_REF, 0x00 },
74 { PCM512x_DAC_ROUTING, 0x11 }, 74 { PCM512x_DAC_ROUTING, 0x11 },
75 { PCM512x_DSP_PROGRAM, 0x01 }, 75 { PCM512x_DSP_PROGRAM, 0x01 },
76 { PCM512x_CLKDET, 0x00 }, 76 { PCM512x_CLKDET, 0x00 },
77 { PCM512x_AUTO_MUTE, 0x00 }, 77 { PCM512x_AUTO_MUTE, 0x00 },
78 { PCM512x_ERROR_DETECT, 0x00 }, 78 { PCM512x_ERROR_DETECT, 0x00 },
79 { PCM512x_DIGITAL_VOLUME_1, 0x00 }, 79 { PCM512x_DIGITAL_VOLUME_1, 0x00 },
80 { PCM512x_DIGITAL_VOLUME_2, 0x30 }, 80 { PCM512x_DIGITAL_VOLUME_2, 0x30 },
81 { PCM512x_DIGITAL_VOLUME_3, 0x30 }, 81 { PCM512x_DIGITAL_VOLUME_3, 0x30 },
82 { PCM512x_DIGITAL_MUTE_1, 0x22 }, 82 { PCM512x_DIGITAL_MUTE_1, 0x22 },
83 { PCM512x_DIGITAL_MUTE_2, 0x00 }, 83 { PCM512x_DIGITAL_MUTE_2, 0x00 },
84 { PCM512x_DIGITAL_MUTE_3, 0x07 }, 84 { PCM512x_DIGITAL_MUTE_3, 0x07 },
85 { PCM512x_OUTPUT_AMPLITUDE, 0x00 },
86 { PCM512x_ANALOG_GAIN_CTRL, 0x00 },
87 { PCM512x_UNDERVOLTAGE_PROT, 0x00 },
88 { PCM512x_ANALOG_MUTE_CTRL, 0x00 },
89 { PCM512x_ANALOG_GAIN_BOOST, 0x00 },
90 { PCM512x_VCOM_CTRL_1, 0x00 },
91 { PCM512x_VCOM_CTRL_2, 0x01 },
85}; 92};
86 93
87static bool pcm512x_readable(struct device *dev, unsigned int reg) 94static bool pcm512x_readable(struct device *dev, unsigned int reg)
@@ -141,9 +148,18 @@ static bool pcm512x_readable(struct device *dev, unsigned int reg)
141 case PCM512x_ANALOG_MUTE_DET: 148 case PCM512x_ANALOG_MUTE_DET:
142 case PCM512x_GPIN: 149 case PCM512x_GPIN:
143 case PCM512x_DIGITAL_MUTE_DET: 150 case PCM512x_DIGITAL_MUTE_DET:
151 case PCM512x_OUTPUT_AMPLITUDE:
152 case PCM512x_ANALOG_GAIN_CTRL:
153 case PCM512x_UNDERVOLTAGE_PROT:
154 case PCM512x_ANALOG_MUTE_CTRL:
155 case PCM512x_ANALOG_GAIN_BOOST:
156 case PCM512x_VCOM_CTRL_1:
157 case PCM512x_VCOM_CTRL_2:
158 case PCM512x_CRAM_CTRL:
144 return true; 159 return true;
145 default: 160 default:
146 return false; 161 /* There are 256 raw register addresses */
162 return reg < 0xff;
147 } 163 }
148} 164}
149 165
@@ -159,9 +175,11 @@ static bool pcm512x_volatile(struct device *dev, unsigned int reg)
159 case PCM512x_ANALOG_MUTE_DET: 175 case PCM512x_ANALOG_MUTE_DET:
160 case PCM512x_GPIN: 176 case PCM512x_GPIN:
161 case PCM512x_DIGITAL_MUTE_DET: 177 case PCM512x_DIGITAL_MUTE_DET:
178 case PCM512x_CRAM_CTRL:
162 return true; 179 return true;
163 default: 180 default:
164 return false; 181 /* There are 256 raw register addresses */
182 return reg < 0xff;
165 } 183 }
166} 184}
167 185
@@ -343,6 +361,14 @@ static struct snd_soc_codec_driver pcm512x_codec_driver = {
343 .num_dapm_routes = ARRAY_SIZE(pcm512x_dapm_routes), 361 .num_dapm_routes = ARRAY_SIZE(pcm512x_dapm_routes),
344}; 362};
345 363
364static const struct regmap_range_cfg pcm512x_range = {
365 .name = "Pages", .range_min = PCM512x_VIRT_BASE,
366 .range_max = PCM512x_MAX_REGISTER,
367 .selector_reg = PCM512x_PAGE,
368 .selector_mask = 0xff,
369 .window_start = 0, .window_len = 0x100,
370};
371
346static const struct regmap_config pcm512x_regmap = { 372static const struct regmap_config pcm512x_regmap = {
347 .reg_bits = 8, 373 .reg_bits = 8,
348 .val_bits = 8, 374 .val_bits = 8,
@@ -350,6 +376,9 @@ static const struct regmap_config pcm512x_regmap = {
350 .readable_reg = pcm512x_readable, 376 .readable_reg = pcm512x_readable,
351 .volatile_reg = pcm512x_volatile, 377 .volatile_reg = pcm512x_volatile,
352 378
379 .ranges = &pcm512x_range,
380 .num_ranges = 1,
381
353 .max_register = PCM512x_MAX_REGISTER, 382 .max_register = PCM512x_MAX_REGISTER,
354 .reg_defaults = pcm512x_reg_defaults, 383 .reg_defaults = pcm512x_reg_defaults,
355 .num_reg_defaults = ARRAY_SIZE(pcm512x_reg_defaults), 384 .num_reg_defaults = ARRAY_SIZE(pcm512x_reg_defaults),
diff --git a/sound/soc/codecs/pcm512x.h b/sound/soc/codecs/pcm512x.h
index b2f518ecb35c..e58743c965d6 100644
--- a/sound/soc/codecs/pcm512x.h
+++ b/sound/soc/codecs/pcm512x.h
@@ -17,66 +17,78 @@
17#ifndef _SND_SOC_PCM512X 17#ifndef _SND_SOC_PCM512X
18#define _SND_SOC_PCM512X 18#define _SND_SOC_PCM512X
19 19
20#define PCM512x_PAGE_0_BASE 0 20#define PCM512x_VIRT_BASE 0x100
21#define PCM512x_PAGE_LEN 0x100
22#define PCM512x_PAGE_BASE(n) (PCM512x_VIRT_BASE + (PCM512x_PAGE_LEN * n))
21 23
22#define PCM512x_PAGE 0 24#define PCM512x_PAGE 0
23 25
24#define PCM512x_RESET (PCM512x_PAGE_0_BASE + 1) 26#define PCM512x_RESET (PCM512x_PAGE_BASE(0) + 1)
25#define PCM512x_POWER (PCM512x_PAGE_0_BASE + 2) 27#define PCM512x_POWER (PCM512x_PAGE_BASE(0) + 2)
26#define PCM512x_MUTE (PCM512x_PAGE_0_BASE + 3) 28#define PCM512x_MUTE (PCM512x_PAGE_BASE(0) + 3)
27#define PCM512x_PLL_EN (PCM512x_PAGE_0_BASE + 4) 29#define PCM512x_PLL_EN (PCM512x_PAGE_BASE(0) + 4)
28#define PCM512x_SPI_MISO_FUNCTION (PCM512x_PAGE_0_BASE + 6) 30#define PCM512x_SPI_MISO_FUNCTION (PCM512x_PAGE_BASE(0) + 6)
29#define PCM512x_DSP (PCM512x_PAGE_0_BASE + 7) 31#define PCM512x_DSP (PCM512x_PAGE_BASE(0) + 7)
30#define PCM512x_GPIO_EN (PCM512x_PAGE_0_BASE + 8) 32#define PCM512x_GPIO_EN (PCM512x_PAGE_BASE(0) + 8)
31#define PCM512x_BCLK_LRCLK_CFG (PCM512x_PAGE_0_BASE + 9) 33#define PCM512x_BCLK_LRCLK_CFG (PCM512x_PAGE_BASE(0) + 9)
32#define PCM512x_DSP_GPIO_INPUT (PCM512x_PAGE_0_BASE + 10) 34#define PCM512x_DSP_GPIO_INPUT (PCM512x_PAGE_BASE(0) + 10)
33#define PCM512x_MASTER_MODE (PCM512x_PAGE_0_BASE + 12) 35#define PCM512x_MASTER_MODE (PCM512x_PAGE_BASE(0) + 12)
34#define PCM512x_PLL_REF (PCM512x_PAGE_0_BASE + 13) 36#define PCM512x_PLL_REF (PCM512x_PAGE_BASE(0) + 13)
35#define PCM512x_PLL_COEFF_0 (PCM512x_PAGE_0_BASE + 20) 37#define PCM512x_PLL_COEFF_0 (PCM512x_PAGE_BASE(0) + 20)
36#define PCM512x_PLL_COEFF_1 (PCM512x_PAGE_0_BASE + 21) 38#define PCM512x_PLL_COEFF_1 (PCM512x_PAGE_BASE(0) + 21)
37#define PCM512x_PLL_COEFF_2 (PCM512x_PAGE_0_BASE + 22) 39#define PCM512x_PLL_COEFF_2 (PCM512x_PAGE_BASE(0) + 22)
38#define PCM512x_PLL_COEFF_3 (PCM512x_PAGE_0_BASE + 23) 40#define PCM512x_PLL_COEFF_3 (PCM512x_PAGE_BASE(0) + 23)
39#define PCM512x_PLL_COEFF_4 (PCM512x_PAGE_0_BASE + 24) 41#define PCM512x_PLL_COEFF_4 (PCM512x_PAGE_BASE(0) + 24)
40#define PCM512x_DSP_CLKDIV (PCM512x_PAGE_0_BASE + 27) 42#define PCM512x_DSP_CLKDIV (PCM512x_PAGE_BASE(0) + 27)
41#define PCM512x_DAC_CLKDIV (PCM512x_PAGE_0_BASE + 28) 43#define PCM512x_DAC_CLKDIV (PCM512x_PAGE_BASE(0) + 28)
42#define PCM512x_NCP_CLKDIV (PCM512x_PAGE_0_BASE + 29) 44#define PCM512x_NCP_CLKDIV (PCM512x_PAGE_BASE(0) + 29)
43#define PCM512x_OSR_CLKDIV (PCM512x_PAGE_0_BASE + 30) 45#define PCM512x_OSR_CLKDIV (PCM512x_PAGE_BASE(0) + 30)
44#define PCM512x_MASTER_CLKDIV_1 (PCM512x_PAGE_0_BASE + 32) 46#define PCM512x_MASTER_CLKDIV_1 (PCM512x_PAGE_BASE(0) + 32)
45#define PCM512x_MASTER_CLKDIV_2 (PCM512x_PAGE_0_BASE + 33) 47#define PCM512x_MASTER_CLKDIV_2 (PCM512x_PAGE_BASE(0) + 33)
46#define PCM512x_FS_SPEED_MODE (PCM512x_PAGE_0_BASE + 34) 48#define PCM512x_FS_SPEED_MODE (PCM512x_PAGE_BASE(0) + 34)
47#define PCM512x_IDAC_1 (PCM512x_PAGE_0_BASE + 35) 49#define PCM512x_IDAC_1 (PCM512x_PAGE_BASE(0) + 35)
48#define PCM512x_IDAC_2 (PCM512x_PAGE_0_BASE + 36) 50#define PCM512x_IDAC_2 (PCM512x_PAGE_BASE(0) + 36)
49#define PCM512x_ERROR_DETECT (PCM512x_PAGE_0_BASE + 37) 51#define PCM512x_ERROR_DETECT (PCM512x_PAGE_BASE(0) + 37)
50#define PCM512x_I2S_1 (PCM512x_PAGE_0_BASE + 40) 52#define PCM512x_I2S_1 (PCM512x_PAGE_BASE(0) + 40)
51#define PCM512x_I2S_2 (PCM512x_PAGE_0_BASE + 41) 53#define PCM512x_I2S_2 (PCM512x_PAGE_BASE(0) + 41)
52#define PCM512x_DAC_ROUTING (PCM512x_PAGE_0_BASE + 42) 54#define PCM512x_DAC_ROUTING (PCM512x_PAGE_BASE(0) + 42)
53#define PCM512x_DSP_PROGRAM (PCM512x_PAGE_0_BASE + 43) 55#define PCM512x_DSP_PROGRAM (PCM512x_PAGE_BASE(0) + 43)
54#define PCM512x_CLKDET (PCM512x_PAGE_0_BASE + 44) 56#define PCM512x_CLKDET (PCM512x_PAGE_BASE(0) + 44)
55#define PCM512x_AUTO_MUTE (PCM512x_PAGE_0_BASE + 59) 57#define PCM512x_AUTO_MUTE (PCM512x_PAGE_BASE(0) + 59)
56#define PCM512x_DIGITAL_VOLUME_1 (PCM512x_PAGE_0_BASE + 60) 58#define PCM512x_DIGITAL_VOLUME_1 (PCM512x_PAGE_BASE(0) + 60)
57#define PCM512x_DIGITAL_VOLUME_2 (PCM512x_PAGE_0_BASE + 61) 59#define PCM512x_DIGITAL_VOLUME_2 (PCM512x_PAGE_BASE(0) + 61)
58#define PCM512x_DIGITAL_VOLUME_3 (PCM512x_PAGE_0_BASE + 62) 60#define PCM512x_DIGITAL_VOLUME_3 (PCM512x_PAGE_BASE(0) + 62)
59#define PCM512x_DIGITAL_MUTE_1 (PCM512x_PAGE_0_BASE + 63) 61#define PCM512x_DIGITAL_MUTE_1 (PCM512x_PAGE_BASE(0) + 63)
60#define PCM512x_DIGITAL_MUTE_2 (PCM512x_PAGE_0_BASE + 64) 62#define PCM512x_DIGITAL_MUTE_2 (PCM512x_PAGE_BASE(0) + 64)
61#define PCM512x_DIGITAL_MUTE_3 (PCM512x_PAGE_0_BASE + 65) 63#define PCM512x_DIGITAL_MUTE_3 (PCM512x_PAGE_BASE(0) + 65)
62#define PCM512x_GPIO_OUTPUT_1 (PCM512x_PAGE_0_BASE + 80) 64#define PCM512x_GPIO_OUTPUT_1 (PCM512x_PAGE_BASE(0) + 80)
63#define PCM512x_GPIO_OUTPUT_2 (PCM512x_PAGE_0_BASE + 81) 65#define PCM512x_GPIO_OUTPUT_2 (PCM512x_PAGE_BASE(0) + 81)
64#define PCM512x_GPIO_OUTPUT_3 (PCM512x_PAGE_0_BASE + 82) 66#define PCM512x_GPIO_OUTPUT_3 (PCM512x_PAGE_BASE(0) + 82)
65#define PCM512x_GPIO_OUTPUT_4 (PCM512x_PAGE_0_BASE + 83) 67#define PCM512x_GPIO_OUTPUT_4 (PCM512x_PAGE_BASE(0) + 83)
66#define PCM512x_GPIO_OUTPUT_5 (PCM512x_PAGE_0_BASE + 84) 68#define PCM512x_GPIO_OUTPUT_5 (PCM512x_PAGE_BASE(0) + 84)
67#define PCM512x_GPIO_OUTPUT_6 (PCM512x_PAGE_0_BASE + 85) 69#define PCM512x_GPIO_OUTPUT_6 (PCM512x_PAGE_BASE(0) + 85)
68#define PCM512x_GPIO_CONTROL_1 (PCM512x_PAGE_0_BASE + 86) 70#define PCM512x_GPIO_CONTROL_1 (PCM512x_PAGE_BASE(0) + 86)
69#define PCM512x_GPIO_CONTROL_2 (PCM512x_PAGE_0_BASE + 87) 71#define PCM512x_GPIO_CONTROL_2 (PCM512x_PAGE_BASE(0) + 87)
70#define PCM512x_OVERFLOW (PCM512x_PAGE_0_BASE + 90) 72#define PCM512x_OVERFLOW (PCM512x_PAGE_BASE(0) + 90)
71#define PCM512x_RATE_DET_1 (PCM512x_PAGE_0_BASE + 91) 73#define PCM512x_RATE_DET_1 (PCM512x_PAGE_BASE(0) + 91)
72#define PCM512x_RATE_DET_2 (PCM512x_PAGE_0_BASE + 92) 74#define PCM512x_RATE_DET_2 (PCM512x_PAGE_BASE(0) + 92)
73#define PCM512x_RATE_DET_3 (PCM512x_PAGE_0_BASE + 93) 75#define PCM512x_RATE_DET_3 (PCM512x_PAGE_BASE(0) + 93)
74#define PCM512x_RATE_DET_4 (PCM512x_PAGE_0_BASE + 94) 76#define PCM512x_RATE_DET_4 (PCM512x_PAGE_BASE(0) + 94)
75#define PCM512x_ANALOG_MUTE_DET (PCM512x_PAGE_0_BASE + 108) 77#define PCM512x_ANALOG_MUTE_DET (PCM512x_PAGE_BASE(0) + 108)
76#define PCM512x_GPIN (PCM512x_PAGE_0_BASE + 119) 78#define PCM512x_GPIN (PCM512x_PAGE_BASE(0) + 119)
77#define PCM512x_DIGITAL_MUTE_DET (PCM512x_PAGE_0_BASE + 120) 79#define PCM512x_DIGITAL_MUTE_DET (PCM512x_PAGE_BASE(0) + 120)
78 80
79#define PCM512x_MAX_REGISTER (PCM512x_PAGE_0_BASE + 120) 81#define PCM512x_OUTPUT_AMPLITUDE (PCM512x_PAGE_BASE(1) + 1)
82#define PCM512x_ANALOG_GAIN_CTRL (PCM512x_PAGE_BASE(1) + 2)
83#define PCM512x_UNDERVOLTAGE_PROT (PCM512x_PAGE_BASE(1) + 5)
84#define PCM512x_ANALOG_MUTE_CTRL (PCM512x_PAGE_BASE(1) + 6)
85#define PCM512x_ANALOG_GAIN_BOOST (PCM512x_PAGE_BASE(1) + 7)
86#define PCM512x_VCOM_CTRL_1 (PCM512x_PAGE_BASE(1) + 8)
87#define PCM512x_VCOM_CTRL_2 (PCM512x_PAGE_BASE(1) + 9)
88
89#define PCM512x_CRAM_CTRL (PCM512x_PAGE_BASE(44) + 1)
90
91#define PCM512x_MAX_REGISTER (PCM512x_PAGE_BASE(44) + 1)
80 92
81/* Page 0, Register 1 - reset */ 93/* Page 0, Register 1 - reset */
82#define PCM512x_RSTR (1 << 0) 94#define PCM512x_RSTR (1 << 0)