From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83B0DCD13D2 for ; Sat, 31 Aug 2024 15:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cZthrGtEqqFLYC6PIzIIDizVrqC6Gx/oqBLZku67P34=; b=yYunvsu/RQod0uKT7WhY0zVXkf aPjwBO3ZLNwbmBiqzt9GyW04wEDypbG9fYC8rH+FVJQRopiP4BRKBEGDFkkIU+eLjmd5pCRSzWpq8 iSGd4I2wMzCxV/OCon8LfUyF9MUfXLLgcrbf+oxk66OfIXU73y2LXDleWBPGA5YRkOjJTn4GkGa+e 59IrnvufN48mri13HEvh7K7Qa3eIiMmoUtAf0tmnPfx6urwhxErNZqShaAtlXn0AUWIpvAu3ksIKE PGZv1fMv7Y0RUQ7flXp9t1HPm2K7ekEpXdqPCMGZojBX3wpsJ6CC2WUFukRUD2na5yNvd5Ae6Jbst 81deE1OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skQBv-00000009b66-02QJ; Sat, 31 Aug 2024 15:39:07 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skQB0-00000009ayM-3mCZ for linux-arm-kernel@lists.infradead.org; Sat, 31 Aug 2024 15:38:12 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42bbc70cc19so13058605e9.0 for ; Sat, 31 Aug 2024 08:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1725118689; x=1725723489; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=cZthrGtEqqFLYC6PIzIIDizVrqC6Gx/oqBLZku67P34=; b=N7O7NA0R1h2PyoZF+NEOJ58Ws2Z0CIoTwvbqQOWLBdrG26ERksBcajH6ic+mB+M83u wur1oGvwhuc47qwMOjBUs+7VEYnBtM7qGonI4lPeztmvpytyliWUuMPSuLaUDLb2Au5V SStKiQhcPO3UJabD7qzVZOqu1BvqfyxvPl0olqcS8XoX8T/h23XdsszAncqa8kSdqkrX Lc+RPxEW6JpzeCtV+7rNkSDP2r0r1KI0gh0BBjlagRbf3xqdN8e1Gs8i4BXF6I41BOKt 0fx5D+VXyNAbmwYRDYNi2EfdETtiYDvXHWK+wx2FI7QU/BGSAR1CDH5gycyE+gnviQsi FgRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725118689; x=1725723489; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cZthrGtEqqFLYC6PIzIIDizVrqC6Gx/oqBLZku67P34=; b=FKXGABbaWLlq7NHN+UkCgxuy5Xgub64zPKPjE58O1Z9JA2G31ocMYm4UB+WFJS+a8I WPFIp0bfPEMekhrKe+m3hBL4Kold4jyY7jJVITE5vAr4ksGAzmKmb5z1rLFj0M6Hj5uL lJo1LyJHv8JvyySp10XjA+5U5IvC3UQSju6WusZLxUBd8y1rCmeSEiDvH64ynP30r3Qx sJzlqy/VMrV1KgYxLcZXQi33GGIxkOQiwVrXgKFQtB+RpfgeipbAlp1w180Q0fmGbZVU PvkMT3ECwVHHvpG58aubTtPUPOctgskkWJZeksUzeRrcD7hNOVWysVBEJ2DtHuCI8LyT VQfg== X-Forwarded-Encrypted: i=1; AJvYcCVgy6+4IPCj4O9c48pcNJG6g5qZIP8tl9t3Mx7pbzq/moj2wrT8zvEG7jBHbG9zPOTsrO2lMm+3md4B3hHr7WMm@lists.infradead.org X-Gm-Message-State: AOJu0YxNeGRQ/p5TLnt7vWJ6VY4/97yWPHkKo9HdU/1IxR2cUp+5KC07 cQHi0qnWfTMd9fiK7nqoY0dRFZ0aJfrBBBQMwDkyNt7zOT57A9+/Qp7nwunBjaQ= X-Google-Smtp-Source: AGHT+IEkkDlKTut9HMW81eLUExS8xSMLD6ArSEwZXNGJj9UgxWCYQMDP/Ydx1Ja/ANu3OiJc/FSH+g== X-Received: by 2002:adf:e405:0:b0:374:bcff:cfa6 with SMTP id ffacd0b85a97d-374bf04f7e6mr1176513f8f.18.1725118688647; Sat, 31 Aug 2024 08:38:08 -0700 (PDT) Received: from [192.168.50.4] ([82.78.167.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3749ee6f76asm6777148f8f.25.2024.08.31.08.38.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 31 Aug 2024 08:38:08 -0700 (PDT) Message-ID: <5e34726c-214a-4e2f-bfb0-e30c89dc7059@tuxon.dev> Date: Sat, 31 Aug 2024 18:38:06 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 00/12] Microchip OTPC driver on SAM9X60 exposing UIDxR as additional nvmem device Content-Language: en-US To: Nicolas Ferre , Christian Melki , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org References: <20240821105943.230281-1-ada@thorsis.com> <717bd06f-3eba-4825-a53f-b2f9aa1c81c8@tuxon.dev> <20240828-steadily-nearby-1fe97d4cbe97@thorsis.com> From: claudiu beznea In-Reply-To: <20240828-steadily-nearby-1fe97d4cbe97@thorsis.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240831_083810_981665_1141F53B X-CRM114-Status: GOOD ( 37.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, Alexander, On 28.08.2024 10:31, Alexander Dahl wrote: > Hello Claudiu, > > thanks for having a closer look on the series. The issues the bots > complained about are already fixed in my working copy and will be part > of v2. Detailed discussion on particular patches itself over there, > general remarks below. > > Am Sat, Aug 24, 2024 at 07:17:43PM +0300 schrieb claudiu beznea: >> Hi, Alexander, >> >> On 21.08.2024 13:59, Alexander Dahl wrote: >>> Hei hei, >>> >>> on a custom sam9x60 based board we want to access a unique ID of the >>> SoC. Microchip sam-ba has a command 'readuniqueid' which returns the >>> content of the OTPC Product UID x Register in that case. >>> >>> (On different boards with a SAMA5D2 we use the Serial Number x Register >>> exposed through the atmel soc driver. Those registers are not present >>> in the SAM9X60 series, but only for SAMA5D2/SAMA5D4 AFAIK.) >> >> Not sure if you are talking about Chip ID, Chip ID extension registers. >> These are available also on SAM9X60. > > No, this is not what I'm talking about. The Chip ID and Chip ID > extension registers are common over all SoCs of the same type. > > What I need is a unique ID, the same sam-ba returns with the > "readuniqueid" applet. The SAMA5D2 has this in SFR_SN0 and SFR_SN1, > handled by drivers/soc/atmel/sfr.c driver. The SFR block on sam9x60 I see, I missed this one. > has no SNx registers, the unique ID comes from OTPC_UIDxR here. > > Best thing would be a simple nvmem device for the SAM9X60 providing > just those 4 registers, in a similar way the sfr driver does for > SAMA5D2. This is the motivation for the series and what's eventually > done in patch 12. The other patches are just fixing the otpc driver > for SAM9X60 so I can add that nvmem stuff. Got it, thanks for details. Thank you, Claudiu Beznea > > Greets > Alex > >>> There is a driver for the OTPC of the SAMA7G5 and after comparing >>> register layouts it seems that one is almost identical to the one used >>> by SAM9X60. Currently that driver has no support for the UIDx >>> registers, but I suppose it would be the right place to implement it, >>> because the registers are within the OTPC register address offsets. >>> >>> The patch series starts with fixups for the current driver. It then >>> adds the necessary pieces to DT and driver to work on SAM9X60 in >>> general. Later support for enabling the main RC oscillator is added, >>> which is required on SAM9X60 for the OTPC to work. The last patch adds >>> an additional nvmem device for the UIDx registers. >>> >>> This v1 of the series was _not_ tested on SAMA7G5, because I don't have >>> such a board for testing. Actually I don't know if the main_rc_osc >>> clock is required on SAMA7G5 too, and if yes how to handle that with >>> regard to the different clock ids. If someone could test on SAMA7G5 >>> and/or help me sorting out the core clock id things, that would be >>> highly appreciated. >> >> Please add Nicolas in the loop on the next revisions of this series as this >> should also be tested on SAMA7G5. I don't have a SAMA7G5 with OTP memory >> populated. >> >>> >>> Also I assume some more devicetree and/or sysfs documentation is >>> necessary. If someone could point me what's exactly required, this >>> would be very helpful for me. You see I expect at least another version >>> v2 of the series. ;-) >>> >>> Maybe some files having that "sama7g5" should be renamed, because that >>> DT binding is used for more SoCs now and deserves a more generic name? >> >> Not needed, adding your compatible there is enough. >> >>> Thinking of these for example: >>> >>> - Documentation/devicetree/bindings/nvmem/microchip,sama7g5-otpc.yaml >>> - include/dt-bindings/nvmem/microchip,sama7g5-otpc.h >>> >>> Are there other SoCs than SAMA7G5 and SAM9X60 using the same OTPC? >>> >>> Last question: Should the UID be added to the device entropy pool with >>> add_device_randomness() as done in the SAMA5D2 sfr driver? >>> >>> I sent an RFC patch on this topic earlier this year, you'll find the >>> link below as a reference to the discussion. The patch itself was >>> trivial and not meant for applying as is anyways, so I decided to not >>> write a full changelog from RFC to v1. >>> >>> Last not least, special thanks to Christian Melki on IRC, who wrote and >>> tested parts of this, and was very kind and helpful in discussing the >>> topic several times in the past months. >>> >>> Christian, if you feel there's credit missing, just point me where to >>> add Co-developed-by and I'll happily do that for v2. >>> >>> Greets >>> Alex >>> >>> (series based on v6.11-rc4) >>> >>> Cc: linux-arm-kernel@lists.infradead.org >>> Cc: devicetree@vger.kernel.org >>> Cc: linux-kernel@vger.kernel.org >>> Cc: linux-clk@vger.kernel.org >>> Link: https://lore.kernel.org/all/20240412140802.1571935-2-ada@thorsis.com/ >>> >>> Alexander Dahl (12): >>> nvmem: microchip-otpc: Avoid writing a write-only register >>> nvmem: microchip-otpc: Fix swapped 'sleep' and 'timeout' parameters >>> dt-bindings: nvmem: microchip-otpc: Add compatible for SAM9X60 >>> nvmem: microchip-otpc: Add SAM9X60 support >>> ARM: dts: microchip: sam9x60: Add OTPC node >>> ARM: dts: microchip: sam9x60_curiosity: Enable OTP Controller >>> nvmem: microchip-otpc: Add missing register definitions >>> nvmem: microchip-otpc: Add warnings for bad OTPC conditions on probe >>> clk: at91: sam9x60: Allow enabling main_rc_osc through DT >>> ARM: dts: microchip: sam9x60: Add clock properties to OTPC >>> nvmem: microchip-otpc: Enable main RC oscillator clock >>> nvmem: microchip-otpc: Expose UID registers as 2nd nvmem device >>> >>> .../nvmem/microchip,sama7g5-otpc.yaml | 1 + >>> .../dts/microchip/at91-sam9x60_curiosity.dts | 4 + >>> arch/arm/boot/dts/microchip/sam9x60.dtsi | 10 +++ >>> drivers/clk/at91/sam9x60.c | 3 +- >>> drivers/nvmem/microchip-otpc.c | 86 ++++++++++++++++++- >>> include/dt-bindings/clock/at91.h | 1 + >>> 6 files changed, 100 insertions(+), 5 deletions(-) >>> >>> >>> base-commit: 47ac09b91befbb6a235ab620c32af719f8208399