From patchwork Tue Jul 2 09:40:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 11027505 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 AFD6613A4 for ; Tue, 2 Jul 2019 09:41:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9307D2886C for ; Tue, 2 Jul 2019 09:41:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 851A628872; Tue, 2 Jul 2019 09:41:14 +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=ham 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 C75AC2886C for ; Tue, 2 Jul 2019 09:41:13 +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=9GOR/0bstvH5ND2iUHFkdYyo+5DgIROH+D/kBaDhjhk=; b=fkYafr/ChNCTNp/jE2hlUGZf4E 7YFm7g8lO5t/mUJKj7GA+1KFSbEIZbIe/7VSIb/1YW/bwbdu/k6sqJtko9WLpb5kwnh7J2VmftiFR 3dvium2A+NgSb5sV7o4PjHp9r3bqLoIiaZdI4zlXbw4io0mCw06+0qn16lJi8Mi/kAkMcnQj2XC6U w7Ql7p/nTg4yslI7iFypfmPTpn5pN4VhWvWjNMmcIPOHme1PWYcZEQS+VhHAvvqd9tivKLJ7UxKUb ED9TH+G/oNBLeO1syYEePAyEe/lkp16zDK5qc5CLtCpQkFqD5umdjdngZaBQxFesq5iPixODPELSY YnQeXuYw==; 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 1hiFHf-0000BA-HF; Tue, 02 Jul 2019 09:41:07 +0000 Received: from mout.gmx.net ([212.227.17.22]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiFHc-00009r-BR; Tue, 02 Jul 2019 09:41:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1562060457; bh=oSqquuEE5yW/c8iRNBPSI0a5cJClK80fy7DvXrOLPr8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=dlagoiXf/RIMZkio48bbIEFFdFxC0w4tvy9u6hAXvstcAOzImbjRJrfBMLaJQQjE4 Me0c5R103Sxko8B/UHSsVYA+gNY5V7QLDnhnywvbhMXJDLET5oarLPP5RGoSjysDIy ogEmPVwoWfRZRDeT4GEToiRzNHubODIOQDqPP+GE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([217.61.147.59]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MvsJ5-1iZW9u3D2l-00srKO; Tue, 02 Jul 2019 11:40:57 +0200 From: Frank Wunderlich To: Rob Herring , Mark Rutland , Matthias Brugger , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] add doc and MAINTAINERS for poweroff Date: Tue, 2 Jul 2019 11:40:43 +0200 Message-Id: <20190702094045.3652-2-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702094045.3652-1-frank-w@public-files.de> References: <20190702094045.3652-1-frank-w@public-files.de> X-Provags-ID: V03:K1:2vYhi+xH+hblnqvwu7JCJIYk+RNMfwzyTaHzeLF4uHhL2sVf5es na0tRbfWtiREIfkOSzpQ4pqdw/gGlzeayu5qhOw5et1M80TXvGZEna7ax/vbyqEADYZrk3I uq5s3VavjDAOv/uOqGtFkUrtx0r/Q8gKMTmYUxv9K9J3TRsEKgn1CQZBZTgrNenoS6P+7Xz ds35ih+ygouOf+FACkwEA== X-UI-Out-Filterresults: notjunk:1;V03:K0:6WGGfsOJ0Z4=:mmz9GFuTPxrR8oTzHF4LQw CMbl9OPIDv0qksIZOiZ3eL7KkLsw9FVgxEgHwbk89ceEldUeH06u46zg3fiVAF38PVn2j9DUV vIdBOkIm1CThm4Gl/39wVNKqWPTaTw2Woi4GuQbmeI6ga19v1Es5xTUUUP6qN2a3KDByYvegb if08rfhlVr14vdTUvxqCaVwbkiiov1h96hBeQw0Q80Z0Vy+8S1Q5QWA2H+kOnWZpmqs+ooOam 9/iSqVmq4wVpe/FlNgFoD+eDUomNy/8MGvHV3DvWcKWgI8pQ3iZNcB9sQpxhODTfw7Qly65Xg eI6Vw1VYJQSYCtr9y3ZZwWgva02ifKkbqLytaaeIACYWJ7MOq6jj+qYMYdH7Esxa2pVCxbJLj mjfvECFG9CP88xWBhZ6A2SvMjejOVks0fgCfFUk4MOSx9CudyWOcJbfZyasz286pjiYoTgu0V D9K47G7F7njz2qdly9yhRWbE2i4DuPc4oVaOh6aCD9txp1RxCPbTd682aE5OH5+PzyomoSLNR pX7S/0L2Hg9EoBLAMuNywM86Z1tzXVTRP7hFAleAd7rHOcdSaUl9z6BM6Lkq1QEWenVLQwZZn DqrkDNAX5nGKGHaEPvdZnp+vi5O8BucZayu19nCpwaHvd5FY1aadKckFlK1APWb3vH5h+SMru ldLt9X0on9t26vJnMxB171/tIPcePmTBsgzC2dwL/sqeEQ35/f7oAh8waEftHyfJ5anHiHO5N YuudQBTHeo0tkG/Iat3DG/F1r6i80pdYXarq0InXE1KrEzqGAxryBT4jvaitvYfffOjxN1353 9rDx7vBwnfPzIIoZ1GX2udhbpHF1Yyvv1ZBu31K672l9GkooGgNnQ8eCvFNQ9hg1uHm30MnDK O7UGBkCEWqqUFGrll+eUD6se43oX0E7R1wXY/7U2qNqu2UH+QfKtXaDOmNlsi1c1LMrLCaQZ8 +0UtrAPpXPk91gM08YypkdQ6B/4SuW1MdeyhmNy0/9BuXiBDGTaDae9pZ3xdjO0xajX7mC3Dp 4Nm74/NMrlkUSfqbFgTQ8Q94USrHpaXyTxaS8LeJ5kzOSvgA3Igov4arEtSdYcGSLBOHQjB9D Z1gmS9XtOQIas8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190702_024104_726889_70992588 X-CRM114-Status: GOOD ( 13.31 ) X-BeenThere: linux-arm-kernel@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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Friedl poweroff for BPI-R2 Suggested-by: Frank Wunderlich Signed-off-by: Josef Friedl --- .../devicetree/bindings/mfd/mt6397.txt | 10 ++++++- .../bindings/power/reset/mt6323-poweroff.txt | 20 +++++++++++++ .../devicetree/bindings/rtc/rtc-mt6397.txt | 29 +++++++++++++++++++ MAINTAINERS | 6 ++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mt6397.txt -- 2.17.1 diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt index 0ebd08af777d..44acb9827716 100644 --- a/Documentation/devicetree/bindings/mfd/mt6397.txt +++ b/Documentation/devicetree/bindings/mfd/mt6397.txt @@ -8,6 +8,7 @@ MT6397/MT6323 is a multifunction device with the following sub modules: - Clock - LED - Keys +- Power controller It is interfaced to host controller using SPI interface by a proprietary hardware called PMIC wrapper or pwrap. MT6397/MT6323 MFD is a child device of pwrap. @@ -22,8 +23,10 @@ compatible: "mediatek,mt6397" or "mediatek,mt6323" Optional subnodes: - rtc - Required properties: + Required properties: Should be one of follows + - compatible: "mediatek,mt6323-rtc" - compatible: "mediatek,mt6397-rtc" + For details, see Documentation/devicetree/bindings/rtc/rtc-mt6397.txt - regulators Required properties: - compatible: "mediatek,mt6397-regulator" @@ -46,6 +49,11 @@ Optional subnodes: - compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys" see Documentation/devicetree/bindings/input/mtk-pmic-keys.txt +- power-controller + Required properties: + - compatible: "mediatek,mt6323-pwrc" + For details, see Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt + Example: pwrap: pwrap@1000f000 { compatible = "mediatek,mt8135-pwrap"; diff --git a/Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt b/Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt new file mode 100644 index 000000000000..933f0c48e887 --- /dev/null +++ b/Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt @@ -0,0 +1,20 @@ +Device Tree Bindings for Power Controller on MediaTek PMIC + +The power controller which could be found on PMIC is responsible for externally +powering off or on the remote MediaTek SoC through the circuit BBPU. + +Required properties: +- compatible: Should be one of follows + "mediatek,mt6323-pwrc": for MT6323 PMIC + +Example: + + pmic { + compatible = "mediatek,mt6323"; + + ... + + power-controller { + compatible = "mediatek,mt6323-pwrc"; + }; + } diff --git a/Documentation/devicetree/bindings/rtc/rtc-mt6397.txt b/Documentation/devicetree/bindings/rtc/rtc-mt6397.txt new file mode 100644 index 000000000000..ebd1cf80dcc8 --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/rtc-mt6397.txt @@ -0,0 +1,29 @@ +Device-Tree bindings for MediaTek PMIC based RTC + +MediaTek PMIC based RTC is an independent function of MediaTek PMIC that works +as a type of multi-function device (MFD). The RTC can be configured and set up +with PMIC wrapper bus which is a common resource shared with the other +functions found on the same PMIC. + +For MediaTek PMIC MFD bindings, see: +Documentation/devicetree/bindings/mfd/mt6397.txt + +For MediaTek PMIC wrapper bus bindings, see: +Documentation/devicetree/bindings/soc/mediatek/pwrap.txt + +Required properties: +- compatible: Should be one of follows + "mediatek,mt6323-rtc": for MT6323 PMIC + "mediatek,mt6397-rtc": for MT6397 PMIC + +Example: + + pmic { + compatible = "mediatek,mt6323"; + + ... + + rtc { + compatible = "mediatek,mt6323-rtc"; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 01a52fc964da..ec6ff342aa3c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9920,6 +9920,12 @@ S: Maintained F: drivers/net/dsa/mt7530.* F: net/dsa/tag_mtk.c +MEDIATEK BOARD LEVEL SHUTDOWN DRIVERS +M: Sean Wang +L: linux-pm@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt + MEDIATEK JPEG DRIVER M: Rick Chang M: Bin Liu From patchwork Tue Jul 2 09:40:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 11027513 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 6025513A4 for ; Tue, 2 Jul 2019 09:41:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 453EE2886C for ; Tue, 2 Jul 2019 09:41:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3935D28872; Tue, 2 Jul 2019 09:41:58 +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=ham 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 D34A42886C for ; Tue, 2 Jul 2019 09:41:57 +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=OCPpES5NUb3E8fUeHQUyxzmmTn9hB+4jEGBrGzmCKpk=; b=Kd5sLCB7KM0UShBvvl3PbOYDr3 KfSLJNJ0JVUNsTomITnYcvqn0KL1iTal42VfnDSkiB5qZeSHWJ2PLRXvHFFmA6DRuCy4mbcW6kfhe xmvNP4+rizNRYwOZLynEsn/AUtDNfnx0FPkVw4Bwb0HiIjEKaUMLglO70ioYOd807wx8jH1+pKQw9 usrzNP8afZudVAzaFVAFZ9mQNjMnpnpht2wuQFpgfkRL7/Vmj8PGxj6VlJUFuhe6hg13jGucjdtBM Qhmprz7QaAruvAiIBJLU8ZMgLzMWzN2arAAF8LjAB6jzwJfPc5HWK2JvQ8NrBF3JMaa9DHbVWttDb iSfBBUbw==; 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 1hiFIO-0000mj-6b; Tue, 02 Jul 2019 09:41:52 +0000 Received: from mout.gmx.net ([212.227.17.20]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiFHd-00009t-Ha; Tue, 02 Jul 2019 09:41:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1562060458; bh=f6kRXJnx0iuLcJu8Xdd4njzNEX/9pGEhKGohBWOOTnU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=BKziDrDKtqG4PEH5TiBq1a7WBSS4JlDEg6vQiLLnMIUnaZ9J0mQeMU6Rw7uhUxIs8 +RKQaEYusoYye9S4Att7DUo6Zi2N9IZkhI2TTtsAmzcNszbKAvLV6+hIyo7oSBsjK/ L5+ZkcmqyyCRtmcCSnXMTi3nsfzqzqGVYKUzh3WM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([217.61.147.59]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M59C8-1hjLDB4900-001Ae7; Tue, 02 Jul 2019 11:40:58 +0200 From: Frank Wunderlich To: Rob Herring , Mark Rutland , Matthias Brugger , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] add dts for poweroff Date: Tue, 2 Jul 2019 11:40:44 +0200 Message-Id: <20190702094045.3652-3-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702094045.3652-1-frank-w@public-files.de> References: <20190702094045.3652-1-frank-w@public-files.de> X-Provags-ID: V03:K1:WVevwR0Nk1xxgXKDn/OupV4Xtu2YX9P9Gipa9pWYtJFb5S1L5GP eTPpkrtcjoWfKZI8M/vF4fIgmhDM2w24Zw9wlsZG2v9Y8v3LjsoOMQYFcbvgCjhtZtHA7NA FnJYqeguCX52RPIWMyp+fbIvFdhn8zr8svro2mlzPPcetmUJLHAW/Z6s612a4q4e/6VgWcB i7+4xz9BCdG7KSuZTFoqA== X-UI-Out-Filterresults: notjunk:1;V03:K0:TYy+FGe1yz8=:OPybtfWj9RkoIpOblvgqL7 rF8ByWKvTBgGbudq2IcFeaOVIg2w4ykQ5XLBv/pzBIsFLvoklHAQ7QCNlAHN4jXtiB+DsL9Fj eSzYP0AoSLlzjP3z+3J3HPNe1tAfAq2HPIvcUEpIF4Am/7X5jK+fN3iCIZt4BzmzVFmPF8fPX 42xgy+i70X17keXI6NtFc1tUmR5ib82RQWg1GNF/Juu0hFVkgHeiBGMKdTtCe65Af1rPqFOVw 6OXz0CMS40fzqoIJKc9Lx4t/MHUaaPAexxUOj3z+3j+sryNI2FngQN4dvcncxY2Bdd5krS8jQ oGFfDmVV7oInaE8NvmPa3e6uZqqR4jaibfDErzEiahI54ChFmMuP+o0h5DbroH6XOLm1ymyiD nEapizIGIcSFhGUrWocjBzGrHVtpTCgbjXe1esw1AUhfM/DADVkJg7MVEpKTLyd8dh3XcO7VA Qq18xeiv2rgqEW++u0bcTuF94qngZmkgNLJjaaWSH3WxiEhFuLJFbdbuFXEGPCcWwwSWmATyK dcszWDE1cbdrf1fzortfrU1MryOmXt2A8OBk1occcvuwjNCH0AwwwnEjTrk9QyI8LOS1RUKiZ NOmvd4jSAD9tj/9MlflHj2TfNZ4v8byhgy8G3FiIdHbuZiJimK9q31xQzbx0ATEchRUf94oa+ 1lOWzu1lnS/hlhuhpnbQUuumQJ+nSD5/5yJD6gTUqFWjKKPjIRJZkCrxVkpPLuNEvtfI95Aii o5+Obw0Tx1Lsm6+PQtYc+4nP+xGrSk0ESv6nAli+dhOVcaXjvI4xOGCP+ujNbDECU6mpjPXui QU/L7qpCNfbuw96eN44o5+WuzIgpLL6JZNBv+9D+Iq8ySFB0uy8vebXxAGgY9Wfz04MnGKhzj /t+jXv9xk12B9ma0CmjIxdsw6cPpUqAeKqg94t+DVmqFkzS8sJfywn1bGmvazCSKgFkOjTbIX 6dphHmcoa0lB6X1RBQaps5v/KVRcOyJxxoZKIG+lrmMip2d4zX0j5g1J60VILwU4PsW1gIJSa lJzmGaipRmvN3j547B/OtUF6IxrAv7Tnnziw+LAYXbWpYoeb9/AXvs4BlXoTHkzi8V+7yYlli 3oz4zhKsW7FN9k= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190702_024105_870225_BC45C226 X-CRM114-Status: UNSURE ( 7.01 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Friedl poweroff for BPI-R2 Suggested-by: Frank Wunderlich Signed-off-by: Josef Friedl --- arch/arm/boot/dts/mt6323.dtsi | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.17.1 diff --git a/arch/arm/boot/dts/mt6323.dtsi b/arch/arm/boot/dts/mt6323.dtsi index ba397407c1dd..7fda40ab5fe8 100644 --- a/arch/arm/boot/dts/mt6323.dtsi +++ b/arch/arm/boot/dts/mt6323.dtsi @@ -238,5 +238,32 @@ regulator-enable-ramp-delay = <216>; }; }; + + mt6323keys: mt6323keys { + compatible = "mediatek,mt6323-keys"; + mediatek,long-press-mode = <1>; + power-off-time-sec = <0>; + + power { + linux,keycodes = <116>; + wakeup-source; + }; + + home { + linux,keycodes = <114>; + }; + }; + + codec: mt6397codec { + compatible = "mediatek,mt6397-codec"; + }; + + power-controller { + compatible = "mediatek,mt6323-pwrc"; + }; + + rtc { + compatible = "mediatek,mt6323-rtc"; + }; }; }; From patchwork Tue Jul 2 09:40:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 11027517 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 C42571510 for ; Tue, 2 Jul 2019 09:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A68392886C for ; Tue, 2 Jul 2019 09:42:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A4FF28872; Tue, 2 Jul 2019 09:42:21 +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=ham 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 A71E52886C for ; Tue, 2 Jul 2019 09:42:20 +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=djOBtr0M0cs4F+LVe1u+oJ/5BKYUp8xN4P8IwQRPiLw=; b=TU+jJB1Q29xujftHxinDaOi/NX 93haff5MLz6NOBJfJhzncKk3Z9jlHNtqoUQVM6B522s/zfCd8PxI1Uwramx7zPGEZLlSOWaVHvPFt tL3MX6SRbz8T/xqZa0XhMvPwzP3o+JE0G7a5oRbPSxBNcbOSEGHRdgxUYbqJ6QQckO9Q1pSfuLBCi DlE8qDFYqgNejEVOgL1DP8Y4D9+trZngv3Wknwi2Dlz1NxMlwTA3GI8cnIPMF8YF5rhUcogpWUZZl 5tUJB/f73fb4CsA4NOpYWu/gIhRcJS21gz9KFYsysAAYazYdT+6TpLoB/eXtNQXEMj3/XoShZQ3p/ sSlj09RQ==; 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 1hiFIh-00014k-TO; Tue, 02 Jul 2019 09:42:11 +0000 Received: from mout.gmx.net ([212.227.17.21]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiFHd-00009u-9g; Tue, 02 Jul 2019 09:41:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1562060458; bh=P78rL3Ld2zVHKNP51vJ5yxaFpjg+8kHYhm1mASieWfo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=cxtqcHWW8BKBfk5Ohh9Shxx0GsuKswn85+c2dXMLoN7+SgO/iMclX94FZ21BpEpPU PL5lm9zKNBrOHQpFk5GojDrUEHBwPsYUUa/P8wZsgO38vKbh30Ne4M+VTqWCHScHxM xM5VdpI4Pin4fg88UGsjq28wcQ4g1D9BRQ1weqVg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([217.61.147.59]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MdefJ-1iHJ3D0quX-00ZgaA; Tue, 02 Jul 2019 11:40:58 +0200 From: Frank Wunderlich To: Rob Herring , Mark Rutland , Matthias Brugger , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] add driver and MAINTAINERS for poweroff Date: Tue, 2 Jul 2019 11:40:45 +0200 Message-Id: <20190702094045.3652-4-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702094045.3652-1-frank-w@public-files.de> References: <20190702094045.3652-1-frank-w@public-files.de> X-Provags-ID: V03:K1:6FmA4arq4ZzpiAobLjMPQOA6UtycJ2Yp9uDqjSKL0F1XwQyhxZV o3Zj4Q4+na5rZtIAKS34Ir22r/3iV6tcpvT1Yte+gGd17xGVUxzysG8nQA37Dl1XrdsuVF2 vXmRR8wuUzpvqkRyCv7MYJIootWmgi4qdRlyPn9PttDfI9ygAkPzQfXD6dp+8i2/ZC5ULvF KhxzfZRd7Dazs/53UHjRQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:wsHrJiLhzcY=:43YkmyE05ntG7JmOQ7Y/Qk ND5H8cXwUfbAK5DK/eBjq3Qvj4zJYAomi1aE2ODxArk5cVyFNQ7e7R6BdubNZ0Qj4zHHcpBZD SeJuEKrWByU4u8qKQUqBHj8+QhkbxMh/A6WkESosw1WyRZOpLCdhjp/GTYdgja1XkfSEBRCD4 T53brgE4dWiRkkkNaZkXeUSmJ3JWmKTfiJENvfBP612SBHEzMD0wJGFXyxe2JFiX46lTI8Ui/ 2NSuc5eVuu8ZpOHOHJ0ly8tHpLBsWMPoTWrm3mbKOlFu9j/VJ26Ynd+VfVFNh3yb54X2qwjRI mpKl9YHeJ2OfmDNaBhRCV8/iah0Yt2z0Pn9pdlazvIR6pzXsE5J/V0i4Xx6EmOKHGb/Gl3mkd zDf6+2yO9fxTPumwIcTm0MBCWdtIvujEYrojPqMrOg/dxu7IYAJUKBnncDS9Zw5wgCaaEZySi kc3WEhO0Ff+K8jU7UObsIE1rqq+p+XaXGfzDE3mRCqDbO62KRM+rK6gD5/u+vBcxBySDLC6qm THS2L/b3NKBnBjAZ4oesT5cNyypTlWI7LuK63vFpZQG/NZeuY5m02F4sGBB3SQGCYVfdPUlqe tIrUr4yRlAgwYUEhHkwjQBjCYFbKN0BnrdRMMPE/14hbiFqZJBpMteP9OyJYRPeWyczGTHzvN eKHFw/2Mb2UWLR5GN3aK/JHVorxjK4GgkIVSkJ8+4MWE5Z8li9EKBt3axWKUtFuqHwPc4gd0r 4hmonUtn/A0+PwwD5PlS5LVzW3Fz9/LOndyYx6pxS5rlJKorpfXVYUECjeYuyPN3zoRXp2dLr lNbYxvWusi5IfubbULvtqWeJNo82Npl7fm6t/SNQuIKjlxY2HcUChyVncpWyl7GMEgt5DhEPn KDfWAxdOBeDjKT75fn+x+ewXIbv6XwJx8l9vlqZobQ/uSoW/XHtI+7Z0WVpbSWN257VTjkbn3 S5/dyX0xMZ5VW5sTMvMhZlihc0Mtgb2oxzG2/4Lu6Ch5HfzD0RoCnaeOprfDvy+qgyPf+j2sP l0ijEIUik1V/H0rWHRLc6cidd4xWQbXJf60+C6tU+eZUkMU6uSY74wwVlFmwOzjg12a1feLPS gldbKDCqBPqQBk= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190702_024105_633807_8E0482A9 X-CRM114-Status: GOOD ( 21.04 ) X-BeenThere: linux-arm-kernel@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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Friedl poweroff for BPI-R2 Suggested-by: Frank Wunderlich Signed-off-by: Josef Friedl --- MAINTAINERS | 1 + drivers/mfd/mt6397-core.c | 40 +++++++--- drivers/power/reset/Kconfig | 10 +++ drivers/power/reset/Makefile | 1 + drivers/power/reset/mt6323-poweroff.c | 97 +++++++++++++++++++++++ drivers/rtc/rtc-mt6397.c | 110 ++++++-------------------- include/linux/mfd/mt6397/core.h | 2 + include/linux/mfd/mt6397/rtc.h | 71 +++++++++++++++++ 8 files changed, 234 insertions(+), 98 deletions(-) create mode 100644 drivers/power/reset/mt6323-poweroff.c create mode 100644 include/linux/mfd/mt6397/rtc.h -- 2.17.1 diff --git a/MAINTAINERS b/MAINTAINERS index ec6ff342aa3c..31c1e882b7d2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9925,6 +9925,7 @@ M: Sean Wang L: linux-pm@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt +F: drivers/power/reset/mt6323-poweroff.c MEDIATEK JPEG DRIVER M: Rick Chang diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c index 337bcccdb914..a4abce00f156 100644 --- a/drivers/mfd/mt6397-core.c +++ b/drivers/mfd/mt6397-core.c @@ -1,10 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2014 MediaTek Inc. + * Copyright (c) 2014-2018 MediaTek Inc. * Author: Flora Fu, MediaTek */ #include +#include #include #include #include @@ -15,24 +16,27 @@ #include #include +#define MT6323_RTC_BASE 0x8000 +#define MT6323_RTC_SIZE 0x40 + #define MT6397_RTC_BASE 0xe000 #define MT6397_RTC_SIZE 0x3e +#define MT6323_PWRC_BASE 0x8000 +#define MT6323_PWRC_SIZE 0x40 + #define MT6323_CID_CODE 0x23 #define MT6391_CID_CODE 0x91 #define MT6397_CID_CODE 0x97 +static const struct resource mt6323_rtc_resources[] = { + DEFINE_RES_MEM(MT6323_RTC_BASE, MT6323_RTC_SIZE), + DEFINE_RES_IRQ(MT6323_IRQ_STATUS_RTC), +}; + static const struct resource mt6397_rtc_resources[] = { - { - .start = MT6397_RTC_BASE, - .end = MT6397_RTC_BASE + MT6397_RTC_SIZE, - .flags = IORESOURCE_MEM, - }, - { - .start = MT6397_IRQ_RTC, - .end = MT6397_IRQ_RTC, - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(MT6397_RTC_BASE, MT6397_RTC_SIZE), + DEFINE_RES_IRQ(MT6397_IRQ_RTC), }; static const struct resource mt6323_keys_resources[] = { @@ -45,8 +49,17 @@ static const struct resource mt6397_keys_resources[] = { DEFINE_RES_IRQ(MT6397_IRQ_HOMEKEY), }; +static const struct resource mt6323_pwrc_resources[] = { + DEFINE_RES_MEM(MT6323_PWRC_BASE, MT6323_PWRC_SIZE), +}; + static const struct mfd_cell mt6323_devs[] = { { + .name = "mt6323-rtc", + .num_resources = ARRAY_SIZE(mt6323_rtc_resources), + .resources = mt6323_rtc_resources, + .of_compatible = "mediatek,mt6323-rtc", + }, { .name = "mt6323-regulator", .of_compatible = "mediatek,mt6323-regulator" }, { @@ -57,6 +70,11 @@ static const struct mfd_cell mt6323_devs[] = { .num_resources = ARRAY_SIZE(mt6323_keys_resources), .resources = mt6323_keys_resources, .of_compatible = "mediatek,mt6323-keys" + }, { + .name = "mt6323-pwrc", + .num_resources = ARRAY_SIZE(mt6323_pwrc_resources), + .resources = mt6323_pwrc_resources, + .of_compatible = "mediatek,mt6323-pwrc" }, }; diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 980951dff834..492678e22088 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -140,6 +140,16 @@ config POWER_RESET_LTC2952 This driver supports an external powerdown trigger and board power down via the LTC2952. Bindings are made in the device tree. +config POWER_RESET_MT6323 + bool "MediaTek MT6323 power-off driver" + depends on MFD_MT6397 + help + The power-off driver is responsible for externally shutdown down + the power of a remote MediaTek SoC MT6323 is connected to through + controlling a tiny circuit BBPU inside MT6323 RTC. + + Say Y if you have a board where MT6323 could be found. + config POWER_RESET_QNAP bool "QNAP power-off driver" depends on OF_GPIO && PLAT_ORION diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index 0aebee954ac1..94eaceb01d66 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o +obj-$(CONFIG_POWER_RESET_MT6323) += mt6323-poweroff.o obj-$(CONFIG_POWER_RESET_QCOM_PON) += qcom-pon.o obj-$(CONFIG_POWER_RESET_OCELOT_RESET) += ocelot-reset.o obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o diff --git a/drivers/power/reset/mt6323-poweroff.c b/drivers/power/reset/mt6323-poweroff.c new file mode 100644 index 000000000000..1caf43d9e46d --- /dev/null +++ b/drivers/power/reset/mt6323-poweroff.c @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Power off through MediaTek PMIC + * + * Copyright (C) 2018 MediaTek Inc. + * + * Author: Sean Wang + * + */ + +#include +#include +#include +#include +#include +#include + +struct mt6323_pwrc { + struct device *dev; + struct regmap *regmap; + u32 base; +}; + +static struct mt6323_pwrc *mt_pwrc; + +static void mt6323_do_pwroff(void) +{ + struct mt6323_pwrc *pwrc = mt_pwrc; + unsigned int val; + int ret; + + regmap_write(pwrc->regmap, pwrc->base + RTC_BBPU, RTC_BBPU_KEY); + regmap_write(pwrc->regmap, pwrc->base + RTC_WRTGR, 1); + + ret = regmap_read_poll_timeout(pwrc->regmap, + pwrc->base + RTC_BBPU, val, + !(val & RTC_BBPU_CBUSY), + MTK_RTC_POLL_DELAY_US, + MTK_RTC_POLL_TIMEOUT); + if (ret) + dev_err(pwrc->dev, "failed to write BBPU: %d\n", ret); + + /* Wait some time until system down, otherwise, notice with a warn */ + mdelay(1000); + + WARN_ONCE(1, "Unable to power off system\n"); +} + +static int mt6323_pwrc_probe(struct platform_device *pdev) +{ + struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent); + struct mt6323_pwrc *pwrc; + struct resource *res; + + pwrc = devm_kzalloc(&pdev->dev, sizeof(*pwrc), GFP_KERNEL); + if (!pwrc) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + pwrc->base = res->start; + pwrc->regmap = mt6397_chip->regmap; + pwrc->dev = &pdev->dev; + mt_pwrc = pwrc; + + pm_power_off = &mt6323_do_pwroff; + + return 0; +} + +static int mt6323_pwrc_remove(struct platform_device *pdev) +{ + if (pm_power_off == &mt6323_do_pwroff) + pm_power_off = NULL; + + return 0; +} + +static const struct of_device_id mt6323_pwrc_dt_match[] = { + { .compatible = "mediatek,mt6323-pwrc" }, + {}, +}; +MODULE_DEVICE_TABLE(of, mt6323_pwrc_dt_match); + +static struct platform_driver mt6323_pwrc_driver = { + .probe = mt6323_pwrc_probe, + .remove = mt6323_pwrc_remove, + .driver = { + .name = "mt6323-pwrc", + .of_match_table = mt6323_pwrc_dt_match, + }, +}; + +module_platform_driver(mt6323_pwrc_driver); + +MODULE_DESCRIPTION("Poweroff driver for MT6323 PMIC"); +MODULE_AUTHOR("Sean Wang "); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c index b46ed4dc7015..e5ddf0d0b6f1 100644 --- a/drivers/rtc/rtc-mt6397.c +++ b/drivers/rtc/rtc-mt6397.c @@ -4,69 +4,19 @@ * Author: Tianping.Fang */ -#include -#include +#include +#include +#include #include +#include +#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 +#include static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) { - unsigned long timeout = jiffies + HZ; int ret; u32 data; @@ -74,19 +24,13 @@ static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) if (ret < 0) return ret; - while (1) { - ret = regmap_read(rtc->regmap, rtc->addr_base + RTC_BBPU, - &data); - if (ret < 0) - break; - if (!(data & RTC_BBPU_CBUSY)) - break; - if (time_after(jiffies, timeout)) { - ret = -ETIMEDOUT; - break; - } - cpu_relax(); - } + ret = regmap_read_poll_timeout(rtc->regmap, + rtc->addr_base + RTC_BBPU, data, + !(data & RTC_BBPU_CBUSY), + MTK_RTC_POLL_DELAY_US, + MTK_RTC_POLL_TIMEOUT); + if (ret < 0) + dev_err(rtc->dev, "failed to write WRTGE: %d\n", ret); return ret; } @@ -324,14 +268,11 @@ static int mtk_rtc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rtc); - rtc->rtc_dev = devm_rtc_allocate_device(rtc->dev); - if (IS_ERR(rtc->rtc_dev)) - return PTR_ERR(rtc->rtc_dev); + ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL, + mtk_rtc_irq_handler_thread, + IRQF_ONESHOT | IRQF_TRIGGER_HIGH, + "mt6397-rtc", rtc); - ret = request_threaded_irq(rtc->irq, NULL, - mtk_rtc_irq_handler_thread, - IRQF_ONESHOT | IRQF_TRIGGER_HIGH, - "mt6397-rtc", rtc); if (ret) { dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", rtc->irq, ret); @@ -340,6 +281,10 @@ static int mtk_rtc_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, 1); + rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(rtc->rtc_dev)) + return PTR_ERR(rtc->rtc_dev); + rtc->rtc_dev->ops = &mtk_rtc_ops; ret = rtc_register_device(rtc->rtc_dev); @@ -355,15 +300,6 @@ static int mtk_rtc_probe(struct platform_device *pdev) return ret; } -static int mtk_rtc_remove(struct platform_device *pdev) -{ - struct mt6397_rtc *rtc = platform_get_drvdata(pdev); - - free_irq(rtc->irq, rtc); - - return 0; -} - #ifdef CONFIG_PM_SLEEP static int mt6397_rtc_suspend(struct device *dev) { @@ -390,6 +326,7 @@ 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", }, { } }; @@ -402,7 +339,6 @@ static struct platform_driver mtk_rtc_driver = { .pm = &mt6397_pm_ops, }, .probe = mtk_rtc_probe, - .remove = mtk_rtc_remove, }; module_platform_driver(mtk_rtc_driver); diff --git a/include/linux/mfd/mt6397/core.h b/include/linux/mfd/mt6397/core.h index 25a95e72179b..652da61e3711 100644 --- a/include/linux/mfd/mt6397/core.h +++ b/include/linux/mfd/mt6397/core.h @@ -7,6 +7,8 @@ #ifndef __MFD_MT6397_CORE_H__ #define __MFD_MT6397_CORE_H__ +#include + enum mt6397_irq_numbers { MT6397_IRQ_SPKL_AB = 0, MT6397_IRQ_SPKR_AB, 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_ */