public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Nikula <jhnikula@gmail.com>
To: Tony Lindgren <tony@atomide.com>
Cc: Hugo Vincent <hugo.vincent@gmail.com>, linux-omap@vger.kernel.org
Subject: Re: [PATCH] OMAP3 Overo: add EXPORT_SYMBOLs for Overo ASoC audio to be built as a module.
Date: Wed, 3 Jun 2009 16:20:12 +0300	[thread overview]
Message-ID: <20090603162012.877be077.jhnikula@gmail.com> (raw)
In-Reply-To: <20090602173543.GE27332@atomide.com>

On Tue, 2 Jun 2009 10:35:43 -0700
Tony Lindgren <tony@atomide.com> wrote:

> * Hugo Vincent <hugo.vincent@gmail.com> [090601 18:03]:
> > I'm pretty new to kernel development, so I don't know any potential
> > problems with doing this, but without this, audio/ASoC support must be
> > built into the kernel (modpost fails when trying to build as modules),
> > whereas with this patch, it can be built and used as a module.
> > 
> > Comments?
> 
> To me it looks like we should rather fix sound/soc/omap/omap-mcbsp.c
> to use the clock framework rather than access omap_ctrl_read/write
> directly.
> 
Yeah, I have something like below in my mind.

I don't know is this idea working but at least I know there is need to define
McBSP FCLK parent clocks for 24xx similar way as they are defined for
34xx and to figure out something for the FIXMEs. McBSP module is
enabling the clocks at request time but fclk must be off in order to change
its parent.

-- 
Jarkko

diff --git a/arch/arm/plat-omap/include/mach/mcbsp.h b/arch/arm/plat-omap/include/mach/mcbsp.h
index bb154ea..3ebbe3f 100644
--- a/arch/arm/plat-omap/include/mach/mcbsp.h
+++ b/arch/arm/plat-omap/include/mach/mcbsp.h
@@ -389,6 +389,7 @@ int omap_mcbsp_request(unsigned int id);
 void omap_mcbsp_free(unsigned int id);
 void omap_mcbsp_start(unsigned int id);
 void omap_mcbsp_stop(unsigned int id);
+int omap_mcbsp_set_fclk_src(unsigned int id, const char *clk_name);
 void omap_mcbsp_xmit_word(unsigned int id, u32 word);
 u32 omap_mcbsp_recv_word(unsigned int id);
 
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index efa0e01..f36c6a6 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -398,6 +398,30 @@ void omap_mcbsp_stop(unsigned int id)
 }
 EXPORT_SYMBOL(omap_mcbsp_stop);
 
+int omap_mcbsp_set_fclk_src(unsigned int id, const char *clk_name)
+{
+	struct omap_mcbsp *mcbsp;
+	struct clk *fclk_src;
+	int err;
+
+	if (!omap_mcbsp_check_valid_id(id)) {
+		printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
+		return -ENODEV;
+	}
+
+	mcbsp = id_to_mcbsp_ptr(id);
+	fclk_src = clk_get(mcbsp->dev, clk_name);
+	if (IS_ERR(fclk_src))
+		return PTR_ERR(fclk_src);
+	clk_disable(mcbsp->fclk); /* FIXME, Hack! */
+	err = clk_set_parent(mcbsp->fclk, fclk_src);
+	clk_enable(mcbsp->fclk); /* FIXME, Hack! */
+	clk_put(fclk_src);
+
+	return err;
+}
+EXPORT_SYMBOL(omap_mcbsp_set_fclk_src);
+
 /* polled mcbsp i/o operations */
 int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
 {
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 9126142..d03a3c0 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -397,8 +397,7 @@ static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai,
 static int omap_mcbsp_dai_set_clks_src(struct omap_mcbsp_data *mcbsp_data,
 				       int clk_id)
 {
-	int sel_bit;
-	u16 reg, reg_devconf1 = OMAP243X_CONTROL_DEVCONF1;
+	const char *clks_src;
 
 	if (cpu_class_is_omap1()) {
 		/* OMAP1's can use only external source clock */
@@ -408,43 +407,16 @@ static int omap_mcbsp_dai_set_clks_src(struct omap_mcbsp_data *mcbsp_data,
 			return 0;
 	}
 
-	if (cpu_is_omap2420() && mcbsp_data->bus_id > 1)
-		return -EINVAL;
-
-	if (cpu_is_omap343x())
-		reg_devconf1 = OMAP343X_CONTROL_DEVCONF1;
-
-	switch (mcbsp_data->bus_id) {
-	case 0:
-		reg = OMAP2_CONTROL_DEVCONF0;
-		sel_bit = 2;
-		break;
-	case 1:
-		reg = OMAP2_CONTROL_DEVCONF0;
-		sel_bit = 6;
-		break;
-	case 2:
-		reg = reg_devconf1;
-		sel_bit = 0;
-		break;
-	case 3:
-		reg = reg_devconf1;
-		sel_bit = 2;
-		break;
-	case 4:
-		reg = reg_devconf1;
-		sel_bit = 4;
-		break;
-	default:
-		return -EINVAL;
+	if (clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK) {
+		if (cpu_is_omap24xx())
+			clks_src = "func_96m_ck";
+		if (cpu_is_omap343x())
+			clks_src = "core_96m_fck";
+	} else {
+		clks_src = "mcbsp_clks";
 	}
 
-	if (clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK)
-		omap_ctrl_writel(omap_ctrl_readl(reg) & ~(1 << sel_bit), reg);
-	else
-		omap_ctrl_writel(omap_ctrl_readl(reg) | (1 << sel_bit), reg);
-
-	return 0;
+	return omap_mcbsp_set_fclk_src(mcbsp_data->bus_id, clks_src);
 }
 
 static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,

  reply	other threads:[~2009-06-03 13:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-02  1:02 [PATCH] OMAP3 Overo: add EXPORT_SYMBOLs for Overo ASoC audio to be built as a module Hugo Vincent
2009-06-02 17:35 ` Tony Lindgren
2009-06-03 13:20   ` Jarkko Nikula [this message]
2009-06-03 16:31     ` Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090603162012.877be077.jhnikula@gmail.com \
    --to=jhnikula@gmail.com \
    --cc=hugo.vincent@gmail.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox