mbox series

[v3,0/6] clk: sunxi-ng: Add a RTC CCU driver

Message ID 20220203021736.13434-1-samuel@sholland.org
Headers show
Series clk: sunxi-ng: Add a RTC CCU driver | expand

Message

Samuel Holland Feb. 3, 2022, 2:17 a.m. UTC
This patch series adds a CCU driver for the RTC in the H616, R329 and
D1. The extra patch at the end of this series shows how it would be
explanded to additional hardware variants.

The driver is intended to support the existing binding used for the H6,
but also an updated binding which includes all RTC input clocks.

A future patch series could add functionality to the driver to manage
IOSC calibration at boot and during suspend/resume.

It may be possible to support all of these hardware variants without
adding this new driver, by adding them to the existing RTC clock
provider, but I'm concerned about the complexity there, without any of
the CCU abstraction.

Changes in v3:
 - Add/fix several maxItems attributes for clocks and clock-items
 - Drop the SUNXI_CCU_MUX_HW_WITH_KEY macro, since it is no longer used.
 - Also drop the patch adding the SUNXI_CCU_MUX_DATA_WITH_GATE macro.
 - Rebase on v5.17-rc2 (CCU module support series was merged).
 - Move IOSC calibration control to prepare/unprepare operations.
 - Declare several `struct clk_init_data`s as static variables (instead
   of as anonymous) so they can be modified from the probe function
   without casting away const.
 - Instead of creating two copies of clocks which may or may not have
   muxes, change the number of parents to 1 in the non-mux case.
 - Use a single CCU description for all variants.
 - Use IS_REACHABLE to guard the call to sun6i_rtc_ccu_probe.
 - Allow the driver to be built on !ARM64 (i.e. RISCV).
 - Rebase example on top of driver changes, and drop the second example.

Changes in v2:
 - Combine "const"s to "enum" in the DT binding compatible property.
 - Properly update the DT binding clocks and clock-names properties.
 - Rebase on v2 of the CCU module support series.
 - Load the CCU driver from the RTC driver, not as an OF provider.

Samuel Holland (6):
  dt-bindings: rtc: sun6i: Clean up repetition
  dt-bindings: rtc: sun6i: Add H616, R329, and D1 support
  rtc: sun6i: Enable the bus clock when provided
  clk: sunxi-ng: mux: Allow muxes to have keys
  clk: sunxi-ng: Add support for the sun6i RTC clocks
  [DO NOT MERGE] clk: sunxi-ng: sun6i-rtc: Add support for H6

 .../bindings/rtc/allwinner,sun6i-a31-rtc.yaml |  84 +++-
 drivers/clk/sunxi-ng/Kconfig                  |   5 +
 drivers/clk/sunxi-ng/Makefile                 |   2 +
 drivers/clk/sunxi-ng/ccu-sun6i-rtc.c          | 393 ++++++++++++++++++
 drivers/clk/sunxi-ng/ccu-sun6i-rtc.h          |  15 +
 drivers/clk/sunxi-ng/ccu_common.h             |   1 +
 drivers/clk/sunxi-ng/ccu_mux.c                |   7 +
 drivers/rtc/rtc-sun6i.c                       |  48 ++-
 include/dt-bindings/clock/sun6i-rtc.h         |  10 +
 include/linux/clk/sunxi-ng.h                  |   2 +
 10 files changed, 538 insertions(+), 29 deletions(-)
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun6i-rtc.c
 create mode 100644 drivers/clk/sunxi-ng/ccu-sun6i-rtc.h
 create mode 100644 include/dt-bindings/clock/sun6i-rtc.h

Comments

Samuel Holland Feb. 7, 2022, 11:54 p.m. UTC | #1
Hi Maxime,

On 2/7/22 3:00 AM, Maxime Ripard wrote:
> On Wed, 2 Feb 2022 20:17:35 -0600, Samuel Holland wrote:
>> The RTC power domain in sun6i and newer SoCs manages the 16 MHz RC
>> oscillator (called "IOSC" or "osc16M") and the optional 32 kHz crystal
>> oscillator (called "LOSC" or "osc32k"). Starting with the H6, this power
>> domain also handles the 24 MHz DCXO (called variously "HOSC", "dcxo24M",
>> or "osc24M") as well. The H6 also adds a calibration circuit for IOSC.
>>
>> Later SoCs introduce further variations on the design:
>>  - H616 adds an additional mux for the 32 kHz fanout source.
>>  - R329 adds an additional mux for the RTC timekeeping clock, a clock
>>    for the SPI bus between power domains inside the RTC, and removes the
>>    IOSC calibration functionality.
>>
>> [...]
> 
> Applied to local tree (sunxi/clk-for-5.18).

Part of the build failures were because this patch depends on patch 3. Is that
okay, or should I update this patch to be independent?

Regards,
Samuel
Alexandre Belloni Feb. 12, 2022, 11:24 p.m. UTC | #2
On 11/02/2022 13:43:12+0100, Maxime Ripard wrote:
> Hi Samuel,
> 
> On Mon, Feb 07, 2022 at 05:54:02PM -0600, Samuel Holland wrote:
> > On 2/7/22 3:00 AM, Maxime Ripard wrote:
> > > On Wed, 2 Feb 2022 20:17:35 -0600, Samuel Holland wrote:
> > >> The RTC power domain in sun6i and newer SoCs manages the 16 MHz RC
> > >> oscillator (called "IOSC" or "osc16M") and the optional 32 kHz crystal
> > >> oscillator (called "LOSC" or "osc32k"). Starting with the H6, this power
> > >> domain also handles the 24 MHz DCXO (called variously "HOSC", "dcxo24M",
> > >> or "osc24M") as well. The H6 also adds a calibration circuit for IOSC.
> > >>
> > >> Later SoCs introduce further variations on the design:
> > >>  - H616 adds an additional mux for the 32 kHz fanout source.
> > >>  - R329 adds an additional mux for the RTC timekeeping clock, a clock
> > >>    for the SPI bus between power domains inside the RTC, and removes the
> > >>    IOSC calibration functionality.
> > >>
> > >> [...]
> > > 
> > > Applied to local tree (sunxi/clk-for-5.18).
> > 
> > Part of the build failures were because this patch depends on patch 3. Is that
> > okay, or should I update this patch to be independent?
> 
> We don't have anything queued up yet, so I think the easiest would be to
> merge this through the RTC tree. So nothing to do on your side yet, we
> just need Alex to answer :)
> 

I can take the whole series but I think I would need acks from Stephen
Stephen Boyd Feb. 18, 2022, 12:33 a.m. UTC | #3
Quoting Alexandre Belloni (2022-02-12 15:24:02)
> On 11/02/2022 13:43:12+0100, Maxime Ripard wrote:
> > Hi Samuel,
> > 
> > On Mon, Feb 07, 2022 at 05:54:02PM -0600, Samuel Holland wrote:
> > > On 2/7/22 3:00 AM, Maxime Ripard wrote:
> > > > On Wed, 2 Feb 2022 20:17:35 -0600, Samuel Holland wrote:
> > > >> The RTC power domain in sun6i and newer SoCs manages the 16 MHz RC
> > > >> oscillator (called "IOSC" or "osc16M") and the optional 32 kHz crystal
> > > >> oscillator (called "LOSC" or "osc32k"). Starting with the H6, this power
> > > >> domain also handles the 24 MHz DCXO (called variously "HOSC", "dcxo24M",
> > > >> or "osc24M") as well. The H6 also adds a calibration circuit for IOSC.
> > > >>
> > > >> Later SoCs introduce further variations on the design:
> > > >>  - H616 adds an additional mux for the 32 kHz fanout source.
> > > >>  - R329 adds an additional mux for the RTC timekeeping clock, a clock
> > > >>    for the SPI bus between power domains inside the RTC, and removes the
> > > >>    IOSC calibration functionality.
> > > >>
> > > >> [...]
> > > > 
> > > > Applied to local tree (sunxi/clk-for-5.18).
> > > 
> > > Part of the build failures were because this patch depends on patch 3. Is that
> > > okay, or should I update this patch to be independent?
> > 
> > We don't have anything queued up yet, so I think the easiest would be to
> > merge this through the RTC tree. So nothing to do on your side yet, we
> > just need Alex to answer :)
> > 
> 
> I can take the whole series but I think I would need acks from Stephen
> 

For the clk patches

Acked-by: Stephen Boyd <sboyd@kernel.org>