From patchwork Wed Apr 1 15:35:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mylene Josserand X-Patchwork-Id: 11469237 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E84692C for ; Wed, 1 Apr 2020 15:35:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 09B3A20CC7 for ; Wed, 1 Apr 2020 15:35:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uEYxjNUr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09B3A20CC7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DVc6S/ZKQnK0EapZPRRsqaQDO1EXFIHewvM+J+KiFow=; b=uEYxjNUrTfIckk LW7ROmmN0oAyoho/Om5d4ooGFYkLVkW2PaOZ4cmbPMkbIq/6GNheJ6m9OLTYLtgcTo4VQjJiCD2JU DEgEg4oaMhKjxk9Y+rrgNXBiPL0gYjFbrdNVVQhjbHn0mmaf7qNGOLLcIA6dfR8gKpdSdkTEiGa4d X4ItK7ajJY2c6CLRyPqadENLo/qL0T4Sl3qEmuMn04y0E2ZYB1BE4yMN5W1/r75/FuGpfEkeIk6TN O1CaR5qffDSq26QzpGC/XNot/hFxye/C2mCFA53M6Kf7+ya0I8xG8PJA9HQMCFmD0p4d/TxRLRDJ4 M7FXqgaC8BQ3YHGibpcg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJfP8-0003it-Tf; Wed, 01 Apr 2020 15:35:46 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJfP2-0003at-DA; Wed, 01 Apr 2020 15:35:41 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: myjosserand) with ESMTPSA id 3B75028A107 From: =?utf-8?q?Myl=C3=A8ne_Josserand?= To: heiko@sntech.de, linux-arm-kernel@lists.infradead.org, mturquette@baylibre.com, sboyd@kernel.org Subject: [PATCH v2 1/2] soc: rockchip: Register a soc_device to retrieve revision Date: Wed, 1 Apr 2020 17:35:12 +0200 Message-Id: <20200401153513.423683-2-mylene.josserand@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200401153513.423683-1-mylene.josserand@collabora.com> References: <20200401153513.423683-1-mylene.josserand@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200401_083540_572976_3C5C63B6 X-CRM114-Status: GOOD ( 15.08 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mylene.josserand@collabora.com, kever.yang@rock-chips.com, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, geert@linux-m68k.org, kernel@collabora.com, linux-clk@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Determine which revision of rk3288 by checking the HDMI version. According to the Rockchip BSP kernel/u-boot, on rk3288w, the HDMI revision equals 0x1A which is not the case for the rk3288. As these SOC have some differences, this driver will help us to know on which revision we are by using 'soc_device' registration to be able to use 'soc_device_match' to detect rk3288/rk3288w. Signed-off-by: Mylène Josserand --- drivers/soc/rockchip/Makefile | 1 + drivers/soc/rockchip/rk3288.c | 125 ++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 drivers/soc/rockchip/rk3288.c diff --git a/drivers/soc/rockchip/Makefile b/drivers/soc/rockchip/Makefile index afca0a4c4b72..9dbf12913512 100644 --- a/drivers/soc/rockchip/Makefile +++ b/drivers/soc/rockchip/Makefile @@ -2,5 +2,6 @@ # # Rockchip Soc drivers # +obj-$(CONFIG_ARCH_ROCKCHIP) += rk3288.o obj-$(CONFIG_ROCKCHIP_GRF) += grf.o obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o diff --git a/drivers/soc/rockchip/rk3288.c b/drivers/soc/rockchip/rk3288.c new file mode 100644 index 000000000000..83379ba2b31b --- /dev/null +++ b/drivers/soc/rockchip/rk3288.c @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2020 Collabora Ltd + * Author: Mylene Josserand + */ + +#include +#include +#include +#include +#include +#include +#include + +#define RK3288_HDMI_REV_REG 0x04 +#define RK3288W_HDMI_REV 0x1A + +enum rk3288_soc_rev { + RK3288_SOC_REV_NOT_DETECT, + RK3288_SOC_REV_RK3288, + RK3288_SOC_REV_RK3288W, +}; + +static int rk3288_revision(void) +{ + static int revision = RK3288_SOC_REV_NOT_DETECT; + struct device_node *dn; + void __iomem *hdmi_base; + + if (revision != RK3288_SOC_REV_NOT_DETECT) + return revision; + + dn = of_find_compatible_node(NULL, NULL, "rockchip,rk3288-dw-hdmi"); + if (!dn) { + pr_err("%s: Couldn't find HDMI node\n", __func__); + return -EINVAL; + } + + hdmi_base = of_iomap(dn, 0); + of_node_put(dn); + + if (!hdmi_base) { + pr_err("%s: Couldn't map %pOF regs\n", __func__, + hdmi_base); + return -ENXIO; + } + + if (readl_relaxed(hdmi_base + RK3288_HDMI_REV_REG) + == RK3288W_HDMI_REV) + revision = RK3288_SOC_REV_RK3288W; + else + revision = RK3288_SOC_REV_RK3288; + + iounmap(hdmi_base); + + return revision; +} + +static const char *rk3288_socinfo_revision(u32 rev) +{ + const char *soc_rev; + + switch (rev) { + case RK3288_SOC_REV_RK3288: + soc_rev = "RK3288"; + break; + + case RK3288_SOC_REV_RK3288W: + soc_rev = "RK3288w"; + break; + + case RK3288_SOC_REV_NOT_DETECT: + soc_rev = ""; + break; + + default: + soc_rev = "unknown"; + break; + } + + return kstrdup_const(soc_rev, GFP_KERNEL); +} + +static const struct of_device_id rk3288_soc_match[] = { + { .compatible = "rockchip,rk3288", }, + { } +}; + +static int __init rk3288_soc_init(void) +{ + struct soc_device_attribute *soc_dev_attr; + struct soc_device *soc_dev; + struct device_node *np; + + np = of_find_matching_node(NULL, rk3288_soc_match); + if (!np) + return -ENODEV; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENOMEM; + + soc_dev_attr->family = "Rockchip"; + soc_dev_attr->soc_id = "RK32xx"; + + np = of_find_node_by_path("/"); + of_property_read_string(np, "model", &soc_dev_attr->machine); + of_node_put(np); + + soc_dev_attr->revision = rk3288_socinfo_revision(rk3288_revision()); + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + kfree_const(soc_dev_attr->revision); + kfree_const(soc_dev_attr->soc_id); + kfree(soc_dev_attr); + return PTR_ERR(soc_dev); + } + + dev_info(soc_device_to_device(soc_dev), "Rockchip %s %s detected\n", + soc_dev_attr->soc_id, soc_dev_attr->revision); + + return 0; +} +postcore_initcall(rk3288_soc_init); From patchwork Wed Apr 1 15:35:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mylene Josserand X-Patchwork-Id: 11469241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD42B92C for ; Wed, 1 Apr 2020 15:36:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB66A20CC7 for ; Wed, 1 Apr 2020 15:36:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hfmAiA82" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB66A20CC7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QQwcTOcDFopbe3yLGoTMYrH/n3ntrSLRHodqc+56GHw=; b=hfmAiA82PmXvv7 LolxT6j8gTtOPj94AtIzdJNYlimmhiIk80/p3Ags5oVpYqTJ903KpDnRvPMJmLjA2TokR0n2h6GEM fJH7L2i3n9brAGquueKzwXUeNqgyQc7In6vHQfTFWrNXmSKDfegQraF3lJBHFwwkQXJDbOeExXxIa FORn9A9aeJAfw1AbPQa512MnVoIiUNbR6JdUDxyyB2nLzwKFo9t0tmUMzrvuJ91oZ6TtxJNebd/Oy cSJe6V+oEvTB1/dMkQZ0qESe9WsLe/ByyAh9lIvLth6rJzVQLtgMJWuJxRrOjXbx01wvn1EgExyFX dO8JtNUhj85TYy0UCHvQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJfPS-000449-ES; Wed, 01 Apr 2020 15:36:06 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJfP4-0003bu-DI; Wed, 01 Apr 2020 15:35:44 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: myjosserand) with ESMTPSA id 4BE02291334 From: =?utf-8?q?Myl=C3=A8ne_Josserand?= To: heiko@sntech.de, linux-arm-kernel@lists.infradead.org, mturquette@baylibre.com, sboyd@kernel.org Subject: [PATCH v2 2/2] clk: rockchip: rk3288: Handle clock tree for rk3288w Date: Wed, 1 Apr 2020 17:35:13 +0200 Message-Id: <20200401153513.423683-3-mylene.josserand@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200401153513.423683-1-mylene.josserand@collabora.com> References: <20200401153513.423683-1-mylene.josserand@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200401_083542_595343_14B0A3B5 X-CRM114-Status: GOOD ( 11.85 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mylene.josserand@collabora.com, kever.yang@rock-chips.com, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, geert@linux-m68k.org, kernel@collabora.com, linux-clk@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The revision rk3288w has a different clock tree about "hclk_vio" clock, according to the BSP kernel code. This patch handles this difference by detecting which SOC it is and creating the div accordingly. Because we are using soc_device_match function, we need to delay the registration of this clock later than others to have time to get SoC revision. Otherwise, because of CLK_OF_DECLARE uses, clock tree will be created too soon to have time to detect SoC's revision. Signed-off-by: Mylène Josserand --- drivers/clk/rockchip/clk-rk3288.c | 36 +++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c index cc2a177bbdbf..1950d1efe1b8 100644 --- a/drivers/clk/rockchip/clk-rk3288.c +++ b/drivers/clk/rockchip/clk-rk3288.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "clk.h" @@ -425,8 +426,6 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { COMPOSITE(0, "aclk_vio0", mux_pll_src_cpll_gpll_usb480m_p, CLK_IGNORE_UNUSED, RK3288_CLKSEL_CON(31), 6, 2, MFLAGS, 0, 5, DFLAGS, RK3288_CLKGATE_CON(3), 0, GFLAGS), - DIV(0, "hclk_vio", "aclk_vio0", 0, - RK3288_CLKSEL_CON(28), 8, 5, DFLAGS), COMPOSITE(0, "aclk_vio1", mux_pll_src_cpll_gpll_usb480m_p, CLK_IGNORE_UNUSED, RK3288_CLKSEL_CON(31), 14, 2, MFLAGS, 8, 5, DFLAGS, RK3288_CLKGATE_CON(3), 2, GFLAGS), @@ -819,6 +818,16 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { INVERTER(0, "pclk_isp", "pclk_isp_in", RK3288_CLKSEL_CON(29), 3, IFLAGS), }; +static struct rockchip_clk_branch rk3288w_hclkvio_branch[] __initdata = { + DIV(0, "hclk_vio", "aclk_vio1", 0, + RK3288_CLKSEL_CON(28), 8, 5, DFLAGS), +}; + +static struct rockchip_clk_branch rk3288_hclkvio_branch[] __initdata = { + DIV(0, "hclk_vio", "aclk_vio0", 0, + RK3288_CLKSEL_CON(28), 8, 5, DFLAGS), +}; + static const char *const rk3288_critical_clocks[] __initconst = { "aclk_cpu", "aclk_peri", @@ -914,10 +923,15 @@ static struct syscore_ops rk3288_clk_syscore_ops = { .resume = rk3288_clk_resume, }; +static const struct soc_device_attribute rk3288w[] = { + { .soc_id = "RK32xx", .revision = "RK3288w" }, + { /* sentinel */ } +}; + +static struct rockchip_clk_provider *ctx; + static void __init rk3288_clk_init(struct device_node *np) { - struct rockchip_clk_provider *ctx; - rk3288_cru_base = of_iomap(np, 0); if (!rk3288_cru_base) { pr_err("%s: could not map cru region\n", __func__); @@ -955,3 +969,17 @@ static void __init rk3288_clk_init(struct device_node *np) rockchip_clk_of_add_provider(np, ctx); } CLK_OF_DECLARE(rk3288_cru, "rockchip,rk3288-cru", rk3288_clk_init); + +static int __init rk3288_hclkvio_register(void) +{ + /* Check for the rk3288w revision as clock tree is different */ + if (soc_device_match(rk3288w)) + rockchip_clk_register_branches(ctx, rk3288w_hclkvio_branch, + ARRAY_SIZE(rk3288w_hclkvio_branch)); + else + rockchip_clk_register_branches(ctx, rk3288_hclkvio_branch, + ARRAY_SIZE(rk3288_hclkvio_branch)); + + return 0; +} +subsys_initcall(rk3288_hclkvio_register);