mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Maso Huang (黃加竹)" <Maso.Huang@mediatek.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Trevor Wu (吳文良)" <Trevor.Wu@mediatek.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"Allen-KH Cheng (程冠勳)" <Allen-KH.Cheng@mediatek.com>,
	"renzhijie2@huawei.com" <renzhijie2@huawei.com>,
	"tiwai@suse.com" <tiwai@suse.com>,
	"Claudiu.Beznea@microchip.com" <Claudiu.Beznea@microchip.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"perex@perex.cz" <perex@perex.cz>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"Jiaxin Yu (俞家鑫)" <Jiaxin.Yu@mediatek.com>
Subject: Re: [PATCH 2/7] ASoC: mediatek: mt79xx: support audio clock control
Date: Wed, 14 Jun 2023 07:44:01 +0000	[thread overview]
Message-ID: <4583d8df9711fad708da3437284734364610d268.camel@mediatek.com> (raw)
In-Reply-To: <6fde0597-a4f4-8f22-fc31-bc8bef3296d8@microchip.com>

On Tue, 2023-06-13 at 07:27 +0000, Claudiu.Beznea@microchip.com wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  On 12.06.2023 13:52, Maso Hunag wrote:
> > [You don't often get email from maso.huang@mediatek.com. Learn why
> this is important at https://aka.ms/LearnAboutSenderIdentification ]
> > 
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> > 
> > From: Maso Huang <maso.huang@mediatek.com>
> > 
> > Add audio clock wrapper and audio tuner control.
> > 
> > Signed-off-by: Maso Huang <maso.huang@mediatek.com>
> > ---
> >  sound/soc/mediatek/mt79xx/mt79xx-afe-clk.c | 123
> +++++++++++++++++++++
> >  sound/soc/mediatek/mt79xx/mt79xx-afe-clk.h |  18 +++
> >  2 files changed, 141 insertions(+)
> >  create mode 100644 sound/soc/mediatek/mt79xx/mt79xx-afe-clk.c
> >  create mode 100644 sound/soc/mediatek/mt79xx/mt79xx-afe-clk.h
> > 
> > diff --git a/sound/soc/mediatek/mt79xx/mt79xx-afe-clk.c
> b/sound/soc/mediatek/mt79xx/mt79xx-afe-clk.c
> > new file mode 100644
> > index 000000000000..f00f0d7de861
> > --- /dev/null
> > +++ b/sound/soc/mediatek/mt79xx/mt79xx-afe-clk.c
> > @@ -0,0 +1,123 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * mt79xx-afe-clk.c  --  MediaTek 79xx afe clock ctrl
> > + *
> > + * Copyright (c) 2021 MediaTek Inc.
> > + * Author: Vic Wu <vic.wu@mediatek.com>
> > + *         Maso Huang <maso.huang@mediatek.com>
> > + */
> > +
> > +#include <linux/clk.h>
> > +
> > +#include "mt79xx-afe-common.h"
> > +#include "mt79xx-afe-clk.h"
> > +#include "mt79xx-reg.h"
> > +
> > +enum {
> > +       CK_INFRA_AUD_BUS_CK = 0,
> > +       CK_INFRA_AUD_26M_CK,
> > +       CK_INFRA_AUD_L_CK,
> > +       CK_INFRA_AUD_AUD_CK,
> > +       CK_INFRA_AUD_EG2_CK,
> > +       CLK_NUM
> > +};
> > +
> > +static const char *aud_clks[CLK_NUM] = {
> > +       [CK_INFRA_AUD_BUS_CK] = "aud_bus_ck",
> > +       [CK_INFRA_AUD_26M_CK] = "aud_26m_ck",
> > +       [CK_INFRA_AUD_L_CK] = "aud_l_ck",
> > +       [CK_INFRA_AUD_AUD_CK] = "aud_aud_ck",
> > +       [CK_INFRA_AUD_EG2_CK] = "aud_eg2_ck",
> > +};
> > +
> > +int mt79xx_init_clock(struct mtk_base_afe *afe)
> > +{
> > +       struct mt79xx_afe_private *afe_priv = afe->platform_priv;
> > +       int i;
> > +
> > +       afe_priv->clk = devm_kcalloc(afe->dev, CLK_NUM,
> sizeof(*afe_priv->clk),
> > +                                    GFP_KERNEL);
> > +       if (!afe_priv->clk)
> > +               return -ENOMEM;
> > +
> > +       for (i = 0; i < CLK_NUM; i++) {
> > +               afe_priv->clk[i] = devm_clk_get(afe->dev,
> aud_clks[i]);
> > +               if (IS_ERR(afe_priv->clk[i])) {
> > +                       dev_err(afe->dev, "%s(), devm_clk_get %s
> fail,
> > +                               ret %ld\n", __func__, aud_clks[i],
> > +                               PTR_ERR(afe_priv->clk[i]));
> > +                       return PTR_ERR(afe_priv->clk[i]);
> > +               }
> > +       }
> 
> You can use devm_clk_bulk_get()
> 

Hi Claudiu,
Thanks for your review.
I'll use this api in v2 patch.

> > +
> > +       return 0;
> > +}
> > +
> > +int mt79xx_afe_enable_clock(struct mtk_base_afe *afe)
> > +{
> > +       struct mt79xx_afe_private *afe_priv = afe->platform_priv;
> > +       int ret;
> > +
> > +       ret = clk_prepare_enable(afe_priv-
> >clk[CK_INFRA_AUD_BUS_CK]);
> > +       if (ret) {
> > +               dev_err(afe->dev, "%s(), clk_prepare_enable %s fail
> %d\n",
> > +                       __func__, aud_clks[CK_INFRA_AUD_BUS_CK],
> ret);
> > +               goto CK_INFRA_AUD_BUS_CK_ERR;
> > +       }
> > +
> > +       ret = clk_prepare_enable(afe_priv-
> >clk[CK_INFRA_AUD_26M_CK]);
> > +       if (ret) {
> > +               dev_err(afe->dev, "%s(), clk_prepare_enable %s fail
> %d\n",
> > +                       __func__, aud_clks[CK_INFRA_AUD_26M_CK],
> ret);
> > +               goto CK_INFRA_AUD_26M_ERR;
> > +       }
> > +
> > +       ret = clk_prepare_enable(afe_priv->clk[CK_INFRA_AUD_L_CK]);
> > +       if (ret) {
> > +               dev_err(afe->dev, "%s(), clk_prepare_enable %s fail
> %d\n",
> > +                       __func__, aud_clks[CK_INFRA_AUD_L_CK],
> ret);
> > +               goto CK_INFRA_AUD_L_CK_ERR;
> > +       }
> > +
> > +       ret = clk_prepare_enable(afe_priv-
> >clk[CK_INFRA_AUD_AUD_CK]);
> > +       if (ret) {
> > +               dev_err(afe->dev, "%s clk_prepare_enable %s fail
> %d\n",
> > +                       __func__, aud_clks[CK_INFRA_AUD_AUD_CK],
> ret);
> > +               goto CK_INFRA_AUD_AUD_CK_ERR;
> > +       }
> > +
> > +       ret = clk_prepare_enable(afe_priv-
> >clk[CK_INFRA_AUD_EG2_CK]);
> > +       if (ret) {
> > +               dev_err(afe->dev, "%s clk_prepare_enable %s fail
> %d\n",
> > +                       __func__, aud_clks[CK_INFRA_AUD_EG2_CK],
> ret);
> > +               goto CK_INFRA_AUD_EG2_CK_ERR;
> > +       }
> 
> And clk_bulk_prepare_enable() instead all these.
> 

I'll use this api in v2 patch.

> > +
> > +       return 0;
> > +
> > +CK_INFRA_AUD_EG2_CK_ERR:
> > +       clk_disable_unprepare(afe_priv->clk[CK_INFRA_AUD_AUD_CK]);
> > +CK_INFRA_AUD_AUD_CK_ERR:
> > +       clk_disable_unprepare(afe_priv->clk[CK_INFRA_AUD_L_CK]);
> > +CK_INFRA_AUD_L_CK_ERR:
> > +       clk_disable_unprepare(afe_priv->clk[CK_INFRA_AUD_26M_CK]);
> > +CK_INFRA_AUD_26M_ERR:
> > +       clk_disable_unprepare(afe_priv->clk[CK_INFRA_AUD_BUS_CK]);
> > +CK_INFRA_AUD_BUS_CK_ERR:
> > +       return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(mt79xx_afe_enable_clock);
> > +
> > +int mt79xx_afe_disable_clock(struct mtk_base_afe *afe)
> > +{
> > +       struct mt79xx_afe_private *afe_priv = afe->platform_priv;
> > +
> > +       clk_disable_unprepare(afe_priv->clk[CK_INFRA_AUD_EG2_CK]);
> > +       clk_disable_unprepare(afe_priv->clk[CK_INFRA_AUD_AUD_CK]);
> > +       clk_disable_unprepare(afe_priv->clk[CK_INFRA_AUD_L_CK]);
> > +       clk_disable_unprepare(afe_priv->clk[CK_INFRA_AUD_26M_CK]);
> > +       clk_disable_unprepare(afe_priv->clk[CK_INFRA_AUD_BUS_CK]);
> > +
> 
> And also clk_bulk_disable_unprepare() here.
> 

I'll use this api in v2 patch.

> > +       return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(mt79xx_afe_disable_clock);
> > diff --git a/sound/soc/mediatek/mt79xx/mt79xx-afe-clk.h
> b/sound/soc/mediatek/mt79xx/mt79xx-afe-clk.h
> > new file mode 100644
> > index 000000000000..bf9c3edb6922
> > --- /dev/null
> > +++ b/sound/soc/mediatek/mt79xx/mt79xx-afe-clk.h
> > @@ -0,0 +1,18 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/*
> > + * mt79xx-afe-clk.h  --  MediaTek 79xx afe clock ctrl definition
> > + *
> > + * Copyright (c) 2021 MediaTek Inc.
> > + * Author: Vic Wu <vic.wu@mediatek.com>
> > + *         Maso Huang <maso.huang@mediatek.com>
> > + */
> > +
> > +#ifndef _MT79XX_AFE_CLK_H_
> > +#define _MT79XX_AFE_CLK_H_
> > +
> > +struct mtk_base_afe;
> > +
> > +int mt79xx_init_clock(struct mtk_base_afe *afe);
> > +int mt79xx_afe_enable_clock(struct mtk_base_afe *afe);
> > +int mt79xx_afe_disable_clock(struct mtk_base_afe *afe);
> > +#endif
> > --
> > 2.18.0
> > 
> > 
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 
> 

Best regards,
Maso

  reply	other threads:[~2023-06-14  8:32 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 10:52 [PATCH 0/7] ASoC: mediatek: Add support for MT79xx SoC Maso Hunag
2023-06-12 10:52 ` [PATCH 1/7] ASoC: mediatek: mt79xx: add common header Maso Hunag
2023-06-14  7:44   ` AngeloGioacchino Del Regno
2023-06-14  7:52     ` Maso Huang (黃加竹)
2023-06-12 10:52 ` [PATCH 2/7] ASoC: mediatek: mt79xx: support audio clock control Maso Hunag
2023-06-13  7:27   ` Claudiu.Beznea
2023-06-14  7:44     ` Maso Huang (黃加竹) [this message]
2023-06-12 10:52 ` [PATCH 3/7] ASoC: mediatek: mt79xx: add platform driver Maso Hunag
2023-06-14  7:57   ` AngeloGioacchino Del Regno
2023-06-14  9:06     ` Maso Huang (黃加竹)
2023-06-14 12:21   ` kernel test robot
2023-06-12 10:52 ` [PATCH 4/7] ASoC: mediatek: mt79xx: support etdm in " Maso Hunag
2023-06-12 10:52 ` [PATCH 5/7] ASoC: mediatek: mt79xx: add machine driver with wm8960 Maso Hunag
2023-06-12 10:52 ` [PATCH 6/7] ASoC: dt-bindings: mediatek,mt79xx-wm8960: add mt79xx-wm8960 document Maso Hunag
2023-06-13  8:49   ` Krzysztof Kozlowski
2023-06-14  7:40     ` Maso Huang (黃加竹)
2023-06-14  8:22       ` Krzysztof Kozlowski
2023-06-14  8:45         ` Maso Huang (黃加竹)
2023-06-12 10:52 ` [PATCH 7/7] ASoC: dt-bindings: mediatek,mt79xx-afe: add audio afe document Maso Hunag
2023-06-13  8:51   ` Krzysztof Kozlowski
2023-06-14  3:17     ` Maso Huang (黃加竹)
2023-06-14  6:34       ` Krzysztof Kozlowski
2023-06-14  7:37         ` Maso Huang (黃加竹)
2023-06-14  8:21           ` Krzysztof Kozlowski
2023-06-14  9:19             ` Maso Huang (黃加竹)
2023-06-14 10:26               ` Krzysztof Kozlowski
2023-06-15  2:26                 ` Maso Huang (黃加竹)

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=4583d8df9711fad708da3437284734364610d268.camel@mediatek.com \
    --to=maso.huang@mediatek.com \
    --cc=Allen-KH.Cheng@mediatek.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=Jiaxin.Yu@mediatek.com \
    --cc=Trevor.Wu@mediatek.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=perex@perex.cz \
    --cc=renzhijie2@huawei.com \
    --cc=tiwai@suse.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

all inboxes | Powered by JetHome®