From patchwork Wed Nov 22 12:56:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viacheslav X-Patchwork-Id: 168362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1301222vqb; Wed, 22 Nov 2023 05:00:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuc3gne/3irNA62sh4SyQp0QE//WPfm5MOt9V467FkXNQeoCSlvHhRbt3TOzYbikQ4603V X-Received: by 2002:a17:90a:fe90:b0:280:4a23:3c84 with SMTP id co16-20020a17090afe9000b002804a233c84mr8363313pjb.22.1700658012764; Wed, 22 Nov 2023 05:00:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700658012; cv=none; d=google.com; s=arc-20160816; b=GbSKunO4VHbkyOELzR7H3TCBEk6taJtuXxstW5YmNh3GYKek0njJ+EzcEtcAZJD/GP LzDkCuIE4SVw1eu/WtQkIOWv6iSN93MGzttowl0zz4qrdXZ5He8IZJCZsU/23ed2YJEC 8rUNzSyf8VfQ0GjOeHzTggIHRwmr2rzFYXlQNASpGjDyiXu2bSlrbBvvLNCz/E3AWjft GdoTH0AvaruQQVxrtsf76sxecfwICEmYpuyFePxhDmb0Lg4TAYhU+g28U0j3t/VH+X2B fW6BiwYXYlDKltfYn1esTt0qbe/VWT5OAlsUdHpnhsKM9nwrbBEWdyQHvrU/R8ATitb8 YVuw== 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:to:from :dkim-signature; bh=wZJcknLSQE6kdQ1bjcwbk6f5DDGjp+KGewdb43Z6bVU=; fh=Bllhknq5mciwRt9/KlTV9ZyEB86DXiZLRo/zORr6zwc=; b=QrRo7DkYKVdz1pS5SZ9ATtfUJk2zt4Zz6U7Kfq40LYsoDXjFiBCBy8jHLuSksehE6W OF9eaU7I3MV4f5Tx9cEJlRC9WfkBNbqShK1x3eeMle8CBhyBqklY6sQVzdzWtv+ynlp3 YBzsj5abdp8xsYwCxkJNq7n8quyuRkZfqJfGNPTmtdluc7LYXaQLY5QeuGs3EDr7rMT4 +xUliUo1wEph8AzI0H+NsvyhLUsp9gIYaSPR4NUZ75oAKQWQGIrkOhvyXDTgz/wWq8lL 4uXYHRxBOdXhCMR+QaU0kQt1Cs4v+eKJLriaP5EVWHWTUBh+MYL76mBEf/tS1brjFLTi WDLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=emeAcex7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ms23-20020a17090b235700b00280470736besi1330934pjb.182.2023.11.22.05.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 05:00:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=emeAcex7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F40AF8184E2E; Wed, 22 Nov 2023 04:57:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344236AbjKVM52 (ORCPT + 99 others); Wed, 22 Nov 2023 07:57:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344249AbjKVM5H (ORCPT ); Wed, 22 Nov 2023 07:57:07 -0500 Received: from mx.msync.work (mx.msync.work [62.182.159.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37161D54; Wed, 22 Nov 2023 04:56:56 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BFAD0540A1; Wed, 22 Nov 2023 12:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lexina.in; s=dkim; t=1700657813; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=wZJcknLSQE6kdQ1bjcwbk6f5DDGjp+KGewdb43Z6bVU=; b=emeAcex7MTdNQYItOcD8oAXdXllmUPtwiSxVek/oU9dagw+hjG40EtoNTlqEiT7PBGGv5p Tw4A+4EwhwpzNK1NR/cVAvuAupb1zlpevsD16mCUDfSv9ZVHyGUO18dFsA5DCQg1LAPI4I NPRHb+VTA2Ny2NYi5koOIEOIkBIhdd1O/5t5Cc1riemheMwILWzeZiyZlCWf/5/RpWg/kF WYQXLYhgeDqDKV5g09aPS0h1kkKUmqUWbJDEPU3fOwKwU7rNU8R5d+Mx+IUZXFgyfhILUA 2fuzAv46AropR7GHODaAOFlMsO9A/Bxinw1qPAO2ZJsrTWqVcNIfZgM1xmM2nw== From: Viacheslav Bocharov To: Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/5] soc: amlogic: meson-gx-socinfo: move common code to header file Date: Wed, 22 Nov 2023 15:56:39 +0300 Message-Id: <20231122125643.1717160-2-adeep@lexina.in> In-Reply-To: <20231122125643.1717160-1-adeep@lexina.in> References: <20231122125643.1717160-1-adeep@lexina.in> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5915; h=from:subject; bh=5lDOXBX94eQyb3bj1qrCKOVZy2f8VFuTwJBZrTGTfS8=; b=owGbwMvMwCHmnhFhrJcZuJTxtFoSQ2rstyNT4n5meL12Twx8OXWtnueVUnEp3foo/U9SB7vuSBuU Rhh1lLIwiHEwyIopsoR1BE3d57H64sQFRgdg5rAygQxh4OIUgIn8DGZk+LejpoBpQ8nKiNOrzVZUpu b879gglvdhlYes3MZpbh65LYwM5w9JLb2bZGIlyvTLPu7tPHfFMEWpIMmF4Vx6TelTxNPZAQ== X-Developer-Key: i=adeep@lexina.in; a=openpgp; fpr=E2FA1A767ACB0716E02E3E7AEE36B110025A8DFA X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 04:57:53 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783269176598104215 X-GMAIL-MSGID: 1783269176598104215 Move common constants and inline functions from meson-gx-socinfo driver to header file Signed-off-by: Viacheslav Bocharov --- .../soc/amlogic/meson-gx-socinfo-internal.h | 99 +++++++++++++++++++ drivers/soc/amlogic/meson-gx-socinfo.c | 80 +-------------- 2 files changed, 100 insertions(+), 79 deletions(-) create mode 100644 drivers/soc/amlogic/meson-gx-socinfo-internal.h diff --git a/drivers/soc/amlogic/meson-gx-socinfo-internal.h b/drivers/soc/amlogic/meson-gx-socinfo-internal.h new file mode 100644 index 000000000000..884cf8fb580f --- /dev/null +++ b/drivers/soc/amlogic/meson-gx-socinfo-internal.h @@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2017 BayLibre, SAS + * Copyright (C) 2023 JetHome + * + * Author: Neil Armstrong + * Author: Viacheslav Bocharov + */ + +#ifndef _MESON_GX_SOCINFO_INTERNAL_H_ +#define _MESON_GX_SOCINFO_INTERNAL_H_ + +#include + +#define AO_SEC_SD_CFG8 0xe0 +#define AO_SEC_SOCINFO_OFFSET AO_SEC_SD_CFG8 + +#define SOCINFO_MAJOR GENMASK(31, 24) +#define SOCINFO_PACK GENMASK(23, 16) +#define SOCINFO_MINOR GENMASK(15, 8) +#define SOCINFO_MISC GENMASK(7, 0) + +static const struct meson_gx_soc_id { + const char *name; + unsigned int id; +} soc_ids[] = { + { "GXBB", 0x1f }, + { "GXTVBB", 0x20 }, + { "GXL", 0x21 }, + { "GXM", 0x22 }, + { "TXL", 0x23 }, + { "TXLX", 0x24 }, + { "AXG", 0x25 }, + { "GXLX", 0x26 }, + { "TXHD", 0x27 }, + { "G12A", 0x28 }, + { "G12B", 0x29 }, + { "SM1", 0x2b }, + { "A1", 0x2c }, +}; + + +static const struct meson_gx_package_id { + const char *name; + unsigned int major_id; + unsigned int pack_id; + unsigned int pack_mask; +} soc_packages[] = { + { "S905", 0x1f, 0, 0x20 }, /* pack_id != 0x20 */ + { "S905H", 0x1f, 0x3, 0xf }, /* pack_id & 0xf == 0x3 */ + { "S905M", 0x1f, 0x20, 0xf0 }, /* pack_id == 0x20 */ + { "S905D", 0x21, 0, 0xf0 }, + { "S905X", 0x21, 0x80, 0xf0 }, + { "S905W", 0x21, 0xa0, 0xf0 }, + { "S905L", 0x21, 0xc0, 0xf0 }, + { "S905M2", 0x21, 0xe0, 0xf0 }, + { "S805X", 0x21, 0x30, 0xf0 }, + { "S805Y", 0x21, 0xb0, 0xf0 }, + { "S912", 0x22, 0, 0x0 }, /* Only S912 is known for GXM */ + { "962X", 0x24, 0x10, 0xf0 }, + { "962E", 0x24, 0x20, 0xf0 }, + { "A113X", 0x25, 0x37, 0xff }, + { "A113X", 0x25, 0x43, 0xff }, + { "A113D", 0x25, 0x22, 0xff }, + { "S905D2", 0x28, 0x10, 0xf0 }, + { "S905Y2", 0x28, 0x30, 0xf0 }, + { "S905X2", 0x28, 0x40, 0xf0 }, + { "A311D", 0x29, 0x10, 0xf0 }, + { "S922X", 0x29, 0x40, 0xf0 }, + { "S905D3", 0x2b, 0x4, 0xf5 }, + { "S905X3", 0x2b, 0x5, 0xf5 }, + { "S905X3", 0x2b, 0x10, 0x3f }, + { "S905D3", 0x2b, 0x30, 0x3f }, + { "A113L", 0x2c, 0x0, 0xf8 }, +}; + + +static inline unsigned int socinfo_to_major(u32 socinfo) +{ + return FIELD_GET(SOCINFO_MAJOR, socinfo); +} + +static inline unsigned int socinfo_to_minor(u32 socinfo) +{ + return FIELD_GET(SOCINFO_MINOR, socinfo); +} + +static inline unsigned int socinfo_to_pack(u32 socinfo) +{ + return FIELD_GET(SOCINFO_PACK, socinfo); +} + +static inline unsigned int socinfo_to_misc(u32 socinfo) +{ + return FIELD_GET(SOCINFO_MISC, socinfo); +} + +#endif /* _MESON_GX_SOCINFO_INTERNAL_H_ */ + diff --git a/drivers/soc/amlogic/meson-gx-socinfo.c b/drivers/soc/amlogic/meson-gx-socinfo.c index 6abb730344ab..9d7921c0fb91 100644 --- a/drivers/soc/amlogic/meson-gx-socinfo.c +++ b/drivers/soc/amlogic/meson-gx-socinfo.c @@ -16,85 +16,7 @@ #include #include -#define AO_SEC_SD_CFG8 0xe0 -#define AO_SEC_SOCINFO_OFFSET AO_SEC_SD_CFG8 - -#define SOCINFO_MAJOR GENMASK(31, 24) -#define SOCINFO_PACK GENMASK(23, 16) -#define SOCINFO_MINOR GENMASK(15, 8) -#define SOCINFO_MISC GENMASK(7, 0) - -static const struct meson_gx_soc_id { - const char *name; - unsigned int id; -} soc_ids[] = { - { "GXBB", 0x1f }, - { "GXTVBB", 0x20 }, - { "GXL", 0x21 }, - { "GXM", 0x22 }, - { "TXL", 0x23 }, - { "TXLX", 0x24 }, - { "AXG", 0x25 }, - { "GXLX", 0x26 }, - { "TXHD", 0x27 }, - { "G12A", 0x28 }, - { "G12B", 0x29 }, - { "SM1", 0x2b }, - { "A1", 0x2c }, -}; - -static const struct meson_gx_package_id { - const char *name; - unsigned int major_id; - unsigned int pack_id; - unsigned int pack_mask; -} soc_packages[] = { - { "S905", 0x1f, 0, 0x20 }, /* pack_id != 0x20 */ - { "S905H", 0x1f, 0x3, 0xf }, /* pack_id & 0xf == 0x3 */ - { "S905M", 0x1f, 0x20, 0xf0 }, /* pack_id == 0x20 */ - { "S905D", 0x21, 0, 0xf0 }, - { "S905X", 0x21, 0x80, 0xf0 }, - { "S905W", 0x21, 0xa0, 0xf0 }, - { "S905L", 0x21, 0xc0, 0xf0 }, - { "S905M2", 0x21, 0xe0, 0xf0 }, - { "S805X", 0x21, 0x30, 0xf0 }, - { "S805Y", 0x21, 0xb0, 0xf0 }, - { "S912", 0x22, 0, 0x0 }, /* Only S912 is known for GXM */ - { "962X", 0x24, 0x10, 0xf0 }, - { "962E", 0x24, 0x20, 0xf0 }, - { "A113X", 0x25, 0x37, 0xff }, - { "A113D", 0x25, 0x22, 0xff }, - { "S905D2", 0x28, 0x10, 0xf0 }, - { "S905Y2", 0x28, 0x30, 0xf0 }, - { "S905X2", 0x28, 0x40, 0xf0 }, - { "A311D", 0x29, 0x10, 0xf0 }, - { "S922X", 0x29, 0x40, 0xf0 }, - { "S905D3", 0x2b, 0x4, 0xf5 }, - { "S905X3", 0x2b, 0x5, 0xf5 }, - { "S905X3", 0x2b, 0x10, 0x3f }, - { "S905D3", 0x2b, 0x30, 0x3f }, - { "A113L", 0x2c, 0x0, 0xf8 }, -}; - -static inline unsigned int socinfo_to_major(u32 socinfo) -{ - return FIELD_GET(SOCINFO_MAJOR, socinfo); -} - -static inline unsigned int socinfo_to_minor(u32 socinfo) -{ - return FIELD_GET(SOCINFO_MINOR, socinfo); -} - -static inline unsigned int socinfo_to_pack(u32 socinfo) -{ - return FIELD_GET(SOCINFO_PACK, socinfo); -} - -static inline unsigned int socinfo_to_misc(u32 socinfo) -{ - return FIELD_GET(SOCINFO_MISC, socinfo); -} +#include "meson-gx-socinfo-internal.h" static const char *socinfo_to_package_id(u32 socinfo) { From patchwork Wed Nov 22 12:56:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viacheslav X-Patchwork-Id: 168355 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1300213vqb; Wed, 22 Nov 2023 04:58:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfPoRvKuEsLNmCZoirB2rWW9DdjnZqvlTNwqQ0d45jfAcafSKdgDVWz8xGNi+wrHd0M+tK X-Received: by 2002:a05:6a20:5485:b0:148:f952:552b with SMTP id i5-20020a056a20548500b00148f952552bmr2556473pzk.51.1700657900457; Wed, 22 Nov 2023 04:58:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700657900; cv=none; d=google.com; s=arc-20160816; b=BTVQ8OWA4XERz5eIZvrjgnqgKLJ3W5AXLVWm0LLALKiijLeEE58spLGESoPlNcX1wg sX7qr1wDr0dzhrpsNmjOZ2pIiXblV2Q8+aXMcOO+tzZApYO7bvdE1rhrnhpV/PiGFq6G un/sFBko2GNYBt9pd9orrKsNllBL7vWOuUP/S1cM8jODGmtDSgrt17plIdqk9ypDpmSf fnsUcHzENmLGq9IarnEdsSsqTCLq+ONaXJhDi2LabRoiAbY0U/gCr9ITGpE+VqBtHhqQ AnQImqCiqQLSqERDspQMFOvKWE42gcWf9whhsv/u47k5ZM454epgVU1TNid3HUlk2wla wfyw== 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:to:from :dkim-signature; bh=TCt0JoZg+p6aWcClOSdNWHnx4AX17W2tb5XYFeiobmA=; fh=Bllhknq5mciwRt9/KlTV9ZyEB86DXiZLRo/zORr6zwc=; b=Til+hnb/qSBlqiAVFbAWn/0it3n+FqdjVNIbF2PspaAl0DbqylpbxJreFioEigcHkl koBGvLGIbsLs7G17exHykk42OKI0QwagvFDSSiw8K63Vq9ylG/RN70gyf4By0g6ER9ON +nqU5y0/q0Cfa/gvP/XNibpCRfY1Kzye0H/6PIPlr47RlNZC7qOWfOUgucEzcD2lHtzr z3f14hOwBN3EhAHE8L6T9Prfj8me/zMF7x7vXeZ81+kIgRnONasRdejqkyQx6IOtVDEQ 7EjajxiMvhZW+qVuoS5ivNSSStMu4t97ZnHlIIVjRvZI9HazIbPcwtVFJWjXzIkti7V0 9mVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b="mA/UeoFe"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id q26-20020a65685a000000b005c21fa725casi9500490pgt.596.2023.11.22.04.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 04:58:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b="mA/UeoFe"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4E4A0824632C; Wed, 22 Nov 2023 04:57:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344222AbjKVM5M (ORCPT + 99 others); Wed, 22 Nov 2023 07:57:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344243AbjKVM5H (ORCPT ); Wed, 22 Nov 2023 07:57:07 -0500 Received: from mx.msync.work (mx.msync.work [62.182.159.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6249AD62; Wed, 22 Nov 2023 04:56:56 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 79DD953ED8; Wed, 22 Nov 2023 12:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lexina.in; s=dkim; t=1700657814; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=TCt0JoZg+p6aWcClOSdNWHnx4AX17W2tb5XYFeiobmA=; b=mA/UeoFeBoCs2qSwF7nxxjkUFaDJmKEQOU5Wa3EZR57SwbPJTyghxGJyrkaqLlt8artEKp XetuKqfHJtF0FUusVm5MxTpbBorJ6XO4yi80Y7kkKVSgxqCsAFgHMeKkXHY7kl/1JKXOAT 3wPLJioi0l8r9tRD4y3K8w8M4TFym6Vpy7w3Hmsy366qrWz8KB1AxlhOZFmK/4LqYMOG8I hxfRLPKqZyrMcGbFncrldnP0BQZFg9HX+CpDFkKMWYDG6sHM29vpnyPSAOTDVjvR1pDeb/ 2kQxQdwn3GkaAdg0SZ3BjvPke9JVwMBaXzMDv741W7XbCIzRVhVnV5A6g2RVPQ== From: Viacheslav Bocharov To: Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/5] soc: amlogic: meson-gx-socinfo: move common code to exported function Date: Wed, 22 Nov 2023 15:56:40 +0300 Message-Id: <20231122125643.1717160-3-adeep@lexina.in> In-Reply-To: <20231122125643.1717160-1-adeep@lexina.in> References: <20231122125643.1717160-1-adeep@lexina.in> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2574; h=from:subject; bh=BnHHuUquDeW8vfYvoIWuzuZnrP1gP/Gae/DQ47jDLU8=; b=owGbwMvMwCHmnhFhrJcZuJTxtFoSQ2rstyP3FWz+1wqt///MM3F/QLJsm3D3Tg8PsXbvuoya5uoP 2tYdpSwMYhwMsmKKLGEdQVP3eay+OHGB0QGYOaxMIEMYuDgFYCInExkZjjtfuFXcoBVz8Iw/O9fm2t J7qisu61w0ZbuSXG3wg/9AAMN/j4jY8vh1NuZZeuEcnzYK/Vc+u6NVsUyGn//ftKlmJyQ5AQ== X-Developer-Key: i=adeep@lexina.in; a=openpgp; fpr=E2FA1A767ACB0716E02E3E7AEE36B110025A8DFA X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 22 Nov 2023 04:57:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783269058233896335 X-GMAIL-MSGID: 1783269058233896335 Move common code fill soc_device_attribute to common function for later use Signed-off-by: Viacheslav Bocharov --- .../soc/amlogic/meson-gx-socinfo-internal.h | 3 +++ drivers/soc/amlogic/meson-gx-socinfo.c | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/soc/amlogic/meson-gx-socinfo-internal.h b/drivers/soc/amlogic/meson-gx-socinfo-internal.h index 884cf8fb580f..5a742cc16fc8 100644 --- a/drivers/soc/amlogic/meson-gx-socinfo-internal.h +++ b/drivers/soc/amlogic/meson-gx-socinfo-internal.h @@ -95,5 +95,8 @@ static inline unsigned int socinfo_to_misc(u32 socinfo) return FIELD_GET(SOCINFO_MISC, socinfo); } +int meson_gx_socinfo_prepare_soc_driver_attr(struct soc_device_attribute *soc_dev_attr, + unsigned int socattr); + #endif /* _MESON_GX_SOCINFO_INTERNAL_H_ */ diff --git a/drivers/soc/amlogic/meson-gx-socinfo.c b/drivers/soc/amlogic/meson-gx-socinfo.c index 9d7921c0fb91..8cf69dd238ee 100644 --- a/drivers/soc/amlogic/meson-gx-socinfo.c +++ b/drivers/soc/amlogic/meson-gx-socinfo.c @@ -47,6 +47,22 @@ static const char *socinfo_to_soc_id(u32 socinfo) return "Unknown"; } +int meson_gx_socinfo_prepare_soc_driver_attr(struct soc_device_attribute *soc_dev_attr, + unsigned int socattr) +{ + soc_dev_attr->family = "Amlogic Meson"; + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%x:%x - %x:%x", + socinfo_to_major(socattr), + socinfo_to_minor(socattr), + socinfo_to_pack(socattr), + socinfo_to_misc(socattr)); + soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%s (%s)", + socinfo_to_soc_id(socattr), + socinfo_to_package_id(socattr)); + return 0; +} +EXPORT_SYMBOL(meson_gx_socinfo_prepare_soc_driver_attr); + static int __init meson_gx_socinfo_init(void) { struct soc_device_attribute *soc_dev_attr; @@ -95,15 +111,7 @@ static int __init meson_gx_socinfo_init(void) if (!soc_dev_attr) return -ENODEV; - soc_dev_attr->family = "Amlogic Meson"; - soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%x:%x - %x:%x", - socinfo_to_major(socinfo), - socinfo_to_minor(socinfo), - socinfo_to_pack(socinfo), - socinfo_to_misc(socinfo)); - soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%s (%s)", - socinfo_to_soc_id(socinfo), - socinfo_to_package_id(socinfo)); + meson_gx_socinfo_prepare_soc_driver_attr(soc_dev_attr, socinfo); soc_dev = soc_device_register(soc_dev_attr); if (IS_ERR(soc_dev)) { From patchwork Wed Nov 22 12:56:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viacheslav X-Patchwork-Id: 168360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1301204vqb; Wed, 22 Nov 2023 05:00:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IERY/s4EcgalRSGf20Yc4VdKQRQ98UQHrtNikaAcS2sLxmTSz/lQLp3oU5htclVfJH0cnxs X-Received: by 2002:a17:90b:1b52:b0:27d:22d7:9787 with SMTP id nv18-20020a17090b1b5200b0027d22d79787mr2265765pjb.36.1700658010702; Wed, 22 Nov 2023 05:00:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700658010; cv=none; d=google.com; s=arc-20160816; b=EHycwaH5Qv4N7SujjdjywmUWOBR+filn78L6zIBlUeuqhjdk+RgCdo6bQUj1SPLftW Q6qPeTN8RhdMBhc1Y+Fh6/T71iUkvBx2FFATq5kCj2cnkn+E2ufcPrALlG6sUyyBGK6S ceSc+HDXL0W111YaR09XgO3DwYLVS6/9w5Oz5mcLZeOtVtf8CGQoH5SmHU7AUqTaBqgq GUSJEMnhdQV/hJ3qaF4U1oUXd/vVyN5ikivmYi13GPdzJeh5Iqv8LlSJZmIuzcr9AbUk Owo6yrTIJUhIZDe5zcp1AreWCwO/rnSFTuMiAOw/fZKeFOx6+TaDFZMV5jZkYOIZt4+Z ehxA== 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:to:from :dkim-signature; bh=1JJrVlQT4dSyAepCsKEppt0JhDAnONuiLebT73/zFmQ=; fh=Bllhknq5mciwRt9/KlTV9ZyEB86DXiZLRo/zORr6zwc=; b=D4QxUSP5FhSNFnLjR7WUnHIouBuG8MItjl3sPhN6Rr1klfsndXwedjS51bv8spR2SE bWcJF9lxpFk8pzcwezQFj44ey2sGhnP/lGLi68y5/PaStCxqUHDSmKZe/yL+za3RJIDH 0nV52V0A1s5lphH7EnPr6VeLj8ujjpPnhqg5drD+mrp9lGEgdoca1GNkR8T1w1hJ8ls7 iKDwVnIH4sVgoenXcaNcZYSGy+AM2XC3WVY8dJBCPbRci+24EBV5jY7joaTuH5jtNMwI WFgh7NhMSc5/27xRdlzXmckST4clu1jghJBa346rLq4bIVX7YTQGO3kBPmC9sKmidiWz oPjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=MyaO1ciE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t21-20020a17090ad51500b00283bc49ad11si1367383pju.183.2023.11.22.05.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 05:00:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=MyaO1ciE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7C056802F879; Wed, 22 Nov 2023 04:57:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344312AbjKVM5U (ORCPT + 99 others); Wed, 22 Nov 2023 07:57:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344246AbjKVM5H (ORCPT ); Wed, 22 Nov 2023 07:57:07 -0500 Received: from mx.msync.work (mx.msync.work [62.182.159.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C31DC112; Wed, 22 Nov 2023 04:56:56 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BBCED540A2; Wed, 22 Nov 2023 12:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lexina.in; s=dkim; t=1700657814; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=1JJrVlQT4dSyAepCsKEppt0JhDAnONuiLebT73/zFmQ=; b=MyaO1ciELUoOTnkA8k5bOa8bMRT2ead7XfG4T1E1/saUsTaq9YZZ5POKgj8j/2kH+2yK5b Yt4F4OdXM0mtM/vpM9Ah9rXVH8A79i4xkMSEeeJ5ltnobxOh/IopZ4eEqDEEVVvjGcT29u McfldYm/gBr2SkJKqT33OyapEP2vdX49Yu1jzgO9lprJ8n8cH5S3QjRISFts71ah/aLaem ynCHhwbAj0wVR7makmAnhlviUDes0UwIiVKX/7ox9cDrUEc5wi/tEHuMC1kmkcWk6EYlbn XbBquQ5X5cVbxtaLtzW1sxqMWhHDJJ7zj8djrGFb755RagPQrgoldenLRpj2WQ== From: Viacheslav Bocharov To: Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/5] firmware: meson_sm: move common definitions to header file Date: Wed, 22 Nov 2023 15:56:41 +0300 Message-Id: <20231122125643.1717160-4-adeep@lexina.in> In-Reply-To: <20231122125643.1717160-1-adeep@lexina.in> References: <20231122125643.1717160-1-adeep@lexina.in> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1284; h=from:subject; bh=qgIgUERrKdBRmt/t8R9MoRn4sT6vtjugdlg8U0yx7ss=; b=owGbwMvMwCHmnhFhrJcZuJTxtFoSQ2rst6N93hV/DR5LPs8LXCH2/fyz36Iv3ldfLpt+SnmDqfNG XbbUjlIWBjEOBlkxRZawjqCp+zxWX5y4wOgAzBxWJpAhDFycAjARETOGv3Jn1KbnZSwoTRbMmhoS8a O3ZVJ970a71oRvJ0K3vctTXcvIcLTzWXu8t1fTt7VmW0tLsiZ9U/OptTUWN+dalL03ukWKDwA= X-Developer-Key: i=adeep@lexina.in; a=openpgp; fpr=E2FA1A767ACB0716E02E3E7AEE36B110025A8DFA X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 04:57:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783269174579158245 X-GMAIL-MSGID: 1783269174579158245 Move SM_CHIPID_* constants from firmware meson sm driver to header file. Signed-off-by: Viacheslav Bocharov --- drivers/firmware/meson/meson_sm.c | 4 ---- include/linux/firmware/meson/meson_sm.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/meson/meson_sm.c b/drivers/firmware/meson/meson_sm.c index 402851ed4ac0..96e50811336f 100644 --- a/drivers/firmware/meson/meson_sm.c +++ b/drivers/firmware/meson/meson_sm.c @@ -240,10 +240,6 @@ struct meson_sm_firmware *meson_sm_get(struct device_node *sm_node) } EXPORT_SYMBOL_GPL(meson_sm_get); -#define SM_CHIP_ID_LENGTH 119 -#define SM_CHIP_ID_OFFSET 4 -#define SM_CHIP_ID_SIZE 12 - static ssize_t serial_show(struct device *dev, struct device_attribute *attr, char *buf) { diff --git a/include/linux/firmware/meson/meson_sm.h b/include/linux/firmware/meson/meson_sm.h index 8eaf8922ab02..f62acd2bf52a 100644 --- a/include/linux/firmware/meson/meson_sm.h +++ b/include/linux/firmware/meson/meson_sm.h @@ -7,6 +7,10 @@ #ifndef _MESON_SM_FW_H_ #define _MESON_SM_FW_H_ +#define SM_CHIP_ID_LENGTH 119 +#define SM_CHIP_ID_OFFSET 4 +#define SM_CHIP_ID_SIZE 12 + enum { SM_EFUSE_READ, SM_EFUSE_WRITE, From patchwork Wed Nov 22 12:56:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viacheslav X-Patchwork-Id: 168357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1300249vqb; Wed, 22 Nov 2023 04:58:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsKPdr/7a7pNCkg+0izhhxdXS98A7xnUq64aUUD6u4XwR+Hp8BNwso7qE8ee6b+kZF2gB1 X-Received: by 2002:a05:6e02:1a02:b0:359:cc98:7508 with SMTP id s2-20020a056e021a0200b00359cc987508mr2378757ild.31.1700657904834; Wed, 22 Nov 2023 04:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700657904; cv=none; d=google.com; s=arc-20160816; b=nyh7iXp4rb5aAN5BKy/V9mMuZtO+MiyahTsnCuCgBvtxEpAcCpB5mVV3FjJBh0dDDl FewDIzIIZOytAoJiaTLxR/6l0y7UUuwWAcp8q2suxDE1aAfrfO/Lf6dWmhqmXc/rzPV0 XdW5qX21J0iq11hjzw6awexUjjH0w7YxTcI4+dqCiClVEURQRBqFz38mwbK76wb3LEP3 v69rmljgzVif5gowgCy4sZhQEdlV6/6UbjHJptUYNNj7m1/qC9S4DcA0HXSPWducJk/4 +JxGVM/4anz9X+oiV26NlP2CQm7CdKo0scrAwnFZ1v6RIa4GL6+HnAjMzYtQEhNG11Iu LhKg== 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:to:from :dkim-signature; bh=9FM903o2pn21k51UZjXAT7x1wyN7v04RutSMU2fbua0=; fh=Bllhknq5mciwRt9/KlTV9ZyEB86DXiZLRo/zORr6zwc=; b=ivQY5wFKIMFRf0tWDnV/R4JuacFmXlQ/vRn6ctwsyck/zFXEf38jr22GxpPr/D5UEi B6N9BzAneUXy3lVkZ/uOEgeSeO1tOHSJ2zheesMEbYj3X3CbRQwDpe+Brsrgcrm8ssxI T+3epWrTT9EiAdDBMAS5myI/wD9x2FPo2hG06+eebUbiBuCTn4iJwE0A9/A++/FzARWs 8oxZLIR4scSIQ7ioXoQGRgNrXWCx8vS1DiaPHtgtdOsqMHq1JvxMENAh7am+PmwwtZQx 8UCVc4Lr8/thYazhB/wjNsutAzwVY9y5TprZbvGsyPtA2kMPMkOyLJRrNBMmTuZho+YT O65w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=FtRsMvL+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id c10-20020a65618a000000b005b18ac47c1csi2008866pgv.310.2023.11.22.04.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 04:58:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=FtRsMvL+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 44074806AA35; Wed, 22 Nov 2023 04:58:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344283AbjKVM5Q (ORCPT + 99 others); Wed, 22 Nov 2023 07:57:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344255AbjKVM5H (ORCPT ); Wed, 22 Nov 2023 07:57:07 -0500 Received: from mx.msync.work (mx.msync.work [62.182.159.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B72BD52; Wed, 22 Nov 2023 04:56:56 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0047A53EDA; Wed, 22 Nov 2023 12:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lexina.in; s=dkim; t=1700657815; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=9FM903o2pn21k51UZjXAT7x1wyN7v04RutSMU2fbua0=; b=FtRsMvL+MGmcCxNEMbpc9Mov5zIfR/IZC+0XQKaH+0coLTkPfleeqBEp7delkJD/YmYbic MwmMR5WCIi2Snr9QUmz3U/b7jc+QqBPOabXv8rXcNmTaJ7tdug+KycOa56s/izHKhJ0vFs 0UBd7mMlzuuJek645V0EDtpLnwBKlVAJCtfXxwZvaQVPK2prlQwYcCQC2bM9GnDLzYc8It ikrlnGjun0H8qPC3Jh+DnqpLYAOAA3EksKzybeDevvqjmouTdD2iRqVjXp6r10Yxo/wTnb wOZavUYZQTI2qgWQvvCRdqOgc7JKthyJXdcUvKQSl6PRFiI+tHCwqpJxfiW6rQ== From: Viacheslav Bocharov To: Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 4/5] soc: amlogic: Add Amlogic secure-monitor SoC Information driver Date: Wed, 22 Nov 2023 15:56:42 +0300 Message-Id: <20231122125643.1717160-5-adeep@lexina.in> In-Reply-To: <20231122125643.1717160-1-adeep@lexina.in> References: <20231122125643.1717160-1-adeep@lexina.in> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7167; h=from:subject; bh=Ts6D5zneNK9fsa5Hu2MDyTR0sZxwo+G3SlCocMKM3Xk=; b=owGbwMvMwCHmnhFhrJcZuJTxtFoSQ2rst6OFk/eIhL8o3vqGde4k1lCRb663fsgkvn2wc4aJ6v57 WxQEOkpZGMQ4GGTFFFnCOoKm7vNYfXHiAqMDMHNYmUCGMHBxCsBE7G8y/M+XuHJ0Pccm1oDfAiFPp5 1n4g6UFjLVLfWQ2nFotdK1o2wM/2t3hOms3erEteKpG9cf9mezxNsVK5e+Oa6w9P3XM4mZpxkA X-Developer-Key: i=adeep@lexina.in; a=openpgp; fpr=E2FA1A767ACB0716E02E3E7AEE36B110025A8DFA X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 04:58:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783269063189304699 X-GMAIL-MSGID: 1783269063189304699 Amlogic SoCs have a SoC information secure-monitor call for SoC type, package type, revision information and chipid. This patchs adds support for secure-monitor call decoding and exposing with the SoC bus infrastructure in addition to the previous SoC Information driver. Signed-off-by: Viacheslav Bocharov --- drivers/soc/amlogic/Kconfig | 10 ++ drivers/soc/amlogic/Makefile | 1 + drivers/soc/amlogic/meson-gx-socinfo-sm.c | 178 ++++++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 drivers/soc/amlogic/meson-gx-socinfo-sm.c diff --git a/drivers/soc/amlogic/Kconfig b/drivers/soc/amlogic/Kconfig index d08e398bdad4..5634ecb60478 100644 --- a/drivers/soc/amlogic/Kconfig +++ b/drivers/soc/amlogic/Kconfig @@ -26,6 +26,16 @@ config MESON_GX_SOCINFO Say yes to support decoding of Amlogic Meson GX SoC family information about the type, package and version. +config MESON_GX_SOCINFO_SM + bool "Amlogic Meson GX SoC Information driver via Secure Monitor" + depends on (ARM64 && ARCH_MESON && MESON_GX_SOCINFO && MESON_SM) || COMPILE_TEST + default MESON_GX_SOCINFO && MESON_SM + select SOC_BUS + help + Say yes to support decoding of Amlogic Meson GX SoC family + information about the type, package and version from secure + monitor call. + config MESON_MX_SOCINFO bool "Amlogic Meson MX SoC Information driver" depends on (ARM && ARCH_MESON) || COMPILE_TEST diff --git a/drivers/soc/amlogic/Makefile b/drivers/soc/amlogic/Makefile index c25f835e6a26..45d9d6f5904c 100644 --- a/drivers/soc/amlogic/Makefile +++ b/drivers/soc/amlogic/Makefile @@ -2,4 +2,5 @@ obj-$(CONFIG_MESON_CANVAS) += meson-canvas.o obj-$(CONFIG_MESON_CLK_MEASURE) += meson-clk-measure.o obj-$(CONFIG_MESON_GX_SOCINFO) += meson-gx-socinfo.o +obj-$(CONFIG_MESON_GX_SOCINFO_SM) += meson-gx-socinfo-sm.o obj-$(CONFIG_MESON_MX_SOCINFO) += meson-mx-socinfo.o diff --git a/drivers/soc/amlogic/meson-gx-socinfo-sm.c b/drivers/soc/amlogic/meson-gx-socinfo-sm.c new file mode 100644 index 000000000000..52bf3bce09e2 --- /dev/null +++ b/drivers/soc/amlogic/meson-gx-socinfo-sm.c @@ -0,0 +1,178 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2023 JetHome + * Author: Viacheslav Bocharov + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "meson-gx-socinfo-internal.h" + +static char *socinfo_get_cpuid(struct device *dev, struct meson_sm_firmware *fw, + unsigned int *socinfo) +{ + char *buf; + uint8_t *id_buf; + int chip_id_version; + int ret; + + id_buf = devm_kzalloc(dev, SM_CHIP_ID_LENGTH, GFP_KERNEL); + if (!id_buf) + return NULL; + + ret = meson_sm_call_read(fw, id_buf, SM_CHIP_ID_LENGTH, SM_GET_CHIP_ID, + 2, 0, 0, 0, 0); + if (ret < 0) { + kfree(id_buf); + return NULL; + } + + chip_id_version = *((unsigned int *)id_buf); + + if (chip_id_version != 2) { + uint8_t tmp; + /** + * Legacy 12-byte chip ID read out, transform data + * to expected order format + */ + + memmove(&id_buf[SM_CHIP_ID_OFFSET + 4], &id_buf[SM_CHIP_ID_OFFSET], 12); + for (int i = 0; i < 6; i++) { + tmp = id_buf[i + SM_CHIP_ID_OFFSET + 4]; + id_buf[i + SM_CHIP_ID_OFFSET + 4] = id_buf[15 - i + SM_CHIP_ID_OFFSET]; + id_buf[15 - i + SM_CHIP_ID_OFFSET] = tmp; + } + *(uint32_t *)(id_buf + SM_CHIP_ID_OFFSET) = + ((*socinfo & 0xff000000) | // Family ID + ((*socinfo << 8) & 0xff0000) | // Chip Revision + ((*socinfo >> 8) & 0xff00)) | // Package ID + ((*socinfo) & 0xff); // Misc + } else { + *socinfo = id_buf[SM_CHIP_ID_OFFSET] << 24 | // Family ID + id_buf[SM_CHIP_ID_OFFSET + 2] << 16 | // Chip revision + id_buf[SM_CHIP_ID_OFFSET + 1] << 8 | // Package ID + id_buf[SM_CHIP_ID_OFFSET + 3]; // Misc + } + + buf = kasprintf(GFP_KERNEL, "%16phN\n", &id_buf[SM_CHIP_ID_OFFSET]); + kfree(id_buf); + + return buf; +} + +static int meson_gx_socinfo_sm_probe(struct platform_device *pdev) +{ + struct soc_device_attribute *soc_dev_attr; + struct soc_device *soc_dev; + struct device_node *sm_np; + struct meson_sm_firmware *fw; + struct regmap *regmap; + unsigned int socinfo; + struct device *dev; + int ret; + + /* check if chip-id is available */ + if (!of_property_read_bool(pdev->dev.of_node, "amlogic,has-chip-id")) + return -ENODEV; + + /* node should be a syscon */ + regmap = syscon_node_to_regmap(pdev->dev.of_node); + if (IS_ERR(regmap)) { + dev_err(&pdev->dev, "failed to get regmap\n"); + return -ENODEV; + } + + sm_np = of_parse_phandle(pdev->dev.of_node, "secure-monitor", 0); + if (!sm_np) { + dev_err(&pdev->dev, "no secure-monitor node found\n"); + return -ENODEV; + } + + fw = meson_sm_get(sm_np); + of_node_put(sm_np); + if (!fw) + return -EPROBE_DEFER; + + dev_err(&pdev->dev, "secure-monitor node found\n"); + + ret = regmap_read(regmap, AO_SEC_SOCINFO_OFFSET, &socinfo); + if (ret < 0) + return ret; + + if (!socinfo) { + dev_err(&pdev->dev, "invalid regmap chipid value\n"); + return -EINVAL; + } + + soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr), + GFP_KERNEL); + if (!soc_dev_attr) + return -ENOMEM; + + soc_dev_attr->serial_number = socinfo_get_cpuid(&pdev->dev, fw, &socinfo); + + meson_gx_socinfo_prepare_soc_driver_attr(soc_dev_attr, socinfo); + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + kfree(soc_dev_attr->revision); + kfree_const(soc_dev_attr->soc_id); + kfree(soc_dev_attr); + return PTR_ERR(soc_dev); + } + + dev = soc_device_to_device(soc_dev); + platform_set_drvdata(pdev, soc_dev); + + dev_info(dev, "Amlogic Meson %s Revision %x:%x (%x:%x) Detected at SM driver %x\n", + soc_dev_attr->soc_id, + socinfo_to_major(socinfo), + socinfo_to_minor(socinfo), + socinfo_to_pack(socinfo), + socinfo_to_misc(socinfo), socinfo); + + return PTR_ERR_OR_ZERO(dev); +} + + +static int meson_gx_socinfo_sm_remove(struct platform_device *pdev) +{ + struct soc_device *soc_dev = platform_get_drvdata(pdev); + + soc_device_unregister(soc_dev); + return 0; +} + +static const struct of_device_id meson_gx_socinfo_match[] = { + { .compatible = "amlogic,meson-gx-ao-secure", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, meson_gx_socinfo_match); + +static struct platform_driver meson_gx_socinfo_driver = { + .probe = meson_gx_socinfo_sm_probe, + .remove = meson_gx_socinfo_sm_remove, + .driver = { + .name = "meson-gx-socinfo-sm", + .of_match_table = meson_gx_socinfo_match, + }, +}; + + +module_platform_driver(meson_gx_socinfo_driver); + +MODULE_AUTHOR("Viacheslav Bocharov "); +MODULE_DESCRIPTION("Amlogic Meson GX SOC SM driver"); +MODULE_LICENSE("GPL"); From patchwork Wed Nov 22 12:56:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viacheslav X-Patchwork-Id: 168361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1301210vqb; Wed, 22 Nov 2023 05:00:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVLmulN3E0wcNNRBaBlIpsdQKM/1omlQclKAyLhZCohG+WnmrIQUQp+l/m9w7gGYe8JuT0 X-Received: by 2002:a17:903:1251:b0:1ce:654a:81e2 with SMTP id u17-20020a170903125100b001ce654a81e2mr2414699plh.16.1700658011684; Wed, 22 Nov 2023 05:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700658011; cv=none; d=google.com; s=arc-20160816; b=tfekkVH/feEDGsMQMfP9pkn5T7y/aph0gFXRVDhqkz0EFPJ5je5bZrk6UHW6KjrhRS d7YyeDZjn+VpVsdhQFjILz/PzczHur+eW6+uqQBT98ThlF2iW530bhdWXazgVC46YrO6 IVnwWJPuPQa3IlyWqAQdlvbP+Au35LZxoAKkhWAaEt0UDv5uhBXppALlJ7Xfohbv+p9I NWESVnCkgRBdC0MgevDErNuLPKWQPpWi3a15zwMn6vfGBGwsMgLbRQqQbYiik8bBXBPS HS2rvbS6KfpubRUMUMvDwnwBUWjCsb59M+JB1gIPnAZifWibhVUivKyzCzwuSCRCzmrV rKkA== 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:to:from :dkim-signature; bh=Ulmefl5yig/F+2V9QAbbUBGE0S2hQKZ3IPeqik+z0UI=; fh=fuM2HdasjMYJmpsK/yKIX9kMyLtOX64DXh9rV1qBlCg=; b=pKo7aHr579kJtwgnZzqO5ZDI9eYaWiEhNLfxBT6vldgc4PRDnTjhDoHvubv1AhrNlu xkZ8oeXm1fqnMudJVZC2sRPEDxS0zB5ygeMbHtGNRCPUZp6H4PWcCRmydSjBTavbYY85 59UddVDukQcFndlpdaJDMY9wL8LzgwGWgKPjeBIoiKHARgjnQHQSC3vRF8FzcMyO7hw4 IRBPng1gd8bYpfNUyxG++GaCqyGDxn8vj2eS0xe4vU0+Bqe53Y7Wacbme4WdBrVSSDHz TBPE8dc3n8jq+2SgM0ebXVbPkUhxWLaM1hWrViPQOyp6Rv/Yawb97fNQ8FsKZTrkH3Mj igeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=obnqjWRU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b6-20020a170902d30600b001c9ce2b6b9esi12211150plc.262.2023.11.22.05.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 05:00:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=obnqjWRU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7F033802E3C7; Wed, 22 Nov 2023 04:57:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344295AbjKVM5Y (ORCPT + 99 others); Wed, 22 Nov 2023 07:57:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344226AbjKVM5I (ORCPT ); Wed, 22 Nov 2023 07:57:08 -0500 Received: from mx.msync.work (mx.msync.work [62.182.159.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB6FB10D5; Wed, 22 Nov 2023 04:57:02 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3F41A53EDB; Wed, 22 Nov 2023 12:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lexina.in; s=dkim; t=1700657815; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=Ulmefl5yig/F+2V9QAbbUBGE0S2hQKZ3IPeqik+z0UI=; b=obnqjWRUmpCSg3j42I/4HoO5hACMJaABq0MXfrlaqopRm6vDn6C0+Mj7rsbVzWyuJB6i0R rjEYNy2N5QabL5j55uL2EuFfluAXcRx1fVMIf3tqMODJ8ExoqO+oOUWxCMeB2ZZDxgXCtr 4WkKzmMnRlipOLOWil8NEG8ZgBUTv3Vp9hPkE7Z2lrMctIPzXeWkmdMsWZ7zhjRe10kITM sUfdmvw15/XacURTXUN/K3o3z/+4tys4qR+AsvUCkT9H7A86ubeZVzxzOvPG2XDsRLwb0w wCCSRyH6+5lprySgxtdAGPrpxv5NwOhk2gFWquNk4bZtT99ub8WMI+zbFJuvAg== From: Viacheslav Bocharov To: Neil Armstrong , Jerome Brunet , Kevin Hilman , Martin Blumenstingl , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring Subject: [PATCH 5/5] arm64: dts: meson: add dts links to secure-monitor for soc driver in a1, axg, gx, g12 Date: Wed, 22 Nov 2023 15:56:43 +0300 Message-Id: <20231122125643.1717160-6-adeep@lexina.in> In-Reply-To: <20231122125643.1717160-1-adeep@lexina.in> References: <20231122125643.1717160-1-adeep@lexina.in> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2338; h=from:subject; bh=5P5fYju1OuJiL/byEBiP3PSi5QUDOL3VUZ+An0H3Yq0=; b=owGbwMvMwCHmnhFhrJcZuJTxtFoSQ2rst6PzpSIPfZiQwrL/6Lz/Yq6reYpjji2pORTNeLc+Rj79 0t/7HaUsDGIcDLJiiixhHUFT93msvjhxgdEBmDmsTCBDGLg4BWAi50QZ/krcyUy9e1Ag4O/3OF29F6 eL570SVgi+mt7GEMu57ENL3Sagiv4ltcEzrio+it5Q/COaS7csWft72s89slNKV35d8s2VEQA= X-Developer-Key: i=adeep@lexina.in; a=openpgp; fpr=E2FA1A767ACB0716E02E3E7AEE36B110025A8DFA X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 04:57:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783269175259834579 X-GMAIL-MSGID: 1783269175259834579 Add links to secure-monitor in soc driver section for A1, AXG, GX, G12 Amlogic family. Signed-off-by: Viacheslav Bocharov --- arch/arm64/boot/dts/amlogic/meson-a1.dtsi | 1 + arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 1 + arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 1 + arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 1 + 4 files changed, 4 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-a1.dtsi b/arch/arm64/boot/dts/amlogic/meson-a1.dtsi index 648e7f49424f..449b328d62b1 100644 --- a/arch/arm64/boot/dts/amlogic/meson-a1.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-a1.dtsi @@ -407,6 +407,7 @@ hwrng: rng@5118 { sec_AO: ao-secure@5a20 { compatible = "amlogic,meson-gx-ao-secure", "syscon"; reg = <0x0 0x5a20 0x0 0x140>; + secure-monitor = <&sm>; amlogic,has-chip-id; }; diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi index a49aa62e3f9f..6e80bdc525e5 100644 --- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi @@ -1660,6 +1660,7 @@ mux { sec_AO: ao-secure@140 { compatible = "amlogic,meson-gx-ao-secure", "syscon"; reg = <0x0 0x140 0x0 0x140>; + secure-monitor = <&sm>; amlogic,has-chip-id; }; diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi index ff68b911b729..0a6b703b0dc0 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi @@ -2026,6 +2026,7 @@ cec_AO: cec@100 { sec_AO: ao-secure@140 { compatible = "amlogic,meson-gx-ao-secure", "syscon"; reg = <0x0 0x140 0x0 0x140>; + secure-monitor = <&sm>; amlogic,has-chip-id; }; diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi index 2673f0dbafe7..656e08b3d872 100644 --- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi @@ -471,6 +471,7 @@ cec_AO: cec@100 { sec_AO: ao-secure@140 { compatible = "amlogic,meson-gx-ao-secure", "syscon"; reg = <0x0 0x140 0x0 0x140>; + secure-monitor = <&sm>; amlogic,has-chip-id; };