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: 168523 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3354996ilk; Fri, 5 Jul 2019 02:58:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0TYrigZZoKcep4PA3il7Gpiq+MGZdXTCz8wZBn9uko2r5+wJ8YSgZFCreBFnsjgaZ8dpC X-Received: by 2002:a17:902:bd94:: with SMTP id q20mr4354119pls.307.1562320705248; Fri, 05 Jul 2019 02:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562320705; cv=none; d=google.com; s=arc-20160816; b=auwPosAS6LGZDTL2NbeTD3IYoiqeM/duo906m2karQUT3aH7m3+OJtauQL/vQuh4Yi 9jB4wj6ihaE9sthVG2IcuEjMs8Q4IvkOev/f/hjlMFoBR3uDknalmSOYTRzwv94DhLBZ WZciaGwJaTwckwqZro0JosTvSYH3fkl8XPqkOiwFYLTphFJzlcN3VI+y25Lhmy1D4H1T IQqDKA29aiUdDxvs4cAjLNqgDi3AnCLjLmZMGY6pDwoZqB96jD52xSXqmFc6noD96xWr vk8Ol2TfpCboMCqMrf/wRfNFBVSSJIktJHK5mU8s4Q24prXI9JXiz/NdH0OG7viIQF0h C5hw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u8/u3bwXkZOSy6eu5Z2KZv4GqIpK73hvpV5W7nEAtr8=; b=PhMOD8GcFclmHciH9cj55l+wrfcf/iINcfg30VE7V+PEo1mf0Gc7vU6pnsY0h9njUR 5VsiTCiuSGaJZjxzhTj0i8nhlJ5/zXbnVip+UnBDDj+s5s/zoYiHlkhp5ycfoxNbAyNR BqHnt2Wm/8x36lGgthnxh9O5Ifi7fYzi2ULzn7mTozuET726Bkia9zerebrn6xhafZWP caEIUEOZMF23yZWJA4J++L9UtALUfSW5Y6QPWTRQEMiJQcb0Ja6zz+qqBxSLZglc5nOq tGOLtWv+zGEuLVzZX38+Tjj7njqTmAJBQMBBr/3B5RFwanuPW7JOKQltWSCFb/HiEWhE jq9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zwiyMKjl; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si8464146plb.177.2019.07.05.02.58.25; Fri, 05 Jul 2019 02:58:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b=zwiyMKjl; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728494AbfGEJ6Y (ORCPT + 15 others); 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-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 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(-) -- 2.21.0 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 }, {}, };