Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1153967ybh; Wed, 11 Mar 2020 18:49:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsIzdCeI9NlVEfM8FVFRvamabu76LEx61p8ShRa4hzb+9ZqpujqePbVoBOkglQcfgQ+3U+N X-Received: by 2002:aca:bfc2:: with SMTP id p185mr1070056oif.57.1583977751698; Wed, 11 Mar 2020 18:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583977751; cv=none; d=google.com; s=arc-20160816; b=lWGIBMHb6dHXf27L0yJ6XuBmbBsbv8KX200ObBAxKwmHE9vKNvPuKmjTX9UOKdk65M hDl4uMJZeKJXDQM7aUcr8P5+d6UuQ7a6bwHajg/yvPzuIrSzHENZO7NJdDVTE8g3Si4M iBfEi2YN/RoUgRV2+qnYxj6XZ3lUHEwof9XtyL4UUrbyJ7luzz6Dogm2uSR1lAnVGnpk Y06id4oIffW2CnO4/qYwo6ngGE4FA5+D9KkfPSoODRsOaNRsliV29FoeqXbMMnT8Nb6k US1inY2Y2yxQyia6yYZE2TGyUBtUEW1633p/cFkA5SjFIKdCJuTaqpaXH33bPh6k+j43 5pTQ== 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=PgMVUPr9CJB662kw0Etj9PzDmEhHdAooW8/c8EV2Xs4=; b=h7xWPsxGzIItVn0/vvD1YvP+PcM9zDNhWob0hxFfbgy8iL2EoWrecxsg4MvzLvgCD9 7aysII8F6g4YdpPcqEq35uohFy67Zud6jzwkM5G8WIKXzk0tHqwHb24HcBFbizykM/4Z qGPNKThmGohWGptuCZFY28EkO3cZ/K6KXfjBkiBTmMyIkH7mIA5jPSGR8NyhgsA1ddom c00sjXQX4Eai7olktHN9cF5Arrcdj4vlrFU46NrWT4N34XEG6itnG8n7Hak9p3RAHAoj SNoSDAF/UwRUHX6qVTnTNmP4HObFIEz9QCa1yPhZ4pa+jFEnDbxIkb6F1XLG73vXBD4k 9bqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JI0NdUuO; 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 p5si370814otf.152.2020.03.11.18.48.59; Wed, 11 Mar 2020 18:49:11 -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=JI0NdUuO; 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 S2387608AbgCLBrq (ORCPT + 99 others); Wed, 11 Mar 2020 21:47:46 -0400 Received: from mail-ua1-f65.google.com ([209.85.222.65]:33848 "EHLO mail-ua1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387501AbgCLBrp (ORCPT ); Wed, 11 Mar 2020 21:47:45 -0400 Received: by mail-ua1-f65.google.com with SMTP id g21so1525772uaj.1 for ; Wed, 11 Mar 2020 18:47:44 -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=PgMVUPr9CJB662kw0Etj9PzDmEhHdAooW8/c8EV2Xs4=; b=JI0NdUuOBJi8irQniAHDZus9gSxHFsPWYFnKXsiqwsOhKAbNzUqHq+VcEDM8T4TnEJ OGifAyneQ4sO654BJ/tCMwd7iiHnlmHuV7b42qkExDUAC0x85FWZUcqYT2EqaWfTVQ3c PY8jyoS8ygU8ctvk99m1zD0Sk/ux/dUV8qhvA= 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=PgMVUPr9CJB662kw0Etj9PzDmEhHdAooW8/c8EV2Xs4=; b=QQVEky0DjpjJYXcSqPmUOi8wegXvR8sdSO4y51/pUoS41WDjMP5IpyXjQospdlUCYX C33D68SF2+t/o6v2I2gN1EMFaK2uiylC8LPmCq79AF5kxgmiaBZJOZdXAI/A+V4V8gnk EyV9Tsytd4ijsqSDeqykKFEjua0x+IT2+LR3lynWwo+h9kX00TQsTXMqd5pPQn/oQ1iY B8jGMUa7z5KB+hhuIcA17GtZy/RpPhVf9h08IU6SXUcWJ+kQ+2duZThkyC4plJdAeWPw aHBnCOUuNM0+qqlzOyheJVNK3BaasDsMZT71xSCvplJ/WfNgNu7U/2/FQsSPhkmfijsR RKSg== X-Gm-Message-State: ANhLgQ1xNVGO31f99fu21w2XHXwSLIe01wRFlY710eDsT4y91y+hVQ0M P5yBBXursPgYzFJTpSd4eVIVqYdvit+6IdfAgnu5Lkftw4Y= X-Received: by 2002:a9f:32da:: with SMTP id f26mr3606235uac.40.1583977664301; Wed, 11 Mar 2020 18:47:44 -0700 (PDT) MIME-Version: 1.0 References: <1583918223-22506-1-git-send-email-hsin-hsiung.wang@mediatek.com> <1583918223-22506-5-git-send-email-hsin-hsiung.wang@mediatek.com> In-Reply-To: <1583918223-22506-5-git-send-email-hsin-hsiung.wang@mediatek.com> From: Nicolas Boichat Date: Thu, 12 Mar 2020 09:47:33 +0800 Message-ID: Subject: Re: [PATCH v10 4/5] rtc: mt6397: Add support for the MediaTek MT6358 RTC To: Hsin-Hsiung Wang Cc: Lee Jones , Rob Herring , Alexandre Belloni , Matthias Brugger , Mark Rutland , Sean Wang , Sebastian Reichel , Eddie Huang , Alessandro Zummo , Frank Wunderlich , Thomas Gleixner , Richard Fontana , Josef Friedl , 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 Wed, Mar 11, 2020 at 5:17 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 > --- > drivers/power/reset/mt6323-poweroff.c | 2 +- > drivers/rtc/rtc-mt6397.c | 32 ++++++++++++++++++++++++-------- > include/linux/mfd/mt6397/rtc.h | 9 ++++++++- > 3 files changed, 33 insertions(+), 10 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..7a5a9e2 100644 > --- a/drivers/rtc/rtc-mt6397.c > +++ b/drivers/rtc/rtc-mt6397.c > @@ -9,18 +9,38 @@ > #include > #include > #include > +#include > #include > #include > #include > #include > #include > > +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", > + .data = (void *)&mt6397_rtc_data, }, > + { .compatible = "mediatek,mt6358-rtc", > + .data = (void *)&mt6358_rtc_data, }, > + { .compatible = "mediatek,mt6397-rtc", > + .data = (void *)&mt6397_rtc_data, }, > + {} > +}; > +MODULE_DEVICE_TABLE(of, mt6397_rtc_of_match); > + > 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 +289,9 @@ static int mtk_rtc_probe(struct platform_device *pdev) > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > rtc->addr_base = res->start; > > + rtc->data = (struct mtk_rtc_data *) > + of_device_get_match_data(&pdev->dev); Sorry for not noticing earlier, the cast is not needed. (also, you cast a const pointer into a non-const, which doesn't matter anyway as rtc->data is const again, but still...). > + > rtc->irq = platform_get_irq(pdev, 0); > if (rtc->irq < 0) > return rtc->irq; > @@ -325,13 +348,6 @@ 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 of_device_id mt6397_rtc_of_match[] = { > - { .compatible = "mediatek,mt6323-rtc", }, > - { .compatible = "mediatek,mt6397-rtc", }, > - { } > -}; > -MODULE_DEVICE_TABLE(of, mt6397_rtc_of_match); > - Why are you moving the MODULE_DEVICE_TABLE to the top of the file? I think you can keep it here with the mt63xx_rtc_data structs? > static struct platform_driver mtk_rtc_driver = { > .driver = { > .name = "mt6397-rtc", > diff --git a/include/linux/mfd/mt6397/rtc.h b/include/linux/mfd/mt6397/rtc.h > index 7dfb63b..66534ed 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