Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp925876pxv; Thu, 22 Jul 2021 16:18:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWgiSwC3HLYtbGSmW6FJEzPaYr2/2DWLwIy8hrFGLDpB0uFvHX+mSjIJN6VvDkANpn8Mug X-Received: by 2002:a6b:f41a:: with SMTP id i26mr1627955iog.162.1626995935856; Thu, 22 Jul 2021 16:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626995935; cv=none; d=google.com; s=arc-20160816; b=kAODk0VhhgmjzD7nKDx4GWMDvsNkeTEOUKaPt+bZKJToIKOYVnpV5NEfAZFXjZT7J8 sLJHMoH8T8jkjX+BA7tSOyTOahHjDV1vHXz5eyWYDdzf52tTQknXcRUYORkBmyRqrCPq hQikyt7i5in0FNqBkJwtlfnjgOwJcrP4EkK5jvwggqxepGa/6enI8oF+IJZHf85Lr3pK Q7tKLVdPOWII8Ppl0t1C6SHWp6v9tXA8R1JCP+pxJxdD+uuRSpXsY/a2XfPPgGZDllJV nbOUxwXY1Qt5Kl2dyaabfvk0qM6dAGuvfAsoHyrcugIRIeSTHqlXqwEzT1Rwy0O+gB5S yaiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=cYn1VVLZd2rXhDBUmfmgwWAbulX5eMM7WRu6CY660zw=; b=oIUjzqJQQbIuvWeOdivukDFgOUv8hX5MUA4WafwaCKfcS8abKZrxOCd3eUIW+Ig52C tv2n7IXcQIKmvNb1cb7LCJpRiIgOBxG/hNG2P0W8zBHLkehRcHOQ5Mq614KYfnRWDfQU IYgn/cQT7DX7Wo6a0/PtBUItRkepRKvFx8zUiPAB2aIjt69IBlnUa9CrPSOBL5bXD+eA PNOkEyi5xXDMuF52LSQyLcd2v5x14Qem5wJ8Gr+njqRQ1pYveh5zTl+At89ut8IjXrC9 BCkVAk0ZfDuRB3qm9398RUjFeledzsV8u9fGmaZk0iDz4j/YaYYAsVbT5iidS7NN9+O2 l+dA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si31122587jao.12.2021.07.22.16.18.43; Thu, 22 Jul 2021 16:18:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232536AbhGVWh0 (ORCPT + 99 others); Thu, 22 Jul 2021 18:37:26 -0400 Received: from foss.arm.com ([217.140.110.172]:35088 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232024AbhGVWhZ (ORCPT ); Thu, 22 Jul 2021 18:37:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4E767106F; Thu, 22 Jul 2021 16:17:59 -0700 (PDT) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5BC713F694; Thu, 22 Jul 2021 16:17:57 -0700 (PDT) Date: Fri, 23 Jul 2021 00:17:21 +0100 From: Andre Przywara To: Maxime Ripard Cc: Chen-Yu Tsai , Jernej Skrabec , Rob Herring , Icenowy Zheng , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Ondrej Jirman , Alessandro Zummo , Alexandre Belloni , linux-rtc@vger.kernel.org Subject: Re: [PATCH v7 06/19] rtc: sun6i: Add support for RTCs without external LOSCs Message-ID: <20210723001721.0bb02cf2@slackpad.fritz.box> In-Reply-To: <20210616091431.6tm3zdf77p2x3upc@gilmour> References: <20210615110636.23403-1-andre.przywara@arm.com> <20210615110636.23403-7-andre.przywara@arm.com> <20210616091431.6tm3zdf77p2x3upc@gilmour> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 16 Jun 2021 11:14:31 +0200 Maxime Ripard wrote: Hi Maxime, > On Tue, Jun 15, 2021 at 12:06:23PM +0100, Andre Przywara wrote: > > Some newer Allwinner RTCs (for instance the one in the H616 SoC) lack > > a pin for an external 32768 Hz oscillator. As a consequence, this LOSC > > can't be selected as the RTC clock source, and we must rely on the > > internal RC oscillator. > > To allow additions of clocks to the RTC node, add a feature bit to ignore > > any provided clocks for now (the current code would think this is the > > external LOSC). Later DTs and code can then for instance add the PLL > > based clock input, and older kernel won't get confused. > > > > Signed-off-by: Andre Przywara > > Honestly, I don't really know if it's worth it at this point. > > If we sums this up: > > - The RTC has 2 features that we use, mostly centered around 2 > registers set plus a global one > > - Those 2 features are programmed in a completely different way > > - Even the common part is different, given the discussion around the > clocks that we have. > > What is there to share in that driver aside from the probe, and maybe > the interrupt handling? Instead of complicating this further with more > special case that you were (rightfully) complaining about, shouldn't we > just acknowledge the fact that it's a completely separate design and > should be treated as such, with a completely separate driver? So I had a look, and I don't think it justifies a separate driver: - Indeed it looks like the core functionality is different, but there are a lot of commonalities, with all the RTC and driver boilerplate, register offsets, and also the special access pattern (rtc_wait and rtc_setaie). - The actual difference is really in the way the *date* is stored (the time is still in 24h H/M/S format), and the missing LOSC input clock - which is already optional for existing devices. The two patches just make this obvious, by using if() statements at the parts where they differ. So we would end up with possibly some shared .c file, and two driver front-end files, which I am not sure is really worth it. Next I thought about providing separate rtc_class_ops, but even they share a lot of code, so they would be possibly be calling a shared function each. I don't think that is really better. If you dislike the rather large if/else branches in the previous two patches, I could move that out into separate functions, but I feel this is more code, for no real benefit. So for now I am tempted to keep it shared. I think Samuel had ideas for bigger changes in the clock part, at which point we could revisit this decision - for instance keep the RTC part (still quite similar) mostly in a shared file, while modelling the clocks in separate files - in a more "common clock" style for the new SoCs. Feel free to disagree, but when I tried to actually separate the drivers it just felt wrong. Cheers, Andre