aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/sound/tas2552.txt26
-rw-r--r--include/sound/tas2552-plat.h25
-rw-r--r--sound/soc/codecs/Kconfig5
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/tas2552.c540
-rw-r--r--sound/soc/codecs/tas2552.h129
6 files changed, 727 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/tas2552.txt b/Documentation/devicetree/bindings/sound/tas2552.txt
new file mode 100644
index 000000000000..55e2a0af5645
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tas2552.txt
@@ -0,0 +1,26 @@
1Texas Instruments - tas2552 Codec module
2
3The tas2552 serial control bus communicates through I2C protocols
4
5Required properties:
6 - compatible - One of:
7 "ti,tas2552" - TAS2552
8 - reg - I2C slave address
9 - supply-*: Required supply regulators are:
10 "vbat" battery voltage
11 "iovdd" I/O Voltage
12 "avdd" Analog DAC Voltage
13
14Optional properties:
15 - enable-gpio - gpio pin to enable/disable the device
16
17Example:
18
19tas2552: tas2552@41 {
20 compatible = "ti,tas2552";
21 reg = <0x41>;
22 enable-gpio = <&gpio4 2 GPIO_ACTIVE_HIGH>;
23};
24
25For more product information please see the link below:
26http://www.ti.com/product/TAS2552
diff --git a/include/sound/tas2552-plat.h b/include/sound/tas2552-plat.h
new file mode 100644
index 000000000000..65e7627ba38e
--- /dev/null
+++ b/include/sound/tas2552-plat.h
@@ -0,0 +1,25 @@
1/*
2 * TAS2552 driver platform header
3 *
4 * Copyright (C) 2014 Texas Instruments Inc.
5 *
6 * Author: Dan Murphy <dmurphy@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef TAS2552_PLAT_H
19#define TAS2552_PLAT_H
20
21struct tas2552_platform_data {
22 int enable_gpio;
23};
24
25#endif
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index cbfa1e18f651..480881747ec5 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -91,6 +91,7 @@ config SND_SOC_ALL_CODECS
91 select SND_SOC_STA350 if I2C 91 select SND_SOC_STA350 if I2C
92 select SND_SOC_STA529 if I2C 92 select SND_SOC_STA529 if I2C
93 select SND_SOC_STAC9766 if SND_SOC_AC97_BUS 93 select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
94 select SND_SOC_TAS2552 if I2C
94 select SND_SOC_TAS5086 if I2C 95 select SND_SOC_TAS5086 if I2C
95 select SND_SOC_TLV320AIC23_I2C if I2C 96 select SND_SOC_TLV320AIC23_I2C if I2C
96 select SND_SOC_TLV320AIC23_SPI if SPI_MASTER 97 select SND_SOC_TLV320AIC23_SPI if SPI_MASTER
@@ -513,6 +514,10 @@ config SND_SOC_STA529
513config SND_SOC_STAC9766 514config SND_SOC_STAC9766
514 tristate 515 tristate
515 516
517config SND_SOC_TAS2552
518 tristate "Texas Instruments TAS2552 Mono Audio amplifier"
519 depends on I2C
520
516config SND_SOC_TAS5086 521config SND_SOC_TAS5086
517 tristate "Texas Instruments TAS5086 speaker amplifier" 522 tristate "Texas Instruments TAS5086 speaker amplifier"
518 depends on I2C 523 depends on I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index be3377b8d73f..d79de052ef8e 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -160,6 +160,7 @@ snd-soc-wm-hubs-objs := wm_hubs.o
160# Amp 160# Amp
161snd-soc-max9877-objs := max9877.o 161snd-soc-max9877-objs := max9877.o
162snd-soc-tpa6130a2-objs := tpa6130a2.o 162snd-soc-tpa6130a2-objs := tpa6130a2.o
163snd-soc-tas2552-objs := tas2552.o
163 164
164obj-$(CONFIG_SND_SOC_88PM860X) += snd-soc-88pm860x.o 165obj-$(CONFIG_SND_SOC_88PM860X) += snd-soc-88pm860x.o
165obj-$(CONFIG_SND_SOC_AB8500_CODEC) += snd-soc-ab8500-codec.o 166obj-$(CONFIG_SND_SOC_AB8500_CODEC) += snd-soc-ab8500-codec.o
@@ -251,6 +252,7 @@ obj-$(CONFIG_SND_SOC_STA32X) += snd-soc-sta32x.o
251obj-$(CONFIG_SND_SOC_STA350) += snd-soc-sta350.o 252obj-$(CONFIG_SND_SOC_STA350) += snd-soc-sta350.o
252obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o 253obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o
253obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o 254obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o
255obj-$(CONFIG_SND_SOC_TAS2552) += snd-soc-tas2552.o
254obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o 256obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o
255obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o 257obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o
256obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o 258obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
new file mode 100644
index 000000000000..f0760af5a21e
--- /dev/null
+++ b/sound/soc/codecs/tas2552.c
@@ -0,0 +1,540 @@
1/*
2 * tas2552.c - ALSA SoC Texas Instruments TAS2552 Mono Audio Amplifier
3 *
4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
5 *
6 * Author: Dan Murphy <dmurphy@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#include <linux/module.h>
19#include <linux/errno.h>
20#include <linux/device.h>
21#include <linux/i2c.h>
22#include <linux/gpio.h>
23#include <linux/of_gpio.h>
24#include <linux/pm_runtime.h>
25#include <linux/regmap.h>
26#include <linux/slab.h>
27
28#include <linux/gpio/consumer.h>
29#include <linux/regulator/consumer.h>
30
31#include <sound/pcm.h>
32#include <sound/pcm_params.h>
33#include <sound/soc.h>
34#include <sound/soc-dapm.h>
35#include <sound/tlv.h>
36#include <sound/tas2552-plat.h>
37
38#include "tas2552.h"
39
40static struct reg_default tas2552_reg_defs[] = {
41 {TAS2552_CFG_1, 0x22},
42 {TAS2552_CFG_3, 0x80},
43 {TAS2552_DOUT, 0x00},
44 {TAS2552_OUTPUT_DATA, 0xc0},
45 {TAS2552_PDM_CFG, 0x01},
46 {TAS2552_PGA_GAIN, 0x00},
47 {TAS2552_BOOST_PT_CTRL, 0x0f},
48 {TAS2552_RESERVED_0D, 0x00},
49 {TAS2552_LIMIT_RATE_HYS, 0x08},
50 {TAS2552_CFG_2, 0xef},
51 {TAS2552_SER_CTRL_1, 0x00},
52 {TAS2552_SER_CTRL_2, 0x00},
53 {TAS2552_PLL_CTRL_1, 0x10},
54 {TAS2552_PLL_CTRL_2, 0x00},
55 {TAS2552_PLL_CTRL_3, 0x00},
56 {TAS2552_BTIP, 0x8f},
57 {TAS2552_BTS_CTRL, 0x80},
58 {TAS2552_LIMIT_RELEASE, 0x04},
59 {TAS2552_LIMIT_INT_COUNT, 0x00},
60 {TAS2552_EDGE_RATE_CTRL, 0x40},
61 {TAS2552_VBAT_DATA, 0x00},
62};
63
64#define TAS2552_NUM_SUPPLIES 3
65static const char *tas2552_supply_names[TAS2552_NUM_SUPPLIES] = {
66 "vbat", /* vbat voltage */
67 "iovdd", /* I/O Voltage */
68 "avdd", /* Analog DAC Voltage */
69};
70
71struct tas2552_data {
72 struct snd_soc_codec *codec;
73 struct regmap *regmap;
74 struct i2c_client *tas2552_client;
75 struct regulator_bulk_data supplies[TAS2552_NUM_SUPPLIES];
76 struct gpio_desc *enable_gpio;
77 unsigned char regs[TAS2552_VBAT_DATA];
78 unsigned int mclk;
79};
80
81static void tas2552_sw_shutdown(struct tas2552_data *tas_data, int sw_shutdown)
82{
83 u8 cfg1_reg;
84
85 if (sw_shutdown)
86 cfg1_reg = 0;
87 else
88 cfg1_reg = TAS2552_SWS_MASK;
89
90 snd_soc_update_bits(tas_data->codec, TAS2552_CFG_1,
91 TAS2552_SWS_MASK, cfg1_reg);
92}
93
94static int tas2552_hw_params(struct snd_pcm_substream *substream,
95 struct snd_pcm_hw_params *params,
96 struct snd_soc_dai *dai)
97{
98 struct snd_soc_codec *codec = dai->codec;
99 struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev);
100 int sample_rate, pll_clk;
101 int d;
102 u8 p, j;
103
104 /* Turn on Class D amplifier */
105 snd_