From patchwork Wed Aug 21 10:59:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Dahl X-Patchwork-Id: 13771243 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 E27D0C52D7C for ; Wed, 21 Aug 2024 11:08:29 +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:References:In-Reply-To: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:List-Owner; bh=jovbb058QzzCeFDP4Da8Wb3JHly5Xy6YvCLwu8Ic6q4=; b=JyEIzkFazafl14FIitg46LkJfx 4RqaJ3t7Q9rO4D5jloU6jZ/iOVZhc9IbC/r7X5cFV8GbLs/vPk2azwK0xnE8H3eX1IHjWIKdlCv72 LUdFaml7Kssmobk5BfiOUg9cjHQ5eXgvtYemfl3pg1h0t37Y3Lv8iKaQp+sHcDtUg0YxUUTX7b2JH x5+S7MBaMDKiostVgBPJMdbsExpNc9gu7uVJMKPI+k6g4KGK9zU9BU9usZsYgOyz110YBAtskSVrS N3z1UoOnONyQJUXnvlqJ+KyNpPSTE9ko1JdGrWcRBR3CA3FSxjgXhCutxm8daDxOSt9uhOhhAum/A eAHJwucw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgjCL-00000008ahe-1pqi; Wed, 21 Aug 2024 11:08:17 +0000 Received: from mail.thorsis.com ([217.92.40.78]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgj4K-00000008XXk-2mMz for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 11:00:10 +0000 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> 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_040004_204002_63594FBF X-CRM114-Status: GOOD ( 11.56 ) 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 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 @@ */ #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 *pdev) if (IS_ERR(otpc->base)) return PTR_ERR(otpc->base); + // NOTE: Maybe make this optional, especially if sama7g5 testing + // shows the clock is not required there? + otpc->clk = 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 = readl_relaxed(otpc->base + MCHP_OTPC_WPSR); if (reg) dev_warn(&pdev->dev,