From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A79EB30C169 for ; Mon, 15 Jun 2026 17:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781546195; cv=none; b=S4I76estqVTzYrwV5xJQ7dkg0hvlmk3Gps4wUNqcbI1toR1RS9juTOyqqMh5qlARVDkZXzndw/WObLUIUpGqoQe8yqdNrIgdJ8FMGJMp5WpEjDA3f3eZN9Tl/gw6jzM2Wh7aCKudsz6l0o9frLSbgZ5wMJcJTK/tBQMFknm8F6Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781546195; c=relaxed/simple; bh=Oj4RKJnXYk35hVFXcx5pzzIrZMT/oGdZI6oDIaOmPDM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=JyP7g0ERT6KxIrmTv0Y0CojBe1uKrGR9ELeYt0+uCW8tbeC76IvqsA7HcvEJImL73Vda2+U6hOYHejEu2a8HbmtgZz3mtM1X36IF4oonIdkmXKCS2J9pqW5QMLXq2DktPoO1T2KAStcfHWAOA/ScSr1G6JyHY0WJa1saESPKTRs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=ZYgddcch; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="ZYgddcch" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-45eee266c6cso3264886f8f.1 for ; Mon, 15 Jun 2026 10:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1781546192; x=1782150992; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V/fOCYr89rjpFF0YHfilwdeTnNExJ5rFE4DuxmsIniE=; b=ZYgddcchxVva+odMWtL5HnoE7HcMRW4Gv0dILBq6x/ZLYOZ5yaa4ampEsYM1QQstTf q7GhOgflz8RcKMZFzK9jP+5iN2h1F/UQ5CBk5xCS9MBC1BVjjAAfYGcNbpWmwRNAMzD8 aNnKwhLUtjA9zEw4/Lb/hULedH/Q08/aaePp2YeY8fNkjzETnFWib1lRIMUby9MeJtnE l+lThamPoSa9NIf2H6HH6jqjYHtfheAUTd8KiCT2ByzjLQPKSJj1HD+aEwco7BhzTBq9 xLg+TwI7G4FBpE5iDrvH8feQ0DAQl4cPix2TZ4PCVVb1SczwY2/CwVWtxM9JdRkI2Ksw qABw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781546192; x=1782150992; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V/fOCYr89rjpFF0YHfilwdeTnNExJ5rFE4DuxmsIniE=; b=PNI5JWd4wO5KJ4QMraudSwz+646By/C3b25haayqDE6lDRAupcVrKh5FASR8ABAttV A08n9rpSIm0xbX6EQFc62fjc+pZtNI7l/bOJWQyseGfAROO14LPUJYKt8b1Z5E4TOGfR 2uCcMA8ex6FBEJKmWjTCLJ8J78UHVXiALNexUKCFDXOcnodoOxvHYek5tpKM+Y7cq8zq ybDiuF5o98cM9NmRPDqPH6WvB1XzNWPAJCeOr5W41dx5HxyIxXwvAlVqh4jWtZgwStv6 XVzm//lXgjb9dfckQVwtN26+U/USPz7Bc9vGlxu6Q4XoYIi/OzvDdjq/h6FO+adYZeHv FYvg== X-Forwarded-Encrypted: i=1; AFNElJ/rUo8AUuTCqeUt7g2hmrt5V6nRGkhHzW/8TeSJyhHa1hzyZyXCKz1sPMpdk48SO8nP2fFvxxpr88wG+g==@lists.linux.dev X-Gm-Message-State: AOJu0YwrnyOxgU3FamKvL4/eVNnZX/++7v3YsRzjoA+mlI9NcZeNx58b igdSTtHq5qIYn71BVQ6DtCtxHrTkKeL3LCcmowBYa0rrEuMwpmIM4ItIcYcMp28Gxfo= X-Gm-Gg: Acq92OEH6YcpK++BLMZxGQaFR5AFkb74zuq6PPAN9vIiK/AGqh9DUP7L0D8qnDNjqJS uv+yDSte2Sds+mQDyFGX76aML3nYplGrrJhNKU/PiQLEPuZthE0hlmNJ4SjXm6vRtFtbExCxTAh XfH2IYw/nTqeRIJTAcpRV96KyfvTpus8KdevLOjMCzCjMSGM9nHSSudHdSTXYVK4JruYguED5yk A2h0nWDHN6JKWAF0SkbgpYQ0rZytufVP6atXMsF+hKkc2Jc4SvX7XVfDqxRsVKgo4QVl8pHQ1v7 qTlgpjc3Brx+pBHN8IlO35yM+CtEtzyjtSGiaTr19I1Zfo4mFzX8c0koLc7e/kf4x6I8IXyxjj8 Wf4hAhm6MZgbXPtopsEdxqitij24oLhejFF4Mr7DNJIwUeuAox6zfZDwjNroAfQHdjz76brIkUH 0YL3eEvzFJ5wuL5LsrZJExYg== X-Received: by 2002:a05:6000:288f:b0:43d:50c:6f33 with SMTP id ffacd0b85a97d-46077f2a62dmr16205392f8f.26.1781546192039; Mon, 15 Jun 2026 10:56:32 -0700 (PDT) Received: from localhost ([2a01:e0a:3c5:5fb1:5176:ebe3:853b:8fb0]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-4606f2e6a8fsm36837329f8f.37.2026.06.15.10.56.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2026 10:56:31 -0700 (PDT) From: Jerome Brunet To: Chen-Yu Tsai Cc: Junhui Liu , Michael Turquette , Stephen Boyd , Jernej Skrabec , Samuel Holland , Alexandre Belloni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Ripard , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, =?utf-8?Q?Andr?= =?utf-8?Q?=C3=A9?= Przywara Subject: Re: [PATCH 7/7] clk: sunxi-ng: Add Allwinner A733 RTC CCU support In-Reply-To: (Chen-Yu Tsai's message of "Sat, 28 Mar 2026 22:41:20 +0800") References: <20260121-a733-rtc-v1-0-d359437f23a7@pigmoral.tech> <20260121-a733-rtc-v1-7-d359437f23a7@pigmoral.tech> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Mon, 15 Jun 2026 19:56:29 +0200 Message-ID: <1jv7bjd6wi.fsf@starbuckisacylon.baylibre.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On sam. 28 mars 2026 at 22:41, Chen-Yu Tsai wrote: > On Wed, Jan 21, 2026 at 7:04=E2=80=AFPM Junhui Liu wrote: >> >> Add support for the internal CCU found in the RTC module of the Allwinner >> A733 SoC. While the basic 16MHz (IOSC) and 32kHz logic remains compatible >> with older SoCs like the sun6i, the A733 introduces several new features. >> >> The A733 RTC CCU supports choosing one of three external crystal >> frequencies: 19.2MHz, 24MHz, and 26MHz. It features hardware detection >> logic to automatically identify the frequency used on the board and >> exports this DCXO signal as the "hosc" clock. >> >> Furthermore, the driver implements logic to derive a 32kHz reference >> from the HOSC. This is achieved through a muxed clock path using fixed >> pre-dividers to normalize the different crystal frequencies to ~32kHz. > > Have you tested whether the actually normalizes the frequency, i.e. > selects a different divider based on the DCXO frequency? Otherwise > we're just lying about the frequency. > >> This path reuses the same hardware mux registers as the HOSC clock. >> >> Additionally, this CCU provides several gate clocks for specific >> peripherals, including SerDes, HDMI, and UFS. The driver is implemented >> as an auxiliary driver to be bound to the sun6i-rtc driver. >> >> Signed-off-by: Junhui Liu >> --- [...] >> +}; >> + >> +static const struct clk_parent_data hosc_parents[] =3D { >> + { .fw_name =3D "osc24M" }, >> + { .fw_name =3D "osc19M" }, >> + { .fw_name =3D "osc26M" }, >> + { .fw_name =3D "osc24M" }, >> +}; > > As mentioned in my reply to the binding, this is wrong. There is only > one input. > > The most you can do is check the rate of the parent clock against the > detected one, and _scream_ that the DT is wrong. And maybe override > the reported frequency. > > If you want to do the latter, you could add a new fixed rate gated > clock type to our library. You would fill in the rate before the > clocks get registered. I probably wouldn't go that far. We want people > to have correct hardware descriptions. > > Funnily enough Allwinner's BSP actually implements a fixed rate gate > for the next 24M-to-32k divider clock. What about implementing the register bellow as a read-only (and non-cached) divider using the factors provided by Junhui ? That would be an accurate description of the HW I think. The oscillator gets set in DT and if the output reported past the divider is not 32728Hz, you know you've got a problem (bad DT or HW gone bad) With a fixed-rate gate, you may actually end up lying about what actually happen, if the HW does not behave as expected. Do you prefer a fixed-rate gate still or should I try the RO divider approach ? > >> + >> +struct ccu_mux hosc_clk =3D { >> + .enable =3D DCXO_CTRL_DCXO_EN, >> + .mux =3D _SUNXI_CCU_MUX(14, 2), >> + .common =3D { >> + .reg =3D DCXO_CTRL_REG, >> + .hw.init =3D CLK_HW_INIT_PARENTS_DATA("hosc", >> + hosc_parents, >> + &ccu_mux_ro_o= ps, >> + 0), >> + }, >> +}; > > So this is wrong. > >> + >> +static const struct ccu_mux_fixed_prediv hosc_32k_predivs[] =3D { >> + { .index =3D 0, .div =3D 732 }, > > Why is it 732 instead of 750? > >> + { .index =3D 1, .div =3D 586 }, >> + { .index =3D 2, .div =3D 793 }, >> + { .index =3D 3, .div =3D 732 }, >> +}; >> + >> +static struct ccu_mux hosc_32k_mux_clk =3D { >> + .enable =3D DCXO_CTRL_DCXO_EN, >