Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2408780ybh; Mon, 5 Aug 2019 00:25:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTaMgmY6n6mXh5wCM+qChUYZc2N1gdgpGiaMKMvuWjUHx5cDxpVJNg2Hxsdmh85UhB8rVC X-Received: by 2002:a17:902:b698:: with SMTP id c24mr11767778pls.28.1564989901588; Mon, 05 Aug 2019 00:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564989901; cv=none; d=google.com; s=arc-20160816; b=yaipVzGBBPSE5LAIWC1CGzWXKql7y0C8Gwaw1gmTBgRY/brosS8lROkycxO1sfxY+z UJXvF8pQMbG2AnLDiTbiJaEcMe/btH1Oyx5qpKoAhZwmg3RzLMyHNrL1anNYEXFYlun2 s1HYZiMWOIR/InXELPhAmxcxMeY6w+kDz6HW6Yrm/vLU7XmcsxpYZ/2pqWyA+73tVwPU WYz+Rt+Jb/EW85IZkD4tORygVi6QYdoeuVcHf7t7Hrgl+sO3js2IiNhtrHt+aNKq4ouC e/MVkzThyHzehZioYZ+bLo5XrlrnuiKYjqPLgxjae6VzAn7uSHZG/8p0W3MZ21XXWHlY a0/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=xIOrP8Ews7qNY4sB47+Wxk2qOt/LjWrnRtvTOOrpTGo=; b=SM/+4VKRrUIUsonT76ZprlPA1GAYeyWAdTtzQmYvkqfT4pRe3bwPnBxH7L0FH3++zi AXVBdaZCifkBlu1ssi1eE2F4UPfZaPQvnrwQgIUTY2p7cyulYMnlxFAWyNj9QHuJanac bpEomO2ca4GY4gJtBK8JjYJatpo8cEiFMkjglP3fMc6btVWNzxydbC28LjYNCfhy4WB6 AKxwlxiR9R5LothGAyK+vl0uIRC/Bi3E0Lmd8LGwYMnXmK0EbUL3yVn0oCzOd4ksO7SL kuSiZ2JgVJP9WSj6+BT53E1j5Xz3iQ9kZNQadep09V+ine9N2d/X+EF7K2jIuMtqiQ9m PCOQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b20si43590486pgk.437.2019.08.05.00.24.45; Mon, 05 Aug 2019 00:25: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727474AbfHEHXq (ORCPT + 99 others); Mon, 5 Aug 2019 03:23:46 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:37391 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726394AbfHEHXq (ORCPT ); Mon, 5 Aug 2019 03:23:46 -0400 X-Originating-IP: 82.246.155.60 Received: from localhost (hy283-1-82-246-155-60.fbx.proxad.net [82.246.155.60]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 2239CC0004; Mon, 5 Aug 2019 07:23:40 +0000 (UTC) Date: Mon, 5 Aug 2019 09:23:38 +0200 From: Alexandre Belloni To: Hsin-Hsiung Wang Cc: Lee Jones , Rob Herring , Matthias Brugger , Mark Brown , Mark Rutland , Liam Girdwood , Eddie Huang , Sean Wang , Alessandro Zummo , Thomas Gleixner , Richard Fontana , Kate Stewart , Allison Randal , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, srv_heupstream@mediatek.com, Ran Bi Subject: Re: [PATCH v4 10/10] rtc: Add support for the MediaTek MT6358 RTC Message-ID: <20190805072338.GB3600@piout.net> References: <1564982518-32163-1-git-send-email-hsin-hsiung.wang@mediatek.com> <1564982518-32163-11-git-send-email-hsin-hsiung.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1564982518-32163-11-git-send-email-hsin-hsiung.wang@mediatek.com> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, The subject should be: "rtc: mt6397: Add support for the MediaTek MT6358 RTC" On 05/08/2019 13:21:58+0800, 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. > > Review-by: Yingjoe Chen > Signed-off-by: Ran Bi > --- > drivers/rtc/rtc-mt6397.c | 43 +++++++++++++++++++++++++++++++++++-------- > 1 file changed, 35 insertions(+), 8 deletions(-) > > diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c > index 828def7..e23c215 100644 > --- a/drivers/rtc/rtc-mt6397.c > +++ b/drivers/rtc/rtc-mt6397.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -19,7 +20,8 @@ > #define RTC_BBPU 0x0000 > #define RTC_BBPU_CBUSY BIT(6) > > -#define RTC_WRTGR 0x003c > +#define RTC_WRTGR_MT6358 0x3a > +#define RTC_WRTGR_MT6397 0x3c > > #define RTC_IRQ_STA 0x0002 > #define RTC_IRQ_STA_AL BIT(0) > @@ -63,6 +65,10 @@ > #define RTC_NUM_YEARS 128 > #define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) > > +struct mtk_rtc_compatible { I would name that struct mtk_rtc_data > + u32 wrtgr_addr; and this member should be wrtgr_offset or simply wrtgr. > +}; > + > struct mt6397_rtc { > struct device *dev; > struct rtc_device *rtc_dev; > @@ -70,7 +76,25 @@ struct mt6397_rtc { > struct regmap *regmap; > int irq; > u32 addr_base; > + const struct mtk_rtc_compatible *dev_comp; > +}; > + > +static const struct mtk_rtc_compatible mt6358_rtc_compat = { > + .wrtgr_addr = RTC_WRTGR_MT6358, > +}; > + > +static const struct mtk_rtc_compatible mt6397_rtc_compat = { > + .wrtgr_addr = RTC_WRTGR_MT6397, > +}; > + > +static const struct of_device_id mt6397_rtc_of_match[] = { > + { .compatible = "mediatek,mt6358-rtc", > + .data = (void *)&mt6358_rtc_compat, }, > + { .compatible = "mediatek,mt6397-rtc", > + .data = (void *)&mt6397_rtc_compat, }, > + {} > }; > +MODULE_DEVICE_TABLE(of, mt6397_rtc_of_match); > > static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) > { > @@ -78,7 +102,8 @@ 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->dev_comp->wrtgr_addr, 1); > if (ret < 0) > return ret; > > @@ -324,6 +349,7 @@ static int mtk_rtc_probe(struct platform_device *pdev) > struct resource *res; > struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent); > struct mt6397_rtc *rtc; > + const struct of_device_id *of_id; > int ret; > > rtc = devm_kzalloc(&pdev->dev, sizeof(struct mt6397_rtc), GFP_KERNEL); > @@ -333,6 +359,13 @@ static int mtk_rtc_probe(struct platform_device *pdev) > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > rtc->addr_base = res->start; > > + of_id = of_match_device(mt6397_rtc_of_match, &pdev->dev); > + if (!of_id) { > + dev_err(&pdev->dev, "Failed to probe of_node\n"); > + return -EINVAL; This will never happen because probe would not be called if there is no match. You could also use of_device_get_match_data to avoid having to move the of_device_id table. > + } > + rtc->dev_comp = of_id->data; > + > rtc->irq = platform_get_irq(pdev, 0); > if (rtc->irq < 0) > return rtc->irq; > @@ -408,12 +441,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,mt6397-rtc", }, > - { } > -}; > -MODULE_DEVICE_TABLE(of, mt6397_rtc_of_match); > - > static struct platform_driver mtk_rtc_driver = { > .driver = { > .name = "mt6397-rtc", > -- > 2.6.4 > -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com