From patchwork Tue Feb 6 14:37:08 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: 197487 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1605839dyb; Tue, 6 Feb 2024 07:11:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGM6dFF/4fobF99PQ+MyjVv5k5/YF2ZnOuWDHwrtVhdy7sKbtCRt2MShA50EuBxORTo75d6 X-Received: by 2002:aa7:8492:0:b0:6e0:4f30:bcfc with SMTP id u18-20020aa78492000000b006e04f30bcfcmr3911226pfn.9.1707232314069; Tue, 06 Feb 2024 07:11:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707232314; cv=pass; d=google.com; s=arc-20160816; b=T/k6c3y3xzkSynKBx+EOxumKKG7MBF2sSs6Kk7pvIJUbrnon2IcRHKBLc26lqIecPg bfVAPWUOOFW69AIIqEk9HdCKiR+B6mi+g9JNP/tx/ld2Bu7dCh5JhJ2vlSoNEUsGQ8i8 dK3tVyHAMFAP+51sQAX//I47Zdy8MBDPpDnQ6jA6HNJXgQ1jzUZxuCjlZ4i7ZOmzwdJc 08QFvI0CJw+uTptCep1H8Rv6B7KYl/Icl/OUALhgF+pIo9JPc3UtyDPCZjqdhBqaoDJI twM0/j5DrDO/ghymX/vBDQWc68tfBPIRWUHXvSLhmij8005nF40lMhoHL0lYPPwIP1q6 ZB/w== 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=9NBgzZuNQ3XMEUB9jdo795d+Eu/PODGnrBF33YaDmlo=; fh=d1XqJKdU7js4pcmjSbESlyPAsf7GE+P2G0U8NjLr/s0=; b=Zzl+xZsgeK5BI/R04G4TmTnZJiLcmEGdHyiw6vTXk33gJx5Xv+yKMK8Fxg0TsdccYc 2a5OGyTs2jPMsMSb+qPi39MLF/lWHlOeR6y+1weFfSeRCXhDPmYNBdm0EolfTsWVagrF H8f0V429tCFfJdJ+6Lk9IlsYdbiTkOBkORH08HtZpefV+7Ck8nA2dS//GLRVsItN4XSL Qt+XA/bpTb30Bzzcigi1n6cvoXCm1VjuD3vwQWc+SsuB4N9Hfa8BMkKkqsgo+Dp3GMI0 q5Eg+WU066mjTAdp8gAhq8+IAp8PBpHGM7tzNhVVQOsC5nqnEL2RYg2oMlDl370+Kw20 xiWA==; 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=qsGMkixy; 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-55127-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55127-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVaA42bnkrFxIxL4CT1IbiqB6y26dMvwXqLI72jNMuNH4zUWa+/V4/FlhIgmy936SnzWXBQAQJv5dNOQHZiClNOzI3bDQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 30-20020a630b1e000000b005d8fdbbd5d6si1707584pgl.718.2024.02.06.07.11.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 07:11:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55127-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=qsGMkixy; 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-55127-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55127-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 479A2B2C8E4 for ; Tue, 6 Feb 2024 14:39:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB8A3131750; 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="qsGMkixy" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 C279E132C24 for ; Tue, 6 Feb 2024 14:38:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707230282; cv=none; b=IcQe77jAMn1MZx1eryw5yL29Nol7JNWSBzKtjiMaqNuAkZTsGva0TewT6X20M7LKaRicoOeA61wpzjn/25WC9TqKVT1Hrgf3A73iZXmgn5+pjwG8B4pYw55dPEiPnePss28rUtfvwGYRl6GkhIQ8jCCpWGN1GPprsgncMguPyPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707230282; c=relaxed/simple; bh=xtB3eH2nc7TbBl5//VOpSw/2z14pXQ/9Y8lHi5/2iUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X0hV4n9OHJcOazOdTLVDeBgH07ySpnjBZjiWoHJ3Duw5l8oIrkj20+uDvmBKeBl+UXSMiK54vWsKvYGiwZEoKQGiHzuIArgiimd4NyirTIlJTDXUG6pSPJoUOLH1G8cBZ1esoxClTZnJoFPYcpjzaNvae7Qz2+BkzWuLvQgfu5w= 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=qsGMkixy; arc=none smtp.client-ip=209.85.218.48 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-ej1-f48.google.com with SMTP id a640c23a62f3a-a380c98e824so124708066b.2 for ; Tue, 06 Feb 2024 06:38:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1707230279; x=1707835079; 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=9NBgzZuNQ3XMEUB9jdo795d+Eu/PODGnrBF33YaDmlo=; b=qsGMkixyaX0y7ygfx4CsJcsLyjvGJ08Hc88xHf6lCGFLwDfaX/AsFwUNISR/3u1qr0 1wR6f6jeDs3/Ej3xenpls0RmMCJ9uiRNLzCa0Vdm18lWkl2WYNmwvwUZP+RK98+nR1qz pwvBBUruKviPEnWBwM7wnlCIeNKpLxf4ZLy1ELCYkb7jDRcDLbBdaSNNqhFPJvCCABhY fQbPYUdsUrl3FnuWyOKtPeoXSwK2ytcT4wfPjUXJb18BtOP1UHkmbrhj7fH2ZzPknX5C 8aYItpOv3VDhK2yaXaN6AkgFDgXQW8ILbSmPswp4mS/4dNAwrm4WK8JNthjp90Mn6LWH VSVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707230279; x=1707835079; 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=9NBgzZuNQ3XMEUB9jdo795d+Eu/PODGnrBF33YaDmlo=; b=aKfz2OH4w20BanPh8UN/eshMkCxfCAIA8lbJ0RpP5hhH/2sgpeDu/jCXqXnJ4tts0+ zMR73Zsdmb2P1MJEW7BPkuzr524cjeWVQ/lhCJ3Y2ifF8JlCUHAWZewrnrg3ANGVtelC 0KFE2/I11aSaZ67XJfQLl+mDdmcB6vz2SpB96jExIjmN8jUbFrPY1gJdbDp/3xOpEGgg X6Cw3TXci5vBewh5N/GE0baKRAM0ZMmEt9ph242KoY1ybNZvJ+dg5WNzr/wyUvD7njhA chlLpcywg42l7Ab2ofDN+EfFm+d0sF3hQvRrogURbEjhujA1mhdMtj8AgRXzK9E/ZFNS YRwg== X-Gm-Message-State: AOJu0YziKE5RTJkLdZbLDwn8qj9DRIwjZOVRVBCHfrWSwAiUfUiauVX/ fEmP+rR6FkRIJgKV9S3hk0zSgcvKgYQw4c40NUc+HZRQs2mFuV1XiSoZUbSj/L0= X-Received: by 2002:a17:906:2e8c:b0:a37:b496:f0ab with SMTP id o12-20020a1709062e8c00b00a37b496f0abmr1833327eji.14.1707230278865; Tue, 06 Feb 2024 06:37:58 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXg8CxjHULLVpZPgZYWeojozwzAg92plTJtWd81a+UmkuTg8Qx3/8fQJBUIPRiYarOw0M/r2WrIaR3HQHuAV/Hx4TvqSIXWRy/pfYfrIN1sbHW5GF2QtBQOxtgDV6judqjqkCBjAllXbA43szdyaoJysbOJPfjXmu/SnFPi5IcitGSrbRMco1K4ouSinHqmemKn5L5H4mfA5sZAuu0XdtwwoDa037B7f8MY7GxcJ4aLYu2Fg4R31HygCq9LNxXuIePFzbANj4TJlfaoxKnpQaIxCDkoAuXab0E3XO8/h5i39vD4p5R3Efipux3/xxnfyTf5jmTLiO4EC/stLIqa5dm/H4/llKHxmPXulRSxsOrKhVE5ZhRUtE148PwUnBKN+mi0afsVBkpnZnyzGCMNilcpjeU7TN3I0lD5hPs3HBZpurQUX1iR 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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 06:37:58 -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 1/4] nvmem: core: Read into buffers larger than data Date: Tue, 6 Feb 2024 15:37:08 +0100 Message-ID: <20240206143711.2410135-2-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790162831115376590 X-GMAIL-MSGID: 1790162831115376590 The actual size that nvmem is using internally on a specific platform with a specific devicetree may not be known in the consumer code. The maximum size may be available at the same time. Allow the use of larger buffers in nvmem_cell_read_common() by setting buffers that are too large to zero before copying into them. Signed-off-by: Markus Schneider-Pargmann --- drivers/nvmem/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 980123fb4dde..6fa061ede605 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1806,12 +1806,14 @@ static int nvmem_cell_read_common(struct device *dev, const char *cell_id, nvmem_cell_put(cell); return PTR_ERR(buf); } - if (len != count) { + if (len > count) { kfree(buf); nvmem_cell_put(cell); return -EINVAL; + } else if (len < count) { + memset(val + len, 0, count - len); } - memcpy(val, buf, count); + memcpy(val, buf, len); kfree(buf); nvmem_cell_put(cell); From patchwork Tue Feb 6 14:37:09 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: 197474 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1583294dyb; Tue, 6 Feb 2024 06:39:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTSWz5iNC566uGm+37fTIbb+wXaXWbeG/2HU9rWeSp1ctk/uVZea7unOpWkhPLXprktLhB X-Received: by 2002:a05:620a:9c3:b0:784:c832:31db with SMTP id y3-20020a05620a09c300b00784c83231dbmr2567247qky.29.1707230374395; Tue, 06 Feb 2024 06:39:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707230374; cv=pass; d=google.com; s=arc-20160816; b=zWNEca/DreirR6ZIvnpwlL9CyF8LeMAWZcOpFJj8kAdtEgUMse8l41l5Pf+WGMDUY5 WsGSeSgpIBrUdyZYC6cJANOfBUBwnP4uMVXrP6SpcgkdD7ag2SgeVc3Img5Nm3Er5a+2 xAqq+WLB8FP7GRqkZUSkO6odwMJeeujTn6JmjyBo9jitGK+s5RFd75bAgUjrh+dykjmb FlHB9FnVR8jsgQHGKLQRrnvVFAcMRjRQEQVtFn6hcmBgTJqyFC55AAb54eGk61IrvqeU nE4Nkb8sqOMtgHDdzSTHU3dtPoJqCAotsa10VNguGQpP/jAhF87JLORz5jADMPkHwmsl nhUQ== 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=MGo2FC7WYDd1/me+URO9ZglcapL0YwY+tHoSxOqlK5Q=; fh=xjEey5xERw/8hQKF5ISr6t626Rj8BIqEZFp1H0wO6a0=; b=p7IGWpfuzRf/dYp6gpIlTRZDT62F2QzXtqHKxIiCgcUw34yr5do1BOeR3/AGo50bXn xbLBfTwNkWpfbWq5KyvLFwlOrfXc4yMj3vaEHbfsibnMfo3MU0XMEzy0ga8lA82mAxnK W+UmTM3qvZh/dRoLrzRhVXbgEIAoISktNLTOClgiptlhjOJzO5UOIlCjss1dlFBULw4b aKTmZsi2flMl+ZmreZOW3Zp8QW+j0QrxFs5DER7LeBFhStrfk2VVsiAFePWCPd3FT5a6 swuUCfZoqu8JnITeK+OpaFfaC0pDvKt2kwU9A0SxRB3jjMuLxibYxDcPy5tPNAh8Fs0e e4rw==; 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=F5HaZh7r; 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-55128-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55128-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUT9O6PYxTvd4XjZQY+u3fIWRf5htSmMEyMsaIW3+Kmi7OwHVMw+i32cvRKcDgHwAcFAbejuD5sej8WtymM9MGlBaF++g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bs13-20020a05620a470d00b007858b5855b0si2408424qkb.325.2024.02.06.06.39.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 06:39:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55128-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=F5HaZh7r; 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-55128-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55128-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 335461C221A7 for ; Tue, 6 Feb 2024 14:39:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE172133993; Tue, 6 Feb 2024 14:38:06 +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="F5HaZh7r" Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 A809238DFE for ; Tue, 6 Feb 2024 14:38:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707230283; cv=none; b=VBqBANGFpnwRscMdQ1ppPBbZGfN2OYCgTuzLnNvjIe5e1gGeMtnaRWg/MEjhIg3p4NNBDR2RGa8/fP0H4WWsicXj1TSiUR2fPfiCS02Uj1Yz+4Id6d6UwtMELBjbHy5CHZW5UD/zVbXg7tADOFxzTAKRXRqLGwuXTksm0sc+2Wc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707230283; c=relaxed/simple; bh=HO6KVEaHf/T7d9XWP5w/68iUgcAaz0HDcz/jMuokJ9Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hypwvVRJ0xAKqweRK9zqKSgsXEMhGiJX+aglMeMNC0qM63DgQ9KKsgkGTnZ7S4tnJ1tMP+Re4Az1khMelDarVzT7nHpYoNHF8VuN2efFybKQv8aCJ/TYHA+HS6iUGhHDirD8hqMqpCfhVjMAZ0M33mxd2t7Kt52OHqUPidnxMi0= 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=F5HaZh7r; arc=none smtp.client-ip=209.85.218.49 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-ej1-f49.google.com with SMTP id a640c23a62f3a-a36126ee41eso719925166b.2 for ; Tue, 06 Feb 2024 06:38:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1707230280; x=1707835080; 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=MGo2FC7WYDd1/me+URO9ZglcapL0YwY+tHoSxOqlK5Q=; b=F5HaZh7rV77AxY79Qfo2D4Cf+bc6TPNq5udZI5pfaXFRgILHCQYQJgsAeHVJPWy/dY xw2XKilNBUxKGHR47MF/X5y0IVk7uNStKVcFfQ1YqXnJy4n8wCvTO3u7EZm+PNGQl8Al yH3CC3DdZuEMes2/r++1evXf2xPlAoGibe81SGBmk/Wiw3pbIG6QhPlz1rITx7BdrqXr Kaovwzif94lhOZTaVzqDrSqMdppNwcsP4P8IRQFDSuN2fM2EXjruBHKLilENcPw4E/30 QxiuQn1SAg1IKH0M6s3Rhyoqucg5i41iFFYIjiD/Ece9e4QaiIbApjyEPKoZbXjW0h3j DvXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707230280; x=1707835080; 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=MGo2FC7WYDd1/me+URO9ZglcapL0YwY+tHoSxOqlK5Q=; b=Xafj58wsZPDIFn2SfTV8LWbnApgvEYPPafvXcQ7H9E9dOR/fgjqrm/jeHkhJ4gMu+t sloSejb+B83qt87iqS/3rL1gq3fcC2TzMOgnQLGPmFp6M7t8QYd+LLIPixo5RYG4yZEJ VJg/b6j+hOOGpP7fwYyUGoHq+EbEQyFcOxl8F0iUYIUMBNoDcQs2bhUd/1qrJb0jH7q5 /LlM1IQgMSBEP0Q5vd+Gc12WtYlAYoXiwrMAP8XLdnylfoIT2NvDyo/kvRfH4yTijkNG 7zz8X7lmCaNhkpl2gUF5t/kAUNbaUyB+OUPzHjAF57uRfjfzeSsBxZTZpNvLTa5P0y+9 86zg== X-Gm-Message-State: AOJu0Yx7DxQ8/GgLd5SqikHjg1ixc3prWKBktR6VgkpmdnAP79r9hlf9 OGeQt4yMk4uMSmuYCfpgNaJofWE9yKr3T1W4EKvvehlq0JTOGX0FdPCWWRXelic= X-Received: by 2002:a17:907:785a:b0:a37:ee9c:273e with SMTP id lb26-20020a170907785a00b00a37ee9c273emr1653077ejc.53.1707230279829; Tue, 06 Feb 2024 06:37:59 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUXWFMbNZogEPZ1ITtLgkoEB7IkPokqz7J5Zt/rg5GPnr0bIPNBNVMhc624wKDa5A4GCh+nu2y+4j91OIUDKBeYcPb763wn0zCzf+F+1dxkqRWMQuIiOsT+HjZQs2XzqnT/RtRe+fROtFviI8I5XsL1+TjoUyZX1Ppr+qEdbCTSHS51JvSSxdjpXj5b35O5pDmDdi9DBxL7bhAAhkTvQKLUWyAO+yxWzXa/uW+zRaPkRF2YYxXrEELv120fyFcSmARQQaWi/zJF5vUEqpqp+uiX8oGPqWNflVriBNezI0dGq6mIKRnXla7t2QQBQRANso9sMHj4/QHnXaKpSAZrLJmtjmY23JuV0kUOihwPSezjpdYHvOL5aQqw8GNNSXb6KfvypgWmTeVTpl0srxEFQPZzIrLq/PvdamOx/FZyRlDVzlMgfUla 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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 06:37:59 -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 2/4] dt-bindings: hwinfo: ti,k3-socinfo: Add nvmem-cells Date: Tue, 6 Feb 2024 15:37:09 +0100 Message-ID: <20240206143711.2410135-3-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790160796937154853 X-GMAIL-MSGID: 1790160796937154853 The information k3-socinfo requires is stored in an efuse area. This area is required by other devices/drivers as well, so using nvmem-cells can be a cleaner way to describe which information are used. If nvmem-cells are supplied, the address range is not required. Cells chipvariant, chippartno and chipmanufacturer are introduced to cover all required information. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Andrew Davis --- .../bindings/hwinfo/ti,k3-socinfo.yaml | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/hwinfo/ti,k3-socinfo.yaml b/Documentation/devicetree/bindings/hwinfo/ti,k3-socinfo.yaml index dada28b47ea0..f085b7275b7d 100644 --- a/Documentation/devicetree/bindings/hwinfo/ti,k3-socinfo.yaml +++ b/Documentation/devicetree/bindings/hwinfo/ti,k3-socinfo.yaml @@ -26,9 +26,24 @@ properties: reg: maxItems: 1 + nvmem-cells: + $ref: /schemas/types.yaml#/definitions/phandle-array + + nvmem-cell-names: + items: + - const: chipvariant + - const: chippartno + - const: chipmanufacturer + required: - compatible - - reg + +oneOf: + - required: + - reg + - required: + - nvmem-cells + - nvmem-cell-names additionalProperties: false @@ -38,3 +53,9 @@ examples: compatible = "ti,am654-chipid"; reg = <0x43000014 0x4>; }; + - | + chipid: chipid@14 { + compatible = "ti,am654-chipid"; + nvmem-cells = <&chip_variant>, <&chip_partno>, <&chip_manufacturer>; + nvmem-cell-names = "chipvariant", "chippartno", "chipmanufacturer"; + }; 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: 197486 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1604152dyb; Tue, 6 Feb 2024 07:09:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqoiFj3OGSCzSv19nFPWJyyuSTeODBSjEWVYkWczaJXiUeM+jySih33O08hhFM1F0itmeR X-Received: by 2002:a17:90b:f18:b0:296:4c7d:8fca with SMTP id br24-20020a17090b0f1800b002964c7d8fcamr2855899pjb.25.1707232187201; Tue, 06 Feb 2024 07:09:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707232187; cv=pass; d=google.com; s=arc-20160816; b=hVY2BnWEOa1YLp61Kvx2BovsdY63tHq1f9eNFTpn2Mh0mzsNHsAT3FA/9uS6qD1dUj SxgcuklvDjQt4J8BQ95PGuUBZXlvz2FNge+Q7ZPmxoR1ERE8Xlu9+4e4eooYrIpG7ohf sS5SE4eSkCsmxG3y2MZtnxAcakQvBOb9xpcOMnWamya2Pv8IUnqENYRmgKoufboURXkf 98w8yeU8Come/57T1C+otBva3QgtmCM8IT7mVVBz71y4NYpPbvZMLbjUtWJAh3GRzwVq N8LIwm4fn1JrZt6HrR5L767YbwAHF680QepHpB3ySbrchXTi0KdIfV8L1j7OinKMXLFL GXVg== 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=s2JlYa3ZI5riTDTJMVRepvYG6OoyBQS7u3dr8zAF4ww=; b=Hk3YTGq53c/yypHtiPTU4JEm1iQ2KKPA6yO1T4/Rxivlcl4lpCdrKGcASmcBJYGZa7 RZ5lrIUa0ZXp6jD628N+PY32ZX7T43rOyNchUT3Te8wsMHYib+7XMZBzl8hq16KrU+CL Rqpdw+nqVP+H0MHwpZ9u5VZb6sIQZXjXwqFQmNSaFSlePghaBxUsRB9VD834FlhF/wio buDFsk0kXgiGdeV3hNCVWfVAa6alf3y7zIK8WajcIb0ptVm1OYcFXK+fFWNKtSKKo5W+ +ytOVxfwwpmtF+w4Wi8OmkV9NeP2mffc+TFbTQbxbn+j1EG2+cnSHeD6NTaNM5TaHu2y heXw==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55129-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVbsUsySc41BIlu2pkiqzpCDyTL7ZHqRpw82VAoLibmAHdZTKlPGDoyKPSVvcUKgrLVvQeZ4h4oI6yyC1AsBe1D+zdwgQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m6-20020a17090a34c600b002906b739813si1230129pjf.151.2024.02.06.07.09.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 07:09:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55129-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55129-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7A92AB2CE0A for ; Tue, 6 Feb 2024 14:39:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27E801339AB; Tue, 6 Feb 2024 14:38:08 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790161398805294798 X-GMAIL-MSGID: 1790162697946645946 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; From patchwork Tue Feb 6 14:37:11 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: 197475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1583513dyb; Tue, 6 Feb 2024 06:39:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHj00FTilAaUnOu8LeQRnRpWAJUwztny4U+e//hG1KXgALbN2NKB8VsOgEH/j6Dqn5IT5Oq X-Received: by 2002:a05:6808:3a06:b0:3bf:e6c5:9b1f with SMTP id gr6-20020a0568083a0600b003bfe6c59b1fmr1216868oib.43.1707230392992; Tue, 06 Feb 2024 06:39:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707230392; cv=pass; d=google.com; s=arc-20160816; b=EQuNppCOvPN60hpkn1QOfGCfKeioA6s4NluKD9uPB9/VlACb7xGJezwBvyjhssZykN SR2MEPRde4TnvR/b1hmBhTuHqLWWH+5cVbbxL0l4ZOps+pgWU3Iu7HUmrTd7+z/Gw4ry S8Ny0nHia6NTgSOTSzfJ7pkWo3OPnC05xe30lR1ihtuoY1jp9Ax/rN60v5+Ohn95WkGn aiPTEMNt9ba9cMtYz2YZVVC8Qe+uo6FbhuSzd3uFFGxnJBMUTWot629FqOeXBUlHTuc5 gl7boPS4TJHGNKZU6jc/5N0wcMMIHNCQFKO9GwPS0jbt79Pn964uuoI+DTMqSC/+NM6B qtVw== 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=mF/Kh9xpZHCKBcFBIr8xXoDa+aUxtWpcGMnQGhXMLkY=; fh=+QfFFIlXF8yEGePw4qH05mWQg+SQcie4fXSugM9E/v0=; b=rsPslGElvJcp4w0bagQeBMwOvvWKaslD8Xzdv+UdR1UWFkYKoYBJDZ4DsPaTEYSJ98 rzOGwKy1f9rG7ys59Yar9hpES5icOIkAV0PVNML6Y1qg9cH+2LFOB0xu3ThndyviwxOE OtBdxvtqPk6vMy1mC/ALbOnsEVqqU/jGCKG/4wvUch3hr3QeALB3jpvBFkerRm8nug+Y 73IZq0JdnnNY6ZDyaEmig79Re3hm3MEyNelCvbwWy+MDRcha7UHNo1oLq+WvZ5LRv3A4 CPXaWX2qanS64rDZUek5BCzzT2ghZG3NAwwkrID/w4kZLFUDCjVwAlG80zM9GKEXNHi3 NUiA==; 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=jBmxg05D; 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-55130-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55130-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXIg70qldgyxcrnu959BzecbqJAuo+WLbTyLXQ/7wQuNE7/p4pswO2NB5B6o55ZZ0UtniWPEkEHUG3aXoVeeat/wOGUKw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g5-20020ac87d05000000b0042b4e02e34dsi2473910qtb.170.2024.02.06.06.39.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 06:39:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55130-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=jBmxg05D; 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-55130-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55130-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A1D741C2295A for ; Tue, 6 Feb 2024 14:39:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5ACD61339AA; Tue, 6 Feb 2024 14:38:08 +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="jBmxg05D" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 7EFF912D157 for ; Tue, 6 Feb 2024 14:38:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707230285; cv=none; b=YmccoXWTHYW/Xy9VDIVN32qr/lb+71wvapJEd8M/0vJikzSPWvxmwJiTuQr6Flf8S5ciRYs/nuLq47uZgmPUJZKe4AzWGPsh4PIz1lpNbeKp7ZLnJ+A84URIaQmNsFAc/NJ1fOkUsCRpgYtggdMhzFuN3AYYEOaZjCPXwNwVwtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707230285; c=relaxed/simple; bh=f/2cueG3Db+hUw8yHz3480LbSCbMp3PrxDGJJ7LSl0E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ry7DO01fiYCWRlBgB7M5JJGXulue51Ck9UnPksaLgl3Vvh4IChPcFANLU2N/RmW/A1lvEnvU0xBKb2WNn2N93e+FwwfyjwUqTzJO+vjdpKiIjpRrdOMkBBSi5WgAK1ZzRRgkjwVoYE9WFqomM0GZvS4Zgzo7A+EW9z5D72pZhYg= 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=jBmxg05D; arc=none smtp.client-ip=209.85.218.54 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-ej1-f54.google.com with SMTP id a640c23a62f3a-a384a7e6103so30326666b.1 for ; Tue, 06 Feb 2024 06:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1707230282; x=1707835082; 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=mF/Kh9xpZHCKBcFBIr8xXoDa+aUxtWpcGMnQGhXMLkY=; b=jBmxg05Dm5E3NktloA/xRoS5uZ4xl9neYw7iVqBflK4DDvmOBKVQbeyaYJr+mG/F2C VqrZ6wukyCEE0Xmbw7Zye7P0LJHoTdQRhDJ1AxyFrS1ExZtBGR3uxR8a6RkNOYkBR9UL BzoWeaSsAVH89tnU+zlM+Mteu41EqGXtY2urXDE5Nzav4KVEExQ4U3K/IONgYw972l1j TvZWESFtxEg5EN1S1v/j0uiG4Kh6Y9mTVAFqe6lZIkBqpOBYM8FMXLuSn0tkacD0YUiL RBJxjHkTSez4RBHVdc40CDoXffC+bRNMrvAvhN5jdL5rN6wgejQ1GunvUh3vy2mfYhqc IVog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707230282; x=1707835082; 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=mF/Kh9xpZHCKBcFBIr8xXoDa+aUxtWpcGMnQGhXMLkY=; b=lJXFp7SmgKE9SsaXb9ZV9uR9044NbeZ2su7GSZYwRgKECzTPnpA6iwl+9QmCgPPUgj vSKJiEsukddNYbchwizedkX/U4EueM/ZrVRu2d4tiqDiAK59IMEId+bBqtI2t1cFDWX+ CYSseem9GS3siwgdWfyB0gWbzB5tLBtvmd9HrZXyBXcaBhbURy4NtZXGKo5uljAUppBk XIpmx1c6osgFVDBQSwF8a0zGNKT6Hno7srUbGDetaAvhZ16Zbvx371rVYbVuK3zTOczl 0Fc+x+TtCI9WimnQ/1l5b2p5WGaEJtpOF34fbF6gt/GJS+J4mC1GfhuQZkBUAxo1iz7X MCSg== X-Gm-Message-State: AOJu0YxTs1olcHFRx+eXncMZaQfq6WhT0Q2o7FCMaU1AvpuYwlhe2zel AVzYCtIch2gBt9OJ4P03R+DrJcD5PZntStIlr8sRtpq34KyNx4UWSNsxbDA3Ulo= X-Received: by 2002:a17:906:3153:b0:a38:52f0:4c49 with SMTP id e19-20020a170906315300b00a3852f04c49mr62055eje.64.1707230281826; Tue, 06 Feb 2024 06:38:01 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWF7Gbu3yiSZnF1ETXTHDiJ8j6rUVsH9sOiCmFo5k2yFXDoldLJ1izSQQaA9RXmZZmNp+qLlULjPfXHqm7ogWNcOZLhw4IC9HCMNsX46i+jfx322iexmcNPklL+RqQP9Rg/+jCY4jPJa0TVRmAQk2YWTarNeFdv26AMZgPkx4hORRzSNXMUqjRxJj51rLnsFUTcF9w9laW/S33d8koZvlJiQIT+W3XrF9B0vtMhIkEg6D0Op46FxUbc1MxMn7JZC25/a3IUxGGhj0iUNaEywe0KGk1UTlKXXIETHfBKfPV/+fSkJOXrwU20C+2qsMDmEEK2+e37VY6obU7yaYO3/1PcWC0hhSX69LkUoGujCEpVGA77Zg3NkL0f7o289CNaocrofjeVb0PQ4oYTGI9EI/dKhbUTmMIlVXXMWUEZ510E+j1M78VE 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.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 06:38:01 -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 4/4] arm64: dts: ti: k3-am62-wakeup: Add chip efuse nodes Date: Tue, 6 Feb 2024 15:37:11 +0100 Message-ID: <20240206143711.2410135-5-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790160816670562857 X-GMAIL-MSGID: 1790160816670562857 Add efuse nodes describing chip variant and speed grade. Signed-off-by: Markus Schneider-Pargmann --- arch/arm64/boot/dts/ti/k3-am62-wakeup.dtsi | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/ti/k3-am62-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-am62-wakeup.dtsi index fef76f52a52e..14419df43624 100644 --- a/arch/arm64/boot/dts/ti/k3-am62-wakeup.dtsi +++ b/arch/arm64/boot/dts/ti/k3-am62-wakeup.dtsi @@ -14,10 +14,44 @@ wkup_conf: syscon@43000000 { #size-cells = <1>; ranges = <0x0 0x00 0x43000000 0x20000>; + wkup_efuse: efuse@0 { + compatible = "socionext,uniphier-efuse"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x0 0x200>; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + chip_manufacturer: jtagidmfg@14 { + reg = <0x14 0x2>; + bits = <1 11>; + }; + + chip_partno: jtagidpartno@15 { + reg = <0x15 0x3>; + bits = <4 16>; + }; + + chip_variant: jtagidvariant@17 { + reg = <0x17 0x1>; + bits = <4 4>; + }; + + chip_speed: jtaguseridspeed@18 { + reg = <0x18 0x4>; + bits = <6 5>; + }; + }; + }; + chipid: chipid@14 { bootph-all; compatible = "ti,am654-chipid"; - reg = <0x14 0x4>; + nvmem-cells = <&chip_variant>, <&chip_partno>, <&chip_manufacturer>; + nvmem-cell-names = "chipvariant", "chippartno", "chipmanufacturer"; }; };