* [PATCH v4 0/3] ARM: mxs: add recording support for saif
@ 2011-11-10 6:42 Dong Aisheng
2011-11-10 6:42 ` [PATCH v4 1/3] ARM: mxs: add saif clkmux functions Dong Aisheng
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Dong Aisheng @ 2011-11-10 6:42 UTC (permalink / raw)
To: linux-arm-kernel
Changes since v3:
* remove unneeded locking according to Sascha.
The patches are based on imx-features branch since commit:
ca4e419c2.
Changes since v2:
* separate clkmux code into another patch according to Uwe
* add lock according to Wolfram
* Other minus fixes suggested by Uwe and Wolfram.
* remove Wolfram's fix saif clock setting patch which is in v2 series
since Wolfram will reform the clock code and send it out himself.
For test purpose, user still needs that patch. People can get it
from v2 series.
The patch is:
[PATCH v2 3/3] arm: mxs: disable clock-gates when setting saif-clocks
The patches are based on imx-features branch since commit:
f4f01e31835f.
Changes since v1:
The main changes are move mach-specific code(clkmux in DIGCTL) from
saif driver to mach-specific layer based on Wolfram's suggestion.
Note that the last patch is a RFC patch and sent out for testing
since without that patch the saif may not work.
Dong Aisheng (3):
ARM: mxs: add saif clkmux functions
ARM: mx28evk: add platform data for saif
ARM: mx28evk: set a initial clock rate for saif
arch/arm/mach-mxs/clock-mx28.c | 65 +++++++++++++++++++++++
arch/arm/mach-mxs/devices-mx28.h | 3 +-
arch/arm/mach-mxs/devices/platform-mxs-saif.c | 5 +-
arch/arm/mach-mxs/include/mach/common.h | 2 +
arch/arm/mach-mxs/include/mach/devices-common.h | 4 +-
arch/arm/mach-mxs/include/mach/digctl.h | 21 +++++++
arch/arm/mach-mxs/mach-mx28evk.c | 16 +++++-
7 files changed, 110 insertions(+), 6 deletions(-)
create mode 100644 arch/arm/mach-mxs/include/mach/digctl.h
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v4 1/3] ARM: mxs: add saif clkmux functions 2011-11-10 6:42 [PATCH v4 0/3] ARM: mxs: add recording support for saif Dong Aisheng @ 2011-11-10 6:42 ` Dong Aisheng 2011-11-11 7:14 ` Shawn Guo 2011-11-10 6:42 ` [PATCH v4 2/3] ARM: mx28evk: add platform data for saif Dong Aisheng ` (2 subsequent siblings) 3 siblings, 1 reply; 13+ messages in thread From: Dong Aisheng @ 2011-11-10 6:42 UTC (permalink / raw) To: linux-arm-kernel Signed-off-by: Dong Aisheng <b29396@freescale.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Wolfram Sang <w.sang@pengutronix.de> Cc: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Liam Girdwood <lrg@ti.com> --- changes since v3: * remove the unneeded locking according to Sascha changes since v2: * This patch is separated from the following patch based on suggestions from Uwe. [PATCH 2/3] ARM: mx28evk: add platform data for saif --- arch/arm/mach-mxs/clock-mx28.c | 56 +++++++++++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/digctl.h | 21 +++++++++++ 2 files changed, 77 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-mxs/clock-mx28.c b/arch/arm/mach-mxs/clock-mx28.c index 7954013..6522d5f 100644 --- a/arch/arm/mach-mxs/clock-mx28.c +++ b/arch/arm/mach-mxs/clock-mx28.c @@ -22,6 +22,7 @@ #include <linux/io.h> #include <linux/jiffies.h> #include <linux/clkdev.h> +#include <linux/spinlock.h> #include <asm/clkdev.h> #include <asm/div64.h> @@ -29,6 +30,7 @@ #include <mach/mx28.h> #include <mach/common.h> #include <mach/clock.h> +#include <mach/digctl.h> #include "regs-clkctrl-mx28.h" @@ -43,6 +45,60 @@ static struct clk emi_clk; static struct clk saif0_clk; static struct clk saif1_clk; static struct clk clk32k_clk; +static DEFINE_SPINLOCK(clkmux_lock); + +/* + * HW_SAIF_CLKMUX_SEL: + * DIRECT(0x0): SAIF0 clock pins selected for SAIF0 input clocks, and SAIF1 + * clock pins selected for SAIF1 input clocks. + * CROSSINPUT(0x1): SAIF1 clock inputs selected for SAIF0 input clocks, and + * SAIF0 clock inputs selected for SAIF1 input clocks. + * EXTMSTR0(0x2): SAIF0 clock pin selected for both SAIF0 and SAIF1 input + * clocks. + * EXTMSTR1(0x3): SAIF1 clock pin selected for both SAIF0 and SAIF1 input + * clocks. + */ +int mxs_saif_clkmux_select(unsigned int clkmux) +{ + if (clkmux > 0x3) + return -EINVAL; + + spin_lock(&clkmux_lock); + __raw_writel(BM_DIGCTL_CTRL_SAIF_CLKMUX, + DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_CLR_ADDR); + __raw_writel(clkmux << BP_DIGCTL_CTRL_SAIF_CLKMUX, + DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_SET_ADDR); + spin_unlock(&clkmux_lock); + + return 0; +} + +int mxs_get_saif_clk_master_id(unsigned int saif_id) +{ + unsigned int saif_clkmux; + unsigned int master_id; + + saif_clkmux = (__raw_readl(DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL) + && BM_DIGCTL_CTRL_SAIF_CLKMUX) >> BP_DIGCTL_CTRL_SAIF_CLKMUX; + switch (saif_clkmux) { + case MXS_DIGCTL_SAIF_CLKMUX_DIRECT: + master_id = saif_id; + break; + case MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT: + master_id = saif_id ? 0 : 1; + break; + case MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0: + master_id = 0; + break; + case MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1: + master_id = 1; + break; + default: + return -EINVAL; + } + + return master_id; +} static int _raw_clk_enable(struct clk *clk) { diff --git a/arch/arm/mach-mxs/include/mach/digctl.h b/arch/arm/mach-mxs/include/mach/digctl.h new file mode 100644 index 0000000..9bd0496 --- /dev/null +++ b/arch/arm/mach-mxs/include/mach/digctl.h @@ -0,0 +1,21 @@ +/* + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * + * 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. + */ + +#ifndef __MACH_DIGCTL_H__ +#define __MACH_DIGCTL_H__ + +/* MXS DIGCTL SAIF CLKMUX */ +#define MXS_DIGCTL_SAIF_CLKMUX_DIRECT 0x0 +#define MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT 0x1 +#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0 0x2 +#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1 0x3 + +#define HW_DIGCTL_CTRL 0x0 +#define BP_DIGCTL_CTRL_SAIF_CLKMUX (10) +#define BM_DIGCTL_CTRL_SAIF_CLKMUX (0x3 << 10) +#endif -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 1/3] ARM: mxs: add saif clkmux functions 2011-11-10 6:42 ` [PATCH v4 1/3] ARM: mxs: add saif clkmux functions Dong Aisheng @ 2011-11-11 7:14 ` Shawn Guo 2011-11-11 7:19 ` Dong Aisheng-B29396 0 siblings, 1 reply; 13+ messages in thread From: Shawn Guo @ 2011-11-11 7:14 UTC (permalink / raw) To: linux-arm-kernel On Thu, Nov 10, 2011 at 02:42:11PM +0800, Dong Aisheng wrote: > Signed-off-by: Dong Aisheng <b29396@freescale.com> > Cc: Sascha Hauer <s.hauer@pengutronix.de> > Cc: Wolfram Sang <w.sang@pengutronix.de> > Cc: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> > Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> > Cc: Liam Girdwood <lrg@ti.com> > > --- > changes since v3: > * remove the unneeded locking according to Sascha > changes since v2: > * This patch is separated from the following patch based on > suggestions from Uwe. > [PATCH 2/3] ARM: mx28evk: add platform data for saif > --- > arch/arm/mach-mxs/clock-mx28.c | 56 +++++++++++++++++++++++++++++++ > arch/arm/mach-mxs/include/mach/digctl.h | 21 +++++++++++ > 2 files changed, 77 insertions(+), 0 deletions(-) > > diff --git a/arch/arm/mach-mxs/clock-mx28.c b/arch/arm/mach-mxs/clock-mx28.c > index 7954013..6522d5f 100644 > --- a/arch/arm/mach-mxs/clock-mx28.c > +++ b/arch/arm/mach-mxs/clock-mx28.c > @@ -22,6 +22,7 @@ > #include <linux/io.h> > #include <linux/jiffies.h> > #include <linux/clkdev.h> > +#include <linux/spinlock.h> > > #include <asm/clkdev.h> > #include <asm/div64.h> > @@ -29,6 +30,7 @@ > #include <mach/mx28.h> > #include <mach/common.h> > #include <mach/clock.h> > +#include <mach/digctl.h> > > #include "regs-clkctrl-mx28.h" > > @@ -43,6 +45,60 @@ static struct clk emi_clk; > static struct clk saif0_clk; > static struct clk saif1_clk; > static struct clk clk32k_clk; > +static DEFINE_SPINLOCK(clkmux_lock); > + > +/* > + * HW_SAIF_CLKMUX_SEL: > + * DIRECT(0x0): SAIF0 clock pins selected for SAIF0 input clocks, and SAIF1 > + * clock pins selected for SAIF1 input clocks. > + * CROSSINPUT(0x1): SAIF1 clock inputs selected for SAIF0 input clocks, and > + * SAIF0 clock inputs selected for SAIF1 input clocks. > + * EXTMSTR0(0x2): SAIF0 clock pin selected for both SAIF0 and SAIF1 input > + * clocks. > + * EXTMSTR1(0x3): SAIF1 clock pin selected for both SAIF0 and SAIF1 input > + * clocks. > + */ > +int mxs_saif_clkmux_select(unsigned int clkmux) > +{ > + if (clkmux > 0x3) > + return -EINVAL; > + > + spin_lock(&clkmux_lock); > + __raw_writel(BM_DIGCTL_CTRL_SAIF_CLKMUX, > + DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_CLR_ADDR); > + __raw_writel(clkmux << BP_DIGCTL_CTRL_SAIF_CLKMUX, > + DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_SET_ADDR); > + spin_unlock(&clkmux_lock); > + > + return 0; > +} > + > +int mxs_get_saif_clk_master_id(unsigned int saif_id) > +{ > + unsigned int saif_clkmux; > + unsigned int master_id; > + > + saif_clkmux = (__raw_readl(DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL) > + && BM_DIGCTL_CTRL_SAIF_CLKMUX) >> BP_DIGCTL_CTRL_SAIF_CLKMUX; > + switch (saif_clkmux) { > + case MXS_DIGCTL_SAIF_CLKMUX_DIRECT: > + master_id = saif_id; > + break; > + case MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT: > + master_id = saif_id ? 0 : 1; > + break; > + case MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0: > + master_id = 0; > + break; > + case MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1: > + master_id = 1; > + break; > + default: > + return -EINVAL; > + } > + > + return master_id; > +} > I'm not completely comfortable to have these DIGCTL setup in clock code. What about creating a digctl.c for all DIGCTL stuff? > static int _raw_clk_enable(struct clk *clk) > { > diff --git a/arch/arm/mach-mxs/include/mach/digctl.h b/arch/arm/mach-mxs/include/mach/digctl.h > new file mode 100644 > index 0000000..9bd0496 > --- /dev/null > +++ b/arch/arm/mach-mxs/include/mach/digctl.h > @@ -0,0 +1,21 @@ > +/* > + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. > + * > + * 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. > + */ > + > +#ifndef __MACH_DIGCTL_H__ > +#define __MACH_DIGCTL_H__ > + > +/* MXS DIGCTL SAIF CLKMUX */ > +#define MXS_DIGCTL_SAIF_CLKMUX_DIRECT 0x0 > +#define MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT 0x1 > +#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0 0x2 > +#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1 0x3 > + > +#define HW_DIGCTL_CTRL 0x0 > +#define BP_DIGCTL_CTRL_SAIF_CLKMUX (10) > +#define BM_DIGCTL_CTRL_SAIF_CLKMUX (0x3 << 10) > +#endif > And if possible, we should try to make these definitions local to that digctl.c. -- Regards, Shawn ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v4 1/3] ARM: mxs: add saif clkmux functions 2011-11-11 7:14 ` Shawn Guo @ 2011-11-11 7:19 ` Dong Aisheng-B29396 2011-11-11 7:41 ` Shawn Guo 0 siblings, 1 reply; 13+ messages in thread From: Dong Aisheng-B29396 @ 2011-11-11 7:19 UTC (permalink / raw) To: linux-arm-kernel > -----Original Message----- > From: Guo Shawn-R65073 > Sent: Friday, November 11, 2011 3:14 PM > To: Dong Aisheng-B29396 > Cc: linux-arm-kernel at lists.infradead.org; alsa-devel at alsa-project.org; > broonie at opensource.wolfsonmicro.com; lrg at ti.com; s.hauer at pengutronix.de; > w.sang at pengutronix.de; u.kleine-koenig at pengutronix.de > Subject: Re: [PATCH v4 1/3] ARM: mxs: add saif clkmux functions > > On Thu, Nov 10, 2011 at 02:42:11PM +0800, Dong Aisheng wrote: > > Signed-off-by: Dong Aisheng <b29396@freescale.com> > > Cc: Sascha Hauer <s.hauer@pengutronix.de> > > Cc: Wolfram Sang <w.sang@pengutronix.de> > > Cc: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> > > Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> > > Cc: Liam Girdwood <lrg@ti.com> > > > > --- > > changes since v3: > > * remove the unneeded locking according to Sascha changes since v2: > > * This patch is separated from the following patch based on > > suggestions from Uwe. > > [PATCH 2/3] ARM: mx28evk: add platform data for saif > > --- > > arch/arm/mach-mxs/clock-mx28.c | 56 > +++++++++++++++++++++++++++++++ > > arch/arm/mach-mxs/include/mach/digctl.h | 21 +++++++++++ > > 2 files changed, 77 insertions(+), 0 deletions(-) > > > > diff --git a/arch/arm/mach-mxs/clock-mx28.c > > b/arch/arm/mach-mxs/clock-mx28.c index 7954013..6522d5f 100644 > > --- a/arch/arm/mach-mxs/clock-mx28.c > > +++ b/arch/arm/mach-mxs/clock-mx28.c > > @@ -22,6 +22,7 @@ > > #include <linux/io.h> > > #include <linux/jiffies.h> > > #include <linux/clkdev.h> > > +#include <linux/spinlock.h> > > > > #include <asm/clkdev.h> > > #include <asm/div64.h> > > @@ -29,6 +30,7 @@ > > #include <mach/mx28.h> > > #include <mach/common.h> > > #include <mach/clock.h> > > +#include <mach/digctl.h> > > > > #include "regs-clkctrl-mx28.h" > > > > @@ -43,6 +45,60 @@ static struct clk emi_clk; static struct clk > > saif0_clk; static struct clk saif1_clk; static struct clk > > clk32k_clk; > > +static DEFINE_SPINLOCK(clkmux_lock); > > + > > +/* > > + * HW_SAIF_CLKMUX_SEL: > > + * DIRECT(0x0): SAIF0 clock pins selected for SAIF0 input clocks, and > SAIF1 > > + * clock pins selected for SAIF1 input clocks. > > + * CROSSINPUT(0x1): SAIF1 clock inputs selected for SAIF0 input > clocks, and > > + * SAIF0 clock inputs selected for SAIF1 input clocks. > > + * EXTMSTR0(0x2): SAIF0 clock pin selected for both SAIF0 and SAIF1 > input > > + * clocks. > > + * EXTMSTR1(0x3): SAIF1 clock pin selected for both SAIF0 and SAIF1 > input > > + * clocks. > > + */ > > +int mxs_saif_clkmux_select(unsigned int clkmux) { > > + if (clkmux > 0x3) > > + return -EINVAL; > > + > > + spin_lock(&clkmux_lock); > > + __raw_writel(BM_DIGCTL_CTRL_SAIF_CLKMUX, > > + DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_CLR_ADDR); > > + __raw_writel(clkmux << BP_DIGCTL_CTRL_SAIF_CLKMUX, > > + DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_SET_ADDR); > > + spin_unlock(&clkmux_lock); > > + > > + return 0; > > +} > > + > > +int mxs_get_saif_clk_master_id(unsigned int saif_id) { > > + unsigned int saif_clkmux; > > + unsigned int master_id; > > + > > + saif_clkmux = (__raw_readl(DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL) > > + && BM_DIGCTL_CTRL_SAIF_CLKMUX) >> > BP_DIGCTL_CTRL_SAIF_CLKMUX; > > + switch (saif_clkmux) { > > + case MXS_DIGCTL_SAIF_CLKMUX_DIRECT: > > + master_id = saif_id; > > + break; > > + case MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT: > > + master_id = saif_id ? 0 : 1; > > + break; > > + case MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0: > > + master_id = 0; > > + break; > > + case MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1: > > + master_id = 1; > > + break; > > + default: > > + return -EINVAL; > > + } > > + > > + return master_id; > > +} > > > > I'm not completely comfortable to have these DIGCTL setup in clock code. > What about creating a digctl.c for all DIGCTL stuff? > Originally I did as you said. But as suggested by Wolfram a long time ago, the question is that there're already some DIGCTL reference codes in clock-mx28.c, so we thought it may be better to keep this stuff in one place. Also these code looks clock related. Do you think it's suitable? > > static int _raw_clk_enable(struct clk *clk) { diff --git > > a/arch/arm/mach-mxs/include/mach/digctl.h > > b/arch/arm/mach-mxs/include/mach/digctl.h > > new file mode 100644 > > index 0000000..9bd0496 > > --- /dev/null > > +++ b/arch/arm/mach-mxs/include/mach/digctl.h > > @@ -0,0 +1,21 @@ > > +/* > > + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. > > + * > > + * 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. > > + */ > > + > > +#ifndef __MACH_DIGCTL_H__ > > +#define __MACH_DIGCTL_H__ > > + > > +/* MXS DIGCTL SAIF CLKMUX */ > > +#define MXS_DIGCTL_SAIF_CLKMUX_DIRECT 0x0 > > +#define MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT 0x1 > > +#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0 0x2 > > +#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1 0x3 > > + > > +#define HW_DIGCTL_CTRL 0x0 > > +#define BP_DIGCTL_CTRL_SAIF_CLKMUX (10) > > +#define BM_DIGCTL_CTRL_SAIF_CLKMUX (0x3 << 10) > > +#endif > > > > And if possible, we should try to make these definitions local to that > digctl.c. > We can do that if nobody else needs it. Regards Dong Aisheng ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v4 1/3] ARM: mxs: add saif clkmux functions 2011-11-11 7:19 ` Dong Aisheng-B29396 @ 2011-11-11 7:41 ` Shawn Guo 0 siblings, 0 replies; 13+ messages in thread From: Shawn Guo @ 2011-11-11 7:41 UTC (permalink / raw) To: linux-arm-kernel On Fri, Nov 11, 2011 at 03:19:49PM +0800, Dong Aisheng-B29396 wrote: > > -----Original Message----- > > From: Guo Shawn-R65073 > > Sent: Friday, November 11, 2011 3:14 PM > > To: Dong Aisheng-B29396 > > Cc: linux-arm-kernel at lists.infradead.org; alsa-devel at alsa-project.org; > > broonie at opensource.wolfsonmicro.com; lrg at ti.com; s.hauer at pengutronix.de; > > w.sang at pengutronix.de; u.kleine-koenig at pengutronix.de > > Subject: Re: [PATCH v4 1/3] ARM: mxs: add saif clkmux functions > > > > On Thu, Nov 10, 2011 at 02:42:11PM +0800, Dong Aisheng wrote: > > > Signed-off-by: Dong Aisheng <b29396@freescale.com> > > > Cc: Sascha Hauer <s.hauer@pengutronix.de> > > > Cc: Wolfram Sang <w.sang@pengutronix.de> > > > Cc: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> > > > Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> > > > Cc: Liam Girdwood <lrg@ti.com> > > > > > > --- > > > changes since v3: > > > * remove the unneeded locking according to Sascha changes since v2: > > > * This patch is separated from the following patch based on > > > suggestions from Uwe. > > > [PATCH 2/3] ARM: mx28evk: add platform data for saif > > > --- > > > arch/arm/mach-mxs/clock-mx28.c | 56 > > +++++++++++++++++++++++++++++++ > > > arch/arm/mach-mxs/include/mach/digctl.h | 21 +++++++++++ > > > 2 files changed, 77 insertions(+), 0 deletions(-) > > > > > > diff --git a/arch/arm/mach-mxs/clock-mx28.c > > > b/arch/arm/mach-mxs/clock-mx28.c index 7954013..6522d5f 100644 > > > --- a/arch/arm/mach-mxs/clock-mx28.c > > > +++ b/arch/arm/mach-mxs/clock-mx28.c > > > @@ -22,6 +22,7 @@ > > > #include <linux/io.h> > > > #include <linux/jiffies.h> > > > #include <linux/clkdev.h> > > > +#include <linux/spinlock.h> > > > > > > #include <asm/clkdev.h> > > > #include <asm/div64.h> > > > @@ -29,6 +30,7 @@ > > > #include <mach/mx28.h> > > > #include <mach/common.h> > > > #include <mach/clock.h> > > > +#include <mach/digctl.h> > > > > > > #include "regs-clkctrl-mx28.h" > > > > > > @@ -43,6 +45,60 @@ static struct clk emi_clk; static struct clk > > > saif0_clk; static struct clk saif1_clk; static struct clk > > > clk32k_clk; > > > +static DEFINE_SPINLOCK(clkmux_lock); > > > + > > > +/* > > > + * HW_SAIF_CLKMUX_SEL: > > > + * DIRECT(0x0): SAIF0 clock pins selected for SAIF0 input clocks, and > > SAIF1 > > > + * clock pins selected for SAIF1 input clocks. > > > + * CROSSINPUT(0x1): SAIF1 clock inputs selected for SAIF0 input > > clocks, and > > > + * SAIF0 clock inputs selected for SAIF1 input clocks. > > > + * EXTMSTR0(0x2): SAIF0 clock pin selected for both SAIF0 and SAIF1 > > input > > > + * clocks. > > > + * EXTMSTR1(0x3): SAIF1 clock pin selected for both SAIF0 and SAIF1 > > input > > > + * clocks. > > > + */ > > > +int mxs_saif_clkmux_select(unsigned int clkmux) { > > > + if (clkmux > 0x3) > > > + return -EINVAL; > > > + > > > + spin_lock(&clkmux_lock); > > > + __raw_writel(BM_DIGCTL_CTRL_SAIF_CLKMUX, > > > + DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_CLR_ADDR); > > > + __raw_writel(clkmux << BP_DIGCTL_CTRL_SAIF_CLKMUX, > > > + DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_SET_ADDR); > > > + spin_unlock(&clkmux_lock); > > > + > > > + return 0; > > > +} > > > + > > > +int mxs_get_saif_clk_master_id(unsigned int saif_id) { > > > + unsigned int saif_clkmux; > > > + unsigned int master_id; > > > + > > > + saif_clkmux = (__raw_readl(DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL) > > > + && BM_DIGCTL_CTRL_SAIF_CLKMUX) >> > > BP_DIGCTL_CTRL_SAIF_CLKMUX; > > > + switch (saif_clkmux) { > > > + case MXS_DIGCTL_SAIF_CLKMUX_DIRECT: > > > + master_id = saif_id; > > > + break; > > > + case MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT: > > > + master_id = saif_id ? 0 : 1; > > > + break; > > > + case MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0: > > > + master_id = 0; > > > + break; > > > + case MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1: > > > + master_id = 1; > > > + break; > > > + default: > > > + return -EINVAL; > > > + } > > > + > > > + return master_id; > > > +} > > > > > > > I'm not completely comfortable to have these DIGCTL setup in clock code. > > What about creating a digctl.c for all DIGCTL stuff? > > > Originally I did as you said. > But as suggested by Wolfram a long time ago, the question is that there're > already some DIGCTL reference codes in clock-mx28.c, so we thought it may be > better to keep this stuff in one place. > Also these code looks clock related. > Do you think it's suitable? > Fair enough. I forgot that we already have usb_clk set up by DIGCTL in there. Regards, Shawn > > > static int _raw_clk_enable(struct clk *clk) { diff --git > > > a/arch/arm/mach-mxs/include/mach/digctl.h > > > b/arch/arm/mach-mxs/include/mach/digctl.h > > > new file mode 100644 > > > index 0000000..9bd0496 > > > --- /dev/null > > > +++ b/arch/arm/mach-mxs/include/mach/digctl.h > > > @@ -0,0 +1,21 @@ > > > +/* > > > + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. > > > + * > > > + * 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. > > > + */ > > > + > > > +#ifndef __MACH_DIGCTL_H__ > > > +#define __MACH_DIGCTL_H__ > > > + > > > +/* MXS DIGCTL SAIF CLKMUX */ > > > +#define MXS_DIGCTL_SAIF_CLKMUX_DIRECT 0x0 > > > +#define MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT 0x1 > > > +#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0 0x2 > > > +#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1 0x3 > > > + > > > +#define HW_DIGCTL_CTRL 0x0 > > > +#define BP_DIGCTL_CTRL_SAIF_CLKMUX (10) > > > +#define BM_DIGCTL_CTRL_SAIF_CLKMUX (0x3 << 10) > > > +#endif > > > > > > > And if possible, we should try to make these definitions local to that > > digctl.c. > > > We can do that if nobody else needs it. > > Regards > Dong Aisheng ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v4 2/3] ARM: mx28evk: add platform data for saif 2011-11-10 6:42 [PATCH v4 0/3] ARM: mxs: add recording support for saif Dong Aisheng 2011-11-10 6:42 ` [PATCH v4 1/3] ARM: mxs: add saif clkmux functions Dong Aisheng @ 2011-11-10 6:42 ` Dong Aisheng 2011-11-10 8:38 ` Sascha Hauer 2011-11-10 6:42 ` [PATCH v4 3/3] ARM: mx28evk: set a initial clock rate " Dong Aisheng 2011-11-10 6:46 ` [PATCH v4 0/3] ARM: mxs: add recording support " Dong Aisheng-B29396 3 siblings, 1 reply; 13+ messages in thread From: Dong Aisheng @ 2011-11-10 6:42 UTC (permalink / raw) To: linux-arm-kernel This is for supporting saif record function. Signed-off-by: Dong Aisheng <b29396@freescale.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Wolfram Sang <w.sang@pengutronix.de> Cc: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Liam Girdwood <lrg@ti.com> --- No changes since v3: Changes since v2: * separate clkmux code into another patch * A few minus fixes suggested by Uwe & Wolfram. Changes since v1: * move saif clkmux code into mach-specific part --- arch/arm/mach-mxs/devices-mx28.h | 3 ++- arch/arm/mach-mxs/devices/platform-mxs-saif.c | 5 +++-- arch/arm/mach-mxs/include/mach/common.h | 2 ++ arch/arm/mach-mxs/include/mach/devices-common.h | 4 +++- arch/arm/mach-mxs/mach-mx28evk.c | 16 ++++++++++++++-- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-mxs/devices-mx28.h b/arch/arm/mach-mxs/devices-mx28.h index c888710..4f50094 100644 --- a/arch/arm/mach-mxs/devices-mx28.h +++ b/arch/arm/mach-mxs/devices-mx28.h @@ -47,6 +47,7 @@ struct platform_device *__init mx28_add_mxsfb( const struct mxsfb_platform_data *pdata); extern const struct mxs_saif_data mx28_saif_data[] __initconst; -#define mx28_add_saif(id) mxs_add_saif(&mx28_saif_data[id]) +#define mx28_add_saif(id, pdata) \ + mxs_add_saif(&mx28_saif_data[id], pdata) struct platform_device *__init mx28_add_rtc_stmp3xxx(void); diff --git a/arch/arm/mach-mxs/devices/platform-mxs-saif.c b/arch/arm/mach-mxs/devices/platform-mxs-saif.c index 1ec965e..f6e3a60 100644 --- a/arch/arm/mach-mxs/devices/platform-mxs-saif.c +++ b/arch/arm/mach-mxs/devices/platform-mxs-saif.c @@ -32,7 +32,8 @@ const struct mxs_saif_data mx28_saif_data[] __initconst = { }; #endif -struct platform_device *__init mxs_add_saif(const struct mxs_saif_data *data) +struct platform_device *__init mxs_add_saif(const struct mxs_saif_data *data, + const struct mxs_saif_platform_data *pdata) { struct resource res[] = { { @@ -56,5 +57,5 @@ struct platform_device *__init mxs_add_saif(const struct mxs_saif_data *data) }; return mxs_add_platform_device("mxs-saif", data->id, res, - ARRAY_SIZE(res), NULL, 0); + ARRAY_SIZE(res), pdata, sizeof(*pdata)); } diff --git a/arch/arm/mach-mxs/include/mach/common.h b/arch/arm/mach-mxs/include/mach/common.h index 635bb5d..bf91a10 100644 --- a/arch/arm/mach-mxs/include/mach/common.h +++ b/arch/arm/mach-mxs/include/mach/common.h @@ -29,4 +29,6 @@ extern void mx28_init_irq(void); extern void icoll_init_irq(void); +extern int mxs_saif_clkmux_select(unsigned int clkmux); +extern int mxs_get_saif_clk_master_id(unsigned int saif_id); #endif /* __MACH_MXS_COMMON_H__ */ diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h index a8080f4..dc369c1 100644 --- a/arch/arm/mach-mxs/include/mach/devices-common.h +++ b/arch/arm/mach-mxs/include/mach/devices-common.h @@ -94,6 +94,7 @@ struct platform_device *__init mxs_add_mxs_pwm( resource_size_t iobase, int id); /* saif */ +#include <sound/saif.h> struct mxs_saif_data { int id; resource_size_t iobase; @@ -103,4 +104,5 @@ struct mxs_saif_data { }; struct platform_device *__init mxs_add_saif( - const struct mxs_saif_data *data); + const struct mxs_saif_data *data, + const struct mxs_saif_platform_data *pdata); diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c index 4a3cca3..5aab344 100644 --- a/arch/arm/mach-mxs/mach-mx28evk.c +++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -28,6 +28,7 @@ #include <mach/common.h> #include <mach/iomux-mx28.h> +#include <mach/digctl.h> #include "devices-mx28.h" @@ -417,6 +418,17 @@ static void __init mx28evk_add_regulators(void) static void __init mx28evk_add_regulators(void) {} #endif +static int mx28evk_mxs_saif_pinit(void) +{ + return mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); +} + +static const struct mxs_saif_platform_data + mx28evk_mxs_saif_pdata __initconst = { + .init = mx28evk_mxs_saif_pinit, + .get_master_id = mxs_get_saif_clk_master_id, +}; + static void __init mx28evk_init(void) { int ret; @@ -457,8 +469,8 @@ static void __init mx28evk_init(void) mx28_add_mxsfb(&mx28evk_mxsfb_pdata); - mx28_add_saif(0); - mx28_add_saif(1); + mx28_add_saif(0, &mx28evk_mxs_saif_pdata); + mx28_add_saif(1, &mx28evk_mxs_saif_pdata); mx28_add_mxs_i2c(0); i2c_register_board_info(0, mxs_i2c0_board_info, -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 2/3] ARM: mx28evk: add platform data for saif 2011-11-10 6:42 ` [PATCH v4 2/3] ARM: mx28evk: add platform data for saif Dong Aisheng @ 2011-11-10 8:38 ` Sascha Hauer 2011-11-10 9:23 ` Dong Aisheng-B29396 2011-11-11 6:06 ` Shawn Guo 0 siblings, 2 replies; 13+ messages in thread From: Sascha Hauer @ 2011-11-10 8:38 UTC (permalink / raw) To: linux-arm-kernel On Thu, Nov 10, 2011 at 02:42:12PM +0800, Dong Aisheng wrote: > This is for supporting saif record function. > > Signed-off-by: Dong Aisheng <b29396@freescale.com> > Cc: Sascha Hauer <s.hauer@pengutronix.de> > Cc: Wolfram Sang <w.sang@pengutronix.de> > Cc: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> > Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> > Cc: Liam Girdwood <lrg@ti.com> > > --- > No changes since v3: > Changes since v2: > * separate clkmux code into another patch > * A few minus fixes suggested by Uwe & Wolfram. > Changes since v1: > * move saif clkmux code into mach-specific part > --- > arch/arm/mach-mxs/devices-mx28.h | 3 ++- > arch/arm/mach-mxs/devices/platform-mxs-saif.c | 5 +++-- > arch/arm/mach-mxs/include/mach/common.h | 2 ++ > arch/arm/mach-mxs/include/mach/devices-common.h | 4 +++- > arch/arm/mach-mxs/mach-mx28evk.c | 16 ++++++++++++++-- > 5 files changed, 24 insertions(+), 6 deletions(-) > > diff --git a/arch/arm/mach-mxs/devices-mx28.h b/arch/arm/mach-mxs/devices-mx28.h > index c888710..4f50094 100644 > --- a/arch/arm/mach-mxs/devices-mx28.h > +++ b/arch/arm/mach-mxs/devices-mx28.h > @@ -47,6 +47,7 @@ struct platform_device *__init mx28_add_mxsfb( > const struct mxsfb_platform_data *pdata); > > extern const struct mxs_saif_data mx28_saif_data[] __initconst; > -#define mx28_add_saif(id) mxs_add_saif(&mx28_saif_data[id]) > +#define mx28_add_saif(id, pdata) \ > + mxs_add_saif(&mx28_saif_data[id], pdata) > > struct platform_device *__init mx28_add_rtc_stmp3xxx(void); > diff --git a/arch/arm/mach-mxs/devices/platform-mxs-saif.c b/arch/arm/mach-mxs/devices/platform-mxs-saif.c > index 1ec965e..f6e3a60 100644 > --- a/arch/arm/mach-mxs/devices/platform-mxs-saif.c > +++ b/arch/arm/mach-mxs/devices/platform-mxs-saif.c > @@ -32,7 +32,8 @@ const struct mxs_saif_data mx28_saif_data[] __initconst = { > }; > #endif > > -struct platform_device *__init mxs_add_saif(const struct mxs_saif_data *data) > +struct platform_device *__init mxs_add_saif(const struct mxs_saif_data *data, > + const struct mxs_saif_platform_data *pdata) > { > struct resource res[] = { > { > @@ -56,5 +57,5 @@ struct platform_device *__init mxs_add_saif(const struct mxs_saif_data *data) > }; > > return mxs_add_platform_device("mxs-saif", data->id, res, > - ARRAY_SIZE(res), NULL, 0); > + ARRAY_SIZE(res), pdata, sizeof(*pdata)); > } > diff --git a/arch/arm/mach-mxs/include/mach/common.h b/arch/arm/mach-mxs/include/mach/common.h > index 635bb5d..bf91a10 100644 > --- a/arch/arm/mach-mxs/include/mach/common.h > +++ b/arch/arm/mach-mxs/include/mach/common.h > @@ -29,4 +29,6 @@ extern void mx28_init_irq(void); > > extern void icoll_init_irq(void); > > +extern int mxs_saif_clkmux_select(unsigned int clkmux); > +extern int mxs_get_saif_clk_master_id(unsigned int saif_id); > #endif /* __MACH_MXS_COMMON_H__ */ > diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h > index a8080f4..dc369c1 100644 > --- a/arch/arm/mach-mxs/include/mach/devices-common.h > +++ b/arch/arm/mach-mxs/include/mach/devices-common.h > @@ -94,6 +94,7 @@ struct platform_device *__init mxs_add_mxs_pwm( > resource_size_t iobase, int id); > > /* saif */ > +#include <sound/saif.h> > struct mxs_saif_data { > int id; > resource_size_t iobase; > @@ -103,4 +104,5 @@ struct mxs_saif_data { > }; > > struct platform_device *__init mxs_add_saif( > - const struct mxs_saif_data *data); > + const struct mxs_saif_data *data, > + const struct mxs_saif_platform_data *pdata); > diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c > index 4a3cca3..5aab344 100644 > --- a/arch/arm/mach-mxs/mach-mx28evk.c > +++ b/arch/arm/mach-mxs/mach-mx28evk.c > @@ -28,6 +28,7 @@ > > #include <mach/common.h> > #include <mach/iomux-mx28.h> > +#include <mach/digctl.h> > > #include "devices-mx28.h" > > @@ -417,6 +418,17 @@ static void __init mx28evk_add_regulators(void) > static void __init mx28evk_add_regulators(void) {} > #endif > > +static int mx28evk_mxs_saif_pinit(void) > +{ > + return mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); > +} This is board specific and not saif specific and thus should be called directly in your board setup. > + > +static const struct mxs_saif_platform_data > + mx28evk_mxs_saif_pdata __initconst = { > + .init = mx28evk_mxs_saif_pinit, > + .get_master_id = mxs_get_saif_clk_master_id, This looks *very* suspicious. .init sets the mux register and .get_master_id reads the very same information back. Why not simply put a bool is_master into platform data? This function pointers are not devicetree friendly. I don't know whether i.MX28 will be ever converted to devicetree, but we should not unnecessary additional hurdles. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v4 2/3] ARM: mx28evk: add platform data for saif 2011-11-10 8:38 ` Sascha Hauer @ 2011-11-10 9:23 ` Dong Aisheng-B29396 2011-11-10 10:26 ` Sascha Hauer 2011-11-11 6:06 ` Shawn Guo 1 sibling, 1 reply; 13+ messages in thread From: Dong Aisheng-B29396 @ 2011-11-10 9:23 UTC (permalink / raw) To: linux-arm-kernel > -----Original Message----- > From: Sascha Hauer [mailto:s.hauer at pengutronix.de] > Sent: Thursday, November 10, 2011 4:39 PM > To: Dong Aisheng-B29396 > Cc: linux-arm-kernel at lists.infradead.org; alsa-devel at alsa-project.org; > broonie at opensource.wolfsonmicro.com; lrg at ti.com; w.sang at pengutronix.de; > u.kleine-koenig at pengutronix.de; Guo Shawn-R65073 > Subject: Re: [PATCH v4 2/3] ARM: mx28evk: add platform data for saif > > On Thu, Nov 10, 2011 at 02:42:12PM +0800, Dong Aisheng wrote: > > This is for supporting saif record function. > > > > Signed-off-by: Dong Aisheng <b29396@freescale.com> > > Cc: Sascha Hauer <s.hauer@pengutronix.de> > > Cc: Wolfram Sang <w.sang@pengutronix.de> > > Cc: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> > > Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> > > Cc: Liam Girdwood <lrg@ti.com> > > > > --- > > No changes since v3: > > Changes since v2: > > * separate clkmux code into another patch > > * A few minus fixes suggested by Uwe & Wolfram. > > Changes since v1: > > * move saif clkmux code into mach-specific part > > --- > > arch/arm/mach-mxs/devices-mx28.h | 3 ++- > > arch/arm/mach-mxs/devices/platform-mxs-saif.c | 5 +++-- > > arch/arm/mach-mxs/include/mach/common.h | 2 ++ > > arch/arm/mach-mxs/include/mach/devices-common.h | 4 +++- > > arch/arm/mach-mxs/mach-mx28evk.c | 16 ++++++++++++++- > - > > 5 files changed, 24 insertions(+), 6 deletions(-) > > > > diff --git a/arch/arm/mach-mxs/devices-mx28.h > > b/arch/arm/mach-mxs/devices-mx28.h > > index c888710..4f50094 100644 > > --- a/arch/arm/mach-mxs/devices-mx28.h > > +++ b/arch/arm/mach-mxs/devices-mx28.h > > @@ -47,6 +47,7 @@ struct platform_device *__init mx28_add_mxsfb( > > const struct mxsfb_platform_data *pdata); > > > > extern const struct mxs_saif_data mx28_saif_data[] __initconst; > > -#define mx28_add_saif(id) > mxs_add_saif(&mx28_saif_data[id]) > > +#define mx28_add_saif(id, pdata) \ > > + mxs_add_saif(&mx28_saif_data[id], pdata) > > > > struct platform_device *__init mx28_add_rtc_stmp3xxx(void); diff > > --git a/arch/arm/mach-mxs/devices/platform-mxs-saif.c > > b/arch/arm/mach-mxs/devices/platform-mxs-saif.c > > index 1ec965e..f6e3a60 100644 > > --- a/arch/arm/mach-mxs/devices/platform-mxs-saif.c > > +++ b/arch/arm/mach-mxs/devices/platform-mxs-saif.c > > @@ -32,7 +32,8 @@ const struct mxs_saif_data mx28_saif_data[] > > __initconst = { }; #endif > > > > -struct platform_device *__init mxs_add_saif(const struct > > mxs_saif_data *data) > > +struct platform_device *__init mxs_add_saif(const struct mxs_saif_data > *data, > > + const struct mxs_saif_platform_data *pdata) > > { > > struct resource res[] = { > > { > > @@ -56,5 +57,5 @@ struct platform_device *__init mxs_add_saif(const > struct mxs_saif_data *data) > > }; > > > > return mxs_add_platform_device("mxs-saif", data->id, res, > > - ARRAY_SIZE(res), NULL, 0); > > + ARRAY_SIZE(res), pdata, sizeof(*pdata)); > > } > > diff --git a/arch/arm/mach-mxs/include/mach/common.h > > b/arch/arm/mach-mxs/include/mach/common.h > > index 635bb5d..bf91a10 100644 > > --- a/arch/arm/mach-mxs/include/mach/common.h > > +++ b/arch/arm/mach-mxs/include/mach/common.h > > @@ -29,4 +29,6 @@ extern void mx28_init_irq(void); > > > > extern void icoll_init_irq(void); > > > > +extern int mxs_saif_clkmux_select(unsigned int clkmux); extern int > > +mxs_get_saif_clk_master_id(unsigned int saif_id); > > #endif /* __MACH_MXS_COMMON_H__ */ > > diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h > > b/arch/arm/mach-mxs/include/mach/devices-common.h > > index a8080f4..dc369c1 100644 > > --- a/arch/arm/mach-mxs/include/mach/devices-common.h > > +++ b/arch/arm/mach-mxs/include/mach/devices-common.h > > @@ -94,6 +94,7 @@ struct platform_device *__init mxs_add_mxs_pwm( > > resource_size_t iobase, int id); > > > > /* saif */ > > +#include <sound/saif.h> > > struct mxs_saif_data { > > int id; > > resource_size_t iobase; > > @@ -103,4 +104,5 @@ struct mxs_saif_data { }; > > > > struct platform_device *__init mxs_add_saif( > > - const struct mxs_saif_data *data); > > + const struct mxs_saif_data *data, > > + const struct mxs_saif_platform_data *pdata); > > diff --git a/arch/arm/mach-mxs/mach-mx28evk.c > > b/arch/arm/mach-mxs/mach-mx28evk.c > > index 4a3cca3..5aab344 100644 > > --- a/arch/arm/mach-mxs/mach-mx28evk.c > > +++ b/arch/arm/mach-mxs/mach-mx28evk.c > > @@ -28,6 +28,7 @@ > > > > #include <mach/common.h> > > #include <mach/iomux-mx28.h> > > +#include <mach/digctl.h> > > > > #include "devices-mx28.h" > > > > @@ -417,6 +418,17 @@ static void __init mx28evk_add_regulators(void) > > static void __init mx28evk_add_regulators(void) {} #endif > > > > +static int mx28evk_mxs_saif_pinit(void) { > > + return mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); > > +} > > This is board specific and not saif specific and thus should be called > directly in your board setup. > Yes, this can be done in board setup. > > + > > +static const struct mxs_saif_platform_data > > + mx28evk_mxs_saif_pdata __initconst = { > > + .init = mx28evk_mxs_saif_pinit, > > + .get_master_id = mxs_get_saif_clk_master_id, > > This looks *very* suspicious. .init sets the mux register > and .get_master_id reads the very same information back. Why not simply > put a bool is_master into platform data? Originally it's used to avoid introduce a global variable to save clkmux Since we can directly read it from register. If put a bool is_master into pdata, we are assuming there are only two saif Instances. As I was suggested by Wolfram before that how about if there are more than two saifs in the future SoCs? So the original saif driver design is following this rule that it only needs to know its master id. If we decide to change here, I may also have a lot to change in saif driver. > This function pointers are not devicetree friendly. I don't know whether > i.MX28 will be ever converted to devicetree, but we should not > unnecessary additional hurdles. > I agree with you that it's a little unfriendly with device tree. I'm willing to find a better way if we can. Please let me know your suggestions! Regards Dong Aisheng ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v4 2/3] ARM: mx28evk: add platform data for saif 2011-11-10 9:23 ` Dong Aisheng-B29396 @ 2011-11-10 10:26 ` Sascha Hauer 2011-11-10 11:05 ` [alsa-devel] " Dong Aisheng-B29396 0 siblings, 1 reply; 13+ messages in thread From: Sascha Hauer @ 2011-11-10 10:26 UTC (permalink / raw) To: linux-arm-kernel On Thu, Nov 10, 2011 at 09:23:18AM +0000, Dong Aisheng-B29396 wrote: > > > + > > > +static const struct mxs_saif_platform_data > > > + mx28evk_mxs_saif_pdata __initconst = { > > > + .init = mx28evk_mxs_saif_pinit, > > > + .get_master_id = mxs_get_saif_clk_master_id, > > > > This looks *very* suspicious. .init sets the mux register > > and .get_master_id reads the very same information back. Why not simply > > put a bool is_master into platform data? > > Originally it's used to avoid introduce a global variable to save clkmux > Since we can directly read it from register. > > If put a bool is_master into pdata, we are assuming there are only two saif > Instances. As I was suggested by Wolfram before that how about if there are > more than two saifs in the future SoCs? I don't understand. A is_master variable in platform_data does not make any assumption about the number of interfaces in the system. > So the original saif driver design is following this rule that it only needs > to know its master id. If that's the design then put the master id into platform_data. This information is purely static and the board knows it. No need to put a function in platform_data. Something like this: struct saif_pdata { bool master_mode; /* if true use master mode */ int master_id; /* id of the master if in slave mode */ }; > If we decide to change here, I may also have a lot to change in saif driver. Some lines in the probe code, not more. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 13+ messages in thread
* [alsa-devel] [PATCH v4 2/3] ARM: mx28evk: add platform data for saif 2011-11-10 10:26 ` Sascha Hauer @ 2011-11-10 11:05 ` Dong Aisheng-B29396 0 siblings, 0 replies; 13+ messages in thread From: Dong Aisheng-B29396 @ 2011-11-10 11:05 UTC (permalink / raw) To: linux-arm-kernel > -----Original Message----- > From: alsa-devel-bounces at alsa-project.org [mailto:alsa-devel- > bounces at alsa-project.org] On Behalf Of Sascha Hauer > Sent: Thursday, November 10, 2011 6:26 PM > To: Dong Aisheng-B29396 > Cc: alsa-devel at alsa-project.org; broonie at opensource.wolfsonmicro.com; > w.sang at pengutronix.de; Guo Shawn-R65073; u.kleine-koenig at pengutronix.de; > lrg at ti.com; linux-arm-kernel at lists.infradead.org > Subject: Re: [alsa-devel] [PATCH v4 2/3] ARM: mx28evk: add platform data > for saif > > On Thu, Nov 10, 2011 at 09:23:18AM +0000, Dong Aisheng-B29396 wrote: > > > > + > > > > +static const struct mxs_saif_platform_data > > > > + mx28evk_mxs_saif_pdata __initconst = { > > > > + .init = mx28evk_mxs_saif_pinit, > > > > + .get_master_id = mxs_get_saif_clk_master_id, > > > > > > This looks *very* suspicious. .init sets the mux register and > > > .get_master_id reads the very same information back. Why not simply > > > put a bool is_master into platform data? > > > > Originally it's used to avoid introduce a global variable to save > > clkmux Since we can directly read it from register. > > > > If put a bool is_master into pdata, we are assuming there are only two > > saif Instances. As I was suggested by Wolfram before that how about if > > there are more than two saifs in the future SoCs? > > I don't understand. A is_master variable in platform_data does not make > any assumption about the number of interfaces in the system. > I was thinking that you may mean we can assume saif1 is master if saif0_pdate.is_master is false. So here we assume there two interfaces and the other is master. Sorry if I mislead your meaning. > > So the original saif driver design is following this rule that it only > > needs to know its master id. > > If that's the design then put the master id into platform_data. This > information is purely static and the board knows it. No need to put a > function in platform_data. Something like this: > struct saif_pdata { > bool master_mode; /* if true use master mode */ > int master_id; /* id of the master if in slave mode */ > }; > Yes, you're right. I will try that. Thanks for the suggestion. > > If we decide to change here, I may also have a lot to change in saif > driver. > > Some lines in the probe code, not more. > > Sascha > > -- > Pengutronix e.K. | > | > Industrial Linux Solutions | http://www.pengutronix.de/ > | > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 > | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 > | > _______________________________________________ > Alsa-devel mailing list > Alsa-devel at alsa-project.org > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel Regards Dong Aisheng ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v4 2/3] ARM: mx28evk: add platform data for saif 2011-11-10 8:38 ` Sascha Hauer 2011-11-10 9:23 ` Dong Aisheng-B29396 @ 2011-11-11 6:06 ` Shawn Guo 1 sibling, 0 replies; 13+ messages in thread From: Shawn Guo @ 2011-11-11 6:06 UTC (permalink / raw) To: linux-arm-kernel On Thu, Nov 10, 2011 at 09:38:52AM +0100, Sascha Hauer wrote: [...] > This function pointers are not devicetree friendly. I don't know whether > i.MX28 will be ever converted to devicetree, It will. This is something on my TODO list. Regards, Shawn > but we should not > unnecessary additional hurdles. > ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v4 3/3] ARM: mx28evk: set a initial clock rate for saif 2011-11-10 6:42 [PATCH v4 0/3] ARM: mxs: add recording support for saif Dong Aisheng 2011-11-10 6:42 ` [PATCH v4 1/3] ARM: mxs: add saif clkmux functions Dong Aisheng 2011-11-10 6:42 ` [PATCH v4 2/3] ARM: mx28evk: add platform data for saif Dong Aisheng @ 2011-11-10 6:42 ` Dong Aisheng 2011-11-10 6:46 ` [PATCH v4 0/3] ARM: mxs: add recording support " Dong Aisheng-B29396 3 siblings, 0 replies; 13+ messages in thread From: Dong Aisheng @ 2011-11-10 6:42 UTC (permalink / raw) To: linux-arm-kernel Signed-off-by: Dong Aisheng <b29396@freescale.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Wolfram Sang <w.sang@pengutronix.de> Cc: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Liam Girdwood <lrg@ti.com> --- No changes since v1. --- arch/arm/mach-mxs/clock-mx28.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-mxs/clock-mx28.c b/arch/arm/mach-mxs/clock-mx28.c index 6522d5f..91bb31a 100644 --- a/arch/arm/mach-mxs/clock-mx28.c +++ b/arch/arm/mach-mxs/clock-mx28.c @@ -835,6 +835,15 @@ int __init mx28_clocks_init(void) clk_set_parent(&saif0_clk, &pll0_clk); clk_set_parent(&saif1_clk, &pll0_clk); + /* + * Set an initial clk rate for saif's internal logic to work properly, + * this is especially for the saif working on EXTMASTER mode that who + * uses other saif's BITCLK&LRCLK but it still needs a basic clk which + * should be bigger enough for its internal logic. + */ + clk_set_rate(&saif0_clk, 24000000); + clk_set_rate(&saif1_clk, 24000000); + clkdev_add_table(lookups, ARRAY_SIZE(lookups)); mxs_timer_init(&clk32k_clk, MX28_INT_TIMER0); -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 0/3] ARM: mxs: add recording support for saif 2011-11-10 6:42 [PATCH v4 0/3] ARM: mxs: add recording support for saif Dong Aisheng ` (2 preceding siblings ...) 2011-11-10 6:42 ` [PATCH v4 3/3] ARM: mx28evk: set a initial clock rate " Dong Aisheng @ 2011-11-10 6:46 ` Dong Aisheng-B29396 3 siblings, 0 replies; 13+ messages in thread From: Dong Aisheng-B29396 @ 2011-11-10 6:46 UTC (permalink / raw) To: linux-arm-kernel Hi Sascha, > -----Original Message----- > From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux-arm- > kernel-bounces at lists.infradead.org] On Behalf Of Dong Aisheng > Sent: Thursday, November 10, 2011 2:42 PM > To: linux-arm-kernel at lists.infradead.org > Cc: alsa-devel at alsa-project.org; s.hauer at pengutronix.de; > broonie at opensource.wolfsonmicro.com; w.sang at pengutronix.de; u.kleine- > koenig at pengutronix.de; lrg at ti.com; Guo Shawn-R65073 > Subject: [PATCH v4 0/3] ARM: mxs: add recording support for saif > > Changes since v3: > * remove unneeded locking according to Sascha. I did not see your objections on my comments about difference between Clkmux and clk api. So I kept it in this new patch series and only removed the unneeded lock as you suggested. If any issue, please let me know. > The patches are based on imx-features branch since commit: > ca4e419c2. > > Changes since v2: > * separate clkmux code into another patch according to Uwe > * add lock according to Wolfram > * Other minus fixes suggested by Uwe and Wolfram. > * remove Wolfram's fix saif clock setting patch which is in v2 series > since Wolfram will reform the clock code and send it out himself. > For test purpose, user still needs that patch. People can get it > from v2 series. > The patch is: > [PATCH v2 3/3] arm: mxs: disable clock-gates when setting saif-clocks > > The patches are based on imx-features branch since commit: > f4f01e31835f. > > Changes since v1: > The main changes are move mach-specific code(clkmux in DIGCTL) from saif > driver to mach-specific layer based on Wolfram's suggestion. > > Note that the last patch is a RFC patch and sent out for testing since > without that patch the saif may not work. > > Dong Aisheng (3): > ARM: mxs: add saif clkmux functions > ARM: mx28evk: add platform data for saif > ARM: mx28evk: set a initial clock rate for saif > > arch/arm/mach-mxs/clock-mx28.c | 65 > +++++++++++++++++++++++ > arch/arm/mach-mxs/devices-mx28.h | 3 +- > arch/arm/mach-mxs/devices/platform-mxs-saif.c | 5 +- > arch/arm/mach-mxs/include/mach/common.h | 2 + > arch/arm/mach-mxs/include/mach/devices-common.h | 4 +- > arch/arm/mach-mxs/include/mach/digctl.h | 21 +++++++ > arch/arm/mach-mxs/mach-mx28evk.c | 16 +++++- > 7 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 > arch/arm/mach-mxs/include/mach/digctl.h > > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel at lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel Regards Dong Aisheng ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-11-11 7:41 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-11-10 6:42 [PATCH v4 0/3] ARM: mxs: add recording support for saif Dong Aisheng 2011-11-10 6:42 ` [PATCH v4 1/3] ARM: mxs: add saif clkmux functions Dong Aisheng 2011-11-11 7:14 ` Shawn Guo 2011-11-11 7:19 ` Dong Aisheng-B29396 2011-11-11 7:41 ` Shawn Guo 2011-11-10 6:42 ` [PATCH v4 2/3] ARM: mx28evk: add platform data for saif Dong Aisheng 2011-11-10 8:38 ` Sascha Hauer 2011-11-10 9:23 ` Dong Aisheng-B29396 2011-11-10 10:26 ` Sascha Hauer 2011-11-10 11:05 ` [alsa-devel] " Dong Aisheng-B29396 2011-11-11 6:06 ` Shawn Guo 2011-11-10 6:42 ` [PATCH v4 3/3] ARM: mx28evk: set a initial clock rate " Dong Aisheng 2011-11-10 6:46 ` [PATCH v4 0/3] ARM: mxs: add recording support " Dong Aisheng-B29396
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).