diff options
| author | Brian Austin <brian.austin@cirrus.com> | 2014-05-05 16:09:08 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@linaro.org> | 2014-05-05 21:20:22 -0400 |
| commit | 272b5edd3b8fe51d4e22fbea996a8d6560b8d048 (patch) | |
| tree | c99d632c93a3656a9a6198de29d3139a4027cc46 | |
| parent | eba17e6868059849fc2ffa79aabdd5b59f229fb9 (diff) | |
ASoC: Add support for CS42L56 CODEC
This patch adds support for the Cirrus Logic Low Power Stereo I2C CODEC
Signed-off-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
| -rw-r--r-- | include/sound/cs42l56.h | 48 | ||||
| -rw-r--r-- | sound/soc/codecs/Kconfig | 5 | ||||
| -rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
| -rw-r--r-- | sound/soc/codecs/cs42l56.c | 1427 | ||||
| -rw-r--r-- | sound/soc/codecs/cs42l56.h | 175 |
5 files changed, 1657 insertions, 0 deletions
diff --git a/include/sound/cs42l56.h b/include/sound/cs42l56.h new file mode 100644 index 000000000000..2467c8ff132c --- /dev/null +++ b/include/sound/cs42l56.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* | ||
| 2 | * linux/sound/cs42l56.h -- Platform data for CS42L56 | ||
| 3 | * | ||
| 4 | * Copyright (c) 2014 Cirrus Logic Inc. | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #ifndef __CS42L56_H | ||
| 12 | #define __CS42L56_H | ||
| 13 | |||
| 14 | struct cs42l56_platform_data { | ||
| 15 | |||
| 16 | /* GPIO for Reset */ | ||
| 17 | unsigned int gpio_nreset; | ||
| 18 | |||
| 19 | /* MICBIAS Level. Check datasheet Pg48 */ | ||
| 20 | unsigned int micbias_lvl; | ||
| 21 | |||
| 22 | /* Analog Input 1A Reference 0=Single 1=Pseudo-Differential */ | ||
| 23 | unsigned int ain1a_ref_cfg; | ||
| 24 | |||
| 25 | /* Analog Input 2A Reference 0=Single 1=Pseudo-Differential */ | ||
| 26 | unsigned int ain2a_ref_cfg; | ||
| 27 | |||
| 28 | /* Analog Input 1B Reference 0=Single 1=Pseudo-Differential */ | ||
| 29 | unsigned int ain1b_ref_cfg; | ||
| 30 | |||
| 31 | /* Analog Input 2B Reference 0=Single 1=Pseudo-Differential */ | ||
| 32 | unsigned int ain2b_ref_cfg; | ||
| 33 | |||
| 34 | /* Charge Pump Freq. Check datasheet Pg62 */ | ||
| 35 | unsigned int chgfreq; | ||
| 36 | |||
| 37 | /* HighPass Filter Right Channel Corner Frequency */ | ||
| 38 | unsigned int hpfb_freq; | ||
| 39 | |||
| 40 | /* HighPass Filter Left Channel Corner Frequency */ | ||
| 41 | unsigned int hpfa_freq; | ||
| 42 | |||
| 43 | /* Adaptive Power Control for LO/HP */ | ||
| 44 | unsigned int adaptive_pwr; | ||
| 45 | |||
| 46 | }; | ||
| 47 | |||
| 48 | #endif /* __CS42L56_H */ | ||
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index d739ba7baeff..755372509cc8 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
| @@ -41,6 +41,7 @@ config SND_SOC_ALL_CODECS | |||
| 41 | select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC | 41 | select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC |
| 42 | select SND_SOC_CS42L51_I2C if I2C | 42 | select SND_SOC_CS42L51_I2C if I2C |
| 43 | select SND_SOC_CS42L52 if I2C && INPUT | 43 | select SND_SOC_CS42L52 if I2C && INPUT |
| 44 | select SND_SOC_CS42L56 if I2C && INPUT | ||
| 44 | select SND_SOC_CS42L73 if I2C | 45 | select SND_SOC_CS42L73 if I2C |
| 45 | select SND_SOC_CS4270 if I2C | 46 | select SND_SOC_CS4270 if I2C |
| 46 | select SND_SOC_CS4271 if SND_SOC_I2C_AND_SPI | 47 | select SND_SOC_CS4271 if SND_SOC_I2C_AND_SPI |
| @@ -288,6 +289,10 @@ config SND_SOC_CS42L52 | |||
| 288 | tristate "Cirrus Logic CS42L52 CODEC" | 289 | tristate "Cirrus Logic CS42L52 CODEC" |
| 289 | depends on I2C && INPUT | 290 | depends on I2C && INPUT |
| 290 | 291 | ||
| 292 | config SND_SOC_CS42L56 | ||
| 293 | tristate "Cirrus Logic CS42L56 CODEC" | ||
| 294 | depends on I2C && INPUT | ||
| 295 | |||
| 291 | config SND_SOC_CS42L73 | 296 | config SND_SOC_CS42L73 |
| 292 | tristate "Cirrus Logic CS42L73 CODEC" | 297 | tristate "Cirrus Logic CS42L73 CODEC" |
| 293 | depends on I2C | 298 | depends on I2C |
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index e06f10032344..c225dae517c3 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
| @@ -28,6 +28,7 @@ snd-soc-cq93vc-objs := cq93vc.o | |||
| 28 | snd-soc-cs42l51-objs := cs42l51.o | 28 | snd-soc-cs42l51-objs := cs42l51.o |
| 29 | snd-soc-cs42l51-i2c-objs := cs42l51-i2c.o | 29 | snd-soc-cs42l51-i2c-objs := cs42l51-i2c.o |
| 30 | snd-soc-cs42l52-objs := cs42l52.o | 30 | snd-soc-cs42l52-objs := cs42l52.o |
| 31 | snd-soc-cs42l56-objs := cs42l56.o | ||
| 31 | snd-soc-cs42l73-objs := cs42l73.o | 32 | snd-soc-cs42l73-objs := cs42l73.o |
| 32 | snd-soc-cs4270-objs := cs4270.o | 33 | snd-soc-cs4270-objs := cs4270.o |
| 33 | snd-soc-cs4271-objs := cs4271.o | 34 | snd-soc-cs4271-objs := cs4271.o |
| @@ -180,6 +181,7 @@ obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o | |||
| 180 | obj-$(CONFIG_SND_SOC_CS42L51) += snd-soc-cs42l51.o | 181 | obj-$(CONFIG_SND_SOC_CS42L51) += snd-soc-cs42l51.o |
| 181 | obj-$(CONFIG_SND_SOC_CS42L51_I2C) += snd-soc-cs42l51-i2c.o | 182 | obj-$(CONFIG_SND_SOC_CS42L51_I2C) += snd-soc-cs42l51-i2c.o |
| 182 | obj-$(CONFIG_SND_SOC_CS42L52) += snd-soc-cs42l52.o | 183 | obj-$(CONFIG_SND_SOC_CS42L52) += snd-soc-cs42l52.o |
| 184 | obj-$(CONFIG_SND_SOC_CS42L56) += snd-soc-cs42l56.o | ||
| 183 | obj-$(CONFIG_SND_SOC_CS42L73) += snd-soc-cs42l73.o | 185 | obj-$(CONFIG_SND_SOC_CS42L73) += snd-soc-cs42l73.o |
| 184 | obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o | 186 | obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o |
| 185 | obj-$(CONFIG_SND_SOC_CS4271) += snd-soc-cs4271.o | 187 | obj-$(CONFIG_SND_SOC_CS4271) += snd-soc-cs4271.o |
diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c new file mode 100644 index 000000000000..5bb134b4ab9b --- /dev/null +++ b/sound/soc/codecs/cs42l56.c | |||
| @@ -0,0 +1,1427 @@ | |||
| 1 | /* | ||
| 2 | * cs42l56.c -- CS42L56 ALSA SoC audio driver | ||
| 3 | * | ||
| 4 | * Copyright 2014 CirrusLogic, Inc. | ||
| 5 | * | ||
| 6 | * Author: Brian Austin <brian.austin@cirrus.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 | |||
| 14 | #include <linux/module.h> | ||
| 15 | #include <linux/moduleparam.h> | ||
| 16 | #include <linux/kernel.h> | ||
| 17 | #include <linux/init.h> | ||
| 18 | #include <linux/delay.h> | ||
| 19 | #include <linux/pm.h> | ||
| 20 | #include <linux/i2c.h> | ||
| 21 | #include <linux/input.h> | ||
| 22 | #include <linux/regmap.h> | ||
| 23 | #include <linux/slab.h> | ||
| 24 | #include <linux/workqueue.h> | ||
| 25 | #include <linux/platform_device.h> | ||
| 26 | #include <linux/regulator/consumer.h> | ||
| 27 | #include <linux/of_device.h> | ||
| 28 | #include <linux/of_gpio.h> | ||
| 29 | #include <sound/core.h> | ||
| 30 | #include <sound/pcm.h> | ||
| 31 | #include <sound/pcm_params.h> | ||
| 32 | #include <sound/soc.h> | ||
| 33 | #include <sound/soc-dapm.h> | ||
| 34 | #include <sound/initval.h> | ||
| 35 | #include <sound/tlv.h> | ||
| 36 | #include <sound/cs42l56.h> | ||
| 37 | #include "cs42l56.h" | ||
| 38 | |||
| 39 | #define CS42L56_NUM_SUPPLIES 3 | ||
| 40 | static const char *const cs42l56_supply_names[CS42L56_NUM_SUPPLIES] = { | ||
| 41 | "VA", | ||
| 42 | "VCP", | ||
| 43 | "VLDO", | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct cs42l56_private { | ||
| 47 | struct regmap *regmap; | ||
| 48 | struct snd_soc_codec *codec; | ||
| 49 | struct device *dev; | ||
| 50 | struct cs42l56_platform_data pdata; | ||
| 51 | struct regulator_bulk_data supplies[CS42L56_NUM_SUPPLIES]; | ||
| 52 | u32 mclk; | ||
| 53 | u8 mclk_prediv; | ||
| 54 | u8 mclk_div2; | ||
| 55 | u8 mclk_ratio; | ||
| 56 | u8 iface; | ||
| 57 | u8 iface_fmt; | ||
| 58 | u8 iface_inv; | ||
| 59 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
| 60 | struct input_dev *beep; | ||
| 61 | struct work_struct beep_work; | ||
| 62 | int beep_rate; | ||
| 63 | #endif | ||
| 64 | }; | ||
| 65 | |||
| 66 | static const struct reg_default cs42l56_reg_defaults[] = { | ||
| 67 | { 1, 0x56 }, /* r01 - ID 1 */ | ||
| 68 | { 2, 0x04 }, /* r02 - ID 2 */ | ||
| 69 | { 3, 0x7f }, /* r03 - Power Ctl 1 */ | ||
| 70 | { 4, 0xff }, /* r04 - Power Ctl 2 */ | ||
| 71 | { 5, 0x00 }, /* ro5 - Clocking Ctl 1 */ | ||
| 72 | { 6, 0x0b }, /* r06 - Clocking Ctl 2 */ | ||
| 73 | { 7, 0x00 }, /* r07 - Serial Format */ | ||
| 74 | { 8, 0x05 }, /* r08 - Class H Ctl */ | ||
| 75 | { 9, 0x0c }, /* r09 - Misc Ctl */ | ||
| 76 | { 10, 0x80 }, /* r0a - INT Status */ | ||
| 77 | { 11, 0x00 }, /* r0b - Playback Ctl */ | ||
| 78 | { 12, 0x0c }, /* r0c - DSP Mute Ctl */ | ||
| 79 | { 13, 0x00 }, /* r0d - ADCA Mixer Volume */ | ||
| 80 | { 14, 0x00 }, /* r0e - ADCB Mixer Volume */ | ||
| 81 | { 15, 0x00 }, /* r0f - PCMA Mixer Volume */ | ||
| 82 | { 16, 0x00 }, /* r10 - PCMB Mixer Volume */ | ||
| 83 | { 17, 0x00 }, /* r11 - Analog Input Advisory Volume */ | ||
| 84 | { 18, 0x00 }, /* r12 - Digital Input Advisory Volume */ | ||
| 85 | { 19, 0x00 }, /* r13 - Master A Volume */ | ||
| 86 | { 20, 0x00 }, /* r14 - Master B Volume */ | ||
| 87 | { 21, 0x00 }, /* r15 - Beep Freq / On Time */ | ||
| 88 | { 22, 0x00 }, /* r16 - Beep Volume / Off Time */ | ||
| 89 | { 23, 0x00 }, /* r17 - Beep Tone Ctl */ | ||
| 90 | { 24, 0x88 }, /* r18 - Tone Ctl */ | ||
| 91 | { 25, 0x00 }, /* r19 - Channel Mixer & Swap */ | ||
| 92 | { 26, 0x00 }, /* r1a - AIN Ref Config / ADC Mux */ | ||
| 93 | { 27, 0xa0 }, /* r1b - High-Pass Filter Ctl */ | ||
| 94 | { 28, 0x00 }, /* r1c - Misc ADC Ctl */ | ||
| 95 | { 29, 0x00 }, /* r1d - Gain & Bias Ctl */ | ||
| 96 | { 30, 0x00 }, /* r1e - PGAA Mux & Volume */ | ||
| 97 | { 31, 0x00 }, /* r1f - PGAB Mux & Volume */ | ||
| 98 | { 32, 0x00 }, /* r20 - ADCA Attenuator */ | ||
| 99 | { 33, 0x00 }, /* r21 - ADCB Attenuator */ | ||
| 100 | { 34, 0x00 }, /* r22 - ALC Enable & Attack Rate */ | ||
| 101 | { 35, 0xbf }, /* r23 - ALC Release Rate */ | ||
| 102 | { 36, 0x00 }, /* r24 - ALC Threshold */ | ||
| 103 | { 37, 0x00 }, /* r25 - Noise Gate Ctl */ | ||
| 104 | { 38, 0x00 }, /* r26 - ALC, Limiter, SFT, ZeroCross */ | ||
| 105 | { 39, 0x00 }, /* r27 - Analog Mute, LO & HP Mux */ | ||
