clk: sprd: Add support for Unisoc SC9832E clocks
Subsystems (3)
cover clk: sprd: Add support for Unisoc SC9832E clocks
This series adds the clock controller support for the Unisoc SC9832E SoC. The SC9832E is a quad-core ARM Cortex-A53 SoC from Unisoc (formerly Spreadtrum), widely used in entry-level smartphones.
This series includes:
1. The device tree bindings in YAML format and its corresponding IDs.
2. The clock driver implementation based on the existing sprd common clock framework.
The driver supports the following clock controllers:
- PMU Gate, PLL, MPLL, DPLL, RPLL
- AP AHB Gate, AON APB Gate, AP APB Gate
- AP Clock, AON Clock
Nadi Ke (2):
dt-bindings: clock: sprd: Add SC9832E clock controller
clk: sprd: Add SC9832E clock driver
.../bindings/clock/sprd,sc9832e-clk.yaml | 129 ++ drivers/clk/sprd/Kconfig | 10 + drivers/clk/sprd/Makefile | 1 + drivers/clk/sprd/sc9832e-clk.c | 1065 +++++++++++++++++ include/dt-bindings/clock/sprd,sc9832e-clk.h | 187 +++ 5 files changed, 1392 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml create mode 100644 drivers/clk/sprd/sc9832e-clk.c create mode 100644 include/dt-bindings/clock/sprd,sc9832e-clk.h
Signature · 1 line
2.34.1
PATCH 1/2 dt-bindings: clock: sprd: Add SC9832E clock controller
Add device tree bindings for the Unisoc SC9832E Clock Control Unit.
--- .../bindings/clock/sprd,sc9832e-clk.yaml | 129 ++++++++++++ include/dt-bindings/clock/sprd,sc9832e-clk.h | 187 ++++++++++++++++++ 2 files changed, 316 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml create mode 100644 include/dt-bindings/clock/sprd,sc9832e-clk.h
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +129 -0
@@ -0,0 +1,129 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright 2026 Nadi Ke <[email protected]> +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/sprd,sc9832e-clk.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Unisoc SC9832E Clock Control Unit + +maintainers: + - Orson Zhai <[email protected]> + - Baolin Wang <[email protected]> + - Chunyan Zhang <[email protected]> + - Nadi Ke <[email protected]> + +properties: + "#clock-cells": + const: 1 + + compatible: + enum: + - sprd,sc9832e-ap-clk + - sprd,sc9832e-aon-clk + - sprd,sc9832e-apahb-gate + - sprd,sc9832e-pmu-gate + - sprd,sc9832e-aonapb-gate + - sprd,sc9832e-apapb-gate + - sprd,sc9832e-pll + - sprd,sc9832e-mpll + - sprd,sc9832e-dpll + - sprd,sc9832e-rpll + + clocks: + minItems: 1 + maxItems: 4 + description: | + The input parent clock(s) phandle for this clock, only list fixed + clocks which are declared in devicetree. + + clock-names: + minItems: 1 + maxItems: 4 + + reg: + maxItems: 1 + +required: + - compatible + - '#clock-cells' + +allOf: + - if: + properties: + compatible: + contains: + const: sprd,sc9832e-ap-clk + then: + required: + - reg + properties: + clocks: + minItems: 2 + maxItems: 2 + clock-names: + items: + - const: ext-26m + - const: ext-1m + + - if: + properties: + compatible: + contains: + const: sprd,sc9832e-pmu-gate + then: + properties: + clocks: + minItems: 1 + maxItems: 1 + clock-names: + items: + - const: ext-26m + + - if: + properties: + compatible: + contains: + const: sprd,sc9832e-aon-clk + then: + required: + - reg + +description: | + Unisoc SC9832E Clock Control Unit. + Other SC9832E clock nodes should be the child of a syscon node with + compatible: "sprd,sc9832e-glbregs", "syscon", "simple-mfd". + The 'reg' property is also required if there is a sub-range of registers. + +additionalProperties: false + +examples: + - | + /* AP Clock Controller */ + ap_clk: clock-controller@21500000 { + compatible = "sprd,sc9832e-ap-clk"; + reg = <0x21500000 0x1000>; + clocks = <&ext_26m>, <&ext_1m>; + clock-names = "ext-26m", "ext-1m"; + #clock-cells = <1>; + }; + + - | + /* PMU Gate Controller inside Syscon */ + syscon@402b0000 { + compatible = "sprd,sc9832e-glbregs", "syscon", "simple-mfd"; + reg = <0x402b0000 0x4000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x402b0000 0x4000>; + + pmu_gate: pmu-gate@0 { + compatible = "sprd,sc9832e-pmu-gate"; + reg = <0x0 0x1000>; + clocks = <&ext_26m>; + clock-names = "ext-26m"; + #clock-cells = <1>; + }; + }; + +...
include/dt-bindings/clock/sprd,sc9832e-clk.h new file +187 -0
187 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v1 1/2] dt-bindings: clock: sprd: Add SC9832E clock controller
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml line 20
Quoted 11 lines · Nadi Ke
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +11
-0+maintainers: + - Orson Zhai <[email protected]> + - Baolin Wang <[email protected]> + - Chunyan Zhang <[email protected]> + - Nadi Ke <[email protected]> + +properties: + "#clock-cells": + const: 1 + + compatible:
Compatible is always first.
Quoted 6 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +6
-0+ enum: + - sprd,sc9832e-ap-clk + - sprd,sc9832e-aon-clk + - sprd,sc9832e-apahb-gate + - sprd,sc9832e-pmu-gate + - sprd,sc9832e-aonapb-gate
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml line 36
Quoted 10 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +10
-0+ - sprd,sc9832e-apapb-gate + - sprd,sc9832e-pll + - sprd,sc9832e-mpll + - sprd,sc9832e-dpll + - sprd,sc9832e-rpll + + clocks: + minItems: 1 + maxItems: 4 + description: |
Do not need '|' unless you need to preserve formatting.
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml line 49
Quoted 13 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +13
-0+ The input parent clock(s) phandle for this clock, only list fixed + clocks which are declared in devicetree. + + clock-names: + minItems: 1 + maxItems: 4 + + reg: + maxItems: 1 + +required: + - compatible + - '#clock-cells'
Why reg is not always required?
Quoted 18 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +18
-0+ +allOf: + - if: + properties: + compatible: + contains: + const: sprd,sc9832e-ap-clk + then: + required: + - reg + properties: + clocks: + minItems: 2 + maxItems: 2 + clock-names: + items: + - const: ext-26m + - const: ext-1m
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml line 77
Quoted 10 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +10
-0+ + - if: + properties: + compatible: + contains: + const: sprd,sc9832e-pmu-gate + then: + properties: + clocks: + minItems: 1
Drop
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml line 66
Quoted 4 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +4
-0+ maxItems: 1 + clock-names: + items: + - const: ext-26m
And the rest? 3-4 clocks? All other devices?
This binding is really poor and messy. Please write constrained binding.
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml line 92
Quoted 11 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +11
-0+ + - if: + properties: + compatible: + contains: + const: sprd,sc9832e-aon-clk + then: + required: + - reg + +description: |
Completely messed placement.
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml line 95
Quoted 3 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +3
-0+ Unisoc SC9832E Clock Control Unit. + Other SC9832E clock nodes should be the child of a syscon node with + compatible: "sprd,sc9832e-glbregs", "syscon", "simple-mfd".
Not relevant. Other schema should define that.
Quoted 8 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +8
-0+ The 'reg' property is also required if there is a sub-range of registers. + +additionalProperties: false + +examples: + - | + /* AP Clock Controller */ + ap_clk: clock-controller@21500000 {
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml line 113
Quoted 10 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +10
-0+ compatible = "sprd,sc9832e-ap-clk"; + reg = <0x21500000 0x1000>; + clocks = <&ext_26m>, <&ext_1m>; + clock-names = "ext-26m", "ext-1m"; + #clock-cells = <1>; + }; + + - | + /* PMU Gate Controller inside Syscon */ + syscon@402b0000 {
Drop entire node, not relevant here.
Quoted 28 lines
Documentation/devicetree/bindings/clock/sprd,sc9832e-clk.yaml new file +16
-0+ compatible = "sprd,sc9832e-glbregs", "syscon", "simple-mfd"; + reg = <0x402b0000 0x4000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x402b0000 0x4000>; + + pmu_gate: pmu-gate@0 { + compatible = "sprd,sc9832e-pmu-gate"; + reg = <0x0 0x1000>; + clocks = <&ext_26m>; + clock-names = "ext-26m"; + #clock-cells = <1>; + }; + }; + +...include/dt-bindings/clock/sprd,sc9832e-clk.h new file +6
-0@@ -0,0 +1,187 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* +* Unisoc SC9832E platform clocks +* +* Copyright (C) 2015 Spreadtrum, Inc. +*/
include/dt-bindings/clock/sprd,sc9832e-clk.h line 16
Quoted 10 lines
include/dt-bindings/clock/sprd,sc9832e-clk.h new file +10
-0+ +#ifndef _DT_BINDINGS_CLK_SC9832E_H_ +#define _DT_BINDINGS_CLK_SC9832E_H_ + +#define CLK_ISPPLL_GATE 0 +#define CLK_MPLL_GATE 1 +#define CLK_DPLL_GATE 2 +#define CLK_LPLL_GATE 3 +#define CLK_GPLL_GATE 4 +#define CLK_PMU_GATE_NUM (CLK_GPLL_GATE + 1)
Drop, not ABI.
Quoted 18 lines
include/dt-bindings/clock/sprd,sc9832e-clk.h new file +18
-0+ +#define CLK_TWPLL 0 +#define CLK_TWPLL_768M 1 +#define CLK_TWPLL_384M 2 +#define CLK_TWPLL_192M 3 +#define CLK_TWPLL_96M 4 +#define CLK_TWPLL_48M 5 +#define CLK_TWPLL_24M 6 +#define CLK_TWPLL_12M 7 +#define CLK_TWPLL_512M 8 +#define CLK_TWPLL_256M 9 +#define CLK_TWPLL_128M 10 +#define CLK_TWPLL_64M 11 +#define CLK_TWPLL_307M2 12 +#define CLK_TWPLL_219M4 13 +#define CLK_TWPLL_170M6 14 +#define CLK_TWPLL_153M6 15 +#define CLK_TWPLL_76M8 16
include/dt-bindings/clock/sprd,sc9832e-clk.h line 44
Quoted 10 lines
include/dt-bindings/clock/sprd,sc9832e-clk.h new file +10
-0+#define CLK_TWPLL_51M2 17 +#define CLK_TWPLL_38M4 18 +#define CLK_TWPLL_19M2 19 +#define CLK_LPLL 20 +#define CLK_LPLL_409M6 21 +#define CLK_LPLL_245M76 22 +#define CLK_GPLL 23 +#define CLK_ISPPLL 24 +#define CLK_ISPPLL_468M 25 +#define CLK_PLL_NUM (CLK_ISPPLL_468M + 1)
Same here and everywhere else.
Best regards,
Krzysztof
PATCH 2/2 clk: sprd: Add SC9832E clock driver
In reply to Nadi KeAdd the clock driver for the Unisoc SC9832E SoC. This driver relies on the common Spreadtrum clock infrastructure.
It supports the following clock controllers:
- PMU Gate
- PLL
- MPLL
- DPLL
- RPLL
- AP AHB Gate
- AON APB Gate
- AP Clock
- AON Clock
- AP APB Gate
--- drivers/clk/sprd/Kconfig | 10 + drivers/clk/sprd/Makefile | 1 + drivers/clk/sprd/sc9832e-clk.c | 1065 ++++++++++++++++++++++++++++++++ 3 files changed, 1076 insertions(+) create mode 100644 drivers/clk/sprd/sc9832e-clk.c
drivers/clk/sprd/Kconfig +10 -0
@@ -8,6 +8,16 @@ config SPRD_COMMON_CLK if SPRD_COMMON_CLK # SoC Drivers +config SPRD_SC9832E_CLK + tristate "Support for the Spreadtrum SC9832E clocks" + depends on (ARM64 && ARCH_SPRD) || COMPILE_TEST + default ARM64 && ARCH_SPRD + help + This enables the clock control unit for Unisoc SC9832E SoCs. + The driver provides support for various clock controllers including + AP, AON, and peripheral gate clocks. + Say Y if you want to use the Spreadtrum SC9832E SoC platform. + If unsure, say N. config SPRD_SC9860_CLK tristate "Support for the Spreadtrum SC9860 clocks"
drivers/clk/sprd/Makefile +1 -0
@@ -9,6 +9,7 @@ clk-sprd-y += composite.o clk-sprd-y += pll.o ## SoC support +obj-$(CONFIG_SPRD_SC9832E_CLK) += sc9832e-clk.o obj-$(CONFIG_SPRD_SC9860_CLK) += sc9860-clk.o obj-$(CONFIG_SPRD_SC9863A_CLK) += sc9863a-clk.o obj-$(CONFIG_SPRD_UMS512_CLK) += ums512-clk.o
drivers/clk/sprd/sc9832e-clk.c new file +1065 -0
1,065 lines not on this page · raw message
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v1 2/2] clk: sprd: Add SC9832E clock driver
kernel test robot noticed the following build errors:
Hi Nadi,
kernel test robot noticed the following build errors:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on linus/master v6.19-rc6 next-20260120] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nadi-Ke/dt-bindings-clock-sprd-Add-SC9832E-clock-controller/20260121-001334 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20260120144436.233998-3-kanadenady%40gmail.com patch subject: [PATCH v1 2/2] clk: sprd: Add SC9832E clock driver config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20260121/[email protected]/config) compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260121/[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 >>):
>> drivers/clk/sprd/sc9832e-clk.c:1041:24: error: use of undeclared identifier 'sc9832e_clk_ids'
1041 | match = of_match_node(sc9832e_clk_ids, pdev->dev.of_node);
| ^
drivers/clk/sprd/sc9832e-clk.c:1058:21: error: use of undeclared identifier 'sc9832e_clk_ids'; did you mean 'sc9832e_pll_hws'?
1058 | .of_match_table = sc9832e_clk_ids,
| ^~~~~~~~~~~~~~~
| sc9832e_pll_hws
drivers/clk/sprd/sc9832e-clk.c:162:35: note: 'sc9832e_pll_hws' declared here
162 | static struct clk_hw_onecell_data sc9832e_pll_hws = {
| ^
>> drivers/clk/sprd/sc9832e-clk.c:1058:21: error: initializing 'const struct of_device_id *' with an expression of incompatible type 'struct clk_hw_onecell_data'
1058 | .of_match_table = sc9832e_clk_ids,
| ^~~~~~~~~~~~~~~3 errors generated.
vim +/sc9832e_clk_ids +1041 drivers/clk/sprd/sc9832e-clk.c
1034
1035 static int sc9832e_clk_probe(struct platform_device *pdev)
1036 {
1037 const struct of_device_id *match;
1038 const struct sprd_clk_desc *desc;
1039 int ret;
1040
> 1041 match = of_match_node(sc9832e_clk_ids, pdev->dev.of_node);
1042 if (!match)
1043 return -ENODEV;
1044
1045 desc = match->data;
1046
1047 ret = sprd_clk_regmap_init(pdev, desc);
1048 if (ret)
1049 return ret;
1050
1051 return sprd_clk_probe(&pdev->dev, desc->hw_clks);
1052 }
1053
1054 static struct platform_driver sc9832e_clk_driver = {
1055 .probe = sc9832e_clk_probe,
1056 .driver = {
1057 .name = "sc9832e-clk",
> 1058 .of_match_table = sc9832e_clk_ids, 1059 },
1060 };
1061
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v1 2/2] clk: sprd: Add SC9832E clock driver
In reply to Nadi Kekernel test robot noticed the following build errors:
Hi Nadi,
kernel test robot noticed the following build errors:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on linus/master v6.19-rc6 next-20260120] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nadi-Ke/dt-bindings-clock-sprd-Add-SC9832E-clock-controller/20260121-001334 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20260120144436.233998-3-kanadenady%40gmail.com patch subject: [PATCH v1 2/2] clk: sprd: Add SC9832E clock driver config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20260121/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260121/[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 >>):
drivers/clk/sprd/sc9832e-clk.c:1041:24: error: use of undeclared identifier 'sc9832e_clk_ids'; did you mean 'sc9832e_pll_hws'?
1041 | match = of_match_node(sc9832e_clk_ids, pdev->dev.of_node);
| ^~~~~~~~~~~~~~~
| sc9832e_pll_hws
drivers/clk/sprd/sc9832e-clk.c:162:35: note: 'sc9832e_pll_hws' declared here
162 | static struct clk_hw_onecell_data sc9832e_pll_hws = {
| ^
>> drivers/clk/sprd/sc9832e-clk.c:1041:24: error: passing 'struct clk_hw_onecell_data' to parameter of incompatible type 'const struct of_device_id *'
1041 | match = of_match_node(sc9832e_clk_ids, pdev->dev.of_node);
| ^~~~~~~~~~~~~~~
include/linux/of.h:379:29: note: passing argument to parameter 'matches' here
379 | const struct of_device_id *matches, const struct device_node *node);
| ^
drivers/clk/sprd/sc9832e-clk.c:1058:21: error: use of undeclared identifier 'sc9832e_clk_ids'; did you mean 'sc9832e_pll_hws'?
1058 | .of_match_table = sc9832e_clk_ids,
| ^~~~~~~~~~~~~~~
| sc9832e_pll_hws
drivers/clk/sprd/sc9832e-clk.c:162:35: note: 'sc9832e_pll_hws' declared here
162 | static struct clk_hw_onecell_data sc9832e_pll_hws = {
| ^
drivers/clk/sprd/sc9832e-clk.c:1058:21: error: initializing 'const struct of_device_id *' with an expression of incompatible type 'struct clk_hw_onecell_data'
1058 | .of_match_table = sc9832e_clk_ids,
| ^~~~~~~~~~~~~~~4 errors generated.
vim +1041 drivers/clk/sprd/sc9832e-clk.c
1034
1035 static int sc9832e_clk_probe(struct platform_device *pdev)
1036 {
1037 const struct of_device_id *match;
1038 const struct sprd_clk_desc *desc;
1039 int ret;
1040
> 1041 match = of_match_node(sc9832e_clk_ids, pdev->dev.of_node);
1042 if (!match)
1043 return -ENODEV;
1044
1045 desc = match->data;
1046
1047 ret = sprd_clk_regmap_init(pdev, desc);
1048 if (ret)
1049 return ret;
1050
1051 return sprd_clk_probe(&pdev->dev, desc->hw_clks);
1052 }
1053
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki