Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5934771ybv; Wed, 12 Feb 2020 03:04:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxIMTRKJVLCkmINu0OWltPo9Ef0izEbc2IbfUISJjZGOxp7pl+rOEQWW4CvKnAIIP36zWoF X-Received: by 2002:aca:cd46:: with SMTP id d67mr5889657oig.156.1581505448759; Wed, 12 Feb 2020 03:04:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581505448; cv=none; d=google.com; s=arc-20160816; b=R+4596JDNV5iWwL5X3m4GqhLRiH9gCUcv7IsMtQ2rRRPXJTf0/qgEjcBDp7vZABfEj zttvjgZxoaYJglNoDlCERpdym97UNOpQkwTIkTYpHpGItwlXwzxJ6p26yqhbVoSCP3Cy BpWTcb6knhTdg/UANQoMjutlHKLev1Glp8oWnkH3qRBmxNLgweouEY+g4ASeOEJtK4DJ +CgzvNlBQ0HXmR5IPVH0VyBkGjSw5iQ+KDQ+D8ubFuH+F17+z/y6jEWU5Ps7oA6cMIj2 XB00P+WRqMSdnl7iMMucliby5OcFmOX4Grlh3hl+8ZrYg2ngimaAQJ0fW9qCNeayyYNe 5YHg== 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:autocrypt:from:references:cc:to:subject:dkim-signature; bh=Ty1lhFhbitfGnMEvYL1IMfLTHYjrK8xuCassV+yVTkI=; b=M2CScBQaBxcli1kB4isUl6hpub1Et9pgoF4ssR9dUDcsBF9gQlUekR3mzrHou+g+fJ 161XHMUMFJpwaDnqBhFYLk7i8pJJ4SwXd+BeGFK4rMU+8T2nmaBJ85htwAvi+2LqRSSW EQCuhrk7t6DQerzcEcO3f8RDHacUklv5uvYbW/7FWPNqnQhUq/KwCBGcg2w7wGqECj08 va5zvlzdJZSsxFiEPE1mvqEXSpFHVC8Mb9u5oL2xKRgbjRAl5vDfcK8YqdJtgKTX9Gc2 k8ASkEMm9ChaQH590XMVaI1XKo7JAaawBLOks4+vtClXWbAacFQyVCqi7gg9oqMemsHw 3RJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pdIuyOyw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m19si3053146oig.91.2020.02.12.03.03.53; Wed, 12 Feb 2020 03:04:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pdIuyOyw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728086AbgBLLCH (ORCPT + 99 others); Wed, 12 Feb 2020 06:02:07 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40260 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbgBLLCH (ORCPT ); Wed, 12 Feb 2020 06:02:07 -0500 Received: by mail-wr1-f65.google.com with SMTP id t3so1693346wru.7 for ; Wed, 12 Feb 2020 03:02:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Ty1lhFhbitfGnMEvYL1IMfLTHYjrK8xuCassV+yVTkI=; b=pdIuyOyw3e777QYypxTxGd854YY+3g06G9xhicn7AE/auqGzApOQMyTwY92CsSE7C3 WHnPe0I/I8mVQ+f+0oMdAQCaeWtMI361ykGcVcDKwQU8g5huZd9nwRuxNA60mhB4md6Z LVMIELbruiBIFEfLrlhnhubYeW0H5ehZ91u9m35fee6aCua2xszIPAAaA/bXnIvPywbf kAI/nJmW8VP9i1CBzMfL+bW5l1UILcoKrLdJpEKS7vsOgDPhTtsIoloH0g7ACQKe6OHr 4w0/6uG8W3cGi47aXMnzqd8MCtceXE7TwO84pmXMySojNIsozarR74Qgy+ydBAdj/0xD eGGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=Ty1lhFhbitfGnMEvYL1IMfLTHYjrK8xuCassV+yVTkI=; b=A9G3JzB/rqdr3LhuVGj7vw8ywRb+ydIVzQyau1P5Krc85IyWq/sNHAWX/PZvQmCV6L 2FY8L+A1WsG0YIpeVkG7aPhHsX86zRnCyRNyqiKmPPD4Qj964iXTqEptaX2la+Su5p/W /ilIS0wQCXUOM51ksy1NGwrz1qMEvpzPyjAFHRMDsY6AZrZ8OnFyx3T+8RRUA9njM5/2 tM1NLA4dVbWImUufoJwJJt3a7mVIObrAurAxrEA3q6DZ3qxZdyixgM+JjBn1Ba9px7Bh 7aRpwn+vMASpLJu1DEIaWlbp0BbrMUH4so2OALfrSoqLA6LgdCZMVoc2wm/12J7Nt9xE 0Odg== X-Gm-Message-State: APjAAAVCC5mXbfczUOwPiAjoAKoio9gD2uDK2XEcwnyo5Cva6tkC9nQ9 /YZ7rlrYh/OyajsmaXB0/Sk= X-Received: by 2002:a5d:498f:: with SMTP id r15mr14437866wrq.284.1581505323895; Wed, 12 Feb 2020 03:02:03 -0800 (PST) Received: from ziggy.stardust ([37.223.145.31]) by smtp.gmail.com with ESMTPSA id t81sm282067wmg.6.2020.02.12.03.02.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Feb 2020 03:02:02 -0800 (PST) Subject: Re: [PATCH v11 06/10] soc: mediatek: Add subsys clock control for bus protection To: Weiyi Lu Cc: Nicolas Boichat , Rob Herring , Sascha Hauer , James Liao , Fan Chen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com References: <1576813564-23927-1-git-send-email-weiyi.lu@mediatek.com> <1576813564-23927-7-git-send-email-weiyi.lu@mediatek.com> <1581476141.22901.34.camel@mtksdaap41> From: Matthias Brugger Autocrypt: addr=matthias.bgg@gmail.com; prefer-encrypt=mutual; keydata= mQINBFP1zgUBEAC21D6hk7//0kOmsUrE3eZ55kjc9DmFPKIz6l4NggqwQjBNRHIMh04BbCMY fL3eT7ZsYV5nur7zctmJ+vbszoOASXUpfq8M+S5hU2w7sBaVk5rpH9yW8CUWz2+ZpQXPJcFa OhLZuSKB1F5JcvLbETRjNzNU7B3TdS2+zkgQQdEyt7Ij2HXGLJ2w+yG2GuR9/iyCJRf10Okq gTh//XESJZ8S6KlOWbLXRE+yfkKDXQx2Jr1XuVvM3zPqH5FMg8reRVFsQ+vI0b+OlyekT/Xe 0Hwvqkev95GG6x7yseJwI+2ydDH6M5O7fPKFW5mzAdDE2g/K9B4e2tYK6/rA7Fq4cqiAw1+u EgO44+eFgv082xtBez5WNkGn18vtw0LW3ESmKh19u6kEGoi0WZwslCNaGFrS4M7OH+aOJeqK fx5dIv2CEbxc6xnHY7dwkcHikTA4QdbdFeUSuj4YhIZ+0QlDVtS1QEXyvZbZky7ur9rHkZvP ZqlUsLJ2nOqsmahMTIQ8Mgx9SLEShWqD4kOF4zNfPJsgEMB49KbS2o9jxbGB+JKupjNddfxZ HlH1KF8QwCMZEYaTNogrVazuEJzx6JdRpR3sFda/0x5qjTadwIW6Cl9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LUf1wLhcHzugTiONz9fWMBLLskKvq7m1tlr61mNgY9nVwwClMU uE7i1H9r/2/UXLd+pY82zcXhFrfmKuCDmOkB5xPsOMVQJH8I0/lbqfLAqfsxSb/X1VKaP243 jzi+DzD9cvj2K6eD5j5kcKJJQactXqfJvF1Eb+OnxlB1BCLE8D1rNkPO5O742Mq3MgDmq19l +abzEL6QDAAxn9md8KwrA3RtucNh87cHlDXfUBKa7SRvBjTczDg+HEPNk2u3hrz1j3l2rliQ y1UfYx7Vk/TrdwUIJgKS8QAr8Lw9WuvY2hSqL9vEjx8VAkPWNWPwrQ== Message-ID: Date: Wed, 12 Feb 2020 12:02:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <1581476141.22901.34.camel@mtksdaap41> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/02/2020 03:55, Weiyi Lu wrote: > On Tue, 2020-02-11 at 18:54 +0100, Matthias Brugger wrote: >> >> On 20/12/2019 04:46, Weiyi Lu wrote: >>> Add subsys CG control flow before/after the bus protect control >>> due to bus protection need SMI bus relative CGs enabled to feedback >>> its ack. >>> >> >> Sorry, I don't understand the commit message. Can you please rephrase and >> explain better what this change is for. >> > > OK! I'll reword it. > >>> Signed-off-by: Weiyi Lu >>> Reviewed-by: Nicolas Boichat >>> --- >>> drivers/soc/mediatek/mtk-scpsys.c | 72 +++++++++++++++++++++++++++++++++++++-- >>> 1 file changed, 70 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c >>> index 763ca58..32be4b3 100644 >>> --- a/drivers/soc/mediatek/mtk-scpsys.c >>> +++ b/drivers/soc/mediatek/mtk-scpsys.c >>> @@ -79,6 +79,7 @@ >>> #define PWR_STATUS_WB BIT(27) /* MT7622 */ >>> >>> #define MAX_CLKS 3 >>> +#define MAX_SUBSYS_CLKS 10 >>> >>> /** >>> * struct scp_domain_data - scp domain data for power on/off flow >>> @@ -88,6 +89,8 @@ >>> * @sram_pdn_bits: The mask for sram power control bits. >>> * @sram_pdn_ack_bits: The mask for sram power control acked bits. >>> * @basic_clk_name: The basic clocks required by this power domain. >>> + * @subsys_clk_prefix: The prefix name of the clocks need to be enabled >>> + * before releasing bus protection. >>> * @caps: The flag for active wake-up action. >>> * @bp_table: The mask table for multiple step bus protection. >>> */ >>> @@ -98,6 +101,7 @@ struct scp_domain_data { >>> u32 sram_pdn_bits; >>> u32 sram_pdn_ack_bits; >>> const char *basic_clk_name[MAX_CLKS]; >>> + const char *subsys_clk_prefix; >>> u8 caps; >>> struct bus_prot bp_table[MAX_STEPS]; >>> }; >>> @@ -108,6 +112,7 @@ struct scp_domain { >>> struct generic_pm_domain genpd; >>> struct scp *scp; >>> struct clk *clk[MAX_CLKS]; >>> + struct clk *subsys_clk[MAX_SUBSYS_CLKS]; >>> const struct scp_domain_data *data; >>> struct regulator *supply; >>> }; >>> @@ -301,16 +306,22 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) >>> val |= PWR_RST_B_BIT; >>> writel(val, ctl_addr); >>> >>> - ret = scpsys_sram_enable(scpd, ctl_addr); >>> + ret = scpsys_clk_enable(scpd->subsys_clk, MAX_SUBSYS_CLKS); >> >> Why can't we enable the subsystem clocks together with the rest just after >> enabeling the regulator? >> > > Subsys CG could only be enabled when its own power domain is already > turned ON, and vice versa. > In the dt-binding doc we mentioned there would have two groups of > clocks. > e.g., > BASIC clocks need to be enabled before enabling the corresponding power > domain. > SUBSYS clocks need to be enabled before releasing the bus protection. > Do I understand correctly that we could enable/disable all clocks in the same place as long as we make sure that the the basic clocks are turned on before we turn on the subsys clocks, correct? So why do we need to implement this logic in the power-controller driver? Shouldn't that be part of the common clock driver? Regards, Matthias >>> if (ret < 0) >>> goto err_pwr_ack; >>> >>> + ret = scpsys_sram_enable(scpd, ctl_addr); >>> + if (ret < 0) >>> + goto err_sram; >>> + >>> ret = scpsys_bus_protect_disable(scpd); >>> if (ret < 0) >>> - goto err_pwr_ack; >>> + goto err_sram; >>> >>> return 0; >>> >>> +err_sram: >>> + scpsys_clk_disable(scpd->subsys_clk, MAX_SUBSYS_CLKS); >>> err_pwr_ack: >>> scpsys_clk_disable(scpd->clk, MAX_CLKS); >>> err_clk: >>> @@ -337,6 +348,8 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) >>> if (ret < 0) >>> goto out; >>> >>> + scpsys_clk_disable(scpd->subsys_clk, MAX_SUBSYS_CLKS); >>> + >> >> Same here, why can't we disable the clocks in the scpsys_clk_disable call? >> >>> /* subsys power off */ >>> val = readl(ctl_addr); >>> val |= PWR_ISO_BIT; >>> @@ -374,6 +387,48 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) >>> return ret; >>> } >>> >>> +static int init_subsys_clks(struct platform_device *pdev, >>> + const char *prefix, struct clk **clk) >>> +{ >>> + struct device_node *node = pdev->dev.of_node; >>> + u32 prefix_len, sub_clk_cnt = 0; >>> + struct property *prop; >>> + const char *clk_name; >>> + >>> + if (!node) { >>> + dev_err(&pdev->dev, "Cannot find scpsys node: %ld\n", >>> + PTR_ERR(node)); >>> + return PTR_ERR(node); >>> + } >>> + >>> + prefix_len = strlen(prefix); >>> + >>> + of_property_for_each_string(node, "clock-names", prop, clk_name) { >>> + if (!strncmp(clk_name, prefix, prefix_len) && >>> + (clk_name[prefix_len] == '-')) { >>> + if (sub_clk_cnt >= MAX_SUBSYS_CLKS) { >>> + dev_err(&pdev->dev, >>> + "subsys clk out of range %d\n", >>> + sub_clk_cnt); >>> + return -ENOMEM; >> >> EINVAL maybe, ENOMEM seems wrong here. >> > > OK, I'll fix with correct error. > >>> + } >>> + >>> + clk[sub_clk_cnt] = devm_clk_get(&pdev->dev, >>> + clk_name); >> >> Here we get hit by the bad design of this driver in the first place. As we need >> the subsystem-name (eg mm-0, mm-1) to group clocks to one scp_domain. >> I think we should better try to model the domains and subdomains in DTS and add >> their clocks to it. This way we can also get rid of the scp_subdomain which can >> hit it's limit anytime soon when we have a chip with a sub-subdomain. >> That will need a new driver, but as it seems the mt8183 and the mt6765 have a >> more complex design I think it is worth it. >> >> That said, given that you are in v11 already I understand that your motivation >> to start over isn't the biggest. The problem is, any new driver will have new >> bindings and won't work with older DTS. So adding a lot of stuff on top of a not >> really nice driver isn't something I'm very keen on. On the other hand you >> already put a lot of work into this solution. >> >> My proposal, I'll try to bake up a new driver this week. If I fail to deliver, >> it's up to you to decide if you want to go on with the approach in this series >> or try to work on the new one. > >> Regards, >> Matthias >> > > Thanks for considering our request. > >>> + >>> + if (IS_ERR(clk[sub_clk_cnt])) { >>> + dev_err(&pdev->dev, >>> + "Subsys clk get fail %ld\n", >>> + PTR_ERR(clk[sub_clk_cnt])); >>> + return PTR_ERR(clk[sub_clk_cnt]); >>> + } >>> + sub_clk_cnt++; >>> + } >>> + } >>> + >>> + return sub_clk_cnt; >>> +} >>> + >>> static int init_basic_clks(struct platform_device *pdev, struct clk **clk, >>> const char * const *name) >>> { >>> @@ -466,6 +521,7 @@ static struct scp *init_scp(struct platform_device *pdev, >>> struct scp_domain *scpd = &scp->domains[i]; >>> struct generic_pm_domain *genpd = &scpd->genpd; >>> const struct scp_domain_data *data = &scp_domain_data[i]; >>> + int clk_cnt; >> >> clk_cnt sounds to me like clock count, but the variable actually is only used to >> check the return value of init_subsys_clks. Please rename it to ret or something >> like this. >> > > OK, I'll fix it. > >>> >>> pd_data->domains[i] = genpd; >>> scpd->scp = scp; >>> @@ -476,6 +532,18 @@ static struct scp *init_scp(struct platform_device *pdev, >>> if (ret) >>> return ERR_PTR(ret); >>> >>> + if (data->subsys_clk_prefix) { >>> + clk_cnt = init_subsys_clks(pdev, >>> + data->subsys_clk_prefix, >>> + scpd->subsys_clk); >>> + if (clk_cnt < 0) { >>> + dev_err(&pdev->dev, >>> + "%s: subsys clk unavailable\n", >>> + data->name); >>> + return ERR_PTR(clk_cnt); >>> + } >>> + } >>> + >>> genpd->name = data->name; >>> genpd->power_off = scpsys_power_off; >>> genpd->power_on = scpsys_power_on; >>> >