Skip to contentSkip to conversation

Clk drivers for NXP LPC18xx family

PATCH Superseded Joachim Eastwood 1 participant 7 messages Apr 2, 2015

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Clk drivers for NXP LPC18xx family

This patch set adds support for the two main clock peripherals types in the LPC18xx/43xx MCU family. For a MCU the clock structure is quite complex. Patches are based on Linus master 4.0-rc6.

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. See the bottom for full clock tree.

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.

I have tried to use the generic clock elements as much as possible to build the driver using composite clocks. For the most part the gates, dividers and muxes in cgu and ccu are simple registers.

In patch 4 there is a function called of_clk_get_parent_arg(...) which could be moved to more generic place if there is interest.

The last patch shows the full cgu/ccu additions to DT.

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

Joachim Eastwood (6):
clk: add table_size member to struct clk_mux
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
ARM: dts: lpc18xx: add clock nodes for cgu and ccu

 .../devicetree/bindings/clock/lpc1850-ccu.txt      | 146 ++++++
 .../devicetree/bindings/clock/lpc1850-cgu.txt      | 138 +++++
 arch/arm/boot/dts/lpc18xx.dtsi                     |  96 +++-
 drivers/clk/Makefile                               |   2 +
 drivers/clk/clk-lpc18xx-ccu.c                      | 318 ++++++++++++
 drivers/clk/clk-lpc18xx-cgu.c                      | 570 +++++++++++++++++++++
 include/dt-bindings/clock/lpc18xx-ccu.h            |  74 +++
 include/dt-bindings/clock/lpc18xx-cgu.h            |  41 ++
 include/linux/clk-provider.h                       |   3 +-
 9 files changed, 1373 insertions(+), 15 deletions(-)
 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/clk-lpc18xx-ccu.c
 create mode 100644 drivers/clk/clk-lpc18xx-cgu.c
 create mode 100644 include/dt-bindings/clock/lpc18xx-ccu.h
 create mode 100644 include/dt-bindings/clock/lpc18xx-cgu.h

Clock tree from /sys/kernel/debug/clk/clk_summary after bootloader setup.

clock enable_cnt prepare_cnt rate accuracy phase

 irc                                      0            0    12000000          0 0  
    base_cgu_out1_clk                     0            0    12000000          0 0  
    base_cgu_out0_clk                     0            0    12000000          0 0  
    base_audio_clk                        0            0    12000000          0 0  
       audio                              0            0    12000000          0 0  
    base_out_clk                          0            0    12000000          0 0  
    base_ssp1_clk                         0            0    12000000          0 0  
       apb2_ssp1                          0            0    12000000          0 0  
    base_ssp0_clk                         0            0    12000000          0 0  
       apb0_ssp0                          0            0    12000000          0 0  
    base_sdio_clk                         0            0    12000000          0 0  
       sdio                               0            0    12000000          0 0  
    base_adchs_clk                        0            0    12000000          0 0  
    base_lcd_clk                          0            0    12000000          0 0  
    base_apb3_clk                         0            0    12000000          0 0  
       apb3_bus                           0            0    12000000          0 0  
          apb3_can0                       0            0    12000000          0 0  
          apb3_adc1                       0            0    12000000          0 0  
          apb3_adc0                       0            0    12000000          0 0  
          apb3_dac                        0            0    12000000          0 0  
          apb3_i2c1                       0            0    12000000          0 0  
    base_apb1_clk                         0            0    12000000          0 0  
       apb1_bus                           0            0    12000000          0 0  
          apb1_can1                       0            0    12000000          0 0  
          apb1_i2s                        0            0    12000000          0 0  
          apb1_i2c0                       0            0    12000000          0 0  
          apb1_motorcon_pwm               0            0    12000000          0 0  
    base_phy_tx_clk                       0            0    12000000          0 0  
    base_phy_rx_clk                       0            0    12000000          0 0  
    base_spi_clk                          0            0    12000000          0 0  
       spi                                0            0    12000000          0 0  
    base_spifi_clk                        0            0    12000000          0 0  
       spifi                              0            0    12000000          0 0  
    base_usb1_clk                         0            0    12000000          0 0  
       usb1                               0            0    12000000          0 0  
    base_periph_clk                       0            0    12000000          0 0  
       periph_bus                         0            0    12000000          0 0  
          periph_sgpio                    0            0    12000000          0 0  
          periph_core                     0            0    12000000          0 0  
    base_safe_clk                         0            0    12000000          0 0  
    idive                                 0            0    12000000          0 0  
    idivd                                 0            0    12000000          0 0  
    idivb                                 0            0    12000000          0 0  
    idiva                                 0            0    12000000          0 0  
    pll0audio                             0            0    12000000          0 0  
 gp_clkin                                 0            0           0          0 0  
 enet_tx_clk                              0            0           0          0 0  
 enet_rx_clk                              0            0           0          0 0  
 xtal32                                   0            0       32768          0 0  
 xtal                                     1            1    12000000          0 0  
    osc                                   1            1    12000000          0 0  
       pll1                               2            2   144000000          0 0  
          base_uart3_clk                  0            0   144000000          0 0  
             apb2_uart3                   0            0   144000000          0 0  
          base_uart2_clk                  0            0   144000000          0 0  
             apb2_uart2                   0            0   144000000          0 0  
          base_uart1_clk                  0            0   144000000          0 0  
             apb0_uart1                   0            0   144000000          0 0  
          base_uart0_clk                  1            1   144000000          0 0  
             apb0_uart0                   1            1   144000000          0 0  
          base_cpu_clk                    1            1   144000000          0 0  
             cpu_bus                      7            7   144000000          0 0  
                cpu_qei                   0            0   144000000          0 0  
                cpu_ssp1                  0            0   144000000          0 0  
                cpu_timer3                0            0   144000000          0 0  
                cpu_timer2                0            0   144000000          0 0  
                cpu_uart3                 0            0   144000000          0 0  
                cpu_uart2                 0            0   144000000          0 0  
                cpu_ritimer               0            0   144000000          0 0  
                cpu_creg                  1            1   144000000          0 0  
                cpu_scu                   0            0   144000000          0 0  
                cpu_timer1                1            1   144000000          0 0  
                cpu_timer0                1            1   144000000          0 0  
                cpu_ssp0                  0            0   144000000          0 0  
                cpu_uart1                 0            0   144000000          0 0  
                cpu_uart0                 1            1   144000000          0 0  
                cpu_wwdt                  0            0   144000000          0 0  
                cpu_eeprom                0            0   144000000          0 0  
                cpu_adchs                 0            0   144000000          0 0  
                cpu_m0app                 0            0   144000000          0 0  
                cpu_flashb                0            0   144000000          0 0  
                cpu_flasha                0            0   144000000          0 0  
                cpu_emcdiv                1            1    72000000          0 0  
                cpu_usb1                  0            0   144000000          0 0  
                cpu_sct                   0            0   144000000          0 0  
                cpu_core                  1            1   144000000          0 0  
                cpu_dma                   0            0   144000000          0 0  
                cpu_sdio                  0            0   144000000          0 0  
                cpu_emc                   1            1   144000000          0 0  
                cpu_usb0                  0            0   144000000          0 0  
                cpu_ethernet              0            0   144000000          0 0  
                cpu_lcd                   0            0   144000000          0 0  
                cpu_gpio                  0            0   144000000          0 0  
                cpu_spifi                 0            0   144000000          0 0  
          idivc                           0            0    48000000          0 0  
       pll0usb                            0            0   480000000          0 0  
          base_usb0_clk                   0            0   480000000          0 0  
             usb0                         0            0   480000000          0 0
Signature · 1 line
1.8.0
#1 lore raw

PATCH 1/6 clk: add table_size member to struct clk_mux

Adding this field makes it a lot easier to loop through and register predefined tables containing struct clk_mux elements.

Also reorder members to prevent unnecessary padding in struct.

---
 include/linux/clk-provider.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/clk-provider.h +2 -1
index 5591ea71a8d1..d5ee7ec7443c 100644
@@ -411,9 +411,10 @@ struct clk_mux {
 	void __iomem	*reg;
 	u32		*table;
 	u32		mask;
+	spinlock_t	*lock;
 	u8		shift;
 	u8		flags;
-	spinlock_t	*lock;
+	u8		table_size;
 };
 
 #define CLK_MUX_INDEX_ONE		BIT(0)
Signature · 1 line
1.8.0
#2 lore raw

PATCH 2/6 clk: add lpc18xx cgu clk driver

In reply to Joachim Eastwood

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/clk-lpc18xx-cgu.c           | 570 ++++++++++++++++++++++++++++++++
 include/dt-bindings/clock/lpc18xx-cgu.h |  41 +++
 3 files changed, 612 insertions(+)
 create mode 100644 drivers/clk/clk-lpc18xx-cgu.c
 create mode 100644 include/dt-bindings/clock/lpc18xx-cgu.h
drivers/clk/Makefile +1 -0
index d478ceb69c5f..222a4e39bb81 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_COMMON_CLK_CDCE706)	+= clk-cdce706.o
 obj-$(CONFIG_ARCH_CLPS711X)		+= clk-clps711x.o
 obj-$(CONFIG_ARCH_EFM32)		+= clk-efm32gg.o
 obj-$(CONFIG_ARCH_HIGHBANK)		+= clk-highbank.o
+obj-$(CONFIG_ARCH_LPC18XX)		+= clk-lpc18xx-cgu.o
 obj-$(CONFIG_MACH_LOONGSON1)		+= clk-ls1x.o
 obj-$(CONFIG_COMMON_CLK_MAX_GEN)	+= clk-max-gen.o
 obj-$(CONFIG_COMMON_CLK_MAX77686)	+= clk-max77686.o
drivers/clk/clk-lpc18xx-cgu.c new file +570 -0

570 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
#3 lore raw

PATCH 3/6 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
#4 lore raw

PATCH 4/6 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/Makefile                    |   1 +
 drivers/clk/clk-lpc18xx-ccu.c           | 318 ++++++++++++++++++++++++++++++++
 include/dt-bindings/clock/lpc18xx-ccu.h |  74 ++++++++
 3 files changed, 393 insertions(+)
 create mode 100644 drivers/clk/clk-lpc18xx-ccu.c
 create mode 100644 include/dt-bindings/clock/lpc18xx-ccu.h
drivers/clk/Makefile +1 -0
index 222a4e39bb81..0c7526df1c84 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_ARCH_CLPS711X)		+= clk-clps711x.o
 obj-$(CONFIG_ARCH_EFM32)		+= clk-efm32gg.o
 obj-$(CONFIG_ARCH_HIGHBANK)		+= clk-highbank.o
 obj-$(CONFIG_ARCH_LPC18XX)		+= clk-lpc18xx-cgu.o
+obj-$(CONFIG_ARCH_LPC18XX)		+= clk-lpc18xx-ccu.o
 obj-$(CONFIG_MACH_LOONGSON1)		+= clk-ls1x.o
 obj-$(CONFIG_COMMON_CLK_MAX_GEN)	+= clk-max-gen.o
 obj-$(CONFIG_COMMON_CLK_MAX77686)	+= clk-max77686.o
drivers/clk/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
#5 lore raw

PATCH 5/6 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
#6 lore raw

PATCH 6/6 ARM: dts: lpc18xx: add clock nodes for cgu and ccu

In reply to Joachim Eastwood
---
 arch/arm/boot/dts/lpc18xx.dtsi | 96 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 82 insertions(+), 14 deletions(-)
arch/arm/boot/dts/lpc18xx.dtsi +82 -14
index 161e98b442e0..8e9f51c88fad 100644
@@ -13,6 +13,9 @@
 
 #include "armv7-m.dtsi"
 
+#include "dt-bindings/clock/lpc18xx-cgu.h"
+#include "dt-bindings/clock/lpc18xx-ccu.h"
+
 / {
 	aliases {
 		serial0 = &uart0;
@@ -29,6 +32,7 @@
 			compatible = "arm,cortex-m3";
 			device_type = "cpu";
 			reg = <0x0>;
+			clocks = <&ccu1 CLK_CPU_CORE>;
 		};
 	};
 
@@ -39,23 +43,84 @@
 			clock-frequency = <12000000>;
 		};
 
-		/* Temporary hardcode PLL1 until clk drivers are merged */
-		pll1: pll1 {
-			compatible = "fixed-factor-clock";
-			clocks = <&xtal>;
+		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-div = <1>;
-			clock-mult = <12>;
+			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>, <&xtal32>, <&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";
+		};
+
+		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>;
+		};
+
 		uart0: serial at 40081000 {
 			compatible = "ns16550a";
 			reg = <0x40081000 0x1000>;
 			reg-shift = <2>;
 			interrupts = <24>;
-			clocks = <&pll1>;
+			clocks = <&ccu2 CLK_APB0_UART0>, <&ccu1 CLK_CPU_UART0>;
+			clock-names = "uart", "reg";
 			status = "disabled";
 		};
 
@@ -64,7 +129,8 @@
 			reg = <0x40082000 0x1000>;
 			reg-shift = <2>;
 			interrupts = <25>;
-			clocks = <&pll1>;
+			clocks = <&ccu2 CLK_APB0_UART1>, <&ccu1 CLK_CPU_UART1>;
+			clock-names = "uart", "reg";
 			status = "disabled";
 		};
 
@@ -72,14 +138,14 @@
 			compatible = "nxp,lpc3250-timer";
 			reg = <0x40084000 0x1000>;
 			interrupts = <12>;
-			clocks = <&pll1>;
+			clocks = <&ccu1 CLK_CPU_TIMER0>;
 		};
 
 		timer1: timer at 40085000 {
 			compatible = "nxp,lpc3250-timer";
 			reg = <0x40085000 0x1000>;
 			interrupts = <13>;
-			clocks = <&pll1>;
+			clocks = <&ccu1 CLK_CPU_TIMER1>;
 		};
 
 		uart2: serial at 400c1000 {
@@ -87,7 +153,8 @@
 			reg = <0x400c1000 0x1000>;
 			reg-shift = <2>;
 			interrupts = <26>;
-			clocks = <&pll1>;
+			clocks = <&ccu2 CLK_APB2_UART2>, <&ccu1 CLK_CPU_UART2>;
+			clock-names = "uart", "reg";
 			status = "disabled";
 		};
 
@@ -96,7 +163,8 @@
 			reg = <0x400c2000 0x1000>;
 			reg-shift = <2>;
 			interrupts = <27>;
-			clocks = <&pll1>;
+			clocks = <&ccu2 CLK_APB2_UART3>, <&ccu1 CLK_CPU_UART3>;
+			clock-names = "uart", "reg";
 			status = "disabled";
 		};
 
@@ -104,14 +172,14 @@
 			compatible = "nxp,lpc3250-timer";
 			reg = <0x400c3000 0x1000>;
 			interrupts = <14>;
-			clocks = <&pll1>;
+			clocks = <&ccu1 CLK_CPU_TIMER2>;
 		};
 
 		timer3: timer at 400c4000 {
 			compatible = "nxp,lpc3250-timer";
 			reg = <0x400c4000 0x1000>;
 			interrupts = <15>;
-			clocks = <&pll1>;
+			clocks = <&ccu1 CLK_CPU_TIMER3>;
 		};
 	};
 };
Signature · 1 line
1.8.0