xref: /linux/sound/soc/codecs/sta350.c (revision 33e02dc69afbd8f1b85a51d74d72f139ba4ca623)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
22439ea1fSSven Brandau /*
32439ea1fSSven Brandau  * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system
42439ea1fSSven Brandau  *
52439ea1fSSven Brandau  * Copyright: 2014 Raumfeld GmbH
62439ea1fSSven Brandau  * Author: Sven Brandau <info@brandau.biz>
72439ea1fSSven Brandau  *
82439ea1fSSven Brandau  * based on code from:
92439ea1fSSven Brandau  *	Raumfeld GmbH
102439ea1fSSven Brandau  *	  Johannes Stezenbach <js@sig21.net>
112439ea1fSSven Brandau  *	Wolfson Microelectronics PLC.
122439ea1fSSven Brandau  *	  Mark Brown <broonie@opensource.wolfsonmicro.com>
132439ea1fSSven Brandau  *	Freescale Semiconductor, Inc.
142439ea1fSSven Brandau  *	  Timur Tabi <timur@freescale.com>
152439ea1fSSven Brandau  */
162439ea1fSSven Brandau 
172439ea1fSSven Brandau #define pr_fmt(fmt) KBUILD_MODNAME ":%s:%d: " fmt, __func__, __LINE__
182439ea1fSSven Brandau 
192439ea1fSSven Brandau #include <linux/module.h>
202439ea1fSSven Brandau #include <linux/moduleparam.h>
212439ea1fSSven Brandau #include <linux/init.h>
222439ea1fSSven Brandau #include <linux/delay.h>
232439ea1fSSven Brandau #include <linux/pm.h>
242439ea1fSSven Brandau #include <linux/i2c.h>
25340d79a1SRob Herring #include <linux/of.h>
262439ea1fSSven Brandau #include <linux/regmap.h>
272439ea1fSSven Brandau #include <linux/regulator/consumer.h>
282439ea1fSSven Brandau #include <linux/gpio/consumer.h>
292439ea1fSSven Brandau #include <linux/slab.h>
302439ea1fSSven Brandau #include <sound/core.h>
312439ea1fSSven Brandau #include <sound/pcm.h>
322439ea1fSSven Brandau #include <sound/pcm_params.h>
332439ea1fSSven Brandau #include <sound/soc.h>
342439ea1fSSven Brandau #include <sound/soc-dapm.h>
352439ea1fSSven Brandau #include <sound/initval.h>
362439ea1fSSven Brandau #include <sound/tlv.h>
372439ea1fSSven Brandau 
382439ea1fSSven Brandau #include <sound/sta350.h>
392439ea1fSSven Brandau #include "sta350.h"
402439ea1fSSven Brandau 
412439ea1fSSven Brandau #define STA350_RATES (SNDRV_PCM_RATE_32000 | \
422439ea1fSSven Brandau 		      SNDRV_PCM_RATE_44100 | \
432439ea1fSSven Brandau 		      SNDRV_PCM_RATE_48000 | \
442439ea1fSSven Brandau 		      SNDRV_PCM_RATE_88200 | \
452439ea1fSSven Brandau 		      SNDRV_PCM_RATE_96000 | \
462439ea1fSSven Brandau 		      SNDRV_PCM_RATE_176400 | \
472439ea1fSSven Brandau 		      SNDRV_PCM_RATE_192000)
482439ea1fSSven Brandau 
492439ea1fSSven Brandau #define STA350_FORMATS \
502ac5b982SCharles Keepax 	(SNDRV_PCM_FMTBIT_S16_LE  | SNDRV_PCM_FMTBIT_S18_3LE | \
512ac5b982SCharles Keepax 	 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_3LE | \
522ac5b982SCharles Keepax 	 SNDRV_PCM_FMTBIT_S24_LE  | SNDRV_PCM_FMTBIT_S32_LE)
532439ea1fSSven Brandau 
542439ea1fSSven Brandau /* Power-up register defaults */
552439ea1fSSven Brandau static const struct reg_default sta350_regs[] = {
562439ea1fSSven Brandau 	{  0x0, 0x63 },
572439ea1fSSven Brandau 	{  0x1, 0x80 },
582439ea1fSSven Brandau 	{  0x2, 0xdf },
592439ea1fSSven Brandau 	{  0x3, 0x40 },
602439ea1fSSven Brandau 	{  0x4, 0xc2 },
612439ea1fSSven Brandau 	{  0x5, 0x5c },
622439ea1fSSven Brandau 	{  0x6, 0x00 },
632439ea1fSSven Brandau 	{  0x7, 0xff },
642439ea1fSSven Brandau 	{  0x8, 0x60 },
652439ea1fSSven Brandau 	{  0x9, 0x60 },
662439ea1fSSven Brandau 	{  0xa, 0x60 },
672439ea1fSSven Brandau 	{  0xb, 0x00 },
682439ea1fSSven Brandau 	{  0xc, 0x00 },
692439ea1fSSven Brandau 	{  0xd, 0x00 },
702439ea1fSSven Brandau 	{  0xe, 0x00 },
712439ea1fSSven Brandau 	{  0xf, 0x40 },
722439ea1fSSven Brandau 	{ 0x10, 0x80 },
732439ea1fSSven Brandau 	{ 0x11, 0x77 },
742439ea1fSSven Brandau 	{ 0x12, 0x6a },
752439ea1fSSven Brandau 	{ 0x13, 0x69 },
762439ea1fSSven Brandau 	{ 0x14, 0x6a },
772439ea1fSSven Brandau 	{ 0x15, 0x69 },
782439ea1fSSven Brandau 	{ 0x16, 0x00 },
792439ea1fSSven Brandau 	{ 0x17, 0x00 },
802439ea1fSSven Brandau 	{ 0x18, 0x00 },
812439ea1fSSven Brandau 	{ 0x19, 0x00 },
822439ea1fSSven Brandau 	{ 0x1a, 0x00 },
832439ea1fSSven Brandau 	{ 0x1b, 0x00 },
842439ea1fSSven Brandau 	{ 0x1c, 0x00 },
852439ea1fSSven Brandau 	{ 0x1d, 0x00 },
862439ea1fSSven Brandau 	{ 0x1e, 0x00 },
872439ea1fSSven Brandau 	{ 0x1f, 0x00 },
882439ea1fSSven Brandau 	{ 0x20, 0x00 },
892439ea1fSSven Brandau 	{ 0x21, 0x00 },
902439ea1fSSven Brandau 	{ 0x22, 0x00 },
912439ea1fSSven Brandau 	{ 0x23, 0x00 },
922439ea1fSSven Brandau 	{ 0x24, 0x00 },
932439ea1fSSven Brandau 	{ 0x25, 0x00 },
942439ea1fSSven Brandau 	{ 0x26, 0x00 },
952439ea1fSSven Brandau 	{ 0x27, 0x2a },
962439ea1fSSven Brandau 	{ 0x28, 0xc0 },
972439ea1fSSven Brandau 	{ 0x29, 0xf3 },
982439ea1fSSven Brandau 	{ 0x2a, 0x33 },
992439ea1fSSven Brandau 	{ 0x2b, 0x00 },
1002439ea1fSSven Brandau 	{ 0x2c, 0x0c },
1012439ea1fSSven Brandau 	{ 0x31, 0x00 },
1022439ea1fSSven Brandau 	{ 0x36, 0x00 },
1032439ea1fSSven Brandau 	{ 0x37, 0x00 },
1042439ea1fSSven Brandau 	{ 0x38, 0x00 },
1052439ea1fSSven Brandau 	{ 0x39, 0x01 },
1062439ea1fSSven Brandau 	{ 0x3a, 0xee },
1072439ea1fSSven Brandau 	{ 0x3b, 0xff },
1082439ea1fSSven Brandau 	{ 0x3c, 0x7e },
1092439ea1fSSven Brandau 	{ 0x3d, 0xc0 },
1102439ea1fSSven Brandau 	{ 0x3e, 0x26 },
1112439ea1fSSven Brandau 	{ 0x3f, 0x00 },
1122439ea1fSSven Brandau 	{ 0x48, 0x00 },
1132439ea1fSSven Brandau 	{ 0x49, 0x00 },
1142439ea1fSSven Brandau 	{ 0x4a, 0x00 },
1152439ea1fSSven Brandau 	{ 0x4b, 0x04 },
1162439ea1fSSven Brandau 	{ 0x4c, 0x00 },
1172439ea1fSSven Brandau };
1182439ea1fSSven Brandau 
1192439ea1fSSven Brandau static const struct regmap_range sta350_write_regs_range[] = {
1202439ea1fSSven Brandau 	regmap_reg_range(STA350_CONFA,  STA350_AUTO2),
1212439ea1fSSven Brandau 	regmap_reg_range(STA350_C1CFG,  STA350_FDRC2),
1222439ea1fSSven Brandau 	regmap_reg_range(STA350_EQCFG,  STA350_EVOLRES),
1232439ea1fSSven Brandau 	regmap_reg_range(STA350_NSHAPE, STA350_MISC2),
1242439ea1fSSven Brandau };
1252439ea1fSSven Brandau 
1262439ea1fSSven Brandau static const struct regmap_range sta350_read_regs_range[] = {
1272439ea1fSSven Brandau 	regmap_reg_range(STA350_CONFA,  STA350_AUTO2),
1282439ea1fSSven Brandau 	regmap_reg_range(STA350_C1CFG,  STA350_STATUS),
1292439ea1fSSven Brandau 	regmap_reg_range(STA350_EQCFG,  STA350_EVOLRES),
1302439ea1fSSven Brandau 	regmap_reg_range(STA350_NSHAPE, STA350_MISC2),
1312439ea1fSSven Brandau };
1322439ea1fSSven Brandau 
1332439ea1fSSven Brandau static const struct regmap_range sta350_volatile_regs_range[] = {
1342439ea1fSSven Brandau 	regmap_reg_range(STA350_CFADDR2, STA350_CFUD),
1352439ea1fSSven Brandau 	regmap_reg_range(STA350_STATUS,  STA350_STATUS),
1362439ea1fSSven Brandau };
1372439ea1fSSven Brandau 
1382439ea1fSSven Brandau static const struct regmap_access_table sta350_write_regs = {
1392439ea1fSSven Brandau 	.yes_ranges =	sta350_write_regs_range,
1402439ea1fSSven Brandau 	.n_yes_ranges =	ARRAY_SIZE(sta350_write_regs_range),
1412439ea1fSSven Brandau };
1422439ea1fSSven Brandau 
1432439ea1fSSven Brandau static const struct regmap_access_table sta350_read_regs = {
1442439ea1fSSven Brandau 	.yes_ranges =	sta350_read_regs_range,
1452439ea1fSSven Brandau 	.n_yes_ranges =	ARRAY_SIZE(sta350_read_regs_range),
1462439ea1fSSven Brandau };
1472439ea1fSSven Brandau 
1482439ea1fSSven Brandau static const struct regmap_access_table sta350_volatile_regs = {
1492439ea1fSSven Brandau 	.yes_ranges =	sta350_volatile_regs_range,
1502439ea1fSSven Brandau 	.n_yes_ranges =	ARRAY_SIZE(sta350_volatile_regs_range),
1512439ea1fSSven Brandau };
1522439ea1fSSven Brandau 
1532439ea1fSSven Brandau /* regulator power supply names */
1542439ea1fSSven Brandau static const char * const sta350_supply_names[] = {
1552439ea1fSSven Brandau 	"vdd-dig",	/* digital supply, 3.3V */
1562439ea1fSSven Brandau 	"vdd-pll",	/* pll supply, 3.3V */
1572439ea1fSSven Brandau 	"vcc"		/* power amp supply, 5V - 26V */
1582439ea1fSSven Brandau };
1592439ea1fSSven Brandau 
1602439ea1fSSven Brandau /* codec private data */
1612439ea1fSSven Brandau struct sta350_priv {
1622439ea1fSSven Brandau 	struct regmap *regmap;
1632439ea1fSSven Brandau 	struct regulator_bulk_data supplies[ARRAY_SIZE(sta350_supply_names)];
1642439ea1fSSven Brandau 	struct sta350_platform_data *pdata;
1652439ea1fSSven Brandau 
1662439ea1fSSven Brandau 	unsigned int mclk;
1672439ea1fSSven Brandau 	unsigned int format;
1682439ea1fSSven Brandau 
1692439ea1fSSven Brandau 	u32 coef_shadow[STA350_COEF_COUNT];
1702439ea1fSSven Brandau 	int shutdown;
1712439ea1fSSven Brandau 
1722439ea1fSSven Brandau 	struct gpio_desc *gpiod_nreset;
1732439ea1fSSven Brandau 	struct gpio_desc *gpiod_power_down;
1742439ea1fSSven Brandau 
1752439ea1fSSven Brandau 	struct mutex coeff_lock;
1762439ea1fSSven Brandau };
1772439ea1fSSven Brandau 
1782439ea1fSSven Brandau static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12750, 50, 1);
1792439ea1fSSven Brandau static const DECLARE_TLV_DB_SCALE(chvol_tlv, -7950, 50, 1);
1802439ea1fSSven Brandau static const DECLARE_TLV_DB_SCALE(tone_tlv, -1200, 200, 0);
1812439ea1fSSven Brandau 
1822439ea1fSSven Brandau static const char * const sta350_drc_ac[] = {
1832439ea1fSSven Brandau 	"Anti-Clipping", "Dynamic Range Compression"
1842439ea1fSSven Brandau };
1852439ea1fSSven Brandau static const char * const sta350_auto_gc_mode[] = {
1862439ea1fSSven Brandau 	"User", "AC no clipping", "AC limited clipping (10%)",
1872439ea1fSSven Brandau 	"DRC nighttime listening mode"
1882439ea1fSSven Brandau };
1892439ea1fSSven Brandau static const char * const sta350_auto_xo_mode[] = {
1902439ea1fSSven Brandau 	"User", "80Hz", "100Hz", "120Hz", "140Hz", "160Hz", "180Hz",
1912439ea1fSSven Brandau 	"200Hz", "220Hz", "240Hz", "260Hz", "280Hz", "300Hz", "320Hz",
1922439ea1fSSven Brandau 	"340Hz", "360Hz"
1932439ea1fSSven Brandau };
1942439ea1fSSven Brandau static const char * const sta350_binary_output[] = {
1952439ea1fSSven Brandau 	"FFX 3-state output - normal operation", "Binary output"
1962439ea1fSSven Brandau };
1972439ea1fSSven Brandau static const char * const sta350_limiter_select[] = {
1982439ea1fSSven Brandau 	"Limiter Disabled", "Limiter #1", "Limiter #2"
1992439ea1fSSven Brandau };
2002439ea1fSSven Brandau static const char * const sta350_limiter_attack_rate[] = {
2012439ea1fSSven Brandau 	"3.1584", "2.7072", "2.2560", "1.8048", "1.3536", "0.9024",
2022439ea1fSSven Brandau 	"0.4512", "0.2256", "0.1504", "0.1123", "0.0902", "0.0752",
2032439ea1fSSven Brandau 	"0.0645", "0.0564", "0.0501", "0.0451"
2042439ea1fSSven Brandau };
2052439ea1fSSven Brandau static const char * const sta350_limiter_release_rate[] = {
2062439ea1fSSven Brandau 	"0.5116", "0.1370", "0.0744", "0.0499", "0.0360", "0.0299",
2072439ea1fSSven Brandau 	"0.0264", "0.0208", "0.0198", "0.0172", "0.0147", "0.0137",
2082439ea1fSSven Brandau 	"0.0134", "0.0117", "0.0110", "0.0104"
2092439ea1fSSven Brandau };
2102439ea1fSSven Brandau static const char * const sta350_noise_shaper_type[] = {
2112439ea1fSSven Brandau 	"Third order", "Fourth order"
2122439ea1fSSven Brandau };
2132439ea1fSSven Brandau 
2142439ea1fSSven Brandau static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_attack_tlv,
2152439ea1fSSven Brandau 	0, 7, TLV_DB_SCALE_ITEM(-1200, 200, 0),
2162439ea1fSSven Brandau 	8, 16, TLV_DB_SCALE_ITEM(300, 100, 0),
2172439ea1fSSven Brandau );
2182439ea1fSSven Brandau 
2192439ea1fSSven Brandau static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_release_tlv,
2202439ea1fSSven Brandau 	0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
2212439ea1fSSven Brandau 	1, 1, TLV_DB_SCALE_ITEM(-2900, 0, 0),
2222439ea1fSSven Brandau 	2, 2, TLV_DB_SCALE_ITEM(-2000, 0, 0),
2232439ea1fSSven Brandau 	3, 8, TLV_DB_SCALE_ITEM(-1400, 200, 0),
2242439ea1fSSven Brandau 	8, 16, TLV_DB_SCALE_ITEM(-700, 100, 0),
2252439ea1fSSven Brandau );
2262439ea1fSSven Brandau 
2272439ea1fSSven Brandau static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_attack_tlv,
2282439ea1fSSven Brandau 	0, 7, TLV_DB_SCALE_ITEM(-3100, 200, 0),
2292439ea1fSSven Brandau 	8, 13, TLV_DB_SCALE_ITEM(-1600, 100, 0),
2302439ea1fSSven Brandau 	14, 16, TLV_DB_SCALE_ITEM(-1000, 300, 0),
2312439ea1fSSven Brandau );
2322439ea1fSSven Brandau 
2332439ea1fSSven Brandau static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_release_tlv,
2342439ea1fSSven Brandau 	0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
2352439ea1fSSven Brandau 	1, 2, TLV_DB_SCALE_ITEM(-3800, 200, 0),
2362439ea1fSSven Brandau 	3, 4, TLV_DB_SCALE_ITEM(-3300, 200, 0),
2372439ea1fSSven Brandau 	5, 12, TLV_DB_SCALE_ITEM(-3000, 200, 0),
2382439ea1fSSven Brandau 	13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0),
2392439ea1fSSven Brandau );
2402439ea1fSSven Brandau 
2412439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_drc_ac_enum,
2422439ea1fSSven Brandau 			    STA350_CONFD, STA350_CONFD_DRC_SHIFT,
2432439ea1fSSven Brandau 			    sta350_drc_ac);
2442439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_noise_shaper_enum,
2452439ea1fSSven Brandau 			    STA350_CONFE, STA350_CONFE_NSBW_SHIFT,
2462439ea1fSSven Brandau 			    sta350_noise_shaper_type);
2472439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_auto_gc_enum,
2482439ea1fSSven Brandau 			    STA350_AUTO1, STA350_AUTO1_AMGC_SHIFT,
2492439ea1fSSven Brandau 			    sta350_auto_gc_mode);
2502439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_auto_xo_enum,
2512439ea1fSSven Brandau 			    STA350_AUTO2, STA350_AUTO2_XO_SHIFT,
2522439ea1fSSven Brandau 			    sta350_auto_xo_mode);
2532439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch1_enum,
2542439ea1fSSven Brandau 			    STA350_C1CFG, STA350_CxCFG_BO_SHIFT,
2552439ea1fSSven Brandau 			    sta350_binary_output);
2562439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch2_enum,
2572439ea1fSSven Brandau 			    STA350_C2CFG, STA350_CxCFG_BO_SHIFT,
2582439ea1fSSven Brandau 			    sta350_binary_output);
2592439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch3_enum,
2602439ea1fSSven Brandau 			    STA350_C3CFG, STA350_CxCFG_BO_SHIFT,
2612439ea1fSSven Brandau 			    sta350_binary_output);
2622439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch1_enum,
2632439ea1fSSven Brandau 			    STA350_C1CFG, STA350_CxCFG_LS_SHIFT,
2642439ea1fSSven Brandau 			    sta350_limiter_select);
2652439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch2_enum,
2662439ea1fSSven Brandau 			    STA350_C2CFG, STA350_CxCFG_LS_SHIFT,
2672439ea1fSSven Brandau 			    sta350_limiter_select);
2682439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch3_enum,
2692439ea1fSSven Brandau 			    STA350_C3CFG, STA350_CxCFG_LS_SHIFT,
2702439ea1fSSven Brandau 			    sta350_limiter_select);
2712439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_limiter1_attack_rate_enum,
2722439ea1fSSven Brandau 			    STA350_L1AR, STA350_LxA_SHIFT,
2732439ea1fSSven Brandau 			    sta350_limiter_attack_rate);
2742439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_limiter2_attack_rate_enum,
2752439ea1fSSven Brandau 			    STA350_L2AR, STA350_LxA_SHIFT,
2762439ea1fSSven Brandau 			    sta350_limiter_attack_rate);
2772439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_limiter1_release_rate_enum,
2782439ea1fSSven Brandau 			    STA350_L1AR, STA350_LxR_SHIFT,
2792439ea1fSSven Brandau 			    sta350_limiter_release_rate);
2802439ea1fSSven Brandau static SOC_ENUM_SINGLE_DECL(sta350_limiter2_release_rate_enum,
2812439ea1fSSven Brandau 			    STA350_L2AR, STA350_LxR_SHIFT,
2822439ea1fSSven Brandau 			    sta350_limiter_release_rate);
2832439ea1fSSven Brandau 
2842439ea1fSSven Brandau /*
2852439ea1fSSven Brandau  * byte array controls for setting biquad, mixer, scaling coefficients;
2862439ea1fSSven Brandau  * for biquads all five coefficients need to be set in one go,
2872439ea1fSSven Brandau  * mixer and pre/postscale coefs can be set individually;
2882439ea1fSSven Brandau  * each coef is 24bit, the bytes are ordered in the same way
2892439ea1fSSven Brandau  * as given in the STA350 data sheet (big endian; b1, b2, a1, a2, b0)
2902439ea1fSSven Brandau  */
2912439ea1fSSven Brandau 
sta350_coefficient_info(struct snd_kcontrol * kcontrol,struct snd_ctl_elem_info * uinfo)2922439ea1fSSven Brandau static int sta350_coefficient_info(struct snd_kcontrol *kcontrol,
2932439ea1fSSven Brandau 				   struct snd_ctl_elem_info *uinfo)
2942439ea1fSSven Brandau {
2952439ea1fSSven Brandau 	int numcoef = kcontrol->private_value >> 16;
2962439ea1fSSven Brandau 	uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
2972439ea1fSSven Brandau 	uinfo->count = 3 * numcoef;
2982439ea1fSSven Brandau 	return 0;
2992439ea1fSSven Brandau }
3002439ea1fSSven Brandau 
sta350_coefficient_get(struct snd_kcontrol * kcontrol,struct snd_ctl_elem_value * ucontrol)3012439ea1fSSven Brandau static int sta350_coefficient_get(struct snd_kcontrol *kcontrol,
3022439ea1fSSven Brandau 				  struct snd_ctl_elem_value *ucontrol)
3032439ea1fSSven Brandau {
3041f6440c5SKuninori Morimoto 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
3051f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
3062439ea1fSSven Brandau 	int numcoef = kcontrol->private_value >> 16;
3072439ea1fSSven Brandau 	int index = kcontrol->private_value & 0xffff;
3082439ea1fSSven Brandau 	unsigned int cfud, val;
3092439ea1fSSven Brandau 	int i, ret = 0;
3102439ea1fSSven Brandau 
3112439ea1fSSven Brandau 	mutex_lock(&sta350->coeff_lock);
3122439ea1fSSven Brandau 
3132439ea1fSSven Brandau 	/* preserve reserved bits in STA350_CFUD */
3142439ea1fSSven Brandau 	regmap_read(sta350->regmap, STA350_CFUD, &cfud);
3152439ea1fSSven Brandau 	cfud &= 0xf0;
3162439ea1fSSven Brandau 	/*
3172439ea1fSSven Brandau 	 * chip documentation does not say if the bits are self clearing,
3182439ea1fSSven Brandau 	 * so do it explicitly
3192439ea1fSSven Brandau 	 */
3202439ea1fSSven Brandau 	regmap_write(sta350->regmap, STA350_CFUD, cfud);
3212439ea1fSSven Brandau 
3222439ea1fSSven Brandau 	regmap_write(sta350->regmap, STA350_CFADDR2, index);
3232439ea1fSSven Brandau 	if (numcoef == 1) {
3242439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x04);
3252439ea1fSSven Brandau 	} else if (numcoef == 5) {
3262439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x08);
3272439ea1fSSven Brandau 	} else {
3282439ea1fSSven Brandau 		ret = -EINVAL;
3292439ea1fSSven Brandau 		goto exit_unlock;
3302439ea1fSSven Brandau 	}
3312439ea1fSSven Brandau 
3322439ea1fSSven Brandau 	for (i = 0; i < 3 * numcoef; i++) {
3332439ea1fSSven Brandau 		regmap_read(sta350->regmap, STA350_B1CF1 + i, &val);
3342439ea1fSSven Brandau 		ucontrol->value.bytes.data[i] = val;
3352439ea1fSSven Brandau 	}
3362439ea1fSSven Brandau 
3372439ea1fSSven Brandau exit_unlock:
3382439ea1fSSven Brandau 	mutex_unlock(&sta350->coeff_lock);
3392439ea1fSSven Brandau 
3402439ea1fSSven Brandau 	return ret;
3412439ea1fSSven Brandau }
3422439ea1fSSven Brandau 
sta350_coefficient_put(struct snd_kcontrol * kcontrol,struct snd_ctl_elem_value * ucontrol)3432439ea1fSSven Brandau static int sta350_coefficient_put(struct snd_kcontrol *kcontrol,
3442439ea1fSSven Brandau 				  struct snd_ctl_elem_value *ucontrol)
3452439ea1fSSven Brandau {
3461f6440c5SKuninori Morimoto 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
3471f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
3482439ea1fSSven Brandau 	int numcoef = kcontrol->private_value >> 16;
3492439ea1fSSven Brandau 	int index = kcontrol->private_value & 0xffff;
3502439ea1fSSven Brandau 	unsigned int cfud;
3512439ea1fSSven Brandau 	int i;
3522439ea1fSSven Brandau 
3532439ea1fSSven Brandau 	/* preserve reserved bits in STA350_CFUD */
3542439ea1fSSven Brandau 	regmap_read(sta350->regmap, STA350_CFUD, &cfud);
3552439ea1fSSven Brandau 	cfud &= 0xf0;
3562439ea1fSSven Brandau 	/*
3572439ea1fSSven Brandau 	 * chip documentation does not say if the bits are self clearing,
3582439ea1fSSven Brandau 	 * so do it explicitly
3592439ea1fSSven Brandau 	 */
3602439ea1fSSven Brandau 	regmap_write(sta350->regmap, STA350_CFUD, cfud);
3612439ea1fSSven Brandau 
3622439ea1fSSven Brandau 	regmap_write(sta350->regmap, STA350_CFADDR2, index);
3632439ea1fSSven Brandau 	for (i = 0; i < numcoef && (index + i < STA350_COEF_COUNT); i++)
3642439ea1fSSven Brandau 		sta350->coef_shadow[index + i] =
3652439ea1fSSven Brandau 			  (ucontrol->value.bytes.data[3 * i] << 16)
3662439ea1fSSven Brandau 			| (ucontrol->value.bytes.data[3 * i + 1] << 8)
3672439ea1fSSven Brandau 			| (ucontrol->value.bytes.data[3 * i + 2]);
3682439ea1fSSven Brandau 	for (i = 0; i < 3 * numcoef; i++)
3692439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_B1CF1 + i,
3702439ea1fSSven Brandau 			     ucontrol->value.bytes.data[i]);
3712439ea1fSSven Brandau 	if (numcoef == 1)
3722439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01);
3732439ea1fSSven Brandau 	else if (numcoef == 5)
3742439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x02);
3752439ea1fSSven Brandau 	else
3762439ea1fSSven Brandau 		return -EINVAL;
3772439ea1fSSven Brandau 
3782439ea1fSSven Brandau 	return 0;
3792439ea1fSSven Brandau }
3802439ea1fSSven Brandau 
sta350_sync_coef_shadow(struct snd_soc_component * component)3811f6440c5SKuninori Morimoto static int sta350_sync_coef_shadow(struct snd_soc_component *component)
3822439ea1fSSven Brandau {
3831f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
3842439ea1fSSven Brandau 	unsigned int cfud;
3852439ea1fSSven Brandau 	int i;
3862439ea1fSSven Brandau 
3872439ea1fSSven Brandau 	/* preserve reserved bits in STA350_CFUD */
3882439ea1fSSven Brandau 	regmap_read(sta350->regmap, STA350_CFUD, &cfud);
3892439ea1fSSven Brandau 	cfud &= 0xf0;
3902439ea1fSSven Brandau 
3912439ea1fSSven Brandau 	for (i = 0; i < STA350_COEF_COUNT; i++) {
3922439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_CFADDR2, i);
3932439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_B1CF1,
3942439ea1fSSven Brandau 			     (sta350->coef_shadow[i] >> 16) & 0xff);
3952439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_B1CF2,
3962439ea1fSSven Brandau 			     (sta350->coef_shadow[i] >> 8) & 0xff);
3972439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_B1CF3,
3982439ea1fSSven Brandau 			     (sta350->coef_shadow[i]) & 0xff);
3992439ea1fSSven Brandau 		/*
4002439ea1fSSven Brandau 		 * chip documentation does not say if the bits are
4012439ea1fSSven Brandau 		 * self-clearing, so do it explicitly
4022439ea1fSSven Brandau 		 */
4032439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_CFUD, cfud);
4042439ea1fSSven Brandau 		regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01);
4052439ea1fSSven Brandau 	}
4062439ea1fSSven Brandau 	return 0;
4072439ea1fSSven Brandau }
4082439ea1fSSven Brandau 
sta350_cache_sync(struct snd_soc_component * component)4091f6440c5SKuninori Morimoto static int sta350_cache_sync(struct snd_soc_component *component)
4102439ea1fSSven Brandau {
4111f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
4122439ea1fSSven Brandau 	unsigned int mute;
4132439ea1fSSven Brandau 	int rc;
4142439ea1fSSven Brandau 
4152439ea1fSSven Brandau 	/* mute during register sync */
4162439ea1fSSven Brandau 	regmap_read(sta350->regmap, STA350_CFUD, &mute);
4172439ea1fSSven Brandau 	regmap_write(sta350->regmap, STA350_MMUTE, mute | STA350_MMUTE_MMUTE);
4181f6440c5SKuninori Morimoto 	sta350_sync_coef_shadow(component);
4192439ea1fSSven Brandau 	rc = regcache_sync(sta350->regmap);
4202439ea1fSSven Brandau 	regmap_write(sta350->regmap, STA350_MMUTE, mute);
4212439ea1fSSven Brandau 	return rc;
4222439ea1fSSven Brandau }
4232439ea1fSSven Brandau 
4242439ea1fSSven Brandau #define SINGLE_COEF(xname, index) \
4252439ea1fSSven Brandau {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
4262439ea1fSSven Brandau 	.info = sta350_coefficient_info, \
4272439ea1fSSven Brandau 	.get = sta350_coefficient_get,\
4282439ea1fSSven Brandau 	.put = sta350_coefficient_put, \
4292439ea1fSSven Brandau 	.private_value = index | (1 << 16) }
4302439ea1fSSven Brandau 
4312439ea1fSSven Brandau #define BIQUAD_COEFS(xname, index) \
4322439ea1fSSven Brandau {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
4332439ea1fSSven Brandau 	.info = sta350_coefficient_info, \
4342439ea1fSSven Brandau 	.get = sta350_coefficient_get,\
4352439ea1fSSven Brandau 	.put = sta350_coefficient_put, \
4362439ea1fSSven Brandau 	.private_value = index | (5 << 16) }
4372439ea1fSSven Brandau 
4382439ea1fSSven Brandau static const struct snd_kcontrol_new sta350_snd_controls[] = {
4392439ea1fSSven Brandau SOC_SINGLE_TLV("Master Volume", STA350_MVOL, 0, 0xff, 1, mvol_tlv),
4402439ea1fSSven Brandau /* VOL */
4412439ea1fSSven Brandau SOC_SINGLE_TLV("Ch1 Volume", STA350_C1VOL, 0, 0xff, 1, chvol_tlv),
4422439ea1fSSven Brandau SOC_SINGLE_TLV("Ch2 Volume", STA350_C2VOL, 0, 0xff, 1, chvol_tlv),
4432439ea1fSSven Brandau SOC_SINGLE_TLV("Ch3 Volume", STA350_C3VOL, 0, 0xff, 1, chvol_tlv),
4442439ea1fSSven Brandau /* CONFD */
4452439ea1fSSven Brandau SOC_SINGLE("High Pass Filter Bypass Switch",
4462439ea1fSSven Brandau 	   STA350_CONFD, STA350_CONFD_HPB_SHIFT, 1, 1),
4472439ea1fSSven Brandau SOC_SINGLE("De-emphasis Filter Switch",
4482439ea1fSSven Brandau 	   STA350_CONFD, STA350_CONFD_DEMP_SHIFT, 1, 0),
4492439ea1fSSven Brandau SOC_SINGLE("DSP Bypass Switch",
4502439ea1fSSven Brandau 	   STA350_CONFD, STA350_CONFD_DSPB_SHIFT, 1, 0),
4512439ea1fSSven Brandau SOC_SINGLE("Post-scale Link Switch",
4522439ea1fSSven Brandau 	   STA350_CONFD, STA350_CONFD_PSL_SHIFT, 1, 0),
4532439ea1fSSven Brandau SOC_SINGLE("Biquad Coefficient Link Switch",
4542439ea1fSSven Brandau 	   STA350_CONFD, STA350_CONFD_BQL_SHIFT, 1, 0),
4552439ea1fSSven Brandau SOC_ENUM("Compressor/Limiter Switch", sta350_drc_ac_enum),
4562439ea1fSSven Brandau SOC_ENUM("Noise Shaper Bandwidth", sta350_noise_shaper_enum),
4572439ea1fSSven Brandau SOC_SINGLE("Zero-detect Mute Enable Switch",
4582439ea1fSSven Brandau 	   STA350_CONFD, STA350_CONFD_ZDE_SHIFT, 1, 0),
4592439ea1fSSven Brandau SOC_SINGLE("Submix Mode Switch",
4602439ea1fSSven Brandau 	   STA350_CONFD, STA350_CONFD_SME_SHIFT, 1, 0),
4612439ea1fSSven Brandau /* CONFE */
4622439ea1fSSven Brandau SOC_SINGLE("Zero Cross Switch", STA350_CONFE, STA350_CONFE_ZCE_SHIFT, 1, 0),
4632439ea1fSSven Brandau SOC_SINGLE("Soft Ramp Switch", STA350_CONFE, STA350_CONFE_SVE_SHIFT, 1, 0),
4642439ea1fSSven Brandau /* MUTE */
4652439ea1fSSven Brandau SOC_SINGLE("Master Switch", STA350_MMUTE, STA350_MMUTE_MMUTE_SHIFT, 1, 1),
4662439ea1fSSven Brandau SOC_SINGLE("Ch1 Switch", STA350_MMUTE, STA350_MMUTE_C1M_SHIFT, 1, 1),
4672439ea1fSSven Brandau SOC_SINGLE("Ch2 Switch", STA350_MMUTE, STA350_MMUTE_C2M_SHIFT, 1, 1),
4682439ea1fSSven Brandau SOC_SINGLE("Ch3 Switch", STA350_MMUTE, STA350_MMUTE_C3M_SHIFT, 1, 1),
4692439ea1fSSven Brandau /* AUTOx */
4702439ea1fSSven Brandau SOC_ENUM("Automode GC", sta350_auto_gc_enum),
4712439ea1fSSven Brandau SOC_ENUM("Automode XO", sta350_auto_xo_enum),
4722439ea1fSSven Brandau /* CxCFG */
4732439ea1fSSven Brandau SOC_SINGLE("Ch1 Tone Control Bypass Switch",
4742439ea1fSSven Brandau 	   STA350_C1CFG, STA350_CxCFG_TCB_SHIFT, 1, 0),
4752439ea1fSSven Brandau SOC_SINGLE("Ch2 Tone Control Bypass Switch",
4762439ea1fSSven Brandau 	   STA350_C2CFG, STA350_CxCFG_TCB_SHIFT, 1, 0),
4772439ea1fSSven Brandau SOC_SINGLE("Ch1 EQ Bypass Switch",
4782439ea1fSSven Brandau 	   STA350_C1CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0),
4792439ea1fSSven Brandau SOC_SINGLE("Ch2 EQ Bypass Switch",
4802439ea1fSSven Brandau 	   STA350_C2CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0),
4812439ea1fSSven Brandau SOC_SINGLE("Ch1 Master Volume Bypass Switch",
4822439ea1fSSven Brandau 	   STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
4832439ea1fSSven Brandau SOC_SINGLE("Ch2 Master Volume Bypass Switch",
4842439ea1fSSven Brandau 	   STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
4852439ea1fSSven Brandau SOC_SINGLE("Ch3 Master Volume Bypass Switch",
4862439ea1fSSven Brandau 	   STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
4872439ea1fSSven Brandau SOC_ENUM("Ch1 Binary Output Select", sta350_binary_output_ch1_enum),
4882439ea1fSSven Brandau SOC_ENUM("Ch2 Binary Output Select", sta350_binary_output_ch2_enum),
4892439ea1fSSven Brandau SOC_ENUM("Ch3 Binary Output Select", sta350_binary_output_ch3_enum),
4902439ea1fSSven Brandau SOC_ENUM("Ch1 Limiter Select", sta350_limiter_ch1_enum),
4912439ea1fSSven Brandau SOC_ENUM("Ch2 Limiter Select", sta350_limiter_ch2_enum),
4922439ea1fSSven Brandau SOC_ENUM("Ch3 Limiter Select", sta350_limiter_ch3_enum),
4932439ea1fSSven Brandau /* TONE */
4942439ea1fSSven Brandau SOC_SINGLE_RANGE_TLV("Bass Tone Control Volume",
4952439ea1fSSven Brandau 		     STA350_TONE, STA350_TONE_BTC_SHIFT, 1, 13, 0, tone_tlv),
4962439ea1fSSven Brandau SOC_SINGLE_RANGE_TLV("Treble Tone Control Volume",
4972439ea1fSSven Brandau 		     STA350_TONE, STA350_TONE_TTC_SHIFT, 1, 13, 0, tone_tlv),
4982439ea1fSSven Brandau SOC_ENUM("Limiter1 Attack Rate (dB/ms)", sta350_limiter1_attack_rate_enum),
4992439ea1fSSven Brandau SOC_ENUM("Limiter2 Attack Rate (dB/ms)", sta350_limiter2_attack_rate_enum),
5002439ea1fSSven Brandau SOC_ENUM("Limiter1 Release Rate (dB/ms)", sta350_limiter1_release_rate_enum),
5012439ea1fSSven Brandau SOC_ENUM("Limiter2 Release Rate (dB/ms)", sta350_limiter2_release_rate_enum),
5022439ea1fSSven Brandau 
5032439ea1fSSven Brandau /*
5042439ea1fSSven Brandau  * depending on mode, the attack/release thresholds have
5052439ea1fSSven Brandau  * two different enum definitions; provide both
5062439ea1fSSven Brandau  */
5072439ea1fSSven Brandau SOC_SINGLE_TLV("Limiter1 Attack Threshold (AC Mode)",
5082439ea1fSSven Brandau 	       STA350_L1ATRT, STA350_LxA_SHIFT,
5092439ea1fSSven Brandau 	       16, 0, sta350_limiter_ac_attack_tlv),
5102439ea1fSSven Brandau SOC_SINGLE_TLV("Limiter2 Attack Threshold (AC Mode)",
5112439ea1fSSven Brandau 	       STA350_L2ATRT, STA350_LxA_SHIFT,
5122439ea1fSSven Brandau 	       16, 0, sta350_limiter_ac_attack_tlv),
5132439ea1fSSven Brandau SOC_SINGLE_TLV("Limiter1 Release Threshold (AC Mode)",
5142439ea1fSSven Brandau 	       STA350_L1ATRT, STA350_LxR_SHIFT,
5152439ea1fSSven Brandau 	       16, 0, sta350_limiter_ac_release_tlv),
5162439ea1fSSven Brandau SOC_SINGLE_TLV("Limiter2 Release Threshold (AC Mode)",
5172439ea1fSSven Brandau 	       STA350_L2ATRT, STA350_LxR_SHIFT,
5182439ea1fSSven Brandau 	       16, 0, sta350_limiter_ac_release_tlv),
5192439ea1fSSven Brandau SOC_SINGLE_TLV("Limiter1 Attack Threshold (DRC Mode)",
5202439ea1fSSven Brandau 	       STA350_L1ATRT, STA350_LxA_SHIFT,
5212439ea1fSSven Brandau 	       16, 0, sta350_limiter_drc_attack_tlv),
5222439ea1fSSven Brandau SOC_SINGLE_TLV("Limiter2 Attack Threshold (DRC Mode)",
5232439ea1fSSven Brandau 	       STA350_L2ATRT, STA350_LxA_SHIFT,
5242439ea1fSSven Brandau 	       16, 0, sta350_limiter_drc_attack_tlv),
5252439ea1fSSven Brandau SOC_SINGLE_TLV("Limiter1 Release Threshold (DRC Mode)",
5262439ea1fSSven Brandau 	       STA350_L1ATRT, STA350_LxR_SHIFT,
5272439ea1fSSven Brandau 	       16, 0, sta350_limiter_drc_release_tlv),
5282439ea1fSSven Brandau SOC_SINGLE_TLV("Limiter2 Release Threshold (DRC Mode)",
5292439ea1fSSven Brandau 	       STA350_L2ATRT, STA350_LxR_SHIFT,
5302439ea1fSSven Brandau 	       16, 0, sta350_limiter_drc_release_tlv),
5312439ea1fSSven Brandau 
5322439ea1fSSven Brandau BIQUAD_COEFS("Ch1 - Biquad 1", 0),
5332439ea1fSSven Brandau BIQUAD_COEFS("Ch1 - Biquad 2", 5),
5342439ea1fSSven Brandau BIQUAD_COEFS("Ch1 - Biquad 3", 10),
5352439ea1fSSven Brandau BIQUAD_COEFS("Ch1 - Biquad 4", 15),
5362439ea1fSSven Brandau BIQUAD_COEFS("Ch2 - Biquad 1", 20),
5372439ea1fSSven Brandau BIQUAD_COEFS("Ch2 - Biquad 2", 25),
5382439ea1fSSven Brandau BIQUAD_COEFS("Ch2 - Biquad 3", 30),
5392439ea1fSSven Brandau BIQUAD_COEFS("Ch2 - Biquad 4", 35),
5402439ea1fSSven Brandau BIQUAD_COEFS("High-pass", 40),
5412439ea1fSSven Brandau BIQUAD_COEFS("Low-pass", 45),
5422439ea1fSSven Brandau SINGLE_COEF("Ch1 - Prescale", 50),
5432439ea1fSSven Brandau SINGLE_COEF("Ch2 - Prescale", 51),
5442439ea1fSSven Brandau SINGLE_COEF("Ch1 - Postscale", 52),
5452439ea1fSSven Brandau SINGLE_COEF("Ch2 - Postscale", 53),
5462439ea1fSSven Brandau SINGLE_COEF("Ch3 - Postscale", 54),
5472439ea1fSSven Brandau SINGLE_COEF("Thermal warning - Postscale", 55),
5482439ea1fSSven Brandau SINGLE_COEF("Ch1 - Mix 1", 56),
5492439ea1fSSven Brandau SINGLE_COEF("Ch1 - Mix 2", 57),
5502439ea1fSSven Brandau SINGLE_COEF("Ch2 - Mix 1", 58),
5512439ea1fSSven Brandau SINGLE_COEF("Ch2 - Mix 2", 59),
5522439ea1fSSven Brandau SINGLE_COEF("Ch3 - Mix 1", 60),
5532439ea1fSSven Brandau SINGLE_COEF("Ch3 - Mix 2", 61),
5542439ea1fSSven Brandau };
5552439ea1fSSven Brandau 
5562439ea1fSSven Brandau static const struct snd_soc_dapm_widget sta350_dapm_widgets[] = {
5572439ea1fSSven Brandau SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0),
5582439ea1fSSven Brandau SND_SOC_DAPM_OUTPUT("LEFT"),
5592439ea1fSSven Brandau SND_SOC_DAPM_OUTPUT("RIGHT"),
5602439ea1fSSven Brandau SND_SOC_DAPM_OUTPUT("SUB"),
5612439ea1fSSven Brandau };
5622439ea1fSSven Brandau 
5632439ea1fSSven Brandau static const struct snd_soc_dapm_route sta350_dapm_routes[] = {
5642439ea1fSSven Brandau 	{ "LEFT", NULL, "DAC" },
5652439ea1fSSven Brandau 	{ "RIGHT", NULL, "DAC" },
5662439ea1fSSven Brandau 	{ "SUB", NULL, "DAC" },
5672439ea1fSSven Brandau 	{ "DAC", NULL, "Playback" },
5682439ea1fSSven Brandau };
5692439ea1fSSven Brandau 
5702439ea1fSSven Brandau /* MCLK interpolation ratio per fs */
5712439ea1fSSven Brandau static struct {
5722439ea1fSSven Brandau 	int fs;
5732439ea1fSSven Brandau 	int ir;
5742439ea1fSSven Brandau } interpolation_ratios[] = {
5752439ea1fSSven Brandau 	{ 32000, 0 },
5762439ea1fSSven Brandau 	{ 44100, 0 },
5772439ea1fSSven Brandau 	{ 48000, 0 },
5782439ea1fSSven Brandau 	{ 88200, 1 },
5792439ea1fSSven Brandau 	{ 96000, 1 },
5802439ea1fSSven Brandau 	{ 176400, 2 },
5812439ea1fSSven Brandau 	{ 192000, 2 },
5822439ea1fSSven Brandau };
5832439ea1fSSven Brandau 
5842439ea1fSSven Brandau /* MCLK to fs clock ratios */
5852439ea1fSSven Brandau static int mcs_ratio_table[3][6] = {
5862439ea1fSSven Brandau 	{ 768, 512, 384, 256, 128, 576 },
5872439ea1fSSven Brandau 	{ 384, 256, 192, 128,  64,   0 },
5882439ea1fSSven Brandau 	{ 192, 128,  96,  64,  32,   0 },
5892439ea1fSSven Brandau };
5902439ea1fSSven Brandau 
5912439ea1fSSven Brandau /**
5922439ea1fSSven Brandau  * sta350_set_dai_sysclk - configure MCLK
5932439ea1fSSven Brandau  * @codec_dai: the codec DAI
5942439ea1fSSven Brandau  * @clk_id: the clock ID (ignored)
5952439ea1fSSven Brandau  * @freq: the MCLK input frequency
5962439ea1fSSven Brandau  * @dir: the clock direction (ignored)
5972439ea1fSSven Brandau  *
5982439ea1fSSven Brandau  * The value of MCLK is used to determine which sample rates are supported
5992439ea1fSSven Brandau  * by the STA350, based on the mcs_ratio_table.
6002439ea1fSSven Brandau  *
6012439ea1fSSven Brandau  * This function must be called by the machine driver's 'startup' function,
6022439ea1fSSven Brandau  * otherwise the list of supported sample rates will not be available in
6032439ea1fSSven Brandau  * time for ALSA.
6042439ea1fSSven Brandau  */
sta350_set_dai_sysclk(struct snd_soc_dai * codec_dai,int clk_id,unsigned int freq,int dir)6052439ea1fSSven Brandau static int sta350_set_dai_sysclk(struct snd_soc_dai *codec_dai,
6062439ea1fSSven Brandau 				 int clk_id, unsigned int freq, int dir)
6072439ea1fSSven Brandau {
6081f6440c5SKuninori Morimoto 	struct snd_soc_component *component = codec_dai->component;
6091f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
6102439ea1fSSven Brandau 
6111f6440c5SKuninori Morimoto 	dev_dbg(component->dev, "mclk=%u\n", freq);
6122439ea1fSSven Brandau 	sta350->mclk = freq;
6132439ea1fSSven Brandau 
6142439ea1fSSven Brandau 	return 0;
6152439ea1fSSven Brandau }
6162439ea1fSSven Brandau 
6172439ea1fSSven Brandau /**
6182439ea1fSSven Brandau  * sta350_set_dai_fmt - configure the codec for the selected audio format
6192439ea1fSSven Brandau  * @codec_dai: the codec DAI
6202439ea1fSSven Brandau  * @fmt: a SND_SOC_DAIFMT_x value indicating the data format
6212439ea1fSSven Brandau  *
6222439ea1fSSven Brandau  * This function takes a bitmask of SND_SOC_DAIFMT_x bits and programs the
6232439ea1fSSven Brandau  * codec accordingly.
6242439ea1fSSven Brandau  */
sta350_set_dai_fmt(struct snd_soc_dai * codec_dai,unsigned int fmt)6252439ea1fSSven Brandau static int sta350_set_dai_fmt(struct snd_soc_dai *codec_dai,
6262439ea1fSSven Brandau 			      unsigned int fmt)
6272439ea1fSSven Brandau {
6281f6440c5SKuninori Morimoto 	struct snd_soc_component *component = codec_dai->component;
6291f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
6302439ea1fSSven Brandau 	unsigned int confb = 0;
6312439ea1fSSven Brandau 
632def5b377SMark Brown 	switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
633def5b377SMark Brown 	case SND_SOC_DAIFMT_CBC_CFC:
6342439ea1fSSven Brandau 		break;
6352439ea1fSSven Brandau 	default:
6362439ea1fSSven Brandau 		return -EINVAL;
6372439ea1fSSven Brandau 	}
6382439ea1fSSven Brandau 
6392439ea1fSSven Brandau 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
6402439ea1fSSven Brandau 	case SND_SOC_DAIFMT_I2S:
6412439ea1fSSven Brandau 	case SND_SOC_DAIFMT_RIGHT_J:
6422439ea1fSSven Brandau 	case SND_SOC_DAIFMT_LEFT_J:
6432439ea1fSSven Brandau 		sta350->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
6442439ea1fSSven Brandau 		break;
6452439ea1fSSven Brandau 	default:
6462439ea1fSSven Brandau 		return -EINVAL;
6472439ea1fSSven Brandau 	}
6482439ea1fSSven Brandau 
6492439ea1fSSven Brandau 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
6502439ea1fSSven Brandau 	case SND_SOC_DAIFMT_NB_NF:
6512439ea1fSSven Brandau 		confb |= STA350_CONFB_C2IM;
6522439ea1fSSven Brandau 		break;
6532439ea1fSSven Brandau 	case SND_SOC_DAIFMT_NB_IF:
6542439ea1fSSven Brandau 		confb |= STA350_CONFB_C1IM;
6552439ea1fSSven Brandau 		break;
6562439ea1fSSven Brandau 	default:
6572439ea1fSSven Brandau 		return -EINVAL;
6582439ea1fSSven Brandau 	}
6592439ea1fSSven Brandau 
6602439ea1fSSven Brandau 	return regmap_update_bits(sta350->regmap, STA350_CONFB,
6612439ea1fSSven Brandau 				  STA350_CONFB_C1IM | STA350_CONFB_C2IM, confb);
6622439ea1fSSven Brandau }
6632439ea1fSSven Brandau 
6642439ea1fSSven Brandau /**
6652439ea1fSSven Brandau  * sta350_hw_params - program the STA350 with the given hardware parameters.
6662439ea1fSSven Brandau  * @substream: the audio stream
6672439ea1fSSven Brandau  * @params: the hardware parameters to set
6682439ea1fSSven Brandau  * @dai: the SOC DAI (ignored)
6692439ea1fSSven Brandau  *
6702439ea1fSSven Brandau  * This function programs the hardware with the values provided.
6712439ea1fSSven Brandau  * Specifically, the sample rate and the data format.
6722439ea1fSSven Brandau  */
sta350_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params,struct snd_soc_dai * dai)6732439ea1fSSven Brandau static int sta350_hw_params(struct snd_pcm_substream *substream,
6742439ea1fSSven Brandau 			    struct snd_pcm_hw_params *params,
6752439ea1fSSven Brandau 			    struct snd_soc_dai *dai)
6762439ea1fSSven Brandau {
6771f6440c5SKuninori Morimoto 	struct snd_soc_component *component = dai->component;
6781f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
6792439ea1fSSven Brandau 	int i, mcs = -EINVAL, ir = -EINVAL;
6802439ea1fSSven Brandau 	unsigned int confa, confb;
6812439ea1fSSven Brandau 	unsigned int rate, ratio;
6822439ea1fSSven Brandau 	int ret;
6832439ea1fSSven Brandau 
6842439ea1fSSven Brandau 	if (!sta350->mclk) {
6851f6440c5SKuninori Morimoto 		dev_err(component->dev,
6862439ea1fSSven Brandau 			"sta350->mclk is unset. Unable to determine ratio\n");
6872439ea1fSSven Brandau 		return -EIO;
6882439ea1fSSven Brandau 	}
6892439ea1fSSven Brandau 
6902439ea1fSSven Brandau 	rate = params_rate(params);
6912439ea1fSSven Brandau 	ratio = sta350->mclk / rate;
6921f6440c5SKuninori Morimoto 	dev_dbg(component->dev, "rate: %u, ratio: %u\n", rate, ratio);
6932439ea1fSSven Brandau 
6942439ea1fSSven Brandau 	for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) {
6952439ea1fSSven Brandau 		if (interpolation_ratios[i].fs == rate) {
6962439ea1fSSven Brandau 			ir = interpolation_ratios[i].ir;
6972439ea1fSSven Brandau 			break;
6982439ea1fSSven Brandau 		}
6992439ea1fSSven Brandau 	}
7002439ea1fSSven Brandau 
7012439ea1fSSven Brandau 	if (ir < 0) {
7021f6440c5SKuninori Morimoto 		dev_err(component->dev, "Unsupported samplerate: %u\n", rate);
7032439ea1fSSven Brandau 		return -EINVAL;
7042439ea1fSSven Brandau 	}
7052439ea1fSSven Brandau 
7062439ea1fSSven Brandau 	for (i = 0; i < 6; i++) {
7072439ea1fSSven Brandau 		if (mcs_ratio_table[ir][i] == ratio) {
7082439ea1fSSven Brandau 			mcs = i;
7092439ea1fSSven Brandau 			break;
7102439ea1fSSven Brandau 		}
7112439ea1fSSven Brandau 	}
7122439ea1fSSven Brandau 
7132439ea1fSSven Brandau 	if (mcs < 0) {
7141f6440c5SKuninori Morimoto 		dev_err(component->dev, "Unresolvable ratio: %u\n", ratio);
7152439ea1fSSven Brandau 		return -EINVAL;
7162439ea1fSSven Brandau 	}
7172439ea1fSSven Brandau 
7182439ea1fSSven Brandau 	confa = (ir << STA350_CONFA_IR_SHIFT) |
7192439ea1fSSven Brandau 		(mcs << STA350_CONFA_MCS_SHIFT);
7202439ea1fSSven Brandau 	confb = 0;
7212439ea1fSSven Brandau 
7222439ea1fSSven Brandau 	switch (params_width(params)) {
7232439ea1fSSven Brandau 	case 24:
7241f6440c5SKuninori Morimoto 		dev_dbg(component->dev, "24bit\n");
7253e146b55SGustavo A. R. Silva 		fallthrough;
7262439ea1fSSven Brandau 	case 32:
7271f6440c5SKuninori Morimoto 		dev_dbg(component->dev, "24bit or 32bit\n");
7282439ea1fSSven Brandau 		switch (sta350->format) {
7292439ea1fSSven Brandau 		case SND_SOC_DAIFMT_I2S:
7302439ea1fSSven Brandau 			confb |= 0x0;
7312439ea1fSSven Brandau 			break;
7322439ea1fSSven Brandau 		case SND_SOC_DAIFMT_LEFT_J:
7332439ea1fSSven Brandau 			confb |= 0x1;
7342439ea1fSSven Brandau 			break;
7352439ea1fSSven Brandau 		case SND_SOC_DAIFMT_RIGHT_J:
7362439ea1fSSven Brandau 			confb |= 0x2;
7372439ea1fSSven Brandau 			break;
7382439ea1fSSven Brandau 		}
7392439ea1fSSven Brandau 
7402439ea1fSSven Brandau 		break;
7412439ea1fSSven Brandau 	case 20:
7421f6440c5SKuninori Morimoto 		dev_dbg(component->dev, "20bit\n");
7432439ea1fSSven Brandau 		switch (sta350->format) {
7442439ea1fSSven Brandau 		case SND_SOC_DAIFMT_I2S:
7452439ea1fSSven Brandau 			confb |= 0x4;
7462439ea1fSSven Brandau 			break;
7472439ea1fSSven Brandau 		case SND_SOC_DAIFMT_LEFT_J:
7482439ea1fSSven Brandau 			confb |= 0x5;
7492439ea1fSSven Brandau 			break;
7502439ea1fSSven Brandau 		case SND_SOC_DAIFMT_RIGHT_J:
7512439ea1fSSven Brandau 			confb |= 0x6;
7522439ea1fSSven Brandau 			break;
7532439ea1fSSven Brandau 		}
7542439ea1fSSven Brandau 
7552439ea1fSSven Brandau 		break;
7562439ea1fSSven Brandau 	case 18:
7571f6440c5SKuninori Morimoto 		dev_dbg(component->dev, "18bit\n");
7582439ea1fSSven Brandau 		switch (sta350->format) {
7592439ea1fSSven Brandau 		case SND_SOC_DAIFMT_I2S:
7602439ea1fSSven Brandau 			confb |= 0x8;
7612439ea1fSSven Brandau 			break;
7622439ea1fSSven Brandau 		case SND_SOC_DAIFMT_LEFT_J:
7632439ea1fSSven Brandau 			confb |= 0x9;
7642439ea1fSSven Brandau 			break;
7652439ea1fSSven Brandau 		case SND_SOC_DAIFMT_RIGHT_J:
7662439ea1fSSven Brandau 			confb |= 0xa;
7672439ea1fSSven Brandau 			break;
7682439ea1fSSven Brandau 		}
7692439ea1fSSven Brandau 
7702439ea1fSSven Brandau 		break;
7712439ea1fSSven Brandau 	case 16:
7721f6440c5SKuninori Morimoto 		dev_dbg(component->dev, "16bit\n");
7732439ea1fSSven Brandau 		switch (sta350->format) {
7742439ea1fSSven Brandau 		case SND_SOC_DAIFMT_I2S:
7752439ea1fSSven Brandau 			confb |= 0x0;
7762439ea1fSSven Brandau 			break;
7772439ea1fSSven Brandau 		case SND_SOC_DAIFMT_LEFT_J:
7782439ea1fSSven Brandau 			confb |= 0xd;
7792439ea1fSSven Brandau 			break;
7802439ea1fSSven Brandau 		case SND_SOC_DAIFMT_RIGHT_J:
7812439ea1fSSven Brandau 			confb |= 0xe;
7822439ea1fSSven Brandau 			break;
7832439ea1fSSven Brandau 		}
7842439ea1fSSven Brandau 
7852439ea1fSSven Brandau 		break;
7862439ea1fSSven Brandau 	default:
7872439ea1fSSven Brandau 		return -EINVAL;
7882439ea1fSSven Brandau 	}
7892439ea1fSSven Brandau 
7902439ea1fSSven Brandau 	ret = regmap_update_bits(sta350->regmap, STA350_CONFA,
7912439ea1fSSven Brandau 				 STA350_CONFA_MCS_MASK | STA350_CONFA_IR_MASK,
7922439ea1fSSven Brandau 				 confa);
7932439ea1fSSven Brandau 	if (ret < 0)
7942439ea1fSSven Brandau 		return ret;
7952439ea1fSSven Brandau 
7962439ea1fSSven Brandau 	ret = regmap_update_bits(sta350->regmap, STA350_CONFB,
7972439ea1fSSven Brandau 				 STA350_CONFB_SAI_MASK | STA350_CONFB_SAIFB,
7982439ea1fSSven Brandau 				 confb);
7992439ea1fSSven Brandau 	if (ret < 0)
8002439ea1fSSven Brandau 		return ret;
8012439ea1fSSven Brandau 
8022439ea1fSSven Brandau 	return 0;
8032439ea1fSSven Brandau }
8042439ea1fSSven Brandau 
sta350_startup_sequence(struct sta350_priv * sta350)8052439ea1fSSven Brandau static int sta350_startup_sequence(struct sta350_priv *sta350)
8062439ea1fSSven Brandau {
8072439ea1fSSven Brandau 	if (sta350->gpiod_power_down)
8082439ea1fSSven Brandau 		gpiod_set_value(sta350->gpiod_power_down, 1);
8092439ea1fSSven Brandau 
8102439ea1fSSven Brandau 	if (sta350->gpiod_nreset) {
8112439ea1fSSven Brandau 		gpiod_set_value(sta350->gpiod_nreset, 0);
8122439ea1fSSven Brandau 		mdelay(1);
8132439ea1fSSven Brandau 		gpiod_set_value(sta350->gpiod_nreset, 1);
8142439ea1fSSven Brandau 		mdelay(1);
8152439ea1fSSven Brandau 	}
8162439ea1fSSven Brandau 
8172439ea1fSSven Brandau 	return 0;
8182439ea1fSSven Brandau }
8192439ea1fSSven Brandau 
8202439ea1fSSven Brandau /**
8212439ea1fSSven Brandau  * sta350_set_bias_level - DAPM callback
8221f6440c5SKuninori Morimoto  * @component: the component device
8232439ea1fSSven Brandau  * @level: DAPM power level
8242439ea1fSSven Brandau  *
8251f6440c5SKuninori Morimoto  * This is called by ALSA to put the component into low power mode
8261f6440c5SKuninori Morimoto  * or to wake it up.  If the component is powered off completely
8272439ea1fSSven Brandau  * all registers must be restored after power on.
8282439ea1fSSven Brandau  */
sta350_set_bias_level(struct snd_soc_component * component,enum snd_soc_bias_level level)8291f6440c5SKuninori Morimoto static int sta350_set_bias_level(struct snd_soc_component *component,
8302439ea1fSSven Brandau 				 enum snd_soc_bias_level level)
8312439ea1fSSven Brandau {
8321f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
8332439ea1fSSven Brandau 	int ret;
8342439ea1fSSven Brandau 
8351f6440c5SKuninori Morimoto 	dev_dbg(component->dev, "level = %d\n", level);
8362439ea1fSSven Brandau 	switch (level) {
8372439ea1fSSven Brandau 	case SND_SOC_BIAS_ON:
8382439ea1fSSven Brandau 		break;
8392439ea1fSSven Brandau 
8402439ea1fSSven Brandau 	case SND_SOC_BIAS_PREPARE:
8412439ea1fSSven Brandau 		/* Full power on */
8422439ea1fSSven Brandau 		regmap_update_bits(sta350->regmap, STA350_CONFF,
8432439ea1fSSven Brandau 				   STA350_CONFF_PWDN | STA350_CONFF_EAPD,
8442439ea1fSSven Brandau 				   STA350_CONFF_PWDN | STA350_CONFF_EAPD);
8452439ea1fSSven Brandau 		break;
8462439ea1fSSven Brandau 
8472439ea1fSSven Brandau 	case SND_SOC_BIAS_STANDBY:
8481f6440c5SKuninori Morimoto 		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
8492439ea1fSSven Brandau 			ret = regulator_bulk_enable(
8502439ea1fSSven Brandau 				ARRAY_SIZE(sta350->supplies),
8512439ea1fSSven Brandau 				sta350->supplies);
8522439ea1fSSven Brandau 			if (ret < 0) {
8531f6440c5SKuninori Morimoto 				dev_err(component->dev,
8542439ea1fSSven Brandau 					"Failed to enable supplies: %d\n",
8552439ea1fSSven Brandau 					ret);
8562439ea1fSSven Brandau 				return ret;
8572439ea1fSSven Brandau 			}
8582439ea1fSSven Brandau 			sta350_startup_sequence(sta350);
8591f6440c5SKuninori Morimoto 			sta350_cache_sync(component);
8602439ea1fSSven Brandau 		}
8612439ea1fSSven Brandau 
8622439ea1fSSven Brandau 		/* Power down */
8632439ea1fSSven Brandau 		regmap_update_bits(sta350->regmap, STA350_CONFF,
8642439ea1fSSven Brandau 				   STA350_CONFF_PWDN | STA350_CONFF_EAPD,
8652439ea1fSSven Brandau 				   0);
8662439ea1fSSven Brandau 
8672439ea1fSSven Brandau 		break;
8682439ea1fSSven Brandau 
8692439ea1fSSven Brandau 	case SND_SOC_BIAS_OFF:
8702439ea1fSSven Brandau 		/* The chip runs through the power down sequence for us */
8712439ea1fSSven Brandau 		regmap_update_bits(sta350->regmap, STA350_CONFF,
8722439ea1fSSven Brandau 				   STA350_CONFF_PWDN | STA350_CONFF_EAPD, 0);
8732439ea1fSSven Brandau 
8742439ea1fSSven Brandau 		/* power down: low */
8752439ea1fSSven Brandau 		if (sta350->gpiod_power_down)
8762439ea1fSSven Brandau 			gpiod_set_value(sta350->gpiod_power_down, 0);
8772439ea1fSSven Brandau 
8782439ea1fSSven Brandau 		if (sta350->gpiod_nreset)
8792439ea1fSSven Brandau 			gpiod_set_value(sta350->gpiod_nreset, 0);
8802439ea1fSSven Brandau 
8812439ea1fSSven Brandau 		regulator_bulk_disable(ARRAY_SIZE(sta350->supplies),
8822439ea1fSSven Brandau 				       sta350->supplies);
8832439ea1fSSven Brandau 		break;
8842439ea1fSSven Brandau 	}
8852439ea1fSSven Brandau 	return 0;
8862439ea1fSSven Brandau }
8872439ea1fSSven Brandau 
8882439ea1fSSven Brandau static const struct snd_soc_dai_ops sta350_dai_ops = {
8892439ea1fSSven Brandau 	.hw_params	= sta350_hw_params,
8902439ea1fSSven Brandau 	.set_sysclk	= sta350_set_dai_sysclk,
8912439ea1fSSven Brandau 	.set_fmt	= sta350_set_dai_fmt,
8922439ea1fSSven Brandau };
8932439ea1fSSven Brandau 
8942439ea1fSSven Brandau static struct snd_soc_dai_driver sta350_dai = {
8952439ea1fSSven Brandau 	.name = "sta350-hifi",
8962439ea1fSSven Brandau 	.playback = {
8972439ea1fSSven Brandau 		.stream_name = "Playback",
8982439ea1fSSven Brandau 		.channels_min = 2,
8992439ea1fSSven Brandau 		.channels_max = 2,
9002439ea1fSSven Brandau 		.rates = STA350_RATES,
9012439ea1fSSven Brandau 		.formats = STA350_FORMATS,
9022439ea1fSSven Brandau 	},
9032439ea1fSSven Brandau 	.ops = &sta350_dai_ops,
9042439ea1fSSven Brandau };
9052439ea1fSSven Brandau 
sta350_probe(struct snd_soc_component * component)9061f6440c5SKuninori Morimoto static int sta350_probe(struct snd_soc_component *component)
9072439ea1fSSven Brandau {
9081f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
9092439ea1fSSven Brandau 	struct sta350_platform_data *pdata = sta350->pdata;
9102439ea1fSSven Brandau 	int i, ret = 0, thermal = 0;
9112439ea1fSSven Brandau 
9122439ea1fSSven Brandau 	ret = regulator_bulk_enable(ARRAY_SIZE(sta350->supplies),
9132439ea1fSSven Brandau 				    sta350->supplies);
9142439ea1fSSven Brandau 	if (ret < 0) {
9151f6440c5SKuninori Morimoto 		dev_err(component->dev, "Failed to enable supplies: %d\n", ret);
9162439ea1fSSven Brandau 		return ret;
9172439ea1fSSven Brandau 	}
9182439ea1fSSven Brandau 
9192439ea1fSSven Brandau 	ret = sta350_startup_sequence(sta350);
9202439ea1fSSven Brandau 	if (ret < 0) {
9211f6440c5SKuninori Morimoto 		dev_err(component->dev, "Failed to startup device\n");
9222439ea1fSSven Brandau 		return ret;
9232439ea1fSSven Brandau 	}
9242439ea1fSSven Brandau 
9252439ea1fSSven Brandau 	/* CONFA */
9262439ea1fSSven Brandau 	if (!pdata->thermal_warning_recovery)
9272439ea1fSSven Brandau 		thermal |= STA350_CONFA_TWAB;
9282439ea1fSSven Brandau 	if (!pdata->thermal_warning_adjustment)
9292439ea1fSSven Brandau 		thermal |= STA350_CONFA_TWRB;
9302439ea1fSSven Brandau 	if (!pdata->fault_detect_recovery)
9312439ea1fSSven Brandau 		thermal |= STA350_CONFA_FDRB;
9322439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFA,
9332439ea1fSSven Brandau 			   STA350_CONFA_TWAB | STA350_CONFA_TWRB |
9342439ea1fSSven Brandau 			   STA350_CONFA_FDRB,
9352439ea1fSSven Brandau 			   thermal);
9362439ea1fSSven Brandau 
9372439ea1fSSven Brandau 	/* CONFC */
9382439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFC,
9392439ea1fSSven Brandau 			   STA350_CONFC_OM_MASK,
9402439ea1fSSven Brandau 			   pdata->ffx_power_output_mode
9412439ea1fSSven Brandau 				<< STA350_CONFC_OM_SHIFT);
9422439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFC,
9432439ea1fSSven Brandau 			   STA350_CONFC_CSZ_MASK,
9442439ea1fSSven Brandau 			   pdata->drop_compensation_ns
9452439ea1fSSven Brandau 				<< STA350_CONFC_CSZ_SHIFT);
9462439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap,
9472439ea1fSSven Brandau 			   STA350_CONFC,
9482439ea1fSSven Brandau 			   STA350_CONFC_OCRB,
9492439ea1fSSven Brandau 			   pdata->oc_warning_adjustment ?
9502439ea1fSSven Brandau 				STA350_CONFC_OCRB : 0);
9512439ea1fSSven Brandau 
9522439ea1fSSven Brandau 	/* CONFE */
9532439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFE,
9542439ea1fSSven Brandau 			   STA350_CONFE_MPCV,
9552439ea1fSSven Brandau 			   pdata->max_power_use_mpcc ?
9562439ea1fSSven Brandau 				STA350_CONFE_MPCV : 0);
9572439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFE,
9582439ea1fSSven Brandau 			   STA350_CONFE_MPC,
9592439ea1fSSven Brandau 			   pdata->max_power_correction ?
9602439ea1fSSven Brandau 				STA350_CONFE_MPC : 0);
9612439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFE,
9622439ea1fSSven Brandau 			   STA350_CONFE_AME,
9632439ea1fSSven Brandau 			   pdata->am_reduction_mode ?
9642439ea1fSSven Brandau 				STA350_CONFE_AME : 0);
9652439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFE,
9662439ea1fSSven Brandau 			   STA350_CONFE_PWMS,
9672439ea1fSSven Brandau 			   pdata->odd_pwm_speed_mode ?
9682439ea1fSSven Brandau 				STA350_CONFE_PWMS : 0);
9692439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFE,
9702439ea1fSSven Brandau 			   STA350_CONFE_DCCV,
9712439ea1fSSven Brandau 			   pdata->distortion_compensation ?
9722439ea1fSSven Brandau 				STA350_CONFE_DCCV : 0);
9732439ea1fSSven Brandau 	/*  CONFF */
9742439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFF,
9752439ea1fSSven Brandau 			   STA350_CONFF_IDE,
9762439ea1fSSven Brandau 			   pdata->invalid_input_detect_mute ?
9772439ea1fSSven Brandau 				STA350_CONFF_IDE : 0);
9782439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_CONFF,
9792439ea1fSSven Brandau 			   STA350_CONFF_OCFG_MASK,
9802439ea1fSSven Brandau 			   pdata->output_conf
9812439ea1fSSven Brandau 				<< STA350_CONFF_OCFG_SHIFT);
9822439ea1fSSven Brandau 
9832439ea1fSSven Brandau 	/* channel to output mapping */
9842439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_C1CFG,
9852439ea1fSSven Brandau 			   STA350_CxCFG_OM_MASK,
9862439ea1fSSven Brandau 			   pdata->ch1_output_mapping
9872439ea1fSSven Brandau 				<< STA350_CxCFG_OM_SHIFT);
9882439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_C2CFG,
9892439ea1fSSven Brandau 			   STA350_CxCFG_OM_MASK,
9902439ea1fSSven Brandau 			   pdata->ch2_output_mapping
9912439ea1fSSven Brandau 				<< STA350_CxCFG_OM_SHIFT);
9922439ea1fSSven Brandau 	regmap_update_bits(sta350->regmap, STA350_C3CFG,
9932439ea1fSSven Brandau 			   STA350_CxCFG_OM_MASK,
9942439ea1fSSven Brandau 			   pdata->ch3_output_mapping
9952439ea1fSSven Brandau 				<< STA350_CxCFG_OM_SHIFT);
9962439ea1fSSven Brandau 
9977c2fccccSDaniel Mack 	/* miscellaneous registers */
9987c2fccccSDaniel Mack 	regmap_update_bits(sta350->regmap, STA350_MISC1,
9997c2fccccSDaniel Mack 			   STA350_MISC1_CPWMEN,
10007c2fccccSDaniel Mack 			   pdata->activate_mute_output ?
10017c2fccccSDaniel Mack 				STA350_MISC1_CPWMEN : 0);
10027c2fccccSDaniel Mack 	regmap_update_bits(sta350->regmap, STA350_MISC1,
10037c2fccccSDaniel Mack 			   STA350_MISC1_BRIDGOFF,
10047c2fccccSDaniel Mack 			   pdata->bridge_immediate_off ?
10057c2fccccSDaniel Mack 				STA350_MISC1_BRIDGOFF : 0);
10067c2fccccSDaniel Mack 	regmap_update_bits(sta350->regmap, STA350_MISC1,
10077c2fccccSDaniel Mack 			   STA350_MISC1_NSHHPEN,
10087c2fccccSDaniel Mack 			   pdata->noise_shape_dc_cut ?
10097c2fccccSDaniel Mack 				STA350_MISC1_NSHHPEN : 0);
10107c2fccccSDaniel Mack 	regmap_update_bits(sta350->regmap, STA350_MISC1,
10117c2fccccSDaniel Mack 			   STA350_MISC1_RPDNEN,
10127c2fccccSDaniel Mack 			   pdata->powerdown_master_vol ?
10137c2fccccSDaniel Mack 				STA350_MISC1_RPDNEN: 0);
10147c2fccccSDaniel Mack 
10157c2fccccSDaniel Mack 	regmap_update_bits(sta350->regmap, STA350_MISC2,
10167c2fccccSDaniel Mack 			   STA350_MISC2_PNDLSL_MASK,
10177c2fccccSDaniel Mack 			   pdata->powerdown_delay_divider
10187c2fccccSDaniel Mack 				<< STA350_MISC2_PNDLSL_SHIFT);
10197c2fccccSDaniel Mack 
10202439ea1fSSven Brandau 	/* initialize coefficient shadow RAM with reset values */
10212439ea1fSSven Brandau 	for (i = 4; i <= 49; i += 5)
10222439ea1fSSven Brandau 		sta350->coef_shadow[i] = 0x400000;
10232439ea1fSSven Brandau 	for (i = 50; i <= 54; i++)
10242439ea1fSSven Brandau 		sta350->coef_shadow[i] = 0x7fffff;
10252439ea1fSSven Brandau 	sta350->coef_shadow[55] = 0x5a9df7;
10262439ea1fSSven Brandau 	sta350->coef_shadow[56] = 0x7fffff;
10272439ea1fSSven Brandau 	sta350->coef_shadow[59] = 0x7fffff;
10282439ea1fSSven Brandau 	sta350->coef_shadow[60] = 0x400000;
10292439ea1fSSven Brandau 	sta350->coef_shadow[61] = 0x400000;
10302439ea1fSSven Brandau 
10311f6440c5SKuninori Morimoto 	snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
10322439ea1fSSven Brandau 	/* Bias level configuration will have done an extra enable */
10332439ea1fSSven Brandau 	regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies);
10342439ea1fSSven Brandau 
10352439ea1fSSven Brandau 	return 0;
10362439ea1fSSven Brandau }
10372439ea1fSSven Brandau 
sta350_remove(struct snd_soc_component * component)10381f6440c5SKuninori Morimoto static void sta350_remove(struct snd_soc_component *component)
10392439ea1fSSven Brandau {
10401f6440c5SKuninori Morimoto 	struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component);
10412439ea1fSSven Brandau 
10422439ea1fSSven Brandau 	regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies);
10432439ea1fSSven Brandau }
10442439ea1fSSven Brandau 
10451f6440c5SKuninori Morimoto static const struct snd_soc_component_driver sta350_component = {
10462439ea1fSSven Brandau 	.probe			= sta350_probe,
10472439ea1fSSven Brandau 	.remove			= sta350_remove,
10482439ea1fSSven Brandau 	.set_bias_level		= sta350_set_bias_level,
10492439ea1fSSven Brandau 	.controls		= sta350_snd_controls,
10502439ea1fSSven Brandau 	.num_controls		= ARRAY_SIZE(sta350_snd_controls),
10512439ea1fSSven Brandau 	.dapm_widgets		= sta350_dapm_widgets,
10522439ea1fSSven Brandau 	.num_dapm_widgets	= ARRAY_SIZE(sta350_dapm_widgets),
10532439ea1fSSven Brandau 	.dapm_routes		= sta350_dapm_routes,
10542439ea1fSSven Brandau 	.num_dapm_routes	= ARRAY_SIZE(sta350_dapm_routes),
10551f6440c5SKuninori Morimoto 	.suspend_bias_off	= 1,
10561f6440c5SKuninori Morimoto 	.idle_bias_on		= 1,
10571f6440c5SKuninori Morimoto 	.use_pmdown_time	= 1,
10581f6440c5SKuninori Morimoto 	.endianness		= 1,
10592439ea1fSSven Brandau };
10602439ea1fSSven Brandau 
10612439ea1fSSven Brandau static const struct regmap_config sta350_regmap = {
10622439ea1fSSven Brandau 	.reg_bits =		8,
10632439ea1fSSven Brandau 	.val_bits =		8,
10642439ea1fSSven Brandau 	.max_register =		STA350_MISC2,
10652439ea1fSSven Brandau 	.reg_defaults =		sta350_regs,
10662439ea1fSSven Brandau 	.num_reg_defaults =	ARRAY_SIZE(sta350_regs),
106787256942SMark Brown 	.cache_type =		REGCACHE_MAPLE,
10682439ea1fSSven Brandau 	.wr_table =		&sta350_write_regs,
10692439ea1fSSven Brandau 	.rd_table =		&sta350_read_regs,
10702439ea1fSSven Brandau 	.volatile_table =	&sta350_volatile_regs,
10712439ea1fSSven Brandau };
10722439ea1fSSven Brandau 
10732439ea1fSSven Brandau #ifdef CONFIG_OF
10742439ea1fSSven Brandau static const struct of_device_id st350_dt_ids[] = {
10752439ea1fSSven Brandau 	{ .compatible = "st,sta350", },
10762439ea1fSSven Brandau 	{ }
10772439ea1fSSven Brandau };
10782439ea1fSSven Brandau MODULE_DEVICE_TABLE(of, st350_dt_ids);
10792439ea1fSSven Brandau 
10802439ea1fSSven Brandau static const char * const sta350_ffx_modes[] = {
10812439ea1fSSven Brandau 	[STA350_FFX_PM_DROP_COMP]		= "drop-compensation",
10822439ea1fSSven Brandau 	[STA350_FFX_PM_TAPERED_COMP]		= "tapered-compensation",
10832439ea1fSSven Brandau 	[STA350_FFX_PM_FULL_POWER]		= "full-power-mode",
10842439ea1fSSven Brandau 	[STA350_FFX_PM_VARIABLE_DROP_COMP]	= "variable-drop-compensation",
10852439ea1fSSven Brandau };
10862439ea1fSSven Brandau 
sta350_probe_dt(struct device * dev,struct sta350_priv * sta350)10872439ea1fSSven Brandau static int sta350_probe_dt(struct device *dev, struct sta350_priv *sta350)
10882439ea1fSSven Brandau {
10892439ea1fSSven Brandau 	struct device_node *np = dev->of_node;
10902439ea1fSSven Brandau 	struct sta350_platform_data *pdata;
10912439ea1fSSven Brandau 	const char *ffx_power_mode;
10922439ea1fSSven Brandau 	u16 tmp;
10937c2fccccSDaniel Mack 	u8 tmp8;
10942439ea1fSSven Brandau 
10952439ea1fSSven Brandau 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
10962439ea1fSSven Brandau 	if (!pdata)
10972439ea1fSSven Brandau 		return -ENOMEM;
10982439ea1fSSven Brandau 
10992439ea1fSSven Brandau 	of_property_read_u8(np, "st,output-conf",
11002439ea1fSSven Brandau 			    &pdata->output_conf);
11012439ea1fSSven Brandau 	of_property_read_u8(np, "st,ch1-output-mapping",
11022439ea1fSSven Brandau 			    &pdata->ch1_output_mapping);
11032439ea1fSSven Brandau 	of_property_read_u8(np, "st,ch2-output-mapping",
11042439ea1fSSven Brandau 			    &pdata->ch2_output_mapping);
11052439ea1fSSven Brandau 	of_property_read_u8(np, "st,ch3-output-mapping",
11062439ea1fSSven Brandau 			    &pdata->ch3_output_mapping);
11072439ea1fSSven Brandau 
11082d2998b8SRob Herring 	pdata->thermal_warning_recovery =
11092d2998b8SRob Herring 		of_property_read_bool(np, "st,thermal-warning-recovery");
11102d2998b8SRob Herring 	pdata->thermal_warning_adjustment =
11112d2998b8SRob Herring 		of_property_read_bool(np, "st,thermal-warning-adjustment");
11122d2998b8SRob Herring 	pdata->fault_detect_recovery =
11132d2998b8SRob Herring 		of_property_read_bool(np, "st,fault-detect-recovery");
11142439ea1fSSven Brandau 
11152439ea1fSSven Brandau 	pdata->ffx_power_output_mode = STA350_FFX_PM_VARIABLE_DROP_COMP;
11162439ea1fSSven Brandau 	if (!of_property_read_string(np, "st,ffx-power-output-mode",
11172439ea1fSSven Brandau 				     &ffx_power_mode)) {
11182439ea1fSSven Brandau 		int i, mode = -EINVAL;
11192439ea1fSSven Brandau 
11202439ea1fSSven Brandau 		for (i = 0; i < ARRAY_SIZE(sta350_ffx_modes); i++)
11212439ea1fSSven Brandau 			if (!strcasecmp(ffx_power_mode, sta350_ffx_modes[i]))
11222439ea1fSSven Brandau 				mode = i;
11232439ea1fSSven Brandau 
11242439ea1fSSven Brandau 		if (mode < 0)
11252439ea1fSSven Brandau 			dev_warn(dev, "Unsupported ffx output mode: %s\n",
11262439ea1fSSven Brandau 				 ffx_power_mode);
11272439ea1fSSven Brandau 		else
11282439ea1fSSven Brandau 			pdata->ffx_power_output_mode = mode;
11292439ea1fSSven Brandau 	}
11302439ea1fSSven Brandau 
11312439ea1fSSven Brandau 	tmp = 140;
11322439ea1fSSven Brandau 	of_property_read_u16(np, "st,drop-compensation-ns", &tmp);
11332439ea1fSSven Brandau 	pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20;
11342439ea1fSSven Brandau 
11352d2998b8SRob Herring 	pdata->oc_warning_adjustment =
11362d2998b8SRob Herring 		of_property_read_bool(np, "st,overcurrent-warning-adjustment");
11372439ea1fSSven Brandau 
11382439ea1fSSven Brandau 	/* CONFE */
11392d2998b8SRob Herring 	pdata->max_power_use_mpcc =
11402d2998b8SRob Herring 		of_property_read_bool(np, "st,max-power-use-mpcc");
11412d2998b8SRob Herring 	pdata->max_power_correction =
11422d2998b8SRob Herring 		of_property_read_bool(np, "st,max-power-correction");
11432d2998b8SRob Herring 	pdata->am_reduction_mode =
11442d2998b8SRob Herring 		of_property_read_bool(np, "st,am-reduction-mode");
11452d2998b8SRob Herring 	pdata->odd_pwm_speed_mode =
11462d2998b8SRob Herring 		of_property_read_bool(np, "st,odd-pwm-speed-mode");
11472d2998b8SRob Herring 	pdata->distortion_compensation =
11482d2998b8SRob Herring 		of_property_read_bool(np, "st,distortion-compensation");
11492439ea1fSSven Brandau 
11502439ea1fSSven Brandau 	/* CONFF */
11512d2998b8SRob Herring 	pdata->invalid_input_detect_mute =
11522d2998b8SRob Herring 		of_property_read_bool(np, "st,invalid-input-detect-mute");
11532439ea1fSSven Brandau 
11547c2fccccSDaniel Mack 	/* MISC */
11552d2998b8SRob Herring 	pdata->activate_mute_output =
11562d2998b8SRob Herring 		of_property_read_bool(np, "st,activate-mute-output");
11572d2998b8SRob Herring 	pdata->bridge_immediate_off =
11582d2998b8SRob Herring 		of_property_read_bool(np, "st,bridge-immediate-off");
11592d2998b8SRob Herring 	pdata->noise_shape_dc_cut =
11602d2998b8SRob Herring 		of_property_read_bool(np, "st,noise-shape-dc-cut");
11612d2998b8SRob Herring 	pdata->powerdown_master_vol =
11622d2998b8SRob Herring 		of_property_read_bool(np, "st,powerdown-master-volume");
11637c2fccccSDaniel Mack 
11647c2fccccSDaniel Mack 	if (!of_property_read_u8(np, "st,powerdown-delay-divider", &tmp8)) {
11657c2fccccSDaniel Mack 		if (is_power_of_2(tmp8) && tmp8 >= 1 && tmp8 <= 128)
11667c2fccccSDaniel Mack 			pdata->powerdown_delay_divider = ilog2(tmp8);
11677c2fccccSDaniel Mack 		else
11687c2fccccSDaniel Mack 			dev_warn(dev, "Unsupported powerdown delay divider %d\n",
11697c2fccccSDaniel Mack 				 tmp8);
11707c2fccccSDaniel Mack 	}
11717c2fccccSDaniel Mack 
11722439ea1fSSven Brandau 	sta350->pdata = pdata;
11732439ea1fSSven Brandau 
11742439ea1fSSven Brandau 	return 0;
11752439ea1fSSven Brandau }
11762439ea1fSSven Brandau #endif
11772439ea1fSSven Brandau 
sta350_i2c_probe(struct i2c_client * i2c)11786f51c158SStephen Kitt static int sta350_i2c_probe(struct i2c_client *i2c)
11792439ea1fSSven Brandau {
11802439ea1fSSven Brandau 	struct device *dev = &i2c->dev;
11812439ea1fSSven Brandau 	struct sta350_priv *sta350;
11822439ea1fSSven Brandau 	int ret, i;
11832439ea1fSSven Brandau 
11842439ea1fSSven Brandau 	sta350 = devm_kzalloc(dev, sizeof(struct sta350_priv), GFP_KERNEL);
11852439ea1fSSven Brandau 	if (!sta350)
11862439ea1fSSven Brandau 		return -ENOMEM;
11872439ea1fSSven Brandau 
11882439ea1fSSven Brandau 	mutex_init(&sta350->coeff_lock);
11892439ea1fSSven Brandau 	sta350->pdata = dev_get_platdata(dev);
11902439ea1fSSven Brandau 
11912439ea1fSSven Brandau #ifdef CONFIG_OF
11922439ea1fSSven Brandau 	if (dev->of_node) {
11932439ea1fSSven Brandau 		ret = sta350_probe_dt(dev, sta350);
11942439ea1fSSven Brandau 		if (ret < 0)
11952439ea1fSSven Brandau 			return ret;
11962439ea1fSSven Brandau 	}
11972439ea1fSSven Brandau #endif
11982439ea1fSSven Brandau 
11992439ea1fSSven Brandau 	/* GPIOs */
120034d7c390SUwe Kleine-König 	sta350->gpiod_nreset = devm_gpiod_get_optional(dev, "reset",
120134d7c390SUwe Kleine-König 						       GPIOD_OUT_LOW);
120234d7c390SUwe Kleine-König 	if (IS_ERR(sta350->gpiod_nreset))
120334d7c390SUwe Kleine-König 		return PTR_ERR(sta350->gpiod_nreset);
12042439ea1fSSven Brandau 
1205c9eac462SAxel Lin 	sta350->gpiod_power_down = devm_gpiod_get_optional(dev, "power-down",
120634d7c390SUwe Kleine-König 							   GPIOD_OUT_LOW);
120734d7c390SUwe Kleine-König 	if (IS_ERR(sta350->gpiod_power_down))
120834d7c390SUwe Kleine-König 		return PTR_ERR(sta350->gpiod_power_down);
12092439ea1fSSven Brandau 
12102439ea1fSSven Brandau 	/* regulators */
12112439ea1fSSven Brandau 	for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++)
12122439ea1fSSven Brandau 		sta350->supplies[i].supply = sta350_supply_names[i];
12132439ea1fSSven Brandau 
12142439ea1fSSven Brandau 	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(sta350->supplies),
12152439ea1fSSven Brandau 				      sta350->supplies);
12162439ea1fSSven Brandau 	if (ret < 0) {
12172439ea1fSSven Brandau 		dev_err(dev, "Failed to request supplies: %d\n", ret);
12182439ea1fSSven Brandau 		return ret;
12192439ea1fSSven Brandau 	}
12202439ea1fSSven Brandau 
12212439ea1fSSven Brandau 	sta350->regmap = devm_regmap_init_i2c(i2c, &sta350_regmap);
12222439ea1fSSven Brandau 	if (IS_ERR(sta350->regmap)) {
12232439ea1fSSven Brandau 		ret = PTR_ERR(sta350->regmap);
12242439ea1fSSven Brandau 		dev_err(dev, "Failed to init regmap: %d\n", ret);
12252439ea1fSSven Brandau 		return ret;
12262439ea1fSSven Brandau 	}
12272439ea1fSSven Brandau 
12282439ea1fSSven Brandau 	i2c_set_clientdata(i2c, sta350);
12292439ea1fSSven Brandau 
12301f6440c5SKuninori Morimoto 	ret = devm_snd_soc_register_component(dev, &sta350_component, &sta350_dai, 1);
12312439ea1fSSven Brandau 	if (ret < 0)
12321f6440c5SKuninori Morimoto 		dev_err(dev, "Failed to register component (%d)\n", ret);
12332439ea1fSSven Brandau 
12342439ea1fSSven Brandau 	return ret;
12352439ea1fSSven Brandau }
12362439ea1fSSven Brandau 
sta350_i2c_remove(struct i2c_client * client)1237ed5c2f5fSUwe Kleine-König static void sta350_i2c_remove(struct i2c_client *client)
1238ed5c2f5fSUwe Kleine-König {}
12392439ea1fSSven Brandau 
12402439ea1fSSven Brandau static const struct i2c_device_id sta350_i2c_id[] = {
1241*ba2a2c37SUwe Kleine-König 	{ "sta350" },
12422439ea1fSSven Brandau 	{ }
12432439ea1fSSven Brandau };
12442439ea1fSSven Brandau MODULE_DEVICE_TABLE(i2c, sta350_i2c_id);
12452439ea1fSSven Brandau 
12462439ea1fSSven Brandau static struct i2c_driver sta350_i2c_driver = {
12472439ea1fSSven Brandau 	.driver = {
12482439ea1fSSven Brandau 		.name = "sta350",
12492439ea1fSSven Brandau 		.of_match_table = of_match_ptr(st350_dt_ids),
12502439ea1fSSven Brandau 	},
12519abcd240SUwe Kleine-König 	.probe =    sta350_i2c_probe,
12522439ea1fSSven Brandau 	.remove =   sta350_i2c_remove,
12532439ea1fSSven Brandau 	.id_table = sta350_i2c_id,
12542439ea1fSSven Brandau };
12552439ea1fSSven Brandau 
12562439ea1fSSven Brandau module_i2c_driver(sta350_i2c_driver);
12572439ea1fSSven Brandau 
12582439ea1fSSven Brandau MODULE_DESCRIPTION("ASoC STA350 driver");
12592439ea1fSSven Brandau MODULE_AUTHOR("Sven Brandau <info@brandau.biz>");
12602439ea1fSSven Brandau MODULE_LICENSE("GPL");
1261