From patchwork Mon Dec 19 19:09:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Lambe Jr X-Patchwork-Id: 635231 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E703C4167B for ; Mon, 19 Dec 2022 19:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbiLSTJ1 (ORCPT ); Mon, 19 Dec 2022 14:09:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbiLSTJ0 (ORCPT ); Mon, 19 Dec 2022 14:09:26 -0500 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47A0265EE for ; Mon, 19 Dec 2022 11:09:25 -0800 (PST) Received: by mail-qt1-x834.google.com with SMTP id c11so1216351qtn.11 for ; Mon, 19 Dec 2022 11:09:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sparkcharge.io; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bt+7Tt3o+8BEAMqMOB9mE5Ei3bYGSWfShEIE2EXWhpo=; b=O5J1MFkjtu2DK19SHsxcO3VrHhhB8EpVDYNdgzjZ0zHbqHMUFfbZQvk08Dy3DgzZVm 37ZKzj8XwRFcDuOPGtx1aale3ohpUFIkWjH1lXmMnBgZUZdaJceu0P52qw9ItMISuktB Gbu81ooJyEzMpklfqyM258OjRg8CJZ1cK9zthDBV7sWVWv/DxuKEbaacQp1SvGzq214i OpGYIy7XS5tvowHg4eA8fUkjf/hu2zBLkbvRG03ZOJuXtBDyTgJhg3kKHTJz/BBeKcuq AOsduwgkcJ3vczfR/KZMUI7uAy3o5W+oCRi2xIbkYiwRDOP3HHmPcWv2ocA68gneMNjM t71Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bt+7Tt3o+8BEAMqMOB9mE5Ei3bYGSWfShEIE2EXWhpo=; b=EO9Z2jK2ktGh2t9QXQP6DWZRT408PlFjcVzBNO0mCDc6348St7JNjM7Cm/YOzEIZKP LfcnmKSk4bm/3ZQHxLu1LQonTbr2WVfc6yUuaN/lVsM7St+o3fUsujrT9eP2IArpLNRc HrObHaMTAodvS8qumD7M+us7k781o5xYF4WWUjzajAaJ629aUoVdl6RGBjKEW0N5YvaR kksUtpfXbm1A/++fcvVsh9AON6MJ0kQ+gQ0lNMvBloguU2tpnRg8lmv9fKTnN90v6PLg 3V5IAnCCePCC1aZhAjSbhqnuFAd5iyT5lsxhDvO+1R4C7k99xvzOHD69r6/Z8jvSoXjh Aadg== X-Gm-Message-State: AFqh2kqeZIpgOdhm4nCtQ2y2XNq3r6ezCvl0ndm280ii2KrhKge2S044 Mzfa0vIf19AXtZU5u9Sj/Me0kA== X-Google-Smtp-Source: AMrXdXtqIvJprjFkBeCepzDnuDDIM8nlR+euxdUGloYM4/cmVIT1oBBjJWppDGM+nV9Gmx+hG6Zcfg== X-Received: by 2002:ac8:538f:0:b0:3a9:89f1:828 with SMTP id x15-20020ac8538f000000b003a989f10828mr5685143qtp.14.1671476964289; Mon, 19 Dec 2022 11:09:24 -0800 (PST) Received: from localhost.localdomain (c-66-31-16-167.hsd1.ma.comcast.net. [66.31.16.167]) by smtp.gmail.com with ESMTPSA id i16-20020a05620a249000b006fa9d101775sm7503743qkn.33.2022.12.19.11.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 11:09:23 -0800 (PST) From: Dennis Lambe Jr To: Alessandro Zummo , Alexandre Belloni , Krzysztof Kozlowski , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Alexander Bigga , Dennis Lambe Jr Subject: [PATCH 0/3] rtc: m41t80: set xtal load capacitance from DT Date: Mon, 19 Dec 2022 19:09:12 +0000 Message-Id: <20221219190915.3912384-1-dennis@sparkcharge.io> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The m41t82 and m41t83 have an adjustable internal capacitance that defaults to 25 pF per xtal pin. This patch series adds the ability to configure it via the devicetree. Patch 1 just switches the CONFIG_OF-dependent block in m41t80_probe() from an ifdef guard to an if(IS_ENABLED(...)) guard, so that I don't need to use __maybe_used on my new functions and variables. Patch 2 is the DeviceTree YAML changes. Patch 3 is the actual added functionality. The desired capacitance comes from quartz-load-capacitance property, following the example of two other RTC ICs that have adjustable internal load capacitance, the NXP pcf85063 and pcf8523. The m41t82 supports much finer-grained control over the capacitance than those chips and calls the feature "analog calibration", but it looks to me like it's essentially the same kind of thing. My use case for this is: ST specifies not to add any additional external load capacitance[1], but the MikroElektronika RTC 9 Click board[2] has a 22 pF cap on each xtal pin[3]. The resulting combined capacitance appears to be outside of the operating range of the xtal, because when power is removed from the boards I'm testing with, the RTC reports an Oscillator-Fail flag on the next power on. I found I could work around the problem by reducing the internal load capacitance as low as it will go. I have tested on the VersaLogic Zebra, an NXP i.MX6 ARM. I made sure it compiles cleanly on amd64 with CONFIG_OF=no. References: [1] https://www.st.com/resource/en/application_note/an3060-applications-guide-for-serial-realtime-clocks-rtcs-stmicroelectronics.pdf [2] https://www.mikroe.com/rtc-9-click [3] https://download.mikroe.com/documents/add-on-boards/click/rtc-9/rtc-9-click-schematic-v100.pdf Dennis Lambe Jr (3): rtc: m41t80: probe: use IS_ENABLED for CONFIG_OF dt-bindings: m41t80: add xtal load capacitance rtc: m41t80: set xtal load capacitance from DT .../devicetree/bindings/rtc/st,m41t80.yaml | 18 ++++ drivers/rtc/rtc-m41t80.c | 84 +++++++++++++++++-- 2 files changed, 94 insertions(+), 8 deletions(-)