From patchwork Mon Jul 29 17:41:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 11064267 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 3B027912 for ; Mon, 29 Jul 2019 17:43:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BB66262FF for ; Mon, 29 Jul 2019 17:43:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F1C728653; Mon, 29 Jul 2019 17:43:25 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89601262FF for ; Mon, 29 Jul 2019 17:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387853AbfG2RnK (ORCPT ); Mon, 29 Jul 2019 13:43:10 -0400 Received: from mout.gmx.net ([212.227.15.15]:56223 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387731AbfG2RnJ (ORCPT ); Mon, 29 Jul 2019 13:43:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1564422139; bh=qNdMiiXHqllRvqvxDwWTThTceo0oHJHWqFHI79Z6uC8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=GBIaAupzyNnDjehhzBxXQlAtnvmvRetwsmvNU6hZAYY37mWDMtTYVAmHC0bJTfPIU xQHRMiA/p7l9p08hMHzEKDQgl2EGfqI0Kip/Pt2EJ0E03fcSNHHBDTSqZcA/V6nr15 TtDtNS9mYBg2RhKtHSvcKbXREbz0X9+ryj3dy4WE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([185.76.97.79]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LcBBl-1iHH8I0Kgf-00jbCk; Mon, 29 Jul 2019 19:42:19 +0200 From: Frank Wunderlich To: Alessandro Zummo , Alexandre Belloni , Allison Randal , "David S. Miller" , devicetree@vger.kernel.org, Eddie Huang , Greg Kroah-Hartman , Jonathan Cameron , Kate Stewart , Lee Jones , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org, Mark Rutland , Matthias Brugger , Mauro Carvalho Chehab , Nicolas Ferre , Richard Fontana , Rob Herring , Sean Wang , Sebastian Reichel , Thomas Gleixner , "Tianping . Fang" Cc: Josef Friedl , Frank Wunderlich Subject: [PATCH v3 03/10] rtc: mt6397: move some common definitions into rtc.h Date: Mon, 29 Jul 2019 19:41:47 +0200 Message-Id: <20190729174154.4335-4-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190729174154.4335-1-frank-w@public-files.de> References: <20190729174154.4335-1-frank-w@public-files.de> X-Provags-ID: V03:K1:XMa6wxfWSzWhCnhua7hhr4idtdRPBvgDLLK/YtTTdVfl1qoX8wl nSZvPJN/Hz34E1qkJ9ecCx0LqvE2em5TN9ckoWjWC9xjhe1pjBdWJiMVGwdnEIHRER0u/lY FflhsGfQJMmG8GmYpmRAEJIQa05wM/HQeuz9/42jRd1sXYLGQcJagMbf6XB+mmC9JGV3tJj TPcqAONrKZLzGtATWXWuA== X-UI-Out-Filterresults: notjun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EXF /QzgXErVLx9/VY/IMrRPVZMpZyGI6+jL/yM8bJPZuK2dbMHU9G95dV/9oI/ZSuR2L3KggCcei YBVe5BDpqUP9dk= Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Friedl move code to separate header-file to reuse definitions later in poweroff-driver (drivers/power/reset/mt6323-poweroff.c) changes since v2: add missing commit-message 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_ */