diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-06-03 05:51:14 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-06-03 05:51:14 -0400 |
commit | 8743dcd6639c28204ac03fb3e9db7932e3d85418 (patch) | |
tree | 53b80846cf6731ddb196d522ed2bbf0f76da8344 | |
parent | efd4b76ef789541e7046e873b3546209352cdb59 (diff) | |
parent | e1d4d3c854f25cff6c6c139588570e124d5e8fa4 (diff) |
Merge tag 'asoc-v3.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Final updates for v3.16
A few more updates from the last week of development, nothing too
exciting. Highlights include:
- GPIO descriptor support for jacks
- More updates and fixes to the Freescale SSI, Intel and rsnd drivers.
- New drivers for Analog Devices ADAU1361, ADAU1381, ADAU1761 and
ADAU1781, and Realtek RT5677.
94 files changed, 9610 insertions, 904 deletions
diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt index e4c8b36dcf89..a5e63fa47dc5 100644 --- a/Documentation/devicetree/bindings/sound/max98090.txt +++ b/Documentation/devicetree/bindings/sound/max98090.txt | |||
@@ -10,6 +10,12 @@ Required properties: | |||
10 | 10 | ||
11 | - interrupts : The CODEC's interrupt output. | 11 | - interrupts : The CODEC's interrupt output. |
12 | 12 | ||
13 | Optional properties: | ||
14 | |||
15 | - clocks: The phandle of the master clock to the CODEC | ||
16 | |||
17 | - clock-names: Should be "mclk" | ||
18 | |||
13 | Pins on the device (for linking into audio routes): | 19 | Pins on the device (for linking into audio routes): |
14 | 20 | ||
15 | * MIC1 | 21 | * MIC1 |
diff --git a/Documentation/devicetree/bindings/sound/max98095.txt b/Documentation/devicetree/bindings/sound/max98095.txt index bacbeaac72b5..318a4c82f17f 100644 --- a/Documentation/devicetree/bindings/sound/max98095.txt +++ b/Documentation/devicetree/bindings/sound/max98095.txt | |||
@@ -8,6 +8,12 @@ Required properties: | |||
8 | 8 | ||
9 | - reg : The I2C address of the device. | 9 | - reg : The I2C address of the device. |
10 | 10 | ||
11 | Optional properties: | ||
12 | |||
13 | - clocks: The phandle of the master clock to the CODEC | ||
14 | |||
15 | - clock-names: Should be "mclk" | ||
16 | |||
11 | Example: | 17 | Example: |
12 | 18 | ||
13 | max98095: codec@11 { | 19 | max98095: codec@11 { |
diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt index a44e9179faf5..8346cab046cd 100644 --- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt +++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt | |||
@@ -20,6 +20,7 @@ Required properties: | |||
20 | SSI subnode properties: | 20 | SSI subnode properties: |
21 | - interrupts : Should contain SSI interrupt for PIO transfer | 21 | - interrupts : Should contain SSI interrupt for PIO transfer |
22 | - shared-pin : if shared clock pin | 22 | - shared-pin : if shared clock pin |
23 | - pio-transfer : use PIO transfer mode | ||
23 | 24 | ||
24 | SRC subnode properties: | 25 | SRC subnode properties: |
25 | no properties at this point | 26 | no properties at this point |
diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index 9b9df146fd1a..c2e9841dfce4 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt | |||
@@ -15,6 +15,9 @@ Optional properties: | |||
15 | Each entry is a pair of strings, the first being the | 15 | Each entry is a pair of strings, the first being the |
16 | connection's sink, the second being the connection's | 16 | connection's sink, the second being the connection's |
17 | source. | 17 | source. |
18 | - simple-audio-card,mclk-fs : Multiplication factor between stream rate and codec | ||
19 | mclk. | ||
20 | |||
18 | Optional subnodes: | 21 | Optional subnodes: |
19 | 22 | ||
20 | - simple-audio-card,dai-link : Container for dai-link level | 23 | - simple-audio-card,dai-link : Container for dai-link level |
diff --git a/include/linux/platform_data/adau17x1.h b/include/linux/platform_data/adau17x1.h new file mode 100644 index 000000000000..a81766cae230 --- /dev/null +++ b/include/linux/platform_data/adau17x1.h | |||
@@ -0,0 +1,109 @@ | |||
1 | /* | ||
2 | * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961/ADAU1781/ADAU1781 codecs | ||
3 | * | ||
4 | * Copyright 2011-2014 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2 or later. | ||
8 | */ | ||
9 | |||
10 | #ifndef __LINUX_PLATFORM_DATA_ADAU17X1_H__ | ||
11 | #define __LINUX_PLATFORM_DATA_ADAU17X1_H__ | ||
12 | |||
13 | /** | ||
14 | * enum adau17x1_micbias_voltage - Microphone bias voltage | ||
15 | * @ADAU17X1_MICBIAS_0_90_AVDD: 0.9 * AVDD | ||
16 | * @ADAU17X1_MICBIAS_0_65_AVDD: 0.65 * AVDD | ||
17 | */ | ||
18 | enum adau17x1_micbias_voltage { | ||
19 | ADAU17X1_MICBIAS_0_90_AVDD = 0, | ||
20 | ADAU17X1_MICBIAS_0_65_AVDD = 1, | ||
21 | }; | ||
22 | |||
23 | /** | ||
24 | * enum adau1761_digmic_jackdet_pin_mode - Configuration of the JACKDET/MICIN pin | ||
25 | * @ADAU1761_DIGMIC_JACKDET_PIN_MODE_NONE: Disable the pin | ||
26 | * @ADAU1761_DIGMIC_JACKDET_PIN_MODE_DIGMIC: Configure the pin for usage as | ||
27 | * digital microphone input. | ||
28 | * @ADAU1761_DIGMIC_JACKDET_PIN_MODE_JACKDETECT: Configure the pin for jack | ||
29 | * insertion detection. | ||
30 | */ | ||
31 | enum adau1761_digmic_jackdet_pin_mode { | ||
32 | ADAU1761_DIGMIC_JACKDET_PIN_MODE_NONE, | ||
33 | ADAU1761_DIGMIC_JACKDET_PIN_MODE_DIGMIC, | ||
34 | ADAU1761_DIGMIC_JACKDET_PIN_MODE_JACKDETECT, | ||
35 | }; | ||
36 | |||
37 | /** | ||
38 | * adau1761_jackdetect_debounce_time - Jack insertion detection debounce time | ||
39 | * @ADAU1761_JACKDETECT_DEBOUNCE_5MS: 5 milliseconds | ||
40 | * @ADAU1761_JACKDETECT_DEBOUNCE_10MS: 10 milliseconds | ||
41 | * @ADAU1761_JACKDETECT_DEBOUNCE_20MS: 20 milliseconds | ||
42 | * @ADAU1761_JACKDETECT_DEBOUNCE_40MS: 40 milliseconds | ||
43 | */ | ||
44 | enum adau1761_jackdetect_debounce_time { | ||
45 | ADAU1761_JACKDETECT_DEBOUNCE_5MS = 0, | ||
46 | ADAU1761_JACKDETECT_DEBOUNCE_10MS = 1, | ||
47 | ADAU1761_JACKDETECT_DEBOUNCE_20MS = 2, | ||
48 | ADAU1761_JACKDETECT_DEBOUNCE_40MS = 3, | ||
49 | }; | ||
50 | |||
51 | /** | ||
52 | * enum adau1761_output_mode - Output mode configuration | ||
53 | * @ADAU1761_OUTPUT_MODE_HEADPHONE: Headphone output | ||
54 | * @ADAU1761_OUTPUT_MODE_HEADPHONE_CAPLESS: Capless headphone output | ||
55 | * @ADAU1761_OUTPUT_MODE_LINE: Line output | ||
56 | */ | ||
57 | enum adau1761_output_mode { | ||
58 | ADAU1761_OUTPUT_MODE_HEADPHONE, | ||
59 | ADAU1761_OUTPUT_MODE_HEADPHONE_CAPLESS, | ||
60 | ADAU1761_OUTPUT_MODE_LINE, | ||
61 | }; | ||
62 | |||
63 | /** | ||
64 | * struct adau1761_platform_data - ADAU1761 Codec driver platform data | ||
65 | * @input_differential: If true the input pins will be configured in | ||
66 | * differential mode. | ||
67 | * @lineout_mode: Output mode for the LOUT/ROUT pins | ||
68 | * @headphone_mode: Output mode for the LHP/RHP pins | ||
69 | * @digmic_jackdetect_pin_mode: JACKDET/MICIN pin configuration | ||
70 | * @jackdetect_debounce_time: Jack insertion detection debounce time. | ||
71 | * Note: This value will only be used, if the JACKDET/MICIN pin is configured | ||
72 | * for jack insertion detection. | ||
73 | * @jackdetect_active_low: If true the jack insertion detection is active low. | ||
74 | * Othwise it will be active high. | ||
75 | * @micbias_voltage: Microphone voltage bias | ||
76 | */ | ||
77 | struct adau1761_platform_data { | ||
78 | bool input_differential; | ||
79 | enum adau1761_output_mode lineout_mode; | ||
80 | enum adau1761_output_mode headphone_mode; | ||
81 | |||
82 | enum adau1761_digmic_jackdet_pin_mode digmic_jackdetect_pin_mode; | ||
83 | |||
84 | enum adau1761_jackdetect_debounce_time jackdetect_debounce_time; | ||
85 | bool jackdetect_active_low; | ||
86 | |||
87 | enum adau17x1_micbias_voltage micbias_voltage; | ||
88 | }; | ||
89 | |||
90 | /** | ||
91 | * struct adau1781_platform_data - ADAU1781 Codec driver platform data | ||
92 | * @left_input_differential: If true configure the left input as | ||
93 | * differential input. | ||
94 | * @right_input_differential: If true configure the right input as differntial | ||
95 | * input. | ||
96 | * @use_dmic: If true configure the MIC pins as digital microphone pins instead | ||
97 | * of analog microphone pins. | ||
98 | * @micbias_voltage: Microphone voltage bias | ||
99 | */ | ||
100 | struct adau1781_platform_data { | ||
101 | bool left_input_differential; | ||
102 | bool right_input_differential; | ||
103 | |||
104 | bool use_dmic; | ||
105 | |||
106 | enum adau17x1_micbias_voltage micbias_voltage; | ||
107 | }; | ||
108 | |||
109 | #endif | ||
diff --git a/sound/soc/omap/omap-pcm.h b/include/sound/omap-pcm.h index c1d2f31d71e9..c1d2f31d71e9 100644 --- a/sound/soc/omap/omap-pcm.h +++ b/include/sound/omap-pcm.h | |||
diff --git a/include/sound/rt5677.h b/include/sound/rt5677.h new file mode 100644 index 000000000000..3da14313bcfc --- /dev/null +++ b/include/sound/rt5677.h | |||
@@ -0,0 +1,21 @@ | |||
1 | /* | ||
2 | * linux/sound/rt5677.h -- Platform data for RT5677 | ||
3 | * | ||
4 | * Copyright 2013 Realtek Semiconductor Corp. | ||
5 | * Author: Oder Chiou <oder_chiou@realtek.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef __LINUX_SND_RT5677_H | ||
13 | #define __LINUX_SND_RT5677_H | ||
14 | |||
15 | struct rt5677_platform_data { | ||
16 | /* IN1 IN2 can optionally be differential */ | ||
17 | bool in1_diff; | ||
18 | bool in2_diff; | ||
19 | }; | ||
20 | |||
21 | #endif | ||
diff --git a/include/sound/soc.h b/include/sound/soc.h index dcdcc95efd1d..ed9e2d7e5fdc 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -452,6 +452,9 @@ int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage); | |||
452 | #ifdef CONFIG_GPIOLIB | 452 | #ifdef CONFIG_GPIOLIB |
453 | int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | 453 | int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, |
454 | struct snd_soc_jack_gpio *gpios); | 454 | struct snd_soc_jack_gpio *gpios); |
455 | int snd_soc_jack_add_gpiods(struct device *gpiod_dev, | ||
456 | struct snd_soc_jack *jack, | ||
457 | int count, struct snd_soc_jack_gpio *gpios); | ||
455 | void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | 458 | void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, |
456 | struct snd_soc_jack_gpio *gpios); | 459 | struct snd_soc_jack_gpio *gpios); |
457 | #else | 460 | #else |
@@ -461,6 +464,14 @@ static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
461 | return 0; | 464 | return 0; |
462 | } | 465 | } |
463 | 466 | ||
467 | static inline int snd_soc_jack_add_gpiods(struct device *gpiod_dev, | ||
468 | struct snd_soc_jack *jack, | ||
469 | int count, | ||
470 | struct snd_soc_jack_gpio *gpios) | ||
471 | { | ||
472 | return 0; | ||
473 | } | ||
474 | |||
464 | static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | 475 | static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, |
465 | struct snd_soc_jack_gpio *gpios) | 476 | struct snd_soc_jack_gpio *gpios) |
466 | { | 477 | { |
@@ -587,8 +598,12 @@ struct snd_soc_jack_zone { | |||
587 | /** | 598 | /** |
588 | * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection | 599 | * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection |
589 | * | 600 | * |
590 | * @gpio: gpio number | 601 | * @gpio: legacy gpio number |
591 | * @name: gpio name | 602 | * @idx: gpio descriptor index within the function of the GPIO |
603 | * consumer device | ||
604 | * @gpiod_dev GPIO consumer device | ||
605 | * @name: gpio name. Also as connection ID for the GPIO consumer | ||
606 | * device function name lookup | ||
592 | * @report: value to report when jack detected | 607 | * @report: value to report when jack detected |
593 | * @invert: report presence in low state | 608 | * @invert: report presence in low state |
594 | * @debouce_time: debouce time in ms | 609 | * @debouce_time: debouce time in ms |
@@ -599,6 +614,8 @@ struct snd_soc_jack_zone { | |||
599 | */ | 614 | */ |
600 | struct snd_soc_jack_gpio { | 615 | struct snd_soc_jack_gpio { |
601 | unsigned int gpio; | 616 | unsigned int gpio; |
617 | unsigned int idx; | ||
618 | struct device *gpiod_dev; | ||
602 | const char *name; | 619 | const char *name; |
603 | int report; | 620 | int report; |
604 | int invert; | 621 | int invert; |
@@ -607,6 +624,7 @@ struct snd_soc_jack_gpio { | |||
607 | 624 | ||
608 | struct snd_soc_jack *jack; | 625 | struct snd_soc_jack *jack; |
609 | struct delayed_work work; | 626 | struct delayed_work work; |
627 | struct gpio_desc *desc; | ||
610 | 628 | ||
611 | void *data; | 629 | void *data; |
612 | int (*jack_status_check)(void *data); | 630 | int (*jack_status_check)(void *data); |
@@ -1146,6 +1164,33 @@ static inline struct snd_soc_platform *snd_soc_component_to_platform( | |||
1146 | return container_of(component, struct snd_soc_platform, component); | 1164 | return container_of(component, struct snd_soc_platform, component); |
1147 | } | 1165 | } |
1148 | 1166 | ||
1167 | /** | ||
1168 | * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in | ||
1169 | * @dapm: The DAPM context to cast to the CODEC | ||
1170 | * | ||
1171 | * This function must only be used on DAPM contexts that are known to be part of | ||
1172 | * a CODEC (e.g. in a CODEC driver). Otherwise the behavior is undefined. | ||
1173 | */ | ||
1174 | static inline struct snd_soc_codec *snd_soc_dapm_to_codec( | ||
1175 | struct snd_soc_dapm_context *dapm) | ||
1176 | { | ||
1177 | return container_of(dapm, struct snd_soc_codec, dapm); | ||
1178 | } | ||
1179 | |||
1180 | /** | ||
1181 | * snd_soc_dapm_to_platform() - Casts a DAPM context to the platform it is | ||
1182 | * embedded in | ||
1183 | * @dapm: The DAPM context to cast to the platform. | ||
1184 | * | ||
1185 | * This function must only be used on DAPM contexts that are known to be part of | ||
1186 | * a platform (e.g. in a platform driver). Otherwise the behavior is undefined. | ||
1187 | */ | ||
1188 | static inline struct snd_soc_platform *snd_soc_dapm_to_platform( | ||
1189 | struct snd_soc_dapm_context *dapm) | ||
1190 | { | ||
1191 | return container_of(dapm, struct snd_soc_platform, dapm); | ||
1192 | } | ||
1193 | |||
1149 | /* codec IO */ | 1194 | /* codec IO */ |
1150 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); | 1195 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); |
1151 | int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, | 1196 | int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, |
diff --git a/sound/soc/blackfin/Kconfig b/sound/soc/blackfin/Kconfig index 6347d5910138..6410aa2cc2cf 100644 --- a/sound/soc/blackfin/Kconfig +++ b/sound/soc/blackfin/Kconfig | |||
@@ -43,6 +43,32 @@ config SND_SOC_BFIN_EVAL_ADAU1373 | |||
43 | Note: This driver assumes that first ADAU1373 DAI is connected to the | 43 | Note: This driver assumes that first ADAU1373 DAI is connected to the |
44 | first SPORT port on the BF5XX board. | 44 | first SPORT port on the BF5XX board. |
45 | 45 | ||
46 | config SND_SOC_BFIN_EVAL_ADAU1X61 | ||
47 | tristate "Support for the EVAL-ADAU1X61 board on Blackfin eval boards" | ||
48 | depends on SND_BF5XX_I2S && I2C | ||
49 | select SND_BF5XX_SOC_I2S | ||
50 | select SND_SOC_ADAU1761_I2C | ||
51 | help | ||
52 | Say Y if you want to add support for the Analog Devices EVAL-ADAU1X61 | ||
53 | board connected to one of the Blackfin evaluation boards like the | ||
54 | BF5XX-STAMP or BF5XX-EZKIT. | ||
55 | |||
56 | Note: This driver assumes that the ADAU1X61 is connected to the | ||
57 | first SPORT port on the BF5XX board. | ||
58 | |||
59 | config SND_SOC_BFIN_EVAL_ADAU1X81 | ||
60 | tristate "Support for the EVAL-ADAU1X81 boards on Blackfin eval boards" | ||
61 | depends on SND_BF5XX_I2S && I2C | ||
62 | select SND_BF5XX_SOC_I2S | ||
63 | select SND_SOC_ADAU1781_I2C | ||
64 | help | ||
65 | Say Y if you want to add support for the Analog Devices EVAL-ADAU1X81 | ||
66 | board connected to one of the Blackfin evaluation boards like the | ||
67 | BF5XX-STAMP or BF5XX-EZKIT. | ||
68 | |||
69 | Note: This driver assumes that the ADAU1X81 is connected to the | ||
70 | first SPORT port on the BF5XX board. | ||
71 | |||
46 | config SND_SOC_BFIN_EVAL_ADAV80X | 72 | config SND_SOC_BFIN_EVAL_ADAV80X |
47 | tristate "Support for the EVAL-ADAV80X boards on Blackfin eval boards" | 73 | tristate "Support for the EVAL-ADAV80X boards on Blackfin eval boards" |
48 | depends on SND_BF5XX_I2S && SND_SOC_I2C_AND_SPI | 74 | depends on SND_BF5XX_I2S && SND_SOC_I2C_AND_SPI |
diff --git a/sound/soc/blackfin/Makefile b/sound/soc/blackfin/Makefile index ad0a6e99bc5d..f21e948b2e9b 100644 --- a/sound/soc/blackfin/Makefile +++ b/sound/soc/blackfin/Makefile | |||
@@ -22,6 +22,8 @@ snd-ssm2602-objs := bf5xx-ssm2602.o | |||
22 | snd-ad73311-objs := bf5xx-ad73311.o | 22 | snd-ad73311-objs := bf5xx-ad73311.o |
23 | snd-ad193x-objs := bf5xx-ad193x.o | 23 | snd-ad193x-objs := bf5xx-ad193x.o |
24 | snd-soc-bfin-eval-adau1373-objs := bfin-eval-adau1373.o | 24 | snd-soc-bfin-eval-adau1373-objs := bfin-eval-adau1373.o |
25 | snd-soc-bfin-eval-adau1x61-objs := bfin-eval-adau1x61.o | ||
26 | snd-soc-bfin-eval-adau1x81-objs := bfin-eval-adau1x81.o | ||
25 | snd-soc-bfin-eval-adau1701-objs := bfin-eval-adau1701.o | 27 | snd-soc-bfin-eval-adau1701-objs := bfin-eval-adau1701.o |
26 | snd-soc-bfin-eval-adav80x-objs := bfin-eval-adav80x.o | 28 | snd-soc-bfin-eval-adav80x-objs := bfin-eval-adav80x.o |
27 | 29 | ||
@@ -31,5 +33,7 @@ obj-$(CONFIG_SND_BF5XX_SOC_SSM2602) += snd-ssm2602.o | |||
31 | obj-$(CONFIG_SND_BF5XX_SOC_AD73311) += snd-ad73311.o | 33 | obj-$(CONFIG_SND_BF5XX_SOC_AD73311) += snd-ad73311.o |
32 | obj-$(CONFIG_SND_BF5XX_SOC_AD193X) += snd-ad193x.o | 34 | obj-$(CONFIG_SND_BF5XX_SOC_AD193X) += snd-ad193x.o |
33 | obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373) += snd-soc-bfin-eval-adau1373.o | 35 | obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373) += snd-soc-bfin-eval-adau1373.o |
36 | obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61) += snd-soc-bfin-eval-adau1x61.o | ||
37 | obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X81) += snd-soc-bfin-eval-adau1x81.o | ||
34 | obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701) += snd-soc-bfin-eval-adau1701.o | 38 | obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701) += snd-soc-bfin-eval-adau1701.o |
35 | obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X) += snd-soc-bfin-eval-adav80x.o | 39 | obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X) += snd-soc-bfin-eval-adav80x.o |
diff --git a/sound/soc/blackfin/bfin-eval-adau1x61.c b/sound/soc/blackfin/bfin-eval-adau1x61.c new file mode 100644 index 000000000000..3011906f9d3b --- /dev/null +++ b/sound/soc/blackfin/bfin-eval-adau1x61.c | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | * Machine driver for EVAL-ADAU1x61MINIZ on Analog Devices bfin | ||
3 | * evaluation boards. | ||
4 | * | ||
5 | * Copyright 2011-2014 Analog Devices Inc. | ||
6 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
7 | * | ||
8 | * Licensed under the GPL-2 or later. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/device.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <sound/core.h> | ||
15 | #include <sound/pcm.h> | ||
16 | #include <sound/soc.h> | ||
17 | #include <sound/pcm_params.h> | ||
18 | |||
19 | #include "../codecs/adau17x1.h" | ||
20 | |||
21 | static const struct snd_soc_dapm_widget bfin_eval_adau1x61_dapm_widgets[] = { | ||
22 | SND_SOC_DAPM_LINE("In 1", NULL), | ||
23 | SND_SOC_DAPM_LINE("In 2", NULL), | ||
24 | SND_SOC_DAPM_LINE("In 3-4", NULL), | ||
25 | |||
26 | SND_SOC_DAPM_LINE("Diff Out L", NULL), | ||
27 | SND_SOC_DAPM_LINE("Diff Out R", NULL), | ||
28 | SND_SOC_DAPM_LINE("Stereo Out", NULL), | ||
29 | SND_SOC_DAPM_HP("Capless HP Out", NULL), | ||
30 | }; | ||
31 | |||
32 | static const struct snd_soc_dapm_route bfin_eval_adau1x61_dapm_routes[] = { | ||
33 | { "LAUX", NULL, "In 3-4" }, | ||
34 | { "RAUX", NULL, "In 3-4" }, | ||
35 | { "LINP", NULL, "In 1" }, | ||
36 | { "LINN", NULL, "In 1"}, | ||
37 | { "RINP", NULL, "In 2" }, | ||
38 | { "RINN", NULL, "In 2" }, | ||
39 | |||
40 | { "In 1", NULL, "MICBIAS" }, | ||
41 | { "In 2", NULL, "MICBIAS" }, | ||
42 | |||
43 | { "Capless HP Out", NULL, "LHP" }, | ||
44 | { "Capless HP Out", NULL, "RHP" }, | ||
45 | { "Diff Out L", NULL, "LOUT" }, | ||
46 | { "Diff Out R", NULL, "ROUT" }, | ||
47 | { "Stereo Out", NULL, "LOUT" }, | ||
48 | { "Stereo Out", NULL, "ROUT" }, | ||
49 | }; | ||
50 | |||
51 | static int bfin_eval_adau1x61_hw_params(struct snd_pcm_substream *substream, | ||
52 | struct snd_pcm_hw_params *params) | ||
53 | { | ||
54 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
55 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
56 | int pll_rate; | ||
57 | int ret; | ||
58 | |||
59 | switch (params_rate(params)) { | ||
60 | case 48000: | ||
61 | case 8000: | ||
62 | case 12000: | ||
63 | case 16000: | ||
64 | case 24000: | ||
65 | case 32000: | ||
66 | case 96000: | ||
67 | pll_rate = 48000 * 1024; | ||
68 | break; | ||
69 | case 44100: | ||
70 | case 7350: | ||
71 | case 11025: | ||
72 | case 14700: | ||
73 | case 22050: | ||
74 | case 29400: | ||
75 | case 88200: | ||
76 | pll_rate = 44100 * 1024; | ||
77 | break; | ||
78 | default: | ||
79 | return -EINVAL; | ||
80 | } | ||
81 | |||
82 | ret = snd_soc_dai_set_pll(codec_dai, ADAU17X1_PLL, | ||
83 | ADAU17X1_PLL_SRC_MCLK, 12288000, pll_rate); | ||
84 | if (ret) | ||
85 | return ret; | ||
86 | |||
87 | ret = snd_soc_dai_set_sysclk(codec_dai, ADAU17X1_CLK_SRC_PLL, pll_rate, | ||
88 | SND_SOC_CLOCK_IN); | ||
89 | |||
90 | return ret; | ||
91 | } | ||
92 | |||
93 | static const struct snd_soc_ops bfin_eval_adau1x61_ops = { | ||
94 | .hw_params = bfin_eval_adau1x61_hw_params, | ||
95 | }; | ||
96 | |||
97 | static struct snd_soc_dai_link bfin_eval_adau1x61_dai = { | ||
98 | .name = "adau1x61", | ||
99 | .stream_name = "adau1x61", | ||
100 | .cpu_dai_name = "bfin-i2s.0", | ||
101 | .codec_dai_name = "adau-hifi", | ||
102 | .platform_name = "bfin-i2s-pcm-audio", | ||
103 | .codec_name = "adau1761.0-0038", | ||
104 | .ops = &bfin_eval_adau1x61_ops, | ||
105 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
106 | SND_SOC_DAIFMT_CBM_CFM, | ||
107 | }; | ||
108 | |||
109 | static struct snd_soc_card bfin_eval_adau1x61 = { | ||
110 | .name = "bfin-eval-adau1x61", | ||
111 | .driver_name = "eval-adau1x61", | ||
112 | .dai_link = &bfin_eval_adau1x61_dai, | ||
113 | .num_links = 1, | ||
114 | |||
115 | .dapm_widgets = bfin_eval_adau1x61_dapm_widgets, | ||
116 | .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1x61_dapm_widgets), | ||
117 | .dapm_routes = bfin_eval_adau1x61_dapm_routes, | ||
118 | .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1x61_dapm_routes), | ||
119 | .fully_routed = true, | ||
120 | }; | ||
121 | |||
122 | static int bfin_eval_adau1x61_probe(struct platform_device *pdev) | ||
123 | { | ||
124 | bfin_eval_adau1x61.dev = &pdev->dev; | ||
125 | |||
126 | return devm_snd_soc_register_card(&pdev->dev, &bfin_eval_adau1x61); | ||
127 | } | ||
128 | |||
129 | static struct platform_driver bfin_eval_adau1x61_driver = { | ||
130 | .driver = { | ||
131 | .name = "bfin-eval-adau1x61", | ||
132 | .owner = THIS_MODULE, | ||
133 | .pm = &snd_soc_pm_ops, | ||
134 | }, | ||
135 | .probe = bfin_eval_adau1x61_probe, | ||
136 | }; | ||
137 | module_platform_driver(bfin_eval_adau1x61_driver); | ||
138 | |||
139 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
140 | MODULE_DESCRIPTION("ALSA SoC bfin adau1x61 driver"); | ||
141 | MODULE_LICENSE("GPL"); | ||
142 | MODULE_ALIAS("platform:bfin-eval-adau1x61"); | ||
diff --git a/sound/soc/blackfin/bfin-eval-adau1x81.c b/sound/soc/blackfin/bfin-eval-adau1x81.c new file mode 100644 index 000000000000..5c380f6aed1a --- /dev/null +++ b/sound/soc/blackfin/bfin-eval-adau1x81.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /* | ||
2 | * Machine driver for EVAL-ADAU1x81 on Analog Devices bfin | ||
3 | * evaluation boards. | ||
4 | * | ||
5 | * Copyright 2011-2014 Analog Devices Inc. | ||
6 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
7 | * | ||
8 | * Licensed under the GPL-2 or later. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/device.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <sound/core.h> | ||
15 | #include <sound/pcm.h> | ||
16 | #include <sound/soc.h> | ||
17 | #include <sound/pcm_params.h> | ||
18 | |||
19 | #include "../codecs/adau17x1.h" | ||
20 | |||
21 | static const struct snd_soc_dapm_widget bfin_eval_adau1x81_dapm_widgets[] = { | ||
22 | SND_SOC_DAPM_LINE("Stereo In", NULL), | ||
23 | SND_SOC_DAPM_LINE("Beep", NULL), | ||
24 | |||
25 | SND_SOC_DAPM_SPK("Speaker", NULL), | ||
26 | SND_SOC_DAPM_HP("Headphone", NULL), | ||
27 | }; | ||
28 | |||
29 | static const struct snd_soc_dapm_route bfin_eval_adau1x81_dapm_routes[] = { | ||
30 | { "BEEP", NULL, "Beep" }, | ||
31 | { "LMIC", NULL, "Stereo In" }, | ||
32 | { "LMIC", NULL, "Stereo In" }, | ||
33 | |||
34 | { "Headphone", NULL, "AOUTL" }, | ||
35 | { "Headphone", NULL, "AOUTR" }, | ||
36 | { "Speaker", NULL, "SP" }, | ||
37 | }; | ||
38 | |||
39 | static int bfin_eval_adau1x81_hw_params(struct snd_pcm_substream *substream, | ||
40 | struct snd_pcm_hw_params *params) | ||
41 | { | ||
42 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
43 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
44 | int pll_rate; | ||
45 | int ret; | ||
46 | |||
47 | switch (params_rate(params)) { | ||
48 | case 48000: | ||
49 | case 8000: | ||
50 | case 12000: | ||
51 | case 16000: | ||
52 | case 24000: | ||
53 | case 32000: | ||
54 | case 96000: | ||
55 | pll_rate = 48000 * 1024; | ||
56 | break; | ||
57 | case 44100: | ||
58 | case 7350: | ||
59 | case 11025: | ||
60 | case 14700: | ||
61 | case 22050: | ||
62 | case 29400: | ||
63 | case 88200: | ||
64 | pll_rate = 44100 * 1024; | ||
65 | break; | ||
66 | default: | ||
67 | return -EINVAL; | ||
68 | } | ||
69 | |||
70 | ret = snd_soc_dai_set_pll(codec_dai, ADAU17X1_PLL, | ||
71 | ADAU17X1_PLL_SRC_MCLK, 12288000, pll_rate); | ||
72 | if (ret) | ||
73 | return ret; | ||
74 | |||
75 | ret = snd_soc_dai_set_sysclk(codec_dai, ADAU17X1_CLK_SRC_PLL, pll_rate, | ||
76 | SND_SOC_CLOCK_IN); | ||
77 | |||
78 | return ret; | ||
79 | } | ||
80 | |||
81 | static const struct snd_soc_ops bfin_eval_adau1x81_ops = { | ||
82 | .hw_params = bfin_eval_adau1x81_hw_params, | ||
83 | }; | ||
84 | |||
85 | static struct snd_soc_dai_link bfin_eval_adau1x81_dai = { | ||
86 | .name = "adau1x81", | ||
87 | .stream_name = "adau1x81", | ||
88 | .cpu_dai_name = "bfin-i2s.0", | ||
89 | .codec_dai_name = "adau-hifi", | ||
90 | .platform_name = "bfin-i2s-pcm-audio", | ||
91 | .codec_name = "adau1781.0-0038", | ||
92 | .ops = &bfin_eval_adau1x81_ops, | ||
93 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
94 | SND_SOC_DAIFMT_CBM_CFM, | ||
95 | }; | ||
96 | |||
97 | static struct snd_soc_card bfin_eval_adau1x81 = { | ||
98 | .name = "bfin-eval-adau1x81", | ||
99 | .driver_name = "eval-adau1x81", | ||
100 | .dai_link = &bfin_eval_adau1x81_dai, | ||
101 | .num_links = 1, | ||
102 | |||
103 | .dapm_widgets = bfin_eval_adau1x81_dapm_widgets, | ||
104 | .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1x81_dapm_widgets), | ||
105 | .dapm_routes = bfin_eval_adau1x81_dapm_routes, | ||
106 | .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1x81_dapm_routes), | ||
107 | .fully_routed = true, | ||
108 | }; | ||
109 | |||
110 | static int bfin_eval_adau1x81_probe(struct platform_device *pdev) | ||
111 | { | ||
112 | bfin_eval_adau1x81.dev = &pdev->dev; | ||
113 | |||
114 | return devm_snd_soc_register_card(&pdev->dev, &bfin_eval_adau1x81); | ||
115 | } | ||
116 | |||
117 | static struct platform_driver bfin_eval_adau1x81_driver = { | ||
118 | .driver = { | ||
119 | .name = "bfin-eval-adau1x81", | ||
120 | .owner = THIS_MODULE, | ||
121 | .pm = &snd_soc_pm_ops, | ||
122 | }, | ||
123 | .probe = bfin_eval_adau1x81_probe, | ||
124 | }; | ||
125 | module_platform_driver(bfin_eval_adau1x81_driver); | ||
126 | |||
127 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
128 | MODULE_DESCRIPTION("ALSA SoC bfin adau1x81 driver"); | ||
129 | MODULE_LICENSE("GPL"); | ||
130 | MODULE_ALIAS("platform:bfin-eval-adau1x81"); | ||
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index c59943a19f94..cbfa1e18f651 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -23,6 +23,10 @@ config SND_SOC_ALL_CODECS | |||
23 | select SND_SOC_AD1980 if SND_SOC_AC97_BUS | 23 | select SND_SOC_AD1980 if SND_SOC_AC97_BUS |
24 | select SND_SOC_AD73311 | 24 | select SND_SOC_AD73311 |
25 | select SND_SOC_ADAU1373 if I2C | 25 | select SND_SOC_ADAU1373 if I2C |
26 | select SND_SOC_ADAU1761_I2C if I2C | ||
27 | select SND_SOC_ADAU1761_SPI if SPI | ||
28 | select SND_SOC_ADAU1781_I2C if I2C | ||
29 | select SND_SOC_ADAU1781_SPI if SPI | ||
26 | select SND_SOC_ADAV801 if SPI_MASTER | 30 | select SND_SOC_ADAV801 if SPI_MASTER |
27 | select SND_SOC_ADAV803 if I2C | 31 | select SND_SOC_ADAV803 if I2C |
28 | select SND_SOC_ADAU1977_SPI if SPI_MASTER | 32 | select SND_SOC_ADAU1977_SPI if SPI_MASTER |
@@ -74,6 +78,7 @@ config SND_SOC_ALL_CODECS | |||
74 | select SND_SOC_RT5640 if I2C | 78 | select SND_SOC_RT5640 if I2C |
75 | select SND_SOC_RT5645 if I2C | 79 | select SND_SOC_RT5645 if I2C |
76 | select SND_SOC_RT5651 if I2C | 80 | select SND_SOC_RT5651 if I2C |
81 | select SND_SOC_RT5677 if I2C | ||
77 | select SND_SOC_SGTL5000 if I2C | 82 | select SND_SOC_SGTL5000 if I2C |
78 | select SND_SOC_SI476X if MFD_SI476X_CORE | 83 | select SND_SOC_SI476X if MFD_SI476X_CORE |
79 | select SND_SOC_SIRF_AUDIO_CODEC | 84 | select SND_SOC_SIRF_AUDIO_CODEC |
@@ -214,14 +219,46 @@ config SND_SOC_AD1980 | |||
214 | config SND_SOC_AD73311 | 219 | config SND_SOC_AD73311 |
215 | tristate | 220 | tristate |
216 | 221 | ||
222 | config SND_SOC_ADAU1373 | ||
223 | tristate | ||
224 | |||
217 | config SND_SOC_ADAU1701 | 225 | config SND_SOC_ADAU1701 |
218 | tristate "Analog Devices ADAU1701 CODEC" | 226 | tristate "Analog Devices ADAU1701 CODEC" |
219 | depends on I2C | 227 | depends on I2C |
220 | select SND_SOC_SIGMADSP | 228 | select SND_SOC_SIGMADSP |
221 | 229 | ||
222 | config SND_SOC_ADAU1373 | 230 | config SND_SOC_ADAU17X1 |
231 | tristate | ||
232 | select SND_SOC_SIGMADSP | ||
233 | |||
234 | config SND_SOC_ADAU1761 | ||
235 | tristate | ||
236 | select SND_SOC_ADAU17X1 | ||
237 | |||
238 | config SND_SOC_ADAU1761_I2C | ||
239 | tristate | ||
240 | select SND_SOC_ADAU1761 | ||
241 | select REGMAP_I2C | ||
242 | |||
243 | config SND_SOC_ADAU1761_SPI | ||
244 | tristate | ||
245 | select SND_SOC_ADAU1761 | ||
246 | select REGMAP_SPI | ||
247 | |||
248 | config SND_SOC_ADAU1781 | ||
249 | select SND_SOC_ADAU17X1 | ||
223 | tristate | 250 | tristate |
224 | 251 | ||
252 | config SND_SOC_ADAU1781_I2C | ||
253 | tristate | ||
254 | select SND_SOC_ADAU1781 | ||
255 | select REGMAP_I2C | ||
256 | |||
257 | config SND_SOC_ADAU1781_SPI | ||
258 | tristate | ||
259 | select SND_SOC_ADAU1781 | ||
260 | select REGMAP_SPI | ||
261 | |||
225 | config SND_SOC_ADAU1977 | 262 | config SND_SOC_ADAU1977 |
226 | tristate | 263 | tristate |
227 | 264 | ||
@@ -274,6 +311,7 @@ config SND_SOC_AK5386 | |||
274 | 311 | ||
275 | config SND_SOC_ALC5623 | 312 | config SND_SOC_ALC5623 |
276 | tristate "Realtek ALC5623 CODEC" | 313 | tristate "Realtek ALC5623 CODEC" |
314 | depends on I2C | ||
277 | 315 | ||
278 | config SND_SOC_ALC5632 | 316 | config SND_SOC_ALC5632 |
279 | tristate | 317 | tristate |
@@ -402,6 +440,15 @@ config SND_SOC_PCM512x_SPI | |||
402 | select SND_SOC_PCM512x | 440 | select SND_SOC_PCM512x |
403 | select REGMAP_SPI | 441 | select REGMAP_SPI |
404 | 442 | ||
443 | config SND_SOC_RL6231 | ||
444 | tristate | ||
445 | default y if SND_SOC_RT5640=y | ||
446 | default y if SND_SOC_RT5645=y | ||
447 | default y if SND_SOC_RT5651=y | ||
448 | default m if SND_SOC_RT5640=m | ||
449 | default m if SND_SOC_RT5645=m | ||
450 | default m if SND_SOC_RT5651=m | ||
451 | |||
405 | config SND_SOC_RT5631 | 452 | config SND_SOC_RT5631 |
406 | tristate | 453 | tristate |
407 | 454 | ||
@@ -414,6 +461,9 @@ config SND_SOC_RT5645 | |||
414 | config SND_SOC_RT5651 | 461 | config SND_SOC_RT5651 |
415 | tristate | 462 | tristate |
416 | 463 | ||
464 | config SND_SOC_RT5677 | ||
465 | tristate | ||
466 | |||
417 | #Freescale sgtl5000 codec | 467 | #Freescale sgtl5000 codec |
418 | config SND_SOC_SGTL5000 | 468 | config SND_SOC_SGTL5000 |
419 | tristate "Freescale SGTL5000 CODEC" | 469 | tristate "Freescale SGTL5000 CODEC" |
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 1ccdaf0c0e3e..be3377b8d73f 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -7,8 +7,15 @@ snd-soc-ad193x-spi-objs := ad193x-spi.o | |||
7 | snd-soc-ad193x-i2c-objs := ad193x-i2c.o | 7 | snd-soc-ad193x-i2c-objs := ad193x-i2c.o |
8 | snd-soc-ad1980-objs := ad1980.o | 8 | snd-soc-ad1980-objs := ad1980.o |
9 | snd-soc-ad73311-objs := ad73311.o | 9 | snd-soc-ad73311-objs := ad73311.o |
10 | snd-soc-adau1701-objs := adau1701.o | ||
11 | snd-soc-adau1373-objs := adau1373.o | 10 | snd-soc-adau1373-objs := adau1373.o |
11 | snd-soc-adau1701-objs := adau1701.o | ||
12 | snd-soc-adau17x1-objs := adau17x1.o | ||
13 | snd-soc-adau1761-objs := adau1761.o | ||
14 | snd-soc-adau1761-i2c-objs := adau1761-i2c.o | ||
15 | snd-soc-adau1761-spi-objs := adau1761-spi.o | ||
16 | snd-soc-adau1781-objs := adau1781.o | ||
17 | snd-soc-adau1781-i2c-objs := adau1781-i2c.o | ||
18 | snd-soc-adau1781-spi-objs := adau1781-spi.o | ||
12 | snd-soc-adau1977-objs := adau1977.o | 19 | snd-soc-adau1977-objs := adau1977.o |
13 | snd-soc-adau1977-spi-objs := adau1977-spi.o | 20 | snd-soc-adau1977-spi-objs := adau1977-spi.o |
14 | snd-soc-adau1977-i2c-objs := adau1977-i2c.o | 21 | snd-soc-adau1977-i2c-objs := adau1977-i2c.o |
@@ -60,10 +67,12 @@ snd-soc-pcm3008-objs := pcm3008.o | |||
60 | snd-soc-pcm512x-objs := pcm512x.o | 67 | snd-soc-pcm512x-objs := pcm512x.o |
61 | snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o | 68 | snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o |
62 | snd-soc-pcm512x-spi-objs := pcm512x-spi.o | 69 | snd-soc-pcm512x-spi-objs := pcm512x-spi.o |
70 | snd-soc-rl6231-objs := rl6231.o | ||
63 | snd-soc-rt5631-objs := rt5631.o | 71 | snd-soc-rt5631-objs := rt5631.o |
64 | snd-soc-rt5640-objs := rt5640.o | 72 | snd-soc-rt5640-objs := rt5640.o |
65 | snd-soc-rt5645-objs := rt5645.o | 73 | snd-soc-rt5645-objs := rt5645.o |
66 | snd-soc-rt5651-objs := rt5651.o | 74 | snd-soc-rt5651-objs := rt5651.o |
75 | snd-soc-rt5677-objs := rt5677.o | ||
67 | snd-soc-sgtl5000-objs := sgtl5000.o | 76 | snd-soc-sgtl5000-objs := sgtl5000.o |
68 | snd-soc-alc5623-objs := alc5623.o | 77 | snd-soc-alc5623-objs := alc5623.o |
69 | snd-soc-alc5632-objs := alc5632.o | 78 | snd-soc-alc5632-objs := alc5632.o |
@@ -162,10 +171,17 @@ obj-$(CONFIG_SND_SOC_AD193X_I2C) += snd-soc-ad193x-i2c.o | |||
162 | obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o | 171 | obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o |
163 | obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o | 172 | obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o |
164 | obj-$(CONFIG_SND_SOC_ADAU1373) += snd-soc-adau1373.o | 173 | obj-$(CONFIG_SND_SOC_ADAU1373) += snd-soc-adau1373.o |
174 | obj-$(CONFIG_SND_SOC_ADAU1701) += snd-soc-adau1701.o | ||
175 | obj-$(CONFIG_SND_SOC_ADAU17X1) += snd-soc-adau17x1.o | ||
176 | obj-$(CONFIG_SND_SOC_ADAU1761) += snd-soc-adau1761.o | ||
177 | obj-$(CONFIG_SND_SOC_ADAU1761_I2C) += snd-soc-adau1761-i2c.o | ||
178 | obj-$(CONFIG_SND_SOC_ADAU1761_SPI) += snd-soc-adau1761-spi.o | ||
179 | obj-$(CONFIG_SND_SOC_ADAU1781) += snd-soc-adau1781.o | ||
180 | obj-$(CONFIG_SND_SOC_ADAU1781_I2C) += snd-soc-adau1781-i2c.o | ||
181 | obj-$(CONFIG_SND_SOC_ADAU1781_SPI) += snd-soc-adau1781-spi.o | ||
165 | obj-$(CONFIG_SND_SOC_ADAU1977) += snd-soc-adau1977.o | 182 | obj-$(CONFIG_SND_SOC_ADAU1977) += snd-soc-adau1977.o |
166 | obj-$(CONFIG_SND_SOC_ADAU1977_SPI) += snd-soc-adau1977-spi.o | 183 | obj-$(CONFIG_SND_SOC_ADAU1977_SPI) += snd-soc-adau1977-spi.o |
167 | obj-$(CONFIG_SND_SOC_ADAU1977_I2C) += snd-soc-adau1977-i2c.o | 184 | obj-$(CONFIG_SND_SOC_ADAU1977_I2C) += snd-soc-adau1977-i2c.o |
168 | obj-$(CONFIG_SND_SOC_ADAU1701) += snd-soc-adau1701.o | ||
169 | obj-$(CONFIG_SND_SOC_ADAV80X) += snd-soc-adav80x.o | 185 | obj-$(CONFIG_SND_SOC_ADAV80X) += snd-soc-adav80x.o |
170 | obj-$(CONFIG_SND_SOC_ADAV801) += snd-soc-adav801.o | 186 | obj-$(CONFIG_SND_SOC_ADAV801) += snd-soc-adav801.o |
171 | obj-$(CONFIG_SND_SOC_ADAV803) += snd-soc-adav803.o | 187 | obj-$(CONFIG_SND_SOC_ADAV803) += snd-soc-adav803.o |
@@ -216,10 +232,12 @@ obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o | |||
216 | obj-$(CONFIG_SND_SOC_PCM512x) += snd-soc-pcm512x.o | 232 | obj-$(CONFIG_SND_SOC_PCM512x) += snd-soc-pcm512x.o |
217 | obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd-soc-pcm512x-i2c.o | 233 | obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd-soc-pcm512x-i2c.o |
218 | obj-$(CONFIG_SND_SOC_PCM512x_SPI) += snd-soc-pcm512x-spi.o | 234 | obj-$(CONFIG_SND_SOC_PCM512x_SPI) += snd-soc-pcm512x-spi.o |
235 | obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o | ||
219 | obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o | 236 | obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o |
220 | obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o | 237 | obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o |
221 | obj-$(CONFIG_SND_SOC_RT5645) += snd-soc-rt5645.o | 238 | obj-$(CONFIG_SND_SOC_RT5645) += snd-soc-rt5645.o |
222 | obj-$(CONFIG_SND_SOC_RT5651) += snd-soc-rt5651.o | 239 | obj-$(CONFIG_SND_SOC_RT5651) += snd-soc-rt5651.o |
240 | obj-$(CONFIG_SND_SOC_RT5677) += snd-soc-rt5677.o | ||
223 | obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o | 241 | obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o |
224 | obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o | 242 | obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o |
225 | obj-$(CONFIG_SND_SOC_SI476X) += snd-soc-si476x.o | 243 | obj-$(CONFIG_SND_SOC_SI476X) += snd-soc-si476x.o |
diff --git a/sound/soc/codecs/adau1761-i2c.c b/sound/soc/codecs/adau1761-i2c.c new file mode 100644 index 000000000000..862796dec693 --- /dev/null +++ b/sound/soc/codecs/adau1761-i2c.c | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961 codec | ||
3 | * | ||
4 | * Copyright 2014 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2. | ||
8 | */ | ||
9 | |||
10 | #include <linux/i2c.h> | ||
11 | #include <linux/mod_devicetable.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/regmap.h> | ||
14 | #include <sound/soc.h> | ||
15 | |||
16 | #include "adau1761.h" | ||
17 | |||
18 | static int adau1761_i2c_probe(struct i2c_client *client, | ||
19 | const struct i2c_device_id *id) | ||
20 | { | ||
21 | struct regmap_config config; | ||
22 | |||
23 | config = adau1761_regmap_config; | ||
24 | config.val_bits = 8; | ||
25 | config.reg_bits = 16; | ||
26 | |||
27 | return adau1761_probe(&client->dev, | ||
28 | devm_regmap_init_i2c(client, &config), | ||
29 | id->driver_data, NULL); | ||
30 | } | ||
31 | |||
32 | static int adau1761_i2c_remove(struct i2c_client *client) | ||
33 | { | ||
34 | snd_soc_unregister_codec(&client->dev); | ||
35 | return 0; | ||
36 | } | ||
37 | |||
38 | static const struct i2c_device_id adau1761_i2c_ids[] = { | ||
39 | { "adau1361", ADAU1361 }, | ||
40 | { "adau1461", ADAU1761 }, | ||
41 | { "adau1761", ADAU1761 }, | ||
42 | { "adau1961", ADAU1361 }, | ||
43 | { } | ||
44 | }; | ||
45 | MODULE_DEVICE_TABLE(i2c, adau1761_i2c_ids); | ||
46 | |||
47 | static struct i2c_driver adau1761_i2c_driver = { | ||
48 | .driver = { | ||
49 | .name = "adau1761", | ||
50 | .owner = THIS_MODULE, | ||
51 | }, | ||
52 | .probe = adau1761_i2c_probe, | ||
53 | .remove = adau1761_i2c_remove, | ||
54 | .id_table = adau1761_i2c_ids, | ||
55 | }; | ||
56 | module_i2c_driver(adau1761_i2c_driver); | ||
57 | |||
58 | MODULE_DESCRIPTION("ASoC ADAU1361/ADAU1461/ADAU1761/ADAU1961 CODEC I2C driver"); | ||
59 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
60 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/adau1761-spi.c b/sound/soc/codecs/adau1761-spi.c new file mode 100644 index 000000000000..cce2f11f1ffb --- /dev/null +++ b/sound/soc/codecs/adau1761-spi.c | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961 codec | ||
3 | * | ||
4 | * Copyright 2014 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2. | ||
8 | */ | ||
9 | |||
10 | #include <linux/mod_devicetable.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/regmap.h> | ||
13 | #include <linux/spi/spi.h> | ||
14 | #include <sound/soc.h> | ||
15 | |||
16 | #include "adau1761.h" | ||
17 | |||
18 | static void adau1761_spi_switch_mode(struct device *dev) | ||
19 | { | ||
20 | struct spi_device *spi = to_spi_device(dev); | ||
21 | |||
22 | /* | ||
23 | * To get the device into SPI mode CLATCH has to be pulled low three | ||
24 | * times. Do this by issuing three dummy reads. | ||
25 | */ | ||
26 | spi_w8r8(spi, 0x00); | ||
27 | spi_w8r8(spi, 0x00); | ||
28 | spi_w8r8(spi, 0x00); | ||
29 | } | ||
30 | |||
31 | static int adau1761_spi_probe(struct spi_device *spi) | ||
32 | { | ||
33 | const struct spi_device_id *id = spi_get_device_id(spi); | ||
34 | struct regmap_config config; | ||
35 | |||
36 | if (!id) | ||
37 | return -EINVAL; | ||
38 | |||
39 | config = adau1761_regmap_config; | ||
40 | config.val_bits = 8; | ||
41 | config.reg_bits = 24; | ||
42 | config.read_flag_mask = 0x1; | ||
43 | |||
44 | return adau1761_probe(&spi->dev, | ||
45 | devm_regmap_init_spi(spi, &config), | ||
46 | id->driver_data, adau1761_spi_switch_mode); | ||
47 | } | ||
48 | |||
49 | static int adau1761_spi_remove(struct spi_device *spi) | ||
50 | { | ||
51 | snd_soc_unregister_codec(&spi->dev); | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static const struct spi_device_id adau1761_spi_id[] = { | ||
56 | { "adau1361", ADAU1361 }, | ||
57 | { "adau1461", ADAU1761 }, | ||
58 | { "adau1761", ADAU1761 }, | ||
59 | { "adau1961", ADAU1361 }, | ||
60 | { } | ||
61 | }; | ||
62 | MODULE_DEVICE_TABLE(spi, adau1761_spi_id); | ||
63 | |||
64 | static struct spi_driver adau1761_spi_driver = { | ||
65 | .driver = { | ||
66 | .name = "adau1761", | ||
67 | .owner = THIS_MODULE, | ||
68 | }, | ||
69 | .probe = adau1761_spi_probe, | ||
70 | .remove = adau1761_spi_remove, | ||
71 | .id_table = adau1761_spi_id, | ||
72 | }; | ||
73 | module_spi_driver(adau1761_spi_driver); | ||
74 | |||
75 | MODULE_DESCRIPTION("ASoC ADAU1361/ADAU1461/ADAU1761/ADAU1961 CODEC SPI driver"); | ||
76 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
77 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c new file mode 100644 index 000000000000..848cab839553 --- /dev/null +++ b/sound/soc/codecs/adau1761.c | |||
@@ -0,0 +1,803 @@ | |||
1 | /* | ||
2 | * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961 codec | ||
3 | * | ||
4 | * Copyright 2011-2013 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2 or later. | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/i2c.h> | ||
13 | #include <linux/spi/spi.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <sound/core.h> | ||
16 | #include <sound/pcm.h> | ||
17 | #include <sound/pcm_params.h> | ||
18 | #include <sound/soc.h> | ||
19 | #include <sound/tlv.h> | ||
20 | #include <linux/platform_data/adau17x1.h> | ||
21 | |||
22 | #include "adau17x1.h" | ||
23 | #include "adau1761.h" | ||
24 | |||
25 | #define ADAU1761_DIGMIC_JACKDETECT 0x4008 | ||
26 | #define ADAU1761_REC_MIXER_LEFT0 0x400a | ||
27 | #define ADAU1761_REC_MIXER_LEFT1 0x400b | ||
28 | #define ADAU1761_REC_MIXER_RIGHT0 0x400c | ||
29 | #define ADAU1761_REC_MIXER_RIGHT1 0x400d | ||
30 | #define ADAU1761_LEFT_DIFF_INPUT_VOL 0x400e | ||
31 | #define ADAU1761_RIGHT_DIFF_INPUT_VOL 0x400f | ||
32 | #define ADAU1761_PLAY_LR_MIXER_LEFT 0x4020 | ||
33 | #define ADAU1761_PLAY_MIXER_LEFT0 0x401c | ||
34 | #define ADAU1761_PLAY_MIXER_LEFT1 0x401d | ||
35 | #define ADAU1761_PLAY_MIXER_RIGHT0 0x401e | ||
36 | #define ADAU1761_PLAY_MIXER_RIGHT1 0x401f | ||
37 | #define ADAU1761_PLAY_LR_MIXER_RIGHT 0x4021 | ||
38 | #define ADAU1761_PLAY_MIXER_MONO 0x4022 | ||
39 | #define ADAU1761_PLAY_HP_LEFT_VOL 0x4023 | ||
40 | #define ADAU1761_PLAY_HP_RIGHT_VOL 0x4024 | ||
41 | #define ADAU1761_PLAY_LINE_LEFT_VOL 0x4025 | ||
42 | #define ADAU1761_PLAY_LINE_RIGHT_VOL 0x4026 | ||
43 | #define ADAU1761_PLAY_MONO_OUTPUT_VOL 0x4027 | ||
44 | #define ADAU1761_POP_CLICK_SUPPRESS 0x4028 | ||
45 | #define ADAU1761_JACK_DETECT_PIN 0x4031 | ||
46 | #define ADAU1761_DEJITTER 0x4036 | ||
47 | #define ADAU1761_CLK_ENABLE0 0x40f9 | ||
48 | #define ADAU1761_CLK_ENABLE1 0x40fa | ||
49 | |||
50 | #define ADAU1761_DIGMIC_JACKDETECT_ACTIVE_LOW BIT(0) | ||
51 | #define ADAU1761_DIGMIC_JACKDETECT_DIGMIC BIT(5) | ||
52 | |||
53 | #define ADAU1761_DIFF_INPUT_VOL_LDEN BIT(0) | ||
54 | |||
55 | #define ADAU1761_PLAY_MONO_OUTPUT_VOL_MODE_HP BIT(0) | ||
56 | #define ADAU1761_PLAY_MONO_OUTPUT_VOL_UNMUTE BIT(1) | ||
57 | |||
58 | #define ADAU1761_PLAY_HP_RIGHT_VOL_MODE_HP BIT(0) | ||
59 | |||
60 | #define ADAU1761_PLAY_LINE_LEFT_VOL_MODE_HP BIT(0) | ||
61 | |||
62 | #define ADAU1761_PLAY_LINE_RIGHT_VOL_MODE_HP BIT(0) | ||
63 | |||
64 | |||
65 | #define ADAU1761_FIRMWARE "adau1761.bin" | ||
66 | |||
67 | static const struct reg_default adau1761_reg_defaults[] = { | ||
68 | { ADAU1761_DEJITTER, 0x03 }, | ||
69 | { ADAU1761_DIGMIC_JACKDETECT, 0x00 }, | ||
70 | { ADAU1761_REC_MIXER_LEFT0, 0x00 }, | ||
71 | { ADAU1761_REC_MIXER_LEFT1, 0x00 }, | ||
72 | { ADAU1761_REC_MIXER_RIGHT0, 0x00 }, | ||
73 | { ADAU1761_REC_MIXER_RIGHT1, 0x00 }, | ||
74 | { ADAU1761_LEFT_DIFF_INPUT_VOL, 0x00 }, | ||
75 | { ADAU1761_RIGHT_DIFF_INPUT_VOL, 0x00 }, | ||
76 | { ADAU1761_PLAY_LR_MIXER_LEFT, 0x00 }, | ||
77 | { ADAU1761_PLAY_MIXER_LEFT0, 0x00 }, | ||
78 | { ADAU1761_PLAY_MIXER_LEFT1, 0x00 }, | ||
79 | { ADAU1761_PLAY_MIXER_RIGHT0, 0x00 }, | ||
80 | { ADAU1761_PLAY_MIXER_RIGHT1, 0x00 }, | ||
81 | { ADAU1761_PLAY_LR_MIXER_RIGHT, 0x00 }, | ||
82 | { ADAU1761_PLAY_MIXER_MONO, 0x00 }, | ||
83 | { ADAU1761_PLAY_HP_LEFT_VOL, 0x00 }, | ||
84 | { ADAU1761_PLAY_HP_RIGHT_VOL, 0x00 }, | ||
85 | { ADAU1761_PLAY_LINE_LEFT_VOL, 0x00 }, | ||
86 | { ADAU1761_PLAY_LINE_RIGHT_VOL, 0x00 }, | ||
87 | { ADAU1761_PLAY_MONO_OUTPUT_VOL, 0x00 }, | ||
88 | { ADAU1761_POP_CLICK_SUPPRESS, 0x00 }, | ||
89 | { ADAU1761_JACK_DETECT_PIN, 0x00 }, | ||
90 | { ADAU1761_CLK_ENABLE0, 0x00 }, | ||
91 | { ADAU1761_CLK_ENABLE1, 0x00 }, | ||
92 | { ADAU17X1_CLOCK_CONTROL, 0x00 }, | ||
93 | { ADAU17X1_PLL_CONTROL, 0x00 }, | ||
94 | { ADAU17X1_REC_POWER_MGMT, 0x00 }, | ||
95 | { ADAU17X1_MICBIAS, 0x00 }, | ||
96 | { ADAU17X1_SERIAL_PORT0, 0x00 }, | ||
97 | { ADAU17X1_SERIAL_PORT1, 0x00 }, | ||
98 | { ADAU17X1_CONVERTER0, 0x00 }, | ||
99 | { ADAU17X1_CONVERTER1, 0x00 }, | ||
100 | { ADAU17X1_LEFT_INPUT_DIGITAL_VOL, 0x00 }, | ||
101 | { ADAU17X1_RIGHT_INPUT_DIGITAL_VOL, 0x00 }, | ||
102 | { ADAU17X1_ADC_CONTROL, 0x00 }, | ||
103 | { ADAU17X1_PLAY_POWER_MGMT, 0x00 }, | ||
104 | { ADAU17X1_DAC_CONTROL0, 0x00 }, | ||
105 | { ADAU17X1_DAC_CONTROL1, 0x00 }, | ||
106 | { ADAU17X1_DAC_CONTROL2, 0x00 }, | ||
107 | { ADAU17X1_SERIAL_PORT_PAD, 0xaa }, | ||
108 | { ADAU17X1_CONTROL_PORT_PAD0, 0xaa }, | ||
109 | { ADAU17X1_CONTROL_PORT_PAD1, 0x00 }, | ||
110 | { ADAU17X1_DSP_SAMPLING_RATE, 0x01 }, | ||
111 | { ADAU17X1_SERIAL_INPUT_ROUTE, 0x00 }, | ||
112 | { ADAU17X1_SERIAL_OUTPUT_ROUTE, 0x00 }, | ||
113 | { ADAU17X1_DSP_ENABLE, 0x00 }, | ||
114 | { ADAU17X1_DSP_RUN, 0x00 }, | ||
115 | { ADAU17X1_SERIAL_SAMPLING_RATE, 0x00 }, | ||
116 | }; | ||
117 | |||
118 | static const DECLARE_TLV_DB_SCALE(adau1761_sing_in_tlv, -1500, 300, 1); | ||
119 | static const DECLARE_TLV_DB_SCALE(adau1761_diff_in_tlv, -1200, 75, 0); | ||
120 | static const DECLARE_TLV_DB_SCALE(adau1761_out_tlv, -5700, 100, 0); | ||
121 | static const DECLARE_TLV_DB_SCALE(adau1761_sidetone_tlv, -1800, 300, 1); | ||
122 | static const DECLARE_TLV_DB_SCALE(adau1761_boost_tlv, -600, 600, 1); | ||
123 | static const DECLARE_TLV_DB_SCALE(adau1761_pga_boost_tlv, -2000, 2000, 1); | ||
124 | |||
125 | static const unsigned int adau1761_bias_select_values[] = { | ||
126 | 0, 2, 3, | ||
127 | }; | ||
128 | |||
129 | static const char * const adau1761_bias_select_text[] = { | ||
130 | "Normal operation", "Enhanced performance", "Power saving", | ||
131 | }; | ||
132 | |||
133 | static const char * const adau1761_bias_select_extreme_text[] = { | ||
134 | "Normal operation", "Extreme power saving", "Enhanced performance", | ||
135 | "Power saving", | ||
136 | }; | ||
137 | |||
138 | static SOC_ENUM_SINGLE_DECL(adau1761_adc_bias_enum, | ||
139 | ADAU17X1_REC_POWER_MGMT, 3, adau1761_bias_select_extreme_text); | ||
140 | static SOC_ENUM_SINGLE_DECL(adau1761_hp_bias_enum, | ||
141 | ADAU17X1_PLAY_POWER_MGMT, 6, adau1761_bias_select_extreme_text); | ||
142 | static SOC_ENUM_SINGLE_DECL(adau1761_dac_bias_enum, | ||
143 | ADAU17X1_PLAY_POWER_MGMT, 4, adau1761_bias_select_extreme_text); | ||
144 | static SOC_VALUE_ENUM_SINGLE_DECL(adau1761_playback_bias_enum, | ||
145 | ADAU17X1_PLAY_POWER_MGMT, 2, 0x3, adau1761_bias_select_text, | ||
146 | adau1761_bias_select_values); | ||
147 | static SOC_VALUE_ENUM_SINGLE_DECL(adau1761_capture_bias_enum, | ||
148 | ADAU17X1_REC_POWER_MGMT, 1, 0x3, adau1761_bias_select_text, | ||
149 | adau1761_bias_select_values); | ||
150 | |||
151 | static const struct snd_kcontrol_new adau1761_jack_detect_controls[] = { | ||
152 | SOC_SINGLE("Speaker Auto-mute Switch", ADAU1761_DIGMIC_JACKDETECT, | ||
153 | 4, 1, 0), | ||
154 | }; | ||
155 | |||
156 | static const struct snd_kcontrol_new adau1761_differential_mode_controls[] = { | ||
157 | SOC_DOUBLE_R_TLV("Capture Volume", ADAU1761_LEFT_DIFF_INPUT_VOL, | ||
158 | ADAU1761_RIGHT_DIFF_INPUT_VOL, 2, 0x3f, 0, | ||
159 | adau1761_diff_in_tlv), | ||
160 | SOC_DOUBLE_R("Capture Switch", ADAU1761_LEFT_DIFF_INPUT_VOL, | ||
161 | ADAU1761_RIGHT_DIFF_INPUT_VOL, 1, 1, 0), | ||
162 | |||
163 | SOC_DOUBLE_R_TLV("PGA Boost Capture Volume", ADAU1761_REC_MIXER_LEFT1, | ||
164 | ADAU1761_REC_MIXER_RIGHT1, 3, 2, 0, adau1761_pga_boost_tlv), | ||
165 | }; | ||
166 | |||
167 | static const struct snd_kcontrol_new adau1761_single_mode_controls[] = { | ||
168 | SOC_SINGLE_TLV("Input 1 Capture Volume", ADAU1761_REC_MIXER_LEFT0, | ||
169 | 4, 7, 0, adau1761_sing_in_tlv), | ||
170 | SOC_SINGLE_TLV("Input 2 Capture Volume", ADAU1761_REC_MIXER_LEFT0, | ||
171 | 1, 7, 0, adau1761_sing_in_tlv), | ||
172 | SOC_SINGLE_TLV("Input 3 Capture Volume", ADAU1761_REC_MIXER_RIGHT0, | ||
173 | 4, 7, 0, adau1761_sing_in_tlv), | ||
174 | SOC_SINGLE_TLV("Input 4 Capture Volume", ADAU1761_REC_MIXER_RIGHT0, | ||
175 | 1, 7, 0, adau1761_sing_in_tlv), | ||
176 | }; | ||
177 | |||
178 | static const struct snd_kcontrol_new adau1761_controls[] = { | ||
179 | SOC_DOUBLE_R_TLV("Aux Capture Volume", ADAU1761_REC_MIXER_LEFT1, | ||
180 | ADAU1761_REC_MIXER_RIGHT1, 0, 7, 0, adau1761_sing_in_tlv), | ||
181 | |||
182 | SOC_DOUBLE_R_TLV("Headphone Playback Volume", ADAU1761_PLAY_HP_LEFT_VOL, | ||
183 | ADAU1761_PLAY_HP_RIGHT_VOL, 2, 0x3f, 0, adau1761_out_tlv), | ||
184 | SOC_DOUBLE_R("Headphone Playback Switch", ADAU1761_PLAY_HP_LEFT_VOL, | ||
185 | ADAU1761_PLAY_HP_RIGHT_VOL, 1, 1, 0), | ||
186 | SOC_DOUBLE_R_TLV("Lineout Playback Volume", ADAU1761_PLAY_LINE_LEFT_VOL, | ||
187 | ADAU1761_PLAY_LINE_RIGHT_VOL, 2, 0x3f, 0, adau1761_out_tlv), | ||
188 | SOC_DOUBLE_R("Lineout Playback Switch", ADAU1761_PLAY_LINE_LEFT_VOL, | ||
189 | ADAU1761_PLAY_LINE_RIGHT_VOL, 1, 1, 0), | ||
190 | |||
191 | SOC_ENUM("ADC Bias", adau1761_adc_bias_enum), | ||
192 | SOC_ENUM("DAC Bias", adau1761_dac_bias_enum), | ||
193 | SOC_ENUM("Capture Bias", adau1761_capture_bias_enum), | ||
194 | SOC_ENUM("Playback Bias", adau1761_playback_bias_enum), | ||
195 | SOC_ENUM("Headphone Bias", adau1761_hp_bias_enum), | ||
196 | }; | ||
197 | |||
198 | static const struct snd_kcontrol_new adau1761_mono_controls[] = { | ||
199 | SOC_SINGLE_TLV("Mono Playback Volume", ADAU1761_PLAY_MONO_OUTPUT_VOL, | ||
200 | 2, 0x3f, 0, adau1761_out_tlv), | ||
201 | SOC_SINGLE("Mono Playback Switch", ADAU1761_PLAY_MONO_OUTPUT_VOL, | ||
202 | 1, 1, 0), | ||
203 | }; | ||
204 | |||
205 | static const struct snd_kcontrol_new adau1761_left_mixer_controls[] = { | ||
206 | SOC_DAPM_SINGLE_AUTODISABLE("Left DAC Switch", | ||
207 | ADAU1761_PLAY_MIXER_LEFT0, 5, 1, 0), | ||
208 | SOC_DAPM_SINGLE_AUTODISABLE("Right DAC Switch", | ||
209 | ADAU1761_PLAY_MIXER_LEFT0, 6, 1, 0), | ||
210 | SOC_DAPM_SINGLE_TLV("Aux Bypass Volume", | ||
211 | ADAU1761_PLAY_MIXER_LEFT0, 1, 8, 0, adau1761_sidetone_tlv), | ||
212 | SOC_DAPM_SINGLE_TLV("Right Bypass Volume", | ||
213 | ADAU1761_PLAY_MIXER_LEFT1, 4, 8, 0, adau1761_sidetone_tlv), | ||
214 | SOC_DAPM_SINGLE_TLV("Left Bypass Volume", | ||
215 | ADAU1761_PLAY_MIXER_LEFT1, 0, 8, 0, adau1761_sidetone_tlv), | ||
216 | }; | ||
217 | |||
218 | static const struct snd_kcontrol_new adau1761_right_mixer_controls[] = { | ||
219 | SOC_DAPM_SINGLE_AUTODISABLE("Left DAC Switch", | ||
220 | ADAU1761_PLAY_MIXER_RIGHT0, 5, 1, 0), | ||
221 | SOC_DAPM_SINGLE_AUTODISABLE("Right DAC Switch", | ||
222 | ADAU1761_PLAY_MIXER_RIGHT0, 6, 1, 0), | ||
223 | SOC_DAPM_SINGLE_TLV("Aux Bypass Volume", | ||
224 | ADAU1761_PLAY_MIXER_RIGHT0, 1, 8, 0, adau1761_sidetone_tlv), | ||
225 | SOC_DAPM_SINGLE_TLV("Right Bypass Volume", | ||
226 | ADAU1761_PLAY_MIXER_RIGHT1, 4, 8, 0, adau1761_sidetone_tlv), | ||
227 | SOC_DAPM_SINGLE_TLV("Left Bypass Volume", | ||
228 | ADAU1761_PLAY_MIXER_RIGHT1, 0, 8, 0, adau1761_sidetone_tlv), | ||
229 | }; | ||
230 | |||
231 | static const struct snd_kcontrol_new adau1761_left_lr_mixer_controls[] = { | ||
232 | SOC_DAPM_SINGLE_TLV("Left Volume", | ||
233 | ADAU1761_PLAY_LR_MIXER_LEFT, 1, 2, 0, adau1761_boost_tlv), | ||
234 | SOC_DAPM_SINGLE_TLV("Right Volume", | ||
235 | ADAU1761_PLAY_LR_MIXER_LEFT, 3, 2, 0, adau1761_boost_tlv), | ||
236 | }; | ||
237 | |||
238 | static const struct snd_kcontrol_new adau1761_right_lr_mixer_controls[] = { | ||
239 | SOC_DAPM_SINGLE_TLV("Left Volume", | ||
240 | ADAU1761_PLAY_LR_MIXER_RIGHT, 1, 2, 0, adau1761_boost_tlv), | ||
241 | SOC_DAPM_SINGLE_TLV("Right Volume", | ||
242 | ADAU1761_PLAY_LR_MIXER_RIGHT, 3, 2, 0, adau1761_boost_tlv), | ||
243 | }; | ||
244 | |||
245 | static const char * const adau1761_input_mux_text[] = { | ||
246 | "ADC", "DMIC", | ||
247 | }; | ||
248 | |||
249 | static SOC_ENUM_SINGLE_DECL(adau1761_input_mux_enum, | ||
250 | ADAU17X1_ADC_CONTROL, 2, adau1761_input_mux_text); | ||
251 | |||
252 | static const struct snd_kcontrol_new adau1761_input_mux_control = | ||
253 | SOC_DAPM_ENUM("Input Select", adau1761_input_mux_enum); | ||
254 | |||
255 | static int adau1761_dejitter_fixup(struct snd_soc_dapm_widget *w, | ||
256 | struct snd_kcontrol *kcontrol, int event) | ||
257 | { | ||
258 | struct adau *adau = snd_soc_codec_get_drvdata(w->codec); | ||
259 | |||
260 | /* After any power changes have been made the dejitter circuit | ||
261 | * has to be reinitialized. */ | ||
262 | regmap_write(adau->regmap, ADAU1761_DEJITTER, 0); | ||
263 | if (!adau->master) | ||
264 | regmap_write(adau->regmap, ADAU1761_DEJITTER, 3); | ||
265 | |||
266 | return 0; | ||
267 | } | ||
268 | |||
269 | static const struct snd_soc_dapm_widget adau1x61_dapm_widgets[] = { | ||
270 | SND_SOC_DAPM_MIXER("Left Input Mixer", ADAU1761_REC_MIXER_LEFT0, 0, 0, | ||
271 | NULL, 0), | ||
272 | SND_SOC_DAPM_MIXER("Right Input Mixer", ADAU1761_REC_MIXER_RIGHT0, 0, 0, | ||
273 | NULL, 0), | ||
274 | |||
275 | SOC_MIXER_ARRAY("Left Playback Mixer", ADAU1761_PLAY_MIXER_LEFT0, | ||
276 | 0, 0, adau1761_left_mixer_controls), | ||
277 | SOC_MIXER_ARRAY("Right Playback Mixer", ADAU1761_PLAY_MIXER_RIGHT0, | ||
278 | 0, 0, adau1761_right_mixer_controls), | ||
279 | SOC_MIXER_ARRAY("Left LR Playback Mixer", ADAU1761_PLAY_LR_MIXER_LEFT, | ||
280 | 0, 0, adau1761_left_lr_mixer_controls), | ||
281 | SOC_MIXER_ARRAY("Right LR Playback Mixer", ADAU1761_PLAY_LR_MIXER_RIGHT, | ||
282 | 0, 0, adau1761_right_lr_mixer_controls), | ||
283 | |||
284 | SND_SOC_DAPM_SUPPLY("Headphone", ADAU1761_PLAY_HP_LEFT_VOL, | ||
285 | 0, 0, NULL, 0), | ||
286 | |||
287 | SND_SOC_DAPM_SUPPLY_S("SYSCLK", 2, SND_SOC_NOPM, 0, 0, NULL, 0), | ||
288 | |||
289 | SND_SOC_DAPM_POST("Dejitter fixup", adau1761_dejitter_fixup), | ||
290 | |||
291 | SND_SOC_DAPM_INPUT("LAUX"), | ||
292 | SND_SOC_DAPM_INPUT("RAUX"), | ||
293 | SND_SOC_DAPM_INPUT("LINP"), | ||
294 | SND_SOC_DAPM_INPUT("LINN"), | ||
295 | SND_SOC_DAPM_INPUT("RINP"), | ||
296 | SND_SOC_DAPM_INPUT("RINN"), | ||
297 | |||
298 | SND_SOC_DAPM_OUTPUT("LOUT"), | ||
299 | SND_SOC_DAPM_OUTPUT("ROUT"), | ||
300 | SND_SOC_DAPM_OUTPUT("LHP"), | ||
301 | SND_SOC_DAPM_OUTPUT("RHP"), | ||
302 | }; | ||
303 | |||
304 | static const struct snd_soc_dapm_widget adau1761_mono_dapm_widgets[] = { | ||
305 | SND_SOC_DAPM_MIXER("Mono Playback Mixer", ADAU1761_PLAY_MIXER_MONO, | ||
306 | 0, 0, NULL, 0), | ||
307 | |||
308 | SND_SOC_DAPM_OUTPUT("MONOOUT"), | ||
309 | }; | ||
310 | |||
311 | static const struct snd_soc_dapm_widget adau1761_capless_dapm_widgets[] = { | ||
312 | SND_SOC_DAPM_SUPPLY_S("Headphone VGND", 1, ADAU1761_PLAY_MIXER_MONO, | ||
313 | 0, 0, NULL, 0), | ||
314 | }; | ||
315 | |||
316 | static const struct snd_soc_dapm_route adau1x61_dapm_routes[] = { | ||
317 | { "Left Input Mixer", NULL, "LINP" }, | ||
318 | { "Left Input Mixer", NULL, "LINN" }, | ||
319 | { "Left Input Mixer", NULL, "LAUX" }, | ||
320 | |||
321 | { "Right Input Mixer", NULL, "RINP" }, | ||
322 | { "Right Input Mixer", NULL, "RINN" }, | ||
323 | { "Right Input Mixer", NULL, "RAUX" }, | ||
324 | |||
325 | { "Left Playback Mixer", NULL, "Left Playback Enable"}, | ||
326 | { "Right Playback Mixer", NULL, "Right Playback Enable"}, | ||
327 | { "Left LR Playback Mixer", NULL, "Left Playback Enable"}, | ||
328 | { "Right LR Playback Mixer", NULL, "Right Playback Enable"}, | ||
329 | |||
330 | { "Left Playback Mixer", "Left DAC Switch", "Left DAC" }, | ||
331 | { "Left Playback Mixer", "Right DAC Switch", "Right DAC" }, | ||
332 | |||
333 | { "Right Playback Mixer", "Left DAC Switch", "Left DAC" }, | ||
334 | { "Right Playback Mixer", "Right DAC Switch", "Right DAC" }, | ||
335 | |||
336 | { "Left LR Playback Mixer", "Left Volume", "Left Playback Mixer" }, | ||
337 | { "Left LR Playback Mixer", "Right Volume", "Right Playback Mixer" }, | ||
338 | |||
339 | { "Right LR Playback Mixer", "Left Volume", "Left Playback Mixer" }, | ||
340 | { "Right LR Playback Mixer", "Right Volume", "Right Playback Mixer" }, | ||
341 | |||
342 | { "LHP", NULL, "Left Playback Mixer" }, | ||
343 | { "RHP", NULL, "Right Playback Mixer" }, | ||
344 | |||
345 | { "LHP", NULL, "Headphone" }, | ||
346 | { "RHP", NULL, "Headphone" }, | ||
347 | |||
348 | { "LOUT", NULL, "Left LR Playback Mixer" }, | ||
349 | { "ROUT", NULL, "Right LR Playback Mixer" }, | ||
350 | |||
351 | { "Left Playback Mixer", "Aux Bypass Volume", "LAUX" }, | ||
352 | { "Left Playback Mixer", "Left Bypass Volume", "Left Input Mixer" }, | ||
353 | { "Left Playback Mixer", "Right Bypass Volume", "Right Input Mixer" }, | ||
354 | { "Right Playback Mixer", "Aux Bypass Volume", "RAUX" }, | ||
355 | { "Right Playback Mixer", "Left Bypass Volume", "Left Input Mixer" }, | ||
356 | { "Right Playback Mixer", "Right Bypass Volume", "Right Input Mixer" }, | ||
357 | }; | ||
358 | |||
359 | static const struct snd_soc_dapm_route adau1761_mono_dapm_routes[] = { | ||
360 | { "Mono Playback Mixer", NULL, "Left Playback Mixer" }, | ||
361 | { "Mono Playback Mixer", NULL, "Right Playback Mixer" }, | ||
362 | |||
363 | { "MONOOUT", NULL, "Mono Playback Mixer" }, | ||
364 | }; | ||
365 | |||
366 | static const struct snd_soc_dapm_route adau1761_capless_dapm_routes[] = { | ||
367 | { "Headphone", NULL, "Headphone VGND" }, | ||
368 | }; | ||
369 | |||
370 | static const struct snd_soc_dapm_widget adau1761_dmic_widgets[] = { | ||
371 | SND_SOC_DAPM_MUX("Left Decimator Mux", SND_SOC_NOPM, 0, 0, | ||
372 | &adau1761_input_mux_control), | ||
373 | SND_SOC_DAPM_MUX("Right Decimator Mux", SND_SOC_NOPM, 0, 0, | ||
374 | &adau1761_input_mux_control), | ||
375 | |||
376 | SND_SOC_DAPM_INPUT("DMIC"), | ||
377 | }; | ||
378 | |||
379 | static const struct snd_soc_dapm_route adau1761_dmic_routes[] = { | ||
380 | { "Left Decimator Mux", "ADC", "Left Input Mixer" }, | ||
381 | { "Left Decimator Mux", "DMIC", "DMIC" }, | ||
382 | { "Right Decimator Mux", "ADC", "Right Input Mixer" }, | ||
383 | { "Right Decimator Mux", "DMIC", "DMIC" }, | ||
384 | |||
385 | { "Left Decimator", NULL, "Left Decimator Mux" }, | ||
386 | { "Right Decimator", NULL, "Right Decimator Mux" }, | ||
387 | }; | ||
388 | |||
389 | static const struct snd_soc_dapm_route adau1761_no_dmic_routes[] = { | ||
390 | { "Left Decimator", NULL, "Left Input Mixer" }, | ||
391 | { "Right Decimator", NULL, "Right Input Mixer" }, | ||
392 | }; | ||
393 | |||
394 | static const struct snd_soc_dapm_widget adau1761_dapm_widgets[] = { | ||
395 | SND_SOC_DAPM_SUPPLY("Serial Port Clock", ADAU1761_CLK_ENABLE0, | ||
396 | 0, 0, NULL, 0), | ||
397 | SND_SOC_DAPM_SUPPLY("Serial Input Routing Clock", ADAU1761_CLK_ENABLE0, | ||
398 | 1, 0, NULL, 0), | ||
399 | SND_SOC_DAPM_SUPPLY("Serial Output Routing Clock", ADAU1761_CLK_ENABLE0, | ||
400 | 3, 0, NULL, 0), | ||
401 | |||
402 | SND_SOC_DAPM_SUPPLY("Decimator Resync Clock", ADAU1761_CLK_ENABLE0, | ||
403 | 4, 0, NULL, 0), | ||
404 | SND_SOC_DAPM_SUPPLY("Interpolator Resync Clock", ADAU1761_CLK_ENABLE0, | ||
405 | 2, 0, NULL, 0), | ||
406 | |||
407 | SND_SOC_DAPM_SUPPLY("Slew Clock", ADAU1761_CLK_ENABLE0, 6, 0, NULL, 0), | ||
408 | |||
409 | SND_SOC_DAPM_SUPPLY_S("Digital Clock 0", 1, ADAU1761_CLK_ENABLE1, | ||
410 | 0, 0, NULL, 0), | ||
411 | SND_SOC_DAPM_SUPPLY_S("Digital Clock 1", 1, ADAU1761_CLK_ENABLE1, | ||
412 | 1, 0, NULL, 0), | ||
413 | }; | ||
414 | |||
415 | static const struct snd_soc_dapm_route adau1761_dapm_routes[] = { | ||
416 | { "Left Decimator", NULL, "Digital Clock 0", }, | ||
417 | { "Right Decimator", NULL, "Digital Clock 0", }, | ||
418 | { "Left DAC", NULL, "Digital Clock 0", }, | ||
419 | { "Right DAC", NULL, "Digital Clock 0", }, | ||
420 | |||
421 | { "AIFCLK", NULL, "Digital Clock 1" }, | ||
422 | |||
423 | { "Playback", NULL, "Serial Port Clock" }, | ||
424 | { "Capture", NULL, "Serial Port Clock" }, | ||
425 | { "Playback", NULL, "Serial Input Routing Clock" }, | ||
426 | { "Capture", NULL, "Serial Output Routing Clock" }, | ||
427 | |||
428 | { "Left Decimator", NULL, "Decimator Resync Clock" }, | ||
429 | { "Right Decimator", NULL, "Decimator Resync Clock" }, | ||
430 | { "Left DAC", NULL, "Interpolator Resync Clock" }, | ||
431 | { "Right DAC", NULL, "Interpolator Resync Clock" }, | ||
432 | |||
433 | { "DSP", NULL, "Digital Clock 0" }, | ||
434 | |||
435 | { "Slew Clock", NULL, "Digital Clock 0" }, | ||
436 | { "Right Playback Mixer", NULL, "Slew Clock" }, | ||
437 | { "Left Playback Mixer", NULL, "Slew Clock" }, | ||
438 | |||
439 | { "Digital Clock 0", NULL, "SYSCLK" }, | ||
440 | { "Digital Clock 1", NULL, "SYSCLK" }, | ||
441 | }; | ||
442 | |||
443 | static int adau1761_set_bias_level(struct snd_soc_codec *codec, | ||
444 | enum snd_soc_bias_level level) | ||
445 | { | ||
446 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
447 | |||
448 | switch (level) { | ||
449 | case SND_SOC_BIAS_ON: | ||
450 | break; | ||
451 | case SND_SOC_BIAS_PREPARE: | ||
452 | break; | ||
453 | case SND_SOC_BIAS_STANDBY: | ||
454 | regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL, | ||
455 | ADAU17X1_CLOCK_CONTROL_SYSCLK_EN, | ||
456 | ADAU17X1_CLOCK_CONTROL_SYSCLK_EN); | ||
457 | break; | ||
458 | case SND_SOC_BIAS_OFF: | ||
459 | regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL, | ||
460 | ADAU17X1_CLOCK_CONTROL_SYSCLK_EN, 0); | ||
461 | break; | ||
462 | |||
463 | } | ||
464 | codec->dapm.bias_level = level; | ||
465 | return 0; | ||
466 | } | ||
467 | |||
468 | static enum adau1761_output_mode adau1761_get_lineout_mode( | ||
469 | struct snd_soc_codec *codec) | ||
470 | { | ||
471 | struct adau1761_platform_data *pdata = codec->dev->platform_data; | ||
472 | |||
473 | if (pdata) | ||
474 | return pdata->lineout_mode; | ||
475 | |||
476 | return ADAU1761_OUTPUT_MODE_LINE; | ||
477 | } | ||
478 | |||
479 | static int adau1761_setup_digmic_jackdetect(struct snd_soc_codec *codec) | ||
480 | { | ||
481 | struct adau1761_platform_data *pdata = codec->dev->platform_data; | ||
482 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
483 | enum adau1761_digmic_jackdet_pin_mode mode; | ||
484 | unsigned int val = 0; | ||
485 | int ret; | ||
486 | |||
487 | if (pdata) | ||
488 | mode = pdata->digmic_jackdetect_pin_mode; | ||
489 | else | ||
490 | mode = ADAU1761_DIGMIC_JACKDET_PIN_MODE_NONE; | ||
491 | |||
492 | switch (mode) { | ||
493 | case ADAU1761_DIGMIC_JACKDET_PIN_MODE_JACKDETECT: | ||
494 | switch (pdata->jackdetect_debounce_time) { | ||
495 | case ADAU1761_JACKDETECT_DEBOUNCE_5MS: | ||
496 | case ADAU1761_JACKDETECT_DEBOUNCE_10MS: | ||
497 | case ADAU1761_JACKDETECT_DEBOUNCE_20MS: | ||
498 | case ADAU1761_JACKDETECT_DEBOUNCE_40MS: | ||
499 | val |= pdata->jackdetect_debounce_time << 6; | ||
500 | break; | ||
501 | default: | ||
502 | return -EINVAL; | ||
503 | } | ||
504 | if (pdata->jackdetect_active_low) | ||
505 | val |= ADAU1761_DIGMIC_JACKDETECT_ACTIVE_LOW; | ||
506 | |||
507 | ret = snd_soc_add_codec_controls(codec, | ||
508 | adau1761_jack_detect_controls, | ||
509 | ARRAY_SIZE(adau1761_jack_detect_controls)); | ||
510 | if (ret) | ||
511 | return ret; | ||
512 | case ADAU1761_DIGMIC_JACKDET_PIN_MODE_NONE: /* fallthrough */ | ||
513 | ret = snd_soc_dapm_add_routes(&codec->dapm, | ||
514 | adau1761_no_dmic_routes, | ||
515 | ARRAY_SIZE(adau1761_no_dmic_routes)); | ||
516 | if (ret) | ||
517 | return ret; | ||
518 | break; | ||
519 | case ADAU1761_DIGMIC_JACKDET_PIN_MODE_DIGMIC: | ||
520 | ret = snd_soc_dapm_new_controls(&codec->dapm, | ||
521 | adau1761_dmic_widgets, | ||
522 | ARRAY_SIZE(adau1761_dmic_widgets)); | ||
523 | if (ret) | ||
524 | return ret; | ||
525 | |||
526 | ret = snd_soc_dapm_add_routes(&codec->dapm, | ||
527 | adau1761_dmic_routes, | ||
528 | ARRAY_SIZE(adau1761_dmic_routes)); | ||
529 | if (ret) | ||
530 | return ret; | ||
531 | |||
532 | val |= ADAU1761_DIGMIC_JACKDETECT_DIGMIC; | ||
533 | break; | ||
534 | default: | ||
535 | return -EINVAL; | ||
536 | } | ||
537 | |||
538 | regmap_write(adau->regmap, ADAU1761_DIGMIC_JACKDETECT, val); | ||
539 | |||
540 | return 0; | ||
541 | } | ||
542 | |||
543 | static int adau1761_setup_headphone_mode(struct snd_soc_codec *codec) | ||
544 | { | ||
545 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
546 | struct adau1761_platform_data *pdata = codec->dev->platform_data; | ||
547 | enum adau1761_output_mode mode; | ||
548 | int ret; | ||
549 | |||
550 | if (pdata) | ||
551 | mode = pdata->headphone_mode; | ||
552 | else | ||
553 | mode = ADAU1761_OUTPUT_MODE_HEADPHONE; | ||
554 | |||
555 | switch (mode) { | ||
556 | case ADAU1761_OUTPUT_MODE_LINE: | ||
557 | break; | ||
558 | case ADAU1761_OUTPUT_MODE_HEADPHONE_CAPLESS: | ||
559 | regmap_update_bits(adau->regmap, ADAU1761_PLAY_MONO_OUTPUT_VOL, | ||
560 | ADAU1761_PLAY_MONO_OUTPUT_VOL_MODE_HP | | ||
561 | ADAU1761_PLAY_MONO_OUTPUT_VOL_UNMUTE, | ||
562 | ADAU1761_PLAY_MONO_OUTPUT_VOL_MODE_HP | | ||
563 | ADAU1761_PLAY_MONO_OUTPUT_VOL_UNMUTE); | ||
564 | /* fallthrough */ | ||
565 | case ADAU1761_OUTPUT_MODE_HEADPHONE: | ||
566 | regmap_update_bits(adau->regmap, ADAU1761_PLAY_HP_RIGHT_VOL, | ||
567 | ADAU1761_PLAY_HP_RIGHT_VOL_MODE_HP, | ||
568 | ADAU1761_PLAY_HP_RIGHT_VOL_MODE_HP); | ||
569 | break; | ||
570 | default: | ||
571 | return -EINVAL; | ||
572 | } | ||
573 | |||
574 | if (mode == ADAU1761_OUTPUT_MODE_HEADPHONE_CAPLESS) { | ||
575 | ret = snd_soc_dapm_new_controls(&codec->dapm, | ||
576 | adau1761_capless_dapm_widgets, | ||
577 | ARRAY_SIZE(adau1761_capless_dapm_widgets)); | ||
578 | if (ret) | ||
579 | return ret; | ||
580 | ret = snd_soc_dapm_add_routes(&codec->dapm, | ||
581 | adau1761_capless_dapm_routes, | ||
582 | ARRAY_SIZE(adau1761_capless_dapm_routes)); | ||
583 | } else { | ||
584 | ret = snd_soc_add_codec_controls(codec, adau1761_mono_controls, | ||
585 | ARRAY_SIZE(adau1761_mono_controls)); | ||
586 | if (ret) | ||
587 | return ret; | ||
588 | ret = snd_soc_dapm_new_controls(&codec->dapm, | ||
589 | adau1761_mono_dapm_widgets, | ||
590 | ARRAY_SIZE(adau1761_mono_dapm_widgets)); | ||
591 | if (ret) | ||
592 | return ret; | ||
593 | ret = snd_soc_dapm_add_routes(&codec->dapm, | ||
594 | adau1761_mono_dapm_routes, | ||
595 | ARRAY_SIZE(adau1761_mono_dapm_routes)); | ||
596 | } | ||
597 | |||
598 | return ret; | ||
599 | } | ||
600 | |||
601 | static bool adau1761_readable_register(struct device *dev, unsigned int reg) | ||
602 | { | ||
603 | switch (reg) { | ||
604 | case ADAU1761_DIGMIC_JACKDETECT: | ||
605 | case ADAU1761_REC_MIXER_LEFT0: | ||
606 | case ADAU1761_REC_MIXER_LEFT1: | ||
607 | case ADAU1761_REC_MIXER_RIGHT0: | ||
608 | case ADAU1761_REC_MIXER_RIGHT1: | ||
609 | case ADAU1761_LEFT_DIFF_INPUT_VOL: | ||
610 | case ADAU1761_RIGHT_DIFF_INPUT_VOL: | ||
611 | case ADAU1761_PLAY_LR_MIXER_LEFT: | ||
612 | case ADAU1761_PLAY_MIXER_LEFT0: | ||
613 | case ADAU1761_PLAY_MIXER_LEFT1: | ||
614 | case ADAU1761_PLAY_MIXER_RIGHT0: | ||
615 | case ADAU1761_PLAY_MIXER_RIGHT1: | ||
616 | case ADAU1761_PLAY_LR_MIXER_RIGHT: | ||
617 | case ADAU1761_PLAY_MIXER_MONO: | ||
618 | case ADAU1761_PLAY_HP_LEFT_VOL: | ||
619 | case ADAU1761_PLAY_HP_RIGHT_VOL: | ||
620 | case ADAU1761_PLAY_LINE_LEFT_VOL: | ||
621 | case ADAU1761_PLAY_LINE_RIGHT_VOL: | ||
622 | case ADAU1761_PLAY_MONO_OUTPUT_VOL: | ||
623 | case ADAU1761_POP_CLICK_SUPPRESS: | ||
624 | case ADAU1761_JACK_DETECT_PIN: | ||
625 | case ADAU1761_DEJITTER: | ||
626 | case ADAU1761_CLK_ENABLE0: | ||
627 | case ADAU1761_CLK_ENABLE1: | ||
628 | return true; | ||
629 | default: | ||
630 | break; | ||
631 | } | ||
632 | |||
633 | return adau17x1_readable_register(dev, reg); | ||
634 | } | ||
635 | |||
636 | static int adau1761_codec_probe(struct snd_soc_codec *codec) | ||
637 | { | ||
638 | struct adau1761_platform_data *pdata = codec->dev->platform_data; | ||
639 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
640 | int ret; | ||
641 | |||
642 | ret = adau17x1_add_widgets(codec); | ||
643 | if (ret < 0) | ||
644 | return ret; | ||
645 | |||
646 | if (pdata && pdata->input_differential) { | ||
647 | regmap_update_bits(adau->regmap, ADAU1761_LEFT_DIFF_INPUT_VOL, | ||
648 | ADAU1761_DIFF_INPUT_VOL_LDEN, | ||
649 | ADAU1761_DIFF_INPUT_VOL_LDEN); | ||
650 | regmap_update_bits(adau->regmap, ADAU1761_RIGHT_DIFF_INPUT_VOL, | ||
651 | ADAU1761_DIFF_INPUT_VOL_LDEN, | ||
652 | ADAU1761_DIFF_INPUT_VOL_LDEN); | ||
653 | ret = snd_soc_add_codec_controls(codec, | ||
654 | adau1761_differential_mode_controls, | ||
655 | ARRAY_SIZE(adau1761_differential_mode_controls)); | ||
656 | if (ret) | ||
657 | return ret; | ||
658 | } else { | ||
659 | ret = snd_soc_add_codec_controls(codec, | ||
660 | adau1761_single_mode_controls, | ||
661 | ARRAY_SIZE(adau1761_single_mode_controls)); | ||
662 | if (ret) | ||
663 | return ret; | ||
664 | } | ||
665 | |||
666 | switch (adau1761_get_lineout_mode(codec)) { | ||
667 | case ADAU1761_OUTPUT_MODE_LINE: | ||
668 | break; | ||
669 | case ADAU1761_OUTPUT_MODE_HEADPHONE: | ||
670 | regmap_update_bits(adau->regmap, ADAU1761_PLAY_LINE_LEFT_VOL, | ||
671 | ADAU1761_PLAY_LINE_LEFT_VOL_MODE_HP, | ||
672 | ADAU1761_PLAY_LINE_LEFT_VOL_MODE_HP); | ||
673 | regmap_update_bits(adau->regmap, ADAU1761_PLAY_LINE_RIGHT_VOL, | ||
674 | ADAU1761_PLAY_LINE_RIGHT_VOL_MODE_HP, | ||
675 | ADAU1761_PLAY_LINE_RIGHT_VOL_MODE_HP); | ||
676 | break; | ||
677 | default: | ||
678 | return -EINVAL; | ||
679 | } | ||
680 | |||
681 | ret = adau1761_setup_headphone_mode(codec); | ||
682 | if (ret) | ||
683 | return ret; | ||
684 | |||
685 | ret = adau1761_setup_digmic_jackdetect(codec); | ||
686 | if (ret) | ||
687 | return ret; | ||
688 | |||
689 | if (adau->type == ADAU1761) { | ||
690 | ret = snd_soc_dapm_new_controls(&codec->dapm, | ||
691 | adau1761_dapm_widgets, | ||
692 | ARRAY_SIZE(adau1761_dapm_widgets)); | ||
693 | if (ret) | ||
694 | return ret; | ||
695 | |||
696 | ret = snd_soc_dapm_add_routes(&codec->dapm, | ||
697 | adau1761_dapm_routes, | ||
698 | ARRAY_SIZE(adau1761_dapm_routes)); | ||
699 | if (ret) | ||
700 | return ret; | ||
701 | |||
702 | ret = adau17x1_load_firmware(adau, codec->dev, | ||
703 | ADAU1761_FIRMWARE); | ||
704 | if (ret) | ||
705 | dev_warn(codec->dev, "Failed to firmware\n"); | ||
706 | } | ||
707 | |||
708 | ret = adau17x1_add_routes(codec); | ||
709 | if (ret < 0) | ||
710 | return ret; | ||
711 | |||
712 | return 0; | ||
713 | } | ||
714 | |||
715 | static const struct snd_soc_codec_driver adau1761_codec_driver = { | ||
716 | .probe = adau1761_codec_probe, | ||
717 | .suspend = adau17x1_suspend, | ||
718 | .resume = adau17x1_resume, | ||
719 | .set_bias_level = adau1761_set_bias_level, | ||
720 | |||
721 | .controls = adau1761_controls, | ||
722 | .num_controls = ARRAY_SIZE(adau1761_controls), | ||
723 | .dapm_widgets = adau1x61_dapm_widgets, | ||
724 | .num_dapm_widgets = ARRAY_SIZE(adau1x61_dapm_widgets), | ||
725 | .dapm_routes = adau1x61_dapm_routes, | ||
726 | .num_dapm_routes = ARRAY_SIZE(adau1x61_dapm_routes), | ||
727 | }; | ||
728 | |||
729 | #define ADAU1761_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \ | ||
730 | SNDRV_PCM_FMTBIT_S32_LE) | ||
731 | |||
732 | static struct snd_soc_dai_driver adau1361_dai_driver = { | ||
733 | .name = "adau-hifi", | ||
734 | .playback = { | ||
735 | .stream_name = "Playback", | ||
736 | .channels_min = 2, | ||
737 | .channels_max = 4, | ||
738 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
739 | .formats = ADAU1761_FORMATS, | ||
740 | }, | ||
741 | .capture = { | ||
742 | .stream_name = "Capture", | ||
743 | .channels_min = 2, | ||
744 | .channels_max = 4, | ||
745 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
746 | .formats = ADAU1761_FORMATS, | ||
747 | }, | ||
748 | .ops = &adau17x1_dai_ops, | ||
749 | }; | ||
750 | |||
751 | static struct snd_soc_dai_driver adau1761_dai_driver = { | ||
752 | .name = "adau-hifi", | ||
753 | .playback = { | ||
754 | .stream_name = "Playback", | ||
755 | .channels_min = 2, | ||
756 | .channels_max = 8, | ||
757 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
758 | .formats = ADAU1761_FORMATS, | ||
759 | }, | ||
760 | .capture = { | ||
761 | .stream_name = "Capture", | ||
762 | .channels_min = 2, | ||
763 | .channels_max = 8, | ||
764 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
765 | .formats = ADAU1761_FORMATS, | ||
766 | }, | ||
767 | .ops = &adau17x1_dai_ops, | ||
768 | }; | ||
769 | |||
770 | int adau1761_probe(struct device *dev, struct regmap *regmap, | ||
771 | enum adau17x1_type type, void (*switch_mode)(struct device *dev)) | ||
772 | { | ||
773 | struct snd_soc_dai_driver *dai_drv; | ||
774 | int ret; | ||
775 | |||
776 | ret = adau17x1_probe(dev, regmap, type, switch_mode); | ||
777 | if (ret) | ||
778 | return ret; | ||
779 | |||
780 | if (type == ADAU1361) | ||
781 | dai_drv = &adau1361_dai_driver; | ||
782 | else | ||
783 | dai_drv = &adau1761_dai_driver; | ||
784 | |||
785 | return snd_soc_register_codec(dev, &adau1761_codec_driver, dai_drv, 1); | ||
786 | } | ||
787 | EXPORT_SYMBOL_GPL(adau1761_probe); | ||
788 | |||
789 | const struct regmap_config adau1761_regmap_config = { | ||
790 | .val_bits = 8, | ||
791 | .reg_bits = 16, | ||
792 | .max_register = 0x40fa, | ||
793 | .reg_defaults = adau1761_reg_defaults, | ||
794 | .num_reg_defaults = ARRAY_SIZE(adau1761_reg_defaults), | ||
795 | .readable_reg = adau1761_readable_register, | ||
796 | .volatile_reg = adau17x1_volatile_register, | ||
797 | .cache_type = REGCACHE_RBTREE, | ||
798 | }; | ||
799 | EXPORT_SYMBOL_GPL(adau1761_regmap_config); | ||
800 | |||
801 | MODULE_DESCRIPTION("ASoC ADAU1361/ADAU1461/ADAU1761/ADAU1961 CODEC driver"); | ||
802 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
803 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/adau1761.h b/sound/soc/codecs/adau1761.h new file mode 100644 index 000000000000..a9e0d288301e --- /dev/null +++ b/sound/soc/codecs/adau1761.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * ADAU1361/ADAU1461/ADAU1761/ADAU1961 driver | ||
3 | * | ||
4 | * Copyright 2014 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2. | ||
8 | */ | ||
9 | |||
10 | #ifndef __SOUND_SOC_CODECS_ADAU1761_H__ | ||
11 | #define __SOUND_SOC_CODECS_ADAU1761_H__ | ||
12 | |||
13 | #include <linux/regmap.h> | ||
14 | #include "adau17x1.h" | ||
15 | |||
16 | struct device; | ||
17 | |||
18 | int adau1761_probe(struct device *dev, struct regmap *regmap, | ||
19 | enum adau17x1_type type, void (*switch_mode)(struct device *dev)); | ||
20 | |||
21 | extern const struct regmap_config adau1761_regmap_config; | ||
22 | |||
23 | #endif | ||
diff --git a/sound/soc/codecs/adau1781-i2c.c b/sound/soc/codecs/adau1781-i2c.c new file mode 100644 index 000000000000..2ce4362ccec1 --- /dev/null +++ b/sound/soc/codecs/adau1781-i2c.c | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Driver for ADAU1381/ADAU1781 CODEC | ||
3 | * | ||
4 | * Copyright 2014 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2. | ||
8 | */ | ||
9 | |||
10 | #include <linux/i2c.h> | ||
11 | #include <linux/mod_devicetable.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/regmap.h> | ||
14 | #include <sound/soc.h> | ||
15 | |||
16 | #include "adau1781.h" | ||
17 | |||
18 | static int adau1781_i2c_probe(struct i2c_client *client, | ||
19 | const struct i2c_device_id *id) | ||
20 | { | ||
21 | struct regmap_config config; | ||
22 | |||
23 | config = adau1781_regmap_config; | ||
24 | config.val_bits = 8; | ||
25 | config.reg_bits = 16; | ||
26 | |||
27 | return adau1781_probe(&client->dev, | ||
28 | devm_regmap_init_i2c(client, &config), | ||
29 | id->driver_data, NULL); | ||
30 | } | ||
31 | |||
32 | static int adau1781_i2c_remove(struct i2c_client *client) | ||
33 | { | ||
34 | snd_soc_unregister_codec(&client->dev); | ||
35 | return 0; | ||
36 | } | ||
37 | |||
38 | static const struct i2c_device_id adau1781_i2c_ids[] = { | ||
39 | { "adau1381", ADAU1381 }, | ||
40 | { "adau1781", ADAU1781 }, | ||
41 | { } | ||
42 | }; | ||
43 | MODULE_DEVICE_TABLE(i2c, adau1781_i2c_ids); | ||
44 | |||
45 | static struct i2c_driver adau1781_i2c_driver = { | ||
46 | .driver = { | ||
47 | .name = "adau1781", | ||
48 | .owner = THIS_MODULE, | ||
49 | }, | ||
50 | .probe = adau1781_i2c_probe, | ||
51 | .remove = adau1781_i2c_remove, | ||
52 | .id_table = adau1781_i2c_ids, | ||
53 | }; | ||
54 | module_i2c_driver(adau1781_i2c_driver); | ||
55 | |||
56 | MODULE_DESCRIPTION("ASoC ADAU1381/ADAU1781 CODEC I2C driver"); | ||
57 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
58 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/adau1781-spi.c b/sound/soc/codecs/adau1781-spi.c new file mode 100644 index 000000000000..194686716bbe --- /dev/null +++ b/sound/soc/codecs/adau1781-spi.c | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * Driver for ADAU1381/ADAU1781 CODEC | ||
3 | * | ||
4 | * Copyright 2014 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2. | ||
8 | */ | ||
9 | |||
10 | #include <linux/mod_devicetable.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/regmap.h> | ||
13 | #include <linux/spi/spi.h> | ||
14 | #include <sound/soc.h> | ||
15 | |||
16 | #include "adau1781.h" | ||
17 | |||
18 | static void adau1781_spi_switch_mode(struct device *dev) | ||
19 | { | ||
20 | struct spi_device *spi = to_spi_device(dev); | ||
21 | |||
22 | /* | ||
23 | * To get the device into SPI mode CLATCH has to be pulled low three | ||
24 | * times. Do this by issuing three dummy reads. | ||
25 | */ | ||
26 | spi_w8r8(spi, 0x00); | ||
27 | spi_w8r8(spi, 0x00); | ||
28 | spi_w8r8(spi, 0x00); | ||
29 | } | ||
30 | |||
31 | static int adau1781_spi_probe(struct spi_device *spi) | ||
32 | { | ||
33 | const struct spi_device_id *id = spi_get_device_id(spi); | ||
34 | struct regmap_config config; | ||
35 | |||
36 | if (!id) | ||
37 | return -EINVAL; | ||
38 | |||
39 | config = adau1781_regmap_config; | ||
40 | config.val_bits = 8; | ||
41 | config.reg_bits = 24; | ||
42 | config.read_flag_mask = 0x1; | ||
43 | |||
44 | return adau1781_probe(&spi->dev, | ||
45 | devm_regmap_init_spi(spi, &config), | ||
46 | id->driver_data, adau1781_spi_switch_mode); | ||
47 | } | ||
48 | |||
49 | static int adau1781_spi_remove(struct spi_device *spi) | ||
50 | { | ||
51 | snd_soc_unregister_codec(&spi->dev); | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static const struct spi_device_id adau1781_spi_id[] = { | ||
56 | { "adau1381", ADAU1381 }, | ||
57 | { "adau1781", ADAU1781 }, | ||
58 | { } | ||
59 | }; | ||
60 | MODULE_DEVICE_TABLE(spi, adau1781_spi_id); | ||
61 | |||
62 | static struct spi_driver adau1781_spi_driver = { | ||
63 | .driver = { | ||
64 | .name = "adau1781", | ||
65 | .owner = THIS_MODULE, | ||
66 | }, | ||
67 | .probe = adau1781_spi_probe, | ||
68 | .remove = adau1781_spi_remove, | ||
69 | .id_table = adau1781_spi_id, | ||
70 | }; | ||
71 | module_spi_driver(adau1781_spi_driver); | ||
72 | |||
73 | MODULE_DESCRIPTION("ASoC ADAU1381/ADAU1781 CODEC SPI driver"); | ||
74 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
75 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/adau1781.c b/sound/soc/codecs/adau1781.c new file mode 100644 index 000000000000..045a61413840 --- /dev/null +++ b/sound/soc/codecs/adau1781.c | |||
@@ -0,0 +1,511 @@ | |||
1 | /* | ||
2 | * Driver for ADAU1781/ADAU1781 codec | ||
3 | * | ||
4 | * Copyright 2011-2013 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2 or later. | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/i2c.h> | ||
13 | #include <linux/spi/spi.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <sound/core.h> | ||
16 | #include <sound/pcm.h> | ||
17 | #include <sound/pcm_params.h> | ||
18 | #include <sound/soc.h> | ||
19 | #include <sound/tlv.h> | ||
20 | #include <linux/platform_data/adau17x1.h> | ||
21 | |||
22 | #include "adau17x1.h" | ||
23 | #include "adau1781.h" | ||
24 | |||
25 | #define ADAU1781_DMIC_BEEP_CTRL 0x4008 | ||
26 | #define ADAU1781_LEFT_PGA 0x400e | ||
27 | #define ADAU1781_RIGHT_PGA 0x400f | ||
28 | #define ADAU1781_LEFT_PLAYBACK_MIXER 0x401c | ||
29 | #define ADAU1781_RIGHT_PLAYBACK_MIXER 0x401e | ||
30 | #define ADAU1781_MONO_PLAYBACK_MIXER 0x401f | ||
31 | #define ADAU1781_LEFT_LINEOUT 0x4025 | ||
32 | #define ADAU1781_RIGHT_LINEOUT 0x4026 | ||
33 | #define ADAU1781_SPEAKER 0x4027 | ||
34 | #define ADAU1781_BEEP_ZC 0x4028 | ||
35 | #define ADAU1781_DEJITTER 0x4032 | ||
36 | #define ADAU1781_DIG_PWDN0 0x4080 | ||
37 | #define ADAU1781_DIG_PWDN1 0x4081 | ||
38 | |||
39 | #define ADAU1781_INPUT_DIFFERNTIAL BIT(3) | ||
40 | |||
41 | #define ADAU1381_FIRMWARE "adau1381.bin" | ||
42 | #define ADAU1781_FIRMWARE "adau1781.bin" | ||
43 | |||
44 | static const struct reg_default adau1781_reg_defaults[] = { | ||
45 | { ADAU1781_DMIC_BEEP_CTRL, 0x00 }, | ||
46 | { ADAU1781_LEFT_PGA, 0xc7 }, | ||
47 | { ADAU1781_RIGHT_PGA, 0xc7 }, | ||
48 | { ADAU1781_LEFT_PLAYBACK_MIXER, 0x00 }, | ||
49 | { ADAU1781_RIGHT_PLAYBACK_MIXER, 0x00 }, | ||
50 | { ADAU1781_MONO_PLAYBACK_MIXER, 0x00 }, | ||
51 | { ADAU1781_LEFT_LINEOUT, 0x00 }, | ||
52 | { ADAU1781_RIGHT_LINEOUT, 0x00 }, | ||
53 | { ADAU1781_SPEAKER, 0x00 }, | ||
54 | { ADAU1781_BEEP_ZC, 0x19 }, | ||
55 | { ADAU1781_DEJITTER, 0x60 }, | ||
56 | { ADAU1781_DIG_PWDN1, 0x0c }, | ||
57 | { ADAU1781_DIG_PWDN1, 0x00 }, | ||
58 | { ADAU17X1_CLOCK_CONTROL, 0x00 }, | ||
59 | { ADAU17X1_PLL_CONTROL, 0x00 }, | ||
60 | { ADAU17X1_REC_POWER_MGMT, 0x00 }, | ||
61 | { ADAU17X1_MICBIAS, 0x04 }, | ||
62 | { ADAU17X1_SERIAL_PORT0, 0x00 }, | ||
63 | { ADAU17X1_SERIAL_PORT1, 0x00 }, | ||
64 | { ADAU17X1_CONVERTER0, 0x00 }, | ||
65 | { ADAU17X1_CONVERTER1, 0x00 }, | ||
66 | { ADAU17X1_LEFT_INPUT_DIGITAL_VOL, 0x00 }, | ||
67 | { ADAU17X1_RIGHT_INPUT_DIGITAL_VOL, 0x00 }, | ||
68 | { ADAU17X1_ADC_CONTROL, 0x00 }, | ||
69 | { ADAU17X1_PLAY_POWER_MGMT, 0x00 }, | ||
70 | { ADAU17X1_DAC_CONTROL0, 0x00 }, | ||
71 | { ADAU17X1_DAC_CONTROL1, 0x00 }, | ||
72 | { ADAU17X1_DAC_CONTROL2, 0x00 }, | ||
73 | { ADAU17X1_SERIAL_PORT_PAD, 0x00 }, | ||
74 | { ADAU17X1_CONTROL_PORT_PAD0, 0x00 }, | ||
75 | { ADAU17X1_CONTROL_PORT_PAD1, 0x00 }, | ||
76 | { ADAU17X1_DSP_SAMPLING_RATE, 0x01 }, | ||
77 | { ADAU17X1_SERIAL_INPUT_ROUTE, 0x00 }, | ||
78 | { ADAU17X1_SERIAL_OUTPUT_ROUTE, 0x00 }, | ||
79 | { ADAU17X1_DSP_ENABLE, 0x00 }, | ||
80 | { ADAU17X1_DSP_RUN, 0x00 }, | ||
81 | { ADAU17X1_SERIAL_SAMPLING_RATE, 0x00 }, | ||
82 | }; | ||
83 | |||
84 | static const DECLARE_TLV_DB_SCALE(adau1781_speaker_tlv, 0, 200, 0); | ||
85 | |||
86 | static const DECLARE_TLV_DB_RANGE(adau1781_pga_tlv, | ||
87 | 0, 1, TLV_DB_SCALE_ITEM(0, 600, 0), | ||
88 | 2, 3, TLV_DB_SCALE_ITEM(1000, 400, 0), | ||
89 | 4, 4, TLV_DB_SCALE_ITEM(1700, 0, 0), | ||
90 | 5, 7, TLV_DB_SCALE_ITEM(2000, 600, 0) | ||
91 | ); | ||
92 | |||
93 | static const DECLARE_TLV_DB_RANGE(adau1781_beep_tlv, | ||
94 | 0, 1, TLV_DB_SCALE_ITEM(0, 600, 0), | ||
95 | 2, 3, TLV_DB_SCALE_ITEM(1000, 400, 0), | ||
96 | 4, 4, TLV_DB_SCALE_ITEM(-2300, 0, 0), | ||
97 | 5, 7, TLV_DB_SCALE_ITEM(2000, 600, 0) | ||
98 | ); | ||
99 | |||
100 | static const DECLARE_TLV_DB_SCALE(adau1781_sidetone_tlv, -1800, 300, 1); | ||
101 | |||
102 | static const char * const adau1781_speaker_bias_select_text[] = { | ||
103 | "Normal operation", "Power saving", "Enhanced performance", | ||
104 | }; | ||
105 | |||
106 | static const char * const adau1781_bias_select_text[] = { | ||
107 | "Normal operation", "Extreme power saving", "Power saving", | ||
108 | "Enhanced performance", | ||
109 | }; | ||
110 | |||
111 | static SOC_ENUM_SINGLE_DECL(adau1781_adc_bias_enum, | ||
112 | ADAU17X1_REC_POWER_MGMT, 3, adau1781_bias_select_text); | ||
113 | static SOC_ENUM_SINGLE_DECL(adau1781_speaker_bias_enum, | ||
114 | ADAU17X1_PLAY_POWER_MGMT, 6, adau1781_speaker_bias_select_text); | ||
115 | static SOC_ENUM_SINGLE_DECL(adau1781_dac_bias_enum, | ||
116 | ADAU17X1_PLAY_POWER_MGMT, 4, adau1781_bias_select_text); | ||
117 | static SOC_ENUM_SINGLE_DECL(adau1781_playback_bias_enum, | ||
118 | ADAU17X1_PLAY_POWER_MGMT, 2, adau1781_bias_select_text); | ||
119 | static SOC_ENUM_SINGLE_DECL(adau1781_capture_bias_enum, | ||
120 | ADAU17X1_REC_POWER_MGMT, 1, adau1781_bias_select_text); | ||
121 | |||
122 | static const struct snd_kcontrol_new adau1781_controls[] = { | ||
123 | SOC_SINGLE_TLV("Beep Capture Volume", ADAU1781_DMIC_BEEP_CTRL, 0, 7, 0, | ||
124 | adau1781_beep_tlv), | ||
125 | SOC_DOUBLE_R_TLV("PGA Capture Volume", ADAU1781_LEFT_PGA, | ||
126 | ADAU1781_RIGHT_PGA, 5, 7, 0, adau1781_pga_tlv), | ||
127 | SOC_DOUBLE_R("PGA Capture Switch", ADAU1781_LEFT_PGA, | ||
128 | ADAU1781_RIGHT_PGA, 1, 1, 0), | ||
129 | |||
130 | SOC_DOUBLE_R("Lineout Playback Switch", ADAU1781_LEFT_LINEOUT, | ||
131 | ADAU1781_RIGHT_LINEOUT, 1, 1, 0), | ||
132 | SOC_SINGLE("Beep ZC Switch", ADAU1781_BEEP_ZC, 0, 1, 0), | ||
133 | |||
134 | SOC_SINGLE("Mono Playback Switch", ADAU1781_MONO_PLAYBACK_MIXER, | ||
135 | 0, 1, 0), | ||
136 | SOC_SINGLE_TLV("Mono Playback Volume", ADAU1781_SPEAKER, 6, 3, 0, | ||
137 | adau1781_speaker_tlv), | ||
138 | |||
139 | SOC_ENUM("ADC Bias", adau1781_adc_bias_enum), | ||
140 | SOC_ENUM("DAC Bias", adau1781_dac_bias_enum), | ||
141 | SOC_ENUM("Capture Bias", adau1781_capture_bias_enum), | ||
142 | SOC_ENUM("Playback Bias", adau1781_playback_bias_enum), | ||
143 | SOC_ENUM("Speaker Bias", adau1781_speaker_bias_enum), | ||
144 | }; | ||
145 | |||
146 | static const struct snd_kcontrol_new adau1781_beep_mixer_controls[] = { | ||
147 | SOC_DAPM_SINGLE("Beep Capture Switch", ADAU1781_DMIC_BEEP_CTRL, | ||
148 | 3, 1, 0), | ||
149 | }; | ||
150 | |||
151 | static const struct snd_kcontrol_new adau1781_left_mixer_controls[] = { | ||
152 | SOC_DAPM_SINGLE_AUTODISABLE("Switch", | ||
153 | ADAU1781_LEFT_PLAYBACK_MIXER, 5, 1, 0), | ||
154 | SOC_DAPM_SINGLE_TLV("Beep Playback Volume", | ||
155 | ADAU1781_LEFT_PLAYBACK_MIXER, 1, 8, 0, adau1781_sidetone_tlv), | ||
156 | }; | ||
157 | |||
158 | static const struct snd_kcontrol_new adau1781_right_mixer_controls[] = { | ||
159 | SOC_DAPM_SINGLE_AUTODISABLE("Switch", | ||
160 | ADAU1781_RIGHT_PLAYBACK_MIXER, 6, 1, 0), | ||
161 | SOC_DAPM_SINGLE_TLV("Beep Playback Volume", | ||
162 | ADAU1781_LEFT_PLAYBACK_MIXER, 1, 8, 0, adau1781_sidetone_tlv), | ||
163 | }; | ||
164 | |||
165 | static const struct snd_kcontrol_new adau1781_mono_mixer_controls[] = { | ||
166 | SOC_DAPM_SINGLE_AUTODISABLE("Left Switch", | ||
167 | ADAU1781_MONO_PLAYBACK_MIXER, 7, 1, 0), | ||
168 | SOC_DAPM_SINGLE_AUTODISABLE("Right Switch", | ||
169 | ADAU1781_MONO_PLAYBACK_MIXER, 6, 1, 0), | ||
170 | SOC_DAPM_SINGLE_TLV("Beep Playback Volume", | ||
171 | ADAU1781_MONO_PLAYBACK_MIXER, 2, 8, 0, adau1781_sidetone_tlv), | ||
172 | }; | ||
173 | |||
174 | static int adau1781_dejitter_fixup(struct snd_soc_dapm_widget *w, | ||
175 | struct snd_kcontrol *kcontrol, int event) | ||
176 | { | ||
177 | struct snd_soc_codec *codec = w->codec; | ||
178 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
179 | |||
180 | /* After any power changes have been made the dejitter circuit | ||
181 | * has to be reinitialized. */ | ||
182 | regmap_write(adau->regmap, ADAU1781_DEJITTER, 0); | ||
183 | if (!adau->master) | ||
184 | regmap_write(adau->regmap, ADAU1781_DEJITTER, 5); | ||
185 | |||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | static const struct snd_soc_dapm_widget adau1781_dapm_widgets[] = { | ||
190 | SND_SOC_DAPM_PGA("Left PGA", ADAU1781_LEFT_PGA, 0, 0, NULL, 0), | ||
191 | SND_SOC_DAPM_PGA("Right PGA", ADAU1781_RIGHT_PGA, 0, 0, NULL, 0), | ||
192 | |||
193 | SND_SOC_DAPM_OUT_DRV("Speaker", ADAU1781_SPEAKER, 0, 0, NULL, 0), | ||
194 | |||
195 | SOC_MIXER_NAMED_CTL_ARRAY("Beep Mixer", ADAU17X1_MICBIAS, 4, 0, | ||
196 | adau1781_beep_mixer_controls), | ||
197 | |||
198 | SOC_MIXER_ARRAY("Left Lineout Mixer", SND_SOC_NOPM, 0, 0, | ||
199 | adau1781_left_mixer_controls), | ||
200 | SOC_MIXER_ARRAY("Right Lineout Mixer", SND_SOC_NOPM, 0, 0, | ||
201 | adau1781_right_mixer_controls), | ||
202 | SOC_MIXER_ARRAY("Mono Mixer", SND_SOC_NOPM, 0, 0, | ||
203 | adau1781_mono_mixer_controls), | ||
204 | |||
205 | SND_SOC_DAPM_SUPPLY("Serial Input Routing", ADAU1781_DIG_PWDN0, | ||
206 | 2, 0, NULL, 0), | ||
207 | SND_SOC_DAPM_SUPPLY("Serial Output Routing", ADAU1781_DIG_PWDN0, | ||
208 | 3, 0, NULL, 0), | ||
209 | SND_SOC_DAPM_SUPPLY("Clock Domain Transfer", ADAU1781_DIG_PWDN0, | ||
210 | 5, 0, NULL, 0), | ||
211 | SND_SOC_DAPM_SUPPLY("Serial Ports", ADAU1781_DIG_PWDN0, 4, 0, NULL, 0), | ||
212 | SND_SOC_DAPM_SUPPLY("ADC Engine", ADAU1781_DIG_PWDN0, 7, 0, NULL, 0), | ||
213 | SND_SOC_DAPM_SUPPLY("DAC Engine", ADAU1781_DIG_PWDN1, 0, 0, NULL, 0), | ||
214 | SND_SOC_DAPM_SUPPLY("Digital Mic", ADAU1781_DIG_PWDN1, 1, 0, NULL, 0), | ||
215 | |||
216 | SND_SOC_DAPM_SUPPLY("Sound Engine", ADAU1781_DIG_PWDN0, 0, 0, NULL, 0), | ||
217 | SND_SOC_DAPM_SUPPLY_S("SYSCLK", 1, ADAU1781_DIG_PWDN0, 1, 0, NULL, 0), | ||
218 | |||
219 | SND_SOC_DAPM_SUPPLY("Zero Crossing Detector", ADAU1781_DIG_PWDN1, 2, 0, | ||
220 | NULL, 0), | ||
221 | |||
222 | SND_SOC_DAPM_POST("Dejitter fixup", adau1781_dejitter_fixup), | ||
223 | |||
224 | SND_SOC_DAPM_INPUT("BEEP"), | ||
225 | |||
226 | SND_SOC_DAPM_OUTPUT("AOUTL"), | ||
227 | SND_SOC_DAPM_OUTPUT("AOUTR"), | ||
228 | SND_SOC_DAPM_OUTPUT("SP"), | ||
229 | SND_SOC_DAPM_INPUT("LMIC"), | ||
230 | SND_SOC_DAPM_INPUT("RMIC"), | ||
231 | }; | ||
232 | |||
233 | static const struct snd_soc_dapm_route adau1781_dapm_routes[] = { | ||
234 | { "Left Lineout Mixer", NULL, "Left Playback Enable" }, | ||
235 | { "Right Lineout Mixer", NULL, "Right Playback Enable" }, | ||
236 | |||
237 | { "Left Lineout Mixer", "Beep Playback Volume", "Beep Mixer" }, | ||
238 | { "Left Lineout Mixer", "Switch", "Left DAC" }, | ||
239 | |||
240 | { "Right Lineout Mixer", "Beep Playback Volume", "Beep Mixer" }, | ||
241 | { "Right Lineout Mixer", "Switch", "Right DAC" }, | ||
242 | |||
243 | { "Mono Mixer", "Beep Playback Volume", "Beep Mixer" }, | ||
244 | { "Mono Mixer", "Right Switch", "Right DAC" }, | ||
245 | { "Mono Mixer", "Left Switch", "Left DAC" }, | ||
246 | { "Speaker", NULL, "Mono Mixer" }, | ||
247 | |||
248 | { "Mono Mixer", NULL, "SYSCLK" }, | ||
249 | { "Left Lineout Mixer", NULL, "SYSCLK" }, | ||
250 | { "Left Lineout Mixer", NULL, "SYSCLK" }, | ||
251 | |||
252 | { "Beep Mixer", "Beep Capture Switch", "BEEP" }, | ||
253 | { "Beep Mixer", NULL, "Zero Crossing Detector" }, | ||
254 | |||
255 | { "Left DAC", NULL, "DAC Engine" }, | ||
256 | { "Right DAC", NULL, "DAC Engine" }, | ||
257 | |||
258 | { "Sound Engine", NULL, "SYSCLK" }, | ||
259 | { "DSP", NULL, "Sound Engine" }, | ||
260 | |||
261 | { "Left Decimator", NULL, "ADC Engine" }, | ||
262 | { "Right Decimator", NULL, "ADC Engine" }, | ||
263 | |||
264 | { "AIFCLK", NULL, "SYSCLK" }, | ||
265 | |||
266 | { "Playback", NULL, "Serial Input Routing" }, | ||
267 | { "Playback", NULL, "Serial Ports" }, | ||
268 | { "Playback", NULL, "Clock Domain Transfer" }, | ||
269 | { "Capture", NULL, "Serial Output Routing" }, | ||
270 | { "Capture", NULL, "Serial Ports" }, | ||
271 | { "Capture", NULL, "Clock Domain Transfer" }, | ||
272 | |||
273 | { "AOUTL", NULL, "Left Lineout Mixer" }, | ||
274 | { "AOUTR", NULL, "Right Lineout Mixer" }, | ||
275 | { "SP", NULL, "Speaker" }, | ||
276 | }; | ||
277 | |||
278 | static const struct snd_soc_dapm_route adau1781_adc_dapm_routes[] = { | ||
279 | { "Left PGA", NULL, "LMIC" }, | ||
280 | { "Right PGA", NULL, "RMIC" }, | ||
281 | |||
282 | { "Left Decimator", NULL, "Left PGA" }, | ||
283 | { "Right Decimator", NULL, "Right PGA" }, | ||
284 | }; | ||
285 | |||
286 | static const char * const adau1781_dmic_select_text[] = { | ||
287 | "DMIC1", "DMIC2", | ||
288 | }; | ||
289 | |||
290 | static SOC_ENUM_SINGLE_VIRT_DECL(adau1781_dmic_select_enum, | ||
291 | adau1781_dmic_select_text); | ||
292 | |||
293 | static const struct snd_kcontrol_new adau1781_dmic_mux = | ||
294 | SOC_DAPM_ENUM("DMIC Select", adau1781_dmic_select_enum); | ||
295 | |||
296 | static const struct snd_soc_dapm_widget adau1781_dmic_dapm_widgets[] = { | ||
297 | SND_SOC_DAPM_MUX("DMIC Select", SND_SOC_NOPM, 0, 0, &adau1781_dmic_mux), | ||
298 | |||
299 | SND_SOC_DAPM_ADC("DMIC1", NULL, ADAU1781_DMIC_BEEP_CTRL, 4, 0), | ||
300 | SND_SOC_DAPM_ADC("DMIC2", NULL, ADAU1781_DMIC_BEEP_CTRL, 5, 0), | ||
301 | }; | ||
302 | |||
303 | static const struct snd_soc_dapm_route adau1781_dmic_dapm_routes[] = { | ||
304 | { "DMIC1", NULL, "LMIC" }, | ||
305 | { "DMIC2", NULL, "RMIC" }, | ||
306 | |||
307 | { "DMIC1", NULL, "Digital Mic" }, | ||
308 | { "DMIC2", NULL, "Digital Mic" }, | ||
309 | |||
310 | { "DMIC Select", "DMIC1", "DMIC1" }, | ||
311 | { "DMIC Select", "DMIC2", "DMIC2" }, | ||
312 | |||
313 | { "Left Decimator", NULL, "DMIC Select" }, | ||
314 | { "Right Decimator", NULL, "DMIC Select" }, | ||
315 | }; | ||
316 | |||
317 | static int adau1781_set_bias_level(struct snd_soc_codec *codec, | ||
318 | enum snd_soc_bias_level level) | ||
319 | { | ||
320 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
321 | |||
322 | switch (level) { | ||
323 | case SND_SOC_BIAS_ON: | ||
324 | break; | ||
325 | case SND_SOC_BIAS_PREPARE: | ||
326 | break; | ||
327 | case SND_SOC_BIAS_STANDBY: | ||
328 | regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL, | ||
329 | ADAU17X1_CLOCK_CONTROL_SYSCLK_EN, | ||
330 | ADAU17X1_CLOCK_CONTROL_SYSCLK_EN); | ||
331 | |||
332 | /* Precharge */ | ||
333 | regmap_update_bits(adau->regmap, ADAU1781_DIG_PWDN1, 0x8, 0x8); | ||
334 | break; | ||
335 | case SND_SOC_BIAS_OFF: | ||
336 | regmap_update_bits(adau->regmap, ADAU1781_DIG_PWDN1, 0xc, 0x0); | ||
337 | regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL, | ||
338 | ADAU17X1_CLOCK_CONTROL_SYSCLK_EN, 0); | ||
339 | break; | ||
340 | } | ||
341 | |||
342 | codec->dapm.bias_level = level; | ||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | static bool adau1781_readable_register(struct device *dev, unsigned int reg) | ||
347 | { | ||
348 | switch (reg) { | ||
349 | case ADAU1781_DMIC_BEEP_CTRL: | ||
350 | case ADAU1781_LEFT_PGA: | ||
351 | case ADAU1781_RIGHT_PGA: | ||
352 | case ADAU1781_LEFT_PLAYBACK_MIXER: | ||
353 | case ADAU1781_RIGHT_PLAYBACK_MIXER: | ||
354 | case ADAU1781_MONO_PLAYBACK_MIXER: | ||
355 | case ADAU1781_LEFT_LINEOUT: | ||
356 | case ADAU1781_RIGHT_LINEOUT: | ||
357 | case ADAU1781_SPEAKER: | ||
358 | case ADAU1781_BEEP_ZC: | ||
359 | case ADAU1781_DEJITTER: | ||
360 | case ADAU1781_DIG_PWDN0: | ||
361 | case ADAU1781_DIG_PWDN1: | ||
362 | return true; | ||
363 | default: | ||
364 | break; | ||
365 | } | ||
366 | |||
367 | return adau17x1_readable_register(dev, reg); | ||
368 | } | ||
369 | |||
370 | static int adau1781_set_input_mode(struct adau *adau, unsigned int reg, | ||
371 | bool differential) | ||
372 | { | ||
373 | unsigned int val; | ||
374 | |||
375 | if (differential) | ||
376 | val = ADAU1781_INPUT_DIFFERNTIAL; | ||
377 | else | ||
378 | val = 0; | ||
379 | |||
380 | return regmap_update_bits(adau->regmap, reg, | ||
381 | ADAU1781_INPUT_DIFFERNTIAL, val); | ||
382 | } | ||
383 | |||
384 | static int adau1781_codec_probe(struct snd_soc_codec *codec) | ||
385 | { | ||
386 | struct adau1781_platform_data *pdata = dev_get_platdata(codec->dev); | ||
387 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
388 | const char *firmware; | ||
389 | int ret; | ||
390 | |||
391 | ret = adau17x1_add_widgets(codec); | ||
392 | if (ret) | ||
393 | return ret; | ||
394 | |||
395 | if (pdata) { | ||
396 | ret = adau1781_set_input_mode(adau, ADAU1781_LEFT_PGA, | ||
397 | pdata->left_input_differential); | ||
398 | if (ret) | ||
399 | return ret; | ||
400 | ret = adau1781_set_input_mode(adau, ADAU1781_RIGHT_PGA, | ||
401 | pdata->right_input_differential); | ||
402 | if (ret) | ||
403 | return ret; | ||
404 | } | ||
405 | |||
406 | if (pdata && pdata->use_dmic) { | ||
407 | ret = snd_soc_dapm_new_controls(&codec->dapm, | ||
408 | adau1781_dmic_dapm_widgets, | ||
409 | ARRAY_SIZE(adau1781_dmic_dapm_widgets)); | ||
410 | if (ret) | ||
411 | return ret; | ||
412 | ret = snd_soc_dapm_add_routes(&codec->dapm, | ||
413 | adau1781_dmic_dapm_routes, | ||
414 | ARRAY_SIZE(adau1781_dmic_dapm_routes)); | ||
415 | if (ret) | ||
416 | return ret; | ||
417 | } else { | ||
418 | ret = snd_soc_dapm_add_routes(&codec->dapm, | ||
419 | adau1781_adc_dapm_routes, | ||
420 | ARRAY_SIZE(adau1781_adc_dapm_routes)); | ||
421 | if (ret) | ||
422 | return ret; | ||
423 | } | ||
424 | |||
425 | switch (adau->type) { | ||
426 | case ADAU1381: | ||
427 | firmware = ADAU1381_FIRMWARE; | ||
428 | break; | ||
429 | case ADAU1781: | ||
430 | firmware = ADAU1781_FIRMWARE; | ||
431 | break; | ||
432 | default: | ||
433 | return -EINVAL; | ||
434 | } | ||
435 | |||
436 | ret = adau17x1_add_routes(codec); | ||
437 | if (ret < 0) | ||
438 | return ret; | ||
439 | |||
440 | ret = adau17x1_load_firmware(adau, codec->dev, firmware); | ||
441 | if (ret) | ||
442 | dev_warn(codec->dev, "Failed to load firmware\n"); | ||
443 | |||
444 | return 0; | ||
445 | } | ||
446 | |||
447 | static const struct snd_soc_codec_driver adau1781_codec_driver = { | ||
448 | .probe = adau1781_codec_probe, | ||
449 | .suspend = adau17x1_suspend, | ||
450 | .resume = adau17x1_resume, | ||
451 | .set_bias_level = adau1781_set_bias_level, | ||
452 | |||
453 | .controls = adau1781_controls, | ||
454 | .num_controls = ARRAY_SIZE(adau1781_controls), | ||
455 | .dapm_widgets = adau1781_dapm_widgets, | ||
456 | .num_dapm_widgets = ARRAY_SIZE(adau1781_dapm_widgets), | ||
457 | .dapm_routes = adau1781_dapm_routes, | ||
458 | .num_dapm_routes = ARRAY_SIZE(adau1781_dapm_routes), | ||
459 | }; | ||
460 | |||
461 | #define ADAU1781_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \ | ||
462 | SNDRV_PCM_FMTBIT_S32_LE) | ||
463 | |||
464 | static struct snd_soc_dai_driver adau1781_dai_driver = { | ||
465 | .name = "adau-hifi", | ||
466 | .playback = { | ||
467 | .stream_name = "Playback", | ||
468 | .channels_min = 2, | ||
469 | .channels_max = 8, | ||
470 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
471 | .formats = ADAU1781_FORMATS, | ||
472 | }, | ||
473 | .capture = { | ||
474 | .stream_name = "Capture", | ||
475 | .channels_min = 2, | ||
476 | .channels_max = 8, | ||
477 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
478 | .formats = ADAU1781_FORMATS, | ||
479 | }, | ||
480 | .ops = &adau17x1_dai_ops, | ||
481 | }; | ||
482 | |||
483 | const struct regmap_config adau1781_regmap_config = { | ||
484 | .val_bits = 8, | ||
485 | .reg_bits = 16, | ||
486 | .max_register = 0x40f8, | ||
487 | .reg_defaults = adau1781_reg_defaults, | ||
488 | .num_reg_defaults = ARRAY_SIZE(adau1781_reg_defaults), | ||
489 | .readable_reg = adau1781_readable_register, | ||
490 | .volatile_reg = adau17x1_volatile_register, | ||
491 | .cache_type = REGCACHE_RBTREE, | ||
492 | }; | ||
493 | EXPORT_SYMBOL_GPL(adau1781_regmap_config); | ||
494 | |||
495 | int adau1781_probe(struct device *dev, struct regmap *regmap, | ||
496 | enum adau17x1_type type, void (*switch_mode)(struct device *dev)) | ||
497 | { | ||
498 | int ret; | ||
499 | |||
500 | ret = adau17x1_probe(dev, regmap, type, switch_mode); | ||
501 | if (ret) | ||
502 | return ret; | ||
503 | |||
504 | return snd_soc_register_codec(dev, &adau1781_codec_driver, | ||
505 | &adau1781_dai_driver, 1); | ||
506 | } | ||
507 | EXPORT_SYMBOL_GPL(adau1781_probe); | ||
508 | |||
509 | MODULE_DESCRIPTION("ASoC ADAU1381/ADAU1781 driver"); | ||
510 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
511 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/adau1781.h b/sound/soc/codecs/adau1781.h new file mode 100644 index 000000000000..2b96e0a9ff2e --- /dev/null +++ b/sound/soc/codecs/adau1781.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * ADAU1381/ADAU1781 driver | ||
3 | * | ||
4 | * Copyright 2014 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2. | ||
8 | */ | ||
9 | |||
10 | #ifndef __SOUND_SOC_CODECS_ADAU1781_H__ | ||
11 | #define __SOUND_SOC_CODECS_ADAU1781_H__ | ||
12 | |||
13 | #include <linux/regmap.h> | ||
14 | #include "adau17x1.h" | ||
15 | |||
16 | struct device; | ||
17 | |||
18 | int adau1781_probe(struct device *dev, struct regmap *regmap, | ||
19 | enum adau17x1_type type, void (*switch_mode)(struct device *dev)); | ||
20 | |||
21 | extern const struct regmap_config adau1781_regmap_config; | ||
22 | |||
23 | #endif | ||
diff --git a/sound/soc/codecs/adau17x1.c b/sound/soc/codecs/adau17x1.c new file mode 100644 index 000000000000..2961fae9670a --- /dev/null +++ b/sound/soc/codecs/adau17x1.c | |||
@@ -0,0 +1,866 @@ | |||
1 | /* | ||
2 | * Common code for ADAU1X61 and ADAU1X81 codecs | ||
3 | * | ||
4 | * Copyright 2011-2014 Analog Devices Inc. | ||
5 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
6 | * | ||
7 | * Licensed under the GPL-2 or later. | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/delay.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <sound/core.h> | ||
15 | #include <sound/pcm.h> | ||
16 | #include <sound/pcm_params.h> | ||
17 | #include <sound/soc.h> | ||
18 | #include <sound/tlv.h> | ||
19 | #include <linux/gcd.h> | ||
20 | #include <linux/i2c.h> | ||
21 | #include <linux/spi/spi.h> | ||
22 | #include <linux/regmap.h> | ||
23 | |||
24 | #include "sigmadsp.h" | ||
25 | #include "adau17x1.h" | ||
26 | |||
27 | static const char * const adau17x1_capture_mixer_boost_text[] = { | ||
28 | "Normal operation", "Boost Level 1", "Boost Level 2", "Boost Level 3", | ||
29 | }; | ||
30 | |||
31 | static SOC_ENUM_SINGLE_DECL(adau17x1_capture_boost_enum, | ||
32 | ADAU17X1_REC_POWER_MGMT, 5, adau17x1_capture_mixer_boost_text); | ||
33 | |||
34 | static const char * const adau17x1_mic_bias_mode_text[] = { | ||
35 | "Normal operation", "High performance", | ||
36 | }; | ||
37 | |||
38 | static SOC_ENUM_SINGLE_DECL(adau17x1_mic_bias_mode_enum, | ||
39 | ADAU17X1_MICBIAS, 3, adau17x1_mic_bias_mode_text); | ||
40 | |||
41 | static const DECLARE_TLV_DB_MINMAX(adau17x1_digital_tlv, -9563, 0); | ||
42 | |||
43 | static const struct snd_kcontrol_new adau17x1_controls[] = { | ||
44 | SOC_DOUBLE_R_TLV("Digital Capture Volume", | ||
45 | ADAU17X1_LEFT_INPUT_DIGITAL_VOL, | ||
46 | ADAU17X1_RIGHT_INPUT_DIGITAL_VOL, | ||
47 | 0, 0xff, 1, adau17x1_digital_tlv), | ||
48 | SOC_DOUBLE_R_TLV("Digital Playback Volume", ADAU17X1_DAC_CONTROL1, | ||
49 | ADAU17X1_DAC_CONTROL2, 0, 0xff, 1, adau17x1_digital_tlv), | ||
50 | |||
51 | SOC_SINGLE("ADC High Pass Filter Switch", ADAU17X1_ADC_CONTROL, | ||
52 | 5, 1, 0), | ||
53 | SOC_SINGLE("Playback De-emphasis Switch", ADAU17X1_DAC_CONTROL0, | ||
54 | 2, 1, 0), | ||
55 | |||
56 | SOC_ENUM("Capture Boost", adau17x1_capture_boost_enum), | ||
57 | |||
58 | SOC_ENUM("Mic Bias Mode", adau17x1_mic_bias_mode_enum), | ||
59 | }; | ||
60 | |||
61 | static int adau17x1_pll_event(struct snd_soc_dapm_widget *w, | ||
62 | struct snd_kcontrol *kcontrol, int event) | ||
63 | { | ||
64 | struct adau *adau = snd_soc_codec_get_drvdata(w->codec); | ||
65 | int ret; | ||
66 | |||
67 | if (SND_SOC_DAPM_EVENT_ON(event)) { | ||
68 | adau->pll_regs[5] = 1; | ||
69 | } else { | ||
70 | adau->pll_regs[5] = 0; | ||
71 | /* Bypass the PLL when disabled, otherwise registers will become | ||
72 | * inaccessible. */ | ||
73 | regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL, | ||
74 | ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL, 0); | ||
75 | } | ||
76 | |||
77 | /* The PLL register is 6 bytes long and can only be written at once. */ | ||
78 | ret = regmap_raw_write(adau->regmap, ADAU17X1_PLL_CONTROL, | ||
79 | adau->pll_regs, ARRAY_SIZE(adau->pll_regs)); | ||
80 | |||
81 | if (SND_SOC_DAPM_EVENT_ON(event)) { | ||
82 | mdelay(5); | ||
83 | regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL, | ||
84 | ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL, | ||
85 | ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL); | ||
86 | } | ||
87 | |||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | static const char * const adau17x1_mono_stereo_text[] = { | ||
92 | "Stereo", | ||
93 | "Mono Left Channel (L+R)", | ||
94 | "Mono Right Channel (L+R)", | ||
95 | "Mono (L+R)", | ||
96 | }; | ||
97 | |||
98 | static SOC_ENUM_SINGLE_DECL(adau17x1_dac_mode_enum, | ||
99 | ADAU17X1_DAC_CONTROL0, 6, adau17x1_mono_stereo_text); | ||
100 | |||
101 | static const struct snd_kcontrol_new adau17x1_dac_mode_mux = | ||
102 | SOC_DAPM_ENUM("DAC Mono-Stereo-Mode", adau17x1_dac_mode_enum); | ||
103 | |||
104 | static const struct snd_soc_dapm_widget adau17x1_dapm_widgets[] = { | ||
105 | SND_SOC_DAPM_SUPPLY_S("PLL", 3, SND_SOC_NOPM, 0, 0, adau17x1_pll_event, | ||
106 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
107 | |||
108 | SND_SOC_DAPM_SUPPLY("AIFCLK", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
109 | |||
110 | SND_SOC_DAPM_SUPPLY("MICBIAS", ADAU17X1_MICBIAS, 0, 0, NULL, 0), | ||
111 | |||
112 | SND_SOC_DAPM_SUPPLY("Left Playback Enable", ADAU17X1_PLAY_POWER_MGMT, | ||
113 | 0, 0, NULL, 0), | ||
114 | SND_SOC_DAPM_SUPPLY("Right Playback Enable", ADAU17X1_PLAY_POWER_MGMT, | ||
115 | 1, 0, NULL, 0), | ||
116 | |||
117 | SND_SOC_DAPM_MUX("Left DAC Mode Mux", SND_SOC_NOPM, 0, 0, | ||
118 | &adau17x1_dac_mode_mux), | ||
119 | SND_SOC_DAPM_MUX("Right DAC Mode Mux", SND_SOC_NOPM, 0, 0, | ||
120 | &adau17x1_dac_mode_mux), | ||
121 | |||
122 | SND_SOC_DAPM_ADC("Left Decimator", NULL, ADAU17X1_ADC_CONTROL, 0, 0), | ||
123 | SND_SOC_DAPM_ADC("Right Decimator", NULL, ADAU17X1_ADC_CONTROL, 1, 0), | ||
124 | SND_SOC_DAPM_DAC("Left DAC", NULL, ADAU17X1_DAC_CONTROL0, 0, 0), | ||
125 | SND_SOC_DAPM_DAC("Right DAC", NULL, ADAU17X1_DAC_CONTROL0, 1, 0), | ||
126 | }; | ||
127 | |||
128 | static const struct snd_soc_dapm_route adau17x1_dapm_routes[] = { | ||
129 | { "Left Decimator", NULL, "SYSCLK" }, | ||
130 | { "Right Decimator", NULL, "SYSCLK" }, | ||
131 | { "Left DAC", NULL, "SYSCLK" }, | ||
132 | { "Right DAC", NULL, "SYSCLK" }, | ||
133 | { "Capture", NULL, "SYSCLK" }, | ||
134 | { "Playback", NULL, "SYSCLK" }, | ||
135 | |||
136 | { "Left DAC", NULL, "Left DAC Mode Mux" }, | ||
137 | { "Right DAC", NULL, "Right DAC Mode Mux" }, | ||
138 | |||
139 | { "Capture", NULL, "AIFCLK" }, | ||
140 | { "Playback", NULL, "AIFCLK" }, | ||
141 | }; | ||
142 | |||
143 | static const struct snd_soc_dapm_route adau17x1_dapm_pll_route = { | ||
144 | "SYSCLK", NULL, "PLL", | ||
145 | }; | ||
146 | |||
147 | /* | ||
148 | * The MUX register for the Capture and Playback MUXs selects either DSP as | ||
149 | * source/destination or one of the TDM slots. The TDM slot is selected via | ||
150 | * snd_soc_dai_set_tdm_slot(), so we only expose whether to go to the DSP or | ||
151 | * directly to the DAI interface with this control. | ||
152 | */ | ||
153 | static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol, | ||
154 | struct snd_ctl_elem_value *ucontrol) | ||
155 | { | ||
156 | struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); | ||
157 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
158 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | ||
159 | struct snd_soc_dapm_update update; | ||
160 | unsigned int stream = e->shift_l; | ||
161 | unsigned int val, change; | ||
162 | int reg; | ||
163 | |||
164 | if (ucontrol->value.enumerated.item[0] >= e->items) | ||
165 | return -EINVAL; | ||
166 | |||
167 | switch (ucontrol->value.enumerated.item[0]) { | ||
168 | case 0: | ||
169 | val = 0; | ||
170 | adau->dsp_bypass[stream] = false; | ||
171 | break; | ||
172 | default: | ||
173 | val = (adau->tdm_slot[stream] * 2) + 1; | ||
174 | adau->dsp_bypass[stream] = true; | ||
175 | break; | ||
176 | } | ||
177 | |||
178 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
179 | reg = ADAU17X1_SERIAL_INPUT_ROUTE; | ||
180 | else | ||
181 | reg = ADAU17X1_SERIAL_OUTPUT_ROUTE; | ||
182 | |||
183 | change = snd_soc_test_bits(codec, reg, 0xff, val); | ||
184 | if (change) { | ||
185 | update.kcontrol = kcontrol; | ||
186 | update.mask = 0xff; | ||
187 | update.reg = reg; | ||
188 | update.val = val; | ||
189 | |||
190 | snd_soc_dapm_mux_update_power(&codec->dapm, kcontrol, | ||
191 | ucontrol->value.enumerated.item[0], e, &update); | ||
192 | } | ||
193 | |||
194 | return change; | ||
195 | } | ||
196 | |||
197 | static int adau17x1_dsp_mux_enum_get(struct snd_kcontrol *kcontrol, | ||
198 | struct snd_ctl_elem_value *ucontrol) | ||
199 | { | ||
200 | struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); | ||
201 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
202 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | ||
203 | unsigned int stream = e->shift_l; | ||
204 | unsigned int reg, val; | ||
205 | int ret; | ||
206 | |||
207 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
208 | reg = ADAU17X1_SERIAL_INPUT_ROUTE; | ||
209 | else | ||
210 | reg = ADAU17X1_SERIAL_OUTPUT_ROUTE; | ||
211 | |||
212 | ret = regmap_read(adau->regmap, reg, &val); | ||
213 | if (ret) | ||
214 | return ret; | ||
215 | |||
216 | if (val != 0) | ||
217 | val = 1; | ||
218 | ucontrol->value.enumerated.item[0] = val; | ||
219 | |||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | #define DECLARE_ADAU17X1_DSP_MUX_CTRL(_name, _label, _stream, _text) \ | ||
224 | const struct snd_kcontrol_new _name = \ | ||
225 | SOC_DAPM_ENUM_EXT(_label, (const struct soc_enum)\ | ||
226 | SOC_ENUM_SINGLE(SND_SOC_NOPM, _stream, \ | ||
227 | ARRAY_SIZE(_text), _text), \ | ||
228 | adau17x1_dsp_mux_enum_get, adau17x1_dsp_mux_enum_put) | ||
229 | |||
230 | static const char * const adau17x1_dac_mux_text[] = { | ||
231 | "DSP", | ||
232 | "AIFIN", | ||
233 | }; | ||
234 | |||
235 | static const char * const adau17x1_capture_mux_text[] = { | ||
236 | "DSP", | ||
237 | "Decimator", | ||
238 | }; | ||
239 | |||
240 | static DECLARE_ADAU17X1_DSP_MUX_CTRL(adau17x1_dac_mux, "DAC Playback Mux", | ||
241 | SNDRV_PCM_STREAM_PLAYBACK, adau17x1_dac_mux_text); | ||
242 | |||
243 | static DECLARE_ADAU17X1_DSP_MUX_CTRL(adau17x1_capture_mux, "Capture Mux", | ||
244 | SNDRV_PCM_STREAM_CAPTURE, adau17x1_capture_mux_text); | ||
245 | |||
246 | static const struct snd_soc_dapm_widget adau17x1_dsp_dapm_widgets[] = { | ||
247 | SND_SOC_DAPM_PGA("DSP", ADAU17X1_DSP_RUN, 0, 0, NULL, 0), | ||
248 | SND_SOC_DAPM_SIGGEN("DSP Siggen"), | ||
249 | |||
250 | SND_SOC_DAPM_MUX("DAC Playback Mux", SND_SOC_NOPM, 0, 0, | ||
251 | &adau17x1_dac_mux), | ||
252 | SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, | ||
253 | &adau17x1_capture_mux), | ||
254 | }; | ||
255 | |||
256 | static const struct snd_soc_dapm_route adau17x1_dsp_dapm_routes[] = { | ||
257 | { "DAC Playback Mux", "DSP", "DSP" }, | ||
258 | { "DAC Playback Mux", "AIFIN", "Playback" }, | ||
259 | |||
260 | { "Left DAC Mode Mux", "Stereo", "DAC Playback Mux" }, | ||
261 | { "Left DAC Mode Mux", "Mono (L+R)", "DAC Playback Mux" }, | ||
262 | { "Left DAC Mode Mux", "Mono Left Channel (L+R)", "DAC Playback Mux" }, | ||
263 | { "Right DAC Mode Mux", "Stereo", "DAC Playback Mux" }, | ||
264 | { "Right DAC Mode Mux", "Mono (L+R)", "DAC Playback Mux" }, | ||
265 | { "Right DAC Mode Mux", "Mono Right Channel (L+R)", "DAC Playback Mux" }, | ||
266 | |||
267 | { "Capture Mux", "DSP", "DSP" }, | ||
268 | { "Capture Mux", "Decimator", "Left Decimator" }, | ||
269 | { "Capture Mux", "Decimator", "Right Decimator" }, | ||
270 | |||
271 | { "Capture", NULL, "Capture Mux" }, | ||
272 | |||
273 | { "DSP", NULL, "DSP Siggen" }, | ||
274 | |||
275 | { "DSP", NULL, "Left Decimator" }, | ||
276 | { "DSP", NULL, "Right Decimator" }, | ||
277 | }; | ||
278 | |||
279 | static const struct snd_soc_dapm_route adau17x1_no_dsp_dapm_routes[] = { | ||
280 | { "Left DAC Mode Mux", "Stereo", "Playback" }, | ||
281 | { "Left DAC Mode Mux", "Mono (L+R)", "Playback" }, | ||
282 | { "Left DAC Mode Mux", "Mono Left Channel (L+R)", "Playback" }, | ||
283 | { "Right DAC Mode Mux", "Stereo", "Playback" }, | ||
284 | { "Right DAC Mode Mux", "Mono (L+R)", "Playback" }, | ||
285 | { "Right DAC Mode Mux", "Mono Right Channel (L+R)", "Playback" }, | ||
286 | { "Capture", NULL, "Left Decimator" }, | ||
287 | { "Capture", NULL, "Right Decimator" }, | ||
288 | }; | ||
289 | |||
290 | bool adau17x1_has_dsp(struct adau *adau) | ||
291 | { | ||
292 | switch (adau->type) { | ||
293 | case ADAU1761: | ||
294 | case ADAU1381: | ||
295 | case ADAU1781: | ||
296 | return true; | ||
297 | default: | ||
298 | return false; | ||
299 | } | ||
300 | } | ||
301 | EXPORT_SYMBOL_GPL(adau17x1_has_dsp); | ||
302 | |||
303 | static int adau17x1_hw_params(struct snd_pcm_substream *substream, | ||
304 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | ||
305 | { | ||
306 | struct snd_soc_codec *codec = dai->codec; | ||
307 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
308 | unsigned int val, div, dsp_div; | ||
309 | unsigned int freq; | ||
310 | |||
311 | if (adau->clk_src == ADAU17X1_CLK_SRC_PLL) | ||
312 | freq = adau->pll_freq; | ||
313 | else | ||
314 | freq = adau->sysclk; | ||
315 | |||
316 | if (freq % params_rate(params) != 0) | ||
317 | return -EINVAL; | ||
318 | |||
319 | switch (freq / params_rate(params)) { | ||
320 | case 1024: /* fs */ | ||
321 | div = 0; | ||
322 | dsp_div = 1; | ||
323 | break; | ||
324 | case 6144: /* fs / 6 */ | ||
325 | div = 1; | ||
326 | dsp_div = 6; | ||
327 | break; | ||
328 | case 4096: /* fs / 4 */ | ||
329 | div = 2; | ||
330 | dsp_div = 5; | ||
331 | break; | ||
332 | case 3072: /* fs / 3 */ | ||
333 | div = 3; | ||
334 | dsp_div = 4; | ||
335 | break; | ||
336 | case 2048: /* fs / 2 */ | ||
337 | div = 4; | ||
338 | dsp_div = 3; | ||
339 | break; | ||
340 | case 1536: /* fs / 1.5 */ | ||
341 | div = 5; | ||
342 | dsp_div = 2; | ||
343 | break; | ||
344 | case 512: /* fs / 0.5 */ | ||
345 | div = 6; | ||
346 | dsp_div = 0; | ||
347 | break; | ||
348 | default: | ||
349 | return -EINVAL; | ||
350 | } | ||
351 | |||
352 | regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0, | ||
353 | ADAU17X1_CONVERTER0_CONVSR_MASK, div); | ||
354 | if (adau17x1_has_dsp(adau)) { | ||
355 | regmap_write(adau->regmap, ADAU17X1_SERIAL_SAMPLING_RATE, div); | ||
356 | regmap_write(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, dsp_div); | ||
357 | } | ||
358 | |||
359 | if (adau->dai_fmt != SND_SOC_DAIFMT_RIGHT_J) | ||
360 | return 0; | ||
361 | |||
362 | switch (params_format(params)) { | ||
363 | case SNDRV_PCM_FORMAT_S16_LE: | ||
364 | val = ADAU17X1_SERIAL_PORT1_DELAY16; | ||
365 | break; | ||
366 | case SNDRV_PCM_FORMAT_S24_LE: | ||
367 | val = ADAU17X1_SERIAL_PORT1_DELAY8; | ||
368 | break; | ||
369 | case SNDRV_PCM_FORMAT_S32_LE: | ||
370 | val = ADAU17X1_SERIAL_PORT1_DELAY0; | ||
371 | break; | ||
372 | default: | ||
373 | return -EINVAL; | ||
374 | } | ||
375 | |||
376 | return regmap_update_bits(adau->regmap, ADAU17X1_SERIAL_PORT1, | ||
377 | ADAU17X1_SERIAL_PORT1_DELAY_MASK, val); | ||
378 | } | ||
379 | |||
380 | static int adau17x1_set_dai_pll(struct snd_soc_dai *dai, int pll_id, | ||
381 | int source, unsigned int freq_in, unsigned int freq_out) | ||
382 | { | ||
383 | struct snd_soc_codec *codec = dai->codec; | ||
384 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
385 | unsigned int r, n, m, i, j; | ||
386 | unsigned int div; | ||
387 | int ret; | ||
388 | |||
389 | if (freq_in < 8000000 || freq_in > 27000000) | ||
390 | return -EINVAL; | ||
391 | |||
392 | if (!freq_out) { | ||
393 | r = 0; | ||
394 | n = 0; | ||
395 | m = 0; | ||
396 | div = 0; | ||
397 | } else { | ||
398 | if (freq_out % freq_in != 0) { | ||
399 | div = DIV_ROUND_UP(freq_in, 13500000); | ||
400 | freq_in /= div; | ||
401 | r = freq_out / freq_in; | ||
402 | i = freq_out % freq_in; | ||
403 | j = gcd(i, freq_in); | ||
404 | n = i / j; | ||
405 | m = freq_in / j; | ||
406 | div--; | ||
407 | } else { | ||
408 | r = freq_out / freq_in; | ||
409 | n = 0; | ||
410 | m = 0; | ||
411 | div = 0; | ||
412 | } | ||
413 | if (n > 0xffff || m > 0xffff || div > 3 || r > 8 || r < 2) | ||
414 | return -EINVAL; | ||
415 | } | ||
416 | |||
417 | adau->pll_regs[0] = m >> 8; | ||
418 | adau->pll_regs[1] = m & 0xff; | ||
419 | adau->pll_regs[2] = n >> 8; | ||
420 | adau->pll_regs[3] = n & 0xff; | ||
421 | adau->pll_regs[4] = (r << 3) | (div << 1); | ||
422 | if (m != 0) | ||
423 | adau->pll_regs[4] |= 1; /* Fractional mode */ | ||
424 | |||
425 | /* The PLL register is 6 bytes long and can only be written at once. */ | ||
426 | ret = regmap_raw_write(adau->regmap, ADAU17X1_PLL_CONTROL, | ||
427 | adau->pll_regs, ARRAY_SIZE(adau->pll_regs)); | ||
428 | if (ret) | ||
429 | return ret; | ||
430 | |||
431 | adau->pll_freq = freq_out; | ||
432 | |||
433 | return 0; | ||
434 | } | ||
435 | |||
436 | static int adau17x1_set_dai_sysclk(struct snd_soc_dai *dai, | ||
437 | int clk_id, unsigned int freq, int dir) | ||
438 | { | ||
439 | struct adau *adau = snd_soc_codec_get_drvdata(dai->codec); | ||
440 | struct snd_soc_dapm_context *dapm = &dai->codec->dapm; | ||
441 | |||
442 | switch (clk_id) { | ||
443 | case ADAU17X1_CLK_SRC_MCLK: | ||
444 | case ADAU17X1_CLK_SRC_PLL: | ||
445 | break; | ||
446 | default: | ||
447 | return -EINVAL; | ||
448 | } | ||
449 | |||
450 | adau->sysclk = freq; | ||
451 | |||
452 | if (adau->clk_src != clk_id) { | ||
453 | if (clk_id == ADAU17X1_CLK_SRC_PLL) { | ||
454 | snd_soc_dapm_add_routes(dapm, | ||
455 | &adau17x1_dapm_pll_route, 1); | ||
456 | } else { | ||
457 | snd_soc_dapm_del_routes(dapm, | ||
458 | &adau17x1_dapm_pll_route, 1); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | adau->clk_src = clk_id; | ||
463 | |||
464 | return 0; | ||
465 | } | ||
466 | |||
467 | static int adau17x1_set_dai_fmt(struct snd_soc_dai *dai, | ||
468 | unsigned int fmt) | ||
469 | { | ||
470 | struct adau *adau = snd_soc_codec_get_drvdata(dai->codec); | ||
471 | unsigned int ctrl0, ctrl1; | ||
472 | int lrclk_pol; | ||
473 | |||
474 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
475 | case SND_SOC_DAIFMT_CBM_CFM: | ||
476 | ctrl0 = ADAU17X1_SERIAL_PORT0_MASTER; | ||
477 | adau->master = true; | ||
478 | break; | ||
479 | case SND_SOC_DAIFMT_CBS_CFS: | ||
480 | ctrl0 = 0; | ||
481 | adau->master = false; | ||
482 | break; | ||
483 | default: | ||
484 | return -EINVAL; | ||
485 | } | ||
486 | |||
487 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
488 | case SND_SOC_DAIFMT_I2S: | ||
489 | lrclk_pol = 0; | ||
490 | ctrl1 = ADAU17X1_SERIAL_PORT1_DELAY1; | ||
491 | break; | ||
492 | case SND_SOC_DAIFMT_LEFT_J: | ||
493 | case SND_SOC_DAIFMT_RIGHT_J: | ||
494 | lrclk_pol = 1; | ||
495 | ctrl1 = ADAU17X1_SERIAL_PORT1_DELAY0; | ||
496 | break; | ||
497 | case SND_SOC_DAIFMT_DSP_A: | ||
498 | lrclk_pol = 1; | ||
499 | ctrl0 |= ADAU17X1_SERIAL_PORT0_PULSE_MODE; | ||
500 | ctrl1 = ADAU17X1_SERIAL_PORT1_DELAY1; | ||
501 | break; | ||
502 | case SND_SOC_DAIFMT_DSP_B: | ||
503 | lrclk_pol = 1; | ||
504 | ctrl0 |= ADAU17X1_SERIAL_PORT0_PULSE_MODE; | ||
505 | ctrl1 = ADAU17X1_SERIAL_PORT1_DELAY0; | ||
506 | break; | ||
507 | default: | ||
508 | return -EINVAL; | ||
509 | } | ||
510 | |||
511 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
512 | case SND_SOC_DAIFMT_NB_NF: | ||
513 | break; | ||
514 | case SND_SOC_DAIFMT_IB_NF: | ||
515 | ctrl0 |= ADAU17X1_SERIAL_PORT0_BCLK_POL; | ||
516 | break; | ||
517 | case SND_SOC_DAIFMT_NB_IF: | ||
518 | lrclk_pol = !lrclk_pol; | ||
519 | break; | ||
520 | case SND_SOC_DAIFMT_IB_IF: | ||
521 | ctrl0 |= ADAU17X1_SERIAL_PORT0_BCLK_POL; | ||
522 | lrclk_pol = !lrclk_pol; | ||
523 | break; | ||
524 | default: | ||
525 | return -EINVAL; | ||
526 | } | ||
527 | |||
528 | if (lrclk_pol) | ||
529 | ctrl0 |= ADAU17X1_SERIAL_PORT0_LRCLK_POL; | ||
530 | |||
531 | regmap_write(adau->regmap, ADAU17X1_SERIAL_PORT0, ctrl0); | ||
532 | regmap_write(adau->regmap, ADAU17X1_SERIAL_PORT1, ctrl1); | ||
533 | |||
534 | adau->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; | ||
535 | |||
536 | return 0; | ||
537 | } | ||
538 | |||
539 | static int adau17x1_set_dai_tdm_slot(struct snd_soc_dai *dai, | ||
540 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) | ||
541 | { | ||
542 | struct adau *adau = snd_soc_codec_get_drvdata(dai->codec); | ||
543 | unsigned int ser_ctrl0, ser_ctrl1; | ||
544 | unsigned int conv_ctrl0, conv_ctrl1; | ||
545 | |||
546 | /* I2S mode */ | ||
547 | if (slots == 0) { | ||
548 | slots = 2; | ||
549 | rx_mask = 3; | ||
550 | tx_mask = 3; | ||
551 | slot_width = 32; | ||
552 | } | ||
553 | |||
554 | switch (slots) { | ||
555 | case 2: | ||
556 | ser_ctrl0 = ADAU17X1_SERIAL_PORT0_STEREO; | ||
557 | break; | ||
558 | case 4: | ||
559 | ser_ctrl0 = ADAU17X1_SERIAL_PORT0_TDM4; | ||
560 | break; | ||
561 | case 8: | ||
562 | if (adau->type == ADAU1361) | ||
563 | return -EINVAL; | ||
564 | |||
565 | ser_ctrl0 = ADAU17X1_SERIAL_PORT0_TDM8; | ||
566 | break; | ||
567 | default: | ||
568 | return -EINVAL; | ||
569 | } | ||
570 | |||
571 | switch (slot_width * slots) { | ||
572 | case 32: | ||
573 | if (adau->type == ADAU1761) | ||
574 | return -EINVAL; | ||
575 | |||
576 | ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK32; | ||
577 | break; | ||
578 | case 64: | ||
579 | ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK64; | ||
580 | break; | ||
581 | case 48: | ||
582 | ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK48; | ||
583 | break; | ||
584 | case 128: | ||
585 | ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK128; | ||
586 | break; | ||
587 | case 256: | ||
588 | if (adau->type == ADAU1361) | ||
589 | return -EINVAL; | ||
590 | |||
591 | ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK256; | ||
592 | break; | ||
593 | default: | ||
594 | return -EINVAL; | ||
595 | } | ||
596 | |||
597 | switch (rx_mask) { | ||
598 | case 0x03: | ||
599 | conv_ctrl1 = ADAU17X1_CONVERTER1_ADC_PAIR(1); | ||
600 | adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] = 0; | ||
601 | break; | ||
602 | case 0x0c: | ||
603 | conv_ctrl1 = ADAU17X1_CONVERTER1_ADC_PAIR(2); | ||
604 | adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] = 1; | ||
605 | break; | ||
606 | case 0x30: | ||
607 | conv_ctrl1 = ADAU17X1_CONVERTER1_ADC_PAIR(3); | ||
608 | adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] = 2; | ||
609 | break; | ||
610 | case 0xc0: | ||
611 | conv_ctrl1 = ADAU17X1_CONVERTER1_ADC_PAIR(4); | ||
612 | adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] = 3; | ||
613 | break; | ||
614 | default: | ||
615 | return -EINVAL; | ||
616 | } | ||
617 | |||
618 | switch (tx_mask) { | ||
619 | case 0x03: | ||
620 | conv_ctrl0 = ADAU17X1_CONVERTER0_DAC_PAIR(1); | ||
621 | adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] = 0; | ||
622 | break; | ||
623 | case 0x0c: | ||
624 | conv_ctrl0 = ADAU17X1_CONVERTER0_DAC_PAIR(2); | ||
625 | adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] = 1; | ||
626 | break; | ||
627 | case 0x30: | ||
628 | conv_ctrl0 = ADAU17X1_CONVERTER0_DAC_PAIR(3); | ||
629 | adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] = 2; | ||
630 | break; | ||
631 | case 0xc0: | ||
632 | conv_ctrl0 = ADAU17X1_CONVERTER0_DAC_PAIR(4); | ||
633 | adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] = 3; | ||
634 | break; | ||
635 | default: | ||
636 | return -EINVAL; | ||
637 | } | ||
638 | |||
639 | regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0, | ||
640 | ADAU17X1_CONVERTER0_DAC_PAIR_MASK, conv_ctrl0); | ||
641 | regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER1, | ||
642 | ADAU17X1_CONVERTER1_ADC_PAIR_MASK, conv_ctrl1); | ||
643 | regmap_update_bits(adau->regmap, ADAU17X1_SERIAL_PORT0, | ||
644 | ADAU17X1_SERIAL_PORT0_TDM_MASK, ser_ctrl0); | ||
645 | regmap_update_bits(adau->regmap, ADAU17X1_SERIAL_PORT1, | ||
646 | ADAU17X1_SERIAL_PORT1_BCLK_MASK, ser_ctrl1); | ||
647 | |||
648 | if (!adau17x1_has_dsp(adau)) | ||
649 | return 0; | ||
650 | |||
651 | if (adau->dsp_bypass[SNDRV_PCM_STREAM_PLAYBACK]) { | ||
652 | regmap_write(adau->regmap, ADAU17X1_SERIAL_INPUT_ROUTE, | ||
653 | (adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] * 2) + 1); | ||
654 | } | ||
655 | |||
656 | if (adau->dsp_bypass[SNDRV_PCM_STREAM_CAPTURE]) { | ||
657 | regmap_write(adau->regmap, ADAU17X1_SERIAL_OUTPUT_ROUTE, | ||
658 | (adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] * 2) + 1); | ||
659 | } | ||
660 | |||
661 | return 0; | ||
662 | } | ||
663 | |||
664 | const struct snd_soc_dai_ops adau17x1_dai_ops = { | ||
665 | .hw_params = adau17x1_hw_params, | ||
666 | .set_sysclk = adau17x1_set_dai_sysclk, | ||
667 | .set_fmt = adau17x1_set_dai_fmt, | ||
668 | .set_pll = adau17x1_set_dai_pll, | ||
669 | .set_tdm_slot = adau17x1_set_dai_tdm_slot, | ||
670 | }; | ||
671 | EXPORT_SYMBOL_GPL(adau17x1_dai_ops); | ||
672 | |||
673 | int adau17x1_set_micbias_voltage(struct snd_soc_codec *codec, | ||
674 | enum adau17x1_micbias_voltage micbias) | ||
675 | { | ||
676 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
677 | |||
678 | switch (micbias) { | ||
679 | case ADAU17X1_MICBIAS_0_90_AVDD: | ||
680 | case ADAU17X1_MICBIAS_0_65_AVDD: | ||
681 | break; | ||
682 | default: | ||
683 | return -EINVAL; | ||
684 | } | ||
685 | |||
686 | return regmap_write(adau->regmap, ADAU17X1_MICBIAS, micbias << 2); | ||
687 | } | ||
688 | EXPORT_SYMBOL_GPL(adau17x1_set_micbias_voltage); | ||
689 | |||
690 | bool adau17x1_readable_register(struct device *dev, unsigned int reg) | ||
691 | { | ||
692 | switch (reg) { | ||
693 | case ADAU17X1_CLOCK_CONTROL: | ||
694 | case ADAU17X1_PLL_CONTROL: | ||
695 | case ADAU17X1_REC_POWER_MGMT: | ||
696 | case ADAU17X1_MICBIAS: | ||
697 | case ADAU17X1_SERIAL_PORT0: | ||
698 | case ADAU17X1_SERIAL_PORT1: | ||
699 | case ADAU17X1_CONVERTER0: | ||
700 | case ADAU17X1_CONVERTER1: | ||
701 | case ADAU17X1_LEFT_INPUT_DIGITAL_VOL: | ||
702 | case ADAU17X1_RIGHT_INPUT_DIGITAL_VOL: | ||
703 | case ADAU17X1_ADC_CONTROL: | ||
704 | case ADAU17X1_PLAY_POWER_MGMT: | ||
705 | case ADAU17X1_DAC_CONTROL0: | ||
706 | case ADAU17X1_DAC_CONTROL1: | ||
707 | case ADAU17X1_DAC_CONTROL2: | ||
708 | case ADAU17X1_SERIAL_PORT_PAD: | ||
709 | case ADAU17X1_CONTROL_PORT_PAD0: | ||
710 | case ADAU17X1_CONTROL_PORT_PAD1: | ||
711 | case ADAU17X1_DSP_SAMPLING_RATE: | ||
712 | case ADAU17X1_SERIAL_INPUT_ROUTE: | ||
713 | case ADAU17X1_SERIAL_OUTPUT_ROUTE: | ||
714 | case ADAU17X1_DSP_ENABLE: | ||
715 | case ADAU17X1_DSP_RUN: | ||
716 | case ADAU17X1_SERIAL_SAMPLING_RATE: | ||
717 | return true; | ||
718 | default: | ||
719 | break; | ||
720 | } | ||
721 | return false; | ||
722 | } | ||
723 | EXPORT_SYMBOL_GPL(adau17x1_readable_register); | ||
724 | |||
725 | bool adau17x1_volatile_register(struct device *dev, unsigned int reg) | ||
726 | { | ||
727 | /* SigmaDSP parameter and program memory */ | ||
728 | if (reg < 0x4000) | ||
729 | return true; | ||
730 | |||
731 | switch (reg) { | ||
732 | /* The PLL register is 6 bytes long */ | ||
733 | case ADAU17X1_PLL_CONTROL: | ||
734 | case ADAU17X1_PLL_CONTROL + 1: | ||
735 | case ADAU17X1_PLL_CONTROL + 2: | ||
736 | case ADAU17X1_PLL_CONTROL + 3: | ||
737 | case ADAU17X1_PLL_CONTROL + 4: | ||
738 | case ADAU17X1_PLL_CONTROL + 5: | ||
739 | return true; | ||
740 | default: | ||
741 | break; | ||
742 | } | ||
743 | |||
744 | return false; | ||
745 | } | ||
746 | EXPORT_SYMBOL_GPL(adau17x1_volatile_register); | ||
747 | |||
748 | int adau17x1_load_firmware(struct adau *adau, struct device *dev, | ||
749 | const char *firmware) | ||
750 | { | ||
751 | int ret; | ||
752 | int dspsr; | ||
753 | |||
754 | ret = regmap_read(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, &dspsr); | ||
755 | if (ret) | ||
756 | return ret; | ||
757 | |||
758 | regmap_write(adau->regmap, ADAU17X1_DSP_ENABLE, 1); | ||
759 | regmap_write(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, 0xf); | ||
760 | |||
761 | ret = process_sigma_firmware_regmap(dev, adau->regmap, firmware); | ||
762 | if (ret) { | ||
763 | regmap_write(adau->regmap, ADAU17X1_DSP_ENABLE, 0); | ||
764 | return ret; | ||
765 | } | ||
766 | regmap_write(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, dspsr); | ||
767 | |||
768 | return 0; | ||
769 | } | ||
770 | EXPORT_SYMBOL_GPL(adau17x1_load_firmware); | ||
771 | |||
772 | int adau17x1_add_widgets(struct snd_soc_codec *codec) | ||
773 | { | ||
774 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
775 | int ret; | ||
776 | |||
777 | ret = snd_soc_add_codec_controls(codec, adau17x1_controls, | ||
778 | ARRAY_SIZE(adau17x1_controls)); | ||
779 | if (ret) | ||
780 | return ret; | ||
781 | ret = snd_soc_dapm_new_controls(&codec->dapm, adau17x1_dapm_widgets, | ||
782 | ARRAY_SIZE(adau17x1_dapm_widgets)); | ||
783 | if (ret) | ||
784 | return ret; | ||
785 | |||
786 | if (adau17x1_has_dsp(adau)) { | ||
787 | ret = snd_soc_dapm_new_controls(&codec->dapm, | ||
788 | adau17x1_dsp_dapm_widgets, | ||
789 | ARRAY_SIZE(adau17x1_dsp_dapm_widgets)); | ||
790 | } | ||
791 | return ret; | ||
792 | } | ||
793 | EXPORT_SYMBOL_GPL(adau17x1_add_widgets); | ||
794 | |||
795 | int adau17x1_add_routes(struct snd_soc_codec *codec) | ||
796 | { | ||
797 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
798 | int ret; | ||
799 | |||
800 | ret = snd_soc_dapm_add_routes(&codec->dapm, adau17x1_dapm_routes, | ||
801 | ARRAY_SIZE(adau17x1_dapm_routes)); | ||
802 | if (ret) | ||
803 | return ret; | ||
804 | |||
805 | if (adau17x1_has_dsp(adau)) { | ||
806 | ret = snd_soc_dapm_add_routes(&codec->dapm, | ||
807 | adau17x1_dsp_dapm_routes, | ||
808 | ARRAY_SIZE(adau17x1_dsp_dapm_routes)); | ||
809 | } else { | ||
810 | ret = snd_soc_dapm_add_routes(&codec->dapm, | ||
811 | adau17x1_no_dsp_dapm_routes, | ||
812 | ARRAY_SIZE(adau17x1_no_dsp_dapm_routes)); | ||
813 | } | ||
814 | return ret; | ||
815 | } | ||
816 | EXPORT_SYMBOL_GPL(adau17x1_add_routes); | ||
817 | |||
818 | int adau17x1_suspend(struct snd_soc_codec *codec) | ||
819 | { | ||
820 | codec->driver->set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
821 | return 0; | ||
822 | } | ||
823 | EXPORT_SYMBOL_GPL(adau17x1_suspend); | ||
824 | |||
825 | int adau17x1_resume(struct snd_soc_codec *codec) | ||
826 | { | ||
827 | struct adau *adau = snd_soc_codec_get_drvdata(codec); | ||
828 | |||
829 | if (adau->switch_mode) | ||
830 | adau->switch_mode(codec->dev); | ||
831 | |||
832 | codec->driver->set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
833 | regcache_sync(adau->regmap); | ||
834 | |||
835 | return 0; | ||
836 | } | ||
837 | EXPORT_SYMBOL_GPL(adau17x1_resume); | ||
838 | |||
839 | int adau17x1_probe(struct device *dev, struct regmap *regmap, | ||
840 | enum adau17x1_type type, void (*switch_mode)(struct device *dev)) | ||
841 | { | ||
842 | struct adau *adau; | ||
843 | |||
844 | if (IS_ERR(regmap)) | ||
845 | return PTR_ERR(regmap); | ||
846 | |||
847 | adau = devm_kzalloc(dev, sizeof(*adau), GFP_KERNEL); | ||
848 | if (!adau) | ||
849 | return -ENOMEM; | ||
850 | |||
851 | adau->regmap = regmap; | ||
852 | adau->switch_mode = switch_mode; | ||
853 | adau->type = type; | ||
854 | |||
855 | dev_set_drvdata(dev, adau); | ||
856 | |||
857 | if (switch_mode) | ||
858 | switch_mode(dev); | ||
859 | |||
860 | return 0; | ||
861 | } | ||
862 | EXPORT_SYMBOL_GPL(adau17x1_probe); | ||
863 | |||
864 | MODULE_DESCRIPTION("ASoC ADAU1X61/ADAU1X81 common code"); | ||
865 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
866 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/adau17x1.h b/sound/soc/codecs/adau17x1.h new file mode 100644 index 000000000000..3ffabaf4c7a8 --- /dev/null +++ b/sound/soc/codecs/adau17x1.h | |||
@@ -0,0 +1,124 @@ | |||
1 | #ifndef __ADAU17X1_H__ | ||
2 | #define __ADAU17X1_H__ | ||
3 | |||
4 | #include <linux/regmap.h> | ||
5 | #include <linux/platform_data/adau17x1.h> | ||
6 | |||
7 | enum adau17x1_type { | ||
8 | ADAU1361, | ||
9 | ADAU1761, | ||
10 | ADAU1381, | ||
11 | ADAU1781, | ||
12 | }; | ||
13 | |||
14 | enum adau17x1_pll { | ||
15 | ADAU17X1_PLL, | ||
16 | }; | ||
17 | |||
18 | enum adau17x1_pll_src { | ||
19 | ADAU17X1_PLL_SRC_MCLK, | ||
20 | }; | ||
21 | |||
22 | enum adau17x1_clk_src { | ||
23 | ADAU17X1_CLK_SRC_MCLK, | ||
24 | ADAU17X1_CLK_SRC_PLL, | ||
25 | }; | ||
26 | |||
27 | struct adau { | ||
28 | unsigned int sysclk; | ||
29 | unsigned int pll_freq; | ||
30 | |||
31 | enum adau17x1_clk_src clk_src; | ||
32 | enum adau17x1_type type; | ||
33 | void (*switch_mode)(struct device *dev); | ||
34 | |||
35 | unsigned int dai_fmt; | ||
36 | |||
37 | uint8_t pll_regs[6]; | ||
38 | |||
39 | bool master; | ||
40 | |||
41 | unsigned int tdm_slot[2]; | ||
42 | bool dsp_bypass[2]; | ||
43 | |||
44 | struct regmap *regmap; | ||
45 | }; | ||
46 | |||
47 | int adau17x1_add_widgets(struct snd_soc_codec *codec); | ||
48 | int adau17x1_add_routes(struct snd_soc_codec *codec); | ||
49 | int adau17x1_probe(struct device *dev, struct regmap *regmap, | ||
50 | enum adau17x1_type type, void (*switch_mode)(struct device *dev)); | ||
51 | int adau17x1_set_micbias_voltage(struct snd_soc_codec *codec, | ||
52 | enum adau17x1_micbias_voltage micbias); | ||
53 | bool adau17x1_readable_register(struct device *dev, unsigned int reg); | ||
54 | bool adau17x1_volatile_register(struct device *dev, unsigned int reg); | ||
55 | int adau17x1_suspend(struct snd_soc_codec *codec); | ||
56 | int adau17x1_resume(struct snd_soc_codec *codec); | ||
57 | |||
58 | extern const struct snd_soc_dai_ops adau17x1_dai_ops; | ||
59 | |||
60 | int adau17x1_load_firmware(struct adau *adau, struct device *dev, | ||
61 | const char *firmware); | ||
62 | bool adau17x1_has_dsp(struct adau *adau); | ||
63 | |||
64 | #define ADAU17X1_CLOCK_CONTROL 0x4000 | ||
65 | #define ADAU17X1_PLL_CONTROL 0x4002 | ||
66 | #define ADAU17X1_REC_POWER_MGMT 0x4009 | ||
67 | #define ADAU17X1_MICBIAS 0x4010 | ||
68 | #define ADAU17X1_SERIAL_PORT0 0x4015 | ||
69 | #define ADAU17X1_SERIAL_PORT1 0x4016 | ||
70 | #define ADAU17X1_CONVERTER0 0x4017 | ||
71 | #define ADAU17X1_CONVERTER1 0x4018 | ||
72 | #define ADAU17X1_LEFT_INPUT_DIGITAL_VOL 0x401a | ||
73 | #define ADAU17X1_RIGHT_INPUT_DIGITAL_VOL 0x401b | ||
74 | #define ADAU17X1_ADC_CONTROL 0x4019 | ||
75 | #define ADAU17X1_PLAY_POWER_MGMT 0x4029 | ||
76 | #define ADAU17X1_DAC_CONTROL0 0x402a | ||
77 | #define ADAU17X1_DAC_CONTROL1 0x402b | ||
78 | #define ADAU17X1_DAC_CONTROL2 0x402c | ||
79 | #define ADAU17X1_SERIAL_PORT_PAD 0x402d | ||
80 | #define ADAU17X1_CONTROL_PORT_PAD0 0x402f | ||
81 | #define ADAU17X1_CONTROL_PORT_PAD1 0x4030 | ||
82 | #define ADAU17X1_DSP_SAMPLING_RATE 0x40eb | ||
83 | #define ADAU17X1_SERIAL_INPUT_ROUTE 0x40f2 | ||
84 | #define ADAU17X1_SERIAL_OUTPUT_ROUTE 0x40f3 | ||
85 | #define ADAU17X1_DSP_ENABLE 0x40f5 | ||
86 | #define ADAU17X1_DSP_RUN 0x40f6 | ||
87 | #define ADAU17X1_SERIAL_SAMPLING_RATE 0x40f8 | ||
88 | |||
89 | #define ADAU17X1_SERIAL_PORT0_BCLK_POL BIT(4) | ||
90 | #define ADAU17X1_SERIAL_PORT0_LRCLK_POL BIT(3) | ||
91 | #define ADAU17X1_SERIAL_PORT0_MASTER BIT(0) | ||
92 | |||
93 | #define ADAU17X1_SERIAL_PORT1_DELAY1 0x00 | ||
94 | #define ADAU17X1_SERIAL_PORT1_DELAY0 0x01 | ||
95 | #define ADAU17X1_SERIAL_PORT1_DELAY8 0x02 | ||
96 | #define ADAU17X1_SERIAL_PORT1_DELAY16 0x03 | ||
97 | #define ADAU17X1_SERIAL_PORT1_DELAY_MASK 0x03 | ||
98 | |||
99 | #define ADAU17X1_CLOCK_CONTROL_INFREQ_MASK 0x6 | ||
100 | #define ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL BIT(3) | ||
101 | #define ADAU17X1_CLOCK_CONTROL_SYSCLK_EN BIT(0) | ||
102 | |||
103 | #define ADAU17X1_SERIAL_PORT1_BCLK32 (0x0 << 5) | ||
104 | #define ADAU17X1_SERIAL_PORT1_BCLK48 (0x1 << 5) | ||
105 | #define ADAU17X1_SERIAL_PORT1_BCLK64 (0x2 << 5) | ||
106 | #define ADAU17X1_SERIAL_PORT1_BCLK128 (0x3 << 5) | ||
107 | #define ADAU17X1_SERIAL_PORT1_BCLK256 (0x4 << 5) | ||
108 | #define ADAU17X1_SERIAL_PORT1_BCLK_MASK (0x7 << 5) | ||
109 | |||
110 | #define ADAU17X1_SERIAL_PORT0_STEREO (0x0 << 1) | ||
111 | #define ADAU17X1_SERIAL_PORT0_TDM4 (0x1 << 1) | ||
112 | #define ADAU17X1_SERIAL_PORT0_TDM8 (0x2 << 1) | ||
113 | #define ADAU17X1_SERIAL_PORT0_TDM_MASK (0x3 << 1) | ||
114 | #define ADAU17X1_SERIAL_PORT0_PULSE_MODE BIT(5) | ||
115 | |||
116 | #define ADAU17X1_CONVERTER0_DAC_PAIR(x) (((x) - 1) << 5) | ||
117 | #define ADAU17X1_CONVERTER0_DAC_PAIR_MASK (0x3 << 5) | ||
118 | #define ADAU17X1_CONVERTER1_ADC_PAIR(x) ((x) - 1) | ||
119 | #define ADAU17X1_CONVERTER1_ADC_PAIR_MASK 0x3 | ||
120 | |||
121 | #define ADAU17X1_CONVERTER0_CONVSR_MASK 0x7 | ||
122 | |||
123 | |||
124 | #endif | ||
diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c index 5bb134b4ab9b..fdc4bd27b0df 100644 --- a/sound/soc/codecs/cs42l56.c +++ b/sound/soc/codecs/cs42l56.c | |||
@@ -763,14 +763,14 @@ static int cs42l56_set_sysclk(struct snd_soc_dai *codec_dai, | |||
763 | case CS42L56_MCLK_11P2896MHZ: | 763 | case CS42L56_MCLK_11P2896MHZ: |
764 | case CS42L56_MCLK_12MHZ: | 764 | case CS42L56_MCLK_12MHZ: |
765 | case CS42L56_MCLK_12P288MHZ: | 765 | case CS42L56_MCLK_12P288MHZ: |
766 | cs42l56->mclk_div2 = 1; | 766 | cs42l56->mclk_div2 = CS42L56_MCLK_DIV2; |
767 | cs42l56->mclk_prediv = 0; | 767 | cs42l56->mclk_prediv = 0; |
768 | break; | 768 | break; |
769 | case CS42L56_MCLK_22P5792MHZ: | 769 | case CS42L56_MCLK_22P5792MHZ: |
770 | case CS42L56_MCLK_24MHZ: | 770 | case CS42L56_MCLK_24MHZ: |
771 | case CS42L56_MCLK_24P576MHZ: | 771 | case CS42L56_MCLK_24P576MHZ: |
772 | cs42l56->mclk_div2 = 1; | 772 | cs42l56->mclk_div2 = CS42L56_MCLK_DIV2; |
773 | cs42l56->mclk_prediv = 1; | 773 | cs42l56->mclk_prediv = CS42L56_MCLK_PREDIV; |
774 | break; | 774 | break; |
775 | default: | 775 | default: |
776 | return -EINVAL; | 776 | return -EINVAL; |
@@ -844,57 +844,49 @@ static int cs42l56_digital_mute(struct snd_soc_dai *dai, int mute) | |||
844 | /* Hit the DSP Mixer first */ | 844 | /* Hit the DSP Mixer first */ |
845 | snd_soc_update_bits(codec, CS42L56_DSP_MUTE_CTL, | 845 | snd_soc_update_bits(codec, CS42L56_DSP_MUTE_CTL, |
846 | CS42L56_ADCAMIX_MUTE_MASK | | 846 | CS42L56_ADCAMIX_MUTE_MASK | |
847 | CS42L56_ADCBMIX_MUTE_MASK | | 847 | CS42L56_ADCBMIX_MUTE_MASK | |
848 | CS42L56_PCMAMIX_MUTE_MASK | | 848 | CS42L56_PCMAMIX_MUTE_MASK | |
849 | CS42L56_PCMBMIX_MUTE_MASK | | 849 | CS42L56_PCMBMIX_MUTE_MASK | |
850 | CS42L56_MSTB_MUTE_MASK | | 850 | CS42L56_MSTB_MUTE_MASK | |
851 | CS42L56_MSTA_MUTE_MASK, | 851 | CS42L56_MSTA_MUTE_MASK, |
852 | CS42L56_MUTE); | 852 | CS42L56_MUTE_ALL); |
853 | /* Mute ADC's */ | 853 | /* Mute ADC's */ |
854 | snd_soc_update_bits(codec, CS42L56_MISC_ADC_CTL, | 854 | snd_soc_update_bits(codec, CS42L56_MISC_ADC_CTL, |
855 | CS42L56_ADCA_MUTE_MASK | | 855 | CS42L56_ADCA_MUTE_MASK | |
856 | CS42L56_ADCB_MUTE_MASK, | 856 | CS42L56_ADCB_MUTE_MASK, |
857 | CS42L56_MUTE); | 857 | CS42L56_MUTE_ALL); |
858 | /* HP And LO */ | 858 | /* HP And LO */ |
859 | snd_soc_update_bits(codec, CS42L56_HPA_VOLUME, | 859 | snd_soc_update_bits(codec, CS42L56_HPA_VOLUME, |
860 | CS42L56_HP_MUTE_MASK, | 860 | CS42L56_HP_MUTE_MASK, CS42L56_MUTE_ALL); |
861 | CS42L56_MUTE); | ||
862 | snd_soc_update_bits(codec, CS42L56_HPB_VOLUME, | 861 | snd_soc_update_bits(codec, CS42L56_HPB_VOLUME, |
863 | CS42L56_HP_MUTE_MASK, | 862 | CS42L56_HP_MUTE_MASK, CS42L56_MUTE_ALL); |
864 | CS42L56_MUTE); | ||
865 | snd_soc_update_bits(codec, CS42L56_LOA_VOLUME, | 863 | snd_soc_update_bits(codec, CS42L56_LOA_VOLUME, |
866 | CS42L56_LO_MUTE_MASK, | 864 | CS42L56_LO_MUTE_MASK, CS42L56_MUTE_ALL); |
867 | CS42L56_MUTE); | ||
868 | snd_soc_update_bits(codec, CS42L56_LOB_VOLUME, | 865 | snd_soc_update_bits(codec, CS42L56_LOB_VOLUME, |
869 | CS42L56_LO_MUTE_MASK, | 866 | CS42L56_LO_MUTE_MASK, CS42L56_MUTE_ALL); |
870 | CS42L56_MUTE); | ||
871 | |||
872 | |||
873 | } else { | 867 | } else { |
874 | snd_soc_update_bits(codec, CS42L56_DSP_MUTE_CTL, | 868 | snd_soc_update_bits(codec, CS42L56_DSP_MUTE_CTL, |
875 | CS42L56_ADCAMIX_MUTE_MASK | | 869 | CS42L56_ADCAMIX_MUTE_MASK | |
876 | CS42L56_ADCBMIX_MUTE_MASK | | 870 | CS42L56_ADCBMIX_MUTE_MASK | |
877 | CS42L56_PCMAMIX_MUTE_MASK | | 871 | CS42L56_PCMAMIX_MUTE_MASK | |
878 | CS42L56_PCMBMIX_MUTE_MASK | | 872 | CS42L56_PCMBMIX_MUTE_MASK | |
879 | CS42L56_MSTB_MUTE_MASK | | 873 | CS42L56_MSTB_MUTE_MASK | |
880 | CS42L56_MSTA_MUTE_MASK, | 874 | CS42L56_MSTA_MUTE_MASK, |
881 | CS42L56_UNMUTE); | 875 | CS42L56_UNMUTE); |
876 | |||
882 | snd_soc_update_bits(codec, CS42L56_MISC_ADC_CTL, | 877 | snd_soc_update_bits(codec, CS42L56_MISC_ADC_CTL, |
883 | CS42L56_ADCA_MUTE_MASK | | 878 | CS42L56_ADCA_MUTE_MASK | |
884 | CS42L56_ADCB_MUTE_MASK, | 879 | CS42L56_ADCB_MUTE_MASK, |
885 | CS42L56_UNMUTE); | 880 | CS42L56_UNMUTE); |
881 | |||
886 | snd_soc_update_bits(codec, CS42L56_HPA_VOLUME, | 882 | snd_soc_update_bits(codec, CS42L56_HPA_VOLUME, |
887 | CS42L56_HP_MUTE_MASK, | 883 | CS42L56_HP_MUTE_MASK, CS42L56_UNMUTE); |
888 | CS42L56_UNMUTE); | ||
889 | snd_soc_update_bits(codec, CS42L56_HPB_VOLUME, | 884 | snd_soc_update_bits(codec, CS42L56_HPB_VOLUME, |
890 | CS42L56_HP_MUTE_MASK, | 885 | CS42L56_HP_MUTE_MASK, CS42L56_UNMUTE); |
891 | CS42L56_UNMUTE); | ||
892 | snd_soc_update_bits(codec, CS42L56_LOA_VOLUME, | 886 | snd_soc_update_bits(codec, CS42L56_LOA_VOLUME, |
893 | CS42L56_LO_MUTE_MASK, | 887 | CS42L56_LO_MUTE_MASK, CS42L56_UNMUTE); |
894 | CS42L56_UNMUTE); | ||
895 | snd_soc_update_bits(codec, CS42L56_LOB_VOLUME, | 888 | snd_soc_update_bits(codec, CS42L56_LOB_VOLUME, |
896 | CS42L56_LO_MUTE_MASK, | 889 | CS42L56_LO_MUTE_MASK, CS42L56_UNMUTE); |
897 | CS42L56_UNMUTE); | ||
898 | } | 890 | } |
899 | return 0; | 891 | return 0; |
900 | } | 892 | } |
diff --git a/sound/soc/codecs/cs42l56.h b/sound/soc/codecs/cs42l56.h index ad2b50a90b16..5025ec9be9b2 100644 --- a/sound/soc/codecs/cs42l56.h +++ b/sound/soc/codecs/cs42l56.h | |||
@@ -80,19 +80,21 @@ | |||
80 | #define CS42L56_PDN_HPB_MASK 0xc0 | 80 | #define CS42L56_PDN_HPB_MASK 0xc0 |
81 | 81 | ||
82 | /* serial port and clk masks */ | 82 | /* serial port and clk masks */ |
83 | #define CS42L56_MASTER_MODE 1 | 83 | #define CS42L56_MASTER_MODE 0x40 |
84 | #define CS42L56_SLAVE_MODE 0 | 84 | #define CS42L56_SLAVE_MODE 0 |
85 | #define CS42L56_MS_MODE_MASK 0x40 | 85 | #define CS42L56_MS_MODE_MASK 0x40 |
86 | #define CS42L56_SCLK_INV 1 | 86 | #define CS42L56_SCLK_INV 0x20 |
87 | #define CS42L56_SCLK_INV_MASK 0x20 | 87 | #define CS42L56_SCLK_INV_MASK 0x20 |
88 | #define CS42L56_SCLK_MCLK_MASK 0x18 | 88 | #define CS42L56_SCLK_MCLK_MASK 0x18 |
89 | #define CS42L56_MCLK_PREDIV 0x04 | ||
89 | #define CS42L56_MCLK_PREDIV_MASK 0x04 | 90 | #define CS42L56_MCLK_PREDIV_MASK 0x04 |
91 | #define CS42L56_MCLK_DIV2 0x02 | ||
90 | #define CS42L56_MCLK_DIV2_MASK 0x02 | 92 | #define CS42L56_MCLK_DIV2_MASK 0x02 |
91 | #define CS42L56_MCLK_DIS_MASK 0x01 | 93 | #define CS42L56_MCLK_DIS_MASK 0x01 |
92 | #define CS42L56_CLK_AUTO_MASK 0x20 | 94 | #define CS42L56_CLK_AUTO_MASK 0x20 |
93 | #define CS42L56_CLK_RATIO_MASK 0x1f | 95 | #define CS42L56_CLK_RATIO_MASK 0x1f |
94 | #define CS42L56_DIG_FMT_I2S 0 | 96 | #define CS42L56_DIG_FMT_I2S 0 |
95 | #define CS42L56_DIG_FMT_LEFT_J 1 | 97 | #define CS42L56_DIG_FMT_LEFT_J 0x08 |
96 | #define CS42L56_DIG_FMT_MASK 0x08 | 98 | #define CS42L56_DIG_FMT_MASK 0x08 |
97 | 99 | ||
98 | /* Class H and misc ctl masks */ | 100 | /* Class H and misc ctl masks */ |
@@ -116,7 +118,7 @@ | |||
116 | #define CS42L56_DEEMPH_MASK 0x40 | 118 | #define CS42L56_DEEMPH_MASK 0x40 |
117 | #define CS42L56_PLYBCK_GANG_MASK 0x10 | 119 | #define CS42L56_PLYBCK_GANG_MASK 0x10 |
118 | #define CS42L56_PCM_INV_MASK 0x0c | 120 | #define CS42L56_PCM_INV_MASK 0x0c |
119 | #define CS42L56_MUTE 1 | 121 | #define CS42L56_MUTE_ALL 0xff |
120 | #define CS42L56_UNMUTE 0 | 122 | #define CS42L56_UNMUTE 0 |
121 | #define CS42L56_ADCAMIX_MUTE_MASK 0x40 | 123 | #define CS42L56_ADCAMIX_MUTE_MASK 0x40 |
122 | #define CS42L56_ADCBMIX_MUTE_MASK 0x80 | 124 | #define CS42L56_ADCBMIX_MUTE_MASK 0x80 |
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 9b76f5a45115..f5fccc7a8e89 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/regmap.h> | 17 | #include <linux/regmap.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
20 | #include <linux/clk.h> | ||
20 | #include <sound/jack.h> | 21 | #include <sound/jack.h> |
21 | #include <sound/pcm.h> | 22 | #include <sound/pcm.h> |
22 | #include <sound/pcm_params.h> | 23 | #include <sound/pcm_params.h> |
@@ -1547,19 +1548,19 @@ static const int lrclk_rates[] = { | |||
1547 | }; | 1548 | }; |
1548 | 1549 | ||
1549 | static const int user_pclk_rates[] = { | 1550 | static const int user_pclk_rates[] = { |
1550 | 13000000, 13000000 | 1551 | 13000000, 13000000, 19200000, 19200000, |
1551 | }; | 1552 | }; |
1552 | 1553 | ||
1553 | static const int user_lrclk_rates[] = { | 1554 | static const int user_lrclk_rates[] = { |
1554 | 44100, 48000 | 1555 | 44100, 48000, 44100, 48000, |
1555 | }; | 1556 | }; |
1556 | 1557 | ||
1557 | static const unsigned long long ni_value[] = { | 1558 | static const unsigned long long ni_value[] = { |
1558 | 3528, 768 | 1559 | 3528, 768, 441, 8 |
1559 | }; | 1560 | }; |
1560 | 1561 | ||
1561 | static const unsigned long long mi_value[] = { | 1562 | static const unsigned long long mi_value[] = { |
1562 | 8125, 1625 | 1563 | 8125, 1625, 1500, 25 |
1563 | }; | 1564 | }; |
1564 | 1565 | ||
1565 | static void max98090_configure_bclk(struct snd_soc_codec *codec) | 1566 | static void max98090_configure_bclk(struct snd_soc_codec *codec) |
@@ -1800,6 +1801,19 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec, | |||
1800 | break; | 1801 | break; |
1801 | 1802 | ||
1802 | case SND_SOC_BIAS_PREPARE: | 1803 | case SND_SOC_BIAS_PREPARE: |
1804 | /* | ||
1805 | * SND_SOC_BIAS_PREPARE is called while preparing for a | ||
1806 | * transition to ON or away from ON. If current bias_level | ||
1807 | * is SND_SOC_BIAS_ON, then it is preparing for a transition | ||
1808 | * away from ON. Disable the clock in that case, otherwise | ||
1809 | * enable it. | ||
1810 | */ | ||
1811 | if (!IS_ERR(max98090->mclk)) { | ||
1812 | if (codec->dapm.bias_level == SND_SOC_BIAS_ON) | ||
1813 | clk_disable_unprepare(max98090->mclk); | ||
1814 | else | ||
1815 | clk_prepare_enable(max98090->mclk); | ||
1816 | } | ||
1803 | break; | 1817 | break; |
1804 | 1818 | ||
1805 | case SND_SOC_BIAS_STANDBY: | 1819 | case SND_SOC_BIAS_STANDBY: |
@@ -1929,6 +1943,11 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai, | |||
1929 | if (freq == max98090->sysclk) | 1943 | if (freq == max98090->sysclk) |
1930 | return 0; | 1944 | return 0; |
1931 | 1945 | ||
1946 | if (!IS_ERR(max98090->mclk)) { | ||
1947 | freq = clk_round_rate(max98090->mclk, freq); | ||
1948 | clk_set_rate(max98090->mclk, freq); | ||
1949 | } | ||
1950 | |||
1932 | /* Setup clocks for slave mode, and using the PLL | 1951 | /* Setup clocks for slave mode, and using the PLL |
1933 | * PSCLK = 0x01 (when master clk is 10MHz to 20MHz) | 1952 | * PSCLK = 0x01 (when master clk is 10MHz to 20MHz) |
1934 | * 0x02 (when master clk is 20MHz to 40MHz).. | 1953 | * 0x02 (when master clk is 20MHz to 40MHz).. |
@@ -2213,6 +2232,10 @@ static int max98090_probe(struct snd_soc_codec *codec) | |||
2213 | 2232 | ||
2214 | dev_dbg(codec->dev, "max98090_probe\n"); | 2233 | dev_dbg(codec->dev, "max98090_probe\n"); |
2215 | 2234 | ||
2235 | max98090->mclk = devm_clk_get(codec->dev, "mclk"); | ||
2236 | if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER) | ||
2237 | return -EPROBE_DEFER; | ||
2238 | |||
2216 | max98090->codec = codec; | 2239 | max98090->codec = codec; |
2217 | 2240 | ||
2218 | /* Reset the codec, the DSP core, and disable all interrupts */ | 2241 | /* Reset the codec, the DSP core, and disable all interrupts */ |
diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h index 5a3c8d0613cb..cf1b6062ba8c 100644 --- a/sound/soc/codecs/max98090.h +++ b/sound/soc/codecs/max98090.h | |||
@@ -1524,6 +1524,7 @@ struct max98090_priv { | |||
1524 | struct snd_soc_codec *codec; | 1524 | struct snd_soc_codec *codec; |
1525 | enum max98090_type devtype; | 1525 | enum max98090_type devtype; |
1526 | struct max98090_pdata *pdata; | 1526 | struct max98090_pdata *pdata; |
1527 | struct clk *mclk; | ||
1527 | unsigned int sysclk; | 1528 | unsigned int sysclk; |
1528 | unsigned int bclk; | 1529 | unsigned int bclk; |
1529 | unsigned int lrclk; | 1530 | unsigned int lrclk; |
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index d6c1e4c19a5a..89ec00424880 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/pm.h> | 16 | #include <linux/pm.h> |
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/clk.h> | ||
18 | #include <sound/core.h> | 19 | #include <sound/core.h> |
19 | #include <sound/pcm.h> | 20 | #include <sound/pcm.h> |
20 | #include <sound/pcm_params.h> | 21 | #include <sound/pcm_params.h> |
@@ -42,6 +43,7 @@ struct max98095_priv { | |||
42 | struct regmap *regmap; | 43 | struct regmap *regmap; |
43 | enum max98095_type devtype; | 44 | enum max98095_type devtype; |
44 | struct max98095_pdata *pdata; | 45 | struct max98095_pdata *pdata; |
46 | struct clk *mclk; | ||
45 | unsigned int sysclk; | 47 | unsigned int sysclk; |
46 | struct max98095_cdata dai[3]; | 48 | struct max98095_cdata dai[3]; |
47 | const char **eq_texts; | 49 | const char **eq_texts; |
@@ -1395,6 +1397,11 @@ static int max98095_dai_set_sysclk(struct snd_soc_dai *dai, | |||
1395 | if (freq == max98095->sysclk) | 1397 | if (freq == max98095->sysclk) |
1396 | return 0; | 1398 | return 0; |
1397 | 1399 | ||
1400 | if (!IS_ERR(max98095->mclk)) { | ||
1401 | freq = clk_round_rate(max98095->mclk, freq); | ||
1402 | clk_set_rate(max98095->mclk, freq); | ||
1403 | } | ||
1404 | |||
1398 | /* Setup clocks for slave mode, and using the PLL | 1405 | /* Setup clocks for slave mode, and using the PLL |
1399 | * PSCLK = 0x01 (when master clk is 10MHz to 20MHz) | 1406 | * PSCLK = 0x01 (when master clk is 10MHz to 20MHz) |
1400 | * 0x02 (when master clk is 20MHz to 40MHz).. | 1407 | * 0x02 (when master clk is 20MHz to 40MHz).. |
@@ -1634,6 +1641,19 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec, | |||
1634 | break; | 1641 | break; |
1635 | 1642 | ||
1636 | case SND_SOC_BIAS_PREPARE: | 1643 | case SND_SOC_BIAS_PREPARE: |
1644 | /* | ||
1645 | * SND_SOC_BIAS_PREPARE is called while preparing for a | ||
1646 | * transition to ON or away from ON. If current bias_level | ||
1647 | * is SND_SOC_BIAS_ON, then it is preparing for a transition | ||
1648 | * away from ON. Disable the clock in that case, otherwise | ||
1649 | * enable it. | ||
1650 | */ | ||
1651 | if (!IS_ERR(max98095->mclk)) { | ||
1652 | if (codec->dapm.bias_level == SND_SOC_BIAS_ON) | ||
1653 | clk_disable_unprepare(max98095->mclk); | ||
1654 | else | ||
1655 | clk_prepare_enable(max98095->mclk); | ||
1656 | } | ||
1637 | break; | 1657 | break; |
1638 | 1658 | ||
1639 | case SND_SOC_BIAS_STANDBY: | 1659 | case SND_SOC_BIAS_STANDBY: |
@@ -2238,6 +2258,10 @@ static int max98095_probe(struct snd_soc_codec *codec) | |||
2238 | struct i2c_client *client; | 2258 | struct i2c_client *client; |
2239 | int ret = 0; | 2259 | int ret = 0; |
2240 | 2260 | ||
2261 | max98095->mclk = devm_clk_get(codec->dev, "mclk"); | ||
2262 | if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER) | ||
2263 | return -EPROBE_DEFER; | ||
2264 | |||
2241 | /* reset the codec, the DSP core, and disable all interrupts */ | 2265 | /* reset the codec, the DSP core, and disable all interrupts */ |
2242 | max98095_reset(codec); | 2266 | max98095_reset(codec); |
2243 | 2267 | ||
diff --git a/sound/soc/codecs/rl6231.c b/sound/soc/codecs/rl6231.c new file mode 100644 index 000000000000..7b82fbe0d14c --- /dev/null +++ b/sound/soc/codecs/rl6231.c | |||
@@ -0,0 +1,152 @@ | |||
1 | /* | ||
2 | * rl6231.c - RL6231 class device shared support | ||
3 | * | ||
4 | * Copyright 2014 Realtek Semiconductor Corp. | ||
5 | * | ||
6 | * Author: Oder Chiou <oder_chiou@realtek.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/moduleparam.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/pm.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/regmap.h> | ||
21 | #include <linux/of.h> | ||
22 | #include <linux/of_gpio.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/spi/spi.h> | ||
25 | #include <linux/acpi.h> | ||
26 | #include <sound/core.h> | ||
27 | #include <sound/pcm.h> | ||
28 | #include <sound/pcm_params.h> | ||
29 | #include <sound/soc.h> | ||
30 | #include <sound/soc-dapm.h> | ||
31 | #include <sound/initval.h> | ||
32 | #include <sound/tlv.h> | ||
33 | |||
34 | #include "rl6231.h" | ||
35 | |||
36 | /** | ||
37 | * rl6231_calc_dmic_clk - Calculate the parameter of dmic. | ||
38 | * | ||
39 | * @rate: base clock rate. | ||
40 | * | ||
41 | * Choose dmic clock between 1MHz and 3MHz. | ||
42 | * It is better for clock to approximate 3MHz. | ||
43 | */ | ||
44 | int rl6231_calc_dmic_clk(int rate) | ||
45 | { | ||
46 | int div[] = {2, 3, 4, 6, 8, 12}, idx = -EINVAL; | ||
47 | int i, red, bound, temp; | ||
48 | |||
49 | red = 3000000 * 12; | ||
50 | for (i = 0; i < ARRAY_SIZE(div); i++) { | ||
51 | bound = div[i] * 3000000; | ||
52 | if (rate > bound) | ||
53 | continue; | ||
54 | temp = bound - rate; | ||
55 | if (temp < red) { | ||
56 | red = temp; | ||
57 | idx = i; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | return idx; | ||
62 | } | ||
63 | EXPORT_SYMBOL_GPL(rl6231_calc_dmic_clk); | ||
64 | |||
65 | /** | ||
66 | * rl6231_pll_calc - Calcualte PLL M/N/K code. | ||
67 | * @freq_in: external clock provided to codec. | ||
68 | * @freq_out: target clock which codec works on. | ||
69 | * @pll_code: Pointer to structure with M, N, K and bypass flag. | ||
70 | * | ||
71 | * Calcualte M/N/K code to configure PLL for codec. | ||
72 | * | ||
73 | * Returns 0 for success or negative error code. | ||
74 | */ | ||
75 | int rl6231_pll_calc(const unsigned int freq_in, | ||
76 | const unsigned int freq_out, struct rl6231_pll_code *pll_code) | ||
77 | { | ||
78 | int max_n = RL6231_PLL_N_MAX, max_m = RL6231_PLL_M_MAX; | ||
79 | int k, red, n_t, pll_out, in_t, out_t; | ||
80 | int n = 0, m = 0, m_t = 0; | ||
81 | int red_t = abs(freq_out - freq_in); | ||
82 | bool bypass = false; | ||
83 | |||
84 | if (RL6231_PLL_INP_MAX < freq_in || RL6231_PLL_INP_MIN > freq_in) | ||
85 | return -EINVAL; | ||
86 | |||
87 | k = 100000000 / freq_out - 2; | ||
88 | if (k > RL6231_PLL_K_MAX) | ||
89 | k = RL6231_PLL_K_MAX; | ||
90 | for (n_t = 0; n_t <= max_n; n_t++) { | ||
91 | in_t = freq_in / (k + 2); | ||
92 | pll_out = freq_out / (n_t + 2); | ||
93 | if (in_t < 0) | ||
94 | continue; | ||
95 | if (in_t == pll_out) { | ||
96 | bypass = true; | ||
97 | n = n_t; | ||
98 | goto code_find; | ||
99 | } | ||
100 | red = abs(in_t - pll_out); | ||
101 | if (red < red_t) { | ||
102 | bypass = true; | ||
103 | n = n_t; | ||
104 | m = m_t; | ||
105 | if (red == 0) | ||
106 | goto code_find; | ||
107 | red_t = red; | ||
108 | } | ||
109 | for (m_t = 0; m_t <= max_m; m_t++) { | ||
110 | out_t = in_t / (m_t + 2); | ||
111 | red = abs(out_t - pll_out); | ||
112 | if (red < red_t) { | ||
113 | bypass = false; | ||
114 | n = n_t; | ||
115 | m = m_t; | ||
116 | if (red == 0) | ||
117 | goto code_find; | ||
118 | red_t = red; | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | pr_debug("Only get approximation about PLL\n"); | ||
123 | |||
124 | code_find: | ||
125 | |||
126 | pll_code->m_bp = bypass; | ||
127 | pll_code->m_code = m; | ||
128 | pll_code->n_code = n; | ||
129 | pll_code->k_code = k; | ||
130 | return 0; | ||
131 | } | ||
132 | EXPORT_SYMBOL_GPL(rl6231_pll_calc); | ||
133 | |||
134 | int rl6231_get_clk_info(int sclk, int rate) | ||
135 | { | ||
136 | int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16}; | ||
137 | |||
138 | if (sclk <= 0 || rate <= 0) | ||
139 | return -EINVAL; | ||
140 | |||
141 | rate = rate << 8; | ||
142 | for (i = 0; i < ARRAY_SIZE(pd); i++) | ||
143 | if (sclk == rate * pd[i]) | ||
144 | return i; | ||
145 | |||
146 | return -EINVAL; | ||
147 | } | ||
148 | EXPORT_SYMBOL_GPL(rl6231_get_clk_info); | ||
149 | |||
150 | MODULE_DESCRIPTION("RL6231 class device shared support"); | ||
151 | MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>"); | ||
152 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/codecs/rl6231.h b/sound/soc/codecs/rl6231.h new file mode 100644 index 000000000000..0f7b057ed736 --- /dev/null +++ b/sound/soc/codecs/rl6231.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * rl6231.h - RL6231 class device shared support | ||
3 | * | ||
4 | * Copyright 2014 Realtek Semiconductor Corp. | ||
5 | * | ||
6 | * Author: Oder Chiou <oder_chiou@realtek.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __RL6231_H__ | ||
14 | #define __RL6231_H__ | ||
15 | |||
16 | #define RL6231_PLL_INP_MAX 40000000 | ||
17 | #define RL6231_PLL_INP_MIN 256000 | ||
18 | #define RL6231_PLL_N_MAX 0x1ff | ||
19 | #define RL6231_PLL_K_MAX 0x1f | ||
20 | #define RL6231_PLL_M_MAX 0xf | ||
21 | |||
22 | struct rl6231_pll_code { | ||
23 | bool m_bp; /* Indicates bypass m code or not. */ | ||
24 | int m_code; | ||
25 | int n_code; | ||
26 | int k_code; | ||
27 | }; | ||
28 | |||
29 | int rl6231_calc_dmic_clk(int rate); | ||
30 | int rl6231_pll_calc(const unsigned int freq_in, | ||
31 | const unsigned int freq_out, struct rl6231_pll_code *pll_code); | ||
32 | int rl6231_get_clk_info(int sclk, int rate); | ||
33 | |||
34 | #endif /* __RL6231_H__ */ | ||
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 9e0d48f98927..de80e89b5fd8 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <sound/initval.h> | 31 | #include <sound/initval.h> |
32 | #include <sound/tlv.h> | 32 | #include <sound/tlv.h> |
33 | 33 | ||
34 | #include "rl6231.h" | ||
34 | #include "rt5640.h" | 35 | #include "rt5640.h" |
35 | 36 | ||
36 | #define RT5640_DEVICE_ID 0x6231 | 37 | #define RT5640_DEVICE_ID 0x6231 |
@@ -453,30 +454,16 @@ static const struct snd_kcontrol_new rt5640_specific_snd_controls[] = { | |||
453 | * @kcontrol: The kcontrol of this widget. | 454 | * @kcontrol: The kcontrol of this widget. |
454 | * @event: Event id. | 455 | * @event: Event id. |
455 | * | 456 | * |
456 | * Choose dmic clock between 1MHz and 3MHz. | ||
457 | * It is better for clock to approximate 3MHz. | ||
458 | */ | 457 | */ |
459 | static int set_dmic_clk(struct snd_soc_dapm_widget *w, | 458 | static int set_dmic_clk(struct snd_soc_dapm_widget *w, |
460 | struct snd_kcontrol *kcontrol, int event) | 459 | struct snd_kcontrol *kcontrol, int event) |
461 | { | 460 | { |
462 | struct snd_soc_codec *codec = w->codec; | 461 | struct snd_soc_codec *codec = w->codec; |
463 | struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); | 462 | struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); |
464 | int div[] = {2, 3, 4, 6, 8, 12}; | 463 | int idx = -EINVAL; |
465 | int idx = -EINVAL, i; | 464 | |
466 | int rate, red, bound, temp; | 465 | idx = rl6231_calc_dmic_clk(rt5640->sysclk); |
467 | 466 | ||
468 | rate = rt5640->sysclk; | ||
469 | red = 3000000 * 12; | ||
470 | for (i = 0; i < ARRAY_SIZE(div); i++) { | ||
471 | bound = div[i] * 3000000; | ||
472 | if (rate > bound) | ||
473 | continue; | ||
474 | temp = bound - rate; | ||
475 | if (temp < red) { | ||
476 | red = temp; | ||
477 | idx = i; | ||
478 | } | ||
479 | } | ||
480 | if (idx < 0) | 467 | if (idx < 0) |
481 | dev_err(codec->dev, "Failed to set DMIC clock\n"); | 468 | dev_err(codec->dev, "Failed to set DMIC clock\n"); |
482 | else | 469 | else |
@@ -1639,21 +1626,6 @@ static int get_sdp_info(struct snd_soc_codec *codec, int dai_id) | |||
1639 | return ret; | 1626 | return ret; |
1640 | } | 1627 | } |
1641 | 1628 | ||
1642 | static int get_clk_info(int sclk, int rate) | ||
1643 | { | ||
1644 | int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16}; | ||
1645 | |||
1646 | if (sclk <= 0 || rate <= 0) | ||
1647 | return -EINVAL; | ||
1648 | |||
1649 | rate = rate << 8; | ||
1650 | for (i = 0; i < ARRAY_SIZE(pd); i++) | ||
1651 | if (sclk == rate * pd[i]) | ||
1652 | return i; | ||
1653 | |||
1654 | return -EINVAL; | ||
1655 | } | ||
1656 | |||
1657 | static int rt5640_hw_params(struct snd_pcm_substream *substream, | 1629 | static int rt5640_hw_params(struct snd_pcm_substream *substream, |
1658 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | 1630 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) |
1659 | { | 1631 | { |
@@ -1663,7 +1635,7 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream, | |||
1663 | int dai_sel, pre_div, bclk_ms, frame_size; | 1635 | int dai_sel, pre_div, bclk_ms, frame_size; |
1664 | 1636 | ||
1665 | rt5640->lrck[dai->id] = params_rate(params); | 1637 | rt5640->lrck[dai->id] = params_rate(params); |
1666 | pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); | 1638 | pre_div = rl6231_get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); |
1667 | if (pre_div < 0) { | 1639 | if (pre_div < 0) { |
1668 | dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", | 1640 | dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", |
1669 | rt5640->lrck[dai->id], dai->id); | 1641 | rt5640->lrck[dai->id], dai->id); |
@@ -1820,65 +1792,12 @@ static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai, | |||
1820 | return 0; | 1792 | return 0; |
1821 | } | 1793 | } |
1822 | 1794 | ||
1823 | /** | ||
1824 | * rt5640_pll_calc - Calculate PLL M/N/K code. | ||
1825 | * @freq_in: external clock provided to codec. | ||
1826 | * @freq_out: target clock which codec works on. | ||
1827 | * @pll_code: Pointer to structure with M, N, K and bypass flag. | ||
1828 | * | ||
1829 | * Calculate M/N/K code to configure PLL for codec. And K is assigned to 2 | ||
1830 | * which make calculation more efficiently. | ||
1831 | * | ||
1832 | * Returns 0 for success or negative error code. | ||
1833 | */ | ||
1834 | static int rt5640_pll_calc(const unsigned int freq_in, | ||
1835 | const unsigned int freq_out, struct rt5640_pll_code *pll_code) | ||
1836 | { | ||
1837 | int max_n = RT5640_PLL_N_MAX, max_m = RT5640_PLL_M_MAX; | ||
1838 | int n = 0, m = 0, red, n_t, m_t, in_t, out_t; | ||
1839 | int red_t = abs(freq_out - freq_in); | ||
1840 | bool bypass = false; | ||
1841 | |||
1842 | if (RT5640_PLL_INP_MAX < freq_in || RT5640_PLL_INP_MIN > freq_in) | ||
1843 | return -EINVAL; | ||
1844 | |||
1845 | for (n_t = 0; n_t <= max_n; n_t++) { | ||
1846 | in_t = (freq_in >> 1) + (freq_in >> 2) * n_t; | ||
1847 | if (in_t < 0) | ||
1848 | continue; | ||
1849 | if (in_t == freq_out) { | ||
1850 | bypass = true; | ||
1851 | n = n_t; | ||
1852 | goto code_find; | ||
1853 | } | ||
1854 | for (m_t = 0; m_t <= max_m; m_t++) { | ||
1855 | out_t = in_t / (m_t + 2); | ||
1856 | red = abs(out_t - freq_out); | ||
1857 | if (red < red_t) { | ||
1858 | n = n_t; | ||
1859 | m = m_t; | ||
1860 | if (red == 0) | ||
1861 | goto code_find; | ||
1862 | red_t = red; | ||
1863 | } | ||
1864 | } | ||
1865 | } | ||
1866 | pr_debug("Only get approximation about PLL\n"); | ||
1867 | |||
1868 | code_find: | ||
1869 | pll_code->m_bp = bypass; | ||
1870 | pll_code->m_code = m; | ||
1871 | pll_code->n_code = n; | ||
1872 | pll_code->k_code = 2; | ||
1873 | return 0; | ||
1874 | } | ||
1875 | |||
1876 | static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | 1795 | static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, |
1877 | unsigned int freq_in, unsigned int freq_out) | 1796 | unsigned int freq_in, unsigned int freq_out) |
1878 | { | 1797 | { |
1879 | struct snd_soc_codec *codec = dai->codec; | 1798 | struct snd_soc_codec *codec = dai->codec; |
1880 | struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); | 1799 | struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); |
1881 | struct rt5640_pll_code *pll_code = &rt5640->pll_code; | 1800 | struct rl6231_pll_code pll_code; |
1882 | int ret, dai_sel; | 1801 | int ret, dai_sel; |
1883 | 1802 | ||
1884 | if (source == rt5640->pll_src && freq_in == rt5640->pll_in && | 1803 | if (source == rt5640->pll_src && freq_in == rt5640->pll_in && |
@@ -1922,20 +1841,21 @@ static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | |||
1922 | return -EINVAL; | 1841 | return -EINVAL; |
1923 | } | 1842 | } |
1924 | 1843 | ||
1925 | ret = rt5640_pll_calc(freq_in, freq_out, pll_code); | 1844 | ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); |
1926 | if (ret < 0) { | 1845 | if (ret < 0) { |
1927 | dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); | 1846 | dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); |
1928 | return ret; | 1847 | return ret; |
1929 | } | 1848 | } |
1930 | 1849 | ||
1931 | dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=2\n", pll_code->m_bp, | 1850 | dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", |
1932 | (pll_code->m_bp ? 0 : pll_code->m_code), pll_code->n_code); | 1851 | pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), |
1852 | pll_code.n_code, pll_code.k_code); | ||
1933 | 1853 | ||
1934 | snd_soc_write(codec, RT5640_PLL_CTRL1, | 1854 | snd_soc_write(codec, RT5640_PLL_CTRL1, |
1935 | pll_code->n_code << RT5640_PLL_N_SFT | pll_code->k_code); | 1855 | pll_code.n_code << RT5640_PLL_N_SFT | pll_code.k_code); |
1936 | snd_soc_write(codec, RT5640_PLL_CTRL2, | 1856 | snd_soc_write(codec, RT5640_PLL_CTRL2, |
1937 | (pll_code->m_bp ? 0 : pll_code->m_code) << RT5640_PLL_M_SFT | | 1857 | (pll_code.m_bp ? 0 : pll_code.m_code) << RT5640_PLL_M_SFT | |
1938 | pll_code->m_bp << RT5640_PLL_M_BP_SFT); | 1858 | pll_code.m_bp << RT5640_PLL_M_BP_SFT); |
1939 | 1859 | ||
1940 | rt5640->pll_in = freq_in; | 1860 | rt5640->pll_in = freq_in; |
1941 | rt5640->pll_out = freq_out; | 1861 | rt5640->pll_out = freq_out; |
diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h index 895ca149db2e..58ebe96b86da 100644 --- a/sound/soc/codecs/rt5640.h +++ b/sound/soc/codecs/rt5640.h | |||
@@ -2079,13 +2079,6 @@ enum { | |||
2079 | RT5640_DMIC2, | 2079 | RT5640_DMIC2, |
2080 | }; | 2080 | }; |
2081 | 2081 | ||
2082 | struct rt5640_pll_code { | ||
2083 | bool m_bp; /* Indicates bypass m code or not. */ | ||
2084 | int m_code; | ||
2085 | int n_code; | ||
2086 | int k_code; | ||
2087 | }; | ||
2088 | |||
2089 | struct rt5640_priv { | 2082 | struct rt5640_priv { |
2090 | struct snd_soc_codec *codec; | 2083 | struct snd_soc_codec *codec; |
2091 | struct rt5640_platform_data pdata; | 2084 | struct rt5640_platform_data pdata; |
@@ -2097,7 +2090,6 @@ struct rt5640_priv { | |||
2097 | int bclk[RT5640_AIFS]; | 2090 | int bclk[RT5640_AIFS]; |
2098 | int master[RT5640_AIFS]; | 2091 | int master[RT5640_AIFS]; |
2099 | 2092 | ||
2100 | struct rt5640_pll_code pll_code; | ||
2101 | int pll_src; | 2093 | int pll_src; |
2102 | int pll_in; | 2094 | int pll_in; |
2103 | int pll_out; | 2095 | int pll_out; |
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index ab97d722e15d..02147be2b302 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <sound/initval.h> | 26 | #include <sound/initval.h> |
27 | #include <sound/tlv.h> | 27 | #include <sound/tlv.h> |
28 | 28 | ||
29 | #include "rl6231.h" | ||
29 | #include "rt5645.h" | 30 | #include "rt5645.h" |
30 | 31 | ||
31 | #define RT5645_DEVICE_ID 0x6308 | 32 | #define RT5645_DEVICE_ID 0x6308 |
@@ -519,30 +520,15 @@ static const struct snd_kcontrol_new rt5645_snd_controls[] = { | |||
519 | * @kcontrol: The kcontrol of this widget. | 520 | * @kcontrol: The kcontrol of this widget. |
520 | * @event: Event id. | 521 | * @event: Event id. |
521 | * | 522 | * |
522 | * Choose dmic clock between 1MHz and 3MHz. | ||
523 | * It is better for clock to approximate 3MHz. | ||
524 | */ | 523 | */ |
525 | static int set_dmic_clk(struct snd_soc_dapm_widget *w, | 524 | static int set_dmic_clk(struct snd_soc_dapm_widget *w, |
526 | struct snd_kcontrol *kcontrol, int event) | 525 | struct snd_kcontrol *kcontrol, int event) |
527 | { | 526 | { |
528 | struct snd_soc_codec *codec = w->codec; | 527 | struct snd_soc_codec *codec = w->codec; |
529 | struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); | 528 | struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); |
530 | int div[] = {2, 3, 4, 6, 8, 12}; | 529 | int idx = -EINVAL; |
531 | int idx = -EINVAL, i; | 530 | |
532 | int rate, red, bound, temp; | 531 | idx = rl6231_calc_dmic_clk(rt5645->sysclk); |
533 | |||
534 | rate = rt5645->sysclk; | ||
535 | red = 3000000 * 12; | ||
536 | for (i = 0; i < ARRAY_SIZE(div); i++) { | ||
537 | bound = div[i] * 3000000; | ||
538 | if (rate > bound) | ||
539 | continue; | ||
540 | temp = bound - rate; | ||
541 | if (temp < red) { | ||
542 | red = temp; | ||
543 | idx = i; | ||
544 | } | ||
545 | } | ||
546 | 532 | ||
547 | if (idx < 0) | 533 | if (idx < 0) |
548 | dev_err(codec->dev, "Failed to set DMIC clock\n"); | 534 | dev_err(codec->dev, "Failed to set DMIC clock\n"); |
@@ -1800,21 +1786,6 @@ static const struct snd_soc_dapm_route rt5645_dapm_routes[] = { | |||
1800 | { "SPOR", NULL, "SPK amp" }, | 1786 | { "SPOR", NULL, "SPK amp" }, |
1801 | }; | 1787 | }; |
1802 | 1788 | ||
1803 | static int get_clk_info(int sclk, int rate) | ||
1804 | { | ||
1805 | int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16}; | ||
1806 | |||
1807 | if (sclk <= 0 || rate <= 0) | ||
1808 | return -EINVAL; | ||
1809 | |||
1810 | rate = rate << 8; | ||
1811 | for (i = 0; i < ARRAY_SIZE(pd); i++) | ||
1812 | if (sclk == rate * pd[i]) | ||
1813 | return i; | ||
1814 | |||
1815 | return -EINVAL; | ||
1816 | } | ||
1817 | |||
1818 | static int rt5645_hw_params(struct snd_pcm_substream *substream, | 1789 | static int rt5645_hw_params(struct snd_pcm_substream *substream, |
1819 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | 1790 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) |
1820 | { | 1791 | { |
@@ -1824,7 +1795,7 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream, | |||
1824 | int pre_div, bclk_ms, frame_size; | 1795 | int pre_div, bclk_ms, frame_size; |
1825 | 1796 | ||
1826 | rt5645->lrck[dai->id] = params_rate(params); | 1797 | rt5645->lrck[dai->id] = params_rate(params); |
1827 | pre_div = get_clk_info(rt5645->sysclk, rt5645->lrck[dai->id]); | 1798 | pre_div = rl6231_get_clk_info(rt5645->sysclk, rt5645->lrck[dai->id]); |
1828 | if (pre_div < 0) { | 1799 | if (pre_div < 0) { |
1829 | dev_err(codec->dev, "Unsupported clock setting\n"); | 1800 | dev_err(codec->dev, "Unsupported clock setting\n"); |
1830 | return -EINVAL; | 1801 | return -EINVAL; |
@@ -1978,80 +1949,12 @@ static int rt5645_set_dai_sysclk(struct snd_soc_dai *dai, | |||
1978 | return 0; | 1949 | return 0; |
1979 | } | 1950 | } |
1980 | 1951 | ||
1981 | /** | ||
1982 | * rt5645_pll_calc - Calcualte PLL M/N/K code. | ||
1983 | * @freq_in: external clock provided to codec. | ||
1984 | * @freq_out: target clock which codec works on. | ||
1985 | * @pll_code: Pointer to structure with M, N, K and bypass flag. | ||
1986 | * | ||
1987 | * Calcualte M/N/K code to configure PLL for codec. And K is assigned to 2 | ||
1988 | * which make calculation more efficiently. | ||
1989 | * | ||
1990 | * Returns 0 for success or negative error code. | ||
1991 | */ | ||
1992 | static int rt5645_pll_calc(const unsigned int freq_in, | ||
1993 | const unsigned int freq_out, struct rt5645_pll_code *pll_code) | ||
1994 | { | ||
1995 | int max_n = RT5645_PLL_N_MAX, max_m = RT5645_PLL_M_MAX; | ||
1996 | int k, n = 0, m = 0, red, n_t, m_t, pll_out, in_t, out_t; | ||
1997 | int red_t = abs(freq_out - freq_in); | ||
1998 | bool bypass = false; | ||
1999 | |||
2000 | if (RT5645_PLL_INP_MAX < freq_in || RT5645_PLL_INP_MIN > freq_in) | ||
2001 | return -EINVAL; | ||
2002 | |||
2003 | k = 100000000 / freq_out - 2; | ||
2004 | if (k > RT5645_PLL_K_MAX) | ||
2005 | k = RT5645_PLL_K_MAX; | ||
2006 | for (n_t = 0; n_t <= max_n; n_t++) { | ||
2007 | in_t = freq_in / (k + 2); | ||
2008 | pll_out = freq_out / (n_t + 2); | ||
2009 | if (in_t < 0) | ||
2010 | continue; | ||
2011 | if (in_t == pll_out) { | ||
2012 | bypass = true; | ||
2013 | n = n_t; | ||
2014 | goto code_find; | ||
2015 | } | ||
2016 | red = abs(in_t - pll_out); | ||
2017 | if (red < red_t) { | ||
2018 | bypass = true; | ||
2019 | n = n_t; | ||
2020 | m = m_t; | ||
2021 | if (red == 0) | ||
2022 | goto code_find; | ||
2023 | red_t = red; | ||
2024 | } | ||
2025 | for (m_t = 0; m_t <= max_m; m_t++) { | ||
2026 | out_t = in_t / (m_t + 2); | ||
2027 | red = abs(out_t - pll_out); | ||
2028 | if (red < red_t) { | ||
2029 | bypass = false; | ||
2030 | n = n_t; | ||
2031 | m = m_t; | ||
2032 | if (red == 0) | ||
2033 | goto code_find; | ||
2034 | red_t = red; | ||
2035 | } | ||
2036 | } | ||
2037 | } | ||
2038 | pr_debug("Only get approximation about PLL\n"); | ||
2039 | |||
2040 | code_find: | ||
2041 | |||
2042 | pll_code->m_bp = bypass; | ||
2043 | pll_code->m_code = m; | ||
2044 | pll_code->n_code = n; | ||
2045 | pll_code->k_code = k; | ||
2046 | return 0; | ||
2047 | } | ||
2048 | |||
2049 | static int rt5645_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | 1952 | static int rt5645_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, |
2050 | unsigned int freq_in, unsigned int freq_out) | 1953 | unsigned int freq_in, unsigned int freq_out) |
2051 | { | 1954 | { |
2052 | struct snd_soc_codec *codec = dai->codec; | 1955 | struct snd_soc_codec *codec = dai->codec; |
2053 | struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); | 1956 | struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); |
2054 | struct rt5645_pll_code pll_code; | 1957 | struct rl6231_pll_code pll_code; |
2055 | int ret; | 1958 | int ret; |
2056 | 1959 | ||
2057 | if (source == rt5645->pll_src && freq_in == rt5645->pll_in && | 1960 | if (source == rt5645->pll_src && freq_in == rt5645->pll_in && |
@@ -2094,7 +1997,7 @@ static int rt5645_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | |||
2094 | return -EINVAL; | 1997 | return -EINVAL; |
2095 | } | 1998 | } |
2096 | 1999 | ||
2097 | ret = rt5645_pll_calc(freq_in, freq_out, &pll_code); | 2000 | ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); |
2098 | if (ret < 0) { | 2001 | if (ret < 0) { |
2099 | dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); | 2002 | dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); |
2100 | return ret; | 2003 | return ret; |
diff --git a/sound/soc/codecs/rt5645.h b/sound/soc/codecs/rt5645.h index 345aa3f5d14f..355b7e9eefab 100644 --- a/sound/soc/codecs/rt5645.h +++ b/sound/soc/codecs/rt5645.h | |||
@@ -2162,13 +2162,6 @@ enum { | |||
2162 | RT5645_DMIC_DATA_GPIO11, | 2162 | RT5645_DMIC_DATA_GPIO11, |
2163 | }; | 2163 | }; |
2164 | 2164 | ||
2165 | struct rt5645_pll_code { | ||
2166 | bool m_bp; /* Indicates bypass m code or not. */ | ||
2167 | int m_code; | ||
2168 | int n_code; | ||
2169 | int k_code; | ||
2170 | }; | ||
2171 | |||
2172 | struct rt5645_priv { | 2165 | struct rt5645_priv { |
2173 | struct snd_soc_codec *codec; | 2166 | struct snd_soc_codec *codec; |
2174 | struct rt5645_platform_data pdata; | 2167 | struct rt5645_platform_data pdata; |
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 9c88d89f41f0..ea4b1c652a26 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <sound/initval.h> | 26 | #include <sound/initval.h> |
27 | #include <sound/tlv.h> | 27 | #include <sound/tlv.h> |
28 | 28 | ||
29 | #include "rl6231.h" | ||
29 | #include "rt5651.h" | 30 | #include "rt5651.h" |
30 | 31 | ||
31 | #define RT5651_DEVICE_ID_VALUE 0x6281 | 32 | #define RT5651_DEVICE_ID_VALUE 0x6281 |
@@ -371,29 +372,16 @@ static const struct snd_kcontrol_new rt5651_snd_controls[] = { | |||
371 | * @kcontrol: The kcontrol of this widget. | 372 | * @kcontrol: The kcontrol of this widget. |
372 | * @event: Event id. | 373 | * @event: Event id. |
373 | * | 374 | * |
374 | * Choose dmic clock between 1MHz and 3MHz. | ||
375 | * It is better for clock to approximate 3MHz. | ||
376 | */ | 375 | */ |
377 | static int set_dmic_clk(struct snd_soc_dapm_widget *w, | 376 | static int set_dmic_clk(struct snd_soc_dapm_widget *w, |
378 | struct snd_kcontrol *kcontrol, int event) | 377 | struct snd_kcontrol *kcontrol, int event) |
379 | { | 378 | { |
380 | struct snd_soc_codec *codec = w->codec; | 379 | struct snd_soc_codec *codec = w->codec; |
381 | struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); | 380 | struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); |
382 | int div[] = {2, 3, 4, 6, 8, 12}, idx = -EINVAL; | 381 | int idx = -EINVAL; |
383 | int i, rate, red, bound, temp; | 382 | |
384 | 383 | idx = rl6231_calc_dmic_clk(rt5651->sysclk); | |
385 | rate = rt5651->sysclk; | 384 | |
386 | red = 3000000 * 12; | ||
387 | for (i = 0; i < ARRAY_SIZE(div); i++) { | ||
388 | bound = div[i] * 3000000; | ||
389 | if (rate > bound) | ||
390 | continue; | ||
391 | temp = bound - rate; | ||
392 | if (temp < red) { | ||
393 | red = temp; | ||
394 | idx = i; | ||
395 | } | ||
396 | } | ||
397 | if (idx < 0) | 385 | if (idx < 0) |
398 | dev_err(codec->dev, "Failed to set DMIC clock\n"); | 386 | dev_err(codec->dev, "Failed to set DMIC clock\n"); |
399 | else | 387 | else |
@@ -1350,21 +1338,6 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = { | |||
1350 | {"PDMR", NULL, "PDM R Mux"}, | 1338 | {"PDMR", NULL, "PDM R Mux"}, |
1351 | }; | 1339 | }; |
1352 | 1340 | ||
1353 | static int get_clk_info(int sclk, int rate) | ||
1354 | { | ||
1355 | int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16}; | ||
1356 | |||
1357 | if (sclk <= 0 || rate <= 0) | ||
1358 | return -EINVAL; | ||
1359 | |||
1360 | rate = rate << 8; | ||
1361 | for (i = 0; i < ARRAY_SIZE(pd); i++) | ||
1362 | if (sclk == rate * pd[i]) | ||
1363 | return i; | ||
1364 | |||
1365 | return -EINVAL; | ||
1366 | } | ||
1367 | |||
1368 | static int rt5651_hw_params(struct snd_pcm_substream *substream, | 1341 | static int rt5651_hw_params(struct snd_pcm_substream *substream, |
1369 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | 1342 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) |
1370 | { | 1343 | { |
@@ -1374,7 +1347,7 @@ static int rt5651_hw_params(struct snd_pcm_substream *substream, | |||
1374 | int pre_div, bclk_ms, frame_size; | 1347 | int pre_div, bclk_ms, frame_size; |
1375 | 1348 | ||
1376 | rt5651->lrck[dai->id] = params_rate(params); | 1349 | rt5651->lrck[dai->id] = params_rate(params); |
1377 | pre_div = get_clk_info(rt5651->sysclk, rt5651->lrck[dai->id]); | 1350 | pre_div = rl6231_get_clk_info(rt5651->sysclk, rt5651->lrck[dai->id]); |
1378 | 1351 | ||
1379 | if (pre_div < 0) { | 1352 | if (pre_div < 0) { |
1380 | dev_err(codec->dev, "Unsupported clock setting\n"); | 1353 | dev_err(codec->dev, "Unsupported clock setting\n"); |
@@ -1528,65 +1501,12 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, | |||
1528 | return 0; | 1501 | return 0; |
1529 | } | 1502 | } |
1530 | 1503 | ||
1531 | /** | ||
1532 | * rt5651_pll_calc - Calcualte PLL M/N/K code. | ||
1533 | * @freq_in: external clock provided to codec. | ||
1534 | * @freq_out: target clock which codec works on. | ||
1535 | * @pll_code: Pointer to structure with M, N, K and bypass flag. | ||
1536 | * | ||
1537 | * Calcualte M/N/K code to configure PLL for codec. And K is assigned to 2 | ||
1538 | * which make calculation more efficiently. | ||
1539 | * | ||
1540 | * Returns 0 for success or negative error code. | ||
1541 | */ | ||
1542 | static int rt5651_pll_calc(const unsigned int freq_in, | ||
1543 | const unsigned int freq_out, struct rt5651_pll_code *pll_code) | ||
1544 | { | ||
1545 | int max_n = RT5651_PLL_N_MAX, max_m = RT5651_PLL_M_MAX; | ||
1546 | int n = 0, m = 0, red, n_t, m_t, in_t, out_t; | ||
1547 | int red_t = abs(freq_out - freq_in); | ||
1548 | bool bypass = false; | ||
1549 | |||
1550 | if (RT5651_PLL_INP_MAX < freq_in || RT5651_PLL_INP_MIN > freq_in) | ||
1551 | return -EINVAL; | ||
1552 | |||
1553 | for (n_t = 0; n_t <= max_n; n_t++) { | ||
1554 | in_t = (freq_in >> 1) + (freq_in >> 2) * n_t; | ||
1555 | if (in_t < 0) | ||
1556 | continue; | ||
1557 | if (in_t == freq_out) { | ||
1558 | bypass = true; | ||
1559 | n = n_t; | ||
1560 | goto code_find; | ||
1561 | } | ||
1562 | for (m_t = 0; m_t <= max_m; m_t++) { | ||
1563 | out_t = in_t / (m_t + 2); | ||
1564 | red = abs(out_t - freq_out); | ||
1565 | if (red < red_t) { | ||
1566 | n = n_t; | ||
1567 | m = m_t; | ||
1568 | if (red == 0) | ||
1569 | goto code_find; | ||
1570 | red_t = red; | ||
1571 | } | ||
1572 | } | ||
1573 | } | ||
1574 | pr_debug("Only get approximation about PLL\n"); | ||
1575 | |||
1576 | code_find: | ||
1577 | pll_code->m_bp = bypass; | ||
1578 | pll_code->m_code = m; | ||
1579 | pll_code->n_code = n; | ||
1580 | pll_code->k_code = 2; | ||
1581 | return 0; | ||
1582 | } | ||
1583 | |||
1584 | static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | 1504 | static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, |
1585 | unsigned int freq_in, unsigned int freq_out) | 1505 | unsigned int freq_in, unsigned int freq_out) |
1586 | { | 1506 | { |
1587 | struct snd_soc_codec *codec = dai->codec; | 1507 | struct snd_soc_codec *codec = dai->codec; |
1588 | struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); | 1508 | struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); |
1589 | struct rt5651_pll_code *pll_code = &rt5651->pll_code; | 1509 | struct rl6231_pll_code pll_code; |
1590 | int ret; | 1510 | int ret; |
1591 | 1511 | ||
1592 | if (source == rt5651->pll_src && freq_in == rt5651->pll_in && | 1512 | if (source == rt5651->pll_src && freq_in == rt5651->pll_in && |
@@ -1621,20 +1541,21 @@ static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | |||
1621 | return -EINVAL; | 1541 | return -EINVAL; |
1622 | } | 1542 | } |
1623 | 1543 | ||
1624 | ret = rt5651_pll_calc(freq_in, freq_out, pll_code); | 1544 | ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); |
1625 | if (ret < 0) { | 1545 | if (ret < 0) { |
1626 | dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); | 1546 | dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); |
1627 | return ret; | 1547 | return ret; |
1628 | } | 1548 | } |
1629 | 1549 | ||
1630 | dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=2\n", pll_code->m_bp, | 1550 | dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", |
1631 | (pll_code->m_bp ? 0 : pll_code->m_code), pll_code->n_code); | 1551 | pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), |
1552 | pll_code.n_code, pll_code.k_code); | ||
1632 | 1553 | ||
1633 | snd_soc_write(codec, RT5651_PLL_CTRL1, | 1554 | snd_soc_write(codec, RT5651_PLL_CTRL1, |
1634 | pll_code->n_code << RT5651_PLL_N_SFT | pll_code->k_code); | 1555 | pll_code.n_code << RT5651_PLL_N_SFT | pll_code.k_code); |
1635 | snd_soc_write(codec, RT5651_PLL_CTRL2, | 1556 | snd_soc_write(codec, RT5651_PLL_CTRL2, |
1636 | (pll_code->m_bp ? 0 : pll_code->m_code) << RT5651_PLL_M_SFT | | 1557 | (pll_code.m_bp ? 0 : pll_code.m_code) << RT5651_PLL_M_SFT | |
1637 | pll_code->m_bp << RT5651_PLL_M_BP_SFT); | 1558 | pll_code.m_bp << RT5651_PLL_M_BP_SFT); |
1638 | 1559 | ||
1639 | rt5651->pll_in = freq_in; | 1560 | rt5651->pll_in = freq_in; |
1640 | rt5651->pll_out = freq_out; | 1561 | rt5651->pll_out = freq_out; |
diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index a28bd0c3d613..1bd33cfa6411 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h | |||
@@ -2069,7 +2069,6 @@ struct rt5651_priv { | |||
2069 | int bclk[RT5651_AIFS]; | 2069 | int bclk[RT5651_AIFS]; |
2070 | int master[RT5651_AIFS]; | 2070 | int master[RT5651_AIFS]; |
2071 | 2071 | ||
2072 | struct rt5651_pll_code pll_code; | ||
2073 | int pll_src; | 2072 | int pll_src; |
2074 | int pll_in; | 2073 | int pll_in; |
2075 | int pll_out; | 2074 | int pll_out; |
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c new file mode 100644 index 000000000000..833231e27340 --- /dev/null +++ b/sound/soc/codecs/rt5677.c | |||
@@ -0,0 +1,3498 @@ | |||
1 | /* | ||
2 | * rt5677.c -- RT5677 ALSA SoC audio codec driver | ||
3 | * | ||
4 | * Copyright 2013 Realtek Semiconductor Corp. | ||
5 | * Author: Oder Chiou <oder_chiou@realtek.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/fs.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/moduleparam.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/pm.h> | ||
18 | #include <linux/regmap.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/spi/spi.h> | ||
22 | #include <sound/core.h> | ||
23 | #include <sound/pcm.h> | ||
24 | #include <sound/pcm_params.h> | ||
25 | #include <sound/soc.h> | ||
26 | #include <sound/soc-dapm.h> | ||
27 | #include <sound/initval.h> | ||
28 | #include <sound/tlv.h> | ||
29 | |||
30 | #include "rt5677.h" | ||
31 | |||
32 | #define RT5677_DEVICE_ID 0x6327 | ||
33 | |||
34 | #define RT5677_PR_RANGE_BASE (0xff + 1) | ||
35 | #define RT5677_PR_SPACING 0x100 | ||
36 | |||
37 | #define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING)) | ||
38 | |||
39 | static const struct regmap_range_cfg rt5677_ranges[] = { | ||
40 | { | ||
41 | .name = "PR", | ||
42 | .range_min = RT5677_PR_BASE, | ||
43 | .range_max = RT5677_PR_BASE + 0xfd, | ||
44 | .selector_reg = RT5677_PRIV_INDEX, | ||
45 | .selector_mask = 0xff, | ||
46 | .selector_shift = 0x0, | ||
47 | .window_start = RT5677_PRIV_DATA, | ||
48 | .window_len = 0x1, | ||
49 | }, | ||
50 | }; | ||
51 | |||
52 | static const struct reg_default init_list[] = { | ||
53 | {RT5677_PR_BASE + 0x3d, 0x364d}, | ||
54 | {RT5677_PR_BASE + 0x17, 0x4fc0}, | ||
55 | {RT5677_PR_BASE + 0x13, 0x0312}, | ||
56 | {RT5677_PR_BASE + 0x1e, 0x0000}, | ||
57 | {RT5677_PR_BASE + 0x12, 0x0eaa}, | ||
58 | {RT5677_PR_BASE + 0x14, 0x018a}, | ||
59 | }; | ||
60 | #define RT5677_INIT_REG_LEN ARRAY_SIZE(init_list) | ||
61 | |||
62 | static const struct reg_default rt5677_reg[] = { | ||
63 | {RT5677_RESET , 0x0000}, | ||
64 | {RT5677_LOUT1 , 0xa800}, | ||
65 | {RT5677_IN1 , 0x0000}, | ||
66 | {RT5677_MICBIAS , 0x0000}, | ||
67 | {RT5677_SLIMBUS_PARAM , 0x0000}, | ||
68 | {RT5677_SLIMBUS_RX , 0x0000}, | ||
69 | {RT5677_SLIMBUS_CTRL , 0x0000}, | ||
70 | {RT5677_SIDETONE_CTRL , 0x000b}, | ||
71 | {RT5677_ANA_DAC1_2_3_SRC , 0x0000}, | ||
72 | {RT5677_IF_DSP_DAC3_4_MIXER , 0x1111}, | ||
73 | {RT5677_DAC4_DIG_VOL , 0xafaf}, | ||
74 | {RT5677_DAC3_DIG_VOL , 0xafaf}, | ||
75 | {RT5677_DAC1_DIG_VOL , 0xafaf}, | ||
76 | {RT5677_DAC2_DIG_VOL , 0xafaf}, | ||
77 | {RT5677_IF_DSP_DAC2_MIXER , 0x0011}, | ||
78 | {RT5677_STO1_ADC_DIG_VOL , 0x2f2f}, | ||
79 | {RT5677_MONO_ADC_DIG_VOL , 0x2f2f}, | ||
80 | {RT5677_STO1_2_ADC_BST , 0x0000}, | ||
81 | {RT5677_STO2_ADC_DIG_VOL , 0x2f2f}, | ||
82 | {RT5677_ADC_BST_CTRL2 , 0x0000}, | ||
83 | {RT5677_STO3_4_ADC_BST , 0x0000}, | ||
84 | {RT5677_STO3_ADC_DIG_VOL , 0x2f2f}, | ||
85 | {RT5677_STO4_ADC_DIG_VOL , 0x2f2f}, | ||
86 | {RT5677_STO4_ADC_MIXER , 0xd4c0}, | ||
87 | {RT5677_STO3_ADC_MIXER , 0xd4c0}, | ||
88 | {RT5677_STO2_ADC_MIXER , 0xd4c0}, | ||
89 | {RT5677_STO1_ADC_MIXER , 0xd4c0}, | ||
90 | {RT5677_MONO_ADC_MIXER , 0xd4d1}, | ||
91 | {RT5677_ADC_IF_DSP_DAC1_MIXER , 0x8080}, | ||
92 | {RT5677_STO1_DAC_MIXER , 0xaaaa}, | ||
93 | {RT5677_MONO_DAC_MIXER , 0xaaaa}, | ||
94 | {RT5677_DD1_MIXER , 0xaaaa}, | ||
95 | {RT5677_DD2_MIXER , 0xaaaa}, | ||
96 | {RT5677_IF3_DATA , 0x0000}, | ||
97 | {RT5677_IF4_DATA , 0x0000}, | ||
98 | {RT5677_PDM_OUT_CTRL , 0x8888}, | ||
99 | {RT5677_PDM_DATA_CTRL1 , 0x0000}, | ||
100 | {RT5677_PDM_DATA_CTRL2 , 0x0000}, | ||
101 | {RT5677_PDM1_DATA_CTRL2 , 0x0000}, | ||
102 | {RT5677_PDM1_DATA_CTRL3 , 0x0000}, | ||
103 | {RT5677_PDM1_DATA_CTRL4 , 0x0000}, | ||
104 | {RT5677_PDM2_DATA_CTRL2 , 0x0000}, | ||
105 | {RT5677_PDM2_DATA_CTRL3 , 0x0000}, | ||
106 | {RT5677_PDM2_DATA_CTRL4 , 0x0000}, | ||
107 | {RT5677_TDM1_CTRL1 , 0x0300}, | ||
108 | {RT5677_TDM1_CTRL2 , 0x0000}, | ||
109 | {RT5677_TDM1_CTRL3 , 0x4000}, | ||
110 | {RT5677_TDM1_CTRL4 , 0x0123}, | ||
111 | {RT5677_TDM1_CTRL5 , 0x4567}, | ||
112 | {RT5677_TDM2_CTRL1 , 0x0300}, | ||
113 | {RT5677_TDM2_CTRL2 , 0x0000}, | ||
114 | {RT5677_TDM2_CTRL3 , 0x4000}, | ||
115 | {RT5677_TDM2_CTRL4 , 0x0123}, | ||
116 | {RT5677_TDM2_CTRL5 , 0x4567}, | ||
117 | {RT5677_I2C_MASTER_CTRL1 , 0x0001}, | ||
118 | {RT5677_I2C_MASTER_CTRL2 , 0x0000}, | ||
119 | {RT5677_I2C_MASTER_CTRL3 , 0x0000}, | ||
120 | {RT5677_I2C_MASTER_CTRL4 , 0x0000}, | ||
121 | {RT5677_I2C_MASTER_CTRL5 , 0x0000}, | ||
122 | {RT5677_I2C_MASTER_CTRL6 , 0x0000}, | ||
123 | {RT5677_I2C_MASTER_CTRL7 , 0x0000}, | ||
124 | {RT5677_I2C_MASTER_CTRL8 , 0x0000}, | ||
125 | {RT5677_DMIC_CTRL1 , 0x1505}, | ||
126 | {RT5677_DMIC_CTRL2 , 0x0055}, | ||
127 | {RT5677_HAP_GENE_CTRL1 , 0x0111}, | ||
128 | {RT5677_HAP_GENE_CTRL2 , 0x0064}, | ||
129 | {RT5677_HAP_GENE_CTRL3 , 0xef0e}, | ||
130 | {RT5677_HAP_GENE_CTRL4 , 0xf0f0}, | ||
131 | {RT5677_HAP_GENE_CTRL5 , 0xef0e}, | ||
132 | {RT5677_HAP_GENE_CTRL6 , 0xf0f0}, | ||
133 | {RT5677_HAP_GENE_CTRL7 , 0xef0e}, | ||
134 | {RT5677_HAP_GENE_CTRL8 , 0xf0f0}, | ||
135 | {RT5677_HAP_GENE_CTRL9 , 0xf000}, | ||
136 | {RT5677_HAP_GENE_CTRL10 , 0x0000}, | ||
137 | {RT5677_PWR_DIG1 , 0x0000}, | ||
138 | {RT5677_PWR_DIG2 , 0x0000}, | ||
139 | {RT5677_PWR_ANLG1 , 0x0055}, | ||
140 | {RT5677_PWR_ANLG2 , 0x0000}, | ||
141 | {RT5677_PWR_DSP1 , 0x0001}, | ||
142 | {RT5677_PWR_DSP_ST , 0x0000}, | ||
143 | {RT5677_PWR_DSP2 , 0x0000}, | ||
144 | {RT5677_ADC_DAC_HPF_CTRL1 , 0x0e00}, | ||
145 | {RT5677_PRIV_INDEX , 0x0000}, | ||
146 | {RT5677_PRIV_DATA , 0x0000}, | ||
147 | {RT5677_I2S4_SDP , 0x8000}, | ||
148 | {RT5677_I2S1_SDP , 0x8000}, | ||
149 | {RT5677_I2S2_SDP , 0x8000}, | ||
150 | {RT5677_I2S3_SDP , 0x8000}, | ||
151 | {RT5677_CLK_TREE_CTRL1 , 0x1111}, | ||
152 | {RT5677_CLK_TREE_CTRL2 , 0x1111}, | ||
153 | {RT5677_CLK_TREE_CTRL3 , 0x0000}, | ||
154 | {RT5677_PLL1_CTRL1 , 0x0000}, | ||
155 | {RT5677_PLL1_CTRL2 , 0x0000}, | ||
156 | {RT5677_PLL2_CTRL1 , 0x0c60}, | ||
157 | {RT5677_PLL2_CTRL2 , 0x2000}, | ||
158 | {RT5677_GLB_CLK1 , 0x0000}, | ||
159 | {RT5677_GLB_CLK2 , 0x0000}, | ||
160 | {RT5677_ASRC_1 , 0x0000}, | ||
161 | {RT5677_ASRC_2 , 0x0000}, | ||
162 | {RT5677_ASRC_3 , 0x0000}, | ||
163 | {RT5677_ASRC_4 , 0x0000}, | ||
164 | {RT5677_ASRC_5 , 0x0000}, | ||
165 | {RT5677_ASRC_6 , 0x0000}, | ||
166 | {RT5677_ASRC_7 , 0x0000}, | ||
167 | {RT5677_ASRC_8 , 0x0000}, | ||
168 | {RT5677_ASRC_9 , 0x0000}, | ||
169 | {RT5677_ASRC_10 , 0x0000}, | ||
170 | {RT5677_ASRC_11 , 0x0000}, | ||
171 | {RT5677_ASRC_12 , 0x0008}, | ||
172 | {RT5677_ASRC_13 , 0x0000}, | ||
173 | {RT5677_ASRC_14 , 0x0000}, | ||
174 | {RT5677_ASRC_15 , 0x0000}, | ||
175 | {RT5677_ASRC_16 , 0x0000}, | ||
176 | {RT5677_ASRC_17 , 0x0000}, | ||
177 | {RT5677_ASRC_18 , 0x0000}, | ||
178 | {RT5677_ASRC_19 , 0x0000}, | ||
179 | {RT5677_ASRC_20 , 0x0000}, | ||
180 | {RT5677_ASRC_21 , 0x000c}, | ||
181 | {RT5677_ASRC_22 , 0x0000}, | ||
182 | {RT5677_ASRC_23 , 0x0000}, | ||
183 | {RT5677_VAD_CTRL1 , 0x2184}, | ||
184 | {RT5677_VAD_CTRL2 , 0x010a}, | ||
185 | {RT5677_VAD_CTRL3 , 0x0aea}, | ||
186 | {RT5677_VAD_CTRL4 , 0x000c}, | ||
187 | {RT5677_VAD_CTRL5 , 0x0000}, | ||
188 | {RT5677_DSP_INB_CTRL1 , 0x0000}, | ||
189 | {RT5677_DSP_INB_CTRL2 , 0x0000}, | ||
190 | {RT5677_DSP_IN_OUTB_CTRL , 0x0000}, | ||
191 | {RT5677_DSP_OUTB0_1_DIG_VOL , 0x2f2f}, | ||
192 | {RT5677_DSP_OUTB2_3_DIG_VOL , 0x2f2f}, | ||
193 | {RT5677_DSP_OUTB4_5_DIG_VOL , 0x2f2f}, | ||
194 | {RT5677_DSP_OUTB6_7_DIG_VOL , 0x2f2f}, | ||
195 | {RT5677_ADC_EQ_CTRL1 , 0x6000}, | ||
196 | {RT5677_ADC_EQ_CTRL2 , 0x0000}, | ||
197 | {RT5677_EQ_CTRL1 , 0xc000}, | ||
198 | {RT5677_EQ_CTRL2 , 0x0000}, | ||
199 | {RT5677_EQ_CTRL3 , 0x0000}, | ||
200 | {RT5677_SOFT_VOL_ZERO_CROSS1 , 0x0009}, | ||
201 | {RT5677_JD_CTRL1 , 0x0000}, | ||
202 | {RT5677_JD_CTRL2 , 0x0000}, | ||
203 | {RT5677_JD_CTRL3 , 0x0000}, | ||
204 | {RT5677_IRQ_CTRL1 , 0x0000}, | ||
205 | {RT5677_IRQ_CTRL2 , 0x0000}, | ||
206 | {RT5677_GPIO_ST , 0x0000}, | ||
207 | {RT5677_GPIO_CTRL1 , 0x0000}, | ||
208 | {RT5677_GPIO_CTRL2 , 0x0000}, | ||
209 | {RT5677_GPIO_CTRL3 , 0x0000}, | ||
210 | {RT5677_STO1_ADC_HI_FILTER1 , 0xb320}, | ||
211 | {RT5677_STO1_ADC_HI_FILTER2 , 0x0000}, | ||
212 | {RT5677_MONO_ADC_HI_FILTER1 , 0xb300}, | ||
213 | {RT5677_MONO_ADC_HI_FILTER2 , 0x0000}, | ||
214 | {RT5677_STO2_ADC_HI_FILTER1 , 0xb300}, | ||
215 | {RT5677_STO2_ADC_HI_FILTER2 , 0x0000}, | ||
216 | {RT5677_STO3_ADC_HI_FILTER1 , 0xb300}, | ||
217 | {RT5677_STO3_ADC_HI_FILTER2 , 0x0000}, | ||
218 | {RT5677_STO4_ADC_HI_FILTER1 , 0xb300}, | ||
219 | {RT5677_STO4_ADC_HI_FILTER2 , 0x0000}, | ||
220 | {RT5677_MB_DRC_CTRL1 , 0x0f20}, | ||
221 | {RT5677_DRC1_CTRL1 , 0x001f}, | ||
222 | {RT5677_DRC1_CTRL2 , 0x020c}, | ||
223 | {RT5677_DRC1_CTRL3 , 0x1f00}, | ||
224 | {RT5677_DRC1_CTRL4 , 0x0000}, | ||
225 | {RT5677_DRC1_CTRL5 , 0x0000}, | ||
226 | {RT5677_DRC1_CTRL6 , 0x0029}, | ||
227 | {RT5677_DRC2_CTRL1 , 0x001f}, | ||
228 | {RT5677_DRC2_CTRL2 , 0x020c}, | ||
229 | {RT5677_DRC2_CTRL3 , 0x1f00}, | ||
230 | {RT5677_DRC2_CTRL4 , 0x0000}, | ||
231 | {RT5677_DRC2_CTRL5 , 0x0000}, | ||
232 | {RT5677_DRC2_CTRL6 , 0x0029}, | ||
233 | {RT5677_DRC1_HL_CTRL1 , 0x8000}, | ||
234 | {RT5677_DRC1_HL_CTRL2 , 0x0200}, | ||
235 | {RT5677_DRC2_HL_CTRL1 , 0x8000}, | ||
236 | {RT5677_DRC2_HL_CTRL2 , 0x0200}, | ||
237 | {RT5677_DSP_INB1_SRC_CTRL1 , 0x5800}, | ||
238 | {RT5677_DSP_INB1_SRC_CTRL2 , 0x0000}, | ||
239 | {RT5677_DSP_INB1_SRC_CTRL3 , 0x0000}, | ||
240 | {RT5677_DSP_INB1_SRC_CTRL4 , 0x0800}, | ||
241 | {RT5677_DSP_INB2_SRC_CTRL1 , 0x5800}, | ||
242 | {RT5677_DSP_INB2_SRC_CTRL2 , 0x0000}, | ||
243 | {RT5677_DSP_INB2_SRC_CTRL3 , 0x0000}, | ||
244 | {RT5677_DSP_INB2_SRC_CTRL4 , 0x0800}, | ||
245 | {RT5677_DSP_INB3_SRC_CTRL1 , 0x5800}, | ||
246 | {RT5677_DSP_INB3_SRC_CTRL2 , 0x0000}, | ||
247 | {RT5677_DSP_INB3_SRC_CTRL3 , 0x0000}, | ||
248 | {RT5677_DSP_INB3_SRC_CTRL4 , 0x0800}, | ||
249 | {RT5677_DSP_OUTB1_SRC_CTRL1 , 0x5800}, | ||
250 | {RT5677_DSP_OUTB1_SRC_CTRL2 , 0x0000}, | ||
251 | {RT5677_DSP_OUTB1_SRC_CTRL3 , 0x0000}, | ||
252 | {RT5677_DSP_OUTB1_SRC_CTRL4 , 0x0800}, | ||
253 | {RT5677_DSP_OUTB2_SRC_CTRL1 , 0x5800}, | ||
254 | {RT5677_DSP_OUTB2_SRC_CTRL2 , 0x0000}, | ||
255 | {RT5677_DSP_OUTB2_SRC_CTRL3 , 0x0000}, | ||
256 | {RT5677_DSP_OUTB2_SRC_CTRL4 , 0x0800}, | ||
257 | {RT5677_DSP_OUTB_0123_MIXER_CTRL, 0xfefe}, | ||
258 | {RT5677_DSP_OUTB_45_MIXER_CTRL , 0xfefe}, | ||
259 | {RT5677_DSP_OUTB_67_MIXER_CTRL , 0xfefe}, | ||
260 | {RT5677_DIG_MISC , 0x0000}, | ||
261 | {RT5677_GEN_CTRL1 , 0x0000}, | ||
262 | {RT5677_GEN_CTRL2 , 0x0000}, | ||
263 | {RT5677_VENDOR_ID , 0x0000}, | ||
264 | {RT5677_VENDOR_ID1 , 0x10ec}, | ||
265 | {RT5677_VENDOR_ID2 , 0x6327}, | ||
266 | }; | ||
267 | |||
268 | static bool rt5677_volatile_register(struct device *dev, unsigned int reg) | ||
269 | { | ||
270 | int i; | ||
271 | |||
272 | for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) { | ||
273 | if (reg >= rt5677_ranges[i].range_min && | ||
274 | reg <= rt5677_ranges[i].range_max) { | ||
275 | return true; | ||
276 | } | ||
277 | } | ||
278 | |||
279 | switch (reg) { | ||
280 | case RT5677_RESET: | ||
281 | case RT5677_SLIMBUS_PARAM: | ||
282 | case RT5677_PDM_DATA_CTRL1: | ||
283 | case RT5677_PDM_DATA_CTRL2: | ||
284 | case RT5677_PDM1_DATA_CTRL4: | ||
285 | case RT5677_PDM2_DATA_CTRL4: | ||
286 | case RT5677_I2C_MASTER_CTRL1: | ||
287 | case RT5677_I2C_MASTER_CTRL7: | ||
288 | case RT5677_I2C_MASTER_CTRL8: | ||
289 | case RT5677_HAP_GENE_CTRL2: | ||
290 | case RT5677_PWR_DSP_ST: | ||
291 | case RT5677_PRIV_DATA: | ||
292 | case RT5677_PLL1_CTRL2: | ||
293 | case RT5677_PLL2_CTRL2: | ||
294 | case RT5677_ASRC_22: | ||
295 | case RT5677_ASRC_23: | ||
296 | case RT5677_VAD_CTRL5: | ||
297 | case RT5677_ADC_EQ_CTRL1: | ||
298 | case RT5677_EQ_CTRL1: | ||
299 | case RT5677_IRQ_CTRL1: | ||
300 | case RT5677_IRQ_CTRL2: | ||
301 | case RT5677_GPIO_ST: | ||
302 | case RT5677_DSP_INB1_SRC_CTRL4: | ||
303 | case RT5677_DSP_INB2_SRC_CTRL4: | ||
304 | case RT5677_DSP_INB3_SRC_CTRL4: | ||
305 | case RT5677_DSP_OUTB1_SRC_CTRL4: | ||
306 | case RT5677_DSP_OUTB2_SRC_CTRL4: | ||
307 | case RT5677_VENDOR_ID: | ||
308 | case RT5677_VENDOR_ID1: | ||
309 | case RT5677_VENDOR_ID2: | ||
310 | return true; | ||
311 | default: | ||
312 | return false; | ||
313 | } | ||
314 | } | ||
315 | |||
316 | static bool rt5677_readable_register(struct device *dev, unsigned int reg) | ||
317 | { | ||
318 | int i; | ||
319 | |||
320 | for (i = 0; i < ARRAY_SIZE(rt5677_ranges); i++) { | ||
321 | if (reg >= rt5677_ranges[i].range_min && | ||
322 | reg <= rt5677_ranges[i].range_max) { | ||
323 | return true; | ||
324 | } | ||
325 | } | ||
326 | |||
327 | switch (reg) { | ||
328 | case RT5677_RESET: | ||
329 | case RT5677_LOUT1: | ||
330 | case RT5677_IN1: | ||
331 | case RT5677_MICBIAS: | ||
332 | case RT5677_SLIMBUS_PARAM: | ||
333 | case RT5677_SLIMBUS_RX: | ||
334 | case RT5677_SLIMBUS_CTRL: | ||
335 | case RT5677_SIDETONE_CTRL: | ||
336 | case RT5677_ANA_DAC1_2_3_SRC: | ||
337 | case RT5677_IF_DSP_DAC3_4_MIXER: | ||
338 | case RT5677_DAC4_DIG_VOL: | ||
339 | case RT5677_DAC3_DIG_VOL: | ||
340 | case RT5677_DAC1_DIG_VOL: | ||
341 | case RT5677_DAC2_DIG_VOL: | ||
342 | case RT5677_IF_DSP_DAC2_MIXER: | ||
343 | case RT5677_STO1_ADC_DIG_VOL: | ||
344 | case RT5677_MONO_ADC_DIG_VOL: | ||
345 | case RT5677_STO1_2_ADC_BST: | ||
346 | case RT5677_STO2_ADC_DIG_VOL: | ||
347 | case RT5677_ADC_BST_CTRL2: | ||
348 | case RT5677_STO3_4_ADC_BST: | ||
349 | case RT5677_STO3_ADC_DIG_VOL: | ||
350 | case RT5677_STO4_ADC_DIG_VOL: | ||
351 | case RT5677_STO4_ADC_MIXER: | ||
352 | case RT5677_STO3_ADC_MIXER: | ||
353 | case RT5677_STO2_ADC_MIXER: | ||
354 | case RT5677_STO1_ADC_MIXER: | ||
355 | case RT5677_MONO_ADC_MIXER: | ||
356 | case RT5677_ADC_IF_DSP_DAC1_MIXER: | ||
357 | case RT5677_STO1_DAC_MIXER: | ||
358 | case RT5677_MONO_DAC_MIXER: | ||
359 | case RT5677_DD1_MIXER: | ||
360 | case RT5677_DD2_MIXER: | ||
361 | case RT5677_IF3_DATA: | ||
362 | case RT5677_IF4_DATA: | ||
363 | case RT5677_PDM_OUT_CTRL: | ||
364 | case RT5677_PDM_DATA_CTRL1: | ||
365 | case RT5677_PDM_DATA_CTRL2: | ||
366 | case RT5677_PDM1_DATA_CTRL2: | ||
367 | case RT5677_PDM1_DATA_CTRL3: | ||
368 | case RT5677_PDM1_DATA_CTRL4: | ||
369 | case RT5677_PDM2_DATA_CTRL2: | ||
370 | case RT5677_PDM2_DATA_CTRL3: | ||
371 | case RT5677_PDM2_DATA_CTRL4: | ||
372 | case RT5677_TDM1_CTRL1: | ||
373 | case RT5677_TDM1_CTRL2: | ||
374 | case RT5677_TDM1_CTRL3: | ||
375 | case RT5677_TDM1_CTRL4: | ||
376 | case RT5677_TDM1_CTRL5: | ||
377 | case RT5677_TDM2_CTRL1: | ||
378 | case RT5677_TDM2_CTRL2: | ||
379 | case RT5677_TDM2_CTRL3: | ||
380 | case RT5677_TDM2_CTRL4: | ||
381 | case RT5677_TDM2_CTRL5: | ||
382 | case RT5677_I2C_MASTER_CTRL1: | ||
383 | case RT5677_I2C_MASTER_CTRL2: | ||
384 | case RT5677_I2C_MASTER_CTRL3: | ||
385 | case RT5677_I2C_MASTER_CTRL4: | ||
386 | case RT5677_I2C_MASTER_CTRL5: | ||
387 | case RT5677_I2C_MASTER_CTRL6: | ||
388 | case RT5677_I2C_MASTER_CTRL7: | ||
389 | case RT5677_I2C_MASTER_CTRL8: | ||
390 | case RT5677_DMIC_CTRL1: | ||
391 | case RT5677_DMIC_CTRL2: | ||
392 | case RT5677_HAP_GENE_CTRL1: | ||
393 | case RT5677_HAP_GENE_CTRL2: | ||
394 | case RT5677_HAP_GENE_CTRL3: | ||
395 | case RT5677_HAP_GENE_CTRL4: | ||
396 | case RT5677_HAP_GENE_CTRL5: | ||
397 | case RT5677_HAP_GENE_CTRL6: | ||
398 | case RT5677_HAP_GENE_CTRL7: | ||
399 | case RT5677_HAP_GENE_CTRL8: | ||
400 | case RT5677_HAP_GENE_CTRL9: | ||
401 | case RT5677_HAP_GENE_CTRL10: | ||
402 | case RT5677_PWR_DIG1: | ||
403 | case RT5677_PWR_DIG2: | ||
404 | case RT5677_PWR_ANLG1: | ||
405 | case RT5677_PWR_ANLG2: | ||
406 | case RT5677_PWR_DSP1: | ||
407 | case RT5677_PWR_DSP_ST: | ||
408 | case RT5677_PWR_DSP2: | ||
409 | case RT5677_ADC_DAC_HPF_CTRL1: | ||
410 | case RT5677_PRIV_INDEX: | ||
411 | case RT5677_PRIV_DATA: | ||
412 | case RT5677_I2S4_SDP: | ||
413 | case RT5677_I2S1_SDP: | ||
414 | case RT5677_I2S2_SDP: | ||
415 | case RT5677_I2S3_SDP: | ||
416 | case RT5677_CLK_TREE_CTRL1: | ||
417 | case RT5677_CLK_TREE_CTRL2: | ||
418 | case RT5677_CLK_TREE_CTRL3: | ||
419 | case RT5677_PLL1_CTRL1: | ||
420 | case RT5677_PLL1_CTRL2: | ||
421 | case RT5677_PLL2_CTRL1: | ||
422 | case RT5677_PLL2_CTRL2: | ||
423 | case RT5677_GLB_CLK1: | ||
424 | case RT5677_GLB_CLK2: | ||
425 | case RT5677_ASRC_1: | ||
426 | case RT5677_ASRC_2: | ||
427 | case RT5677_ASRC_3: | ||
428 | case RT5677_ASRC_4: | ||
429 | case RT5677_ASRC_5: | ||
430 | case RT5677_ASRC_6: | ||
431 | case RT5677_ASRC_7: | ||
432 | case RT5677_ASRC_8: | ||
433 | case RT5677_ASRC_9: | ||
434 | case RT5677_ASRC_10: | ||
435 | case RT5677_ASRC_11: | ||
436 | case RT5677_ASRC_12: | ||
437 | case RT5677_ASRC_13: | ||
438 | case RT5677_ASRC_14: | ||
439 | case RT5677_ASRC_15: | ||
440 | case RT5677_ASRC_16: | ||
441 | case RT5677_ASRC_17: | ||
442 | case RT5677_ASRC_18: | ||
443 | case RT5677_ASRC_19: | ||
444 | case RT5677_ASRC_20: | ||
445 | case RT5677_ASRC_21: | ||
446 | case RT5677_ASRC_22: | ||
447 | case RT5677_ASRC_23: | ||
448 | case RT5677_VAD_CTRL1: | ||
449 | case RT5677_VAD_CTRL2: | ||
450 | case RT5677_VAD_CTRL3: | ||
451 | case RT5677_VAD_CTRL4: | ||
452 | case RT5677_VAD_CTRL5: | ||
453 | case RT5677_DSP_INB_CTRL1: | ||
454 | case RT5677_DSP_INB_CTRL2: | ||
455 | case RT5677_DSP_IN_OUTB_CTRL: | ||
456 | case RT5677_DSP_OUTB0_1_DIG_VOL: | ||
457 | case RT5677_DSP_OUTB2_3_DIG_VOL: | ||
458 | case RT5677_DSP_OUTB4_5_DIG_VOL: | ||
459 | case RT5677_DSP_OUTB6_7_DIG_VOL: | ||
460 | case RT5677_ADC_EQ_CTRL1: | ||
461 | case RT5677_ADC_EQ_CTRL2: | ||
462 | case RT5677_EQ_CTRL1: | ||
463 | case RT5677_EQ_CTRL2: | ||
464 | case RT5677_EQ_CTRL3: | ||
465 | case RT5677_SOFT_VOL_ZERO_CROSS1: | ||
466 | case RT5677_JD_CTRL1: | ||
467 | case RT5677_JD_CTRL2: | ||
468 | case RT5677_JD_CTRL3: | ||
469 | case RT5677_IRQ_CTRL1: | ||
470 | case RT5677_IRQ_CTRL2: | ||
471 | case RT5677_GPIO_ST: | ||
472 | case RT5677_GPIO_CTRL1: | ||
473 | case RT5677_GPIO_CTRL2: | ||
474 | case RT5677_GPIO_CTRL3: | ||
475 | case RT5677_STO1_ADC_HI_FILTER1: | ||
476 | case RT5677_STO1_ADC_HI_FILTER2: | ||
477 | case RT5677_MONO_ADC_HI_FILTER1: | ||
478 | case RT5677_MONO_ADC_HI_FILTER2: | ||
479 | case RT5677_STO2_ADC_HI_FILTER1: | ||
480 | case RT5677_STO2_ADC_HI_FILTER2: | ||
481 | case RT5677_STO3_ADC_HI_FILTER1: | ||
482 | case RT5677_STO3_ADC_HI_FILTER2: | ||
483 | case RT5677_STO4_ADC_HI_FILTER1: | ||
484 | case RT5677_STO4_ADC_HI_FILTER2: | ||
485 | case RT5677_MB_DRC_CTRL1: | ||
486 | case RT5677_DRC1_CTRL1: | ||
487 | case RT5677_DRC1_CTRL2: | ||
488 | case RT5677_DRC1_CTRL3: | ||
489 | case RT5677_DRC1_CTRL4: | ||
490 | case RT5677_DRC1_CTRL5: | ||
491 | case RT5677_DRC1_CTRL6: | ||
492 | case RT5677_DRC2_CTRL1: | ||
493 | case RT5677_DRC2_CTRL2: | ||
494 | case RT5677_DRC2_CTRL3: | ||
495 | case RT5677_DRC2_CTRL4: | ||
496 | case RT5677_DRC2_CTRL5: | ||
497 | case RT5677_DRC2_CTRL6: | ||
498 | case RT5677_DRC1_HL_CTRL1: | ||
499 | case RT5677_DRC1_HL_CTRL2: | ||
500 | case RT5677_DRC2_HL_CTRL1: | ||
501 | case RT5677_DRC2_HL_CTRL2: | ||
502 | case RT5677_DSP_INB1_SRC_CTRL1: | ||
503 | case RT5677_DSP_INB1_SRC_CTRL2: | ||
504 | case RT5677_DSP_INB1_SRC_CTRL3: | ||
505 | case RT5677_DSP_INB1_SRC_CTRL4: | ||
506 | case RT5677_DSP_INB2_SRC_CTRL1: | ||
507 | case RT5677_DSP_INB2_SRC_CTRL2: | ||
508 | case RT5677_DSP_INB2_SRC_CTRL3: | ||
509 | case RT5677_DSP_INB2_SRC_CTRL4: | ||
510 | case RT5677_DSP_INB3_SRC_CTRL1: | ||
511 | case RT5677_DSP_INB3_SRC_CTRL2: | ||
512 | case RT5677_DSP_INB3_SRC_CTRL3: | ||
513 | case RT5677_DSP_INB3_SRC_CTRL4: | ||
514 | case RT5677_DSP_OUTB1_SRC_CTRL1: | ||
515 | case RT5677_DSP_OUTB1_SRC_CTRL2: | ||
516 | case RT5677_DSP_OUTB1_SRC_CTRL3: | ||
517 | case RT5677_DSP_OUTB1_SRC_CTRL4: | ||
518 | case RT5677_DSP_OUTB2_SRC_CTRL1: | ||
519 | case RT5677_DSP_OUTB2_SRC_CTRL2: | ||
520 | case RT5677_DSP_OUTB2_SRC_CTRL3: | ||
521 | case RT5677_DSP_OUTB2_SRC_CTRL4: | ||
522 | case RT5677_DSP_OUTB_0123_MIXER_CTRL: | ||
523 | case RT5677_DSP_OUTB_45_MIXER_CTRL: | ||
524 | case RT5677_DSP_OUTB_67_MIXER_CTRL: | ||
525 | case RT5677_DIG_MISC: | ||
526 | case RT5677_GEN_CTRL1: | ||
527 | case RT5677_GEN_CTRL2: | ||
528 | case RT5677_VENDOR_ID: | ||
529 | case RT5677_VENDOR_ID1: | ||
530 | case RT5677_VENDOR_ID2: | ||
531 | return true; | ||
532 | default: | ||
533 | return false; | ||
534 | } | ||
535 | } | ||
536 | |||
537 | static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); | ||
538 | static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0); | ||
539 | static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); | ||
540 | static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0); | ||
541 | static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); | ||
542 | |||
543 | /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ | ||
544 | static unsigned int bst_tlv[] = { | ||
545 | TLV_DB_RANGE_HEAD(7), | ||
546 | 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), | ||
547 | 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), | ||
548 | 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), | ||
549 | 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), | ||
550 | 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), | ||
551 | 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), | ||
552 | 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0), | ||
553 | }; | ||
554 | |||
555 | static const struct snd_kcontrol_new rt5677_snd_controls[] = { | ||
556 | /* OUTPUT Control */ | ||
557 | SOC_SINGLE("OUT1 Playback Switch", RT5677_LOUT1, | ||
558 | RT5677_LOUT1_L_MUTE_SFT, 1, 1), | ||
559 | SOC_SINGLE("OUT2 Playback Switch", RT5677_LOUT1, | ||
560 | RT5677_LOUT2_L_MUTE_SFT, 1, 1), | ||
561 | SOC_SINGLE("OUT3 Playback Switch", RT5677_LOUT1, | ||
562 | RT5677_LOUT3_L_MUTE_SFT, 1, 1), | ||
563 | |||
564 | /* DAC Digital Volume */ | ||
565 | SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5677_DAC1_DIG_VOL, | ||
566 | RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 175, 0, dac_vol_tlv), | ||
567 | SOC_DOUBLE_TLV("DAC2 Playback Volume", RT5677_DAC2_DIG_VOL, | ||
568 | RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 175, 0, dac_vol_tlv), | ||
569 | SOC_DOUBLE_TLV("DAC3 Playback Volume", RT5677_DAC3_DIG_VOL, | ||
570 | RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 175, 0, dac_vol_tlv), | ||
571 | SOC_DOUBLE_TLV("DAC4 Playback Volume", RT5677_DAC4_DIG_VOL, | ||
572 | RT5677_L_VOL_SFT, RT5677_R_VOL_SFT, 175, 0, dac_vol_tlv), | ||
573 | |||
574 | /* IN1/IN2 Control */ | ||
575 | SOC_SINGLE_TLV("IN1 Boost", RT5677_IN1, RT5677_BST_SFT1, 8, 0, bst_tlv), | ||
576 | SOC_SINGLE_TLV("IN2 Boost", RT5677_IN1, RT5677_BST_SFT2, 8, 0, bst_tlv), | ||
577 | |||
578 | /* ADC Digital Volume Control */ | ||
579 | SOC_DOUBLE("ADC1 Capture Switch", RT5677_STO1_ADC_DIG_VOL, | ||
580 | RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), | ||
581 | SOC_DOUBLE("ADC2 Capture Switch", RT5677_STO2_ADC_DIG_VOL, | ||
582 | RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), | ||
583 | SOC_DOUBLE("ADC3 Capture Switch", RT5677_STO3_ADC_DIG_VOL, | ||
584 | RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), | ||
585 | SOC_DOUBLE("ADC4 Capture Switch", RT5677_STO4_ADC_DIG_VOL, | ||
586 | RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), | ||
587 | SOC_DOUBLE("Mono ADC Capture Switch", RT5677_MONO_ADC_DIG_VOL, | ||
588 | RT5677_L_MUTE_SFT, RT5677_R_MUTE_SFT, 1, 1), | ||
589 | |||
590 | SOC_DOUBLE_TLV("ADC1 Capture Volume", RT5677_STO1_ADC_DIG_VOL, | ||
591 | RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 127, 0, | ||
592 | adc_vol_tlv), | ||
593 | SOC_DOUBLE_TLV("ADC2 Capture Volume", RT5677_STO2_ADC_DIG_VOL, | ||
594 | RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 127, 0, | ||
595 | adc_vol_tlv), | ||
596 | SOC_DOUBLE_TLV("ADC3 Capture Volume", RT5677_STO3_ADC_DIG_VOL, | ||
597 | RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 127, 0, | ||
598 | adc_vol_tlv), | ||
599 | SOC_DOUBLE_TLV("ADC4 Capture Volume", RT5677_STO4_ADC_DIG_VOL, | ||
600 | RT5677_STO1_ADC_L_VOL_SFT, RT5677_STO1_ADC_R_VOL_SFT, 127, 0, | ||
601 | adc_vol_tlv), | ||
602 | SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5677_MONO_ADC_DIG_VOL, | ||
603 | RT5677_MONO_ADC_L_VOL_SFT, RT5677_MONO_ADC_R_VOL_SFT, 127, 0, | ||
604 | adc_vol_tlv), | ||
605 | |||
606 | /* ADC Boost Volume Control */ | ||
607 | SOC_DOUBLE_TLV("STO1 ADC Boost Gain", RT5677_STO1_2_ADC_BST, | ||
608 | RT5677_STO1_ADC_L_BST_SFT, RT5677_STO1_ADC_R_BST_SFT, 3, 0, | ||
609 | adc_bst_tlv), | ||
610 | SOC_DOUBLE_TLV("STO2 ADC Boost Gain", RT5677_STO1_2_ADC_BST, | ||
611 | RT5677_STO2_ADC_L_BST_SFT, RT5677_STO2_ADC_R_BST_SFT, 3, 0, | ||
612 | adc_bst_tlv), | ||
613 | SOC_DOUBLE_TLV("STO3 ADC Boost Gain", RT5677_STO3_4_ADC_BST, | ||
614 | RT5677_STO3_ADC_L_BST_SFT, RT5677_STO3_ADC_R_BST_SFT, 3, 0, | ||
615 | adc_bst_tlv), | ||
616 | SOC_DOUBLE_TLV("STO4 ADC Boost Gain", RT5677_STO3_4_ADC_BST, | ||
617 | RT5677_STO4_ADC_L_BST_SFT, RT5677_STO4_ADC_R_BST_SFT, 3, 0, | ||
618 | adc_bst_tlv), | ||
619 | SOC_DOUBLE_TLV("Mono ADC Boost Gain", RT5677_ADC_BST_CTRL2, | ||
620 | RT5677_MONO_ADC_L_BST_SFT, RT5677_MONO_ADC_R_BST_SFT, 3, 0, | ||
621 | adc_bst_tlv), | ||
622 | }; | ||
623 | |||
624 | /** | ||
625 | * set_dmic_clk - Set parameter of dmic. | ||
626 | * | ||
627 | * @w: DAPM widget. | ||
628 | * @kcontrol: The kcontrol of this widget. | ||
629 | * @event: Event id. | ||
630 | * | ||
631 | * Choose dmic clock between 1MHz and 3MHz. | ||
632 | * It is better for clock to approximate 3MHz. | ||
633 | */ | ||
634 | static int set_dmic_clk(struct snd_soc_dapm_widget *w, | ||
635 | struct snd_kcontrol *kcontrol, int event) | ||
636 | { | ||
637 | struct snd_soc_codec *codec = w->codec; | ||
638 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
639 | int div[] = {2, 3, 4, 6, 8, 12}, idx = -EINVAL, i; | ||
640 | int rate, red, bound, temp; | ||
641 | |||
642 | rate = rt5677->sysclk; | ||
643 | red = 3000000 * 12; | ||
644 | for (i = 0; i < ARRAY_SIZE(div); i++) { | ||
645 | bound = div[i] * 3000000; | ||
646 | if (rate > bound) | ||
647 | continue; | ||
648 | temp = bound - rate; | ||
649 | if (temp < red) { | ||
650 | red = temp; | ||
651 | idx = i; | ||
652 | } | ||
653 | } | ||
654 | |||
655 | if (idx < 0) | ||
656 | dev_err(codec->dev, "Failed to set DMIC clock\n"); | ||
657 | else | ||
658 | regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1, | ||
659 | RT5677_DMIC_CLK_MASK, idx << RT5677_DMIC_CLK_SFT); | ||
660 | return idx; | ||
661 | } | ||
662 | |||
663 | static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, | ||
664 | struct snd_soc_dapm_widget *sink) | ||
665 | { | ||
666 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(source->codec); | ||
667 | unsigned int val; | ||
668 | |||
669 | regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val); | ||
670 | val &= RT5677_SCLK_SRC_MASK; | ||
671 | if (val == RT5677_SCLK_SRC_PLL1) | ||
672 | return 1; | ||
673 | else | ||
674 | return 0; | ||
675 | } | ||
676 | |||
677 | /* Digital Mixer */ | ||
678 | static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = { | ||
679 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER, | ||
680 | RT5677_M_STO1_ADC_L1_SFT, 1, 1), | ||
681 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER, | ||
682 | RT5677_M_STO1_ADC_L2_SFT, 1, 1), | ||
683 | }; | ||
684 | |||
685 | static const struct snd_kcontrol_new rt5677_sto1_adc_r_mix[] = { | ||
686 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER, | ||
687 | RT5677_M_STO1_ADC_R1_SFT, 1, 1), | ||
688 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO1_ADC_MIXER, | ||
689 | RT5677_M_STO1_ADC_R2_SFT, 1, 1), | ||
690 | }; | ||
691 | |||
692 | static const struct snd_kcontrol_new rt5677_sto2_adc_l_mix[] = { | ||
693 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER, | ||
694 | RT5677_M_STO2_ADC_L1_SFT, 1, 1), | ||
695 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER, | ||
696 | RT5677_M_STO2_ADC_L2_SFT, 1, 1), | ||
697 | }; | ||
698 | |||
699 | static const struct snd_kcontrol_new rt5677_sto2_adc_r_mix[] = { | ||
700 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO2_ADC_MIXER, | ||
701 | RT5677_M_STO2_ADC_R1_SFT, 1, 1), | ||
702 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO2_ADC_MIXER, | ||
703 | RT5677_M_STO2_ADC_R2_SFT, 1, 1), | ||
704 | }; | ||
705 | |||
706 | static const struct snd_kcontrol_new rt5677_sto3_adc_l_mix[] = { | ||
707 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER, | ||
708 | RT5677_M_STO3_ADC_L1_SFT, 1, 1), | ||
709 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER, | ||
710 | RT5677_M_STO3_ADC_L2_SFT, 1, 1), | ||
711 | }; | ||
712 | |||
713 | static const struct snd_kcontrol_new rt5677_sto3_adc_r_mix[] = { | ||
714 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO3_ADC_MIXER, | ||
715 | RT5677_M_STO3_ADC_R1_SFT, 1, 1), | ||
716 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO3_ADC_MIXER, | ||
717 | RT5677_M_STO3_ADC_R2_SFT, 1, 1), | ||
718 | }; | ||
719 | |||
720 | static const struct snd_kcontrol_new rt5677_sto4_adc_l_mix[] = { | ||
721 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER, | ||
722 | RT5677_M_STO4_ADC_L1_SFT, 1, 1), | ||
723 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER, | ||
724 | RT5677_M_STO4_ADC_L2_SFT, 1, 1), | ||
725 | }; | ||
726 | |||
727 | static const struct snd_kcontrol_new rt5677_sto4_adc_r_mix[] = { | ||
728 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO4_ADC_MIXER, | ||
729 | RT5677_M_STO4_ADC_R1_SFT, 1, 1), | ||
730 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_STO4_ADC_MIXER, | ||
731 | RT5677_M_STO4_ADC_R2_SFT, 1, 1), | ||
732 | }; | ||
733 | |||
734 | static const struct snd_kcontrol_new rt5677_mono_adc_l_mix[] = { | ||
735 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER, | ||
736 | RT5677_M_MONO_ADC_L1_SFT, 1, 1), | ||
737 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER, | ||
738 | RT5677_M_MONO_ADC_L2_SFT, 1, 1), | ||
739 | }; | ||
740 | |||
741 | static const struct snd_kcontrol_new rt5677_mono_adc_r_mix[] = { | ||
742 | SOC_DAPM_SINGLE("ADC1 Switch", RT5677_MONO_ADC_MIXER, | ||
743 | RT5677_M_MONO_ADC_R1_SFT, 1, 1), | ||
744 | SOC_DAPM_SINGLE("ADC2 Switch", RT5677_MONO_ADC_MIXER, | ||
745 | RT5677_M_MONO_ADC_R2_SFT, 1, 1), | ||
746 | }; | ||
747 | |||
748 | static const struct snd_kcontrol_new rt5677_dac_l_mix[] = { | ||
749 | SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER, | ||
750 | RT5677_M_ADDA_MIXER1_L_SFT, 1, 1), | ||
751 | SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER, | ||
752 | RT5677_M_DAC1_L_SFT, 1, 1), | ||
753 | }; | ||
754 | |||
755 | static const struct snd_kcontrol_new rt5677_dac_r_mix[] = { | ||
756 | SOC_DAPM_SINGLE("Stereo ADC Switch", RT5677_ADC_IF_DSP_DAC1_MIXER, | ||
757 | RT5677_M_ADDA_MIXER1_R_SFT, 1, 1), | ||
758 | SOC_DAPM_SINGLE("DAC1 Switch", RT5677_ADC_IF_DSP_DAC1_MIXER, | ||
759 | RT5677_M_DAC1_R_SFT, 1, 1), | ||
760 | }; | ||
761 | |||
762 | static const struct snd_kcontrol_new rt5677_sto1_dac_l_mix[] = { | ||
763 | SOC_DAPM_SINGLE("ST L Switch", RT5677_STO1_DAC_MIXER, | ||
764 | RT5677_M_ST_DAC1_L_SFT, 1, 1), | ||
765 | SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER, | ||
766 | RT5677_M_DAC1_L_STO_L_SFT, 1, 1), | ||
767 | SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_STO1_DAC_MIXER, | ||
768 | RT5677_M_DAC2_L_STO_L_SFT, 1, 1), | ||
769 | SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER, | ||
770 | RT5677_M_DAC1_R_STO_L_SFT, 1, 1), | ||
771 | }; | ||
772 | |||
773 | static const struct snd_kcontrol_new rt5677_sto1_dac_r_mix[] = { | ||
774 | SOC_DAPM_SINGLE("ST R Switch", RT5677_STO1_DAC_MIXER, | ||
775 | RT5677_M_ST_DAC1_R_SFT, 1, 1), | ||
776 | SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_STO1_DAC_MIXER, | ||
777 | RT5677_M_DAC1_R_STO_R_SFT, 1, 1), | ||
778 | SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_STO1_DAC_MIXER, | ||
779 | RT5677_M_DAC2_R_STO_R_SFT, 1, 1), | ||
780 | SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_STO1_DAC_MIXER, | ||
781 | RT5677_M_DAC1_L_STO_R_SFT, 1, 1), | ||
782 | }; | ||
783 | |||
784 | static const struct snd_kcontrol_new rt5677_mono_dac_l_mix[] = { | ||
785 | SOC_DAPM_SINGLE("ST L Switch", RT5677_MONO_DAC_MIXER, | ||
786 | RT5677_M_ST_DAC2_L_SFT, 1, 1), | ||
787 | SOC_DAPM_SINGLE("DAC1 L Switch", RT5677_MONO_DAC_MIXER, | ||
788 | RT5677_M_DAC1_L_MONO_L_SFT, 1, 1), | ||
789 | SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER, | ||
790 | RT5677_M_DAC2_L_MONO_L_SFT, 1, 1), | ||
791 | SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER, | ||
792 | RT5677_M_DAC2_R_MONO_L_SFT, 1, 1), | ||
793 | }; | ||
794 | |||
795 | static const struct snd_kcontrol_new rt5677_mono_dac_r_mix[] = { | ||
796 | SOC_DAPM_SINGLE("ST R Switch", RT5677_MONO_DAC_MIXER, | ||
797 | RT5677_M_ST_DAC2_R_SFT, 1, 1), | ||
798 | SOC_DAPM_SINGLE("DAC1 R Switch", RT5677_MONO_DAC_MIXER, | ||
799 | RT5677_M_DAC1_R_MONO_R_SFT, 1, 1), | ||
800 | SOC_DAPM_SINGLE("DAC2 R Switch", RT5677_MONO_DAC_MIXER, | ||
801 | RT5677_M_DAC2_R_MONO_R_SFT, 1, 1), | ||
802 | SOC_DAPM_SINGLE("DAC2 L Switch", RT5677_MONO_DAC_MIXER, | ||
803 | RT5677_M_DAC2_L_MONO_R_SFT, 1, 1), | ||
804 | }; | ||
805 | |||
806 | static const struct snd_kcontrol_new rt5677_dd1_l_mix[] = { | ||
807 | SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD1_MIXER, | ||
808 | RT5677_M_STO_L_DD1_L_SFT, 1, 1), | ||
809 | SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD1_MIXER, | ||
810 | RT5677_M_MONO_L_DD1_L_SFT, 1, 1), | ||
811 | SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER, | ||
812 | RT5677_M_DAC3_L_DD1_L_SFT, 1, 1), | ||
813 | SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER, | ||
814 | RT5677_M_DAC3_R_DD1_L_SFT, 1, 1), | ||
815 | }; | ||
816 | |||
817 | static const struct snd_kcontrol_new rt5677_dd1_r_mix[] = { | ||
818 | SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD1_MIXER, | ||
819 | RT5677_M_STO_R_DD1_R_SFT, 1, 1), | ||
820 | SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD1_MIXER, | ||
821 | RT5677_M_MONO_R_DD1_R_SFT, 1, 1), | ||
822 | SOC_DAPM_SINGLE("DAC3 R Switch", RT5677_DD1_MIXER, | ||
823 | RT5677_M_DAC3_R_DD1_R_SFT, 1, 1), | ||
824 | SOC_DAPM_SINGLE("DAC3 L Switch", RT5677_DD1_MIXER, | ||
825 | RT5677_M_DAC3_L_DD1_R_SFT, 1, 1), | ||
826 | }; | ||
827 | |||
828 | static const struct snd_kcontrol_new rt5677_dd2_l_mix[] = { | ||
829 | SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5677_DD2_MIXER, | ||
830 | RT5677_M_STO_L_DD2_L_SFT, 1, 1), | ||
831 | SOC_DAPM_SINGLE("Mono DAC Mix L Switch", RT5677_DD2_MIXER, | ||
832 | RT5677_M_MONO_L_DD2_L_SFT, 1, 1), | ||
833 | SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER, | ||
834 | RT5677_M_DAC4_L_DD2_L_SFT, 1, 1), | ||
835 | SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER, | ||
836 | RT5677_M_DAC4_R_DD2_L_SFT, 1, 1), | ||
837 | }; | ||
838 | |||
839 | static const struct snd_kcontrol_new rt5677_dd2_r_mix[] = { | ||
840 | SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5677_DD2_MIXER, | ||
841 | RT5677_M_STO_R_DD2_R_SFT, 1, 1), | ||
842 | SOC_DAPM_SINGLE("Mono DAC Mix R Switch", RT5677_DD2_MIXER, | ||
843 | RT5677_M_MONO_R_DD2_R_SFT, 1, 1), | ||
844 | SOC_DAPM_SINGLE("DAC4 R Switch", RT5677_DD2_MIXER, | ||
845 | RT5677_M_DAC4_R_DD2_R_SFT, 1, 1), | ||
846 | SOC_DAPM_SINGLE("DAC4 L Switch", RT5677_DD2_MIXER, | ||
847 | RT5677_M_DAC4_L_DD2_R_SFT, 1, 1), | ||
848 | }; | ||
849 | |||
850 | static const struct snd_kcontrol_new rt5677_ob_01_mix[] = { | ||
851 | SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
852 | RT5677_DSP_IB_01_H_SFT, 1, 1), | ||
853 | SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
854 | RT5677_DSP_IB_23_H_SFT, 1, 1), | ||
855 | SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
856 | RT5677_DSP_IB_45_H_SFT, 1, 1), | ||
857 | SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
858 | RT5677_DSP_IB_6_H_SFT, 1, 1), | ||
859 | SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
860 | RT5677_DSP_IB_7_H_SFT, 1, 1), | ||
861 | SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
862 | RT5677_DSP_IB_8_H_SFT, 1, 1), | ||
863 | SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
864 | RT5677_DSP_IB_9_H_SFT, 1, 1), | ||
865 | }; | ||
866 | |||
867 | static const struct snd_kcontrol_new rt5677_ob_23_mix[] = { | ||
868 | SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
869 | RT5677_DSP_IB_01_L_SFT, 1, 1), | ||
870 | SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
871 | RT5677_DSP_IB_23_L_SFT, 1, 1), | ||
872 | SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
873 | RT5677_DSP_IB_45_L_SFT, 1, 1), | ||
874 | SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
875 | RT5677_DSP_IB_6_L_SFT, 1, 1), | ||
876 | SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
877 | RT5677_DSP_IB_7_L_SFT, 1, 1), | ||
878 | SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
879 | RT5677_DSP_IB_8_L_SFT, 1, 1), | ||
880 | SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_0123_MIXER_CTRL, | ||
881 | RT5677_DSP_IB_9_L_SFT, 1, 1), | ||
882 | }; | ||
883 | |||
884 | static const struct snd_kcontrol_new rt5677_ob_4_mix[] = { | ||
885 | SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
886 | RT5677_DSP_IB_01_H_SFT, 1, 1), | ||
887 | SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
888 | RT5677_DSP_IB_23_H_SFT, 1, 1), | ||
889 | SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
890 | RT5677_DSP_IB_45_H_SFT, 1, 1), | ||
891 | SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
892 | RT5677_DSP_IB_6_H_SFT, 1, 1), | ||
893 | SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
894 | RT5677_DSP_IB_7_H_SFT, 1, 1), | ||
895 | SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
896 | RT5677_DSP_IB_8_H_SFT, 1, 1), | ||
897 | SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
898 | RT5677_DSP_IB_9_H_SFT, 1, 1), | ||
899 | }; | ||
900 | |||
901 | static const struct snd_kcontrol_new rt5677_ob_5_mix[] = { | ||
902 | SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
903 | RT5677_DSP_IB_01_L_SFT, 1, 1), | ||
904 | SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
905 | RT5677_DSP_IB_23_L_SFT, 1, 1), | ||
906 | SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
907 | RT5677_DSP_IB_45_L_SFT, 1, 1), | ||
908 | SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
909 | RT5677_DSP_IB_6_L_SFT, 1, 1), | ||
910 | SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
911 | RT5677_DSP_IB_7_L_SFT, 1, 1), | ||
912 | SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
913 | RT5677_DSP_IB_8_L_SFT, 1, 1), | ||
914 | SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_45_MIXER_CTRL, | ||
915 | RT5677_DSP_IB_9_L_SFT, 1, 1), | ||
916 | }; | ||
917 | |||
918 | static const struct snd_kcontrol_new rt5677_ob_6_mix[] = { | ||
919 | SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
920 | RT5677_DSP_IB_01_H_SFT, 1, 1), | ||
921 | SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
922 | RT5677_DSP_IB_23_H_SFT, 1, 1), | ||
923 | SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
924 | RT5677_DSP_IB_45_H_SFT, 1, 1), | ||
925 | SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
926 | RT5677_DSP_IB_6_H_SFT, 1, 1), | ||
927 | SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
928 | RT5677_DSP_IB_7_H_SFT, 1, 1), | ||
929 | SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
930 | RT5677_DSP_IB_8_H_SFT, 1, 1), | ||
931 | SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
932 | RT5677_DSP_IB_9_H_SFT, 1, 1), | ||
933 | }; | ||
934 | |||
935 | static const struct snd_kcontrol_new rt5677_ob_7_mix[] = { | ||
936 | SOC_DAPM_SINGLE("IB01 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
937 | RT5677_DSP_IB_01_L_SFT, 1, 1), | ||
938 | SOC_DAPM_SINGLE("IB23 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
939 | RT5677_DSP_IB_23_L_SFT, 1, 1), | ||
940 | SOC_DAPM_SINGLE("IB45 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
941 | RT5677_DSP_IB_45_L_SFT, 1, 1), | ||
942 | SOC_DAPM_SINGLE("IB6 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
943 | RT5677_DSP_IB_6_L_SFT, 1, 1), | ||
944 | SOC_DAPM_SINGLE("IB7 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
945 | RT5677_DSP_IB_7_L_SFT, 1, 1), | ||
946 | SOC_DAPM_SINGLE("IB8 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
947 | RT5677_DSP_IB_8_L_SFT, 1, 1), | ||
948 | SOC_DAPM_SINGLE("IB9 Switch", RT5677_DSP_OUTB_67_MIXER_CTRL, | ||
949 | RT5677_DSP_IB_9_L_SFT, 1, 1), | ||
950 | }; | ||
951 | |||
952 | |||
953 | /* Mux */ | ||
954 | /* DAC1 L/R source */ /* MX-29 [10:8] */ | ||
955 | static const char * const rt5677_dac1_src[] = { | ||
956 | "IF1 DAC 01", "IF2 DAC 01", "IF3 DAC LR", "IF4 DAC LR", "SLB DAC 01", | ||
957 | "OB 01" | ||
958 | }; | ||
959 | |||
960 | static SOC_ENUM_SINGLE_DECL( | ||
961 | rt5677_dac1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER, | ||
962 | RT5677_DAC1_L_SEL_SFT, rt5677_dac1_src); | ||
963 | |||
964 | static const struct snd_kcontrol_new rt5677_dac1_mux = | ||
965 | SOC_DAPM_ENUM("DAC1 source", rt5677_dac1_enum); | ||
966 | |||
967 | /* ADDA1 L/R source */ /* MX-29 [1:0] */ | ||
968 | static const char * const rt5677_adda1_src[] = { | ||
969 | "STO1 ADC MIX", "STO2 ADC MIX", "OB 67", | ||
970 | }; | ||
971 | |||
972 | static SOC_ENUM_SINGLE_DECL( | ||
973 | rt5677_adda1_enum, RT5677_ADC_IF_DSP_DAC1_MIXER, | ||
974 | RT5677_ADDA1_SEL_SFT, rt5677_adda1_src); | ||
975 | |||
976 | static const struct snd_kcontrol_new rt5677_adda1_mux = | ||
977 | SOC_DAPM_ENUM("ADDA1 source", rt5677_adda1_enum); | ||
978 | |||
979 | |||
980 | /*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */ | ||
981 | static const char * const rt5677_dac2l_src[] = { | ||
982 | "IF1 DAC 2", "IF2 DAC 2", "IF3 DAC L", "IF4 DAC L", "SLB DAC 2", | ||
983 | "OB 2", | ||
984 | }; | ||
985 | |||
986 | static SOC_ENUM_SINGLE_DECL( | ||
987 | rt5677_dac2l_enum, RT5677_IF_DSP_DAC2_MIXER, | ||
988 | RT5677_SEL_DAC2_L_SRC_SFT, rt5677_dac2l_src); | ||
989 | |||
990 | static const struct snd_kcontrol_new rt5677_dac2_l_mux = | ||
991 | SOC_DAPM_ENUM("DAC2 L source", rt5677_dac2l_enum); | ||
992 | |||
993 | static const char * const rt5677_dac2r_src[] = { | ||
994 | "IF1 DAC 3", "IF2 DAC 3", "IF3 DAC R", "IF4 DAC R", "SLB DAC 3", | ||
995 | "OB 3", "Haptic Generator", "VAD ADC" | ||
996 | }; | ||
997 | |||
998 | static SOC_ENUM_SINGLE_DECL( | ||
999 | rt5677_dac2r_enum, RT5677_IF_DSP_DAC2_MIXER, | ||
1000 | RT5677_SEL_DAC2_R_SRC_SFT, rt5677_dac2r_src); | ||
1001 | |||
1002 | static const struct snd_kcontrol_new rt5677_dac2_r_mux = | ||
1003 | SOC_DAPM_ENUM("DAC2 R source", rt5677_dac2r_enum); | ||
1004 | |||
1005 | /*DAC3 L/R source*/ /* MX-16 [6:4] [2:0] */ | ||
1006 | static const char * const rt5677_dac3l_src[] = { | ||
1007 | "IF1 DAC 4", "IF2 DAC 4", "IF3 DAC L", "IF4 DAC L", | ||
1008 | "SLB DAC 4", "OB 4" | ||
1009 | }; | ||
1010 | |||
1011 | static SOC_ENUM_SINGLE_DECL( | ||
1012 | rt5677_dac3l_enum, RT5677_IF_DSP_DAC3_4_MIXER, | ||
1013 | RT5677_SEL_DAC3_L_SRC_SFT, rt5677_dac3l_src); | ||
1014 | |||
1015 | static const struct snd_kcontrol_new rt5677_dac3_l_mux = | ||
1016 | SOC_DAPM_ENUM("DAC3 L source", rt5677_dac3l_enum); | ||
1017 | |||
1018 | static const char * const rt5677_dac3r_src[] = { | ||
1019 | "IF1 DAC 5", "IF2 DAC 5", "IF3 DAC R", "IF4 DAC R", | ||
1020 | "SLB DAC 5", "OB 5" | ||
1021 | }; | ||
1022 | |||
1023 | static SOC_ENUM_SINGLE_DECL( | ||
1024 | rt5677_dac3r_enum, RT5677_IF_DSP_DAC3_4_MIXER, | ||
1025 | RT5677_SEL_DAC3_R_SRC_SFT, rt5677_dac3r_src); | ||
1026 | |||
1027 | static const struct snd_kcontrol_new rt5677_dac3_r_mux = | ||
1028 | SOC_DAPM_ENUM("DAC3 R source", rt5677_dac3r_enum); | ||
1029 | |||
1030 | /*DAC4 L/R source*/ /* MX-16 [14:12] [10:8] */ | ||
1031 | static const char * const rt5677_dac4l_src[] = { | ||
1032 | "IF1 DAC 6", "IF2 DAC 6", "IF3 DAC L", "IF4 DAC L", | ||
1033 | "SLB DAC 6", "OB 6" | ||
1034 | }; | ||
1035 | |||
1036 | static SOC_ENUM_SINGLE_DECL( | ||
1037 | rt5677_dac4l_enum, RT5677_IF_DSP_DAC3_4_MIXER, | ||
1038 | RT5677_SEL_DAC4_L_SRC_SFT, rt5677_dac4l_src); | ||
1039 | |||
1040 | static const struct snd_kcontrol_new rt5677_dac4_l_mux = | ||
1041 | SOC_DAPM_ENUM("DAC4 L source", rt5677_dac4l_enum); | ||
1042 | |||
1043 | static const char * const rt5677_dac4r_src[] = { | ||
1044 | "IF1 DAC 7", "IF2 DAC 7", "IF3 DAC R", "IF4 DAC R", | ||
1045 | "SLB DAC 7", "OB 7" | ||
1046 | }; | ||
1047 | |||
1048 | static SOC_ENUM_SINGLE_DECL( | ||
1049 | rt5677_dac4r_enum, RT5677_IF_DSP_DAC3_4_MIXER, | ||
1050 | RT5677_SEL_DAC4_R_SRC_SFT, rt5677_dac4r_src); | ||
1051 | |||
1052 | static const struct snd_kcontrol_new rt5677_dac4_r_mux = | ||
1053 | SOC_DAPM_ENUM("DAC4 R source", rt5677_dac4r_enum); | ||
1054 | |||
1055 | /* In/OutBound Source Pass SRC */ /* MX-A5 [3] [4] [0] [1] [2] */ | ||
1056 | static const char * const rt5677_iob_bypass_src[] = { | ||
1057 | "Bypass", "Pass SRC" | ||
1058 | }; | ||
1059 | |||
1060 | static SOC_ENUM_SINGLE_DECL( | ||
1061 | rt5677_ob01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, | ||
1062 | RT5677_SEL_SRC_OB01_SFT, rt5677_iob_bypass_src); | ||
1063 | |||
1064 | static const struct snd_kcontrol_new rt5677_ob01_bypass_src_mux = | ||
1065 | SOC_DAPM_ENUM("OB01 Bypass source", rt5677_ob01_bypass_src_enum); | ||
1066 | |||
1067 | static SOC_ENUM_SINGLE_DECL( | ||
1068 | rt5677_ob23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, | ||
1069 | RT5677_SEL_SRC_OB23_SFT, rt5677_iob_bypass_src); | ||
1070 | |||
1071 | static const struct snd_kcontrol_new rt5677_ob23_bypass_src_mux = | ||
1072 | SOC_DAPM_ENUM("OB23 Bypass source", rt5677_ob23_bypass_src_enum); | ||
1073 | |||
1074 | static SOC_ENUM_SINGLE_DECL( | ||
1075 | rt5677_ib01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, | ||
1076 | RT5677_SEL_SRC_IB01_SFT, rt5677_iob_bypass_src); | ||
1077 | |||
1078 | static const struct snd_kcontrol_new rt5677_ib01_bypass_src_mux = | ||
1079 | SOC_DAPM_ENUM("IB01 Bypass source", rt5677_ib01_bypass_src_enum); | ||
1080 | |||
1081 | static SOC_ENUM_SINGLE_DECL( | ||
1082 | rt5677_ib23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, | ||
1083 | RT5677_SEL_SRC_IB23_SFT, rt5677_iob_bypass_src); | ||
1084 | |||
1085 | static const struct snd_kcontrol_new rt5677_ib23_bypass_src_mux = | ||
1086 | SOC_DAPM_ENUM("IB23 Bypass source", rt5677_ib23_bypass_src_enum); | ||
1087 | |||
1088 | static SOC_ENUM_SINGLE_DECL( | ||
1089 | rt5677_ib45_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, | ||
1090 | RT5677_SEL_SRC_IB45_SFT, rt5677_iob_bypass_src); | ||
1091 | |||
1092 | static const struct snd_kcontrol_new rt5677_ib45_bypass_src_mux = | ||
1093 | SOC_DAPM_ENUM("IB45 Bypass source", rt5677_ib45_bypass_src_enum); | ||
1094 | |||
1095 | /* Stereo ADC Source 2 */ /* MX-27 MX26 MX25 [11:10] */ | ||
1096 | static const char * const rt5677_stereo_adc2_src[] = { | ||
1097 | "DD MIX1", "DMIC", "Stereo DAC MIX" | ||
1098 | }; | ||
1099 | |||
1100 | static SOC_ENUM_SINGLE_DECL( | ||
1101 | rt5677_stereo1_adc2_enum, RT5677_STO1_ADC_MIXER, | ||
1102 | RT5677_SEL_STO1_ADC2_SFT, rt5677_stereo_adc2_src); | ||
1103 | |||
1104 | static const struct snd_kcontrol_new rt5677_sto1_adc2_mux = | ||
1105 | SOC_DAPM_ENUM("Stereo1 ADC2 source", rt5677_stereo1_adc2_enum); | ||
1106 | |||
1107 | static SOC_ENUM_SINGLE_DECL( | ||
1108 | rt5677_stereo2_adc2_enum, RT5677_STO2_ADC_MIXER, | ||
1109 | RT5677_SEL_STO2_ADC2_SFT, rt5677_stereo_adc2_src); | ||
1110 | |||
1111 | static const struct snd_kcontrol_new rt5677_sto2_adc2_mux = | ||
1112 | SOC_DAPM_ENUM("Stereo2 ADC2 source", rt5677_stereo2_adc2_enum); | ||
1113 | |||
1114 | static SOC_ENUM_SINGLE_DECL( | ||
1115 | rt5677_stereo3_adc2_enum, RT5677_STO3_ADC_MIXER, | ||
1116 | RT5677_SEL_STO3_ADC2_SFT, rt5677_stereo_adc2_src); | ||
1117 | |||
1118 | static const struct snd_kcontrol_new rt5677_sto3_adc2_mux = | ||
1119 | SOC_DAPM_ENUM("Stereo3 ADC2 source", rt5677_stereo3_adc2_enum); | ||
1120 | |||
1121 | /* DMIC Source */ /* MX-28 [9:8][1:0] MX-27 MX-26 MX-25 MX-24 [9:8] */ | ||
1122 | static const char * const rt5677_dmic_src[] = { | ||
1123 | "DMIC1", "DMIC2", "DMIC3", "DMIC4" | ||
1124 | }; | ||
1125 | |||
1126 | static SOC_ENUM_SINGLE_DECL( | ||
1127 | rt5677_mono_dmic_l_enum, RT5677_MONO_ADC_MIXER, | ||
1128 | RT5677_SEL_MONO_DMIC_L_SFT, rt5677_dmic_src); | ||
1129 | |||
1130 | static const struct snd_kcontrol_new rt5677_mono_dmic_l_mux = | ||
1131 | SOC_DAPM_ENUM("Mono DMIC L source", rt5677_mono_dmic_l_enum); | ||
1132 | |||
1133 | static SOC_ENUM_SINGLE_DECL( | ||
1134 | rt5677_mono_dmic_r_enum, RT5677_MONO_ADC_MIXER, | ||
1135 | RT5677_SEL_MONO_DMIC_R_SFT, rt5677_dmic_src); | ||
1136 | |||
1137 | static const struct snd_kcontrol_new rt5677_mono_dmic_r_mux = | ||
1138 | SOC_DAPM_ENUM("Mono DMIC R source", rt5677_mono_dmic_r_enum); | ||
1139 | |||
1140 | static SOC_ENUM_SINGLE_DECL( | ||
1141 | rt5677_stereo1_dmic_enum, RT5677_STO1_ADC_MIXER, | ||
1142 | RT5677_SEL_STO1_DMIC_SFT, rt5677_dmic_src); | ||
1143 | |||
1144 | static const struct snd_kcontrol_new rt5677_sto1_dmic_mux = | ||
1145 | SOC_DAPM_ENUM("Stereo1 DMIC source", rt5677_stereo1_dmic_enum); | ||
1146 | |||
1147 | static SOC_ENUM_SINGLE_DECL( | ||
1148 | rt5677_stereo2_dmic_enum, RT5677_STO2_ADC_MIXER, | ||
1149 | RT5677_SEL_STO2_DMIC_SFT, rt5677_dmic_src); | ||
1150 | |||
1151 | static const struct snd_kcontrol_new rt5677_sto2_dmic_mux = | ||
1152 | SOC_DAPM_ENUM("Stereo2 DMIC source", rt5677_stereo2_dmic_enum); | ||
1153 | |||
1154 | static SOC_ENUM_SINGLE_DECL( | ||
1155 | rt5677_stereo3_dmic_enum, RT5677_STO3_ADC_MIXER, | ||
1156 | RT5677_SEL_STO3_DMIC_SFT, rt5677_dmic_src); | ||
1157 | |||
1158 | static const struct snd_kcontrol_new rt5677_sto3_dmic_mux = | ||
1159 | SOC_DAPM_ENUM("Stereo3 DMIC source", rt5677_stereo3_dmic_enum); | ||
1160 | |||
1161 | static SOC_ENUM_SINGLE_DECL( | ||
1162 | rt5677_stereo4_dmic_enum, RT5677_STO4_ADC_MIXER, | ||
1163 | RT5677_SEL_STO4_DMIC_SFT, rt5677_dmic_src); | ||
1164 | |||
1165 | static const struct snd_kcontrol_new rt5677_sto4_dmic_mux = | ||
1166 | SOC_DAPM_ENUM("Stereo4 DMIC source", rt5677_stereo4_dmic_enum); | ||
1167 | |||
1168 | /* Stereo2 ADC source */ /* MX-26 [0] */ | ||
1169 | static const char * const rt5677_stereo2_adc_lr_src[] = { | ||
1170 | "L", "LR" | ||
1171 | }; | ||
1172 | |||
1173 | static SOC_ENUM_SINGLE_DECL( | ||
1174 | rt5677_stereo2_adc_lr_enum, RT5677_STO2_ADC_MIXER, | ||
1175 | RT5677_SEL_STO2_LR_MIX_SFT, rt5677_stereo2_adc_lr_src); | ||
1176 | |||
1177 | static const struct snd_kcontrol_new rt5677_sto2_adc_lr_mux = | ||
1178 | SOC_DAPM_ENUM("Stereo2 ADC LR source", rt5677_stereo2_adc_lr_enum); | ||
1179 | |||
1180 | /* Stereo1 ADC Source 1 */ /* MX-27 MX26 MX25 [13:12] */ | ||
1181 | static const char * const rt5677_stereo_adc1_src[] = { | ||
1182 | "DD MIX1", "ADC1/2", "Stereo DAC MIX" | ||
1183 | }; | ||
1184 | |||
1185 | static SOC_ENUM_SINGLE_DECL( | ||
1186 | rt5677_stereo1_adc1_enum, RT5677_STO1_ADC_MIXER, | ||
1187 | RT5677_SEL_STO1_ADC1_SFT, rt5677_stereo_adc1_src); | ||
1188 | |||
1189 | static const struct snd_kcontrol_new rt5677_sto1_adc1_mux = | ||
1190 | SOC_DAPM_ENUM("Stereo1 ADC1 source", rt5677_stereo1_adc1_enum); | ||
1191 | |||
1192 | static SOC_ENUM_SINGLE_DECL( | ||
1193 | rt5677_stereo2_adc1_enum, RT5677_STO2_ADC_MIXER, | ||
1194 | RT5677_SEL_STO2_ADC1_SFT, rt5677_stereo_adc1_src); | ||
1195 | |||
1196 | static const struct snd_kcontrol_new rt5677_sto2_adc1_mux = | ||
1197 | SOC_DAPM_ENUM("Stereo2 ADC1 source", rt5677_stereo2_adc1_enum); | ||
1198 | |||
1199 | static SOC_ENUM_SINGLE_DECL( | ||
1200 | rt5677_stereo3_adc1_enum, RT5677_STO3_ADC_MIXER, | ||
1201 | RT5677_SEL_STO3_ADC1_SFT, rt5677_stereo_adc1_src); | ||
1202 | |||
1203 | static const struct snd_kcontrol_new rt5677_sto3_adc1_mux = | ||
1204 | SOC_DAPM_ENUM("Stereo3 ADC1 source", rt5677_stereo3_adc1_enum); | ||
1205 | |||
1206 | /* Mono ADC Left source 2 */ /* MX-28 [11:10] */ | ||
1207 | static const char * const rt5677_mono_adc2_l_src[] = { | ||
1208 | "DD MIX1L", "DMIC", "MONO DAC MIXL" | ||
1209 | }; | ||
1210 | |||
1211 | static SOC_ENUM_SINGLE_DECL( | ||
1212 | rt5677_mono_adc2_l_enum, RT5677_MONO_ADC_MIXER, | ||
1213 | RT5677_SEL_MONO_ADC_L2_SFT, rt5677_mono_adc2_l_src); | ||
1214 | |||
1215 | static const struct snd_kcontrol_new rt5677_mono_adc2_l_mux = | ||
1216 | SOC_DAPM_ENUM("Mono ADC2 L source", rt5677_mono_adc2_l_enum); | ||
1217 | |||
1218 | /* Mono ADC Left source 1 */ /* MX-28 [13:12] */ | ||
1219 | static const char * const rt5677_mono_adc1_l_src[] = { | ||
1220 | "DD MIX1L", "ADC1", "MONO DAC MIXL" | ||
1221 | }; | ||
1222 | |||
1223 | static SOC_ENUM_SINGLE_DECL( | ||
1224 | rt5677_mono_adc1_l_enum, RT5677_MONO_ADC_MIXER, | ||
1225 | RT5677_SEL_MONO_ADC_L1_SFT, rt5677_mono_adc1_l_src); | ||
1226 | |||
1227 | static const struct snd_kcontrol_new rt5677_mono_adc1_l_mux = | ||
1228 | SOC_DAPM_ENUM("Mono ADC1 L source", rt5677_mono_adc1_l_enum); | ||
1229 | |||
1230 | /* Mono ADC Right source 2 */ /* MX-28 [3:2] */ | ||
1231 | static const char * const rt5677_mono_adc2_r_src[] = { | ||
1232 | "DD MIX1R", "DMIC", "MONO DAC MIXR" | ||
1233 | }; | ||
1234 | |||
1235 | static SOC_ENUM_SINGLE_DECL( | ||
1236 | rt5677_mono_adc2_r_enum, RT5677_MONO_ADC_MIXER, | ||
1237 | RT5677_SEL_MONO_ADC_R2_SFT, rt5677_mono_adc2_r_src); | ||
1238 | |||
1239 | static const struct snd_kcontrol_new rt5677_mono_adc2_r_mux = | ||
1240 | SOC_DAPM_ENUM("Mono ADC2 R source", rt5677_mono_adc2_r_enum); | ||
1241 | |||
1242 | /* Mono ADC Right source 1 */ /* MX-28 [5:4] */ | ||
1243 | static const char * const rt5677_mono_adc1_r_src[] = { | ||
1244 | "DD MIX1R", "ADC2", "MONO DAC MIXR" | ||
1245 | }; | ||
1246 | |||
1247 | static SOC_ENUM_SINGLE_DECL( | ||
1248 | rt5677_mono_adc1_r_enum, RT5677_MONO_ADC_MIXER, | ||
1249 | RT5677_SEL_MONO_ADC_R1_SFT, rt5677_mono_adc1_r_src); | ||
1250 | |||
1251 | static const struct snd_kcontrol_new rt5677_mono_adc1_r_mux = | ||
1252 | SOC_DAPM_ENUM("Mono ADC1 R source", rt5677_mono_adc1_r_enum); | ||
1253 | |||
1254 | /* Stereo4 ADC Source 2 */ /* MX-24 [11:10] */ | ||
1255 | static const char * const rt5677_stereo4_adc2_src[] = { | ||
1256 | "DD MIX1", "DMIC", "DD MIX2" | ||
1257 | }; | ||
1258 | |||
1259 | static SOC_ENUM_SINGLE_DECL( | ||
1260 | rt5677_stereo4_adc2_enum, RT5677_STO4_ADC_MIXER, | ||
1261 | RT5677_SEL_STO4_ADC2_SFT, rt5677_stereo4_adc2_src); | ||
1262 | |||
1263 | static const struct snd_kcontrol_new rt5677_sto4_adc2_mux = | ||
1264 | SOC_DAPM_ENUM("Stereo4 ADC2 source", rt5677_stereo4_adc2_enum); | ||
1265 | |||
1266 | |||
1267 | /* Stereo4 ADC Source 1 */ /* MX-24 [13:12] */ | ||
1268 | static const char * const rt5677_stereo4_adc1_src[] = { | ||
1269 | "DD MIX1", "ADC1/2", "DD MIX2" | ||
1270 | }; | ||
1271 | |||
1272 | static SOC_ENUM_SINGLE_DECL( | ||
1273 | rt5677_stereo4_adc1_enum, RT5677_STO4_ADC_MIXER, | ||
1274 | RT5677_SEL_STO4_ADC1_SFT, rt5677_stereo4_adc1_src); | ||
1275 | |||
1276 | static const struct snd_kcontrol_new rt5677_sto4_adc1_mux = | ||
1277 | SOC_DAPM_ENUM("Stereo4 ADC1 source", rt5677_stereo4_adc1_enum); | ||
1278 | |||
1279 | /* InBound0/1 Source */ /* MX-A3 [14:12] */ | ||
1280 | static const char * const rt5677_inbound01_src[] = { | ||
1281 | "IF1 DAC 01", "IF2 DAC 01", "SLB DAC 01", "STO1 ADC MIX", | ||
1282 | "VAD ADC/DAC1 FS" | ||
1283 | }; | ||
1284 | |||
1285 | static SOC_ENUM_SINGLE_DECL( | ||
1286 | rt5677_inbound01_enum, RT5677_DSP_INB_CTRL1, | ||
1287 | RT5677_IB01_SRC_SFT, rt5677_inbound01_src); | ||
1288 | |||
1289 | static const struct snd_kcontrol_new rt5677_ib01_src_mux = | ||
1290 | SOC_DAPM_ENUM("InBound0/1 Source", rt5677_inbound01_enum); | ||
1291 | |||
1292 | /* InBound2/3 Source */ /* MX-A3 [10:8] */ | ||
1293 | static const char * const rt5677_inbound23_src[] = { | ||
1294 | "IF1 DAC 23", "IF2 DAC 23", "SLB DAC 23", "STO2 ADC MIX", | ||
1295 | "DAC1 FS", "IF4 DAC" | ||
1296 | }; | ||
1297 | |||
1298 | static SOC_ENUM_SINGLE_DECL( | ||
1299 | rt5677_inbound23_enum, RT5677_DSP_INB_CTRL1, | ||
1300 | RT5677_IB23_SRC_SFT, rt5677_inbound23_src); | ||
1301 | |||
1302 | static const struct snd_kcontrol_new rt5677_ib23_src_mux = | ||
1303 | SOC_DAPM_ENUM("InBound2/3 Source", rt5677_inbound23_enum); | ||
1304 | |||
1305 | /* InBound4/5 Source */ /* MX-A3 [6:4] */ | ||
1306 | static const char * const rt5677_inbound45_src[] = { | ||
1307 | "IF1 DAC 45", "IF2 DAC 45", "SLB DAC 45", "STO3 ADC MIX", | ||
1308 | "IF3 DAC" | ||
1309 | }; | ||
1310 | |||
1311 | static SOC_ENUM_SINGLE_DECL( | ||
1312 | rt5677_inbound45_enum, RT5677_DSP_INB_CTRL1, | ||
1313 | RT5677_IB45_SRC_SFT, rt5677_inbound45_src); | ||
1314 | |||
1315 | static const struct snd_kcontrol_new rt5677_ib45_src_mux = | ||
1316 | SOC_DAPM_ENUM("InBound4/5 Source", rt5677_inbound45_enum); | ||
1317 | |||
1318 | /* InBound6 Source */ /* MX-A3 [2:0] */ | ||
1319 | static const char * const rt5677_inbound6_src[] = { | ||
1320 | "IF1 DAC 6", "IF2 DAC 6", "SLB DAC 6", "STO4 ADC MIX L", | ||
1321 | "IF4 DAC L", "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L" | ||
1322 | }; | ||
1323 | |||
1324 | static SOC_ENUM_SINGLE_DECL( | ||
1325 | rt5677_inbound6_enum, RT5677_DSP_INB_CTRL1, | ||
1326 | RT5677_IB6_SRC_SFT, rt5677_inbound6_src); | ||
1327 | |||
1328 | static const struct snd_kcontrol_new rt5677_ib6_src_mux = | ||
1329 | SOC_DAPM_ENUM("InBound6 Source", rt5677_inbound6_enum); | ||
1330 | |||
1331 | /* InBound7 Source */ /* MX-A4 [14:12] */ | ||
1332 | static const char * const rt5677_inbound7_src[] = { | ||
1333 | "IF1 DAC 7", "IF2 DAC 7", "SLB DAC 7", "STO4 ADC MIX R", | ||
1334 | "IF4 DAC R", "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R" | ||
1335 | }; | ||
1336 | |||
1337 | static SOC_ENUM_SINGLE_DECL( | ||
1338 | rt5677_inbound7_enum, RT5677_DSP_INB_CTRL2, | ||
1339 | RT5677_IB7_SRC_SFT, rt5677_inbound7_src); | ||
1340 | |||
1341 | static const struct snd_kcontrol_new rt5677_ib7_src_mux = | ||
1342 | SOC_DAPM_ENUM("InBound7 Source", rt5677_inbound7_enum); | ||
1343 | |||
1344 | /* InBound8 Source */ /* MX-A4 [10:8] */ | ||
1345 | static const char * const rt5677_inbound8_src[] = { | ||
1346 | "STO1 ADC MIX L", "STO2 ADC MIX L", "STO3 ADC MIX L", "STO4 ADC MIX L", | ||
1347 | "MONO ADC MIX L", "DACL1 FS" | ||
1348 | }; | ||
1349 | |||
1350 | static SOC_ENUM_SINGLE_DECL( | ||
1351 | rt5677_inbound8_enum, RT5677_DSP_INB_CTRL2, | ||
1352 | RT5677_IB8_SRC_SFT, rt5677_inbound8_src); | ||
1353 | |||
1354 | static const struct snd_kcontrol_new rt5677_ib8_src_mux = | ||
1355 | SOC_DAPM_ENUM("InBound8 Source", rt5677_inbound8_enum); | ||
1356 | |||
1357 | /* InBound9 Source */ /* MX-A4 [6:4] */ | ||
1358 | static const char * const rt5677_inbound9_src[] = { | ||
1359 | "STO1 ADC MIX R", "STO2 ADC MIX R", "STO3 ADC MIX R", "STO4 ADC MIX R", | ||
1360 | "MONO ADC MIX R", "DACR1 FS", "DAC1 FS" | ||
1361 | }; | ||
1362 | |||
1363 | static SOC_ENUM_SINGLE_DECL( | ||
1364 | rt5677_inbound9_enum, RT5677_DSP_INB_CTRL2, | ||
1365 | RT5677_IB9_SRC_SFT, rt5677_inbound9_src); | ||
1366 | |||
1367 | static const struct snd_kcontrol_new rt5677_ib9_src_mux = | ||
1368 | SOC_DAPM_ENUM("InBound9 Source", rt5677_inbound9_enum); | ||
1369 | |||
1370 | /* VAD Source */ /* MX-9F [6:4] */ | ||
1371 | static const char * const rt5677_vad_src[] = { | ||
1372 | "STO1 ADC MIX L", "MONO ADC MIX L", "MONO ADC MIX R", "STO2 ADC MIX L", | ||
1373 | "STO3 ADC MIX L" | ||
1374 | }; | ||
1375 | |||
1376 | static SOC_ENUM_SINGLE_DECL( | ||
1377 | rt5677_vad_enum, RT5677_VAD_CTRL4, | ||
1378 | RT5677_VAD_SRC_SFT, rt5677_vad_src); | ||
1379 | |||
1380 | static const struct snd_kcontrol_new rt5677_vad_src_mux = | ||
1381 | SOC_DAPM_ENUM("VAD Source", rt5677_vad_enum); | ||
1382 | |||
1383 | /* Sidetone Source */ /* MX-13 [11:9] */ | ||
1384 | static const char * const rt5677_sidetone_src[] = { | ||
1385 | "DMIC1 L", "DMIC2 L", "DMIC3 L", "DMIC4 L", "ADC1", "ADC2" | ||
1386 | }; | ||
1387 | |||
1388 | static SOC_ENUM_SINGLE_DECL( | ||
1389 | rt5677_sidetone_enum, RT5677_SIDETONE_CTRL, | ||
1390 | RT5677_ST_SEL_SFT, rt5677_sidetone_src); | ||
1391 | |||
1392 | static const struct snd_kcontrol_new rt5677_sidetone_mux = | ||
1393 | SOC_DAPM_ENUM("Sidetone Source", rt5677_sidetone_enum); | ||
1394 | |||
1395 | /* DAC1/2 Source */ /* MX-15 [1:0] */ | ||
1396 | static const char * const rt5677_dac12_src[] = { | ||
1397 | "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2" | ||
1398 | }; | ||
1399 | |||
1400 | static SOC_ENUM_SINGLE_DECL( | ||
1401 | rt5677_dac12_enum, RT5677_ANA_DAC1_2_3_SRC, | ||
1402 | RT5677_ANA_DAC1_2_SRC_SEL_SFT, rt5677_dac12_src); | ||
1403 | |||
1404 | static const struct snd_kcontrol_new rt5677_dac12_mux = | ||
1405 | SOC_DAPM_ENUM("Analog DAC1/2 Source", rt5677_dac12_enum); | ||
1406 | |||
1407 | /* DAC3 Source */ /* MX-15 [5:4] */ | ||
1408 | static const char * const rt5677_dac3_src[] = { | ||
1409 | "MONO DAC MIXL", "MONO DAC MIXR", "DD MIX1L", "DD MIX2L" | ||
1410 | }; | ||
1411 | |||
1412 | static SOC_ENUM_SINGLE_DECL( | ||
1413 | rt5677_dac3_enum, RT5677_ANA_DAC1_2_3_SRC, | ||
1414 | RT5677_ANA_DAC3_SRC_SEL_SFT, rt5677_dac3_src); | ||
1415 | |||
1416 | static const struct snd_kcontrol_new rt5677_dac3_mux = | ||
1417 | SOC_DAPM_ENUM("Analog DAC3 Source", rt5677_dac3_enum); | ||
1418 | |||
1419 | /* PDM channel source */ /* MX-31 [13:12][9:8][5:4][1:0] */ | ||
1420 | static const char * const rt5677_pdm_src[] = { | ||
1421 | "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2" | ||
1422 | }; | ||
1423 | |||
1424 | static SOC_ENUM_SINGLE_DECL( | ||
1425 | rt5677_pdm1_l_enum, RT5677_PDM_OUT_CTRL, | ||
1426 | RT5677_SEL_PDM1_L_SFT, rt5677_pdm_src); | ||
1427 | |||
1428 | static const struct snd_kcontrol_new rt5677_pdm1_l_mux = | ||
1429 | SOC_DAPM_ENUM("PDM1 source", rt5677_pdm1_l_enum); | ||
1430 | |||
1431 | static SOC_ENUM_SINGLE_DECL( | ||
1432 | rt5677_pdm2_l_enum, RT5677_PDM_OUT_CTRL, | ||
1433 | RT5677_SEL_PDM2_L_SFT, rt5677_pdm_src); | ||
1434 | |||
1435 | static const struct snd_kcontrol_new rt5677_pdm2_l_mux = | ||
1436 | SOC_DAPM_ENUM("PDM2 source", rt5677_pdm2_l_enum); | ||
1437 | |||
1438 | static SOC_ENUM_SINGLE_DECL( | ||
1439 | rt5677_pdm1_r_enum, RT5677_PDM_OUT_CTRL, | ||
1440 | RT5677_SEL_PDM1_R_SFT, rt5677_pdm_src); | ||
1441 | |||
1442 | static const struct snd_kcontrol_new rt5677_pdm1_r_mux = | ||
1443 | SOC_DAPM_ENUM("PDM1 source", rt5677_pdm1_r_enum); | ||
1444 | |||
1445 | static SOC_ENUM_SINGLE_DECL( | ||
1446 | rt5677_pdm2_r_enum, RT5677_PDM_OUT_CTRL, | ||
1447 | RT5677_SEL_PDM2_R_SFT, rt5677_pdm_src); | ||
1448 | |||
1449 | static const struct snd_kcontrol_new rt5677_pdm2_r_mux = | ||
1450 | SOC_DAPM_ENUM("PDM2 source", rt5677_pdm2_r_enum); | ||
1451 | |||
1452 | /* TDM IF1/2 SLB ADC1 Data Selection */ /* MX-3C MX-41 [5:4] MX-08 [1:0]*/ | ||
1453 | static const char * const rt5677_if12_adc1_src[] = { | ||
1454 | "STO1 ADC MIX", "OB01", "VAD ADC" | ||
1455 | }; | ||
1456 | |||
1457 | static SOC_ENUM_SINGLE_DECL( | ||
1458 | rt5677_if1_adc1_enum, RT5677_TDM1_CTRL2, | ||
1459 | RT5677_IF1_ADC1_SFT, rt5677_if12_adc1_src); | ||
1460 | |||
1461 | static const struct snd_kcontrol_new rt5677_if1_adc1_mux = | ||
1462 | SOC_DAPM_ENUM("IF1 ADC1 source", rt5677_if1_adc1_enum); | ||
1463 | |||
1464 | static SOC_ENUM_SINGLE_DECL( | ||
1465 | rt5677_if2_adc1_enum, RT5677_TDM2_CTRL2, | ||
1466 | RT5677_IF2_ADC1_SFT, rt5677_if12_adc1_src); | ||
1467 | |||
1468 | static const struct snd_kcontrol_new rt5677_if2_adc1_mux = | ||
1469 | SOC_DAPM_ENUM("IF2 ADC1 source", rt5677_if2_adc1_enum); | ||
1470 | |||
1471 | static SOC_ENUM_SINGLE_DECL( | ||
1472 | rt5677_slb_adc1_enum, RT5677_SLIMBUS_RX, | ||
1473 | RT5677_SLB_ADC1_SFT, rt5677_if12_adc1_src); | ||
1474 | |||
1475 | static const struct snd_kcontrol_new rt5677_slb_adc1_mux = | ||
1476 | SOC_DAPM_ENUM("SLB ADC1 source", rt5677_slb_adc1_enum); | ||
1477 | |||
1478 | /* TDM IF1/2 SLB ADC2 Data Selection */ /* MX-3C MX-41 [7:6] MX-08 [3:2] */ | ||
1479 | static const char * const rt5677_if12_adc2_src[] = { | ||
1480 | "STO2 ADC MIX", "OB23" | ||
1481 | }; | ||
1482 | |||
1483 | static SOC_ENUM_SINGLE_DECL( | ||
1484 | rt5677_if1_adc2_enum, RT5677_TDM1_CTRL2, | ||
1485 | RT5677_IF1_ADC2_SFT, rt5677_if12_adc2_src); | ||
1486 | |||
1487 | static const struct snd_kcontrol_new rt5677_if1_adc2_mux = | ||
1488 | SOC_DAPM_ENUM("IF1 ADC2 source", rt5677_if1_adc2_enum); | ||
1489 | |||
1490 | static SOC_ENUM_SINGLE_DECL( | ||
1491 | rt5677_if2_adc2_enum, RT5677_TDM2_CTRL2, | ||
1492 | RT5677_IF2_ADC2_SFT, rt5677_if12_adc2_src); | ||
1493 | |||
1494 | static const struct snd_kcontrol_new rt5677_if2_adc2_mux = | ||
1495 | SOC_DAPM_ENUM("IF2 ADC2 source", rt5677_if2_adc2_enum); | ||
1496 | |||
1497 | static SOC_ENUM_SINGLE_DECL( | ||
1498 | rt5677_slb_adc2_enum, RT5677_SLIMBUS_RX, | ||
1499 | RT5677_SLB_ADC2_SFT, rt5677_if12_adc2_src); | ||
1500 | |||
1501 | static const struct snd_kcontrol_new rt5677_slb_adc2_mux = | ||
1502 | SOC_DAPM_ENUM("SLB ADC2 source", rt5677_slb_adc2_enum); | ||
1503 | |||
1504 | /* TDM IF1/2 SLB ADC3 Data Selection */ /* MX-3C MX-41 [9:8] MX-08 [5:4] */ | ||
1505 | static const char * const rt5677_if12_adc3_src[] = { | ||
1506 | "STO3 ADC MIX", "MONO ADC MIX", "OB45" | ||
1507 | }; | ||
1508 | |||
1509 | static SOC_ENUM_SINGLE_DECL( | ||
1510 | rt5677_if1_adc3_enum, RT5677_TDM1_CTRL2, | ||
1511 | RT5677_IF1_ADC3_SFT, rt5677_if12_adc3_src); | ||
1512 | |||
1513 | static const struct snd_kcontrol_new rt5677_if1_adc3_mux = | ||
1514 | SOC_DAPM_ENUM("IF1 ADC3 source", rt5677_if1_adc3_enum); | ||
1515 | |||
1516 | static SOC_ENUM_SINGLE_DECL( | ||
1517 | rt5677_if2_adc3_enum, RT5677_TDM2_CTRL2, | ||
1518 | RT5677_IF2_ADC3_SFT, rt5677_if12_adc3_src); | ||
1519 | |||
1520 | static const struct snd_kcontrol_new rt5677_if2_adc3_mux = | ||
1521 | SOC_DAPM_ENUM("IF2 ADC3 source", rt5677_if2_adc3_enum); | ||
1522 | |||
1523 | static SOC_ENUM_SINGLE_DECL( | ||
1524 | rt5677_slb_adc3_enum, RT5677_SLIMBUS_RX, | ||
1525 | RT5677_SLB_ADC3_SFT, rt5677_if12_adc3_src); | ||
1526 | |||
1527 | static const struct snd_kcontrol_new rt5677_slb_adc3_mux = | ||
1528 | SOC_DAPM_ENUM("SLB ADC3 source", rt5677_slb_adc3_enum); | ||
1529 | |||
1530 | /* TDM IF1/2 SLB ADC4 Data Selection */ /* MX-3C MX-41 [11:10] MX-08 [7:6] */ | ||
1531 | static const char * const rt5677_if12_adc4_src[] = { | ||
1532 | "STO4 ADC MIX", "OB67", "OB01" | ||
1533 | }; | ||
1534 | |||
1535 | static SOC_ENUM_SINGLE_DECL( | ||
1536 | rt5677_if1_adc4_enum, RT5677_TDM1_CTRL2, | ||
1537 | RT5677_IF1_ADC4_SFT, rt5677_if12_adc4_src); | ||
1538 | |||
1539 | static const struct snd_kcontrol_new rt5677_if1_adc4_mux = | ||
1540 | SOC_DAPM_ENUM("IF1 ADC4 source", rt5677_if1_adc4_enum); | ||
1541 | |||
1542 | static SOC_ENUM_SINGLE_DECL( | ||
1543 | rt5677_if2_adc4_enum, RT5677_TDM2_CTRL2, | ||
1544 | RT5677_IF2_ADC4_SFT, rt5677_if12_adc4_src); | ||
1545 | |||
1546 | static const struct snd_kcontrol_new rt5677_if2_adc4_mux = | ||
1547 | SOC_DAPM_ENUM("IF2 ADC4 source", rt5677_if2_adc4_enum); | ||
1548 | |||
1549 | static SOC_ENUM_SINGLE_DECL( | ||
1550 | rt5677_slb_adc4_enum, RT5677_SLIMBUS_RX, | ||
1551 | RT5677_SLB_ADC4_SFT, rt5677_if12_adc4_src); | ||
1552 | |||
1553 | static const struct snd_kcontrol_new rt5677_slb_adc4_mux = | ||
1554 | SOC_DAPM_ENUM("SLB ADC4 source", rt5677_slb_adc4_enum); | ||
1555 | |||
1556 | /* Interface3/4 ADC Data Input */ /* MX-2F [3:0] MX-30 [7:4]*/ | ||
1557 | static const char * const rt5677_if34_adc_src[] = { | ||
1558 | "STO1 ADC MIX", "STO2 ADC MIX", "STO3 ADC MIX", "STO4 ADC MIX", | ||
1559 | "MONO ADC MIX", "OB01", "OB23", "VAD ADC" | ||
1560 | }; | ||
1561 | |||
1562 | static SOC_ENUM_SINGLE_DECL( | ||
1563 | rt5677_if3_adc_enum, RT5677_IF3_DATA, | ||
1564 | RT5677_IF3_ADC_IN_SFT, rt5677_if34_adc_src); | ||
1565 | |||
1566 | static const struct snd_kcontrol_new rt5677_if3_adc_mux = | ||
1567 | SOC_DAPM_ENUM("IF3 ADC source", rt5677_if3_adc_enum); | ||
1568 | |||
1569 | static SOC_ENUM_SINGLE_DECL( | ||
1570 | rt5677_if4_adc_enum, RT5677_IF4_DATA, | ||
1571 | RT5677_IF4_ADC_IN_SFT, rt5677_if34_adc_src); | ||
1572 | |||
1573 | static const struct snd_kcontrol_new rt5677_if4_adc_mux = | ||
1574 | SOC_DAPM_ENUM("IF4 ADC source", rt5677_if4_adc_enum); | ||
1575 | |||
1576 | static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, | ||
1577 | struct snd_kcontrol *kcontrol, int event) | ||
1578 | { | ||
1579 | struct snd_soc_codec *codec = w->codec; | ||
1580 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
1581 | |||
1582 | switch (event) { | ||
1583 | case SND_SOC_DAPM_POST_PMU: | ||
1584 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, | ||
1585 | RT5677_PWR_BST1_P, RT5677_PWR_BST1_P); | ||
1586 | break; | ||
1587 | |||
1588 | case SND_SOC_DAPM_PRE_PMD: | ||
1589 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, | ||
1590 | RT5677_PWR_BST1_P, 0); | ||
1591 | break; | ||
1592 | |||
1593 | default: | ||
1594 | return 0; | ||
1595 | } | ||
1596 | |||
1597 | return 0; | ||
1598 | } | ||
1599 | |||
1600 | static int rt5677_bst2_event(struct snd_soc_dapm_widget *w, | ||
1601 | struct snd_kcontrol *kcontrol, int event) | ||
1602 | { | ||
1603 | struct snd_soc_codec *codec = w->codec; | ||
1604 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
1605 | |||
1606 | switch (event) { | ||
1607 | case SND_SOC_DAPM_POST_PMU: | ||
1608 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, | ||
1609 | RT5677_PWR_BST2_P, RT5677_PWR_BST2_P); | ||
1610 | break; | ||
1611 | |||
1612 | case SND_SOC_DAPM_PRE_PMD: | ||
1613 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, | ||
1614 | RT5677_PWR_BST2_P, 0); | ||
1615 | break; | ||
1616 | |||
1617 | default: | ||
1618 | return 0; | ||
1619 | } | ||
1620 | |||
1621 | return 0; | ||
1622 | } | ||
1623 | |||
1624 | static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w, | ||
1625 | struct snd_kcontrol *kcontrol, int event) | ||
1626 | { | ||
1627 | struct snd_soc_codec *codec = w->codec; | ||
1628 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
1629 | |||
1630 | switch (event) { | ||
1631 | case SND_SOC_DAPM_POST_PMU: | ||
1632 | regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x2); | ||
1633 | regmap_update_bits(rt5677->regmap, RT5677_PLL1_CTRL2, 0x2, 0x0); | ||
1634 | break; | ||
1635 | default: | ||
1636 | return 0; | ||
1637 | } | ||
1638 | |||
1639 | return 0; | ||
1640 | } | ||
1641 | |||
1642 | static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w, | ||
1643 | struct snd_kcontrol *kcontrol, int event) | ||
1644 | { | ||
1645 | struct snd_soc_codec *codec = w->codec; | ||
1646 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
1647 | |||
1648 | switch (event) { | ||
1649 | case SND_SOC_DAPM_POST_PMU: | ||
1650 | regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x2); | ||
1651 | regmap_update_bits(rt5677->regmap, RT5677_PLL2_CTRL2, 0x2, 0x0); | ||
1652 | break; | ||
1653 | default: | ||
1654 | return 0; | ||
1655 | } | ||
1656 | |||
1657 | return 0; | ||
1658 | } | ||
1659 | |||
1660 | static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w, | ||
1661 | struct snd_kcontrol *kcontrol, int event) | ||
1662 | { | ||
1663 | struct snd_soc_codec *codec = w->codec; | ||
1664 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
1665 | |||
1666 | switch (event) { | ||
1667 | case SND_SOC_DAPM_POST_PMU: | ||
1668 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, | ||
1669 | RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 | | ||
1670 | RT5677_PWR_CLK_MB, RT5677_PWR_CLK_MB1 | | ||
1671 | RT5677_PWR_PP_MB1 | RT5677_PWR_CLK_MB); | ||
1672 | break; | ||
1673 | default: | ||
1674 | return 0; | ||
1675 | } | ||
1676 | |||
1677 | return 0; | ||
1678 | } | ||
1679 | |||
1680 | static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = { | ||
1681 | SND_SOC_DAPM_SUPPLY("PLL1", RT5677_PWR_ANLG2, RT5677_PWR_PLL1_BIT, | ||
1682 | 0, rt5677_set_pll1_event, SND_SOC_DAPM_POST_PMU), | ||
1683 | SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT, | ||
1684 | 0, rt5677_set_pll2_event, SND_SOC_DAPM_POST_PMU), | ||
1685 | |||
1686 | /* Input Side */ | ||
1687 | /* micbias */ | ||
1688 | SND_SOC_DAPM_SUPPLY("micbias1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT, | ||
1689 | 0, rt5677_set_micbias1_event, SND_SOC_DAPM_POST_PMU), | ||
1690 | |||
1691 | /* Input Lines */ | ||
1692 | SND_SOC_DAPM_INPUT("DMIC L1"), | ||
1693 | SND_SOC_DAPM_INPUT("DMIC R1"), | ||
1694 | SND_SOC_DAPM_INPUT("DMIC L2"), | ||
1695 | SND_SOC_DAPM_INPUT("DMIC R2"), | ||
1696 | SND_SOC_DAPM_INPUT("DMIC L3"), | ||
1697 | SND_SOC_DAPM_INPUT("DMIC R3"), | ||
1698 | SND_SOC_DAPM_INPUT("DMIC L4"), | ||
1699 | SND_SOC_DAPM_INPUT("DMIC R4"), | ||
1700 | |||
1701 | SND_SOC_DAPM_INPUT("IN1P"), | ||
1702 | SND_SOC_DAPM_INPUT("IN1N"), | ||
1703 | SND_SOC_DAPM_INPUT("IN2P"), | ||
1704 | SND_SOC_DAPM_INPUT("IN2N"), | ||
1705 | |||
1706 | SND_SOC_DAPM_INPUT("Haptic Generator"), | ||
1707 | |||
1708 | SND_SOC_DAPM_PGA("DMIC1", RT5677_DMIC_CTRL1, RT5677_DMIC_1_EN_SFT, 0, | ||
1709 | NULL, 0), | ||
1710 | SND_SOC_DAPM_PGA("DMIC2", RT5677_DMIC_CTRL1, RT5677_DMIC_2_EN_SFT, 0, | ||
1711 | NULL, 0), | ||
1712 | SND_SOC_DAPM_PGA("DMIC3", RT5677_DMIC_CTRL1, RT5677_DMIC_3_EN_SFT, 0, | ||
1713 | NULL, 0), | ||
1714 | SND_SOC_DAPM_PGA("DMIC4", RT5677_DMIC_CTRL2, RT5677_DMIC_4_EN_SFT, 0, | ||
1715 | NULL, 0), | ||
1716 | |||
1717 | SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0, | ||
1718 | set_dmic_clk, SND_SOC_DAPM_PRE_PMU), | ||
1719 | |||
1720 | /* Boost */ | ||
1721 | SND_SOC_DAPM_PGA_E("BST1", RT5677_PWR_ANLG2, | ||
1722 | RT5677_PWR_BST1_BIT, 0, NULL, 0, rt5677_bst1_event, | ||
1723 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
1724 | SND_SOC_DAPM_PGA_E("BST2", RT5677_PWR_ANLG2, | ||
1725 | RT5677_PWR_BST2_BIT, 0, NULL, 0, rt5677_bst2_event, | ||
1726 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
1727 | |||
1728 | /* ADCs */ | ||
1729 | SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, | ||
1730 | 0, 0), | ||
1731 | SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM, | ||
1732 | 0, 0), | ||
1733 | SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1734 | |||
1735 | SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5677_PWR_DIG1, | ||
1736 | RT5677_PWR_ADC_L_BIT, 0, NULL, 0), | ||
1737 | SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5677_PWR_DIG1, | ||
1738 | RT5677_PWR_ADC_R_BIT, 0, NULL, 0), | ||
1739 | SND_SOC_DAPM_SUPPLY("ADC1 clock", RT5677_PWR_DIG1, | ||
1740 | RT5677_PWR_ADCFED1_BIT, 0, NULL, 0), | ||
1741 | SND_SOC_DAPM_SUPPLY("ADC2 clock", RT5677_PWR_DIG1, | ||
1742 | RT5677_PWR_ADCFED2_BIT, 0, NULL, 0), | ||
1743 | |||
1744 | /* ADC Mux */ | ||
1745 | SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0, | ||
1746 | &rt5677_sto1_dmic_mux), | ||
1747 | SND_SOC_DAPM_MUX("Stereo1 ADC1 Mux", SND_SOC_NOPM, 0, 0, | ||
1748 | &rt5677_sto1_adc1_mux), | ||
1749 | SND_SOC_DAPM_MUX("Stereo1 ADC2 Mux", SND_SOC_NOPM, 0, 0, | ||
1750 | &rt5677_sto1_adc2_mux), | ||
1751 | SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0, | ||
1752 | &rt5677_sto2_dmic_mux), | ||
1753 | SND_SOC_DAPM_MUX("Stereo2 ADC1 Mux", SND_SOC_NOPM, 0, 0, | ||
1754 | &rt5677_sto2_adc1_mux), | ||
1755 | SND_SOC_DAPM_MUX("Stereo2 ADC2 Mux", SND_SOC_NOPM, 0, 0, | ||
1756 | &rt5677_sto2_adc2_mux), | ||
1757 | SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0, | ||
1758 | &rt5677_sto2_adc_lr_mux), | ||
1759 | SND_SOC_DAPM_MUX("Stereo3 DMIC Mux", SND_SOC_NOPM, 0, 0, | ||
1760 | &rt5677_sto3_dmic_mux), | ||
1761 | SND_SOC_DAPM_MUX("Stereo3 ADC1 Mux", SND_SOC_NOPM, 0, 0, | ||
1762 | &rt5677_sto3_adc1_mux), | ||
1763 | SND_SOC_DAPM_MUX("Stereo3 ADC2 Mux", SND_SOC_NOPM, 0, 0, | ||
1764 | &rt5677_sto3_adc2_mux), | ||
1765 | SND_SOC_DAPM_MUX("Stereo4 DMIC Mux", SND_SOC_NOPM, 0, 0, | ||
1766 | &rt5677_sto4_dmic_mux), | ||
1767 | SND_SOC_DAPM_MUX("Stereo4 ADC1 Mux", SND_SOC_NOPM, 0, 0, | ||
1768 | &rt5677_sto4_adc1_mux), | ||
1769 | SND_SOC_DAPM_MUX("Stereo4 ADC2 Mux", SND_SOC_NOPM, 0, 0, | ||
1770 | &rt5677_sto4_adc2_mux), | ||
1771 | SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0, | ||
1772 | &rt5677_mono_dmic_l_mux), | ||
1773 | SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0, | ||
1774 | &rt5677_mono_dmic_r_mux), | ||
1775 | SND_SOC_DAPM_MUX("Mono ADC2 L Mux", SND_SOC_NOPM, 0, 0, | ||
1776 | &rt5677_mono_adc2_l_mux), | ||
1777 | SND_SOC_DAPM_MUX("Mono ADC1 L Mux", SND_SOC_NOPM, 0, 0, | ||
1778 | &rt5677_mono_adc1_l_mux), | ||
1779 | SND_SOC_DAPM_MUX("Mono ADC1 R Mux", SND_SOC_NOPM, 0, 0, | ||
1780 | &rt5677_mono_adc1_r_mux), | ||
1781 | SND_SOC_DAPM_MUX("Mono ADC2 R Mux", SND_SOC_NOPM, 0, 0, | ||
1782 | &rt5677_mono_adc2_r_mux), | ||
1783 | |||
1784 | /* ADC Mixer */ | ||
1785 | SND_SOC_DAPM_SUPPLY("adc stereo1 filter", RT5677_PWR_DIG2, | ||
1786 | RT5677_PWR_ADC_S1F_BIT, 0, NULL, 0), | ||
1787 | SND_SOC_DAPM_SUPPLY("adc stereo2 filter", RT5677_PWR_DIG2, | ||
1788 | RT5677_PWR_ADC_S2F_BIT, 0, NULL, 0), | ||
1789 | SND_SOC_DAPM_SUPPLY("adc stereo3 filter", RT5677_PWR_DIG2, | ||
1790 | RT5677_PWR_ADC_S3F_BIT, 0, NULL, 0), | ||
1791 | SND_SOC_DAPM_SUPPLY("adc stereo4 filter", RT5677_PWR_DIG2, | ||
1792 | RT5677_PWR_ADC_S4F_BIT, 0, NULL, 0), | ||
1793 | SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0, | ||
1794 | rt5677_sto1_adc_l_mix, ARRAY_SIZE(rt5677_sto1_adc_l_mix)), | ||
1795 | SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0, | ||
1796 | rt5677_sto1_adc_r_mix, ARRAY_SIZE(rt5677_sto1_adc_r_mix)), | ||
1797 | SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0, | ||
1798 | rt5677_sto2_adc_l_mix, ARRAY_SIZE(rt5677_sto2_adc_l_mix)), | ||
1799 | SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0, | ||
1800 | rt5677_sto2_adc_r_mix, ARRAY_SIZE(rt5677_sto2_adc_r_mix)), | ||
1801 | SND_SOC_DAPM_MIXER("Sto3 ADC MIXL", SND_SOC_NOPM, 0, 0, | ||
1802 | rt5677_sto3_adc_l_mix, ARRAY_SIZE(rt5677_sto3_adc_l_mix)), | ||
1803 | SND_SOC_DAPM_MIXER("Sto3 ADC MIXR", SND_SOC_NOPM, 0, 0, | ||
1804 | rt5677_sto3_adc_r_mix, ARRAY_SIZE(rt5677_sto3_adc_r_mix)), | ||
1805 | SND_SOC_DAPM_MIXER("Sto4 ADC MIXL", SND_SOC_NOPM, 0, 0, | ||
1806 | rt5677_sto4_adc_l_mix, ARRAY_SIZE(rt5677_sto4_adc_l_mix)), | ||
1807 | SND_SOC_DAPM_MIXER("Sto4 ADC MIXR", SND_SOC_NOPM, 0, 0, | ||
1808 | rt5677_sto4_adc_r_mix, ARRAY_SIZE(rt5677_sto4_adc_r_mix)), | ||
1809 | SND_SOC_DAPM_SUPPLY("adc mono left filter", RT5677_PWR_DIG2, | ||
1810 | RT5677_PWR_ADC_MF_L_BIT, 0, NULL, 0), | ||
1811 | SND_SOC_DAPM_MIXER("Mono ADC MIXL", SND_SOC_NOPM, 0, 0, | ||
1812 | rt5677_mono_adc_l_mix, ARRAY_SIZE(rt5677_mono_adc_l_mix)), | ||
1813 | SND_SOC_DAPM_SUPPLY("adc mono right filter", RT5677_PWR_DIG2, | ||
1814 | RT5677_PWR_ADC_MF_R_BIT, 0, NULL, 0), | ||
1815 | SND_SOC_DAPM_MIXER("Mono ADC MIXR", SND_SOC_NOPM, 0, 0, | ||
1816 | rt5677_mono_adc_r_mix, ARRAY_SIZE(rt5677_mono_adc_r_mix)), | ||
1817 | |||
1818 | /* ADC PGA */ | ||
1819 | SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1820 | SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1821 | SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1822 | SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1823 | SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1824 | SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1825 | SND_SOC_DAPM_PGA("Stereo3 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1826 | SND_SOC_DAPM_PGA("Stereo3 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1827 | SND_SOC_DAPM_PGA("Stereo3 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1828 | SND_SOC_DAPM_PGA("Stereo4 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1829 | SND_SOC_DAPM_PGA("Stereo4 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1830 | SND_SOC_DAPM_PGA("Stereo4 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1831 | SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1832 | SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1833 | SND_SOC_DAPM_PGA("IF1_ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1834 | SND_SOC_DAPM_PGA("IF1_ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1835 | SND_SOC_DAPM_PGA("IF1_ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1836 | SND_SOC_DAPM_PGA("IF1_ADC4", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1837 | |||
1838 | /* DSP */ | ||
1839 | SND_SOC_DAPM_MUX("IB9 Mux", SND_SOC_NOPM, 0, 0, | ||
1840 | &rt5677_ib9_src_mux), | ||
1841 | SND_SOC_DAPM_MUX("IB8 Mux", SND_SOC_NOPM, 0, 0, | ||
1842 | &rt5677_ib8_src_mux), | ||
1843 | SND_SOC_DAPM_MUX("IB7 Mux", SND_SOC_NOPM, 0, 0, | ||
1844 | &rt5677_ib7_src_mux), | ||
1845 | SND_SOC_DAPM_MUX("IB6 Mux", SND_SOC_NOPM, 0, 0, | ||
1846 | &rt5677_ib6_src_mux), | ||
1847 | SND_SOC_DAPM_MUX("IB45 Mux", SND_SOC_NOPM, 0, 0, | ||
1848 | &rt5677_ib45_src_mux), | ||
1849 | SND_SOC_DAPM_MUX("IB23 Mux", SND_SOC_NOPM, 0, 0, | ||
1850 | &rt5677_ib23_src_mux), | ||
1851 | SND_SOC_DAPM_MUX("IB01 Mux", SND_SOC_NOPM, 0, 0, | ||
1852 | &rt5677_ib01_src_mux), | ||
1853 | SND_SOC_DAPM_MUX("IB45 Bypass Mux", SND_SOC_NOPM, 0, 0, | ||
1854 | &rt5677_ib45_bypass_src_mux), | ||
1855 | SND_SOC_DAPM_MUX("IB23 Bypass Mux", SND_SOC_NOPM, 0, 0, | ||
1856 | &rt5677_ib23_bypass_src_mux), | ||
1857 | SND_SOC_DAPM_MUX("IB01 Bypass Mux", SND_SOC_NOPM, 0, 0, | ||
1858 | &rt5677_ib01_bypass_src_mux), | ||
1859 | SND_SOC_DAPM_MUX("OB23 Bypass Mux", SND_SOC_NOPM, 0, 0, | ||
1860 | &rt5677_ob23_bypass_src_mux), | ||
1861 | SND_SOC_DAPM_MUX("OB01 Bypass Mux", SND_SOC_NOPM, 0, 0, | ||
1862 | &rt5677_ob01_bypass_src_mux), | ||
1863 | |||
1864 | SND_SOC_DAPM_PGA("OB45", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1865 | SND_SOC_DAPM_PGA("OB67", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1866 | |||
1867 | SND_SOC_DAPM_PGA("OutBound2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1868 | SND_SOC_DAPM_PGA("OutBound3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1869 | SND_SOC_DAPM_PGA("OutBound4", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1870 | SND_SOC_DAPM_PGA("OutBound5", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1871 | SND_SOC_DAPM_PGA("OutBound6", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1872 | SND_SOC_DAPM_PGA("OutBound7", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1873 | |||
1874 | /* Digital Interface */ | ||
1875 | SND_SOC_DAPM_SUPPLY("I2S1", RT5677_PWR_DIG1, | ||
1876 | RT5677_PWR_I2S1_BIT, 0, NULL, 0), | ||
1877 | SND_SOC_DAPM_PGA("IF1 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1878 | SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1879 | SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1880 | SND_SOC_DAPM_PGA("IF1 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1881 | SND_SOC_DAPM_PGA("IF1 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1882 | SND_SOC_DAPM_PGA("IF1 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1883 | SND_SOC_DAPM_PGA("IF1 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1884 | SND_SOC_DAPM_PGA("IF1 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1885 | SND_SOC_DAPM_PGA("IF1 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1886 | SND_SOC_DAPM_PGA("IF1 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1887 | SND_SOC_DAPM_PGA("IF1 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1888 | SND_SOC_DAPM_PGA("IF1 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1889 | SND_SOC_DAPM_PGA("IF1 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1890 | SND_SOC_DAPM_PGA("IF1 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1891 | SND_SOC_DAPM_PGA("IF1 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1892 | SND_SOC_DAPM_PGA("IF1 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1893 | |||
1894 | SND_SOC_DAPM_SUPPLY("I2S2", RT5677_PWR_DIG1, | ||
1895 | RT5677_PWR_I2S2_BIT, 0, NULL, 0), | ||
1896 | SND_SOC_DAPM_PGA("IF2 DAC0", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1897 | SND_SOC_DAPM_PGA("IF2 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1898 | SND_SOC_DAPM_PGA("IF2 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1899 | SND_SOC_DAPM_PGA("IF2 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1900 | SND_SOC_DAPM_PGA("IF2 DAC4", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1901 | SND_SOC_DAPM_PGA("IF2 DAC5", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1902 | SND_SOC_DAPM_PGA("IF2 DAC6", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1903 | SND_SOC_DAPM_PGA("IF2 DAC7", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1904 | SND_SOC_DAPM_PGA("IF2 DAC01", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1905 | SND_SOC_DAPM_PGA("IF2 DAC23", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1906 | SND_SOC_DAPM_PGA("IF2 DAC45", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1907 | SND_SOC_DAPM_PGA("IF2 DAC67", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1908 | SND_SOC_DAPM_PGA("IF2 ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1909 | SND_SOC_DAPM_PGA("IF2 ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1910 | SND_SOC_DAPM_PGA("IF2 ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1911 | SND_SOC_DAPM_PGA("IF2 ADC4", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1912 | |||
1913 | SND_SOC_DAPM_SUPPLY("I2S3", RT5677_PWR_DIG1, | ||
1914 | RT5677_PWR_I2S3_BIT, 0, NULL, 0), | ||
1915 | SND_SOC_DAPM_PGA("IF3 DAC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1916 | SND_SOC_DAPM_PGA("IF3 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1917 | SND_SOC_DAPM_PGA("IF3 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1918 | SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1919 | SND_SOC_DAPM_PGA("IF3 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1920 | SND_SOC_DAPM_PGA("IF3 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1921 | |||
1922 | SND_SOC_DAPM_SUPPLY("I2S4", RT5677_PWR_DIG1, | ||
1923 | RT5677_PWR_I2S4_BIT, 0, NULL, 0), | ||
1924 | SND_SOC_DAPM_PGA("IF4 DAC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1925 | SND_SOC_DAPM_PGA("IF4 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1926 | SND_SOC_DAPM_PGA("IF4 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1927 | SND_SOC_DAPM_PGA("IF4 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1928 | SND_SOC_DAPM_PGA("IF4 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1929 | SND_SOC_DAPM_PGA("IF4 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1930 | |||
1931 | SND_SOC_DAPM_SUPPLY("SLB", RT5677_PWR_DIG1, | ||
1932 | RT5677_PWR_SLB_BIT, 0, NULL, 0), | ||
1933 | SND_SOC_DAPM_PGA("SLB DAC0", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1934 | SND_SOC_DAPM_PGA("SLB DAC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1935 | SND_SOC_DAPM_PGA("SLB DAC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1936 | SND_SOC_DAPM_PGA("SLB DAC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1937 | SND_SOC_DAPM_PGA("SLB DAC4", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1938 | SND_SOC_DAPM_PGA("SLB DAC5", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1939 | SND_SOC_DAPM_PGA("SLB DAC6", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1940 | SND_SOC_DAPM_PGA("SLB DAC7", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1941 | SND_SOC_DAPM_PGA("SLB DAC01", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1942 | SND_SOC_DAPM_PGA("SLB DAC23", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1943 | SND_SOC_DAPM_PGA("SLB DAC45", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1944 | SND_SOC_DAPM_PGA("SLB DAC67", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1945 | SND_SOC_DAPM_PGA("SLB ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1946 | SND_SOC_DAPM_PGA("SLB ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1947 | SND_SOC_DAPM_PGA("SLB ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1948 | SND_SOC_DAPM_PGA("SLB ADC4", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1949 | |||
1950 | /* Digital Interface Select */ | ||
1951 | SND_SOC_DAPM_MUX("IF1 ADC1 Mux", SND_SOC_NOPM, 0, 0, | ||
1952 | &rt5677_if1_adc1_mux), | ||
1953 | SND_SOC_DAPM_MUX("IF1 ADC2 Mux", SND_SOC_NOPM, 0, 0, | ||
1954 | &rt5677_if1_adc2_mux), | ||
1955 | SND_SOC_DAPM_MUX("IF1 ADC3 Mux", SND_SOC_NOPM, 0, 0, | ||
1956 | &rt5677_if1_adc3_mux), | ||
1957 | SND_SOC_DAPM_MUX("IF1 ADC4 Mux", SND_SOC_NOPM, 0, 0, | ||
1958 | &rt5677_if1_adc4_mux), | ||
1959 | SND_SOC_DAPM_MUX("IF2 ADC1 Mux", SND_SOC_NOPM, 0, 0, | ||
1960 | &rt5677_if2_adc1_mux), | ||
1961 | SND_SOC_DAPM_MUX("IF2 ADC2 Mux", SND_SOC_NOPM, 0, 0, | ||
1962 | &rt5677_if2_adc2_mux), | ||
1963 | SND_SOC_DAPM_MUX("IF2 ADC3 Mux", SND_SOC_NOPM, 0, 0, | ||
1964 | &rt5677_if2_adc3_mux), | ||
1965 | SND_SOC_DAPM_MUX("IF2 ADC4 Mux", SND_SOC_NOPM, 0, 0, | ||
1966 | &rt5677_if2_adc4_mux), | ||
1967 | SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0, | ||
1968 | &rt5677_if3_adc_mux), | ||
1969 | SND_SOC_DAPM_MUX("IF4 ADC Mux", SND_SOC_NOPM, 0, 0, | ||
1970 | &rt5677_if4_adc_mux), | ||
1971 | SND_SOC_DAPM_MUX("SLB ADC1 Mux", SND_SOC_NOPM, 0, 0, | ||
1972 | &rt5677_slb_adc1_mux), | ||
1973 | SND_SOC_DAPM_MUX("SLB ADC2 Mux", SND_SOC_NOPM, 0, 0, | ||
1974 | &rt5677_slb_adc2_mux), | ||
1975 | SND_SOC_DAPM_MUX("SLB ADC3 Mux", SND_SOC_NOPM, 0, 0, | ||
1976 | &rt5677_slb_adc3_mux), | ||
1977 | SND_SOC_DAPM_MUX("SLB ADC4 Mux", SND_SOC_NOPM, 0, 0, | ||
1978 | &rt5677_slb_adc4_mux), | ||
1979 | |||
1980 | /* Audio Interface */ | ||
1981 | SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
1982 | SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), | ||
1983 | SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
1984 | SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0), | ||
1985 | SND_SOC_DAPM_AIF_IN("AIF3RX", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
1986 | SND_SOC_DAPM_AIF_OUT("AIF3TX", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0), | ||
1987 | SND_SOC_DAPM_AIF_IN("AIF4RX", "AIF4 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
1988 | SND_SOC_DAPM_AIF_OUT("AIF4TX", "AIF4 Capture", 0, SND_SOC_NOPM, 0, 0), | ||
1989 | SND_SOC_DAPM_AIF_IN("SLBRX", "SLIMBus Playback", 0, SND_SOC_NOPM, 0, 0), | ||
1990 | SND_SOC_DAPM_AIF_OUT("SLBTX", "SLIMBus Capture", 0, SND_SOC_NOPM, 0, 0), | ||
1991 | |||
1992 | /* Sidetone Mux */ | ||
1993 | SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0, | ||
1994 | &rt5677_sidetone_mux), | ||
1995 | /* VAD Mux*/ | ||
1996 | SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0, | ||
1997 | &rt5677_vad_src_mux), | ||
1998 | |||
1999 | /* Tensilica DSP */ | ||
2000 | SND_SOC_DAPM_PGA("Tensilica DSP", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
2001 | SND_SOC_DAPM_MIXER("OB01 MIX", SND_SOC_NOPM, 0, 0, | ||
2002 | rt5677_ob_01_mix, ARRAY_SIZE(rt5677_ob_01_mix)), | ||
2003 | SND_SOC_DAPM_MIXER("OB23 MIX", SND_SOC_NOPM, 0, 0, | ||
2004 | rt5677_ob_23_mix, ARRAY_SIZE(rt5677_ob_23_mix)), | ||
2005 | SND_SOC_DAPM_MIXER("OB4 MIX", SND_SOC_NOPM, 0, 0, | ||
2006 | rt5677_ob_4_mix, ARRAY_SIZE(rt5677_ob_4_mix)), | ||
2007 | SND_SOC_DAPM_MIXER("OB5 MIX", SND_SOC_NOPM, 0, 0, | ||
2008 | rt5677_ob_5_mix, ARRAY_SIZE(rt5677_ob_5_mix)), | ||
2009 | SND_SOC_DAPM_MIXER("OB6 MIX", SND_SOC_NOPM, 0, 0, | ||
2010 | rt5677_ob_6_mix, ARRAY_SIZE(rt5677_ob_6_mix)), | ||
2011 | SND_SOC_DAPM_MIXER("OB7 MIX", SND_SOC_NOPM, 0, 0, | ||
2012 | rt5677_ob_7_mix, ARRAY_SIZE(rt5677_ob_7_mix)), | ||
2013 | |||
2014 | /* Output Side */ | ||
2015 | /* DAC mixer before sound effect */ | ||
2016 | SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0, | ||
2017 | rt5677_dac_l_mix, ARRAY_SIZE(rt5677_dac_l_mix)), | ||
2018 | SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0, | ||
2019 | rt5677_dac_r_mix, ARRAY_SIZE(rt5677_dac_r_mix)), | ||
2020 | SND_SOC_DAPM_PGA("DAC1 FS", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
2021 | |||
2022 | /* DAC Mux */ | ||
2023 | SND_SOC_DAPM_MUX("DAC1 Mux", SND_SOC_NOPM, 0, 0, | ||
2024 | &rt5677_dac1_mux), | ||
2025 | SND_SOC_DAPM_MUX("ADDA1 Mux", SND_SOC_NOPM, 0, 0, | ||
2026 | &rt5677_adda1_mux), | ||
2027 | SND_SOC_DAPM_MUX("DAC12 SRC Mux", SND_SOC_NOPM, 0, 0, | ||
2028 | &rt5677_dac12_mux), | ||
2029 | SND_SOC_DAPM_MUX("DAC3 SRC Mux", SND_SOC_NOPM, 0, 0, | ||
2030 | &rt5677_dac3_mux), | ||
2031 | |||
2032 | /* DAC2 channel Mux */ | ||
2033 | SND_SOC_DAPM_MUX("DAC2 L Mux", SND_SOC_NOPM, 0, 0, | ||
2034 | &rt5677_dac2_l_mux), | ||
2035 | SND_SOC_DAPM_MUX("DAC2 R Mux", SND_SOC_NOPM, 0, 0, | ||
2036 | &rt5677_dac2_r_mux), | ||
2037 | |||
2038 | /* DAC3 channel Mux */ | ||
2039 | SND_SOC_DAPM_MUX("DAC3 L Mux", SND_SOC_NOPM, 0, 0, | ||
2040 | &rt5677_dac3_l_mux), | ||
2041 | SND_SOC_DAPM_MUX("DAC3 R Mux", SND_SOC_NOPM, 0, 0, | ||
2042 | &rt5677_dac3_r_mux), | ||
2043 | |||
2044 | /* DAC4 channel Mux */ | ||
2045 | SND_SOC_DAPM_MUX("DAC4 L Mux", SND_SOC_NOPM, 0, 0, | ||
2046 | &rt5677_dac4_l_mux), | ||
2047 | SND_SOC_DAPM_MUX("DAC4 R Mux", SND_SOC_NOPM, 0, 0, | ||
2048 | &rt5677_dac4_r_mux), | ||
2049 | |||
2050 | /* DAC Mixer */ | ||
2051 | SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2, | ||
2052 | RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0), | ||
2053 | SND_SOC_DAPM_SUPPLY("dac mono left filter", RT5677_PWR_DIG2, | ||
2054 | RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0), | ||
2055 | SND_SOC_DAPM_SUPPLY("dac mono right filter", RT5677_PWR_DIG2, | ||
2056 | RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0), | ||
2057 | |||
2058 | SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, | ||
2059 | rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)), | ||
2060 | SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0, | ||
2061 | rt5677_sto1_dac_r_mix, ARRAY_SIZE(rt5677_sto1_dac_r_mix)), | ||
2062 | SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0, | ||
2063 | rt5677_mono_dac_l_mix, ARRAY_SIZE(rt5677_mono_dac_l_mix)), | ||
2064 | SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0, | ||
2065 | rt5677_mono_dac_r_mix, ARRAY_SIZE(rt5677_mono_dac_r_mix)), | ||
2066 | SND_SOC_DAPM_MIXER("DD1 MIXL", SND_SOC_NOPM, 0, 0, | ||
2067 | rt5677_dd1_l_mix, ARRAY_SIZE(rt5677_dd1_l_mix)), | ||
2068 | SND_SOC_DAPM_MIXER("DD1 MIXR", SND_SOC_NOPM, 0, 0, | ||
2069 | rt5677_dd1_r_mix, ARRAY_SIZE(rt5677_dd1_r_mix)), | ||
2070 | SND_SOC_DAPM_MIXER("DD2 MIXL", SND_SOC_NOPM, 0, 0, | ||
2071 | rt5677_dd2_l_mix, ARRAY_SIZE(rt5677_dd2_l_mix)), | ||
2072 | SND_SOC_DAPM_MIXER("DD2 MIXR", SND_SOC_NOPM, 0, 0, | ||
2073 | rt5677_dd2_r_mix, ARRAY_SIZE(rt5677_dd2_r_mix)), | ||
2074 | SND_SOC_DAPM_PGA("Stereo DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
2075 | SND_SOC_DAPM_PGA("Mono DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
2076 | SND_SOC_DAPM_PGA("DD1 MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
2077 | SND_SOC_DAPM_PGA("DD2 MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
2078 | |||
2079 | /* DACs */ | ||
2080 | SND_SOC_DAPM_DAC("DAC 1", NULL, RT5677_PWR_DIG1, | ||
2081 | RT5677_PWR_DAC1_BIT, 0), | ||
2082 | SND_SOC_DAPM_DAC("DAC 2", NULL, RT5677_PWR_DIG1, | ||
2083 | RT5677_PWR_DAC2_BIT, 0), | ||
2084 | SND_SOC_DAPM_DAC("DAC 3", NULL, RT5677_PWR_DIG1, | ||
2085 | RT5677_PWR_DAC3_BIT, 0), | ||
2086 | |||
2087 | /* PDM */ | ||
2088 | SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5677_PWR_DIG2, | ||
2089 | RT5677_PWR_PDM1_BIT, 0, NULL, 0), | ||
2090 | SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5677_PWR_DIG2, | ||
2091 | RT5677_PWR_PDM2_BIT, 0, NULL, 0), | ||
2092 | |||
2093 | SND_SOC_DAPM_MUX("PDM1 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_L_SFT, | ||
2094 | 1, &rt5677_pdm1_l_mux), | ||
2095 | SND_SOC_DAPM_MUX("PDM1 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM1_R_SFT, | ||
2096 | 1, &rt5677_pdm1_r_mux), | ||
2097 | SND_SOC_DAPM_MUX("PDM2 L Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_L_SFT, | ||
2098 | 1, &rt5677_pdm2_l_mux), | ||
2099 | SND_SOC_DAPM_MUX("PDM2 R Mux", RT5677_PDM_OUT_CTRL, RT5677_M_PDM2_R_SFT, | ||
2100 | 1, &rt5677_pdm2_r_mux), | ||
2101 | |||
2102 | SND_SOC_DAPM_PGA_S("LOUT1 amp", 1, RT5677_PWR_ANLG1, RT5677_PWR_LO1_BIT, | ||
2103 | 0, NULL, 0), | ||
2104 | SND_SOC_DAPM_PGA_S("LOUT2 amp", 1, RT5677_PWR_ANLG1, RT5677_PWR_LO2_BIT, | ||
2105 | 0, NULL, 0), | ||
2106 | SND_SOC_DAPM_PGA_S("LOUT3 amp", 1, RT5677_PWR_ANLG1, RT5677_PWR_LO3_BIT, | ||
2107 | 0, NULL, 0), | ||
2108 | |||
2109 | /* Output Lines */ | ||
2110 | SND_SOC_DAPM_OUTPUT("LOUT1"), | ||
2111 | SND_SOC_DAPM_OUTPUT("LOUT2"), | ||
2112 | SND_SOC_DAPM_OUTPUT("LOUT3"), | ||
2113 | SND_SOC_DAPM_OUTPUT("PDM1L"), | ||
2114 | SND_SOC_DAPM_OUTPUT("PDM1R"), | ||
2115 | SND_SOC_DAPM_OUTPUT("PDM2L"), | ||
2116 | SND_SOC_DAPM_OUTPUT("PDM2R"), | ||
2117 | }; | ||
2118 | |||
2119 | static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { | ||
2120 | { "DMIC1", NULL, "DMIC L1" }, | ||
2121 | { "DMIC1", NULL, "DMIC R1" }, | ||
2122 | { "DMIC2", NULL, "DMIC L2" }, | ||
2123 | { "DMIC2", NULL, "DMIC R2" }, | ||
2124 | { "DMIC3", NULL, "DMIC L3" }, | ||
2125 | { "DMIC3", NULL, "DMIC R3" }, | ||
2126 | { "DMIC4", NULL, "DMIC L4" }, | ||
2127 | { "DMIC4", NULL, "DMIC R4" }, | ||
2128 | |||
2129 | { "DMIC L1", NULL, "DMIC CLK" }, | ||
2130 | { "DMIC R1", NULL, "DMIC CLK" }, | ||
2131 | { "DMIC L2", NULL, "DMIC CLK" }, | ||
2132 | { "DMIC R2", NULL, "DMIC CLK" }, | ||
2133 | { "DMIC L3", NULL, "DMIC CLK" }, | ||
2134 | { "DMIC R3", NULL, "DMIC CLK" }, | ||
2135 | { "DMIC L4", NULL, "DMIC CLK" }, | ||
2136 | { "DMIC R4", NULL, "DMIC CLK" }, | ||
2137 | |||
2138 | { "BST1", NULL, "IN1P" }, | ||
2139 | { "BST1", NULL, "IN1N" }, | ||
2140 | { "BST2", NULL, "IN2P" }, | ||
2141 | { "BST2", NULL, "IN2N" }, | ||
2142 | |||
2143 | { "IN1P", NULL, "micbias1" }, | ||
2144 | { "IN1N", NULL, "micbias1" }, | ||
2145 | { "IN2P", NULL, "micbias1" }, | ||
2146 | { "IN2N", NULL, "micbias1" }, | ||
2147 | |||
2148 | { "ADC 1", NULL, "BST1" }, | ||
2149 | { "ADC 1", NULL, "ADC 1 power" }, | ||
2150 | { "ADC 1", NULL, "ADC1 clock" }, | ||
2151 | { "ADC 2", NULL, "BST2" }, | ||
2152 | { "ADC 2", NULL, "ADC 2 power" }, | ||
2153 | { "ADC 2", NULL, "ADC2 clock" }, | ||
2154 | |||
2155 | { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" }, | ||
2156 | { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" }, | ||
2157 | { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" }, | ||
2158 | { "Stereo1 DMIC Mux", "DMIC4", "DMIC4" }, | ||
2159 | |||
2160 | { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" }, | ||
2161 | { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" }, | ||
2162 | { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" }, | ||
2163 | { "Stereo2 DMIC Mux", "DMIC4", "DMIC4" }, | ||
2164 | |||
2165 | { "Stereo3 DMIC Mux", "DMIC1", "DMIC1" }, | ||
2166 | { "Stereo3 DMIC Mux", "DMIC2", "DMIC2" }, | ||
2167 | { "Stereo3 DMIC Mux", "DMIC3", "DMIC3" }, | ||
2168 | { "Stereo3 DMIC Mux", "DMIC4", "DMIC4" }, | ||
2169 | |||
2170 | { "Stereo4 DMIC Mux", "DMIC1", "DMIC1" }, | ||
2171 | { "Stereo4 DMIC Mux", "DMIC2", "DMIC2" }, | ||
2172 | { "Stereo4 DMIC Mux", "DMIC3", "DMIC3" }, | ||
2173 | { "Stereo4 DMIC Mux", "DMIC4", "DMIC4" }, | ||
2174 | |||
2175 | { "Mono DMIC L Mux", "DMIC1", "DMIC1" }, | ||
2176 | { "Mono DMIC L Mux", "DMIC2", "DMIC2" }, | ||
2177 | { "Mono DMIC L Mux", "DMIC3", "DMIC3" }, | ||
2178 | { "Mono DMIC L Mux", "DMIC4", "DMIC4" }, | ||
2179 | |||
2180 | { "Mono DMIC R Mux", "DMIC1", "DMIC1" }, | ||
2181 | { "Mono DMIC R Mux", "DMIC2", "DMIC2" }, | ||
2182 | { "Mono DMIC R Mux", "DMIC3", "DMIC3" }, | ||
2183 | { "Mono DMIC R Mux", "DMIC4", "DMIC4" }, | ||
2184 | |||
2185 | { "ADC 1_2", NULL, "ADC 1" }, | ||
2186 | { "ADC 1_2", NULL, "ADC 2" }, | ||
2187 | |||
2188 | { "Stereo1 ADC1 Mux", "DD MIX1", "DD1 MIX" }, | ||
2189 | { "Stereo1 ADC1 Mux", "ADC1/2", "ADC 1_2" }, | ||
2190 | { "Stereo1 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, | ||
2191 | |||
2192 | { "Stereo1 ADC2 Mux", "DD MIX1", "DD1 MIX" }, | ||
2193 | { "Stereo1 ADC2 Mux", "DMIC", "Stereo1 DMIC Mux" }, | ||
2194 | { "Stereo1 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, | ||
2195 | |||
2196 | { "Stereo2 ADC1 Mux", "DD MIX1", "DD1 MIX" }, | ||
2197 | { "Stereo2 ADC1 Mux", "ADC1/2", "ADC 1_2" }, | ||
2198 | { "Stereo2 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, | ||
2199 | |||
2200 | { "Stereo2 ADC2 Mux", "DD MIX1", "DD1 MIX" }, | ||
2201 | { "Stereo2 ADC2 Mux", "DMIC", "Stereo2 DMIC Mux" }, | ||
2202 | { "Stereo2 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, | ||
2203 | |||
2204 | { "Stereo3 ADC1 Mux", "DD MIX1", "DD1 MIX" }, | ||
2205 | { "Stereo3 ADC1 Mux", "ADC1/2", "ADC 1_2" }, | ||
2206 | { "Stereo3 ADC1 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, | ||
2207 | |||
2208 | { "Stereo3 ADC2 Mux", "DD MIX1", "DD1 MIX" }, | ||
2209 | { "Stereo3 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" }, | ||
2210 | { "Stereo3 ADC2 Mux", "Stereo DAC MIX", "Stereo DAC MIX" }, | ||
2211 | |||
2212 | { "Stereo4 ADC1 Mux", "DD MIX1", "DD1 MIX" }, | ||
2213 | { "Stereo4 ADC1 Mux", "ADC1/2", "ADC 1_2" }, | ||
2214 | { "Stereo4 ADC1 Mux", "DD MIX2", "DD2 MIX" }, | ||
2215 | |||
2216 | { "Stereo4 ADC2 Mux", "DD MIX1", "DD1 MIX" }, | ||
2217 | { "Stereo4 ADC2 Mux", "DMIC", "Stereo3 DMIC Mux" }, | ||
2218 | { "Stereo4 ADC2 Mux", "DD MIX2", "DD2 MIX" }, | ||
2219 | |||
2220 | { "Mono ADC2 L Mux", "DD MIX1L", "DD1 MIXL" }, | ||
2221 | { "Mono ADC2 L Mux", "DMIC", "Mono DMIC L Mux" }, | ||
2222 | { "Mono ADC2 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" }, | ||
2223 | |||
2224 | { "Mono ADC1 L Mux", "DD MIX1L", "DD1 MIXL" }, | ||
2225 | { "Mono ADC1 L Mux", "ADC1", "ADC 1" }, | ||
2226 | { "Mono ADC1 L Mux", "MONO DAC MIXL", "Mono DAC MIXL" }, | ||
2227 | |||
2228 | { "Mono ADC1 R Mux", "DD MIX1R", "DD1 MIXR" }, | ||
2229 | { "Mono ADC1 R Mux", "ADC2", "ADC 2" }, | ||
2230 | { "Mono ADC1 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" }, | ||
2231 | |||
2232 | { "Mono ADC2 R Mux", "DD MIX1R", "DD1 MIXR" }, | ||
2233 | { "Mono ADC2 R Mux", "DMIC", "Mono DMIC R Mux" }, | ||
2234 | { "Mono ADC2 R Mux", "MONO DAC MIXR", "Mono DAC MIXR" }, | ||
2235 | |||
2236 | { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC1 Mux" }, | ||
2237 | { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC2 Mux" }, | ||
2238 | { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC1 Mux" }, | ||
2239 | { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC2 Mux" }, | ||
2240 | |||
2241 | { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" }, | ||
2242 | { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" }, | ||
2243 | { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2244 | |||
2245 | { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" }, | ||
2246 | { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" }, | ||
2247 | { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2248 | |||
2249 | { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" }, | ||
2250 | { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" }, | ||
2251 | |||
2252 | { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC1 Mux" }, | ||
2253 | { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC2 Mux" }, | ||
2254 | { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC1 Mux" }, | ||
2255 | { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC2 Mux" }, | ||
2256 | |||
2257 | { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" }, | ||
2258 | { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" }, | ||
2259 | |||
2260 | { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" }, | ||
2261 | { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" }, | ||
2262 | |||
2263 | { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" }, | ||
2264 | { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" }, | ||
2265 | { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2266 | |||
2267 | { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" }, | ||
2268 | { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" }, | ||
2269 | { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2270 | |||
2271 | { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXL" }, | ||
2272 | { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXR" }, | ||
2273 | |||
2274 | { "Sto3 ADC MIXL", "ADC1 Switch", "Stereo3 ADC1 Mux" }, | ||
2275 | { "Sto3 ADC MIXL", "ADC2 Switch", "Stereo3 ADC2 Mux" }, | ||
2276 | { "Sto3 ADC MIXR", "ADC1 Switch", "Stereo3 ADC1 Mux" }, | ||
2277 | { "Sto3 ADC MIXR", "ADC2 Switch", "Stereo3 ADC2 Mux" }, | ||
2278 | |||
2279 | { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" }, | ||
2280 | { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" }, | ||
2281 | { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2282 | |||
2283 | { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" }, | ||
2284 | { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" }, | ||
2285 | { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2286 | |||
2287 | { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXL" }, | ||
2288 | { "Stereo3 ADC MIX", NULL, "Stereo3 ADC MIXR" }, | ||
2289 | |||
2290 | { "Sto4 ADC MIXL", "ADC1 Switch", "Stereo4 ADC1 Mux" }, | ||
2291 | { "Sto4 ADC MIXL", "ADC2 Switch", "Stereo4 ADC2 Mux" }, | ||
2292 | { "Sto4 ADC MIXR", "ADC1 Switch", "Stereo4 ADC1 Mux" }, | ||
2293 | { "Sto4 ADC MIXR", "ADC2 Switch", "Stereo4 ADC2 Mux" }, | ||
2294 | |||
2295 | { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" }, | ||
2296 | { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" }, | ||
2297 | { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2298 | |||
2299 | { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" }, | ||
2300 | { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" }, | ||
2301 | { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2302 | |||
2303 | { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXL" }, | ||
2304 | { "Stereo4 ADC MIX", NULL, "Stereo4 ADC MIXR" }, | ||
2305 | |||
2306 | { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC1 L Mux" }, | ||
2307 | { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC2 L Mux" }, | ||
2308 | { "Mono ADC MIXL", NULL, "adc mono left filter" }, | ||
2309 | { "adc mono left filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2310 | |||
2311 | { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC1 R Mux" }, | ||
2312 | { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC2 R Mux" }, | ||
2313 | { "Mono ADC MIXR", NULL, "adc mono right filter" }, | ||
2314 | { "adc mono right filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2315 | |||
2316 | { "Mono ADC MIX", NULL, "Mono ADC MIXL" }, | ||
2317 | { "Mono ADC MIX", NULL, "Mono ADC MIXR" }, | ||
2318 | |||
2319 | { "VAD ADC Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" }, | ||
2320 | { "VAD ADC Mux", "MONO ADC MIX L", "Mono ADC MIXL" }, | ||
2321 | { "VAD ADC Mux", "MONO ADC MIX R", "Mono ADC MIXR" }, | ||
2322 | { "VAD ADC Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" }, | ||
2323 | { "VAD ADC Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" }, | ||
2324 | |||
2325 | { "IF1 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, | ||
2326 | { "IF1 ADC1 Mux", "OB01", "OB01 Bypass Mux" }, | ||
2327 | { "IF1 ADC1 Mux", "VAD ADC", "VAD ADC Mux" }, | ||
2328 | |||
2329 | { "IF1 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, | ||
2330 | { "IF1 ADC2 Mux", "OB23", "OB23 Bypass Mux" }, | ||
2331 | |||
2332 | { "IF1 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, | ||
2333 | { "IF1 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" }, | ||
2334 | { "IF1 ADC3 Mux", "OB45", "OB45" }, | ||
2335 | |||
2336 | { "IF1 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, | ||
2337 | { "IF1 ADC4 Mux", "OB67", "OB67" }, | ||
2338 | { "IF1 ADC4 Mux", "OB01", "OB01 Bypass Mux" }, | ||
2339 | |||
2340 | { "AIF1TX", NULL, "I2S1" }, | ||
2341 | { "AIF1TX", NULL, "IF1 ADC1 Mux" }, | ||
2342 | { "AIF1TX", NULL, "IF1 ADC2 Mux" }, | ||
2343 | { "AIF1TX", NULL, "IF1 ADC3 Mux" }, | ||
2344 | { "AIF1TX", NULL, "IF1 ADC4 Mux" }, | ||
2345 | |||
2346 | { "IF2 ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, | ||
2347 | { "IF2 ADC1 Mux", "OB01", "OB01 Bypass Mux" }, | ||
2348 | { "IF2 ADC1 Mux", "VAD ADC", "VAD ADC Mux" }, | ||
2349 | |||
2350 | { "IF2 ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, | ||
2351 | { "IF2 ADC2 Mux", "OB23", "OB23 Bypass Mux" }, | ||
2352 | |||
2353 | { "IF2 ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, | ||
2354 | { "IF2 ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" }, | ||
2355 | { "IF2 ADC3 Mux", "OB45", "OB45" }, | ||
2356 | |||
2357 | { "IF2 ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, | ||
2358 | { "IF2 ADC4 Mux", "OB67", "OB67" }, | ||
2359 | { "IF2 ADC4 Mux", "OB01", "OB01 Bypass Mux" }, | ||
2360 | |||
2361 | { "AIF2TX", NULL, "I2S2" }, | ||
2362 | { "AIF2TX", NULL, "IF2 ADC1 Mux" }, | ||
2363 | { "AIF2TX", NULL, "IF2 ADC2 Mux" }, | ||
2364 | { "AIF2TX", NULL, "IF2 ADC3 Mux" }, | ||
2365 | { "AIF2TX", NULL, "IF2 ADC4 Mux" }, | ||
2366 | |||
2367 | { "IF3 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, | ||
2368 | { "IF3 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, | ||
2369 | { "IF3 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, | ||
2370 | { "IF3 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, | ||
2371 | { "IF3 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" }, | ||
2372 | { "IF3 ADC Mux", "OB01", "OB01 Bypass Mux" }, | ||
2373 | { "IF3 ADC Mux", "OB23", "OB23 Bypass Mux" }, | ||
2374 | { "IF3 ADC Mux", "VAD ADC", "VAD ADC Mux" }, | ||
2375 | |||
2376 | { "AIF3TX", NULL, "I2S3" }, | ||
2377 | { "AIF3TX", NULL, "IF3 ADC Mux" }, | ||
2378 | |||
2379 | { "IF4 ADC Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, | ||
2380 | { "IF4 ADC Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, | ||
2381 | { "IF4 ADC Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, | ||
2382 | { "IF4 ADC Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, | ||
2383 | { "IF4 ADC Mux", "MONO ADC MIX", "Mono ADC MIX" }, | ||
2384 | { "IF4 ADC Mux", "OB01", "OB01 Bypass Mux" }, | ||
2385 | { "IF4 ADC Mux", "OB23", "OB23 Bypass Mux" }, | ||
2386 | { "IF4 ADC Mux", "VAD ADC", "VAD ADC Mux" }, | ||
2387 | |||
2388 | { "AIF4TX", NULL, "I2S4" }, | ||
2389 | { "AIF4TX", NULL, "IF4 ADC Mux" }, | ||
2390 | |||
2391 | { "SLB ADC1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, | ||
2392 | { "SLB ADC1 Mux", "OB01", "OB01 Bypass Mux" }, | ||
2393 | { "SLB ADC1 Mux", "VAD ADC", "VAD ADC Mux" }, | ||
2394 | |||
2395 | { "SLB ADC2 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, | ||
2396 | { "SLB ADC2 Mux", "OB23", "OB23 Bypass Mux" }, | ||
2397 | |||
2398 | { "SLB ADC3 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, | ||
2399 | { "SLB ADC3 Mux", "MONO ADC MIX", "Mono ADC MIX" }, | ||
2400 | { "SLB ADC3 Mux", "OB45", "OB45" }, | ||
2401 | |||
2402 | { "SLB ADC4 Mux", "STO4 ADC MIX", "Stereo4 ADC MIX" }, | ||
2403 | { "SLB ADC4 Mux", "OB67", "OB67" }, | ||
2404 | { "SLB ADC4 Mux", "OB01", "OB01 Bypass Mux" }, | ||
2405 | |||
2406 | { "SLBTX", NULL, "SLB" }, | ||
2407 | { "SLBTX", NULL, "SLB ADC1 Mux" }, | ||
2408 | { "SLBTX", NULL, "SLB ADC2 Mux" }, | ||
2409 | { "SLBTX", NULL, "SLB ADC3 Mux" }, | ||
2410 | { "SLBTX", NULL, "SLB ADC4 Mux" }, | ||
2411 | |||
2412 | { "IB01 Mux", "IF1 DAC 01", "IF1 DAC01" }, | ||
2413 | { "IB01 Mux", "IF2 DAC 01", "IF2 DAC01" }, | ||
2414 | { "IB01 Mux", "SLB DAC 01", "SLB DAC01" }, | ||
2415 | { "IB01 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, | ||
2416 | { "IB01 Mux", "VAD ADC/DAC1 FS", "DAC1 FS" }, | ||
2417 | |||
2418 | { "IB01 Bypass Mux", "Bypass", "IB01 Mux" }, | ||
2419 | { "IB01 Bypass Mux", "Pass SRC", "IB01 Mux" }, | ||
2420 | |||
2421 | { "IB23 Mux", "IF1 DAC 23", "IF1 DAC23" }, | ||
2422 | { "IB23 Mux", "IF2 DAC 23", "IF2 DAC23" }, | ||
2423 | { "IB23 Mux", "SLB DAC 23", "SLB DAC23" }, | ||
2424 | { "IB23 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, | ||
2425 | { "IB23 Mux", "DAC1 FS", "DAC1 FS" }, | ||
2426 | { "IB23 Mux", "IF4 DAC", "IF4 DAC" }, | ||
2427 | |||
2428 | { "IB23 Bypass Mux", "Bypass", "IB23 Mux" }, | ||
2429 | { "IB23 Bypass Mux", "Pass SRC", "IB23 Mux" }, | ||
2430 | |||
2431 | { "IB45 Mux", "IF1 DAC 45", "IF1 DAC45" }, | ||
2432 | { "IB45 Mux", "IF2 DAC 45", "IF2 DAC45" }, | ||
2433 | { "IB45 Mux", "SLB DAC 45", "SLB DAC45" }, | ||
2434 | { "IB45 Mux", "STO3 ADC MIX", "Stereo3 ADC MIX" }, | ||
2435 | { "IB45 Mux", "IF3 DAC", "IF3 DAC" }, | ||
2436 | |||
2437 | { "IB45 Bypass Mux", "Bypass", "IB45 Mux" }, | ||
2438 | { "IB45 Bypass Mux", "Pass SRC", "IB45 Mux" }, | ||
2439 | |||
2440 | { "IB6 Mux", "IF1 DAC 6", "IF1 DAC6" }, | ||
2441 | { "IB6 Mux", "IF2 DAC 6", "IF2 DAC6" }, | ||
2442 | { "IB6 Mux", "SLB DAC 6", "SLB DAC6" }, | ||
2443 | { "IB6 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" }, | ||
2444 | { "IB6 Mux", "IF4 DAC L", "IF4 DAC L" }, | ||
2445 | { "IB6 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" }, | ||
2446 | { "IB6 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" }, | ||
2447 | { "IB6 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" }, | ||
2448 | |||
2449 | { "IB7 Mux", "IF1 DAC 7", "IF1 DAC7" }, | ||
2450 | { "IB7 Mux", "IF2 DAC 7", "IF2 DAC7" }, | ||
2451 | { "IB7 Mux", "SLB DAC 7", "SLB DAC7" }, | ||
2452 | { "IB7 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" }, | ||
2453 | { "IB7 Mux", "IF4 DAC R", "IF4 DAC R" }, | ||
2454 | { "IB7 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" }, | ||
2455 | { "IB7 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" }, | ||
2456 | { "IB7 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" }, | ||
2457 | |||
2458 | { "IB8 Mux", "STO1 ADC MIX L", "Stereo1 ADC MIXL" }, | ||
2459 | { "IB8 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" }, | ||
2460 | { "IB8 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" }, | ||
2461 | { "IB8 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" }, | ||
2462 | { "IB8 Mux", "MONO ADC MIX L", "Mono ADC MIXL" }, | ||
2463 | { "IB8 Mux", "DACL1 FS", "DAC1 MIXL" }, | ||
2464 | |||
2465 | { "IB9 Mux", "STO1 ADC MIX R", "Stereo1 ADC MIXR" }, | ||
2466 | { "IB9 Mux", "STO2 ADC MIX R", "Stereo2 ADC MIXR" }, | ||
2467 | { "IB9 Mux", "STO3 ADC MIX R", "Stereo3 ADC MIXR" }, | ||
2468 | { "IB9 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" }, | ||
2469 | { "IB9 Mux", "MONO ADC MIX R", "Mono ADC MIXR" }, | ||
2470 | { "IB9 Mux", "DACR1 FS", "DAC1 MIXR" }, | ||
2471 | { "IB9 Mux", "DAC1 FS", "DAC1 FS" }, | ||
2472 | |||
2473 | { "OB01 MIX", "IB01 Switch", "IB01 Bypass Mux" }, | ||
2474 | { "OB01 MIX", "IB23 Switch", "IB23 Bypass Mux" }, | ||
2475 | { "OB01 MIX", "IB45 Switch", "IB45 Bypass Mux" }, | ||
2476 | { "OB01 MIX", "IB6 Switch", "IB6 Mux" }, | ||
2477 | { "OB01 MIX", "IB7 Switch", "IB7 Mux" }, | ||
2478 | { "OB01 MIX", "IB8 Switch", "IB8 Mux" }, | ||
2479 | { "OB01 MIX", "IB9 Switch", "IB9 Mux" }, | ||
2480 | |||
2481 | { "OB23 MIX", "IB01 Switch", "IB01 Bypass Mux" }, | ||
2482 | { "OB23 MIX", "IB23 Switch", "IB23 Bypass Mux" }, | ||
2483 | { "OB23 MIX", "IB45 Switch", "IB45 Bypass Mux" }, | ||
2484 | { "OB23 MIX", "IB6 Switch", "IB6 Mux" }, | ||
2485 | { "OB23 MIX", "IB7 Switch", "IB7 Mux" }, | ||
2486 | { "OB23 MIX", "IB8 Switch", "IB8 Mux" }, | ||
2487 | { "OB23 MIX", "IB9 Switch", "IB9 Mux" }, | ||
2488 | |||
2489 | { "OB4 MIX", "IB01 Switch", "IB01 Bypass Mux" }, | ||
2490 | { "OB4 MIX", "IB23 Switch", "IB23 Bypass Mux" }, | ||
2491 | { "OB4 MIX", "IB45 Switch", "IB45 Bypass Mux" }, | ||
2492 | { "OB4 MIX", "IB6 Switch", "IB6 Mux" }, | ||
2493 | { "OB4 MIX", "IB7 Switch", "IB7 Mux" }, | ||
2494 | { "OB4 MIX", "IB8 Switch", "IB8 Mux" }, | ||
2495 | { "OB4 MIX", "IB9 Switch", "IB9 Mux" }, | ||
2496 | |||
2497 | { "OB5 MIX", "IB01 Switch", "IB01 Bypass Mux" }, | ||
2498 | { "OB5 MIX", "IB23 Switch", "IB23 Bypass Mux" }, | ||
2499 | { "OB5 MIX", "IB45 Switch", "IB45 Bypass Mux" }, | ||
2500 | { "OB5 MIX", "IB6 Switch", "IB6 Mux" }, | ||
2501 | { "OB5 MIX", "IB7 Switch", "IB7 Mux" }, | ||
2502 | { "OB5 MIX", "IB8 Switch", "IB8 Mux" }, | ||
2503 | { "OB5 MIX", "IB9 Switch", "IB9 Mux" }, | ||
2504 | |||
2505 | { "OB6 MIX", "IB01 Switch", "IB01 Bypass Mux" }, | ||
2506 | { "OB6 MIX", "IB23 Switch", "IB23 Bypass Mux" }, | ||
2507 | { "OB6 MIX", "IB45 Switch", "IB45 Bypass Mux" }, | ||
2508 | { "OB6 MIX", "IB6 Switch", "IB6 Mux" }, | ||
2509 | { "OB6 MIX", "IB7 Switch", "IB7 Mux" }, | ||
2510 | { "OB6 MIX", "IB8 Switch", "IB8 Mux" }, | ||
2511 | { "OB6 MIX", "IB9 Switch", "IB9 Mux" }, | ||
2512 | |||
2513 | { "OB7 MIX", "IB01 Switch", "IB01 Bypass Mux" }, | ||
2514 | { "OB7 MIX", "IB23 Switch", "IB23 Bypass Mux" }, | ||
2515 | { "OB7 MIX", "IB45 Switch", "IB45 Bypass Mux" }, | ||
2516 | { "OB7 MIX", "IB6 Switch", "IB6 Mux" }, | ||
2517 | { "OB7 MIX", "IB7 Switch", "IB7 Mux" }, | ||
2518 | { "OB7 MIX", "IB8 Switch", "IB8 Mux" }, | ||
2519 | { "OB7 MIX", "IB9 Switch", "IB9 Mux" }, | ||
2520 | |||
2521 | { "OB01 Bypass Mux", "Bypass", "OB01 MIX" }, | ||
2522 | { "OB01 Bypass Mux", "Pass SRC", "OB01 MIX" }, | ||
2523 | { "OB23 Bypass Mux", "Bypass", "OB23 MIX" }, | ||
2524 | { "OB23 Bypass Mux", "Pass SRC", "OB23 MIX" }, | ||
2525 | |||
2526 | { "OutBound2", NULL, "OB23 Bypass Mux" }, | ||
2527 | { "OutBound3", NULL, "OB23 Bypass Mux" }, | ||
2528 | { "OutBound4", NULL, "OB4 MIX" }, | ||
2529 | { "OutBound5", NULL, "OB5 MIX" }, | ||
2530 | { "OutBound6", NULL, "OB6 MIX" }, | ||
2531 | { "OutBound7", NULL, "OB7 MIX" }, | ||
2532 | |||
2533 | { "OB45", NULL, "OutBound4" }, | ||
2534 | { "OB45", NULL, "OutBound5" }, | ||
2535 | { "OB67", NULL, "OutBound6" }, | ||
2536 | { "OB67", NULL, "OutBound7" }, | ||
2537 | |||
2538 | { "IF1 DAC0", NULL, "AIF1RX" }, | ||
2539 | { "IF1 DAC1", NULL, "AIF1RX" }, | ||
2540 | { "IF1 DAC2", NULL, "AIF1RX" }, | ||
2541 | { "IF1 DAC3", NULL, "AIF1RX" }, | ||
2542 | { "IF1 DAC4", NULL, "AIF1RX" }, | ||
2543 | { "IF1 DAC5", NULL, "AIF1RX" }, | ||
2544 | { "IF1 DAC6", NULL, "AIF1RX" }, | ||
2545 | { "IF1 DAC7", NULL, "AIF1RX" }, | ||
2546 | { "IF1 DAC0", NULL, "I2S1" }, | ||
2547 | { "IF1 DAC1", NULL, "I2S1" }, | ||
2548 | { "IF1 DAC2", NULL, "I2S1" }, | ||
2549 | { "IF1 DAC3", NULL, "I2S1" }, | ||
2550 | { "IF1 DAC4", NULL, "I2S1" }, | ||
2551 | { "IF1 DAC5", NULL, "I2S1" }, | ||
2552 | { "IF1 DAC6", NULL, "I2S1" }, | ||
2553 | { "IF1 DAC7", NULL, "I2S1" }, | ||
2554 | |||
2555 | { "IF1 DAC01", NULL, "IF1 DAC0" }, | ||
2556 | { "IF1 DAC01", NULL, "IF1 DAC1" }, | ||
2557 | { "IF1 DAC23", NULL, "IF1 DAC2" }, | ||
2558 | { "IF1 DAC23", NULL, "IF1 DAC3" }, | ||
2559 | { "IF1 DAC45", NULL, "IF1 DAC4" }, | ||
2560 | { "IF1 DAC45", NULL, "IF1 DAC5" }, | ||
2561 | { "IF1 DAC67", NULL, "IF1 DAC6" }, | ||
2562 | { "IF1 DAC67", NULL, "IF1 DAC7" }, | ||
2563 | |||
2564 | { "IF2 DAC0", NULL, "AIF2RX" }, | ||
2565 | { "IF2 DAC1", NULL, "AIF2RX" }, | ||
2566 | { "IF2 DAC2", NULL, "AIF2RX" }, | ||
2567 | { "IF2 DAC3", NULL, "AIF2RX" }, | ||
2568 | { "IF2 DAC4", NULL, "AIF2RX" }, | ||
2569 | { "IF2 DAC5", NULL, "AIF2RX" }, | ||
2570 | { "IF2 DAC6", NULL, "AIF2RX" }, | ||
2571 | { "IF2 DAC7", NULL, "AIF2RX" }, | ||
2572 | { "IF2 DAC0", NULL, "I2S2" }, | ||
2573 | { "IF2 DAC1", NULL, "I2S2" }, | ||
2574 | { "IF2 DAC2", NULL, "I2S2" }, | ||
2575 | { "IF2 DAC3", NULL, "I2S2" }, | ||
2576 | { "IF2 DAC4", NULL, "I2S2" }, | ||
2577 | { "IF2 DAC5", NULL, "I2S2" }, | ||
2578 | { "IF2 DAC6", NULL, "I2S2" }, | ||
2579 | { "IF2 DAC7", NULL, "I2S2" }, | ||
2580 | |||
2581 | { "IF2 DAC01", NULL, "IF2 DAC0" }, | ||
2582 | { "IF2 DAC01", NULL, "IF2 DAC1" }, | ||
2583 | { "IF2 DAC23", NULL, "IF2 DAC2" }, | ||
2584 | { "IF2 DAC23", NULL, "IF2 DAC3" }, | ||
2585 | { "IF2 DAC45", NULL, "IF2 DAC4" }, | ||
2586 | { "IF2 DAC45", NULL, "IF2 DAC5" }, | ||
2587 | { "IF2 DAC67", NULL, "IF2 DAC6" }, | ||
2588 | { "IF2 DAC67", NULL, "IF2 DAC7" }, | ||
2589 | |||
2590 | { "IF3 DAC", NULL, "AIF3RX" }, | ||
2591 | { "IF3 DAC", NULL, "I2S3" }, | ||
2592 | |||
2593 | { "IF4 DAC", NULL, "AIF4RX" }, | ||
2594 | { "IF4 DAC", NULL, "I2S4" }, | ||
2595 | |||
2596 | { "IF3 DAC L", NULL, "IF3 DAC" }, | ||
2597 | { "IF3 DAC R", NULL, "IF3 DAC" }, | ||
2598 | |||
2599 | { "IF4 DAC L", NULL, "IF4 DAC" }, | ||
2600 | { "IF4 DAC R", NULL, "IF4 DAC" }, | ||
2601 | |||
2602 | { "SLB DAC0", NULL, "SLBRX" }, | ||
2603 | { "SLB DAC1", NULL, "SLBRX" }, | ||
2604 | { "SLB DAC2", NULL, "SLBRX" }, | ||
2605 | { "SLB DAC3", NULL, "SLBRX" }, | ||
2606 | { "SLB DAC4", NULL, "SLBRX" }, | ||
2607 | { "SLB DAC5", NULL, "SLBRX" }, | ||
2608 | { "SLB DAC6", NULL, "SLBRX" }, | ||
2609 | { "SLB DAC7", NULL, "SLBRX" }, | ||
2610 | { "SLB DAC0", NULL, "SLB" }, | ||
2611 | { "SLB DAC1", NULL, "SLB" }, | ||
2612 | { "SLB DAC2", NULL, "SLB" }, | ||
2613 | { "SLB DAC3", NULL, "SLB" }, | ||
2614 | { "SLB DAC4", NULL, "SLB" }, | ||
2615 | { "SLB DAC5", NULL, "SLB" }, | ||
2616 | { "SLB DAC6", NULL, "SLB" }, | ||
2617 | { "SLB DAC7", NULL, "SLB" }, | ||
2618 | |||
2619 | { "SLB DAC01", NULL, "SLB DAC0" }, | ||
2620 | { "SLB DAC01", NULL, "SLB DAC1" }, | ||
2621 | { "SLB DAC23", NULL, "SLB DAC2" }, | ||
2622 | { "SLB DAC23", NULL, "SLB DAC3" }, | ||
2623 | { "SLB DAC45", NULL, "SLB DAC4" }, | ||
2624 | { "SLB DAC45", NULL, "SLB DAC5" }, | ||
2625 | { "SLB DAC67", NULL, "SLB DAC6" }, | ||
2626 | { "SLB DAC67", NULL, "SLB DAC7" }, | ||
2627 | |||
2628 | { "ADDA1 Mux", "STO1 ADC MIX", "Stereo1 ADC MIX" }, | ||
2629 | { "ADDA1 Mux", "STO2 ADC MIX", "Stereo2 ADC MIX" }, | ||
2630 | { "ADDA1 Mux", "OB 67", "OB67" }, | ||
2631 | |||
2632 | { "DAC1 Mux", "IF1 DAC 01", "IF1 DAC01" }, | ||
2633 | { "DAC1 Mux", "IF2 DAC 01", "IF2 DAC01" }, | ||
2634 | { "DAC1 Mux", "IF3 DAC LR", "IF3 DAC" }, | ||
2635 | { "DAC1 Mux", "IF4 DAC LR", "IF4 DAC" }, | ||
2636 | { "DAC1 Mux", "SLB DAC 01", "SLB DAC01" }, | ||
2637 | { "DAC1 Mux", "OB 01", "OB01 Bypass Mux" }, | ||
2638 | |||
2639 | { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" }, | ||
2640 | { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" }, | ||
2641 | { "DAC1 MIXL", NULL, "dac stereo1 filter" }, | ||
2642 | { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" }, | ||
2643 | { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" }, | ||
2644 | { "DAC1 MIXR", NULL, "dac stereo1 filter" }, | ||
2645 | |||
2646 | { "DAC1 FS", NULL, "DAC1 MIXL" }, | ||
2647 | { "DAC1 FS", NULL, "DAC1 MIXR" }, | ||
2648 | |||
2649 | { "DAC2 L Mux", "IF1 DAC 2", "IF1 DAC2" }, | ||
2650 | { "DAC2 L Mux", "IF2 DAC 2", "IF2 DAC2" }, | ||
2651 | { "DAC2 L Mux", "IF3 DAC L", "IF3 DAC L" }, | ||
2652 | { "DAC2 L Mux", "IF4 DAC L", "IF4 DAC L" }, | ||
2653 | { "DAC2 L Mux", "SLB DAC 2", "SLB DAC2" }, | ||
2654 | { "DAC2 L Mux", "OB 2", "OutBound2" }, | ||
2655 | |||
2656 | { "DAC2 R Mux", "IF1 DAC 3", "IF1 DAC3" }, | ||
2657 | { "DAC2 R Mux", "IF2 DAC 3", "IF2 DAC3" }, | ||
2658 | { "DAC2 R Mux", "IF3 DAC R", "IF3 DAC R" }, | ||
2659 | { "DAC2 R Mux", "IF4 DAC R", "IF4 DAC R" }, | ||
2660 | { "DAC2 R Mux", "SLB DAC 3", "SLB DAC3" }, | ||
2661 | { "DAC2 R Mux", "OB 3", "OutBound3" }, | ||
2662 | { "DAC2 R Mux", "Haptic Generator", "Haptic Generator" }, | ||
2663 | { "DAC2 R Mux", "VAD ADC", "VAD ADC Mux" }, | ||
2664 | |||
2665 | { "DAC3 L Mux", "IF1 DAC 4", "IF1 DAC4" }, | ||
2666 | { "DAC3 L Mux", "IF2 DAC 4", "IF2 DAC4" }, | ||
2667 | { "DAC3 L Mux", "IF3 DAC L", "IF3 DAC L" }, | ||
2668 | { "DAC3 L Mux", "IF4 DAC L", "IF4 DAC L" }, | ||
2669 | { "DAC3 L Mux", "SLB DAC 4", "SLB DAC4" }, | ||
2670 | { "DAC3 L Mux", "OB 4", "OutBound4" }, | ||
2671 | |||
2672 | { "DAC3 R Mux", "IF1 DAC 5", "IF1 DAC4" }, | ||
2673 | { "DAC3 R Mux", "IF2 DAC 5", "IF2 DAC4" }, | ||
2674 | { "DAC3 R Mux", "IF3 DAC R", "IF3 DAC R" }, | ||
2675 | { "DAC3 R Mux", "IF4 DAC R", "IF4 DAC R" }, | ||
2676 | { "DAC3 R Mux", "SLB DAC 5", "SLB DAC5" }, | ||
2677 | { "DAC3 R Mux", "OB 5", "OutBound5" }, | ||
2678 | |||
2679 | { "DAC4 L Mux", "IF1 DAC 6", "IF1 DAC6" }, | ||
2680 | { "DAC4 L Mux", "IF2 DAC 6", "IF2 DAC6" }, | ||
2681 | { "DAC4 L Mux", "IF3 DAC L", "IF3 DAC L" }, | ||
2682 | { "DAC4 L Mux", "IF4 DAC L", "IF4 DAC L" }, | ||
2683 | { "DAC4 L Mux", "SLB DAC 6", "SLB DAC6" }, | ||
2684 | { "DAC4 L Mux", "OB 6", "OutBound6" }, | ||
2685 | |||
2686 | { "DAC4 R Mux", "IF1 DAC 7", "IF1 DAC7" }, | ||
2687 | { "DAC4 R Mux", "IF2 DAC 7", "IF2 DAC7" }, | ||
2688 | { "DAC4 R Mux", "IF3 DAC R", "IF3 DAC R" }, | ||
2689 | { "DAC4 R Mux", "IF4 DAC R", "IF4 DAC R" }, | ||
2690 | { "DAC4 R Mux", "SLB DAC 7", "SLB DAC7" }, | ||
2691 | { "DAC4 R Mux", "OB 7", "OutBound7" }, | ||
2692 | |||
2693 | { "Sidetone Mux", "DMIC1 L", "DMIC L1" }, | ||
2694 | { "Sidetone Mux", "DMIC2 L", "DMIC L2" }, | ||
2695 | { "Sidetone Mux", "DMIC3 L", "DMIC L3" }, | ||
2696 | { "Sidetone Mux", "DMIC4 L", "DMIC L4" }, | ||
2697 | { "Sidetone Mux", "ADC1", "ADC 1" }, | ||
2698 | { "Sidetone Mux", "ADC2", "ADC 2" }, | ||
2699 | |||
2700 | { "Stereo DAC MIXL", "ST L Switch", "Sidetone Mux" }, | ||
2701 | { "Stereo DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" }, | ||
2702 | { "Stereo DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" }, | ||
2703 | { "Stereo DAC MIXL", "DAC1 R Switch", "DAC1 MIXR" }, | ||
2704 | { "Stereo DAC MIXL", NULL, "dac stereo1 filter" }, | ||
2705 | { "Stereo DAC MIXR", "ST R Switch", "Sidetone Mux" }, | ||
2706 | { "Stereo DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" }, | ||
2707 | { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, | ||
2708 | { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" }, | ||
2709 | { "Stereo DAC MIXR", NULL, "dac stereo1 filter" }, | ||
2710 | |||
2711 | { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" }, | ||
2712 | { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" }, | ||
2713 | { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" }, | ||
2714 | { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" }, | ||
2715 | { "Mono DAC MIXL", NULL, "dac mono left filter" }, | ||
2716 | { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" }, | ||
2717 | { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" }, | ||
2718 | { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, | ||
2719 | { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" }, | ||
2720 | { "Mono DAC MIXR", NULL, "dac mono right filter" }, | ||
2721 | |||
2722 | { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, | ||
2723 | { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, | ||
2724 | { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" }, | ||
2725 | { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" }, | ||
2726 | { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, | ||
2727 | { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, | ||
2728 | { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" }, | ||
2729 | { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" }, | ||
2730 | |||
2731 | { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, | ||
2732 | { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, | ||
2733 | { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" }, | ||
2734 | { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" }, | ||
2735 | { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, | ||
2736 | { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, | ||
2737 | { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" }, | ||
2738 | { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" }, | ||
2739 | |||
2740 | { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" }, | ||
2741 | { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" }, | ||
2742 | { "Mono DAC MIX", NULL, "Mono DAC MIXL" }, | ||
2743 | { "Mono DAC MIX", NULL, "Mono DAC MIXR" }, | ||
2744 | { "DD1 MIX", NULL, "DD1 MIXL" }, | ||
2745 | { "DD1 MIX", NULL, "DD1 MIXR" }, | ||
2746 | { "DD2 MIX", NULL, "DD2 MIXL" }, | ||
2747 | { "DD2 MIX", NULL, "DD2 MIXR" }, | ||
2748 | |||
2749 | { "DAC12 SRC Mux", "STO1 DAC MIX", "Stereo DAC MIX" }, | ||
2750 | { "DAC12 SRC Mux", "MONO DAC MIX", "Mono DAC MIX" }, | ||
2751 | { "DAC12 SRC Mux", "DD MIX1", "DD1 MIX" }, | ||
2752 | { "DAC12 SRC Mux", "DD MIX2", "DD2 MIX" }, | ||
2753 | |||
2754 | { "DAC3 SRC Mux", "MONO DAC MIXL", "Mono DAC MIXL" }, | ||
2755 | { "DAC3 SRC Mux", "MONO DAC MIXR", "Mono DAC MIXR" }, | ||
2756 | { "DAC3 SRC Mux", "DD MIX1L", "DD1 MIXL" }, | ||
2757 | { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" }, | ||
2758 | |||
2759 | { "DAC 1", NULL, "DAC12 SRC Mux" }, | ||
2760 | { "DAC 1", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2761 | { "DAC 2", NULL, "DAC12 SRC Mux" }, | ||
2762 | { "DAC 2", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2763 | { "DAC 3", NULL, "DAC3 SRC Mux" }, | ||
2764 | { "DAC 3", NULL, "PLL1", is_sys_clk_from_pll }, | ||
2765 | |||
2766 | { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" }, | ||
2767 | { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" }, | ||
2768 | { "PDM1 L Mux", "DD MIX1", "DD1 MIXL" }, | ||
2769 | { "PDM1 L Mux", "DD MIX2", "DD2 MIXL" }, | ||
2770 | { "PDM1 L Mux", NULL, "PDM1 Power" }, | ||
2771 | { "PDM1 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" }, | ||
2772 | { "PDM1 R Mux", "MONO DAC MIX", "Mono DAC MIXR" }, | ||
2773 | { "PDM1 R Mux", "DD MIX1", "DD1 MIXR" }, | ||
2774 | { "PDM1 R Mux", "DD MIX2", "DD2 MIXR" }, | ||
2775 | { "PDM1 R Mux", NULL, "PDM1 Power" }, | ||
2776 | { "PDM2 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" }, | ||
2777 | { "PDM2 L Mux", "MONO DAC MIX", "Mono DAC MIXL" }, | ||
2778 | { "PDM2 L Mux", "DD MIX1", "DD1 MIXL" }, | ||
2779 | { "PDM2 L Mux", "DD MIX2", "DD2 MIXL" }, | ||
2780 | { "PDM2 L Mux", NULL, "PDM2 Power" }, | ||
2781 | { "PDM2 R Mux", "STO1 DAC MIX", "Stereo DAC MIXR" }, | ||
2782 | { "PDM2 R Mux", "MONO DAC MIX", "Mono DAC MIXR" }, | ||
2783 | { "PDM2 R Mux", "DD MIX1", "DD1 MIXR" }, | ||
2784 | { "PDM2 R Mux", "DD MIX1", "DD2 MIXR" }, | ||
2785 | { "PDM2 R Mux", NULL, "PDM2 Power" }, | ||
2786 | |||
2787 | { "LOUT1 amp", NULL, "DAC 1" }, | ||
2788 | { "LOUT2 amp", NULL, "DAC 2" }, | ||
2789 | { "LOUT3 amp", NULL, "DAC 3" }, | ||
2790 | |||
2791 | { "LOUT1", NULL, "LOUT1 amp" }, | ||
2792 | { "LOUT2", NULL, "LOUT2 amp" }, | ||
2793 | { "LOUT3", NULL, "LOUT3 amp" }, | ||
2794 | |||
2795 | { "PDM1L", NULL, "PDM1 L Mux" }, | ||
2796 | { "PDM1R", NULL, "PDM1 R Mux" }, | ||
2797 | { "PDM2L", NULL, "PDM2 L Mux" }, | ||
2798 | { "PDM2R", NULL, "PDM2 R Mux" }, | ||
2799 | }; | ||
2800 | |||
2801 | static int get_clk_info(int sclk, int rate) | ||
2802 | { | ||
2803 | int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16}; | ||
2804 | |||
2805 | if (sclk <= 0 || rate <= 0) | ||
2806 | return -EINVAL; | ||
2807 | |||
2808 | rate = rate << 8; | ||
2809 | for (i = 0; i < ARRAY_SIZE(pd); i++) | ||
2810 | if (sclk == rate * pd[i]) | ||
2811 | return i; | ||
2812 | |||
2813 | return -EINVAL; | ||
2814 | } | ||
2815 | |||
2816 | static int rt5677_hw_params(struct snd_pcm_substream *substream, | ||
2817 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | ||
2818 | { | ||
2819 | struct snd_soc_codec *codec = dai->codec; | ||
2820 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
2821 | unsigned int val_len = 0, val_clk, mask_clk; | ||
2822 | int pre_div, bclk_ms, frame_size; | ||
2823 | |||
2824 | rt5677->lrck[dai->id] = params_rate(params); | ||
2825 | pre_div = get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]); | ||
2826 | if (pre_div < 0) { | ||
2827 | dev_err(codec->dev, "Unsupported clock setting\n"); | ||
2828 | return -EINVAL; | ||
2829 | } | ||
2830 | frame_size = snd_soc_params_to_frame_size(params); | ||
2831 | if (frame_size < 0) { | ||
2832 | dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); | ||
2833 | return -EINVAL; | ||
2834 | } | ||
2835 | bclk_ms = frame_size > 32; | ||
2836 | rt5677->bclk[dai->id] = rt5677->lrck[dai->id] * (32 << bclk_ms); | ||
2837 | |||
2838 | dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", | ||
2839 | rt5677->bclk[dai->id], rt5677->lrck[dai->id]); | ||
2840 | dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", | ||
2841 | bclk_ms, pre_div, dai->id); | ||
2842 | |||
2843 | switch (params_width(params)) { | ||
2844 | case 16: | ||
2845 | break; | ||
2846 | case 20: | ||
2847 | val_len |= RT5677_I2S_DL_20; | ||
2848 | break; | ||
2849 | case 24: | ||
2850 | val_len |= RT5677_I2S_DL_24; | ||
2851 | break; | ||
2852 | case 8: | ||
2853 | val_len |= RT5677_I2S_DL_8; | ||
2854 | break; | ||
2855 | default: | ||
2856 | return -EINVAL; | ||
2857 | } | ||
2858 | |||
2859 | switch (dai->id) { | ||
2860 | case RT5677_AIF1: | ||
2861 | mask_clk = RT5677_I2S_PD1_MASK; | ||
2862 | val_clk = pre_div << RT5677_I2S_PD1_SFT; | ||
2863 | regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP, | ||
2864 | RT5677_I2S_DL_MASK, val_len); | ||
2865 | regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, | ||
2866 | mask_clk, val_clk); | ||
2867 | break; | ||
2868 | case RT5677_AIF2: | ||
2869 | mask_clk = RT5677_I2S_PD2_MASK; | ||
2870 | val_clk = pre_div << RT5677_I2S_PD2_SFT; | ||
2871 | regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP, | ||
2872 | RT5677_I2S_DL_MASK, val_len); | ||
2873 | regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, | ||
2874 | mask_clk, val_clk); | ||
2875 | break; | ||
2876 | case RT5677_AIF3: | ||
2877 | mask_clk = RT5677_I2S_BCLK_MS3_MASK | RT5677_I2S_PD3_MASK; | ||
2878 | val_clk = bclk_ms << RT5677_I2S_BCLK_MS3_SFT | | ||
2879 | pre_div << RT5677_I2S_PD3_SFT; | ||
2880 | regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP, | ||
2881 | RT5677_I2S_DL_MASK, val_len); | ||
2882 | regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, | ||
2883 | mask_clk, val_clk); | ||
2884 | break; | ||
2885 | case RT5677_AIF4: | ||
2886 | mask_clk = RT5677_I2S_BCLK_MS4_MASK | RT5677_I2S_PD4_MASK; | ||
2887 | val_clk = bclk_ms << RT5677_I2S_BCLK_MS4_SFT | | ||
2888 | pre_div << RT5677_I2S_PD4_SFT; | ||
2889 | regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP, | ||
2890 | RT5677_I2S_DL_MASK, val_len); | ||
2891 | regmap_update_bits(rt5677->regmap, RT5677_CLK_TREE_CTRL1, | ||
2892 | mask_clk, val_clk); | ||
2893 | break; | ||
2894 | default: | ||
2895 | break; | ||
2896 | } | ||
2897 | |||
2898 | return 0; | ||
2899 | } | ||
2900 | |||
2901 | static int rt5677_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) | ||
2902 | { | ||
2903 | struct snd_soc_codec *codec = dai->codec; | ||
2904 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
2905 | unsigned int reg_val = 0; | ||
2906 | |||
2907 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
2908 | case SND_SOC_DAIFMT_CBM_CFM: | ||
2909 | rt5677->master[dai->id] = 1; | ||
2910 | break; | ||
2911 | case SND_SOC_DAIFMT_CBS_CFS: | ||
2912 | reg_val |= RT5677_I2S_MS_S; | ||
2913 | rt5677->master[dai->id] = 0; | ||
2914 | break; | ||
2915 | default: | ||
2916 | return -EINVAL; | ||
2917 | } | ||
2918 | |||
2919 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
2920 | case SND_SOC_DAIFMT_NB_NF: | ||
2921 | break; | ||
2922 | case SND_SOC_DAIFMT_IB_NF: | ||
2923 | reg_val |= RT5677_I2S_BP_INV; | ||
2924 | break; | ||
2925 | default: | ||
2926 | return -EINVAL; | ||
2927 | } | ||
2928 | |||
2929 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
2930 | case SND_SOC_DAIFMT_I2S: | ||
2931 | break; | ||
2932 | case SND_SOC_DAIFMT_LEFT_J: | ||
2933 | reg_val |= RT5677_I2S_DF_LEFT; | ||
2934 | break; | ||
2935 | case SND_SOC_DAIFMT_DSP_A: | ||
2936 | reg_val |= RT5677_I2S_DF_PCM_A; | ||
2937 | break; | ||
2938 | case SND_SOC_DAIFMT_DSP_B: | ||
2939 | reg_val |= RT5677_I2S_DF_PCM_B; | ||
2940 | break; | ||
2941 | default: | ||
2942 | return -EINVAL; | ||
2943 | } | ||
2944 | |||
2945 | switch (dai->id) { | ||
2946 | case RT5677_AIF1: | ||
2947 | regmap_update_bits(rt5677->regmap, RT5677_I2S1_SDP, | ||
2948 | RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK | | ||
2949 | RT5677_I2S_DF_MASK, reg_val); | ||
2950 | break; | ||
2951 | case RT5677_AIF2: | ||
2952 | regmap_update_bits(rt5677->regmap, RT5677_I2S2_SDP, | ||
2953 | RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK | | ||
2954 | RT5677_I2S_DF_MASK, reg_val); | ||
2955 | break; | ||
2956 | case RT5677_AIF3: | ||
2957 | regmap_update_bits(rt5677->regmap, RT5677_I2S3_SDP, | ||
2958 | RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK | | ||
2959 | RT5677_I2S_DF_MASK, reg_val); | ||
2960 | break; | ||
2961 | case RT5677_AIF4: | ||
2962 | regmap_update_bits(rt5677->regmap, RT5677_I2S4_SDP, | ||
2963 | RT5677_I2S_MS_MASK | RT5677_I2S_BP_MASK | | ||
2964 | RT5677_I2S_DF_MASK, reg_val); | ||
2965 | break; | ||
2966 | default: | ||
2967 | break; | ||
2968 | } | ||
2969 | |||
2970 | |||
2971 | return 0; | ||
2972 | } | ||
2973 | |||
2974 | static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai, | ||
2975 | int clk_id, unsigned int freq, int dir) | ||
2976 | { | ||
2977 | struct snd_soc_codec *codec = dai->codec; | ||
2978 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
2979 | unsigned int reg_val = 0; | ||
2980 | |||
2981 | if (freq == rt5677->sysclk && clk_id == rt5677->sysclk_src) | ||
2982 | return 0; | ||
2983 | |||
2984 | switch (clk_id) { | ||
2985 | case RT5677_SCLK_S_MCLK: | ||
2986 | reg_val |= RT5677_SCLK_SRC_MCLK; | ||
2987 | break; | ||
2988 | case RT5677_SCLK_S_PLL1: | ||
2989 | reg_val |= RT5677_SCLK_SRC_PLL1; | ||
2990 | break; | ||
2991 | case RT5677_SCLK_S_RCCLK: | ||
2992 | reg_val |= RT5677_SCLK_SRC_RCCLK; | ||
2993 | break; | ||
2994 | default: | ||
2995 | dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); | ||
2996 | return -EINVAL; | ||
2997 | } | ||
2998 | regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, | ||
2999 | RT5677_SCLK_SRC_MASK, reg_val); | ||
3000 | rt5677->sysclk = freq; | ||
3001 | rt5677->sysclk_src = clk_id; | ||
3002 | |||
3003 | dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); | ||
3004 | |||
3005 | return 0; | ||
3006 | } | ||
3007 | |||
3008 | /** | ||
3009 | * rt5677_pll_calc - Calcualte PLL M/N/K code. | ||
3010 | * @freq_in: external clock provided to codec. | ||
3011 | * @freq_out: target clock which codec works on. | ||
3012 | * @pll_code: Pointer to structure with M, N, K, bypass K and bypass M flag. | ||
3013 | * | ||
3014 | * Calcualte M/N/K code and bypass K/M flag to configure PLL for codec. | ||
3015 | * | ||
3016 | * Returns 0 for success or negative error code. | ||
3017 | */ | ||
3018 | static int rt5677_pll_calc(const unsigned int freq_in, | ||
3019 | const unsigned int freq_out, struct rt5677_pll_code *pll_code) | ||
3020 | { | ||
3021 | int max_n = RT5677_PLL_N_MAX, max_m = RT5677_PLL_M_MAX; | ||
3022 | int k, red, n_t, pll_out, in_t; | ||
3023 | int n = 0, m = 0, m_t = 0; | ||
3024 | int out_t, red_t = abs(freq_out - freq_in); | ||
3025 | bool m_bp = false, k_bp = false; | ||
3026 | |||
3027 | if (RT5677_PLL_INP_MAX < freq_in || RT5677_PLL_INP_MIN > freq_in) | ||
3028 | return -EINVAL; | ||
3029 | |||
3030 | k = 100000000 / freq_out - 2; | ||
3031 | if (k > RT5677_PLL_K_MAX) | ||
3032 | k = RT5677_PLL_K_MAX; | ||
3033 | for (n_t = 0; n_t <= max_n; n_t++) { | ||
3034 | in_t = freq_in / (k + 2); | ||
3035 | pll_out = freq_out / (n_t + 2); | ||
3036 | if (in_t < 0) | ||
3037 | continue; | ||
3038 | if (in_t == pll_out) { | ||
3039 | m_bp = true; | ||
3040 | n = n_t; | ||
3041 | goto code_find; | ||
3042 | } | ||
3043 | red = abs(in_t - pll_out); | ||
3044 | if (red < red_t) { | ||
3045 | m_bp = true; | ||
3046 | n = n_t; | ||
3047 | m = m_t; | ||
3048 | if (red == 0) | ||
3049 | goto code_find; | ||
3050 | red_t = red; | ||
3051 | } | ||
3052 | for (m_t = 0; m_t <= max_m; m_t++) { | ||
3053 | out_t = in_t / (m_t + 2); | ||
3054 | red = abs(out_t - pll_out); | ||
3055 | if (red < red_t) { | ||
3056 | m_bp = false; | ||
3057 | n = n_t; | ||
3058 | m = m_t; | ||
3059 | if (red == 0) | ||
3060 | goto code_find; | ||
3061 | red_t = red; | ||
3062 | } | ||
3063 | } | ||
3064 | } | ||
3065 | pr_debug("Only get approximation about PLL\n"); | ||
3066 | |||
3067 | code_find: | ||
3068 | |||
3069 | pll_code->m_bp = m_bp; | ||
3070 | pll_code->k_bp = k_bp; | ||
3071 | pll_code->m_code = m; | ||
3072 | pll_code->n_code = n; | ||
3073 | pll_code->k_code = k; | ||
3074 | return 0; | ||
3075 | } | ||
3076 | |||
3077 | static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | ||
3078 | unsigned int freq_in, unsigned int freq_out) | ||
3079 | { | ||
3080 | struct snd_soc_codec *codec = dai->codec; | ||
3081 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
3082 | struct rt5677_pll_code pll_code; | ||
3083 | int ret; | ||
3084 | |||
3085 | if (source == rt5677->pll_src && freq_in == rt5677->pll_in && | ||
3086 | freq_out == rt5677->pll_out) | ||
3087 | return 0; | ||
3088 | |||
3089 | if (!freq_in || !freq_out) { | ||
3090 | dev_dbg(codec->dev, "PLL disabled\n"); | ||
3091 | |||
3092 | rt5677->pll_in = 0; | ||
3093 | rt5677->pll_out = 0; | ||
3094 | regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, | ||
3095 | RT5677_SCLK_SRC_MASK, RT5677_SCLK_SRC_MCLK); | ||
3096 | return 0; | ||
3097 | } | ||
3098 | |||
3099 | switch (source) { | ||
3100 | case RT5677_PLL1_S_MCLK: | ||
3101 | regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, | ||
3102 | RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_MCLK); | ||
3103 | break; | ||
3104 | case RT5677_PLL1_S_BCLK1: | ||
3105 | case RT5677_PLL1_S_BCLK2: | ||
3106 | case RT5677_PLL1_S_BCLK3: | ||
3107 | case RT5677_PLL1_S_BCLK4: | ||
3108 | switch (dai->id) { | ||
3109 | case RT5677_AIF1: | ||
3110 | regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, | ||
3111 | RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK1); | ||
3112 | break; | ||
3113 | case RT5677_AIF2: | ||
3114 | regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, | ||
3115 | RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK2); | ||
3116 | break; | ||
3117 | case RT5677_AIF3: | ||
3118 | regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, | ||
3119 | RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK3); | ||
3120 | break; | ||
3121 | case RT5677_AIF4: | ||
3122 | regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, | ||
3123 | RT5677_PLL1_SRC_MASK, RT5677_PLL1_SRC_BCLK4); | ||
3124 | break; | ||
3125 | default: | ||
3126 | break; | ||
3127 | } | ||
3128 | break; | ||
3129 | default: | ||
3130 | dev_err(codec->dev, "Unknown PLL source %d\n", source); | ||
3131 | return -EINVAL; | ||
3132 | } | ||
3133 | |||
3134 | ret = rt5677_pll_calc(freq_in, freq_out, &pll_code); | ||
3135 | if (ret < 0) { | ||
3136 | dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); | ||
3137 | return ret; | ||
3138 | } | ||
3139 | |||
3140 | dev_dbg(codec->dev, "m_bypass=%d k_bypass=%d m=%d n=%d k=%d\n", | ||
3141 | pll_code.m_bp, pll_code.k_bp, | ||
3142 | (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, | ||
3143 | (pll_code.k_bp ? 0 : pll_code.k_code)); | ||
3144 | |||
3145 | regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1, | ||
3146 | pll_code.n_code << RT5677_PLL_N_SFT | | ||
3147 | pll_code.k_bp << RT5677_PLL_K_BP_SFT | | ||
3148 | (pll_code.k_bp ? 0 : pll_code.k_code)); | ||
3149 | regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2, | ||
3150 | (pll_code.m_bp ? 0 : pll_code.m_code) << RT5677_PLL_M_SFT | | ||
3151 | pll_code.m_bp << RT5677_PLL_M_BP_SFT); | ||
3152 | |||
3153 | rt5677->pll_in = freq_in; | ||
3154 | rt5677->pll_out = freq_out; | ||
3155 | rt5677->pll_src = source; | ||
3156 | |||
3157 | return 0; | ||
3158 | } | ||
3159 | |||
3160 | static int rt5677_set_bias_level(struct snd_soc_codec *codec, | ||
3161 | enum snd_soc_bias_level level) | ||
3162 | { | ||
3163 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
3164 | |||
3165 | switch (level) { | ||
3166 | case SND_SOC_BIAS_ON: | ||
3167 | break; | ||
3168 | |||
3169 | case SND_SOC_BIAS_PREPARE: | ||
3170 | if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) { | ||
3171 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, | ||
3172 | RT5677_LDO1_SEL_MASK | RT5677_LDO2_SEL_MASK, | ||
3173 | 0x0055); | ||
3174 | regmap_update_bits(rt5677->regmap, | ||
3175 | RT5677_PR_BASE + RT5677_BIAS_CUR4, | ||
3176 | 0x0f00, 0x0f00); | ||
3177 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, | ||
3178 | RT5677_PWR_VREF1 | RT5677_PWR_MB | | ||
3179 | RT5677_PWR_BG | RT5677_PWR_VREF2, | ||
3180 | RT5677_PWR_VREF1 | RT5677_PWR_MB | | ||
3181 | RT5677_PWR_BG | RT5677_PWR_VREF2); | ||
3182 | mdelay(20); | ||
3183 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, | ||
3184 | RT5677_PWR_FV1 | RT5677_PWR_FV2, | ||
3185 | RT5677_PWR_FV1 | RT5677_PWR_FV2); | ||
3186 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, | ||
3187 | RT5677_PWR_CORE, RT5677_PWR_CORE); | ||
3188 | regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, | ||
3189 | 0x1, 0x1); | ||
3190 | } | ||
3191 | break; | ||
3192 | |||
3193 | case SND_SOC_BIAS_STANDBY: | ||
3194 | break; | ||
3195 | |||
3196 | case SND_SOC_BIAS_OFF: | ||
3197 | regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0); | ||
3198 | regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000); | ||
3199 | regmap_write(rt5677->regmap, RT5677_PWR_DIG2, 0x0000); | ||
3200 | regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, 0x0000); | ||
3201 | regmap_write(rt5677->regmap, RT5677_PWR_ANLG2, 0x0000); | ||
3202 | regmap_update_bits(rt5677->regmap, | ||
3203 | RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000); | ||
3204 | break; | ||
3205 | |||
3206 | default: | ||
3207 | break; | ||
3208 | } | ||
3209 | codec->dapm.bias_level = level; | ||
3210 | |||
3211 | return 0; | ||
3212 | } | ||
3213 | |||
3214 | static int rt5677_probe(struct snd_soc_codec *codec) | ||
3215 | { | ||
3216 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
3217 | |||
3218 | rt5677->codec = codec; | ||
3219 | |||
3220 | rt5677_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
3221 | |||
3222 | regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020); | ||
3223 | regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00); | ||
3224 | |||
3225 | return 0; | ||
3226 | } | ||
3227 | |||
3228 | static int rt5677_remove(struct snd_soc_codec *codec) | ||
3229 | { | ||
3230 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
3231 | |||
3232 | regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); | ||
3233 | |||
3234 | return 0; | ||
3235 | } | ||
3236 | |||
3237 | #ifdef CONFIG_PM | ||
3238 | static int rt5677_suspend(struct snd_soc_codec *codec) | ||
3239 | { | ||
3240 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
3241 | |||
3242 | regcache_cache_only(rt5677->regmap, true); | ||
3243 | regcache_mark_dirty(rt5677->regmap); | ||
3244 | |||
3245 | return 0; | ||
3246 | } | ||
3247 | |||
3248 | static int rt5677_resume(struct snd_soc_codec *codec) | ||
3249 | { | ||
3250 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | ||
3251 | |||
3252 | regcache_cache_only(rt5677->regmap, false); | ||
3253 | regcache_sync(rt5677->regmap); | ||
3254 | |||
3255 | return 0; | ||
3256 | } | ||
3257 | #else | ||
3258 | #define rt5677_suspend NULL | ||
3259 | #define rt5677_resume NULL | ||
3260 | #endif | ||
3261 | |||
3262 | #define RT5677_STEREO_RATES SNDRV_PCM_RATE_8000_96000 | ||
3263 | #define RT5677_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ | ||
3264 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) | ||
3265 | |||
3266 | static struct snd_soc_dai_ops rt5677_aif_dai_ops = { | ||
3267 | .hw_params = rt5677_hw_params, | ||
3268 | .set_fmt = rt5677_set_dai_fmt, | ||
3269 | .set_sysclk = rt5677_set_dai_sysclk, | ||
3270 | .set_pll = rt5677_set_dai_pll, | ||
3271 | }; | ||
3272 | |||
3273 | static struct snd_soc_dai_driver rt5677_dai[] = { | ||
3274 | { | ||
3275 | .name = "rt5677-aif1", | ||
3276 | .id = RT5677_AIF1, | ||
3277 | .playback = { | ||
3278 | .stream_name = "AIF1 Playback", | ||
3279 | .channels_min = 1, | ||
3280 | .channels_max = 2, | ||
3281 | .rates = RT5677_STEREO_RATES, | ||
3282 | .formats = RT5677_FORMATS, | ||
3283 | }, | ||
3284 | .capture = { | ||
3285 | .stream_name = "AIF1 Capture", | ||
3286 | .channels_min = 1, | ||
3287 | .channels_max = 2, | ||
3288 | .rates = RT5677_STEREO_RATES, | ||
3289 | .formats = RT5677_FORMATS, | ||
3290 | }, | ||
3291 | .ops = &rt5677_aif_dai_ops, | ||
3292 | }, | ||
3293 | { | ||
3294 | .name = "rt5677-aif2", | ||
3295 | .id = RT5677_AIF2, | ||
3296 | .playback = { | ||
3297 | .stream_name = "AIF2 Playback", | ||
3298 | .channels_min = 1, | ||
3299 | .channels_max = 2, | ||
3300 | .rates = RT5677_STEREO_RATES, | ||
3301 | .formats = RT5677_FORMATS, | ||
3302 | }, | ||
3303 | .capture = { | ||
3304 | .stream_name = "AIF2 Capture", | ||
3305 | .channels_min = 1, | ||
3306 | .channels_max = 2, | ||
3307 | .rates = RT5677_STEREO_RATES, | ||
3308 | .formats = RT5677_FORMATS, | ||
3309 | }, | ||
3310 | .ops = &rt5677_aif_dai_ops, | ||
3311 | }, | ||
3312 | { | ||
3313 | .name = "rt5677-aif3", | ||
3314 | .id = RT5677_AIF3, | ||
3315 | .playback = { | ||
3316 | .stream_name = "AIF3 Playback", | ||
3317 | .channels_min = 1, | ||
3318 | .channels_max = 2, | ||
3319 | .rates = RT5677_STEREO_RATES, | ||
3320 | .formats = RT5677_FORMATS, | ||
3321 | }, | ||
3322 | .capture = { | ||
3323 | .stream_name = "AIF3 Capture", | ||
3324 | .channels_min = 1, | ||
3325 | .channels_max = 2, | ||
3326 | .rates = RT5677_STEREO_RATES, | ||
3327 | .formats = RT5677_FORMATS, | ||
3328 | }, | ||
3329 | .ops = &rt5677_aif_dai_ops, | ||
3330 | }, | ||
3331 | { | ||
3332 | .name = "rt5677-aif4", | ||
3333 | .id = RT5677_AIF4, | ||
3334 | .playback = { | ||
3335 | .stream_name = "AIF4 Playback", | ||
3336 | .channels_min = 1, | ||
3337 | .channels_max = 2, | ||
3338 | .rates = RT5677_STEREO_RATES, | ||
3339 | .formats = RT5677_FORMATS, | ||
3340 | }, | ||
3341 | .capture = { | ||
3342 | .stream_name = "AIF4 Capture", | ||
3343 | .channels_min = 1, | ||
3344 | .channels_max = 2, | ||
3345 | .rates = RT5677_STEREO_RATES, | ||
3346 | .formats = RT5677_FORMATS, | ||
3347 | }, | ||
3348 | .ops = &rt5677_aif_dai_ops, | ||
3349 | }, | ||
3350 | { | ||
3351 | .name = "rt5677-slimbus", | ||
3352 | .id = RT5677_AIF5, | ||
3353 | .playback = { | ||
3354 | .stream_name = "SLIMBus Playback", | ||
3355 | .channels_min = 1, | ||
3356 | .channels_max = 2, | ||
3357 | .rates = RT5677_STEREO_RATES, | ||
3358 | .formats = RT5677_FORMATS, | ||
3359 | }, | ||
3360 | .capture = { | ||
3361 | .stream_name = "SLIMBus Capture", | ||
3362 | .channels_min = 1, | ||
3363 | .channels_max = 2, | ||
3364 | .rates = RT5677_STEREO_RATES, | ||
3365 | .formats = RT5677_FORMATS, | ||
3366 | }, | ||
3367 | .ops = &rt5677_aif_dai_ops, | ||
3368 | }, | ||
3369 | }; | ||
3370 | |||
3371 | static struct snd_soc_codec_driver soc_codec_dev_rt5677 = { | ||
3372 | .probe = rt5677_probe, | ||
3373 | .remove = rt5677_remove, | ||
3374 | .suspend = rt5677_suspend, | ||
3375 | .resume = rt5677_resume, | ||
3376 | .set_bias_level = rt5677_set_bias_level, | ||
3377 | .idle_bias_off = true, | ||
3378 | .controls = rt5677_snd_controls, | ||
3379 | .num_controls = ARRAY_SIZE(rt5677_snd_controls), | ||
3380 | .dapm_widgets = rt5677_dapm_widgets, | ||
3381 | .num_dapm_widgets = ARRAY_SIZE(rt5677_dapm_widgets), | ||
3382 | .dapm_routes = rt5677_dapm_routes, | ||
3383 | .num_dapm_routes = ARRAY_SIZE(rt5677_dapm_routes), | ||
3384 | }; | ||
3385 | |||
3386 | static const struct regmap_config rt5677_regmap = { | ||
3387 | .reg_bits = 8, | ||
3388 | .val_bits = 16, | ||
3389 | |||
3390 | .max_register = RT5677_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5677_ranges) * | ||
3391 | RT5677_PR_SPACING), | ||
3392 | |||
3393 | .volatile_reg = rt5677_volatile_register, | ||
3394 | .readable_reg = rt5677_readable_register, | ||
3395 | |||
3396 | .cache_type = REGCACHE_RBTREE, | ||
3397 | .reg_defaults = rt5677_reg, | ||
3398 | .num_reg_defaults = ARRAY_SIZE(rt5677_reg), | ||
3399 | .ranges = rt5677_ranges, | ||
3400 | .num_ranges = ARRAY_SIZE(rt5677_ranges), | ||
3401 | }; | ||
3402 | |||
3403 | static const struct i2c_device_id rt5677_i2c_id[] = { | ||
3404 | { "rt5677", 0 }, | ||
3405 | { } | ||
3406 | }; | ||
3407 | MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); | ||
3408 | |||
3409 | static int rt5677_i2c_probe(struct i2c_client *i2c, | ||
3410 | const struct i2c_device_id *id) | ||
3411 | { | ||
3412 | struct rt5677_platform_data *pdata = dev_get_platdata(&i2c->dev); | ||
3413 | struct rt5677_priv *rt5677; | ||
3414 | int ret; | ||
3415 | unsigned int val; | ||
3416 | |||
3417 | rt5677 = devm_kzalloc(&i2c->dev, sizeof(struct rt5677_priv), | ||
3418 | GFP_KERNEL); | ||
3419 | if (rt5677 == NULL) | ||
3420 | return -ENOMEM; | ||
3421 | |||
3422 | i2c_set_clientdata(i2c, rt5677); | ||
3423 | |||
3424 | if (pdata) | ||
3425 | rt5677->pdata = *pdata; | ||
3426 | |||
3427 | rt5677->regmap = devm_regmap_init_i2c(i2c, &rt5677_regmap); | ||
3428 | if (IS_ERR(rt5677->regmap)) { | ||
3429 | ret = PTR_ERR(rt5677->regmap); | ||
3430 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", | ||
3431 | ret); | ||
3432 | return ret; | ||
3433 | } | ||
3434 | |||
3435 | regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val); | ||
3436 | if (val != RT5677_DEVICE_ID) { | ||
3437 | dev_err(&i2c->dev, | ||
3438 | "Device with ID register %x is not rt5677\n", val); | ||
3439 | return -ENODEV; | ||
3440 | } | ||
3441 | |||
3442 | regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); | ||
3443 | |||
3444 | ret = regmap_register_patch(rt5677->regmap, init_list, | ||
3445 | ARRAY_SIZE(init_list)); | ||
3446 | if (ret != 0) | ||
3447 | dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); | ||
3448 | |||
3449 | if (rt5677->pdata.in1_diff) | ||
3450 | regmap_update_bits(rt5677->regmap, RT5677_IN1, | ||
3451 | RT5677_IN_DF1, RT5677_IN_DF1); | ||
3452 | |||
3453 | if (rt5677->pdata.in2_diff) | ||
3454 | regmap_update_bits(rt5677->regmap, RT5677_IN1, | ||
3455 | RT5677_IN_DF2, RT5677_IN_DF2); | ||
3456 | |||
3457 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677, | ||
3458 | rt5677_dai, ARRAY_SIZE(rt5677_dai)); | ||
3459 | if (ret < 0) | ||
3460 | goto err; | ||
3461 | |||
3462 | return 0; | ||
3463 | err: | ||
3464 | return ret; | ||
3465 | } | ||
3466 | |||
3467 | static int rt5677_i2c_remove(struct i2c_client *i2c) | ||
3468 | { | ||
3469 | snd_soc_unregister_codec(&i2c->dev); | ||
3470 | |||
3471 | return 0; | ||
3472 | } | ||
3473 | |||
3474 | static struct i2c_driver rt5677_i2c_driver = { | ||
3475 | .driver = { | ||
3476 | .name = "rt5677", | ||
3477 | .owner = THIS_MODULE, | ||
3478 | }, | ||
3479 | .probe = rt5677_i2c_probe, | ||
3480 | .remove = rt5677_i2c_remove, | ||
3481 | .id_table = rt5677_i2c_id, | ||
3482 | }; | ||
3483 | |||
3484 | static int __init rt5677_modinit(void) | ||
3485 | { | ||
3486 | return i2c_add_driver(&rt5677_i2c_driver); | ||
3487 | } | ||
3488 | module_init(rt5677_modinit); | ||
3489 | |||
3490 | static void __exit rt5677_modexit(void) | ||
3491 | { | ||
3492 | i2c_del_driver(&rt5677_i2c_driver); | ||
3493 | } | ||
3494 | module_exit(rt5677_modexit); | ||
3495 | |||
3496 | MODULE_DESCRIPTION("ASoC RT5677 driver"); | ||
3497 | MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>"); | ||
3498 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h new file mode 100644 index 000000000000..af4e9c797408 --- /dev/null +++ b/sound/soc/codecs/rt5677.h | |||
@@ -0,0 +1,1451 @@ | |||
1 | /* | ||
2 | * rt5677.h -- RT5677 ALSA SoC audio driver | ||
3 | * | ||
4 | * Copyright 2013 Realtek Semiconductor Corp. | ||
5 | * Author: Oder Chiou <oder_chiou@realtek.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef __RT5677_H__ | ||
13 | #define __RT5677_H__ | ||
14 | |||
15 | #include <sound/rt5677.h> | ||
16 | |||
17 | /* Info */ | ||
18 | #define RT5677_RESET 0x00 | ||
19 | #define RT5677_VENDOR_ID 0xfd | ||
20 | #define RT5677_VENDOR_ID1 0xfe | ||
21 | #define RT5677_VENDOR_ID2 0xff | ||
22 | /* I/O - Output */ | ||
23 | #define RT5677_LOUT1 0x01 | ||
24 | /* I/O - Input */ | ||
25 | #define RT5677_IN1 0x03 | ||
26 | #define RT5677_MICBIAS 0x04 | ||
27 | /* I/O - SLIMBus */ | ||
28 | #define RT5677_SLIMBUS_PARAM 0x07 | ||
29 | #define RT5677_SLIMBUS_RX 0x08 | ||
30 | #define RT5677_SLIMBUS_CTRL 0x09 | ||
31 | /* I/O */ | ||
32 | #define RT5677_SIDETONE_CTRL 0x13 | ||
33 | /* I/O - ADC/DAC */ | ||
34 | #define RT5677_ANA_DAC1_2_3_SRC 0x15 | ||
35 | #define RT5677_IF_DSP_DAC3_4_MIXER 0x16 | ||
36 | #define RT5677_DAC4_DIG_VOL 0x17 | ||
37 | #define RT5677_DAC3_DIG_VOL 0x18 | ||
38 | #define RT5677_DAC1_DIG_VOL 0x19 | ||
39 | #define RT5677_DAC2_DIG_VOL 0x1a | ||
40 | #define RT5677_IF_DSP_DAC2_MIXER 0x1b | ||
41 | #define RT5677_STO1_ADC_DIG_VOL 0x1c | ||
42 | #define RT5677_MONO_ADC_DIG_VOL 0x1d | ||
43 | #define RT5677_STO1_2_ADC_BST 0x1e | ||
44 | #define RT5677_STO2_ADC_DIG_VOL 0x1f | ||
45 | /* Mixer - D-D */ | ||
46 | #define RT5677_ADC_BST_CTRL2 0x20 | ||
47 | #define RT5677_STO3_4_ADC_BST 0x21 | ||
48 | #define RT5677_STO3_ADC_DIG_VOL 0x22 | ||
49 | #define RT5677_STO4_ADC_DIG_VOL 0x23 | ||
50 | #define RT5677_STO4_ADC_MIXER 0x24 | ||
51 | #define RT5677_STO3_ADC_MIXER 0x25 | ||
52 | #define RT5677_STO2_ADC_MIXER 0x26 | ||
53 | #define RT5677_STO1_ADC_MIXER 0x27 | ||
54 | #define RT5677_MONO_ADC_MIXER 0x28 | ||
55 | #define RT5677_ADC_IF_DSP_DAC1_MIXER 0x29 | ||
56 | #define RT5677_STO1_DAC_MIXER 0x2a | ||
57 | #define RT5677_MONO_DAC_MIXER 0x2b | ||
58 | #define RT5677_DD1_MIXER 0x2c | ||
59 | #define RT5677_DD2_MIXER 0x2d | ||
60 | #define RT5677_IF3_DATA 0x2f | ||
61 | #define RT5677_IF4_DATA 0x30 | ||
62 | /* Mixer - PDM */ | ||
63 | #define RT5677_PDM_OUT_CTRL 0x31 | ||
64 | #define RT5677_PDM_DATA_CTRL1 0x32 | ||
65 | #define RT5677_PDM_DATA_CTRL2 0x33 | ||
66 | #define RT5677_PDM1_DATA_CTRL2 0x34 | ||
67 | #define RT5677_PDM1_DATA_CTRL3 0x35 | ||
68 | #define RT5677_PDM1_DATA_CTRL4 0x36 | ||
69 | #define RT5677_PDM2_DATA_CTRL2 0x37 | ||
70 | #define RT5677_PDM2_DATA_CTRL3 0x38 | ||
71 | #define RT5677_PDM2_DATA_CTRL4 0x39 | ||
72 | /* TDM */ | ||
73 | #define RT5677_TDM1_CTRL1 0x3b | ||
74 | #define RT5677_TDM1_CTRL2 0x3c | ||
75 | #define RT5677_TDM1_CTRL3 0x3d | ||
76 | #define RT5677_TDM1_CTRL4 0x3e | ||
77 | #define RT5677_TDM1_CTRL5 0x3f | ||
78 | #define RT5677_TDM2_CTRL1 0x40 | ||
79 | #define RT5677_TDM2_CTRL2 0x41 | ||
80 | #define RT5677_TDM2_CTRL3 0x42 | ||
81 | #define RT5677_TDM2_CTRL4 0x43 | ||
82 | #define RT5677_TDM2_CTRL5 0x44 | ||
83 | /* I2C_MASTER_CTRL */ | ||
84 | #define RT5677_I2C_MASTER_CTRL1 0x47 | ||
85 | #define RT5677_I2C_MASTER_CTRL2 0x48 | ||
86 | #define RT5677_I2C_MASTER_CTRL3 0x49 | ||
87 | #define RT5677_I2C_MASTER_CTRL4 0x4a | ||
88 | #define RT5677_I2C_MASTER_CTRL5 0x4b | ||
89 | #define RT5677_I2C_MASTER_CTRL6 0x4c | ||
90 | #define RT5677_I2C_MASTER_CTRL7 0x4d | ||
91 | #define RT5677_I2C_MASTER_CTRL8 0x4e | ||
92 | /* DMIC */ | ||
93 | #define RT5677_DMIC_CTRL1 0x50 | ||
94 | #define RT5677_DMIC_CTRL2 0x51 | ||
95 | /* Haptic Generator */ | ||
96 | #define RT5677_HAP_GENE_CTRL1 0x56 | ||
97 | #define RT5677_HAP_GENE_CTRL2 0x57 | ||
98 | #define RT5677_HAP_GENE_CTRL3 0x58 | ||
99 | #define RT5677_HAP_GENE_CTRL4 0x59 | ||
100 | #define RT5677_HAP_GENE_CTRL5 0x5a | ||
101 | #define RT5677_HAP_GENE_CTRL6 0x5b | ||
102 | #define RT5677_HAP_GENE_CTRL7 0x5c | ||
103 | #define RT5677_HAP_GENE_CTRL8 0x5d | ||
104 | #define RT5677_HAP_GENE_CTRL9 0x5e | ||
105 | #define RT5677_HAP_GENE_CTRL10 0x5f | ||
106 | /* Power */ | ||
107 | #define RT5677_PWR_DIG1 0x61 | ||
108 | #define RT5677_PWR_DIG2 0x62 | ||
109 | #define RT5677_PWR_ANLG1 0x63 | ||
110 | #define RT5677_PWR_ANLG2 0x64 | ||
111 | #define RT5677_PWR_DSP1 0x65 | ||
112 | #define RT5677_PWR_DSP_ST 0x66 | ||
113 | #define RT5677_PWR_DSP2 0x67 | ||
114 | #define RT5677_ADC_DAC_HPF_CTRL1 0x68 | ||
115 | /* Private Register Control */ | ||
116 | #define RT5677_PRIV_INDEX 0x6a | ||
117 | #define RT5677_PRIV_DATA 0x6c | ||
118 | /* Format - ADC/DAC */ | ||
119 | #define RT5677_I2S4_SDP 0x6f | ||
120 | #define RT5677_I2S1_SDP 0x70 | ||
121 | #define RT5677_I2S2_SDP 0x71 | ||
122 | #define RT5677_I2S3_SDP 0x72 | ||
123 | #define RT5677_CLK_TREE_CTRL1 0x73 | ||
124 | #define RT5677_CLK_TREE_CTRL2 0x74 | ||
125 | #define RT5677_CLK_TREE_CTRL3 0x75 | ||
126 | /* Function - Analog */ | ||
127 | #define RT5677_PLL1_CTRL1 0x7a | ||
128 | #define RT5677_PLL1_CTRL2 0x7b | ||
129 | #define RT5677_PLL2_CTRL1 0x7c | ||
130 | #define RT5677_PLL2_CTRL2 0x7d | ||
131 | #define RT5677_GLB_CLK1 0x80 | ||
132 | #define RT5677_GLB_CLK2 0x81 | ||
133 | #define RT5677_ASRC_1 0x83 | ||
134 | #define RT5677_ASRC_2 0x84 | ||
135 | #define RT5677_ASRC_3 0x85 | ||
136 | #define RT5677_ASRC_4 0x86 | ||
137 | #define RT5677_ASRC_5 0x87 | ||
138 | #define RT5677_ASRC_6 0x88 | ||
139 | #define RT5677_ASRC_7 0x89 | ||
140 | #define RT5677_ASRC_8 0x8a | ||
141 | #define RT5677_ASRC_9 0x8b | ||
142 | #define RT5677_ASRC_10 0x8c | ||
143 | #define RT5677_ASRC_11 0x8d | ||
144 | #define RT5677_ASRC_12 0x8e | ||
145 | #define RT5677_ASRC_13 0x8f | ||
146 | #define RT5677_ASRC_14 0x90 | ||
147 | #define RT5677_ASRC_15 0x91 | ||
148 | #define RT5677_ASRC_16 0x92 | ||
149 | #define RT5677_ASRC_17 0x93 | ||
150 | #define RT5677_ASRC_18 0x94 | ||
151 | #define RT5677_ASRC_19 0x95 | ||
152 | #define RT5677_ASRC_20 0x97 | ||
153 | #define RT5677_ASRC_21 0x98 | ||
154 | #define RT5677_ASRC_22 0x99 | ||
155 | #define RT5677_ASRC_23 0x9a | ||
156 | #define RT5677_VAD_CTRL1 0x9c | ||
157 | #define RT5677_VAD_CTRL2 0x9d | ||
158 | #define RT5677_VAD_CTRL3 0x9e | ||
159 | #define RT5677_VAD_CTRL4 0x9f | ||
160 | #define RT5677_VAD_CTRL5 0xa0 | ||
161 | /* Function - Digital */ | ||
162 | #define RT5677_DSP_INB_CTRL1 0xa3 | ||
163 | #define RT5677_DSP_INB_CTRL2 0xa4 | ||
164 | #define RT5677_DSP_IN_OUTB_CTRL 0xa5 | ||
165 | #define RT5677_DSP_OUTB0_1_DIG_VOL 0xa6 | ||
166 | #define RT5677_DSP_OUTB2_3_DIG_VOL 0xa7 | ||
167 | #define RT5677_DSP_OUTB4_5_DIG_VOL 0xa8 | ||
168 | #define RT5677_DSP_OUTB6_7_DIG_VOL 0xa9 | ||
169 | #define RT5677_ADC_EQ_CTRL1 0xae | ||
170 | #define RT5677_ADC_EQ_CTRL2 0xaf | ||
171 | #define RT5677_EQ_CTRL1 0xb0 | ||
172 | #define RT5677_EQ_CTRL2 0xb1 | ||
173 | #define RT5677_EQ_CTRL3 0xb2 | ||
174 | #define RT5677_SOFT_VOL_ZERO_CROSS1 0xb3 | ||
175 | #define RT5677_JD_CTRL1 0xb5 | ||
176 | #define RT5677_JD_CTRL2 0xb6 | ||
177 | #define RT5677_JD_CTRL3 0xb8 | ||
178 | #define RT5677_IRQ_CTRL1 0xbd | ||
179 | #define RT5677_IRQ_CTRL2 0xbe | ||
180 | #define RT5677_GPIO_ST 0xbf | ||
181 | #define RT5677_GPIO_CTRL1 0xc0 | ||
182 | #define RT5677_GPIO_CTRL2 0xc1 | ||
183 | #define RT5677_GPIO_CTRL3 0xc2 | ||
184 | #define RT5677_STO1_ADC_HI_FILTER1 0xc5 | ||
185 | #define RT5677_STO1_ADC_HI_FILTER2 0xc6 | ||
186 | #define RT5677_MONO_ADC_HI_FILTER1 0xc7 | ||
187 | #define RT5677_MONO_ADC_HI_FILTER2 0xc8 | ||
188 | #define RT5677_STO2_ADC_HI_FILTER1 0xc9 | ||
189 | #define RT5677_STO2_ADC_HI_FILTER2 0xca | ||
190 | #define RT5677_STO3_ADC_HI_FILTER1 0xcb | ||
191 | #define RT5677_STO3_ADC_HI_FILTER2 0xcc | ||
192 | #define RT5677_STO4_ADC_HI_FILTER1 0xcd | ||
193 | #define RT5677_STO4_ADC_HI_FILTER2 0xce | ||
194 | #define RT5677_MB_DRC_CTRL1 0xd0 | ||
195 | #define RT5677_DRC1_CTRL1 0xd2 | ||
196 | #define RT5677_DRC1_CTRL2 0xd3 | ||
197 | #define RT5677_DRC1_CTRL3 0xd4 | ||
198 | #define RT5677_DRC1_CTRL4 0xd5 | ||
199 | #define RT5677_DRC1_CTRL5 0xd6 | ||
200 | #define RT5677_DRC1_CTRL6 0xd7 | ||
201 | #define RT5677_DRC2_CTRL1 0xd8 | ||
202 | #define RT5677_DRC2_CTRL2 0xd9 | ||
203 | #define RT5677_DRC2_CTRL3 0xda | ||
204 | #define RT5677_DRC2_CTRL4 0xdb | ||
205 | #define RT5677_DRC2_CTRL5 0xdc | ||
206 | #define RT5677_DRC2_CTRL6 0xdd | ||
207 | #define RT5677_DRC1_HL_CTRL1 0xde | ||
208 | #define RT5677_DRC1_HL_CTRL2 0xdf | ||
209 | #define RT5677_DRC2_HL_CTRL1 0xe0 | ||
210 | #define RT5677_DRC2_HL_CTRL2 0xe1 | ||
211 | #define RT5677_DSP_INB1_SRC_CTRL1 0xe3 | ||
212 | #define RT5677_DSP_INB1_SRC_CTRL2 0xe4 | ||
213 | #define RT5677_DSP_INB1_SRC_CTRL3 0xe5 | ||
214 | #define RT5677_DSP_INB1_SRC_CTRL4 0xe6 | ||
215 | #define RT5677_DSP_INB2_SRC_CTRL1 0xe7 | ||
216 | #define RT5677_DSP_INB2_SRC_CTRL2 0xe8 | ||
217 | #define RT5677_DSP_INB2_SRC_CTRL3 0xe9 | ||
218 | #define RT5677_DSP_INB2_SRC_CTRL4 0xea | ||
219 | #define RT5677_DSP_INB3_SRC_CTRL1 0xeb | ||
220 | #define RT5677_DSP_INB3_SRC_CTRL2 0xec | ||
221 | #define RT5677_DSP_INB3_SRC_CTRL3 0xed | ||
222 | #define RT5677_DSP_INB3_SRC_CTRL4 0xee | ||
223 | #define RT5677_DSP_OUTB1_SRC_CTRL1 0xef | ||
224 | #define RT5677_DSP_OUTB1_SRC_CTRL2 0xf0 | ||
225 | #define RT5677_DSP_OUTB1_SRC_CTRL3 0xf1 | ||
226 | #define RT5677_DSP_OUTB1_SRC_CTRL4 0xf2 | ||
227 | #define RT5677_DSP_OUTB2_SRC_CTRL1 0xf3 | ||
228 | #define RT5677_DSP_OUTB2_SRC_CTRL2 0xf4 | ||
229 | #define RT5677_DSP_OUTB2_SRC_CTRL3 0xf5 | ||
230 | #define RT5677_DSP_OUTB2_SRC_CTRL4 0xf6 | ||
231 | |||
232 | /* Virtual DSP Mixer Control */ | ||
233 | #define RT5677_DSP_OUTB_0123_MIXER_CTRL 0xf7 | ||
234 | #define RT5677_DSP_OUTB_45_MIXER_CTRL 0xf8 | ||
235 | #define RT5677_DSP_OUTB_67_MIXER_CTRL 0xf9 | ||
236 | |||
237 | /* General Control */ | ||
238 | #define RT5677_DIG_MISC 0xfa | ||
239 | #define RT5677_GEN_CTRL1 0xfb | ||
240 | #define RT5677_GEN_CTRL2 0xfc | ||
241 | |||
242 | /* DSP Mode I2C Control*/ | ||
243 | #define RT5677_DSP_I2C_OP_CODE 0x00 | ||
244 | #define RT5677_DSP_I2C_ADDR_LSB 0x01 | ||
245 | #define RT5677_DSP_I2C_ADDR_MSB 0x02 | ||
246 | #define RT5677_DSP_I2C_DATA_LSB 0x03 | ||
247 | #define RT5677_DSP_I2C_DATA_MSB 0x04 | ||
248 | |||
249 | /* Index of Codec Private Register definition */ | ||
250 | #define RT5677_PR_DRC1_CTRL_1 0x01 | ||
251 | #define RT5677_PR_DRC1_CTRL_2 0x02 | ||
252 | #define RT5677_PR_DRC1_CTRL_3 0x03 | ||
253 | #define RT5677_PR_DRC1_CTRL_4 0x04 | ||
254 | #define RT5677_PR_DRC1_CTRL_5 0x05 | ||
255 | #define RT5677_PR_DRC1_CTRL_6 0x06 | ||
256 | #define RT5677_PR_DRC1_CTRL_7 0x07 | ||
257 | #define RT5677_PR_DRC2_CTRL_1 0x08 | ||
258 | #define RT5677_PR_DRC2_CTRL_2 0x09 | ||
259 | #define RT5677_PR_DRC2_CTRL_3 0x0a | ||
260 | #define RT5677_PR_DRC2_CTRL_4 0x0b | ||
261 | #define RT5677_PR_DRC2_CTRL_5 0x0c | ||
262 | #define RT5677_PR_DRC2_CTRL_6 0x0d | ||
263 | #define RT5677_PR_DRC2_CTRL_7 0x0e | ||
264 | #define RT5677_BIAS_CUR1 0x10 | ||
265 | #define RT5677_BIAS_CUR2 0x12 | ||
266 | #define RT5677_BIAS_CUR3 0x13 | ||
267 | #define RT5677_BIAS_CUR4 0x14 | ||
268 | #define RT5677_BIAS_CUR5 0x15 | ||
269 | #define RT5677_VREF_LOUT_CTRL 0x17 | ||
270 | #define RT5677_DIG_VOL_CTRL1 0x1a | ||
271 | #define RT5677_DIG_VOL_CTRL2 0x1b | ||
272 | #define RT5677_ANA_ADC_GAIN_CTRL 0x1e | ||
273 | #define RT5677_VAD_SRAM_TEST1 0x20 | ||
274 | #define RT5677_VAD_SRAM_TEST2 0x21 | ||
275 | #define RT5677_VAD_SRAM_TEST3 0x22 | ||
276 | #define RT5677_VAD_SRAM_TEST4 0x23 | ||
277 | #define RT5677_PAD_DRV_CTRL 0x26 | ||
278 | #define RT5677_DIG_IN_PIN_ST_CTRL1 0x29 | ||
279 | #define RT5677_DIG_IN_PIN_ST_CTRL2 0x2a | ||
280 | #define RT5677_DIG_IN_PIN_ST_CTRL3 0x2b | ||
281 | #define RT5677_PLL1_INT 0x38 | ||
282 | #define RT5677_PLL2_INT 0x39 | ||
283 | #define RT5677_TEST_CTRL1 0x3a | ||
284 | #define RT5677_TEST_CTRL2 0x3b | ||
285 | #define RT5677_TEST_CTRL3 0x3c | ||
286 | #define RT5677_CHOP_DAC_ADC 0x3d | ||
287 | #define RT5677_SOFT_DEPOP_DAC_CLK_CTRL 0x3e | ||
288 | #define RT5677_CROSS_OVER_FILTER1 0x90 | ||
289 | #define RT5677_CROSS_OVER_FILTER2 0x91 | ||
290 | #define RT5677_CROSS_OVER_FILTER3 0x92 | ||
291 | #define RT5677_CROSS_OVER_FILTER4 0x93 | ||
292 | #define RT5677_CROSS_OVER_FILTER5 0x94 | ||
293 | #define RT5677_CROSS_OVER_FILTER6 0x95 | ||
294 | #define RT5677_CROSS_OVER_FILTER7 0x96 | ||
295 | #define RT5677_CROSS_OVER_FILTER8 0x97 | ||
296 | #define RT5677_CROSS_OVER_FILTER9 0x98 | ||
297 | #define RT5677_CROSS_OVER_FILTER10 0x99 | ||
298 | |||
299 | /* global definition */ | ||
300 | #define RT5677_L_MUTE (0x1 << 15) | ||
301 | #define RT5677_L_MUTE_SFT 15 | ||
302 | #define RT5677_VOL_L_MUTE (0x1 << 14) | ||
303 | #define RT5677_VOL_L_SFT 14 | ||
304 | #define RT5677_R_MUTE (0x1 << 7) | ||
305 | #define RT5677_R_MUTE_SFT 7 | ||
306 | #define RT5677_VOL_R_MUTE (0x1 << 6) | ||
307 | #define RT5677_VOL_R_SFT 6 | ||
308 | #define RT5677_L_VOL_MASK (0x3f << 8) | ||
309 | #define RT5677_L_VOL_SFT 8 | ||
310 | #define RT5677_R_VOL_MASK (0x3f) | ||
311 | #define RT5677_R_VOL_SFT 0 | ||
312 | |||
313 | /* LOUT1 Control (0x01) */ | ||
314 | #define RT5677_LOUT1_L_MUTE (0x1 << 15) | ||
315 | #define RT5677_LOUT1_L_MUTE_SFT (15) | ||
316 | #define RT5677_LOUT1_L_DF (0x1 << 14) | ||
317 | #define RT5677_LOUT1_L_DF_SFT (14) | ||
318 | #define RT5677_LOUT2_L_MUTE (0x1 << 13) | ||
319 | #define RT5677_LOUT2_L_MUTE_SFT (13) | ||
320 | #define RT5677_LOUT2_L_DF (0x1 << 12) | ||
321 | #define RT5677_LOUT2_L_DF_SFT (12) | ||
322 | #define RT5677_LOUT3_L_MUTE (0x1 << 11) | ||
323 | #define RT5677_LOUT3_L_MUTE_SFT (11) | ||
324 | #define RT5677_LOUT3_L_DF (0x1 << 10) | ||
325 | #define RT5677_LOUT3_L_DF_SFT (10) | ||
326 | #define RT5677_LOUT1_ENH_DRV (0x1 << 9) | ||
327 | #define RT5677_LOUT1_ENH_DRV_SFT (9) | ||
328 | #define RT5677_LOUT2_ENH_DRV (0x1 << 8) | ||
329 | #define RT5677_LOUT2_ENH_DRV_SFT (8) | ||
330 | #define RT5677_LOUT3_ENH_DRV (0x1 << 7) | ||
331 | #define RT5677_LOUT3_ENH_DRV_SFT (7) | ||
332 | |||
333 | /* IN1 Control (0x03) */ | ||
334 | #define RT5677_BST_MASK1 (0xf << 12) | ||
335 | #define RT5677_BST_SFT1 12 | ||
336 | #define RT5677_BST_MASK2 (0xf << 8) | ||
337 | #define RT5677_BST_SFT2 8 | ||
338 | #define RT5677_IN_DF1 (0x1 << 7) | ||
339 | #define RT5677_IN_DF1_SFT 7 | ||
340 | #define RT5677_IN_DF2 (0x1 << 6) | ||
341 | #define RT5677_IN_DF2_SFT 6 | ||
342 | |||
343 | /* Micbias Control (0x04) */ | ||
344 | #define RT5677_MICBIAS1_OUTVOLT_MASK (0x1 << 15) | ||
345 | #define RT5677_MICBIAS1_OUTVOLT_SFT (15) | ||
346 | #define RT5677_MICBIAS1_OUTVOLT_2_7V (0x0 << 15) | ||
347 | #define RT5677_MICBIAS1_OUTVOLT_2_25V (0x1 << 15) | ||
348 | #define RT5677_MICBIAS1_CTRL_VDD_MASK (0x1 << 14) | ||
349 | #define RT5677_MICBIAS1_CTRL_VDD_SFT (14) | ||
350 | #define RT5677_MICBIAS1_CTRL_VDD_1_8V (0x0 << 14) | ||
351 | #define RT5677_MICBIAS1_CTRL_VDD_3_3V (0x1 << 14) | ||
352 | #define RT5677_MICBIAS1_OVCD_MASK (0x1 << 11) | ||
353 | #define RT5677_MICBIAS1_OVCD_SHIFT (11) | ||
354 | #define RT5677_MICBIAS1_OVCD_DIS (0x0 << 11) | ||
355 | #define RT5677_MICBIAS1_OVCD_EN (0x1 << 11) | ||
356 | #define RT5677_MICBIAS1_OVTH_MASK (0x3 << 9) | ||
357 | #define RT5677_MICBIAS1_OVTH_SFT 9 | ||
358 | #define RT5677_MICBIAS1_OVTH_640UA (0x0 << 9) | ||
359 | #define RT5677_MICBIAS1_OVTH_1280UA (0x1 << 9) | ||
360 | #define RT5677_MICBIAS1_OVTH_1920UA (0x2 << 9) | ||
361 | |||
362 | /* SLIMbus Parameter (0x07) */ | ||
363 | |||
364 | /* SLIMbus Rx (0x08) */ | ||
365 | #define RT5677_SLB_ADC4_MASK (0x3 << 6) | ||
366 | #define RT5677_SLB_ADC4_SFT 6 | ||
367 | #define RT5677_SLB_ADC3_MASK (0x3 << 4) | ||
368 | #define RT5677_SLB_ADC3_SFT 4 | ||
369 | #define RT5677_SLB_ADC2_MASK (0x3 << 2) | ||
370 | #define RT5677_SLB_ADC2_SFT 2 | ||
371 | #define RT5677_SLB_ADC1_MASK (0x3 << 0) | ||
372 | #define RT5677_SLB_ADC1_SFT 0 | ||
373 | |||
374 | /* SLIMBus control (0x09) */ | ||
375 | |||
376 | /* Sidetone Control (0x13) */ | ||
377 | #define RT5677_ST_HPF_SEL_MASK (0x7 << 13) | ||
378 | #define RT5677_ST_HPF_SEL_SFT 13 | ||
379 | #define RT5677_ST_HPF_PATH (0x1 << 12) | ||
380 | #define RT5677_ST_HPF_PATH_SFT 12 | ||
381 | #define RT5677_ST_SEL_MASK (0x7 << 9) | ||
382 | #define RT5677_ST_SEL_SFT 9 | ||
383 | #define RT5677_ST_EN (0x1 << 6) | ||
384 | #define RT5677_ST_EN_SFT 6 | ||
385 | |||
386 | /* Analog DAC1/2/3 Source Control (0x15) */ | ||
387 | #define RT5677_ANA_DAC3_SRC_SEL_MASK (0x3 << 4) | ||
388 | #define RT5677_ANA_DAC3_SRC_SEL_SFT 4 | ||
389 | #define RT5677_ANA_DAC1_2_SRC_SEL_MASK (0x3 << 0) | ||
390 | #define RT5677_ANA_DAC1_2_SRC_SEL_SFT 0 | ||
391 | |||
392 | /* IF/DSP to DAC3/4 Mixer Control (0x16) */ | ||
393 | #define RT5677_M_DAC4_L_VOL (0x1 << 15) | ||
394 | #define RT5677_M_DAC4_L_VOL_SFT 15 | ||
395 | #define RT5677_SEL_DAC4_L_SRC_MASK (0x7 << 12) | ||
396 | #define RT5677_SEL_DAC4_L_SRC_SFT 12 | ||
397 | #define RT5677_M_DAC4_R_VOL (0x1 << 11) | ||
398 | #define RT5677_M_DAC4_R_VOL_SFT 11 | ||
399 | #define RT5677_SEL_DAC4_R_SRC_MASK (0x7 << 8) | ||
400 | #define RT5677_SEL_DAC4_R_SRC_SFT 8 | ||
401 | #define RT5677_M_DAC3_L_VOL (0x1 << 7) | ||
402 | #define RT5677_M_DAC3_L_VOL_SFT 7 | ||
403 | #define RT5677_SEL_DAC3_L_SRC_MASK (0x7 << 4) | ||
404 | #define RT5677_SEL_DAC3_L_SRC_SFT 4 | ||
405 | #define RT5677_M_DAC3_R_VOL (0x1 << 3) | ||
406 | #define RT5677_M_DAC3_R_VOL_SFT 3 | ||
407 | #define RT5677_SEL_DAC3_R_SRC_MASK (0x7 << 0) | ||
408 | #define RT5677_SEL_DAC3_R_SRC_SFT 0 | ||
409 | |||
410 | /* DAC4 Digital Volume (0x17) */ | ||
411 | #define RT5677_DAC4_L_VOL_MASK (0xff << 8) | ||
412 | #define RT5677_DAC4_L_VOL_SFT 8 | ||
413 | #define RT5677_DAC4_R_VOL_MASK (0xff) | ||
414 | #define RT5677_DAC4_R_VOL_SFT 0 | ||
415 | |||
416 | /* DAC3 Digital Volume (0x18) */ | ||
417 | #define RT5677_DAC3_L_VOL_MASK (0xff << 8) | ||
418 | #define RT5677_DAC3_L_VOL_SFT 8 | ||
419 | #define RT5677_DAC3_R_VOL_MASK (0xff) | ||
420 | #define RT5677_DAC3_R_VOL_SFT 0 | ||
421 | |||
422 | /* DAC3 Digital Volume (0x19) */ | ||
423 | #define RT5677_DAC1_L_VOL_MASK (0xff << 8) | ||
424 | #define RT5677_DAC1_L_VOL_SFT 8 | ||
425 | #define RT5677_DAC1_R_VOL_MASK (0xff) | ||
426 | #define RT5677_DAC1_R_VOL_SFT 0 | ||
427 | |||
428 | /* DAC2 Digital Volume (0x1a) */ | ||
429 | #define RT5677_DAC2_L_VOL_MASK (0xff << 8) | ||
430 | #define RT5677_DAC2_L_VOL_SFT 8 | ||
431 | #define RT5677_DAC2_R_VOL_MASK (0xff) | ||
432 | #define RT5677_DAC2_R_VOL_SFT 0 | ||
433 | |||
434 | /* IF/DSP to DAC2 Mixer Control (0x1b) */ | ||
435 | #define RT5677_M_DAC2_L_VOL (0x1 << 7) | ||
436 | #define RT5677_M_DAC2_L_VOL_SFT 7 | ||
437 | #define RT5677_SEL_DAC2_L_SRC_MASK (0x7 << 4) | ||
438 | #define RT5677_SEL_DAC2_L_SRC_SFT 4 | ||
439 | #define RT5677_M_DAC2_R_VOL (0x1 << 3) | ||
440 | #define RT5677_M_DAC2_R_VOL_SFT 3 | ||
441 | #define RT5677_SEL_DAC2_R_SRC_MASK (0x7 << 0) | ||
442 | #define RT5677_SEL_DAC2_R_SRC_SFT 0 | ||
443 | |||
444 | /* Stereo1 ADC Digital Volume Control (0x1c) */ | ||
445 | #define RT5677_STO1_ADC_L_VOL_MASK (0x7f << 8) | ||
446 | #define RT5677_STO1_ADC_L_VOL_SFT 8 | ||
447 | #define RT5677_STO1_ADC_R_VOL_MASK (0x7f) | ||
448 | #define RT5677_STO1_ADC_R_VOL_SFT 0 | ||
449 | |||
450 | /* Mono ADC Digital Volume Control (0x1d) */ | ||
451 | #define RT5677_MONO_ADC_L_VOL_MASK (0x7f << 8) | ||
452 | #define RT5677_MONO_ADC_L_VOL_SFT 8 | ||
453 | #define RT5677_MONO_ADC_R_VOL_MASK (0x7f) | ||
454 | #define RT5677_MONO_ADC_R_VOL_SFT 0 | ||
455 | |||
456 | /* Stereo 1/2 ADC Boost Gain Control (0x1e) */ | ||
457 | #define RT5677_STO1_ADC_L_BST_MASK (0x3 << 14) | ||
458 | #define RT5677_STO1_ADC_L_BST_SFT 14 | ||
459 | #define RT5677_STO1_ADC_R_BST_MASK (0x3 << 12) | ||
460 | #define RT5677_STO1_ADC_R_BST_SFT 12 | ||
461 | #define RT5677_STO1_ADC_COMP_MASK (0x3 << 10) | ||
462 | #define RT5677_STO1_ADC_COMP_SFT 10 | ||
463 | #define RT5677_STO2_ADC_L_BST_MASK (0x3 << 8) | ||
464 | #define RT5677_STO2_ADC_L_BST_SFT 8 | ||
465 | #define RT5677_STO2_ADC_R_BST_MASK (0x3 << 6) | ||
466 | #define RT5677_STO2_ADC_R_BST_SFT 6 | ||
467 | #define RT5677_STO2_ADC_COMP_MASK (0x3 << 4) | ||
468 | #define RT5677_STO2_ADC_COMP_SFT 4 | ||
469 | |||
470 | /* Stereo2 ADC Digital Volume Control (0x1f) */ | ||
471 | #define RT5677_STO2_ADC_L_VOL_MASK (0x7f << 8) | ||
472 | #define RT5677_STO2_ADC_L_VOL_SFT 8 | ||
473 | #define RT5677_STO2_ADC_R_VOL_MASK (0x7f) | ||
474 | #define RT5677_STO2_ADC_R_VOL_SFT 0 | ||
475 | |||
476 | /* ADC Boost Gain Control 2 (0x20) */ | ||
477 | #define RT5677_MONO_ADC_L_BST_MASK (0x3 << 14) | ||
478 | #define RT5677_MONO_ADC_L_BST_SFT 14 | ||
479 | #define RT5677_MONO_ADC_R_BST_MASK (0x3 << 12) | ||
480 | #define RT5677_MONO_ADC_R_BST_SFT 12 | ||
481 | #define RT5677_MONO_ADC_COMP_MASK (0x3 << 10) | ||
482 | #define RT5677_MONO_ADC_COMP_SFT 10 | ||
483 | |||
484 | /* Stereo 3/4 ADC Boost Gain Control (0x21) */ | ||
485 | #define RT5677_STO3_ADC_L_BST_MASK (0x3 << 14) | ||
486 | #define RT5677_STO3_ADC_L_BST_SFT 14 | ||
487 | #define RT5677_STO3_ADC_R_BST_MASK (0x3 << 12) | ||
488 | #define RT5677_STO3_ADC_R_BST_SFT 12 | ||
489 | #define RT5677_STO3_ADC_COMP_MASK (0x3 << 10) | ||
490 | #define RT5677_STO3_ADC_COMP_SFT 10 | ||
491 | #define RT5677_STO4_ADC_L_BST_MASK (0x3 << 8) | ||
492 | #define RT5677_STO4_ADC_L_BST_SFT 8 | ||
493 | #define RT5677_STO4_ADC_R_BST_MASK (0x3 << 6) | ||
494 | #define RT5677_STO4_ADC_R_BST_SFT 6 | ||
495 | #define RT5677_STO4_ADC_COMP_MASK (0x3 << 4) | ||
496 | #define RT5677_STO4_ADC_COMP_SFT 4 | ||
497 | |||
498 | /* Stereo3 ADC Digital Volume Control (0x22) */ | ||
499 | #define RT5677_STO3_ADC_L_VOL_MASK (0x7f << 8) | ||
500 | #define RT5677_STO3_ADC_L_VOL_SFT 8 | ||
501 | #define RT5677_STO3_ADC_R_VOL_MASK (0x7f) | ||
502 | #define RT5677_STO3_ADC_R_VOL_SFT 0 | ||
503 | |||
504 | /* Stereo4 ADC Digital Volume Control (0x23) */ | ||
505 | #define RT5677_STO4_ADC_L_VOL_MASK (0x7f << 8) | ||
506 | #define RT5677_STO4_ADC_L_VOL_SFT 8 | ||
507 | #define RT5677_STO4_ADC_R_VOL_MASK (0x7f) | ||
508 | #define RT5677_STO4_ADC_R_VOL_SFT 0 | ||
509 | |||
510 | /* Stereo4 ADC Mixer control (0x24) */ | ||
511 | #define RT5677_M_STO4_ADC_L2 (0x1 << 15) | ||
512 | #define RT5677_M_STO4_ADC_L2_SFT 15 | ||
513 | #define RT5677_M_STO4_ADC_L1 (0x1 << 14) | ||
514 | #define RT5677_M_STO4_ADC_L1_SFT 14 | ||
515 | #define RT5677_SEL_STO4_ADC1_MASK (0x3 << 12) | ||
516 | #define RT5677_SEL_STO4_ADC1_SFT 12 | ||
517 | #define RT5677_SEL_STO4_ADC2_MASK (0x3 << 10) | ||
518 | #define RT5677_SEL_STO4_ADC2_SFT 10 | ||
519 | #define RT5677_SEL_STO4_DMIC_MASK (0x3 << 8) | ||
520 | #define RT5677_SEL_STO4_DMIC_SFT 8 | ||
521 | #define RT5677_M_STO4_ADC_R1 (0x1 << 7) | ||
522 | #define RT5677_M_STO4_ADC_R1_SFT 7 | ||
523 | #define RT5677_M_STO4_ADC_R2 (0x1 << 6) | ||
524 | #define RT5677_M_STO4_ADC_R2_SFT 6 | ||
525 | |||
526 | /* Stereo3 ADC Mixer control (0x25) */ | ||
527 | #define RT5677_M_STO3_ADC_L2 (0x1 << 15) | ||
528 | #define RT5677_M_STO3_ADC_L2_SFT 15 | ||
529 | #define RT5677_M_STO3_ADC_L1 (0x1 << 14) | ||
530 | #define RT5677_M_STO3_ADC_L1_SFT 14 | ||
531 | #define RT5677_SEL_STO3_ADC1_MASK (0x3 << 12) | ||
532 | #define RT5677_SEL_STO3_ADC1_SFT 12 | ||
533 | #define RT5677_SEL_STO3_ADC2_MASK (0x3 << 10) | ||
534 | #define RT5677_SEL_STO3_ADC2_SFT 10 | ||
535 | #define RT5677_SEL_STO3_DMIC_MASK (0x3 << 8) | ||
536 | #define RT5677_SEL_STO3_DMIC_SFT 8 | ||
537 | #define RT5677_M_STO3_ADC_R1 (0x1 << 7) | ||
538 | #define RT5677_M_STO3_ADC_R1_SFT 7 | ||
539 | #define RT5677_M_STO3_ADC_R2 (0x1 << 6) | ||
540 | #define RT5677_M_STO3_ADC_R2_SFT 6 | ||
541 | |||
542 | /* Stereo2 ADC Mixer Control (0x26) */ | ||
543 | #define RT5677_M_STO2_ADC_L2 (0x1 << 15) | ||
544 | #define RT5677_M_STO2_ADC_L2_SFT 15 | ||
545 | #define RT5677_M_STO2_ADC_L1 (0x1 << 14) | ||
546 | #define RT5677_M_STO2_ADC_L1_SFT 14 | ||
547 | #define RT5677_SEL_STO2_ADC1_MASK (0x3 << 12) | ||
548 | #define RT5677_SEL_STO2_ADC1_SFT 12 | ||
549 | #define RT5677_SEL_STO2_ADC2_MASK (0x3 << 10) | ||
550 | #define RT5677_SEL_STO2_ADC2_SFT 10 | ||
551 | #define RT5677_SEL_STO2_DMIC_MASK (0x3 << 8) | ||
552 | #define RT5677_SEL_STO2_DMIC_SFT 8 | ||
553 | #define RT5677_M_STO2_ADC_R1 (0x1 << 7) | ||
554 | #define RT5677_M_STO2_ADC_R1_SFT 7 | ||
555 | #define RT5677_M_STO2_ADC_R2 (0x1 << 6) | ||
556 | #define RT5677_M_STO2_ADC_R2_SFT 6 | ||
557 | #define RT5677_SEL_STO2_LR_MIX_MASK (0x1 << 0) | ||
558 | #define RT5677_SEL_STO2_LR_MIX_SFT 0 | ||
559 | #define RT5677_SEL_STO2_LR_MIX_L (0x0 << 0) | ||
560 | #define RT5677_SEL_STO2_LR_MIX_LR (0x1 << 0) | ||
561 | |||
562 | /* Stereo1 ADC Mixer control (0x27) */ | ||
563 | #define RT5677_M_STO1_ADC_L2 (0x1 << 15) | ||
564 | #define RT5677_M_STO1_ADC_L2_SFT 15 | ||
565 | #define RT5677_M_STO1_ADC_L1 (0x1 << 14) | ||
566 | #define RT5677_M_STO1_ADC_L1_SFT 14 | ||
567 | #define RT5677_SEL_STO1_ADC1_MASK (0x3 << 12) | ||
568 | #define RT5677_SEL_STO1_ADC1_SFT 12 | ||
569 | #define RT5677_SEL_STO1_ADC2_MASK (0x3 << 10) | ||
570 | #define RT5677_SEL_STO1_ADC2_SFT 10 | ||
571 | #define RT5677_SEL_STO1_DMIC_MASK (0x3 << 8) | ||
572 | #define RT5677_SEL_STO1_DMIC_SFT 8 | ||
573 | #define RT5677_M_STO1_ADC_R1 (0x1 << 7) | ||
574 | #define RT5677_M_STO1_ADC_R1_SFT 7 | ||
575 | #define RT5677_M_STO1_ADC_R2 (0x1 << 6) | ||
576 | #define RT5677_M_STO1_ADC_R2_SFT 6 | ||
577 | |||
578 | /* Mono ADC Mixer control (0x28) */ | ||
579 | #define RT5677_M_MONO_ADC_L2 (0x1 << 15) | ||
580 | #define RT5677_M_MONO_ADC_L2_SFT 15 | ||
581 | #define RT5677_M_MONO_ADC_L1 (0x1 << 14) | ||
582 | #define RT5677_M_MONO_ADC_L1_SFT 14 | ||
583 | #define RT5677_SEL_MONO_ADC_L1_MASK (0x3 << 12) | ||
584 | #define RT5677_SEL_MONO_ADC_L1_SFT 12 | ||
585 | #define RT5677_SEL_MONO_ADC_L2_MASK (0x3 << 10) | ||
586 | #define RT5677_SEL_MONO_ADC_L2_SFT 10 | ||
587 | #define RT5677_SEL_MONO_DMIC_L_MASK (0x3 << 8) | ||
588 | #define RT5677_SEL_MONO_DMIC_L_SFT 8 | ||
589 | #define RT5677_M_MONO_ADC_R1 (0x1 << 7) | ||
590 | #define RT5677_M_MONO_ADC_R1_SFT 7 | ||
591 | #define RT5677_M_MONO_ADC_R2 (0x1 << 6) | ||
592 | #define RT5677_M_MONO_ADC_R2_SFT 6 | ||
593 | #define RT5677_SEL_MONO_ADC_R1_MASK (0x3 << 4) | ||
594 | #define RT5677_SEL_MONO_ADC_R1_SFT 4 | ||
595 | #define RT5677_SEL_MONO_ADC_R2_MASK (0x3 << 2) | ||
596 | #define RT5677_SEL_MONO_ADC_R2_SFT 2 | ||
597 | #define RT5677_SEL_MONO_DMIC_R_MASK (0x3 << 0) | ||
598 | #define RT5677_SEL_MONO_DMIC_R_SFT 0 | ||
599 | |||
600 | /* ADC/IF/DSP to DAC1 Mixer control (0x29) */ | ||
601 | #define RT5677_M_ADDA_MIXER1_L (0x1 << 15) | ||
602 | #define RT5677_M_ADDA_MIXER1_L_SFT 15 | ||
603 | #define RT5677_M_DAC1_L (0x1 << 14) | ||
604 | #define RT5677_M_DAC1_L_SFT 14 | ||
605 | #define RT5677_DAC1_L_SEL_MASK (0x7 << 8) | ||
606 | #define RT5677_DAC1_L_SEL_SFT 8 | ||
607 | #define RT5677_M_ADDA_MIXER1_R (0x1 << 7) | ||
608 | #define RT5677_M_ADDA_MIXER1_R_SFT 7 | ||
609 | #define RT5677_M_DAC1_R (0x1 << 6) | ||
610 | #define RT5677_M_DAC1_R_SFT 6 | ||
611 | #define RT5677_ADDA1_SEL_MASK (0x3 << 0) | ||
612 | #define RT5677_ADDA1_SEL_SFT 0 | ||
613 | |||
614 | /* Stereo1 DAC Mixer L/R Control (0x2a) */ | ||
615 | #define RT5677_M_ST_DAC1_L (0x1 << 15) | ||
616 | #define RT5677_M_ST_DAC1_L_SFT 15 | ||
617 | #define RT5677_M_DAC1_L_STO_L (0x1 << 13) | ||
618 | #define RT5677_M_DAC1_L_STO_L_SFT 13 | ||
619 | #define RT5677_DAC1_L_STO_L_VOL_MASK (0x1 << 12) | ||
620 | #define RT5677_DAC1_L_STO_L_VOL_SFT 12 | ||
621 | #define RT5677_M_DAC2_L_STO_L (0x1 << 11) | ||
622 | #define RT5677_M_DAC2_L_STO_L_SFT 11 | ||
623 | #define RT5677_DAC2_L_STO_L_VOL_MASK (0x1 << 10) | ||
624 | #define RT5677_DAC2_L_STO_L_VOL_SFT 10 | ||
625 | #define RT5677_M_DAC1_R_STO_L (0x1 << 9) | ||
626 | #define RT5677_M_DAC1_R_STO_L_SFT 9 | ||
627 | #define RT5677_DAC1_R_STO_L_VOL_MASK (0x1 << 8) | ||
628 | #define RT5677_DAC1_R_STO_L_VOL_SFT 8 | ||
629 | #define RT5677_M_ST_DAC1_R (0x1 << 7) | ||
630 | #define RT5677_M_ST_DAC1_R_SFT 7 | ||
631 | #define RT5677_M_DAC1_R_STO_R (0x1 << 5) | ||
632 | #define RT5677_M_DAC1_R_STO_R_SFT 5 | ||
633 | #define RT5677_DAC1_R_STO_R_VOL_MASK (0x1 << 4) | ||
634 | #define RT5677_DAC1_R_STO_R_VOL_SFT 4 | ||
635 | #define RT5677_M_DAC2_R_STO_R (0x1 << 3) | ||
636 | #define RT5677_M_DAC2_R_STO_R_SFT 3 | ||
637 | #define RT5677_DAC2_R_STO_R_VOL_MASK (0x1 << 2) | ||
638 | #define RT5677_DAC2_R_STO_R_VOL_SFT 2 | ||
639 | #define RT5677_M_DAC1_L_STO_R (0x1 << 1) | ||
640 | #define RT5677_M_DAC1_L_STO_R_SFT 1 | ||
641 | #define RT5677_DAC1_L_STO_R_VOL_MASK (0x1 << 0) | ||
642 | #define RT5677_DAC1_L_STO_R_VOL_SFT 0 | ||
643 | |||
644 | /* Mono DAC Mixer L/R Control (0x2b) */ | ||
645 | #define RT5677_M_ST_DAC2_L (0x1 << 15) | ||
646 | #define RT5677_M_ST_DAC2_L_SFT 15 | ||
647 | #define RT5677_M_DAC2_L_MONO_L (0x1 << 13) | ||
648 | #define RT5677_M_DAC2_L_MONO_L_SFT 13 | ||
649 | #define RT5677_DAC2_L_MONO_L_VOL_MASK (0x1 << 12) | ||
650 | #define RT5677_DAC2_L_MONO_L_VOL_SFT 12 | ||
651 | #define RT5677_M_DAC2_R_MONO_L (0x1 << 11) | ||
652 | #define RT5677_M_DAC2_R_MONO_L_SFT 11 | ||
653 | #define RT5677_DAC2_R_MONO_L_VOL_MASK (0x1 << 10) | ||
654 | #define RT5677_DAC2_R_MONO_L_VOL_SFT 10 | ||
655 | #define RT5677_M_DAC1_L_MONO_L (0x1 << 9) | ||
656 | #define RT5677_M_DAC1_L_MONO_L_SFT 9 | ||
657 | #define RT5677_DAC1_L_MONO_L_VOL_MASK (0x1 << 8) | ||
658 | #define RT5677_DAC1_L_MONO_L_VOL_SFT 8 | ||
659 | #define RT5677_M_ST_DAC2_R (0x1 << 7) | ||
660 | #define RT5677_M_ST_DAC2_R_SFT 7 | ||
661 | #define RT5677_M_DAC2_R_MONO_R (0x1 << 5) | ||
662 | #define RT5677_M_DAC2_R_MONO_R_SFT 5 | ||
663 | #define RT5677_DAC2_R_MONO_R_VOL_MASK (0x1 << 4) | ||
664 | #define RT5677_DAC2_R_MONO_R_VOL_SFT 4 | ||
665 | #define RT5677_M_DAC1_R_MONO_R (0x1 << 3) | ||
666 | #define RT5677_M_DAC1_R_MONO_R_SFT 3 | ||
667 | #define RT5677_DAC1_R_MONO_R_VOL_MASK (0x1 << 2) | ||
668 | #define RT5677_DAC1_R_MONO_R_VOL_SFT 2 | ||
669 | #define RT5677_M_DAC2_L_MONO_R (0x1 << 1) | ||
670 | #define RT5677_M_DAC2_L_MONO_R_SFT 1 | ||
671 | #define RT5677_DAC2_L_MONO_R_VOL_MASK (0x1 << 0) | ||
672 | #define RT5677_DAC2_L_MONO_R_VOL_SFT 0 | ||
673 | |||
674 | /* DD Mixer 1 Control (0x2c) */ | ||
675 | #define RT5677_M_STO_L_DD1_L (0x1 << 15) | ||
676 | #define RT5677_M_STO_L_DD1_L_SFT 15 | ||
677 | #define RT5677_STO_L_DD1_L_VOL_MASK (0x1 << 14) | ||
678 | #define RT5677_STO_L_DD1_L_VOL_SFT 14 | ||
679 | #define RT5677_M_MONO_L_DD1_L (0x1 << 13) | ||
680 | #define RT5677_M_MONO_L_DD1_L_SFT 13 | ||
681 | #define RT5677_MONO_L_DD1_L_VOL_MASK (0x1 << 12) | ||
682 | #define RT5677_MONO_L_DD1_L_VOL_SFT 12 | ||
683 | #define RT5677_M_DAC3_L_DD1_L (0x1 << 11) | ||
684 | #define RT5677_M_DAC3_L_DD1_L_SFT 11 | ||
685 | #define RT5677_DAC3_L_DD1_L_VOL_MASK (0x1 << 10) | ||
686 | #define RT5677_DAC3_L_DD1_L_VOL_SFT 10 | ||
687 | #define RT5677_M_DAC3_R_DD1_L (0x1 << 9) | ||
688 | #define RT5677_M_DAC3_R_DD1_L_SFT 9 | ||
689 | #define RT5677_DAC3_R_DD1_L_VOL_MASK (0x1 << 8) | ||
690 | #define RT5677_DAC3_R_DD1_L_VOL_SFT 8 | ||
691 | #define RT5677_M_STO_R_DD1_R (0x1 << 7) | ||
692 | #define RT5677_M_STO_R_DD1_R_SFT 7 | ||
693 | #define RT5677_STO_R_DD1_R_VOL_MASK (0x1 << 6) | ||
694 | #define RT5677_STO_R_DD1_R_VOL_SFT 6 | ||
695 | #define RT5677_M_MONO_R_DD1_R (0x1 << 5) | ||
696 | #define RT5677_M_MONO_R_DD1_R_SFT 5 | ||
697 | #define RT5677_MONO_R_DD1_R_VOL_MASK (0x1 << 4) | ||
698 | #define RT5677_MONO_R_DD1_R_VOL_SFT 4 | ||
699 | #define RT5677_M_DAC3_R_DD1_R (0x1 << 3) | ||
700 | #define RT5677_M_DAC3_R_DD1_R_SFT 3 | ||
701 | #define RT5677_DAC3_R_DD1_R_VOL_MASK (0x1 << 2) | ||
702 | #define RT5677_DAC3_R_DD1_R_VOL_SFT 2 | ||
703 | #define RT5677_M_DAC3_L_DD1_R (0x1 << 1) | ||
704 | #define RT5677_M_DAC3_L_DD1_R_SFT 1 | ||
705 | #define RT5677_DAC3_L_DD1_R_VOL_MASK (0x1 << 0) | ||
706 | #define RT5677_DAC3_L_DD1_R_VOL_SFT 0 | ||
707 | |||
708 | /* DD Mixer 2 Control (0x2d) */ | ||
709 | #define RT5677_M_STO_L_DD2_L (0x1 << 15) | ||
710 | #define RT5677_M_STO_L_DD2_L_SFT 15 | ||
711 | #define RT5677_STO_L_DD2_L_VOL_MASK (0x1 << 14) | ||
712 | #define RT5677_STO_L_DD2_L_VOL_SFT 14 | ||
713 | #define RT5677_M_MONO_L_DD2_L (0x1 << 13) | ||
714 | #define RT5677_M_MONO_L_DD2_L_SFT 13 | ||
715 | #define RT5677_MONO_L_DD2_L_VOL_MASK (0x1 << 12) | ||
716 | #define RT5677_MONO_L_DD2_L_VOL_SFT 12 | ||
717 | #define RT5677_M_DAC4_L_DD2_L (0x1 << 11) | ||
718 | #define RT5677_M_DAC4_L_DD2_L_SFT 11 | ||
719 | #define RT5677_DAC4_L_DD2_L_VOL_MASK (0x1 << 10) | ||
720 | #define RT5677_DAC4_L_DD2_L_VOL_SFT 10 | ||
721 | #define RT5677_M_DAC4_R_DD2_L (0x1 << 9) | ||
722 | #define RT5677_M_DAC4_R_DD2_L_SFT 9 | ||
723 | #define RT5677_DAC4_R_DD2_L_VOL_MASK (0x1 << 8) | ||
724 | #define RT5677_DAC4_R_DD2_L_VOL_SFT 8 | ||
725 | #define RT5677_M_STO_R_DD2_R (0x1 << 7) | ||
726 | #define RT5677_M_STO_R_DD2_R_SFT 7 | ||
727 | #define RT5677_STO_R_DD2_R_VOL_MASK (0x1 << 6) | ||
728 | #define RT5677_STO_R_DD2_R_VOL_SFT 6 | ||
729 | #define RT5677_M_MONO_R_DD2_R (0x1 << 5) | ||
730 | #define RT5677_M_MONO_R_DD2_R_SFT 5 | ||
731 | #define RT5677_MONO_R_DD2_R_VOL_MASK (0x1 << 4) | ||
732 | #define RT5677_MONO_R_DD2_R_VOL_SFT 4 | ||
733 | #define RT5677_M_DAC4_R_DD2_R (0x1 << 3) | ||
734 | #define RT5677_M_DAC4_R_DD2_R_SFT 3 | ||
735 | #define RT5677_DAC4_R_DD2_R_VOL_MASK (0x1 << 2) | ||
736 | #define RT5677_DAC4_R_DD2_R_VOL_SFT 2 | ||
737 | #define RT5677_M_DAC4_L_DD2_R (0x1 << 1) | ||
738 | #define RT5677_M_DAC4_L_DD2_R_SFT 1 | ||
739 | #define RT5677_DAC4_L_DD2_R_VOL_MASK (0x1 << 0) | ||
740 | #define RT5677_DAC4_L_DD2_R_VOL_SFT 0 | ||
741 | |||
742 | /* IF3 data control (0x2f) */ | ||
743 | #define RT5677_IF3_DAC_SEL_MASK (0x3 << 6) | ||
744 | #define RT5677_IF3_DAC_SEL_SFT 6 | ||
745 | #define RT5677_IF3_ADC_SEL_MASK (0x3 << 4) | ||
746 | #define RT5677_IF3_ADC_SEL_SFT 4 | ||
747 | #define RT5677_IF3_ADC_IN_MASK (0xf << 0) | ||
748 | #define RT5677_IF3_ADC_IN_SFT 0 | ||
749 | |||
750 | /* IF4 data control (0x30) */ | ||
751 | #define RT5677_IF4_ADC_IN_MASK (0xf << 4) | ||
752 | #define RT5677_IF4_ADC_IN_SFT 4 | ||
753 | #define RT5677_IF4_DAC_SEL_MASK (0x3 << 2) | ||
754 | #define RT5677_IF4_DAC_SEL_SFT 2 | ||
755 | #define RT5677_IF4_ADC_SEL_MASK (0x3 << 0) | ||
756 | #define RT5677_IF4_ADC_SEL_SFT 0 | ||
757 | |||
758 | /* PDM Output Control (0x31) */ | ||
759 | #define RT5677_M_PDM1_L (0x1 << 15) | ||
760 | #define RT5677_M_PDM1_L_SFT 15 | ||
761 | #define RT5677_SEL_PDM1_L_MASK (0x3 << 12) | ||
762 | #define RT5677_SEL_PDM1_L_SFT 12 | ||
763 | #define RT5677_M_PDM1_R (0x1 << 11) | ||
764 | #define RT5677_M_PDM1_R_SFT 11 | ||
765 | #define RT5677_SEL_PDM1_R_MASK (0x3 << 8) | ||
766 | #define RT5677_SEL_PDM1_R_SFT 8 | ||
767 | #define RT5677_M_PDM2_L (0x1 << 7) | ||
768 | #define RT5677_M_PDM2_L_SFT 7 | ||
769 | #define RT5677_SEL_PDM2_L_MASK (0x3 << 4) | ||
770 | #define RT5677_SEL_PDM2_L_SFT 4 | ||
771 | #define RT5677_M_PDM2_R (0x1 << 3) | ||
772 | #define RT5677_M_PDM2_R_SFT 3 | ||
773 | #define RT5677_SEL_PDM2_R_MASK (0x3 << 0) | ||
774 | #define RT5677_SEL_PDM2_R_SFT 0 | ||
775 | |||
776 | /* PDM I2C / Data Control 1 (0x32) */ | ||
777 | #define RT5677_PDM2_PW_DOWN (0x1 << 7) | ||
778 | #define RT5677_PDM1_PW_DOWN (0x1 << 6) | ||
779 | #define RT5677_PDM2_BUSY (0x1 << 5) | ||
780 | #define RT5677_PDM1_BUSY (0x1 << 4) | ||
781 | #define RT5677_PDM_PATTERN (0x1 << 3) | ||
782 | #define RT5677_PDM_GAIN (0x1 << 2) | ||
783 | #define RT5677_PDM_DIV_MASK (0x3 << 0) | ||
784 | |||
785 | /* PDM I2C / Data Control 2 (0x33) */ | ||
786 | #define RT5677_PDM1_I2C_ID (0xf << 12) | ||
787 | #define RT5677_PDM1_EXE (0x1 << 11) | ||
788 | #define RT5677_PDM1_I2C_CMD (0x1 << 10) | ||
789 | #define RT5677_PDM1_I2C_EXE (0x1 << 9) | ||
790 | #define RT5677_PDM1_I2C_BUSY (0x1 << 8) | ||
791 | #define RT5677_PDM2_I2C_ID (0xf << 4) | ||
792 | #define RT5677_PDM2_EXE (0x1 << 3) | ||
793 | #define RT5677_PDM2_I2C_CMD (0x1 << 2) | ||
794 | #define RT5677_PDM2_I2C_EXE (0x1 << 1) | ||
795 | #define RT5677_PDM2_I2C_BUSY (0x1 << 0) | ||
796 | |||
797 | /* MX3C TDM1 control 1 (0x3c) */ | ||
798 | #define RT5677_IF1_ADC4_MASK (0x3 << 10) | ||
799 | #define RT5677_IF1_ADC4_SFT 10 | ||
800 | #define RT5677_IF1_ADC3_MASK (0x3 << 8) | ||
801 | #define RT5677_IF1_ADC3_SFT 8 | ||
802 | #define RT5677_IF1_ADC2_MASK (0x3 << 6) | ||
803 | #define RT5677_IF1_ADC2_SFT 6 | ||
804 | #define RT5677_IF1_ADC1_MASK (0x3 << 4) | ||
805 | #define RT5677_IF1_ADC1_SFT 4 | ||
806 | |||
807 | /* MX41 TDM2 control 1 (0x41) */ | ||
808 | #define RT5677_IF2_ADC4_MASK (0x3 << 10) | ||
809 | #define RT5677_IF2_ADC4_SFT 10 | ||
810 | #define RT5677_IF2_ADC3_MASK (0x3 << 8) | ||
811 | #define RT5677_IF2_ADC3_SFT 8 | ||
812 | #define RT5677_IF2_ADC2_MASK (0x3 << 6) | ||
813 | #define RT5677_IF2_ADC2_SFT 6 | ||
814 | #define RT5677_IF2_ADC1_MASK (0x3 << 4) | ||
815 | #define RT5677_IF2_ADC1_SFT 4 | ||
816 | |||
817 | /* Digital Microphone Control 1 (0x50) */ | ||
818 | #define RT5677_DMIC_1_EN_MASK (0x1 << 15) | ||
819 | #define RT5677_DMIC_1_EN_SFT 15 | ||
820 | #define RT5677_DMIC_1_DIS (0x0 << 15) | ||
821 | #define RT5677_DMIC_1_EN (0x1 << 15) | ||
822 | #define RT5677_DMIC_2_EN_MASK (0x1 << 14) | ||
823 | #define RT5677_DMIC_2_EN_SFT 14 | ||
824 | #define RT5677_DMIC_2_DIS (0x0 << 14) | ||
825 | #define RT5677_DMIC_2_EN (0x1 << 14) | ||
826 | #define RT5677_DMIC_L_STO1_LH_MASK (0x1 << 13) | ||
827 | #define RT5677_DMIC_L_STO1_LH_SFT 13 | ||
828 | #define RT5677_DMIC_L_STO1_LH_FALLING (0x0 << 13) | ||
829 | #define RT5677_DMIC_L_STO1_LH_RISING (0x1 << 13) | ||
830 | #define RT5677_DMIC_R_STO1_LH_MASK (0x1 << 12) | ||
831 | #define RT5677_DMIC_R_STO1_LH_SFT 12 | ||
832 | #define RT5677_DMIC_R_STO1_LH_FALLING (0x0 << 12) | ||
833 | #define RT5677_DMIC_R_STO1_LH_RISING (0x1 << 12) | ||
834 | #define RT5677_DMIC_L_STO3_LH_MASK (0x1 << 11) | ||
835 | #define RT5677_DMIC_L_STO3_LH_SFT 11 | ||
836 | #define RT5677_DMIC_L_STO3_LH_FALLING (0x0 << 11) | ||
837 | #define RT5677_DMIC_L_STO3_LH_RISING (0x1 << 11) | ||
838 | #define RT5677_DMIC_R_STO3_LH_MASK (0x1 << 10) | ||
839 | #define RT5677_DMIC_R_STO3_LH_SFT 10 | ||
840 | #define RT5677_DMIC_R_STO3_LH_FALLING (0x0 << 10) | ||
841 | #define RT5677_DMIC_R_STO3_LH_RISING (0x1 << 10) | ||
842 | #define RT5677_DMIC_L_STO2_LH_MASK (0x1 << 9) | ||
843 | #define RT5677_DMIC_L_STO2_LH_SFT 9 | ||
844 | #define RT5677_DMIC_L_STO2_LH_FALLING (0x0 << 9) | ||
845 | #define RT5677_DMIC_L_STO2_LH_RISING (0x1 << 9) | ||
846 | #define RT5677_DMIC_R_STO2_LH_MASK (0x1 << 8) | ||
847 | #define RT5677_DMIC_R_STO2_LH_SFT 8 | ||
848 | #define RT5677_DMIC_R_STO2_LH_FALLING (0x0 << 8) | ||
849 | #define RT5677_DMIC_R_STO2_LH_RISING (0x1 << 8) | ||
850 | #define RT5677_DMIC_CLK_MASK (0x7 << 5) | ||
851 | #define RT5677_DMIC_CLK_SFT 5 | ||
852 | #define RT5677_DMIC_3_EN_MASK (0x1 << 4) | ||
853 | #define RT5677_DMIC_3_EN_SFT 4 | ||
854 | #define RT5677_DMIC_3_DIS (0x0 << 4) | ||
855 | #define RT5677_DMIC_3_EN (0x1 << 4) | ||
856 | #define RT5677_DMIC_R_MONO_LH_MASK (0x1 << 2) | ||
857 | #define RT5677_DMIC_R_MONO_LH_SFT 2 | ||
858 | #define RT5677_DMIC_R_MONO_LH_FALLING (0x0 << 2) | ||
859 | #define RT5677_DMIC_R_MONO_LH_RISING (0x1 << 2) | ||
860 | #define RT5677_DMIC_L_STO4_LH_MASK (0x1 << 1) | ||
861 | #define RT5677_DMIC_L_STO4_LH_SFT 1 | ||
862 | #define RT5677_DMIC_L_STO4_LH_FALLING (0x0 << 1) | ||
863 | #define RT5677_DMIC_L_STO4_LH_RISING (0x1 << 1) | ||
864 | #define RT5677_DMIC_R_STO4_LH_MASK (0x1 << 0) | ||
865 | #define RT5677_DMIC_R_STO4_LH_SFT 0 | ||
866 | #define RT5677_DMIC_R_STO4_LH_FALLING (0x0 << 0) | ||
867 | #define RT5677_DMIC_R_STO4_LH_RISING (0x1 << 0) | ||
868 | |||
869 | /* Digital Microphone Control 2 (0x51) */ | ||
870 | #define RT5677_DMIC_4_EN_MASK (0x1 << 15) | ||
871 | #define RT5677_DMIC_4_EN_SFT 15 | ||
872 | #define RT5677_DMIC_4_DIS (0x0 << 15) | ||
873 | #define RT5677_DMIC_4_EN (0x1 << 15) | ||
874 | #define RT5677_DMIC_4L_LH_MASK (0x1 << 7) | ||
875 | #define RT5677_DMIC_4L_LH_SFT 7 | ||
876 | #define RT5677_DMIC_4L_LH_FALLING (0x0 << 7) | ||
877 | #define RT5677_DMIC_4L_LH_RISING (0x1 << 7) | ||
878 | #define RT5677_DMIC_4R_LH_MASK (0x1 << 6) | ||
879 | #define RT5677_DMIC_4R_LH_SFT 6 | ||
880 | #define RT5677_DMIC_4R_LH_FALLING (0x0 << 6) | ||
881 | #define RT5677_DMIC_4R_LH_RISING (0x1 << 6) | ||
882 | #define RT5677_DMIC_3L_LH_MASK (0x1 << 5) | ||
883 | #define RT5677_DMIC_3L_LH_SFT 5 | ||
884 | #define RT5677_DMIC_3L_LH_FALLING (0x0 << 5) | ||
885 | #define RT5677_DMIC_3L_LH_RISING (0x1 << 5) | ||
886 | #define RT5677_DMIC_3R_LH_MASK (0x1 << 4) | ||
887 | #define RT5677_DMIC_3R_LH_SFT 4 | ||
888 | #define RT5677_DMIC_3R_LH_FALLING (0x0 << 4) | ||
889 | #define RT5677_DMIC_3R_LH_RISING (0x1 << 4) | ||
890 | #define RT5677_DMIC_2L_LH_MASK (0x1 << 3) | ||
891 | #define RT5677_DMIC_2L_LH_SFT 3 | ||
892 | #define RT5677_DMIC_2L_LH_FALLING (0x0 << 3) | ||
893 | #define RT5677_DMIC_2L_LH_RISING (0x1 << 3) | ||
894 | #define RT5677_DMIC_2R_LH_MASK (0x1 << 2) | ||
895 | #define RT5677_DMIC_2R_LH_SFT 2 | ||
896 | #define RT5677_DMIC_2R_LH_FALLING (0x0 << 2) | ||
897 | #define RT5677_DMIC_2R_LH_RISING (0x1 << 2) | ||
898 | #define RT5677_DMIC_1L_LH_MASK (0x1 << 1) | ||
899 | #define RT5677_DMIC_1L_LH_SFT 1 | ||
900 | #define RT5677_DMIC_1L_LH_FALLING (0x0 << 1) | ||
901 | #define RT5677_DMIC_1L_LH_RISING (0x1 << 1) | ||
902 | #define RT5677_DMIC_1R_LH_MASK (0x1 << 0) | ||
903 | #define RT5677_DMIC_1R_LH_SFT 0 | ||
904 | #define RT5677_DMIC_1R_LH_FALLING (0x0 << 0) | ||
905 | #define RT5677_DMIC_1R_LH_RISING (0x1 << 0) | ||
906 | |||
907 | /* Power Management for Digital 1 (0x61) */ | ||
908 | #define RT5677_PWR_I2S1 (0x1 << 15) | ||
909 | #define RT5677_PWR_I2S1_BIT 15 | ||
910 | #define RT5677_PWR_I2S2 (0x1 << 14) | ||
911 | #define RT5677_PWR_I2S2_BIT 14 | ||
912 | #define RT5677_PWR_I2S3 (0x1 << 13) | ||
913 | #define RT5677_PWR_I2S3_BIT 13 | ||
914 | #define RT5677_PWR_DAC1 (0x1 << 12) | ||
915 | #define RT5677_PWR_DAC1_BIT 12 | ||
916 | #define RT5677_PWR_DAC2 (0x1 << 11) | ||
917 | #define RT5677_PWR_DAC2_BIT 11 | ||
918 | #define RT5677_PWR_I2S4 (0x1 << 10) | ||
919 | #define RT5677_PWR_I2S4_BIT 10 | ||
920 | #define RT5677_PWR_SLB (0x1 << 9) | ||
921 | #define RT5677_PWR_SLB_BIT 9 | ||
922 | #define RT5677_PWR_DAC3 (0x1 << 7) | ||
923 | #define RT5677_PWR_DAC3_BIT 7 | ||
924 | #define RT5677_PWR_ADCFED2 (0x1 << 4) | ||
925 | #define RT5677_PWR_ADCFED2_BIT 4 | ||
926 | #define RT5677_PWR_ADCFED1 (0x1 << 3) | ||
927 | #define RT5677_PWR_ADCFED1_BIT 3 | ||
928 | #define RT5677_PWR_ADC_L (0x1 << 2) | ||
929 | #define RT5677_PWR_ADC_L_BIT 2 | ||
930 | #define RT5677_PWR_ADC_R (0x1 << 1) | ||
931 | #define RT5677_PWR_ADC_R_BIT 1 | ||
932 | #define RT5677_PWR_I2C_MASTER (0x1 << 0) | ||
933 | #define RT5677_PWR_I2C_MASTER_BIT 0 | ||
934 | |||
935 | /* Power Management for Digital 2 (0x62) */ | ||
936 | #define RT5677_PWR_ADC_S1F (0x1 << 15) | ||
937 | #define RT5677_PWR_ADC_S1F_BIT 15 | ||
938 | #define RT5677_PWR_ADC_MF_L (0x1 << 14) | ||
939 | #define RT5677_PWR_ADC_MF_L_BIT 14 | ||
940 | #define RT5677_PWR_ADC_MF_R (0x1 << 13) | ||
941 | #define RT5677_PWR_ADC_MF_R_BIT 13 | ||
942 | #define RT5677_PWR_DAC_S1F (0x1 << 12) | ||
943 | #define RT5677_PWR_DAC_S1F_BIT 12 | ||
944 | #define RT5677_PWR_DAC_M2F_L (0x1 << 11) | ||
945 | #define RT5677_PWR_DAC_M2F_L_BIT 11 | ||
946 | #define RT5677_PWR_DAC_M2F_R (0x1 << 10) | ||
947 | #define RT5677_PWR_DAC_M2F_R_BIT 10 | ||
948 | #define RT5677_PWR_DAC_M3F_L (0x1 << 9) | ||
949 | #define RT5677_PWR_DAC_M3F_L_BIT 9 | ||
950 | #define RT5677_PWR_DAC_M3F_R (0x1 << 8) | ||
951 | #define RT5677_PWR_DAC_M3F_R_BIT 8 | ||
952 | #define RT5677_PWR_DAC_M4F_L (0x1 << 7) | ||
953 | #define RT5677_PWR_DAC_M4F_L_BIT 7 | ||
954 | #define RT5677_PWR_DAC_M4F_R (0x1 << 6) | ||
955 | #define RT5677_PWR_DAC_M4F_R_BIT 6 | ||
956 | #define RT5677_PWR_ADC_S2F (0x1 << 5) | ||
957 | #define RT5677_PWR_ADC_S2F_BIT 5 | ||
958 | #define RT5677_PWR_ADC_S3F (0x1 << 4) | ||
959 | #define RT5677_PWR_ADC_S3F_BIT 4 | ||
960 | #define RT5677_PWR_ADC_S4F (0x1 << 3) | ||
961 | #define RT5677_PWR_ADC_S4F_BIT 3 | ||
962 | #define RT5677_PWR_PDM1 (0x1 << 2) | ||
963 | #define RT5677_PWR_PDM1_BIT 2 | ||
964 | #define RT5677_PWR_PDM2 (0x1 << 1) | ||
965 | #define RT5677_PWR_PDM2_BIT 1 | ||
966 | |||
967 | /* Power Management for Analog 1 (0x63) */ | ||
968 | #define RT5677_PWR_VREF1 (0x1 << 15) | ||
969 | #define RT5677_PWR_VREF1_BIT 15 | ||
970 | #define RT5677_PWR_FV1 (0x1 << 14) | ||
971 | #define RT5677_PWR_FV1_BIT 14 | ||
972 | #define RT5677_PWR_MB (0x1 << 13) | ||
973 | #define RT5677_PWR_MB_BIT 13 | ||
974 | #define RT5677_PWR_LO1 (0x1 << 12) | ||
975 | #define RT5677_PWR_LO1_BIT 12 | ||
976 | #define RT5677_PWR_BG (0x1 << 11) | ||
977 | #define RT5677_PWR_BG_BIT 11 | ||
978 | #define RT5677_PWR_LO2 (0x1 << 10) | ||
979 | #define RT5677_PWR_LO2_BIT 10 | ||
980 | #define RT5677_PWR_LO3 (0x1 << 9) | ||
981 | #define RT5677_PWR_LO3_BIT 9 | ||
982 | #define RT5677_PWR_VREF2 (0x1 << 8) | ||
983 | #define RT5677_PWR_VREF2_BIT 8 | ||
984 | #define RT5677_PWR_FV2 (0x1 << 7) | ||
985 | #define RT5677_PWR_FV2_BIT 7 | ||
986 | #define RT5677_LDO2_SEL_MASK (0x7 << 4) | ||
987 | #define RT5677_LDO2_SEL_SFT 4 | ||
988 | #define RT5677_LDO1_SEL_MASK (0x7 << 0) | ||
989 | #define RT5677_LDO1_SEL_SFT 0 | ||
990 | |||
991 | /* Power Management for Analog 2 (0x64) */ | ||
992 | #define RT5677_PWR_BST1 (0x1 << 15) | ||
993 | #define RT5677_PWR_BST1_BIT 15 | ||
994 | #define RT5677_PWR_BST2 (0x1 << 14) | ||
995 | #define RT5677_PWR_BST2_BIT 14 | ||
996 | #define RT5677_PWR_CLK_MB1 (0x1 << 13) | ||
997 | #define RT5677_PWR_CLK_MB1_BIT 13 | ||
998 | #define RT5677_PWR_SLIM (0x1 << 12) | ||
999 | #define RT5677_PWR_SLIM_BIT 12 | ||
1000 | #define RT5677_PWR_MB1 (0x1 << 11) | ||
1001 | #define RT5677_PWR_MB1_BIT 11 | ||
1002 | #define RT5677_PWR_PP_MB1 (0x1 << 10) | ||
1003 | #define RT5677_PWR_PP_MB1_BIT 10 | ||
1004 | #define RT5677_PWR_PLL1 (0x1 << 9) | ||
1005 | #define RT5677_PWR_PLL1_BIT 9 | ||
1006 | #define RT5677_PWR_PLL2 (0x1 << 8) | ||
1007 | #define RT5677_PWR_PLL2_BIT 8 | ||
1008 | #define RT5677_PWR_CORE (0x1 << 7) | ||
1009 | #define RT5677_PWR_CORE_BIT 7 | ||
1010 | #define RT5677_PWR_CLK_MB (0x1 << 6) | ||
1011 | #define RT5677_PWR_CLK_MB_BIT 6 | ||
1012 | #define RT5677_PWR_BST1_P (0x1 << 5) | ||
1013 | #define RT5677_PWR_BST1_P_BIT 5 | ||
1014 | #define RT5677_PWR_BST2_P (0x1 << 4) | ||
1015 | #define RT5677_PWR_BST2_P_BIT 4 | ||
1016 | #define RT5677_PWR_IPTV (0x1 << 3) | ||
1017 | #define RT5677_PWR_IPTV_BIT 3 | ||
1018 | #define RT5677_PWR_25M_CLK (0x1 << 1) | ||
1019 | #define RT5677_PWR_25M_CLK_BIT 1 | ||
1020 | #define RT5677_PWR_LDO1 (0x1 << 0) | ||
1021 | #define RT5677_PWR_LDO1_BIT 0 | ||
1022 | |||
1023 | /* Power Management for DSP (0x65) */ | ||
1024 | #define RT5677_PWR_SR7 (0x1 << 10) | ||
1025 | #define RT5677_PWR_SR7_BIT 10 | ||
1026 | #define RT5677_PWR_SR6 (0x1 << 9) | ||
1027 | #define RT5677_PWR_SR6_BIT 9 | ||
1028 | #define RT5677_PWR_SR5 (0x1 << 8) | ||
1029 | #define RT5677_PWR_SR5_BIT 8 | ||
1030 | #define RT5677_PWR_SR4 (0x1 << 7) | ||
1031 | #define RT5677_PWR_SR4_BIT 7 | ||
1032 | #define RT5677_PWR_SR3 (0x1 << 6) | ||
1033 | #define RT5677_PWR_SR3_BIT 6 | ||
1034 | #define RT5677_PWR_SR2 (0x1 << 5) | ||
1035 | #define RT5677_PWR_SR2_BIT 5 | ||
1036 | #define RT5677_PWR_SR1 (0x1 << 4) | ||
1037 | #define RT5677_PWR_SR1_BIT 4 | ||
1038 | #define RT5677_PWR_SR0 (0x1 << 3) | ||
1039 | #define RT5677_PWR_SR0_BIT 3 | ||
1040 | #define RT5677_PWR_MLT (0x1 << 2) | ||
1041 | #define RT5677_PWR_MLT_BIT 2 | ||
1042 | #define RT5677_PWR_DSP (0x1 << 1) | ||
1043 | #define RT5677_PWR_DSP_BIT 1 | ||
1044 | #define RT5677_PWR_DSP_CPU (0x1 << 0) | ||
1045 | #define RT5677_PWR_DSP_CPU_BIT 0 | ||
1046 | |||
1047 | /* Power Status for DSP (0x66) */ | ||
1048 | #define RT5677_PWR_SR7_RDY (0x1 << 9) | ||
1049 | #define RT5677_PWR_SR7_RDY_BIT 9 | ||
1050 | #define RT5677_PWR_SR6_RDY (0x1 << 8) | ||
1051 | #define RT5677_PWR_SR6_RDY_BIT 8 | ||
1052 | #define RT5677_PWR_SR5_RDY (0x1 << 7) | ||
1053 | #define RT5677_PWR_SR5_RDY_BIT 7 | ||
1054 | #define RT5677_PWR_SR4_RDY (0x1 << 6) | ||
1055 | #define RT5677_PWR_SR4_RDY_BIT 6 | ||
1056 | #define RT5677_PWR_SR3_RDY (0x1 << 5) | ||
1057 | #define RT5677_PWR_SR3_RDY_BIT 5 | ||
1058 | #define RT5677_PWR_SR2_RDY (0x1 << 4) | ||
1059 | #define RT5677_PWR_SR2_RDY_BIT 4 | ||
1060 | #define RT5677_PWR_SR1_RDY (0x1 << 3) | ||
1061 | #define RT5677_PWR_SR1_RDY_BIT 3 | ||
1062 | #define RT5677_PWR_SR0_RDY (0x1 << 2) | ||
1063 | #define RT5677_PWR_SR0_RDY_BIT 2 | ||
1064 | #define RT5677_PWR_MLT_RDY (0x1 << 1) | ||
1065 | #define RT5677_PWR_MLT_RDY_BIT 1 | ||
1066 | #define RT5677_PWR_DSP_RDY (0x1 << 0) | ||
1067 | #define RT5677_PWR_DSP_RDY_BIT 0 | ||
1068 | |||
1069 | /* Power Management for DSP (0x67) */ | ||
1070 | #define RT5677_PWR_SLIM_ISO (0x1 << 11) | ||
1071 | #define RT5677_PWR_SLIM_ISO_BIT 11 | ||
1072 | #define RT5677_PWR_CORE_ISO (0x1 << 10) | ||
1073 | #define RT5677_PWR_CORE_ISO_BIT 10 | ||
1074 | #define RT5677_PWR_DSP_ISO (0x1 << 9) | ||
1075 | #define RT5677_PWR_DSP_ISO_BIT 9 | ||
1076 | #define RT5677_PWR_SR7_ISO (0x1 << 8) | ||
1077 | #define RT5677_PWR_SR7_ISO_BIT 8 | ||
1078 | #define RT5677_PWR_SR6_ISO (0x1 << 7) | ||
1079 | #define RT5677_PWR_SR6_ISO_BIT 7 | ||
1080 | #define RT5677_PWR_SR5_ISO (0x1 << 6) | ||
1081 | #define RT5677_PWR_SR5_ISO_BIT 6 | ||
1082 | #define RT5677_PWR_SR4_ISO (0x1 << 5) | ||
1083 | #define RT5677_PWR_SR4_ISO_BIT 5 | ||
1084 | #define RT5677_PWR_SR3_ISO (0x1 << 4) | ||
1085 | #define RT5677_PWR_SR3_ISO_BIT 4 | ||
1086 | #define RT5677_PWR_SR2_ISO (0x1 << 3) | ||
1087 | #define RT5677_PWR_SR2_ISO_BIT 3 | ||
1088 | #define RT5677_PWR_SR1_ISO (0x1 << 2) | ||
1089 | #define RT5677_PWR_SR1_ISO_BIT 2 | ||
1090 | #define RT5677_PWR_SR0_ISO (0x1 << 1) | ||
1091 | #define RT5677_PWR_SR0_ISO_BIT 1 | ||
1092 | #define RT5677_PWR_MLT_ISO (0x1 << 0) | ||
1093 | #define RT5677_PWR_MLT_ISO_BIT 0 | ||
1094 | |||
1095 | /* I2S1/2/3/4 Audio Serial Data Port Control (0x6f 0x70 0x71 0x72) */ | ||
1096 | #define RT5677_I2S_MS_MASK (0x1 << 15) | ||
1097 | #define RT5677_I2S_MS_SFT 15 | ||
1098 | #define RT5677_I2S_MS_M (0x0 << 15) | ||
1099 | #define RT5677_I2S_MS_S (0x1 << 15) | ||
1100 | #define RT5677_I2S_O_CP_MASK (0x3 << 10) | ||
1101 | #define RT5677_I2S_O_CP_SFT 10 | ||
1102 | #define RT5677_I2S_O_CP_OFF (0x0 << 10) | ||
1103 | #define RT5677_I2S_O_CP_U_LAW (0x1 << 10) | ||
1104 | #define RT5677_I2S_O_CP_A_LAW (0x2 << 10) | ||
1105 | #define RT5677_I2S_I_CP_MASK (0x3 << 8) | ||
1106 | #define RT5677_I2S_I_CP_SFT 8 | ||
1107 | #define RT5677_I2S_I_CP_OFF (0x0 << 8) | ||
1108 | #define RT5677_I2S_I_CP_U_LAW (0x1 << 8) | ||
1109 | #define RT5677_I2S_I_CP_A_LAW (0x2 << 8) | ||
1110 | #define RT5677_I2S_BP_MASK (0x1 << 7) | ||
1111 | #define RT5677_I2S_BP_SFT 7 | ||
1112 | #define RT5677_I2S_BP_NOR (0x0 << 7) | ||
1113 | #define RT5677_I2S_BP_INV (0x1 << 7) | ||
1114 | #define RT5677_I2S_DL_MASK (0x3 << 2) | ||
1115 | #define RT5677_I2S_DL_SFT 2 | ||
1116 | #define RT5677_I2S_DL_16 (0x0 << 2) | ||
1117 | #define RT5677_I2S_DL_20 (0x1 << 2) | ||
1118 | #define RT5677_I2S_DL_24 (0x2 << 2) | ||
1119 | #define RT5677_I2S_DL_8 (0x3 << 2) | ||
1120 | #define RT5677_I2S_DF_MASK (0x3 << 0) | ||
1121 | #define RT5677_I2S_DF_SFT 0 | ||
1122 | #define RT5677_I2S_DF_I2S (0x0 << 0) | ||
1123 | #define RT5677_I2S_DF_LEFT (0x1 << 0) | ||
1124 | #define RT5677_I2S_DF_PCM_A (0x2 << 0) | ||
1125 | #define RT5677_I2S_DF_PCM_B (0x3 << 0) | ||
1126 | |||
1127 | /* Clock Tree Control 1 (0x73) */ | ||
1128 | #define RT5677_I2S_PD1_MASK (0x7 << 12) | ||
1129 | #define RT5677_I2S_PD1_SFT 12 | ||
1130 | #define RT5677_I2S_PD1_1 (0x0 << 12) | ||
1131 | #define RT5677_I2S_PD1_2 (0x1 << 12) | ||
1132 | #define RT5677_I2S_PD1_3 (0x2 << 12) | ||
1133 | #define RT5677_I2S_PD1_4 (0x3 << 12) | ||
1134 | #define RT5677_I2S_PD1_6 (0x4 << 12) | ||
1135 | #define RT5677_I2S_PD1_8 (0x5 << 12) | ||
1136 | #define RT5677_I2S_PD1_12 (0x6 << 12) | ||
1137 | #define RT5677_I2S_PD1_16 (0x7 << 12) | ||
1138 | #define RT5677_I2S_BCLK_MS2_MASK (0x1 << 11) | ||
1139 | #define RT5677_I2S_BCLK_MS2_SFT 11 | ||
1140 | #define RT5677_I2S_BCLK_MS2_32 (0x0 << 11) | ||
1141 | #define RT5677_I2S_BCLK_MS2_64 (0x1 << 11) | ||
1142 | #define RT5677_I2S_PD2_MASK (0x7 << 8) | ||
1143 | #define RT5677_I2S_PD2_SFT 8 | ||
1144 | #define RT5677_I2S_PD2_1 (0x0 << 8) | ||
1145 | #define RT5677_I2S_PD2_2 (0x1 << 8) | ||
1146 | #define RT5677_I2S_PD2_3 (0x2 << 8) | ||
1147 | #define RT5677_I2S_PD2_4 (0x3 << 8) | ||
1148 | #define RT5677_I2S_PD2_6 (0x4 << 8) | ||
1149 | #define RT5677_I2S_PD2_8 (0x5 << 8) | ||
1150 | #define RT5677_I2S_PD2_12 (0x6 << 8) | ||
1151 | #define RT5677_I2S_PD2_16 (0x7 << 8) | ||
1152 | #define RT5677_I2S_BCLK_MS3_MASK (0x1 << 7) | ||
1153 | #define RT5677_I2S_BCLK_MS3_SFT 7 | ||
1154 | #define RT5677_I2S_BCLK_MS3_32 (0x0 << 7) | ||
1155 | #define RT5677_I2S_BCLK_MS3_64 (0x1 << 7) | ||
1156 | #define RT5677_I2S_PD3_MASK (0x7 << 4) | ||
1157 | #define RT5677_I2S_PD3_SFT 4 | ||
1158 | #define RT5677_I2S_PD3_1 (0x0 << 4) | ||
1159 | #define RT5677_I2S_PD3_2 (0x1 << 4) | ||
1160 | #define RT5677_I2S_PD3_3 (0x2 << 4) | ||
1161 | #define RT5677_I2S_PD3_4 (0x3 << 4) | ||
1162 | #define RT5677_I2S_PD3_6 (0x4 << 4) | ||
1163 | #define RT5677_I2S_PD3_8 (0x5 << 4) | ||
1164 | #define RT5677_I2S_PD3_12 (0x6 << 4) | ||
1165 | #define RT5677_I2S_PD3_16 (0x7 << 4) | ||
1166 | #define RT5677_I2S_BCLK_MS4_MASK (0x1 << 3) | ||
1167 | #define RT5677_I2S_BCLK_MS4_SFT 3 | ||
1168 | #define RT5677_I2S_BCLK_MS4_32 (0x0 << 3) | ||
1169 | #define RT5677_I2S_BCLK_MS4_64 (0x1 << 3) | ||
1170 | #define RT5677_I2S_PD4_MASK (0x7 << 0) | ||
1171 | #define RT5677_I2S_PD4_SFT 0 | ||
1172 | #define RT5677_I2S_PD4_1 (0x0 << 0) | ||
1173 | #define RT5677_I2S_PD4_2 (0x1 << 0) | ||
1174 | #define RT5677_I2S_PD4_3 (0x2 << 0) | ||
1175 | #define RT5677_I2S_PD4_4 (0x3 << 0) | ||
1176 | #define RT5677_I2S_PD4_6 (0x4 << 0) | ||
1177 | #define RT5677_I2S_PD4_8 (0x5 << 0) | ||
1178 | #define RT5677_I2S_PD4_12 (0x6 << 0) | ||
1179 | #define RT5677_I2S_PD4_16 (0x7 << 0) | ||
1180 | |||
1181 | /* Clock Tree Control 2 (0x74) */ | ||
1182 | #define RT5677_I2S_PD5_MASK (0x7 << 12) | ||
1183 | #define RT5677_I2S_PD5_SFT 12 | ||
1184 | #define RT5677_I2S_PD5_1 (0x0 << 12) | ||
1185 | #define RT5677_I2S_PD5_2 (0x1 << 12) | ||
1186 | #define RT5677_I2S_PD5_3 (0x2 << 12) | ||
1187 | #define RT5677_I2S_PD5_4 (0x3 << 12) | ||
1188 | #define RT5677_I2S_PD5_6 (0x4 << 12) | ||
1189 | #define RT5677_I2S_PD5_8 (0x5 << 12) | ||
1190 | #define RT5677_I2S_PD5_12 (0x6 << 12) | ||
1191 | #define RT5677_I2S_PD5_16 (0x7 << 12) | ||
1192 | #define RT5677_I2S_PD6_MASK (0x7 << 8) | ||
1193 | #define RT5677_I2S_PD6_SFT 8 | ||
1194 | #define RT5677_I2S_PD6_1 (0x0 << 8) | ||
1195 | #define RT5677_I2S_PD6_2 (0x1 << 8) | ||
1196 | #define RT5677_I2S_PD6_3 (0x2 << 8) | ||
1197 | #define RT5677_I2S_PD6_4 (0x3 << 8) | ||
1198 | #define RT5677_I2S_PD6_6 (0x4 << 8) | ||
1199 | #define RT5677_I2S_PD6_8 (0x5 << 8) | ||
1200 | #define RT5677_I2S_PD6_12 (0x6 << 8) | ||
1201 | #define RT5677_I2S_PD6_16 (0x7 << 8) | ||
1202 | #define RT5677_I2S_PD7_MASK (0x7 << 4) | ||
1203 | #define RT5677_I2S_PD7_SFT 4 | ||
1204 | #define RT5677_I2S_PD7_1 (0x0 << 4) | ||
1205 | #define RT5677_I2S_PD7_2 (0x1 << 4) | ||
1206 | #define RT5677_I2S_PD7_3 (0x2 << 4) | ||
1207 | #define RT5677_I2S_PD7_4 (0x3 << 4) | ||
1208 | #define RT5677_I2S_PD7_6 (0x4 << 4) | ||
1209 | #define RT5677_I2S_PD7_8 (0x5 << 4) | ||
1210 | #define RT5677_I2S_PD7_12 (0x6 << 4) | ||
1211 | #define RT5677_I2S_PD7_16 (0x7 << 4) | ||
1212 | #define RT5677_I2S_PD8_MASK (0x7 << 0) | ||
1213 | #define RT5677_I2S_PD8_SFT 0 | ||
1214 | #define RT5677_I2S_PD8_1 (0x0 << 0) | ||
1215 | #define RT5677_I2S_PD8_2 (0x1 << 0) | ||
1216 | #define RT5677_I2S_PD8_3 (0x2 << 0) | ||
1217 | #define RT5677_I2S_PD8_4 (0x3 << 0) | ||
1218 | #define RT5677_I2S_PD8_6 (0x4 << 0) | ||
1219 | #define RT5677_I2S_PD8_8 (0x5 << 0) | ||
1220 | #define RT5677_I2S_PD8_12 (0x6 << 0) | ||
1221 | #define RT5677_I2S_PD8_16 (0x7 << 0) | ||
1222 | |||
1223 | /* Clock Tree Control 3 (0x75) */ | ||
1224 | #define RT5677_DSP_ASRC_O_MASK (0x3 << 6) | ||
1225 | #define RT5677_DSP_ASRC_O_SFT 6 | ||
1226 | #define RT5677_DSP_ASRC_O_1_0 (0x0 << 6) | ||
1227 | #define RT5677_DSP_ASRC_O_1_5 (0x1 << 6) | ||
1228 | #define RT5677_DSP_ASRC_O_2_0 (0x2 << 6) | ||
1229 | #define RT5677_DSP_ASRC_O_3_0 (0x3 << 6) | ||
1230 | #define RT5677_DSP_ASRC_I_MASK (0x3 << 4) | ||
1231 | #define RT5677_DSP_ASRC_I_SFT 4 | ||
1232 | #define RT5677_DSP_ASRC_I_1_0 (0x0 << 4) | ||
1233 | #define RT5677_DSP_ASRC_I_1_5 (0x1 << 4) | ||
1234 | #define RT5677_DSP_ASRC_I_2_0 (0x2 << 4) | ||
1235 | #define RT5677_DSP_ASRC_I_3_0 (0x3 << 4) | ||
1236 | #define RT5677_DSP_BUS_PD_MASK (0x7 << 0) | ||
1237 | #define RT5677_DSP_BUS_PD_SFT 0 | ||
1238 | #define RT5677_DSP_BUS_PD_1 (0x0 << 0) | ||
1239 | #define RT5677_DSP_BUS_PD_2 (0x1 << 0) | ||
1240 | #define RT5677_DSP_BUS_PD_3 (0x2 << 0) | ||
1241 | #define RT5677_DSP_BUS_PD_4 (0x3 << 0) | ||
1242 | #define RT5677_DSP_BUS_PD_6 (0x4 << 0) | ||
1243 | #define RT5677_DSP_BUS_PD_8 (0x5 << 0) | ||
1244 | #define RT5677_DSP_BUS_PD_12 (0x6 << 0) | ||
1245 | #define RT5677_DSP_BUS_PD_16 (0x7 << 0) | ||
1246 | |||
1247 | #define RT5677_PLL_INP_MAX 40000000 | ||
1248 | #define RT5677_PLL_INP_MIN 2048000 | ||
1249 | /* PLL M/N/K Code Control 1 (0x7a 0x7c) */ | ||
1250 | #define RT5677_PLL_N_MAX 0x1ff | ||
1251 | #define RT5677_PLL_N_MASK (RT5677_PLL_N_MAX << 7) | ||
1252 | #define RT5677_PLL_N_SFT 7 | ||
1253 | #define RT5677_PLL_K_BP (0x1 << 5) | ||
1254 | #define RT5677_PLL_K_BP_SFT 5 | ||
1255 | #define RT5677_PLL_K_MAX 0x1f | ||
1256 | #define RT5677_PLL_K_MASK (RT5677_PLL_K_MAX) | ||
1257 | #define RT5677_PLL_K_SFT 0 | ||
1258 | |||
1259 | /* PLL M/N/K Code Control 2 (0x7b 0x7d) */ | ||
1260 | #define RT5677_PLL_M_MAX 0xf | ||
1261 | #define RT5677_PLL_M_MASK (RT5677_PLL_M_MAX << 12) | ||
1262 | #define RT5677_PLL_M_SFT 12 | ||
1263 | #define RT5677_PLL_M_BP (0x1 << 11) | ||
1264 | #define RT5677_PLL_M_BP_SFT 11 | ||
1265 | |||
1266 | /* Global Clock Control 1 (0x80) */ | ||
1267 | #define RT5677_SCLK_SRC_MASK (0x3 << 14) | ||
1268 | #define RT5677_SCLK_SRC_SFT 14 | ||
1269 | #define RT5677_SCLK_SRC_MCLK (0x0 << 14) | ||
1270 | #define RT5677_SCLK_SRC_PLL1 (0x1 << 14) | ||
1271 | #define RT5677_SCLK_SRC_RCCLK (0x2 << 14) /* 25MHz */ | ||
1272 | #define RT5677_SCLK_SRC_SLIM (0x3 << 14) | ||
1273 | #define RT5677_PLL1_SRC_MASK (0x7 << 11) | ||
1274 | #define RT5677_PLL1_SRC_SFT 11 | ||
1275 | #define RT5677_PLL1_SRC_MCLK (0x0 << 11) | ||
1276 | #define RT5677_PLL1_SRC_BCLK1 (0x1 << 11) | ||
1277 | #define RT5677_PLL1_SRC_BCLK2 (0x2 << 11) | ||
1278 | #define RT5677_PLL1_SRC_BCLK3 (0x3 << 11) | ||
1279 | #define RT5677_PLL1_SRC_BCLK4 (0x4 << 11) | ||
1280 | #define RT5677_PLL1_SRC_RCCLK (0x5 << 11) | ||
1281 | #define RT5677_PLL1_SRC_SLIM (0x6 << 11) | ||
1282 | #define RT5677_MCLK_SRC_MASK (0x1 << 10) | ||
1283 | #define RT5677_MCLK_SRC_SFT 10 | ||
1284 | #define RT5677_MCLK1_SRC (0x0 << 10) | ||
1285 | #define RT5677_MCLK2_SRC (0x1 << 10) | ||
1286 | #define RT5677_PLL1_PD_MASK (0x1 << 8) | ||
1287 | #define RT5677_PLL1_PD_SFT 8 | ||
1288 | #define RT5677_PLL1_PD_1 (0x0 << 8) | ||
1289 | #define RT5677_PLL1_PD_2 (0x1 << 8) | ||
1290 | #define RT5671_DAC_OSR_MASK (0x3 << 6) | ||
1291 | #define RT5671_DAC_OSR_SFT 6 | ||
1292 | #define RT5671_DAC_OSR_128 (0x0 << 6) | ||
1293 | #define RT5671_DAC_OSR_64 (0x1 << 6) | ||
1294 | #define RT5671_DAC_OSR_32 (0x2 << 6) | ||
1295 | #define RT5671_ADC_OSR_MASK (0x3 << 4) | ||
1296 | #define RT5671_ADC_OSR_SFT 4 | ||
1297 | #define RT5671_ADC_OSR_128 (0x0 << 4) | ||
1298 | #define RT5671_ADC_OSR_64 (0x1 << 4) | ||
1299 | #define RT5671_ADC_OSR_32 (0x2 << 4) | ||
1300 | |||
1301 | /* Global Clock Control 2 (0x81) */ | ||
1302 | #define RT5677_PLL2_PR_SRC_MASK (0x1 << 15) | ||
1303 | #define RT5677_PLL2_PR_SRC_SFT 15 | ||
1304 | #define RT5677_PLL2_PR_SRC_MCLK1 (0x0 << 15) | ||
1305 | #define RT5677_PLL2_PR_SRC_MCLK2 (0x1 << 15) | ||
1306 | #define RT5677_PLL2_SRC_MASK (0x7 << 12) | ||
1307 | #define RT5677_PLL2_SRC_SFT 12 | ||
1308 | #define RT5677_PLL2_SRC_MCLK (0x0 << 12) | ||
1309 | #define RT5677_PLL2_SRC_BCLK1 (0x1 << 12) | ||
1310 | #define RT5677_PLL2_SRC_BCLK2 (0x2 << 12) | ||
1311 | #define RT5677_PLL2_SRC_BCLK3 (0x3 << 12) | ||
1312 | #define RT5677_PLL2_SRC_BCLK4 (0x4 << 12) | ||
1313 | #define RT5677_PLL2_SRC_RCCLK (0x5 << 12) | ||
1314 | #define RT5677_PLL2_SRC_SLIM (0x6 << 12) | ||
1315 | #define RT5671_DSP_ASRC_O_SRC (0x3 << 10) | ||
1316 | #define RT5671_DSP_ASRC_O_SRC_SFT 10 | ||
1317 | #define RT5671_DSP_ASRC_O_MCLK (0x0 << 10) | ||
1318 | #define RT5671_DSP_ASRC_O_PLL1 (0x1 << 10) | ||
1319 | #define RT5671_DSP_ASRC_O_SLIM (0x2 << 10) | ||
1320 | #define RT5671_DSP_ASRC_O_RCCLK (0x3 << 10) | ||
1321 | #define RT5671_DSP_ASRC_I_SRC (0x3 << 8) | ||
1322 | #define RT5671_DSP_ASRC_I_SRC_SFT 8 | ||
1323 | #define RT5671_DSP_ASRC_I_MCLK (0x0 << 8) | ||
1324 | #define RT5671_DSP_ASRC_I_PLL1 (0x1 << 8) | ||
1325 | #define RT5671_DSP_ASRC_I_SLIM (0x2 << 8) | ||
1326 | #define RT5671_DSP_ASRC_I_RCCLK (0x3 << 8) | ||
1327 | #define RT5677_DSP_CLK_SRC_MASK (0x1 << 7) | ||
1328 | #define RT5677_DSP_CLK_SRC_SFT 7 | ||
1329 | #define RT5677_DSP_CLK_SRC_PLL2 (0x0 << 7) | ||
1330 | #define RT5677_DSP_CLK_SRC_BYPASS (0x1 << 7) | ||
1331 | |||
1332 | /* VAD Function Control 4 (0x9f) */ | ||
1333 | #define RT5677_VAD_SRC_MASK (0x7 << 8) | ||
1334 | #define RT5677_VAD_SRC_SFT 8 | ||
1335 | |||
1336 | /* DSP InBound Control (0xa3) */ | ||
1337 | #define RT5677_IB01_SRC_MASK (0x7 << 12) | ||
1338 | #define RT5677_IB01_SRC_SFT 12 | ||
1339 | #define RT5677_IB23_SRC_MASK (0x7 << 8) | ||
1340 | #define RT5677_IB23_SRC_SFT 8 | ||
1341 | #define RT5677_IB45_SRC_MASK (0x7 << 4) | ||
1342 | #define RT5677_IB45_SRC_SFT 4 | ||
1343 | #define RT5677_IB6_SRC_MASK (0x7 << 0) | ||
1344 | #define RT5677_IB6_SRC_SFT 0 | ||
1345 | |||
1346 | /* DSP InBound Control (0xa4) */ | ||
1347 | #define RT5677_IB7_SRC_MASK (0x7 << 12) | ||
1348 | #define RT5677_IB7_SRC_SFT 12 | ||
1349 | #define RT5677_IB8_SRC_MASK (0x7 << 8) | ||
1350 | #define RT5677_IB8_SRC_SFT 8 | ||
1351 | #define RT5677_IB9_SRC_MASK (0x7 << 4) | ||
1352 | #define RT5677_IB9_SRC_SFT 4 | ||
1353 | |||
1354 | /* DSP In/OutBound Control (0xa5) */ | ||
1355 | #define RT5677_SEL_SRC_OB23 (0x1 << 4) | ||
1356 | #define RT5677_SEL_SRC_OB23_SFT 4 | ||
1357 | #define RT5677_SEL_SRC_OB01 (0x1 << 3) | ||
1358 | #define RT5677_SEL_SRC_OB01_SFT 3 | ||
1359 | #define RT5677_SEL_SRC_IB45 (0x1 << 2) | ||
1360 | #define RT5677_SEL_SRC_IB45_SFT 2 | ||
1361 | #define RT5677_SEL_SRC_IB23 (0x1 << 1) | ||
1362 | #define RT5677_SEL_SRC_IB23_SFT 1 | ||
1363 | #define RT5677_SEL_SRC_IB01 (0x1 << 0) | ||
1364 | #define RT5677_SEL_SRC_IB01_SFT 0 | ||
1365 | |||
1366 | /* Virtual DSP Mixer Control (0xf7 0xf8 0xf9) */ | ||
1367 | #define RT5677_DSP_IB_01_H (0x1 << 15) | ||
1368 | #define RT5677_DSP_IB_01_H_SFT 15 | ||
1369 | #define RT5677_DSP_IB_23_H (0x1 << 14) | ||
1370 | #define RT5677_DSP_IB_23_H_SFT 14 | ||
1371 | #define RT5677_DSP_IB_45_H (0x1 << 13) | ||
1372 | #define RT5677_DSP_IB_45_H_SFT 13 | ||
1373 | #define RT5677_DSP_IB_6_H (0x1 << 12) | ||
1374 | #define RT5677_DSP_IB_6_H_SFT 12 | ||
1375 | #define RT5677_DSP_IB_7_H (0x1 << 11) | ||
1376 | #define RT5677_DSP_IB_7_H_SFT 11 | ||
1377 | #define RT5677_DSP_IB_8_H (0x1 << 10) | ||
1378 | #define RT5677_DSP_IB_8_H_SFT 10 | ||
1379 | #define RT5677_DSP_IB_9_H (0x1 << 9) | ||
1380 | #define RT5677_DSP_IB_9_H_SFT 9 | ||
1381 | #define RT5677_DSP_IB_01_L (0x1 << 7) | ||
1382 | #define RT5677_DSP_IB_01_L_SFT 7 | ||
1383 | #define RT5677_DSP_IB_23_L (0x1 << 6) | ||
1384 | #define RT5677_DSP_IB_23_L_SFT 6 | ||
1385 | #define RT5677_DSP_IB_45_L (0x1 << 5) | ||
1386 | #define RT5677_DSP_IB_45_L_SFT 5 | ||
1387 | #define RT5677_DSP_IB_6_L (0x1 << 4) | ||
1388 | #define RT5677_DSP_IB_6_L_SFT 4 | ||
1389 | #define RT5677_DSP_IB_7_L (0x1 << 3) | ||
1390 | #define RT5677_DSP_IB_7_L_SFT 3 | ||
1391 | #define RT5677_DSP_IB_8_L (0x1 << 2) | ||
1392 | #define RT5677_DSP_IB_8_L_SFT 2 | ||
1393 | #define RT5677_DSP_IB_9_L (0x1 << 1) | ||
1394 | #define RT5677_DSP_IB_9_L_SFT 1 | ||
1395 | |||
1396 | /* Debug String Length */ | ||
1397 | #define RT5677_REG_DISP_LEN 23 | ||
1398 | |||
1399 | #define RT5677_NO_JACK BIT(0) | ||
1400 | #define RT5677_HEADSET_DET BIT(1) | ||
1401 | #define RT5677_HEADPHO_DET BIT(2) | ||
1402 | |||
1403 | /* System Clock Source */ | ||
1404 | enum { | ||
1405 | RT5677_SCLK_S_MCLK, | ||
1406 | RT5677_SCLK_S_PLL1, | ||
1407 | RT5677_SCLK_S_RCCLK, | ||
1408 | }; | ||
1409 | |||
1410 | /* PLL1 Source */ | ||
1411 | enum { | ||
1412 | RT5677_PLL1_S_MCLK, | ||
1413 | RT5677_PLL1_S_BCLK1, | ||
1414 | RT5677_PLL1_S_BCLK2, | ||
1415 | RT5677_PLL1_S_BCLK3, | ||
1416 | RT5677_PLL1_S_BCLK4, | ||
1417 | }; | ||
1418 | |||
1419 | enum { | ||
1420 | RT5677_AIF1, | ||
1421 | RT5677_AIF2, | ||
1422 | RT5677_AIF3, | ||
1423 | RT5677_AIF4, | ||
1424 | RT5677_AIF5, | ||
1425 | RT5677_AIFS, | ||
1426 | }; | ||
1427 | |||
1428 | struct rt5677_pll_code { | ||
1429 | bool m_bp; /* Indicates bypass m code or not. */ | ||
1430 | bool k_bp; /* Indicates bypass k code or not. */ | ||
1431 | int m_code; | ||
1432 | int n_code; | ||
1433 | int k_code; | ||
1434 | }; | ||
1435 | |||
1436 | struct rt5677_priv { | ||
1437 | struct snd_soc_codec *codec; | ||
1438 | struct rt5677_platform_data pdata; | ||
1439 | struct regmap *regmap; | ||
1440 | |||
1441 | int sysclk; | ||
1442 | int sysclk_src; | ||
1443 | int lrck[RT5677_AIFS]; | ||
1444 | int bclk[RT5677_AIFS]; | ||
1445 | int master[RT5677_AIFS]; | ||
1446 | int pll_src; | ||
1447 | int pll_in; | ||
1448 | int pll_out; | ||
1449 | }; | ||
1450 | |||
1451 | #endif /* __RT5677_H__ */ | ||
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 9626ee0417cd..3d39f0b5b4a8 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c | |||
@@ -36,18 +36,32 @@ | |||
36 | 36 | ||
37 | /* default value of sgtl5000 registers */ | 37 | /* default value of sgtl5000 registers */ |
38 | static const struct reg_default sgtl5000_reg_defaults[] = { | 38 | static const struct reg_default sgtl5000_reg_defaults[] = { |
39 | { SGTL5000_CHIP_DIG_POWER, 0x0000 }, | ||
39 | { SGTL5000_CHIP_CLK_CTRL, 0x0008 }, | 40 | { SGTL5000_CHIP_CLK_CTRL, 0x0008 }, |
40 | { SGTL5000_CHIP_I2S_CTRL, 0x0010 }, | 41 | { SGTL5000_CHIP_I2S_CTRL, 0x0010 }, |
41 | { SGTL5000_CHIP_SSS_CTRL, 0x0010 }, | 42 | { SGTL5000_CHIP_SSS_CTRL, 0x0010 }, |
43 | { SGTL5000_CHIP_ADCDAC_CTRL, 0x020c }, | ||
42 | { SGTL5000_CHIP_DAC_VOL, 0x3c3c }, | 44 | { SGTL5000_CHIP_DAC_VOL, 0x3c3c }, |
43 | { SGTL5000_CHIP_PAD_STRENGTH, 0x015f }, | 45 | { SGTL5000_CHIP_PAD_STRENGTH, 0x015f }, |
46 | { SGTL5000_CHIP_ANA_ADC_CTRL, 0x0000 }, | ||
44 | { SGTL5000_CHIP_ANA_HP_CTRL, 0x1818 }, | 47 | { SGTL5000_CHIP_ANA_HP_CTRL, 0x1818 }, |
45 | { SGTL5000_CHIP_ANA_CTRL, 0x0111 }, | 48 | { SGTL5000_CHIP_ANA_CTRL, 0x0111 }, |
49 | { SGTL5000_CHIP_LINREG_CTRL, 0x0000 }, | ||
50 | { SGTL5000_CHIP_REF_CTRL, 0x0000 }, | ||
51 | { SGTL5000_CHIP_MIC_CTRL, 0x0000 }, | ||
52 | { SGTL5000_CHIP_LINE_OUT_CTRL, 0x0000 }, | ||
46 | { SGTL5000_CHIP_LINE_OUT_VOL, 0x0404 }, | 53 | { SGTL5000_CHIP_LINE_OUT_VOL, 0x0404 }, |
47 | { SGTL5000_CHIP_ANA_POWER, 0x7060 }, | 54 | { SGTL5000_CHIP_ANA_POWER, 0x7060 }, |
48 | { SGTL5000_CHIP_PLL_CTRL, 0x5000 }, | 55 | { SGTL5000_CHIP_PLL_CTRL, 0x5000 }, |
56 | { SGTL5000_CHIP_CLK_TOP_CTRL, 0x0000 }, | ||
57 | { SGTL5000_CHIP_ANA_STATUS, 0x0000 }, | ||
58 | { SGTL5000_CHIP_SHORT_CTRL, 0x0000 }, | ||
59 | { SGTL5000_CHIP_ANA_TEST2, 0x0000 }, | ||
60 | { SGTL5000_DAP_CTRL, 0x0000 }, | ||
61 | { SGTL5000_DAP_PEQ, 0x0000 }, | ||
49 | { SGTL5000_DAP_BASS_ENHANCE, 0x0040 }, | 62 | { SGTL5000_DAP_BASS_ENHANCE, 0x0040 }, |
50 | { SGTL5000_DAP_BASS_ENHANCE_CTRL, 0x051f }, | 63 | { SGTL5000_DAP_BASS_ENHANCE_CTRL, 0x051f }, |
64 | { SGTL5000_DAP_AUDIO_EQ, 0x0000 }, | ||
51 | { SGTL5000_DAP_SURROUND, 0x0040 }, | 65 | { SGTL5000_DAP_SURROUND, 0x0040 }, |
52 | { SGTL5000_DAP_EQ_BASS_BAND0, 0x002f }, | 66 | { SGTL5000_DAP_EQ_BASS_BAND0, 0x002f }, |
53 | { SGTL5000_DAP_EQ_BASS_BAND1, 0x002f }, | 67 | { SGTL5000_DAP_EQ_BASS_BAND1, 0x002f }, |
@@ -55,6 +69,7 @@ static const struct reg_default sgtl5000_reg_defaults[] = { | |||
55 | { SGTL5000_DAP_EQ_BASS_BAND3, 0x002f }, | 69 | { SGTL5000_DAP_EQ_BASS_BAND3, 0x002f }, |
56 | { SGTL5000_DAP_EQ_BASS_BAND4, 0x002f }, | 70 | { SGTL5000_DAP_EQ_BASS_BAND4, 0x002f }, |
57 | { SGTL5000_DAP_MAIN_CHAN, 0x8000 }, | 71 | { SGTL5000_DAP_MAIN_CHAN, 0x8000 }, |
72 | { SGTL5000_DAP_MIX_CHAN, 0x0000 }, | ||
58 | { SGTL5000_DAP_AVC_CTRL, 0x0510 }, | 73 | { SGTL5000_DAP_AVC_CTRL, 0x0510 }, |
59 | { SGTL5000_DAP_AVC_THRESHOLD, 0x1473 }, | 74 | { SGTL5000_DAP_AVC_THRESHOLD, 0x1473 }, |
60 | { SGTL5000_DAP_AVC_ATTACK, 0x0028 }, | 75 | { SGTL5000_DAP_AVC_ATTACK, 0x0028 }, |
@@ -1068,71 +1083,11 @@ static int sgtl5000_suspend(struct snd_soc_codec *codec) | |||
1068 | return 0; | 1083 | return 0; |
1069 | } | 1084 | } |
1070 | 1085 | ||
1071 | /* | ||
1072 | * restore all sgtl5000 registers, | ||
1073 | * since a big hole between dap and regular registers, | ||
1074 | * we will restore them respectively. | ||
1075 | */ | ||
1076 | static int sgtl5000_restore_regs(struct snd_soc_codec *codec) | ||
1077 | { | ||
1078 | u16 *cache = codec->reg_cache; | ||
1079 | u16 reg; | ||
1080 | |||
1081 | /* restore regular registers */ | ||
1082 | for (reg = 0; reg <= SGTL5000_CHIP_SHORT_CTRL; reg += 2) { | ||
1083 | |||
1084 | /* These regs should restore in particular order */ | ||
1085 | if (reg == SGTL5000_CHIP_ANA_POWER || | ||
1086 | reg == SGTL5000_CHIP_CLK_CTRL || | ||
1087 | reg == SGTL5000_CHIP_LINREG_CTRL || | ||
1088 | reg == SGTL5000_CHIP_LINE_OUT_CTRL || | ||
1089 | reg == SGTL5000_CHIP_REF_CTRL) | ||
1090 | continue; | ||
1091 | |||
1092 | snd_soc_write(codec, reg, cache[reg]); | ||
1093 | } | ||
1094 | |||
1095 | /* restore dap registers */ | ||
1096 | for (reg = SGTL5000_DAP_REG_OFFSET; reg < SGTL5000_MAX_REG_OFFSET; reg += 2) | ||
1097 | snd_soc_write(codec, reg, cache[reg]); | ||
1098 | |||
1099 | /* | ||
1100 | * restore these regs according to the power setting sequence in | ||
1101 | * sgtl5000_set_power_regs() and clock setting sequence in | ||
1102 | * sgtl5000_set_clock(). | ||
1103 | * | ||
1104 | * The order of restore is: | ||
1105 | * 1. SGTL5000_CHIP_CLK_CTRL MCLK_FREQ bits (1:0) should be restore after | ||
1106 | * SGTL5000_CHIP_ANA_POWER PLL bits set | ||
1107 | * 2. SGTL5000_CHIP_LINREG_CTRL should be set before | ||
1108 | * SGTL5000_CHIP_ANA_POWER LINREG_D restored | ||
1109 | * 3. SGTL5000_CHIP_REF_CTRL controls Analog Ground Voltage, | ||
1110 | * prefer to resotre it after SGTL5000_CHIP_ANA_POWER restored | ||
1111 | */ | ||
1112 | snd_soc_write(codec, SGTL5000_CHIP_LINREG_CTRL, | ||
1113 | cache[SGTL5000_CHIP_LINREG_CTRL]); | ||
1114 | |||
1115 | snd_soc_write(codec, SGTL5000_CHIP_ANA_POWER, | ||
1116 | cache[SGTL5000_CHIP_ANA_POWER]); | ||
1117 | |||
1118 | snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, | ||
1119 | cache[SGTL5000_CHIP_CLK_CTRL]); | ||
1120 | |||
1121 | snd_soc_write(codec, SGTL5000_CHIP_REF_CTRL, | ||
1122 | cache[SGTL5000_CHIP_REF_CTRL]); | ||
1123 | |||
1124 | snd_soc_write(codec, SGTL5000_CHIP_LINE_OUT_CTRL, | ||
1125 | cache[SGTL5000_CHIP_LINE_OUT_CTRL]); | ||
1126 | return 0; | ||
1127 | } | ||
1128 | |||
1129 | static int sgtl5000_resume(struct snd_soc_codec *codec) | 1086 | static int sgtl5000_resume(struct snd_soc_codec *codec) |
1130 | { | 1087 | { |
1131 | /* Bring the codec back up to standby to enable regulators */ | 1088 | /* Bring the codec back up to standby to enable regulators */ |
1132 | sgtl5000_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1089 | sgtl5000_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
1133 | 1090 | ||
1134 | /* Restore registers by cached in memory */ | ||
1135 | sgtl5000_restore_regs(codec); | ||
1136 | return 0; | 1091 | return 0; |
1137 | } | 1092 | } |
1138 | #else | 1093 | #else |
diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c index c5177bc5df82..d90cb0fafcb2 100644 --- a/sound/soc/codecs/sirf-audio-codec.c +++ b/sound/soc/codecs/sirf-audio-codec.c | |||
@@ -109,7 +109,7 @@ static void enable_and_reset_codec(struct regmap *regmap, | |||
109 | { | 109 | { |
110 | regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1, | 110 | regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1, |
111 | codec_enable_bits | codec_reset_bits, | 111 | codec_enable_bits | codec_reset_bits, |
112 | codec_enable_bits | ~codec_reset_bits); | 112 | codec_enable_bits); |
113 | msleep(20); | 113 | msleep(20); |
114 | regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1, | 114 | regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1, |
115 | codec_reset_bits, codec_reset_bits); | 115 | codec_reset_bits, codec_reset_bits); |
@@ -128,8 +128,7 @@ static int atlas6_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w, | |||
128 | break; | 128 | break; |
129 | case SND_SOC_DAPM_POST_PMD: | 129 | case SND_SOC_DAPM_POST_PMD: |
130 | regmap_update_bits(sirf_audio_codec->regmap, | 130 | regmap_update_bits(sirf_audio_codec->regmap, |
131 | AUDIO_IC_CODEC_CTRL1, ATLAS6_CODEC_ENABLE_BITS, | 131 | AUDIO_IC_CODEC_CTRL1, ATLAS6_CODEC_ENABLE_BITS, 0); |
132 | ~ATLAS6_CODEC_ENABLE_BITS); | ||
133 | break; | 132 | break; |
134 | default: | 133 | default: |
135 | break; | 134 | break; |
@@ -151,8 +150,7 @@ static int prima2_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w, | |||
151 | break; | 150 | break; |
152 | case SND_SOC_DAPM_POST_PMD: | 151 | case SND_SOC_DAPM_POST_PMD: |
153 | regmap_update_bits(sirf_audio_codec->regmap, | 152 | regmap_update_bits(sirf_audio_codec->regmap, |
154 | AUDIO_IC_CODEC_CTRL1, PRIMA2_CODEC_ENABLE_BITS, | 153 | AUDIO_IC_CODEC_CTRL1, PRIMA2_CODEC_ENABLE_BITS, 0); |
155 | ~PRIMA2_CODEC_ENABLE_BITS); | ||
156 | break; | 154 | break; |
157 | default: | 155 | default: |
158 | break; | 156 | break; |
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index d7349bc89ad3..e12fafbb1e09 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
@@ -169,7 +169,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, | |||
169 | mask <<= shift; | 169 | mask <<= shift; |
170 | val <<= shift; | 170 | val <<= shift; |
171 | 171 | ||
172 | change = snd_soc_test_bits(codec, val, mask, reg); | 172 | change = snd_soc_test_bits(codec, reg, mask, val); |
173 | if (change) { | 173 | if (change) { |
174 | update.kcontrol = kcontrol; | 174 | update.kcontrol = kcontrol; |
175 | update.reg = reg; | 175 | update.reg = reg; |
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index bbcad9ff3c98..d96e5963ee35 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c | |||
@@ -63,6 +63,7 @@ struct wm8804_priv { | |||
63 | struct regmap *regmap; | 63 | struct regmap *regmap; |
64 | struct regulator_bulk_data supplies[WM8804_NUM_SUPPLIES]; | 64 | struct regulator_bulk_data supplies[WM8804_NUM_SUPPLIES]; |
65 | struct notifier_block disable_nb[WM8804_NUM_SUPPLIES]; | 65 | struct notifier_block disable_nb[WM8804_NUM_SUPPLIES]; |
66 | int mclk_div; | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | static int txsrc_get(struct snd_kcontrol *kcontrol, | 69 | static int txsrc_get(struct snd_kcontrol *kcontrol, |
@@ -318,7 +319,7 @@ static struct { | |||
318 | 319 | ||
319 | #define FIXED_PLL_SIZE ((1ULL << 22) * 10) | 320 | #define FIXED_PLL_SIZE ((1ULL << 22) * 10) |
320 | static int pll_factors(struct pll_div *pll_div, unsigned int target, | 321 | static int pll_factors(struct pll_div *pll_div, unsigned int target, |
321 | unsigned int source) | 322 | unsigned int source, unsigned int mclk_div) |
322 | { | 323 | { |
323 | u64 Kpart; | 324 | u64 Kpart; |
324 | unsigned long int K, Ndiv, Nmod, tmp; | 325 | unsigned long int K, Ndiv, Nmod, tmp; |
@@ -330,7 +331,8 @@ static int pll_factors(struct pll_div *pll_div, unsigned int target, | |||
330 | */ | 331 | */ |
331 | for (i = 0; i < ARRAY_SIZE(post_table); i++) { | 332 | for (i = 0; i < ARRAY_SIZE(post_table); i++) { |
332 | tmp = target * post_table[i].div; | 333 | tmp = target * post_table[i].div; |
333 | if (tmp >= 90000000 && tmp <= 100000000) { | 334 | if ((tmp >= 90000000 && tmp <= 100000000) && |
335 | (mclk_div == post_table[i].mclkdiv)) { | ||
334 | pll_div->freqmode = post_table[i].freqmode; | 336 | pll_div->freqmode = post_table[i].freqmode; |
335 | pll_div->mclkdiv = post_table[i].mclkdiv; | 337 | pll_div->mclkdiv = post_table[i].mclkdiv; |
336 | target *= post_table[i].div; | 338 | target *= post_table[i].div; |
@@ -387,8 +389,12 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, | |||
387 | } else { | 389 | } else { |
388 | int ret; | 390 | int ret; |
389 | struct pll_div pll_div; | 391 | struct pll_div pll_div; |
392 | struct wm8804_priv *wm8804; | ||
390 | 393 | ||
391 | ret = pll_factors(&pll_div, freq_out, freq_in); | 394 | wm8804 = snd_soc_codec_get_drvdata(codec); |
395 | |||
396 | ret = pll_factors(&pll_div, freq_out, freq_in, | ||
397 | wm8804->mclk_div); | ||
392 | if (ret) | 398 | if (ret) |
393 | return ret; | 399 | return ret; |
394 | 400 | ||
@@ -452,6 +458,7 @@ static int wm8804_set_clkdiv(struct snd_soc_dai *dai, | |||
452 | int div_id, int div) | 458 | int div_id, int div) |
453 | { | 459 | { |
454 | struct snd_soc_codec *codec; | 460 | struct snd_soc_codec *codec; |
461 | struct wm8804_priv *wm8804; | ||
455 | 462 | ||
456 | codec = dai->codec; | 463 | codec = dai->codec; |
457 | switch (div_id) { | 464 | switch (div_id) { |
@@ -459,6 +466,10 @@ static int wm8804_set_clkdiv(struct snd_soc_dai *dai, | |||
459 | snd_soc_update_bits(codec, WM8804_PLL5, 0x30, | 466 | snd_soc_update_bits(codec, WM8804_PLL5, 0x30, |
460 | (div & 0x3) << 4); | 467 | (div & 0x3) << 4); |
461 | break; | 468 | break; |
469 | case WM8804_MCLK_DIV: | ||
470 | wm8804 = snd_soc_codec_get_drvdata(codec); | ||
471 | wm8804->mclk_div = div; | ||
472 | break; | ||
462 | default: | 473 | default: |
463 | dev_err(dai->dev, "Unknown clock divider: %d\n", div_id); | 474 | dev_err(dai->dev, "Unknown clock divider: %d\n", div_id); |
464 | return -EINVAL; | 475 | return -EINVAL; |
diff --git a/sound/soc/codecs/wm8804.h b/sound/soc/codecs/wm8804.h index 8ec14f5573cb..e72d4f4ba6b1 100644 --- a/sound/soc/codecs/wm8804.h +++ b/sound/soc/codecs/wm8804.h | |||
@@ -57,5 +57,9 @@ | |||
57 | #define WM8804_CLKOUT_SRC_OSCCLK 4 | 57 | #define WM8804_CLKOUT_SRC_OSCCLK 4 |
58 | 58 | ||
59 | #define WM8804_CLKOUT_DIV 1 | 59 | #define WM8804_CLKOUT_DIV 1 |
60 | #define WM8804_MCLK_DIV 2 | ||
61 | |||
62 | #define WM8804_MCLKDIV_256FS 0 | ||
63 | #define WM8804_MCLKDIV_128FS 1 | ||
60 | 64 | ||
61 | #endif /* _WM8804_H */ | 65 | #endif /* _WM8804_H */ |
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index acea8927905b..2a9c6d11330c 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c | |||
@@ -74,8 +74,7 @@ static const char *wm9713_rec_src[] = | |||
74 | "Mono Out", "Zh"}; | 74 | "Mono Out", "Zh"}; |
75 | static const char *wm9713_rec_gain[] = {"+1.5dB Steps", "+0.75dB Steps"}; | 75 | static const char *wm9713_rec_gain[] = {"+1.5dB Steps", "+0.75dB Steps"}; |
76 | static const char *wm9713_alc_select[] = {"None", "Left", "Right", "Stereo"}; | 76 | static const char *wm9713_alc_select[] = {"None", "Left", "Right", "Stereo"}; |
77 | static const char *wm9713_mono_pga[] = {"Vmid", "Zh", "Mono", "Inv", | 77 | static const char *wm9713_mono_pga[] = {"Vmid", "Zh", "Mono", "Inv"}; |
78 | "Mono Vmid", "Inv Vmid"}; | ||
79 | static const char *wm9713_spk_pga[] = | 78 | static const char *wm9713_spk_pga[] = |
80 | {"Vmid", "Zh", "Headphone", "Speaker", "Inv", "Headphone Vmid", | 79 | {"Vmid", "Zh", "Headphone", "Speaker", "Inv", "Headphone Vmid", |
81 | "Speaker Vmid", "Inv Vmid"}; | 80 | "Speaker Vmid", "Inv Vmid"}; |
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index ff15eec3ab2f..060027182dcb 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c | |||
@@ -1543,16 +1543,16 @@ static void wm_adsp2_boot_work(struct work_struct *work) | |||
1543 | ret = regmap_read(dsp->regmap, | 1543 | ret = regmap_read(dsp->regmap, |
1544 | dsp->base + ADSP2_CLOCKING, &val); | 1544 | dsp->base + ADSP2_CLOCKING, &val); |
1545 | if (ret != 0) { | 1545 | if (ret != 0) { |
1546 | dev_err(dsp->dev, "Failed to read clocking: %d\n", ret); | 1546 | adsp_err(dsp, "Failed to read clocking: %d\n", ret); |
1547 | return; | 1547 | return; |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | if ((val & ADSP2_CLK_SEL_MASK) >= 3) { | 1550 | if ((val & ADSP2_CLK_SEL_MASK) >= 3) { |
1551 | ret = regulator_enable(dsp->dvfs); | 1551 | ret = regulator_enable(dsp->dvfs); |
1552 | if (ret != 0) { | 1552 | if (ret != 0) { |
1553 | dev_err(dsp->dev, | 1553 | adsp_err(dsp, |
1554 | "Failed to enable supply: %d\n", | 1554 | "Failed to enable supply: %d\n", |
1555 | ret); | 1555 | ret); |
1556 | return; | 1556 | return; |
1557 | } | 1557 | } |
1558 | 1558 | ||
@@ -1560,9 +1560,9 @@ static void wm_adsp2_boot_work(struct work_struct *work) | |||
1560 | 1800000, | 1560 | 1800000, |
1561 | 1800000); | 1561 | 1800000); |
1562 | if (ret != 0) { | 1562 | if (ret != 0) { |
1563 | dev_err(dsp->dev, | 1563 | adsp_err(dsp, |
1564 | "Failed to raise supply: %d\n", | 1564 | "Failed to raise supply: %d\n", |
1565 | ret); | 1565 | ret); |
1566 | return; | 1566 | return; |
1567 | } | 1567 | } |
1568 | } | 1568 | } |
@@ -1672,15 +1672,15 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, | |||
1672 | ret = regulator_set_voltage(dsp->dvfs, 1200000, | 1672 | ret = regulator_set_voltage(dsp->dvfs, 1200000, |
1673 | 1800000); | 1673 | 1800000); |
1674 | if (ret != 0) | 1674 | if (ret != 0) |
1675 | dev_warn(dsp->dev, | 1675 | adsp_warn(dsp, |
1676 | "Failed to lower supply: %d\n", | 1676 | "Failed to lower supply: %d\n", |
1677 | ret); | 1677 | ret); |
1678 | 1678 | ||
1679 | ret = regulator_disable(dsp->dvfs); | 1679 | ret = regulator_disable(dsp->dvfs); |
1680 | if (ret != 0) | 1680 | if (ret != 0) |
1681 | dev_err(dsp->dev, | 1681 | adsp_err(dsp, |
1682 | "Failed to enable supply: %d\n", | 1682 | "Failed to enable supply: %d\n", |
1683 | ret); | 1683 | ret); |
1684 | } | 1684 | } |
1685 | 1685 | ||
1686 | list_for_each_entry(ctl, &dsp->ctl_list, list) | 1686 | list_for_each_entry(ctl, &dsp->ctl_list, list) |
@@ -1732,28 +1732,25 @@ int wm_adsp2_init(struct wm_adsp *adsp, bool dvfs) | |||
1732 | adsp->dvfs = devm_regulator_get(adsp->dev, "DCVDD"); | 1732 | adsp->dvfs = devm_regulator_get(adsp->dev, "DCVDD"); |
1733 | if (IS_ERR(adsp->dvfs)) { | 1733 | if (IS_ERR(adsp->dvfs)) { |
1734 | ret = PTR_ERR(adsp->dvfs); | 1734 | ret = PTR_ERR(adsp->dvfs); |
1735 | dev_err(adsp->dev, "Failed to get DCVDD: %d\n", ret); | 1735 | adsp_err(adsp, "Failed to get DCVDD: %d\n", ret); |
1736 | return ret; | 1736 | return ret; |
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | ret = regulator_enable(adsp->dvfs); | 1739 | ret = regulator_enable(adsp->dvfs); |
1740 | if (ret != 0) { | 1740 | if (ret != 0) { |
1741 | dev_err(adsp->dev, "Failed to enable DCVDD: %d\n", | 1741 | adsp_err(adsp, "Failed to enable DCVDD: %d\n", ret); |
1742 | ret); | ||
1743 | return ret; | 1742 | return ret; |
1744 | } | 1743 | } |
1745 | 1744 | ||
1746 | ret = regulator_set_voltage(adsp->dvfs, 1200000, 1800000); | 1745 | ret = regulator_set_voltage(adsp->dvfs, 1200000, 1800000); |
1747 | if (ret != 0) { | 1746 | if (ret != 0) { |
1748 | dev_err(adsp->dev, "Failed to initialise DVFS: %d\n", | 1747 | adsp_err(adsp, "Failed to initialise DVFS: %d\n", ret); |
1749 | ret); | ||
1750 | return ret; | 1748 | return ret; |
1751 | } | 1749 | } |
1752 | 1750 | ||
1753 | ret = regulator_disable(adsp->dvfs); | 1751 | ret = regulator_disable(adsp->dvfs); |
1754 | if (ret != 0) { | 1752 | if (ret != 0) { |
1755 | dev_err(adsp->dev, "Failed to disable DCVDD: %d\n", | 1753 | adsp_err(adsp, "Failed to disable DCVDD: %d\n", ret); |
1756 | ret); | ||
1757 | return ret; | 1754 | return ret; |
1758 | } | 1755 | } |
1759 | } | 1756 | } |
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index cab98a580053..a50010e2891f 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c | |||
@@ -38,7 +38,7 @@ struct snd_soc_card_drvdata_davinci { | |||
38 | static int evm_startup(struct snd_pcm_substream *substream) | 38 | static int evm_startup(struct snd_pcm_substream *substream) |
39 | { | 39 | { |
40 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 40 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
41 | struct snd_soc_card *soc_card = rtd->codec->card; | 41 | struct snd_soc_card *soc_card = rtd->card; |
42 | struct snd_soc_card_drvdata_davinci *drvdata = | 42 | struct snd_soc_card_drvdata_davinci *drvdata = |
43 | snd_soc_card_get_drvdata(soc_card); | 43 | snd_soc_card_get_drvdata(soc_card); |
44 | 44 | ||
@@ -51,7 +51,7 @@ static int evm_startup(struct snd_pcm_substream *substream) | |||
51 | static void evm_shutdown(struct snd_pcm_substream *substream) | 51 | static void evm_shutdown(struct snd_pcm_substream *substream) |
52 | { | 52 | { |
53 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 53 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
54 | struct snd_soc_card *soc_card = rtd->codec->card; | 54 | struct snd_soc_card *soc_card = rtd->card; |
55 | struct snd_soc_card_drvdata_davinci *drvdata = | 55 | struct snd_soc_card_drvdata_davinci *drvdata = |
56 | snd_soc_card_get_drvdata(soc_card); | 56 | snd_soc_card_get_drvdata(soc_card); |
57 | 57 | ||
@@ -65,8 +65,7 @@ static int evm_hw_params(struct snd_pcm_substream *substream, | |||
65 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 65 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
66 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 66 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
67 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 67 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
68 | struct snd_soc_codec *codec = rtd->codec; | 68 | struct snd_soc_card *soc_card = rtd->card; |
69 | struct snd_soc_card *soc_card = codec->card; | ||
70 | int ret = 0; | 69 | int ret = 0; |
71 | unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *) | 70 | unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *) |
72 | snd_soc_card_get_drvdata(soc_card))->sysclk; | 71 | snd_soc_card_get_drvdata(soc_card))->sysclk; |
@@ -125,7 +124,7 @@ static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd) | |||
125 | { | 124 | { |
126 | struct snd_soc_card *card = rtd->card; | 125 | struct snd_soc_card *card = rtd->card; |
127 | struct snd_soc_codec *codec = rtd->codec; | 126 | struct snd_soc_codec *codec = rtd->codec; |
128 | struct device_node *np = codec->card->dev->of_node; | 127 | struct device_node *np = card->dev->of_node; |
129 | int ret; | 128 | int ret; |
130 | 129 | ||
131 | /* Add davinci-evm specific widgets */ | 130 | /* Add davinci-evm specific widgets */ |
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 14058dc6eaf8..9afb14629a17 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
@@ -33,10 +33,10 @@ | |||
33 | #include <sound/initval.h> | 33 | #include <sound/initval.h> |
34 | #include <sound/soc.h> | 34 | #include <sound/soc.h> |
35 | #include <sound/dmaengine_pcm.h> | 35 | #include <sound/dmaengine_pcm.h> |
36 | #include <sound/omap-pcm.h> | ||
36 | 37 | ||
37 | #include "davinci-pcm.h" | 38 | #include "davinci-pcm.h" |
38 | #include "davinci-mcasp.h" | 39 | #include "davinci-mcasp.h" |
39 | #include "../omap/omap-pcm.h" | ||
40 | 40 | ||
41 | #define MCASP_MAX_AFIFO_DEPTH 64 | 41 | #define MCASP_MAX_AFIFO_DEPTH 64 |
42 | 42 | ||
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index d262ec0653d3..37933629cbed 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig | |||
@@ -16,6 +16,7 @@ config SND_SOC_FSL_SSI | |||
16 | tristate "Synchronous Serial Interface module support" | 16 | tristate "Synchronous Serial Interface module support" |
17 | select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n | 17 | select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n |
18 | select SND_SOC_IMX_PCM_FIQ if SND_IMX_SOC != n && ARCH_MXC | 18 | select SND_SOC_IMX_PCM_FIQ if SND_IMX_SOC != n && ARCH_MXC |
19 | select REGMAP_MMIO | ||
19 | help | 20 | help |
20 | Say Y if you want to add Synchronous Serial Interface (SSI) | 21 | Say Y if you want to add Synchronous Serial Interface (SSI) |
21 | support for the Freescale CPUs. | 22 | support for the Freescale CPUs. |
@@ -207,12 +208,7 @@ config SND_SOC_PHYCORE_AC97 | |||
207 | 208 | ||
208 | config SND_SOC_EUKREA_TLV320 | 209 | config SND_SOC_EUKREA_TLV320 |
209 | tristate "Eukrea TLV320" | 210 | tristate "Eukrea TLV320" |
210 | depends on MACH_EUKREA_MBIMX27_BASEBOARD \ | 211 | depends on ARCH_MXC && I2C |
211 | || MACH_EUKREA_MBIMXSD25_BASEBOARD \ | ||
212 | || MACH_EUKREA_MBIMXSD35_BASEBOARD \ | ||
213 | || MACH_EUKREA_MBIMXSD51_BASEBOARD \ | ||
214 | || (OF && ARM) | ||
215 | depends on I2C | ||
216 | select SND_SOC_TLV320AIC23_I2C | 212 | select SND_SOC_TLV320AIC23_I2C |
217 | select SND_SOC_IMX_AUDMUX | 213 | select SND_SOC_IMX_AUDMUX |
218 | select SND_SOC_IMX_SSI | 214 | select SND_SOC_IMX_SSI |
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index f233d915b7e4..9bfef55d77d1 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c | |||
@@ -54,25 +54,6 @@ | |||
54 | #include "fsl_ssi.h" | 54 | #include "fsl_ssi.h" |
55 | #include "imx-pcm.h" | 55 | #include "imx-pcm.h" |
56 | 56 | ||
57 | #ifdef PPC | ||
58 | #define read_ssi(addr) in_be32(addr) | ||
59 | #define write_ssi(val, addr) out_be32(addr, val) | ||
60 | #define write_ssi_mask(addr, clear, set) clrsetbits_be32(addr, clear, set) | ||
61 | #else | ||
62 | #define read_ssi(addr) readl(addr) | ||
63 | #define write_ssi(val, addr) writel(val, addr) | ||
64 | /* | ||
65 | * FIXME: Proper locking should be added at write_ssi_mask caller level | ||
66 | * to ensure this register read/modify/write sequence is race free. | ||
67 | */ | ||
68 | static inline void write_ssi_mask(u32 __iomem *addr, u32 clear, u32 set) | ||
69 | { | ||
70 | u32 val = readl(addr); | ||
71 | val = (val & ~clear) | set; | ||
72 | writel(val, addr); | ||
73 | } | ||
74 | #endif | ||
75 | |||
76 | /** | 57 | /** |
77 | * FSLSSI_I2S_RATES: sample rates supported by the I2S | 58 | * FSLSSI_I2S_RATES: sample rates supported by the I2S |
78 | * | 59 | * |
@@ -132,72 +113,86 @@ struct fsl_ssi_rxtx_reg_val { | |||
132 | struct fsl_ssi_reg_val rx; | 113 | struct fsl_ssi_reg_val rx; |
133 | struct fsl_ssi_reg_val tx; | 114 | struct fsl_ssi_reg_val tx; |
134 | }; | 115 | }; |
116 | static const struct regmap_config fsl_ssi_regconfig = { | ||
117 | .max_register = CCSR_SSI_SACCDIS, | ||
118 | .reg_bits = 32, | ||
119 | .val_bits = 32, | ||
120 | .reg_stride = 4, | ||
121 | .val_format_endian = REGMAP_ENDIAN_NATIVE, | ||
122 | }; | ||
123 | |||
124 | struct fsl_ssi_soc_data { | ||
125 | bool imx; | ||
126 | bool offline_config; | ||
127 | u32 sisr_write_mask; | ||
128 | }; | ||
135 | 129 | ||
136 | /** | 130 | /** |
137 | * fsl_ssi_private: per-SSI private data | 131 | * fsl_ssi_private: per-SSI private data |
138 | * | 132 | * |
139 | * @ssi: pointer to the SSI's registers | 133 | * @reg: Pointer to the regmap registers |
140 | * @ssi_phys: physical address of the SSI registers | ||
141 | * @irq: IRQ of this SSI | 134 | * @irq: IRQ of this SSI |
142 | * @playback: the number of playback streams opened | 135 | * @cpu_dai_drv: CPU DAI driver for this device |
143 | * @capture: the number of capture streams opened | 136 | * |
144 | * @cpu_dai: the CPU DAI for this device | 137 | * @dai_fmt: DAI configuration this device is currently used with |
145 | * @dev_attr: the sysfs device attribute structure | 138 | * @i2s_mode: i2s and network mode configuration of the device. Is used to |
146 | * @stats: SSI statistics | 139 | * switch between normal and i2s/network mode |
140 | * mode depending on the number of channels | ||
141 | * @use_dma: DMA is used or FIQ with stream filter | ||
142 | * @use_dual_fifo: DMA with support for both FIFOs used | ||
143 | * @fifo_deph: Depth of the SSI FIFOs | ||
144 | * @rxtx_reg_val: Specific register settings for receive/transmit configuration | ||
145 | * | ||
146 | * @clk: SSI clock | ||
147 | * @baudclk: SSI baud clock for master mode | ||
148 | * @baudclk_streams: Active streams that are using baudclk | ||
149 | * @bitclk_freq: bitclock frequency set by .set_dai_sysclk | ||
150 | * | ||
151 | * @dma_params_tx: DMA transmit parameters | ||
152 | * @dma_params_rx: DMA receive parameters | ||
153 | * @ssi_phys: physical address of the SSI registers | ||
154 | * | ||
155 | * @fiq_params: FIQ stream filtering parameters | ||
156 | * | ||
157 | * @pdev: Pointer to pdev used for deprecated fsl-ssi sound card | ||
158 | * | ||
159 | * @dbg_stats: Debugging statistics | ||
160 | * | ||
161 | * @soc: SoC specifc data | ||
147 | */ | 162 | */ |
148 | struct fsl_ssi_private { | 163 | struct fsl_ssi_private { |
149 | struct ccsr_ssi __iomem *ssi; | 164 | struct regmap *regs; |
150 | dma_addr_t ssi_phys; | ||
151 | unsigned int irq; | 165 | unsigned int irq; |
152 | unsigned int fifo_depth; | ||
153 | struct snd_soc_dai_driver cpu_dai_drv; | 166 | struct snd_soc_dai_driver cpu_dai_drv; |
154 | struct platform_device *pdev; | ||
155 | unsigned int dai_fmt; | ||
156 | 167 | ||
157 | enum fsl_ssi_type hw_type; | 168 | unsigned int dai_fmt; |
169 | u8 i2s_mode; | ||
158 | bool use_dma; | 170 | bool use_dma; |
159 | bool baudclk_locked; | ||
160 | bool use_dual_fifo; | 171 | bool use_dual_fifo; |
161 | u8 i2s_mode; | 172 | unsigned int fifo_depth; |
162 | spinlock_t baudclk_lock; | 173 | struct fsl_ssi_rxtx_reg_val rxtx_reg_val; |
163 | struct clk *baudclk; | 174 | |
164 | struct clk *clk; | 175 | struct clk *clk; |
176 | struct clk *baudclk; | ||
177 | unsigned int baudclk_streams; | ||
178 | unsigned int bitclk_freq; | ||
179 | |||
180 | /* DMA params */ | ||
165 | struct snd_dmaengine_dai_dma_data dma_params_tx; | 181 | struct snd_dmaengine_dai_dma_data dma_params_tx; |
166 | struct snd_dmaengine_dai_dma_data dma_params_rx; | 182 | struct snd_dmaengine_dai_dma_data dma_params_rx; |
183 | dma_addr_t ssi_phys; | ||
184 | |||
185 | /* params for non-dma FIQ stream filtered mode */ | ||
167 | struct imx_pcm_fiq_params fiq_params; | 186 | struct imx_pcm_fiq_params fiq_params; |
168 | /* Register values for rx/tx configuration */ | 187 | |
169 | struct fsl_ssi_rxtx_reg_val rxtx_reg_val; | 188 | /* Used when using fsl-ssi as sound-card. This is only used by ppc and |
189 | * should be replaced with simple-sound-card. */ | ||
190 | struct platform_device *pdev; | ||
170 | 191 | ||
171 | struct fsl_ssi_dbg dbg_stats; | 192 | struct fsl_ssi_dbg dbg_stats; |
172 | }; | ||
173 | 193 | ||
174 | static const struct of_device_id fsl_ssi_ids[] = { | 194 | const struct fsl_ssi_soc_data *soc; |
175 | { .compatible = "fsl,mpc8610-ssi", .data = (void *) FSL_SSI_MCP8610}, | ||
176 | { .compatible = "fsl,imx51-ssi", .data = (void *) FSL_SSI_MX51}, | ||
177 | { .compatible = "fsl,imx35-ssi", .data = (void *) FSL_SSI_MX35}, | ||
178 | { .compatible = "fsl,imx21-ssi", .data = (void *) FSL_SSI_MX21}, | ||
179 | {} | ||
180 | }; | 195 | }; |
181 | MODULE_DEVICE_TABLE(of, fsl_ssi_ids); | ||
182 | |||
183 | static bool fsl_ssi_is_ac97(struct fsl_ssi_private *ssi_private) | ||
184 | { | ||
185 | return !!(ssi_private->dai_fmt & SND_SOC_DAIFMT_AC97); | ||
186 | } | ||
187 | |||
188 | static bool fsl_ssi_on_imx(struct fsl_ssi_private *ssi_private) | ||
189 | { | ||
190 | switch (ssi_private->hw_type) { | ||
191 | case FSL_SSI_MX21: | ||
192 | case FSL_SSI_MX35: | ||
193 | case FSL_SSI_MX51: | ||
194 | return true; | ||
195 | case FSL_SSI_MCP8610: | ||
196 | return false; | ||
197 | } | ||
198 | |||
199 | return false; | ||
200 | } | ||
201 | 196 | ||
202 | /* | 197 | /* |
203 | * imx51 and later SoCs have a slightly different IP that allows the | 198 | * imx51 and later SoCs have a slightly different IP that allows the |
@@ -214,18 +209,54 @@ static bool fsl_ssi_on_imx(struct fsl_ssi_private *ssi_private) | |||
214 | * while the SSI unit is running (SSIEN). So we support the necessary | 209 | * while the SSI unit is running (SSIEN). So we support the necessary |
215 | * online configuration of fsl-ssi starting at imx51. | 210 | * online configuration of fsl-ssi starting at imx51. |
216 | */ | 211 | */ |
217 | static bool fsl_ssi_offline_config(struct fsl_ssi_private *ssi_private) | 212 | |
213 | static struct fsl_ssi_soc_data fsl_ssi_mpc8610 = { | ||
214 | .imx = false, | ||
215 | .offline_config = true, | ||
216 | .sisr_write_mask = CCSR_SSI_SISR_RFRC | CCSR_SSI_SISR_TFRC | | ||
217 | CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | | ||
218 | CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1, | ||
219 | }; | ||
220 | |||
221 | static struct fsl_ssi_soc_data fsl_ssi_imx21 = { | ||
222 | .imx = true, | ||
223 | .offline_config = true, | ||
224 | .sisr_write_mask = 0, | ||
225 | }; | ||
226 | |||
227 | static struct fsl_ssi_soc_data fsl_ssi_imx35 = { | ||
228 | .imx = true, | ||
229 | .offline_config = true, | ||
230 | .sisr_write_mask = CCSR_SSI_SISR_RFRC | CCSR_SSI_SISR_TFRC | | ||
231 | CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | | ||
232 | CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1, | ||
233 | }; | ||
234 | |||
235 | static struct fsl_ssi_soc_data fsl_ssi_imx51 = { | ||
236 | .imx = true, | ||
237 | .offline_config = false, | ||
238 | .sisr_write_mask = CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | | ||
239 | CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1, | ||
240 | }; | ||
241 | |||
242 | static const struct of_device_id fsl_ssi_ids[] = { | ||
243 | { .compatible = "fsl,mpc8610-ssi", .data = &fsl_ssi_mpc8610 }, | ||
244 | { .compatible = "fsl,imx51-ssi", .data = &fsl_ssi_imx51 }, | ||
245 | { .compatible = "fsl,imx35-ssi", .data = &fsl_ssi_imx35 }, | ||
246 | { .compatible = "fsl,imx21-ssi", .data = &fsl_ssi_imx21 }, | ||
247 | {} | ||
248 | }; | ||
249 | MODULE_DEVICE_TABLE(of, fsl_ssi_ids); | ||
250 | |||
251 | static bool fsl_ssi_is_ac97(struct fsl_ssi_private *ssi_private) | ||
218 | { | 252 | { |
219 | switch (ssi_private->hw_type) { | 253 | return !!(ssi_private->dai_fmt & SND_SOC_DAIFMT_AC97); |
220 | case FSL_SSI_MCP8610: | 254 | } |
221 | case FSL_SSI_MX21: | ||
222 | case FSL_SSI_MX35: | ||
223 | return true; | ||
224 | case FSL_SSI_MX51: | ||
225 | return false; | ||
226 | } | ||
227 | 255 | ||
228 | return true; | 256 | static bool fsl_ssi_is_i2s_master(struct fsl_ssi_private *ssi_private) |
257 | { | ||
258 | return (ssi_private->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == | ||
259 | SND_SOC_DAIFMT_CBS_CFS; | ||
229 | } | 260 | } |
230 | 261 | ||
231 | /** | 262 | /** |
@@ -243,39 +274,20 @@ static bool fsl_ssi_offline_config(struct fsl_ssi_private *ssi_private) | |||
243 | static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) | 274 | static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) |
244 | { | 275 | { |
245 | struct fsl_ssi_private *ssi_private = dev_id; | 276 | struct fsl_ssi_private *ssi_private = dev_id; |
246 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 277 | struct regmap *regs = ssi_private->regs; |
247 | __be32 sisr; | 278 | __be32 sisr; |
248 | __be32 sisr2; | 279 | __be32 sisr2; |
249 | __be32 sisr_write_mask = 0; | ||
250 | |||
251 | switch (ssi_private->hw_type) { | ||
252 | case FSL_SSI_MX21: | ||
253 | sisr_write_mask = 0; | ||
254 | break; | ||
255 | |||
256 | case FSL_SSI_MCP8610: | ||
257 | case FSL_SSI_MX35: | ||
258 | sisr_write_mask = CCSR_SSI_SISR_RFRC | CCSR_SSI_SISR_TFRC | | ||
259 | CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | | ||
260 | CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1; | ||
261 | break; | ||
262 | |||
263 | case FSL_SSI_MX51: | ||
264 | sisr_write_mask = CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | | ||
265 | CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1; | ||
266 | break; | ||
267 | } | ||
268 | 280 | ||
269 | /* We got an interrupt, so read the status register to see what we | 281 | /* We got an interrupt, so read the status register to see what we |
270 | were interrupted for. We mask it with the Interrupt Enable register | 282 | were interrupted for. We mask it with the Interrupt Enable register |
271 | so that we only check for events that we're interested in. | 283 | so that we only check for events that we're interested in. |
272 | */ | 284 | */ |
273 | sisr = read_ssi(&ssi->sisr); | 285 | regmap_read(regs, CCSR_SSI_SISR, &sisr); |
274 | 286 | ||
275 | sisr2 = sisr & sisr_write_mask; | 287 | sisr2 = sisr & ssi_private->soc->sisr_write_mask; |
276 | /* Clear the bits that we set */ | 288 | /* Clear the bits that we set */ |
277 | if (sisr2) | 289 | if (sisr2) |
278 | write_ssi(sisr2, &ssi->sisr); | 290 | regmap_write(regs, CCSR_SSI_SISR, sisr2); |
279 | 291 | ||
280 | fsl_ssi_dbg_isr(&ssi_private->dbg_stats, sisr); | 292 | fsl_ssi_dbg_isr(&ssi_private->dbg_stats, sisr); |
281 | 293 | ||
@@ -288,17 +300,26 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) | |||
288 | static void fsl_ssi_rxtx_config(struct fsl_ssi_private *ssi_private, | 300 | static void fsl_ssi_rxtx_config(struct fsl_ssi_private *ssi_private, |
289 | bool enable) | 301 | bool enable) |
290 | { | 302 | { |
291 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 303 | struct regmap *regs = ssi_private->regs; |
292 | struct fsl_ssi_rxtx_reg_val *vals = &ssi_private->rxtx_reg_val; | 304 | struct fsl_ssi_rxtx_reg_val *vals = &ssi_private->rxtx_reg_val; |
293 | 305 | ||
294 | if (enable) { | 306 | if (enable) { |
295 | write_ssi_mask(&ssi->sier, 0, vals->rx.sier | vals->tx.sier); | 307 | regmap_update_bits(regs, CCSR_SSI_SIER, |
296 | write_ssi_mask(&ssi->srcr, 0, vals->rx.srcr | vals->tx.srcr); | 308 | vals->rx.sier | vals->tx.sier, |
297 | write_ssi_mask(&ssi->stcr, 0, vals->rx.stcr | vals->tx.stcr); | 309 | vals->rx.sier | vals->tx.sier); |
310 | regmap_update_bits(regs, CCSR_SSI_SRCR, | ||
311 | vals->rx.srcr | vals->tx.srcr, | ||
312 | vals->rx.srcr | vals->tx.srcr); | ||
313 | regmap_update_bits(regs, CCSR_SSI_STCR, | ||
314 | vals->rx.stcr | vals->tx.stcr, | ||
315 | vals->rx.stcr | vals->tx.stcr); | ||
298 | } else { | 316 | } else { |
299 | write_ssi_mask(&ssi->srcr, vals->rx.srcr | vals->tx.srcr, 0); | 317 | regmap_update_bits(regs, CCSR_SSI_SRCR, |
300 | write_ssi_mask(&ssi->stcr, vals->rx.stcr | vals->tx.stcr, 0); | 318 | vals->rx.srcr | vals->tx.srcr, 0); |
301 | write_ssi_mask(&ssi->sier, vals->rx.sier | vals->tx.sier, 0); | 319 | regmap_update_bits(regs, CCSR_SSI_STCR, |
320 | vals->rx.stcr | vals->tx.stcr, 0); | ||
321 | regmap_update_bits(regs, CCSR_SSI_SIER, | ||
322 | vals->rx.sier | vals->tx.sier, 0); | ||
302 | } | 323 | } |
303 | } | 324 | } |
304 | 325 | ||
@@ -329,13 +350,17 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi_private *ssi_private, | |||
329 | static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, | 350 | static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, |
330 | struct fsl_ssi_reg_val *vals) | 351 | struct fsl_ssi_reg_val *vals) |
331 | { | 352 | { |
332 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 353 | struct regmap *regs = ssi_private->regs; |
333 | struct fsl_ssi_reg_val *avals; | 354 | struct fsl_ssi_reg_val *avals; |
334 | u32 scr_val = read_ssi(&ssi->scr); | 355 | int nr_active_streams; |
335 | int nr_active_streams = !!(scr_val & CCSR_SSI_SCR_TE) + | 356 | u32 scr_val; |
336 | !!(scr_val & CCSR_SSI_SCR_RE); | ||
337 | int keep_active; | 357 | int keep_active; |
338 | 358 | ||
359 | regmap_read(regs, CCSR_SSI_SCR, &scr_val); | ||
360 | |||
361 | nr_active_streams = !!(scr_val & CCSR_SSI_SCR_TE) + | ||
362 | !!(scr_val & CCSR_SSI_SCR_RE); | ||
363 | |||
339 | if (nr_active_streams - 1 > 0) | 364 | if (nr_active_streams - 1 > 0) |
340 | keep_active = 1; | 365 | keep_active = 1; |
341 | else | 366 | else |
@@ -352,7 +377,7 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, | |||
352 | if (!enable) { | 377 | if (!enable) { |
353 | u32 scr = fsl_ssi_disable_val(vals->scr, avals->scr, | 378 | u32 scr = fsl_ssi_disable_val(vals->scr, avals->scr, |
354 | keep_active); | 379 | keep_active); |
355 | write_ssi_mask(&ssi->scr, scr, 0); | 380 | regmap_update_bits(regs, CCSR_SSI_SCR, scr, 0); |
356 | } | 381 | } |
357 | 382 | ||
358 | /* | 383 | /* |
@@ -360,7 +385,7 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, | |||
360 | * reconfiguration, so we have to enable all necessary flags at once | 385 | * reconfiguration, so we have to enable all necessary flags at once |
361 | * even if we do not use them later (capture and playback configuration) | 386 | * even if we do not use them later (capture and playback configuration) |
362 | */ | 387 | */ |
363 | if (fsl_ssi_offline_config(ssi_private)) { | 388 | if (ssi_private->soc->offline_config) { |
364 | if ((enable && !nr_active_streams) || | 389 | if ((enable && !nr_active_streams) || |
365 | (!enable && !keep_active)) | 390 | (!enable && !keep_active)) |
366 | fsl_ssi_rxtx_config(ssi_private, enable); | 391 | fsl_ssi_rxtx_config(ssi_private, enable); |
@@ -373,9 +398,9 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, | |||
373 | * (online configuration) | 398 | * (online configuration) |
374 | */ | 399 | */ |
375 | if (enable) { | 400 | if (enable) { |
376 | write_ssi_mask(&ssi->sier, 0, vals->sier); | 401 | regmap_update_bits(regs, CCSR_SSI_SIER, vals->sier, vals->sier); |
377 | write_ssi_mask(&ssi->srcr, 0, vals->srcr); | 402 | regmap_update_bits(regs, CCSR_SSI_SRCR, vals->srcr, vals->srcr); |
378 | write_ssi_mask(&ssi->stcr, 0, vals->stcr); | 403 | regmap_update_bits(regs, CCSR_SSI_STCR, vals->stcr, vals->stcr); |
379 | } else { | 404 | } else { |
380 | u32 sier; | 405 | u32 sier; |
381 | u32 srcr; | 406 | u32 srcr; |
@@ -398,15 +423,15 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, | |||
398 | stcr = fsl_ssi_disable_val(vals->stcr, avals->stcr, | 423 | stcr = fsl_ssi_disable_val(vals->stcr, avals->stcr, |
399 | keep_active); | 424 | keep_active); |
400 | 425 | ||
401 | write_ssi_mask(&ssi->srcr, srcr, 0); | 426 | regmap_update_bits(regs, CCSR_SSI_SRCR, srcr, 0); |
402 | write_ssi_mask(&ssi->stcr, stcr, 0); | 427 | regmap_update_bits(regs, CCSR_SSI_STCR, stcr, 0); |
403 | write_ssi_mask(&ssi->sier, sier, 0); | 428 | regmap_update_bits(regs, CCSR_SSI_SIER, sier, 0); |
404 | } | 429 | } |
405 | 430 | ||
406 | config_done: | 431 | config_done: |
407 | /* Enabling of subunits is done after configuration */ | 432 | /* Enabling of subunits is done after configuration */ |
408 | if (enable) | 433 | if (enable) |
409 | write_ssi_mask(&ssi->scr, 0, vals->scr); | 434 | regmap_update_bits(regs, CCSR_SSI_SCR, vals->scr, vals->scr); |
410 | } | 435 | } |
411 | 436 | ||
412 | 437 | ||
@@ -457,32 +482,33 @@ static void fsl_ssi_setup_reg_vals(struct fsl_ssi_private *ssi_private) | |||
457 | 482 | ||
458 | static void fsl_ssi_setup_ac97(struct fsl_ssi_private *ssi_private) | 483 | static void fsl_ssi_setup_ac97(struct fsl_ssi_private *ssi_private) |
459 | { | 484 | { |
460 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 485 | struct regmap *regs = ssi_private->regs; |
461 | 486 | ||
462 | /* | 487 | /* |
463 | * Setup the clock control register | 488 | * Setup the clock control register |
464 | */ | 489 | */ |
465 | write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), | 490 | regmap_write(regs, CCSR_SSI_STCCR, |
466 | &ssi->stccr); | 491 | CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13)); |
467 | write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), | 492 | regmap_write(regs, CCSR_SSI_SRCCR, |
468 | &ssi->srccr); | 493 | CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13)); |
469 | 494 | ||
470 | /* | 495 | /* |
471 | * Enable AC97 mode and startup the SSI | 496 | * Enable AC97 mode and startup the SSI |
472 | */ | 497 | */ |
473 | write_ssi(CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV, | 498 | regmap_write(regs, CCSR_SSI_SACNT, |
474 | &ssi->sacnt); | 499 | CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV); |
475 | write_ssi(0xff, &ssi->saccdis); | 500 | regmap_write(regs, CCSR_SSI_SACCDIS, 0xff); |
476 | write_ssi(0x300, &ssi->saccen); | 501 | regmap_write(regs, CCSR_SSI_SACCEN, 0x300); |
477 | 502 | ||
478 | /* | 503 | /* |
479 | * Enable SSI, Transmit and Receive. AC97 has to communicate with the | 504 | * Enable SSI, Transmit and Receive. AC97 has to communicate with the |
480 | * codec before a stream is started. | 505 | * codec before a stream is started. |
481 | */ | 506 | */ |
482 | write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | | 507 | regmap_update_bits(regs, CCSR_SSI_SCR, |
483 | CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE); | 508 | CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE, |
509 | CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE); | ||
484 | 510 | ||
485 | write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor); | 511 | regmap_write(regs, CCSR_SSI_SOR, CCSR_SSI_SOR_WAIT(3)); |
486 | } | 512 | } |
487 | 513 | ||
488 | /** | 514 | /** |
@@ -499,13 +525,6 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, | |||
499 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 525 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
500 | struct fsl_ssi_private *ssi_private = | 526 | struct fsl_ssi_private *ssi_private = |
501 | snd_soc_dai_get_drvdata(rtd->cpu_dai); | 527 | snd_soc_dai_get_drvdata(rtd->cpu_dai); |
502 | unsigned long flags; | ||
503 | |||
504 | if (!dai->active && !fsl_ssi_is_ac97(ssi_private)) { | ||
505 | spin_lock_irqsave(&ssi_private->baudclk_lock, flags); | ||
506 | ssi_private->baudclk_locked = false; | ||
507 | spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); | ||
508 | } | ||
509 | 528 | ||
510 | /* When using dual fifo mode, it is safer to ensure an even period | 529 | /* When using dual fifo mode, it is safer to ensure an even period |
511 | * size. If appearing to an odd number while DMA always starts its | 530 | * size. If appearing to an odd number while DMA always starts its |
@@ -520,7 +539,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, | |||
520 | } | 539 | } |
521 | 540 | ||
522 | /** | 541 | /** |
523 | * fsl_ssi_set_dai_sysclk - configure Digital Audio Interface bit clock | 542 | * fsl_ssi_set_bclk - configure Digital Audio Interface bit clock |
524 | * | 543 | * |
525 | * Note: This function can be only called when using SSI as DAI master | 544 | * Note: This function can be only called when using SSI as DAI master |
526 | * | 545 | * |
@@ -528,20 +547,31 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, | |||
528 | * freq: Output BCLK frequency = samplerate * 32 (fixed) * channels | 547 | * freq: Output BCLK frequency = samplerate * 32 (fixed) * channels |
529 | * dir: SND_SOC_CLOCK_OUT -> TxBCLK, SND_SOC_CLOCK_IN -> RxBCLK. | 548 | * dir: SND_SOC_CLOCK_OUT -> TxBCLK, SND_SOC_CLOCK_IN -> RxBCLK. |
530 | */ | 549 | */ |
531 | static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | 550 | static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, |
532 | int clk_id, unsigned int freq, int dir) | 551 | struct snd_soc_dai *cpu_dai, |
552 | struct snd_pcm_hw_params *hw_params) | ||
533 | { | 553 | { |
534 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | 554 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); |
535 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 555 | struct regmap *regs = ssi_private->regs; |
536 | int synchronous = ssi_private->cpu_dai_drv.symmetric_rates, ret; | 556 | int synchronous = ssi_private->cpu_dai_drv.symmetric_rates, ret; |
537 | u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i; | 557 | u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i; |
538 | unsigned long flags, clkrate, baudrate, tmprate; | 558 | unsigned long clkrate, baudrate, tmprate; |
539 | u64 sub, savesub = 100000; | 559 | u64 sub, savesub = 100000; |
560 | unsigned int freq; | ||
561 | bool baudclk_is_used; | ||
562 | |||
563 | /* Prefer the explicitly set bitclock frequency */ | ||
564 | if (ssi_private->bitclk_freq) | ||
565 | freq = ssi_private->bitclk_freq; | ||
566 | else | ||
567 | freq = params_channels(hw_params) * 32 * params_rate(hw_params); | ||
540 | 568 | ||
541 | /* Don't apply it to any non-baudclk circumstance */ | 569 | /* Don't apply it to any non-baudclk circumstance */ |
542 | if (IS_ERR(ssi_private->baudclk)) | 570 | if (IS_ERR(ssi_private->baudclk)) |
543 | return -EINVAL; | 571 | return -EINVAL; |
544 | 572 | ||
573 | baudclk_is_used = ssi_private->baudclk_streams & ~(BIT(substream->stream)); | ||
574 | |||
545 | /* It should be already enough to divide clock by setting pm alone */ | 575 | /* It should be already enough to divide clock by setting pm alone */ |
546 | psr = 0; | 576 | psr = 0; |
547 | div2 = 0; | 577 | div2 = 0; |
@@ -554,7 +584,11 @@ static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | |||
554 | continue; | 584 | continue; |
555 | 585 | ||
556 | tmprate = freq * factor * (i + 2); | 586 | tmprate = freq * factor * (i + 2); |
557 | clkrate = clk_round_rate(ssi_private->baudclk, tmprate); | 587 | |
588 | if (baudclk_is_used) | ||
589 | clkrate = clk_get_rate(ssi_private->baudclk); | ||
590 | else | ||
591 | clkrate = clk_round_rate(ssi_private->baudclk, tmprate); | ||
558 | 592 | ||
559 | do_div(clkrate, factor); | 593 | do_div(clkrate, factor); |
560 | afreq = (u32)clkrate / (i + 1); | 594 | afreq = (u32)clkrate / (i + 1); |
@@ -594,23 +628,28 @@ static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | |||
594 | mask = CCSR_SSI_SxCCR_PM_MASK | CCSR_SSI_SxCCR_DIV2 | | 628 | mask = CCSR_SSI_SxCCR_PM_MASK | CCSR_SSI_SxCCR_DIV2 | |
595 | CCSR_SSI_SxCCR_PSR; | 629 | CCSR_SSI_SxCCR_PSR; |
596 | 630 | ||
597 | if (dir == SND_SOC_CLOCK_OUT || synchronous) | 631 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || synchronous) |
598 | write_ssi_mask(&ssi->stccr, mask, stccr); | 632 | regmap_update_bits(regs, CCSR_SSI_STCCR, mask, stccr); |
599 | else | 633 | else |
600 | write_ssi_mask(&ssi->srccr, mask, stccr); | 634 | regmap_update_bits(regs, CCSR_SSI_SRCCR, mask, stccr); |
601 | 635 | ||
602 | spin_lock_irqsave(&ssi_private->baudclk_lock, flags); | 636 | if (!baudclk_is_used) { |
603 | if (!ssi_private->baudclk_locked) { | ||
604 | ret = clk_set_rate(ssi_private->baudclk, baudrate); | 637 | ret = clk_set_rate(ssi_private->baudclk, baudrate); |
605 | if (ret) { | 638 | if (ret) { |
606 | spin_unlock_irqrestore(&ssi_private->baudclk_lock, | ||
607 | flags); | ||
608 | dev_err(cpu_dai->dev, "failed to set baudclk rate\n"); | 639 | dev_err(cpu_dai->dev, "failed to set baudclk rate\n"); |
609 | return -EINVAL; | 640 | return -EINVAL; |
610 | } | 641 | } |
611 | ssi_private->baudclk_locked = true; | ||
612 | } | 642 | } |
613 | spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); | 643 | |
644 | return 0; | ||
645 | } | ||
646 | |||
647 | static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | ||
648 | int clk_id, unsigned int freq, int dir) | ||
649 | { | ||
650 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | ||
651 | |||
652 | ssi_private->bitclk_freq = freq; | ||
614 | 653 | ||
615 | return 0; | 654 | return 0; |
616 | } | 655 | } |
@@ -632,12 +671,17 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, | |||
632 | struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai) | 671 | struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai) |
633 | { | 672 | { |
634 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | 673 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); |
635 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 674 | struct regmap *regs = ssi_private->regs; |
636 | unsigned int channels = params_channels(hw_params); | 675 | unsigned int channels = params_channels(hw_params); |
637 | unsigned int sample_size = | 676 | unsigned int sample_size = |
638 | snd_pcm_format_width(params_format(hw_params)); | 677 | snd_pcm_format_width(params_format(hw_params)); |
639 | u32 wl = CCSR_SSI_SxCCR_WL(sample_size); | 678 | u32 wl = CCSR_SSI_SxCCR_WL(sample_size); |
640 | int enabled = read_ssi(&ssi->scr) & CCSR_SSI_SCR_SSIEN; | 679 | int ret; |
680 | u32 scr_val; | ||
681 | int enabled; | ||
682 | |||
683 | regmap_read(regs, CCSR_SSI_SCR, &scr_val); | ||
684 | enabled = scr_val & CCSR_SSI_SCR_SSIEN; | ||
641 | 685 | ||
642 | /* | 686 | /* |
643 | * If we're in synchronous mode, and the SSI is already enabled, | 687 | * If we're in synchronous mode, and the SSI is already enabled, |
@@ -646,6 +690,21 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, | |||
646 | if (enabled && ssi_private->cpu_dai_drv.symmetric_rates) | 690 | if (enabled && ssi_private->cpu_dai_drv.symmetric_rates) |
647 | return 0; | 691 | return 0; |
648 | 692 | ||
693 | if (fsl_ssi_is_i2s_master(ssi_private)) { | ||
694 | ret = fsl_ssi_set_bclk(substream, cpu_dai, hw_params); | ||
695 | if (ret) | ||
696 | return ret; | ||
697 | |||
698 | /* Do not enable the clock if it is already enabled */ | ||
699 | if (!(ssi_private->baudclk_streams & BIT(substream->stream))) { | ||
700 | ret = clk_prepare_enable(ssi_private->baudclk); | ||
701 | if (ret) | ||
702 | return ret; | ||
703 | |||
704 | ssi_private->baudclk_streams |= BIT(substream->stream); | ||
705 | } | ||
706 | } | ||
707 | |||
649 | /* | 708 | /* |
650 | * FIXME: The documentation says that SxCCR[WL] should not be | 709 | * FIXME: The documentation says that SxCCR[WL] should not be |
651 | * modified while the SSI is enabled. The only time this can | 710 | * modified while the SSI is enabled. The only time this can |
@@ -659,40 +718,63 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, | |||
659 | /* In synchronous mode, the SSI uses STCCR for capture */ | 718 | /* In synchronous mode, the SSI uses STCCR for capture */ |
660 | if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) || | 719 | if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) || |
661 | ssi_private->cpu_dai_drv.symmetric_rates) | 720 | ssi_private->cpu_dai_drv.symmetric_rates) |
662 | write_ssi_mask(&ssi->stccr, CCSR_SSI_SxCCR_WL_MASK, wl); | 721 | regmap_update_bits(regs, CCSR_SSI_STCCR, CCSR_SSI_SxCCR_WL_MASK, |
722 | wl); | ||
663 | else | 723 | else |
664 | write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl); | 724 | regmap_update_bits(regs, CCSR_SSI_SRCCR, CCSR_SSI_SxCCR_WL_MASK, |
725 | wl); | ||
665 | 726 | ||
666 | if (!fsl_ssi_is_ac97(ssi_private)) | 727 | if (!fsl_ssi_is_ac97(ssi_private)) |
667 | write_ssi_mask(&ssi->scr, | 728 | regmap_update_bits(regs, CCSR_SSI_SCR, |
668 | CCSR_SSI_SCR_NET | CCSR_SSI_SCR_I2S_MODE_MASK, | 729 | CCSR_SSI_SCR_NET | CCSR_SSI_SCR_I2S_MODE_MASK, |
669 | channels == 1 ? 0 : ssi_private->i2s_mode); | 730 | channels == 1 ? 0 : ssi_private->i2s_mode); |
670 | 731 | ||
671 | return 0; | 732 | return 0; |
672 | } | 733 | } |
673 | 734 | ||
674 | /** | 735 | static int fsl_ssi_hw_free(struct snd_pcm_substream *substream, |
675 | * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format. | 736 | struct snd_soc_dai *cpu_dai) |
676 | */ | ||
677 | static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | ||
678 | { | 737 | { |
679 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | 738 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
680 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 739 | struct fsl_ssi_private *ssi_private = |
740 | snd_soc_dai_get_drvdata(rtd->cpu_dai); | ||
741 | |||
742 | if (fsl_ssi_is_i2s_master(ssi_private) && | ||
743 | ssi_private->baudclk_streams & BIT(substream->stream)) { | ||
744 | clk_disable_unprepare(ssi_private->baudclk); | ||
745 | ssi_private->baudclk_streams &= ~BIT(substream->stream); | ||
746 | } | ||
747 | |||
748 | return 0; | ||
749 | } | ||
750 | |||
751 | static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private, | ||
752 | unsigned int fmt) | ||
753 | { | ||
754 | struct regmap *regs = ssi_private->regs; | ||
681 | u32 strcr = 0, stcr, srcr, scr, mask; | 755 | u32 strcr = 0, stcr, srcr, scr, mask; |
682 | u8 wm; | 756 | u8 wm; |
683 | 757 | ||
684 | ssi_private->dai_fmt = fmt; | 758 | ssi_private->dai_fmt = fmt; |
685 | 759 | ||
760 | if (fsl_ssi_is_i2s_master(ssi_private) && IS_ERR(ssi_private->baudclk)) { | ||
761 | dev_err(&ssi_private->pdev->dev, "baudclk is missing which is necessary for master mode\n"); | ||
762 | return -EINVAL; | ||
763 | } | ||
764 | |||
686 | fsl_ssi_setup_reg_vals(ssi_private); | 765 | fsl_ssi_setup_reg_vals(ssi_private); |
687 | 766 | ||
688 | scr = read_ssi(&ssi->scr) & ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK); | 767 | regmap_read(regs, CCSR_SSI_SCR, &scr); |
768 | scr &= ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK); | ||
689 | scr |= CCSR_SSI_SCR_SYNC_TX_FS; | 769 | scr |= CCSR_SSI_SCR_SYNC_TX_FS; |
690 | 770 | ||
691 | mask = CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR | | 771 | mask = CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR | |
692 | CCSR_SSI_STCR_TSCKP | CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TFSL | | 772 | CCSR_SSI_STCR_TSCKP | CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TFSL | |
693 | CCSR_SSI_STCR_TEFS; | 773 | CCSR_SSI_STCR_TEFS; |
694 | stcr = read_ssi(&ssi->stcr) & ~mask; | 774 | regmap_read(regs, CCSR_SSI_STCR, &stcr); |
695 | srcr = read_ssi(&ssi->srcr) & ~mask; | 775 | regmap_read(regs, CCSR_SSI_SRCR, &srcr); |
776 | stcr &= ~mask; | ||
777 | srcr &= ~mask; | ||
696 | 778 | ||
697 | ssi_private->i2s_mode = CCSR_SSI_SCR_NET; | 779 | ssi_private->i2s_mode = CCSR_SSI_SCR_NET; |
698 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | 780 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
@@ -700,6 +782,12 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | |||
700 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 782 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
701 | case SND_SOC_DAIFMT_CBS_CFS: | 783 | case SND_SOC_DAIFMT_CBS_CFS: |
702 | ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_MASTER; | 784 | ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_MASTER; |
785 | regmap_update_bits(regs, CCSR_SSI_STCCR, | ||
786 | CCSR_SSI_SxCCR_DC_MASK, | ||
787 | CCSR_SSI_SxCCR_DC(2)); | ||
788 | regmap_update_bits(regs, CCSR_SSI_SRCCR, | ||
789 | CCSR_SSI_SxCCR_DC_MASK, | ||
790 | CCSR_SSI_SxCCR_DC(2)); | ||
703 | break; | 791 | break; |
704 | case SND_SOC_DAIFMT_CBM_CFM: | 792 | case SND_SOC_DAIFMT_CBM_CFM: |
705 | ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_SLAVE; | 793 | ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_SLAVE; |
@@ -778,9 +866,9 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | |||
778 | scr |= CCSR_SSI_SCR_SYN; | 866 | scr |= CCSR_SSI_SCR_SYN; |
779 | } | 867 | } |
780 | 868 | ||
781 | write_ssi(stcr, &ssi->stcr); | 869 | regmap_write(regs, CCSR_SSI_STCR, stcr); |
782 | write_ssi(srcr, &ssi->srcr); | 870 | regmap_write(regs, CCSR_SSI_SRCR, srcr); |
783 | write_ssi(scr, &ssi->scr); | 871 | regmap_write(regs, CCSR_SSI_SCR, scr); |
784 | 872 | ||
785 | /* | 873 | /* |
786 | * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't | 874 | * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't |
@@ -798,16 +886,16 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | |||
798 | else | 886 | else |
799 | wm = ssi_private->fifo_depth; | 887 | wm = ssi_private->fifo_depth; |
800 | 888 | ||
801 | write_ssi(CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) | | 889 | regmap_write(regs, CCSR_SSI_SFCSR, |
802 | CCSR_SSI_SFCSR_TFWM1(wm) | CCSR_SSI_SFCSR_RFWM1(wm), | 890 | CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) | |
803 | &ssi->sfcsr); | 891 | CCSR_SSI_SFCSR_TFWM1(wm) | CCSR_SSI_SFCSR_RFWM1(wm)); |
804 | 892 | ||
805 | if (ssi_private->use_dual_fifo) { | 893 | if (ssi_private->use_dual_fifo) { |
806 | write_ssi_mask(&ssi->srcr, CCSR_SSI_SRCR_RFEN1, | 894 | regmap_update_bits(regs, CCSR_SSI_SRCR, CCSR_SSI_SRCR_RFEN1, |
807 | CCSR_SSI_SRCR_RFEN1); | 895 | CCSR_SSI_SRCR_RFEN1); |
808 | write_ssi_mask(&ssi->stcr, CCSR_SSI_STCR_TFEN1, | 896 | regmap_update_bits(regs, CCSR_SSI_STCR, CCSR_SSI_STCR_TFEN1, |
809 | CCSR_SSI_STCR_TFEN1); | 897 | CCSR_SSI_STCR_TFEN1); |
810 | write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TCH_EN, | 898 | regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_TCH_EN, |
811 | CCSR_SSI_SCR_TCH_EN); | 899 | CCSR_SSI_SCR_TCH_EN); |
812 | } | 900 | } |
813 | 901 | ||
@@ -815,6 +903,17 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | |||
815 | fsl_ssi_setup_ac97(ssi_private); | 903 | fsl_ssi_setup_ac97(ssi_private); |
816 | 904 | ||
817 | return 0; | 905 | return 0; |
906 | |||
907 | } | ||
908 | |||
909 | /** | ||
910 | * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format. | ||
911 | */ | ||
912 | static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | ||
913 | { | ||
914 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | ||
915 | |||
916 | return _fsl_ssi_set_dai_fmt(ssi_private, fmt); | ||
818 | } | 917 | } |
819 | 918 | ||
820 | /** | 919 | /** |
@@ -826,31 +925,34 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, | |||
826 | u32 rx_mask, int slots, int slot_width) | 925 | u32 rx_mask, int slots, int slot_width) |
827 | { | 926 | { |
828 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | 927 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); |
829 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 928 | struct regmap *regs = ssi_private->regs; |
830 | u32 val; | 929 | u32 val; |
831 | 930 | ||
832 | /* The slot number should be >= 2 if using Network mode or I2S mode */ | 931 | /* The slot number should be >= 2 if using Network mode or I2S mode */ |
833 | val = read_ssi(&ssi->scr) & (CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_NET); | 932 | regmap_read(regs, CCSR_SSI_SCR, &val); |
933 | val &= CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_NET; | ||
834 | if (val && slots < 2) { | 934 | if (val && slots < 2) { |
835 | dev_err(cpu_dai->dev, "slot number should be >= 2 in I2S or NET\n"); | 935 | dev_err(cpu_dai->dev, "slot number should be >= 2 in I2S or NET\n"); |
836 | return -EINVAL; | 936 | return -EINVAL; |
837 | } | 937 | } |
838 | 938 | ||
839 | write_ssi_mask(&ssi->stccr, CCSR_SSI_SxCCR_DC_MASK, | 939 | regmap_update_bits(regs, CCSR_SSI_STCCR, CCSR_SSI_SxCCR_DC_MASK, |
840 | CCSR_SSI_SxCCR_DC(slots)); | 940 | CCSR_SSI_SxCCR_DC(slots)); |
841 | write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_DC_MASK, | 941 | regmap_update_bits(regs, CCSR_SSI_SRCCR, CCSR_SSI_SxCCR_DC_MASK, |
842 | CCSR_SSI_SxCCR_DC(slots)); | 942 | CCSR_SSI_SxCCR_DC(slots)); |
843 | 943 | ||
844 | /* The register SxMSKs needs SSI to provide essential clock due to | 944 | /* The register SxMSKs needs SSI to provide essential clock due to |
845 | * hardware design. So we here temporarily enable SSI to set them. | 945 | * hardware design. So we here temporarily enable SSI to set them. |
846 | */ | 946 | */ |
847 | val = read_ssi(&ssi->scr) & CCSR_SSI_SCR_SSIEN; | 947 | regmap_read(regs, CCSR_SSI_SCR, &val); |
848 | write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN); | 948 | val &= CCSR_SSI_SCR_SSIEN; |
949 | regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, | ||
950 | CCSR_SSI_SCR_SSIEN); | ||
849 | 951 | ||
850 | write_ssi(tx_mask, &ssi->stmsk); | 952 | regmap_write(regs, CCSR_SSI_STMSK, tx_mask); |
851 | write_ssi(rx_mask, &ssi->srmsk); | 953 | regmap_write(regs, CCSR_SSI_SRMSK, rx_mask); |
852 | 954 | ||
853 | write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, val); | 955 | regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, val); |
854 | 956 | ||
855 | return 0; | 957 | return 0; |
856 | } | 958 | } |
@@ -869,11 +971,11 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, | |||
869 | { | 971 | { |
870 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 972 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
871 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai); | 973 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
872 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 974 | struct regmap *regs = ssi_private->regs; |
873 | unsigned long flags; | ||
874 | 975 | ||
875 | switch (cmd) { | 976 | switch (cmd) { |
876 | case SNDRV_PCM_TRIGGER_START: | 977 | case SNDRV_PCM_TRIGGER_START: |
978 | case SNDRV_PCM_TRIGGER_RESUME: | ||
877 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 979 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
878 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 980 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
879 | fsl_ssi_tx_config(ssi_private, true); | 981 | fsl_ssi_tx_config(ssi_private, true); |
@@ -882,18 +984,12 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, | |||
882 | break; | 984 | break; |
883 | 985 | ||
884 | case SNDRV_PCM_TRIGGER_STOP: | 986 | case SNDRV_PCM_TRIGGER_STOP: |
987 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
885 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 988 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
886 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 989 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
887 | fsl_ssi_tx_config(ssi_private, false); | 990 | fsl_ssi_tx_config(ssi_private, false); |
888 | else | 991 | else |
889 | fsl_ssi_rx_config(ssi_private, false); | 992 | fsl_ssi_rx_config(ssi_private, false); |
890 | |||
891 | if (!fsl_ssi_is_ac97(ssi_private) && (read_ssi(&ssi->scr) & | ||
892 | (CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE)) == 0) { | ||
893 | spin_lock_irqsave(&ssi_private->baudclk_lock, flags); | ||
894 | ssi_private->baudclk_locked = false; | ||
895 | spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); | ||
896 | } | ||
897 | break; | 993 | break; |
898 | 994 | ||
899 | default: | 995 | default: |
@@ -902,9 +998,9 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, | |||
902 | 998 | ||
903 | if (fsl_ssi_is_ac97(ssi_private)) { | 999 | if (fsl_ssi_is_ac97(ssi_private)) { |
904 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 1000 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
905 | write_ssi(CCSR_SSI_SOR_TX_CLR, &ssi->sor); | 1001 | regmap_write(regs, CCSR_SSI_SOR, CCSR_SSI_SOR_TX_CLR); |
906 | else | 1002 | else |
907 | write_ssi(CCSR_SSI_SOR_RX_CLR, &ssi->sor); | 1003 | regmap_write(regs, CCSR_SSI_SOR, CCSR_SSI_SOR_RX_CLR); |
908 | } | 1004 | } |
909 | 1005 | ||
910 | return 0; | 1006 | return 0; |
@@ -914,7 +1010,7 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) | |||
914 | { | 1010 | { |
915 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(dai); | 1011 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(dai); |
916 | 1012 | ||
917 | if (fsl_ssi_on_imx(ssi_private) && ssi_private->use_dma) { | 1013 | if (ssi_private->soc->imx && ssi_private->use_dma) { |
918 | dai->playback_dma_data = &ssi_private->dma_params_tx; | 1014 | dai->playback_dma_data = &ssi_private->dma_params_tx; |
919 | dai->capture_dma_data = &ssi_private->dma_params_rx; | 1015 | dai->capture_dma_data = &ssi_private->dma_params_rx; |
920 | } | 1016 | } |
@@ -925,6 +1021,7 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) | |||
925 | static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { | 1021 | static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { |
926 | .startup = fsl_ssi_startup, | 1022 | .startup = fsl_ssi_startup, |
927 | .hw_params = fsl_ssi_hw_params, | 1023 | .hw_params = fsl_ssi_hw_params, |
1024 | .hw_free = fsl_ssi_hw_free, | ||
928 | .set_fmt = fsl_ssi_set_dai_fmt, | 1025 | .set_fmt = fsl_ssi_set_dai_fmt, |
929 | .set_sysclk = fsl_ssi_set_dai_sysclk, | 1026 | .set_sysclk = fsl_ssi_set_dai_sysclk, |
930 | .set_tdm_slot = fsl_ssi_set_dai_tdm_slot, | 1027 | .set_tdm_slot = fsl_ssi_set_dai_tdm_slot, |
@@ -978,7 +1075,7 @@ static struct fsl_ssi_private *fsl_ac97_data; | |||
978 | static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | 1075 | static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, |
979 | unsigned short val) | 1076 | unsigned short val) |
980 | { | 1077 | { |
981 | struct ccsr_ssi *ssi = fsl_ac97_data->ssi; | 1078 | struct regmap *regs = fsl_ac97_data->regs; |
982 | unsigned int lreg; | 1079 | unsigned int lreg; |
983 | unsigned int lval; | 1080 | unsigned int lval; |
984 | 1081 | ||
@@ -987,12 +1084,12 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | |||
987 | 1084 | ||
988 | 1085 | ||
989 | lreg = reg << 12; | 1086 | lreg = reg << 12; |
990 | write_ssi(lreg, &ssi->sacadd); | 1087 | regmap_write(regs, CCSR_SSI_SACADD, lreg); |
991 | 1088 | ||
992 | lval = val << 4; | 1089 | lval = val << 4; |
993 | write_ssi(lval , &ssi->sacdat); | 1090 | regmap_write(regs, CCSR_SSI_SACDAT, lval); |
994 | 1091 | ||
995 | write_ssi_mask(&ssi->sacnt, CCSR_SSI_SACNT_RDWR_MASK, | 1092 | regmap_update_bits(regs, CCSR_SSI_SACNT, CCSR_SSI_SACNT_RDWR_MASK, |
996 | CCSR_SSI_SACNT_WR); | 1093 | CCSR_SSI_SACNT_WR); |
997 | udelay(100); | 1094 | udelay(100); |
998 | } | 1095 | } |
@@ -1000,19 +1097,21 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | |||
1000 | static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97, | 1097 | static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97, |
1001 | unsigned short reg) | 1098 | unsigned short reg) |
1002 | { | 1099 | { |
1003 | struct ccsr_ssi *ssi = fsl_ac97_data->ssi; | 1100 | struct regmap *regs = fsl_ac97_data->regs; |
1004 | 1101 | ||
1005 | unsigned short val = -1; | 1102 | unsigned short val = -1; |
1103 | u32 reg_val; | ||
1006 | unsigned int lreg; | 1104 | unsigned int lreg; |
1007 | 1105 | ||
1008 | lreg = (reg & 0x7f) << 12; | 1106 | lreg = (reg & 0x7f) << 12; |
1009 | write_ssi(lreg, &ssi->sacadd); | 1107 | regmap_write(regs, CCSR_SSI_SACADD, lreg); |
1010 | write_ssi_mask(&ssi->sacnt, CCSR_SSI_SACNT_RDWR_MASK, | 1108 | regmap_update_bits(regs, CCSR_SSI_SACNT, CCSR_SSI_SACNT_RDWR_MASK, |
1011 | CCSR_SSI_SACNT_RD); | 1109 | CCSR_SSI_SACNT_RD); |
1012 | 1110 | ||
1013 | udelay(100); | 1111 | udelay(100); |
1014 | 1112 | ||
1015 | val = (read_ssi(&ssi->sacdat) >> 4) & 0xffff; | 1113 | regmap_read(regs, CCSR_SSI_SACDAT, ®_val); |
1114 | val = (reg_val >> 4) & 0xffff; | ||
1016 | 1115 | ||
1017 | return val; | 1116 | return val; |
1018 | } | 1117 | } |
@@ -1064,8 +1163,6 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev, | |||
1064 | if (IS_ERR(ssi_private->baudclk)) | 1163 | if (IS_ERR(ssi_private->baudclk)) |
1065 | dev_dbg(&pdev->dev, "could not get baud clock: %ld\n", | 1164 | dev_dbg(&pdev->dev, "could not get baud clock: %ld\n", |
1066 | PTR_ERR(ssi_private->baudclk)); | 1165 | PTR_ERR(ssi_private->baudclk)); |
1067 | else | ||
1068 | clk_prepare_enable(ssi_private->baudclk); | ||
1069 | 1166 | ||
1070 | /* | 1167 | /* |
1071 | * We have burstsize be "fifo_depth - 2" to match the SSI | 1168 | * We have burstsize be "fifo_depth - 2" to match the SSI |
@@ -1073,10 +1170,8 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev, | |||
1073 | */ | 1170 | */ |
1074 | ssi_private->dma_params_tx.maxburst = ssi_private->fifo_depth - 2; | 1171 | ssi_private->dma_params_tx.maxburst = ssi_private->fifo_depth - 2; |
1075 | ssi_private->dma_params_rx.maxburst = ssi_private->fifo_depth - 2; | 1172 | ssi_private->dma_params_rx.maxburst = ssi_private->fifo_depth - 2; |
1076 | ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + | 1173 | ssi_private->dma_params_tx.addr = ssi_private->ssi_phys + CCSR_SSI_STX0; |
1077 | offsetof(struct ccsr_ssi, stx0); | 1174 | ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + CCSR_SSI_SRX0; |
1078 | ssi_private->dma_params_rx.addr = ssi_private->ssi_phys + | ||
1079 | offsetof(struct ccsr_ssi, srx0); | ||
1080 | 1175 | ||
1081 | ret = !of_property_read_u32_array(np, "dmas", dmas, 4); | 1176 | ret = !of_property_read_u32_array(np, "dmas", dmas, 4); |
1082 | if (ssi_private->use_dma && !ret && dmas[2] == IMX_DMATYPE_SSI_DUAL) { | 1177 | if (ssi_private->use_dma && !ret && dmas[2] == IMX_DMATYPE_SSI_DUAL) { |
@@ -1116,9 +1211,6 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev, | |||
1116 | return 0; | 1211 | return 0; |
1117 | 1212 | ||
1118 | error_pcm: | 1213 | error_pcm: |
1119 | if (!IS_ERR(ssi_private->baudclk)) | ||
1120 | clk_disable_unprepare(ssi_private->baudclk); | ||
1121 | |||
1122 | clk_disable_unprepare(ssi_private->clk); | 1214 | clk_disable_unprepare(ssi_private->clk); |
1123 | 1215 | ||
1124 | return ret; | 1216 | return ret; |
@@ -1129,8 +1221,6 @@ static void fsl_ssi_imx_clean(struct platform_device *pdev, | |||
1129 | { | 1221 | { |
1130 | if (!ssi_private->use_dma) | 1222 | if (!ssi_private->use_dma) |
1131 | imx_pcm_fiq_exit(pdev); | 1223 | imx_pcm_fiq_exit(pdev); |
1132 | if (!IS_ERR(ssi_private->baudclk)) | ||
1133 | clk_disable_unprepare(ssi_private->baudclk); | ||
1134 | clk_disable_unprepare(ssi_private->clk); | 1224 | clk_disable_unprepare(ssi_private->clk); |
1135 | } | 1225 | } |
1136 | 1226 | ||
@@ -1140,12 +1230,11 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
1140 | int ret = 0; | 1230 | int ret = 0; |
1141 | struct device_node *np = pdev->dev.of_node; | 1231 | struct device_node *np = pdev->dev.of_node; |
1142 | const struct of_device_id *of_id; | 1232 | const struct of_device_id *of_id; |
1143 | enum fsl_ssi_type hw_type; | ||
1144 | const char *p, *sprop; | 1233 | const char *p, *sprop; |
1145 | const uint32_t *iprop; | 1234 | const uint32_t *iprop; |
1146 | struct resource res; | 1235 | struct resource res; |
1236 | void __iomem *iomem; | ||
1147 | char name[64]; | 1237 | char name[64]; |
1148 | bool ac97 = false; | ||
1149 | 1238 | ||
1150 | /* SSIs that are not connected on the board should have a | 1239 | /* SSIs that are not connected on the board should have a |
1151 | * status = "disabled" | 1240 | * status = "disabled" |
@@ -1155,17 +1244,8 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
1155 | return -ENODEV; | 1244 | return -ENODEV; |
1156 | 1245 | ||
1157 | of_id = of_match_device(fsl_ssi_ids, &pdev->dev); | 1246 | of_id = of_match_device(fsl_ssi_ids, &pdev->dev); |
1158 | if (!of_id) | 1247 | if (!of_id || !of_id->data) |
1159 | return -EINVAL; | ||
1160 | hw_type = (enum fsl_ssi_type) of_id->data; | ||
1161 | |||
1162 | sprop = of_get_property(np, "fsl,mode", NULL); | ||
1163 | if (!sprop) { | ||
1164 | dev_err(&pdev->dev, "fsl,mode property is necessary\n"); | ||
1165 | return -EINVAL; | 1248 | return -EINVAL; |
1166 | } | ||
1167 | if (!strcmp(sprop, "ac97-slave")) | ||
1168 | ac97 = true; | ||
1169 | 1249 | ||
1170 | ssi_private = devm_kzalloc(&pdev->dev, sizeof(*ssi_private), | 1250 | ssi_private = devm_kzalloc(&pdev->dev, sizeof(*ssi_private), |
1171 | GFP_KERNEL); | 1251 | GFP_KERNEL); |
@@ -1174,11 +1254,21 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
1174 | return -ENOMEM; | 1254 | return -ENOMEM; |
1175 | } | 1255 | } |
1176 | 1256 | ||
1257 | ssi_private->soc = of_id->data; | ||
1258 | |||
1259 | sprop = of_get_property(np, "fsl,mode", NULL); | ||
1260 | if (sprop) { | ||
1261 | if (!strcmp(sprop, "ac97-slave")) | ||
1262 | ssi_private->dai_fmt = SND_SOC_DAIFMT_AC97; | ||
1263 | else if (!strcmp(sprop, "i2s-slave")) | ||
1264 | ssi_private->dai_fmt = SND_SOC_DAIFMT_I2S | | ||
1265 | SND_SOC_DAIFMT_CBM_CFM; | ||
1266 | } | ||
1267 | |||
1177 | ssi_private->use_dma = !of_property_read_bool(np, | 1268 | ssi_private->use_dma = !of_property_read_bool(np, |
1178 | "fsl,fiq-stream-filter"); | 1269 | "fsl,fiq-stream-filter"); |
1179 | ssi_private->hw_type = hw_type; | ||
1180 | 1270 | ||
1181 | if (ac97) { | 1271 | if (fsl_ssi_is_ac97(ssi_private)) { |
1182 | memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai, | 1272 | memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai, |
1183 | sizeof(fsl_ssi_ac97_dai)); | 1273 | sizeof(fsl_ssi_ac97_dai)); |
1184 | 1274 | ||
@@ -1198,12 +1288,20 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
1198 | dev_err(&pdev->dev, "could not determine device resources\n"); | 1288 | dev_err(&pdev->dev, "could not determine device resources\n"); |
1199 | return ret; | 1289 | return ret; |
1200 | } | 1290 | } |
1201 | ssi_private->ssi = of_iomap(np, 0); | 1291 | ssi_private->ssi_phys = res.start; |
1202 | if (!ssi_private->ssi) { | 1292 | |
1293 | iomem = devm_ioremap(&pdev->dev, res.start, resource_size(&res)); | ||
1294 | if (!iomem) { | ||
1203 | dev_err(&pdev->dev, "could not map device resources\n"); | 1295 | dev_err(&pdev->dev, "could not map device resources\n"); |
1204 | return -ENOMEM; | 1296 | return -ENOMEM; |
1205 | } | 1297 | } |
1206 | ssi_private->ssi_phys = res.start; | 1298 | |
1299 | ssi_private->regs = devm_regmap_init_mmio(&pdev->dev, iomem, | ||
1300 | &fsl_ssi_regconfig); | ||
1301 | if (IS_ERR(ssi_private->regs)) { | ||
1302 | dev_err(&pdev->dev, "Failed to init register map\n"); | ||
1303 | return PTR_ERR(ssi_private->regs); | ||
1304 | } | ||
1207 | 1305 | ||
1208 | ssi_private->irq = irq_of_parse_and_map(np, 0); | 1306 | ssi_private->irq = irq_of_parse_and_map(np, 0); |
1209 | if (!ssi_private->irq) { | 1307 | if (!ssi_private->irq) { |
@@ -1226,13 +1324,10 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
1226 | /* Older 8610 DTs didn't have the fifo-depth property */ | 1324 | /* Older 8610 DTs didn't have the fifo-depth property */ |
1227 | ssi_private->fifo_depth = 8; | 1325 | ssi_private->fifo_depth = 8; |
1228 | 1326 | ||
1229 | ssi_private->baudclk_locked = false; | ||
1230 | spin_lock_init(&ssi_private->baudclk_lock); | ||
1231 | |||
1232 | dev_set_drvdata(&pdev->dev, ssi_private); | 1327 | dev_set_drvdata(&pdev->dev, ssi_private); |
1233 | 1328 | ||
1234 | if (fsl_ssi_on_imx(ssi_private)) { | 1329 | if (ssi_private->soc->imx) { |
1235 | ret = fsl_ssi_imx_probe(pdev, ssi_private, ssi_private->ssi); | 1330 | ret = fsl_ssi_imx_probe(pdev, ssi_private, iomem); |
1236 | if (ret) | 1331 | if (ret) |
1237 | goto error_irqmap; | 1332 | goto error_irqmap; |
1238 | } | 1333 | } |
@@ -1289,6 +1384,9 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
1289 | } | 1384 | } |
1290 | 1385 | ||
1291 | done: | 1386 | done: |
1387 | if (ssi_private->dai_fmt) | ||
1388 | _fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt); | ||
1389 | |||
1292 | return 0; | 1390 | return 0; |
1293 | 1391 | ||
1294 | error_sound_card: | 1392 | error_sound_card: |
@@ -1298,7 +1396,7 @@ error_irq: | |||
1298 | snd_soc_unregister_component(&pdev->dev); | 1396 | snd_soc_unregister_component(&pdev->dev); |
1299 | 1397 | ||
1300 | error_asoc_register: | 1398 | error_asoc_register: |
1301 | if (fsl_ssi_on_imx(ssi_private)) | 1399 | if (ssi_private->soc->imx) |
1302 | fsl_ssi_imx_clean(pdev, ssi_private); | 1400 | fsl_ssi_imx_clean(pdev, ssi_private); |
1303 | 1401 | ||
1304 | error_irqmap: | 1402 | error_irqmap: |
@@ -1318,7 +1416,7 @@ static int fsl_ssi_remove(struct platform_device *pdev) | |||
1318 | platform_device_unregister(ssi_private->pdev); | 1416 | platform_device_unregister(ssi_private->pdev); |
1319 | snd_soc_unregister_component(&pdev->dev); | 1417 | snd_soc_unregister_component(&pdev->dev); |
1320 | 1418 | ||
1321 | if (fsl_ssi_on_imx(ssi_private)) | 1419 | if (ssi_private->soc->imx) |
1322 | fsl_ssi_imx_clean(pdev, ssi_private); | 1420 | fsl_ssi_imx_clean(pdev, ssi_private); |
1323 | 1421 | ||
1324 | if (ssi_private->use_dma) | 1422 | if (ssi_private->use_dma) |
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h index 71c3e7e4340d..506510540d0a 100644 --- a/sound/soc/fsl/fsl_ssi.h +++ b/sound/soc/fsl/fsl_ssi.h | |||
@@ -12,32 +12,30 @@ | |||
12 | #ifndef _MPC8610_I2S_H | 12 | #ifndef _MPC8610_I2S_H |
13 | #define _MPC8610_I2S_H | 13 | #define _MPC8610_I2S_H |
14 | 14 | ||
15 | /* SSI Register Map */ | 15 | /* SSI registers */ |
16 | struct ccsr_ssi { | 16 | #define CCSR_SSI_STX0 0x00 |
17 | __be32 stx0; /* 0x.0000 - SSI Transmit Data Register 0 */ | 17 | #define CCSR_SSI_STX1 0x04 |
18 | __be32 stx1; /* 0x.0004 - SSI Transmit Data Register 1 */ | 18 | #define CCSR_SSI_SRX0 0x08 |
19 | __be32 srx0; /* 0x.0008 - SSI Receive Data Register 0 */ | 19 | #define CCSR_SSI_SRX1 0x0c |
20 | __be32 srx1; /* 0x.000C - SSI Receive Data Register 1 */ | 20 | #define CCSR_SSI_SCR 0x10 |
21 | __be32 scr; /* 0x.0010 - SSI Control Register */ | 21 | #define CCSR_SSI_SISR 0x14 |
22 | __be32 sisr; /* 0x.0014 - SSI Interrupt Status Register Mixed */ | 22 | #define CCSR_SSI_SIER 0x18 |
23 | __be32 sier; /* 0x.0018 - SSI Interrupt Enable Register */ | 23 | #define CCSR_SSI_STCR 0x1c |
24 | __be32 stcr; /* 0x.001C - SSI Transmit Configuration Register */ | 24 | #define CCSR_SSI_SRCR 0x20 |
25 | __be32 srcr; /* 0x.0020 - SSI Receive Configuration Register */ | 25 | #define CCSR_SSI_STCCR 0x24 |
26 | __be32 stccr; /* 0x.0024 - SSI Transmit Clock Control Register */ | 26 | #define CCSR_SSI_SRCCR 0x28 |
27 | __be32 srccr; /* 0x.0028 - SSI Receive Clock Control Register */ | 27 | #define CCSR_SSI_SFCSR 0x2c |
28 | __be32 sfcsr; /* 0x.002C - SSI FIFO Control/Status Register */ | 28 | #define CCSR_SSI_STR 0x30 |
29 | __be32 str; /* 0x.0030 - SSI Test Register */ | 29 | #define CCSR_SSI_SOR 0x34 |
30 | __be32 sor; /* 0x.0034 - SSI Option Register */ | 30 | #define CCSR_SSI_SACNT 0x38 |
31 | __be32 sacnt; /* 0x.0038 - SSI AC97 Control Register */ | 31 | #define CCSR_SSI_SACADD 0x3c |
32 | __be32 sacadd; /* 0x.003C - SSI AC97 Command Address Register */ | 32 | #define CCSR_SSI_SACDAT 0x40 |
33 | __be32 sacdat; /* 0x.0040 - SSI AC97 Command Data Register */ | 33 | #define CCSR_SSI_SATAG 0x44 |
34 | __be32 satag; /* 0x.0044 - SSI AC97 Tag Register */ | 34 | #define CCSR_SSI_STMSK 0x48 |
35 | __be32 stmsk; /* 0x.0048 - SSI Transmit Time Slot Mask Register */ | 35 | #define CCSR_SSI_SRMSK 0x4c |
36 | __be32 srmsk; /* 0x.004C - SSI Receive Time Slot Mask Register */ | 36 | #define CCSR_SSI_SACCST 0x50 |
37 | __be32 saccst; /* 0x.0050 - SSI AC97 Channel Status Register */ | 37 | #define CCSR_SSI_SACCEN 0x54 |
38 | __be32 saccen; /* 0x.0054 - SSI AC97 Channel Enable Register */ | 38 | #define CCSR_SSI_SACCDIS 0x58 |
39 | __be32 saccdis; /* 0x.0058 - SSI AC97 Channel Disable Register */ | ||
40 | }; | ||
41 | 39 | ||
42 | #define CCSR_SSI_SCR_SYNC_TX_FS 0x00001000 | 40 | #define CCSR_SSI_SCR_SYNC_TX_FS 0x00001000 |
43 | #define CCSR_SSI_SCR_RFR_CLK_DIS 0x00000800 | 41 | #define CCSR_SSI_SCR_RFR_CLK_DIS 0x00000800 |
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 98f97e543c29..03a7fdcdf114 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
@@ -24,9 +24,32 @@ struct simple_card_data { | |||
24 | struct asoc_simple_dai cpu_dai; | 24 | struct asoc_simple_dai cpu_dai; |
25 | struct asoc_simple_dai codec_dai; | 25 | struct asoc_simple_dai codec_dai; |
26 | } *dai_props; | 26 | } *dai_props; |
27 | unsigned int mclk_fs; | ||
27 | struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ | 28 | struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ |
28 | }; | 29 | }; |
29 | 30 | ||
31 | static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, | ||
32 | struct snd_pcm_hw_params *params) | ||
33 | { | ||
34 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
35 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
36 | struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); | ||
37 | unsigned int mclk; | ||
38 | int ret = 0; | ||
39 | |||
40 | if (priv->mclk_fs) { | ||
41 | mclk = params_rate(params) * priv->mclk_fs; | ||
42 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, | ||
43 | SND_SOC_CLOCK_IN); | ||
44 | } | ||
45 | |||
46 | return ret; | ||
47 | } | ||
48 | |||
49 | static struct snd_soc_ops asoc_simple_card_ops = { | ||
50 | .hw_params = asoc_simple_card_hw_params, | ||
51 | }; | ||
52 | |||
30 | static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, | 53 | static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, |
31 | struct asoc_simple_dai *set) | 54 | struct asoc_simple_dai *set) |
32 | { | 55 | { |
@@ -144,7 +167,8 @@ asoc_simple_card_sub_parse_of(struct device_node *np, | |||
144 | static int simple_card_dai_link_of(struct device_node *node, | 167 | static int simple_card_dai_link_of(struct device_node *node, |
145 | struct device *dev, | 168 | struct device *dev, |
146 | struct snd_soc_dai_link *dai_link, | 169 | struct snd_soc_dai_link *dai_link, |
147 | struct simple_dai_props *dai_props) | 170 | struct simple_dai_props *dai_props, |
171 | bool is_top_level_node) | ||
148 | { | 172 | { |
149 | struct device_node *np = NULL; | 173 | struct device_node *np = NULL; |
150 | struct device_node *bitclkmaster = NULL; | 174 | struct device_node *bitclkmaster = NULL; |
@@ -155,7 +179,8 @@ static int simple_card_dai_link_of(struct device_node *node, | |||
155 | char *prefix = ""; | 179 | char *prefix = ""; |
156 | int ret; | 180 | int ret; |
157 | 181 | ||
158 | prefix = "simple-audio-card,"; | 182 | if (is_top_level_node) |
183 | prefix = "simple-audio-card,"; | ||
159 | 184 | ||
160 | daifmt = snd_soc_of_parse_daifmt(node, prefix, | 185 | daifmt = snd_soc_of_parse_daifmt(node, prefix, |
161 | &bitclkmaster, &framemaster); | 186 | &bitclkmaster, &framemaster); |
@@ -249,6 +274,7 @@ static int simple_card_dai_link_of(struct device_node *node, | |||
249 | sprintf(name, "%s-%s", dai_link->cpu_dai_name, | 274 | sprintf(name, "%s-%s", dai_link->cpu_dai_name, |
250 | dai_link->codec_dai_name); | 275 | dai_link->codec_dai_name); |
251 | dai_link->name = dai_link->stream_name = name; | 276 | dai_link->name = dai_link->stream_name = name; |
277 | dai_link->ops = &asoc_simple_card_ops; | ||
252 | 278 | ||
253 | dev_dbg(dev, "\tname : %s\n", dai_link->stream_name); | 279 | dev_dbg(dev, "\tname : %s\n", dai_link->stream_name); |
254 | dev_dbg(dev, "\tcpu : %s / %04x / %d\n", | 280 | dev_dbg(dev, "\tcpu : %s / %04x / %d\n", |
@@ -298,6 +324,10 @@ static int asoc_simple_card_parse_of(struct device_node *node, | |||
298 | return ret; | 324 | return ret; |
299 | } | 325 | } |
300 | 326 | ||
327 | /* Factor to mclk, used in hw_params() */ | ||
328 | of_property_read_u32(node, "simple-audio-card,mclk-fs", | ||
329 | &priv->mclk_fs); | ||
330 | |||
301 | dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ? | 331 | dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ? |
302 | priv->snd_card.name : ""); | 332 | priv->snd_card.name : ""); |
303 | 333 | ||
@@ -307,14 +337,15 @@ static int asoc_simple_card_parse_of(struct device_node *node, | |||
307 | for (i = 0; (np = of_get_next_child(node, np)); i++) { | 337 | for (i = 0; (np = of_get_next_child(node, np)); i++) { |
308 | dev_dbg(dev, "\tlink %d:\n", i); | 338 | dev_dbg(dev, "\tlink %d:\n", i); |
309 | ret = simple_card_dai_link_of(np, dev, dai_link + i, | 339 | ret = simple_card_dai_link_of(np, dev, dai_link + i, |
310 | dai_props + i); | 340 | dai_props + i, false); |
311 | if (ret < 0) { | 341 | if (ret < 0) { |
312 | of_node_put(np); | 342 | of_node_put(np); |
313 | return ret; | 343 | return ret; |
314 | } | 344 | } |
315 | } | 345 | } |
316 | } else { | 346 | } else { |
317 | ret = simple_card_dai_link_of(node, dev, dai_link, dai_props); | 347 | ret = simple_card_dai_link_of(node, dev, dai_link, dai_props, |
348 | true); | ||
318 | if (ret < 0) | 349 | if (ret < 0) |
319 | return ret; | 350 | return ret; |
320 | } | 351 | } |
diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig index 3c81b3891209..c30fedb3e149 100644 --- a/sound/soc/intel/Kconfig +++ b/sound/soc/intel/Kconfig | |||
@@ -49,3 +49,12 @@ config SND_SOC_INTEL_BYT_RT5640_MACH | |||
49 | help | 49 | help |
50 | This adds audio driver for Intel Baytrail platform based boards | 50 | This adds audio driver for Intel Baytrail platform based boards |
51 | with the RT5640 audio codec. | 51 | with the RT5640 audio codec. |
52 | |||
53 | config SND_SOC_INTEL_BYT_MAX98090_MACH | ||
54 | tristate "ASoC Audio driver for Intel Baytrail with MAX98090 codec" | ||
55 | depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C | ||
56 | select SND_SOC_INTEL_BAYTRAIL | ||
57 | select SND_SOC_MAX98090 | ||
58 | help | ||
59 | This adds audio driver for Intel Baytrail platform based boards | ||
60 | with the MAX98090 audio codec. | ||
diff --git a/sound/soc/intel/Makefile b/sound/soc/intel/Makefile index 0db4e2f336dc..4bfca79a42ba 100644 --- a/sound/soc/intel/Makefile +++ b/sound/soc/intel/Makefile | |||
@@ -23,6 +23,8 @@ obj-$(CONFIG_SND_SOC_INTEL_BAYTRAIL) += snd-soc-sst-baytrail-pcm.o | |||
23 | # Machine support | 23 | # Machine support |
24 | snd-soc-sst-haswell-objs := haswell.o | 24 | snd-soc-sst-haswell-objs := haswell.o |
25 | snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o | 25 | snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o |
26 | snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o | ||
26 | 27 | ||
27 | obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o | 28 | obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o |
28 | obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o | 29 | obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o |
30 | obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o | ||
diff --git a/sound/soc/intel/byt-max98090.c b/sound/soc/intel/byt-max98090.c new file mode 100644 index 000000000000..5fc98c64a3f4 --- /dev/null +++ b/sound/soc/intel/byt-max98090.c | |||
@@ -0,0 +1,203 @@ | |||
1 | /* | ||
2 | * Intel Baytrail SST MAX98090 machine driver | ||
3 | * Copyright (c) 2014, Intel Corporation. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | */ | ||
14 | |||
15 | #include <linux/init.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/acpi.h> | ||
19 | #include <linux/device.h> | ||
20 | #include <linux/gpio.h> | ||
21 | #include <linux/gpio/consumer.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <sound/pcm.h> | ||
24 | #include <sound/pcm_params.h> | ||
25 | #include <sound/soc.h> | ||
26 | #include <sound/jack.h> | ||
27 | #include "../codecs/max98090.h" | ||
28 | |||
29 | struct byt_max98090_private { | ||
30 | struct snd_soc_jack jack; | ||
31 | }; | ||
32 | |||
33 | static const struct snd_soc_dapm_widget byt_max98090_widgets[] = { | ||
34 | SND_SOC_DAPM_HP("Headphone", NULL), | ||
35 | SND_SOC_DAPM_MIC("Headset Mic", NULL), | ||
36 | SND_SOC_DAPM_MIC("Int Mic", NULL), | ||
37 | SND_SOC_DAPM_SPK("Ext Spk", NULL), | ||
38 | }; | ||
39 | |||
40 | static const struct snd_soc_dapm_route byt_max98090_audio_map[] = { | ||
41 | {"IN34", NULL, "Headset Mic"}, | ||
42 | {"IN34", NULL, "MICBIAS"}, | ||
43 | {"MICBIAS", NULL, "Headset Mic"}, | ||
44 | {"DMICL", NULL, "Int Mic"}, | ||
45 | {"Headphone", NULL, "HPL"}, | ||
46 | {"Headphone", NULL, "HPR"}, | ||
47 | {"Ext Spk", NULL, "SPKL"}, | ||
48 | {"Ext Spk", NULL, "SPKR"}, | ||
49 | }; | ||
50 | |||
51 | static const struct snd_kcontrol_new byt_max98090_controls[] = { | ||
52 | SOC_DAPM_PIN_SWITCH("Headphone"), | ||
53 | SOC_DAPM_PIN_SWITCH("Headset Mic"), | ||
54 | SOC_DAPM_PIN_SWITCH("Int Mic"), | ||
55 | SOC_DAPM_PIN_SWITCH("Ext Spk"), | ||
56 | }; | ||
57 | |||
58 | static struct snd_soc_jack_pin hs_jack_pins[] = { | ||
59 | { | ||
60 | .pin = "Headphone", | ||
61 | .mask = SND_JACK_HEADPHONE, | ||
62 | }, | ||
63 | { | ||
64 | .pin = "Headset Mic", | ||
65 | .mask = SND_JACK_MICROPHONE, | ||
66 | }, | ||
67 | { | ||
68 | .pin = "Ext Spk", | ||
69 | .mask = SND_JACK_LINEOUT, | ||
70 | }, | ||
71 | { | ||
72 | .pin = "Int Mic", | ||
73 | .mask = SND_JACK_LINEIN, | ||
74 | }, | ||
75 | }; | ||
76 | |||
77 | static struct snd_soc_jack_gpio hs_jack_gpios[] = { | ||
78 | { | ||
79 | .name = "hp-gpio", | ||
80 | .idx = 0, | ||
81 | .report = SND_JACK_HEADPHONE | SND_JACK_LINEOUT, | ||
82 | .debounce_time = 200, | ||
83 | }, | ||
84 | { | ||
85 | .name = "mic-gpio", | ||
86 | .idx = 1, | ||
87 | .report = SND_JACK_MICROPHONE | SND_JACK_LINEIN, | ||
88 | .debounce_time = 200, | ||
89 | }, | ||
90 | }; | ||
91 | |||
92 | static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime) | ||
93 | { | ||
94 | int ret; | ||
95 | struct snd_soc_codec *codec = runtime->codec; | ||
96 | struct snd_soc_card *card = runtime->card; | ||
97 | struct byt_max98090_private *drv = snd_soc_card_get_drvdata(card); | ||
98 | struct snd_soc_jack *jack = &drv->jack; | ||
99 | |||
100 | card->dapm.idle_bias_off = true; | ||
101 | |||
102 | ret = snd_soc_dai_set_sysclk(runtime->codec_dai, | ||
103 | M98090_REG_SYSTEM_CLOCK, | ||
104 | 25000000, SND_SOC_CLOCK_IN); | ||
105 | if (ret < 0) { | ||
106 | dev_err(card->dev, "Can't set codec clock %d\n", ret); | ||
107 | return ret; | ||
108 | } | ||
109 | |||
110 | /* Enable jack detection */ | ||
111 | ret = snd_soc_jack_new(codec, "Headphone", SND_JACK_HEADPHONE, jack); | ||
112 | if (ret) | ||
113 | return ret; | ||
114 | |||
115 | ret = snd_soc_jack_add_pins(jack, ARRAY_SIZE(hs_jack_pins), | ||
116 | hs_jack_pins); | ||
117 | if (ret) | ||
118 | return ret; | ||
119 | |||
120 | ret = snd_soc_jack_add_gpiods(card->dev->parent, jack, | ||
121 | ARRAY_SIZE(hs_jack_gpios), | ||
122 | hs_jack_gpios); | ||
123 | if (ret) | ||
124 | return ret; | ||
125 | |||
126 | return max98090_mic_detect(codec, jack); | ||
127 | } | ||
128 | |||
129 | static struct snd_soc_dai_link byt_max98090_dais[] = { | ||
130 | { | ||
131 | .name = "Baytrail Audio", | ||
132 | .stream_name = "Audio", | ||
133 | .cpu_dai_name = "baytrail-pcm-audio", | ||
134 | .codec_dai_name = "HiFi", | ||
135 | .codec_name = "i2c-193C9890:00", | ||
136 | .platform_name = "baytrail-pcm-audio", | ||
137 | .init = byt_max98090_init, | ||
138 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
139 | SND_SOC_DAIFMT_CBS_CFS, | ||
140 | }, | ||
141 | }; | ||
142 | |||
143 | static struct snd_soc_card byt_max98090_card = { | ||
144 | .name = "byt-max98090", | ||
145 | .dai_link = byt_max98090_dais, | ||
146 | .num_links = ARRAY_SIZE(byt_max98090_dais), | ||
147 | .dapm_widgets = byt_max98090_widgets, | ||
148 | .num_dapm_widgets = ARRAY_SIZE(byt_max98090_widgets), | ||
149 | .dapm_routes = byt_max98090_audio_map, | ||
150 | .num_dapm_routes = ARRAY_SIZE(byt_max98090_audio_map), | ||
151 | .controls = byt_max98090_controls, | ||
152 | .num_controls = ARRAY_SIZE(byt_max98090_controls), | ||
153 | }; | ||
154 | |||
155 | static int byt_max98090_probe(struct platform_device *pdev) | ||
156 | { | ||
157 | int ret_val = 0; | ||
158 | struct byt_max98090_private *priv; | ||
159 | |||
160 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC); | ||
161 | if (!priv) { | ||
162 | dev_err(&pdev->dev, "allocation failed\n"); | ||
163 | return -ENOMEM; | ||
164 | } | ||
165 | |||
166 | byt_max98090_card.dev = &pdev->dev; | ||
167 | snd_soc_card_set_drvdata(&byt_max98090_card, priv); | ||
168 | ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_max98090_card); | ||
169 | if (ret_val) { | ||
170 | dev_err(&pdev->dev, | ||
171 | "snd_soc_register_card failed %d\n", ret_val); | ||
172 | return ret_val; | ||
173 | } | ||
174 | |||
175 | return ret_val; | ||
176 | } | ||
177 | |||
178 | static int byt_max98090_remove(struct platform_device *pdev) | ||
179 | { | ||
180 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
181 | struct byt_max98090_private *priv = snd_soc_card_get_drvdata(card); | ||
182 | |||
183 | snd_soc_jack_free_gpios(&priv->jack, ARRAY_SIZE(hs_jack_gpios), | ||
184 | hs_jack_gpios); | ||
185 | |||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | static struct platform_driver byt_max98090_driver = { | ||
190 | .probe = byt_max98090_probe, | ||
191 | .remove = byt_max98090_remove, | ||
192 | .driver = { | ||
193 | .name = "byt-max98090", | ||
194 | .owner = THIS_MODULE, | ||
195 | .pm = &snd_soc_pm_ops, | ||
196 | }, | ||
197 | }; | ||
198 | module_platform_driver(byt_max98090_driver) | ||
199 | |||
200 | MODULE_DESCRIPTION("ASoC Intel(R) Baytrail Machine driver"); | ||
201 | MODULE_AUTHOR("Omair Md Abdullah, Jarkko Nikula"); | ||
202 | MODULE_LICENSE("GPL v2"); | ||
203 | MODULE_ALIAS("platform:byt-max98090"); | ||
diff --git a/sound/soc/intel/byt-rt5640.c b/sound/soc/intel/byt-rt5640.c index 5535c3fb7922..53d160d39972 100644 --- a/sound/soc/intel/byt-rt5640.c +++ b/sound/soc/intel/byt-rt5640.c | |||
@@ -132,43 +132,20 @@ static struct snd_soc_card byt_rt5640_card = { | |||
132 | .num_dapm_routes = ARRAY_SIZE(byt_rt5640_audio_map), | 132 | .num_dapm_routes = ARRAY_SIZE(byt_rt5640_audio_map), |
133 | }; | 133 | }; |
134 | 134 | ||
135 | #ifdef CONFIG_PM_SLEEP | ||
136 | static const struct dev_pm_ops byt_rt5640_pm_ops = { | ||
137 | .suspend = snd_soc_suspend, | ||
138 | .resume = snd_soc_resume, | ||
139 | }; | ||
140 | |||
141 | #define BYT_RT5640_PM_OPS (&byt_rt5640_pm_ops) | ||
142 | #else | ||
143 | #define BYT_RT5640_PM_OPS NULL | ||
144 | #endif | ||
145 | |||
146 | static int byt_rt5640_probe(struct platform_device *pdev) | 135 | static int byt_rt5640_probe(struct platform_device *pdev) |
147 | { | 136 | { |
148 | struct snd_soc_card *card = &byt_rt5640_card; | 137 | struct snd_soc_card *card = &byt_rt5640_card; |
149 | struct device *dev = &pdev->dev; | ||
150 | 138 | ||
151 | card->dev = &pdev->dev; | 139 | card->dev = &pdev->dev; |
152 | dev_set_drvdata(dev, card); | 140 | return devm_snd_soc_register_card(&pdev->dev, card); |
153 | return snd_soc_register_card(card); | ||
154 | } | ||
155 | |||
156 | static int byt_rt5640_remove(struct platform_device *pdev) | ||
157 | { | ||
158 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
159 | |||
160 | snd_soc_unregister_card(card); | ||
161 | |||
162 | return 0; | ||
163 | } | 141 | } |
164 | 142 | ||
165 | static struct platform_driver byt_rt5640_audio = { | 143 | static struct platform_driver byt_rt5640_audio = { |
166 | .probe = byt_rt5640_probe, | 144 | .probe = byt_rt5640_probe, |
167 | .remove = byt_rt5640_remove, | ||
168 | .driver = { | 145 | .driver = { |
169 | .name = "byt-rt5640", | 146 | .name = "byt-rt5640", |
170 | .owner = THIS_MODULE, | 147 | .owner = THIS_MODULE, |
171 | .pm = BYT_RT5640_PM_OPS, | 148 | .pm = &snd_soc_pm_ops, |
172 | }, | 149 | }, |
173 | }; | 150 | }; |
174 | module_platform_driver(byt_rt5640_audio) | 151 | module_platform_driver(byt_rt5640_audio) |
diff --git a/sound/soc/intel/haswell.c b/sound/soc/intel/haswell.c index 94c2c33ffe49..3981982674ac 100644 --- a/sound/soc/intel/haswell.c +++ b/sound/soc/intel/haswell.c | |||
@@ -202,18 +202,11 @@ static int haswell_audio_probe(struct platform_device *pdev) | |||
202 | { | 202 | { |
203 | haswell_rt5640.dev = &pdev->dev; | 203 | haswell_rt5640.dev = &pdev->dev; |
204 | 204 | ||
205 | return snd_soc_register_card(&haswell_rt5640); | 205 | return devm_snd_soc_register_card(&pdev->dev, &haswell_rt5640); |
206 | } | ||
207 | |||
208 | static int haswell_audio_remove(struct platform_device *pdev) | ||
209 | { | ||
210 | snd_soc_unregister_card(&haswell_rt5640); | ||
211 | return 0; | ||
212 | } | 206 | } |
213 | 207 | ||
214 | static struct platform_driver haswell_audio = { | 208 | static struct platform_driver haswell_audio = { |
215 | .probe = haswell_audio_probe, | 209 | .probe = haswell_audio_probe, |
216 | .remove = haswell_audio_remove, | ||
217 | .driver = { | 210 | .driver = { |
218 | .name = "haswell-audio", | 211 | .name = "haswell-audio", |
219 | .owner = THIS_MODULE, | 212 | .owner = THIS_MODULE, |
diff --git a/sound/soc/intel/sst-acpi.c b/sound/soc/intel/sst-acpi.c index 18aee77f8d4a..42edc6f4fc4a 100644 --- a/sound/soc/intel/sst-acpi.c +++ b/sound/soc/intel/sst-acpi.c | |||
@@ -247,6 +247,7 @@ static struct sst_acpi_desc sst_acpi_broadwell_desc = { | |||
247 | 247 | ||
248 | static struct sst_acpi_mach baytrail_machines[] = { | 248 | static struct sst_acpi_mach baytrail_machines[] = { |
249 | { "10EC5640", "byt-rt5640", "intel/fw_sst_0f28.bin-i2s_master" }, | 249 | { "10EC5640", "byt-rt5640", "intel/fw_sst_0f28.bin-i2s_master" }, |
250 | { "193C9890", "byt-max98090", "intel/fw_sst_0f28.bin-i2s_master" }, | ||
250 | {} | 251 | {} |
251 | }; | 252 | }; |
252 | 253 | ||
diff --git a/sound/soc/intel/sst-baytrail-ipc.c b/sound/soc/intel/sst-baytrail-ipc.c index 7c1ec003d55d..d207b22ea330 100644 --- a/sound/soc/intel/sst-baytrail-ipc.c +++ b/sound/soc/intel/sst-baytrail-ipc.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/export.h> | 22 | #include <linux/export.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/list.h> | ||
26 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
27 | #include <linux/kthread.h> | 26 | #include <linux/kthread.h> |
28 | #include <linux/firmware.h> | 27 | #include <linux/firmware.h> |
@@ -892,7 +891,7 @@ int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata) | |||
892 | /* start the IPC message thread */ | 891 | /* start the IPC message thread */ |
893 | init_kthread_worker(&byt->kworker); | 892 | init_kthread_worker(&byt->kworker); |
894 | byt->tx_thread = kthread_run(kthread_worker_fn, | 893 | byt->tx_thread = kthread_run(kthread_worker_fn, |
895 | &byt->kworker, | 894 | &byt->kworker, "%s", |
896 | dev_name(byt->dev)); | 895 | dev_name(byt->dev)); |
897 | if (IS_ERR(byt->tx_thread)) { | 896 | if (IS_ERR(byt->tx_thread)) { |
898 | err = PTR_ERR(byt->tx_thread); | 897 | err = PTR_ERR(byt->tx_thread); |
@@ -907,7 +906,7 @@ int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata) | |||
907 | byt->dsp = sst_dsp_new(dev, &byt_dev, pdata); | 906 | byt->dsp = sst_dsp_new(dev, &byt_dev, pdata); |
908 | if (byt->dsp == NULL) { | 907 | if (byt->dsp == NULL) { |
909 | err = -ENODEV; | 908 | err = -ENODEV; |
910 | goto err_free_msg; | 909 | goto dsp_err; |
911 | } | 910 | } |
912 | 911 | ||
913 | /* keep the DSP in reset state for base FW loading */ | 912 | /* keep the DSP in reset state for base FW loading */ |
@@ -940,6 +939,8 @@ boot_err: | |||
940 | sst_fw_free(byt_sst_fw); | 939 | sst_fw_free(byt_sst_fw); |
941 | fw_err: | 940 | fw_err: |
942 | sst_dsp_free(byt->dsp); | 941 | sst_dsp_free(byt->dsp); |
942 | dsp_err: | ||
943 | kthread_stop(byt->tx_thread); | ||
943 | err_free_msg: | 944 | err_free_msg: |
944 | kfree(byt->msg); | 945 | kfree(byt->msg); |
945 | 946 | ||
@@ -954,6 +955,7 @@ void sst_byt_dsp_free(struct device *dev, struct sst_pdata *pdata) | |||
954 | sst_dsp_reset(byt->dsp); | 955 | sst_dsp_reset(byt->dsp); |
955 | sst_fw_free_all(byt->dsp); | 956 | sst_fw_free_all(byt->dsp); |
956 | sst_dsp_free(byt->dsp); | 957 | sst_dsp_free(byt->dsp); |
958 | kthread_stop(byt->tx_thread); | ||
957 | kfree(byt->msg); | 959 | kfree(byt->msg); |
958 | } | 960 | } |
959 | EXPORT_SYMBOL_GPL(sst_byt_dsp_free); | 961 | EXPORT_SYMBOL_GPL(sst_byt_dsp_free); |
diff --git a/sound/soc/intel/sst-baytrail-pcm.c b/sound/soc/intel/sst-baytrail-pcm.c index 3af38576e91e..8eab97368ea7 100644 --- a/sound/soc/intel/sst-baytrail-pcm.c +++ b/sound/soc/intel/sst-baytrail-pcm.c | |||
@@ -180,6 +180,7 @@ static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
180 | 180 | ||
181 | switch (cmd) { | 181 | switch (cmd) { |
182 | case SNDRV_PCM_TRIGGER_START: | 182 | case SNDRV_PCM_TRIGGER_START: |
183 | pcm_data->hw_ptr = 0; | ||
183 | sst_byt_stream_start(byt, pcm_data->stream, 0); | 184 | sst_byt_stream_start(byt, pcm_data->stream, 0); |
184 | break; | 185 | break; |
185 | case SNDRV_PCM_TRIGGER_RESUME: | 186 | case SNDRV_PCM_TRIGGER_RESUME: |
diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c index e7996b39a484..434236343ddf 100644 --- a/sound/soc/intel/sst-haswell-ipc.c +++ b/sound/soc/intel/sst-haswell-ipc.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/sched.h> | 27 | #include <linux/sched.h> |
28 | #include <linux/list.h> | ||
29 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
30 | #include <linux/kthread.h> | 29 | #include <linux/kthread.h> |
31 | #include <linux/firmware.h> | 30 | #include <linux/firmware.h> |
@@ -1730,17 +1729,17 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata) | |||
1730 | 1729 | ||
1731 | ret = msg_empty_list_init(hsw); | 1730 | ret = msg_empty_list_init(hsw); |
1732 | if (ret < 0) | 1731 | if (ret < 0) |
1733 | goto list_err; | 1732 | return -ENOMEM; |
1734 | 1733 | ||
1735 | /* start the IPC message thread */ | 1734 | /* start the IPC message thread */ |
1736 | init_kthread_worker(&hsw->kworker); | 1735 | init_kthread_worker(&hsw->kworker); |
1737 | hsw->tx_thread = kthread_run(kthread_worker_fn, | 1736 | hsw->tx_thread = kthread_run(kthread_worker_fn, |
1738 | &hsw->kworker, | 1737 | &hsw->kworker, "%s", |
1739 | dev_name(hsw->dev)); | 1738 | dev_name(hsw->dev)); |
1740 | if (IS_ERR(hsw->tx_thread)) { | 1739 | if (IS_ERR(hsw->tx_thread)) { |
1741 | ret = PTR_ERR(hsw->tx_thread); | 1740 | ret = PTR_ERR(hsw->tx_thread); |
1742 | dev_err(hsw->dev, "error: failed to create message TX task\n"); | 1741 | dev_err(hsw->dev, "error: failed to create message TX task\n"); |
1743 | goto list_err; | 1742 | goto err_free_msg; |
1744 | } | 1743 | } |
1745 | init_kthread_work(&hsw->kwork, ipc_tx_msgs); | 1744 | init_kthread_work(&hsw->kwork, ipc_tx_msgs); |
1746 | 1745 | ||
@@ -1750,7 +1749,7 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata) | |||
1750 | hsw->dsp = sst_dsp_new(dev, &hsw_dev, pdata); | 1749 | hsw->dsp = sst_dsp_new(dev, &hsw_dev, pdata); |
1751 | if (hsw->dsp == NULL) { | 1750 | if (hsw->dsp == NULL) { |
1752 | ret = -ENODEV; | 1751 | ret = -ENODEV; |
1753 | goto list_err; | 1752 | goto dsp_err; |
1754 | } | 1753 | } |
1755 | 1754 | ||
1756 | /* keep the DSP in reset state for base FW loading */ | 1755 | /* keep the DSP in reset state for base FW loading */ |
@@ -1794,8 +1793,11 @@ boot_err: | |||
1794 | sst_fw_free(hsw_sst_fw); | 1793 | sst_fw_free(hsw_sst_fw); |
1795 | fw_err: | 1794 | fw_err: |
1796 | sst_dsp_free(hsw->dsp); | 1795 | sst_dsp_free(hsw->dsp); |
1796 | dsp_err: | ||
1797 | kthread_stop(hsw->tx_thread); | ||
1798 | err_free_msg: | ||
1797 | kfree(hsw->msg); | 1799 | kfree(hsw->msg); |
1798 | list_err: | 1800 | |
1799 | return ret; | 1801 | return ret; |
1800 | } | 1802 | } |
1801 | EXPORT_SYMBOL_GPL(sst_hsw_dsp_init); | 1803 | EXPORT_SYMBOL_GPL(sst_hsw_dsp_init); |
@@ -1808,6 +1810,7 @@ void sst_hsw_dsp_free(struct device *dev, struct sst_pdata *pdata) | |||
1808 | sst_fw_free_all(hsw->dsp); | 1810 | sst_fw_free_all(hsw->dsp); |
1809 | sst_dsp_free(hsw->dsp); | 1811 | sst_dsp_free(hsw->dsp); |
1810 | kfree(hsw->scratch); | 1812 | kfree(hsw->scratch); |
1813 | kthread_stop(hsw->tx_thread); | ||
1811 | kfree(hsw->msg); | 1814 | kfree(hsw->msg); |
1812 | } | 1815 | } |
1813 | EXPORT_SYMBOL_GPL(sst_hsw_dsp_free); | 1816 | EXPORT_SYMBOL_GPL(sst_hsw_dsp_free); |
diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index ce27b507d5ef..058efb17c568 100644 --- a/sound/soc/intel/sst-haswell-pcm.c +++ b/sound/soc/intel/sst-haswell-pcm.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/dma-mapping.h> | 18 | #include <linux/dma-mapping.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/module.h> | ||
21 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
22 | #include <asm/page.h> | 21 | #include <asm/page.h> |
23 | #include <asm/pgtable.h> | 22 | #include <asm/pgtable.h> |
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index bb243c663e6b..1f41951d8b7f 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c | |||
@@ -527,6 +527,15 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) | |||
527 | return 0; | 527 | return 0; |
528 | } | 528 | } |
529 | 529 | ||
530 | static int ams_delta_card_remove(struct snd_soc_pcm_runtime *rtd) | ||
531 | { | ||
532 | snd_soc_jack_free_gpios(&ams_delta_hook_switch, | ||
533 | ARRAY_SIZE(ams_delta_hook_switch_gpios), | ||
534 | ams_delta_hook_switch_gpios); | ||
535 | |||
536 | return 0; | ||
537 | } | ||
538 | |||
530 | /* DAI glue - connects codec <--> CPU */ | 539 | /* DAI glue - connects codec <--> CPU */ |
531 | static struct snd_soc_dai_link ams_delta_dai_link = { | 540 | static struct snd_soc_dai_link ams_delta_dai_link = { |
532 | .name = "CX20442", | 541 | .name = "CX20442", |
@@ -543,6 +552,7 @@ static struct snd_soc_dai_link ams_delta_dai_link = { | |||
543 | static struct snd_soc_card ams_delta_audio_card = { | 552 | static struct snd_soc_card ams_delta_audio_card = { |
544 | .name = "AMS_DELTA", | 553 | .name = "AMS_DELTA", |
545 | .owner = THIS_MODULE, | 554 | .owner = THIS_MODULE, |
555 | .remove = ams_delta_card_remove, | ||
546 | .dai_link = &ams_delta_dai_link, | 556 | .dai_link = &ams_delta_dai_link, |
547 | .num_links = 1, | 557 | .num_links = 1, |
548 | 558 | ||
@@ -579,10 +589,6 @@ static int ams_delta_remove(struct platform_device *pdev) | |||
579 | dev_warn(&pdev->dev, | 589 | dev_warn(&pdev->dev, |
580 | "failed to unregister V253 line discipline\n"); | 590 | "failed to unregister V253 line discipline\n"); |
581 | 591 | ||
582 | snd_soc_jack_free_gpios(&ams_delta_hook_switch, | ||
583 | ARRAY_SIZE(ams_delta_hook_switch_gpios), | ||
584 | ams_delta_hook_switch_gpios); | ||
585 | |||
586 | snd_soc_unregister_card(card); | 592 | snd_soc_unregister_card(card); |
587 | card->dev = NULL; | 593 | card->dev = NULL; |
588 | return 0; | 594 | return 0; |
diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c index 53da041896c4..6925d7141215 100644 --- a/sound/soc/omap/omap-dmic.c +++ b/sound/soc/omap/omap-dmic.c | |||
@@ -40,9 +40,9 @@ | |||
40 | #include <sound/initval.h> | 40 | #include <sound/initval.h> |
41 | #include <sound/soc.h> | 41 | #include <sound/soc.h> |
42 | #include <sound/dmaengine_pcm.h> | 42 | #include <sound/dmaengine_pcm.h> |
43 | #include <sound/omap-pcm.h> | ||
43 | 44 | ||
44 | #include "omap-dmic.h" | 45 | #include "omap-dmic.h" |
45 | #include "omap-pcm.h" | ||
46 | 46 | ||
47 | struct omap_dmic { | 47 | struct omap_dmic { |
48 | struct device *dev; | 48 | struct device *dev; |
diff --git a/sound/soc/omap/omap-hdmi.c b/sound/soc/omap/omap-hdmi.c index 537a1ec8ad61..eb9c39299f81 100644 --- a/sound/soc/omap/omap-hdmi.c +++ b/sound/soc/omap/omap-hdmi.c | |||
@@ -34,9 +34,9 @@ | |||
34 | #include <sound/asoundef.h> | 34 | #include <sound/asoundef.h> |
35 | #include <sound/dmaengine_pcm.h> | 35 | #include <sound/dmaengine_pcm.h> |
36 | #include <video/omapdss.h> | 36 | #include <video/omapdss.h> |
37 | #include <sound/omap-pcm.h> | ||
37 | 38 | ||
38 | #include "omap-hdmi.h" | 39 | #include "omap-hdmi.h" |
39 | #include "omap-pcm.h" | ||
40 | 40 | ||
41 | #define DRV_NAME "omap-hdmi-audio-dai" | 41 | #define DRV_NAME "omap-hdmi-audio-dai" |
42 | 42 | ||
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 71d226626f7c..efe2cd699b77 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -34,11 +34,11 @@ | |||
34 | #include <sound/initval.h> | 34 | #include <sound/initval.h> |
35 | #include <sound/soc.h> | 35 | #include <sound/soc.h> |
36 | #include <sound/dmaengine_pcm.h> | 36 | #include <sound/dmaengine_pcm.h> |
37 | #include <sound/omap-pcm.h> | ||
37 | 38 | ||
38 | #include <linux/platform_data/asoc-ti-mcbsp.h> | 39 | #include <linux/platform_data/asoc-ti-mcbsp.h> |
39 | #include "mcbsp.h" | 40 | #include "mcbsp.h" |
40 | #include "omap-mcbsp.h" | 41 | #include "omap-mcbsp.h" |
41 | #include "omap-pcm.h" | ||
42 | 42 | ||
43 | #define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000) | 43 | #define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000) |
44 | 44 | ||
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index d8ebb52645a9..f0e2ebeab02b 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c | |||
@@ -40,9 +40,9 @@ | |||
40 | #include <sound/pcm_params.h> | 40 | #include <sound/pcm_params.h> |
41 | #include <sound/soc.h> | 41 | #include <sound/soc.h> |
42 | #include <sound/dmaengine_pcm.h> | 42 | #include <sound/dmaengine_pcm.h> |
43 | #include <sound/omap-pcm.h> | ||
43 | 44 | ||
44 | #include "omap-mcpdm.h" | 45 | #include "omap-mcpdm.h" |
45 | #include "omap-pcm.h" | ||
46 | 46 | ||
47 | struct mcpdm_link_config { | 47 | struct mcpdm_link_config { |
48 | u32 link_mask; /* channel mask for the direction */ | 48 | u32 link_mask; /* channel mask for the direction */ |
diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c index 64141db311b2..b4e282871658 100644 --- a/sound/soc/omap/omap-twl4030.c +++ b/sound/soc/omap/omap-twl4030.c | |||
@@ -231,6 +231,19 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd) | |||
231 | return ret; | 231 | return ret; |
232 | } | 232 | } |
233 | 233 | ||
234 | static int omap_twl4030_card_remove(struct snd_soc_pcm_runtime *rtd) | ||
235 | { | ||
236 | struct snd_soc_card *card = rtd->card; | ||
237 | struct omap_twl4030 *priv = snd_soc_card_get_drvdata(card); | ||
238 | |||
239 | if (priv->jack_detect > 0) | ||
240 | snd_soc_jack_free_gpios(&priv->hs_jack, | ||
241 | ARRAY_SIZE(hs_jack_gpios), | ||
242 | hs_jack_gpios); | ||
243 | |||
244 | return 0; | ||
245 | } | ||
246 | |||
234 | /* Digital audio interface glue - connects codec <--> CPU */ | 247 | /* Digital audio interface glue - connects codec <--> CPU */ |
235 | static struct snd_soc_dai_link omap_twl4030_dai_links[] = { | 248 | static struct snd_soc_dai_link omap_twl4030_dai_links[] = { |
236 | { | 249 | { |
@@ -258,6 +271,7 @@ static struct snd_soc_dai_link omap_twl4030_dai_links[] = { | |||
258 | /* Audio machine driver */ | 271 | /* Audio machine driver */ |
259 | static struct snd_soc_card omap_twl4030_card = { | 272 | static struct snd_soc_card omap_twl4030_card = { |
260 | .owner = THIS_MODULE, | 273 | .owner = THIS_MODULE, |
274 | .remove = omap_twl4030_card_remove, | ||
261 | .dai_link = omap_twl4030_dai_links, | 275 | .dai_link = omap_twl4030_dai_links, |
262 | .num_links = ARRAY_SIZE(omap_twl4030_dai_links), | 276 | .num_links = ARRAY_SIZE(omap_twl4030_dai_links), |
263 | 277 | ||
@@ -353,19 +367,6 @@ static int omap_twl4030_probe(struct platform_device *pdev) | |||
353 | return 0; | 367 | return 0; |
354 | } | 368 | } |
355 | 369 | ||
356 | static int omap_twl4030_remove(struct platform_device *pdev) | ||
357 | { | ||
358 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
359 | struct omap_twl4030 *priv = snd_soc_card_get_drvdata(card); | ||
360 | |||
361 | if (priv->jack_detect > 0) | ||
362 | snd_soc_jack_free_gpios(&priv->hs_jack, | ||
363 | ARRAY_SIZE(hs_jack_gpios), | ||
364 | hs_jack_gpios); | ||
365 | |||
366 | return 0; | ||
367 | } | ||
368 | |||
369 | static const struct of_device_id omap_twl4030_of_match[] = { | 370 | static const struct of_device_id omap_twl4030_of_match[] = { |
370 | {.compatible = "ti,omap-twl4030", }, | 371 | {.compatible = "ti,omap-twl4030", }, |
371 | { }, | 372 | { }, |
@@ -380,7 +381,6 @@ static struct platform_driver omap_twl4030_driver = { | |||
380 | .of_match_table = omap_twl4030_of_match, | 381 | .of_match_table = omap_twl4030_of_match, |
381 | }, | 382 | }, |
382 | .probe = omap_twl4030_probe, | 383 | .probe = omap_twl4030_probe, |
383 | .remove = omap_twl4030_remove, | ||
384 | }; | 384 | }; |
385 | 385 | ||
386 | module_platform_driver(omap_twl4030_driver); | 386 | module_platform_driver(omap_twl4030_driver); |
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 6951dc812055..47a10290535b 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c | |||
@@ -334,6 +334,14 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) | |||
334 | return err; | 334 | return err; |
335 | } | 335 | } |
336 | 336 | ||
337 | static int rx51_card_remove(struct snd_soc_pcm_runtime *rtd) | ||
338 | { | ||
339 | snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios), | ||
340 | rx51_av_jack_gpios); | ||
341 | |||
342 | return 0; | ||
343 | } | ||
344 | |||
337 | /* Digital audio interface glue - connects codec <--> CPU */ | 345 | /* Digital audio interface glue - connects codec <--> CPU */ |
338 | static struct snd_soc_dai_link rx51_dai[] = { | 346 | static struct snd_soc_dai_link rx51_dai[] = { |
339 | { | 347 | { |
@@ -368,6 +376,7 @@ static struct snd_soc_codec_conf rx51_codec_conf[] = { | |||
368 | static struct snd_soc_card rx51_sound_card = { | 376 | static struct snd_soc_card rx51_sound_card = { |
369 | .name = "RX-51", | 377 | .name = "RX-51", |
370 | .owner = THIS_MODULE, | 378 | .owner = THIS_MODULE, |
379 | .remove = rx51_card_remove, | ||
371 | .dai_link = rx51_dai, | 380 | .dai_link = rx51_dai, |
372 | .num_links = ARRAY_SIZE(rx51_dai), | 381 | .num_links = ARRAY_SIZE(rx51_dai), |
373 | .aux_dev = rx51_aux_dev, | 382 | .aux_dev = rx51_aux_dev, |
@@ -499,14 +508,6 @@ static int rx51_soc_probe(struct platform_device *pdev) | |||
499 | return 0; | 508 | return 0; |
500 | } | 509 | } |
501 | 510 | ||
502 | static int rx51_soc_remove(struct platform_device *pdev) | ||
503 | { | ||
504 | snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios), | ||
505 | rx51_av_jack_gpios); | ||
506 | |||
507 | return 0; | ||
508 | } | ||
509 | |||
510 | #if defined(CONFIG_OF) | 511 | #if defined(CONFIG_OF) |
511 | static const struct of_device_id rx51_audio_of_match[] = { | 512 | static const struct of_device_id rx51_audio_of_match[] = { |
512 | { .compatible = "nokia,n900-audio", }, | 513 | { .compatible = "nokia,n900-audio", }, |
@@ -522,7 +523,6 @@ static struct platform_driver rx51_soc_driver = { | |||
522 | .of_match_table = of_match_ptr(rx51_audio_of_match), | 523 | .of_match_table = of_match_ptr(rx51_audio_of_match), |
523 | }, | 524 | }, |
524 | .probe = rx51_soc_probe, | 525 | .probe = rx51_soc_probe, |
525 | .remove = rx51_soc_remove, | ||
526 | }; | 526 | }; |
527 | 527 | ||
528 | module_platform_driver(rx51_soc_driver); | 528 | module_platform_driver(rx51_soc_driver); |
diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c index dcc9b04bd92c..6b81acaffddd 100644 --- a/sound/soc/pxa/hx4700.c +++ b/sound/soc/pxa/hx4700.c | |||
@@ -152,6 +152,13 @@ static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd) | |||
152 | return err; | 152 | return err; |
153 | } | 153 | } |
154 | 154 | ||
155 | static int hx4700_card_remove(struct snd_soc_pcm_runtime *rtd) | ||
156 | { | ||
157 | snd_soc_jack_free_gpios(&hs_jack, 1, &hs_jack_gpio); | ||
158 | |||
159 | return 0; | ||
160 | } | ||
161 | |||
155 | /* hx4700 digital audio interface glue - connects codec <--> CPU */ | 162 | /* hx4700 digital audio interface glue - connects codec <--> CPU */ |
156 | static struct snd_soc_dai_link hx4700_dai = { | 163 | static struct snd_soc_dai_link hx4700_dai = { |
157 | .name = "ak4641", | 164 | .name = "ak4641", |
@@ -170,6 +177,7 @@ static struct snd_soc_dai_link hx4700_dai = { | |||
170 | static struct snd_soc_card snd_soc_card_hx4700 = { | 177 | static struct snd_soc_card snd_soc_card_hx4700 = { |
171 | .name = "iPAQ hx4700", | 178 | .name = "iPAQ hx4700", |
172 | .owner = THIS_MODULE, | 179 | .owner = THIS_MODULE, |
180 | .remove = hx4700_card_remove, | ||
173 | .dai_link = &hx4700_dai, | 181 | .dai_link = &hx4700_dai, |
174 | .num_links = 1, | 182 | .num_links = 1, |
175 | .dapm_widgets = hx4700_dapm_widgets, | 183 | .dapm_widgets = hx4700_dapm_widgets, |
@@ -206,7 +214,6 @@ static int hx4700_audio_probe(struct platform_device *pdev) | |||
206 | 214 | ||
207 | static int hx4700_audio_remove(struct platform_device *pdev) | 215 | static int hx4700_audio_remove(struct platform_device *pdev) |
208 | { | 216 | { |
209 | snd_soc_jack_free_gpios(&hs_jack, 1, &hs_jack_gpio); | ||
210 | snd_soc_unregister_card(&snd_soc_card_hx4700); | 217 | snd_soc_unregister_card(&snd_soc_card_hx4700); |
211 | 218 | ||
212 | gpio_set_value(GPIO92_HX4700_HP_DRIVER, 0); | 219 | gpio_set_value(GPIO92_HX4700_HP_DRIVER, 0); |
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 9b19ee70291f..199a8b377553 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c | |||
@@ -808,6 +808,7 @@ static const struct snd_soc_component_driver pxa_ssp_component = { | |||
808 | #ifdef CONFIG_OF | 808 | #ifdef CONFIG_OF |
809 | static const struct of_device_id pxa_ssp_of_ids[] = { | 809 | static const struct of_device_id pxa_ssp_of_ids[] = { |
810 | { .compatible = "mrvl,pxa-ssp-dai" }, | 810 | { .compatible = "mrvl,pxa-ssp-dai" }, |
811 | {} | ||
811 | }; | 812 | }; |
812 | #endif | 813 | #endif |
813 | 814 | ||
diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c index 9f2fb69dbaae..720357f11a7f 100644 --- a/sound/soc/samsung/h1940_uda1380.c +++ b/sound/soc/samsung/h1940_uda1380.c | |||
@@ -189,6 +189,14 @@ static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd) | |||
189 | return 0; | 189 | return 0; |
190 | } | 190 | } |
191 | 191 | ||
192 | static int h1940_uda1380_card_remove(struct snd_soc_pcm_runtime *rtd) | ||
193 | { | ||
194 | snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), | ||
195 | hp_jack_gpios); | ||
196 | |||
197 | return 0; | ||
198 | } | ||
199 | |||
192 | /* s3c24xx digital audio interface glue - connects codec <--> CPU */ | 200 | /* s3c24xx digital audio interface glue - connects codec <--> CPU */ |
193 | static struct snd_soc_dai_link h1940_uda1380_dai[] = { | 201 | static struct snd_soc_dai_link h1940_uda1380_dai[] = { |
194 | { | 202 | { |
@@ -206,6 +214,7 @@ static struct snd_soc_dai_link h1940_uda1380_dai[] = { | |||
206 | static struct snd_soc_card h1940_asoc = { | 214 | static struct snd_soc_card h1940_asoc = { |
207 | .name = "h1940", | 215 | .name = "h1940", |
208 | .owner = THIS_MODULE, | 216 | .owner = THIS_MODULE, |
217 | .remove = h1940_uda1380_card_remove, | ||
209 | .dai_link = h1940_uda1380_dai, | 218 | .dai_link = h1940_uda1380_dai, |
210 | .num_links = ARRAY_SIZE(h1940_uda1380_dai), | 219 | .num_links = ARRAY_SIZE(h1940_uda1380_dai), |
211 | 220 | ||
@@ -257,8 +266,6 @@ err_out: | |||
257 | static void __exit h1940_exit(void) | 266 | static void __exit h1940_exit(void) |
258 | { | 267 | { |
259 | platform_device_unregister(s3c24xx_snd_device); | 268 | platform_device_unregister(s3c24xx_snd_device); |
260 | snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), | ||
261 | hp_jack_gpios); | ||
262 | gpio_free(S3C_GPIO_END + 9); | 269 | gpio_free(S3C_GPIO_END + 9); |
263 | } | 270 | } |
264 | 271 | ||
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 07ff3e7cb890..2ac76fa3e742 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c | |||
@@ -488,7 +488,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, | |||
488 | clk_id = 1; | 488 | clk_id = 1; |
489 | 489 | ||
490 | if (!any_active(i2s)) { | 490 | if (!any_active(i2s)) { |
491 | if (i2s->op_clk) { | 491 | if (i2s->op_clk && !IS_ERR(i2s->op_clk)) { |
492 | if ((clk_id && !(mod & MOD_IMS_SYSMUX)) || | 492 | if ((clk_id && !(mod & MOD_IMS_SYSMUX)) || |
493 | (!clk_id && (mod & MOD_IMS_SYSMUX))) { | 493 | (!clk_id && (mod & MOD_IMS_SYSMUX))) { |
494 | clk_disable_unprepare(i2s->op_clk); | 494 | clk_disable_unprepare(i2s->op_clk); |
@@ -506,6 +506,10 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, | |||
506 | else | 506 | else |
507 | i2s->op_clk = clk_get(&i2s->pdev->dev, | 507 | i2s->op_clk = clk_get(&i2s->pdev->dev, |
508 | "i2s_opclk0"); | 508 | "i2s_opclk0"); |
509 | |||
510 | if (WARN_ON(IS_ERR(i2s->op_clk))) | ||
511 | return PTR_ERR(i2s->op_clk); | ||
512 | |||
509 | clk_prepare_enable(i2s->op_clk); | 513 | clk_prepare_enable(i2s->op_clk); |
510 | i2s->rclk_srcrate = clk_get_rate(i2s->op_clk); | 514 | i2s->rclk_srcrate = clk_get_rate(i2s->op_clk); |
511 | 515 | ||
@@ -672,8 +676,8 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, | |||
672 | if (is_manager(i2s)) | 676 | if (is_manager(i2s)) |
673 | mod &= ~MOD_BLC_MASK; | 677 | mod &= ~MOD_BLC_MASK; |
674 | 678 | ||
675 | switch (params_format(params)) { | 679 | switch (params_width(params)) { |
676 | case SNDRV_PCM_FORMAT_S8: | 680 | case 8: |
677 | if (is_secondary(i2s)) | 681 | if (is_secondary(i2s)) |
678 | mod |= MOD_BLCS_8BIT; | 682 | mod |= MOD_BLCS_8BIT; |
679 | else | 683 | else |
@@ -681,7 +685,7 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, | |||
681 | if (is_manager(i2s)) | 685 | if (is_manager(i2s)) |
682 | mod |= MOD_BLC_8BIT; | 686 | mod |= MOD_BLC_8BIT; |
683 | break; | 687 | break; |
684 | case SNDRV_PCM_FORMAT_S16_LE: | 688 | case 16: |
685 | if (is_secondary(i2s)) | 689 | if (is_secondary(i2s)) |
686 | mod |= MOD_BLCS_16BIT; | 690 | mod |= MOD_BLCS_16BIT; |
687 | else | 691 | else |
@@ -689,7 +693,7 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, | |||
689 | if (is_manager(i2s)) | 693 | if (is_manager(i2s)) |
690 | mod |= MOD_BLC_16BIT; | 694 | mod |= MOD_BLC_16BIT; |
691 | break; | 695 | break; |
692 | case SNDRV_PCM_FORMAT_S24_LE: | 696 | case 24: |
693 | if (is_secondary(i2s)) | 697 | if (is_secondary(i2s)) |
694 | mod |= MOD_BLCS_24BIT; | 698 | mod |= MOD_BLCS_24BIT; |
695 | else | 699 | else |
diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c index a3c9c9cba3b0..4c5f97fe45c8 100644 --- a/sound/soc/samsung/pcm.c +++ b/sound/soc/samsung/pcm.c | |||
@@ -283,8 +283,8 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream, | |||
283 | dev_dbg(pcm->dev, "Entered %s\n", __func__); | 283 | dev_dbg(pcm->dev, "Entered %s\n", __func__); |
284 | 284 | ||
285 | /* Strictly check for sample size */ | 285 | /* Strictly check for sample size */ |
286 | switch (params_format(params)) { | 286 | switch (params_width(params)) { |
287 | case SNDRV_PCM_FORMAT_S16_LE: | 287 | case 16: |
288 | break; | 288 | break; |
289 | default: | 289 | default: |
290 | return -EINVAL; | 290 | return -EINVAL; |
diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c index 5b3e504d3a32..192aa9fc102f 100644 --- a/sound/soc/samsung/rx1950_uda1380.c +++ b/sound/soc/samsung/rx1950_uda1380.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "s3c24xx-i2s.h" | 31 | #include "s3c24xx-i2s.h" |
32 | 32 | ||
33 | static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd); | 33 | static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd); |
34 | static int rx1950_uda1380_card_remove(struct snd_soc_pcm_runtime *rtd); | ||
34 | static int rx1950_startup(struct snd_pcm_substream *substream); | 35 | static int rx1950_startup(struct snd_pcm_substream *substream); |
35 | static int rx1950_hw_params(struct snd_pcm_substream *substream, | 36 | static int rx1950_hw_params(struct snd_pcm_substream *substream, |
36 | struct snd_pcm_hw_params *params); | 37 | struct snd_pcm_hw_params *params); |
@@ -116,6 +117,7 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
116 | static struct snd_soc_card rx1950_asoc = { | 117 | static struct snd_soc_card rx1950_asoc = { |
117 | .name = "rx1950", | 118 | .name = "rx1950", |
118 | .owner = THIS_MODULE, | 119 | .owner = THIS_MODULE, |
120 | .remove = rx1950_uda1380_card_remove, | ||
119 | .dai_link = rx1950_uda1380_dai, | 121 | .dai_link = rx1950_uda1380_dai, |
120 | .num_links = ARRAY_SIZE(rx1950_uda1380_dai), | 122 | .num_links = ARRAY_SIZE(rx1950_uda1380_dai), |
121 | 123 | ||
@@ -234,6 +236,14 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd) | |||
234 | return 0; | 236 | return 0; |
235 | } | 237 | } |
236 | 238 | ||
239 | static int rx1950_uda1380_card_remove(struct snd_soc_pcm_runtime *rtd) | ||
240 | { | ||
241 | snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), | ||
242 | hp_jack_gpios); | ||
243 | |||
244 | return 0; | ||
245 | } | ||
246 | |||
237 | static int __init rx1950_init(void) | 247 | static int __init rx1950_init(void) |
238 | { | 248 | { |
239 | int ret; | 249 | int ret; |
@@ -278,8 +288,6 @@ err_gpio: | |||
278 | static void __exit rx1950_exit(void) | 288 | static void __exit rx1950_exit(void) |
279 | { | 289 | { |
280 | platform_device_unregister(s3c24xx_snd_device); | 290 | platform_device_unregister(s3c24xx_snd_device); |
281 | snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), | ||
282 | hp_jack_gpios); | ||
283 | gpio_free(S3C2410_GPA(1)); | 291 | gpio_free(S3C2410_GPA(1)); |
284 | } | 292 | } |
285 | 293 | ||
diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c index 77a2ae50dc94..0ff4bbe23af3 100644 --- a/sound/soc/samsung/s3c-i2s-v2.c +++ b/sound/soc/samsung/s3c-i2s-v2.c | |||
@@ -322,13 +322,13 @@ static int s3c_i2sv2_hw_params(struct snd_pcm_substream *substream, | |||
322 | 322 | ||
323 | iismod &= ~S3C64XX_IISMOD_BLC_MASK; | 323 | iismod &= ~S3C64XX_IISMOD_BLC_MASK; |
324 | /* Sample size */ | 324 | /* Sample size */ |
325 | switch (params_format(params)) { | 325 | switch (params_width(params)) { |
326 | case SNDRV_PCM_FORMAT_S8: | 326 | case 8: |
327 | iismod |= S3C64XX_IISMOD_BLC_8BIT; | 327 | iismod |= S3C64XX_IISMOD_BLC_8BIT; |
328 | break; | 328 | break; |
329 | case SNDRV_PCM_FORMAT_S16_LE: | 329 | case 16: |
330 | break; | 330 | break; |
331 | case SNDRV_PCM_FORMAT_S24_LE: | 331 | case 24: |
332 | iismod |= S3C64XX_IISMOD_BLC_24BIT; | 332 | iismod |= S3C64XX_IISMOD_BLC_24BIT; |
333 | break; | 333 | break; |
334 | } | 334 | } |
diff --git a/sound/soc/samsung/s3c2412-i2s.c b/sound/soc/samsung/s3c2412-i2s.c index 843f315dcb3a..08c059be9104 100644 --- a/sound/soc/samsung/s3c2412-i2s.c +++ b/sound/soc/samsung/s3c2412-i2s.c | |||
@@ -120,11 +120,11 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, | |||
120 | iismod = readl(i2s->regs + S3C2412_IISMOD); | 120 | iismod = readl(i2s->regs + S3C2412_IISMOD); |
121 | pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); | 121 | pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); |
122 | 122 | ||
123 | switch (params_format(params)) { | 123 | switch (params_width(params)) { |
124 | case SNDRV_PCM_FORMAT_S8: | 124 | case 8: |
125 | iismod |= S3C2412_IISMOD_8BIT; | 125 | iismod |= S3C2412_IISMOD_8BIT; |
126 | break; | 126 | break; |
127 | case SNDRV_PCM_FORMAT_S16_LE: | 127 | case 16: |
128 | iismod &= ~S3C2412_IISMOD_8BIT; | 128 | iismod &= ~S3C2412_IISMOD_8BIT; |
129 | break; | 129 | break; |
130 | } | 130 | } |
diff --git a/sound/soc/samsung/s3c24xx-i2s.c b/sound/soc/samsung/s3c24xx-i2s.c index 4a6d206db222..9aba9fb7df0e 100644 --- a/sound/soc/samsung/s3c24xx-i2s.c +++ b/sound/soc/samsung/s3c24xx-i2s.c | |||
@@ -248,12 +248,12 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
248 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); | 248 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); |
249 | pr_debug("hw_params r: IISMOD: %x\n", iismod); | 249 | pr_debug("hw_params r: IISMOD: %x\n", iismod); |
250 | 250 | ||
251 | switch (params_format(params)) { | 251 | switch (params_width(params)) { |
252 | case SNDRV_PCM_FORMAT_S8: | 252 | case 8: |
253 | iismod &= ~S3C2410_IISMOD_16BIT; | 253 | iismod &= ~S3C2410_IISMOD_16BIT; |
254 | dma_data->dma_size = 1; | 254 | dma_data->dma_size = 1; |
255 | break; | 255 | break; |
256 | case SNDRV_PCM_FORMAT_S16_LE: | 256 | case 16: |
257 | iismod |= S3C2410_IISMOD_16BIT; | 257 | iismod |= S3C2410_IISMOD_16BIT; |
258 | dma_data->dma_size = 2; | 258 | dma_data->dma_size = 2; |
259 | break; | 259 | break; |
diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c index df55db5d3554..271a904277a1 100644 --- a/sound/soc/samsung/smartq_wm8987.c +++ b/sound/soc/samsung/smartq_wm8987.c | |||
@@ -182,6 +182,14 @@ static int smartq_wm8987_init(struct snd_soc_pcm_runtime *rtd) | |||
182 | return err; | 182 | return err; |
183 | } | 183 | } |
184 | 184 | ||
185 | static int smartq_wm8987_card_remove(struct snd_soc_pcm_runtime *rtd) | ||
186 | { | ||
187 | snd_soc_jack_free_gpios(&smartq_jack, ARRAY_SIZE(smartq_jack_gpios), | ||
188 | smartq_jack_gpios); | ||
189 | |||
190 | return 0; | ||
191 | } | ||
192 | |||
185 | static struct snd_soc_dai_link smartq_dai[] = { | 193 | static struct snd_soc_dai_link smartq_dai[] = { |
186 | { | 194 | { |
187 | .name = "wm8987", | 195 | .name = "wm8987", |
@@ -198,6 +206,7 @@ static struct snd_soc_dai_link smartq_dai[] = { | |||
198 | static struct snd_soc_card snd_soc_smartq = { | 206 | static struct snd_soc_card snd_soc_smartq = { |
199 | .name = "SmartQ", | 207 | .name = "SmartQ", |
200 | .owner = THIS_MODULE, | 208 | .owner = THIS_MODULE, |
209 | .remove = smartq_wm8987_card_remove, | ||
201 | .dai_link = smartq_dai, | 210 | .dai_link = smartq_dai, |
202 | .num_links = ARRAY_SIZE(smartq_dai), | 211 | .num_links = ARRAY_SIZE(smartq_dai), |
203 | 212 | ||
@@ -259,8 +268,6 @@ err_unregister_device: | |||
259 | static void __exit smartq_exit(void) | 268 | static void __exit smartq_exit(void) |
260 | { | 269 | { |
261 | gpio_free(S3C64XX_GPK(12)); | 270 | gpio_free(S3C64XX_GPK(12)); |
262 | snd_soc_jack_free_gpios(&smartq_jack, ARRAY_SIZE(smartq_jack_gpios), | ||
263 | smartq_jack_gpios); | ||
264 | 271 | ||
265 | platform_device_unregister(smartq_snd_device); | 272 | platform_device_unregister(smartq_snd_device); |
266 | } | 273 | } |
diff --git a/sound/soc/samsung/smdk_wm8580.c b/sound/soc/samsung/smdk_wm8580.c index 7a16b32ed673..b1a519f83b29 100644 --- a/sound/soc/samsung/smdk_wm8580.c +++ b/sound/soc/samsung/smdk_wm8580.c | |||
@@ -37,13 +37,11 @@ static int smdk_hw_params(struct snd_pcm_substream *substream, | |||
37 | unsigned int pll_out; | 37 | unsigned int pll_out; |
38 | int bfs, rfs, ret; | 38 | int bfs, rfs, ret; |
39 | 39 | ||
40 | switch (params_format(params)) { | 40 | switch (params_width(params)) { |
41 | case SNDRV_PCM_FORMAT_U8: | 41 | case 8: |
42 | case SNDRV_PCM_FORMAT_S8: | ||
43 | bfs = 16; | 42 | bfs = 16; |
44 | break; | 43 | break; |
45 | case SNDRV_PCM_FORMAT_U16_LE: | 44 | case 16: |
46 | case SNDRV_PCM_FORMAT_S16_LE: | ||
47 | bfs = 32; | 45 | bfs = 32; |
48 | break; | 46 | break; |
49 | default: | 47 | default: |
diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c index fc25cc00f0f2..3d6272a8cad2 100644 --- a/sound/soc/samsung/smdk_wm8994.c +++ b/sound/soc/samsung/smdk_wm8994.c | |||
@@ -57,7 +57,7 @@ static int smdk_hw_params(struct snd_pcm_substream *substream, | |||
57 | int ret; | 57 | int ret; |
58 | 58 | ||
59 | /* AIF1CLK should be >=3MHz for optimal performance */ | 59 | /* AIF1CLK should be >=3MHz for optimal performance */ |
60 | if (params_format(params) == SNDRV_PCM_FORMAT_S24_LE) | 60 | if (params_width(params) == 24) |
61 | pll_out = params_rate(params) * 384; | 61 | pll_out = params_rate(params) * 384; |
62 | else if (params_rate(params) == 8000 || params_rate(params) == 11025) | 62 | else if (params_rate(params) == 8000 || params_rate(params) == 11025) |
63 | pll_out = params_rate(params) * 512; | 63 | pll_out = params_rate(params) * 512; |
diff --git a/sound/soc/samsung/spdif.c b/sound/soc/samsung/spdif.c index e93a93e296f4..d9ffc48fce5e 100644 --- a/sound/soc/samsung/spdif.c +++ b/sound/soc/samsung/spdif.c | |||
@@ -211,8 +211,8 @@ static int spdif_hw_params(struct snd_pcm_substream *substream, | |||
211 | con |= CON_PCM_DATA; | 211 | con |= CON_PCM_DATA; |
212 | 212 | ||
213 | con &= ~CON_PCM_MASK; | 213 | con &= ~CON_PCM_MASK; |
214 | switch (params_format(params)) { | 214 | switch (params_width(params)) { |
215 | case SNDRV_PCM_FORMAT_S16_LE: | 215 | case 16: |
216 | con |= CON_PCM_16BIT; | 216 | con |= CON_PCM_16BIT; |
217 | break; | 217 | break; |
218 | default: | 218 | default: |
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 964463dada87..91880156e1ae 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c | |||
@@ -255,11 +255,81 @@ int rsnd_dma_available(struct rsnd_dma *dma) | |||
255 | return !!dma->chan; | 255 | return !!dma->chan; |
256 | } | 256 | } |
257 | 257 | ||
258 | #define DMA_NAME_SIZE 16 | ||
259 | #define MOD_MAX 4 /* MEM/SSI/SRC/DVC */ | ||
260 | static int _rsnd_dma_of_name(char *dma_name, struct rsnd_mod *mod) | ||
261 | { | ||
262 | if (mod) | ||
263 | return snprintf(dma_name, DMA_NAME_SIZE / 2, "%s%d", | ||
264 | rsnd_mod_name(mod), rsnd_mod_id(mod)); | ||
265 | else | ||
266 | return snprintf(dma_name, DMA_NAME_SIZE / 2, "mem"); | ||
267 | |||
268 | } | ||
269 | |||
270 | static void rsnd_dma_of_name(struct rsnd_dma *dma, | ||
271 | int is_play, char *dma_name) | ||
272 | { | ||
273 | struct rsnd_mod *this = rsnd_dma_to_mod(dma); | ||
274 | struct rsnd_dai_stream *io = rsnd_mod_to_io(this); | ||
275 | struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io); | ||
276 | struct rsnd_mod *src = rsnd_io_to_mod_src(io); | ||
277 | struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io); | ||
278 | struct rsnd_mod *mod[MOD_MAX]; | ||
279 | struct rsnd_mod *src_mod, *dst_mod; | ||
280 | int i, index; | ||
281 | |||
282 | |||
283 | for (i = 0; i < MOD_MAX; i++) | ||
284 | mod[i] = NULL; | ||
285 | |||
286 | /* | ||
287 | * in play case... | ||
288 | * | ||
289 | * src -> dst | ||
290 | * | ||
291 | * mem -> SSI | ||
292 | * mem -> SRC -> SSI | ||
293 | * mem -> SRC -> DVC -> SSI | ||
294 | */ | ||
295 | mod[0] = NULL; /* for "mem" */ | ||
296 | index = 1; | ||
297 | for (i = 1; i < MOD_MAX; i++) { | ||
298 | if (!src) { | ||
299 | mod[i] = ssi; | ||
300 | break; | ||
301 | } else if (!dvc) { | ||
302 | mod[i] = src; | ||
303 | src = NULL; | ||
304 | } else { | ||
305 | mod[i] = dvc; | ||
306 | dvc = NULL; | ||
307 | } | ||
308 | |||
309 | if (mod[i] == this) | ||
310 | index = i; | ||
311 | } | ||
312 | |||
313 | if (is_play) { | ||
314 | src_mod = mod[index - 1]; | ||
315 | dst_mod = mod[index]; | ||
316 | } else { | ||
317 | src_mod = mod[index]; | ||
318 | dst_mod = mod[index + 1]; | ||
319 | } | ||
320 | |||
321 | index = 0; | ||
322 | index = _rsnd_dma_of_name(dma_name + index, src_mod); | ||
323 | *(dma_name + index++) = '_'; | ||
324 | index = _rsnd_dma_of_name(dma_name + index, dst_mod); | ||
325 | } | ||
326 | |||
258 | int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, | 327 | int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, |
259 | int is_play, int id) | 328 | int is_play, int id) |
260 | { | 329 | { |
261 | struct device *dev = rsnd_priv_to_dev(priv); | 330 | struct device *dev = rsnd_priv_to_dev(priv); |
262 | struct dma_slave_config cfg; | 331 | struct dma_slave_config cfg; |
332 | char dma_name[DMA_NAME_SIZE]; | ||
263 | dma_cap_mask_t mask; | 333 | dma_cap_mask_t mask; |
264 | int ret; | 334 | int ret; |
265 | 335 | ||
@@ -271,18 +341,23 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, | |||
271 | dma_cap_zero(mask); | 341 | dma_cap_zero(mask); |
272 | dma_cap_set(DMA_SLAVE, mask); | 342 | dma_cap_set(DMA_SLAVE, mask); |
273 | 343 | ||
344 | if (dev->of_node) | ||
345 | rsnd_dma_of_name(dma, is_play, dma_name); | ||
346 | else | ||
347 | snprintf(dma_name, DMA_NAME_SIZE, | ||
348 | is_play ? "tx" : "rx"); | ||
349 | |||
350 | dev_dbg(dev, "dma name : %s\n", dma_name); | ||
351 | |||
274 | dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, | 352 | dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, |
275 | (void *)id, dev, | 353 | (void *)id, dev, |
276 | is_play ? "tx" : "rx"); | 354 | dma_name); |
277 | if (!dma->chan) { | 355 | if (!dma->chan) { |
278 | dev_err(dev, "can't get dma channel\n"); | 356 | dev_err(dev, "can't get dma channel\n"); |
279 | return -EIO; | 357 | return -EIO; |
280 | } | 358 | } |
281 | 359 | ||
282 | cfg.slave_id = id; | 360 | rsnd_gen_dma_addr(priv, dma, &cfg, is_play, id); |
283 | cfg.dst_addr = 0; /* use default addr when playback */ | ||
284 | cfg.src_addr = 0; /* use default addr when capture */ | ||
285 | cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; | ||
286 | 361 | ||
287 | ret = dmaengine_slave_config(dma->chan, &cfg); | 362 | ret = dmaengine_slave_config(dma->chan, &cfg); |
288 | if (ret < 0) | 363 | if (ret < 0) |
@@ -956,7 +1031,7 @@ static int rsnd_probe(struct platform_device *pdev) | |||
956 | return -ENODEV; | 1031 | return -ENODEV; |
957 | } | 1032 | } |
958 | 1033 | ||
959 | priv->dev = dev; | 1034 | priv->pdev = pdev; |
960 | priv->info = info; | 1035 | priv->info = info; |
961 | spin_lock_init(&priv->lock); | 1036 | spin_lock_init(&priv->lock); |
962 | 1037 | ||
diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 74769b1be005..ed0007006899 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c | |||
@@ -13,6 +13,9 @@ | |||
13 | #define RSND_DVC_NAME_SIZE 16 | 13 | #define RSND_DVC_NAME_SIZE 16 |
14 | #define RSND_DVC_VOLUME_MAX 100 | 14 | #define RSND_DVC_VOLUME_MAX 100 |
15 | #define RSND_DVC_VOLUME_NUM 2 | 15 | #define RSND_DVC_VOLUME_NUM 2 |
16 | |||
17 | #define DVC_NAME "dvc" | ||
18 | |||
16 | struct rsnd_dvc { | 19 | struct rsnd_dvc { |
17 | struct rsnd_dvc_platform_info *info; /* rcar_snd.h */ | 20 | struct rsnd_dvc_platform_info *info; /* rcar_snd.h */ |
18 | struct rsnd_mod mod; | 21 | struct rsnd_mod mod; |
@@ -43,6 +46,17 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod) | |||
43 | rsnd_mod_write(mod, DVC_VOL1R, vol[1]); | 46 | rsnd_mod_write(mod, DVC_VOL1R, vol[1]); |
44 | } | 47 | } |
45 | 48 | ||
49 | static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod, | ||
50 | struct rsnd_dai *rdai) | ||
51 | { | ||
52 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | ||
53 | struct device *dev = rsnd_priv_to_dev(priv); | ||
54 | |||
55 | dev_dbg(dev, "%s (Gen2) is probed\n", rsnd_mod_name(mod)); | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
46 | static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, | 60 | static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, |
47 | struct rsnd_dai *rdai) | 61 | struct rsnd_dai *rdai) |
48 | { | 62 | { |
@@ -208,7 +222,8 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, | |||
208 | } | 222 | } |
209 | 223 | ||
210 | static struct rsnd_mod_ops rsnd_dvc_ops = { | 224 | static struct rsnd_mod_ops rsnd_dvc_ops = { |
211 | .name = "dvc (gen2)", | 225 | .name = DVC_NAME, |
226 | .probe = rsnd_dvc_probe_gen2, | ||
212 | .init = rsnd_dvc_init, | 227 | .init = rsnd_dvc_init, |
213 | .quit = rsnd_dvc_quit, | 228 | .quit = rsnd_dvc_quit, |
214 | .start = rsnd_dvc_start, | 229 | .start = rsnd_dvc_start, |
@@ -255,7 +270,8 @@ int rsnd_dvc_probe(struct platform_device *pdev, | |||
255 | priv->dvc = dvc; | 270 | priv->dvc = dvc; |
256 | 271 | ||
257 | for_each_rsnd_dvc(dvc, priv, i) { | 272 | for_each_rsnd_dvc(dvc, priv, i) { |
258 | snprintf(name, RSND_DVC_NAME_SIZE, "dvc.%d", i); | 273 | snprintf(name, RSND_DVC_NAME_SIZE, "%s.%d", |
274 | DVC_NAME, i); | ||
259 | 275 | ||
260 | clk = devm_clk_get(dev, name); | 276 | clk = devm_clk_get(dev, name); |
261 | if (IS_ERR(clk)) | 277 | if (IS_ERR(clk)) |
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index a1583b57bf8d..1dd2b7d38c2c 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c | |||
@@ -156,6 +156,101 @@ static int rsnd_gen_regmap_init(struct rsnd_priv *priv, | |||
156 | } | 156 | } |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * DMA read/write register offset | ||
160 | * | ||
161 | * RSND_xxx_I_N for Audio DMAC input | ||
162 | * RSND_xxx_O_N for Audio DMAC output | ||
163 | * RSND_xxx_I_P for Audio DMAC peri peri input | ||
164 | * RSND_xxx_O_P for Audio DMAC peri peri output | ||
165 | * | ||
166 | * ex) R-Car H2 case | ||
167 | * mod / DMAC in / DMAC out / DMAC PP in / DMAC pp out | ||
168 | * SSI : 0xec541000 / 0xec241008 / 0xec24100c / 0xec400000 / 0xec400000 | ||
169 | * SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000 | ||
170 | * CMD : 0xec500000 / 0xec008000 0xec308000 | ||
171 | */ | ||
172 | #define RDMA_SSI_I_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8) | ||
173 | #define RDMA_SSI_O_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc) | ||
174 | |||
175 | #define RDMA_SSI_I_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i)) | ||
176 | #define RDMA_SSI_O_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i)) | ||
177 | |||
178 | #define RDMA_SRC_I_N(addr, i) (addr ##_reg - 0x00500000 + (0x400 * i)) | ||
179 | #define RDMA_SRC_O_N(addr, i) (addr ##_reg - 0x004fc000 + (0x400 * i)) | ||
180 | |||
181 | #define RDMA_SRC_I_P(addr, i) (addr ##_reg - 0x00200000 + (0x400 * i)) | ||
182 | #define RDMA_SRC_O_P(addr, i) (addr ##_reg - 0x001fc000 + (0x400 * i)) | ||
183 | |||
184 | #define RDMA_CMD_O_N(addr, i) (addr ##_reg - 0x004f8000 + (0x400 * i)) | ||
185 | #define RDMA_CMD_O_P(addr, i) (addr ##_reg - 0x001f8000 + (0x400 * i)) | ||
186 | |||
187 | void rsnd_gen_dma_addr(struct rsnd_priv *priv, | ||
188 | struct rsnd_dma *dma, | ||
189 | struct dma_slave_config *cfg, | ||
190 | int is_play, int slave_id) | ||
191 | { | ||
192 | struct platform_device *pdev = rsnd_priv_to_pdev(priv); | ||
193 | struct device *dev = rsnd_priv_to_dev(priv); | ||
194 | struct rsnd_mod *mod = rsnd_dma_to_mod(dma); | ||
195 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); | ||
196 | dma_addr_t ssi_reg = platform_get_resource(pdev, | ||
197 | IORESOURCE_MEM, RSND_GEN2_SSI)->start; | ||
198 | dma_addr_t src_reg = platform_get_resource(pdev, | ||
199 | IORESOURCE_MEM, RSND_GEN2_SCU)->start; | ||
200 | int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod); | ||
201 | int use_src = !!rsnd_io_to_mod_src(io); | ||
202 | int use_dvc = !!rsnd_io_to_mod_dvc(io); | ||
203 | int id = rsnd_mod_id(mod); | ||
204 | struct dma_addr { | ||
205 | dma_addr_t src_addr; | ||
206 | dma_addr_t dst_addr; | ||
207 | } dma_addrs[2][2][3] = { | ||
208 | { /* SRC */ | ||
209 | /* Capture */ | ||
210 | {{ 0, 0 }, | ||
211 | { RDMA_SRC_O_N(src, id), 0 }, | ||
212 | { RDMA_CMD_O_N(src, id), 0 }}, | ||
213 | /* Playback */ | ||
214 | {{ 0, 0, }, | ||
215 | { 0, RDMA_SRC_I_N(src, id) }, | ||
216 | { 0, RDMA_SRC_I_N(src, id) }} | ||
217 | }, { /* SSI */ | ||
218 | /* Capture */ | ||
219 | {{ RDMA_SSI_O_N(ssi, id), 0 }, | ||
220 | { RDMA_SSI_O_P(ssi, id), RDMA_SRC_I_P(src, id) }, | ||
221 | { RDMA_SSI_O_P(ssi, id), RDMA_SRC_I_P(src, id) }}, | ||
222 | /* Playback */ | ||
223 | {{ 0, RDMA_SSI_I_N(ssi, id) }, | ||
224 | { RDMA_SRC_O_P(src, id), RDMA_SSI_I_P(ssi, id) }, | ||
225 | { RDMA_CMD_O_P(src, id), RDMA_SSI_I_P(ssi, id) }} | ||
226 | } | ||
227 | }; | ||
228 | |||
229 | cfg->slave_id = slave_id; | ||
230 | cfg->src_addr = 0; | ||
231 | cfg->dst_addr = 0; | ||
232 | cfg->direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; | ||
233 | |||
234 | /* | ||
235 | * gen1 uses default DMA addr | ||
236 | */ | ||
237 | if (rsnd_is_gen1(priv)) | ||
238 | return; | ||
239 | |||
240 | /* it shouldn't happen */ | ||
241 | if (use_dvc & !use_src) { | ||
242 | dev_err(dev, "DVC is selected without SRC\n"); | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | cfg->src_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].src_addr; | ||
247 | cfg->dst_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].dst_addr; | ||
248 | |||
249 | dev_dbg(dev, "dma%d addr - src : %x / dst : %x\n", | ||
250 | id, cfg->src_addr, cfg->dst_addr); | ||
251 | } | ||
252 | |||
253 | /* | ||
159 | * Gen2 | 254 | * Gen2 |
160 | */ | 255 | */ |
161 | 256 | ||
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 5aa790170b01..39d98af5ee05 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
@@ -281,6 +281,11 @@ int rsnd_gen_probe(struct platform_device *pdev, | |||
281 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, | 281 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, |
282 | struct rsnd_mod *mod, | 282 | struct rsnd_mod *mod, |
283 | enum rsnd_reg reg); | 283 | enum rsnd_reg reg); |
284 | void rsnd_gen_dma_addr(struct rsnd_priv *priv, | ||
285 | struct rsnd_dma *dma, | ||
286 | struct dma_slave_config *cfg, | ||
287 | int is_play, int slave_id); | ||
288 | |||
284 | #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) | 289 | #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) |
285 | #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2) | 290 | #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2) |
286 | 291 | ||
@@ -317,7 +322,7 @@ struct rsnd_of_data { | |||
317 | 322 | ||
318 | struct rsnd_priv { | 323 | struct rsnd_priv { |
319 | 324 | ||
320 | struct device *dev; | 325 | struct platform_device *pdev; |
321 | struct rcar_snd_info *info; | 326 | struct rcar_snd_info *info; |
322 | spinlock_t lock; | 327 | spinlock_t lock; |
323 | 328 | ||
@@ -357,7 +362,8 @@ struct rsnd_priv { | |||
357 | int rdai_nr; | 362 | int rdai_nr; |
358 | }; | 363 | }; |
359 | 364 | ||
360 | #define rsnd_priv_to_dev(priv) ((priv)->dev) | 365 | #define rsnd_priv_to_pdev(priv) ((priv)->pdev) |
366 | #define rsnd_priv_to_dev(priv) (&(rsnd_priv_to_pdev(priv)->dev)) | ||
361 | #define rsnd_priv_to_info(priv) ((priv)->info) | 367 | #define rsnd_priv_to_info(priv) ((priv)->info) |
362 | #define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags) | 368 | #define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags) |
363 | #define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags) | 369 | #define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags) |
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index e3b078e7c3aa..200eda019bc7 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c | |||
@@ -10,6 +10,8 @@ | |||
10 | */ | 10 | */ |
11 | #include "rsnd.h" | 11 | #include "rsnd.h" |
12 | 12 | ||
13 | #define SRC_NAME "src" | ||
14 | |||
13 | struct rsnd_src { | 15 | struct rsnd_src { |
14 | struct rsnd_src_platform_info *info; /* rcar_snd.h */ | 16 | struct rsnd_src_platform_info *info; /* rcar_snd.h */ |
15 | struct rsnd_mod mod; | 17 | struct rsnd_mod mod; |
@@ -268,10 +270,6 @@ static int rsnd_src_stop(struct rsnd_mod *mod, | |||
268 | return 0; | 270 | return 0; |
269 | } | 271 | } |
270 | 272 | ||
271 | static struct rsnd_mod_ops rsnd_src_non_ops = { | ||
272 | .name = "src (non)", | ||
273 | }; | ||
274 | |||
275 | /* | 273 | /* |
276 | * Gen1 functions | 274 | * Gen1 functions |
277 | */ | 275 | */ |
@@ -393,6 +391,17 @@ static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod, | |||
393 | return 0; | 391 | return 0; |
394 | } | 392 | } |
395 | 393 | ||
394 | static int rsnd_src_probe_gen1(struct rsnd_mod *mod, | ||
395 | struct rsnd_dai *rdai) | ||
396 | { | ||
397 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | ||
398 | struct device *dev = rsnd_priv_to_dev(priv); | ||
399 | |||
400 | dev_dbg(dev, "%s (Gen1) is probed\n", rsnd_mod_name(mod)); | ||
401 | |||
402 | return 0; | ||
403 | } | ||
404 | |||
396 | static int rsnd_src_init_gen1(struct rsnd_mod *mod, | 405 | static int rsnd_src_init_gen1(struct rsnd_mod *mod, |
397 | struct rsnd_dai *rdai) | 406 | struct rsnd_dai *rdai) |
398 | { | 407 | { |
@@ -438,7 +447,8 @@ static int rsnd_src_stop_gen1(struct rsnd_mod *mod, | |||
438 | } | 447 | } |
439 | 448 | ||
440 | static struct rsnd_mod_ops rsnd_src_gen1_ops = { | 449 | static struct rsnd_mod_ops rsnd_src_gen1_ops = { |
441 | .name = "sru (gen1)", | 450 | .name = SRC_NAME, |
451 | .probe = rsnd_src_probe_gen1, | ||
442 | .init = rsnd_src_init_gen1, | 452 | .init = rsnd_src_init_gen1, |
443 | .quit = rsnd_src_quit, | 453 | .quit = rsnd_src_quit, |
444 | .start = rsnd_src_start_gen1, | 454 | .start = rsnd_src_start_gen1, |
@@ -502,6 +512,8 @@ static int rsnd_src_probe_gen2(struct rsnd_mod *mod, | |||
502 | if (ret < 0) | 512 | if (ret < 0) |
503 | dev_err(dev, "SRC DMA failed\n"); | 513 | dev_err(dev, "SRC DMA failed\n"); |
504 | 514 | ||
515 | dev_dbg(dev, "%s (Gen2) is probed\n", rsnd_mod_name(mod)); | ||
516 | |||
505 | return ret; | 517 | return ret; |
506 | } | 518 | } |
507 | 519 | ||
@@ -562,7 +574,7 @@ static int rsnd_src_stop_gen2(struct rsnd_mod *mod, | |||
562 | } | 574 | } |
563 | 575 | ||
564 | static struct rsnd_mod_ops rsnd_src_gen2_ops = { | 576 | static struct rsnd_mod_ops rsnd_src_gen2_ops = { |
565 | .name = "src (gen2)", | 577 | .name = SRC_NAME, |
566 | .probe = rsnd_src_probe_gen2, | 578 | .probe = rsnd_src_probe_gen2, |
567 | .remove = rsnd_src_remove_gen2, | 579 | .remove = rsnd_src_remove_gen2, |
568 | .init = rsnd_src_init_gen2, | 580 | .init = rsnd_src_init_gen2, |
@@ -598,18 +610,21 @@ static void rsnd_of_parse_src(struct platform_device *pdev, | |||
598 | 610 | ||
599 | nr = of_get_child_count(src_node); | 611 | nr = of_get_child_count(src_node); |
600 | if (!nr) | 612 | if (!nr) |
601 | return; | 613 | goto rsnd_of_parse_src_end; |
602 | 614 | ||
603 | src_info = devm_kzalloc(dev, | 615 | src_info = devm_kzalloc(dev, |
604 | sizeof(struct rsnd_src_platform_info) * nr, | 616 | sizeof(struct rsnd_src_platform_info) * nr, |
605 | GFP_KERNEL); | 617 | GFP_KERNEL); |
606 | if (!src_info) { | 618 | if (!src_info) { |
607 | dev_err(dev, "src info allocation error\n"); | 619 | dev_err(dev, "src info allocation error\n"); |
608 | return; | 620 | goto rsnd_of_parse_src_end; |
609 | } | 621 | } |
610 | 622 | ||
611 | info->src_info = src_info; | 623 | info->src_info = src_info; |
612 | info->src_info_nr = nr; | 624 | info->src_info_nr = nr; |
625 | |||
626 | rsnd_of_parse_src_end: | ||
627 | of_node_put(src_node); | ||
613 | } | 628 | } |
614 | 629 | ||
615 | int rsnd_src_probe(struct platform_device *pdev, | 630 | int rsnd_src_probe(struct platform_device *pdev, |
@@ -624,6 +639,16 @@ int rsnd_src_probe(struct platform_device *pdev, | |||
624 | char name[RSND_SRC_NAME_SIZE]; | 639 | char name[RSND_SRC_NAME_SIZE]; |
625 | int i, nr; | 640 | int i, nr; |
626 | 641 | ||
642 | ops = NULL; | ||
643 | if (rsnd_is_gen1(priv)) | ||
644 | ops = &rsnd_src_gen1_ops; | ||
645 | if (rsnd_is_gen2(priv)) | ||
646 | ops = &rsnd_src_gen2_ops; | ||
647 | if (!ops) { | ||
648 | dev_err(dev, "unknown Generation\n"); | ||
649 | return -EIO; | ||
650 | } | ||
651 | |||
627 | rsnd_of_parse_src(pdev, of_data, priv); | 652 | rsnd_of_parse_src(pdev, of_data, priv); |
628 | 653 | ||
629 | /* | 654 | /* |
@@ -643,7 +668,8 @@ int rsnd_src_probe(struct platform_device *pdev, | |||
643 | priv->src = src; | 668 | priv->src = src; |
644 | 669 | ||
645 | for_each_rsnd_src(src, priv, i) { | 670 | for_each_rsnd_src(src, priv, i) { |
646 | snprintf(name, RSND_SRC_NAME_SIZE, "src.%d", i); | 671 | snprintf(name, RSND_SRC_NAME_SIZE, "%s.%d", |
672 | SRC_NAME, i); | ||
647 | 673 | ||
648 | clk = devm_clk_get(dev, name); | 674 | clk = devm_clk_get(dev, name); |
649 | if (IS_ERR(clk)) | 675 | if (IS_ERR(clk)) |
@@ -652,12 +678,6 @@ int rsnd_src_probe(struct platform_device *pdev, | |||
652 | src->info = &info->src_info[i]; | 678 | src->info = &info->src_info[i]; |
653 | src->clk = clk; | 679 | src->clk = clk; |
654 | 680 | ||
655 | ops = &rsnd_src_non_ops; | ||
656 | if (rsnd_is_gen1(priv)) | ||
657 | ops = &rsnd_src_gen1_ops; | ||
658 | if (rsnd_is_gen2(priv)) | ||
659 | ops = &rsnd_src_gen2_ops; | ||
660 | |||
661 | rsnd_mod_init(priv, &src->mod, ops, RSND_MOD_SRC, i); | 681 | rsnd_mod_init(priv, &src->mod, ops, RSND_MOD_SRC, i); |
662 | 682 | ||
663 | dev_dbg(dev, "SRC%d probed\n", i); | 683 | dev_dbg(dev, "SRC%d probed\n", i); |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 36654bd4e428..2df723df5d19 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
@@ -57,6 +57,8 @@ | |||
57 | */ | 57 | */ |
58 | #define CONT (1 << 8) /* WS Continue Function */ | 58 | #define CONT (1 << 8) /* WS Continue Function */ |
59 | 59 | ||
60 | #define SSI_NAME "ssi" | ||
61 | |||
60 | struct rsnd_ssi { | 62 | struct rsnd_ssi { |
61 | struct clk *clk; | 63 | struct clk *clk; |
62 | struct rsnd_ssi_platform_info *info; /* rcar_snd.h */ | 64 | struct rsnd_ssi_platform_info *info; /* rcar_snd.h */ |
@@ -373,6 +375,8 @@ static int rsnd_ssi_pio_probe(struct rsnd_mod *mod, | |||
373 | if (ret) | 375 | if (ret) |
374 | dev_err(dev, "SSI request interrupt failed\n"); | 376 | dev_err(dev, "SSI request interrupt failed\n"); |
375 | 377 | ||
378 | dev_dbg(dev, "%s (PIO) is probed\n", rsnd_mod_name(mod)); | ||
379 | |||
376 | return ret; | 380 | return ret; |
377 | } | 381 | } |
378 | 382 | ||
@@ -405,7 +409,7 @@ static int rsnd_ssi_pio_stop(struct rsnd_mod *mod, | |||
405 | } | 409 | } |
406 | 410 | ||
407 | static struct rsnd_mod_ops rsnd_ssi_pio_ops = { | 411 | static struct rsnd_mod_ops rsnd_ssi_pio_ops = { |
408 | .name = "ssi (pio)", | 412 | .name = SSI_NAME, |
409 | .probe = rsnd_ssi_pio_probe, | 413 | .probe = rsnd_ssi_pio_probe, |
410 | .init = rsnd_ssi_init, | 414 | .init = rsnd_ssi_init, |
411 | .quit = rsnd_ssi_quit, | 415 | .quit = rsnd_ssi_quit, |
@@ -430,6 +434,8 @@ static int rsnd_ssi_dma_probe(struct rsnd_mod *mod, | |||
430 | if (ret < 0) | 434 | if (ret < 0) |
431 | dev_err(dev, "SSI DMA failed\n"); | 435 | dev_err(dev, "SSI DMA failed\n"); |
432 | 436 | ||
437 | dev_dbg(dev, "%s (DMA) is probed\n", rsnd_mod_name(mod)); | ||
438 | |||
433 | return ret; | 439 | return ret; |
434 | } | 440 | } |
435 | 441 | ||
@@ -480,7 +486,7 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod, | |||
480 | } | 486 | } |
481 | 487 | ||
482 | static struct rsnd_mod_ops rsnd_ssi_dma_ops = { | 488 | static struct rsnd_mod_ops rsnd_ssi_dma_ops = { |
483 | .name = "ssi (dma)", | 489 | .name = SSI_NAME, |
484 | .probe = rsnd_ssi_dma_probe, | 490 | .probe = rsnd_ssi_dma_probe, |
485 | .remove = rsnd_ssi_dma_remove, | 491 | .remove = rsnd_ssi_dma_remove, |
486 | .init = rsnd_ssi_init, | 492 | .init = rsnd_ssi_init, |
@@ -493,7 +499,7 @@ static struct rsnd_mod_ops rsnd_ssi_dma_ops = { | |||
493 | * Non SSI | 499 | * Non SSI |
494 | */ | 500 | */ |
495 | static struct rsnd_mod_ops rsnd_ssi_non_ops = { | 501 | static struct rsnd_mod_ops rsnd_ssi_non_ops = { |
496 | .name = "ssi (non)", | 502 | .name = SSI_NAME, |
497 | }; | 503 | }; |
498 | 504 | ||
499 | /* | 505 | /* |
@@ -554,14 +560,14 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev, | |||
554 | 560 | ||
555 | nr = of_get_child_count(node); | 561 | nr = of_get_child_count(node); |
556 | if (!nr) | 562 | if (!nr) |
557 | return; | 563 | goto rsnd_of_parse_ssi_end; |
558 | 564 | ||
559 | ssi_info = devm_kzalloc(dev, | 565 | ssi_info = devm_kzalloc(dev, |
560 | sizeof(struct rsnd_ssi_platform_info) * nr, | 566 | sizeof(struct rsnd_ssi_platform_info) * nr, |
561 | GFP_KERNEL); | 567 | GFP_KERNEL); |
562 | if (!ssi_info) { | 568 | if (!ssi_info) { |
563 | dev_err(dev, "ssi info allocation error\n"); | 569 | dev_err(dev, "ssi info allocation error\n"); |
564 | return; | 570 | goto rsnd_of_parse_ssi_end; |
565 | } | 571 | } |
566 | 572 | ||
567 | info->ssi_info = ssi_info; | 573 | info->ssi_info = ssi_info; |
@@ -583,7 +589,16 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev, | |||
583 | * irq | 589 | * irq |
584 | */ | 590 | */ |
585 | ssi_info->pio_irq = irq_of_parse_and_map(np, 0); | 591 | ssi_info->pio_irq = irq_of_parse_and_map(np, 0); |
592 | |||
593 | /* | ||
594 | * DMA | ||
595 | */ | ||
596 | ssi_info->dma_id = of_get_property(np, "pio-transfer", NULL) ? | ||
597 | 0 : 1; | ||
586 | } | 598 | } |
599 | |||
600 | rsnd_of_parse_ssi_end: | ||
601 | of_node_put(node); | ||
587 | } | 602 | } |
588 | 603 | ||
589 | int rsnd_ssi_probe(struct platform_device *pdev, | 604 | int rsnd_ssi_probe(struct platform_device *pdev, |
@@ -617,7 +632,8 @@ int rsnd_ssi_probe(struct platform_device *pdev, | |||
617 | for_each_rsnd_ssi(ssi, priv, i) { | 632 | for_each_rsnd_ssi(ssi, priv, i) { |
618 | pinfo = &info->ssi_info[i]; | 633 | pinfo = &info->ssi_info[i]; |
619 | 634 | ||
620 | snprintf(name, RSND_SSI_NAME_SIZE, "ssi.%d", i); | 635 | snprintf(name, RSND_SSI_NAME_SIZE, "%s.%d", |
636 | SSI_NAME, i); | ||
621 | 637 | ||
622 | clk = devm_clk_get(dev, name); | 638 | clk = devm_clk_get(dev, name); |
623 | if (IS_ERR(clk)) | 639 | if (IS_ERR(clk)) |
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index 3fa77d5f9b75..00e70b6c7da2 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c | |||
@@ -72,6 +72,9 @@ int snd_soc_cache_init(struct snd_soc_codec *codec) | |||
72 | 72 | ||
73 | reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; | 73 | reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; |
74 | 74 | ||
75 | if (!reg_size) | ||
76 | return 0; | ||
77 | |||
75 | mutex_init(&codec->cache_rw_mutex); | 78 | mutex_init(&codec->cache_rw_mutex); |
76 | 79 | ||
77 | dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", | 80 | dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", |
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index b903f822d1b2..d0d98810af91 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <sound/jack.h> | 14 | #include <sound/jack.h> |
15 | #include <sound/soc.h> | 15 | #include <sound/soc.h> |
16 | #include <linux/gpio.h> | 16 | #include <linux/gpio.h> |
17 | #include <linux/gpio/consumer.h> | ||
17 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
18 | #include <linux/workqueue.h> | 19 | #include <linux/workqueue.h> |
19 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
@@ -240,7 +241,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) | |||
240 | int enable; | 241 | int enable; |
241 | int report; | 242 | int report; |
242 | 243 | ||
243 | enable = gpio_get_value_cansleep(gpio->gpio); | 244 | enable = gpiod_get_value_cansleep(gpio->desc); |
244 | if (gpio->invert) | 245 | if (gpio->invert) |
245 | enable = !enable; | 246 | enable = !enable; |
246 | 247 | ||
@@ -297,31 +298,50 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
297 | int i, ret; | 298 | int i, ret; |
298 | 299 | ||
299 | for (i = 0; i < count; i++) { | 300 | for (i = 0; i < count; i++) { |
300 | if (!gpio_is_valid(gpios[i].gpio)) { | ||
301 | dev_err(jack->codec->dev, "ASoC: Invalid gpio %d\n", | ||
302 | gpios[i].gpio); | ||
303 | ret = -EINVAL; | ||
304 | goto undo; | ||
305 | } | ||
306 | if (!gpios[i].name) { | 301 | if (!gpios[i].name) { |
307 | dev_err(jack->codec->dev, "ASoC: No name for gpio %d\n", | 302 | dev_err(jack->codec->dev, |
308 | gpios[i].gpio); | 303 | "ASoC: No name for gpio at index %d\n", i); |
309 | ret = -EINVAL; | 304 | ret = -EINVAL; |
310 | goto undo; | 305 | goto undo; |
311 | } | 306 | } |
312 | 307 | ||
313 | ret = gpio_request(gpios[i].gpio, gpios[i].name); | 308 | if (gpios[i].gpiod_dev) { |
314 | if (ret) | 309 | /* GPIO descriptor */ |
315 | goto undo; | 310 | gpios[i].desc = gpiod_get_index(gpios[i].gpiod_dev, |
311 | gpios[i].name, | ||
312 | gpios[i].idx); | ||
313 | if (IS_ERR(gpios[i].desc)) { | ||
314 | ret = PTR_ERR(gpios[i].desc); | ||
315 | dev_err(gpios[i].gpiod_dev, | ||
316 | "ASoC: Cannot get gpio at index %d: %d", | ||
317 | i, ret); | ||
318 | goto undo; | ||
319 | } | ||
320 | } else { | ||
321 | /* legacy GPIO number */ | ||
322 | if (!gpio_is_valid(gpios[i].gpio)) { | ||
323 | dev_err(jack->codec->dev, | ||
324 | "ASoC: Invalid gpio %d\n", | ||
325 | gpios[i].gpio); | ||
326 | ret = -EINVAL; | ||
327 | goto undo; | ||
328 | } | ||
329 | |||
330 | ret = gpio_request(gpios[i].gpio, gpios[i].name); | ||
331 | if (ret) | ||
332 | goto undo; | ||
333 | |||
334 | gpios[i].desc = gpio_to_desc(gpios[i].gpio); | ||
335 | } | ||
316 | 336 | ||
317 | ret = gpio_direction_input(gpios[i].gpio); | 337 | ret = gpiod_direction_input(gpios[i].desc); |
318 | if (ret) | 338 | if (ret) |
319 | goto err; | 339 | goto err; |
320 | 340 | ||
321 | INIT_DELAYED_WORK(&gpios[i].work, gpio_work); | 341 | INIT_DELAYED_WORK(&gpios[i].work, gpio_work); |
322 | gpios[i].jack = jack; | 342 | gpios[i].jack = jack; |
323 | 343 | ||
324 | ret = request_any_context_irq(gpio_to_irq(gpios[i].gpio), | 344 | ret = request_any_context_irq(gpiod_to_irq(gpios[i].desc), |
325 | gpio_handler, | 345 | gpio_handler, |
326 | IRQF_TRIGGER_RISING | | 346 | IRQF_TRIGGER_RISING | |
327 | IRQF_TRIGGER_FALLING, | 347 | IRQF_TRIGGER_FALLING, |
@@ -331,15 +351,15 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
331 | goto err; | 351 | goto err; |
332 | 352 | ||
333 | if (gpios[i].wake) { | 353 | if (gpios[i].wake) { |
334 | ret = irq_set_irq_wake(gpio_to_irq(gpios[i].gpio), 1); | 354 | ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1); |
335 | if (ret != 0) | 355 | if (ret != 0) |
336 | dev_err(jack->codec->dev, "ASoC: " | 356 | dev_err(jack->codec->dev, |
337 | "Failed to mark GPIO %d as wake source: %d\n", | 357 | "ASoC: Failed to mark GPIO at index %d as wake source: %d\n", |
338 | gpios[i].gpio, ret); | 358 | i, ret); |
339 | } | 359 | } |
340 | 360 | ||
341 | /* Expose GPIO value over sysfs for diagnostic purposes */ | 361 | /* Expose GPIO value over sysfs for diagnostic purposes */ |
342 | gpio_export(gpios[i].gpio, false); | 362 | gpiod_export(gpios[i].desc, false); |
343 | 363 | ||
344 | /* Update initial jack status */ | 364 | /* Update initial jack status */ |
345 | schedule_delayed_work(&gpios[i].work, | 365 | schedule_delayed_work(&gpios[i].work, |
@@ -358,6 +378,30 @@ undo: | |||
358 | EXPORT_SYMBOL_GPL(snd_soc_jack_add_gpios); | 378 | EXPORT_SYMBOL_GPL(snd_soc_jack_add_gpios); |
359 | 379 | ||
360 | /** | 380 | /** |
381 | * snd_soc_jack_add_gpiods - Associate GPIO descriptor pins with an ASoC jack | ||
382 | * | ||
383 | * @gpiod_dev: GPIO consumer device | ||
384 | * @jack: ASoC jack | ||
385 | * @count: number of pins | ||
386 | * @gpios: array of gpio pins | ||
387 | * | ||
388 | * This function will request gpio, set data direction and request irq | ||
389 | * for each gpio in the array. | ||
390 | */ | ||
391 | int snd_soc_jack_add_gpiods(struct device *gpiod_dev, | ||
392 | struct snd_soc_jack *jack, | ||
393 | int count, struct snd_soc_jack_gpio *gpios) | ||
394 | { | ||
395 | int i; | ||
396 | |||
397 | for (i = 0; i < count; i++) | ||
398 | gpios[i].gpiod_dev = gpiod_dev; | ||
399 | |||
400 | return snd_soc_jack_add_gpios(jack, count, gpios); | ||
401 | } | ||
402 | EXPORT_SYMBOL_GPL(snd_soc_jack_add_gpiods); | ||
403 | |||
404 | /** | ||
361 | * snd_soc_jack_free_gpios - Release GPIO pins' resources of an ASoC jack | 405 | * snd_soc_jack_free_gpios - Release GPIO pins' resources of an ASoC jack |
362 | * | 406 | * |
363 | * @jack: ASoC jack | 407 | * @jack: ASoC jack |
@@ -372,10 +416,10 @@ void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | |||
372 | int i; | 416 | int i; |
373 | 417 | ||
374 | for (i = 0; i < count; i++) { | 418 | for (i = 0; i < count; i++) { |
375 | gpio_unexport(gpios[i].gpio); | 419 | gpiod_unexport(gpios[i].desc); |
376 | free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]); | 420 | free_irq(gpiod_to_irq(gpios[i].desc), &gpios[i]); |
377 | cancel_delayed_work_sync(&gpios[i].work); | 421 | cancel_delayed_work_sync(&gpios[i].work); |
378 | gpio_free(gpios[i].gpio); | 422 | gpiod_put(gpios[i].desc); |
379 | gpios[i].jack = NULL; | 423 | gpios[i].jack = NULL; |
380 | } | 424 | } |
381 | } | 425 | } |
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c index c61ea3a1030f..02734bd4f09b 100644 --- a/sound/soc/tegra/tegra_alc5632.c +++ b/sound/soc/tegra/tegra_alc5632.c | |||
@@ -125,6 +125,18 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
125 | return 0; | 125 | return 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | static int tegra_alc5632_card_remove(struct snd_soc_card *card) | ||
129 | { | ||
130 | struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card); | ||
131 | |||
132 | if (gpio_is_valid(machine->gpio_hp_det)) { | ||
133 | snd_soc_jack_free_gpios(&tegra_alc5632_hs_jack, 1, | ||
134 | &tegra_alc5632_hp_jack_gpio); | ||
135 | } | ||
136 | |||
137 | return 0; | ||
138 | } | ||
139 | |||
128 | static struct snd_soc_dai_link tegra_alc5632_dai = { | 140 | static struct snd_soc_dai_link tegra_alc5632_dai = { |
129 | .name = "ALC5632", | 141 | .name = "ALC5632", |
130 | .stream_name = "ALC5632 PCM", | 142 | .stream_name = "ALC5632 PCM", |
@@ -139,6 +151,7 @@ static struct snd_soc_dai_link tegra_alc5632_dai = { | |||
139 | static struct snd_soc_card snd_soc_tegra_alc5632 = { | 151 | static struct snd_soc_card snd_soc_tegra_alc5632 = { |
140 | .name = "tegra-alc5632", | 152 | .name = "tegra-alc5632", |
141 | .owner = THIS_MODULE, | 153 | .owner = THIS_MODULE, |
154 | .remove = tegra_alc5632_card_remove, | ||
142 | .dai_link = &tegra_alc5632_dai, | 155 | .dai_link = &tegra_alc5632_dai, |
143 | .num_links = 1, | 156 | .num_links = 1, |
144 | .controls = tegra_alc5632_controls, | 157 | .controls = tegra_alc5632_controls, |
@@ -223,9 +236,6 @@ static int tegra_alc5632_remove(struct platform_device *pdev) | |||
223 | struct snd_soc_card *card = platform_get_drvdata(pdev); | 236 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
224 | struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card); | 237 | struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card); |
225 | 238 | ||
226 | snd_soc_jack_free_gpios(&tegra_alc5632_hs_jack, 1, | ||
227 | &tegra_alc5632_hp_jack_gpio); | ||
228 | |||
229 | snd_soc_unregister_card(card); | 239 | snd_soc_unregister_card(card); |
230 | 240 | ||
231 | tegra_asoc_utils_fini(&machine->util_data); | 241 | tegra_asoc_utils_fini(&machine->util_data); |
diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c index 0283cfb7c031..ce73e1f62c4b 100644 --- a/sound/soc/tegra/tegra_max98090.c +++ b/sound/soc/tegra/tegra_max98090.c | |||
@@ -145,6 +145,18 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
145 | return 0; | 145 | return 0; |
146 | } | 146 | } |
147 | 147 | ||
148 | static int tegra_max98090_card_remove(struct snd_soc_card *card) | ||
149 | { | ||
150 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); | ||
151 | |||
152 | if (gpio_is_valid(machine->gpio_hp_det)) { | ||
153 | snd_soc_jack_free_gpios(&tegra_max98090_hp_jack, 1, | ||
154 | &tegra_max98090_hp_jack_gpio); | ||
155 | } | ||
156 | |||
157 | return 0; | ||
158 | } | ||
159 | |||
148 | static struct snd_soc_dai_link tegra_max98090_dai = { | 160 | static struct snd_soc_dai_link tegra_max98090_dai = { |
149 | .name = "max98090", | 161 | .name = "max98090", |
150 | .stream_name = "max98090 PCM", | 162 | .stream_name = "max98090 PCM", |
@@ -158,6 +170,7 @@ static struct snd_soc_dai_link tegra_max98090_dai = { | |||
158 | static struct snd_soc_card snd_soc_tegra_max98090 = { | 170 | static struct snd_soc_card snd_soc_tegra_max98090 = { |
159 | .name = "tegra-max98090", | 171 | .name = "tegra-max98090", |
160 | .owner = THIS_MODULE, | 172 | .owner = THIS_MODULE, |
173 | .remove = tegra_max98090_card_remove, | ||
161 | .dai_link = &tegra_max98090_dai, | 174 | .dai_link = &tegra_max98090_dai, |
162 | .num_links = 1, | 175 | .num_links = 1, |
163 | .controls = tegra_max98090_controls, | 176 | .controls = tegra_max98090_controls, |
@@ -241,9 +254,6 @@ static int tegra_max98090_remove(struct platform_device *pdev) | |||
241 | struct snd_soc_card *card = platform_get_drvdata(pdev); | 254 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
242 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); | 255 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); |
243 | 256 | ||
244 | snd_soc_jack_free_gpios(&tegra_max98090_hp_jack, 1, | ||
245 | &tegra_max98090_hp_jack_gpio); | ||
246 | |||
247 | snd_soc_unregister_card(card); | 257 | snd_soc_unregister_card(card); |
248 | 258 | ||
249 | tegra_asoc_utils_fini(&machine->util_data); | 259 | tegra_asoc_utils_fini(&machine->util_data); |
diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c index 4511c5a875ec..4feb16a99e02 100644 --- a/sound/soc/tegra/tegra_rt5640.c +++ b/sound/soc/tegra/tegra_rt5640.c | |||
@@ -128,6 +128,18 @@ static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
128 | return 0; | 128 | return 0; |
129 | } | 129 | } |
130 | 130 | ||
131 | static int tegra_rt5640_card_remove(struct snd_soc_card *card) | ||
132 | { | ||
133 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); | ||
134 | |||
135 | if (gpio_is_valid(machine->gpio_hp_det)) { | ||
136 | snd_soc_jack_free_gpios(&tegra_rt5640_hp_jack, 1, | ||
137 | &tegra_rt5640_hp_jack_gpio); | ||
138 | } | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
131 | static struct snd_soc_dai_link tegra_rt5640_dai = { | 143 | static struct snd_soc_dai_link tegra_rt5640_dai = { |
132 | .name = "RT5640", | 144 | .name = "RT5640", |
133 | .stream_name = "RT5640 PCM", | 145 | .stream_name = "RT5640 PCM", |
@@ -141,6 +153,7 @@ static struct snd_soc_dai_link tegra_rt5640_dai = { | |||
141 | static struct snd_soc_card snd_soc_tegra_rt5640 = { | 153 | static struct snd_soc_card snd_soc_tegra_rt5640 = { |
142 | .name = "tegra-rt5640", | 154 | .name = "tegra-rt5640", |
143 | .owner = THIS_MODULE, | 155 | .owner = THIS_MODULE, |
156 | .remove = tegra_rt5640_card_remove, | ||
144 | .dai_link = &tegra_rt5640_dai, | 157 | .dai_link = &tegra_rt5640_dai, |
145 | .num_links = 1, | 158 | .num_links = 1, |
146 | .controls = tegra_rt5640_controls, | 159 | .controls = tegra_rt5640_controls, |
@@ -224,9 +237,6 @@ static int tegra_rt5640_remove(struct platform_device *pdev) | |||
224 | struct snd_soc_card *card = platform_get_drvdata(pdev); | 237 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
225 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); | 238 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); |
226 | 239 | ||
227 | snd_soc_jack_free_gpios(&tegra_rt5640_hp_jack, 1, | ||
228 | &tegra_rt5640_hp_jack_gpio); | ||
229 | |||
230 | snd_soc_unregister_card(card); | 240 | snd_soc_unregister_card(card); |
231 | 241 | ||
232 | tegra_asoc_utils_fini(&machine->util_data); | 242 | tegra_asoc_utils_fini(&machine->util_data); |
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index 4ac73730d79a..0939661df60b 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c | |||
@@ -206,6 +206,12 @@ static int tegra_wm8903_remove(struct snd_soc_card *card) | |||
206 | struct snd_soc_pcm_runtime *rtd = &(card->rtd[0]); | 206 | struct snd_soc_pcm_runtime *rtd = &(card->rtd[0]); |
207 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 207 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
208 | struct snd_soc_codec *codec = codec_dai->codec; | 208 | struct snd_soc_codec *codec = codec_dai->codec; |
209 | struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); | ||
210 | |||
211 | if (gpio_is_valid(machine->gpio_hp_det)) { | ||
212 | snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack, 1, | ||
213 | &tegra_wm8903_hp_jack_gpio); | ||
214 | } | ||
209 | 215 | ||
210 | wm8903_mic_detect(codec, NULL, 0, 0); | 216 | wm8903_mic_detect(codec, NULL, 0, 0); |
211 | 217 | ||
@@ -228,9 +234,7 @@ static struct snd_soc_card snd_soc_tegra_wm8903 = { | |||
228 | .owner = THIS_MODULE, | 234 | .owner = THIS_MODULE, |
229 | .dai_link = &tegra_wm8903_dai, | 235 | .dai_link = &tegra_wm8903_dai, |
230 | .num_links = 1, | 236 | .num_links = 1, |
231 | |||
232 | .remove = tegra_wm8903_remove, | 237 | .remove = tegra_wm8903_remove, |
233 | |||
234 | .controls = tegra_wm8903_controls, | 238 | .controls = tegra_wm8903_controls, |
235 | .num_controls = ARRAY_SIZE(tegra_wm8903_controls), | 239 | .num_controls = ARRAY_SIZE(tegra_wm8903_controls), |
236 | .dapm_widgets = tegra_wm8903_dapm_widgets, | 240 | .dapm_widgets = tegra_wm8903_dapm_widgets, |
@@ -368,9 +372,6 @@ static int tegra_wm8903_driver_remove(struct platform_device *pdev) | |||
368 | struct snd_soc_card *card = platform_get_drvdata(pdev); | 372 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
369 | struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); | 373 | struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); |
370 | 374 | ||
371 | snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack, 1, | ||
372 | &tegra_wm8903_hp_jack_gpio); | ||
373 | |||
374 | snd_soc_unregister_card(card); | 375 | snd_soc_unregister_card(card); |
375 | 376 | ||
376 | tegra_asoc_utils_fini(&machine->util_data); | 377 | tegra_asoc_utils_fini(&machine->util_data); |