From patchwork Wed Feb 15 08:18:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 57422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp70056wrn; Wed, 15 Feb 2023 00:26:08 -0800 (PST) X-Google-Smtp-Source: AK7set+Be3Qd0tuaL/qWbmhyFyb4wClpDgn2TGxo4S6a6lQoy3Eu4dg9Oxdb0r+LvzwQVC5/vDz5 X-Received: by 2002:a17:902:da8c:b0:19a:9a66:9030 with SMTP id j12-20020a170902da8c00b0019a9a669030mr2842849plx.4.1676449567705; Wed, 15 Feb 2023 00:26:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676449567; cv=pass; d=google.com; s=arc-20160816; b=GhQyAdI9VJFD7DjLwyXuLb/8//zuIR1WLTKiYlzosSQk9WCmI3/FkOOqwzRgtB6HYs ru80UqpAkakPH4DdkNgmBEJp5UN2n46OPil07tvgibzzZaTGrRPIeriumHbETCF8TPhR ZltFC6fpGAPbF91/J5QoKVDPOwb2t6YSYnXiZHonYDGNTBNFkHbavN1cIN+9G+OvUdIU 6e5aOI+MvdoOtCKgtYWDCHjFisrHtibBpXxr7QYIOA4WiNyG2U2Yw4W74w1xKHe0gBNC QBx5QlHus/igs9aKsFBbMs7zwbH1kuvVEkcC7i5QbbUYbyPWwSwJwUNHi+uo+E0EcVn9 ydgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VdZrAV39bni52qDgW8gVM9Ny/UmpHAeL4/SinHM4BMI=; b=SPxLQsv9JGYVGbtHrYLE3PDy6FQZcv2UeqyDgb8i5hZksLy+65B0rQsW+ajYouDp8v EuMUW2X0Xl996NDyLzksSMFNNkEOQnYgJ5DD2qtEB8PdgO8/OUe+66ITEBa+IaJjpBC2 qc29+orbpT8D1zut7aJZIHOwKCLicio6tQ+BxymHSSUGkqE+7YjtEAYlOmYd6O6jL7Sl 3nq02suUXSUUe/6icWOmQK5mpUmthz3IXMSapZTbLwlKL3RGQ3deCfwSWDp0WQvs9hu0 ZZln7woWvTZEyNuiABmmBMAD2iz4DddyvdzrZeMmwMWvywKPEMPuMvahlPc8Uk4r0jSX n1bg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=rY1PDTYu; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a17090332c900b00199049f8844si19673467plr.118.2023.02.15.00.25.55; Wed, 15 Feb 2023 00:26:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=rY1PDTYu; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233036AbjBOITA (ORCPT + 99 others); Wed, 15 Feb 2023 03:19:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232690AbjBOISy (ORCPT ); Wed, 15 Feb 2023 03:18:54 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2070.outbound.protection.outlook.com [40.107.22.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 980C636442; Wed, 15 Feb 2023 00:18:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gEIVhec2oVaIbk2qJkCNakID9dvyDW08vfxMmJ+h9xjS8wXoimUkk30mLe7V6ow4v3YlpVWCu685EjJqQsUYBgiFqTZZ2NwJa8Gq6jv9JZqQYRVcgaw1lmKTl8RTunamTeNWUunWigmRt0euC3nRChZBvST7LxE+tNpp3eMn6nJOWylu7g7wor1RXJyaOUFdRGJfAunq0kxsJK6bM2w5kn8NcAaS24PLf0Ly5/HLCuWEUmMfZ2yY71UW5NcZ2Gs0sN8SaCZg+H3n20aRLL/OGVvOsY8nRlMFt27oB7Q1I+iDPm6ttIfQr+z4Q+4qL1KmxhMFu2GM1LJGQM0oH77WSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VdZrAV39bni52qDgW8gVM9Ny/UmpHAeL4/SinHM4BMI=; b=aUgJyUEs/BnlpBF/LssoqWx4BzPqCy3hARwEd2+MOw0uhNoSBYiySy9YDsVkhEZ4bSV9TSGWdpN43hpdEaMBz0zUErQkHmGz0luUT8p6NVsHXWWsrxLFSUfyYbDkRjlg3SfBr+/k4h3LbwTYtOQTABgnPErMY362grxilOzs2sCRvkcMpz8STRbJWl6g10cKYU1L3j8XJRkn0XD9Ze340IAqGt8/7/jxHKo0UdVjhWM59fybcN8p62F/V0QkAfWW2O00NqJt4FS4D2Rlrq4pt7KXeCcNq2s48hOgbIwoUeQv/IUVgK2Rox5EMKbkplM6u3Xy6bQH7OYj2U1kdlv5wQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VdZrAV39bni52qDgW8gVM9Ny/UmpHAeL4/SinHM4BMI=; b=rY1PDTYuEWJ7BPoZGX9zA6fsUe2kgAj2iB6Acoz2O7pXM1r6n0O8qYyOryqwbkrdfEtMLbVggZ/Og4o27ZUetG8pDuvB1r8wnNCTzSibtzkIvyWFOCso0D3LZrPhMp6P5ATMDuQ6rX8j3fp3gFhsuc7qTQdlfZqvRPgmGmiiLTY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by PR3PR08MB5706.eurprd08.prod.outlook.com (2603:10a6:102:80::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Wed, 15 Feb 2023 08:18:49 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::93ad:a231:e2ea:d1b1]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::93ad:a231:e2ea:d1b1%5]) with mapi id 15.20.6086.026; Wed, 15 Feb 2023 08:18:49 +0000 From: Javier Carrasco To: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alessandro Zummo , Alexandre Belloni , Rob Herring , Krzysztof Kozlowski , Michael Riesch , Javier Carrasco Subject: [PATCH v2 2/2] rtc: pcf85363: add support for the quartz-load-femtofarads property Date: Wed, 15 Feb 2023 09:18:15 +0100 Message-Id: <20230215081815.3141776-3-javier.carrasco@wolfvision.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230215081815.3141776-1-javier.carrasco@wolfvision.net> References: <20230215081815.3141776-1-javier.carrasco@wolfvision.net> X-ClientProxiedBy: VI1PR06CA0161.eurprd06.prod.outlook.com (2603:10a6:803:c8::18) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|PR3PR08MB5706:EE_ X-MS-Office365-Filtering-Correlation-Id: 73d8a279-971c-42a7-cfca-08db0f2d43ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CnoT6kFr5kDlm9NcuoOU7+B7jzLPilPMEXbe52jEFvNUHbSsi8obuGm4NIdqRBYFsPfO4ak9D4WaKgw9lAMQmQQIkJuUJdmIzkhluvYhe07x2AEL5+nH0R5EjAkzLa7TCnpEJfo0EQkFK/8boZxhKEVyeO6HgA6CNqo3BPlJV/Qc3blzgf+ATRuH5IzkA3HYnGllHqB8ItpDGWpx/vvMOZaRcOuQG0NhTs5MBsQfVDWlsTszGIzrkCGgSft/87+5MgvHFfHupJYupVIYtHpxo152FIU4+K/6EZAhhQ2aJQwtEeO47S6uNwMJ7N5v7E8hInQ42eH+UAX99wTNZS2r6HG4HqPHm1B4mpCZRsz9WkPO73EaXPRGPf/FA1+IAQF9eoYeIMi6aryExY7c836bMPw2/8/Hm5DfXmk++80cHK3JAeWsz997ixttuzXJG1QPbSPtRjones4dzrysBtQ8BHEr40P7d3f1nKRXQVU8v77UqXHX20EQvTAPKPGFdoQl6PBm6CPuJvusWSo+Kyb69JwfsvTggGmMg4ieT6FFIVpWdrvViwKuvLsnH68j2zOnkX/kVxHsnLA9p3BgmBUnckitsQ0OHcvyh6VTIgjwaxzMNk1pNyIjSBpEvF6BMoXUbXawf7HskKf4XvZn0Oji/ca8eq8oue4iy5uL/0pfCRJoUwxPVrArCSrtI/wI1aKfHlOxnA3WCProDnqUt0bGMg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR08MB4974.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(346002)(376002)(366004)(136003)(396003)(39850400004)(451199018)(83380400001)(316002)(54906003)(38100700002)(38350700002)(2906002)(5660300002)(36756003)(44832011)(86362001)(4326008)(8676002)(66946007)(66476007)(66556008)(8936002)(6666004)(107886003)(1076003)(2616005)(478600001)(6486002)(26005)(186003)(6512007)(6506007)(41300700001)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K+RZkDmfmQaf/8S8A6ZR7fP+yufzfePc7KWQ9vgrCKQncV5U88CbfTl5mRPTPqQy98kR4Mu+ctOyDp4kmJSUhSPx7O27aVPk06kRB8CI74eQIt4p/usb+hTof0AH0iE6mWa2XtYo5mPzSo/yp/+/oE6YV3aMUOVzljBSYoODLTZ9hFfa0P7Eb6+PZ1oiB5X9IjLAANRD8TNtz3d13WwEk9+1d4kEl6anOWzJ3anY8gY1Q0jZBzuDOGXJx3aqJFZey0kRZbYq+Kzk3KVOZdzmsM6M14uwIYeYNoMH3WxjQsAj0hhSrSIK9wF1oZnEt8zgL7hmVihhnaEkacKKIntgx44lzJm5udG+pSXRT6BAGYQvid1IIpEOfo6lUHZ1d0Dwvjg5wHTAwZ1LVCfKizp9FwpWDe2E5DeKQWVDWQgg2qVQKu1aILa8ljE9nMu+19erq8OfjKzdJLv7DkaHjOUX17CKty9aCWK0eoI7xeoSRBiUqCfi48+19FmhbTkeOHfyPBrqIRipQW786l+IGcl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Qh+1TaNNoHqvJUCccbANqaZ2D0= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 73d8a279-971c-42a7-cfca-08db0f2d43ef X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2023 08:18:49.2198 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1foFLZNwyK20Bf9iwf9S08gBfese+Okkh4SrWf8XSSgqk66sjLt1m8tL+S8NbeRYlnlRvz3/c0ZkOpabvi3ZBKxW6V1REC/DLWe6GBUmQeE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5706 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757884781479316059?= X-GMAIL-MSGID: =?utf-8?q?1757884781479316059?= The quartz oscillator load capacitance of the PCF85263 and PCF85363 can be adjusted to 6 pF, 7 pF (default) and 12.5 pF with the CL[1:0] bits in the oscillator control register (address 25h). Signed-off-by: Javier Carrasco --- v2: - simple assignment operator instead of |= for the "value" variable. drivers/rtc/rtc-pcf85363.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c index c05b722f0060..219fbca8c47f 100644 --- a/drivers/rtc/rtc-pcf85363.c +++ b/drivers/rtc/rtc-pcf85363.c @@ -101,6 +101,10 @@ #define PIN_IO_INTA_OUT 2 #define PIN_IO_INTA_HIZ 3 +#define OSC_CAP_SEL GENMASK(1, 0) +#define OSC_CAP_6000 0x01 +#define OSC_CAP_12500 0x02 + #define STOP_EN_STOP BIT(0) #define RESET_CPR 0xa4 @@ -117,6 +121,32 @@ struct pcf85x63_config { unsigned int num_nvram; }; +static int pcf85363_load_capacitance(struct pcf85363 *pcf85363, struct device_node *node) +{ + u32 load = 7000; + u8 value = 0; + + of_property_read_u32(node, "quartz-load-femtofarads", &load); + + switch (load) { + default: + dev_warn(&pcf85363->rtc->dev, "Unknown quartz-load-femtofarads value: %d. Assuming 7000", + load); + fallthrough; + case 7000: + break; + case 6000: + value = OSC_CAP_6000; + break; + case 12500: + value = OSC_CAP_12500; + break; + } + + return regmap_update_bits(pcf85363->regmap, CTRL_OSCILLATOR, + OSC_CAP_SEL, value); +} + static int pcf85363_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct pcf85363 *pcf85363 = dev_get_drvdata(dev); @@ -372,7 +402,7 @@ static int pcf85363_probe(struct i2c_client *client) .reg_write = pcf85363_nvram_write, }, }; - int ret, i; + int ret, i, err; if (data) config = data; @@ -394,6 +424,11 @@ static int pcf85363_probe(struct i2c_client *client) if (IS_ERR(pcf85363->rtc)) return PTR_ERR(pcf85363->rtc); + err = pcf85363_load_capacitance(pcf85363, client->dev.of_node); + if (err < 0) + dev_warn(&client->dev, "failed to set xtal load capacitance: %d", + err); + pcf85363->rtc->ops = &rtc_ops; pcf85363->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; pcf85363->rtc->range_max = RTC_TIMESTAMP_END_2099;