From patchwork Wed Mar 6 17:47:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 159759 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp6449083jad; Wed, 6 Mar 2019 09:47:20 -0800 (PST) X-Google-Smtp-Source: APXvYqzR3z/B7Vne52q1zpwZFrfnbVRKdnRi2rYeU+l/g218ebyfIDf1C5xh0b9VBb1qHBccCIJw X-Received: by 2002:a17:902:778c:: with SMTP id o12mr8279933pll.112.1551894440279; Wed, 06 Mar 2019 09:47:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551894440; cv=none; d=google.com; s=arc-20160816; b=WCl1VdAR1RXfxRjmVCnMfay1Zxo15lDhHmwvlFHx1AUhTIPJVbqu0PbVTGSh8GXhk4 guDd186o3r2Ww1w7K/QCN3hpEAB1S4hE+NbutnrykpsoKJQemYhAmG1ObLcKDRTT+XA7 ZwoQxkJWfNCXn1m6ljMOnZeHmAD6I/0XZ8fgORGg8ChutMpt3DR27ntBwvRdpsQhOcz5 MwNl/usCp5BiTBSE4tlazmYigdUthA8kOj6wXTFoWi5wU7YIZwsm1zpp4LHw+Z3e5cJB 9oHryBddXxrXAaWp7dv8aTHPUWoHhSKtbGpgSezuRzbCrmYs+LtkijJ4unTb7tsNuVTC 2J6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=mQqRiUcOBnf84owwha1uaK826K7g8AcK1SIu5pAC4cY=; b=In12qmlQMe3LjDNkcYDRX2KqnQUUd+Q8hZONDhjsAyGd+py9KcSvZ9JgkrdiV8/D0E stiil40Q06FOZv+FvAdyF0jSkvo4kPE1UyJBPFni0cLNMv7a0gNQlZNMKg3kQvl2voJU xTHEGDGLPr/fRd19sMw2BZTb0HJ/X4/ymZ9QgkoWZPyGjn5jxvUSEi+YLUWX8UM6TPNv 07HFJg3iREuxehNjfDtc8XLsPAK8PiX5pHiopbwiDfoF97iwwY9aAJDrNsAPfCUAx6QZ TXlV9pcOxw6f1d/q6shTNqluQO/dPTk1COwCMmvt3XuGXPh9ygH+DDR3cJrGvszpP1cr 2caQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yKRcvIa0; 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 u2si1932211pls.34.2019.03.06.09.47.20; Wed, 06 Mar 2019 09:47:20 -0800 (PST) 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=yKRcvIa0; 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 S1730536AbfCFRrR (ORCPT + 15 others); Wed, 6 Mar 2019 12:47:17 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38280 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730546AbfCFRrQ (ORCPT ); Wed, 6 Mar 2019 12:47:16 -0500 Received: by mail-pf1-f196.google.com with SMTP id n125so9180908pfn.5 for ; Wed, 06 Mar 2019 09:47:15 -0800 (PST) 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; bh=mQqRiUcOBnf84owwha1uaK826K7g8AcK1SIu5pAC4cY=; b=yKRcvIa0DkIaHDQxu1z4+ypdBKlq6eamk8w3W+jcg+s/8cpAdwFSARvx0egLS8JL9H CS5/NHTedguwCIt/3AZXEEz771qMkyNa9+v3m1OPfHKieGPNy6hu/mkB56br8ECcPCBG nZCD2YaZHUyT2m9TdqPwgtyaV4p/akJPn4w1OtEDmKs3JWjP+q94mz0DNHu8EliWVcqs 9IT/28u0wylN6Dg6CFlNW0GCyIujGYNWx5iA+AbYA/y3hML9THBqby78VVc0NNKnKcP7 nkzJzPfIzzUAeP2Fp4Jt7ZUEn1lKM3jBbBlDC7Ix5DMcCynV8uCGyMhwKzlCayCMvCEC oCuA== 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; bh=mQqRiUcOBnf84owwha1uaK826K7g8AcK1SIu5pAC4cY=; b=iPqPwKbETkOV/2ivh2VLiL3QWzUfF9otIM5kbf0T2O7gb9cu8WxrRuAvIBgPRwG4qy ZdPlJCOcFpLchboZ629z4HQPHHqkthc0cyJeu3NLI+IzGuCEgv1he33bwYz4snitSrcx amOaKA4kuESMi+iVZbI+NKeRCSgCRfCXoZrwSavdiPcgVJuaG2CtnS344QaJKlvMlxeI pjUpAgKkBuIAk58Yt8EEIZ3YeeYnqC1SLa43O1rBjkKNt9oBgG2Om6OCV1eXlOR5v22b HwZrlEp9DdHJCz0qAWXBAJH58SBmC3JeqoFqBgAKtyULZWodPs3iWgU1nXwOSvjaMh4y QHvQ== X-Gm-Message-State: APjAAAW07cdT1094ZZ3Eh6gTyfvxsVullw9Sv3priB9wnrh6NEMkWqZU TJRRJCGi8ZqL1qMNtpnQceuaQw== X-Received: by 2002:a62:20c9:: with SMTP id m70mr8297130pfj.118.1551894434669; Wed, 06 Mar 2019 09:47:14 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id h64sm4098293pfj.40.2019.03.06.09.47.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Mar 2019 09:47:14 -0800 (PST) From: Bjorn Andersson To: Michael Turquette , Stephen Boyd Cc: Andy Gross , David Brown , Rob Herring , Mark Rutland , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] clk: qcom: Add QCS404 TuringCC Date: Wed, 6 Mar 2019 09:47:58 -0800 Message-Id: <20190306174758.22462-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190306174758.22462-1-bjorn.andersson@linaro.org> References: <20190306174758.22462-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The Turing Clock Controller provides resources related to running the Turing subsystem. PM runtime is used to ensure that the associated AHB clock is ticking while the clock framework is accessing the registers in the Turing clock controller. Signed-off-by: Bjorn Andersson --- drivers/clk/qcom/Kconfig | 6 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/turingcc-qcs404.c | 170 +++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 drivers/clk/qcom/turingcc-qcs404.c -- 2.18.0 diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig index 1c04575c118f..18bdf34d5e64 100644 --- a/drivers/clk/qcom/Kconfig +++ b/drivers/clk/qcom/Kconfig @@ -243,6 +243,12 @@ config SDM_GCC_660 Say Y if you want to use peripheral devices such as UART, SPI, i2C, USB, UFS, SDDC, PCIe, etc. +config QCS_TURING_404 + tristate "QCS404 Turing Clock Controller" + help + Support for the Turing Clock Controller on QCS404, provides clocks + and resets for the Turing subsystem. + config SDM_GCC_845 tristate "SDM845 Global Clock Controller" select QCOM_GDSC diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile index ee8d0698e370..f0768fb1f037 100644 --- a/drivers/clk/qcom/Makefile +++ b/drivers/clk/qcom/Makefile @@ -42,6 +42,7 @@ obj-$(CONFIG_QCOM_CLK_RPM) += clk-rpm.o obj-$(CONFIG_QCOM_CLK_RPMH) += clk-rpmh.o obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o obj-$(CONFIG_QCS_GCC_404) += gcc-qcs404.o +obj-$(CONFIG_QCS_TURING_404) += turingcc-qcs404.o obj-$(CONFIG_SDM_CAMCC_845) += camcc-sdm845.o obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o obj-$(CONFIG_SDM_GCC_660) += gcc-sdm660.o diff --git a/drivers/clk/qcom/turingcc-qcs404.c b/drivers/clk/qcom/turingcc-qcs404.c new file mode 100644 index 000000000000..aa859e6ec9bd --- /dev/null +++ b/drivers/clk/qcom/turingcc-qcs404.c @@ -0,0 +1,170 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "clk-regmap.h" +#include "clk-branch.h" +#include "common.h" +#include "reset.h" + +static struct clk_branch turing_wrapper_aon_cbcr = { + .halt_reg = 0x5098, + .halt_check = BRANCH_HALT, + .clkr = { + .enable_reg = 0x5098, + .enable_mask = BIT(0), + .hw.init = &(struct clk_init_data) { + .name = "turing_wrapper_aon_clk", + .ops = &clk_branch2_aon_ops, + }, + }, +}; + +static struct clk_branch turing_q6ss_ahbm_aon_cbcr = { + .halt_reg = 0x9000, + .halt_check = BRANCH_HALT, + .clkr = { + .enable_reg = 0x9000, + .enable_mask = BIT(0), + .hw.init = &(struct clk_init_data) { + .name = "turing_q6ss_ahbm_aon_cbcr", + .ops = &clk_branch2_ops, + }, + }, +}; + +static struct clk_branch turing_q6ss_q6_axim_clk = { + .halt_reg = 0xb000, + .halt_check = BRANCH_HALT, + .clkr = { + .enable_reg = 0xb000, + .enable_mask = BIT(0), + .hw.init = &(struct clk_init_data) { + .name = "turing_q6ss_q6_axim_clk", + .ops = &clk_branch2_aon_ops, + }, + }, +}; + +static struct clk_branch turing_q6ss_ahbs_aon_cbcr = { + .halt_reg = 0x10000, + .halt_check = BRANCH_HALT, + .clkr = { + .enable_reg = 0x10000, + .enable_mask = BIT(0), + .hw.init = &(struct clk_init_data) { + .name = "turing_q6ss_ahbs_aon_clk", + .ops = &clk_branch2_aon_ops, + }, + }, +}; + +static struct clk_branch turing_wrapper_qos_ahbs_aon_cbcr = { + .halt_reg = 0x11014, + .halt_check = BRANCH_HALT, + .clkr = { + .enable_reg = 0x11014, + .enable_mask = BIT(0), + .hw.init = &(struct clk_init_data) { + .name = "turing_wrapper_qos_ahbs_aon_clk", + .ops = &clk_branch2_aon_ops, + }, + }, +}; + +static struct clk_regmap *turingcc_clocks[] = { + [TURING_WRAPPER_AON_CLK] = &turing_wrapper_aon_cbcr.clkr, + [TURING_Q6SS_AHBM_AON_CLK] = &turing_q6ss_ahbm_aon_cbcr.clkr, + [TURING_Q6SS_Q6_AXIM_CLK] = &turing_q6ss_q6_axim_clk.clkr, + [TURING_Q6SS_AHBS_AON_CLK] = &turing_q6ss_ahbs_aon_cbcr.clkr, + [TURING_WRAPPER_QOS_AHBS_AON_CLK] = &turing_wrapper_qos_ahbs_aon_cbcr.clkr, +}; + +static const struct regmap_config turingcc_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = 0x30000, + .fast_io = true, +}; + +static const struct qcom_cc_desc turingcc_desc = { + .config = &turingcc_regmap_config, + .clks = turingcc_clocks, + .num_clks = ARRAY_SIZE(turingcc_clocks), +}; + +static int turingcc_probe(struct platform_device *pdev) +{ + int ret; + + pm_runtime_enable(&pdev->dev); + ret = pm_clk_create(&pdev->dev); + if (ret) + goto disable_pm_runtime; + + ret = pm_clk_add(&pdev->dev, NULL); + if (ret < 0) { + dev_err(&pdev->dev, "failed to acquire iface clock\n"); + goto destroy_pm_clk; + } + + ret = qcom_cc_probe(pdev, &turingcc_desc); + if (ret < 0) + goto destroy_pm_clk; + + return 0; + +destroy_pm_clk: + pm_clk_destroy(&pdev->dev); + +disable_pm_runtime: + pm_runtime_disable(&pdev->dev); + + return ret; +} + +static int turingcc_remove(struct platform_device *pdev) +{ + pm_clk_destroy(&pdev->dev); + pm_runtime_disable(&pdev->dev); + + return 0; +} + +static const struct dev_pm_ops turingcc_pm_ops = { + SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL) +}; + +static const struct of_device_id turingcc_match_table[] = { + { .compatible = "qcom,qcs404-turingcc" }, + { } +}; +MODULE_DEVICE_TABLE(of, turingcc_match_table); + +static struct platform_driver turingcc_driver = { + .probe = turingcc_probe, + .remove = turingcc_remove, + .driver = { + .name = "qcs404-turingcc", + .of_match_table = turingcc_match_table, + .pm = &turingcc_pm_ops, + }, +}; + +module_platform_driver(turingcc_driver); + +MODULE_DESCRIPTION("Qualcomm QCS404 Turing Clock Controller"); +MODULE_LICENSE("GPL v2");