Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp316208ybj; Wed, 6 May 2020 18:36:36 -0700 (PDT) X-Google-Smtp-Source: APiQypI5RJP10SYtm0Rihrza+BKXlEM6RVk4nOQ+6Lg2JuKApkpyn6QTiXP4V2j9JfxpiHO3XpQx X-Received: by 2002:a05:6402:686:: with SMTP id f6mr10170919edy.136.1588815395926; Wed, 06 May 2020 18:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588815395; cv=none; d=google.com; s=arc-20160816; b=zQSsBFtxKoQJjFZgTmQFqjwENctnq8aTJEWhPRQZIauZVcgbuFGl5yMBlDq2rVF9i3 gfOz1LAyE+a0gqZPpIfpiVVeM2DUx7+bUEe62szjeX1D+kTvrmtHx1cgRWpFHcY1syMe kK1c8kxtrzkQorV3KwaMdJ4yJr4AuDjQDquQjU3yb5+JEHLTaLE2kgl6en52u4jBpcLe mEOa7fSR4MmZoXLFF9JOw2XPwxLHLuL1mBBU/YrYnZI8SGrBKa96XPBi6PSbClViPua7 F6ri22gbHJOeXMmH7obyudhtytplJHWXPBkVrgIeiWL+qakj+p68nJXTmB3a6YXxx4xb /ZHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=vE+sWwX0Yu3oc+f0HM0UuHbWwI/UCIPhKxPzQDGLHyg=; b=n0aovcvI4xTI6APg7XdEww9aNooB3rXr9dhhbLqa3fmWygdUxcBJUffU59HwLjufAl xTHtjOjnhS+5SnxKU06Ihw8NY3sKpOmSnI3BQXJMdwLgiWgbGV6sw2fHoOPb6yEAi6CC 6por0NDWu5F/LynEuZRioKz42lho9PrVjbnGfaeaMiJq4PP314znOo63CauTjyS13WcR 9Oa0CINauhbGKOtmcSk9QvPiOwMT3kOqo+LEagMSqjRl73TNMHBByYp853FGKBCnFhFM UFQg47kRsX/Il/OsT6vk7yLH08zvHwkQpMOB2M2F8tbXx8cq85cDNv0SXxzrESxDISAu 274A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l35si2106053edl.187.2020.05.06.18.36.13; Wed, 06 May 2020 18:36:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729533AbgEFVB4 (ORCPT + 99 others); Wed, 6 May 2020 17:01:56 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58152 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728535AbgEFVBz (ORCPT ); Wed, 6 May 2020 17:01:55 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 59C212A22DB From: Enric Balletbo i Serra Subject: Re: [PATCH v14 03/11] soc: mediatek: Add basic_clk_name to scp_power_data To: Weiyi Lu , Enric Balletbo Serra , Matthias Brugger , Nicolas Boichat , Rob Herring , Sascha Hauer Cc: James Liao , srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, Fan Chen , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org References: <1588752963-19934-1-git-send-email-weiyi.lu@mediatek.com> <1588752963-19934-4-git-send-email-weiyi.lu@mediatek.com> Message-ID: <7ad67855-a3f8-f979-8849-3765bd8289d3@collabora.com> Date: Wed, 6 May 2020 23:01:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <1588752963-19934-4-git-send-email-weiyi.lu@mediatek.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Weiyi, Thank you for your patch. On 6/5/20 10:15, Weiyi Lu wrote: > Try to stop extending the clk_id or clk_names if there are > more and more new BASIC clocks. To get its own clocks by the > basic_clk_name of each power domain. > And then use basic_clk_name strings for all compatibles, instead of > mixing clk_id and clk_name. > > Signed-off-by: Weiyi Lu > Reviewed-by: Nicolas Boichat > --- > drivers/soc/mediatek/mtk-scpsys.c | 134 ++++++++++++-------------------------- > 1 file changed, 41 insertions(+), 93 deletions(-) > > diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c > index f669d37..c9c3cf7 100644 > --- a/drivers/soc/mediatek/mtk-scpsys.c > +++ b/drivers/soc/mediatek/mtk-scpsys.c > @@ -78,34 +78,6 @@ > #define PWR_STATUS_HIF1 BIT(26) /* MT7622 */ > #define PWR_STATUS_WB BIT(27) /* MT7622 */ > > -enum clk_id { > - CLK_NONE, > - CLK_MM, > - CLK_MFG, > - CLK_VENC, > - CLK_VENC_LT, > - CLK_ETHIF, > - CLK_VDEC, > - CLK_HIFSEL, > - CLK_JPGDEC, > - CLK_AUDIO, > - CLK_MAX, > -}; > - > -static const char * const clk_names[] = { > - NULL, > - "mm", > - "mfg", > - "venc", > - "venc_lt", > - "ethif", > - "vdec", > - "hif_sel", > - "jpgdec", > - "audio", > - NULL, > -}; > - > #define MAX_CLKS 3 > > /** > @@ -116,7 +88,7 @@ enum clk_id { > * @sram_pdn_bits: The mask for sram power control bits. > * @sram_pdn_ack_bits: The mask for sram power control acked bits. > * @bus_prot_mask: The mask for single step bus protection. > - * @clk_id: The basic clocks required by this power domain. > + * @basic_clk_name: The basic clocks required by this power domain. > * @caps: The flag for active wake-up action. > */ > struct scp_domain_data { > @@ -126,7 +98,7 @@ struct scp_domain_data { > u32 sram_pdn_bits; > u32 sram_pdn_ack_bits; > u32 bus_prot_mask; > - enum clk_id clk_id[MAX_CLKS]; > + const char *basic_clk_name[MAX_CLKS]; I only reviewed v13, so sorry if this was already discussed. I am wondering if would be better take advantage of the devm_clk_bulk_get() function instead of kind of reimplementing the same, something like this const struct clk_bulk_data *basic_clocks; > u8 caps; > }; > > @@ -411,12 +383,19 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) > return ret; > } > > -static void init_clks(struct platform_device *pdev, struct clk **clk) > +static int init_basic_clks(struct platform_device *pdev, struct clk **clk, > + const char * const *name) > { > int i; > > - for (i = CLK_NONE + 1; i < CLK_MAX; i++) > - clk[i] = devm_clk_get(&pdev->dev, clk_names[i]); > + for (i = 0; i < MAX_CLKS && name[i]; i++) { > + clk[i] = devm_clk_get(&pdev->dev, name[i]); > + > + if (IS_ERR(clk[i])) > + return PTR_ERR(clk[i]); > + } You will be able to remove this function, see below ... > + > + return 0; > } > > static struct scp *init_scp(struct platform_device *pdev, > @@ -426,9 +405,8 @@ static struct scp *init_scp(struct platform_device *pdev, > { > struct genpd_onecell_data *pd_data; > struct resource *res; > - int i, j; > + int i, ret; > struct scp *scp; > - struct clk *clk[CLK_MAX]; > > scp = devm_kzalloc(&pdev->dev, sizeof(*scp), GFP_KERNEL); > if (!scp) > @@ -481,8 +459,6 @@ static struct scp *init_scp(struct platform_device *pdev, > > pd_data->num_domains = num; > > - init_clks(pdev, clk); > - > for (i = 0; i < num; i++) { > struct scp_domain *scpd = &scp->domains[i]; > struct generic_pm_domain *genpd = &scpd->genpd; > @@ -493,17 +469,9 @@ static struct scp *init_scp(struct platform_device *pdev, > > scpd->data = data; > > - for (j = 0; j < MAX_CLKS && data->clk_id[j]; j++) { > - struct clk *c = clk[data->clk_id[j]]; > - > - if (IS_ERR(c)) { > - dev_err(&pdev->dev, "%s: clk unavailable\n", > - data->name); > - return ERR_CAST(c); > - } > - > - scpd->clk[j] = c; > - } > + ret = init_basic_clks(pdev, scpd->clk, data->basic_clk_name); > + if (ret) > + return ERR_PTR(ret); Just call: ret = devm_clk_bulk_get(&pdev->dev, ARRAY_SIZE(basic_clocks), data->basic_clocks); if (ret) return ERR_PTR(ret); > > genpd->name = data->name; > genpd->power_off = scpsys_power_off; > @@ -560,7 +528,6 @@ static void mtk_register_power_domains(struct platform_device *pdev, > .ctl_offs = SPM_CONN_PWR_CON, > .bus_prot_mask = MT2701_TOP_AXI_PROT_EN_CONN_M | > MT2701_TOP_AXI_PROT_EN_CONN_S, > - .clk_id = {CLK_NONE}, > .caps = MTK_SCPD_ACTIVE_WAKEUP, > }, > [MT2701_POWER_DOMAIN_DISP] = { > @@ -568,7 +535,7 @@ static void mtk_register_power_domains(struct platform_device *pdev, > .sta_mask = PWR_STATUS_DISP, > .ctl_offs = SPM_DIS_PWR_CON, > .sram_pdn_bits = GENMASK(11, 8), > - .clk_id = {CLK_MM}, > + .basic_clk_name = {"mm"}, .basic_clocks[] = { { .id = "mm" }, }; > .bus_prot_mask = MT2701_TOP_AXI_PROT_EN_MM_M0, > .caps = MTK_SCPD_ACTIVE_WAKEUP, > }, > @@ -578,7 +545,7 @@ static void mtk_register_power_domains(struct platform_device *pdev, > .ctl_offs = SPM_MFG_PWR_CON, > .sram_pdn_bits = GENMASK(11, 8), > .sram_pdn_ack_bits = GENMASK(12, 12), > - .clk_id = {CLK_MFG}, > + .basic_clk_name = {"mfg"}, .basic_clocks[] = { { .id = "mfg" }, }; > .caps = MTK_SCPD_ACTIVE_WAKEUP, > }, > [MT2701_POWER_DOMAIN_VDEC] = { > @@ -587,7 +554,7 @@ static void mtk_register_power_domains(struct platform_device *pdev, > .ctl_offs = SPM_VDE_PWR_CON, > .sram_pdn_bits = GENMASK(11, 8), > .sram_pdn_ack_bits = GENMASK(12, 12), > - .clk_id = {CLK_MM}, > + .basic_clk_name = {"mm"}, ... [snip]