Re: [PATCH v2] ASoC: tfa9879: New driver for NXP Semiconductors TFA9879 amplifier.

2014-11-07 Thread Mark Brown
On Thu, Nov 06, 2014 at 05:39:45PM +0100, Peter Rosin wrote:

> + { TFA9879_MISC_STATUS,  0x }, /* 0x15, read-only */

The fix here is the wrong way round - if the device is reporting status
here there should be no default and there should be a volatile operation
(though it's not the end of the world to omit that if it's not used).

Otherwise this looks good.


signature.asc
Description: Digital signature


[PATCH v2] ASoC: tfa9879: New driver for NXP Semiconductors TFA9879 amplifier.

2014-11-06 Thread Peter Rosin
From: Peter Rosin 

Signed-off-by: Peter Rosin 
---
 MAINTAINERS|6 +
 sound/soc/codecs/Kconfig   |5 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tfa9879.c |  323 
 sound/soc/codecs/tfa9879.h |  202 +++
 5 files changed, 538 insertions(+)
 create mode 100644 sound/soc/codecs/tfa9879.c
 create mode 100644 sound/soc/codecs/tfa9879.h

diff --git a/MAINTAINERS b/MAINTAINERS
index f10ed3914ea8..9ca9e68ea9ab 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6467,6 +6467,12 @@ S:   Supported
 F: drivers/gpu/drm/i2c/tda998x_drv.c
 F: include/drm/i2c/tda998x.h
 
+NXP TFA9879 DRIVER
+M: Peter Rosin 
+L: alsa-de...@alsa-project.org (moderated for non-subscribers)
+S: Maintained
+F: sound/soc/codecs/tfa9879*
+
 OMAP SUPPORT
 M: Tony Lindgren 
 L: linux-o...@vger.kernel.org
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 8838838e25ed..36bf3f83a333 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -96,6 +96,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
select SND_SOC_TAS2552 if I2C
select SND_SOC_TAS5086 if I2C
+   select SND_SOC_TFA9879 if I2C
select SND_SOC_TLV320AIC23_I2C if I2C
select SND_SOC_TLV320AIC23_SPI if SPI_MASTER
select SND_SOC_TLV320AIC26 if SPI_MASTER
@@ -548,6 +549,10 @@ config SND_SOC_TAS5086
tristate "Texas Instruments TAS5086 speaker amplifier"
depends on I2C
 
+config SND_SOC_TFA9879
+   tristate "NXP Semiconductors TFA9879 amplifier"
+   depends on I2C
+
 config SND_SOC_TLV320AIC23
tristate
 
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 20afe0f0c5be..678a3a6df8a5 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -96,6 +96,7 @@ snd-soc-sta350-objs := sta350.o
 snd-soc-sta529-objs := sta529.o
 snd-soc-stac9766-objs := stac9766.o
 snd-soc-tas5086-objs := tas5086.o
+snd-soc-tfa9879-objs := tfa9879.o
 snd-soc-tlv320aic23-objs := tlv320aic23.o
 snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o
 snd-soc-tlv320aic23-spi-objs := tlv320aic23-spi.o
@@ -264,6 +265,7 @@ obj-$(CONFIG_SND_SOC_STA529)   += snd-soc-sta529.o
 obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o
 obj-$(CONFIG_SND_SOC_TAS2552)  += snd-soc-tas2552.o
 obj-$(CONFIG_SND_SOC_TAS5086)  += snd-soc-tas5086.o
+obj-$(CONFIG_SND_SOC_TFA9879)  += snd-soc-tfa9879.o
 obj-$(CONFIG_SND_SOC_TLV320AIC23)  += snd-soc-tlv320aic23.o
 obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C)  += snd-soc-tlv320aic23-i2c.o
 obj-$(CONFIG_SND_SOC_TLV320AIC23_SPI)  += snd-soc-tlv320aic23-spi.o
diff --git a/sound/soc/codecs/tfa9879.c b/sound/soc/codecs/tfa9879.c
new file mode 100644
index ..c48022639a29
--- /dev/null
+++ b/sound/soc/codecs/tfa9879.c
@@ -0,0 +1,323 @@
+/*
+ * tfa9879.c  --  driver for NXP Semiconductors TFA9879
+ *
+ * Copyright (C) 2014 Axentia Technologies AB
+ * Author: Peter Rosin 
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "tfa9879.h"
+
+struct tfa9879_priv {
+   struct regmap *regmap;
+   int lsb_justified;
+};
+
+static int tfa9879_hw_params(struct snd_pcm_substream *substream,
+struct snd_pcm_hw_params *params,
+struct snd_soc_dai *dai)
+{
+   struct snd_soc_codec *codec = dai->codec;
+   struct tfa9879_priv *tfa9879 = snd_soc_codec_get_drvdata(codec);
+   int fs;
+   int i2s_set = 0;
+
+   switch (params_rate(params)) {
+   case 8000:
+   fs = TFA9879_I2S_FS_8000;
+   break;
+   case 11025:
+   fs = TFA9879_I2S_FS_11025;
+   break;
+   case 12000:
+   fs = TFA9879_I2S_FS_12000;
+   break;
+   case 16000:
+   fs = TFA9879_I2S_FS_16000;
+   break;
+   case 22050:
+   fs = TFA9879_I2S_FS_22050;
+   break;
+   case 24000:
+   fs = TFA9879_I2S_FS_24000;
+   break;
+   case 32000:
+   fs = TFA9879_I2S_FS_32000;
+   break;
+   case 44100:
+   fs = TFA9879_I2S_FS_44100;
+   break;
+   case 48000:
+   fs = TFA9879_I2S_FS_48000;
+   break;
+   case 64000:
+   fs = TFA9879_I2S_FS_64000;
+   break;
+   case 88200:
+   fs = TFA9879_I2S_FS_88200;
+   break;
+   case 96000:
+   fs = TFA9879_I2S_FS_96000;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   sw