Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3231111ybb; Tue, 31 Mar 2020 00:40:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu3yrVKHVu4rRdT/mtgmaR13a6/IfmTGfR96v8V1b/zESFFcHpVxifvHFZuayzXSBf2IrG2 X-Received: by 2002:a05:6830:1348:: with SMTP id r8mr11558466otq.57.1585640401489; Tue, 31 Mar 2020 00:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585640401; cv=none; d=google.com; s=arc-20160816; b=ybo34AkcmZmwjTHUlktyXwPp7zz5BXsdL6OCgHlUzuyzLZ/i1151XcixfmwqJNX3lC 92yWLlu1f3OJEEoJ+Pc5BghSZDLN9iVnh3whE4OYqAz5suD3UP65w3PC2SZY07ImVQGo dVxZ95FWE38Xx86NMOZSNHfDkwbNMhkD7vLRDxsf++diTZIFY+aeMjFMfk5d6WZwY3S6 r1XrLGC841LYQ0dKgJBydCaiZ82KoPWRCfpxfRtjKeHQn0ywynVHo0nXnEqSrcXhvysj j4f3g5+jXVW03Yvag6NmeYiHMsu4tFmRGa6baGPEQlzsRdlPbzsq3fEORbcxfBAa9Wds sMAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Mf4BvDmC+BGalJU9mD8gdNB8rFbbjrC+WqY4Crh0V9U=; b=yvPFAeLinXSs8gKImJ8tEVvaa4vKK1/CgL3TAj3o0xuj9oGo1icNZD9HMV9f0QacSn AdWQZgnqqsPW3IHuCPOHwggLUV4WCl2i9AJVrKQP7pDEPssSawuVorEGsXPugr7G4xpA h9AVjidU+YPeao/L9kG6rbN3Ew2pUnN3w/b7YfHrHN37uP5ofq6EMO9W+lOs09GK4Omz nOScRTUNm9/mb3WY8K4uZSR2q2/pMvrc6OtaxOmQO7jQ7XKsbEm7kZGxRMEAJVGhU33q 25hQA6yud5daYYuwUdGgn4cG7oaNj/QPt2PzyB+n9V54tprcq97I1ZuOkHfFcwWUE6/s i9eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Dmi4tPnj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si5248058otp.126.2020.03.31.00.39.49; Tue, 31 Mar 2020 00:40:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Dmi4tPnj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730031AbgCaHjI (ORCPT + 99 others); Tue, 31 Mar 2020 03:39:08 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:38674 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbgCaHjI (ORCPT ); Tue, 31 Mar 2020 03:39:08 -0400 Received: by mail-vs1-f68.google.com with SMTP id x206so12872768vsx.5 for ; Tue, 31 Mar 2020 00:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mf4BvDmC+BGalJU9mD8gdNB8rFbbjrC+WqY4Crh0V9U=; b=Dmi4tPnjWtoexjKLMIWqLDO5lCj3eQdHzUN071JAVkhCTGW2dViDrf3zad75bGYIPc d0tqnzqL8Bj8qwzVlVzHOjntDEyZw9VhRwUYwJur//Tfk8ueGnJdlsdF2P4u2IE6rzEw 5vzDSI7EvnvF1qwMf1GqeACswRLGjCYk2lItk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mf4BvDmC+BGalJU9mD8gdNB8rFbbjrC+WqY4Crh0V9U=; b=Nv+ToQaEZDZkL26QX7ojO6iMx9WDSt2U/kNu2mzUY9W/pVx60iNf53qjOXdpVWQbIf vkOkyko917vMnZCtrE0zu+c2hlkBTdtt9znJBXRAfGM3cgsET0zw2ULITb6FPes4B6SO AFbvF2pTRgzTlhkSCMfNzDP9vnjkTl+AvEg16ntruL/NJvHzHYw3mW7thtAFp9dM7tm+ iWRjWCTvbTPoBGTW4mKjCa/62jIAbP32g+vXm35uQ2JfU3sICFv+y8j0T5wA35gFuDjc 50dZC8f0exSQ37NB7jyBtXlFPCbot8U96APFasxPMBKuVH7VG5K5PnKgfuCuMekueZmR HgXw== X-Gm-Message-State: AGi0PuY1yxHH7QgpXjX5o/lSeQSVMLa+PwhSOEdN26NAsGTcpwR7jCO4 EiHdlNPze56+ejFexM9O5LWvARORQJVOznF/hzG6ig== X-Received: by 2002:a67:d45:: with SMTP id 66mr10355355vsn.1.1585640346189; Tue, 31 Mar 2020 00:39:06 -0700 (PDT) MIME-Version: 1.0 References: <1585627657-3265-1-git-send-email-hsin-hsiung.wang@mediatek.com> <1585627657-3265-5-git-send-email-hsin-hsiung.wang@mediatek.com> In-Reply-To: <1585627657-3265-5-git-send-email-hsin-hsiung.wang@mediatek.com> From: Nicolas Boichat Date: Tue, 31 Mar 2020 15:38:55 +0800 Message-ID: Subject: Re: [PATCH v11 4/5] rtc: mt6397: Add support for the MediaTek MT6358 RTC To: Hsin-Hsiung Wang Cc: Lee Jones , Rob Herring , Matthias Brugger , Alexandre Belloni , Mark Rutland , Sean Wang , Sebastian Reichel , Eddie Huang , Alessandro Zummo , Kate Stewart , Richard Fontana , Frank Wunderlich , Josef Friedl , Thomas Gleixner , Ran Bi , Devicetree List , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , lkml , "open list:THERMAL" , linux-rtc@vger.kernel.org, srv_heupstream Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 31, 2020 at 12:07 PM Hsin-Hsiung Wang wrote: > > From: Ran Bi > > This add support for the MediaTek MT6358 RTC. Driver using > compatible data to store different RTC_WRTGR address offset. > This replace RTC_WRTGR to RTC_WRTGR_MT6323 in mt6323-poweroff > driver which only needed by armv7 CPU without ATF. > > Signed-off-by: Ran Bi > Signed-off-by: Hsin-Hsiung Wang This looks good to me now, thanks. Reviewed-by: Nicolas Boichat > --- > drivers/power/reset/mt6323-poweroff.c | 2 +- > drivers/rtc/rtc-mt6397.c | 23 +++++++++++++++++++---- > include/linux/mfd/mt6397/rtc.h | 9 ++++++++- > 3 files changed, 28 insertions(+), 6 deletions(-) > > diff --git a/drivers/power/reset/mt6323-poweroff.c b/drivers/power/reset/mt6323-poweroff.c > index 1caf43d..0532803 100644 > --- a/drivers/power/reset/mt6323-poweroff.c > +++ b/drivers/power/reset/mt6323-poweroff.c > @@ -30,7 +30,7 @@ static void mt6323_do_pwroff(void) > int ret; > > regmap_write(pwrc->regmap, pwrc->base + RTC_BBPU, RTC_BBPU_KEY); > - regmap_write(pwrc->regmap, pwrc->base + RTC_WRTGR, 1); > + regmap_write(pwrc->regmap, pwrc->base + RTC_WRTGR_MT6323, 1); > > ret = regmap_read_poll_timeout(pwrc->regmap, > pwrc->base + RTC_BBPU, val, > diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c > index cda238d..7f3dfd2 100644 > --- a/drivers/rtc/rtc-mt6397.c > +++ b/drivers/rtc/rtc-mt6397.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -20,7 +21,7 @@ static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) > int ret; > u32 data; > > - ret = regmap_write(rtc->regmap, rtc->addr_base + RTC_WRTGR, 1); > + ret = regmap_write(rtc->regmap, rtc->addr_base + rtc->data->wrtgr, 1); > if (ret < 0) > return ret; > > @@ -269,6 +270,8 @@ static int mtk_rtc_probe(struct platform_device *pdev) > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > rtc->addr_base = res->start; > > + rtc->data = of_device_get_match_data(&pdev->dev); > + > rtc->irq = platform_get_irq(pdev, 0); > if (rtc->irq < 0) > return rtc->irq; > @@ -325,10 +328,22 @@ static int mt6397_rtc_resume(struct device *dev) > static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_rtc_suspend, > mt6397_rtc_resume); > > +static const struct mtk_rtc_data mt6358_rtc_data = { > + .wrtgr = RTC_WRTGR_MT6358, > +}; > + > +static const struct mtk_rtc_data mt6397_rtc_data = { > + .wrtgr = RTC_WRTGR_MT6397, > +}; > + > static const struct of_device_id mt6397_rtc_of_match[] = { > - { .compatible = "mediatek,mt6323-rtc", }, > - { .compatible = "mediatek,mt6397-rtc", }, > - { } > + { .compatible = "mediatek,mt6323-rtc", > + .data = &mt6397_rtc_data, }, > + { .compatible = "mediatek,mt6358-rtc", > + .data = &mt6358_rtc_data, }, > + { .compatible = "mediatek,mt6397-rtc", > + .data = &mt6397_rtc_data, }, > + {} > }; > MODULE_DEVICE_TABLE(of, mt6397_rtc_of_match); > > diff --git a/include/linux/mfd/mt6397/rtc.h b/include/linux/mfd/mt6397/rtc.h > index 7dfb63b..6200f3b 100644 > --- a/include/linux/mfd/mt6397/rtc.h > +++ b/include/linux/mfd/mt6397/rtc.h > @@ -18,7 +18,9 @@ > #define RTC_BBPU_CBUSY BIT(6) > #define RTC_BBPU_KEY (0x43 << 8) > > -#define RTC_WRTGR 0x003c > +#define RTC_WRTGR_MT6358 0x3a > +#define RTC_WRTGR_MT6397 0x3c > +#define RTC_WRTGR_MT6323 RTC_WRTGR_MT6397 > > #define RTC_IRQ_STA 0x0002 > #define RTC_IRQ_STA_AL BIT(0) > @@ -65,6 +67,10 @@ > #define MTK_RTC_POLL_DELAY_US 10 > #define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) > > +struct mtk_rtc_data { > + u32 wrtgr; > +}; > + > struct mt6397_rtc { > struct device *dev; > struct rtc_device *rtc_dev; > @@ -74,6 +80,7 @@ struct mt6397_rtc { > struct regmap *regmap; > int irq; > u32 addr_base; > + const struct mtk_rtc_data *data; > }; > > #endif /* _LINUX_MFD_MT6397_RTC_H_ */ > -- > 2.6.4