From: sugar zhang <sugar.zhang@rock-chips.com>
To: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>,
broonie@kernel.org, heiko@sntech.de,
linux-rockchip@lists.infradead.org
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
Xing Zheng <zhengxing@rock-chips.com>
Subject: Re: [PATCH 14/15] ASoC: rockchip: i2s: Add support for 'rockchip, clk-trcm' property
Date: Tue, 24 Aug 2021 09:41:21 +0800 [thread overview]
Message-ID: <a17f688f-3219-33e2-bf75-3c5d197ba274@rock-chips.com> (raw)
In-Reply-To: <5017702.Vq9jUBFu5T@archbook>
Hi Nicolas,
On 2021/8/23 19:47, Nicolas Frattaroli wrote:
> On Montag, 23. August 2021 12:54:35 CEST Sugar Zhang wrote:
>> From: Xing Zheng <zhengxing@rock-chips.com>
>>
>> If there is only one lrck (tx or rx) by hardware, we need to
>> use 'rockchip,clk-trcm' to specify which lrck can be used.
>>
>> Change-Id: I3bf8d87a6bc8c45e183040012d87d8be21a4c133
>> Signed-off-by: Xing Zheng <zhengxing@rock-chips.com>
>> Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
>> ---
>> sound/soc/rockchip/rockchip_i2s.c | 22 +++++++++++++---------
>> 1 file changed, 13 insertions(+), 9 deletions(-)
>>
>> diff --git a/sound/soc/rockchip/rockchip_i2s.c
>> b/sound/soc/rockchip/rockchip_i2s.c index 6ccb62e..b9d9c88 100644
>> --- a/sound/soc/rockchip/rockchip_i2s.c
>> +++ b/sound/soc/rockchip/rockchip_i2s.c
>> @@ -54,6 +54,7 @@ struct rk_i2s_dev {
>> bool is_master_mode;
>> const struct rk_i2s_pins *pins;
>> unsigned int bclk_ratio;
>> + unsigned int clk_trcm;
>> };
>>
>> /* tx/rx ctrl lock */
>> @@ -321,7 +322,6 @@ static int rockchip_i2s_hw_params(struct
>> snd_pcm_substream *substream, struct snd_soc_dai *dai)
>> {
>> struct rk_i2s_dev *i2s = to_info(dai);
>> - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
>> unsigned int val = 0;
>> unsigned int mclk_rate, bclk_rate, div_bclk, div_lrck;
>>
>> @@ -421,13 +421,6 @@ static int rockchip_i2s_hw_params(struct
>> snd_pcm_substream *substream, regmap_update_bits(i2s->regmap, I2S_DMACR,
>> I2S_DMACR_RDL_MASK,
>> I2S_DMACR_RDL(16));
>>
>> - val = I2S_CKR_TRCM_TXRX;
>> - if (dai->driver->symmetric_rate && rtd->dai_link->symmetric_rate)
>> - val = I2S_CKR_TRCM_TXONLY;
>> -
>> - regmap_update_bits(i2s->regmap, I2S_CKR,
>> - I2S_CKR_TRCM_MASK,
>> - val);
>> return 0;
>> }
>>
>> @@ -531,7 +524,6 @@ static struct snd_soc_dai_driver rockchip_i2s_dai = {
>> SNDRV_PCM_FMTBIT_S32_LE),
>> },
>> .ops = &rockchip_i2s_dai_ops,
>> - .symmetric_rate = 1,
>> };
>>
>> static const struct snd_soc_component_driver rockchip_i2s_component = {
>> @@ -750,6 +742,18 @@ static int rockchip_i2s_probe(struct platform_device
>> *pdev) else if (of_property_read_bool(node, "rockchip,capture-only"))
>> soc_dai->playback.channels_min = 0;
>>
>> + i2s->clk_trcm = I2S_CKR_TRCM_TXRX;
>> + if (!of_property_read_u32(node, "rockchip,clk-trcm", &val)) {
>> + if (val >= 0 && val <= 2) {
>> + i2s->clk_trcm = val << I2S_CKR_TRCM_SHIFT;
>> + if (i2s->clk_trcm)
>> + soc_dai->symmetric_rate = 1;
>> + }
>> + }
>> +
>> + regmap_update_bits(i2s->regmap, I2S_CKR,
>> + I2S_CKR_TRCM_MASK, i2s->clk_trcm);
>> +
>> ret = devm_snd_soc_register_component(&pdev->dev,
>> &rockchip_i2s_component,
>> soc_dai, 1);
> Hello,
>
> I recommend doing the same thing with clk-trcm that I'm going to do in v3 of
> my i2s-tdm driver, as per Robin Murphy's suggestion:
>
> Have tx-only and rx-only be two boolean properties. I named them
> rockchip,trcm-sync-tx-only and rockchip,trcm-sync-rx-only.
>
> I also recommend only shifting the value when writing it to registers, and
> storing it in its unshifted state for debug reasons.
okay, will do in v2.
> My probe function looks like this:
>
> i2s_tdm->clk_trcm = TRCM_TXRX;
> if (of_property_read_bool(node, "rockchip,trcm-sync-tx-only"))
> i2s_tdm->clk_trcm = TRCM_TX;
> if (of_property_read_bool(node, "rockchip,trcm-sync-rx-only")) {
> if (i2s_tdm->clk_trcm) {
> dev_err(i2s_tdm->dev, "invalid trcm-sync
> configuration\n");
> return -EINVAL;
> }
> i2s_tdm->clk_trcm = TRCM_RX;
> }
> if (i2s_tdm->clk_trcm != TRCM_TXRX)
> i2s_tdm_dai.symmetric_rate = 1;
>
> When writing clk_trcm to a register, I then just do:
>
> regmap_update_bits(i2s_tdm->regmap, I2S_CKR, I2S_CKR_TRCM_MASK,
> i2s_tdm->clk_trcm << I2S_CKR_TRCM_SHIFT);
>
> This way if I need to add an error message or debug print somewhere, then
> clk_trcm is still either 0, 1 or 2.
>
> In general, we should look into supporting both i2s and i2s-tdm controllers in
> the same driver if possible. This way we don't need to duplicate work like
> this. Do you think this is feasible to do? When I looked at the register maps
> I saw that the bits I2S/TDM uses were reserved in the I2S version of the
> controller, so I think it should work.
It's possible, but will make the driver much more complicate(a lot of
'if...else...').
Though the registers were compatible, but the design is totally
different, such as clks, reset signal, pins and core logic.
so, split into two drivers to support old controller and new one.
> Regards,
> Nicolas Frattaroli
>
>
>
>
>
--
Best Regards!
张学广/Sugar
瑞芯微电子股份有限公司
Rockchip Electronics Co., Ltd.
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2021-08-24 1:41 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 10:48 [PATCH v1 0/15] Patches to update for rockchip i2s Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 01/15] ASoC: rockchip: i2s: Add support for set bclk ratio Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 02/15] ASoC: rockchip: i2s: Fixup clk div error Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 03/15] ASoC: rockchip: i2s: Improve dma data transfer efficiency Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 04/15] ASoC: rockchip: i2s: Fix regmap_ops hang Sugar Zhang
2021-08-23 10:53 ` [PATCH 05/15] ASoC: rockchip: i2s: Fix concurrency between tx/rx Sugar Zhang
2021-08-23 10:53 ` [PATCH 06/15] ASoC: rockchip: i2s: Reset the controller if soft reset failed Sugar Zhang
2021-08-23 10:53 ` [PATCH 07/15] ASoC: dt-bindings: rockchip: Document reset property for i2s Sugar Zhang
2021-08-23 10:53 ` [PATCH 08/15] ASoC: rockchip: i2s: Fixup config for DAIFMT_DSP_A/B Sugar Zhang
2021-08-23 10:53 ` [PATCH 09/15] ASoC: rockchip: i2s: Add property to specify play/cap capability Sugar Zhang
2021-08-23 10:54 ` [PATCH 10/15] ASoC: dt-bindings: rockchip: i2s: Document property for playback/capture Sugar Zhang
2021-08-23 10:54 ` [PATCH 11/15] ASoC: rockchip: i2s: Add compatible for more SoCs Sugar Zhang
2021-08-23 10:54 ` [PATCH 12/15] ASoC: dt-bindings: rockchip: Add compatible strings " Sugar Zhang
2021-08-23 10:54 ` [PATCH 13/15] ASoC: rockchip: i2s: Add support for frame inversion Sugar Zhang
2021-08-23 10:54 ` [PATCH 14/15] ASoC: rockchip: i2s: Add support for 'rockchip, clk-trcm' property Sugar Zhang
2021-08-23 11:47 ` Nicolas Frattaroli
2021-08-24 1:41 ` sugar zhang [this message]
2021-08-23 10:55 ` [PATCH 15/15] ASoC: dt-bindings: rockchip: i2s: Document property 'clk-trcm' Sugar Zhang
2021-08-23 13:30 ` Rob Herring
2021-08-23 17:36 ` Rob Herring
2021-08-24 2:48 ` [PATCH 15/15] ASoC: dt-bindings: rockchip: i2s: Document property 'clk-trcm'【请注意,邮件由robherring2@gmail.com代发】 sugar zhang
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=a17f688f-3219-33e2-bf75-3c5d197ba274@rock-chips.com \
--to=sugar.zhang@rock-chips.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=frattaroli.nicolas@gmail.com \
--cc=heiko@sntech.de \
--cc=linux-rockchip@lists.infradead.org \
--cc=zhengxing@rock-chips.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