]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
Merge tag 'asoc-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound...
authorTakashi Iwai <tiwai@suse.de>
Mon, 5 Mar 2012 14:07:33 +0000 (15:07 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 5 Mar 2012 14:07:33 +0000 (15:07 +0100)
This has been a very active release for ASoC, as well as the usual raft
of bugfixes and driver updates there's quite a few framework enhancements.
Most are either small or are laying the groundwork for user visible
features (especially dynamic PCM), the most directly visible change is
the dmaengine library.  There's also a bunch of regmap API enhancements
pulled into the tree so that either the framework or drivers can take
advantage of the new features.

Changes include:

- Support for widgets not associated with a CODEC, an important part of
  the dynamic PCM framework.

- A library factoring out the common code shared by dmaengine based DMA
  drivers contributed by Lars-Peter Clausen.  This will save a lot of
  code and make it much easier to deploy enhancements to dmaengine.

- Support for binary controls, used for providing runtime configuration
  of algorithm coefficients.

- A new DAPM widget type for regulator supplies allowing drivers for
  devices that can power down unused supplies while active to do without
  any per-driver code.

- DAPM widgets for DAIs, initially giving a speed boost for playback
  startup and shutdown and also the basis for CODEC<->CODEC DAI link
  support.

- Support for specifying the number of significant bits on audio
  interfaces, useful for allowing applications to know how much effort to
  put into generating data for a larger sample format.

- Conversion of the FSI driver used on some SH processors to DMAEngine.

- New CODEC drivers for Maxim MAX9768 and Wolfson Microelectronics WM2200.

arch/arm/mach-omap2/board-4430sdp.c
arch/arm/mach-omap2/board-omap4panda.c
include/linux/platform_data/omap-abe-twl6040.h [new file with mode: 0644]
sound/soc/codecs/twl6040.c
sound/soc/omap/Kconfig
sound/soc/omap/Makefile
sound/soc/omap/omap-abe-twl6040.c [new file with mode: 0644]
sound/soc/omap/sdp4430.c [deleted file]

index 4e9071589bfb60ac3bfb5a222eefcfebc700bd03..90c76d340fb3b6b7a4119822504279e9211b5228 100644 (file)
@@ -41,6 +41,7 @@
 #include <video/omap-panel-nokia-dsi.h>
 #include <video/omap-panel-picodlp.h>
 #include <linux/wl12xx.h>
+#include <linux/platform_data/omap-abe-twl6040.h>
 
 #include "mux.h"
 #include "hsmmc.h"
@@ -378,12 +379,40 @@ static struct platform_device sdp4430_dmic_codec = {
        .id     = -1,
 };
 
+static struct omap_abe_twl6040_data sdp4430_abe_audio_data = {
+       .card_name = "SDP4430",
+       .has_hs         = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
+       .has_hf         = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
+       .has_ep         = 1,
+       .has_aux        = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
+       .has_vibra      = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
+
+       .has_dmic       = 1,
+       .has_hsmic      = 1,
+       .has_mainmic    = 1,
+       .has_submic     = 1,
+       .has_afm        = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
+
+       .jack_detection = 1,
+       /* MCLK input is 38.4MHz */
+       .mclk_freq      = 38400000,
+};
+
+static struct platform_device sdp4430_abe_audio = {
+       .name           = "omap-abe-twl6040",
+       .id             = -1,
+       .dev = {
+               .platform_data = &sdp4430_abe_audio_data,
+       },
+};
+
 static struct platform_device *sdp4430_devices[] __initdata = {
        &sdp4430_gpio_keys_device,
        &sdp4430_leds_gpio,
        &sdp4430_leds_pwm,
        &sdp4430_vbat,
        &sdp4430_dmic_codec,
+       &sdp4430_abe_audio,
 };
 
 static struct omap_musb_board_data musb_board_data = {
index 28fc271f70316510b5268c2a212adcac3718fce1..1af564b0487ee1e5428d98f562a9a1562793ade7 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/regulator/machine.h>
 #include <linux/regulator/fixed.h>
 #include <linux/wl12xx.h>
+#include <linux/platform_data/omap-abe-twl6040.h>
 
 #include <mach/hardware.h>
 #include <asm/hardware/gic.h>
@@ -91,9 +92,34 @@ static struct platform_device leds_gpio = {
        },
 };
 
+static struct omap_abe_twl6040_data panda_abe_audio_data = {
+       /* Audio out */
+       .has_hs         = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
+       /* HandsFree through expasion connector */
+       .has_hf         = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
+       /* PandaBoard: FM TX, PandaBoardES: can be connected to audio out */
+       .has_aux        = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
+       /* PandaBoard: FM RX, PandaBoardES: audio in */
+       .has_afm        = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
+       /* No jack detection. */
+       .jack_detection = 0,
+       /* MCLK input is 38.4MHz */
+       .mclk_freq      = 38400000,
+
+};
+
+static struct platform_device panda_abe_audio = {
+       .name           = "omap-abe-twl6040",
+       .id             = -1,
+       .dev = {
+               .platform_data = &panda_abe_audio_data,
+       },
+};
+
 static struct platform_device *panda_devices[] __initdata = {
        &leds_gpio,
        &wl1271_device,
+       &panda_abe_audio,
 };
 
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
@@ -252,8 +278,25 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
        return 0;
 }
 
+static struct twl4030_codec_data twl6040_codec = {
+       /* single-step ramp for headset and handsfree */
+       .hs_left_step   = 0x0f,
+       .hs_right_step  = 0x0f,
+       .hf_left_step   = 0x1d,
+       .hf_right_step  = 0x1d,
+};
+
+static struct twl4030_audio_data twl6040_audio = {
+       .codec          = &twl6040_codec,
+       .audpwron_gpio  = 127,
+       .naudint_irq    = OMAP44XX_IRQ_SYS_2N,
+       .irq_base       = TWL6040_CODEC_IRQ_BASE,
+};
+
 /* Panda board uses the common PMIC configuration */
-static struct twl4030_platform_data omap4_panda_twldata;
+static struct twl4030_platform_data omap4_panda_twldata = {
+       .audio          = &twl6040_audio,
+};
 
 /*
  * Display monitor features are burnt in their EEPROM as EDID data. The EEPROM
@@ -485,6 +528,20 @@ void omap4_panda_display_init(void)
        omap_mux_init_gpio(HDMI_GPIO_HPD, OMAP_PIN_INPUT_PULLDOWN);
 }
 
+static void omap4_panda_init_rev(void)
+{
+       if (cpu_is_omap4430()) {
+               /* PandaBoard 4430 */
+               /* ASoC audio configuration */
+               panda_abe_audio_data.card_name = "PandaBoard";
+               panda_abe_audio_data.has_hsmic = 1;
+       } else {
+               /* PandaBoard ES */
+               /* ASoC audio configuration */
+               panda_abe_audio_data.card_name = "PandaBoardES";
+       }
+}
+
 static void __init omap4_panda_init(void)
 {
        int package = OMAP_PACKAGE_CBS;
@@ -498,6 +555,7 @@ static void __init omap4_panda_init(void)
        if (ret)
                pr_err("error setting wl12xx data: %d\n", ret);
 
+       omap4_panda_init_rev();
        omap4_panda_i2c_init();
        platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
        platform_device_register(&omap_vwlan_device);
diff --git a/include/linux/platform_data/omap-abe-twl6040.h b/include/linux/platform_data/omap-abe-twl6040.h
new file mode 100644 (file)
index 0000000..5d298ac
--- /dev/null
@@ -0,0 +1,49 @@
+/**
+ * omap-abe-twl6040.h - ASoC machine driver OMAP4+ devices, header.
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
+ * All rights reserved.
+ *
+ * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _OMAP_ABE_TWL6040_H_
+#define _OMAP_ABE_TWL6040_H_
+
+/* To select if only one channel is connected in a stereo port */
+#define ABE_TWL6040_LEFT       (1 << 0)
+#define ABE_TWL6040_RIGHT      (1 << 1)
+
+struct omap_abe_twl6040_data {
+       char *card_name;
+       /* Feature flags for connected audio pins */
+       u8      has_hs;
+       u8      has_hf;
+       bool    has_ep;
+       u8      has_aux;
+       u8      has_vibra;
+       bool    has_dmic;
+       bool    has_hsmic;
+       bool    has_mainmic;
+       bool    has_submic;
+       u8      has_afm;
+       /* Other features */
+       bool    jack_detection; /* board can detect jack events */
+       int     mclk_freq;      /* MCLK frequency speed for twl6040 */
+};
+
+#endif /* _OMAP_ABE_TWL6040_H_ */
index 836eb14f7b85a0598aea3aa7f1cdb9c572cf4ebf..2d8c6b825e57b9ecd17253c5de57432260ecdaab 100644 (file)
@@ -1138,14 +1138,14 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
                        TWL6040_REG_MICRCTL, 2, 0),
 
        /* Microphone bias */
-       SND_SOC_DAPM_MICBIAS("Headset Mic Bias",
-                       TWL6040_REG_AMICBCTL, 0, 0),
-       SND_SOC_DAPM_MICBIAS("Main Mic Bias",
-                       TWL6040_REG_AMICBCTL, 4, 0),
-       SND_SOC_DAPM_MICBIAS("Digital Mic1 Bias",
-                       TWL6040_REG_DMICBCTL, 0, 0),
-       SND_SOC_DAPM_MICBIAS("Digital Mic2 Bias",
-                       TWL6040_REG_DMICBCTL, 4, 0),
+       SND_SOC_DAPM_SUPPLY("Headset Mic Bias",
+                           TWL6040_REG_AMICBCTL, 0, 0, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("Main Mic Bias",
+                           TWL6040_REG_AMICBCTL, 4, 0, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("Digital Mic1 Bias",
+                           TWL6040_REG_DMICBCTL, 0, 0, NULL, 0),
+       SND_SOC_DAPM_SUPPLY("Digital Mic2 Bias",
+                           TWL6040_REG_DMICBCTL, 4, 0, NULL, 0),
 
        /* DACs */
        SND_SOC_DAPM_DAC("HSDAC Left", "Headset Playback", SND_SOC_NOPM, 0, 0),
index fb1bf2581efb1b224aadbdd040ec83feab61f88d..47b23fea20c21cc897b60428c8abb4ac218b766e 100644 (file)
@@ -97,16 +97,19 @@ config SND_OMAP_SOC_SDP3430
          Say Y if you want to add support for SoC audio on Texas Instruments
          SDP3430.
 
-config SND_OMAP_SOC_SDP4430
-       tristate "SoC Audio support for Texas Instruments SDP4430"
-       depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_4430SDP
+config SND_OMAP_SOC_OMAP_ABE_TWL6040
+       tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec"
+       depends on TWL4030_CORE && SND_OMAP_SOC && ARCH_OMAP4
        select SND_OMAP_SOC_DMIC
        select SND_OMAP_SOC_MCPDM
        select SND_SOC_TWL6040
        select SND_SOC_DMIC
        help
-         Say Y if you want to add support for SoC audio on Texas Instruments
-         SDP4430.
+         Say Y if you want to add support for SoC audio on OMAP boards using
+         ABE and twl6040 codec. This driver currently supports:
+         - SDP4430/Blaze boards
+         - PandaBoard (4430)
+         - PandaBoardES (4460)
 
 config SND_OMAP_SOC_OMAP4_HDMI
        tristate "SoC Audio support for Texas Instruments OMAP4 HDMI"
index 1fd723fb559d0e14b55bd4b2bf549f77a532ea5c..123ac18303e50bbd759d6ef98d28288d8c5b750a 100644 (file)
@@ -20,7 +20,7 @@ snd-soc-overo-objs := overo.o
 snd-soc-omap3evm-objs := omap3evm.o
 snd-soc-am3517evm-objs := am3517evm.o
 snd-soc-sdp3430-objs := sdp3430.o
-snd-soc-sdp4430-objs := sdp4430.o
+snd-soc-omap-abe-twl6040-objs := omap-abe-twl6040.o
 snd-soc-omap3pandora-objs := omap3pandora.o
 snd-soc-omap3beagle-objs := omap3beagle.o
 snd-soc-zoom2-objs := zoom2.o
@@ -36,7 +36,7 @@ obj-$(CONFIG_SND_OMAP_SOC_OMAP2EVM) += snd-soc-omap2evm.o
 obj-$(CONFIG_SND_OMAP_SOC_OMAP3EVM) += snd-soc-omap3evm.o
 obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o
 obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o
-obj-$(CONFIG_SND_OMAP_SOC_SDP4430) += snd-soc-sdp4430.o
+obj-$(CONFIG_SND_OMAP_SOC_OMAP_ABE_TWL6040) += snd-soc-omap-abe-twl6040.o
 obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o
 obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o
 obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
new file mode 100644 (file)
index 0000000..93bb8ee
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * omap-abe-twl6040.c  --  SoC audio for TI OMAP based boards with ABE and
+ *                        twl6040 codec
+ *
+ * Author: Misael Lopez Cruz <misael.lopez@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/clk.h>
+#include <linux/platform_device.h>
+#include <linux/mfd/twl6040.h>
+#include <linux/platform_data/omap-abe-twl6040.h>
+#include <linux/module.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/jack.h>
+
+#include <asm/mach-types.h>
+#include <plat/hardware.h>
+#include <plat/mux.h>
+
+#include "omap-dmic.h"
+#include "omap-mcpdm.h"
+#include "omap-pcm.h"
+#include "../codecs/twl6040.h"
+
+static int omap_abe_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_codec *codec = rtd->codec;
+       struct snd_soc_card *card = codec->card;
+       struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev);
+       int clk_id, freq;
+       int ret;
+
+       clk_id = twl6040_get_clk_id(rtd->codec);
+       if (clk_id == TWL6040_SYSCLK_SEL_HPPLL)
+               freq = pdata->mclk_freq;
+       else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL)
+               freq = 32768;
+       else
+               return -EINVAL;
+
+       /* set the codec mclk */
+       ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, freq,
+                               SND_SOC_CLOCK_IN);
+       if (ret) {
+               printk(KERN_ERR "can't set codec system clock\n");
+               return ret;
+       }
+       return ret;
+}
+
+static struct snd_soc_ops omap_abe_ops = {
+       .hw_params = omap_abe_hw_params,
+};
+
+static int omap_abe_dmic_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+       int ret = 0;
+
+       ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_DMIC_SYSCLK_PAD_CLKS,
+                                    19200000, SND_SOC_CLOCK_IN);
+       if (ret < 0) {
+               printk(KERN_ERR "can't set DMIC cpu system clock\n");
+               return ret;
+       }
+       ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_DMIC_ABE_DMIC_CLK, 2400000,
+                                    SND_SOC_CLOCK_OUT);
+       if (ret < 0) {
+               printk(KERN_ERR "can't set DMIC output clock\n");
+               return ret;
+       }
+       return 0;
+}
+
+static struct snd_soc_ops omap_abe_dmic_ops = {
+       .hw_params = omap_abe_dmic_hw_params,
+};
+
+/* Headset jack */
+static struct snd_soc_jack hs_jack;
+
+/*Headset jack detection DAPM pins */
+static struct snd_soc_jack_pin hs_jack_pins[] = {
+       {
+               .pin = "Headset Mic",
+               .mask = SND_JACK_MICROPHONE,
+       },
+       {
+               .pin = "Headset Stereophone",
+               .mask = SND_JACK_HEADPHONE,
+       },
+};
+
+/* SDP4430 machine DAPM */
+static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
+       /* Outputs */
+       SND_SOC_DAPM_HP("Headset Stereophone", NULL),
+       SND_SOC_DAPM_SPK("Earphone Spk", NULL),
+       SND_SOC_DAPM_SPK("Ext Spk", NULL),
+       SND_SOC_DAPM_LINE("Line Out", NULL),
+       SND_SOC_DAPM_SPK("Vibrator", NULL),
+
+       /* Inputs */
+       SND_SOC_DAPM_MIC("Headset Mic", NULL),
+       SND_SOC_DAPM_MIC("Main Handset Mic", NULL),
+       SND_SOC_DAPM_MIC("Sub Handset Mic", NULL),
+       SND_SOC_DAPM_LINE("Line In", NULL),
+};
+
+static const struct snd_soc_dapm_route audio_map[] = {
+       /* Routings for outputs */
+       {"Headset Stereophone", NULL, "HSOL"},
+       {"Headset Stereophone", NULL, "HSOR"},
+
+       {"Earphone Spk", NULL, "EP"},
+
+       {"Ext Spk", NULL, "HFL"},
+       {"Ext Spk", NULL, "HFR"},
+
+       {"Line Out", NULL, "AUXL"},
+       {"Line Out", NULL, "AUXR"},
+
+       {"Vibrator", NULL, "VIBRAL"},
+       {"Vibrator", NULL, "VIBRAR"},
+
+       /* Routings for inputs */
+       {"HSMIC", NULL, "Headset Mic"},
+       {"Headset Mic", NULL, "Headset Mic Bias"},
+
+       {"MAINMIC", NULL, "Main Handset Mic"},
+       {"Main Handset Mic", NULL, "Main Mic Bias"},
+
+       {"SUBMIC", NULL, "Sub Handset Mic"},
+       {"Sub Handset Mic", NULL, "Main Mic Bias"},
+
+       {"AFML", NULL, "Line In"},
+       {"AFMR", NULL, "Line In"},
+};
+
+static inline void twl6040_disconnect_pin(struct snd_soc_dapm_context *dapm,
+                                         int connected, char *pin)
+{
+       if (!connected)
+               snd_soc_dapm_disable_pin(dapm, pin);
+}
+
+static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
+{
+       struct snd_soc_codec *codec = rtd->codec;
+       struct snd_soc_card *card = codec->card;
+       struct snd_soc_dapm_context *dapm = &codec->dapm;
+       struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev);
+       int hs_trim;
+       int ret = 0;
+
+       /* Disable not connected paths if not used */
+       twl6040_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone");
+       twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk");
+       twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk");
+       twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out");
+       twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vinrator");
+       twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic");
+       twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic");
+       twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic");
+       twl6040_disconnect_pin(dapm, pdata->has_afm, "Line In");
+
+       /*
+        * Configure McPDM offset cancellation based on the HSOTRIM value from
+        * twl6040.
+        */
+       hs_trim = twl6040_get_trim_value(codec, TWL6040_TRIM_HSOTRIM);
+       omap_mcpdm_configure_dn_offsets(rtd, TWL6040_HSF_TRIM_LEFT(hs_trim),
+                                       TWL6040_HSF_TRIM_RIGHT(hs_trim));
+
+       /* Headset jack detection only if it is supported */
+       if (pdata->jack_detection) {
+               ret = snd_soc_jack_new(codec, "Headset Jack",
+                                       SND_JACK_HEADSET, &hs_jack);
+               if (ret)
+                       return ret;
+
+               ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
+                                       hs_jack_pins);
+               twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
+       }
+
+       return ret;
+}
+
+static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = {
+       SND_SOC_DAPM_MIC("Digital Mic", NULL),
+};
+
+static const struct snd_soc_dapm_route dmic_audio_map[] = {
+       {"DMic", NULL, "Digital Mic"},
+       {"Digital Mic", NULL, "Digital Mic1 Bias"},
+};
+
+static int omap_abe_dmic_init(struct snd_soc_pcm_runtime *rtd)
+{
+       struct snd_soc_codec *codec = rtd->codec;
+       struct snd_soc_dapm_context *dapm = &codec->dapm;
+       int ret;
+
+       ret = snd_soc_dapm_new_controls(dapm, dmic_dapm_widgets,
+                               ARRAY_SIZE(dmic_dapm_widgets));
+       if (ret)
+               return ret;
+
+       return snd_soc_dapm_add_routes(dapm, dmic_audio_map,
+                               ARRAY_SIZE(dmic_audio_map));
+}
+
+/* Digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link twl6040_dmic_dai[] = {
+       {
+               .name = "TWL6040",
+               .stream_name = "TWL6040",
+               .cpu_dai_name = "omap-mcpdm",
+               .codec_dai_name = "twl6040-legacy",
+               .platform_name = "omap-pcm-audio",
+               .codec_name = "twl6040-codec",
+               .init = omap_abe_twl6040_init,
+               .ops = &omap_abe_ops,
+       },
+       {
+               .name = "DMIC",
+               .stream_name = "DMIC Capture",
+               .cpu_dai_name = "omap-dmic",
+               .codec_dai_name = "dmic-hifi",
+               .platform_name = "omap-pcm-audio",
+               .codec_name = "dmic-codec",
+               .init = omap_abe_dmic_init,
+               .ops = &omap_abe_dmic_ops,
+       },
+};
+
+static struct snd_soc_dai_link twl6040_only_dai[] = {
+       {
+               .name = "TWL6040",
+               .stream_name = "TWL6040",
+               .cpu_dai_name = "omap-mcpdm",
+               .codec_dai_name = "twl6040-legacy",
+               .platform_name = "omap-pcm-audio",
+               .codec_name = "twl6040-codec",
+               .init = omap_abe_twl6040_init,
+               .ops = &omap_abe_ops,
+       },
+};
+
+/* Audio machine driver */
+static struct snd_soc_card omap_abe_card = {
+       .owner = THIS_MODULE,
+
+       .dapm_widgets = twl6040_dapm_widgets,
+       .num_dapm_widgets = ARRAY_SIZE(twl6040_dapm_widgets),
+       .dapm_routes = audio_map,
+       .num_dapm_routes = ARRAY_SIZE(audio_map),
+};
+
+static __devinit int omap_abe_probe(struct platform_device *pdev)
+{
+       struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev);
+       struct snd_soc_card *card = &omap_abe_card;
+       int ret;
+
+       card->dev = &pdev->dev;
+
+       if (!pdata) {
+               dev_err(&pdev->dev, "Missing pdata\n");
+               return -ENODEV;
+       }
+
+       if (pdata->card_name) {
+               card->name = pdata->card_name;
+       } else {
+               dev_err(&pdev->dev, "Card name is not provided\n");
+               return -ENODEV;
+       }
+
+       if (!pdata->mclk_freq) {
+               dev_err(&pdev->dev, "MCLK frequency missing\n");
+               return -ENODEV;
+       }
+
+       if (pdata->has_dmic) {
+               card->dai_link = twl6040_dmic_dai;
+               card->num_links = ARRAY_SIZE(twl6040_dmic_dai);
+       } else {
+               card->dai_link = twl6040_only_dai;
+               card->num_links = ARRAY_SIZE(twl6040_only_dai);
+       }
+
+       ret = snd_soc_register_card(card);
+       if (ret)
+               dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
+                       ret);
+
+       return ret;
+}
+
+static int __devexit omap_abe_remove(struct platform_device *pdev)
+{
+       struct snd_soc_card *card = platform_get_drvdata(pdev);
+
+       snd_soc_unregister_card(card);
+
+       return 0;
+}
+
+static struct platform_driver omap_abe_driver = {
+       .driver = {
+               .name = "omap-abe-twl6040",
+               .owner = THIS_MODULE,
+               .pm = &snd_soc_pm_ops,
+       },
+       .probe = omap_abe_probe,
+       .remove = __devexit_p(omap_abe_remove),
+};
+
+module_platform_driver(omap_abe_driver);
+
+MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>");
+MODULE_DESCRIPTION("ALSA SoC for OMAP boards with ABE and twl6040 codec");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:omap-abe-twl6040");
diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c
deleted file mode 100644 (file)
index 175ba9a..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * sdp4430.c  --  SoC audio for TI OMAP4430 SDP
- *
- * Author: Misael Lopez Cruz <x0052729@ti.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#include <linux/clk.h>
-#include <linux/platform_device.h>
-#include <linux/mfd/twl6040.h>
-#include <linux/module.h>
-
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/soc.h>
-#include <sound/jack.h>
-
-#include <asm/mach-types.h>
-#include <plat/hardware.h>
-#include <plat/mux.h>
-
-#include "omap-dmic.h"
-#include "omap-mcpdm.h"
-#include "omap-pcm.h"
-#include "../codecs/twl6040.h"
-
-static int sdp4430_hw_params(struct snd_pcm_substream *substream,
-       struct snd_pcm_hw_params *params)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       int clk_id, freq;
-       int ret;
-
-       clk_id = twl6040_get_clk_id(rtd->codec);
-       if (clk_id == TWL6040_SYSCLK_SEL_HPPLL)
-               freq = 38400000;
-       else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL)
-               freq = 32768;
-       else
-               return -EINVAL;
-
-       /* set the codec mclk */
-       ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, freq,
-                               SND_SOC_CLOCK_IN);
-       if (ret) {
-               printk(KERN_ERR "can't set codec system clock\n");
-               return ret;
-       }
-       return ret;
-}
-
-static struct snd_soc_ops sdp4430_ops = {
-       .hw_params = sdp4430_hw_params,
-};
-
-static int sdp4430_dmic_hw_params(struct snd_pcm_substream *substream,
-       struct snd_pcm_hw_params *params)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       int ret = 0;
-
-       ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_DMIC_SYSCLK_PAD_CLKS,
-                                    19200000, SND_SOC_CLOCK_IN);
-       if (ret < 0) {
-               printk(KERN_ERR "can't set DMIC cpu system clock\n");
-               return ret;
-       }
-       ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_DMIC_ABE_DMIC_CLK, 2400000,
-                                    SND_SOC_CLOCK_OUT);
-       if (ret < 0) {
-               printk(KERN_ERR "can't set DMIC output clock\n");
-               return ret;
-       }
-       return 0;
-}
-
-static struct snd_soc_ops sdp4430_dmic_ops = {
-       .hw_params = sdp4430_dmic_hw_params,
-};
-
-/* Headset jack */
-static struct snd_soc_jack hs_jack;
-
-/*Headset jack detection DAPM pins */
-static struct snd_soc_jack_pin hs_jack_pins[] = {
-       {
-               .pin = "Headset Mic",
-               .mask = SND_JACK_MICROPHONE,
-       },
-       {
-               .pin = "Headset Stereophone",
-               .mask = SND_JACK_HEADPHONE,
-       },
-};
-
-/* SDP4430 machine DAPM */
-static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = {
-       SND_SOC_DAPM_MIC("Ext Mic", NULL),
-       SND_SOC_DAPM_SPK("Ext Spk", NULL),
-       SND_SOC_DAPM_MIC("Headset Mic", NULL),
-       SND_SOC_DAPM_HP("Headset Stereophone", NULL),
-       SND_SOC_DAPM_SPK("Earphone Spk", NULL),
-       SND_SOC_DAPM_INPUT("FM Stereo In"),
-};
-
-static const struct snd_soc_dapm_route audio_map[] = {
-       /* External Mics: MAINMIC, SUBMIC with bias*/
-       {"MAINMIC", NULL, "Main Mic Bias"},
-       {"SUBMIC", NULL, "Main Mic Bias"},
-       {"Main Mic Bias", NULL, "Ext Mic"},
-
-       /* External Speakers: HFL, HFR */
-       {"Ext Spk", NULL, "HFL"},
-       {"Ext Spk", NULL, "HFR"},
-
-       /* Headset Mic: HSMIC with bias */
-       {"HSMIC", NULL, "Headset Mic Bias"},
-       {"Headset Mic Bias", NULL, "Headset Mic"},
-
-       /* Headset Stereophone (Headphone): HSOL, HSOR */
-       {"Headset Stereophone", NULL, "HSOL"},
-       {"Headset Stereophone", NULL, "HSOR"},
-
-       /* Earphone speaker */
-       {"Earphone Spk", NULL, "EP"},
-
-       /* Aux/FM Stereo In: AFML, AFMR */
-       {"AFML", NULL, "FM Stereo In"},
-       {"AFMR", NULL, "FM Stereo In"},
-};
-
-static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd)
-{
-       struct snd_soc_codec *codec = rtd->codec;
-       int ret, hs_trim;
-
-       /*
-        * Configure McPDM offset cancellation based on the HSOTRIM value from
-        * twl6040.
-        */
-       hs_trim = twl6040_get_trim_value(codec, TWL6040_TRIM_HSOTRIM);
-       omap_mcpdm_configure_dn_offsets(rtd, TWL6040_HSF_TRIM_LEFT(hs_trim),
-                                       TWL6040_HSF_TRIM_RIGHT(hs_trim));
-
-       /* Headset jack detection */
-       ret = snd_soc_jack_new(codec, "Headset Jack",
-                               SND_JACK_HEADSET, &hs_jack);
-       if (ret)
-               return ret;
-
-       ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
-                               hs_jack_pins);
-
-       if (machine_is_omap_4430sdp())
-               twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
-       else
-               snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET);
-
-       return ret;
-}
-
-static const struct snd_soc_dapm_widget sdp4430_dmic_dapm_widgets[] = {
-       SND_SOC_DAPM_MIC("Digital Mic", NULL),
-};
-
-static const struct snd_soc_dapm_route dmic_audio_map[] = {
-       {"DMic", NULL, "Digital Mic1 Bias"},
-       {"Digital Mic1 Bias", NULL, "Digital Mic"},
-};
-
-static int sdp4430_dmic_init(struct snd_soc_pcm_runtime *rtd)
-{
-       struct snd_soc_codec *codec = rtd->codec;
-       struct snd_soc_dapm_context *dapm = &codec->dapm;
-       int ret;
-
-       ret = snd_soc_dapm_new_controls(dapm, sdp4430_dmic_dapm_widgets,
-                               ARRAY_SIZE(sdp4430_dmic_dapm_widgets));
-       if (ret)
-               return ret;
-
-       return snd_soc_dapm_add_routes(dapm, dmic_audio_map,
-                               ARRAY_SIZE(dmic_audio_map));
-}
-
-/* Digital audio interface glue - connects codec <--> CPU */
-static struct snd_soc_dai_link sdp4430_dai[] = {
-       {
-               .name = "TWL6040",
-               .stream_name = "TWL6040",
-               .cpu_dai_name = "omap-mcpdm",
-               .codec_dai_name = "twl6040-legacy",
-               .platform_name = "omap-pcm-audio",
-               .codec_name = "twl6040-codec",
-               .init = sdp4430_twl6040_init,
-               .ops = &sdp4430_ops,
-       },
-       {
-               .name = "DMIC",
-               .stream_name = "DMIC Capture",
-               .cpu_dai_name = "omap-dmic",
-               .codec_dai_name = "dmic-hifi",
-               .platform_name = "omap-pcm-audio",
-               .codec_name = "dmic-codec",
-               .init = sdp4430_dmic_init,
-               .ops = &sdp4430_dmic_ops,
-       },
-};
-
-/* Audio machine driver */
-static struct snd_soc_card snd_soc_sdp4430 = {
-       .name = "SDP4430",
-       .owner = THIS_MODULE,
-       .dai_link = sdp4430_dai,
-       .num_links = ARRAY_SIZE(sdp4430_dai),
-
-       .dapm_widgets = sdp4430_twl6040_dapm_widgets,
-       .num_dapm_widgets = ARRAY_SIZE(sdp4430_twl6040_dapm_widgets),
-       .dapm_routes = audio_map,
-       .num_dapm_routes = ARRAY_SIZE(audio_map),
-};
-
-static struct platform_device *sdp4430_snd_device;
-
-static int __init sdp4430_soc_init(void)
-{
-       int ret;
-
-       if (!machine_is_omap_4430sdp())
-               return -ENODEV;
-       printk(KERN_INFO "SDP4430 SoC init\n");
-
-       sdp4430_snd_device = platform_device_alloc("soc-audio", -1);
-       if (!sdp4430_snd_device) {
-               printk(KERN_ERR "Platform device allocation failed\n");
-               return -ENOMEM;
-       }
-
-       platform_set_drvdata(sdp4430_snd_device, &snd_soc_sdp4430);
-
-       ret = platform_device_add(sdp4430_snd_device);
-       if (ret)
-               goto err;
-
-       return 0;
-
-err:
-       printk(KERN_ERR "Unable to add platform device\n");
-       platform_device_put(sdp4430_snd_device);
-       return ret;
-}
-module_init(sdp4430_soc_init);
-
-static void __exit sdp4430_soc_exit(void)
-{
-       platform_device_unregister(sdp4430_snd_device);
-}
-module_exit(sdp4430_soc_exit);
-
-MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>");
-MODULE_DESCRIPTION("ALSA SoC SDP4430");
-MODULE_LICENSE("GPL");
-