From patchwork Fri Oct 28 14:40:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: glasveze@delta.nl X-Patchwork-Id: 12369 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp871929wru; Fri, 28 Oct 2022 07:46:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6YJIOylXn00Fu5eRPQLg3toAEkaHanqhKPQ8x+30fg6axA376el1Nt0SWDTe7GIrdmQrLG X-Received: by 2002:a05:6402:5483:b0:45c:1336:6d9b with SMTP id fg3-20020a056402548300b0045c13366d9bmr51395479edb.100.1666968394100; Fri, 28 Oct 2022 07:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666968394; cv=none; d=google.com; s=arc-20160816; b=lIhl7p0h1EQBSHZK6mrXyO4s1cq1o2KN3QowZ2yHSKDIrY1Hte5yqqF38ZDzgBnSn8 PXTrleSiFFdtGLczQlc53GBq2YE+GLYMyUnMv8deQr71BbqY/xQSJJUFOsctLpbbVJEu aNBFKSx/ni1DZGDFcCKPoXW0gJ1NDf6iGAbYTqcq52a6oVAEbiGeuy4IM5u+mC6YzNAO 7muNYfxv94KYEIwqD++2liBn9ckntyKNc4TPINb+NUuk93kjads1FdcUf0dPTi1k0jC0 XZzJRuLfUeNj4hS31a9SOPHZyUNnRaEeW96kVytkLAHGmp3j7qP3Hrae2XYsZfhCkq3F YM9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=xlDW0sta6QxKQ1gC5wEbr7tspMCD/A8KETvX+KN6ivM=; b=yZNhCQa45BFurH06A/HzGBExxfqOAkTtqXsdaSwJSelCXqWMY0LFulzWjKGU9XAfxa mqEuB42bfUHsBwWIoIJMZS+TJMyvcr1sXHAH093cj3Xlc80sRujB9Ra0Rv7IpIeIUzMF 79HwPvEEftJknE+pgiyo53/sOXjsmg7b9lFYIfe3gACP1icYMrUKqDlaP2y7uhxLpO0O 7g9IDL04k55BkErI+tBVFyY0CphiVy6hMmj6TJcVXWjpuNbKlff4VAcPIFJBUXVlKNqO jFSG23H7vRDtyQSSAUwOdge7BsCD/tIQLue9dOtIhzjLgzKIzA3MvQftcrEpQ5kPNr1F fyrw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g3-20020a170906868300b0078df1c345e4si4047593ejx.518.2022.10.28.07.46.10; Fri, 28 Oct 2022 07:46:34 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbiJ1OlI (ORCPT + 99 others); Fri, 28 Oct 2022 10:41:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbiJ1OlA (ORCPT ); Fri, 28 Oct 2022 10:41:00 -0400 X-Greylist: delayed 1258 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 28 Oct 2022 07:40:49 PDT Received: from spamfilter04.delta.nl (spamfilter04.delta.nl [217.102.255.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC7FD4D144; Fri, 28 Oct 2022 07:40:47 -0700 (PDT) Received: from host-ubmmyvj.static.zeelandnet.nl ([217.102.255.198] helo=mail.zeelandnet.nl) by spamfilter04.delta.nl with esmtp (Exim 4.92) (envelope-from ) id 1ooQXa-0006p8-3F; Fri, 28 Oct 2022 16:41:01 +0200 X-Sender-IP: 204.168.188.16 Received: from phenom.domain_not_set.invalid (016-188-168-204.dynamic.caiway.nl [204.168.188.16]) (Authenticated sender: glasveze@delta.nl) by mail.zeelandnet.nl (Postfix) with ESMTPA; Fri, 28 Oct 2022 16:40:41 +0200 (CEST) From: glasveze@delta.nl To: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org Cc: a.zummo@towertech.it, alexandre.belloni@bootlin.com, robh+dt@kernel.org, linux-kernel@vger.kernel.org, Mike Looijmans Subject: [PATCH 1/2] dt-bindings: rtc: ds1307: Add support for Epson RX8111 Date: Fri, 28 Oct 2022 16:40:40 +0200 Message-Id: <20221028144041.11067-1-glasveze@delta.nl> X-Mailer: git-send-email 2.17.1 X-Originating-IP: 217.102.255.198 X-DELTA-Domain: zeelandnet.nl X-DELTA-Username: 217.102.255.198 Authentication-Results: delta.nl; auth=pass smtp.auth=217.102.255.198@zeelandnet.nl X-DELTA-Outgoing-Class: ham X-DELTA-Outgoing-Evidence: SB/global_tokens (0.002289898612) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT97NVj8sYO3r8fFN9efxfSJPUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5wqSBOxlRVmV45FJ8CYZCUIt8C9mOBdONdnsxgsk1D2p824 MyjFWyZM3gh7kZ3N2o0EIJgF/Accv4lLtE4TWYNIJfRvS2W4wMvaxnuacmrzO63tkTFTGbdbrgNb v6tn6AfNVkAfS7Ep78PSHeldbo1JKbK8f51zBH5eEJ3C3XgargegwxR90Cn/9qseLqmc4NPbC8dt /CV3fELBVC/AS5PvDdqpp0PwvA0T6h+PF2lQM+UptZeMWqwM87Sr86NOUNNXJcphKwwtkJ0il/aM E1JAuAZvvM53msAYiwEKD8v9MuKVse1sVhWabI0/+PN3sIJkYWvWNZaZ0U+2WAj4IohtB5Wku8Z+ HjscnTdG7OzuuhO9UWZR6DygHL2uL+fpoKfkmbmoofKALtn/uXeLjRifqraCXgGgCDOczZcC0s+1 rMP5P71XxSY6Bud0I4P+npSUhdUKb/ejZlGAm5aYDC522S9lxf1W0a5eEMc7eunFGmvh9GiopPC0 UD6wcbWJMl9n+3TblTAKGom+tz90NlkS2XisTmNxpUcDTKRyhJJrVG18n/RbDuZUqQqTgt7VC9CP AtwL+re6Uz43RIVa9gaV9SxdNCEKGT/Znx3aa/MYykHvm3Pq/TMVhLiLVSlbDnIwjZjn7QogpmK0 eNWmS0n931/E3ahF5MMcDI7KdpjQKTxLZ9y9gIsjefalsT+at7OgkXa3w91ZfeRDvUeK4qGp36oy bTZpB4Wv6ElyTZU8c8TJRwRvw2AEVD26W3GQDiXO7ujGdCQPoAa02/HGzYqRDuOlu0DGJJ/yi3xl Qv+7Ye5iAwG6iqW74zZvnRHNN8yTpLp2PMH9oCKYkdrB5ehHlkfYl3WF84H/Cjwt2E5W/Nc7xQ2h dHEckmcQGOuBPq9rt4dOEn9WJA7yfGK6BkBGG0mLtmuzbfeFGb2hZWsDt/fmCo6d12yvI0wed/0Q udAWg/9etw9TIOEergZFaJ91hnCJ4odIJjOae1BAYoct5kE8YuWLCDggped/vs/9FWCUjqRRs/Dj xSLAF0pUu0ZIctgzcDoFd+96Xw4QUNtTnctHmbpOK0RKd6E2YmmZo3u87jDsfKYWdCAewd7hjSHD v1yU8GDv9kO7wH7K9y8hX1+STHELjwkcdmgWo2JoBLv+psOGtMjI9qGEbmhFtfi+crcUX31Co0Zg NRr7F4I7T5HIIbgqOGhNKCbnOkqTNOYxCCw6fqSlOTqlv1QhfFxXVbH+G+02TrybDOP2Co+U5w== X-Report-Abuse-To: spam@spamfilter03.delta.nl X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, T_SPF_PERMERROR 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?1747943050641682102?= X-GMAIL-MSGID: =?utf-8?q?1747943050641682102?= From: Mike Looijmans The rx_8111 is quite similar to the rx_8030. This adds support for this chip to the ds1307 driver. This adds the entry to the devicetree bindings. Signed-off-by: Mike Looijmans Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml index 98d10e680144..a9590da64b84 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml +++ b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml @@ -30,6 +30,7 @@ properties: - pericom,pt7c4338 - epson,rx8025 - isil,isl12057 + - epson,rx8111 - epson,rx8130 - items: From patchwork Fri Oct 28 14:40:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: glasveze@delta.nl X-Patchwork-Id: 12370 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp871984wru; Fri, 28 Oct 2022 07:46:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5yrtt1n3zpXzGNd0uuC4fCPJJJpwOb6NL/s+WjqwnHmEC6uhfCNBunceXIWEHI4Ao7xUUy X-Received: by 2002:a17:906:db0e:b0:77b:82cf:54a6 with SMTP id xj14-20020a170906db0e00b0077b82cf54a6mr46199128ejb.691.1666968399214; Fri, 28 Oct 2022 07:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666968399; cv=none; d=google.com; s=arc-20160816; b=cUx/HCSWB8u2T/Ssas1ThctBSuJ6143B16X9LSDVp55VxAkzBMituEqEBKYbzCPxD/ 3SIJtOGLCetXZyu5UkzQCBSLg/yJ/aA9PvNTLBZFoQLXgxtBssWeSSeaVuWA8LmLJNJt 9RdigThjmuvEWbYPbosHcT+pVqWR4LNQUvigajkXK5l+CjiyDzWIfOZd5OFj03MaDFoH lArcymHYQABwHslRS8jT/C8uFkJMeA5rVcImsyMKPzisqhMINLQjJd7IHtssZE/iVLId w/3YF8gy23A9fSVUGFA4zkFgfBdyrf6iGtPV8lPdLfYEhoHDzBMRw/eXeucDtiTWySqt YabQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=ViQ2QMtGcDZLR1TUgl1HQ1s4g9d1gdcaOWkXuIbsz7U=; b=OFnk5M7VMhruyCmRLfbbUsAeoQEUT3hHrFWzqSYGJ+FYWQPM0jPbniZvlV/8N/cuiq FtCB6PJij50D0CUk/HKSk/sxlTcWRUiVR6ObiFyH+KCi1OPvP/hoJn2vpxZNUpFVe8kF tlkrBakcvUGEvNgaWGwauw+goqxlrPmkEG8rgh5q4J3Hh7QPEcuu8VncDitpofngvJQ6 d3HyfLHHvI2cwjEelXIWE+7GrBvgXWU8d65k6um94dOl9YIDRySkAf6A2Bpndk+4/Pct Cn7h2MxyiJj9zq6QeX6/y1AdLKuGNnBcalyOIUSUwg4uz4iCKFgZ+ZGv7b5eAUFeZsKu ETAg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020a0564021f8200b0045c97cb9027si4950572edc.421.2022.10.28.07.46.14; Fri, 28 Oct 2022 07:46:39 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229828AbiJ1OlL (ORCPT + 99 others); Fri, 28 Oct 2022 10:41:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbiJ1OlA (ORCPT ); Fri, 28 Oct 2022 10:41:00 -0400 Received: from spamfilter04.delta.nl (spamfilter04.delta.nl [217.102.255.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C84A230A; Fri, 28 Oct 2022 07:40:48 -0700 (PDT) Received: from host-ubmmyvj.static.zeelandnet.nl ([217.102.255.198] helo=mail.zeelandnet.nl) by spamfilter04.delta.nl with esmtp (Exim 4.92) (envelope-from ) id 1ooQXd-0006r6-Dg; Fri, 28 Oct 2022 16:41:02 +0200 X-Sender-IP: 204.168.188.16 Received: from phenom.domain_not_set.invalid (016-188-168-204.dynamic.caiway.nl [204.168.188.16]) (Authenticated sender: glasveze@delta.nl) by mail.zeelandnet.nl (Postfix) with ESMTPA; Fri, 28 Oct 2022 16:40:45 +0200 (CEST) From: glasveze@delta.nl To: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org Cc: a.zummo@towertech.it, alexandre.belloni@bootlin.com, robh+dt@kernel.org, linux-kernel@vger.kernel.org, Mike Looijmans Subject: [PATCH 2/2] rtc: ds1307: Add support for Epson RX8111 Date: Fri, 28 Oct 2022 16:40:41 +0200 Message-Id: <20221028144041.11067-2-glasveze@delta.nl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221028144041.11067-1-glasveze@delta.nl> References: <20221028144041.11067-1-glasveze@delta.nl> X-Originating-IP: 217.102.255.198 X-DELTA-Domain: zeelandnet.nl X-DELTA-Username: 217.102.255.198 Authentication-Results: delta.nl; auth=pass smtp.auth=217.102.255.198@zeelandnet.nl X-DELTA-Outgoing-Class: ham X-DELTA-Outgoing-Evidence: SB/global_tokens (4.87032021966e-05) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT8kNd2BxSw5Q8dvr7v5shyUPUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5wqSBOxlRVmV45FJ8CYZCUIt8C9mOBdONdnsxgsk1D2p824 MyjFWyZM3gh7kZ3N2o0EIJgF/Accv4lLtE4TWYNIJfRvS2W4wMvaxnuacmrzO63tkTFTGbdbrgNb v6tn6AfNVkAfS7Ep78PSHeldbo1JKbK8f51zBH5eEJ3C3XgargegwxR90Cn/9qseLqmc4NPbC8dt /CV3fELBVC/AS5PvDdqpp0PwvA0T6h+PF2lQM+UptZeMWqwM87Sr86NOUNNXJcphKwwtkJ0il/aM E1JAZtrBdHBRJ6jZlMHaTtIWCOKVse1sVhWabI0/+PN3sIJkYWvWNZaZ0U+2WAj4IohtB5Wku8Z+ HjscnTdG7OzuuhO9UWZR6DygHL2uL+fpoKfkmbmoofKALtn/uXeLjRifqraCXgGgCDOczZcC0s+1 rMP5P71XxSY6Bud0I4P+npSUhdUKb/ejZlGAm5aYDC522S9lxf1W0a5eEMc7eunFGmvh9GiopPC0 UD6wcbWJMl9n+3TblTAKGom+tz90NlkS2XisTmNxpUcDTKRyhJJrVG18n/RbDuZUqQqTgt7VC9CP AtwL+re6Uz43RIVa9gaV9SxdNCEKGT/Znx3aa/MYykHvm3Pq/TMVhLiLVSlbDnIwjZjn7QogpmK0 eNWmS0n931/E3ahF5MMcDI7KdpjQKTxLZ9y9gIsjefalsT+at7OgkXa3w91ZfeRDvUeK4qGp36oy bTZpB4Wv6ElyTZU8c8TJRwRvw2AEVD26W3GQDiXO7ujGdCQPoAa02/HGzYqRDuOlu0DGJJ/yi3xl Qv+7Ye5iAwG6iqW74zZvnRHNN8xFkXoQ7AlHFcnaD27arbY3ttduV7DW3PbFRQoy8BjTmdc7xQ2h dHEckmcQGOuBPq9rt4dOEn9WJA7yfGK6BkBGG0mLtmuzbfeFGb2hZWsDt/fmCo6d12yvI0wed/0Q udAWg/9etw9TIOEergZFaJ91hnCJ4odIJjOae1BAYoct5kE8YuWLCDggped/vs/9FWBvQpe4E/1Y Shp5MpqDb2QrctgzcDoFd+96Xw4QUNtTnctHmbpOK0RKd6E2YmmZo3u87jDsfKYWdCAewd7hjSHD v1yU8GDv9kO7wH7K9y8hX1+STHELjwkcdmgWo2JoBLv+psOGtMjI9qGEbmhFtfi+crcUX31Co0Zg NRr7F4I7T5HIIbgqOGhNKCbnOkqTNOYxCCw6fqSlOTqlv1QhfFxXVbH+G+02TrybDOP2Co+U5w== X-Report-Abuse-To: spam@spamfilter03.delta.nl X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, T_SPF_PERMERROR 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?1747943056304373468?= X-GMAIL-MSGID: =?utf-8?q?1747943056304373468?= From: Mike Looijmans The rx_8111 is quite similar to the rx_8030. This adds support for this chip to the ds1307 driver. Date/time and alarm registers are in the usual places. The nvmem is located at 0x40. Time stamping is not supported. Signed-off-by: Mike Looijmans --- drivers/rtc/rtc-ds1307.c | 129 ++++++++++++++++++++++++++++++++------- 1 file changed, 107 insertions(+), 22 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index d51565bcc189..f5f0f0d02fe0 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -46,6 +46,7 @@ enum ds_type { m41t11, mcp794xx, rx_8025, + rx_8111, rx_8130, last_ds_type /* always last */ /* rs5c372 too? different address... */ @@ -113,6 +114,14 @@ enum ds_type { # define RX8025_BIT_VDET 0x40 # define RX8025_BIT_XST 0x20 +#define RX8111_FLAG 0x1e +# define RX8111_FLAG_VLF BIT(1) +# define RX8111_FLAG_AF BIT(3) +#define RX8111_PWR_SWITCH_CTRL 0x32 +# define RX8111_PSC_SMP_INIEN BIT(6) +# define RX8111_PSC_SMP_CHGEN BIT(7) +#define RX8111_TIME_STAMP_BUF_CTRL 0x34 + #define RX8130_REG_ALARM_MIN 0x17 #define RX8130_REG_ALARM_HOUR 0x18 #define RX8130_REG_ALARM_WEEK_OR_DAY 0x19 @@ -205,6 +214,68 @@ struct chip_desc { static const struct chip_desc chips[last_ds_type]; +static int ds1307_check_voltage_lost(struct ds1307 *ds1307) +{ + int ret; + unsigned int reg; + unsigned int mask; + unsigned int regflag; + + switch (ds1307->type) { + case rx_8111: + reg = RX8111_FLAG; + mask = RX8111_FLAG_VLF; + break; + case rx_8130: + reg = RX8130_REG_FLAG; + mask = RX8130_REG_FLAG_VLF; + break; + default: + return 0; + } + + ret = regmap_read(ds1307->regmap, reg, ®flag); + if (ret) { + dev_err(ds1307->dev, "%s error %d\n", "read", ret); + return ret; + } + + if (regflag & mask) { + dev_warn_once(ds1307->dev, "oscillator failed, set time!\n"); + return -EINVAL; + } + + return 0; +} + +static int ds1307_clear_voltage_lost(struct ds1307 *ds1307) +{ + int ret; + unsigned int reg; + unsigned int mask; + + switch (ds1307->type) { + case rx_8111: + reg = RX8111_FLAG; + mask = (unsigned int)~RX8111_FLAG_VLF; + break; + case rx_8130: + reg = RX8130_REG_FLAG; + mask = (unsigned int)~RX8130_REG_FLAG_VLF; + break; + default: + return 0; + } + + ret = regmap_write(ds1307->regmap, reg, mask); + if (ret) { + dev_err(ds1307->dev, "%s error %d\n", "write", ret); + return ret; + } + + return 0; +} + static int ds1307_get_time(struct device *dev, struct rtc_time *t) { struct ds1307 *ds1307 = dev_get_drvdata(dev); @@ -212,19 +283,9 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t) const struct chip_desc *chip = &chips[ds1307->type]; u8 regs[7]; - if (ds1307->type == rx_8130) { - unsigned int regflag; - ret = regmap_read(ds1307->regmap, RX8130_REG_FLAG, ®flag); - if (ret) { - dev_err(dev, "%s error %d\n", "read", ret); - return ret; - } - - if (regflag & RX8130_REG_FLAG_VLF) { - dev_warn_once(dev, "oscillator failed, set time!\n"); - return -EINVAL; - } - } + ret = ds1307_check_voltage_lost(ds1307); + if (ret) + return ret; /* read the RTC date and time registers all at once */ ret = regmap_bulk_read(ds1307->regmap, chip->offset, regs, @@ -397,15 +458,9 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) return result; } - if (ds1307->type == rx_8130) { - /* clear Voltage Loss Flag as data is available now */ - result = regmap_write(ds1307->regmap, RX8130_REG_FLAG, - ~(u8)RX8130_REG_FLAG_VLF); - if (result) { - dev_err(dev, "%s error %d\n", "write", result); - return result; - } - } + result = ds1307_clear_voltage_lost(ds1307); + if (result) + return result; return 0; } @@ -541,6 +596,17 @@ static u8 do_trickle_setup_ds1339(struct ds1307 *ds1307, u32 ohms, bool diode) return setup; } +static u8 do_trickle_setup_rx8111(struct ds1307 *ds1307, u32 ohms, bool diode) +{ + /* make sure that the backup battery is enabled */ + u8 setup = RX8111_PSC_SMP_INIEN; + + if (diode) + setup |= RX8111_PSC_SMP_CHGEN; + + return setup; +} + static u8 do_trickle_setup_rx8130(struct ds1307 *ds1307, u32 ohms, bool diode) { /* make sure that the backup battery is enabled */ @@ -1012,6 +1078,16 @@ static const struct chip_desc chips[last_ds_type] = { .century_bit = DS1337_BIT_CENTURY, .bbsqi_bit = DS3231_BIT_BBSQW, }, + [rx_8111] = { + .alarm = 1, + .nvram_offset = 0x40, + .nvram_size = 0x40, /* 0x40 .. 0x7F is user RAM */ + .offset = 0x10, + .irq_handler = rx8130_irq, + .rtc_ops = &rx8130_rtc_ops, + .trickle_charger_reg = RX8111_PWR_SWITCH_CTRL, + .do_trickle_setup = &do_trickle_setup_rx8111, + }, [rx_8130] = { .alarm = 1, /* this is battery backed SRAM */ @@ -1063,6 +1139,7 @@ static const struct i2c_device_id ds1307_id[] = { { "pt7c4338", ds_1307 }, { "rx8025", rx_8025 }, { "isl12057", ds_1337 }, + { "rx8111", rx_8111 }, { "rx8130", rx_8130 }, { } }; @@ -1137,6 +1214,10 @@ static const struct of_device_id ds1307_of_match[] = { .compatible = "isil,isl12057", .data = (void *)ds_1337 }, + { + .compatible = "epson,rx8111", + .data = (void *)rx_8111 + }, { .compatible = "epson,rx8130", .data = (void *)rx_8130 @@ -1880,6 +1961,10 @@ static int ds1307_probe(struct i2c_client *client, DS1307_REG_HOUR << 4 | 0x08, hour); } break; + case rx_8111: + /* Use memory as user RAM */ + regmap_write(ds1307->regmap, RX8111_TIME_STAMP_BUF_CTRL, 0); + break; case ds_1388: err = regmap_read(ds1307->regmap, DS1388_REG_CONTROL, &tmp); if (err) {