From patchwork Wed Jul 3 16:48:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 11029953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2460C13B1 for ; Wed, 3 Jul 2019 16:51:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1193B286D1 for ; Wed, 3 Jul 2019 16:51:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0343A28992; Wed, 3 Jul 2019 16:51:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8720A286D1 for ; Wed, 3 Jul 2019 16:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0UFx1z9CEImaelA5TBJHA5yKx71p5JcGuQ6YZW4VvDI=; b=R8aQNBiTOMjjAGKh0k5vp8qZXl WcXr/1xAkq7RImJ5Mkhi6skky+rDhYAQdE69zdG4yL+onH7VIvXfsNGRYdZN7kD60da5teJ+v+vXe idsLzq61328DHdnlJyqNd3HQUW3YKpagyPfP+9G4jPf3BHyuDq+ejTh0mSB5f9Km6Ga8bPfdboTDV xii2LGT0NLpbhzvcI7hQTV32VE2VM0TFIt6GkAmqTGoFaLs/Zs7gs2LNfNYf5eqAMgU8iLr4/IlZ1 WMMHTjhNv6quw3ByyI8KhZlHbAOqTr14GPrI2scQF0M62TGYcH3lNTHoUJ06H2Eqfb3rgWPyknhgc H1se6sdw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hiiTj-0003uV-5j; Wed, 03 Jul 2019 16:51:31 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiiRo-0001CH-PW; Wed, 03 Jul 2019 16:49:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1562172514; bh=/9xBDfa8MmyCEGy9lts4eV0fUCDWP2vWjFBrUMAHZIw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=NJL6u9vCVUAcj0aiV9JL+ahQq/Z3X+rRu6afSaN6dMYm+Evbul46DCtz365/Naq2f RSTEGdTVeueXpiveIakMux/69G0mtdqLpPiDN3f+KIueDJAgt0jB0lZ8ej6mdwiwDD 9bB2mbSEgwKIQ4a0M/fu/pfntvqwrENfhrz9JTj4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([217.61.158.204]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M42jK-1hiiQr3zXc-0001fV; Wed, 03 Jul 2019 18:48:34 +0200 From: Frank Wunderlich To: Lee Jones , Rob Herring , Mark Rutland , Matthias Brugger , Sean Wang , Sebastian Reichel , Alessandro Zummo , Alexandre Belloni , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org, Eddie Huang , Thomas Gleixner , Richard Fontana , Allison Randal , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Rob Herring , Linus Walleij , Nicolas Ferre , "Paul E . McKenney" Subject: [PATCH v2 2/7] rtc: mt6397: move some common definitions into rtc.h Date: Wed, 3 Jul 2019 18:48:17 +0200 Message-Id: <20190703164822.17924-3-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703164822.17924-1-frank-w@public-files.de> References: <20190703164822.17924-1-frank-w@public-files.de> X-Provags-ID: V03:K1:eNTAGak/khtebF18hP1o00uJHTFlKw0xrt738upulxWk1z31acU PoB2U9jBsL3a67ozQdB+gG5Tq5CJQPDRj0dNh3mKEH1ReCjxe96SLWjYx9mEeCzDeIYs1eE BYo7WMGYd5CUSfhSLvOqR02xzohVYND0/oRHlhR7xCxaVLxuHJxze47sRzK2taMUN5K6QHZ IPFfX9BTpN8nR4lpP3t7A== X-UI-Out-Filterresults: notjunk:1;V03:K0:hrXaNRx2yJU=:n8xY8hWfUEOQNncyM2MDfb hgyC4lTVSopY06MROwkDrLATI7KOf4BREy8UbjkvevcUbP4bo5sS3X0ccBpwv+LSxbLvv2bT6 ttpL9s26RLDTYq8XPNI+DfEz7fk1JIYwyXVfjrahDo9t1gymXebc8+AL1yiURT7SSPQkPa6Om 8jweZxjKExbRyKfcakJOQvSXiI2DzhVePFsHbb0NpOEaLjVHCHnUvoghqrbAhc5TBDMYk507J 3aT6AJSgAJYTEbLRUCmEWBoyZ7bG5BCi1UBDegmje2IxGOOLPndIrZ2M1qioBdm2K5RU1v1Ta II8QrtGmItpLyoOIciLHCgn+6gZ0r7zBAM94DjgmIFZRPvOq2uxzUNJ0+JPlN65XF0wkSRbKm wStGGr9H6EF7GdUlejbBJ28BX0apwmU/ZlH0kR2nGczm4sp08ZQgEV7dv8d9N4kDu9J2+r6xv PZaqWYe32TkeI+lAoQqVhDKzr8i5lKPWTgFcn94Rnr3FaoiNE6VPHupq7vpXHGhef5CwwHVK9 j+uBjgyExZ1pBjLO6X9rx3KW5j1FiCE6GHSKtZt7wz5feqYEV8pd5ohXSqiBanx+hbVH7byQG ua39EHS9jirtv1JtXBFl1QW8JO5Ui4KxuMElsaYCeHwdV00Mt/D1wj0aXg6zocC+zwerw5uJ5 djRwYqlIyr91G7i1qRFAP2KDvPX42lK1LWpXXICoyT3onns0k302e1vFS+PxlDzC9VMn2kLci aASSswHtFmYPuFBbGQE417bNLH8vXTPQR+nlCzqING608uUxya3ZCRlZKY53FI2jjC6tI/oiD 0UGtZyTCaK5x5ftWGdUWavLNF8rB8RnJDxVTm3jyne4C7mNDJ+AyDIb1orvJw0Bbb8aZUopFo 2MTz+ca155ddzmrY6Tt9lOqy3xNc23yrzbBEt4ERl1lodvnfJgNTmhhi3dgD6XspcD9fZEpNA RHRxfcrtVMGMXiuVkzDwhND9BsB2vtj5EoX3YcG0k3vlg0iL66fApiWnXBIkKFyKWUr/pciph ayZcEgOAUcqfyrLmvtHT2OotSl4rfNSzdwjgu0Zs7bk+R6tPNt3kCSrSF2z9UmgHLM/l9r6p2 vYvFnzLNIXh0Nc= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190703_094933_124812_44ACFAEE X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Josef Friedl , Frank Wunderlich MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Friedl Suggested-by: Frank Wunderlich Signed-off-by: Josef Friedl Signed-off-by: Frank Wunderlich --- drivers/rtc/rtc-mt6397.c | 55 +------------------------- include/linux/mfd/mt6397/rtc.h | 71 ++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 54 deletions(-) create mode 100644 include/linux/mfd/mt6397/rtc.h -- 2.17.1 diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c index b46ed4dc7015..c08ee5edf865 100644 --- a/drivers/rtc/rtc-mt6397.c +++ b/drivers/rtc/rtc-mt6397.c @@ -9,60 +9,7 @@ #include #include #include -#include -#include -#include -#include -#include -#include - -#define RTC_BBPU 0x0000 -#define RTC_BBPU_CBUSY BIT(6) - -#define RTC_WRTGR 0x003c - -#define RTC_IRQ_STA 0x0002 -#define RTC_IRQ_STA_AL BIT(0) -#define RTC_IRQ_STA_LP BIT(3) - -#define RTC_IRQ_EN 0x0004 -#define RTC_IRQ_EN_AL BIT(0) -#define RTC_IRQ_EN_ONESHOT BIT(2) -#define RTC_IRQ_EN_LP BIT(3) -#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL) - -#define RTC_AL_MASK 0x0008 -#define RTC_AL_MASK_DOW BIT(4) - -#define RTC_TC_SEC 0x000a -/* Min, Hour, Dom... register offset to RTC_TC_SEC */ -#define RTC_OFFSET_SEC 0 -#define RTC_OFFSET_MIN 1 -#define RTC_OFFSET_HOUR 2 -#define RTC_OFFSET_DOM 3 -#define RTC_OFFSET_DOW 4 -#define RTC_OFFSET_MTH 5 -#define RTC_OFFSET_YEAR 6 -#define RTC_OFFSET_COUNT 7 - -#define RTC_AL_SEC 0x0018 - -#define RTC_PDN2 0x002e -#define RTC_PDN2_PWRON_ALARM BIT(4) - -#define RTC_MIN_YEAR 1968 -#define RTC_BASE_YEAR 1900 -#define RTC_NUM_YEARS 128 -#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) - -struct mt6397_rtc { - struct device *dev; - struct rtc_device *rtc_dev; - struct mutex lock; - struct regmap *regmap; - int irq; - u32 addr_base; -}; +#include static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) { diff --git a/include/linux/mfd/mt6397/rtc.h b/include/linux/mfd/mt6397/rtc.h new file mode 100644 index 000000000000..b702c29e8c74 --- /dev/null +++ b/include/linux/mfd/mt6397/rtc.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2014-2018 MediaTek Inc. + * + * Author: Tianping.Fang + * Sean Wang + */ + +#ifndef _LINUX_MFD_MT6397_RTC_H_ +#define _LINUX_MFD_MT6397_RTC_H_ + +#include +#include +#include +#include + +#define RTC_BBPU 0x0000 +#define RTC_BBPU_CBUSY BIT(6) +#define RTC_BBPU_KEY (0x43 << 8) + +#define RTC_WRTGR 0x003c + +#define RTC_IRQ_STA 0x0002 +#define RTC_IRQ_STA_AL BIT(0) +#define RTC_IRQ_STA_LP BIT(3) + +#define RTC_IRQ_EN 0x0004 +#define RTC_IRQ_EN_AL BIT(0) +#define RTC_IRQ_EN_ONESHOT BIT(2) +#define RTC_IRQ_EN_LP BIT(3) +#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL) + +#define RTC_AL_MASK 0x0008 +#define RTC_AL_MASK_DOW BIT(4) + +#define RTC_TC_SEC 0x000a +/* Min, Hour, Dom... register offset to RTC_TC_SEC */ +#define RTC_OFFSET_SEC 0 +#define RTC_OFFSET_MIN 1 +#define RTC_OFFSET_HOUR 2 +#define RTC_OFFSET_DOM 3 +#define RTC_OFFSET_DOW 4 +#define RTC_OFFSET_MTH 5 +#define RTC_OFFSET_YEAR 6 +#define RTC_OFFSET_COUNT 7 + +#define RTC_AL_SEC 0x0018 + +#define RTC_PDN2 0x002e +#define RTC_PDN2_PWRON_ALARM BIT(4) + +#define RTC_MIN_YEAR 1968 +#define RTC_BASE_YEAR 1900 +#define RTC_NUM_YEARS 128 +#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) + +#define MTK_RTC_POLL_DELAY_US 10 +#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) + +struct mt6397_rtc { + struct device *dev; + struct rtc_device *rtc_dev; + + /* Protect register access from multiple tasks */ + struct mutex lock; + struct regmap *regmap; + int irq; + u32 addr_base; +}; + +#endif /* _LINUX_MFD_MT6397_RTC_H_ */