Nuvoton WPCM450 clock and reset driver
Subsystems (5)
Jonathan Neuschäfer
maintainerv9 cover Nuvoton WPCM450 clock and reset driver
This series adds support for the clock and reset controller in the Nuvoton WPCM450 SoC. This means that the clock rates for peripherals will be calculated automatically based on the clock tree as it was preconfigured by the bootloader. The 24 MHz dummy clock, that is currently in the devicetree, is no longer needed. Somewhat unfortunately, this also means that there is a breaking change once the devicetree starts relying on the clock driver, but I find it acceptable in this case, because WPCM450 is still at a somewhat early stage.
v9:
- Various improvements to the driver
- No longer use global clock names (and the clock-output-names property) to refer to the reference clock, but instead rely on a phandle reference
v8:
- https://lore.kernel.org/lkml/[email protected]/
- Use %pe throughout the driver
v7:
- Simplified the error handling, by largely removing resource deallocation, which:
- was already incomplete
- would only happen in a case when the system is in pretty bad state because the clock driver didn't initialize correctly (in other words, the clock driver isn't optional enough that complex error handling really pays off)
v6:
- Dropped all patches except the clock binding and the clock driver, because they have mostly been merged
- Minor correction to how RESET_SIMPLE is selected
v5:
- Dropped patch 2 (watchdog: npcm: Enable clock if provided), which was since merged upstream
- Added patch 2 (clocksource: timer-npcm7xx: Enable timer 1 clock before use) again, because I wasn't able to find it in linux-next
- Switched the driver to using struct clk_parent_data
- Rebased on 6.1-rc3
v4:
- Leave WDT clock running during after restart handler
- Fix reset controller initialization
- Dropped patch 2/7 (clocksource: timer-npcm7xx: Enable timer 1 clock before use), as it was applied by Daniel Lezcano
v3:
- https://lore.kernel.org/lkml/[email protected]/
- Changed "refclk" string to "ref"
- Fixed some dead code in the driver
- Added clk_prepare_enable call to the watchdog restart handler
- Added a few review tags
v2:
- https://lore.kernel.org/lkml/[email protected]/
- various small improvements
v1:
- https://lore.kernel.org/lkml/[email protected]/
Jonathan Neuschäfer (3):
dt-bindings: clock: Add Nuvoton WPCM450 clock/reset controller
ARM: dts: wpcm450: Remove clock-output-names from reference clock node
clk: wpcm450: Add Nuvoton WPCM450 clock/reset controller driver
.../bindings/clock/nuvoton,wpcm450-clk.yaml | 65 +++ .../arm/boot/dts/nuvoton/nuvoton-wpcm450.dtsi | 1 - drivers/clk/Makefile | 2 +- drivers/clk/nuvoton/Kconfig | 8 +- drivers/clk/nuvoton/Makefile | 1 + drivers/clk/nuvoton/clk-wpcm450.c | 372 ++++++++++++++++++ drivers/reset/Kconfig | 2 +- .../dt-bindings/clock/nuvoton,wpcm450-clk.h | 67 ++++ 8 files changed, 514 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/nuvoton,wpcm450-clk.yaml create mode 100644 drivers/clk/nuvoton/clk-wpcm450.c create mode 100644 include/dt-bindings/clock/nuvoton,wpcm450-clk.h
--
2.40.1
Jonathan Neuschäfer
maintainerPATCH v9 1/3 dt-bindings: clock: Add Nuvoton WPCM450 clock/reset controller
The Nuvoton WPCM450 SoC has a combined clock and reset controller. Add a devicetree binding for it, as well as definitions for the bit numbers used by it.
---
v9:
- Remove clock-output-names in example, because it's now unnecessary due to driver improvements
v5-v8:
- no changes
v4:
- https://lore.kernel.org/lkml/[email protected]/
- Add R-b tag
v3:
- Change clock-output-names and clock-names from "refclk" to "ref", suggested by Krzysztof Kozlowski
v2:
- https://lore.kernel.org/lkml/[email protected]/
- Various improvements, suggested by Krzysztof Kozlowski
v1:
- https://lore.kernel.org/lkml/[email protected]/
--- .../bindings/clock/nuvoton,wpcm450-clk.yaml | 65 ++++++++++++++++++ .../dt-bindings/clock/nuvoton,wpcm450-clk.h | 67 +++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/nuvoton,wpcm450-clk.yaml create mode 100644 include/dt-bindings/clock/nuvoton,wpcm450-clk.h
Documentation/devicetree/bindings/clock/nuvoton,wpcm450-clk.yaml new file +65 -0
@@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/nuvoton,wpcm450-clk.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton WPCM450 clock controller + +maintainers: + - Jonathan Neuschäfer <[email protected]> + +description: + The clock controller of the Nuvoton WPCM450 SoC supplies clocks and resets to + the rest of the chip. + +properties: + compatible: + const: nuvoton,wpcm450-clk + + reg: + maxItems: 1 + + clocks: + items: + - description: Reference clock oscillator (should be 48 MHz) + + clock-names: + items: + - const: ref + + '#clock-cells': + const: 1 + + '#reset-cells': + const: 1 + +additionalProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + - '#clock-cells' + +examples: + - | + #include <dt-bindings/clock/nuvoton,wpcm450-clk.h> + #include <dt-bindings/interrupt-controller/irq.h> + + refclk: clock-48mhz { + /* 48 MHz reference oscillator */ + compatible = "fixed-clock"; + clock-frequency = <48000000>; + #clock-cells = <0>; + }; + + clk: clock-controller@b0000200 { + reg = <0xb0000200 0x100>; + compatible = "nuvoton,wpcm450-clk"; + clocks = <&refclk>; + clock-names = "ref"; + #clock-cells = <1>; + #reset-cells = <1>; + };
include/dt-bindings/clock/nuvoton,wpcm450-clk.h new file +67 -0
67 lines not on this page · raw message
--
2.40.1
Jonathan Neuschäfer
maintainerPATCH v9 2/3 ARM: dts: wpcm450: Remove clock-output-names from reference clock node
In reply to Jonathan NeuschäferThis is not necessary anymore, because the clk-wpcm450 driver doesn't rely on global clock names anymore.
---
v9:
- New patch
--- arch/arm/boot/dts/nuvoton/nuvoton-wpcm450.dtsi | 1 - 1 file changed, 1 deletion(-)
arch/arm/boot/dts/nuvoton/nuvoton-wpcm450.dtsi +0 -1
@@ -40,7 +40,6 @@ clk24m: clock-24mhz { refclk: clock-48mhz { /* 48 MHz reference oscillator */ compatible = "fixed-clock"; - clock-output-names = "ref"; clock-frequency = <48000000>; #clock-cells = <0>; };
--
2.40.1
Jonathan Neuschäfer
maintainerPATCH v9 3/3 clk: wpcm450: Add Nuvoton WPCM450 clock/reset controller driver
In reply to Jonathan NeuschäferThis driver implements the following features w.r.t. the clock and reset controller in the WPCM450 SoC:
- It calculates the rates for all clocks managed by the clock controller
- It leaves the clock tree mostly unchanged, except that it enables/ disables clock gates based on usage.
- It exposes the reset lines managed by the controller using the Generic Reset Controller subsystem
NOTE: If the driver and the corresponding devicetree node are present,
the driver will disable "unused" clocks. This is problem until the clock relations are properly declared in the devicetree (in a later patch). Until then, the clk_ignore_unused kernel parameter can be used as a workaround.
---
I have considered converting this driver to a platform driver instead of using CLK_OF_DECLARE, because platform drivers are generally the way forward. However, the timer-npcm7xx driver used on the same platform requires is initialized with TIMER_OF_DECLARE and thus requires the clocks to be available earlier than a platform driver can provide them.
v9:
- Apply comments made by Stephen Boyd
- Move to drivers/clk/nuvoton/ directory
- Update SPDX license identifier from GPL-2.0 to GPL-2.0-only
- Rename clk_np variable to np
- Use of_clk_hw_register
- Refer to clock parents by .fw_name
v8:
- https://lore.kernel.org/lkml/[email protected]/
- Use %pe format specifier throughout the driver, as suggested by Philipp Zabel
- Add Joel's R-b
v7:
- https://lore.kernel.org/lkml/[email protected]/
- Simplify error handling by not deallocating resources
v6:
- Enable RESET_SIMPLE based on ARCH_WPCM450, not ARCH_NPCM, as suggested by Tomer Maimon
v5:
- https://lore.kernel.org/lkml/[email protected]/
- Switch to using clk_parent_data
v4:
- Fix reset controller initialization
v3:
- Change reference clock name from "refclk" to "ref"
- Remove unused variable in return path of wpcm450_clk_register_pll
- Remove unused divisor tables
v2:
- no changes
--- drivers/clk/Makefile | 2 +- drivers/clk/nuvoton/Kconfig | 8 +- drivers/clk/nuvoton/Makefile | 1 + drivers/clk/nuvoton/clk-wpcm450.c | 372 ++++++++++++++++++++++++++++++ drivers/reset/Kconfig | 2 +- 5 files changed, 382 insertions(+), 3 deletions(-) create mode 100644 drivers/clk/nuvoton/clk-wpcm450.c
drivers/clk/Makefile +1 -1
@@ -106,7 +106,7 @@ endif obj-y += mstar/ obj-y += mvebu/ obj-$(CONFIG_ARCH_MXS) += mxs/ -obj-$(CONFIG_ARCH_MA35) += nuvoton/ +obj-y += nuvoton/ obj-$(CONFIG_COMMON_CLK_NXP) += nxp/ obj-$(CONFIG_COMMON_CLK_PISTACHIO) += pistachio/ obj-$(CONFIG_COMMON_CLK_PXA) += pxa/
drivers/clk/nuvoton/Kconfig +7 -1
@@ -3,7 +3,7 @@ config COMMON_CLK_NUVOTON bool "Nuvoton clock controller common support" - depends on ARCH_MA35 || COMPILE_TEST + depends on ARCH_MA35 || ARCH_NPCM || COMPILE_TEST default y help Say y here to enable common clock controller for Nuvoton platforms.
@@ -16,4 +16,10 @@ config CLK_MA35D1 help Build the clock controller driver for MA35D1 SoC. +config CLK_WPCM450 + bool "Nuvoton WPCM450 clock/reset controller support" + default y + help + Build the clock and reset controller driver for the WPCM450 SoC. + endif
drivers/clk/nuvoton/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_CLK_MA35D1) += clk-ma35d1.o obj-$(CONFIG_CLK_MA35D1) += clk-ma35d1-divider.o obj-$(CONFIG_CLK_MA35D1) += clk-ma35d1-pll.o +obj-$(CONFIG_CLK_WPCM450) += clk-wpcm450.o
drivers/clk/nuvoton/clk-wpcm450.c new file +372 -0
372 lines not on this page · raw message
drivers/reset/Kconfig +1 -1
@@ -213,7 +213,7 @@ config RESET_SCMI config RESET_SIMPLE bool "Simple Reset Controller Driver" if COMPILE_TEST || EXPERT - default ARCH_ASPEED || ARCH_BCMBCA || ARCH_BITMAIN || ARCH_REALTEK || ARCH_STM32 || (ARCH_INTEL_SOCFPGA && ARM64) || ARCH_SUNXI || ARC + default ARCH_ASPEED || ARCH_BCMBCA || ARCH_BITMAIN || ARCH_REALTEK || ARCH_STM32 || (ARCH_INTEL_SOCFPGA && ARM64) || ARCH_SUNXI || ARC || ARCH_WPCM450 depends on HAS_IOMEM help This enables a simple reset controller driver for reset lines that
--
2.40.1
kernel test robot
build botRe: [PATCH v9 3/3] clk: wpcm450: Add Nuvoton WPCM450 clock/reset controller driver
kernel test robot noticed the following build errors:
Hi Jonathan,
kernel test robot noticed the following build errors:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on robh/for-next pza/reset/next linus/master v6.6-rc2 next-20230921] [cannot apply to pza/imx-drm/next]
[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/Jonathan-Neusch-fer/dt-bindings-clock-Add-Nuvoton-WPCM450-clock-reset-controller/20230923-223751 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20230923143438.1895461-4-j.neuschaefer%40gmx.net patch subject: [PATCH v9 3/3] clk: wpcm450: Add Nuvoton WPCM450 clock/reset controller driver config: loongarch-randconfig-002-20230924 (https://download.01.org/0day-ci/archive/20230924/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230924/[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 >>):
loongarch64-linux-ld: drivers/clk/nuvoton/clk-wpcm450.o: in function `.L40':
>> clk-wpcm450.c:(.init.text+0x508): undefined reference to `reset_simple_ops' >> loongarch64-linux-ld: clk-wpcm450.c:(.init.text+0x50c): undefined reference to `reset_simple_ops'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v9 3/3] clk: wpcm450: Add Nuvoton WPCM450 clock/reset controller driver
In reply to Jonathan Neuschäferkernel test robot noticed the following build errors:
Hi Jonathan,
kernel test robot noticed the following build errors:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on robh/for-next pza/reset/next linus/master v6.6-rc2 next-20230921] [cannot apply to pza/imx-drm/next]
[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/Jonathan-Neusch-fer/dt-bindings-clock-Add-Nuvoton-WPCM450-clock-reset-controller/20230923-223751 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/20230923143438.1895461-4-j.neuschaefer%40gmx.net patch subject: [PATCH v9 3/3] clk: wpcm450: Add Nuvoton WPCM450 clock/reset controller driver config: nios2-randconfig-002-20230924 (https://download.01.org/0day-ci/archive/20230924/[email protected]/config) compiler: nios2-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230924/[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 >>):
nios2-linux-ld: drivers/clk/nuvoton/clk-wpcm450.o: in function `wpcm450_clk_init':
clk-wpcm450.c:(.init.text+0x384): undefined reference to `reset_simple_ops'
>> nios2-linux-ld: clk-wpcm450.c:(.init.text+0x388): undefined reference to `reset_simple_ops'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
J. Neuschäfer
maintainerRe: [PATCH v9 3/3] clk: wpcm450: Add Nuvoton WPCM450 clock/reset controller driver
In reply to Jonathan NeuschäferQuoted 18 lines · Jonathan Neuschäfer
This driver implements the following features w.r.t. the clock and reset controller in the WPCM450 SoC:
- It calculates the rates for all clocks managed by the clock controller
- It leaves the clock tree mostly unchanged, except that it enables/ disables clock gates based on usage.
- It exposes the reset lines managed by the controller using the Generic Reset Controller subsystemNOTE: If the driver and the corresponding devicetree node are present,
the driver will disable "unused" clocks. This is problem until the clock relations are properly declared in the devicetree (in a later patch). Until then, theclk_ignore_unusedkernel parameter can be used as a workaround.Signed-off-by Jonathan Neuschäfer <[email protected]>Reviewed-by Joel Stanley <[email protected]>---
[...]
Quoted 6 lines
drivers/clk/nuvoton/Kconfig +6
-0+config CLK_WPCM450 + bool "Nuvoton WPCM450 clock/reset controller support" + default y + help + Build the clock and reset controller driver for the WPCM450 SoC. +
[...]
drivers/reset/Kconfig config RESET_SCMI · line 216
Quoted 4 lines
config
RESET_SIMPLEdrivers/reset/Kconfig +1
-1bool "Simple Reset Controller Driver" if COMPILE_TEST || EXPERT - default ARCH_ASPEED || ARCH_BCMBCA || ARCH_BITMAIN || ARCH_REALTEK || ARCH_STM32 || (ARCH_INTEL_SOCFPGA && ARM64) || ARCH_SUNXI || ARC + default ARCH_ASPEED || ARCH_BCMBCA || ARCH_BITMAIN || ARCH_REALTEK || ARCH_STM32 || (ARCH_INTEL_SOCFPGA && ARM64) || ARCH_SUNXI || ARC || ARCH_WPCM450
Considering the build bot failures and the fragility of adding tons of platforms to this "default" line, I think I'll just select RESET_CONTROLLER and RESET_SIMPLE from CLK_WPCM450.
Jonathan