Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4484669ybf; Wed, 4 Mar 2020 05:00:48 -0800 (PST) X-Google-Smtp-Source: ADFU+vsnDkALLTqIvZ2jKnUK38hPp12H4AcQuXKW+7HXFbKGqETTMMhQIn/H4Pd6G2Y/nlKkfp8y X-Received: by 2002:aca:7283:: with SMTP id p125mr1680517oic.1.1583326848240; Wed, 04 Mar 2020 05:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583326848; cv=none; d=google.com; s=arc-20160816; b=UOdbF6JUficREtXh3nSrCsSpW7DS23iJ52RacAin9TZC1vqj3E52vBlPPhS91/1sPp r+V4EFpqcm2MjSig9Ngz44vPuEhbOwFX3n4l9DXFu6LKHQjpW8DvdiDIzKNGDcZsPdvk ieHLdRjHUOU23HlwiIzCksdNNCgf4ZBa3wCycAcRtxfSRTra5OfMBjG9b0jrKpcpfAMq 3G2gfAg4rDR/1Rdv/DjLhFn60LzJkbIDYwdUVBJgD8HL5dhctYrDJCMSexjHuY2A+jbV uH5nnu0nrvgXq73LGDGcTLj2v3KaHUd6A8N8PTSEFjPsZ0DqtbSkBJq3ct9jKo/gBqBL EUEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Beu3qvFTUH06Rlm0/R7E/eA87SF87SDv5KPlGbUEFUY=; b=rTHlNlh8eYN6teqauPD/fOGXulToOqeh3i3YR1k3ggNI+qgf6AiKxjwec95uLluryT 7n/EtlwPxYg+vi2Ic0tIVonCmzUeH50bL7pC/tc6RwxWkhyCpTnfcXtKRbrdHdQ3Rtx/ PptuPAp4X3knYPa0aKnxze+Nh5ZWJGiqAp1WyTBWhZFLwIcAsYNX/98VPuj26lZJTDlp rPPc6S3ygtp61uCPGCmJ4WfUUdIvK8Xb5piZ8XpSHZdn7CEqfKHHbljEpuIf3ZU2jqKA h7WSzyjaKCOpxVTNTN4UsUEPn2imAKAPU52l400bjis43HKl5Unqnr2k4MhjhhaIAZSd GRUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SjfdFlS3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si1033684otr.108.2020.03.04.05.00.36; Wed, 04 Mar 2020 05:00:48 -0800 (PST) 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; dkim=pass header.i=@chromium.org header.s=google header.b=SjfdFlS3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388087AbgCDNAI (ORCPT + 99 others); Wed, 4 Mar 2020 08:00:08 -0500 Received: from mail-qv1-f65.google.com ([209.85.219.65]:37473 "EHLO mail-qv1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388060AbgCDNAH (ORCPT ); Wed, 4 Mar 2020 08:00:07 -0500 Received: by mail-qv1-f65.google.com with SMTP id c19so716920qvv.4 for ; Wed, 04 Mar 2020 05:00:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Beu3qvFTUH06Rlm0/R7E/eA87SF87SDv5KPlGbUEFUY=; b=SjfdFlS3wO55dVhIbilav3RQtVBWgW91Cnb/+8n7jkIY3LxEaXZNW4wSRZ1w0P+Y2Z m2wcVG3v4ccrUcE2gOaZ9eeheXa1jOFC15/2rUmkBSsjvSz5A70/65MZ8+07ABoV8gmL lUJOwfGxVQgX8ZwatFqrgLAj0QQ4QVNzVsKWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Beu3qvFTUH06Rlm0/R7E/eA87SF87SDv5KPlGbUEFUY=; b=btj/eIFVNg4r3QzmJBWwH96RS6mNbscI5Oi1VolJjt7bq3B2Ar9oQMEIkzfRiYiIuz F7gW4pS2rBWMegaqxwB/YBD3LxWo5ziuT6qKhaU1biegcvG35FhlO/nBY+dF1JVYvMfJ 9yd283aOfWkVoQYrpd1hZ3gQoK2TzQH2mhKgdz5zcYacM/BqG+KE9IFCNF5rAtaXWq03 I8azpOwwc9XYYiS3EsFLsIeb1uMwj69UXzI1WIQsTZpGLzK1TQ236l4UdBRukG+9onoi 9xAfqFiacWP0DVfoDtdoegPXz1c/6tGk/zOhl4630G8aHvw+YW6C182sq5K7O9WfGqyG VDVw== X-Gm-Message-State: ANhLgQ3peP9XF9BZAtRk2AvfOwLdGGqwNvyOjyKuBPMIjwxbVVD+DuyY ZbXBaTsxWax6hGkjkcq9E23vrPLiI9D2BA/YZxHJaQ== X-Received: by 2002:a05:6214:1750:: with SMTP id dc16mr1985308qvb.47.1583326806377; Wed, 04 Mar 2020 05:00:06 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: <1581911502.20099.13.camel@mhfsdcap03> From: Nicolas Boichat Date: Wed, 4 Mar 2020 20:59:55 +0800 Message-ID: Subject: Re: [PATCH v8 4/5] rtc: mt6397: Add support for the MediaTek MT6358 RTC To: Ran Bi Cc: Yingjoe Chen , Hsin-Hsiung Wang , Lee Jones , Rob Herring , Alexandre Belloni , Matthias Brugger , Mark Rutland , Alessandro Zummo , Josef Friedl , srv_heupstream , Frank Wunderlich , Greg Kroah-Hartman , Sean Wang , lkml , Richard Fontana , Devicetree List , "moderated list:ARM/Mediatek SoC support" , linux-arm Mailing List , Thomas Gleixner , Eddie Huang , linux-rtc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: > > > diff --git a/include/linux/mfd/mt6397/rtc.h b/include/linux/mfd/mt6397/rtc.h > > > index f84b916..fffe34a 100644 > > > --- a/include/linux/mfd/mt6397/rtc.h > > > +++ b/include/linux/mfd/mt6397/rtc.h > > > @@ -18,7 +18,8 @@ > > > #define RTC_BBPU_CBUSY BIT(6) > > > #define RTC_BBPU_KEY (0x43 << 8) > > > > > > -#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) > > > @@ -57,6 +58,10 @@ > > > #define MTK_RTC_POLL_DELAY_US 10 > > > #define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) > > > > > > +struct mtk_rtc_data { > > > + u32 wrtgr; > > > +}; > > > + > > > struct mt6397_rtc { > > > struct device *dev; > > > struct rtc_device *rtc_dev; > > > @@ -66,6 +71,15 @@ struct mt6397_rtc { > > > struct regmap *regmap; > > > int irq; > > > u32 addr_base; > > > + const struct mtk_rtc_data *data; > > > +}; > > > + > > > +static const struct mtk_rtc_data mt6358_rtc_data = { > > > + .wrtgr = RTC_WRTGR_MT6358, > > > +}; > > > + > > > +static const struct mtk_rtc_data mt6397_rtc_data = { > > > + .wrtgr = RTC_WRTGR_MT6397, > > > }; > > > > Hi, > > > > 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? Is there any plan to have mt6323-poweroff.c support any of the other PMICs (not just MT6323?)? 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. 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?) Hope this makes sense? Best,