Add Mobileye EyeQ clock support
Subsystems (3)
Théo Lebrun
maintainerv2 cover Add Mobileye EyeQ clock support
This is a new iteration on the Mobileye system-controller series. It used to be sent as a single series [0], but has been split in the previous revision (see [1], [2], [3], [4]) to faciliate merging.
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 the 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.
Related series are targeted at reset [5], pinctrl [6] and MIPS [4]. The first two are receiving a second version. The last one has no change and stays at its V1.
Have a nice day,
Théo
[0]: https://lore.kernel.org/lkml/[email protected]/
[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/
[3]: https://lore.kernel.org/lkml/[email protected]/
[4]: https://lore.kernel.org/lkml/[email protected]/
[5]: https://lore.kernel.org/lkml/[email protected]/
[6]: https://lore.kernel.org/lkml/[email protected]/
---
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.
---
Théo Lebrun (4):
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
clk: eyeq: add driver
.../bindings/clock/mobileye,eyeq5-clk.yaml | 51 -- drivers/clk/Kconfig | 12 + drivers/clk/Makefile | 1 + drivers/clk/clk-divider.c | 12 +- drivers/clk/clk-eyeq.c | 789 +++++++++++++++++++++ include/dt-bindings/clock/mobileye,eyeq5-clk.h | 21 + include/linux/clk-provider.h | 11 +- 7 files changed, 839 insertions(+), 58 deletions(-)
---
base-commit: f2661062f16b2de5d7b6a5c42a9a5c96326b8454
change-id: 20240628-mbly-clk-4c6ebc716347
Best regards,
Signature · 1 line
Théo Lebrun <[email protected]>
Théo Lebrun
maintainerPATCH v2 1/4 Revert "dt-bindings: clock: mobileye,eyeq5-clk: add bindings"
Switch from one sub-node per functionality in the system-controller to a single node representing the entire OLB instance. This is the recommended approach for controllers handling many different functionalities; it is a single controller and should be represented by a single devicetree node.
The clock bindings is removed and all properties will be described by:soc/mobileye/mobileye,eyeq5-olb.yaml
--- .../bindings/clock/mobileye,eyeq5-clk.yaml | 51 ---------------------- 1 file changed, 51 deletions(-)
Documentation/devicetree/bindings/clock/mobileye,eyeq5-clk.yaml deleted +0 -51
@@ -1,51 +0,0 @@ -# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) -%YAML 1.2 ---- -$id: http://devicetree.org/schemas/clock/mobileye,eyeq5-clk.yaml# -$schema: http://devicetree.org/meta-schemas/core.yaml# - -title: Mobileye EyeQ5 clock controller - -description: - The EyeQ5 clock controller handles 10 read-only PLLs derived from the main - crystal clock. It also exposes one divider clock, a child of one of the PLLs. - Its registers live in a shared region called OLB. - -maintainers: - - Grégory Clement <[email protected]> - - Théo Lebrun <[email protected]> - - Vladimir Kondratiev <[email protected]> - -properties: - compatible: - const: mobileye,eyeq5-clk - - reg: - maxItems: 2 - - reg-names: - items: - - const: plls - - const: ospi - - "#clock-cells": - const: 1 - - clocks: - maxItems: 1 - description: - Input parent clock to all PLLs. Expected to be the main crystal. - - clock-names: - items: - - const: ref - -required: - - compatible - - reg - - reg-names - - "#clock-cells" - - clocks - - clock-names - -additionalProperties: false
Signature · 1 line
2.45.2
Théo Lebrun
maintainerPATCH v2 2/4 dt-bindings: clock: add Mobileye EyeQ6L/EyeQ6H clock indexes
In reply to Théo LebrunAdd #defines for Mobileye EyeQ6L and EyeQ6H SoC clocks.
Constant prefixes are:
- EQ6LC_PLL_: EyeQ6L clock PLLs
- EQ6HC_SOUTH_PLL_: EyeQ6H south OLB PLLs
- EQ6HC_SOUTH_DIV_: EyeQ6H south OLB divider clocks
- EQ6HC_ACC_PLL_: EyeQ6H accelerator OLB PLLs
--- include/dt-bindings/clock/mobileye,eyeq5-clk.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
include/dt-bindings/clock/mobileye,eyeq5-clk.h +21 -0
@@ -19,4 +19,25 @@#define EQ5C_DIV_OSPI 10 +#define EQ6LC_PLL_DDR 0 +#define EQ6LC_PLL_CPU 1 +#define EQ6LC_PLL_PER 2 +#define EQ6LC_PLL_VDI 3 + +#define EQ6HC_SOUTH_PLL_VDI 0 +#define EQ6HC_SOUTH_PLL_PCIE 1 +#define EQ6HC_SOUTH_PLL_PER 2 +#define EQ6HC_SOUTH_PLL_ISP 3 + +#define EQ6HC_SOUTH_DIV_EMMC 4 +#define EQ6HC_SOUTH_DIV_OSPI_REF 5 +#define EQ6HC_SOUTH_DIV_OSPI_SYS 6 +#define EQ6HC_SOUTH_DIV_TSU 7 + +#define EQ6HC_ACC_PLL_XNN 0 +#define EQ6HC_ACC_PLL_VMP 1 +#define EQ6HC_ACC_PLL_PMA 2 +#define EQ6HC_ACC_PLL_MPC 3 +#define EQ6HC_ACC_PLL_NOC 4 +#endif
Signature · 1 line
2.45.2
Théo Lebrun
maintainerPATCH v2 3/4 clk: divider: Introduce CLK_DIVIDER_EVEN_INTEGERS flag
In reply to Théo LebrunAdd CLK_DIVIDER_EVEN_INTEGERS flag to support divisor of 2, 4, 6, etc. The same divisor can be done using a table, which would be big and wasteful for a clock dividor of width 8 (256 entries).
Require increasing flags size from u8 to u16 because CLK_DIVIDER_EVEN_INTEGERS is the eighth flag.
--- drivers/clk/clk-divider.c | 12 +++++++++--- include/linux/clk-provider.h | 11 +++++++---- 2 files changed, 16 insertions(+), 7 deletions(-)
drivers/clk/clk-divider.c +9 -3
@@ -72,6 +72,8 @@ static unsigned int _get_maxdiv(const struct clk_div_table *table, u8 width,return clk_div_mask (width);if (flags &CLK_DIVIDER_POWER_OF_TWO )return 1 <<clk_div_mask (width); +if (flags &CLK_DIVIDER_EVEN_INTEGERS ) +return 2 * (clk_div_mask (width) +1 );if (table)return _get_table_maxdiv (table, width);return clk_div_mask (width) +1 ;
@@ -97,6 +99,8 @@ static unsigned int _get_div(const struct clk_div_table *table,return 1 << val;if (flags &CLK_DIVIDER_MAX_AT_ZERO )return val ? val :clk_div_mask (width) +1 ; +if (flags &CLK_DIVIDER_EVEN_INTEGERS ) +return 2 * (val +1 );if (table)return _get_table_div (table, val);return val +1 ;
@@ -122,6 +126,8 @@ static unsigned int _get_val(const struct clk_div_table *table,return __ffs (div);if (flags &CLK_DIVIDER_MAX_AT_ZERO )return (div ==clk_div_mask (width) +1 ) ?0 : div; +if (flags &CLK_DIVIDER_EVEN_INTEGERS ) +return (div >>1 ) -1 ;if (table)return _get_table_val (table, div);return div -1 ;
@@ -538,7 +544,7 @@ struct clk_hw *__clk_hw_register_divider(struct device *dev, struct device_node *np, const char *name, const char *parent_name, const struct clk_hw *parent_hw, const struct clk_parent_data *parent_data, unsigned long flags, - void __iomem *reg, u8 shift, u8 width, u8 clk_divider_flags, + void __iomem *reg, u8 shift, u8 width, u16 clk_divider_flags, const struct clk_div_table *table, spinlock_t *lock) { struct clk_divider *div;
@@ -610,7 +616,7 @@ EXPORT_SYMBOL_GPL(__clk_hw_register_divider);struct clk *clk_register_divider_table (struct device *dev,const char *name,const char *parent_name,unsigned long flags,void __iomem *reg,u8 shift,u8 width, -u8 clk_divider_flags,const struct clk_div_table *table, +u16 clk_divider_flags,const struct clk_div_table *table,spinlock_t *lock) {struct clk_hw *hw;
@@ -664,7 +670,7 @@ struct clk_hw *__devm_clk_hw_register_divider(struct device *dev, struct device_node *np, const char *name, const char *parent_name, const struct clk_hw *parent_hw, const struct clk_parent_data *parent_data, unsigned long flags, - void __iomem *reg, u8 shift, u8 width, u8 clk_divider_flags, + void __iomem *reg, u8 shift, u8 width, u16 clk_divider_flags, const struct clk_div_table *table, spinlock_t *lock) { struct clk_hw **ptr, *hw;
include/linux/clk-provider.h +7 -4
@@ -675,13 +675,15 @@ struct clk_div_table {* CLK_DIVIDER_BIG_ENDIAN - By default little endian register accesses are used * for the divider register. Setting this flag makes the register accesses * big endian. +* CLK_DIVIDER_EVEN_INTEGERS - clock divisor is 2, 4, 6, 8, 10, etc. +* Formula is 2 * (value read from hardware + 1). */ struct clk_divider {struct clk_hw hw;void __iomem *reg;u8 shift;u8 width; -u8 flags; +u16 flags;const struct clk_div_table *table;spinlock_t *lock; };
@@ -697,6 +699,7 @@ struct clk_divider {#define CLK_DIVIDER_READ_ONLY BIT(5)#define CLK_DIVIDER_MAX_AT_ZERO BIT(6)#define CLK_DIVIDER_BIG_ENDIAN BIT(7) +#define CLK_DIVIDER_EVEN_INTEGERS BIT(8)extern const struct clk_ops clk_divider_ops;extern const struct clk_ops clk_divider_ro_ops;
@@ -726,18 +729,18 @@ struct clk_hw *__clk_hw_register_divider(struct device *dev, struct device_node *np, const char *name, const char *parent_name, const struct clk_hw *parent_hw, const struct clk_parent_data *parent_data, unsigned long flags, - void __iomem *reg, u8 shift, u8 width, u8 clk_divider_flags, + void __iomem *reg, u8 shift, u8 width, u16 clk_divider_flags, const struct clk_div_table *table, spinlock_t *lock);struct clk_hw *__devm_clk_hw_register_divider (struct device *dev,struct device_node *np,const char *name,const char *parent_name,const struct clk_hw *parent_hw,const struct clk_parent_data *parent_data,unsigned long flags, -void __iomem *reg,u8 shift,u8 width,u8 clk_divider_flags, +void __iomem *reg,u8 shift,u8 width,u16 clk_divider_flags,const struct clk_div_table *table,spinlock_t *lock);struct clk *clk_register_divider_table (struct device *dev,const char *name,const char *parent_name,unsigned long flags,void __iomem *reg,u8 shift,u8 width, -u8 clk_divider_flags,const struct clk_div_table *table, +u16 clk_divider_flags,const struct clk_div_table *table,spinlock_t *lock);/** * clk_register_divider - register a divider clock with the clock framework
Signature · 1 line
2.45.2
Théo Lebrun
maintainerPATCH v2 4/4 clk: eyeq: add driver
In reply to Théo LebrunAdd 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_init() initialises early PLLs and stores clock array in a static linked list. It marks other clocks as deferred. eqc_probe() retrieves the clock array and adds all remaining clocks.
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.
--- drivers/clk/Kconfig | 12 + drivers/clk/Makefile | 1 + drivers/clk/clk-eyeq.c | 789 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 802 insertions(+)
drivers/clk/Kconfig +12 -0
@@ -218,6 +218,18 @@ config COMMON_CLK_EN7523 This driver provides the fixed clocks and gates present on Airoha ARM silicon. +config COMMON_CLK_EYEQ + bool "Clock driver for the Mobileye EyeQ platform" + depends on OF || COMPILE_TEST + 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
@@ -32,6 +32,7 @@ obj-$(CONFIG_ARCH_CLPS711X) += clk-clps711x.o obj-$(CONFIG_COMMON_CLK_CS2000_CP) += clk-cs2000-cp.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 +789 -0
789 lines not on this page · raw message
Signature · 1 line
2.45.2
kernel test robot
build botRe: [PATCH v2 4/4] clk: eyeq: add driver
kernel test robot noticed the following build errors:
Hi Théo,
kernel test robot noticed the following build errors:
[auto build test ERROR on f2661062f16b2de5d7b6a5c42a9a5c96326b8454]
url: https://github.com/intel-lab-lkp/linux/commits/Th-o-Lebrun/Revert-dt-bindings-clock-mobileye-eyeq5-clk-add-bindings/20240704-211515 base: f2661062f16b2de5d7b6a5c42a9a5c96326b8454 patch link: https://lore.kernel.org/r/20240703-mbly-clk-v2-4-fe8c6199a579%40bootlin.com patch subject: [PATCH v2 4/4] clk: eyeq: add driver config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20240705/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project a0c6b8aef853eedaa0980f07c0a502a5a8a9740e) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240705/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/clk/clk-eyeq.c:30:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from drivers/clk/clk-eyeq.c:30:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from drivers/clk/clk-eyeq.c:30:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
>> drivers/clk/clk-eyeq.c:264:9: error: call to undeclared function 'readq'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
264 | val = readq(priv->base + pll->reg64);
| ^
drivers/clk/clk-eyeq.c:724:9: error: call to undeclared function 'readq'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
724 | val = readq(base + pll->reg64);
| ^6 warnings and 2 errors generated.
vim +/readq +264 drivers/clk/clk-eyeq.c
249
250 static void eqc_probe_init_plls(struct device *dev, struct eqc_priv *priv)
251 {
252 const struct eqc_match_data *data = priv->data;
253 unsigned long mult, div, acc;
254 const struct eqc_pll *pll;
255 struct clk_hw *hw;
256 unsigned int i;
257 u32 r0, r1;
258 u64 val;
259 int ret;
260
261 for (i = 0; i < data->pll_count; i++) {
262 pll = &data->plls[i];
263
> 264 val = readq(priv->base + pll->reg64);
265 r0 = val;
266 r1 = val >> 32;
267
268 ret = eqc_pll_parse_registers(r0, r1, &mult, &div, &acc);
269 if (ret) {
270 dev_warn(dev, "failed parsing state of %s\n", pll->name);
271 priv->cells->hws[pll->index] = ERR_PTR(ret);
272 continue;
273 }
274
275 hw = clk_hw_register_fixed_factor_with_accuracy_fwname(dev,
276 dev->of_node, pll->name, "ref", 0, mult, div, acc);
277 priv->cells->hws[pll->index] = hw;
278 if (IS_ERR(hw))
279 dev_warn(dev, "failed registering %s: %pe\n", pll->name, hw);
280 }
281 }
282
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Théo Lebrun
maintainerRe: [PATCH v2 4/4] clk: eyeq: add driver
Hello,
*Grasp*, I forgot addressing this topic.
Quoted 1 line · kernel test robot
kernel test robot noticed the following build errors:
[...]
Quoted 9 lines
All errors (new ones prefixed by >>):
In file included from
drivers/clk/clk-eyeq.c:30:
In file included frominclude/linux/io.h:14:
In file included fromarch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:548:31: warning: performing pointerarithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 548 | val = __raw_readb(PCI_IOBASE + addr); | ~~~~~~~~~~ ^
[...]
Ignoring all the warnings relative to <linux/io.h> as they appear on all objects using this config, nothing specific to clk-eyeq.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
drivers/clk/clk-eyeq.c:264:9: error: call to undeclared function
'readq'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]264 | val = readq(priv->base + pll->reg64); | ^
Options are:
- #include <linux/io-64-nonatomic-lo-hi.h> or
<linux/io-64-nonatomic-hi-lo.h> or
- in Kconfig, add "depends on 64BIT # for readq()"
I'm leaning towards the Kconfig option. Build testing this driver on 32bit platforms makes no sense, this is a SoC clk platform driver used on 64bit SoCs. Including a compat layer is a more complex solution.
I'll wait a bit before sending next revision. You can ping if you want it straight away of course.
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
kernel test robot
build botRe: [PATCH v2 4/4] clk: eyeq: add driver
In reply to Théo Lebrunkernel test robot noticed the following build errors:
Hi Théo,
kernel test robot noticed the following build errors:
[auto build test ERROR on f2661062f16b2de5d7b6a5c42a9a5c96326b8454]
url: https://github.com/intel-lab-lkp/linux/commits/Th-o-Lebrun/Revert-dt-bindings-clock-mobileye-eyeq5-clk-add-bindings/20240704-211515 base: f2661062f16b2de5d7b6a5c42a9a5c96326b8454 patch link: https://lore.kernel.org/r/20240703-mbly-clk-v2-4-fe8c6199a579%40bootlin.com patch subject: [PATCH v2 4/4] clk: eyeq: add driver config: s390-randconfig-r132-20240705 (https://download.01.org/0day-ci/archive/20240706/[email protected]/config) compiler: s390-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20240706/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
drivers/clk/clk-eyeq.c: In function 'eqc_init':
>> drivers/clk/clk-eyeq.c:679:62: warning: dereferencing 'void *' pointer
679 | early_data = of_match_node(eqc_early_match_table, np)->data;
| ^~
>> drivers/clk/clk-eyeq.c:679:62: error: request for member 'data' in something not a structure or union
drivers/clk/clk-eyeq.c: At top level:
>> drivers/clk/clk-eyeq.c:653:34: warning: 'eqc_early_match_table' defined but not used [-Wunused-const-variable=]
653 | static const struct of_device_id eqc_early_match_table[] = {
| ^~~~~~~~~~~~~~~~~~~~~vim +/data +679 drivers/clk/clk-eyeq.c
652
> 653 static const struct of_device_id eqc_early_match_table[] = {
654 {
655 .compatible = "mobileye,eyeq5-olb",
656 .data = &eqc_eyeq5_early_match_data,
657 },
658 {
659 .compatible = "mobileye,eyeq6h-central-olb",
660 .data = &eqc_eyeq6h_central_early_match_data,
661 },
662 {
663 .compatible = "mobileye,eyeq6h-west-olb",
664 .data = &eqc_eyeq6h_west_early_match_data,
665 },
666 {}
667 };
668 MODULE_DEVICE_TABLE(of, eqc_early_match_table);
669
670 static void __init eqc_init(struct device_node *np)
671 {
672 const struct eqc_early_match_data *early_data;
673 unsigned int nb_clks = 0;
674 struct eqc_priv *priv;
675 void __iomem *base;
676 unsigned int i;
677 int ret;
678
> 679 early_data = of_match_node(eqc_early_match_table, np)->data; 680
681 /* No reason to early init this clock provider. Delay until probe. */
682 if (!early_data || early_data->early_pll_count == 0)
683 return;
684
685 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
686 if (!priv) {
687 ret = -ENOMEM;
688 goto err;
689 }
690
691 priv->np = np;
692 priv->early_data = early_data;
693
694 nb_clks = early_data->early_pll_count + early_data->nb_late_clks;
695 priv->cells = kzalloc(struct_size(priv->cells, hws, nb_clks), GFP_KERNEL);
696 if (!priv->cells) {
697 ret = -ENOMEM;
698 goto err;
699 }
700
701 priv->cells->num = nb_clks;
702
703 /*
704 * Mark all clocks as deferred; some are registered here, the rest at
705 * platform device probe.
706 */
707 for (i = 0; i < nb_clks; i++)
708 priv->cells->hws[i] = ERR_PTR(-EPROBE_DEFER);
709
710 /* Offsets (reg64) of early PLLs are relative to OLB block. */
711 base = of_iomap(np, 0);
712 if (!base) {
713 ret = -ENODEV;
714 goto err;
715 }
716
717 for (i = 0; i < early_data->early_pll_count; i++) {
718 const struct eqc_pll *pll = &early_data->early_plls[i];
719 unsigned long mult, div, acc;
720 struct clk_hw *hw;
721 u32 r0, r1;
722 u64 val;
723
724 val = readq(base + pll->reg64);
725 r0 = val;
726 r1 = val >> 32;
727
728 ret = eqc_pll_parse_registers(r0, r1, &mult, &div, &acc);
729 if (ret) {
730 pr_err("failed parsing state of %s\n", pll->name);
731 goto err;
732 }
733
734 hw = clk_hw_register_fixed_factor_with_accuracy_fwname(NULL,
735 np, pll->name, "ref", 0, mult, div, acc);
736 priv->cells->hws[pll->index] = hw;
737 if (IS_ERR(hw)) {
738 pr_err("failed registering %s: %pe\n", pll->name, hw);
739 ret = PTR_ERR(hw);
740 goto err;
741 }
742 }
743
744 /* When providing a single clock, require no cell. */
745 if (nb_clks == 1)
746 ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, priv->cells->hws[0]);
747 else
748 ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, priv->cells);
749 if (ret) {
750 pr_err("failed registering clk provider: %d\n", ret);
751 goto err;
752 }
753
754 spin_lock(&eqc_list_slock);
755 list_add_tail(&priv->list, &eqc_list);
756 spin_unlock(&eqc_list_slock);
757
758 return;
759
760 err:
761 /*
762 * We are doomed. The system will not be able to boot.
763 *
764 * Let's still try to be good citizens by freeing resources and print
765 * a last error message that might help debugging.
766 */
767
768 if (priv && priv->cells) {
769 of_clk_del_provider(np);
770
771 for (i = 0; i < early_data->early_pll_count; i++) {
772 const struct eqc_pll *pll = &early_data->early_plls[i];
773 struct clk_hw *hw = priv->cells->hws[pll->index];
774
775 if (!IS_ERR_OR_NULL(hw))
776 clk_hw_unregister_fixed_factor(hw);
777 }
778
779 kfree(priv->cells);
780 }
781
782 kfree(priv);
783
784 pr_err("failed clk init: %d\n", ret);
785 }
786
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki