diff mbox

[V2,2/2] ASoC: OMAP2+: Move McBSP, DMIC and McPDM to generic DMA DT binding

Message ID 1362988223-22455-3-git-send-email-s-guiriec@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sebastien Guiriec March 11, 2013, 7:50 a.m. UTC
Update OMAP2+ driver in order to use OMAP DMA DT binding for OMAP2+.
In case of DT boot snd_dmaengine_generic_pcm_open function is used.

Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com>
---
 sound/soc/omap/mcbsp.c      |   26 ++++++++++++++++----------
 sound/soc/omap/omap-dmic.c  |   15 +++++++++------
 sound/soc/omap/omap-mcpdm.c |   22 ++++++++++++++--------
 sound/soc/omap/omap-pcm.c   |   12 ++++++++++--
 sound/soc/omap/omap-pcm.h   |    1 +
 5 files changed, 50 insertions(+), 26 deletions(-)

Comments

Peter Ujfalusi March 11, 2013, 2:18 p.m. UTC | #1
On 03/11/2013 08:50 AM, Sebastien Guiriec wrote:
> Update OMAP2+ driver in order to use OMAP DMA DT binding for OMAP2+.
> In case of DT boot snd_dmaengine_generic_pcm_open function is used.

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> 
> Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com>
> ---
>  sound/soc/omap/mcbsp.c      |   26 ++++++++++++++++----------
>  sound/soc/omap/omap-dmic.c  |   15 +++++++++------
>  sound/soc/omap/omap-mcpdm.c |   22 ++++++++++++++--------
>  sound/soc/omap/omap-pcm.c   |   12 ++++++++++--
>  sound/soc/omap/omap-pcm.h   |    1 +
>  5 files changed, 50 insertions(+), 26 deletions(-)
> 
> diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
> index 285c836..16936493 100644
> --- a/sound/soc/omap/mcbsp.c
> +++ b/sound/soc/omap/mcbsp.c
> @@ -1012,24 +1012,30 @@ int omap_mcbsp_init(struct platform_device *pdev)
>  		}
>  	}
>  
> -	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
> -	if (!res) {
> -		dev_err(&pdev->dev, "invalid rx DMA channel\n");
> -		return -ENODEV;
> +	if (!pdev->dev.of_node) {
> +		res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
> +		if (!res) {
> +			dev_err(&pdev->dev, "invalid rx DMA channel\n");
> +			return -ENODEV;
> +		}
> +		mcbsp->dma_data[1].dma_req = res->start;
>  	}
>  	/* RX DMA request number, and port address configuration */
>  	mcbsp->dma_data[1].name = "Audio Capture";
> -	mcbsp->dma_data[1].dma_req = res->start;
> +	mcbsp->dma_data[1].dma_name = "rx";
>  	mcbsp->dma_data[1].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
>  
> -	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
> -	if (!res) {
> -		dev_err(&pdev->dev, "invalid tx DMA channel\n");
> -		return -ENODEV;
> +	if (!pdev->dev.of_node) {
> +		res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
> +		if (!res) {
> +			dev_err(&pdev->dev, "invalid tx DMA channel\n");
> +			return -ENODEV;
> +		}
> +		mcbsp->dma_data[0].dma_req = res->start;
>  	}
>  	/* TX DMA request number, and port address configuration */
>  	mcbsp->dma_data[0].name = "Audio Playback";
> -	mcbsp->dma_data[0].dma_req = res->start;
> +	mcbsp->dma_data[0].dma_name = "tx";
>  	mcbsp->dma_data[0].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 0);
>  
>  	mcbsp->fclk = clk_get(&pdev->dev, "fck");
> diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
> index ba49ccd..8695b32 100644
> --- a/sound/soc/omap/omap-dmic.c
> +++ b/sound/soc/omap/omap-dmic.c
> @@ -62,6 +62,7 @@ struct omap_dmic {
>   */
>  static struct omap_pcm_dma_data omap_dmic_dai_dma_params = {
>  	.name		= "DMIC capture",
> +	.dma_name	= "up_link",
>  };
>  
>  static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val)
> @@ -478,13 +479,15 @@ static int asoc_dmic_probe(struct platform_device *pdev)
>  	}
>  	omap_dmic_dai_dma_params.port_addr = res->start + OMAP_DMIC_DATA_REG;
>  
> -	res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
> -	if (!res) {
> -		dev_err(dmic->dev, "invalid dma resource\n");
> -		ret = -ENODEV;
> -		goto err_put_clk;
> +	if (!pdev->dev.of_node) {
> +		res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
> +		if (!res) {
> +			dev_err(dmic->dev, "invalid dma resource\n");
> +			ret = -ENODEV;
> +			goto err_put_clk;
> +		}
> +		omap_dmic_dai_dma_params.dma_req = res->start;
>  	}
> -	omap_dmic_dai_dma_params.dma_req = res->start;
>  
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
>  	if (!res) {
> diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
> index 5ca11bd..f41bac8 100644
> --- a/sound/soc/omap/omap-mcpdm.c
> +++ b/sound/soc/omap/omap-mcpdm.c
> @@ -71,9 +71,11 @@ struct omap_mcpdm {
>  static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = {
>  	{
>  		.name = "Audio playback",
> +		.dma_name = "dn_link",
>  	},
>  	{
>  		.name = "Audio capture",
> +		.dma_name = "up_link",
>  	},
>  };
>  
> @@ -449,17 +451,21 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
>  	omap_mcpdm_dai_dma_params[0].port_addr = res->start + MCPDM_REG_DN_DATA;
>  	omap_mcpdm_dai_dma_params[1].port_addr = res->start + MCPDM_REG_UP_DATA;
>  
> -	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link");
> -	if (!res)
> -		return -ENODEV;
> +	if (!pdev->dev.of_node) {
> +		res = platform_get_resource_byname(pdev, IORESOURCE_DMA,
> +						   "dn_link");
> +		if (!res)
> +			return -ENODEV;
>  
> -	omap_mcpdm_dai_dma_params[0].dma_req = res->start;
> +		omap_mcpdm_dai_dma_params[0].dma_req = res->start;
>  
> -	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link");
> -	if (!res)
> -		return -ENODEV;
> +		res = platform_get_resource_byname(pdev, IORESOURCE_DMA,
> +						   "up_link");
> +		if (!res)
> +			return -ENODEV;
>  
> -	omap_mcpdm_dai_dma_params[1].dma_req = res->start;
> +		omap_mcpdm_dai_dma_params[1].dma_req = res->start;
> +	}
>  
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
>  	if (res == NULL)
> diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
> index c722c2e..df01a95 100644
> --- a/sound/soc/omap/omap-pcm.c
> +++ b/sound/soc/omap/omap-pcm.c
> @@ -176,13 +176,21 @@ static int omap_pcm_open(struct snd_pcm_substream *substream)
>  {
>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
>  	struct omap_pcm_dma_data *dma_data;
> +	int ret;
>  
>  	snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
>  
>  	dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
>  
> -	return snd_dmaengine_pcm_open(substream, omap_dma_filter_fn,
> -				      &dma_data->dma_req);
> +	if (rtd->cpu_dai->dev->of_node)
> +		ret = snd_dmaengine_generic_pcm_open(substream,
> +						     rtd->cpu_dai->dev,
> +						     dma_data->dma_name);
> +	else
> +		ret = snd_dmaengine_pcm_open(substream, omap_dma_filter_fn,
> +					     &dma_data->dma_req);
> +
> +	return ret;
>  }
>  
>  static int omap_pcm_close(struct snd_pcm_substream *substream)
> diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
> index cabe74c..06faa38 100644
> --- a/sound/soc/omap/omap-pcm.h
> +++ b/sound/soc/omap/omap-pcm.h
> @@ -29,6 +29,7 @@ struct snd_pcm_substream;
>  
>  struct omap_pcm_dma_data {
>  	char		*name;		/* stream identifier */
> +	char		*dma_name;	/* DMA request name */
>  	int		dma_req;	/* DMA request line */
>  	unsigned long	port_addr;	/* transmit/receive register */
>  	void (*set_threshold)(struct snd_pcm_substream *substream);
>
Mark Brown March 11, 2013, 2:33 p.m. UTC | #2
On Mon, Mar 11, 2013 at 08:50:22AM +0100, Sebastien Guiriec wrote:
> Update OMAP2+ driver in order to use OMAP DMA DT binding for OMAP2+.
> In case of DT boot snd_dmaengine_generic_pcm_open function is used.

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

or I can apply to ASoC if people prefer, I don't think it makes much
difference either way.
Tony Lindgren March 11, 2013, 4:27 p.m. UTC | #3
* Mark Brown <broonie@opensource.wolfsonmicro.com> [130311 07:37]:
> On Mon, Mar 11, 2013 at 08:50:22AM +0100, Sebastien Guiriec wrote:
> > Update OMAP2+ driver in order to use OMAP DMA DT binding for OMAP2+.
> > In case of DT boot snd_dmaengine_generic_pcm_open function is used.
> 
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> 
> or I can apply to ASoC if people prefer, I don't think it makes much
> difference either way.

I suggest you take the driver changes and Benoit takes the .dts
changes as those should be queued separately to avoid unnecessary
merge conflicts with the .dts files.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown March 11, 2013, 4:28 p.m. UTC | #4
On Mon, Mar 11, 2013 at 09:27:00AM -0700, Tony Lindgren wrote:

> I suggest you take the driver changes and Benoit takes the .dts
> changes as those should be queued separately to avoid unnecessary
> merge conflicts with the .dts files.

Won't that cause a bisect issue if the driver starts looking for generic
DT stuff that's not in the DTS files?
Tony Lindgren March 11, 2013, 4:38 p.m. UTC | #5
* Mark Brown <broonie@opensource.wolfsonmicro.com> [130311 09:32]:
> On Mon, Mar 11, 2013 at 09:27:00AM -0700, Tony Lindgren wrote:
> 
> > I suggest you take the driver changes and Benoit takes the .dts
> > changes as those should be queued separately to avoid unnecessary
> > merge conflicts with the .dts files.
> 
> Won't that cause a bisect issue if the driver starts looking for generic
> DT stuff that's not in the DTS files?

It should only affect additional features being enabled. When the .dts
changes get merged the new features just starts working. Or if the .dts
changes go in first, the driver starts working when the driver changes
go in.

If there's some dependency between the driver and the .dts changes
breaking booting etc, that should be fixed in the patches by
for example removing old legacy code later on in a separate series.

This allows us to break the dependency between arch/arm code and
drivers in most cases to keep things simpler.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jarkko Nikula March 11, 2013, 6:29 p.m. UTC | #6
On 03/11/2013 04:18 PM, Peter Ujfalusi wrote:
> On 03/11/2013 08:50 AM, Sebastien Guiriec wrote:
>> Update OMAP2+ driver in order to use OMAP DMA DT binding for OMAP2+.
>> In case of DT boot snd_dmaengine_generic_pcm_open function is used.
> 
> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> 
Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown March 12, 2013, 6:26 p.m. UTC | #7
On Mon, Mar 11, 2013 at 08:50:22AM +0100, Sebastien Guiriec wrote:
> Update OMAP2+ driver in order to use OMAP DMA DT binding for OMAP2+.
> In case of DT boot snd_dmaengine_generic_pcm_open function is used.

Applied, thanks.
Mark Brown March 13, 2013, 10:36 a.m. UTC | #8
On Mon, Mar 11, 2013 at 08:50:22AM +0100, Sebastien Guiriec wrote:
> Update OMAP2+ driver in order to use OMAP DMA DT binding for OMAP2+.
> In case of DT boot snd_dmaengine_generic_pcm_open function is used.
> 
> Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com>

Discarded since it breaks the build as a result of depending on unmerged
patches.
diff mbox

Patch

diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index 285c836..16936493 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -1012,24 +1012,30 @@  int omap_mcbsp_init(struct platform_device *pdev)
 		}
 	}
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
-	if (!res) {
-		dev_err(&pdev->dev, "invalid rx DMA channel\n");
-		return -ENODEV;
+	if (!pdev->dev.of_node) {
+		res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
+		if (!res) {
+			dev_err(&pdev->dev, "invalid rx DMA channel\n");
+			return -ENODEV;
+		}
+		mcbsp->dma_data[1].dma_req = res->start;
 	}
 	/* RX DMA request number, and port address configuration */
 	mcbsp->dma_data[1].name = "Audio Capture";
-	mcbsp->dma_data[1].dma_req = res->start;
+	mcbsp->dma_data[1].dma_name = "rx";
 	mcbsp->dma_data[1].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
-	if (!res) {
-		dev_err(&pdev->dev, "invalid tx DMA channel\n");
-		return -ENODEV;
+	if (!pdev->dev.of_node) {
+		res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
+		if (!res) {
+			dev_err(&pdev->dev, "invalid tx DMA channel\n");
+			return -ENODEV;
+		}
+		mcbsp->dma_data[0].dma_req = res->start;
 	}
 	/* TX DMA request number, and port address configuration */
 	mcbsp->dma_data[0].name = "Audio Playback";
-	mcbsp->dma_data[0].dma_req = res->start;
+	mcbsp->dma_data[0].dma_name = "tx";
 	mcbsp->dma_data[0].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 0);
 
 	mcbsp->fclk = clk_get(&pdev->dev, "fck");
diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
index ba49ccd..8695b32 100644
--- a/sound/soc/omap/omap-dmic.c
+++ b/sound/soc/omap/omap-dmic.c
@@ -62,6 +62,7 @@  struct omap_dmic {
  */
 static struct omap_pcm_dma_data omap_dmic_dai_dma_params = {
 	.name		= "DMIC capture",
+	.dma_name	= "up_link",
 };
 
 static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val)
@@ -478,13 +479,15 @@  static int asoc_dmic_probe(struct platform_device *pdev)
 	}
 	omap_dmic_dai_dma_params.port_addr = res->start + OMAP_DMIC_DATA_REG;
 
-	res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-	if (!res) {
-		dev_err(dmic->dev, "invalid dma resource\n");
-		ret = -ENODEV;
-		goto err_put_clk;
+	if (!pdev->dev.of_node) {
+		res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
+		if (!res) {
+			dev_err(dmic->dev, "invalid dma resource\n");
+			ret = -ENODEV;
+			goto err_put_clk;
+		}
+		omap_dmic_dai_dma_params.dma_req = res->start;
 	}
-	omap_dmic_dai_dma_params.dma_req = res->start;
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
 	if (!res) {
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index 5ca11bd..f41bac8 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -71,9 +71,11 @@  struct omap_mcpdm {
 static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = {
 	{
 		.name = "Audio playback",
+		.dma_name = "dn_link",
 	},
 	{
 		.name = "Audio capture",
+		.dma_name = "up_link",
 	},
 };
 
@@ -449,17 +451,21 @@  static int asoc_mcpdm_probe(struct platform_device *pdev)
 	omap_mcpdm_dai_dma_params[0].port_addr = res->start + MCPDM_REG_DN_DATA;
 	omap_mcpdm_dai_dma_params[1].port_addr = res->start + MCPDM_REG_UP_DATA;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link");
-	if (!res)
-		return -ENODEV;
+	if (!pdev->dev.of_node) {
+		res = platform_get_resource_byname(pdev, IORESOURCE_DMA,
+						   "dn_link");
+		if (!res)
+			return -ENODEV;
 
-	omap_mcpdm_dai_dma_params[0].dma_req = res->start;
+		omap_mcpdm_dai_dma_params[0].dma_req = res->start;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link");
-	if (!res)
-		return -ENODEV;
+		res = platform_get_resource_byname(pdev, IORESOURCE_DMA,
+						   "up_link");
+		if (!res)
+			return -ENODEV;
 
-	omap_mcpdm_dai_dma_params[1].dma_req = res->start;
+		omap_mcpdm_dai_dma_params[1].dma_req = res->start;
+	}
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
 	if (res == NULL)
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index c722c2e..df01a95 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -176,13 +176,21 @@  static int omap_pcm_open(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct omap_pcm_dma_data *dma_data;
+	int ret;
 
 	snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
 
 	dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
 
-	return snd_dmaengine_pcm_open(substream, omap_dma_filter_fn,
-				      &dma_data->dma_req);
+	if (rtd->cpu_dai->dev->of_node)
+		ret = snd_dmaengine_generic_pcm_open(substream,
+						     rtd->cpu_dai->dev,
+						     dma_data->dma_name);
+	else
+		ret = snd_dmaengine_pcm_open(substream, omap_dma_filter_fn,
+					     &dma_data->dma_req);
+
+	return ret;
 }
 
 static int omap_pcm_close(struct snd_pcm_substream *substream)
diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
index cabe74c..06faa38 100644
--- a/sound/soc/omap/omap-pcm.h
+++ b/sound/soc/omap/omap-pcm.h
@@ -29,6 +29,7 @@  struct snd_pcm_substream;
 
 struct omap_pcm_dma_data {
 	char		*name;		/* stream identifier */
+	char		*dma_name;	/* DMA request name */
 	int		dma_req;	/* DMA request line */
 	unsigned long	port_addr;	/* transmit/receive register */
 	void (*set_threshold)(struct snd_pcm_substream *substream);