Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3615383pxv; Mon, 26 Jul 2021 08:01:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoPuGLFGvYc8YOQlG3p64ZeGlujI6SPuMYNh4morXUcpA+UP6ac4H3nU+lhW05FSDMkPQ5 X-Received: by 2002:a17:906:4889:: with SMTP id v9mr17177145ejq.269.1627311677935; Mon, 26 Jul 2021 08:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627311677; cv=none; d=google.com; s=arc-20160816; b=KGMkFU7Y+ar7l2IszyqjvlaFVX1+ypwNu0lqaoZ5oN04g0+HXRM453CaUjdPQzW2ZZ 9omidAgjhsfZXGlWgwtXx19SDxbT47VF+mTiAt8ZqlvUWjotb2Wx1mOE4QtjXz783/UK zY7IvAnXJ5yJsCxmv8Va9b6jhYixtN37JPKfcziKEfwDQAomPysplpIkfO9STnY3FhA5 g3eUI7dMj0UhE82oHtiYjAVrCQ+VaLvTAQfNLQsFO2GcNl/0yy41Xs/+KPQQINYyffRf yOY8AQdGAmMLVcblM8d5kNr3L/OswZszYL0MdXJmpfPnOHMUOmWwkVqaR29noEe+Upwa bu/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=aafEayI1sVZWEQ+8Kldbq4MehnlcqhooAS5lRNnCO7Q=; b=wpT9rbDy/e+l/Kgl7GAhrBWJBVFvcAmJ0BQ7mNv8haz4ujbN8atOEu1CO1Q4Sj0iXb P3gdkHOHKILaFKYKXE4vHX55RqZxBQc/X7S7n/MWfo0K51aVCMGCgzPZUCrwJyRwYvcx AtxRcHU1LUtDeiOzTaMzf94MkWx3sGu2eU06tn5e9so2rKxL+6CzU91EoRRabRoUSdcc kIp/0NQ3/TrI/FlL9AGBHQJ+3zOsmCQWRKQhm7StZQ4YX90Wv2L7igs3seqlhzJH3r/0 Uq+4+BpJDVi80mcOqhr3NQKHAGqfPlM1h3aM3S/pFNxXghK+lH6pxRDOKAcGqtjI1RDI BGJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=1xZtgOsN; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=IDplYQoI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d15si127147ejc.258.2021.07.26.08.00.54; Mon, 26 Jul 2021 08:01:17 -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; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=1xZtgOsN; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=IDplYQoI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234721AbhGZOTE (ORCPT + 99 others); Mon, 26 Jul 2021 10:19:04 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:45579 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234837AbhGZOS7 (ORCPT ); Mon, 26 Jul 2021 10:18:59 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 0F50E58041D; Mon, 26 Jul 2021 10:59:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 26 Jul 2021 10:59:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=aafEayI1sVZWEQ+8Kldbq4Mehnl cqhooAS5lRNnCO7Q=; b=1xZtgOsNPwxRhKdemCXg5/P1UQ/TvHM4SDl8L/Wrepj uxm931dVSx7NZlCh5RaWw38eIDlyO+8DFnlyMMX7JNr0tM81i2kTMCUl8WpnodEI Crq/XQ8W8++H+nGxC/8Wy4ZsmoEXh7kNZVFKAOzZxFCDIrQa2ADfQzjag3RG/foi JLHNpezIBnAW9IYnySDRs2+i/5ItKePmc1l8of6gQRazAhWtKXjupKTAEyupanGJ B5ZGHbz5I4pbeFWBT4e9jv3JWk78QXmNAq/J83rC26g/6YC8QZjEABUqrun0zEnK 7M87gSb/vgKBJgRGMoQKkfrkwIH+TIVkp2Z9St0uJPQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=aafEay I1sVZWEQ+8Kldbq4MehnlcqhooAS5lRNnCO7Q=; b=IDplYQoIDpe3BvYBGdCCGE ISvOzLFz4DkiFBdTRDWWDBFNzgh5CLpcQU4g6faWBjdPUWBApjP3wlIveSEqYACa oYsyrZXmbJjJGL864XGnfH8I7iBKk6AHkceKcTz/to6zJnCJ3W+fFwVznBm2cGJC T3fSBfryP7hSaY9eeIHYXOMSM40tD5PUAoznE0yPKXvT79NcOVFVOLZDYn7rSXZl l/eq5V9lVWe4kt6AQgjZD2E7w7UJCKfhUJ60AanLHqCVAKT9dn0JFA8ZNh6Dckm2 vi4jXw9L3lAfgZObV3Xu7JETGAp1uOZ/K/2CTf/1k01VQ3d7k8fQYnubzzJMQSBA == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrgeehgdekfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpeelkeeghefhuddtleejgfeljeffheffgfeijefhgfeufefhtdevteegheeiheeg udenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 26 Jul 2021 10:59:26 -0400 (EDT) Date: Mon, 26 Jul 2021 16:59:23 +0200 From: Maxime Ripard To: Andre Przywara 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: <20210726145923.mdk6llzqppczkv5v@gilmour> References: <20210615110636.23403-1-andre.przywara@arm.com> <20210615110636.23403-7-andre.przywara@arm.com> <20210616091431.6tm3zdf77p2x3upc@gilmour> <20210723001721.0bb02cf2@slackpad.fritz.box> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lfxsk3mfqv3tm5fy" Content-Disposition: inline In-Reply-To: <20210723001721.0bb02cf2@slackpad.fritz.box> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --lfxsk3mfqv3tm5fy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 23, 2021 at 12:17:21AM +0100, Andre Przywara wrote: > On Wed, 16 Jun 2021 11:14:31 +0200 > Maxime Ripard wrote: >=20 > Hi Maxime, >=20 > > 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 ig= nore > > > 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. > > >=20 > > > Signed-off-by: Andre Przywara =20 > >=20 > > Honestly, I don't really know if it's worth it at this point. > >=20 > > If we sums this up: > >=20 > > - The RTC has 2 features that we use, mostly centered around 2 > > registers set plus a global one > >=20 > > - Those 2 features are programmed in a completely different way > >=20 > > - Even the common part is different, given the discussion around the > > clocks that we have. > >=20 > > 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? >=20 > 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. My point was that the code that is shared, like the driver boilerplate, is much more complicated than it can be precisely because it's shared. I'd take two simple-but-with-some-redundancy drivers over one big, shared but complicated driver any day. But fine, I guess. > 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. >=20 > 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. >=20 > 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. >=20 > 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. What's the plan? Maxime --lfxsk3mfqv3tm5fy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYP7NywAKCRDj7w1vZxhR xRY+AP41nD/WBdA9hAMZ6UcQge286Jku1Q+P63JZGaIwFd1zPgD7BOEoO8cWt8Fg ep6EHpxzz7yzcEIouyu2MVJ5FNzHMQI= =nHk2 -----END PGP SIGNATURE----- --lfxsk3mfqv3tm5fy--