Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3599849rdg; Tue, 17 Oct 2023 23:19:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSjmvZpqjHU+yYyWeAAmiZTcS571lT87nKNQGtyU9EObyA9oIUTOn5PFqrNrBtny51+Ihd X-Received: by 2002:a54:4882:0:b0:3a7:1e40:6ce9 with SMTP id r2-20020a544882000000b003a71e406ce9mr4223202oic.26.1697609946433; Tue, 17 Oct 2023 23:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697609946; cv=none; d=google.com; s=arc-20160816; b=atjiBrzodSWSNmVhokWt8NkNbEby1w73AGuk7+hEACQ/ucsDijfhrkg9XtLDgSWjUV Qaod4Eph+5NsVjRpkm4/AJUvrWgkb0fkbJX3vh1Be61hk78V9avyQynYwEYULO0KUwUY RuXZODEK1H4dhA9BL/BvlrbjKIfB4YuepeZlmKYjEBgF7QEKWzyZPLmhMGCAxLsrVrNl ssg8Puoc1EZs15CYktNU6jTnOq62qjjADbUnKGO2FuK1Q+wUuC1ESOLIIFpdfPWeLljq gtJqXwmonOr7O5WfXFYoT/TgAYfVT1II1BQb/WI0CTRYdlkZBdftMmibLBwxKt87HcJl 1YMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0ecnKR2giD7FyLLCAWKoY+EPgh0DFU1kApJsoRlMLis=; fh=fCKtpw9CfdQ3PvVD3VDWQjIZjGoF8tkGHyUGDo9ja4M=; b=UcbJkgq2eCUe72Wf+rZxSbm1D0ipABZnyUVuqGYS59RH1FcFAW77fyHKwByqgtjr1R /LC/5I1YiQ3nMNyhLUIkh3uLIpuoBZYZsBbbCOkEvh6EtUsYiY/EF34qQOGEZ9rEZxWX gIFDTO1J5+4n/s6KYdwsUlCRoGOMBPyTtf7Btdil6qPqr1pjBkAbMD/AwxJNVNY68Jis nLcGEpcVswAV4PzWh6R7PNcJJ19ZAiMgG8Ge+4DBD9NYu5Ge9LOlD4SsRj3VZZ+OJpKZ XYAZJ60eFaol3l7Rq/4M8aeq1Lseo6E6qVgZe+xn/myERKs63IcJIyMJKGzVENRXcrDk nLgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id e27-20020aa798db000000b006be31c8eea5si1648238pfm.61.2023.10.17.23.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 23:19:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 344598148BB5; Tue, 17 Oct 2023 23:19:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344515AbjJRGSs (ORCPT + 99 others); Wed, 18 Oct 2023 02:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344517AbjJRGSJ (ORCPT ); Wed, 18 Oct 2023 02:18:09 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E1001BE for ; Tue, 17 Oct 2023 23:17:56 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qszrx-0001Zs-7S; Wed, 18 Oct 2023 08:17:25 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qszrq-002UYB-TP; Wed, 18 Oct 2023 08:17:18 +0200 Received: from sha by dude02.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qszrq-00EviY-2Z; Wed, 18 Oct 2023 08:17:18 +0200 From: Sascha Hauer To: linux-rockchip@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Heiko Stuebner , Chanwoo Choi , Kyungmin Park , MyungJoo Ham , Will Deacon , Mark Rutland , kernel@pengutronix.de, Michael Riesch , Robin Murphy , Vincent Legoll , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, Sebastian Reichel , Sascha Hauer Subject: [PATCH v8 10/26] PM / devfreq: rockchip-dfi: Add RK3568 support Date: Wed, 18 Oct 2023 08:16:58 +0200 Message-Id: <20231018061714.3553817-11-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231018061714.3553817-1-s.hauer@pengutronix.de> References: <20231018061714.3553817-1-s.hauer@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 17 Oct 2023 23:19:01 -0700 (PDT) This adds RK3568 support to the DFI driver. Only iniitialization differs from the currently supported RK3399. Signed-off-by: Sascha Hauer --- Notes: Changes since v7: - Add comment to explain << 3 drivers/devfreq/event/rockchip-dfi.c | 27 +++++++++++++++++++++++++++ include/soc/rockchip/rk3568_grf.h | 12 ++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 include/soc/rockchip/rk3568_grf.h diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c index 12f9096879235..571d72d1abd1c 100644 --- a/drivers/devfreq/event/rockchip-dfi.c +++ b/drivers/devfreq/event/rockchip-dfi.c @@ -23,6 +23,7 @@ #include #include +#include #define DMC_MAX_CHANNELS 2 @@ -211,10 +212,36 @@ static int rk3399_dfi_init(struct rockchip_dfi *dfi) return 0; }; +static int rk3568_dfi_init(struct rockchip_dfi *dfi) +{ + struct regmap *regmap_pmu = dfi->regmap_pmu; + u32 reg2, reg3; + + regmap_read(regmap_pmu, RK3568_PMUGRF_OS_REG2, ®2); + regmap_read(regmap_pmu, RK3568_PMUGRF_OS_REG3, ®3); + + /* lower 3 bits of the DDR type */ + dfi->ddr_type = FIELD_GET(RK3568_PMUGRF_OS_REG2_DRAMTYPE_INFO, reg2); + + /* + * For version three and higher the upper two bits of the DDR type are + * in RK3568_PMUGRF_OS_REG3 + */ + if (FIELD_GET(RK3568_PMUGRF_OS_REG3_SYSREG_VERSION, reg3) >= 0x3) + dfi->ddr_type |= FIELD_GET(RK3568_PMUGRF_OS_REG3_DRAMTYPE_INFO_V3, reg3) << 3; + + dfi->channel_mask = BIT(0); + dfi->max_channels = 1; + + return 0; +}; + static const struct of_device_id rockchip_dfi_id_match[] = { { .compatible = "rockchip,rk3399-dfi", .data = rk3399_dfi_init }, + { .compatible = "rockchip,rk3568-dfi", .data = rk3568_dfi_init }, { }, }; + MODULE_DEVICE_TABLE(of, rockchip_dfi_id_match); static int rockchip_dfi_probe(struct platform_device *pdev) diff --git a/include/soc/rockchip/rk3568_grf.h b/include/soc/rockchip/rk3568_grf.h new file mode 100644 index 0000000000000..575584e9d8834 --- /dev/null +++ b/include/soc/rockchip/rk3568_grf.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +#ifndef __SOC_RK3568_GRF_H +#define __SOC_RK3568_GRF_H + +#define RK3568_PMUGRF_OS_REG2 0x208 +#define RK3568_PMUGRF_OS_REG2_DRAMTYPE_INFO GENMASK(15, 13) + +#define RK3568_PMUGRF_OS_REG3 0x20c +#define RK3568_PMUGRF_OS_REG3_DRAMTYPE_INFO_V3 GENMASK(13, 12) +#define RK3568_PMUGRF_OS_REG3_SYSREG_VERSION GENMASK(31, 28) + +#endif /* __SOC_RK3568_GRF_H */ -- 2.39.2