From patchwork Fri Jul 9 04:45:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathew McBride X-Patchwork-Id: 471786 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp952472jao; Thu, 8 Jul 2021 21:45:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzI3a42OIdIUTYyuQYh7W3zQgimRM1DWNfLiXHzSRcYtQ/XTBKFcCeAUFk+gerjIkL9n2I X-Received: by 2002:a17:907:2ce6:: with SMTP id hz6mr35173428ejc.325.1625805938478; Thu, 08 Jul 2021 21:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625805938; cv=none; d=google.com; s=arc-20160816; b=mrgQL/C7ebDw+QNg+ebyvMnlYKJt4wjz4n5VqQaD6Vd8TUfR6fwcDQUT3fSasQOYCB Ira2sJXqPtuHyYBD375deeUod125yw/9W4K4uKI6Q82GS3nkx1U3Quxoc1RoW4KAxwyk GAiPg2rQgSXmlikEjah2yxsQw2KmjPt8yp2Yue9LsyirhK9ietW59Kh6QsbMYeFXut0L QNZL7QW6IzkscZHNesWcL9qA1N2WlIiFInNtlsRzsM+pOWGK42Olq3nkBG+pPvNXneq7 N4omSZe5NOoHQ1wabWCZBBIyKthsYH/18hHe8/KtyzLME9Rm3eizlWBhNTFTq16wGAcT 41TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=eK0WV/zEHFtuRFWHm0jzOm68Jx13N9BURcSUN1+ytBY=; b=rDBJyGgR/N3U8TU1uWDa1jIOPAX7yXnLEHmmMGIurIxKK35/2hJVthGfuPDCCvK9w+ qzp/GKuummtP04MFo87Px//JaEyqwGGGpQIO6D5xz5cq/tVCJjK/nFNRIOfr1fXXYqLj KrVRAwi0I0xhLy3pg71JGfS+yiZNXr/MRLYE1xaL4zANQCEut2D8wgV96L5Je4ou+BUN 2sFMAnxYWRno1WSMw1e/6cijK/PVMKZumGdmOJiPHf10m6+3Zv5b8DQMvfTfxSwD++a3 wKC87gtpXtUV57vi7m3gsgfNjCMewNC1xIRoa6oze1Ncv1zXiHtwFYJH1QbMo+qkCcDh w2vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@traverse.com.au header.s=fm1 header.b="eq1X736/"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=b2lfUqaC; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si5550641edd.65.2021.07.08.21.45.38; Thu, 08 Jul 2021 21:45:38 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@traverse.com.au header.s=fm1 header.b="eq1X736/"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=b2lfUqaC; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbhGIEsT (ORCPT + 7 others); Fri, 9 Jul 2021 00:48:19 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:56789 "EHLO wout5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhGIEsT (ORCPT ); Fri, 9 Jul 2021 00:48:19 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 16BAE320089C; Fri, 9 Jul 2021 00:45:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 09 Jul 2021 00:45:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=traverse.com.au; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=eK0WV/zEHFtuR FWHm0jzOm68Jx13N9BURcSUN1+ytBY=; b=eq1X736/Jpuowq4gl+4cDFHj9lK5r jk8T1TzdMHIoqV1zb9yFFA01XdS387s8+W7/YbcfruH9Wb4LFEctDSre6u/Q90LS hXOYkmaIHXncTDAVPQRC5BFpmCdiZxYErgCsxNA6sTd33feDJCxi8hYnB6nSqNWD mSr2ZSTBw3bbSwfuMiQdO4PN64k9cojChzUoFaY+RQXOCBmSLMSSr/gbKzHPX19u 0EtdzzXMP47rauHCH43WzteRkQEhBax1288zlsAmg1T1+HIDoByhXAv80CIKgJKN HB44/EQ+muuMCGcahcz9op5rr3xFeA1XgOB4DEFthmif8PaDpAzNaBkrg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=eK0WV/zEHFtuRFWHm0jzOm68Jx13N9BURcSUN1+ytBY=; b=b2lfUqaC KPizEX7O4VMo61y7nL5mh6IsRWCl5u1q8FNsNDkOxMX8k7BwUIhlLmadP9kIkqhl 7oPrsMt9WD19WsEr6+6VrgaHzpaPS7XtaXHpvpUq2njecfMurQuuDZn/AVFXXmm+ 44kjc53c7FwUfFzp9CHm7qXWFeWzNX+VB91ws7YS/qAjsJyg1h5cmmY/Ttpv5z0b vKSJKBMg/iaMPtE8pds/x0sjV5Obj4QnkBBYt6wC1wBFQlj03zQj1nxcyHQ1MmqO 0txefcp++T2IfdqemJJ0NzOa4Nk7mYdLj5HXSbeXSlg6P1iZq7LNzWNwRQR0QX6h lIcC/ttZpymcTg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrtdehgdehkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrthhhvgif ucfotgeurhhiuggvuceomhgrthhtsehtrhgrvhgvrhhsvgdrtghomhdrrghuqeenucggtf frrghtthgvrhhnpeekleevteelvdduheetgfdvfeelueekffeggeethedtteeljeeivedv gfehjeejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrghtthesthhrrghvvghrshgvrdgtohhmrdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Jul 2021 00:45:33 -0400 (EDT) From: Mathew McBride To: linux-rtc@vger.kernel.org, Alessandro Zummo , Alexandre Belloni , Rob Herring , devicetree@vger.kernel.org Cc: Mathew McBride Subject: [PATCH v2 1/2] rtc: rx8025: implement RX-8035 support Date: Fri, 9 Jul 2021 04:45:17 +0000 Message-Id: <20210709044518.28769-2-matt@traverse.com.au> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210709044518.28769-1-matt@traverse.com.au> References: <20210709044518.28769-1-matt@traverse.com.au> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The RX-8035 is a newer RTC from EPSON that is very similar to the RX-8025. The key difference is in the oscillation stop (XSTP) bit which is inverted on the RX-8035. Signed-off-by: Mathew McBride --- drivers/rtc/rtc-rx8025.c | 58 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) -- 2.30.1 diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c index c914091819ba..7a0258fe4b8e 100644 --- a/drivers/rtc/rtc-rx8025.c +++ b/drivers/rtc/rtc-rx8025.c @@ -60,14 +60,23 @@ #define RX8025_ADJ_DATA_MAX 62 #define RX8025_ADJ_DATA_MIN -62 +enum rx_model { + model_rx_unknown, + model_rx_8025, + model_rx_8035, + model_last +}; + static const struct i2c_device_id rx8025_id[] = { - { "rx8025", 0 }, + { "rx8025", model_rx_8025 }, + { "rx8035", model_rx_8035 }, { } }; MODULE_DEVICE_TABLE(i2c, rx8025_id); struct rx8025_data { struct rtc_device *rtc; + enum rx_model model; u8 ctrl1; }; @@ -100,10 +109,26 @@ static s32 rx8025_write_regs(const struct i2c_client *client, length, values); } +static int rx8025_is_osc_stopped(enum rx_model model, int ctrl2) +{ + int xstp = ctrl2 & RX8025_BIT_CTRL2_XST; + /* XSTP bit has different polarity on RX-8025 vs RX-8035. + * RX-8025: 0 == oscillator stopped + * RX-8035: 1 == oscillator stopped + */ + + if (model == model_rx_8025) + xstp = !xstp; + + return xstp; +} + static int rx8025_check_validity(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct rx8025_data *drvdata = dev_get_drvdata(dev); int ctrl2; + int xstp; ctrl2 = rx8025_read_reg(client, RX8025_REG_CTRL2); if (ctrl2 < 0) @@ -117,7 +142,8 @@ static int rx8025_check_validity(struct device *dev) return -EINVAL; } - if (!(ctrl2 & RX8025_BIT_CTRL2_XST)) { + xstp = rx8025_is_osc_stopped(drvdata->model, ctrl2); + if (xstp) { dev_warn(dev, "crystal stopped, date is invalid\n"); return -EINVAL; } @@ -127,6 +153,7 @@ static int rx8025_check_validity(struct device *dev) static int rx8025_reset_validity(struct i2c_client *client) { + struct rx8025_data *drvdata = i2c_get_clientdata(client); int ctrl2 = rx8025_read_reg(client, RX8025_REG_CTRL2); if (ctrl2 < 0) @@ -134,22 +161,28 @@ static int rx8025_reset_validity(struct i2c_client *client) ctrl2 &= ~(RX8025_BIT_CTRL2_PON | RX8025_BIT_CTRL2_VDET); + if (drvdata->model == model_rx_8025) + ctrl2 |= RX8025_BIT_CTRL2_XST; + else + ctrl2 &= ~(RX8025_BIT_CTRL2_XST); + return rx8025_write_reg(client, RX8025_REG_CTRL2, - ctrl2 | RX8025_BIT_CTRL2_XST); + ctrl2); } static irqreturn_t rx8025_handle_irq(int irq, void *dev_id) { struct i2c_client *client = dev_id; struct rx8025_data *rx8025 = i2c_get_clientdata(client); - int status; + int status, xstp; rtc_lock(rx8025->rtc); status = rx8025_read_reg(client, RX8025_REG_CTRL2); if (status < 0) goto out; - if (!(status & RX8025_BIT_CTRL2_XST)) + xstp = rx8025_is_osc_stopped(rx8025->model, status); + if (xstp) dev_warn(&client->dev, "Oscillation stop was detected," "you may have to readjust the clock\n"); @@ -519,6 +552,21 @@ static int rx8025_probe(struct i2c_client *client, i2c_set_clientdata(client, rx8025); + if (id) { + rx8025->model = id->driver_data; + switch (rx8025->model) { + case model_rx_8025: + dev_info(&client->dev, "Model RX-8025"); + break; + case model_rx_8035: + dev_info(&client->dev, "Model RX-8035"); + break; + default: + dev_warn(&client->dev, "Unknown model: %d\n", rx8025->model); + break; + } + } + err = rx8025_init_client(client); if (err) return err; From patchwork Fri Jul 9 04:45:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathew McBride X-Patchwork-Id: 471787 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp952525jao; Thu, 8 Jul 2021 21:45:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWSVyqJfNJVjPb8n9Co6EaCgdd7f12Z/lb2zh2j4t+T0VXhQUVEHnTCvHXYA85+tVfnYIp X-Received: by 2002:a05:6402:1e8e:: with SMTP id f14mr30344336edf.52.1625805943788; Thu, 08 Jul 2021 21:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625805943; cv=none; d=google.com; s=arc-20160816; b=de9EgARlqIWKdrn30lLPzuHd3WaiqyYVd15Ci4ZIqIlU7l99He0XPuicia0ynLT65s 2pBYYRXUbj2I59XHwaEHe3Sroyrsiq7cbxlh3yQucg5yBhfLhvUrokCiU0Vzuc4SSWL7 OiWMNlRAXvHxqcHNkewCwN1Z4ZmjTcfMus5ulIBmFlGZ+af2nfTII7RNZ6VB8IZ8m/sg eNJEi2dmmz8ekY4evgzC0WeZjAY4xOSbMlhgZqissTItUSZzLCHsEND710mUu2cENH2U ez+mnrfTmusTAvyr4mSDxtNdT35useGrOyyn05dVXjV+WY+1t2EFq2Y/r2eSmQBr5PGa ybgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=qWSOt0gGfUpBvwE5RaWU1tB/jIDs+S806JHTjV04tWw=; b=ti1/JqKCyC4IKsvvGSaUO2IZTORHijMYW8fGJDEAzHFM3Qwwu6m7/cwfFjN58McOcc HhAHnsi83DFlad8vYMwgmL/qxPZrxO/05CfHoPCPZjCvG9O4RyCmiW+/FjXkatTXdu1L oyOteRXQWA4lyWAyGXB5gObRebzeEbQCEdl7wSBnvMoQhSIYpQavRTw8bICRvJjHYmkD oy3E3LmrA1LiTfOOS2oIA2e4a3x6V2PUQxUbye3h2x9vlVxXlAhcnMBHiVm4Yc1YA6FP XEgdbWIoGhvtxO8TxVm1gH8VWhvxMZJ3Nv8l0IoUcwDM+vQ3sjo2ZOYlOaQuoO9fhXgi u2iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@traverse.com.au header.s=fm1 header.b=MkaTpM+G; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=JQJnq0R0; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si5550641edd.65.2021.07.08.21.45.43; Thu, 08 Jul 2021 21:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@traverse.com.au header.s=fm1 header.b=MkaTpM+G; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=JQJnq0R0; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbhGIEsZ (ORCPT + 7 others); Fri, 9 Jul 2021 00:48:25 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:33829 "EHLO wout5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhGIEsY (ORCPT ); Fri, 9 Jul 2021 00:48:24 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id E537C32008C3; Fri, 9 Jul 2021 00:45:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 09 Jul 2021 00:45:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=traverse.com.au; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=qWSOt0gGfUpBv wE5RaWU1tB/jIDs+S806JHTjV04tWw=; b=MkaTpM+GahiUUnXbCpesJfnFbbGbB /c84WfQDNpQLNTqLSekYtFbnO/y/FogwqLeAHzIQ7OW06+xbwXo0zH06wkcBs/I+ hQvD8xXFbIB+el4Uuuu8WH4w1tVlX6Xd9iDkJLPYWomidzdW0vwzaFrLfbkPy6Qr cglr+eNcZcu/MhutzxIozBzairgTKXtLrar3k12Ed1f9KtPi/ZAenowqeUM3KBME NQu50z3Y9h6ZFFfixExVBc3pa6lqvu9NAXRFtZimZnsmEgWzU4vfiLnuoObSpgVI lEJCkBhrWnRBGgsTMoo17Ntp1BEzUlTqrzU1SWEIO9ogiPmQCDY0+vadg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=qWSOt0gGfUpBvwE5RaWU1tB/jIDs+S806JHTjV04tWw=; b=JQJnq0R0 WPKB2UFAnj6dIXlJj8yg2oByleUUpTBv6P+LKPtJRGe6DvV4cm7fkABqnd/w+nQp /FMa+4l3rDW/1NnzcPzl61hctOrCCnp/FBM17MjrLrubUzCEObWvFZ7kLp4MtnVV LqsmZyyOcuBWK77mBttTWUnBCrqIfeolOMW+zPPB1rQh1vmnryLy1rWSfkCF9zxE jEYtwSpkDgnqGYMLH73OkmMhxWrZL1a6ByeyPTWKjARFz/XFaOHNPhIRir5g/MJ6 7gCXNOevAIuuRRqjOIJjemOHY6cXxoGPcgm1QwrNcgUo1KbLMUqN8F+UPveFcw1G jZYbq/IV6QKvDg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrtdehgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrthhhvgif ucfotgeurhhiuggvuceomhgrthhtsehtrhgrvhgvrhhsvgdrtghomhdrrghuqeenucggtf frrghtthgvrhhnpeekleevteelvdduheetgfdvfeelueekffeggeethedtteeljeeivedv gfehjeejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrghtthesthhrrghvvghrshgvrdgtohhmrdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Jul 2021 00:45:38 -0400 (EDT) From: Mathew McBride To: linux-rtc@vger.kernel.org, Alessandro Zummo , Alexandre Belloni , Rob Herring , devicetree@vger.kernel.org Cc: Mathew McBride Subject: [PATCH v2 2/2] dt-bindings: rtc: add Epson RX-8025 and RX-8035 Date: Fri, 9 Jul 2021 04:45:18 +0000 Message-Id: <20210709044518.28769-3-matt@traverse.com.au> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210709044518.28769-1-matt@traverse.com.au> References: <20210709044518.28769-1-matt@traverse.com.au> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org These are supported by the rtc-rx8025 module. RX-8025 also has support in ds1307 due to compatible time registers. Signed-off-by: Mathew McBride --- Documentation/devicetree/bindings/rtc/trivial-rtc.yaml | 3 +++ 1 file changed, 3 insertions(+) -- 2.30.1 Acked-by: Rob Herring Reviewed-by: Nobuhiro Iwamatsu diff --git a/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml b/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml index 7548d8714871..13925bb78ec7 100644 --- a/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml +++ b/Documentation/devicetree/bindings/rtc/trivial-rtc.yaml @@ -32,6 +32,9 @@ properties: - dallas,ds3232 # I2C-BUS INTERFACE REAL TIME CLOCK MODULE - epson,rx8010 + # I2C-BUS INTERFACE REAL TIME CLOCK MODULE + - epson,rx8025 + - epson,rx8035 # I2C-BUS INTERFACE REAL TIME CLOCK MODULE with Battery Backed RAM - epson,rx8571 # I2C-BUS INTERFACE REAL TIME CLOCK MODULE