From patchwork Mon Mar 2 15:57:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mylene Josserand X-Patchwork-Id: 11415819 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 CC19914E3 for ; Mon, 2 Mar 2020 15:59:43 +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 AA68A217F4 for ; Mon, 2 Mar 2020 15:59:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BmOrXXLj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA68A217F4 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-rockchip-bounces+patchwork-linux-rockchip=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=WupoBUGia6Vmg730JOaL5lfFv+RsJOVN/m0BREO0NY4=; b=BmOrXXLjVKdGAA tKYHuO4wAlAW5OKR0uSgnID790nMcyKlJwYcB0syGAEQYlnXbQgqqREi2hESpmEUU0v98DlZ7owph wNWdAcwajRKRP6Fy5lmDgyF5e2192jAfpLsCfxLhRCXxwdhKWVdbLVMxZQnNu+qDkkt+5z1+p7hwX gk2vCP8LEJf6YsDQzTfNQE6st/If4TzRC7xoIhyPZCvN1I0rbUBteLXOVDs7bbfnhoRMoQvuoD3+H CCaBkOh5hxOjnR141iuGsGgi/uK/EvljU0lW87uEvjgschKc0H9agX3T2sAWi86o4vsHqA/L6nsDi HKnBdreWMpYJjuMNo59w==; 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 1j8nTl-0006LZ-LE; Mon, 02 Mar 2020 15:59:37 +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 1j8nSh-0005Hk-LB; Mon, 02 Mar 2020 15:58:33 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: myjosserand) with ESMTPSA id 0B2A628A18A From: =?utf-8?q?Myl=C3=A8ne_Josserand?= To: linux@armlinux.org.uk, heiko@sntech.de, mturquette@baylibre.com, sboyd@kernel.org Subject: [PATCH 1/2] ARM: Rockchip: Handle rk3288/rk3288w revision Date: Mon, 2 Mar 2020 16:57:02 +0100 Message-Id: <20200302155703.278421-2-mylene.josserand@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200302155703.278421-1-mylene.josserand@collabora.com> References: <20200302155703.278421-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-20200302_075831_841724_CBD13628 X-CRM114-Status: GOOD ( 13.41 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 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-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mylene.josserand@collabora.com, kernel@collabora.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Determine which revision of rk3288 by checking the HDMI version. According to the Rockchip BSP kernel, on rk3288w, the HDMI revision equals 0x1A which is not the case for the rk3288 [1]. As these SOC have some differences, the new function 'soc_is_rk3288w' will help us to know on which revision we are. [1]:https://github.com/rockchip-linux/u-boot/blob/f992fe3334aa5090acb448261982628b5a3d37a5/arch/arm/include/asm/arch-rockchip/cpu.h#L30..L34 Signed-off-by: Mylène Josserand --- arch/arm/mach-rockchip/rockchip.c | 45 +++++++++++++++++++++++++++++++ include/soc/rockchip/revision.h | 22 +++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 include/soc/rockchip/revision.h diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c index f9797a2b5d0d..b907ba390093 100644 --- a/arch/arm/mach-rockchip/rockchip.c +++ b/arch/arm/mach-rockchip/rockchip.c @@ -9,12 +9,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -22,6 +24,49 @@ #include "pm.h" #define RK3288_TIMER6_7_PHYS 0xff810000 +#define RK3288_HDMI_REV_REG 0x04 +#define RK3288W_HDMI_REV 0x1A + +static const struct of_device_id rk3288_dt_hdmi_match[] __initconst = { + { .compatible = "rockchip,rk3288-dw-hdmi" }, + { } +}; + +int rk3288_get_revision(void) +{ + static int revision = RK3288_SOC_REV_UNKNOWN; + struct device_node *dn; + void __iomem *hdmi_base; + + if (revision != RK3288_SOC_REV_UNKNOWN) + return revision; + + dn = of_find_matching_node(NULL, rk3288_dt_hdmi_match); + 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; +} +EXPORT_SYMBOL(rk3288_get_revision); static void __init rockchip_timer_init(void) { diff --git a/include/soc/rockchip/revision.h b/include/soc/rockchip/revision.h new file mode 100644 index 000000000000..226419c60af0 --- /dev/null +++ b/include/soc/rockchip/revision.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright 2020 Collabora + */ + +#ifndef __SOC_ROCKCHIP_REVISION_H__ +#define __SOC_ROCKCHIP_REVISION_H__ + +enum rk3288_soc_revision { + RK3288_SOC_REV_UNKNOWN, + RK3288_SOC_REV_RK3288, + RK3288_SOC_REV_RK3288W, +}; + +int rk3288_get_revision(void); + +static inline bool soc_is_rk3288w(void) +{ + return rk3288_get_revision() == RK3288_SOC_REV_RK3288W; +} + +#endif /* __SOC_ROCKCHIP_REVISION_H__ */