From patchwork Thu Mar 15 14:37:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 131797 Delivered-To: patch@linaro.org Received: by 10.80.210.197 with SMTP id q5csp1561618edg; Thu, 15 Mar 2018 07:39:32 -0700 (PDT) X-Google-Smtp-Source: AG47ELsZaYoICpTqFqMUYujG2nI4B0HaFVNfwQzuaFakPL6UJvgSINY1IGQ7Q6tnInQ7JEdLSZhl X-Received: by 10.99.120.5 with SMTP id t5mr3572561pgc.30.1521124772661; Thu, 15 Mar 2018 07:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521124772; cv=none; d=google.com; s=arc-20160816; b=d9tCerLtFBC6uN3ywnGfaxu7/3SPFrnACS8Y83nXi7RbgO6mSbQXySfvQr5W1NmRP5 EAlA0a7M7YiZt1pR7wY46FDyc9pHMYZ5SO94pvekB6DPHF3a+S9jbsRMvyQKkpYTTUgU do1R0AoKNureayeLsMcRfmAtQc1N9v4uiTS1xhvezyMT2WPebbVhr6ryvR9hObW+uV5P 9hIRYqrgDOG2pBvNBeqEr17ALXaJZqhRQoQMxxJFqZ/lNNAyz+A4aONxQtSKG7+YGG1t G/yc63M7gEkZovvfYnmgQKZlYeMMqW0U71w/gsOS9NkhAbYdH/bEEQc9Yz31XYviAcID BnDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=XqKvYAV1l3j1KF/cF/1zT85Aeo+pflvllJQnTP2fJ30=; b=Ktx2FKcHaXKbpXUH3A8ZKB+hFQL+Myw9jUMlH8Mz45fzdzdR1WduDgs3LhaBjX84iF RwD1vjlsZJg07VufWvJwTDBahhMdn85iJG5sojvjrCamVJG2v2lB6nrRN7GYxYodJ3iy 8FJACIo0CCuhifAaFhZXBWSjBefIBlhAP+JbVMrWtGbZ2l1wrNuWc4l5gu+NA6bx4g8o aakSXAXoTIIuHJu8BY8FV6zzZajbaV3epl7hGiWwpQ8F6aXfh0sMX00KNx70HhUfxXpr Dr7VypUa5ivxSUG8uDFBfI7arWNmTI6ja707bdn3OsmQ4bTNbmyWclbikw/T8Gb3Shzc 3tUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fsOPh45C; 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=fail (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 f3si3481633pgn.787.2018.03.15.07.39.32; Thu, 15 Mar 2018 07:39:32 -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=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fsOPh45C; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932222AbeCOOjb (ORCPT + 10 others); Thu, 15 Mar 2018 10:39:31 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:42329 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752372AbeCOOj3 (ORCPT ); Thu, 15 Mar 2018 10:39:29 -0400 Received: by mail-wr0-f196.google.com with SMTP id s18so8504854wrg.9 for ; Thu, 15 Mar 2018 07:39:29 -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; bh=az1khOoVfM9KdmlSj5kGHSNsprnPyvi5HCdwaU16pkU=; b=fsOPh45C4hCByMT5jPssZrjazjItZtp7zNdjkKBUxrK9JZgSV2ZfFgnCNIK4/h1Ggc dqPo47Ky08LOYFOl2srzwbT5eaaFUKdYcC9zyZCHbBWM9s87DGDNj+P0Vx8rKU1RQGH2 Ilj119uaZC+HfxbJ3FIF1EuhOwCm8Iw5MSuzI= 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; bh=az1khOoVfM9KdmlSj5kGHSNsprnPyvi5HCdwaU16pkU=; b=H6XjSQp+BHnl2Hdqfp2DgCueS8ggGiuwaPFKwKSCZayk/YaRfvmWrRimJUi+ftEr+p CgggxxFO5ZbGSQzc2Xcf1xbyp6y48iS2Kc98Df0E75/WbzxbacesUCjW27Exbjow9PfA ZrB32iAz8ebLu7xDPq2Tk9UoWOWhTB36gyMJY/qNWRS4sCmQAlmQnylq5WepJiwXcyP6 NdPn8e/WP32upRNVFnRcbPyMZNzRuyy37zWPYsBKMiY0R6sNvpOtx22d//YNSMjrmDAk vf7teO6MWGCkFouy2ntSdUugD5xds3RGiSnIKq7VXgwff/Q9l6ECgr21Gu3w6Buo09gZ CBtA== X-Gm-Message-State: AElRT7Gz/aOCI9dZCjwn1VjmWpzVYvandBqoeLbWlv1PNgO84MgKP9RD 653Oqk1QmCCHcAZ2GDQQN3GvJQ== X-Received: by 10.223.166.171 with SMTP id t40mr7832562wrc.49.1521124768266; Thu, 15 Mar 2018 07:39:28 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id f8sm3696195wmc.1.2018.03.15.07.39.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Mar 2018 07:39:27 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Stephen Boyd , andy.gross@linaro.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: david.brown@linaro.org, mturquette@baylibre.com, robh+dt@kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, georgi.djakov@linaro.org, Srinivas Kandagatla Subject: [RFC PATCH] clk: qcom: rpmcc: Add support to XO buffered clocks Date: Thu, 15 Mar 2018 14:37:24 +0000 Message-Id: <20180315143724.13859-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Srinivas Kandagatla XO is onchip buffer clock to generate 19.2MHz. This patch adds support to 5 XO buffer clocks found on PMIC8921, these buffer clocks can be controlled from external pin or in manual mode. Signed-off-by: Srinivas Kandagatla --- drivers/clk/qcom/clk-rpm.c | 39 +++++++++++++++++++++++++++++++++- include/dt-bindings/clock/qcom,rpmcc.h | 5 +++++ 2 files changed, 43 insertions(+), 1 deletion(-) -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clk/qcom/clk-rpm.c b/drivers/clk/qcom/clk-rpm.c index c60f61b10c7f..261f5505e714 100644 --- a/drivers/clk/qcom/clk-rpm.c +++ b/drivers/clk/qcom/clk-rpm.c @@ -29,6 +29,7 @@ #define QCOM_RPM_MISC_CLK_TYPE 0x306b6c63 #define QCOM_RPM_SCALING_ENABLE_ID 0x2 +#define QCOM_RPM_XO_MODE_ON 0x2 #define DEFINE_CLK_RPM(_platform, _name, _active, r_id) \ static struct clk_rpm _platform##_##_active; \ @@ -56,6 +57,19 @@ }, \ } +#define DEFINE_CLK_RPM_XO_BUFFER(_platform, _name, _active, offset) \ + static struct clk_rpm _platform##_##_name = { \ + .rpm_clk_id = QCOM_RPM_CXO_BUFFERS, \ + .xo_offset = (offset), \ + .rate = 19200000, \ + .hw.init = &(struct clk_init_data){ \ + .ops = &clk_rpm_fixed_ops, \ + .name = #_name, \ + .parent_names = (const char *[]){ "pxo_board" }, \ + .num_parents = 1, \ + }, \ + } + #define DEFINE_CLK_RPM_FIXED(_platform, _name, _active, r_id, r) \ static struct clk_rpm _platform##_##_name = { \ .rpm_clk_id = (r_id), \ @@ -128,6 +142,8 @@ struct clk_rpm { const int rpm_clk_id; + const int xo_offset; + u32 xo_buffer_value; const bool active_only; unsigned long rate; bool enabled; @@ -159,7 +175,8 @@ static int clk_rpm_handoff(struct clk_rpm *r) * The vendor tree simply reads the status for this * RPM clock. */ - if (r->rpm_clk_id == QCOM_RPM_PLL_4) + if (r->rpm_clk_id == QCOM_RPM_PLL_4 || + r->rpm_clk_id == QCOM_RPM_CXO_BUFFERS) return 0; ret = qcom_rpm_write(r->rpm, QCOM_RPM_ACTIVE_STATE, @@ -294,6 +311,11 @@ static int clk_rpm_fixed_prepare(struct clk_hw *hw) u32 value = 1; int ret; + if (r->rpm_clk_id == QCOM_RPM_CXO_BUFFERS) { + r->xo_buffer_value |= (QCOM_RPM_XO_MODE_ON << r->xo_offset); + value = r->xo_buffer_value; + } + ret = qcom_rpm_write(r->rpm, QCOM_RPM_ACTIVE_STATE, r->rpm_clk_id, &value, 1); if (!ret) @@ -308,6 +330,11 @@ static void clk_rpm_fixed_unprepare(struct clk_hw *hw) u32 value = 0; int ret; + if (r->rpm_clk_id == QCOM_RPM_CXO_BUFFERS) { + r->xo_buffer_value &= ~(QCOM_RPM_XO_MODE_ON << r->xo_offset); + value = r->xo_buffer_value; + } + ret = qcom_rpm_write(r->rpm, QCOM_RPM_ACTIVE_STATE, r->rpm_clk_id, &value, 1); if (!ret) @@ -449,6 +476,11 @@ DEFINE_CLK_RPM(apq8064, mmfpb_clk, mmfpb_a_clk, QCOM_RPM_MMFPB_CLK); DEFINE_CLK_RPM(apq8064, sfab_clk, sfab_a_clk, QCOM_RPM_SYS_FABRIC_CLK); DEFINE_CLK_RPM(apq8064, sfpb_clk, sfpb_a_clk, QCOM_RPM_SFPB_CLK); DEFINE_CLK_RPM(apq8064, qdss_clk, qdss_a_clk, QCOM_RPM_QDSS_CLK); +DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_d0_clk, xo_d0_a_clk, 0); +DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_d1_clk, xo_d1_a_clk, 8); +DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_a0_clk, xo_a0_a_clk, 16); +DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_a1_clk, xo_a1_a_clk, 24); +DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_a2_clk, xo_a2_a_clk, 28); static struct clk_rpm *apq8064_clks[] = { [RPM_APPS_FABRIC_CLK] = &apq8064_afab_clk, @@ -469,6 +501,11 @@ static struct clk_rpm *apq8064_clks[] = { [RPM_SFPB_A_CLK] = &apq8064_sfpb_a_clk, [RPM_QDSS_CLK] = &apq8064_qdss_clk, [RPM_QDSS_A_CLK] = &apq8064_qdss_a_clk, + [RPM_XO_D0] = &apq8064_xo_d0_clk, + [RPM_XO_D1] = &apq8064_xo_d1_clk, + [RPM_XO_A0] = &apq8064_xo_a0_clk, + [RPM_XO_A1] = &apq8064_xo_a1_clk, + [RPM_XO_A2] = &apq8064_xo_a2_clk, }; static const struct rpm_clk_desc rpm_clk_apq8064 = { diff --git a/include/dt-bindings/clock/qcom,rpmcc.h b/include/dt-bindings/clock/qcom,rpmcc.h index b8337a5fa347..c585b82b9c05 100644 --- a/include/dt-bindings/clock/qcom,rpmcc.h +++ b/include/dt-bindings/clock/qcom,rpmcc.h @@ -40,6 +40,11 @@ #define RPM_SMI_CLK 22 #define RPM_SMI_A_CLK 23 #define RPM_PLL4_CLK 24 +#define RPM_XO_D0 25 +#define RPM_XO_D1 26 +#define RPM_XO_A0 27 +#define RPM_XO_A1 28 +#define RPM_XO_A2 29 /* SMD RPM clocks */ #define RPM_SMD_XO_CLK_SRC 0