From patchwork Thu Jun 22 14:57:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 111722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5139995vqr; Thu, 22 Jun 2023 08:10:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7PlbTEGWZnnTJqKaPt/0h34A3/vb2/iPnW1WNqKS/lAntUaBYVhADjGbsjMXcpFiVMj3k5 X-Received: by 2002:a92:d30e:0:b0:335:56cb:a3a with SMTP id x14-20020a92d30e000000b0033556cb0a3amr14404299ila.16.1687446623125; Thu, 22 Jun 2023 08:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687446623; cv=none; d=google.com; s=arc-20160816; b=Z0rPniwgYPwPrMHe7fY7tGMA4EN8xMtMZ+tv1OshxTnJCU4Pn3TEUobpyrIz42+szN fFvDTtH2TAl6g5aC0nsOU87ESc/mX2KM4GxbB5h55skh/3pPl5YGeeWsLd9nLzS9Tjms g5Zxv1QuoEdToNRY3a662RjKC1RJuH+UDssK6AIfRjAq+rnGB7P1bxzlp9/zyYCmoUsC loCNJ5uuDvJGdz8vjSVCK7Fk7jm8KLKJhNbg5uHymR0FVfCVdhkhcReUboENk3Xgo00Z rElG+8IKwb2LjD9BoeLE9dnDgzPiszvEvStHUPiifTb/+P+Tk/vlAU4XQR3Qj5uo1glO EvjA== 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=SGY6nyxedz/MrsHxRZq44oAULx7Vv+IDnNYFC8bOlqQ=; b=wFxUStQLKYdBaXADA/0uA9KGkq7a1qKS+P5eLUrpGUWYuvT3ggjEn34Dpr2EmwoJMg piSQN5sSXxnofwXbh3O4cMKXHTfOTG9dicve1GsDuV7ssRFp/A1BhOcniHHyyG+E87Zl BekPvOPYaTNKzvcFKu+7bEaxegh1dTgn5DznpWD+ebMbnV5DA5W5897Zhyhr5sVm8736 qAZutY/lRBGEM34RgelL1gzrz0s3eTlrITvRKpRgqccXHq4yDS+Q3gsm3ERXZG/sEugk jUcAPQ8GDeBBpfIw1ke3ogg4BH09nAiqy0AJUnqu5Wdb7GI5C3lTnedk1mSejgTzU7c+ 4xfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=TwHjE4Ea; 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 185-20020a6301c2000000b0054f71faf5aasi1867207pgb.581.2023.06.22.08.10.09; Thu, 22 Jun 2023 08:10:23 -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; dkim=fail header.i=@hugovil.com header.s=x header.b=TwHjE4Ea; 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 S231297AbjFVO6m (ORCPT + 99 others); Thu, 22 Jun 2023 10:58:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232071AbjFVO6S (ORCPT ); Thu, 22 Jun 2023 10:58:18 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8F3B1FC0; Thu, 22 Jun 2023 07:58:14 -0700 (PDT) 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=SGY6nyxedz/MrsHxRZq44oAULx7Vv+IDnNYFC8bOlqQ=; b=TwHjE4EaZXO5RtVoBQ7OvDxC25 4yHQ3kmsTsRwfaQmsX8XnjGGr+1VU6KODcj2zshTvle/lczB7bf0kiiypGTQ8UnRUbgepVyNSTGVg alRyNmnVSeWeyvePexrtMJE+HMVUGc6mhNf8aMgMNlMIzMF2WNeUjhDYpEOGCkR4rvrc=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:55382 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qCLlD-0002fr-PS; Thu, 22 Jun 2023 10:58:12 -0400 From: Hugo Villeneuve To: a.zummo@towertech.it, alexandre.belloni@bootlin.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hugo@hugovil.com, Hugo Villeneuve Date: Thu, 22 Jun 2023 10:57:50 -0400 Message-Id: <20230622145800.2442116-8-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230622145800.2442116-1-hugo@hugovil.com> References: <20230622145800.2442116-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 184.161.19.61 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v4 07/17] rtc: pcf2127: adapt for alarm 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?1769416030095945583?= X-GMAIL-MSGID: =?utf-8?q?1769416030095945583?= From: Hugo Villeneuve This will simplify the implementation of new variants into this driver. Signed-off-by: Hugo Villeneuve --- drivers/rtc/rtc-pcf2127.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c index 0b9110b936f0..31f6bba81212 100644 --- a/drivers/rtc/rtc-pcf2127.c +++ b/drivers/rtc/rtc-pcf2127.c @@ -47,11 +47,7 @@ #define PCF2127_REG_TIME_BASE 0x03 #define PCF2127_BIT_SC_OSF BIT(7) /* Alarm registers */ -#define PCF2127_REG_ALARM_SC 0x0A -#define PCF2127_REG_ALARM_MN 0x0B -#define PCF2127_REG_ALARM_HR 0x0C -#define PCF2127_REG_ALARM_DM 0x0D -#define PCF2127_REG_ALARM_DW 0x0E +#define PCF2127_REG_ALARM_BASE 0x0A #define PCF2127_BIT_ALARM_AE BIT(7) /* CLKOUT control register */ #define PCF2127_REG_CLKOUT 0x0f @@ -102,6 +98,7 @@ struct pcf21xx_config { unsigned int has_nvmem:1; unsigned int has_bit_wd_ctl_cd0:1; u8 reg_time_base; /* Time/date base register. */ + u8 regs_alarm_base; /* Alarm function base registers. */ }; struct pcf2127 { @@ -381,8 +378,8 @@ static int pcf2127_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) if (ret) return ret; - ret = regmap_bulk_read(pcf2127->regmap, PCF2127_REG_ALARM_SC, buf, - sizeof(buf)); + ret = regmap_bulk_read(pcf2127->regmap, pcf2127->cfg->regs_alarm_base, + buf, sizeof(buf)); if (ret) return ret; @@ -432,8 +429,8 @@ static int pcf2127_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) buf[3] = bin2bcd(alrm->time.tm_mday); buf[4] = PCF2127_BIT_ALARM_AE; /* Do not match on week day */ - ret = regmap_bulk_write(pcf2127->regmap, PCF2127_REG_ALARM_SC, buf, - sizeof(buf)); + ret = regmap_bulk_write(pcf2127->regmap, pcf2127->cfg->regs_alarm_base, + buf, sizeof(buf)); if (ret) return ret; @@ -629,6 +626,7 @@ static struct pcf21xx_config pcf21xx_cfg[] = { .has_nvmem = 1, .has_bit_wd_ctl_cd0 = 1, .reg_time_base = PCF2127_REG_TIME_BASE, + .regs_alarm_base = PCF2127_REG_ALARM_BASE, }, [PCF2129] = { .type = PCF2129, @@ -636,6 +634,7 @@ static struct pcf21xx_config pcf21xx_cfg[] = { .has_nvmem = 0, .has_bit_wd_ctl_cd0 = 0, .reg_time_base = PCF2127_REG_TIME_BASE, + .regs_alarm_base = PCF2127_REG_ALARM_BASE, }, };