Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3077187rdb; Tue, 6 Feb 2024 06:39:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IG650XQX1ntSL2PncjdaX2iV4ON/0Uv8A0YvzymEm6uyk+GY0TDnz1r61iWceJKCxodGxH/ X-Received: by 2002:a17:906:6acf:b0:a36:c353:952e with SMTP id q15-20020a1709066acf00b00a36c353952emr2139592ejs.41.1707230356968; Tue, 06 Feb 2024 06:39:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707230356; cv=pass; d=google.com; s=arc-20160816; b=EuLipmSCKIMK8P5VKyndnzOj93DgKG4cSjDGWc45kJa2xfCHDDEJg4X+bBgcvQNNTE UTC9aezD6xzCLNaSi7W0zZkTr6seDdvjEIgEk4ho7UqwcdRlD2VTVnuUyN5x+P6AxT6u HFdx9pEZ+LiJtMskcZG/MwaMFwmIIK9WMAxTlCXEYt7HXkV5CUwtF1fMrOLL5RMAUYCp mIgr3YgANWtL6rdBPHkLotZRz8FitcoEGOM+76NatC2dEZGLuSJ2HosPdv9WDiQhvjpz zy+R2JDu0kcTRceoa1Gyc0cSuONGYAJlflOP6TqtDb+g91FiwH2KSugFzDAu0GUOgFun +JQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2W+bhvv0j8yck+8GT/uP++ViHHwBweYBoHrSumeE15A=; fh=3HPSsqwQ85ZDR09e+i4ktmbsA8p2aRknR2BD0R9WkvM=; b=LATJusqaE2xv6mTXeHUoEEjxWBL8Mt9BTRY/nvX1Tasf2q6HJwf0RYAzbWgISMUxIn zpG6rj+dxpR46+iYv2qQsMpJJjrR9p5eEd7kXLW5oMB9+YlmS8GpaZGS1G2HsJjF5MEt c9Lrmw6Rbop/Lf2pDMOMamq4yHqkkMYkf1/9vICUYVaQfy8nCZugKJb6Rs1+T1Ke9hc5 5nniiHtd6VxLVHu3rxswq4DdlD65b3gYq8L/bi8FYZlK2W93lCpEnWcKEeG4qlGzSP2Y JOYHi2tspBH03myP7u/bh/fqEHiktAv+EZF7B1tLfrmHqVRDWqdOw3tVmj1Pr0ItMfSR TcSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=pIO21g6D; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-55129-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55129-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXZ17MofFUOWdo15Ra2Q1Kfu9UQdRaQJy3NN4wdjyegKSzXVc9eN4aUFJ2hZCV2U/izfY35JaDx9yVCmzwkYdcoSILRk7vWOKZTSzcFVA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p27-20020a170906229b00b00a37041208a1si1129067eja.28.2024.02.06.06.39.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 06:39:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55129-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=pIO21g6D; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-55129-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55129-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6F9081F230D3 for ; Tue, 6 Feb 2024 14:39:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0C6F133428; Tue, 6 Feb 2024 14:38:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="pIO21g6D" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2245132C39 for ; Tue, 6 Feb 2024 14:38:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707230284; cv=none; b=rcR9qKx7qbtVtXk8P7W6DjLXNMggrqtK++xT6r6sNLz27TVf4c9ZRMNhKpAfi0uEmElJsbSW9JE4jUcqFpb7OpaGadMFaME+GEONNeHTLv6KF2F+7g5yX5Y0J4BEHn4Je1/IrEVuGwMySwQ+8L7xzaCgwJwOiYpikhQezIaAjfQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707230284; c=relaxed/simple; bh=JSA+JTxZwyy4vGSW5/N+RDxQNtaOg/Fg9ZTWoKkSIvc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E+ar8OTcENLCKvEgj4wWaOzGWbaHNlyIoroiZw6ShCtqTTZ+0+IXfERX9VJ33PZY2FyoEgMqGsO+eH7aZJlvuYpoCrV6+FeqKcFkKPENZikngjXULmDvLrHYgn5OBIHeWFkdTpjqI9I6fSi68K90c3mOwMg3m1ERKxqHOYDHS/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=pIO21g6D; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-51025cafb51so8430704e87.2 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=vger.kernel.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=pIO21g6DwTfnp6YimaXLBSBWFgadK8O8cYB0d+aV717JRS0dMUkeLY2zox8sO4Gikd a3gaHeV1QQTrGP2AcfTR8B9IU4geZoY/Lac0et8y0FhojuOxTqY2U5gCGsIZaJc/XQU2 wlIRmZ7hj6riSBhLSNaC3NN0MWYk/UuYC9u0lp64r2+cU0lMKBobusfCy9NVUYR6I1qa vbeZJGsd4Zd4RgRArCfWuo5JKhLqx/kxYUVHDkiGGO/y1zclvEkYmiHAqnVch2YQxrLX V1fSEbwI6zxztIb4obKvK8mtDBKPP3NreSCrrGL19ZOlNE5lsOXIeGUwvPKvuPNM+JuQ Kd4g== 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=A3KUqDh0UUFLDwk4T87JTibf8eMV1o9lkAk0NSXGiIETyvqROXKiLsP9l+g2o9qKQl 4RiNRRPTLyIATbKvUn2huyU4hd1WsEAQ8VrurQ71NQBPMrf3Pvr6ITCp195d1ttCJhri fR1bVERHKQPj9NFM70fehufJsDPgEKF5ojZHaqfHcSb+leVd4gLYEaYuhNs7jmsw8swc yXOpQXbGUlyuE7lEV6bc7OyKpyUzIeeylxaN48spnlGkXCU5YsUatoPB4WN+Qj/Keb4l HESmijJq0qT3B7rhQdJmEd+q+i91kYsw8iFDOLT9FoXOa4LrBXcj/HVdLMsYdTjxpcPB Z9Jg== X-Gm-Message-State: AOJu0YzBET5DDOj1qFD7Bbh5xqhhuSRchp82H5PdDy5QOHRTO/KfNtxf ZX9kQhyYEjsV8PMdH08+w6srDB5Ak7j9XPMAFUBqMvR/hYVmouMw4u8Y63CtQNw= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.43.0