Skip to contentSkip to conversation

clk: eyeq: add driver

PATCH Applied Théo Lebrun 2 participants 2 messages Oct 23, 2024 – Oct 28, 2024

Subsystems (3)
lore
Share & tools
lore

Théo Lebrun

author maintainer
#0 lore raw

PATCH v6 1/1 clk: eyeq: add driver

Add Mobileye EyeQ5, EyeQ6L and EyeQ6H clock controller driver. It is both a platform driver and a hook onto of_clk_init() used for clocks required early (GIC timer, UARTs).

For some compatible, it is both at the same time. eqc_early_init() initialises early PLLs and exposes its own clock provider. It marks other clocks as deferred. eqc_probe() adds all remaining clocks using another clock provider.

It exposes read-only PLLs derived from the main crystal on board. It also exposes another type of clocks: divider clocks. They always have even divisors and have one PLL as parent.

This driver also bears the responsability for optional reset and pinctrl auxiliary devices. The match data attached to the devicetree node compatible indicate if such devices should be created. They all get passed a pointer to the start of the OLB region.

---
This series adds a platform driver dealing with read-only PLLs derived from the main crystal, and some divider clocks based on those PLLs. It also acts at the one instantiating reset and pinctrl auxiliary devices.

One special feature is that some clocks are required before platform bus infrastructure is available; we therefore register some clocks at of_clk_init() stage.

We support EyeQ5, EyeQ6L and EyeQ6H SoCs. The last one is special in that there are seven instances of this system-controller. All of those handle clocks.

The clock driver instantiates reset and pinctrl auxiliary devices present in the same system controller. Those drivers are upstream already, as well as the devicetree patches to switch from static clocks to using this driver:
- 487b1b32e317 ("reset: eyeq: add platform driver") since v6.12-rc1
- 41795aa1f56a ("pinctrl: eyeq5: add platform driver") since v6.12-rc1
- bde4b22dc526 ("dt-bindings: soc: mobileye: add EyeQ OLB system controller") since v6.11-rc1

This revision mainly simplifies code. We switch from a single clock provider used by both of_clk_init() and platform device to two separate clock providers.

Have a nice day,
Thanks,
Théo

[0]: https://lore.kernel.org/lkml/[email protected]/
---
Changes in v6:
- Rebase onto clk-next. Drop three applied patches (and drop To/Cc):
Revert "dt-bindings: clock: mobileye,eyeq5-clk: add bindings"
dt-bindings: clock: add Mobileye EyeQ6L/EyeQ6H clock indexes
clk: divider: Introduce CLK_DIVIDER_EVEN_INTEGERS flag
- Kconfig:
- Drop "depends on 64BIT" which breaks Stephen's testing scripts.
- driver:
- Use one clock provider at of_clk_init() stage and one at platform device stage. Implications:
- Avoid sharing from early init to probe the cells array and the memory mappings using a static linked list.
- No need for struct eqc_priv, remove it.
- A divider parent clk might not be in the current clk provider. If it is not, we use struct clk_parent_data::index to reference it; see eqc_probe_init_divs().
- Early code must know the total number of clocks, to properly return EPROBE_DEFER. We put that info in early match data.
- Add #include <linux/io-64-nonatomic-hi-lo.h>, see Kconfig change.
- Add missing #include <linux/mod_devicetable.h>.
- Drop __initconst from match data used at probe; probe might be
called after init memory is freed.
- Remove unused EQC_MAX_DIV_COUNT constant.
- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- Set .suppress_bind_attrs = true.
- Replace devm_platform_ioremap_resource()
by platform_get_resource() + ioremap().
- Use non-devres version of devm_kzalloc().
- Use non-devres version of devm_of_clk_add_hw_provider().
- Remove the eqc_auxdev_unregister() devres action.
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- clk-divider:
- Switch flags function arguments from u16 to unsigned long.
- clk-eyeq Kconfig:
- Remove OF dependency that is not required.
- clk-eyeq driver:
- eqc_pll_parse_registers():
- Make clk accuracy computation more explicit using a comment.
- Early return when not spread spectrum, to deindent code.
- Rename eqc_init() to eqc_early_init().
- Remove the early match table. Register a different function in each CLK_OF_DECLARE_DRIVER(), which calls eqc_early_init() with an additional match data argument.
- Add __initconst to early match data structs.
- Remove spinlock on static linked list.
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Kconfig: add "depends on 64BIT" because we use readq(). This removes the ability to COMPILE_TEST the driver on 32bit, which is fine as this is a SoC clk platform driver used on 64bit SoCs.
- driver: avoid of_match_node(...)->data because, if !CONFIG_OF, of_match_node(...) is resolved by the preprocessor to NULL. There is still a warning "eqc_early_match_table declared but unused" if !CONFIG_OF. We fix the <linux/of.h> header in a separate patch:
https://lore.kernel.org/lkml/[email protected]/
- Link to v2: see [1]

Changes in v2:
- bindings: take Acked-by: Krzysztof Kozlowski.
- driver: eqc_auxdev_create(): cast the void __iomem *base variable to (void __force *) before putting it in platform_data, to avoid sparse warning.
- Link to v1: see [1]

Changes since OLB v3 [0]:
- MAINTAINERS: Move changes into a separate commit to avoid merge conflicts. This commit is in the MIPS series [3].
- dt-bindings: split include/dt-bindings/ changes into its own commit. It is part of this clk series.
- dt-bindings: Take Reviewed-by: Rob Herring. The include/dt-bindings/ new commit has NOT inherited from it, just to make sure.

---
 drivers/clk/Kconfig    |  11 +
 drivers/clk/Makefile   |   1 +
 drivers/clk/clk-eyeq.c | 695 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 707 insertions(+)
drivers/clk/Kconfig +11 -0
index 89fc6708f6d67f9d15ecaec073e06b061f81248d..ef709327cba1c7db89d44d847b293890c70c6c57 100644
@@ -226,6 +226,17 @@ config COMMON_CLK_EP93XX
 	help
 	  This driver supports the SoC clocks on the Cirrus Logic ep93xx.
 
+config COMMON_CLK_EYEQ
+	bool "Clock driver for the Mobileye EyeQ platform"
+	depends on MACH_EYEQ5 || MACH_EYEQ6H || COMPILE_TEST
+	select AUXILIARY_BUS
+	default MACH_EYEQ5 || MACH_EYEQ6H
+	help
+	  This driver provides clocks found on Mobileye EyeQ5, EyeQ6L and Eye6H
+	  SoCs. Controllers live in shared register regions called OLB. Driver
+	  provides read-only PLLs, derived from the main crystal clock (which
+	  must be constant). It also exposes some divider clocks.
+
 config COMMON_CLK_FSL_FLEXSPI
 	tristate "Clock driver for FlexSPI on Layerscape SoCs"
 	depends on ARCH_LAYERSCAPE || COMPILE_TEST
drivers/clk/Makefile +1 -0
index 01d664838a9ff659f013d94fe5b345d4bd379f43..bf4bd45adc3a0ed8c9dc699c76f303dc91b524c4 100644
@@ -56,6 +56,7 @@ obj-$(CONFIG_COMMON_CLK_CS2000_CP)	+= clk-cs2000-cp.o
 obj-$(CONFIG_COMMON_CLK_EP93XX)		+= clk-ep93xx.o
 obj-$(CONFIG_ARCH_SPARX5)		+= clk-sparx5.o
 obj-$(CONFIG_COMMON_CLK_EN7523)		+= clk-en7523.o
+obj-$(CONFIG_COMMON_CLK_EYEQ)		+= clk-eyeq.o
 obj-$(CONFIG_COMMON_CLK_FIXED_MMIO)	+= clk-fixed-mmio.o
 obj-$(CONFIG_COMMON_CLK_FSL_FLEXSPI)	+= clk-fsl-flexspi.o
 obj-$(CONFIG_COMMON_CLK_FSL_SAI)	+= clk-fsl-sai.o
drivers/clk/clk-eyeq.c new file +695 -0

695 lines not on this page · raw message

---
base-commit: d635691d84616cfe3a3419ec01cfc2c9277a0b46
change-id: 20240628-mbly-clk-4c6ebc716347

Best regards,

Signature · 1 line
Théo Lebrun <[email protected]>
maintainer Applied
#1 lore raw

Quoting Théo Lebrun (2024-10-23 03:58:40)

Quoted 13 lines

Add Mobileye EyeQ5, EyeQ6L and EyeQ6H clock controller driver. It is both a platform driver and a hook onto of_clk_init() used for clocks required early (GIC timer, UARTs).

For some compatible, it is both at the same time. eqc_early_init() initialises early PLLs and exposes its own clock provider. It marks other clocks as deferred. eqc_probe() adds all remaining clocks using another clock provider.

It exposes read-only PLLs derived from the main crystal on board. It also exposes another type of clocks: divider clocks. They always have even divisors and have one PLL as parent.

Quoted 7 lines

This driver also bears the responsability for optional reset and pinctrl auxiliary devices. The match data attached to the devicetree node compatible indicate if such devices should be created. They all get passed a pointer to the start of the OLB region.

---

Applied to clk-next