Skip to contentSkip to conversation

Clk drivers for NXP LPC18xx family

PATCH Superseded Joachim Eastwood 3 participants 13 messages Apr 27, 2015 – May 21, 2015

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Clk drivers for NXP LPC18xx family

This patch set adds support for the two main clock peripherals in the LPC18xx/43xx MCU family.

The Clock Generation Unit (CGU) is the base source of all clocks. It has five external inputs and contains PLLs, dividers and muxes. The outputs from the CGU are then routed to a Clock Control Unit (CCU) and a few peripherals directly. There are two CCUs in the MCU. The CCU is a collection of gates and a few dividers that sits between the CGU and most of the peripherals.

Which clocks that are available depends on the specific device and it's peripherals. It's possible in DT to setup the routing between the CGU and the CCUs.

Changes since v1:
- reorganize cgu clk structs
- macros to create cgu clk structs
- move drivers to nxp subdir
- rebase on v4.1-rc1

Since there were no comments on v1. I hope that these drivers can make it to Linux 4.1.

There are no dependencies in this patch set. The DTS changes will be sent separately to arm-soc once this patch set goes upstream.

See the base support patch set for LPC18xx here:
http://marc.info/?l=linux-arm-kernel&m=143016894704253&w=2

Joachim Eastwood (4):
clk: add lpc18xx cgu clk driver
doc: dt: add documentation for lpc1850-cgu clk driver
clk: add lpc18xx ccu clk driver
doc: dt: add documentation for lpc1850-ccu clk driver

 .../devicetree/bindings/clock/lpc1850-ccu.txt      | 146 +++++
 .../devicetree/bindings/clock/lpc1850-cgu.txt      | 138 +++++
 drivers/clk/Makefile                               |   1 +
 drivers/clk/nxp/Makefile                           |   2 +
 drivers/clk/nxp/clk-lpc18xx-ccu.c                  | 318 +++++++++++
 drivers/clk/nxp/clk-lpc18xx-cgu.c                  | 628 +++++++++++++++++++++
 include/dt-bindings/clock/lpc18xx-ccu.h            |  74 +++
 include/dt-bindings/clock/lpc18xx-cgu.h            |  41 ++
 8 files changed, 1348 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-ccu.txt
 create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-cgu.txt
 create mode 100644 drivers/clk/nxp/Makefile
 create mode 100644 drivers/clk/nxp/clk-lpc18xx-ccu.c
 create mode 100644 drivers/clk/nxp/clk-lpc18xx-cgu.c
 create mode 100644 include/dt-bindings/clock/lpc18xx-ccu.h
 create mode 100644 include/dt-bindings/clock/lpc18xx-cgu.h
Signature · 1 line
1.8.0
#1 lore raw

PATCH v2 1/4 clk: add lpc18xx cgu clk driver

Add driver for NXP LPC18xx/43xx Clock Generation Unit (CGU). The CGU contains several clock generators and output stages that route the clocks either directly to peripherals or to a Clock Control Unit (CCU).

---
 drivers/clk/Makefile                    |   1 +
 drivers/clk/nxp/Makefile                |   1 +
 drivers/clk/nxp/clk-lpc18xx-cgu.c       | 628 ++++++++++++++++++++++++++++++++
 include/dt-bindings/clock/lpc18xx-cgu.h |  41 +++
 4 files changed, 671 insertions(+)
 create mode 100644 drivers/clk/nxp/Makefile
 create mode 100644 drivers/clk/nxp/clk-lpc18xx-cgu.c
 create mode 100644 include/dt-bindings/clock/lpc18xx-cgu.h
drivers/clk/Makefile +1 -0
index 3d00c25382c5..4a34419c1da1 100644
@@ -56,6 +56,7 @@ obj-$(CONFIG_ARCH_MMP)			+= mmp/
 endif
 obj-$(CONFIG_PLAT_ORION)		+= mvebu/
 obj-$(CONFIG_ARCH_MXS)			+= mxs/
+obj-$(CONFIG_ARCH_LPC18XX)		+= nxp/
 obj-$(CONFIG_MACH_PISTACHIO)		+= pistachio/
 obj-$(CONFIG_COMMON_CLK_PXA)		+= pxa/
 obj-$(CONFIG_COMMON_CLK_QCOM)		+= qcom/
drivers/clk/nxp/Makefile new file +1 -0
new file mode 100644
index 000000000000..aca9d3e4f7fe
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_LPC18XX)	+= clk-lpc18xx-cgu.o
drivers/clk/nxp/clk-lpc18xx-cgu.c new file +628 -0

628 lines not on this page · raw message

include/dt-bindings/clock/lpc18xx-cgu.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
1.8.0
#2 lore raw

PATCH v2 2/4 doc: dt: add documentation for lpc1850-cgu clk driver

In reply to Joachim Eastwood

Add DT binding documentation for lpc1850-cgu driver.

---
 .../devicetree/bindings/clock/lpc1850-cgu.txt      | 138 +++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-cgu.txt
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +138 -0
new file mode 100644
index 000000000000..0b278ca6aee7
@@ -0,0 +1,138 @@
+* NXP LPC1850 Clock Generation Unit (CGU)
+
+The CGU generates multiple independent clocks for the core and the
+peripheral blocks of the LPC18xx. Each independent clock is called
+a base clock and itself is one of the inputs to the two Clock
+Control Units (CCUs) which control the branch clocks to the
+individual peripherals.
+
+The CGU selects the inputs to the clock generators from multiple
+clock sources, controls the clock generation, and routes the outputs
+of the clock generators through the clock source bus to the output
+stages. Each output stage provides an independent clock source and
+corresponds to one of the base clocks for the LPC18xx.
+
+ - Above text taken from NXP LPC1850 User Manual.
+
+
+This binding uses the common clock binding:
+    Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible:
+	Should be "nxp,lpc1850-cgu"
+- reg:
+	Shall define the base and range of the address space
+	containing clock control registers
+- #clock-cells:
+	Shall have value <1>.  The permitted clock-specifier values
+	are the base clock numbers defined below.
+- clocks:
+	Shall contain a list of phandles for the external input
+	sources to the CGU. The list shall be in the following
+	order: xtal, 32khz, enet_rx_clk, enet_tx_clk, gp_clkin.
+- clock-indices:
+	Shall be an ordered list of numbers defining the base clock
+	number provided by the CGU.
+- clock-output-names:
+	Shall be an ordered list of strings defining the names of
+	the clocks provided by the CGU.
+
+Which base clocks that are available on the CGU depends on the
+specific LPC part. Base cloks are numbered from 0 to 27.
+
+Number:		Name:			Description:
+ 0		BASE_SAFE_CLK		Base safe clock (always on) for WWDT
+ 1		BASE_USB0_CLK		Base clock for USB0
+ 2		BASE_PERIPH_CLK		Base clock for Cortex-M0SUB subsystem,
+					SPI, and SGPIO
+ 3		BASE_USB1_CLK		Base clock for USB1
+ 4		BASE_CPU_CLK		System base clock for ARM Cortex-M core
+					and APB peripheral blocks #0 and #2
+ 5		BASE_SPIFI_CLK		Base clock for SPIFI
+ 6		BASE_SPI_CLK		Base clock for SPI
+ 7		BASE_PHY_RX_CLK		Base clock for Ethernet PHY Receive clock
+ 8		BASE_PHY_TX_CLK		Base clock for Ethernet PHY Transmit clock
+ 9		BASE_APB1_CLK		Base clock for APB peripheral block # 1
+10		BASE_APB3_CLK		Base clock for APB peripheral block # 3
+11		BASE_LCD_CLK		Base clock for LCD
+12		BASE_ADCHS_CLK		Base clock for ADCHS
+13		BASE_SDIO_CLK		Base clock for SD/MMC
+14		BASE_SSP0_CLK		Base clock for SSP0
+15		BASE_SSP1_CLK		Base clock for SSP1
+16		BASE_UART0_CLK		Base clock for UART0
+17		BASE_UART1_CLK		Base clock for UART1
+18		BASE_UART2_CLK		Base clock for UART2
+19		BASE_UART3_CLK		Base clock for UART3
+20		BASE_OUT_CLK		Base clock for CLKOUT pin
+24-21		-			Reserved
+25		BASE_AUDIO_CLK		Base clock for audio system (I2S)
+26 		BASE_CGU_OUT0_CLK	Base clock for CGU_OUT0 clock output
+27 		BASE_CGU_OUT1_CLK	Base clock for CGU_OUT1 clock output
+
+BASE_PERIPH_CLK and BASE_SPI_CLK is only available on LPC43xx.
+BASE_ADCHS_CLK is only available on LPC4370.
+
+
+Example board file:
+
+/ {
+	clocks {
+		xtal: xtal {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <12000000>;
+		};
+
+		xtal32: xtal32 {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <32768>;
+		};
+
+		enet_rx_clk: enet_rx_clk {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <0>;
+			clock-output-names = "enet_rx_clk";
+		};
+
+		enet_tx_clk: enet_tx_clk {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <0>;
+			clock-output-names = "enet_tx_clk";
+		};
+
+		gp_clkin: gp_clkin {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <0>;
+			clock-output-names = "gp_clkin";
+		};
+	};
+
+	soc {
+		cgu: cgu at 40050000 {
+			compatible = "nxp,lpc1850-cgu";
+			reg = <0x40050000 0x1000>;
+			#clock-cells = <1>;
+			clocks = <&xtal>, <&creg_clk 1>, <&enet_rx_clk>, <&enet_tx_clk>, <&gp_clkin>;
+			clock-indices =  <0>,  <1>,  <2>,  <3>,  <4>,  <5>,  <6>,  <7>,
+					 <8>,  <9>, <10>, <11>, <12>, <13>, <14>, <15>,
+					<16>, <17>, <18>, <19>, <20>, <25>, <26>, <27>;
+			clock-output-names = "base_safe_clk",    "base_usb0_clk",
+					     "base_periph_clk",  "base_usb1_clk",
+					     "base_cpu_clk",     "base_spifi_clk",
+					     "base_spi_clk",     "base_phy_rx_clk",
+					     "base_phy_tx_clk",  "base_apb1_clk",
+					     "base_apb3_clk",    "base_lcd_clk",
+					     "base_adchs_clk",   "base_sdio_clk",
+					     "base_ssp0_clk",    "base_ssp1_clk",
+					     "base_uart0_clk",   "base_uart1_clk",
+					     "base_uart2_clk",   "base_uart3_clk",
+					     "base_out_clk",     "base_audio_clk",
+					     "base_cgu_out0_clk","base_cgu_out1_clk";
+		};
+	};
+};
Signature · 1 line
1.8.0
#3 lore raw

PATCH v2 2/4 doc: dt: add documentation for lpc1850-cgu clk driver

Quoting Joachim Eastwood (2015-04-27 14:38:11)

Quoted 46 lines

Add DT binding documentation for lpc1850-cgu driver.

---
 .../devicetree/bindings/clock/lpc1850-cgu.txt      | 138 +++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-cgu.txt
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +32 -0
new file mode 100644
index 000000000000..0b278ca6aee7
@@ -0,0 +1,138 @@
+* NXP LPC1850 Clock Generation Unit (CGU)
+
+The CGU generates multiple independent clocks for the core and the
+peripheral blocks of the LPC18xx. Each independent clock is called
+a base clock and itself is one of the inputs to the two Clock
+Control Units (CCUs) which control the branch clocks to the
+individual peripherals.
+
+The CGU selects the inputs to the clock generators from multiple
+clock sources, controls the clock generation, and routes the outputs
+of the clock generators through the clock source bus to the output
+stages. Each output stage provides an independent clock source and
+corresponds to one of the base clocks for the LPC18xx.
+
+ - Above text taken from NXP LPC1850 User Manual.
+
+
+This binding uses the common clock binding:
+    Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible:
+       Should be "nxp,lpc1850-cgu"
+- reg:
+       Shall define the base and range of the address space
+       containing clock control registers
+- #clock-cells:
+       Shall have value <1>.  The permitted clock-specifier values
+       are the base clock numbers defined below.
+- clocks:
+       Shall contain a list of phandles for the external input
+       sources to the CGU. The list shall be in the following

Documentation/devicetree/bindings/clock/lpc1850-cgu.txt line 42

Quoted 10 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +10 -0
+       order: xtal, 32khz, enet_rx_clk, enet_tx_clk, gp_clkin.
+- clock-indices:
+       Shall be an ordered list of numbers defining the base clock
+       number provided by the CGU.
+- clock-output-names:
+       Shall be an ordered list of strings defining the names of
+       the clocks provided by the CGU.
+
+Which base clocks that are available on the CGU depends on the
+specific LPC part. Base cloks are numbered from 0 to 27.

s/cloks/clocks/

Quoted 83 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +83 -0
+
+Number:                Name:                   Description:
+ 0             BASE_SAFE_CLK           Base safe clock (always on) for WWDT
+ 1             BASE_USB0_CLK           Base clock for USB0
+ 2             BASE_PERIPH_CLK         Base clock for Cortex-M0SUB subsystem,
+                                       SPI, and SGPIO
+ 3             BASE_USB1_CLK           Base clock for USB1
+ 4             BASE_CPU_CLK            System base clock for ARM Cortex-M core
+                                       and APB peripheral blocks #0 and #2
+ 5             BASE_SPIFI_CLK          Base clock for SPIFI
+ 6             BASE_SPI_CLK            Base clock for SPI
+ 7             BASE_PHY_RX_CLK         Base clock for Ethernet PHY Receive clock
+ 8             BASE_PHY_TX_CLK         Base clock for Ethernet PHY Transmit clock
+ 9             BASE_APB1_CLK           Base clock for APB peripheral block # 1
+10             BASE_APB3_CLK           Base clock for APB peripheral block # 3
+11             BASE_LCD_CLK            Base clock for LCD
+12             BASE_ADCHS_CLK          Base clock for ADCHS
+13             BASE_SDIO_CLK           Base clock for SD/MMC
+14             BASE_SSP0_CLK           Base clock for SSP0
+15             BASE_SSP1_CLK           Base clock for SSP1
+16             BASE_UART0_CLK          Base clock for UART0
+17             BASE_UART1_CLK          Base clock for UART1
+18             BASE_UART2_CLK          Base clock for UART2
+19             BASE_UART3_CLK          Base clock for UART3
+20             BASE_OUT_CLK            Base clock for CLKOUT pin
+24-21          -                       Reserved
+25             BASE_AUDIO_CLK          Base clock for audio system (I2S)
+26             BASE_CGU_OUT0_CLK       Base clock for CGU_OUT0 clock output
+27             BASE_CGU_OUT1_CLK       Base clock for CGU_OUT1 clock output
+
+BASE_PERIPH_CLK and BASE_SPI_CLK is only available on LPC43xx.
+BASE_ADCHS_CLK is only available on LPC4370.
+
+
+Example board file:
+
+/ {
+       clocks {
+               xtal: xtal {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <12000000>;
+               };
+
+               xtal32: xtal32 {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <32768>;
+               };
+
+               enet_rx_clk: enet_rx_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "enet_rx_clk";
+               };
+
+               enet_tx_clk: enet_tx_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "enet_tx_clk";
+               };
+
+               gp_clkin: gp_clkin {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "gp_clkin";
+               };
+       };
+
+       soc {
+               cgu: cgu at 40050000 {
+                       compatible = "nxp,lpc1850-cgu";
+                       reg = <0x40050000 0x1000>;
+                       #clock-cells = <1>;
+                       clocks = <&xtal>, <&creg_clk 1>, <&enet_rx_clk>, <&enet_tx_clk>, <&gp_clkin>;
+                       clock-indices =  <0>,  <1>,  <2>,  <3>,  <4>,  <5>,  <6>,  <7>,
+                                        <8>,  <9>, <10>, <11>, <12>, <13>, <14>, <15>,
+                                       <16>, <17>, <18>, <19>, <20>, <25>, <26>, <27>;
+                       clock-output-names = "base_safe_clk",    "base_usb0_clk",
+                                            "base_periph_clk",  "base_usb1_clk",

Documentation/devicetree/bindings/clock/lpc1850-cgu.txt line 135

Quoted 10 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +10 -0
+                                            "base_cpu_clk",     "base_spifi_clk",
+                                            "base_spi_clk",     "base_phy_rx_clk",
+                                            "base_phy_tx_clk",  "base_apb1_clk",
+                                            "base_apb3_clk",    "base_lcd_clk",
+                                            "base_adchs_clk",   "base_sdio_clk",
+                                            "base_ssp0_clk",    "base_ssp1_clk",
+                                            "base_uart0_clk",   "base_uart1_clk",
+                                            "base_uart2_clk",   "base_uart3_clk",
+                                            "base_out_clk",     "base_audio_clk",
+                                            "base_cgu_out0_clk","base_cgu_out1_clk";

Why do you need to use clock-indices?

Why do you need to use clock-output-names? If all of your clock consumers have nodes in DT then you can skip this and name them on the consuming side. See a further explanation here:
http://lkml.kernel.org/r/<20150416192014.19585.9663@quantum>

Also note that providing a clock consumer node in the examples section of the binding is helpful when reviewing.

Regards,
Mike

Quoted 6 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +3 -0
+               };
+       };
+};
Signature · 1 line
1.8.0
#4 lore raw

PATCH v2 2/4 doc: dt: add documentation for lpc1850-cgu clk driver

Quoted 147 lines · Michael Turquette

Quoting Joachim Eastwood (2015-04-27 14:38:11)

Quoted 46 lines

Add DT binding documentation for lpc1850-cgu driver.

---
 .../devicetree/bindings/clock/lpc1850-cgu.txt      | 138 +++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-cgu.txt
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +32 -0
new file mode 100644
index 000000000000..0b278ca6aee7
@@ -0,0 +1,138 @@
+* NXP LPC1850 Clock Generation Unit (CGU)
+
+The CGU generates multiple independent clocks for the core and the
+peripheral blocks of the LPC18xx. Each independent clock is called
+a base clock and itself is one of the inputs to the two Clock
+Control Units (CCUs) which control the branch clocks to the
+individual peripherals.
+
+The CGU selects the inputs to the clock generators from multiple
+clock sources, controls the clock generation, and routes the outputs
+of the clock generators through the clock source bus to the output
+stages. Each output stage provides an independent clock source and
+corresponds to one of the base clocks for the LPC18xx.
+
+ - Above text taken from NXP LPC1850 User Manual.
+
+
+This binding uses the common clock binding:
+    Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible:
+       Should be "nxp,lpc1850-cgu"
+- reg:
+       Shall define the base and range of the address space
+       containing clock control registers
+- #clock-cells:
+       Shall have value <1>.  The permitted clock-specifier values
+       are the base clock numbers defined below.
+- clocks:
+       Shall contain a list of phandles for the external input
+       sources to the CGU. The list shall be in the following

Documentation/devicetree/bindings/clock/lpc1850-cgu.txt line 42

Quoted 10 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +10 -0
+       order: xtal, 32khz, enet_rx_clk, enet_tx_clk, gp_clkin.
+- clock-indices:
+       Shall be an ordered list of numbers defining the base clock
+       number provided by the CGU.
+- clock-output-names:
+       Shall be an ordered list of strings defining the names of
+       the clocks provided by the CGU.
+
+Which base clocks that are available on the CGU depends on the
+specific LPC part. Base cloks are numbered from 0 to 27.

s/cloks/clocks/

Quoted 87 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +87 -0
+
+Number:                Name:                   Description:
+ 0             BASE_SAFE_CLK           Base safe clock (always on) for WWDT
+ 1             BASE_USB0_CLK           Base clock for USB0
+ 2             BASE_PERIPH_CLK         Base clock for Cortex-M0SUB subsystem,
+                                       SPI, and SGPIO
+ 3             BASE_USB1_CLK           Base clock for USB1
+ 4             BASE_CPU_CLK            System base clock for ARM Cortex-M core
+                                       and APB peripheral blocks #0 and #2
+ 5             BASE_SPIFI_CLK          Base clock for SPIFI
+ 6             BASE_SPI_CLK            Base clock for SPI
+ 7             BASE_PHY_RX_CLK         Base clock for Ethernet PHY Receive clock
+ 8             BASE_PHY_TX_CLK         Base clock for Ethernet PHY Transmit clock
+ 9             BASE_APB1_CLK           Base clock for APB peripheral block # 1
+10             BASE_APB3_CLK           Base clock for APB peripheral block # 3
+11             BASE_LCD_CLK            Base clock for LCD
+12             BASE_ADCHS_CLK          Base clock for ADCHS
+13             BASE_SDIO_CLK           Base clock for SD/MMC
+14             BASE_SSP0_CLK           Base clock for SSP0
+15             BASE_SSP1_CLK           Base clock for SSP1
+16             BASE_UART0_CLK          Base clock for UART0
+17             BASE_UART1_CLK          Base clock for UART1
+18             BASE_UART2_CLK          Base clock for UART2
+19             BASE_UART3_CLK          Base clock for UART3
+20             BASE_OUT_CLK            Base clock for CLKOUT pin
+24-21          -                       Reserved
+25             BASE_AUDIO_CLK          Base clock for audio system (I2S)
+26             BASE_CGU_OUT0_CLK       Base clock for CGU_OUT0 clock output
+27             BASE_CGU_OUT1_CLK       Base clock for CGU_OUT1 clock output
+
+BASE_PERIPH_CLK and BASE_SPI_CLK is only available on LPC43xx.
+BASE_ADCHS_CLK is only available on LPC4370.
+
+
+Example board file:
+
+/ {
+       clocks {
+               xtal: xtal {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <12000000>;
+               };
+
+               xtal32: xtal32 {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <32768>;
+               };
+
+               enet_rx_clk: enet_rx_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "enet_rx_clk";
+               };
+
+               enet_tx_clk: enet_tx_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "enet_tx_clk";
+               };
+
+               gp_clkin: gp_clkin {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "gp_clkin";
+               };
+       };
+
+       soc {
+               cgu: cgu at 40050000 {
+                       compatible = "nxp,lpc1850-cgu";
+                       reg = <0x40050000 0x1000>;
+                       #clock-cells = <1>;
+                       clocks = <&xtal>, <&creg_clk 1>, <&enet_rx_clk>, <&enet_tx_clk>, <&gp_clkin>;
+                       clock-indices =  <0>,  <1>,  <2>,  <3>,  <4>,  <5>,  <6>,  <7>,
+                                        <8>,  <9>, <10>, <11>, <12>, <13>, <14>, <15>,
+                                       <16>, <17>, <18>, <19>, <20>, <25>, <26>, <27>;
+                       clock-output-names = "base_safe_clk",    "base_usb0_clk",
+                                            "base_periph_clk",  "base_usb1_clk",
+                                            "base_cpu_clk",     "base_spifi_clk",
+                                            "base_spi_clk",     "base_phy_rx_clk",
+                                            "base_phy_tx_clk",  "base_apb1_clk",
+                                            "base_apb3_clk",    "base_lcd_clk",
Quoted 8 lines

Documentation/devicetree/bindings/clock/lpc1850-cgu.txt line 135

Quoted 6 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +6 -0
+                                            "base_adchs_clk",   "base_sdio_clk",
+                                            "base_ssp0_clk",    "base_ssp1_clk",
+                                            "base_uart0_clk",   "base_uart1_clk",
+                                            "base_uart2_clk",   "base_uart3_clk",
+                                            "base_out_clk",     "base_audio_clk",
+                                            "base_cgu_out0_clk","base_cgu_out1_clk";

Why do you need to use clock-indices?

Since the CGU can have up to 27 clock lines, but in this device not all are used. So I use clock-indices so I don't need to have empty entries in the clock-output-names array. I thought this was the intended usage(?)

Quoted 4 lines

Why do you need to use clock-output-names? If all of your clock consumers have nodes in DT then you can skip this and name them on the consuming side. See a further explanation here:
http://lkml.kernel.org/r/<20150416192014.19585.9663@quantum>

Most of the clocks from the CGU goes to a CCU, but the CCU isn't the real consumer. It's more like a clock router with a bunch of gates.

If you take a close look at the CCU driver you will notice that it doesn't do clk_get on any of the clocks. My reason for doing this is to not increase the usage counter on the CGU clock so that if there are no consumer after a CCU the entire clock line up to the CGU can be disabled. So this is the reason that the CCU driver uses a "special" way to grab the clock output names from the CGU.

Hope this makes sense.

Quoted 2 lines

Also note that providing a clock consumer node in the examples section of the binding is helpful when reviewing.

I'll add a consumer example in the next version.

regards,
Joachim Eastwood

#5 lore raw

PATCH v2 2/4 doc: dt: add documentation for lpc1850-cgu clk driver

Quoting Joachim Eastwood (2015-05-13 00:57:18)

Quoted 170 lines · Michael Turquette
Quoted 147 lines

Quoting Joachim Eastwood (2015-04-27 14:38:11)

Quoted 46 lines

Add DT binding documentation for lpc1850-cgu driver.

---
 .../devicetree/bindings/clock/lpc1850-cgu.txt      | 138 +++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-cgu.txt
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +32 -0
new file mode 100644
index 000000000000..0b278ca6aee7
@@ -0,0 +1,138 @@
+* NXP LPC1850 Clock Generation Unit (CGU)
+
+The CGU generates multiple independent clocks for the core and the
+peripheral blocks of the LPC18xx. Each independent clock is called
+a base clock and itself is one of the inputs to the two Clock
+Control Units (CCUs) which control the branch clocks to the
+individual peripherals.
+
+The CGU selects the inputs to the clock generators from multiple
+clock sources, controls the clock generation, and routes the outputs
+of the clock generators through the clock source bus to the output
+stages. Each output stage provides an independent clock source and
+corresponds to one of the base clocks for the LPC18xx.
+
+ - Above text taken from NXP LPC1850 User Manual.
+
+
+This binding uses the common clock binding:
+    Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible:
+       Should be "nxp,lpc1850-cgu"
+- reg:
+       Shall define the base and range of the address space
+       containing clock control registers
+- #clock-cells:
+       Shall have value <1>.  The permitted clock-specifier values
+       are the base clock numbers defined below.
+- clocks:
+       Shall contain a list of phandles for the external input
+       sources to the CGU. The list shall be in the following

Documentation/devicetree/bindings/clock/lpc1850-cgu.txt line 42

Quoted 10 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +10 -0
+       order: xtal, 32khz, enet_rx_clk, enet_tx_clk, gp_clkin.
+- clock-indices:
+       Shall be an ordered list of numbers defining the base clock
+       number provided by the CGU.
+- clock-output-names:
+       Shall be an ordered list of strings defining the names of
+       the clocks provided by the CGU.
+
+Which base clocks that are available on the CGU depends on the
+specific LPC part. Base cloks are numbered from 0 to 27.

s/cloks/clocks/

Quoted 87 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +87 -0
+
+Number:                Name:                   Description:
+ 0             BASE_SAFE_CLK           Base safe clock (always on) for WWDT
+ 1             BASE_USB0_CLK           Base clock for USB0
+ 2             BASE_PERIPH_CLK         Base clock for Cortex-M0SUB subsystem,
+                                       SPI, and SGPIO
+ 3             BASE_USB1_CLK           Base clock for USB1
+ 4             BASE_CPU_CLK            System base clock for ARM Cortex-M core
+                                       and APB peripheral blocks #0 and #2
+ 5             BASE_SPIFI_CLK          Base clock for SPIFI
+ 6             BASE_SPI_CLK            Base clock for SPI
+ 7             BASE_PHY_RX_CLK         Base clock for Ethernet PHY Receive clock
+ 8             BASE_PHY_TX_CLK         Base clock for Ethernet PHY Transmit clock
+ 9             BASE_APB1_CLK           Base clock for APB peripheral block # 1
+10             BASE_APB3_CLK           Base clock for APB peripheral block # 3
+11             BASE_LCD_CLK            Base clock for LCD
+12             BASE_ADCHS_CLK          Base clock for ADCHS
+13             BASE_SDIO_CLK           Base clock for SD/MMC
+14             BASE_SSP0_CLK           Base clock for SSP0
+15             BASE_SSP1_CLK           Base clock for SSP1
+16             BASE_UART0_CLK          Base clock for UART0
+17             BASE_UART1_CLK          Base clock for UART1
+18             BASE_UART2_CLK          Base clock for UART2
+19             BASE_UART3_CLK          Base clock for UART3
+20             BASE_OUT_CLK            Base clock for CLKOUT pin
+24-21          -                       Reserved
+25             BASE_AUDIO_CLK          Base clock for audio system (I2S)
+26             BASE_CGU_OUT0_CLK       Base clock for CGU_OUT0 clock output
+27             BASE_CGU_OUT1_CLK       Base clock for CGU_OUT1 clock output
+
+BASE_PERIPH_CLK and BASE_SPI_CLK is only available on LPC43xx.
+BASE_ADCHS_CLK is only available on LPC4370.
+
+
+Example board file:
+
+/ {
+       clocks {
+               xtal: xtal {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <12000000>;
+               };
+
+               xtal32: xtal32 {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <32768>;
+               };
+
+               enet_rx_clk: enet_rx_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "enet_rx_clk";
+               };
+
+               enet_tx_clk: enet_tx_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "enet_tx_clk";
+               };
+
+               gp_clkin: gp_clkin {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "gp_clkin";
+               };
+       };
+
+       soc {
+               cgu: cgu at 40050000 {
+                       compatible = "nxp,lpc1850-cgu";
+                       reg = <0x40050000 0x1000>;
+                       #clock-cells = <1>;
+                       clocks = <&xtal>, <&creg_clk 1>, <&enet_rx_clk>, <&enet_tx_clk>, <&gp_clkin>;
+                       clock-indices =  <0>,  <1>,  <2>,  <3>,  <4>,  <5>,  <6>,  <7>,
+                                        <8>,  <9>, <10>, <11>, <12>, <13>, <14>, <15>,
+                                       <16>, <17>, <18>, <19>, <20>, <25>, <26>, <27>;
+                       clock-output-names = "base_safe_clk",    "base_usb0_clk",
+                                            "base_periph_clk",  "base_usb1_clk",
+                                            "base_cpu_clk",     "base_spifi_clk",
+                                            "base_spi_clk",     "base_phy_rx_clk",
+                                            "base_phy_tx_clk",  "base_apb1_clk",
+                                            "base_apb3_clk",    "base_lcd_clk",
Quoted 8 lines

Documentation/devicetree/bindings/clock/lpc1850-cgu.txt line 135

Quoted 6 lines
Documentation/devicetree/bindings/clock/lpc1850-cgu.txt new file +6 -0
+                                            "base_adchs_clk",   "base_sdio_clk",
+                                            "base_ssp0_clk",    "base_ssp1_clk",
+                                            "base_uart0_clk",   "base_uart1_clk",
+                                            "base_uart2_clk",   "base_uart3_clk",
+                                            "base_out_clk",     "base_audio_clk",
+                                            "base_cgu_out0_clk","base_cgu_out1_clk";

Why do you need to use clock-indices?

Since the CGU can have up to 27 clock lines, but in this device not all are used. So I use clock-indices so I don't need to have empty entries in the clock-output-names array. I thought this was the intended usage(?)

Quoted 4 lines

Why do you need to use clock-output-names? If all of your clock consumers have nodes in DT then you can skip this and name them on the consuming side. See a further explanation here:
http://lkml.kernel.org/r/<20150416192014.19585.9663@quantum>

Most of the clocks from the CGU goes to a CCU, but the CCU isn't the real consumer. It's more like a clock router with a bunch of gates.

Quoted 6 lines

If you take a close look at the CCU driver you will notice that it doesn't do clk_get on any of the clocks. My reason for doing this is to not increase the usage counter on the CGU clock so that if there are no consumer after a CCU the entire clock line up to the CGU can be disabled. So this is the reason that the CCU driver uses a "special" way to grab the clock output names from the CGU.

A call to clk_get will not enable/ungate the clock signal. It seems that there might be some confusion around that. It is always OK to get the clk. This will not increase the enable_count or prepare_count values.

If the CCU is a separate IP block then it might make sense for it to call clk_get on the CGU clocks. On the other hand it might make more sense for the CCU clocks to simply use the CGU clocks as parent clock signal inputs.

None of the points above have anything to do with my original comment. The use of the clock-output-names property is unnecessary if all of the consumer devices have DT nodes of their own. Please look at the thread I linked to and let me know what you think about getting rid of the clock-output-names property.

Quoted 7 lines

Hope this makes sense.

Quoted 2 lines

Also note that providing a clock consumer node in the examples section of the binding is helpful when reviewing.

I'll add a consumer example in the next version.

Great.

Thanks,
Mike

Quoted 3 lines

regards,
Joachim Eastwood

#6 lore raw

PATCH v2 2/4 doc: dt: add documentation for lpc1850-cgu clk driver

Quoted 25 lines · Michael Turquette

Quoting Joachim Eastwood (2015-05-13 00:57:18)

Quoted 17 lines · Michael Turquette
Quoted 2 lines

Why do you need to use clock-indices?

Since the CGU can have up to 27 clock lines, but in this device not all are used. So I use clock-indices so I don't need to have empty entries in the clock-output-names array. I thought this was the intended usage(?)

Quoted 4 lines

Why do you need to use clock-output-names? If all of your clock consumers have nodes in DT then you can skip this and name them on the consuming side. See a further explanation here:
http://lkml.kernel.org/r/<20150416192014.19585.9663@quantum>

Most of the clocks from the CGU goes to a CCU, but the CCU isn't the real consumer. It's more like a clock router with a bunch of gates.

Quoted 6 lines

If you take a close look at the CCU driver you will notice that it doesn't do clk_get on any of the clocks. My reason for doing this is to not increase the usage counter on the CGU clock so that if there are no consumer after a CCU the entire clock line up to the CGU can be disabled. So this is the reason that the CCU driver uses a "special" way to grab the clock output names from the CGU.

Quoted 8 lines

A call to clk_get will not enable/ungate the clock signal. It seems that there might be some confusion around that. It is always OK to get the clk. This will not increase the enable_count or prepare_count values.

If the CCU is a separate IP block then it might make sense for it to call clk_get on the CGU clocks. On the other hand it might make more sense for the CCU clocks to simply use the CGU clocks as parent clock signal inputs.

v3, that was sent a couple of days ago, uses of_clk_get/clk_get_name to set the CCU clock parents. See v3 cover letter for a short explanation.

Quoted 5 lines

None of the points above have anything to do with my original comment. The use of the clock-output-names property is unnecessary if all of the consumer devices have DT nodes of their own. Please look at the thread I linked to and let me know what you think about getting rid of the clock-output-names property.

v3 removes the property. Please take a look at it when you get the time.

regards,
Joachim Eastwood

#7 lore raw

PATCH v2 3/4 clk: add lpc18xx ccu clk driver

In reply to Joachim Eastwood

Add driver for NXP LPC18xx/43xx Clock Control Unit (CCU). The CCU provides fine grained gating of most clocks present in the SoC.

---
 drivers/clk/nxp/Makefile                |   1 +
 drivers/clk/nxp/clk-lpc18xx-ccu.c       | 318 ++++++++++++++++++++++++++++++++
 include/dt-bindings/clock/lpc18xx-ccu.h |  74 ++++++++
 3 files changed, 393 insertions(+)
 create mode 100644 drivers/clk/nxp/clk-lpc18xx-ccu.c
 create mode 100644 include/dt-bindings/clock/lpc18xx-ccu.h
drivers/clk/nxp/Makefile +1 -0
index aca9d3e4f7fe..7f608b0ad7b4 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_ARCH_LPC18XX)	+= clk-lpc18xx-cgu.o
+obj-$(CONFIG_ARCH_LPC18XX)	+= clk-lpc18xx-ccu.o
drivers/clk/nxp/clk-lpc18xx-ccu.c new file +318 -0

318 lines not on this page · raw message

include/dt-bindings/clock/lpc18xx-ccu.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
1.8.0
#8 lore raw

PATCH v2 3/4 clk: add lpc18xx ccu clk driver

Quoting Joachim Eastwood (2015-04-27 14:38:12)

Quoted 5 lines
drivers/clk/nxp/clk-lpc18xx-ccu.c new file +5 -0
+static int of_clk_get_parent_arg(struct device_node *np, int index)
+{
+       struct of_phandle_args clkspec;
+       int rc;
+

drivers/clk/nxp/clk-lpc18xx-ccu.c line 131

Quoted 10 lines
drivers/clk/nxp/clk-lpc18xx-ccu.c new file +10 -0
+       if (index < 0)
+               return -EINVAL;
+
+       rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index,
+                                       &clkspec);
+       if (rc)
+               return -EINVAL;
+
+       return clkspec.args_count ? clkspec.args[0] : -EINVAL;
+}

Hi Joachim,

I'm not sure why you need this. I guess it is related to my question in patch #2 about using clock-indices? Can you explain why this function is required?

Anyways if returning the clock index is something that is really needed then why not rename it to "of_clk_get_index" and put it in drivers/clk/clk.c?

Thanks,
Mike

#9 lore raw

PATCH v2 3/4 clk: add lpc18xx ccu clk driver

Quoted 19 lines · Michael Turquette

Quoting Joachim Eastwood (2015-04-27 14:38:12)

Quoted 5 lines
drivers/clk/nxp/clk-lpc18xx-ccu.c new file +5 -0
+static int of_clk_get_parent_arg(struct device_node *np, int index)
+{
+       struct of_phandle_args clkspec;
+       int rc;
+

drivers/clk/nxp/clk-lpc18xx-ccu.c line 131

Quoted 10 lines
drivers/clk/nxp/clk-lpc18xx-ccu.c new file +10 -0
+       if (index < 0)
+               return -EINVAL;
+
+       rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index,
+                                       &clkspec);
+       if (rc)
+               return -EINVAL;
+
+       return clkspec.args_count ? clkspec.args[0] : -EINVAL;
+}

Hi Joachim,

Quoted 2 lines

I'm not sure why you need this. I guess it is related to my question in patch #2 about using clock-indices?

Yes. I basically need the clock id without grabbing the clock using a clk_get function. See below.

Quoted 1 line

Can you explain why this function is required?

Since the CCU doesn't act like a normal clock consumer using clk_get type functions I use this function to retrieve the CGU clock id. This drivers is used on two CCUs blocks and I need to match the id with one in the clk_branches array so that the driver itself can be generic.

Quoted 3 lines

Anyways if returning the clock index is something that is really needed then why not rename it to "of_clk_get_index" and put it in drivers/clk/clk.c?

Okey, I'll do that in the next version if we agree that the function is still needed.

regards,
Joachim Eastwood

#10 lore raw

PATCH v2 4/4 doc: dt: add documentation for lpc1850-ccu clk driver

In reply to Joachim Eastwood

Add DT binding documentation for lpc1850-ccu clk driver.

---
 .../devicetree/bindings/clock/lpc1850-ccu.txt      | 146 +++++++++++++++++++++
 1 file changed, 146 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/lpc1850-ccu.txt
Documentation/devicetree/bindings/clock/lpc1850-ccu.txt new file +146 -0
new file mode 100644
index 000000000000..1b45bc9f004f
@@ -0,0 +1,146 @@
+* NXP LPC1850 Clock Control Unit (CCU)
+
+Each CGU base clock has several clock branches which can be turned on
+or off independently by the Clock Control Units CCU1 or CCU2. The
+branch clocks are distributed between CCU1 and CCU2.
+
+ - Above text taken from NXP LPC1850 User Manual.
+
+This binding uses the common clock binding:
+    Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible:
+	Should be "nxp,lpc1850-ccu"
+- reg:
+	Shall define the base and range of the address space
+	containing clock control registers
+- #clock-cells:
+	Shall have value <1>.  The permitted clock-specifier values
+	are the branch clock names defined in table below.
+- clocks:
+	Shall contain a list of phandles for the base clocks routed
+	from the CGU to the specific CCU. See mapping of base clocks
+	and CCU in table below.
+
+Which brach clocks that are available on the CCU depends on the
+specific LPC part.
+
+CCU1 branch clocks:
+Base clock	Branch clock		Description
+BASE_APB3_CLK	CLK_APB3_BUS		APB3 bus clock.
+		CLK_APB3_I2C1		Clock to the I2C1 register interface
+					and I2C1 peripheral clock.
+		CLK_APB3_DAC		Clock to the DAC register interface.
+		CLK_APB3_ADC0		Clock to the ADC0 register interface
+					and ADC0 peripheral clock.
+		CLK_APB3_ADC1		Clock to the ADC1 register interface
+					and ADC1 peripheral clock.
+		CLK_APB3_CAN0		Clock to the C_CAN0 register interface
+					and C_CAN0 peripheral clock.
+BASE_APB1_CLK	CLK_APB1_BUS		APB1 bus clock.
+		CLK_APB1_MOTOCON_PWM	Clock to the PWM Motor control block and
+					PWM Motor control peripheral clock.
+		CLK_APB1_I2C0		Clock to the I2C0 register interface and
+					I2C0 peripheral clock.
+		CLK_APB1_I2S		Clock to the I2S0 and I2S1 register interfaces
+					and I2S0 and I2S1 peripheral clock.
+		CLK_APB1_CAN1		Clock to the C_CAN1 register interface and
+					C_CAN1 peripheral clock.
+BASE_SPIFI_CLK	CLK_SPIFI		Clock for the SPIFI SCKI clock input.
+BASE_CPU_CLK	CLK_CPU_BUS		M4 bus clock.
+		CLK_CPU_SPIFI		Clock to the SPIFI register interface.
+		CLK_CPU_GPIO		Clock to the GPIO register interface
+		CLK_CPU_LCD		Clock to the LCD register interface.
+		CLK_CPU_ETHERNET	Clock to the Ethernet register interface.
+		CLK_CPU_USB0		Clock to the USB0 register interface.
+		CLK_CPU_EMC		Clock to the External memory controller.
+		CLK_CPU_SDIO		Clock to the SD/MMC register interface.
+		CLK_CPU_DMA		Clock to the DMA register interface.
+		CLK_CPU_CORE		Clock to the Cortex-M core
+		CLK_CPU_SCT		Clock to the SCT register interface.
+		CLK_CPU_USB1		Clock to the USB1 register interface.
+		CLK_CPU_EMC_DIV		Clock to the EMC with clock divider.
+		CLK_CPU_FLASHA		Clock to the flash bank A.
+		CLK_CPU_FLASHB		Clock to the flash bank B.
+		CLK_CPU_M0APP		Clock to the M0APP coprocessor.
+		CLK_CPU_ADCHS		Clock to the ADCHS.
+		CLK_CPU_EEPROM		Clock to the EEPROM.
+		CLK_CPU_WWDT		Clock to the WWDT register interface.
+		CLK_CPU_UART0		Clock to the USART0 register interface.
+		CLK_CPU_UART1		Clock to the UART1 register interface.
+		CLK_CPU_SSP0		Clock to the SSP0 register interface.
+		CLK_CPU_TIMER0		Clock to the timer0 register interface and
+					timer0 peripheral clock.
+		CLK_CPU_TIMER1		Clock to the timer1 register interface and
+					timer1 peripheral clock.
+		CLK_CPU_SCU		Clock to the System control unit register interface.
+		CLK_CPU_CREG		Clock to the CREG register interface.
+		CLK_CPU_RITIMER		Clock to the RI timer register interface and
+					RI timer peripheral clock.
+		CLK_CPU_UART2		Clock to the UART2 register interface.
+		CLK_CPU_UART3		Clock to the UART3 register interface.
+		CLK_CPU_TIMER2		Clock to the timer2 register interface and
+					timer2 peripheral clock.
+		CLK_CPU_TIMER3		Clock to the timer3 register interface and
+					timer3 peripheral clock.
+		CLK_CPU_SSP1		Clock to the SSP1 register interface.
+		CLK_CPU_QEI		Clock to the QEI register interface and
+					QEI peripheral clock.
+BASE_PERIPH_CLK	CLK_PERIPH_BUS		Clock to the peripheral bus and the
+					Cortex-M0 subsystem AHB multilayer matrix.
+		CLK_PERIPH_CORE		Clock to the Cortex-M0 subsystem core.
+		CLK_PERIPH_SGPIO	Clock to the SGPIO interface.
+BASE_USB0_CLK	CLK_USB0		USB0 peripheral clock.
+BASE_USB1_CLK	CLK_USB1		USB1 peripheral clock.
+BASE_SPI_CLK	CLK_SPI			Clock to the SPI interface.
+BASE_ADCHS_CLK	CLK_ADCHS		ADCHS clock.
+
+CCU2 branch clocks:
+BASE_AUDIO_CLK	CLK_AUDIO		Audio system (I2S) clock.
+BASE_UART3_CLK	CLK_APB2_UART3		USART3 peripheral clock.
+BASE_UART2_CLK	CLK_APB2_UART2		USART2 peripheral clock.
+BASE_UART1_CLK	CLK_APB0_UART1		UART1 peripheral clock.
+BASE_UART0_CLK	CLK_APB0_UART0		USART0 peripheral clock.
+BASE_SSP1_CLK	CLK_APB2_SSP1		SSP1 peripheral clock.
+BASE_SSP0_CLK	CLK_APB0_SSP0		SSP0 peripheral clock.
+BASE_SDIO_CLK	CLK_SDIO		SD/MMC peripheral clock.
+
+Not all branch clocks are available on all LPC parts. Check the user
+manual for your specific part.
+
+Note that CLK_M3_x and CLK_M4_x have been renamed to CLK_CPU_x here
+be more generic since both LPC18xx (M3) and LPC43xx (M4) are
+supported.
+
+
+Example board file:
+
+soc {
+	ccu1: ccu at 40051000 {
+		compatible = "nxp,lpc1850-ccu";
+		reg = <0x40051000 0x1000>;
+		#clock-cells = <1>;
+		clocks = <&cgu BASE_APB3_CLK>,   <&cgu BASE_APB1_CLK>,
+			 <&cgu BASE_SPIFI_CLK>,  <&cgu BASE_CPU_CLK>,
+			 <&cgu BASE_PERIPH_CLK>, <&cgu BASE_USB0_CLK>,
+			 <&cgu BASE_USB1_CLK>,   <&cgu BASE_SPI_CLK>;
+	};
+
+	ccu2: ccu at 40052000 {
+		compatible = "nxp,lpc1850-ccu";
+		reg = <0x40052000 0x1000>;
+		#clock-cells = <1>;
+		clocks = <&cgu BASE_AUDIO_CLK>, <&cgu BASE_UART3_CLK>,
+			 <&cgu BASE_UART2_CLK>, <&cgu BASE_UART1_CLK>,
+			 <&cgu BASE_UART0_CLK>, <&cgu BASE_SSP1_CLK>,
+			 <&cgu BASE_SSP0_CLK>,  <&cgu BASE_SDIO_CLK>;
+	};
+
+	/* A user of CCU brach clocks */
+	uart1: serial at 40082000 {
+		...
+		clocks = <&ccu2 CLK_APB0_UART1>, <&ccu1 CLK_CPU_UART1>;
+		...
+	};
+};
Signature · 1 line
1.8.0
#11 lore raw

v2 cover Clk drivers for NXP LPC18xx family

In reply to Joachim Eastwood
Quoted 10 lines · Joachim Eastwood

This patch set adds support for the two main clock peripherals in the LPC18xx/43xx MCU family.

The Clock Generation Unit (CGU) is the base source of all clocks. It has five external inputs and contains PLLs, dividers and muxes. The outputs from the CGU are then routed to a Clock Control Unit (CCU) and a few peripherals directly. There are two CCUs in the MCU. The CCU is a collection of gates and a few dividers that sits between the CGU and most of the peripherals.

Quoted 3 lines

Which clocks that are available depends on the specific device and it's peripherals. It's possible in DT to setup the routing between the CGU and the CCUs.

Is there any reason why this uses CLK_OF_DECLARE over the platform device model? Typically we have CLK_OF_DECLARE for cases where a provider needs to be up and running early during boot for hardware that can't probe defer (i.e. timers, irq controllers). Otherwise we should be able to use the standard linux device model to probe clk providers. It looks like the clocksource is using something from CCU, but perhaps CGU isn't "special" and could be using device model.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#12 lore raw

v2 cover Clk drivers for NXP LPC18xx family

Quoted 11 lines · Stephen Boyd
Quoted 10 lines · Joachim Eastwood

This patch set adds support for the two main clock peripherals in the LPC18xx/43xx MCU family.

The Clock Generation Unit (CGU) is the base source of all clocks. It has five external inputs and contains PLLs, dividers and muxes. The outputs from the CGU are then routed to a Clock Control Unit (CCU) and a few peripherals directly. There are two CCUs in the MCU. The CCU is a collection of gates and a few dividers that sits between the CGU and most of the peripherals.

Quoted 8 lines
Quoted 3 lines

Which clocks that are available depends on the specific device and it's peripherals. It's possible in DT to setup the routing between the CGU and the CCUs.

Is there any reason why this uses CLK_OF_DECLARE over the platform device model? Typically we have CLK_OF_DECLARE for cases where a provider needs to be up and running early during boot for hardware that can't probe defer (i.e. timers, irq controllers).

One of the CCUs provided clock for two of the timers that are used as clock sources.
Specifically this timer:
http://marc.info/?l=linux-arm-kernel&m=143138193704763&w=2

Since the CGU provides the clock to the CCU which then again provides the clock to the timer both must use CLK_OF_DECLARE for clk enable/get rate to work in the timer driver.

Quoted 4 lines

Otherwise we should be able to use the standard linux device model to probe clk providers. It looks like the clocksource is using something from CCU, but perhaps CGU isn't "special" and could be using device model.

It's is the CCU that uses the clocks from the CGU. So I think both drivers needs to use CLK_OF_DECLARE.

regards,
Joachim Eastwood