Skip to contentSkip to conversation

clk: nuvoton: Add clock driver for ma35d1 clock controller

PATCH In review Jacky Huang 2 participants 3 messages Jun 19, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v15 2/2 clk: nuvoton: Add clock driver for ma35d1 clock controller

From: Jacky Huang <[email protected]>

The clock controller generates clocks for the whole chip, including system clocks and all peripheral clocks. This driver support ma35d1 clock gating, divider, and individual PLL configuration.

There are 6 PLLs in ma35d1 SoC:
- CA-PLL for the two Cortex-A35 CPU clock
- SYS-PLL for system bus, which comes from the companion MCU and cannot be programmed by clock controller.
- DDR-PLL for DDR
- EPLL for GMAC and GFX, Display, and VDEC IPs.
- VPLL for video output pixel clock
- APLL for SDHC, I2S audio, and other IPs.
CA-PLL has only one operation mode.
DDR-PLL, EPLL, VPLL, and APLL are advanced PLLs which have 3 operation modes: integer mode, fraction mode, and spread specturm mode.

---
 drivers/clk/Kconfig                      |    1 +
 drivers/clk/Makefile                     |    1 +
 drivers/clk/nuvoton/Kconfig              |   19 +
 drivers/clk/nuvoton/Makefile             |    4 +
 drivers/clk/nuvoton/clk-ma35d1-divider.c |  132 +++
 drivers/clk/nuvoton/clk-ma35d1-pll.c     |  360 ++++++++
 drivers/clk/nuvoton/clk-ma35d1.c         | 1046 ++++++++++++++++++++++
 drivers/clk/nuvoton/clk-ma35d1.h         |   18 +
 8 files changed, 1581 insertions(+)
 create mode 100644 drivers/clk/nuvoton/Kconfig
 create mode 100644 drivers/clk/nuvoton/Makefile
 create mode 100644 drivers/clk/nuvoton/clk-ma35d1-divider.c
 create mode 100644 drivers/clk/nuvoton/clk-ma35d1-pll.c
 create mode 100644 drivers/clk/nuvoton/clk-ma35d1.c
 create mode 100644 drivers/clk/nuvoton/clk-ma35d1.h
drivers/clk/Kconfig +1 -0
index 016814e15536..db789055e0fd 100644
@@ -478,6 +478,7 @@ source "drivers/clk/meson/Kconfig"
 source "drivers/clk/mstar/Kconfig"
 source "drivers/clk/microchip/Kconfig"
 source "drivers/clk/mvebu/Kconfig"
+source "drivers/clk/nuvoton/Kconfig"
 source "drivers/clk/pistachio/Kconfig"
 source "drivers/clk/qcom/Kconfig"
 source "drivers/clk/ralink/Kconfig"
drivers/clk/Makefile +1 -0
index 0aebef17edc6..7cb000549b61 100644
@@ -106,6 +106,7 @@ endif
 obj-y					+= mstar/
 obj-y					+= mvebu/
 obj-$(CONFIG_ARCH_MXS)			+= mxs/
+obj-$(CONFIG_ARCH_MA35)			+= nuvoton/
 obj-$(CONFIG_COMMON_CLK_NXP)		+= nxp/
 obj-$(CONFIG_COMMON_CLK_PISTACHIO)	+= pistachio/
 obj-$(CONFIG_COMMON_CLK_PXA)		+= pxa/
drivers/clk/nuvoton/Kconfig new file +19 -0
new file mode 100644
index 000000000000..fe4b7f62f467
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0
+# common clock support for Nuvoton SoC family.
+
+config COMMON_CLK_NUVOTON
+	bool "Nuvoton clock controller common support"
+	depends on ARCH_MA35 || COMPILE_TEST
+	default y
+	help
+	  Say y here to enable common clock controller for Nuvoton platforms.
+
+if COMMON_CLK_NUVOTON
+
+config CLK_MA35D1
+	bool "Nuvoton MA35D1 clock controller support"
+	default y
+	help
+	  Build the clock controller driver for MA35D1 SoC.
+
+endif
drivers/clk/nuvoton/Makefile new file +4 -0
new file mode 100644
index 000000000000..c3c59dd9f2aa
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_CLK_MA35D1) += clk-ma35d1.o
+obj-$(CONFIG_CLK_MA35D1) += clk-ma35d1-divider.o
+obj-$(CONFIG_CLK_MA35D1) += clk-ma35d1-pll.o
drivers/clk/nuvoton/clk-ma35d1-divider.c new file +132 -0

132 lines not on this page · raw message

drivers/clk/nuvoton/clk-ma35d1-pll.c new file +360 -0

360 lines not on this page · raw message

drivers/clk/nuvoton/clk-ma35d1.c new file +1046 -0

1,046 lines not on this page · raw message

drivers/clk/nuvoton/clk-ma35d1.h new file +18 -0
new file mode 100644
index 000000000000..3adee440f60a
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2023 Nuvoton Technology Corp.
+ * Author: Chi-Fang Li <[email protected]>
+ */
+
+#ifndef __DRV_CLK_NUVOTON_MA35D1_H
+#define __DRV_CLK_NUVOTON_MA35D1_H
+
+struct clk_hw *ma35d1_reg_clk_pll(struct device *dev, u32 id, u8 u8mode, const char *name,
+				  struct clk_hw *parent_hw, void __iomem *base);
+
+struct clk_hw *ma35d1_reg_adc_clkdiv(struct device *dev, const char *name,
+				     struct clk_hw *parent_hw, spinlock_t *lock,
+				     unsigned long flags, void __iomem *reg,
+				     u8 shift, u8 width, u32 mask_bit);
+
+#endif /* __DRV_CLK_NUVOTON_MA35D1_H */
Signature · 1 line
2.34.1
#1 lore raw
Quoted 18 lines · Jacky Huang

From: Jacky Huang <[email protected]>

The clock controller generates clocks for the whole chip, including system clocks and all peripheral clocks. This driver support ma35d1 clock gating, divider, and individual PLL configuration.

There are 6 PLLs in ma35d1 SoC:
- CA-PLL for the two Cortex-A35 CPU clock
- SYS-PLL for system bus, which comes from the companion MCU and cannot be programmed by clock controller.
- DDR-PLL for DDR
- EPLL for GMAC and GFX, Display, and VDEC IPs.
- VPLL for video output pixel clock
- APLL for SDHC, I2S audio, and other IPs.
CA-PLL has only one operation mode.
DDR-PLL, EPLL, VPLL, and APLL are advanced PLLs which have 3 operation modes: integer mode, fraction mode, and spread specturm mode.

Quoted 2 lines

Hi Jacky,

Since I have already picked up the previous version of this patch, please send a diff against the version I merged please.

Arnd

#2 lore raw
Quoted 19 lines · Arnd Bergmann
Quoted 18 lines · Jacky Huang

From: Jacky Huang <[email protected]>

The clock controller generates clocks for the whole chip, including system clocks and all peripheral clocks. This driver support ma35d1 clock gating, divider, and individual PLL configuration.

There are 6 PLLs in ma35d1 SoC:
- CA-PLL for the two Cortex-A35 CPU clock
- SYS-PLL for system bus, which comes from the companion MCU and cannot be programmed by clock controller.
- DDR-PLL for DDR
- EPLL for GMAC and GFX, Display, and VDEC IPs.
- VPLL for video output pixel clock
- APLL for SDHC, I2S audio, and other IPs.
CA-PLL has only one operation mode.
DDR-PLL, EPLL, VPLL, and APLL are advanced PLLs which have 3 operation modes: integer mode, fraction mode, and spread specturm mode.

Quoted 8 lines
Quoted 2 lines

Hi Jacky,

Since I have already picked up the previous version of this patch, please send a diff against the version I merged please.

Arnd

Dear Arnd,

I got it. Thank you.
I will send a diff version based on the previous patch.

Best regards,
Jacky Huang