From patchwork Fri Jul 5 09:57:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 11032311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7879813B1 for ; Fri, 5 Jul 2019 09:58:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66A4528A82 for ; Fri, 5 Jul 2019 09:58:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5958828A8C; Fri, 5 Jul 2019 09:58:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9CEC28A82 for ; Fri, 5 Jul 2019 09:58:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728494AbfGEJ6Y (ORCPT ); Fri, 5 Jul 2019 05:58:24 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:43567 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbfGEJ6X (ORCPT ); Fri, 5 Jul 2019 05:58:23 -0400 Received: by mail-lj1-f194.google.com with SMTP id 16so8654193ljv.10 for ; Fri, 05 Jul 2019 02:58:22 -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=u8/u3bwXkZOSy6eu5Z2KZv4GqIpK73hvpV5W7nEAtr8=; b=zwiyMKjlZMwH8lIXSWo0y8pv7/y9FQ3ndFZlbQXwbt2CgMSHLw59lKvqVT5NLf4Nue //0Xa5ov/+9HP2LeL3DPtc8TMao2ZsZU+fxiged59/1r6aTSaGy+NF2Bs/1gEyVbf7bs vCPqrxOoV4We3Q+XOhXrP3ruQzV8RmCvrpSHDFv88QY/PONG5zkyfMoY5RA/pLf1D5wa wHp5u5FTVwS2mUNLe6EOXxKsNu+5Ygl0EqAmqX3XLmTETdYgAoicSB16q+PDOviJf2hO 3XF+0rQrWpr7pHNDf140WQa/6WZixjxUexnMSKz7XcYmZ49Hos0OfneEwVNijyENt8dB ou4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u8/u3bwXkZOSy6eu5Z2KZv4GqIpK73hvpV5W7nEAtr8=; b=nH7Q4mB06aE5MTVzACc0xWIR6+mLRm0hgYn1B/8TTTSZGShJ18G6Ki6MdHe2apCxY/ EQRmQPBYN3ybbDEBtTIsz4GW7RtQjteqlWsLUf+aMGBj7+/S7VxyUESfn0GHxydvKgrO RZsAmWAutTt6cTFrQI2O1xiaJj+G6JCO8sUl+C+Z5aFukbErgUqx1zXXOskM+pWNq7yi 90R09olPSh1ebnP++j+AFPSpVilbt0s2YxCZD1SE7sMaW2gJBBL7WMRyUdULY+ZYXXm+ UI5bFIEzo2Aa/Qlg60FcajX97D7Lqhxe3HaQPniEtxLcGww9kZaPXkj/hWVU7JIeINdH 0v3A== X-Gm-Message-State: APjAAAVjWtIOKFCuRkdD9gdY/UBSrX3kB/LvywQSzCUzB6jD4yUKFm51 d1oo8nlIzxK1GJBYeDsGL1DP6nz3pmQ= X-Google-Smtp-Source: APXvYqy9qyxO4byetmUOuxjcwJQ/AdDI4S8b8jwDDftgCLI9lrDWCz0l5rilbiAT1LRClw/eDjpHmg== X-Received: by 2002:a2e:1290:: with SMTP id 16mr1601420ljs.88.1562320701743; Fri, 05 Jul 2019 02:58:21 -0700 (PDT) Received: from localhost.localdomain (ua-83-226-34-119.bbcust.telenor.se. [83.226.34.119]) by smtp.gmail.com with ESMTPSA id o24sm1674955ljg.6.2019.07.05.02.58.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 02:58:21 -0700 (PDT) From: Niklas Cassel To: Andy Gross , Ilia Lin , "Rafael J. Wysocki" , Viresh Kumar Cc: linux-arm-msm@vger.kernel.org, jorge.ramirez-ortiz@linaro.org, sboyd@kernel.org, vireshk@kernel.org, bjorn.andersson@linaro.org, ulf.hansson@linaro.org, Niklas Cassel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/13] cpufreq: qcom: Add support for qcs404 on nvmem driver Date: Fri, 5 Jul 2019 11:57:17 +0200 Message-Id: <20190705095726.21433-7-niklas.cassel@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190705095726.21433-1-niklas.cassel@linaro.org> References: <20190705095726.21433-1-niklas.cassel@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for qcs404 on nvmem driver. The qcs404 SoC has support for Core Power Reduction (CPR), which is implemented as a power domain provider, therefore add optional support in this driver to attach to a genpd power domain. Co-developed-by: Jorge Ramirez-Ortiz Signed-off-by: Jorge Ramirez-Ortiz Signed-off-by: Niklas Cassel --- Changes since RFC: -Remove empty stub. -Add power domain attach as a feature in the match_data struct. -Failing to attach to the power domain is treated as a hard error. drivers/cpufreq/qcom-cpufreq-nvmem.c | 49 ++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c index c0377b0eb2f4..ec87c14b598c 100644 --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -49,10 +50,12 @@ struct qcom_cpufreq_match_data { int (*get_version)(struct device *cpu_dev, struct nvmem_cell *speedbin_nvmem, struct qcom_cpufreq_drv *drv); + const char **genpd_names; }; struct qcom_cpufreq_drv { struct opp_table **opp_tables; + struct opp_table **genpd_opp_tables; u32 versions; const struct qcom_cpufreq_match_data *data; }; @@ -126,6 +129,12 @@ static const struct qcom_cpufreq_match_data match_data_kryo = { .get_version = qcom_cpufreq_kryo_name_version, }; +static const char *qcs404_genpd_names[] = { "cpr", NULL }; + +static const struct qcom_cpufreq_match_data match_data_qcs404 = { + .genpd_names = qcs404_genpd_names, +}; + static int qcom_cpufreq_probe(struct platform_device *pdev) { struct qcom_cpufreq_drv *drv; @@ -188,11 +197,19 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) goto free_drv; } + drv->genpd_opp_tables = kcalloc(num_possible_cpus(), + sizeof(*drv->genpd_opp_tables), + GFP_KERNEL); + if (!drv->genpd_opp_tables) { + ret = -ENOMEM; + goto free_opp; + } + for_each_possible_cpu(cpu) { cpu_dev = get_cpu_device(cpu); if (NULL == cpu_dev) { ret = -ENODEV; - goto free_opp; + goto free_genpd_opp; } if (drv->data->get_version) { @@ -203,7 +220,21 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) ret = PTR_ERR(drv->opp_tables[cpu]); dev_err(cpu_dev, "Failed to set supported hardware\n"); - goto free_opp; + goto free_genpd_opp; + } + } + + if (drv->data->genpd_names) { + drv->genpd_opp_tables[cpu] = + dev_pm_opp_attach_genpd(cpu_dev, + drv->data->genpd_names); + if (IS_ERR(drv->genpd_opp_tables[cpu])) { + ret = PTR_ERR(drv->genpd_opp_tables[cpu]); + if (ret != -EPROBE_DEFER) + dev_err(cpu_dev, + "Could not attach to pm_domain: %d\n", + ret); + goto free_genpd_opp; } } } @@ -218,6 +249,13 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) ret = PTR_ERR(cpufreq_dt_pdev); dev_err(cpu_dev, "Failed to register platform device\n"); +free_genpd_opp: + for_each_possible_cpu(cpu) { + if (IS_ERR_OR_NULL(drv->genpd_opp_tables[cpu])) + break; + dev_pm_opp_detach_genpd(drv->genpd_opp_tables[cpu]); + } + kfree(drv->genpd_opp_tables); free_opp: for_each_possible_cpu(cpu) { if (IS_ERR_OR_NULL(drv->opp_tables[cpu])) @@ -238,11 +276,15 @@ static int qcom_cpufreq_remove(struct platform_device *pdev) platform_device_unregister(cpufreq_dt_pdev); - for_each_possible_cpu(cpu) + for_each_possible_cpu(cpu) { if (drv->opp_tables[cpu]) dev_pm_opp_put_supported_hw(drv->opp_tables[cpu]); + if (drv->genpd_opp_tables[cpu]) + dev_pm_opp_detach_genpd(drv->genpd_opp_tables[cpu]); + } kfree(drv->opp_tables); + kfree(drv->genpd_opp_tables); kfree(drv); return 0; @@ -259,6 +301,7 @@ static struct platform_driver qcom_cpufreq_driver = { static const struct of_device_id qcom_cpufreq_match_list[] __initconst = { { .compatible = "qcom,apq8096", .data = &match_data_kryo }, { .compatible = "qcom,msm8996", .data = &match_data_kryo }, + { .compatible = "qcom,qcs404", .data = &match_data_qcs404 }, {}, };