Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe2a1e53 authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branch 'asoc/topic/omap' into asoc-next

parents 49ffa3b1 673c24e9
Loading
Loading
Loading
Loading
+0 −49
Original line number Original line Diff line number Diff line
/**
 * 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_ */
+3 −3
Original line number Original line Diff line number Diff line
config SND_OMAP_SOC
config SND_OMAP_SOC
	tristate "SoC Audio for the Texas Instruments OMAP chips"
	tristate "SoC Audio for the Texas Instruments OMAP chips"
	depends on ARCH_OMAP && DMA_OMAP
	depends on (ARCH_OMAP && DMA_OMAP) || (ARCH_ARM && COMPILE_TEST)
	select SND_DMAENGINE_PCM
	select SND_DMAENGINE_PCM


config SND_OMAP_SOC_DMIC
config SND_OMAP_SOC_DMIC
@@ -26,7 +26,7 @@ config SND_OMAP_SOC_N810


config SND_OMAP_SOC_RX51
config SND_OMAP_SOC_RX51
	tristate "SoC Audio support for Nokia RX-51"
	tristate "SoC Audio support for Nokia RX-51"
	depends on SND_OMAP_SOC && MACH_NOKIA_RX51
	depends on SND_OMAP_SOC && ARCH_ARM && (MACH_NOKIA_RX51 || COMPILE_TEST)
	select SND_OMAP_SOC_MCBSP
	select SND_OMAP_SOC_MCBSP
	select SND_SOC_TLV320AIC3X
	select SND_SOC_TLV320AIC3X
	select SND_SOC_TPA6130A2
	select SND_SOC_TPA6130A2
@@ -87,7 +87,7 @@ config SND_OMAP_SOC_OMAP_TWL4030


config SND_OMAP_SOC_OMAP_ABE_TWL6040
config SND_OMAP_SOC_OMAP_ABE_TWL6040
	tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec"
	tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec"
	depends on TWL6040_CORE && SND_OMAP_SOC && ARCH_OMAP4
	depends on TWL6040_CORE && SND_OMAP_SOC && (ARCH_OMAP4 || COMPILE_TEST)
	select SND_OMAP_SOC_DMIC
	select SND_OMAP_SOC_DMIC
	select SND_OMAP_SOC_MCPDM
	select SND_OMAP_SOC_MCPDM
	select SND_SOC_TWL6040
	select SND_SOC_TWL6040
+41 −92
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@
#include <linux/clk.h>
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/platform_device.h>
#include <linux/mfd/twl6040.h>
#include <linux/mfd/twl6040.h>
#include <linux/platform_data/omap-abe-twl6040.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of.h>


@@ -166,19 +165,10 @@ static const struct snd_soc_dapm_route audio_map[] = {
	{"AFMR", 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)
static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
{
{
	struct snd_soc_codec *codec = rtd->codec;
	struct snd_soc_codec *codec = rtd->codec;
	struct snd_soc_card *card = codec->card;
	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);
	struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card);
	struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card);
	int hs_trim;
	int hs_trim;
	int ret = 0;
	int ret = 0;
@@ -203,24 +193,6 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
		twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
		twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
	}
	}


	/*
	 * NULL pdata means we booted with DT. In this case the routing is
	 * provided and the card is fully routed, no need to mark pins.
	 */
	if (!pdata)
		return ret;

	/* 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, "Vibrator");
	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");

	return ret;
	return ret;
}
}


@@ -274,13 +246,18 @@ static struct snd_soc_card omap_abe_card = {


static int omap_abe_probe(struct platform_device *pdev)
static int omap_abe_probe(struct platform_device *pdev)
{
{
	struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev);
	struct device_node *node = pdev->dev.of_node;
	struct device_node *node = pdev->dev.of_node;
	struct snd_soc_card *card = &omap_abe_card;
	struct snd_soc_card *card = &omap_abe_card;
	struct device_node *dai_node;
	struct abe_twl6040 *priv;
	struct abe_twl6040 *priv;
	int num_links = 0;
	int num_links = 0;
	int ret = 0;
	int ret = 0;


	if (!node) {
		dev_err(&pdev->dev, "of node is missing.\n");
		return -ENODEV;
	}

	card->dev = &pdev->dev;
	card->dev = &pdev->dev;


	priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL);
	priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL);
@@ -289,19 +266,14 @@ static int omap_abe_probe(struct platform_device *pdev)


	priv->dmic_codec_dev = ERR_PTR(-EINVAL);
	priv->dmic_codec_dev = ERR_PTR(-EINVAL);


	if (node) {
		struct device_node *dai_node;

	if (snd_soc_of_parse_card_name(card, "ti,model")) {
	if (snd_soc_of_parse_card_name(card, "ti,model")) {
		dev_err(&pdev->dev, "Card name is not provided\n");
		dev_err(&pdev->dev, "Card name is not provided\n");
		return -ENODEV;
		return -ENODEV;
	}
	}


		ret = snd_soc_of_parse_audio_routing(card,
	ret = snd_soc_of_parse_audio_routing(card, "ti,audio-routing");
						"ti,audio-routing");
	if (ret) {
	if (ret) {
			dev_err(&pdev->dev,
		dev_err(&pdev->dev, "Error while parsing DAPM routing\n");
				"Error while parsing DAPM routing\n");
		return ret;
		return ret;
	}
	}


@@ -322,45 +294,22 @@ static int omap_abe_probe(struct platform_device *pdev)
		priv->dmic_codec_dev = platform_device_register_simple(
		priv->dmic_codec_dev = platform_device_register_simple(
						"dmic-codec", -1, NULL, 0);
						"dmic-codec", -1, NULL, 0);
		if (IS_ERR(priv->dmic_codec_dev)) {
		if (IS_ERR(priv->dmic_codec_dev)) {
				dev_err(&pdev->dev,
			dev_err(&pdev->dev, "Can't instantiate dmic-codec\n");
					"Can't instantiate dmic-codec\n");
			return PTR_ERR(priv->dmic_codec_dev);
			return PTR_ERR(priv->dmic_codec_dev);
		}
		}
	} else {
	} else {
		num_links = 1;
		num_links = 1;
	}
	}


		priv->jack_detection = of_property_read_bool(node,
	priv->jack_detection = of_property_read_bool(node, "ti,jack-detection");
							   "ti,jack-detection");
	of_property_read_u32(node, "ti,mclk-freq", &priv->mclk_freq);
		of_property_read_u32(node, "ti,mclk-freq",
				     &priv->mclk_freq);
	if (!priv->mclk_freq) {
	if (!priv->mclk_freq) {
		dev_err(&pdev->dev, "MCLK frequency not provided\n");
		dev_err(&pdev->dev, "MCLK frequency not provided\n");
		ret = -EINVAL;
		ret = -EINVAL;
		goto err_unregister;
		goto err_unregister;
	}
	}


		omap_abe_card.fully_routed = 1;
	card->fully_routed = 1;
	} else if (pdata) {
		if (pdata->card_name) {
			card->name = pdata->card_name;
		} else {
			dev_err(&pdev->dev, "Card name is not provided\n");
			return -ENODEV;
		}

		if (pdata->has_dmic)
			num_links = 2;
		else
			num_links = 1;

		priv->jack_detection = pdata->jack_detection;
		priv->mclk_freq = pdata->mclk_freq;
	} else {
		dev_err(&pdev->dev, "Missing pdata\n");
		return -ENODEV;
	}



	if (!priv->mclk_freq) {
	if (!priv->mclk_freq) {
		dev_err(&pdev->dev, "MCLK frequency missing\n");
		dev_err(&pdev->dev, "MCLK frequency missing\n");
+3 −6
Original line number Original line Diff line number Diff line
@@ -480,15 +480,12 @@ static int asoc_dmic_probe(struct platform_device *pdev)
	dmic->dma_data.filter_data = "up_link";
	dmic->dma_data.filter_data = "up_link";


	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
	if (!res) {
	dmic->io_base = devm_ioremap_resource(&pdev->dev, res);
		dev_err(dmic->dev, "invalid memory resource\n");
	if (IS_ERR(dmic->io_base)) {
		ret = -ENODEV;
		ret = PTR_ERR(dmic->io_base);
		goto err_put_clk;
		goto err_put_clk;
	}
	}


	dmic->io_base = devm_ioremap_resource(&pdev->dev, res);
	if (IS_ERR(dmic->io_base))
		return PTR_ERR(dmic->io_base);


	ret = snd_soc_register_component(&pdev->dev, &omap_dmic_component,
	ret = snd_soc_register_component(&pdev->dev, &omap_dmic_component,
					 &omap_dmic_dai, 1);
					 &omap_dmic_dai, 1);
+5 −0
Original line number Original line Diff line number Diff line
@@ -433,6 +433,11 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
		/* Sample rate generator drives the FS */
		/* Sample rate generator drives the FS */
		regs->srgr2	|= FSGM;
		regs->srgr2	|= FSGM;
		break;
		break;
	case SND_SOC_DAIFMT_CBM_CFS:
		/* McBSP slave. FS clock as output */
		regs->srgr2	|= FSGM;
		regs->pcr0	|= FSXM;
		break;
	case SND_SOC_DAIFMT_CBM_CFM:
	case SND_SOC_DAIFMT_CBM_CFM:
		/* McBSP slave */
		/* McBSP slave */
		break;
		break;
Loading