From patchwork Wed Aug 21 10:59:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771231 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 9BF3EC52D6F for ; Wed, 21 Aug 2024 11:01:11 +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: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=GQKlVPzitG3/Y0AW44WM1THcHTkHaH0mCBA5mVPTsDU=; b=JwG9XTgmplGx+tjJMYLcUZk3hN j3JrM209YupCnBcwHz/PKAsoqkjrHeTGm9nHZX/det1hCm/4MZgICE7ggKh8n/84uh6zOxAx0uWxC WhFJ4q6SfxsR3y9v0oKEqqVhVaefxbwmaAL6LmiwyO318Wzi7bt6nbbCmtO5iQkg02+wh3lw3s3f1 9LSTUtGIvLTVVri+V4fMXvKe1EQGauq+6nWJ0E7D7i7WhfTidiYv0ksmuUT8yGf0GAYc8uAnjllzU CBDWD7r7QlwDijBZgbwwyzqNPB6G4B2MpDaTtqqQKwpROZYB9YKhbpr2RLXCGkmv9sxmcw5dJQWr9 QuHByUzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj5B-00000008XqP-23NI; Wed, 21 Aug 2024 11:00:53 +0000 Received: from mail.thorsis.com ([2003:a:e28:26e4::10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4D-00000008XRL-0RKV for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 10:59:55 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9EDF81483DED; Wed, 21 Aug 2024 12:59:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1724237990; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=GQKlVPzitG3/Y0AW44WM1THcHTkHaH0mCBA5mVPTsDU=; b=DPAVs4OC32jMj2qSWcPms3XieM3u/BHRr4nRemoURWmwlke5t8FhB/f8Q7sQ52oDfuGZE7 q29FwYAUQxWSQ7ntVFzevL4DWfZkh0ACw+OZ+PJkKTeRvSXdnevwH/badcjXX8njR+5EMe onppQDNL04Da5Wkqdx5qtHG9ig6AtHtpJo6UUrF55ObQl9GFP59eBJ/Vy0Q0za8+a/LKI6 E+yMk8GdZgc60rKsw6NkBHkjbnUlNCpXdyCtzD1SCHK6Y53mmwhdmmTENjcGvlDmruy2Jd PZ9UPqKlVlMViVFjJKhaNfQIT3Eu50MF3Xh40z9nmtr6gkFZRWgbUELFccptIA== From: Alexander Dahl To: Claudiu Beznea Cc: Christian Melki , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v1 00/12] Microchip OTPC driver on SAM9X60 exposing UIDxR as additional nvmem device Date: Wed, 21 Aug 2024 12:59:31 +0200 Message-Id: <20240821105943.230281-1-ada@thorsis.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_035953_606981_C17C4B0D X-CRM114-Status: GOOD ( 24.59 ) 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 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.) 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. 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? 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