Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2304759ybh; Sun, 4 Aug 2019 22:25:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjSmOi/1onbC2POOoe+kozU3V4Zuc45oJOXXBjnO5nSzv9cmM39MygizGcleIjJRbFqlTj X-Received: by 2002:a17:902:b68f:: with SMTP id c15mr144011333pls.104.1564982731692; Sun, 04 Aug 2019 22:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564982731; cv=none; d=google.com; s=arc-20160816; b=l5HWmmDgBA2FjepIm5rn/XGZSiABJI/ia0xxio2vGl+cE1HFH0QIzkyVvC5NqlnS67 C79/JObVI0IWlXyvP0Mnh5M4dirES4sG+SuaK8cDb7qyiDdKps+hnMOwlQ8mE6oE+ydZ woMDyTodAQ1lSRn1rMjg2/7E1mZTtikUMjKBltpoQx4FixjB4NLJ6LJE9ogTLXjZQqGw Y1uqF9gIa0aws4wgmuSEf45qZJCnECPWVVeG46CKqKcQ1vl9flYdLRRWl621uMPf+a48 yLn8nS5XLe2mCLKM7jPN1WG/IU9adQ/JxgxhZ8eytnR0BJeqg3KMldDqrvd3HUbog3Do sqOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ozva5PQeALIXUq/xOScdVlgCUgh62VZlYVpM7gMMVYU=; b=SRXOarzr7l6IcuD/THIcT3lEfne4tRt9uIh2FSqwzbeoP9g/8whNdNRtndU8Z6nMvL eQJ8F2IegkWccBzwdLaAgRX4FsNGdKZrxte8HlI/leqxQ13gSch8FDJvlLeb1bSkmo/b lZN3ASxFcxW9+pGtv4e0PoEypjuM4W6TmL25vx1EnbCkEX5EZnMD4ZCPK9Juh5KG1xy5 3uCG/yXNnR4dLVXObLH/bquvO2P3hyf+zJyhO6tm2BaLh9i5KOakaBXyxoDGs7OKaoss aFlfMOc6xmtMZ3N+6nYL8PdhOpr0eoocZd2ccFchA/OMantWny1aiPdNmF8AQPI1ouMA nhCw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fr6si11569989pjb.97.2019.08.04.22.25.16; Sun, 04 Aug 2019 22:25:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727473AbfHEFXS (ORCPT + 99 others); Mon, 5 Aug 2019 01:23:18 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:20050 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727222AbfHEFWv (ORCPT ); Mon, 5 Aug 2019 01:22:51 -0400 X-UUID: bdbccfe973e34113a132421d215dd87c-20190805 X-UUID: bdbccfe973e34113a132421d215dd87c-20190805 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 1095245785; Mon, 05 Aug 2019 13:22:43 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 5 Aug 2019 13:22:43 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 5 Aug 2019 13:22:43 +0800 From: Hsin-Hsiung Wang To: Lee Jones , Rob Herring , Matthias Brugger , Mark Brown CC: Mark Rutland , Liam Girdwood , Eddie Huang , Sean Wang , Alessandro Zummo , Alexandre Belloni , Hsin-Hsiung Wang , Thomas Gleixner , Richard Fontana , Kate Stewart , Allison Randal , , , , , , , Ran Bi Subject: [PATCH v4 10/10] rtc: Add support for the MediaTek MT6358 RTC Date: Mon, 5 Aug 2019 13:21:58 +0800 Message-ID: <1564982518-32163-11-git-send-email-hsin-hsiung.wang@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1564982518-32163-1-git-send-email-hsin-hsiung.wang@mediatek.com> References: <1564982518-32163-1-git-send-email-hsin-hsiung.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 { + u32 wrtgr_addr; +}; + 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; + } + 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