diff mbox

[07/26] davinci: dm646x: Adds McASP clock

Message ID 87fxd0ff4q.fsf@deeprootsystems.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Kevin Hilman July 13, 2009, 9:27 p.m. UTC
Troy Kisky <troy.kisky@boundarydevices.com> writes:

> Russell King - ARM Linux wrote:
>> On Fri, Jul 10, 2009 at 12:47:50PM -0700, Troy Kisky wrote:
>>> Mani, Arun wrote:
>>>> Hi,
>>>> I am trying the latest 2.6.31 rc2 branch. I am trying to make the Audio work.
>>>>  I found that the I2S clock is set to NULL. Because of this I am getting a NODEV error.
>>>> If I commented the check, I was able to map the I2S to the AIC33X. but I am not getting any sound.
>>> You need a clock, so don't comment out the check, rather give it one. ie.
>>>
>>> +static struct snd_platform_data snd_data = {
>>> +       .clk_name       = "asp0",
>>> +};
>>> +
>> 
>> This is broken from the clk API perspective.  clock "names" must not
>> be passed via platform data.  If you want to do that kind of thing you
>> might as well give up with the clk API and stop abusing it.
>>
>
> Then this patch needs further review. I added Chaithrika to the CC.
>
>
> commit 2a0232a115e81a4687d7ae07d5e1f2719a67f8a8
> Author: Chaithrika U S <chaithrika@ti.com>
> Date:   Fri Jun 5 06:28:08 2009 -0400
>
>     davinci: ASoC: Add the platform devices for ASP
>
>     1) Registers the platform devices for ASP on dm355, dm644x and dm646x
>        so that the machine driver can probe to get ASP related platform
>        data.
>     2) Move towards definition of the asp clocks using physical name(for
>        dm355 and dm644x)
>     3) Add platform data to board specific files.
>
>     Signed-off-by: Naresh Medisetty <naresh@ti.com>
>     Signed-off-by: Chaithrika U S <chaithrika@ti.com>
>     Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
>
> diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
> index 5ac2f56..78a9604 100644
> --- a/arch/arm/mach-davinci/board-dm355-evm.c
> +++ b/arch/arm/mach-davinci/board-dm355-evm.c
> @@ -118,6 +118,10 @@ static struct davinci_i2c_platform_data i2c_pdata = {
>         .bus_delay      = 0     /* usec */,
>  };
>
> +static struct snd_platform_data dm355_evm_snd_data = {
> +       .clk_name       = "asp1",
> +};
> +
>  static int dm355evm_mmc_gpios = -EINVAL;
>
>  static void dm355evm_mmcsd_gpios(unsigned gpio)
> @@ -280,6 +284,9 @@ static __init void dm355_evm_init(void)
>
>         dm355_init_spi0(BIT(0), dm355_evm_spi_info,
>                         ARRAY_SIZE(dm355_evm_spi_info));
> +
> +       /* DM335 EVM uses ASP1; line-out is a stereo mini-jack */
> +       dm355_init_asp1(ASP1_TX_EVT_EN | ASP1_RX_EVT_EN, &dm355_evm_snd_data);
>  }

Well, it's not actually this patch that started the problem, it was
the platform_data updates where clock names were added as part of the
new platform_data struct shared between platform code and ASoC.

My original proposal was to pass a clock pointer, not a clock name,
but that was not done, so...

I've pushed an update my 'temp/asoc' branch with the patch below which
converts to pasing clock pointers instead of clock names.

I'll rework this into two parts.  One for DaVinci git and one for
Mark's for-2.6.32 branch and submit.

Kevin

>From 9a3f98f1ed34ea407644f5bf174f7d70b496fb9e Mon Sep 17 00:00:00 2001
From: Kevin Hilman <khilman@deeprootsystems.com>
Date: Mon, 13 Jul 2009 14:06:10 -0700
Subject: [PATCH 3/3] davinci: ASoC: pass clock instead of clock name

Clock name strings should not be passed along to drivers.  Rather,
Let platform code get the correct clock for the platform, and
pass it along to ASoC via platform data.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-davinci/board-dm355-evm.c  |    9 +++++----
 arch/arm/mach-davinci/board-dm644x-evm.c |    9 +++++----
 arch/arm/mach-davinci/board-dm646x-evm.c |   12 ++++++++----
 arch/arm/mach-davinci/include/mach/asp.h |    2 +-
 sound/soc/davinci/davinci-i2s.c          |    2 +-
 sound/soc/davinci/davinci-mcasp.c        |    2 +-
 6 files changed, 21 insertions(+), 15 deletions(-)

Comments

Troy Kisky July 13, 2009, 9:52 p.m. UTC | #1
Kevin Hilman wrote:
> Well, it's not actually this patch that started the problem, it was
> the platform_data updates where clock names were added as part of the
> new platform_data struct shared between platform code and ASoC.
> 
> My original proposal was to pass a clock pointer, not a clock name,
> but that was not done, so...
> 
> I've pushed an update my 'temp/asoc' branch with the patch below which
> converts to pasing clock pointers instead of clock names.
> 
> I'll rework this into two parts.  One for DaVinci git and one for
> Mark's for-2.6.32 branch and submit.
> 
> Kevin
> 

Can you explain the philosophy of why this is better than the previous? They look about the same
to me. Both call clk_get with a name string, just in a different place.
Kevin Hilman July 13, 2009, 9:59 p.m. UTC | #2
Troy Kisky <troy.kisky@boundarydevices.com> writes:

> Kevin Hilman wrote:
>> Well, it's not actually this patch that started the problem, it was
>> the platform_data updates where clock names were added as part of the
>> new platform_data struct shared between platform code and ASoC.
>> 
>> My original proposal was to pass a clock pointer, not a clock name,
>> but that was not done, so...
>> 
>> I've pushed an update my 'temp/asoc' branch with the patch below which
>> converts to pasing clock pointers instead of clock names.
>> 
>> I'll rework this into two parts.  One for DaVinci git and one for
>> Mark's for-2.6.32 branch and submit.
>> 
>> Kevin
>> 
>
> Can you explain the philosophy of why this is better than the
> previous? They look about the same to me. Both call clk_get with a
> name string, just in a different place.

Correct. But in the updatd version, the code that uses the name is
platform specific code that has to know which physical clock to hook
up.

The point is that we should not be passing around platform-dependent
physical clock name strings to platform-indepenent code.

Kevin
Troy Kisky July 13, 2009, 10:08 p.m. UTC | #3
Kevin Hilman wrote:
> The point is that we should not be passing around platform-dependent
> physical clock name strings to platform-indepenent code.
> 
> Kevin
> 

I don't see the light, but that's ok. I'm not afraid of the dark.

Troy
Kevin Hilman July 13, 2009, 10:26 p.m. UTC | #4
Russell King - ARM Linux <linux@arm.linux.org.uk> writes:

> On Mon, Jul 13, 2009 at 02:27:01PM -0700, Kevin Hilman wrote:
>> Well, it's not actually this patch that started the problem, it was
>> the platform_data updates where clock names were added as part of the
>> new platform_data struct shared between platform code and ASoC.
>> 
>> My original proposal was to pass a clock pointer, not a clock name,
>> but that was not done, so...
>> 
>> I've pushed an update my 'temp/asoc' branch with the patch below which
>> converts to pasing clock pointers instead of clock names.
>
> Also wrong.  Why do you want to pass a clock name _or_ a clock pointer?
> Why not follow the clk API and derive it from the struct device.

This is how it is currently is in davinci mainline.

There was some objection to this on the ASoC side when support for a
new DaVinci SoC was added, so things were changed to pass clock name
strings.

I need to better understand from ASoC folks why the original model
wasn't working so we try to keep the current mainline code, or
possibly use clk_add_alias() if needed.

Kevin
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index 78a9604..cd87f89 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -118,9 +118,7 @@  static struct davinci_i2c_platform_data i2c_pdata = {
 	.bus_delay	= 0	/* usec */,
 };
 
-static struct snd_platform_data dm355_evm_snd_data = {
-	.clk_name	= "asp1",
-};
+static struct snd_platform_data dm355_evm_snd_data;
 
 static int dm355evm_mmc_gpios = -EINVAL;
 
@@ -286,7 +284,10 @@  static __init void dm355_evm_init(void)
 			ARRAY_SIZE(dm355_evm_spi_info));
 
 	/* DM335 EVM uses ASP1; line-out is a stereo mini-jack */
-	dm355_init_asp1(ASP1_TX_EVT_EN | ASP1_RX_EVT_EN, &dm355_evm_snd_data);
+	dm355_evm_snd_data.clk = clk_get(NULL, "asp1");
+	if (!WARN_ON(!dm355_evm_snd_data.clk))
+		dm355_init_asp1(ASP1_TX_EVT_EN | ASP1_RX_EVT_EN,
+				&dm355_evm_snd_data);
 }
 
 static __init void dm355_evm_irq_init(void)
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 30b2fd4..611583b 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -226,9 +226,7 @@  static struct platform_device ide_dev = {
 	},
 };
 
-static struct snd_platform_data dm644x_evm_snd_data = {
-	.clk_name	= "asp0",
-};
+static struct snd_platform_data dm644x_evm_snd_data;
 
 /*----------------------------------------------------------------------*/
 
@@ -671,7 +669,10 @@  static __init void davinci_evm_init(void)
 	davinci_setup_mmc(0, &dm6446evm_mmc_config);
 
 	davinci_serial_init(&uart_config);
-	dm644x_init_asp(&dm644x_evm_snd_data);
+
+	dm644x_evm_snd_data.clk = clk_get(NULL, "asp0");
+	if (!WARN_ON(!dm644x_evm_snd_data.clk))
+		dm644x_init_asp(&dm644x_evm_snd_data);
 
 	soc_info->emac_pdata->phy_mask = DM644X_EVM_PHY_MASK;
 	soc_info->emac_pdata->mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY;
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 575c6ca..b8fe6f4 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -33,6 +33,7 @@ 
 #include <linux/i2c/at24.h>
 #include <linux/i2c/pcf857x.h>
 #include <linux/etherdevice.h>
+#include <linux/clk.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -217,7 +218,6 @@  static u8 dm646x_dit_serializer_direction[] = {
 
 static struct snd_platform_data dm646x_evm_snd_data[] = {
 	{
-		.clk_name       = "mcasp0",
 		.tx_dma_offset  = 0x400,
 		.rx_dma_offset  = 0x400,
 		.op_mode        = DAVINCI_MCASP_IIS_MODE,
@@ -227,7 +227,6 @@  static struct snd_platform_data dm646x_evm_snd_data[] = {
 		.eventq_no      = EVENTQ_0,
 	},
 	{
-		.clk_name       = "mcasp1",
 		.tx_dma_offset  = 0x400,
 		.rx_dma_offset  = 0,
 		.op_mode        = DAVINCI_MCASP_DIT_MODE,
@@ -271,8 +270,13 @@  static __init void evm_init(void)
 
 	evm_init_i2c();
 	davinci_serial_init(&uart_config);
-	dm646x_init_mcasp0(&dm646x_evm_snd_data[0]);
-	dm646x_init_mcasp1(&dm646x_evm_snd_data[1]);
+
+	dm646x_evm_snd_data[0].clk = clk_get(NULL, "mcasp0");
+	if (!WARN_ON(!dm646x_evm_snd_data[0].clk))
+		dm646x_init_mcasp0(&dm646x_evm_snd_data[0]);
+	dm646x_evm_snd_data[1].clk = clk_get(NULL, "mcasp1");
+	if (!WARN_ON(!dm646x_evm_snd_data[1].clk))
+		dm646x_init_mcasp1(&dm646x_evm_snd_data[1]);
 
 	soc_info->emac_pdata->phy_mask = DM646X_EVM_PHY_MASK;
 	soc_info->emac_pdata->mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY;
diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/arch/arm/mach-davinci/include/mach/asp.h
index 038ecb7..2df4ecb 100644
--- a/arch/arm/mach-davinci/include/mach/asp.h
+++ b/arch/arm/mach-davinci/include/mach/asp.h
@@ -33,7 +33,7 @@ 
 #define DAVINCI_ASP1_TX_INT	IRQ_MBXINT
 
 struct snd_platform_data {
-	char *clk_name;
+	struct clk *clk;
 	u32 tx_dma_offset;
 	u32 rx_dma_offset;
 	enum dma_event_q eventq_no;	/* event queue number */
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index f7330e1..ddc047e 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -528,7 +528,7 @@  static int davinci_i2s_probe(struct platform_device *pdev)
 		goto err_release_region;
 	}
 
-	dev->clk = clk_get(&pdev->dev, pdata->clk_name);
+	dev->clk = pdata->clk;
 	if (IS_ERR(dev->clk)) {
 		ret = -ENODEV;
 		goto err_free_mem;
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index b27aab6..3b095f9 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -764,7 +764,7 @@  static int davinci_mcasp_probe(struct platform_device *pdev)
 	}
 
 	pdata = pdev->dev.platform_data;
-	dev->clk = clk_get(&pdev->dev, pdata->clk_name);
+	dev->clk = pdata->clk;
 	if (IS_ERR(dev->clk)) {
 		ret = -ENODEV;
 		goto err_release_region;