From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF0661B5310 for ; Wed, 21 Aug 2024 10:59:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237996; cv=none; b=jobNMmYCtXn9oJcjhH1KC0nWfy758+oCjtkHaxfOjB33mpCcGmr1PSVM9NhstfJ2mWlJT2xv3bqX9Ov9rX0b6wCuClClDpPoGKJH452O6kO6G6AhLLXpFdjJWPF2H8DdYtFLG35cJqccjsaa7V6JDc6Kg0D+AfBRFSWDABouo5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237996; c=relaxed/simple; bh=Tb7mcQWNr9yNvFm4o+lSxpWxsHkML9cqEr8oE1gW1gs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kazC6p9T4UXgcO6xkjUYMD0+vTsT8bMNu6mgQVK+cs/XK3Rbd3B7As0BOCHftp80gi23l1yRZrwevTvSnq+AdHVazIk5TBPIZg280HNPY6eA3M4ZoXEbnN2rEcT7ftbhtYn3XikS9lcMzrNLCymQo9dbyvoH1avE1Od700vc4pI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=qRaGUGE1; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="qRaGUGE1" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 106881483DEE; Wed, 21 Aug 2024 12:59:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237991; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=crou9icPFQt6qy3frq3zWNsDVrBMyW0y4VXPpAGZ1pA=; b=qRaGUGE1xf+8Ul3ZG4giMuFfKzm0Ur44w+zplS6CK3K0tR1Rg40kPZbPFkaXPNMG597iw3 FNo4ZWHVG+NgvzZiaYlYvstoscl+7CRgPtH+blxo6W87OCaNnVe4vZGvH2igzN2ZrzMB3E aobBwsu65a4qFAL9mlIhVXzvCCKGkMcn76HoEskvuR5yNCfVR77mu5fJmrMF6iV1QrwXrS aj+APQQOvlC/p2Jv7Rm5ZKmh+EJdEF0+tYOnwdBqbdRrl057mnRu7fhmPKXEES6ibcANLx a0nsNH1N4cMXy8vkOiLrY4xFdD2R2IXcnsR+dhkESfZVSZzPy71p0YzMBEaGtw== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 01/12] nvmem: microchip-otpc: Avoid writing a write-only register Date: Wed, 21 Aug 2024 12:59:32 +0200 Message-Id: <20240821105943.230281-2-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The OTPC Control Register (OTPC_CR) has just write-only members. Reading from that register leads to a warning in OTPC Write Protection Status Register (OTPC_WPSR) in field Software Error Type (SWETYP) of type READ_WO (A write-only register has been read (warning).) Just create the register write content from scratch is sufficient here. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index 7cf81738a3e0..03e60b99f2c9 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -82,7 +82,7 @@ static int mchp_otpc_prepare_read(struct mchp_otpc *otpc, writel_relaxed(tmp, otpc->base + MCHP_OTPC_MR); =20 /* Set read. */ - tmp =3D readl_relaxed(otpc->base + MCHP_OTPC_CR); + tmp =3D 0; tmp |=3D MCHP_OTPC_CR_READ; writel_relaxed(tmp, otpc->base + MCHP_OTPC_CR); =20 --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A3471B5311 for ; Wed, 21 Aug 2024 10:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237996; cv=none; b=BW374gL3yndzK1t64HXt9xIsGjN4qLxdhY6SITTuTWz1QwxzW4RgOIex4DrMWVn0hu5W5qj+9ijZKftjzzuNa3BpwpUv4M7XvwKTMtPs/EdKnj0m5KcUDdavvnuCkHxf3ssOaVSfQ72+uKTEzvSFpMTrG8v5Kdku50iwujyD/a8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237996; c=relaxed/simple; bh=eClaG8jD82jJND52UR5S1toTYxEheg+rPjpNi0zp30k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L/FCQyrGou5bl/+pmaSrwjcAsIAj6XG23rWlPapu0Dfk8PctblWX0QmBRpha0a1URE2kHEhbLWxzLlUvjgXA3NWhEuB7b+L3uCESlA19fY+NANehHWiMmWxOo+2ZX5pvwrWThGc9KDAw1t1ZUXL+KghExWuvHL7t7U20iOIzpDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=qTbTlp5J; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="qTbTlp5J" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D30F31483DF2; Wed, 21 Aug 2024 12:59:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237991; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=82Txq8wjdCnYwZ4j95zlkdbSO+k6QphWbvjQj7xx3Mw=; b=qTbTlp5JakJrsN0woUsh5s94nZgneFmNAoyviJMtzyfQ0lInYveVm/gdfwHGfPgESSmPYW Mk6ZhapHCM68T+FfA9eNyNmySbp1/6JUp4A9ugeAq5W/PTdWnQFoc1BvylP3E+nh8EwmOC ZzW/hf5duBG8wm2soyTi+ab8E24paU3MREzfXecY+H7wXklmCkdFlaPgz38FI4qLNsOzub Dmln7iBA3+5/qu7W4X6EM6ge9O4E6p403K6PpmyNX4kpk1FdHQH2r7wWkqC/+FaLUcqg7+ mIjeKBJcujk2+BGLeuZdrBGxlvV5c9joAOCYkiJbXcf+Qk98aPqTe5FbGGxR8A== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 02/12] nvmem: microchip-otpc: Fix swapped 'sleep' and 'timeout' parameters Date: Wed, 21 Aug 2024 12:59:33 +0200 Message-Id: <20240821105943.230281-3-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Makes no sense to have a timeout shorter than the sleep time, it would run into timeout right after the first sleep already. While at it, use a more specific macro instead of the generic one, which does exactly the same, but needs less parameters. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index 03e60b99f2c9..bd3383eabdf6 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -87,8 +87,8 @@ static int mchp_otpc_prepare_read(struct mchp_otpc *otpc, writel_relaxed(tmp, otpc->base + MCHP_OTPC_CR); =20 /* Wait for packet to be transferred into temporary buffers. */ - return read_poll_timeout(readl_relaxed, tmp, !(tmp & MCHP_OTPC_SR_READ), - 10000, 2000, false, otpc->base + MCHP_OTPC_SR); + return readl_relaxed_poll_timeout(otpc->base + MCHP_OTPC_SR, tmp, + !(tmp & MCHP_OTPC_SR_READ), 2000, 10000); } =20 /* --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F4611B3B20; Wed, 21 Aug 2024 10:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237996; cv=none; b=Z0O4AxF//D401PxTcnVxd8NScstnmHxVEnYzYRD/YJENB0NltvQu76hLyUB/Zxboq2SAAvQ0bUIOEgjzFqSFPg92tudCwmY/RRvbGnvSuB9C/sJzb7j284P7izkqTQWT9FZCnldpPeUFUjKBdovLVIPieLaAtNkgFEfVmFAYstE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237996; c=relaxed/simple; bh=lOVznm8znpiD9wHxT5WSSLClhJbN3kr6RCRdHWLy3eA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hC4WyTkVOZegwtx+zr0yjt1fMbiYi9eiq51eUv5aowAddmIrIkALmDlrEWShwNXLa8uYaeFa1CT6vmC9cU1J+pv5noJG75OyPDKC/pKBDkWzfWvKxacmMUjECFp1FMH7Bhv+lDCSt8K2oRqjZ2GaNg5ierG3y7F/ymHhnzwC4Zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=MqXjlRaG; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="MqXjlRaG" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 334771483DF3; Wed, 21 Aug 2024 12:59:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237992; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=vc+ZNqDqtDjunBZp8r2rWXp9yJg3iRJrNVvLS3A0AHU=; b=MqXjlRaGpeliknT7/fXfpDP3ZLqCTYlPXXl618rXz38QxZTqKCZoV53B5btH7ZNTIrVBXE kwGwoyEpE4GWjvIuiEEx+BxV+VkZzrKz3JDN87ees/0qIfaLWWnEjpMR+/I8b+5RKpkO3V NNJVhQVkdBWi72PEIOxvKm+pJuh6a8B/OGzG3LyZS3TL/o/Pjch7rFzIYryGDT++6dU/YG OZ8o3epf/A0u3cDEgPKAXbWmMcY1EhI5KwoKOznoiQ9LtkunCpOEzmrIqiSuxc9uPogmsj AHQAHwptUiIdiO8g1xfY/FZ50KDxBt/ORWrZbDwk5KJsu8l/f8s50Rk29WYHGA== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 03/12] dt-bindings: nvmem: microchip-otpc: Add compatible for SAM9X60 Date: Wed, 21 Aug 2024 12:59:34 +0200 Message-Id: <20240821105943.230281-4-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The SAM9X60 SoC family has a similar OTPC to the SAMA7G5 family. Signed-off-by: Alexander Dahl --- .../devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/nvmem/microchip,sama7g5-otpc= .yaml b/Documentation/devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml index cc25f2927682..d98b6711bdfd 100644 --- a/Documentation/devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml +++ b/Documentation/devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml @@ -21,6 +21,7 @@ allOf: properties: compatible: items: + - const: microchip,sam9x60-otpc - const: microchip,sama7g5-otpc - const: syscon =20 --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4008B134AC for ; Wed, 21 Aug 2024 10:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237997; cv=none; b=RtEjRZwa0xYVmUdrOLy2YcBy8qYzt0Hfy6WoCArTernMVhwGngTnL+xk5bFzkgPgB45AGm/uZzZHSkJZVuJZlTRFR6V5gDV+pV1bGXfu3pGIsBl5h4i0JvsY8PkE0AuHLR/vFjdTnYMS3i7n0ElaFa58SVWY5vC2uKkSzhPep0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237997; c=relaxed/simple; bh=aaL8W66lNYNlZ6TUB83q0Zo2UdqSMXWQj/xUy6d09UQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gyMjvXkKFl7pGEcDZUpgROPtMYkgg4j2DlMuPX8qXotttFUyjP+MCaTfAKrLlk0Wc3f+WOMVGJoPJco5ZwWPrO5M3N56KhJi+uO6eqXGADXtcQOXhgJtlosjKdyfV2s5DCbY6YM3NWHm3tDZ3O0M9Z7ZT4gbU6F4ISQ3Bcx8ZUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=rGG9LCDS; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="rGG9LCDS" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DAD6F1483DF5; Wed, 21 Aug 2024 12:59:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237993; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=i/ckHEQYfw6TnDB+9CVHZLVZThux547JhXou9MWo738=; b=rGG9LCDSm0fkhl56SGjODNpBKWm1V8D5PrYK2UCtQV43tq4Nrps/v/0kiT85fvlCWA/pVe vSZgNKWIF5+vU4Qi1W57x/BRaPRQt6M022rPdRX6PNFrMD8VbRiYGLHU9aeJc8Kl1DwRz4 mR9oQ+H3VpO5HxB2KVIgh4Ak2+yS+M7+xe3hh6d1W8GR22q7mNq48KBv8lFG+iKss4sn8O y3QbFqDKIgnIgUELUP1kBzwnd3Oy23gXGWXZKp3XDZArYqa8HB2NWqSfAu3y5SWTFoQp2K AMyITMJp+eSh+6cnAYMpbIHpsvtNGXoapzEFN4nGOCOczaZq+NaYyW0D3FDY1w== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 04/12] nvmem: microchip-otpc: Add SAM9X60 support Date: Wed, 21 Aug 2024 12:59:35 +0200 Message-Id: <20240821105943.230281-5-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Register layout is almost identical to sama7g5 OTPC. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index bd3383eabdf6..b8ed7412dbca 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -271,6 +271,7 @@ static int mchp_otpc_probe(struct platform_device *pdev) =20 static const struct of_device_id __maybe_unused mchp_otpc_ids[] =3D { { .compatible =3D "microchip,sama7g5-otpc", }, + { .compatible =3D "microchip,sam9x60-otpc", }, { }, }; MODULE_DEVICE_TABLE(of, mchp_otpc_ids); --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0722E1B654E; Wed, 21 Aug 2024 10:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237999; cv=none; b=WgoA5Eyg4ks1MhsS/DT7n8Xrl40EwXOD1R+YPR5m8GnrY6kHatRh1CKwoIyVeUmM6x7GkQ/Eji3l4CNS7glX9m89e+uGftiGtWk43BjmEwl7fxTa1Q6EUu8aIPCfdA7tT/yjbQHgMjDBbYLR/O1cLk3V2HOqT+JjkJwRk4Xxi8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237999; c=relaxed/simple; bh=S+h5jXrA7YMUAbkYheYPZ9pn05AyL6g6Zi2qsKGDVp4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PDRcPpP2cLIDuMDizbM4WWoShlsF8lqqSElki6++NEPZiCGCNxJ+dkB8nOxVoJ1eryA3RimUI4azaUYXobKbjNg7cIb6A48dnUcwafaBDL05S3Ihn1NEgrMDaWrbI0X368/6ExedcCs1JY2lGAC20snvqkDuNCUsnTbTBjT+wdc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=w1mvVPiH; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="w1mvVPiH" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C42A71483DF4; Wed, 21 Aug 2024 12:59:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237993; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=o6Z9plrI34xx6HsJ1k36/QnTasThr1NJXWR2tkzloNs=; b=w1mvVPiHQU/BhJcC0MaXV+zMyRmOFakVw3bunQ4cbbERulGd1H7d/xRMeBq6SaT8H4s5Dg pNMpkNsa3nro5C7xDKJnJeiNHqygYOFhZ3kM5Slw3XpRWbOWHDd4LUO4MRkfcZxTXsW88V 6LUVecQXAKE04lKOUBmRs7sPSTbItbYQs/kG36kT0iqix49X4A5Qu40fM0Xn/w1U8QbjDx 8eH7uaOvJeE5Gn5uyUywMCeog5I2e7v89pIk2VU4CalSK5PbM5c80CGtOhFrj9tFkNm1Dp ZcnRhIGBZ4i9RivwmNLWqSin2IYB7DIvbzA6GPuGmzUthpHNxXB91p8cfKbtNQ== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 05/12] ARM: dts: microchip: sam9x60: Add OTPC node Date: Wed, 21 Aug 2024 12:59:36 +0200 Message-Id: <20240821105943.230281-6-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" See datasheet (DS60001579G) sections "7. Memories" and "23. OTP Memory Controller (OTPC)" for reference. Signed-off-by: Alexander Dahl --- arch/arm/boot/dts/microchip/sam9x60.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/boot/dts/microchip/sam9x60.dtsi b/arch/arm/boot/dts/m= icrochip/sam9x60.dtsi index 291540e5d81e..2159a6817f44 100644 --- a/arch/arm/boot/dts/microchip/sam9x60.dtsi +++ b/arch/arm/boot/dts/microchip/sam9x60.dtsi @@ -14,6 +14,7 @@ #include #include #include +#include =20 / { #address-cells =3D <1>; @@ -156,6 +157,13 @@ sdmmc1: sdio-host@90000000 { status =3D "disabled"; }; =20 + otpc: efuse@eff00000 { + compatible =3D "microchip,sam9x60-otpc", "syscon"; + reg =3D <0xeff00000 0xec>; + #address-cells =3D <1>; + #size-cells =3D <1>; + }; + apb { compatible =3D "simple-bus"; #address-cells =3D <1>; --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F0BF1B655A; Wed, 21 Aug 2024 10:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238000; cv=none; b=jOzCpfaMdPFhrsWE34iawHeKebTNcgLCbnKuLaN5yW4OgN5gjAKlqnbXUyRC6c8vgoH1Bw7AG6nyBAgplF/m6hUzvvQsxAZrwjzyi7JvENppBtar76zsiCLiTJvYQ6q8MfSrBGFj63WsElLCDnzmlvenfvSWLu5CH56hH+Pd0io= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238000; c=relaxed/simple; bh=Z5C1FRckoTVEYt6BvjisZfD0B2IGu9+fT7K99xpq5tQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W4sEv2t9z4hgaG4JN6B6fz1VmbU5XfT4LYvHmP9vcJf2Cvt+wwrwwTKbcut5WxkwOuk7Xn7Iy88T2hauRwFFXvayaPZL28rEmMm814aT0CLhspF17EoKeCJm0gYV4WvTr+BWv3FgnkRC4k6r3QMsDQoJzlu9UrKTILg8aNyVTho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=kUIOuA1V; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="kUIOuA1V" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 697211483DF6; Wed, 21 Aug 2024 12:59:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237995; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=16XwRQ9Fnf5UaoUkVrP6/gJBIWPHHwI4pGVmwBYvBoM=; b=kUIOuA1VyC34Wteyyw80TGEFtsL048BEsSLab6Q79E3iie5zLTNXdlTHmXcJzB/dxzRYhJ 0a5sX98oqWlLFzN+clu5sCSF1QjGEdAz+6usFZ8GU9hGgeIn0GJOhSA1H6OdttAHxTDa24 SvowOrwbgIe2KeSDSjAgMW7whNiZ/GUY3iJBpC165rc19kMXOQJWmgcc7NlRKpeUbSo9J+ cTsYkZYxzKp59yurJ7cWNRIjb3cp0TGzqf3Ba5TEo2e/mlCLyLE5Ep51ZqtZ8Las581yUD HnGFvXB8wLhwqFeTzXTv1rQWd5U6guNB2nFoNNJYX2jIeQtQVadLKp+sTlaV7Q== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nicolas Ferre , Alexandre Belloni , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Microchip (AT91) SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 06/12] ARM: dts: microchip: sam9x60_curiosity: Enable OTP Controller Date: Wed, 21 Aug 2024 12:59:37 +0200 Message-Id: <20240821105943.230281-7-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Allows to access the OTP memory now, and Product UID later. Signed-off-by: Alexander Dahl --- arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts b/arch/= arm/boot/dts/microchip/at91-sam9x60_curiosity.dts index c6fbdd29019f..754ce8134f73 100644 --- a/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts +++ b/arch/arm/boot/dts/microchip/at91-sam9x60_curiosity.dts @@ -254,6 +254,10 @@ ethernet-phy@0 { }; }; =20 +&otpc { + status =3D "okay"; +}; + &pinctrl { adc { pinctrl_adc_default: adc-default { --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 733391B78F0 for ; Wed, 21 Aug 2024 10:59:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237999; cv=none; b=hClkOXXQsBsSPh0Yd989xRo6rnTnp+6rQSHeRoF7e3Sij3NeQJWHQ9xfltDakSENpxzhK6C2sm/xmwcu2EqvC4DbZELLEf0aUkHozdFGNfvxqtkaauUUJTlrlbAIPVesMwrL270Em/AWur3DQJpv1gxP+qATy5XWQEznvTfSKLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724237999; c=relaxed/simple; bh=+r16e6E/NoU9KjknAuvQSKBFp/BO5QVchGpqTPpo194=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KySS5ZR3LF2ovQBCk9q9YgejhKcfAUah/8wV98jhGP+6KYrUfkPlGf6NFe4eGC2Ofo/O8ExmV+muiqvxX7ehWW+pT8mWAMVRNJZjq43AaRUM6MuVb6UOU1VaQMNOjMp7ru/4KuXHyBV2gzEpjUaFoov2ZTjED3g88Ga+ojS6zTk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=YMTL7SeQ; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="YMTL7SeQ" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 87DDB1483DF7; Wed, 21 Aug 2024 12:59:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237995; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=TJAnNoD40VE5kpvISU24IPj7vHBlSQ5pDs+zABOQSs0=; b=YMTL7SeQM64uKQNcWd8bzFevbMhV0oqgifu10n6KA86rdiPH5/XtLyoqVc+EjgRrO042ZV WspHsUoaxdQq2QWugRBxsls/7Lr67GHSs4My+YXTlAWDHxnAO71iIh1hQNfQwz22PC9Xb7 VFt8vRJbDCBibIR5iHN95fGK2EdFn3g2yAr7zDjHfDL/8WF7Ee/PcbuTenMYgRw/EJ90k8 AYoiuABeJ1Qz8Zg4W8Q+Zoq3o3UwsFXw5iWE7tlW7fXqPdiWycUMIYkYy16Cy9dOQbywCK t5eOW43r8s7ziqZyRRTWZ7q7pax4+IRdh2JtBQWCJ44zTUryvP/r7L5kvwG0Vg== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 07/12] nvmem: microchip-otpc: Add missing register definitions Date: Wed, 21 Aug 2024 12:59:38 +0200 Message-Id: <20240821105943.230281-8-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" According to datasheets DS60001765B for SAMA7G5 and DS60001579G for SAM9X60. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index b8ed7412dbca..4630e96243ac 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -21,9 +21,24 @@ #define MCHP_OTPC_AR (0x8) #define MCHP_OTPC_SR (0xc) #define MCHP_OTPC_SR_READ BIT(6) +#define MCHP_OTPC_IER (0x10) +#define MCHP_OTPC_IDR (0x14) +#define MCHP_OTPC_IMR (0x18) +#define MCHP_OTPC_ISR (0x1C) +#define MCHP_OTPC_ISR_COERR BIT(13) #define MCHP_OTPC_HR (0x20) #define MCHP_OTPC_HR_SIZE GENMASK(15, 8) #define MCHP_OTPC_DR (0x24) +#define MCHP_OTPC_BAR (0x30) +#define MCHP_OTPC_CAR (0x34) +#define MCHP_OTPC_UHC0R (0x50) +#define MCHP_OTPC_UHC1R (0x54) +#define MCHP_OTPC_UID0R (0x60) +#define MCHP_OTPC_UID1R (0x64) +#define MCHP_OTPC_UID2R (0x68) +#define MCHP_OTPC_UID3R (0x6C) +#define MCHP_OTPC_WPMR (0xE4) +#define MCHP_OTPC_WPSR (0xE8) =20 #define MCHP_OTPC_NAME "mchp-otpc" #define MCHP_OTPC_SIZE (11 * 1024) --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 733AC1B78F1 for ; Wed, 21 Aug 2024 10:59:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238000; cv=none; b=GxL6kocofAvpUyh6GLc1tDNp0TYk+fD3/9ulxzuYGw0tK0AJM+DLRQ4pv7EwpTgj+aBxBoC2qZxROWAfv1meF3RgSUDwDri54zMUeCbui7nJ1qJ/HhchpJBTsIK7E1JiHXucRQvcL7lz7pbJPsqLwwBMHPR+QRJqd/L9PjOp06g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238000; c=relaxed/simple; bh=HEhJgnKmGCTfVx3YtNlr94JVj4+kbZWoTHoFbCmLgsA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mKWNC5duB42FrR/dv8LlJvhQKjZcHUX8B4LTc59YJjDZ361nTvVTlbCpWuY6KnwPl/wh3F/gOCg+jlwn4Cqmw8zhXcmc7Igp5wC1O6x6HmwZkGjWwkOKK64X6HcSE+VYbOiVM181RQh++mLsIT9U8TyxSJZf/cjNrXFDYpHOnp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=H4An3j4C; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="H4An3j4C" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DDC611483DF8; Wed, 21 Aug 2024 12:59:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237996; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=+hE4Oaa/+RDBODWq0UJM3XXnYgcGWlBIKzul9txp90I=; b=H4An3j4CsF/zMsyyX616M0lmcq0coy9KfP0i1tuxNvh/Z3qtjzQZj4E8+44XU3I4+U8a+R JXtT0A/0TVrbPuMyC0RcSC+pYUXX9tNsx1CGkCKslwBH/fkXRl1LGucosKHd/u5aG0cA7j grkIE4uQFVAWFkdKAmP5POGgyzMuUFZU1RywA98xK33WEmzh8FP/D5yBA20WureSPre/V4 pmdaRkH31phg35fxpBCZl5CEu34UV5Y0SZUJK282z2JkVD43gC485p6KzyBhvYYwCxEpJR Mf76kaXaYmIq6ZA8Ix2biACBKaMub9I6Ajx6A9S7jlyNNJsQ+wcobMb6/5mV3w== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 08/12] nvmem: microchip-otpc: Add warnings for bad OTPC conditions on probe Date: Wed, 21 Aug 2024 12:59:39 +0200 Message-Id: <20240821105943.230281-9-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" These conditions could affect correct function of the driver. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index 4630e96243ac..a80535c3d162 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -8,6 +8,7 @@ */ =20 #include +#include #include #include #include @@ -260,6 +261,7 @@ static int mchp_otpc_probe(struct platform_device *pdev) struct nvmem_device *nvmem; struct mchp_otpc *otpc; u32 size; + u32 reg; int ret; =20 otpc =3D devm_kzalloc(&pdev->dev, sizeof(*otpc), GFP_KERNEL); @@ -270,6 +272,16 @@ static int mchp_otpc_probe(struct platform_device *pde= v) if (IS_ERR(otpc->base)) return PTR_ERR(otpc->base); =20 + reg =3D readl_relaxed(otpc->base + MCHP_OTPC_WPSR); + if (reg) + dev_warn(&pdev->dev, + "Write Protection Status Register Bit set: 0x%08x\n", reg); + + reg =3D readl_relaxed(otpc->base + MCHP_OTPC_ISR); + if (reg & MCHP_OTPC_ISR_COERR) + dev_warn(&pdev->dev, + "A corruption occurred since the last read of OTPC_ISR.\n"); + otpc->dev =3D &pdev->dev; ret =3D mchp_otpc_init_packets_list(otpc, &size); if (ret) --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A57E1B81B2; Wed, 21 Aug 2024 10:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238001; cv=none; b=eWj2I3TsIYbZN0qUkfROI+iQZZChG881d27clGMeg6JClU41Hnb4zZ+c76hjhx7b2ZRnJ0zkUd9FZNNamISdBnZnWjY5CPzWtxiB1UNcBXhSi5FBZpwxILoBPQmvtyB3gQIRLaBQBi5Eanx+kpjl4NPGfbg4W2yEUNohCmLseb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238001; c=relaxed/simple; bh=+tqmoTa1quo78lh0ER4UFgZxylnStwrnOjZvqTlhY5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jSlQOfNSLrtHh3xjKoXrnCofSlN15SiB0ejXuzoOPHQ0Ig5H5t9B7MnjN4ICdeSD3sCERK3TEeXy6zqv1cUAcFd3MJgyWTG/1ZVlP4FyhrKkhVs8dXpfPuNC4HS7IHj57NsrJEis0raY6qCjAqeY1y/252ZpCAUqpIFdjoc+AlQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=YmOGDdOg; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="YmOGDdOg" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D8D5B1483DED; Wed, 21 Aug 2024 12:59:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237997; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=f3c3Rb0MaGLfvzOor2+zbB5i0hEP30uww3c4MW+lsbw=; b=YmOGDdOgxWvh/GWC/OCxBEmVYsKO3lJkNsRx3guhWR1wIDL1qcFGNbGznSRMKndM1od4RH SYnWCBbfaXD2k3JeMbj7dDMWL+4w48QEdz1GyFdd4A5j5w8qj2PU0sqwDZFZkl+7W4R3R6 dn0SDIUkNJ1RbW2wmTQ9JCNQZHKHrj5IzvExaqyT++6suwhJX3rsvRq+DAAxQhKehlS1Un 2dcVNNj9a5/5SfJQvOGzNZCwu5AX7L+sfxGPHJJnIzxTp8xnV68f7pw83ATU4ibQPqQATT eX55ep9Gll/Mk++jVEPZcoyM5RrV+Y6Zn1I7dZFfNx7zxVlrzPLQMU554RMn6Q== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Michael Turquette , Stephen Boyd , Nicolas Ferre , Alexandre Belloni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-clk@vger.kernel.org (open list:COMMON CLK FRAMEWORK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Microchip (AT91) SoC support), linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH v1 09/12] clk: at91: sam9x60: Allow enabling main_rc_osc through DT Date: Wed, 21 Aug 2024 12:59:40 +0200 Message-Id: <20240821105943.230281-10-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" SAM9X60 Datasheet (DS60001579G) Section "23.4 Product Dependencies" says: "The OTPC is clocked through the Power Management Controller (PMC). The user must power on the main RC oscillator and enable the peripheral clock of the OTPC prior to reading or writing the OTP memory." The code for enabling/disabling that clock is already present, it was just not possible to hook into DT anymore, after at91 clk devicetree binding rework back in 2018 for kernel v4.19. Signed-off-by: Alexander Dahl --- drivers/clk/at91/sam9x60.c | 3 ++- include/dt-bindings/clock/at91.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/at91/sam9x60.c b/drivers/clk/at91/sam9x60.c index e309cbf3cb9a..4d5ee20b8fc4 100644 --- a/drivers/clk/at91/sam9x60.c +++ b/drivers/clk/at91/sam9x60.c @@ -207,7 +207,7 @@ static void __init sam9x60_pmc_setup(struct device_node= *np) if (IS_ERR(regmap)) return; =20 - sam9x60_pmc =3D pmc_data_allocate(PMC_PLLACK + 1, + sam9x60_pmc =3D pmc_data_allocate(PMC_MAIN_RC + 1, nck(sam9x60_systemck), nck(sam9x60_periphck), nck(sam9x60_gck), 8); @@ -218,6 +218,7 @@ static void __init sam9x60_pmc_setup(struct device_node= *np) 50000000); if (IS_ERR(hw)) goto err_free; + sam9x60_pmc->chws[PMC_MAIN_RC] =3D hw; =20 hw =3D at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL= , 0); if (IS_ERR(hw)) diff --git a/include/dt-bindings/clock/at91.h b/include/dt-bindings/clock/a= t91.h index 3e3972a814c1..f957625cb3ac 100644 --- a/include/dt-bindings/clock/at91.h +++ b/include/dt-bindings/clock/at91.h @@ -25,6 +25,7 @@ #define PMC_PLLBCK 8 #define PMC_AUDIOPLLCK 9 #define PMC_AUDIOPINCK 10 +#define PMC_MAIN_RC 11 =20 /* SAMA7G5 */ #define PMC_CPUPLL (PMC_MAIN + 1) --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA2751BA286; Wed, 21 Aug 2024 11:00:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238002; cv=none; b=NBN1AglqhiF7/sSvH/1VbdO/9wHok9Xwa40gweOoi1pvws0hBkZ9RON5O7mpjah35GIXVV4fU/Rep3nQruHVAVZWdk7elP9d15liuahZdBfitvyLlTKPWAEP5Csi44HJ9eNc8eU6dKwVnf0ILanKm3o1cWRlR6G52CYFe9TD9u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238002; c=relaxed/simple; bh=st6qru0aA6v8gy4EaRFbuG3ZJ7Z30JGYCTim6v6PJus=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bw87kbwTXKifg3OuUHaplFqrBTHY/NTscv8KMLSGuni0DxYFHAk0LSlggKk8BHHHeLf3D4adq7NVYfqmAFHMh9uJktcxX7h/k97JRLNZqjxzmHCeOH1l78EwwEJhijYGbpWE7CEyT+3nVz8ZiLa2B8OYX71bhf9AYdL8BvGymFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=u967oBSE; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="u967oBSE" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2A25E1483DEE; Wed, 21 Aug 2024 12:59:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237998; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=RxP+7FhQ7B7RR8we2m9jYjfDUkGx0+B+yYzfsV/BxBo=; b=u967oBSEa9c1H/goYN6LwJDfcx2Bv3V2fiOhtyYaL4yCT5Wi9smjiEVFExrkMrr9XCMjUS B10dLm2dERlXaQDGpl1wL/+neYKyOD3VJLcd3qexBWzsBmEg+TunZjufbC+Nl1rNCiEc3h QJeE/oPpP/6xTTdtY3aUamR6t3KrvCXj+hxEl9/sD6R+OB7hlq80MVhOG/ao80ObXbp8ad V5YcD2JaR76PTEgPsYU5qhenJZ3lSWYGZMxMuOGJEvv+19C2w5QxnzVMQbwTJgWli5MTj+ esSeNjR0qKw2e3iYEipyCOsEbYYv5fD3NF9httW/r/UkwwlCD4d+FJZiIkrUFw== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 10/12] ARM: dts: microchip: sam9x60: Add clock properties to OTPC Date: Wed, 21 Aug 2024 12:59:41 +0200 Message-Id: <20240821105943.230281-11-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" This will allow to enable the main RC Oscillator from nvmem_microchip_otpc driver. Signed-off-by: Alexander Dahl --- Notes: This requires some DT bindings update, right? arch/arm/boot/dts/microchip/sam9x60.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/microchip/sam9x60.dtsi b/arch/arm/boot/dts/m= icrochip/sam9x60.dtsi index 2159a6817f44..4f0651b8cb60 100644 --- a/arch/arm/boot/dts/microchip/sam9x60.dtsi +++ b/arch/arm/boot/dts/microchip/sam9x60.dtsi @@ -162,6 +162,8 @@ otpc: efuse@eff00000 { reg =3D <0xeff00000 0xec>; #address-cells =3D <1>; #size-cells =3D <1>; + clocks =3D <&pmc PMC_TYPE_CORE 11>; + clock-names =3D "main_rc_osc"; }; =20 apb { --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F8CE1BAEC5 for ; Wed, 21 Aug 2024 11:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238003; cv=none; b=JHb+oXyh58POTsfF4mtLMoVn8sFiLYkqEmyEuhHqVSJ9MooKdlSbbUB3+uAM7B35V9GoLRkXL0wO3jdtHF/Ceux3E5l0r9KAIlIMpb9I9wF0/gmd/2/zyqUuVUKSgdCWXCHusuIiKnkxm7fDK64xRRKWvH6T6gw0YmQNYw9b1qg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238003; c=relaxed/simple; bh=1K56cFtxqRrqKL3dsbtsNJZdC6zpznB5RkaKOagcN9M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RKO7c6nYBNpHX/8yW3DwaxzmNul7dXMwxmz9XvnH4Xj72z+SmtDQILlWw+cVewkdEbf6EY1IUgpTuzXU/HUjEM+o5ZCu/8180Wo0c+2guwV2Lw5ACAfmBU9j2pC9GqBoXmQm+gh7p+hLu1CS4tW30V5P374pIgnZwp21oyOaMeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=vBc/BFZP; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="vBc/BFZP" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1EFAA1483DF2; Wed, 21 Aug 2024 12:59:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237999; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=jovbb058QzzCeFDP4Da8Wb3JHly5Xy6YvCLwu8Ic6q4=; b=vBc/BFZPkHoTOZP55cWp8jIcwt2YXJwPdq0Zk3/yQHb06gka0w8sOFpxXT3RYBpDw73D7f IxKKLjFxrDTticjvnANOv6RIRKzqRqJpaDjZrL2Nq65z4K64/o5Q/azqfms4KPsCnSQECW pR6Y4w6MlJKoacR6z9p7hEEhwJulCg+/wDcYCB2Ayg8fehf5DYPGWx0+7GrW6MsQJ6Aw4D Zsan9FH9auUf3k/suXz2EDAoMI4G284/YeHGF9u4qiHunWMzDggWfJbCDNXqIIayEIGAoV PbWg+pxA5tkvoKw075F2xMN5E35BP8ML+unevBlaleYvWD11N1Z6q+YKkY6qLg== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 11/12] nvmem: microchip-otpc: Enable main RC oscillator clock Date: Wed, 21 Aug 2024 12:59:42 +0200 Message-Id: <20240821105943.230281-12-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Without enabling that clock, initializing the packet list leads to a read timeout on the first packet. According to SAM9X60 datasheet (DS60001579G) section "23.4 Product Dependencies" the clock must be enabled for reading and writing. Tested on sam9x60-curiosity board. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index a80535c3d162..047ca5ac6407 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -8,6 +8,7 @@ */ =20 #include +#include #include #include #include @@ -54,6 +55,7 @@ struct mchp_otpc { void __iomem *base; struct device *dev; + struct clk *clk; struct list_head packets; u32 npackets; }; @@ -272,6 +274,15 @@ static int mchp_otpc_probe(struct platform_device *pde= v) if (IS_ERR(otpc->base)) return PTR_ERR(otpc->base); =20 + // NOTE: Maybe make this optional, especially if sama7g5 testing + // shows the clock is not required there? + otpc->clk =3D devm_clk_get_enabled(&pdev->dev, "main_rc_osc"); + if (IS_ERR(otpc->clk)) { + dev_err(&pdev->dev, "Error (%ld) getting clock!\n", + PTR_ERR(otpc->clk)); + return PTR_ERR(otpc->clk); + } + reg =3D readl_relaxed(otpc->base + MCHP_OTPC_WPSR); if (reg) dev_warn(&pdev->dev, --=20 2.39.2 From nobody Fri Dec 19 18:59:37 2025 Received: from mail.thorsis.com (mail.thorsis.com [217.92.40.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CF961BA29C for ; Wed, 21 Aug 2024 11:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.92.40.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238003; cv=none; b=tg/kEl3DWc7NohCdsbYZRrhu9sTbjm2AGAX+XXJoimHPChdow5XLVlCF8VMPQxktjg3+p93RzMIwMJXmgIcZ+g54bVNYkEcdsGYCnmdnsoRS/Bq6C23ry4urni1UsuXMPbKR5VU1MKwZ0BlN0D5NUi3N2upPk7X55KohYnBHd0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724238003; c=relaxed/simple; bh=FefeWmBE3XufmHRreHUqF2kiLEqYzrbKkLAjSc7pSZk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LZgi7k/jQdTymDd0DAa1Tlh29GxHlMoNN6K+79V+uovTrHwX/VCwXogy3ln+uz42JpVtFfIqHOnEt4B8WFwvb7d9wIJjNc8Sl71F307i1f6lkMW580dDi6YWXsopD3V3CBcF1V7duvSPCAeGUnW/uNAwHYabAgwjhbAs13dTXZ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com; spf=pass smtp.mailfrom=thorsis.com; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b=KVp4uR8R; arc=none smtp.client-ip=217.92.40.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=thorsis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thorsis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=thorsis.com header.i=@thorsis.com header.b="KVp4uR8R" Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 8F3A11483DF3; Wed, 21 Aug 2024 12:59:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237999; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=7R+I3eWvRMVL77L44Gt897N18NavS4Wc92V6aQKadT8=; b=KVp4uR8Ro7N7VsYnYCe7XQW9iovUZvzIxkjmraWg6QtT5tIdFvmg1TaDL2MdPL5cco68jN nQWP5krf94zjpxKBG/OF5ZZkvbJ4mkLHaZebnUVJ1k4QIpc1jCnj3ERK0O4thIb2bJMHhq j3HJBWWtGCGna5vefOmbNA/TMj6GlsJnBRDWRrrR0lU1l7z6pFRYusz/b++dYL4IJj08ay 0/YQmSPtbGij9AmB6NNTPT5pRZ1vXHBXwHh/hZc/PC3FvNTKThDGiOjedgeufu5lPbUJ0y yjTDVY7XPPJYoDXOkECg5awvIbh02hRaqhAWPNbmDbS84fs6UndhWNDiwaNHYA== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , Srinivas Kandagatla , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP OTPC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 12/12] nvmem: microchip-otpc: Expose UID registers as 2nd nvmem device Date: Wed, 21 Aug 2024 12:59:43 +0200 Message-Id: <20240821105943.230281-13-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821105943.230281-1-ada@thorsis.com> References: <20240821105943.230281-1-ada@thorsis.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" For SAM9X60 the Product UID x Register containing the Unique Product ID is part of the OTPC registers. We have everything at hand here to just create a trivial nvmem device for those. Signed-off-by: Alexander Dahl --- drivers/nvmem/microchip-otpc.c | 41 +++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c index 047ca5ac6407..52af4c137204 100644 --- a/drivers/nvmem/microchip-otpc.c +++ b/drivers/nvmem/microchip-otpc.c @@ -45,6 +45,9 @@ #define MCHP_OTPC_NAME "mchp-otpc" #define MCHP_OTPC_SIZE (11 * 1024) =20 +#define MCHP_OTPC_UID_NAME "mchp-uid" +#define MCHP_OTPC_UID_SIZE 16 + /** * struct mchp_otpc - OTPC private data structure * @base: base address @@ -249,6 +252,16 @@ static int mchp_otpc_init_packets_list(struct mchp_otp= c *otpc, u32 *size) return 0; } =20 +static int mchp_otpc_uid_read(void *priv, unsigned int offset, + void *val, size_t bytes) +{ + struct mchp_otpc *otpc =3D priv; + + memcpy_fromio(val, otpc->base + MCHP_OTPC_UID0R + offset, bytes); + + return 0; +} + static struct nvmem_config mchp_nvmem_config =3D { .name =3D MCHP_OTPC_NAME, .type =3D NVMEM_TYPE_OTP, @@ -258,6 +271,15 @@ static struct nvmem_config mchp_nvmem_config =3D { .reg_read =3D mchp_otpc_read, }; =20 +static struct nvmem_config mchp_otpc_uid_nvmem_config =3D { + .name =3D MCHP_OTPC_UID_NAME, + .read_only =3D true, + .word_size =3D 4, + .stride =3D 4, + .size =3D MCHP_OTPC_UID_SIZE, + .reg_read =3D mchp_otpc_uid_read, +}; + static int mchp_otpc_probe(struct platform_device *pdev) { struct nvmem_device *nvmem; @@ -303,8 +325,25 @@ static int mchp_otpc_probe(struct platform_device *pde= v) mchp_nvmem_config.size =3D size; mchp_nvmem_config.priv =3D otpc; nvmem =3D devm_nvmem_register(&pdev->dev, &mchp_nvmem_config); + if (IS_ERR(nvmem)) { + dev_err(&pdev->dev, + "Error (%ld) registering OTP as nvmem device\n", + PTR_ERR(nvmem)); + return PTR_ERR(nvmem); + } =20 - return PTR_ERR_OR_ZERO(nvmem); + mchp_otpc_uid_nvmem_config.dev =3D otpc->dev; + mchp_otpc_uid_nvmem_config.priv =3D otpc; + + nvmem =3D devm_nvmem_register(&pdev->dev, &mchp_otpc_uid_nvmem_config); + if (IS_ERR(nvmem)) { + dev_err(&pdev->dev, + "Error (%ld) registering UIDxR as nvmem device\n", + PTR_ERR(nvmem)); + return PTR_ERR(nvmem); + } + + return 0; } =20 static const struct of_device_id __maybe_unused mchp_otpc_ids[] =3D { --=20 2.39.2