From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29887C10DCE for ; Mon, 9 Mar 2020 02:33:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EEF67206D5 for ; Mon, 9 Mar 2020 02:33:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gFJ/uvmc"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="STFwxFTn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEF67206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7KWSbfLx1fhXLGe6WkzHmxPqcFbgL9n49+syy//lVRQ=; b=gFJ/uvmcuzvbGA T3okFuJSG9vPsYrDr+0v8FzZTgzHV87Octj004mKDWIO4BVbUAXo94sT/Gy05uOtFGAkBt0vyc+38 UnqYTYJ4bz5ClheIMMOzLgnlJ0vpDVkrLu3UetD1Y4sZ5tVsBVhMUrAfEnOhN6ae2h1mhHJfkgCY+ qImJUAiTOfRQH7C/0/1XmZZDrZzYqqtfxz25keqFoJ0Kjbp9QIz3kGqcDXL6vgp1MeYXGe1WWXIYs gYiuiFArFCU0B1wNQYyGquEwEHOUUlqmf3PXIYPRj/8y6qc8JE4DxzXfomr7P9pa8bIMKsi1l04Vg jDDoYDYJLJaYzuaOw7Nw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jB8Ef-00060d-9R; Mon, 09 Mar 2020 02:33:41 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jB8Eb-0005zE-GL; Mon, 09 Mar 2020 02:33:39 +0000 X-UUID: 70422fe94b564a2298d9b4563711b189-20200308 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=dVRMX7HzacB89Rfs5D6p0q4PZANziX89+dXutatF4V0=; b=STFwxFTnAkpf4VQdSYH4HmwkhTAq+Mez0yThP3MFHKgA25ufdUfper2JH0TcH7uX+7Ij2wpjxUFsWDSmlbLdGxtKz+aXXDiKMHS/tiCxYYyscvnUqKpV4cmpQknOu95qTPiatDY2/j/E5wxjVLlfQquYk5O4KKCxqrwL6mNn+Fo=; X-UUID: 70422fe94b564a2298d9b4563711b189-20200308 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 1449962774; Sun, 08 Mar 2020 18:33:32 -0800 Received: from mtkmbs05n2.mediatek.inc (172.21.101.140) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 8 Mar 2020 19:33:29 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 9 Mar 2020 10:32:26 +0800 Received: from [172.21.77.4] (172.21.77.4) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 9 Mar 2020 10:30:47 +0800 Message-ID: <1583721209.28755.29.camel@mtksdaap41> Subject: Re: [PATCH v8 4/5] rtc: mt6397: Add support for the MediaTek MT6358 RTC From: Yingjoe Chen To: Ran Bi Date: Mon, 9 Mar 2020 10:33:29 +0800 In-Reply-To: <1583393876.8521.15.camel@mhfsdcap03> References: <1580730044-30501-1-git-send-email-hsin-hsiung.wang@mediatek.com> <1580730044-30501-5-git-send-email-hsin-hsiung.wang@mediatek.com> <1580748607.31376.3.camel@mtksdaap41> <1581911502.20099.13.camel@mhfsdcap03> <1583393876.8521.15.camel@mhfsdcap03> X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200308_193337_556644_5EA20D52 X-CRM114-Status: GOOD ( 28.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: Mark Rutland , Alexandre Belloni , Richard Fontana , Lee Jones , Hsin-Hsiung Wang , linux-rtc@vger.kernel.org, Nicolas Boichat , Sebastian Reichel , Devicetree List , Frank Wunderlich , Sean Wang , Rob Herring , "moderated list:ARM/Mediatek SoC support" , Matthias Brugger , Thomas Gleixner , Eddie Huang , linux-arm Mailing List , Alessandro Zummo , Josef Friedl , srv_heupstream , Greg Kroah-Hartman , lkml Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 2020-03-05 at 15:37 +0800, Ran Bi wrote: > Hi, > > On Wed, 2020-03-04 at 20:59 +0800, Nicolas Boichat wrote: > > Hi, > > > > On Mon, Feb 17, 2020 at 11:52 AM Ran Bi wrote: > > > > > > On Tue, 2020-02-04 at 00:50 +0800, Yingjoe Chen wrote: <....> > > > > > > > > Putting these in header file doesn't looks right to me. > > > > Who need this? can you move them back to rtc-mt6397.c? > > > > Joe.C > > > > > > > > > > This could also effect kernel/drivers/power/reset/mt6323-poweroff.c > > > which using same region of RTC registers. > > > There are 2 ways of modification: > > > 1. kernel/drivers/rtc/rtc-mt6397.c implement do_pwroff function and > > > export to mt6323-poweroff.c > > > 2. Just modify mt6323-poweroff.c file to compatible this patch. I mean > > > using RTC_WRTGR_MT6397 to replace RTC_WRTGR. Or modify mt6323-poweroff.c > > > like rtc-mt6397.c > > > > Oh, I see, so basically both rtc-mt6397.c and mt6323-poweroff.c need > > to know at what offset RTC_WRTGR actually is. Correct? > > > > Yes, you are right both drivers need to know RTC_WRTGR offset. Offsets > of other registers are the same. > > > Is there any plan to have mt6323-poweroff.c support any of the other > > PMICs (not just MT6323?)? > > > > Currently, we don't have a plan to let mt6323-poweroff.c support other > PMICs. Because other PMICs like mt6397 and mt6358 could using > arm-trust-firmware PSCI power off flow instead. mt6323-poweroff.c was > prepared for platform without arm-trust-firmware. This depends on SoC instead of PMIC. We will need mt6323-poweroff.c for soc with armv7 CPU, because we won't have ATF on them. I'm not aware of new plan for this. > > a. If not, I'd just add: > > #define RTC_WRTGR_MT6323 RTC_WRTGR_MT6397 > > in rtc.h, for added clarity, use that in mt6323-poweroff.c > > (s/RTC_WRTGR/RTC_WRTGR_MT6323/), and be done with it. > > > > I would just change RTC_WRTGR to RTC_WRTGR_MT6397 in mt6323-poweroff.c > at next patchset. > > > Actually, even if there's a plan, you can go ahead with this simpler > > solution for now, and fix later when the issue comes up. > > > > b. If you ever want to support multiple PMICs with mt6323-poweroff.c, > > you'd need that offset for 2 different sub-devices under the same mfd, > > so the matching logic belongs in the main mfd device, not in > > rtc/poweroff driver. > > > > So I'd move the matching logic in drivers/mfd/mt6397-core.c, and add > > rtc_wrtgr offset (or a full _data structure) to `struct mt6397_chip`, > > or, probably better, add a IORESOURCE_REG to the matching resources to > > specify the offset (that's what drivers/mfd/88pm860x-core.c seems to > > be doing, for example). > > > > And then mt6323-poweroff.c should probably be renamed to mt6397-poweroff.c. > > > > (actually, looking at this, I'm even questioning if mt6323-poweroff.c > > should even exist, and if you should just fold it into rtc-mt6397.c? > > Since they use the same registers?) > > > > mt6323-poweroff.c which hijack pm_power_off pointer is only for platform > without arm-trust-firmware. This is the reason I am considering > mt6323-poweroff.c should not be folded into rtc-mt6397.c. Using/sharing same set of registers from different drivers is not good: - WRTGR is a special register to 'commit' previous changes. If 2 drivers are running at the same time, it is possible to commit incomplete update and cause unexpected result. It is easier to control this from same driver. - It is easy to overlook the register is access by others and lead to bugs/build fails when doing driver update, eg, this patchset. - The trigger code is duplicate in mt6323-poweroff.c, can just call mtk_rtc_write_trigger. So I agree with Nicolas, mt6323-poweroff should be folded into rtc-mt6397.c. We should be able to disable pm_power_off hijacking for platform with armV8 CPU. Maybe we can keep "mediatek,mt6323-pwrc" compatible in mt6323-poweroff.c for this. I'm ok with implement a. as suggested by Nicolas for now. Joe.C _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel