linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
To: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: "lars@metafoo.de" <lars@metafoo.de>,
	"laurent.pinchart+renesas@ideasonboard.com" 
	<laurent.pinchart+renesas@ideasonboard.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"pawel.moll@arm.com" <pawel.moll@arm.com>,
	"Carlos Palminha" <CARLOS.PALMINHA@synopsys.com>,
	"nariman@opensource.wolfsonmicro.com" 
	<nariman@opensource.wolfsonmicro.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"ville.syrjala@linux.intel.com" <ville.syrjala@linux.intel.com>,
	"alexander.deucher@amd.com" <alexander.deucher@amd.com>,
	"tixy@linaro.org" <tixy@linaro.org>,
	"yitian.bu@tangramtek.com" <yitian.bu@tangramtek.com>,
	"linux-snps-arc@lists.infradead.org" 
	<linux-snps-arc@lists.infradead.org>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"galak@codeaurora.org" <galak@codeaurora.org>,
	"ijc+devicetree@hellion.org.uk" <ijc+devicetree@hellion.org.uk>,
	"tiwai@suse.com" <tiwai@suse.com>,
	"buyitian@gmail.com" <buyitian@gmail.com>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	Vineet Gupta <Vineet.Gupta1@synopsys.com>,
	"wsa+renesas@sang-engineering.com"
	<wsa+renesas@sang-engineering.com>,
	"airlied@linux.ie" <airlied@linux.ie>,
	"Maruthi.Bayyavarapu@amd.com" <Maruthi.Bayyavarapu@amd.com>,
	"perex@perex.cz" <perex@perex.cz>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: Re: [PATCH 2/3 v2] ASoC: dwc: Add I2S HDMI audio support
Date: Mon, 28 Mar 2016 15:35:46 +0000	[thread overview]
Message-ID: <1459179345.4785.127.camel@synopsys.com> (raw)
In-Reply-To: <538be366488bf0d7633d702f2d0bab16707b7a47.1459174494.git.joabreu@synopsys.com>

Hi Jose,

On Mon, 2016-03-28 at 15:36 +0100, Jose Abreu wrote:
> HDMI audio support was added to the AXS board using an
> I2S cpu driver and a custom platform driver.
> 
> The platform driver supports two channels @ 16 bits with
> rates 32k, 44.1k and 48k. ALSA Simple audio card is used to
> glue the cpu, platform and codec driver (adv7511).
> 
> Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> ---
> 
> No changes v1 -> v2.
> 
>  sound/soc/dwc/Kconfig          |   1 +
>  sound/soc/dwc/designware_i2s.c | 385 +++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 373 insertions(+), 13 deletions(-)
> 
> diff --git a/sound/soc/dwc/Kconfig b/sound/soc/dwc/Kconfig
> index d50e085..bc3fae7 100644
> --- a/sound/soc/dwc/Kconfig
> +++ b/sound/soc/dwc/Kconfig
> @@ -2,6 +2,7 @@ config SND_DESIGNWARE_I2S
>  	tristate "Synopsys I2S Device Driver"
>  	depends on CLKDEV_LOOKUP
>  	select SND_SOC_GENERIC_DMAENGINE_PCM
> +	select SND_SIMPLE_CARD
>  	help
>  	 Say Y or M if you want to add support for I2S driver for
>  	 Synopsys desigwnware I2S device. The device supports upto
> diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
> index bff258d..0f2f588 100644
> --- a/sound/soc/dwc/designware_i2s.c
> +++ b/sound/soc/dwc/designware_i2s.c
> @@ -84,11 +84,37 @@
>  #define MAX_CHANNEL_NUM		8
>  #define MIN_CHANNEL_NUM		2
>  
> +/* FPGA Version Info */
> +#define FPGA_VER_INFO	0xE0011230
> +#define FPGA_VER_27M	0x000FBED9
> +
> +/* PLL registers addresses */
> +#define PLL_IDIV_ADDR	0xE00100A0
> +#define PLL_FBDIV_ADDR	0xE00100A4
> +#define PLL_ODIV0_ADDR	0xE00100A8
> +#define PLL_ODIV1_ADDR	0xE00100AC

Well I think all is not acceptable.
See all these FPGA_VER_xxx as well as PLL_xxx
are strictly ARC SDP specific things and have nothing to do with generic driver.

That's so pity we don't have a driver for all clocks/PLLs on ARC SDP yet.
So as of now I may only propose to use hard-coded fixed clocks as I did with
ARC PGU, see "pguclk" here:
http://lists.infradead.org/pipermail/linux-snps-arc/2016-March/000790.html

Again I'll try to implement missing clock driver sometime soon because
more and more stuff requires it but for now let's use a work-around.

> +struct dw_i2s_pll {
> +	unsigned int rate;
> +	unsigned int data_width;
> +	unsigned int idiv;
> +	unsigned int fbdiv;
> +	unsigned int odiv0;
> +	unsigned int odiv1;
> +};
> +
> +static const struct dw_i2s_pll dw_i2s_pll_cfg_27m[] = {
> +	/* 27Mhz */
> +	{ 32000, 16, 0x104, 0x451, 0x10E38, 0x2000 },
> +	{ 44100, 16, 0x104, 0x596, 0x10D35, 0x2000 },
> +	{ 48000, 16, 0x208, 0xA28, 0x10B2C, 0x2000 },
> +	{ 0, 0, 0, 0, 0, 0 },
>  };
>  
> +static const struct dw_i2s_pll dw_i2s_pll_cfg_28m[] = {
> +	/* 28.224Mhz */
> +	{ 32000, 16, 0x82, 0x105, 0x107DF, 0x2000 },
> +	{ 44100, 16, 0x28A, 0x1, 0x10001, 0x2000 },
> +	{ 48000, 16, 0xA28, 0x187, 0x10042, 0x2000 },
> +	{ 0, 0, 0, 0, 0, 0 },
> +};

These 2 hunks as well should go in ARC SDP clocks.

> +static int i2s_pll_cfg(struct i2s_clk_config_data *config)
> +{
> +	const struct dw_i2s_pll *pll_cfg;
> +	u32 rate = config->sample_rate;
> +	u32 data_width = config->data_width;
> +	int i;
> +
> +	if (readl((void *)FPGA_VER_INFO) <= FPGA_VER_27M)
> +		pll_cfg = dw_i2s_pll_cfg_27m;
> +	else
> +		pll_cfg = dw_i2s_pll_cfg_28m;
> +
> +	for (i = 0; pll_cfg[i].rate != 0; i++) {
> +		if ((pll_cfg[i].rate == rate) &&
> +				(pll_cfg[i].data_width == data_width)) {
> +			writel(pll_cfg[i].idiv, (void *)PLL_IDIV_ADDR);
> +			writel(pll_cfg[i].fbdiv, (void *)PLL_FBDIV_ADDR);
> +			writel(pll_cfg[i].odiv0, (void *)PLL_ODIV0_ADDR);
> +			writel(pll_cfg[i].odiv1, (void *)PLL_ODIV1_ADDR);
> +			return 0;
> +		}
> +	}
> +
> +	return -EINVAL;
> +}

Ditto.

-Alexey

  reply	other threads:[~2016-03-28 15:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-28 14:36 [PATCH 0/3 v2] Add I2S/ADV7511 audio support for ARC AXS10x boards Jose Abreu
2016-03-28 14:36 ` [PATCH 1/3 v2] drm/i2c/adv7511: Add audio support Jose Abreu
2016-03-29  8:05   ` Archit Taneja
2016-03-29 10:52     ` Jose Abreu
2016-03-29 17:03       ` Archit Taneja
2016-03-31 12:57         ` Jose Abreu
2016-03-30  9:58   ` Emil Velikov
2016-04-01 17:10   ` Laurent Pinchart
2016-04-04  9:05     ` Jose Abreu
2016-04-04 21:41       ` Laurent Pinchart
2016-04-05 11:00         ` Jose Abreu
2016-04-05 16:03           ` Laurent Pinchart
2016-04-03  5:05   ` kbuild test robot
2016-03-28 14:36 ` [PATCH 2/3 v2] ASoC: dwc: Add I2S HDMI " Jose Abreu
2016-03-28 15:35   ` Alexey Brodkin [this message]
2016-03-28 16:07     ` Jose Abreu
2016-03-29 17:31   ` Mark Brown
     [not found]     ` <56FAC355.1040705@synopsys.com>
2016-03-29 18:22       ` Mark Brown
2016-03-31  9:37         ` Jose Abreu
2016-03-31 16:56           ` Mark Brown
2016-03-28 14:36 ` [PATCH 3/3 v2] arc: axs10x: Add support for Designware I2S on DT Jose Abreu
2016-03-29 17:00 ` [PATCH 0/3 v2] Add I2S/ADV7511 audio support for ARC AXS10x boards Mark Brown

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=1459179345.4785.127.camel@synopsys.com \
    --to=alexey.brodkin@synopsys.com \
    --cc=CARLOS.PALMINHA@synopsys.com \
    --cc=Jose.Abreu@synopsys.com \
    --cc=Maruthi.Bayyavarapu@amd.com \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=buyitian@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=lars@metafoo.de \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=nariman@opensource.wolfsonmicro.com \
    --cc=pawel.moll@arm.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.com \
    --cc=tixy@linaro.org \
    --cc=ville.syrjala@linux.intel.com \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yitian.bu@tangramtek.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;
as well as URLs for NNTP newsgroup(s).