Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1360129pxb; Fri, 21 Jan 2022 16:29:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBEUxCu6w08xae6kN+rRRLApa10KRSEeunVByLQC6rGgLaGzigFPoaXiv1w5F2vKk6iktH X-Received: by 2002:a17:902:74c7:b0:14a:e071:8ce3 with SMTP id f7-20020a17090274c700b0014ae0718ce3mr5843902plt.108.1642811368235; Fri, 21 Jan 2022 16:29:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642811368; cv=none; d=google.com; s=arc-20160816; b=QRSuTSP3QO09aLy/KQsAVvStMRTgdFTv5bXnOUu0yB6YJiup2QchvGcKD/WT+5IieI uRgFximZHKbijPnTJV/VaM/jpKvLVtFKSm6/cQ61pr/K5ejGRIcZ1iKDHaJaqLtkbSKh Lwrq0yphmk+h/RuCE3aOwtR2uk5NVHGSEhdyqosYZtLSV202MQzqabo1shKrvnA9BlUb 9yVxtIuIF/i7pRtuzbmEjqdDDEe/0yUri97T3KGYqKlTuiJ+p2UpGXn4894Ax/wOdd8t Xd9+lFBJhxiuq15AwFmGxsSajmEWWABLhUe8d/19aT0qG0CUVelC2ADbCa8fTkpdZo5S 4LwQ== 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=LEQ1F9cepcEMuuKZ1mYZLbVfU+Rxf9QClErwNjlXhrw=; b=oWCVOpx4kDcq+HYurz3NCeUOFLipQ2tCJAPBC/GceCEdm2Xu0Krnbn8UolMvzCyHyK HCQNQxPHOc33IXqPwvg5I2zYRRbkzn5Rxc6TYbEvrKjE6RJuaFYqA5G4W3xiVzsJ/ibn RxGkq9LpHVEgkYrNDpMZmi3TR5EQ3SHi+mXAIL/lCGISUdvtraoTKDCqRG/5WKk7gz5m AM/V1GUt7Jb8MgCuCEP16inip3XDIPwH3MBjqcpjGrwXFVlyxVC3HthdU2EM2u2Q62zR 7oe+QnMwL6kIIKSgnkmTGZZS9lt5SnFRP0U6TZI5D8cr6OT1froNkRBeLzfGrfEsUW95 xwqQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q84si7741329pgq.500.2022.01.21.16.29.16; Fri, 21 Jan 2022 16:29:28 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348300AbiAUBl1 (ORCPT + 99 others); Thu, 20 Jan 2022 20:41:27 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:44805 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233355AbiAUBl0 (ORCPT ); Thu, 20 Jan 2022 20:41:26 -0500 X-IronPort-AV: E=Sophos;i="5.88,303,1635174000"; d="scan'208";a="107148210" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 21 Jan 2022 10:41:25 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id DE52440134FE; Fri, 21 Jan 2022 10:41:23 +0900 (JST) From: Lad Prabhakar To: Geert Uytterhoeven , Magnus Damm , linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: [PATCH v2] soc: renesas: Add support for reading product revision for RZ/G2L family Date: Fri, 21 Jan 2022 01:41:17 +0000 Message-Id: <20220121014117.21248-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 From: Biju Das As per RZ/G2L HW manual (Rev.1.00 Sep, 2021) DEV_ID [31:28] indicates product revision. Use this information to populate the revision info for RZ/G2L family. Signed-off-by: Biju Das Signed-off-by: Lad Prabhakar --- v1->v2 * Fixed freeing up soc_dev_attr in error path. Output from SMARC RZ/G2L: root@smarc-rzg2l:~# for i in machine family soc_id revision; do echo -n "$i: ";cat /sys/devices/soc0/$i; done machine: Renesas SMARC EVK based on r9a07g044l2 family: RZ/G2L soc_id: r9a07g044 revision: Rev 1 root@smarc-rzg2l:~# root@smarc-rzg2l:~# --- drivers/soc/renesas/renesas-soc.c | 49 ++++++++++++++++++------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/drivers/soc/renesas/renesas-soc.c b/drivers/soc/renesas/renesas-soc.c index 7da0ea3587c4..44e365b36b26 100644 --- a/drivers/soc/renesas/renesas-soc.c +++ b/drivers/soc/renesas/renesas-soc.c @@ -371,6 +371,7 @@ static int __init renesas_soc_init(void) struct soc_device *soc_dev; struct device_node *np; const char *soc_id; + int ret; match = of_match_node(renesas_socs, of_root); if (!match) @@ -391,6 +392,17 @@ static int __init renesas_soc_init(void) chipid = ioremap(family->reg, 4); } + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENOMEM; + + np = of_find_node_by_path("/"); + of_property_read_string(np, "model", &soc_dev_attr->machine); + of_node_put(np); + + soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL); + soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL); + if (chipid) { product = readl(chipid + id->offset); iounmap(chipid); @@ -405,41 +417,38 @@ static int __init renesas_soc_init(void) eshi = ((product >> 4) & 0x0f) + 1; eslo = product & 0xf; + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", + eshi, eslo); + } else if (id == &id_rzg2l) { + eshi = ((product >> 28) & 0x0f); + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "Rev %u", + eshi); } if (soc->id && ((product & id->mask) >> __ffs(id->mask)) != soc->id) { pr_warn("SoC mismatch (product = 0x%x)\n", product); - return -ENODEV; + ret = -ENODEV; + goto free_soc_dev_attr; } } - soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); - if (!soc_dev_attr) - return -ENOMEM; - - np = of_find_node_by_path("/"); - of_property_read_string(np, "model", &soc_dev_attr->machine); - of_node_put(np); - - soc_dev_attr->family = kstrdup_const(family->name, GFP_KERNEL); - soc_dev_attr->soc_id = kstrdup_const(soc_id, GFP_KERNEL); - if (eshi) - soc_dev_attr->revision = kasprintf(GFP_KERNEL, "ES%u.%u", eshi, - eslo); - pr_info("Detected Renesas %s %s %s\n", soc_dev_attr->family, soc_dev_attr->soc_id, soc_dev_attr->revision ?: ""); 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_const(soc_dev_attr->family); - kfree(soc_dev_attr); - return PTR_ERR(soc_dev); + ret = PTR_ERR(soc_dev); + goto free_soc_dev_attr; } return 0; + +free_soc_dev_attr: + kfree(soc_dev_attr->revision); + kfree_const(soc_dev_attr->soc_id); + kfree_const(soc_dev_attr->family); + kfree(soc_dev_attr); + return ret; } early_initcall(renesas_soc_init); -- 2.17.1