From patchwork Wed Jul 7 07:16:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathew McBride X-Patchwork-Id: 470786 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp5731912jao; Wed, 7 Jul 2021 00:17:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/65IOJ04eS1SvlyW0Q0FfgxvQK3lzYj+cXRM820wlcC+9owDBPkqY+1XCBCRxldnEiBxn X-Received: by 2002:a50:ee98:: with SMTP id f24mr3999583edr.72.1625642245826; Wed, 07 Jul 2021 00:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625642245; cv=none; d=google.com; s=arc-20160816; b=brSV5l4Di5ukRXX1mid6aoKBivBIV3nImNhjWp8ZB0B8gS7KspNJDcu1DZYDcCf6lV f/81bTkFRYKjRnyqwHb3M/ABlWKVR9Ee9RAIoVKg91ngN2qFf6xmgIqmdWWoZc51xXO5 NOH7j1hXUx5z/Dwp0JbOk42WDur0Ta/nW3tT2CIaIUmMO7iyd+PwmAtaCJTAut7Nc7bG KQkWbL5cX8Wbhts8xU95XBn4TmRFpmcV7HruLZ9IcVUnVeu3bbT/tXdWzl0ksJF25UpE th1gbP5xl+YKdLUGuEOBrXvPrNmniB2RR2DLQXT6j2U/okVrFC2G9mylTBLGYG2gtUWR Dc3Q== 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=MktD/xXCqcqj8q7cUFe+PwgxPjObZLIa/Eh89OVde9Q=; b=Rkqg3wlqNBBhct9lU6zMEpl0LTmqKvRTe1dKMwMnz/ObOrLbOyUHo3COPFfyXAtslI IqahsloVXUfO2p2xluVVCn7h7CdPtZ8VEJ2sCwNG76tmB7yzcQ18Dw4lBySK+B3Ap7cw 7bjai50eXLTVNv7AqqtiC7gFV6ZywcxvZIeCdos5/l5Fmiez1YL5S4sW7K6XdoP28k8a /Qn9wuqtx/xd6HauK0vm9e+Y2x5mwRxG4RFITnvm/irLW72cbBGPIsfLBOUnG+4Z4xln vjfkIYpt2lMTK1ibVU+SiKLXnB9ZbZ6kW5z8pfmuEWLQLOgnaPQagAuA2Hp7IlxcPY6n ekng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@traverse.com.au header.s=fm1 header.b=sYLNoiuH; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=mGOq4beE; 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 l3si20509554ejd.407.2021.07.07.00.17.25; Wed, 07 Jul 2021 00:17:25 -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=sYLNoiuH; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=mGOq4beE; 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 S230349AbhGGHUE (ORCPT + 7 others); Wed, 7 Jul 2021 03:20:04 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:51451 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230340AbhGGHUE (ORCPT ); Wed, 7 Jul 2021 03:20:04 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 4267D5C0148; Wed, 7 Jul 2021 03:17:24 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 07 Jul 2021 03:17:24 -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=MktD/xXCqcqj8 q7cUFe+PwgxPjObZLIa/Eh89OVde9Q=; b=sYLNoiuHXpQLaFI3cW0h6VQDKYDCm 5g+QsxN8MyIjx85AQjUl3nsMQVwKGabRgJqvdIYgiXPTaimRtSxoi11xh8woWlyb ciEgZUSc+kaXWewa0iND9WUSv+cpoGtn66RTbRu0Ziodazx6R5w3OKiLXORC9zag BqydI15MeJxCsxt0jSCJePaBLEoAnjP+TZxoKuLEets8R4Pwhll8VRdJyO8TMeF0 K338pc4DvE0t09wUgv+sH8adVYU3C3fbFST2CZqkEUygY3YKw5J75NZi8cDDykw5 C7T9D7A5vYawSixN4T79S+na6OUalJDPmHkqqhE42OzFPpK3NnX8DK8fQ== 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=MktD/xXCqcqj8q7cUFe+PwgxPjObZLIa/Eh89OVde9Q=; b=mGOq4beE cJZfyQNqCxJl3LBLjekddmL0guoJHp5xm+0gQ8JPN5TDcVv37B05w1s8UrYpCSHz Psm29xnmcfkdFDu2vxj7QwK1lzLaYJnUGiZEroNXxZyMcpm/L5hEhcOm6P49rlP5 NCK7uaVXcMq0gKernbF3sAv5nvHKgSjSRZ0VBLoNn/7uFpq3KOVgha28tTJBWEVd SzLOomCbhGzVnFfl3Hhper2GUCQB5wf2nR5bpZaNcRwqRE+9CyaBVqDoIrX+CJ9d HU5uHHo7bIoGIuAKadvCDLECaiaycofieIm649GUaTqt/JBldo4A2l1x2ZeXYIcS D9F5aFo7NXzmqw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrtddugdekkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrthhhvgif ucfotgeurhhiuggvuceomhgrthhtsehtrhgrvhgvrhhsvgdrtghomhdrrghuqeenucggtf frrghtthgvrhhnpeekleevteelvdduheetgfdvfeelueekffeggeethedtteeljeeivedv gfehjeejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrghtthesthhrrghvvghrshgvrdgtohhmrdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Jul 2021 03:17:22 -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 1/2] rtc: rx8025: implement RX-8035 support Date: Wed, 7 Jul 2021 07:16:15 +0000 Message-Id: <20210707071616.28976-2-matt@traverse.com.au> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210707071616.28976-1-matt@traverse.com.au> References: <20210707071616.28976-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 | 59 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-) -- 2.30.1 diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c index c914091819ba..1a33ec402f4a 100644 --- a/drivers/rtc/rtc-rx8025.c +++ b/drivers/rtc/rtc-rx8025.c @@ -60,14 +60,24 @@ #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 type; u8 ctrl1; }; @@ -100,10 +110,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 +143,8 @@ static int rx8025_check_validity(struct device *dev) return -EINVAL; } - if (!(ctrl2 & RX8025_BIT_CTRL2_XST)) { + xstp = rx8025_is_osc_stopped(drvdata->type, ctrl2); + if (xstp) { dev_warn(dev, "crystal stopped, date is invalid\n"); return -EINVAL; } @@ -125,7 +152,7 @@ static int rx8025_check_validity(struct device *dev) return 0; } -static int rx8025_reset_validity(struct i2c_client *client) +static int rx8025_reset_validity(enum rx_model model, struct i2c_client *client) { int ctrl2 = rx8025_read_reg(client, RX8025_REG_CTRL2); @@ -134,8 +161,13 @@ static int rx8025_reset_validity(struct i2c_client *client) ctrl2 &= ~(RX8025_BIT_CTRL2_PON | RX8025_BIT_CTRL2_VDET); + if (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) @@ -149,7 +181,7 @@ static irqreturn_t rx8025_handle_irq(int irq, void *dev_id) if (status < 0) goto out; - if (!(status & RX8025_BIT_CTRL2_XST)) + if (rx8025_is_osc_stopped(rx8025->type, status)) dev_warn(&client->dev, "Oscillation stop was detected," "you may have to readjust the clock\n"); @@ -241,7 +273,7 @@ static int rx8025_set_time(struct device *dev, struct rtc_time *dt) if (ret < 0) return ret; - return rx8025_reset_validity(client); + return rx8025_reset_validity(rx8025->type, client); } static int rx8025_init_client(struct i2c_client *client) @@ -519,6 +551,21 @@ static int rx8025_probe(struct i2c_client *client, i2c_set_clientdata(client, rx8025); + if (id) { + rx8025->type = id->driver_data; + switch (rx8025->type) { + case model_rx_8025: + dev_info(&client->dev, "Type RX-8025"); + break; + case model_rx_8035: + dev_info(&client->dev, "Type RX-8035"); + break; + default: + dev_warn(&client->dev, "Unknown type: %d\n", rx8025->type); + break; + } + } + err = rx8025_init_client(client); if (err) return err; From patchwork Wed Jul 7 07:16:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathew McBride X-Patchwork-Id: 470787 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp5731944jao; Wed, 7 Jul 2021 00:17:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2nW79l7kNwtd8G0x1kzsB8MubSerm6Ah1Aof3xoHWG77I1hK1b4EptYNJzBI4gG9k0AGL X-Received: by 2002:a17:907:724b:: with SMTP id ds11mr14443441ejc.192.1625642249496; Wed, 07 Jul 2021 00:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625642249; cv=none; d=google.com; s=arc-20160816; b=d1tbNvGdFMAN9zvCRnC1xsV29CJSVmCMQu3hqzEi5ALlMDZlbVN+lacs18WYYHyHtr I4u4k4jaTxT7jm/86Ej3kUkEhMahtxClMAtJbJgK0aMaeWYrqg5besSsvHjqEFj4iuAm sfR47vILHhks1CdvFUzcv9CETSikkJ/ZkgbLTfJHvRCMZCK3h5TZXJOvrT3aaquBXswB G43OcnSAQ8dDi/Ju4e3W9kJIcIH/xrr1+eCBVWEMizA3gEyIDgJ9RtvdrP9zKhokjdCU 9y4JJ2Py1jCEdrk+dQxeqQ4VzGNfKpwxfi6qVkDUrhRr8coe6cbJe9mysqlI+GMqVNcf o0aw== 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=HF76j+H0g9EEBKAfFJIMLpwlBtodsyO3RO1aFq5ti8s4txNpL8lzOWhroI0WaMDxuw vYn7xrXWtT7o2PWBNHMkj9YF8gvvC/DWg6iI15HKPPH9ofdmGYZHokrGpXixeS1V7ZVA wv/vawa+Aj+F1MS3ycjy3REv77csf0lGexOaoUeGYyjCt6/26wk5ZuiN+ZYY1r7Ri+YZ DZqAxerhtvodocEuSNWdiDMJC9KNH7hS5nsW0ja6O8nBi0L8wui4jqUIKnixKdIzenhF YLEvcVDQLMiRfBWkr0qi6PQ1WGPvtGmz9z+Y+ixwpSPThYh4q31cHBZv80q0rtl5Jjrz 5ZTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@traverse.com.au header.s=fm1 header.b=ndUWsJpN; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=H29aRc7E; 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 l3si20509554ejd.407.2021.07.07.00.17.29; Wed, 07 Jul 2021 00:17:29 -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=ndUWsJpN; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=H29aRc7E; 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 S230340AbhGGHUI (ORCPT + 7 others); Wed, 7 Jul 2021 03:20:08 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:42889 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbhGGHUH (ORCPT ); Wed, 7 Jul 2021 03:20:07 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id EB26A5C0143; Wed, 7 Jul 2021 03:17:27 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 07 Jul 2021 03:17:27 -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=ndUWsJpNu4iFHFS4xZjv/K0RJftEQ Ij3cDV7XxE94hE6PwgtdFk8zSbdMR7LV9+eRLEqSQmSrvgSFgrPG6K4K8IS5FVn0 Mhp8OepO9crszdlkbC8cei6qjy+q0gTzhqnPywF68SXo3/l+/7sqLm72q/bt4Y8c KSX8SCo04yp/dNM/CpIqJRQiYKMVq5rDYHTpq6hhLhpyAfAXd7AJeBEXnrUM9/E3 YRTjzk1211OiXr+PDIPPWf8DImj0y1rLasz2WqvRBq/j4oVR0xpO/mobzk+7HdLo ALxN7Dgo6J+c6vuBggvZYgIoupZmsplkfSTwjE9WSATs8tvQpbdQMwnhA== 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=H29aRc7E TZck2xW8br1WNNeHD5xPLMTJFjsAUy0+9SR7oVuOoF19E5Co1HTt6fAHF+Tl6PBl 8BJ59RGZwK4tIfO7Lm9RUzIinFoCWnjHaM8ip6FsimR4IoZYxc0Tzg95J6okCln/ 9eAB5w8rF0VCTk7vT69UXHr1CZpSJbAyYM1AwIgmJJLvUfy1h3U+rUwwcFZKuxun bBx4RgKzzWNpcafiryKbBOPknHF78ajypYzqX44IN/vkXTdPbf3dGGZ5I/UI5mtD JBcP2P+VZFPwljrudGQgvAYZJwrUTivO+mpPOEtvxvr0p0ZuDjYz2tLKgatVe4+r uz6kMK3Xb0uXaQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrtddugdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrthhhvgif ucfotgeurhhiuggvuceomhgrthhtsehtrhgrvhgvrhhsvgdrtghomhdrrghuqeenucggtf frrghtthgvrhhnpeekleevteelvdduheetgfdvfeelueekffeggeethedtteeljeeivedv gfehjeejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrghtthesthhrrghvvghrshgvrdgtohhmrdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Jul 2021 03:17:25 -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 2/2] dt-bindings: rtc: add Epson RX-8025 and RX-8035 Date: Wed, 7 Jul 2021 07:16:16 +0000 Message-Id: <20210707071616.28976-3-matt@traverse.com.au> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210707071616.28976-1-matt@traverse.com.au> References: <20210707071616.28976-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 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