From patchwork Thu Jul 28 11:37:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 594277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 831B7C19F21 for ; Thu, 28 Jul 2022 11:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236416AbiG1LiB (ORCPT ); Thu, 28 Jul 2022 07:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236250AbiG1Lh6 (ORCPT ); Thu, 28 Jul 2022 07:37:58 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82BDF52DEB for ; Thu, 28 Jul 2022 04:37:57 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id p11so2435822lfu.5 for ; Thu, 28 Jul 2022 04:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8f7AzP41RwjwjZoc5Fi63P8k3nDowsYtu1Mq4bqqV00=; b=uRee3hHcuqRucHOZB3WCx5VdGAyydjYM5zjTsBKtDKgkMtOI8MOv66+a+0HMyNLZd6 6Q1LcPPX/b6nOZ83WoVq1Jyme1AH4prpuQxj9AL3BZ1SPAYUdZLDOVLZXL3zEcP3tYZm wa/N2d6kHIMjSvytZl+GnFZbnn4RO8PTrZdhRTNqThr54komn5FXDxzf7wyr/7Vrfx7e FSPxtGVDVr84TYiKy799uFEP7t73w8tvbWGZ/1LQ0wbk4mHxTVuwLA2yqrIKhnlA+m+m DbMop+WnD/kcQTfHz7+MVwdFxdcVu7m63MNahhCIzUXa04cOUOefM1g+5rSkGiT4CjhJ Ayrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8f7AzP41RwjwjZoc5Fi63P8k3nDowsYtu1Mq4bqqV00=; b=2d0F5iG8Ls94klgz/TkOV+BawAf7ajvlbtiVmTFMj2WsyjkEsQaw2Yqq36AeFu5ujI RZNm60eKj5JfjITFOsj0juYc5h36O0Mpt9NzhcAUX8qq/qYWmkrW7zvOF5WE6KHw9Pey wvRyg3vcmI1+Ok1YjhzmqeTNYP/D46Nigpai7ZzudHo5Ryv0uHsuqFAl5PbLy0Tis3TL Vx4uFjGhIwXzc0EYW+pvzd6T/W1lIjdBdu/Ks4AMQbt/PtXSdLh+5VK4kH1+ZlLatNDE Sw/26i6eUUj8GeYZlNqZE9Ol1qS3xfsroJmz1OAPZUWe08DBbVkx4QAM57XVas+fAm0k Nhpg== X-Gm-Message-State: AJIora/WhJZktwWZtvqwwq9sYKGyp6VSFkkUhT24vx7antnAyI0D3G02 /QxG8G1bgoU8cHJXVpOb5we5hg== X-Google-Smtp-Source: AGRyM1svL/jAfEzurLOoAGAE0tDhv8inIGoxoPYrjBITobXC5679QnZn5OdPRm4PKEqAmE4ETI/Oiw== X-Received: by 2002:a05:6512:1291:b0:48a:9148:64e6 with SMTP id u17-20020a056512129100b0048a914864e6mr6720951lfs.480.1659008275675; Thu, 28 Jul 2022 04:37:55 -0700 (PDT) Received: from krzk-bin.lan (78-26-46-173.network.trollfjord.no. [78.26.46.173]) by smtp.gmail.com with ESMTPSA id l12-20020a2ea80c000000b0025e0396786dsm98192ljq.93.2022.07.28.04.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 04:37:55 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Konrad Dybcio , Georgi Djakov , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rajendra Nayak , Sibi Sankar Subject: [PATCH v2 02/11] soc: qcom: icc-bwmon: re-use IRQ enable/clear define Date: Thu, 28 Jul 2022 13:37:39 +0200 Message-Id: <20220728113748.170548-3-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> References: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The interrupt enable, status and clear registers have the same layout, so BWMON_GLOBAL_IRQ_ENABLE_ENABLE define can be used also for clearing IRQ, instead of hard-coded value. Cc: Rajendra Nayak Cc: Sibi Sankar Signed-off-by: Krzysztof Kozlowski Reviewed-by: Sibi Sankar --- drivers/soc/qcom/icc-bwmon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/icc-bwmon.c b/drivers/soc/qcom/icc-bwmon.c index bea3ea1de7a4..3415f42523cd 100644 --- a/drivers/soc/qcom/icc-bwmon.c +++ b/drivers/soc/qcom/icc-bwmon.c @@ -162,7 +162,8 @@ static void bwmon_clear_irq(struct icc_bwmon *bwmon) * interrupt is cleared. */ writel(BWMON_IRQ_ENABLE_MASK, bwmon->base + BWMON_IRQ_CLEAR); - writel(BIT(0), bwmon->base + BWMON_GLOBAL_IRQ_CLEAR); + writel(BWMON_GLOBAL_IRQ_ENABLE_ENABLE, + bwmon->base + BWMON_GLOBAL_IRQ_CLEAR); } static void bwmon_disable(struct icc_bwmon *bwmon) From patchwork Thu Jul 28 11:37:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 594276 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3013C19F21 for ; Thu, 28 Jul 2022 11:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236616AbiG1LiG (ORCPT ); Thu, 28 Jul 2022 07:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236466AbiG1LiB (ORCPT ); Thu, 28 Jul 2022 07:38:01 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C89AB52DC8 for ; Thu, 28 Jul 2022 04:37:59 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id w18so1679810lje.1 for ; Thu, 28 Jul 2022 04:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RVi3swbk6lGpU9EJQbU7r2ZRE/KO3o6omSpmuiZtsWw=; b=w1W/Ury8HO4KqOu7zRw6RW6avw1X0Mx7lp+AFM5+L8gNxOjYQrRGluYLjYinO4VTqr csFHyvPdXVlO7fTCGdJATOWpP6feg8Q2vO4EH8iKbG5MMGFH8x+3kWUNn8ZSur9Ty9bu ynZ6X51TqcsJq8MUM9lntwu6UBmSPUeWyIkNP/FHwfkcwtfn7gTY6qv5ayIEhcJJybGy QJLljsCOunRvpMwHvjwjeVhEFxViZ/j8LA3eKF2OKCdNMni5k71uuXxl9J0dhbSlGPGQ sLZjRC6fEAi6u8yV7lRviEE5x/gwau7etD1JTagzZ1GAN0wXTefghUIm26pnMAvXI6Oc 6igg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RVi3swbk6lGpU9EJQbU7r2ZRE/KO3o6omSpmuiZtsWw=; b=lZZQctwMDoNMu1Kh8rdL+w+y9VI5A/pv6mpuaIvr1BLA3Qpj75fcWQDhYQPn/rxBwf sAB1y+Zb3ySeAxGtFzl7soa0kuUmeLwH6z5OPYBTGYjK9CYcsU4LlPpT3VpKi3ORrWHp tIGPGAsXHekgGd16jBhmIRP3XIfLVKQvdqzirHYpglRTWcx+Krse9WOLRQ8NptVSzwdf 1BcIp5+4v122iAbTH/0zdXiWSXXPN++UgJ0XeUzg3oUAyhuffTR40Sppqk7rY0lMTb1I GG4YLmhORQFCPJqtiB77jFUozKLg5hfFfNk2NOXjpCnBK10EgdnwWuq9d4mjyeUi1vj6 WtDA== X-Gm-Message-State: AJIora9gftJ2Nb4Xuo6ubvmNouk8QA4/3e13qlMscwHYKglYnB51EDMs F5Y/NYfrAKSvMnVPi89G4MWVWQ== X-Google-Smtp-Source: AGRyM1uJZtN6+fLM32G+sSz15AwD0OD2dt1jSpLQqVnJGNSEabBzgYbVhtYm5OMYCfSTeTGs3364Mg== X-Received: by 2002:a2e:98d6:0:b0:25e:c2e:a5dd with SMTP id s22-20020a2e98d6000000b0025e0c2ea5ddmr6067980ljj.455.1659008278139; Thu, 28 Jul 2022 04:37:58 -0700 (PDT) Received: from krzk-bin.lan (78-26-46-173.network.trollfjord.no. [78.26.46.173]) by smtp.gmail.com with ESMTPSA id l12-20020a2ea80c000000b0025e0396786dsm98192ljq.93.2022.07.28.04.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 04:37:57 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Konrad Dybcio , Georgi Djakov , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rajendra Nayak , Sibi Sankar Subject: [PATCH v2 04/11] soc: qcom: icc-bwmon: store reference to variant data in container Date: Thu, 28 Jul 2022 13:37:41 +0200 Message-Id: <20220728113748.170548-5-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> References: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Instead of copying pieces of variant-specific data (struct icc_bwmon_data) into the state container (struct icc_bwmon), just store a pointer to it. This simplifies a bit the code and allows later to grow easily the variant-specific data for new BWMON v5. Cc: Rajendra Nayak Cc: Sibi Sankar Signed-off-by: Krzysztof Kozlowski Reviewed-by: Sibi Sankar --- drivers/soc/qcom/icc-bwmon.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/soc/qcom/icc-bwmon.c b/drivers/soc/qcom/icc-bwmon.c index 9295ea04356a..a820855e85b4 100644 --- a/drivers/soc/qcom/icc-bwmon.c +++ b/drivers/soc/qcom/icc-bwmon.c @@ -117,11 +117,10 @@ struct icc_bwmon_data { struct icc_bwmon { struct device *dev; + const struct icc_bwmon_data *data; void __iomem *base; int irq; - unsigned int default_lowbw_kbps; - unsigned int sample_ms; unsigned int max_bw_kbps; unsigned int min_bw_kbps; unsigned int target_kbps; @@ -198,20 +197,20 @@ static void bwmon_set_threshold(struct icc_bwmon *bwmon, unsigned int reg, { unsigned int thres; - thres = mult_frac(bwmon_kbps_to_count(kbps), bwmon->sample_ms, + thres = mult_frac(bwmon_kbps_to_count(kbps), bwmon->data->sample_ms, MSEC_PER_SEC); writel_relaxed(thres, bwmon->base + reg); } -static void bwmon_start(struct icc_bwmon *bwmon, - const struct icc_bwmon_data *data) +static void bwmon_start(struct icc_bwmon *bwmon) { + const struct icc_bwmon_data *data = bwmon->data; unsigned int thres_count; int window; bwmon_clear_counters(bwmon); - window = mult_frac(bwmon->sample_ms, HW_TIMER_HZ, MSEC_PER_SEC); + window = mult_frac(bwmon->data->sample_ms, HW_TIMER_HZ, MSEC_PER_SEC); /* Maximum sampling window: 0xfffff */ writel_relaxed(window, bwmon->base + BWMON_SAMPLE_WINDOW); @@ -266,7 +265,7 @@ static irqreturn_t bwmon_intr(int irq, void *dev_id) */ max = readl(bwmon->base + BWMON_ZONE_MAX(zone)) + 1; max *= BWMON_COUNT_UNIT_KB; - bwmon->target_kbps = mult_frac(max, MSEC_PER_SEC, bwmon->sample_ms); + bwmon->target_kbps = mult_frac(max, MSEC_PER_SEC, bwmon->data->sample_ms); return IRQ_WAKE_THREAD; } @@ -328,14 +327,13 @@ static int bwmon_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct dev_pm_opp *opp; struct icc_bwmon *bwmon; - const struct icc_bwmon_data *data; int ret; bwmon = devm_kzalloc(dev, sizeof(*bwmon), GFP_KERNEL); if (!bwmon) return -ENOMEM; - data = of_device_get_match_data(dev); + bwmon->data = of_device_get_match_data(dev); bwmon->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(bwmon->base)) { @@ -363,8 +361,6 @@ static int bwmon_probe(struct platform_device *pdev) if (IS_ERR(opp)) return dev_err_probe(dev, ret, "failed to find min peak bandwidth\n"); - bwmon->sample_ms = data->sample_ms; - bwmon->default_lowbw_kbps = data->default_lowbw_kbps; bwmon->dev = dev; bwmon_disable(bwmon); @@ -375,7 +371,7 @@ static int bwmon_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "failed to request IRQ\n"); platform_set_drvdata(pdev, bwmon); - bwmon_start(bwmon, data); + bwmon_start(bwmon); return 0; } From patchwork Thu Jul 28 11:37:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 594275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7E55C04A68 for ; Thu, 28 Jul 2022 11:38:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236520AbiG1LiX (ORCPT ); Thu, 28 Jul 2022 07:38:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236715AbiG1LiL (ORCPT ); Thu, 28 Jul 2022 07:38:11 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 069DF61D77 for ; Thu, 28 Jul 2022 04:38:03 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id w18so1679915lje.1 for ; Thu, 28 Jul 2022 04:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4E4ZpRRBiSt4prWSjtt/tlG1ntxY2YUOQqTaH587sJs=; b=oUjIFxePcHOen0XvNvUfTXgAyNgPx04xpNN5Zu8/447lUmblII0dpR9lMM3ZGbjHjB onuLFC1nKHHJlzFsTmpRzfKcU2WjShuGVmAFsiP/Xd0RVkswfOUM9+mkxd8Ar7qaM9KQ RnJyj4aMGPCQh3p8dI24t0CVPDJO+W0qYiom9Wd4qj0PK/ClmHup/06fE+0igItcE+ng NlIXCKcTWoXWLKz9b6O0QfXBN1Wi+f3izBxx9s6wPcyUTdP2rZWFvwfIkBMLeoqaXRlJ A56HBtX4NYreNDxPK90mBVMgmAlXZy8JoIfp6cph56RSvPOzQ68avWke3uY+9NdyhHI2 HD3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4E4ZpRRBiSt4prWSjtt/tlG1ntxY2YUOQqTaH587sJs=; b=bl1UPS9MK8iPCSoQbP/X2k5svD1uk/VM5eUScC/DusZMljD6Wm45yVaKA/V2UOvrsJ HN9DcfwJg5aS11Q+HHNnhU1wLf1ywG0e9QbvAk+2fTz9DVlIWdTSGuZt6p5WnFIcVc0l 5MnMco7ATfSkEPNP9fz3X2yQqgn0E3oxiUnq/mh5Y2S5p2C7QRonxABmDowN7leXIizT ZlgMA/MzSAi7NOGFcjFxZZo/TsdvTn4o/SnBEYPU65uUUJTb/ifn5qfyE0JSEJEDOXDj H6bPgOyamHI1B9uRzGUJO1nJiM7euHsP8+uMjE3gvvyAd7tQaJLbgj622ggdrDIG751C Lwqw== X-Gm-Message-State: AJIora/LHFd1pUO3B+UvQ3m8W0wWyh71thhm8Ej2DLt7hA38VJ1Kgyy5 4HYtk9bQTFXz1DKy2/dKXfNjHA== X-Google-Smtp-Source: AGRyM1uiCsF2TKehRmM8girZmFexYc7sCS4vIAS3JTbG+VrAcScxFzqVRIC3/APBu/7f5gLiBPzUkw== X-Received: by 2002:a2e:5746:0:b0:25e:2da3:e244 with SMTP id r6-20020a2e5746000000b0025e2da3e244mr760737ljd.297.1659008281258; Thu, 28 Jul 2022 04:38:01 -0700 (PDT) Received: from krzk-bin.lan (78-26-46-173.network.trollfjord.no. [78.26.46.173]) by smtp.gmail.com with ESMTPSA id l12-20020a2ea80c000000b0025e0396786dsm98192ljq.93.2022.07.28.04.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 04:38:00 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Konrad Dybcio , Georgi Djakov , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rajendra Nayak , Sibi Sankar Subject: [PATCH v2 06/11] soc: qcom: icc-bwmon: store count unit per variant Date: Thu, 28 Jul 2022 13:37:43 +0200 Message-Id: <20220728113748.170548-7-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> References: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Versions v4 and v5 of BWMON on SDM845 use different unit count, so allow easier variant customization by storing its value in struct icc_bwmon_data. Cc: Rajendra Nayak Cc: Sibi Sankar Signed-off-by: Krzysztof Kozlowski Reviewed-by: Sibi Sankar --- drivers/soc/qcom/icc-bwmon.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/soc/qcom/icc-bwmon.c b/drivers/soc/qcom/icc-bwmon.c index d2df8feff651..7fd0e41c63e6 100644 --- a/drivers/soc/qcom/icc-bwmon.c +++ b/drivers/soc/qcom/icc-bwmon.c @@ -103,12 +103,11 @@ #define BWMON_THRESHOLD_COUNT_ZONE0_DEFAULT 0xff #define BWMON_THRESHOLD_COUNT_ZONE2_DEFAULT 0xff -/* BWMONv4 count registers use count unit of 64 kB */ -#define BWMON_COUNT_UNIT_KB 64 #define BWMON_ZONE_MAX(zone) (0x2e0 + 4 * (zone)) struct icc_bwmon_data { unsigned int sample_ms; + unsigned int count_unit_kb; /* kbytes */ unsigned int default_highbw_kbps; unsigned int default_medbw_kbps; unsigned int default_lowbw_kbps; @@ -192,9 +191,10 @@ static void bwmon_enable(struct icc_bwmon *bwmon, unsigned int irq_enable) writel(BWMON_ENABLE_ENABLE, bwmon->base + BWMON_ENABLE); } -static unsigned int bwmon_kbps_to_count(unsigned int kbps) +static unsigned int bwmon_kbps_to_count(struct icc_bwmon *bwmon, + unsigned int kbps) { - return kbps / BWMON_COUNT_UNIT_KB; + return kbps / bwmon->data->count_unit_kb; } static void bwmon_set_threshold(struct icc_bwmon *bwmon, unsigned int reg, @@ -202,8 +202,8 @@ static void bwmon_set_threshold(struct icc_bwmon *bwmon, unsigned int reg, { unsigned int thres; - thres = mult_frac(bwmon_kbps_to_count(kbps), bwmon->data->sample_ms, - MSEC_PER_SEC); + thres = mult_frac(bwmon_kbps_to_count(bwmon, kbps), + bwmon->data->sample_ms, MSEC_PER_SEC); writel_relaxed(thres, bwmon->base + reg); } @@ -269,7 +269,7 @@ static irqreturn_t bwmon_intr(int irq, void *dev_id) * downstream) always increments the max bytes count by one. */ max = readl(bwmon->base + BWMON_ZONE_MAX(zone)) + 1; - max *= BWMON_COUNT_UNIT_KB; + max *= bwmon->data->count_unit_kb; bwmon->target_kbps = mult_frac(max, MSEC_PER_SEC, bwmon->data->sample_ms); return IRQ_WAKE_THREAD; @@ -393,6 +393,7 @@ static int bwmon_remove(struct platform_device *pdev) /* BWMON v4 */ static const struct icc_bwmon_data msm8998_bwmon_data = { .sample_ms = 4, + .count_unit_kb = 64, .default_highbw_kbps = 4800 * 1024, /* 4.8 GBps */ .default_medbw_kbps = 512 * 1024, /* 512 MBps */ .default_lowbw_kbps = 0, From patchwork Thu Jul 28 11:37:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 594274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2114EC19F29 for ; Thu, 28 Jul 2022 11:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237267AbiG1Lii (ORCPT ); Thu, 28 Jul 2022 07:38:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236921AbiG1LiZ (ORCPT ); Thu, 28 Jul 2022 07:38:25 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E4A061131 for ; Thu, 28 Jul 2022 04:38:06 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id w15so2392652lft.11 for ; Thu, 28 Jul 2022 04:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9vUNSXhigYPL6YxGm2dwwRSYcJw5sLrH/ALUNKD6VII=; b=XOJMgXpybulWrGv5BYGON9YiSnqxYrtIhsPEE+fdCvYm4cnp9bW1DaJLQ28XQgv4ni EZk+yYNnqO5zKpqfWWXOALRzrf3oUbkeLn0tbg5/CZ9zZISzsGjwgvIzFd8SBLDWWFTX nIp3ZdQqWOQDptA/nD+d7UzCtI0IODyRcLUw5qEnMZTNWA1zzFGT8xFQqvXtqdvpxL9c A5kwEiE2hC1Y2l0TDjnzAlmRinEWBOef8+x5pcpSsZXfEOXS3buN/LhBsMUMbe8JnqRO lZvqUe3A03W8cUTUjAEXApqkBZ9al4aMPKVYqRYZGunHGwnwBvPWuGzL4GX27NT6I0xm BRcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9vUNSXhigYPL6YxGm2dwwRSYcJw5sLrH/ALUNKD6VII=; b=NrBUd1/8m5tC7q+e3Kbs1moVXC7fqVFjUuYLPJ+0+vCzL0hSnCk4Alioeyg3Llu7vR jRUGunY7soNvWbKVgCpOw9DSTlgfUeXjVRfxLWTM6TvEpocU1NViwUEIRZ5slPBT36l8 RXNQuKgK3wn+CuPqlcugRYfqes+N/RC9aaCM6izGuShzFJXUNTGB/2RDLmS9dKAc2bPz OUekApIPq440Q3NQF+yKam022Ch46d4+wWxdnBG/zanrIR+IAiRHH1d2qvL0DANLRfiM o7SWL/veCLiFSayaQylnu0pjhLZqbM1UjhncYHAw8MKzw26olbdYnwc0j7CuRdMn49Gu AkUg== X-Gm-Message-State: AJIora90Dva36RKevAxvGPnOklfuAunPfjJPcWG5El7anMHQepvMQ8dz e/GfUZB4GXLx++YLpeYjgJRBXg== X-Google-Smtp-Source: AGRyM1u4l5FrUVJW7COD2loUiZSWMDYea21EE9UTvzVI/D3j6i15Fo5HjsfTJdQqoa5lYZPE+dOlfg== X-Received: by 2002:ac2:484c:0:b0:48a:7a62:6dd3 with SMTP id 12-20020ac2484c000000b0048a7a626dd3mr10869205lfy.455.1659008284090; Thu, 28 Jul 2022 04:38:04 -0700 (PDT) Received: from krzk-bin.lan (78-26-46-173.network.trollfjord.no. [78.26.46.173]) by smtp.gmail.com with ESMTPSA id l12-20020a2ea80c000000b0025e0396786dsm98192ljq.93.2022.07.28.04.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 04:38:03 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Konrad Dybcio , Georgi Djakov , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rajendra Nayak , Sibi Sankar Subject: [PATCH v2 08/11] soc: qcom: icc-bwmon: add per-variant quirks Date: Thu, 28 Jul 2022 13:37:45 +0200 Message-Id: <20220728113748.170548-9-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> References: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org BWMON v5 lacks global interrupt registers. Other BWMON versions differ as well, so add quirks for easier customization of code flow. Cc: Rajendra Nayak Cc: Sibi Sankar Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/icc-bwmon.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/soc/qcom/icc-bwmon.c b/drivers/soc/qcom/icc-bwmon.c index 058c35d8dbbe..2e4a0fdfbf54 100644 --- a/drivers/soc/qcom/icc-bwmon.c +++ b/drivers/soc/qcom/icc-bwmon.c @@ -100,6 +100,9 @@ #define BWMON_V4_ZONE_MAX(zone) (0x2e0 + 4 * (zone)) +/* Quirks for specific BWMON types */ +#define BWMON_HAS_GLOBAL_IRQ BIT(0) + enum bwmon_fields { F_GLOBAL_IRQ_CLEAR, F_GLOBAL_IRQ_ENABLE, @@ -136,6 +139,7 @@ struct icc_bwmon_data { unsigned int default_lowbw_kbps; u8 zone1_thres_count; u8 zone3_thres_count; + unsigned int quirks; const struct regmap_config *regmap_cfg; const struct reg_field *regmap_fields; @@ -270,14 +274,16 @@ static void bwmon_clear_irq(struct icc_bwmon *bwmon) * interrupt is cleared. */ regmap_field_force_write(bwmon->regs[F_IRQ_CLEAR], BWMON_IRQ_ENABLE_MASK); - regmap_field_force_write(bwmon->regs[F_GLOBAL_IRQ_CLEAR], - BWMON_V4_GLOBAL_IRQ_ENABLE_ENABLE); + if (bwmon->data->quirks & BWMON_HAS_GLOBAL_IRQ) + regmap_field_force_write(bwmon->regs[F_GLOBAL_IRQ_CLEAR], + BWMON_V4_GLOBAL_IRQ_ENABLE_ENABLE); } static void bwmon_disable(struct icc_bwmon *bwmon) { /* Disable interrupts. Strict ordering, see bwmon_clear_irq(). */ - regmap_field_write(bwmon->regs[F_GLOBAL_IRQ_ENABLE], 0x0); + if (bwmon->data->quirks & BWMON_HAS_GLOBAL_IRQ) + regmap_field_write(bwmon->regs[F_GLOBAL_IRQ_ENABLE], 0x0); regmap_field_write(bwmon->regs[F_IRQ_ENABLE], 0x0); /* @@ -290,8 +296,9 @@ static void bwmon_disable(struct icc_bwmon *bwmon) static void bwmon_enable(struct icc_bwmon *bwmon, unsigned int irq_enable) { /* Enable interrupts */ - regmap_field_write(bwmon->regs[F_GLOBAL_IRQ_ENABLE], - BWMON_V4_GLOBAL_IRQ_ENABLE_ENABLE); + if (bwmon->data->quirks & BWMON_HAS_GLOBAL_IRQ) + regmap_field_write(bwmon->regs[F_GLOBAL_IRQ_ENABLE], + BWMON_V4_GLOBAL_IRQ_ENABLE_ENABLE); regmap_field_write(bwmon->regs[F_IRQ_ENABLE], irq_enable); /* Enable bwmon */ @@ -543,6 +550,7 @@ static const struct icc_bwmon_data msm8998_bwmon_data = { .default_lowbw_kbps = 0, .zone1_thres_count = 16, .zone3_thres_count = 1, + .quirks = BWMON_HAS_GLOBAL_IRQ, .regmap_fields = msm8998_bwmon_reg_fields, .regmap_cfg = &msm8998_bwmon_regmap_cfg, }; From patchwork Thu Jul 28 11:37:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 594273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A777C04A68 for ; Thu, 28 Jul 2022 11:38:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236733AbiG1Lis (ORCPT ); Thu, 28 Jul 2022 07:38:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237017AbiG1Li1 (ORCPT ); Thu, 28 Jul 2022 07:38:27 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 194FB68DD4 for ; Thu, 28 Jul 2022 04:38:09 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id bf9so2386056lfb.13 for ; Thu, 28 Jul 2022 04:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7WcyHHWIuXa8VBPBmhioGhUQ+Xl6g95Mz+t9tkKTCEE=; b=XXikpq4I/jW+AumV70eTCCV2Ptd5SsO9qHv6A7iZSY642uz4UUiHeNoXa2gawDIUzJ 31q4HvbJggh03XUgtkoOORHYaMw5CegBW2yHLsebrPvU59gkc04uQvLo/v9nWVCdvAVw 2I0v6Edzo0kV21nMh7FtpRmgxbLpEfoTzMo5sszqzaNCHdaGyOzMGZmXL568hxAiprDO M6LSNypKapgJOB1T9DhDQwfRCF/9jJDtedl1ySmgHTlE9tp1XNv7V4q8BEe9EfPV5l4W TtLTMnCS20lad85a827ns0XsxqvvsDPEf1dlbSewP4WHtiuHNyYz0pH4vQvpZgT+Bthj uvtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7WcyHHWIuXa8VBPBmhioGhUQ+Xl6g95Mz+t9tkKTCEE=; b=CXY33Hh9C88ArXaaJTbFbWkqRCZFBmBq8r5r5nyyw319p/h+4Bsjs9lupw3BHcxvpw bgimDWVdHx+Q7gzBb5R3xk4p2fVxOAHI/kOX+a/GGNbv861TutNqaEqabWEr6agfA67X 70kmn0F9/WQIbj3qQ4Xo1LvgGwSXubJNBE6OlO5vLGDumm0l9BiV3HbuXAa9osJWI1L7 teZ4Eph7hIV3V2gpccuTHT88GAbPXP8x9f4MFf9ZEXvkSV+5v+wVliLuDX+Uy5PbJkjI YaAW9ew48tSNNssXCzzoi4bPcGgro57bxouaJY2j2ELeUX1bASqaEe7dx0LSTp65ml1E U9Vg== X-Gm-Message-State: AJIora+SrKKTfoxzNbUlJ/dIvrN3hfi4a0NzVd+fX+xWtDl9qzrs1jbY puzuNa5uSNNndIWqafxjDjz7n99XuEhYPg== X-Google-Smtp-Source: AGRyM1uJfu0P2CdKUsT7ENojpTOjhC0cbukQWp9qJUtVrhWH1EkfyW9GtqdTSI08jIL1v+KwbDuvLw== X-Received: by 2002:a05:6512:3d19:b0:48a:7d10:b972 with SMTP id d25-20020a0565123d1900b0048a7d10b972mr9786396lfv.615.1659008286924; Thu, 28 Jul 2022 04:38:06 -0700 (PDT) Received: from krzk-bin.lan (78-26-46-173.network.trollfjord.no. [78.26.46.173]) by smtp.gmail.com with ESMTPSA id l12-20020a2ea80c000000b0025e0396786dsm98192ljq.93.2022.07.28.04.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 04:38:06 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Konrad Dybcio , Georgi Djakov , Rob Herring , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Rajendra Nayak , Sibi Sankar , Steev Klimaszewski Subject: [PATCH v2 10/11] arm64: dts: qcom: sdm845: narrow LLCC address space Date: Thu, 28 Jul 2022 13:37:47 +0200 Message-Id: <20220728113748.170548-11-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> References: <20220728113748.170548-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The Last Level Cache Controller (LLCC) device does not need to access entire LLCC address space. Currently driver uses only hardware info and status registers which both reside in LLCC0_COMMON range (offset 0x30000, size 0x1000). Narrow the address space to allow binding other drivers to rest of LLCC address space. Cc: Rajendra Nayak Cc: Sibi Sankar Reported-by: Steev Klimaszewski Suggested-by: Sibi Sankar Signed-off-by: Krzysztof Kozlowski --- arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi index fe14f7e7523b..e318c3f8aee0 100644 --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi @@ -2048,7 +2048,7 @@ uart15: serial@a9c000 { llcc: system-cache-controller@1100000 { compatible = "qcom,sdm845-llcc"; - reg = <0 0x01100000 0 0x200000>, <0 0x01300000 0 0x50000>; + reg = <0 0x01100000 0 0x31000>, <0 0x01300000 0 0x50000>; reg-names = "llcc_base", "llcc_broadcast_base"; interrupts = ; };