Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2974277pxb; Mon, 16 Nov 2020 02:16:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxc5wPGz6PzXRwWsu8DOXBNvyjdIE69o1bYjWuK1QJwEPszMUDK5BvLMfACCHSgUI0lecj4 X-Received: by 2002:a17:906:66c9:: with SMTP id k9mr14475948ejp.204.1605521801682; Mon, 16 Nov 2020 02:16:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605521801; cv=none; d=google.com; s=arc-20160816; b=ZKcRO8ThatBwonuFD8uTbyzvAVqS8b3Fd4xvbo0BS17nhjPFu+ADDfzl6UCVhwgVnG EM7B67WK2lNP5VT+sMLg4GMsj4JL4y9TeCIG2bQiFRif8/7Sv8XSx1+1C1Vd7TjbM46c 21aE6+3jKmObT7eukHGTWJD9lRg9oI7A/HWyObIkkaAFARMG+mI28Ph2pGsS2jEFTeMn ljgpTG/VkafWGPd/WYOW7qy9hsN9E7lllwypPmgd8Ygrez9J3yO5l0Xl8WvxGadLMBz/ VQlJ7LgC8J397VSDC+CvPcQCg84PouKvpEFYJRJjH6OPAUEktwWfZxLZqhY69USrPkD7 7IsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=9HDzLvbiGj7j/8SN5Yh28ZUiQtibKhgeeAj33aNoRhs=; b=yY074AIy+f5t1WBNWfih9VMgDz3CBzZrt3UYq+onG3N3m70MqVn3D7tpUTQxnqyxAd +IXf19zS1IPQVJpneE+Z/SNHiK3BU1MG0nWRn0tIAHekfNLu9WEsGqR/2KuIRskVm1lB lN4CQK2xXhFYvzYZKEzEPUND0Dkn0bdZAuiKQUnPkxv7U62Lno9Acu8hF4DhRnL3xwRl GYPibE4yD/MCvB6Lbzrhfi0Wy97SYUSizMANWBnX0Qg9+1CTE1ugK5f0PEp9CMXWuUqO QPxRwD0ILdYRl0GA/ahSdGA4dZDw0FcieeW2pycGkEpa3X1nnggQehFpbeye8WDVMiE+ axAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k22si11410452eds.368.2020.11.16.02.16.18; Mon, 16 Nov 2020 02:16:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728711AbgKPKKc (ORCPT + 99 others); Mon, 16 Nov 2020 05:10:32 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:46267 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726611AbgKPKKc (ORCPT ); Mon, 16 Nov 2020 05:10:32 -0500 X-IronPort-AV: E=Sophos;i="5.77,482,1596466800"; d="scan'208";a="62859650" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 16 Nov 2020 19:10:30 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 7E97040078AD; Mon, 16 Nov 2020 19:10:28 +0900 (JST) From: Lad Prabhakar To: Geert Uytterhoeven , Michael Turquette , Stephen Boyd , linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Biju Das , Prabhakar , Lad Prabhakar Subject: [PATCH v4] clk: renesas: r8a774c0: Add RPC clocks Date: Mon, 16 Nov 2020 10:10:02 +0000 Message-Id: <20201116101002.5986-1-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Describe the RPCSRC internal clock and the RPC[D2] clocks derived from it, as well as the RPC-IF module clock, in the RZ/G2E (R8A774C0) CPG/MSSR driver. Add new clk type CLK_TYPE_GEN3_E3_RPCSRC to register rpcsrc as a fixed clock on R-Car Gen3 E3 (and also RZ/G2E which is identical to E3 SoC), parent and the divider is set based on the register value CPG_RPCCKCR[4:3] which has been set prior to booting the kernel. Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das --- v3->v4 * Dropped cross verification of clock source * Changed DEF_FIXED_RPCSRC_E3 macro so that SoC specific div can be passed which would make addition of D3 SoC easier * Renamed CLK_TYPE_GEN3E3_RPCSRC to CLK_TYPE_GEN3_E3_RPCSRC * Updated the commit message v2->v3 * Implemented as a fixed clock v1->v2 * Fixed divider table depending on the clk source * Introduced CLK_TYPE_GEN3E3_RPCSRC for E3/G2E. v1: https://lkml.org/lkml/2020/10/16/474 --- drivers/clk/renesas/r8a774c0-cpg-mssr.c | 9 ++++++++ drivers/clk/renesas/rcar-gen3-cpg.c | 28 +++++++++++++++++++++++++ drivers/clk/renesas/rcar-gen3-cpg.h | 5 +++++ 3 files changed, 42 insertions(+) diff --git a/drivers/clk/renesas/r8a774c0-cpg-mssr.c b/drivers/clk/renesas/r8a774c0-cpg-mssr.c index 9fc9fa9e531a..ed3a2cf0e0bb 100644 --- a/drivers/clk/renesas/r8a774c0-cpg-mssr.c +++ b/drivers/clk/renesas/r8a774c0-cpg-mssr.c @@ -44,6 +44,7 @@ enum clk_ids { CLK_S2, CLK_S3, CLK_SDSRC, + CLK_RPCSRC, CLK_RINT, CLK_OCO, @@ -74,6 +75,13 @@ static const struct cpg_core_clk r8a774c0_core_clks[] __initconst = { DEF_FIXED(".s3", CLK_S3, CLK_PLL1, 6, 1), DEF_FIXED(".sdsrc", CLK_SDSRC, CLK_PLL1, 2, 1), + DEF_FIXED_RPCSRC_E3(".rpcsrc", CLK_RPCSRC, CLK_PLL0, CLK_PLL1), + + DEF_BASE("rpc", R8A774C0_CLK_RPC, CLK_TYPE_GEN3_RPC, + CLK_RPCSRC), + DEF_BASE("rpcd2", R8A774C0_CLK_RPCD2, CLK_TYPE_GEN3_RPCD2, + R8A774C0_CLK_RPC), + DEF_DIV6_RO(".r", CLK_RINT, CLK_EXTAL, CPG_RCKCR, 32), DEF_RATE(".oco", CLK_OCO, 8 * 1000 * 1000), @@ -199,6 +207,7 @@ static const struct mssr_mod_clk r8a774c0_mod_clks[] __initconst = { DEF_MOD("can-fd", 914, R8A774C0_CLK_S3D2), DEF_MOD("can-if1", 915, R8A774C0_CLK_S3D4), DEF_MOD("can-if0", 916, R8A774C0_CLK_S3D4), + DEF_MOD("rpc-if", 917, R8A774C0_CLK_RPCD2), DEF_MOD("i2c6", 918, R8A774C0_CLK_S3D2), DEF_MOD("i2c5", 919, R8A774C0_CLK_S3D2), DEF_MOD("i2c-dvfs", 926, R8A774C0_CLK_CP), diff --git a/drivers/clk/renesas/rcar-gen3-cpg.c b/drivers/clk/renesas/rcar-gen3-cpg.c index 488f8b3980c5..20de135e28ed 100644 --- a/drivers/clk/renesas/rcar-gen3-cpg.c +++ b/drivers/clk/renesas/rcar-gen3-cpg.c @@ -696,6 +696,34 @@ struct clk * __init rcar_gen3_cpg_clk_register(struct device *dev, cpg_rpcsrc_div_table, &cpg_lock); + case CLK_TYPE_GEN3_E3_RPCSRC: + /* + * Register RPCSRC as fixed factor clock based on the + * MD[4:1] pins and CPG_RPCCKCR[4:3] register value for + * which has been set prior to booting the kernel. + */ + value = (readl(base + CPG_RPCCKCR) & GENMASK(4, 3)) >> 3; + + switch (value) { + case 0: + div = 5; + break; + case 1: + div = 3; + break; + case 2: + parent = clks[core->parent >> 16]; + if (IS_ERR(parent)) + return ERR_CAST(parent); + div = core->div; + break; + case 3: + default: + div = 2; + break; + } + break; + case CLK_TYPE_GEN3_RPC: return cpg_rpc_clk_register(core->name, base, __clk_get_name(parent), notifiers); diff --git a/drivers/clk/renesas/rcar-gen3-cpg.h b/drivers/clk/renesas/rcar-gen3-cpg.h index c4ac80cac6a0..3d949c4a3244 100644 --- a/drivers/clk/renesas/rcar-gen3-cpg.h +++ b/drivers/clk/renesas/rcar-gen3-cpg.h @@ -24,6 +24,7 @@ enum rcar_gen3_clk_types { CLK_TYPE_GEN3_OSC, /* OSC EXTAL predivider and fixed divider */ CLK_TYPE_GEN3_RCKSEL, /* Select parent/divider using RCKCR.CKSEL */ CLK_TYPE_GEN3_RPCSRC, + CLK_TYPE_GEN3_E3_RPCSRC, CLK_TYPE_GEN3_RPC, CLK_TYPE_GEN3_RPCD2, @@ -54,6 +55,10 @@ enum rcar_gen3_clk_types { #define DEF_GEN3_Z(_name, _id, _type, _parent, _div, _offset) \ DEF_BASE(_name, _id, _type, _parent, .div = _div, .offset = _offset) +#define DEF_FIXED_RPCSRC_E3(_name, _id, _parent0, _parent1) \ + DEF_BASE(_name, _id, CLK_TYPE_GEN3_E3_RPCSRC, \ + (_parent0) << 16 | (_parent1), .div = 8) + struct rcar_gen3_cpg_pll_config { u8 extal_div; u8 pll1_mult; -- 2.25.1