From patchwork Tue Feb 6 14:37:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13547386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BB6F2C4828D for ; Tue, 6 Feb 2024 14:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1hi3gwZfHWAvgdn94T0YmNVBywE6QUQ/xm3bKibro3E=; b=tOszsNcIKq7ZSI xC4hGBr2XBB9mL0zOUmtzwJzWIoPdSHaV6k0gQwdFUbPbptEd7TqgSg1zfOOHUFamhja+wYS9Nn2w gvkCPj+zUO7wYl4wjyyk9a0mhWZk51A6z3P9pmsrOPy/LSPoOr3WYmRlSIrEaxcACJTQUovaY3und gvaFayVTGNKYdtwCo8Cw9e9UALEW3uZne1Fx59aaMcjtslBj1NvaF5AcoEmOrdR+fTLam8hZqYoZs PbjDCCHiblHqNSMRekcbCfPKsBtI2o+bNCXCAhfctZ1g0XXHN0J7phQRi1gyxvMo1T5suFTdjw13K EOe8Z+/F057MimJYzMGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXMaS-00000007tLi-2GZs; Tue, 06 Feb 2024 14:38:12 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXMaI-00000007tGg-30Ao for linux-arm-kernel@lists.infradead.org; Tue, 06 Feb 2024 14:38:03 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-50eac018059so7058325e87.0 for ; Tue, 06 Feb 2024 06:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1707230281; x=1707835081; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2W+bhvv0j8yck+8GT/uP++ViHHwBweYBoHrSumeE15A=; b=DECvoT8EadDQjeyADoBBMfbJwBErjduf8QGsX52zJUPj6Hqf/61PCM/TTVc2e3ZLVN zEC/CxGS7+FbjLCInvKfif4G6HVWNPrordLZzXk6tdJk4x1HQen0/g22xJRFgC5ZvuSY yOD32DPO57Tg9MXsYrubR5VYhF+IocAjuPWC61YPkrV2O4LspY0pq6QQmDE3HD+WBr3J bzmmAaJB0d2NrtaUuqkhuHrME+ViGBPo9vGrw1qMPZgscgoq4igamicJzY8mmMPeOR+L xRH+/T65/+At57LCl4eVJZRug+VuaJ00QZvicX3QvuTlpZP0JGdS2QWj29U9101wnKHq 717Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707230281; x=1707835081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2W+bhvv0j8yck+8GT/uP++ViHHwBweYBoHrSumeE15A=; b=gHfl040T8RhnQeB6Xh0QAqRHg6qTGtaidAdxkApdKYgpLikYa5d48oTWgJcDL368RM hShS+jtclC8K9PhyEoV+wkPvH8LxYX65O3PGr5y/37/IGllGqVywPCpSTcGoRllMmTEd JUK/uI77JTizTsqmHj4/1fm9kUw2D0ayOdyOpXBybpuoVoia3xSENZyHbMPanSkwwvhb //vC188oRhMpyblK1i3SZZC85Wde0uxDlN+DKBfE4lDrYWkc9NsT/5srSi61zE392INo nW6Oap3vzXRJZHKR15hXWAG/1D/0RHvObYQJQziSkMWWDfX91UB+bWHSSiEYs/AIdcXi e8ug== X-Gm-Message-State: AOJu0YxjtFSI0lH9yEuF5D3GX/ef+dZ+Lr8NXzydNJWAjrYayJjk4sX+ T8afR2SYWn+aNtAwgwNAm/YLw04SE1wB5LBOzzVlWddf9LmM6eXRKuEnD4BbvnM= X-Google-Smtp-Source: AGHT+IFq40p5PGRZgK2PDID88ekIhXGdOYju/iR3pvUeF7F3dzHYw/J6u+QgBb2DegU7Af/HkHjnCw== X-Received: by 2002:a05:6512:31c7:b0:511:54e8:b82e with SMTP id j7-20020a05651231c700b0051154e8b82emr2165876lfe.47.1707230280818; Tue, 06 Feb 2024 06:38:00 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWA4bduWkPXsrwXkvP0AHmjMJ9kVUsar3ZVfJ6PAFzztWBt2XGLA/HzTQ6kKQA2T2M0Vz3Tvtm9r4I1EInMLHaOwmsXzoXCHER82pTbiprCITW7TUc/O+baBK0j3xcC7EgLztJSgxkqxbKHFq42s2O8XnO9xWIfiJws9S1IRFCGb4LeYD+TNSOpTtuEihJAiPrWAGEWgcn7PhGGQdOKheWHIJGGHxMkc5hLlbr/3X0TWkGLbIlFkJrSu6f+vWYZ1sbX/ZWiJB1grXNb2xwWroT1eR2lN0WY5o3Wd/fPj2NOePxj572MJUiNU6PI1Gf/ASEYH14JsZRfsyHelKP/KFfKkT0QHAlPKTK3xJBcwbsWiRFeN0UVsm7riXT/P8shLWjTVmssYHVIJJIObse8UfoeZyNuMXBQCLHsQxUbkTXlUB4jjQb8 Received: from blmsp.fritz.box ([2001:4091:a246:821e:6f3b:6b50:4762:8343]) by smtp.gmail.com with ESMTPSA id e22-20020a1709062c1600b00a37585d5dcesm1224418ejh.51.2024.02.06.06.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 06:38:00 -0800 (PST) From: Markus Schneider-Pargmann To: Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Srinivas Kandagatla , Santosh Shilimkar Cc: Andrew Davis , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH 3/4] soc: ti: k3-socinfo: Add support for nvmem cells Date: Tue, 6 Feb 2024 15:37:10 +0100 Message-ID: <20240206143711.2410135-4-msp@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206143711.2410135-1-msp@baylibre.com> References: <20240206143711.2410135-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240206_063802_778789_53EACC23 X-CRM114-Status: GOOD ( 17.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Support nvmem cells to retrieve chip variant, part number and manufacturer. As multiple different devices depend on these information it is cleaner to abstract efuse fields with nvmem cells. If chipvariant nvmem cell is found, the driver assumes nvmem cells are being used and tries to find the other fields as well. If it can't find 'chipvariant' it will try to create a regmap. Some prints had to be updated as I don't read the full jtagid anymore. Signed-off-by: Markus Schneider-Pargmann Acked-by: Andrew Davis --- drivers/soc/ti/k3-socinfo.c | 67 +++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/drivers/soc/ti/k3-socinfo.c b/drivers/soc/ti/k3-socinfo.c index 59101bf7cf23..99794aeb6206 100644 --- a/drivers/soc/ti/k3-socinfo.c +++ b/drivers/soc/ti/k3-socinfo.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -114,45 +115,68 @@ static int k3_chipinfo_probe(struct platform_device *pdev) struct regmap *regmap; u32 partno_id; u32 variant; - u32 jtag_id; u32 mfg; int ret; - regmap = device_node_to_regmap(node); - if (IS_ERR(regmap)) - return PTR_ERR(regmap); - - ret = regmap_read(regmap, CTRLMMR_WKUP_JTAGID_REG, &jtag_id); - if (ret < 0) - return ret; - - mfg = (jtag_id & CTRLMMR_WKUP_JTAGID_MFG_MASK) >> - CTRLMMR_WKUP_JTAGID_MFG_SHIFT; + ret = nvmem_cell_read_u32(dev, "chipvariant", &variant); + if (ret && ret != -ENOENT) + return dev_err_probe(dev, ret, + "Failed to read nvmem cell 'chipvariant': %pe", + ERR_PTR(ret)); + + if (ret != -ENOENT) { + ret = nvmem_cell_read_u32(dev, "chippartno", &partno_id); + if (ret) + return dev_err_probe(dev, ret, + "Failed to read nvmem cell 'chippartno': %pe", + ERR_PTR(ret)); + + ret = nvmem_cell_read_u32(dev, "chipmanufacturer", &mfg); + if (ret) + return dev_err_probe(dev, ret, + "Failed to read nvmem cell 'chipmanufacturer': %pe", + ERR_PTR(ret)); + } else { + u32 jtag_id; + + regmap = device_node_to_regmap(node); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + ret = regmap_read(regmap, CTRLMMR_WKUP_JTAGID_REG, &jtag_id); + if (ret < 0) + return ret; + + mfg = (jtag_id & CTRLMMR_WKUP_JTAGID_MFG_MASK) >> + CTRLMMR_WKUP_JTAGID_MFG_SHIFT; + + variant = (jtag_id & CTRLMMR_WKUP_JTAGID_VARIANT_MASK) >> + CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT; + + partno_id = (jtag_id & CTRLMMR_WKUP_JTAGID_PARTNO_MASK) >> + CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT; + } if (mfg != CTRLMMR_WKUP_JTAGID_MFG_TI) { dev_err(dev, "Invalid MFG SoC\n"); return -ENODEV; } - variant = (jtag_id & CTRLMMR_WKUP_JTAGID_VARIANT_MASK) >> - CTRLMMR_WKUP_JTAGID_VARIANT_SHIFT; - - partno_id = (jtag_id & CTRLMMR_WKUP_JTAGID_PARTNO_MASK) >> - CTRLMMR_WKUP_JTAGID_PARTNO_SHIFT; - soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); if (!soc_dev_attr) return -ENOMEM; ret = k3_chipinfo_partno_to_names(partno_id, soc_dev_attr); if (ret) { - dev_err(dev, "Unknown SoC JTAGID[0x%08X]: %d\n", jtag_id, ret); + dev_err(dev, "Unknown SoC JTAGID[variant=0x%X, partno=0x%X]: %d\n", + variant, partno_id, ret); goto err; } ret = k3_chipinfo_variant_to_sr(partno_id, variant, soc_dev_attr); if (ret) { - dev_err(dev, "Unknown SoC SR[0x%08X]: %d\n", jtag_id, ret); + dev_err(dev, "Unknown SoC SR[variant=0x%X, partno=0x%X]: %d\n", + variant, partno_id, ret); goto err; } @@ -166,9 +190,10 @@ static int k3_chipinfo_probe(struct platform_device *pdev) goto err_free_rev; } - dev_info(dev, "Family:%s rev:%s JTAGID[0x%08x] Detected\n", + dev_info(dev, "Family:%s rev:%s JTAGID[variant=0x%X, partno=0x%X] Detected\n", soc_dev_attr->family, - soc_dev_attr->revision, jtag_id); + soc_dev_attr->revision, + variant, partno_id); return 0;