From patchwork Fri Sep 17 06:46:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathew McBride X-Patchwork-Id: 514166 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1943958jao; Thu, 16 Sep 2021 23:46:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1m6vhc1B3XpxgWJTmNtfzXn/bZFiGj9F3dZgMIgoSdGxoORtueq0tbj9+xRdPMvUszwtk X-Received: by 2002:a05:6402:b23:: with SMTP id bo3mr10981600edb.145.1631861209472; Thu, 16 Sep 2021 23:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631861209; cv=none; d=google.com; s=arc-20160816; b=zeRdLhK5npP4LAeu7EBFySHuJHkykgoIurrmjtzFYofPSD1XsmVTS9L+6gON4g1LBR 8PbKgmWHsL1sOd5gyX0b4JvmL/Lg5lao6OyV/MeOLg0cWQ1SYv44JLyCcedpcHa91uEA CbYe3h6QauLtDfzgytGesZBnJDulbdfVOk4QCiTA7TdbtAVjTUtaidbJS/K+RzQW9sDY v+ywJEJAmsJ0Nx9woT3qKAivBtKbYmoMZWiUegZt6KqCzHY1pbkyG7ERtTD34rop4FkG BhxuqIBBUNQJHgAOjwfLQMvCCbrA3GWRtAIQvjd79V6G59UdhJLxTo/SgRB0iPVdqgRn depw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=PftpGZ1DIluCKzJ+A1TQr8FM3E85+uKOb93uJ99eiPM=; b=GY1Dul1TniJ796X4sz5B7SleBMl0RB+4OSvMcr1nAgAlDfqg1e+yneniOsHM45cEgW iQO/U3K/RuOY1jbKRicATj+lxI2jkUayo0B8peSA3f8ymdW4URFabDOHwFjCH7RzlRu6 +3iKm40ayds193dgp02wZ1iuaeVks5g8BjKwCFI1tLTQxh0qQS204OUW2Y4QQjgELLEL r7FN4JPPxogthRY1dk4VQWxQBO62h9VM1/bPC9vidE2VhXPx31tZN3BkzHLWafciAPt3 KPxS3PlGVSTKgkIi5AaJToUjDpKZjxrNTSbnjD3Cj5F8AqtM3NnlTkwspIDFt3ZtFfdd 2e2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@traverse.com.au header.s=fm1 header.b="C3sBY/Qi"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=bUrW26vv; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id kq18si7232753ejb.533.2021.09.16.23.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 23:46:49 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@traverse.com.au header.s=fm1 header.b="C3sBY/Qi"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=bUrW26vv; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C50DF831D8; Fri, 17 Sep 2021 08:46:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=traverse.com.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=traverse.com.au header.i=@traverse.com.au header.b="C3sBY/Qi"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="bUrW26vv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB08682F34; Fri, 17 Sep 2021 08:46:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: 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_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 04C13831AC for ; Fri, 17 Sep 2021 08:46:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=traverse.com.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=matt@traverse.com.au Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id CB2FB5C0113; Fri, 17 Sep 2021 02:46:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 17 Sep 2021 02:46:21 -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=PftpGZ1DIluCK zJ+A1TQr8FM3E85+uKOb93uJ99eiPM=; b=C3sBY/Qi2UyiKXTp9r/9lOpl6q4H1 wApU+WgIShowkMMcW+z+tsikckR9ckGyzwuJLLpf99XWEd+3NuvoZjerTmpGZTG6 u6+zIvHuT6uS4Yms1FtA+LDNrucxGwhe0oXphen+mhA/7f4nxSDA3nMXtA5v08iv pq2Pszb457hEXYq778MsL3q0mXDERlRUpqjwOyrf50ezidO0e+SskwGU5rlTqF0f 6vEEysjKRppNBcTMXy6hwBuRwMxWz2hAQLkWiFr3HGyvmddXKvVtJghfll7Ws31k 5rbzMLHroQNf7J010VrJtSdH5yBW0L1ZBhEe9rQEyvaryVqjONxKKgBSw== 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=PftpGZ1DIluCKzJ+A1TQr8FM3E85+uKOb93uJ99eiPM=; b=bUrW26vv dC+9CHiAlsLp3b0kBR5m4epVIYiZpfBBohVcspLGcqf7q/Fwau782T7A7x9o+5yj CCLNvBt9imc1j7g9LTQ0OhOxxd+MfpCNWvJ79u9DokRr12EKrvWPa7eKVr6jIlTv xCaErrZtIQ9gyeniRQmm4ZC8SGbNakX1jukLIcx22tMDW0lhUyZfpMS2lX9x2nmP FgTdc/EpXZGEIVcfkdnk10Rtzm2YfDX3PZMEHGSNqPQM6Gw6OIjs2U23YV/BCNbe tQxQ2+YeJYCKoKT/QezRXkRJdsbRDv0NDKm/xJ6anVVQqqtzP6wr+/PQFvwFKu8N dNixaOE6OsRY5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehhedguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeforghthhgvficuofgtuehrihguvgcuoehmrghtthesthhr rghvvghrshgvrdgtohhmrdgruheqnecuggftrfgrthhtvghrnhephedukeegvefhfeeuie dugeejlefgiedtveevkeektefgieetteetffelveevtdelnecuffhomhgrihhnpehkvghr nhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehmrghtthesthhrrghvvghrshgvrdgtohhmrdgruh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 17 Sep 2021 02:46:20 -0400 (EDT) From: Mathew McBride To: u-boot@lists.denx.de Cc: Mathew McBride Subject: [PATCH 2/4] rtc: rx8025: add support for EPSON RX8035. Date: Fri, 17 Sep 2021 06:46:02 +0000 Message-Id: <20210917064604.3912-3-matt@traverse.com.au> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210917064604.3912-1-matt@traverse.com.au> References: <20210917064604.3912-1-matt@traverse.com.au> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean The RX8035 is a newer model from EPSON which is very similar in operation to the RX8025. The changes mirror similar ones that will be in Linux 5.15: https://lore.kernel.org/all/20210709044518.28769-2-matt@traverse.com.au/ The UBOOT_DRIVER ID has also been corrected, previously it declared itself as rx8010sj_rtc which is a different driver. Signed-off-by: Mathew McBride --- drivers/rtc/rx8025.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) -- 2.30.1 diff --git a/drivers/rtc/rx8025.c b/drivers/rtc/rx8025.c index 36e5b0122c..09bf365f63 100644 --- a/drivers/rtc/rx8025.c +++ b/drivers/rtc/rx8025.c @@ -24,6 +24,11 @@ #endif /*---------------------------------------------------------------------*/ +enum rx_model { + model_rx_8025, + model_rx_8035, +}; + /* * RTC register addresses */ @@ -64,6 +69,20 @@ static int rtc_write(struct udevice *dev, uchar reg, uchar val); +static int rx8025_is_osc_stopped(enum rx_model model, int ctrl2) +{ + int xstp = ctrl2 & RTC_CTL2_BIT_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; +} + /* * Get the current time from the RTC */ @@ -101,8 +120,7 @@ static int rx8025_rtc_get(struct udevice *dev, struct rtc_time *tmp) printf("RTC: voltage drop detected\n"); rel = -1; } - - if (!(ctl2 & RTC_CTL2_BIT_XST)) { + if (rx8025_is_osc_stopped(dev->driver_data, ctl2)) { printf("RTC: oscillator stop detected\n"); rel = -1; } @@ -180,7 +198,11 @@ static int rx8025_rtc_reset(struct udevice *dev) ctl2 = rtc_read(RTC_CTL2_REG_ADDR); ctl2 &= ~(RTC_CTL2_BIT_PON | RTC_CTL2_BIT_VDET); - ctl2 |= RTC_CTL2_BIT_XST | RTC_CTL2_BIT_VDSL; + + if (dev->driver_data == model_rx_8035) + ctl2 &= ~(RTC_CTL2_BIT_XST); + else + ctl2 |= RTC_CTL2_BIT_XST; return rtc_write(dev, RTC_CTL2_REG_ADDR, ctl2); } @@ -223,11 +245,12 @@ static const struct rtc_ops rx8025_rtc_ops = { }; static const struct udevice_id rx8025_rtc_ids[] = { - { .compatible = "epson,rx8025" }, + { .compatible = "epson,rx8025", .data = model_rx_8025 }, + { .compatible = "epson,rx8035", .data = model_rx_8035 }, { } }; -U_BOOT_DRIVER(rx8010sj_rtc) = { +U_BOOT_DRIVER(rx8025_rtc) = { .name = "rx8025_rtc", .id = UCLASS_RTC, .probe = rx8025_probe,