From patchwork Thu Dec 15 15:02:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 33682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp421702wrn; Thu, 15 Dec 2022 07:20:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf78haVdZ++fGAXA3LJKfJGdHszWFoyPCqjlciBbplojTneOVWjvad4Z/2lzXxcmQHQIMsAi X-Received: by 2002:a17:902:ca14:b0:189:bbd3:a5a7 with SMTP id w20-20020a170902ca1400b00189bbd3a5a7mr24030001pld.51.1671117629592; Thu, 15 Dec 2022 07:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671117629; cv=none; d=google.com; s=arc-20160816; b=qvKtlPIcBCxzBYlrOniR6rTzeBH1i0QfbY0dWu+q1C8ieKvBtXAubzW+0LraiUnSrp +dotk8gFt+3oGX0gICytWGbeeLspVZ/0dumylb8Pp8lfXSg8E48NC4sOCxMuwsHfl/z1 ZHvsf3SM0daRW1DPS1CK8HE8TWZFN4qW9JCa8Z4LaY9O1iUwz6guFXVAUzNEONQ5jMzs f8j6+xe37TVTHvrSDDwY7dbekmjO4p0Y7t8A7KQ8Ok/9uXmR70yIqMp6GA57l8e1RRay 8mug+nAUyxhGQXd5TmIbD2I4fIUz2Tm/eflclGPhtqKb33wlCaT0Ija1Puwj+Ja2lnVA R4jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=8Q7ceOCImgW1+k459ANYj+kIkkp23Qja0+B2W043r04=; b=I7G5nQBjwGocFvO0D5jwktAmLU3Sw445S0IcFlzwgqN1/6jUVsIbTCpisUlqJ+r8St IpFbGMDAoYgZxDqMo+4XV3jplabgLkPffuxud8ayxpz1+hpCgtfhCX/EG9ezxx4pqoUY yx03f+J+gAo4IcbtwD7OJB+7EGjLk6ZLGlrT/aqAWPWT4V15NUBMBNLjN8a5Oj8EZt05 M45F2LNKJbbws+K9VN3kWry9H24Qxig9E3h09hLbkMv7vPasRp5Lgq2z4fULW1fXAiZH 4EmJmIEmFrxLCh4T+8Z/N5EqXD1GhF5BbhS6ZeqjFQ4naEYwD82AINlIoTwiUSdpDeJZ JnUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=ecaDfEzJ; 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 d15-20020a170902cecf00b00189cf69e4cesi6222741plg.525.2022.12.15.07.20.16; Thu, 15 Dec 2022 07:20:29 -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=fail header.i=@hugovil.com header.s=x header.b=ecaDfEzJ; 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 S230150AbiLOPSt (ORCPT + 99 others); Thu, 15 Dec 2022 10:18:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbiLOPST (ORCPT ); Thu, 15 Dec 2022 10:18:19 -0500 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22154DD3; Thu, 15 Dec 2022 07:18:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8Q7ceOCImgW1+k459ANYj+kIkkp23Qja0+B2W043r04=; b=ecaDfEzJgkzaKfq9Kg+aEDBzUC 7mdnunTIzfUga4HHAt25A11reGD8Lq4t/lSD+Zy0PB13spxF6QlhBSJykLuw4y3BG86XLQHkIqkJO MMpAjoOq/zlfEV0QMW4oZ+NIs9/Y4CVXW7+xozMV/3HExeCsWwABy0AMB3lsGnnL6E80=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:48102 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1p5pmC-0000EC-1I; Thu, 15 Dec 2022 10:04:00 -0500 From: Hugo Villeneuve To: a.zummo@towertech.it, alexandre.belloni@bootlin.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org Cc: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hugo@hugovil.com, Hugo Villeneuve Date: Thu, 15 Dec 2022 10:02:05 -0500 Message-Id: <20221215150214.1109074-5-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221215150214.1109074-1-hugo@hugovil.com> References: <20221215150214.1109074-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v3 04/14] rtc: pcf2127: adapt for WD registers at any offset X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) 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?1752293839479807963?= X-GMAIL-MSGID: =?utf-8?q?1752293839479807963?= From: Hugo Villeneuve This will simplify the implementation of new variants into this driver. Signed-off-by: Hugo Villeneuve Reviewed-by: Bruno Thomsen Tested-by: Bruno Thomsen --- drivers/rtc/rtc-pcf2127.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c index db0cb784c0c9..5d8c06e32dce 100644 --- a/drivers/rtc/rtc-pcf2127.c +++ b/drivers/rtc/rtc-pcf2127.c @@ -114,6 +114,8 @@ struct pcf21xx_config { unsigned int has_bit_wd_ctl_cd0:1; u8 regs_td_base; /* Time/data base registers. */ u8 regs_alarm_base; /* Alarm function base registers. */ + u8 reg_wd_ctl; /* Watchdog control register. */ + u8 reg_wd_val; /* Watchdog value register. */ }; struct pcf2127 { @@ -297,7 +299,7 @@ static int pcf2127_wdt_ping(struct watchdog_device *wdd) { struct pcf2127 *pcf2127 = watchdog_get_drvdata(wdd); - return regmap_write(pcf2127->regmap, PCF2127_REG_WD_VAL, wdd->timeout); + return regmap_write(pcf2127->regmap, pcf2127->cfg->reg_wd_val, wdd->timeout); } /* @@ -331,7 +333,7 @@ static int pcf2127_wdt_stop(struct watchdog_device *wdd) { struct pcf2127 *pcf2127 = watchdog_get_drvdata(wdd); - return regmap_write(pcf2127->regmap, PCF2127_REG_WD_VAL, + return regmap_write(pcf2127->regmap, pcf2127->cfg->reg_wd_val, PCF2127_WD_VAL_STOP); } @@ -380,7 +382,7 @@ static int pcf2127_watchdog_init(struct device *dev, struct pcf2127 *pcf2127) watchdog_set_drvdata(&pcf2127->wdd, pcf2127); /* Test if watchdog timer is started by bootloader */ - ret = regmap_read(pcf2127->regmap, PCF2127_REG_WD_VAL, &wdd_timeout); + ret = regmap_read(pcf2127->regmap, pcf2127->cfg->reg_wd_val, &wdd_timeout); if (ret) return ret; @@ -664,6 +666,8 @@ static struct pcf21xx_config pcf21xx_cfg[] = { .has_bit_wd_ctl_cd0 = 1, .regs_td_base = PCF2127_REG_TIME_DATE_BASE, .regs_alarm_base = PCF2127_REG_ALARM_BASE, + .reg_wd_ctl = PCF2127_REG_WD_CTL, + .reg_wd_val = PCF2127_REG_WD_VAL, }, [PCF2129] = { .max_register = 0x19, @@ -671,6 +675,8 @@ static struct pcf21xx_config pcf21xx_cfg[] = { .has_bit_wd_ctl_cd0 = 0, .regs_td_base = PCF2127_REG_TIME_DATE_BASE, .regs_alarm_base = PCF2127_REG_ALARM_BASE, + .reg_wd_ctl = PCF2127_REG_WD_CTL, + .reg_wd_val = PCF2127_REG_WD_VAL, }, }; @@ -772,7 +778,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap, * as T. Bits labeled as T must always be written with * logic 0. */ - ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL, + ret = regmap_update_bits(pcf2127->regmap, pcf2127->cfg->reg_wd_ctl, PCF2127_BIT_WD_CTL_CD1 | PCF2127_BIT_WD_CTL_CD0 | PCF2127_BIT_WD_CTL_TF1 |