Skip to contentSkip to conversation

ARM: at91: move to common clk framework

PATCH In review Boris BREZILLON 3 participants 21 messages Nov 28, 2013 – Dec 2, 2013

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

v6 cover ARM: at91: move to common clk framework

Hello,

This patch series is the 5th version of the at91 clk implementations using the Common Clk Framework.

Most of the clock provided by the PMC (Power Management Controller) are implemented :
- main clock (main oscillator)
- pll clocks
- master clock
- programmable clocks
- utmi clock
- peripheral clocks
- system clocks

Actually some clk drivers are missing (slow clk, main clk and processor clk), and some drivers only implement a subset of the hardware capabilities (master clk rate change is missing).
But this series implements all the already available clks, and I will hopefully add missing features in a near future.

This implementation is only compatible with device tree definition. The goal is to define the whole clock tree using the device tree.

Just a note to let you know these bindings are currently unstable and might change in the future.

Best Regards,
Boris

Changes since v5:
- remove peripheral divisors macros from dt binding include file
- remove file path from comment blocks
- replace pll and utmi disable function by unprepare function to avoid issue when disabling and reenabling a clk
- fix programmable clk interrupt retrieval
- fix OF_CLK_DECLARE names (xxx_clk_main -> xxx_clk_pmc)
- add missing comma in at91rm9200 main clk dt declaration
- fix num_parents check in smd clk driver

Changes since v4:
- rework dt bindings:
* replace "atmel,clk-id" property by the standard "reg" property
* reference system, peripheral and programmable clks using the direct clk node instead of the parent node plus a clk id
- provide a new helper function (of_at91_get_clk_range) to retrieve a clk range from the device tree

Changes since v3:
- simplify master clk implementation (drop set_rate/parent support)
- fix bug in set_rate function of pll driver
- fix coding style issues
- define macros and constants where needed
- remove peripheral id macro references
- remove sam9g35 specific handling (sam9g35 = sam9x5)
- rework main clk prepare function to handle automatic rate calculation

Changes since v2:
- fix several bugs in clk implementations
- drop non-dt boards support
- split the series to ease review and tests:
* 1 patch series for new clk implementations (this series)
* 1 patch series to move each at91 SoC to common clk framework (coming soon)
- modify dt-bindings (add atmel,clk- prefix to atmel specific properties)
- add clk macros for dt-bindings
- add pmc framework (helper function to access pmc registers)
- add interrupt support to enable passive wait in clk_prepare functions

Changes since v1:
- fix bugs in pll, programmable and system clock implementations (wrong bit position).
- add usb clock configuration support (ohci and udc drivers + clk_lookup for non dt boards)
- rework of the system clock interfaces (no need to define a parent clock, system clock is a gate with no rate info)
- change system, peripheral and programmable clk dt bindings (1 master node and multiple child nodes each defining a system/peripheral or prog clock)
- fix bugs in sama5 dt definition

Boris BREZILLON (16):
ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h
ARM: at91: add Kconfig options for common clk support
clk: at91: add PMC base support
clk: at91: add PMC macro file for dt definitions
clk: at91: add PMC main clock
clk: at91: add PMC pll clocks
clk: at91: add PMC master clock
clk: at91: add PMC system clocks
clk: at91: add PMC peripheral clocks
clk: at91: add PMC programmable clocks
clk: at91: add PMC utmi clock
clk: at91: add PMC usb clock
clk: at91: add PMC smd clock
dt: binding: add at91 clks dt bindings documentation
ARM: at91: move pit timer to common clk framework
ARM: at91: add new compatible strings for pmc driver

 .../devicetree/bindings/clock/at91-clock.txt       |  339 +++++++++++++
 arch/arm/mach-at91/Kconfig                         |   44 ++
 arch/arm/mach-at91/Kconfig.non_dt                  |    6 +
 arch/arm/mach-at91/Makefile                        |    2 +-
 arch/arm/mach-at91/at91rm9200.c                    |    2 +-
 arch/arm/mach-at91/at91sam9260.c                   |    2 +-
 arch/arm/mach-at91/at91sam9261.c                   |    2 +-
 arch/arm/mach-at91/at91sam9263.c                   |    2 +-
 arch/arm/mach-at91/at91sam926x_time.c              |   14 +-
 arch/arm/mach-at91/at91sam9g45.c                   |    2 +-
 arch/arm/mach-at91/at91sam9n12.c                   |    2 +-
 arch/arm/mach-at91/at91sam9rl.c                    |    2 +-
 arch/arm/mach-at91/at91sam9x5.c                    |    2 +-
 arch/arm/mach-at91/clock.c                         |    7 +-
 arch/arm/mach-at91/generic.h                       |    3 +-
 arch/arm/mach-at91/pm.c                            |    2 +-
 arch/arm/mach-at91/pm_slowclock.S                  |    2 +-
 arch/arm/mach-at91/sama5d3.c                       |    2 +-
 arch/arm/mach-at91/setup.c                         |    8 +-
 drivers/clk/Makefile                               |    1 +
 drivers/clk/at91/Makefile                          |   12 +
 drivers/clk/at91/clk-main.c                        |  187 +++++++
 drivers/clk/at91/clk-master.c                      |  270 ++++++++++
 drivers/clk/at91/clk-peripheral.c                  |  410 +++++++++++++++
 drivers/clk/at91/clk-pll.c                         |  531 ++++++++++++++++++++
 drivers/clk/at91/clk-plldiv.c                      |  135 +++++
 drivers/clk/at91/clk-programmable.c                |  366 ++++++++++++++
 drivers/clk/at91/clk-smd.c                         |  171 +++++++
 drivers/clk/at91/clk-system.c                      |  135 +++++
 drivers/clk/at91/clk-usb.c                         |  398 +++++++++++++++
 drivers/clk/at91/clk-utmi.c                        |  159 ++++++
 drivers/clk/at91/pmc.c                             |  397 +++++++++++++++
 drivers/clk/at91/pmc.h                             |  116 +++++
 drivers/usb/gadget/atmel_usba_udc.c                |    2 +-
 include/dt-bindings/clk/at91.h                     |   22 +
 .../include/mach => include/linux/clk}/at91_pmc.h  |    4 +-
 36 files changed, 3741 insertions(+), 20 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/at91-clock.txt
 create mode 100644 drivers/clk/at91/Makefile
 create mode 100644 drivers/clk/at91/clk-main.c
 create mode 100644 drivers/clk/at91/clk-master.c
 create mode 100644 drivers/clk/at91/clk-peripheral.c
 create mode 100644 drivers/clk/at91/clk-pll.c
 create mode 100644 drivers/clk/at91/clk-plldiv.c
 create mode 100644 drivers/clk/at91/clk-programmable.c
 create mode 100644 drivers/clk/at91/clk-smd.c
 create mode 100644 drivers/clk/at91/clk-system.c
 create mode 100644 drivers/clk/at91/clk-usb.c
 create mode 100644 drivers/clk/at91/clk-utmi.c
 create mode 100644 drivers/clk/at91/pmc.c
 create mode 100644 drivers/clk/at91/pmc.h
 create mode 100644 include/dt-bindings/clk/at91.h
 rename {arch/arm/mach-at91/include/mach => include/linux/clk}/at91_pmc.h (98%)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v6 1/16 ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h

This patch moves at91_pmc.h header from machine specific directory (arch/arm/mach-at91/include/mach/at91_pmc.h) to clk include directory (include/linux/clk/at91_pmc.h).
We need this to avoid reference to machine specific headers in clk drivers.

---
 arch/arm/mach-at91/at91rm9200.c                    |    2 +-
 arch/arm/mach-at91/at91sam9260.c                   |    2 +-
 arch/arm/mach-at91/at91sam9261.c                   |    2 +-
 arch/arm/mach-at91/at91sam9263.c                   |    2 +-
 arch/arm/mach-at91/at91sam9g45.c                   |    2 +-
 arch/arm/mach-at91/at91sam9n12.c                   |    2 +-
 arch/arm/mach-at91/at91sam9rl.c                    |    2 +-
 arch/arm/mach-at91/at91sam9x5.c                    |    2 +-
 arch/arm/mach-at91/clock.c                         |    2 +-
 arch/arm/mach-at91/pm.c                            |    2 +-
 arch/arm/mach-at91/pm_slowclock.S                  |    2 +-
 arch/arm/mach-at91/sama5d3.c                       |    2 +-
 arch/arm/mach-at91/setup.c                         |    2 +-
 drivers/usb/gadget/atmel_usba_udc.c                |    2 +-
 .../include/mach => include/linux/clk}/at91_pmc.h  |    2 +-
 15 files changed, 15 insertions(+), 15 deletions(-)
 rename {arch/arm/mach-at91/include/mach => include/linux/clk}/at91_pmc.h (99%)
arch/arm/mach-at91/at91rm9200.c +1 -1
index 4aad93d..102dac6 100644
@@ -12,13 +12,13 @@
 
 #include <linux/module.h>
 #include <linux/reboot.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/irq.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/system_misc.h>
 #include <mach/at91rm9200.h>
-#include <mach/at91_pmc.h>
 #include <mach/at91_st.h>
 #include <mach/cpu.h>
 
arch/arm/mach-at91/at91sam9260.c +1 -1
index 5de6074..16d7817 100644
@@ -11,6 +11,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/proc-fns.h>
 #include <asm/irq.h>
@@ -20,7 +21,6 @@
 #include <mach/cpu.h>
 #include <mach/at91_dbgu.h>
 #include <mach/at91sam9260.h>
-#include <mach/at91_pmc.h>
 
 #include "at91_aic.h"
 #include "at91_rstc.h"
arch/arm/mach-at91/at91sam9261.c +1 -1
index 0e07932..c8f5958 100644
@@ -11,6 +11,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/proc-fns.h>
 #include <asm/irq.h>
@@ -19,7 +20,6 @@
 #include <asm/system_misc.h>
 #include <mach/cpu.h>
 #include <mach/at91sam9261.h>
-#include <mach/at91_pmc.h>
 
 #include "at91_aic.h"
 #include "at91_rstc.h"
arch/arm/mach-at91/at91sam9263.c +1 -1
index 6ce7d18..cd8ad95 100644
@@ -11,6 +11,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/proc-fns.h>
 #include <asm/irq.h>
@@ -18,7 +19,6 @@
 #include <asm/mach/map.h>
 #include <asm/system_misc.h>
 #include <mach/at91sam9263.h>
-#include <mach/at91_pmc.h>
 
 #include "at91_aic.h"
 #include "at91_rstc.h"
arch/arm/mach-at91/at91sam9g45.c +1 -1
index 474ee04..9794b20 100644
@@ -12,13 +12,13 @@
 
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/irq.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/system_misc.h>
 #include <mach/at91sam9g45.h>
-#include <mach/at91_pmc.h>
 #include <mach/cpu.h>
 
 #include "at91_aic.h"
arch/arm/mach-at91/at91sam9n12.c +1 -1
index 2d895a2..deafab2 100644
@@ -8,12 +8,12 @@
 
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/irq.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <mach/at91sam9n12.h>
-#include <mach/at91_pmc.h>
 #include <mach/cpu.h>
 
 #include "board.h"
arch/arm/mach-at91/at91sam9rl.c +1 -1
index d4ec0d9..947da95 100644
@@ -10,6 +10,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/proc-fns.h>
 #include <asm/irq.h>
@@ -19,7 +20,6 @@
 #include <mach/cpu.h>
 #include <mach/at91_dbgu.h>
 #include <mach/at91sam9rl.h>
-#include <mach/at91_pmc.h>
 
 #include "at91_aic.h"
 #include "at91_rstc.h"
arch/arm/mach-at91/at91sam9x5.c +1 -1
index 916e5a1..a930d73 100644
@@ -8,12 +8,12 @@
 
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/irq.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <mach/at91sam9x5.h>
-#include <mach/at91_pmc.h>
 #include <mach/cpu.h>
 
 #include "board.h"
arch/arm/mach-at91/clock.c +1 -1
index 6b2630a..5f02aea 100644
@@ -24,9 +24,9 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/of_address.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <mach/hardware.h>
-#include <mach/at91_pmc.h>
 #include <mach/cpu.h>
 
 #include <asm/proc-fns.h>
arch/arm/mach-at91/pm.c +1 -1
index 15afb5d..692cacd 100644
@@ -19,13 +19,13 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/irq.h>
 #include <linux/atomic.h>
 #include <asm/mach/time.h>
 #include <asm/mach/irq.h>
 
-#include <mach/at91_pmc.h>
 #include <mach/cpu.h>
 
 #include "at91_aic.h"
arch/arm/mach-at91/pm_slowclock.S +1 -1
index 098c28d..2001877 100644
@@ -13,8 +13,8 @@
  */
 
 #include <linux/linkage.h>
+#include <linux/clk/at91_pmc.h>
 #include <mach/hardware.h>
-#include <mach/at91_pmc.h>
 #include <mach/at91_ramc.h>
 
 
arch/arm/mach-at91/sama5d3.c +1 -1
index 4012797..0003949 100644
@@ -9,12 +9,12 @@
 
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/irq.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <mach/sama5d3.h>
-#include <mach/at91_pmc.h>
 #include <mach/cpu.h>
 
 #include "soc.h"
arch/arm/mach-at91/setup.c +1 -1
index b17fbcf..41aa68b 100644
@@ -11,6 +11,7 @@
 #include <linux/pm.h>
 #include <linux/of_address.h>
 #include <linux/pinctrl/machine.h>
+#include <linux/clk/at91_pmc.h>
 
 #include <asm/system_misc.h>
 #include <asm/mach/map.h>
@@ -18,7 +19,6 @@
 #include <mach/hardware.h>
 #include <mach/cpu.h>
 #include <mach/at91_dbgu.h>
-#include <mach/at91_pmc.h>
 
 #include "at91_shdwc.h"
 #include "soc.h"
drivers/usb/gadget/atmel_usba_udc.c +1 -1
index 2cb52e0..9f71d9f 100644
@@ -326,7 +326,7 @@ static int vbus_is_present(struct usba_udc *udc)
 
 #if defined(CONFIG_ARCH_AT91SAM9RL)
 
-#include <mach/at91_pmc.h>
+#include <linux/clk/at91_pmc.h>
 
 static void toggle_bias(int is_on)
 {
include/linux/clk/at91_pmc.h renamed from arch/arm/mach-at91/include/mach/at91_pmc.h +1 -1
similarity index 99%
rename from arch/arm/mach-at91/include/mach/at91_pmc.h
rename to include/linux/clk/at91_pmc.h
index c604cc6..00c45b3 100644
@@ -1,5 +1,5 @@
 /*
- * arch/arm/mach-at91/include/mach/at91_pmc.h
+ * include/linux/clk/at91_pmc.h
  *
  * Copyright (C) 2005 Ivan Kokshaysky
  * Copyright (C) SAN People
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v6 2/16 ARM: at91: add Kconfig options for common clk support

In reply to Boris BREZILLON

This patch adds the following Kconfig options to prepare the transition to common clk framework:

- AT91_USE_OLD_CLK: this option is selected by every SoC which does not support new at91 clks based on common clk framework (SoC which does not define the clock tree in its device tree).
This options is also selected when the user choose non dt boards support (new at91 clks can only be registered from a device tree definition).

- COMMON_CLK_AT91: this option cannot be selected directly. Instead it is enabled if these 3 conditions are met:
* at least one of the selected SoCs have a PMC (Power Management Controller) Unit
* device tree support is enabled
* the old at91 clk implementation is disabled (every selected SoC define its clks in its device tree and non dt boards support is disabled)

- OLD_CLK_AT91: this option cannot be selected directly. Instead it is enabled if these 2 conditions are met:
* at least one of the selected SoCs have a PMC (Power Management Controller) Unit
* at least one of the selected SoCs does not define its clks in its device tree or non dt-boards support is enabled

This patch selects AT91_USE_OLD_CLK in all currently supported SoCs. These selects will be removed after clk definitions are properly added in each soc's device tree.
It also selects AT91_USE_OLD_CLK in all non-dt boards support.

AT91_PMC_UNIT references are replaced by OLD_CLK_AT91, because PMC Unit is enabled for both old and common clk implementations, and old clk implementation should not be compiled if COMMON_CLK is enabled.

To avoid future link errors, a new stub is created for at91_dt_clock_init function if OLD_CLK_AT91 is disabled.

A new check is added in dt init functions (setup.c) to prepare for SoCs supporting new clk implementation. These SoCs won't setup the register_clocks callback (clk registration is done using of_clk_init).

---
 arch/arm/mach-at91/Kconfig        |   21 +++++++++++++++++++++
 arch/arm/mach-at91/Kconfig.non_dt |    6 ++++++
 arch/arm/mach-at91/Makefile       |    2 +-
 arch/arm/mach-at91/generic.h      |    3 ++-
 arch/arm/mach-at91/setup.c        |    6 ++++--
 5 files changed, 34 insertions(+), 4 deletions(-)
arch/arm/mach-at91/Kconfig +21 -0
index 699b71e..85b53a4 100644
@@ -6,10 +6,22 @@ config HAVE_AT91_DBGU0
 config HAVE_AT91_DBGU1
 	bool
 
+config AT91_USE_OLD_CLK
+	bool
+
 config AT91_PMC_UNIT
 	bool
 	default !ARCH_AT91X40
 
+config COMMON_CLK_AT91
+	bool
+	default AT91_PMC_UNIT && USE_OF && !AT91_USE_OLD_CLK
+	select COMMON_CLK
+
+config OLD_CLK_AT91
+	bool
+	default AT91_PMC_UNIT && AT91_USE_OLD_CLK
+
 config AT91_SAM9_ALT_RESET
 	bool
 	default !ARCH_AT91X40
@@ -65,6 +77,7 @@ config SOC_SAMA5D3
 	select SOC_SAMA5
 	select HAVE_FB_ATMEL
 	select HAVE_AT91_DBGU1
+	select AT91_USE_OLD_CLK
 	help
 	  Select this if you are using one of Atmel's SAMA5D3 family SoC.
 	  This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35.
@@ -78,11 +91,13 @@ config SOC_AT91RM9200
 	select HAVE_AT91_DBGU0
 	select MULTI_IRQ_HANDLER
 	select SPARSE_IRQ
+	select AT91_USE_OLD_CLK
 
 config SOC_AT91SAM9260
 	bool "AT91SAM9260, AT91SAM9XE or AT91SAM9G20"
 	select HAVE_AT91_DBGU0
 	select SOC_AT91SAM9
+	select AT91_USE_OLD_CLK
 	help
 	  Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE
 	  or AT91SAM9G20 SoC.
@@ -92,6 +107,7 @@ config SOC_AT91SAM9261
 	select HAVE_AT91_DBGU0
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
+	select AT91_USE_OLD_CLK
 	help
 	  Select this if you are using one of Atmel's AT91SAM9261 or AT91SAM9G10 SoC.
 
@@ -100,18 +116,21 @@ config SOC_AT91SAM9263
 	select HAVE_AT91_DBGU1
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
+	select AT91_USE_OLD_CLK
 
 config SOC_AT91SAM9RL
 	bool "AT91SAM9RL"
 	select HAVE_AT91_DBGU0
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
+	select AT91_USE_OLD_CLK
 
 config SOC_AT91SAM9G45
 	bool "AT91SAM9G45 or AT91SAM9M10 families"
 	select HAVE_AT91_DBGU1
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
+	select AT91_USE_OLD_CLK
 	help
 	  Select this if you are using one of Atmel's AT91SAM9G45 family SoC.
 	  This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11.
@@ -121,6 +140,7 @@ config SOC_AT91SAM9X5
 	select HAVE_AT91_DBGU0
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
+	select AT91_USE_OLD_CLK
 	help
 	  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
 	  This means that your SAM9 name finishes with a '5' (except if it is
@@ -133,6 +153,7 @@ config SOC_AT91SAM9N12
 	select HAVE_AT91_DBGU0
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
+	select AT91_USE_OLD_CLK
 	help
 	  Select this if you are using Atmel's AT91SAM9N12 SoC.
 
arch/arm/mach-at91/Kconfig.non_dt +6 -0
index ca900be..b736b57 100644
@@ -12,26 +12,32 @@ config ARCH_AT91_NONE
 config ARCH_AT91RM9200
 	bool "AT91RM9200"
 	select SOC_AT91RM9200
+	select AT91_USE_OLD_CLK
 
 config ARCH_AT91SAM9260
 	bool "AT91SAM9260 or AT91SAM9XE or AT91SAM9G20"
 	select SOC_AT91SAM9260
+	select AT91_USE_OLD_CLK
 
 config ARCH_AT91SAM9261
 	bool "AT91SAM9261 or AT91SAM9G10"
 	select SOC_AT91SAM9261
+	select AT91_USE_OLD_CLK
 
 config ARCH_AT91SAM9263
 	bool "AT91SAM9263"
 	select SOC_AT91SAM9263
+	select AT91_USE_OLD_CLK
 
 config ARCH_AT91SAM9RL
 	bool "AT91SAM9RL"
 	select SOC_AT91SAM9RL
+	select AT91_USE_OLD_CLK
 
 config ARCH_AT91SAM9G45
 	bool "AT91SAM9G45"
 	select SOC_AT91SAM9G45
+	select AT91_USE_OLD_CLK
 
 config ARCH_AT91X40
 	bool "AT91x40"
arch/arm/mach-at91/Makefile +1 -1
index 3b0a953..8539411 100644
@@ -7,7 +7,7 @@ obj-m		:=
 obj-n		:=
 obj-		:=
 
-obj-$(CONFIG_AT91_PMC_UNIT)	+= clock.o
+obj-$(CONFIG_OLD_CLK_AT91)	+= clock.o
 obj-$(CONFIG_AT91_SAM9_ALT_RESET) += at91sam9_alt_reset.o
 obj-$(CONFIG_AT91_SAM9G45_RESET) += at91sam9g45_reset.o
 obj-$(CONFIG_AT91_SAM9_TIME)	+= at91sam926x_time.o
arch/arm/mach-at91/generic.h +2 -1
index dc6e2f5..375c42e 100644
@@ -44,11 +44,12 @@ extern void at91sam926x_pit_init(void);
 extern void at91x40_timer_init(void);
 
  /* Clocks */
-#ifdef CONFIG_AT91_PMC_UNIT
+#ifdef CONFIG_OLD_CLK_AT91
 extern int __init at91_clock_init(unsigned long main_clock);
 extern int __init at91_dt_clock_init(void);
 #else
 static int inline at91_clock_init(unsigned long main_clock) { return 0; }
+static int inline at91_dt_clock_init(void) { return 0; }
 #endif
 struct device;
 
arch/arm/mach-at91/setup.c +4 -2
index 41aa68b..06052fc 100644
@@ -483,7 +483,8 @@ void __init at91rm9200_dt_initialize(void)
 	at91_dt_clock_init();
 
 	/* Register the processor-specific clocks */
-	at91_boot_soc.register_clocks();
+	if (at91_boot_soc.register_clocks)
+		at91_boot_soc.register_clocks();
 
 	at91_boot_soc.init();
 }
@@ -498,7 +499,8 @@ void __init at91_dt_initialize(void)
 	at91_dt_clock_init();
 
 	/* Register the processor-specific clocks */
-	at91_boot_soc.register_clocks();
+	if (at91_boot_soc.register_clocks)
+		at91_boot_soc.register_clocks();
 
 	if (at91_boot_soc.init)
 		at91_boot_soc.init();
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v6 3/16 clk: at91: add PMC base support

In reply to Boris BREZILLON

This patch adds at91 PMC (Power Management Controller) base support.

All at91 clocks managed by the PMC unit will use this framework.

This framework provides the following fonctionalities:
- define a new struct at91_pmc to hide PMC internals (lock, PMC memory mapping, irq domain, ...)
- read/write helper functions (pmc_read/write) to access PMC registers
- lock/unlock helper functions (pmc_lock/unlock) to lock/unlock access to pmc registers
- a new irq domain and its associated irq chip to request PMC specific interrupts (useful for clk prepare callbacks)

The PMC unit is declared as a dt clk provider (CLK_OF_DECLARE), and every clk using this framework will declare a table of of_at91_clk_init_cb_t and add it to the pmc_clk_ids table.

When the pmc dt clock setup function is called (by of_clk_init function), it triggers the registration of every supported child clk (those matching the definitions in pmc_clk_ids).

This patch copies at91_pmc_base (memory mapping) and at91sam9_idle (function) from arch/arm/mach-at91/clock.c (which is not compiled if COMMON_CLK_AT91 is enabled).

---
 drivers/clk/Makefile      |    1 +
 drivers/clk/at91/Makefile |    5 +
 drivers/clk/at91/pmc.c    |  304 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h    |   61 +++++++++
 4 files changed, 371 insertions(+)
 create mode 100644 drivers/clk/at91/Makefile
 create mode 100644 drivers/clk/at91/pmc.c
 create mode 100644 drivers/clk/at91/pmc.h
drivers/clk/Makefile +1 -0
index 7b11106..28c2678 100644
@@ -32,6 +32,7 @@ obj-$(CONFIG_ARCH_VT8500)	+= clk-vt8500.o
 obj-$(CONFIG_ARCH_ZYNQ)		+= zynq/
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 obj-$(CONFIG_PLAT_SAMSUNG)	+= samsung/
+obj-$(CONFIG_COMMON_CLK_AT91)	+= at91/
 
 obj-$(CONFIG_X86)		+= x86/
 
drivers/clk/at91/Makefile new file +5 -0
new file mode 100644
index 0000000..1d4fb21
@@ -0,0 +1,5 @@
+#
+# Makefile for at91 specific clk
+#
+
+obj-y += pmc.o
drivers/clk/at91/pmc.c new file +304 -0

304 lines not on this page · raw message

drivers/clk/at91/pmc.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v6 4/16 clk: at91: add PMC macro file for dt definitions

In reply to Boris BREZILLON

This patch adds a new macro file for PMC macros.

This macro file includes the definitions of SR (status register) bit offsets and will be use to reference PMC irqs.

---
 include/dt-bindings/clk/at91.h |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 include/dt-bindings/clk/at91.h
include/dt-bindings/clk/at91.h new file +22 -0
new file mode 100644
index 0000000..0b4cb99
@@ -0,0 +1,22 @@
+/*
+ * This header provides constants for AT91 pmc status.
+ *
+ * The constants defined in this header are being used in dts.
+ *
+ * Licensed under GPLv2 or later.
+ */
+
+#ifndef _DT_BINDINGS_CLK_AT91_H
+#define _DT_BINDINGS_CLK_AT91_H
+
+#define AT91_PMC_MOSCS		0		/* MOSCS Flag */
+#define AT91_PMC_LOCKA		1		/* PLLA Lock */
+#define AT91_PMC_LOCKB		2		/* PLLB Lock */
+#define AT91_PMC_MCKRDY		3		/* Master Clock */
+#define AT91_PMC_LOCKU		6		/* UPLL Lock */
+#define AT91_PMC_PCKRDY(id)	(8 + (id))	/* Programmable Clock */
+#define AT91_PMC_MOSCSELS	16		/* Main Oscillator Selection */
+#define AT91_PMC_MOSCRCS	17		/* Main On-Chip RC */
+#define AT91_PMC_CFDEV		18		/* Clock Failure Detector Event */
+
+#endif
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v6 5/16 clk: at91: add PMC main clock

In reply to Boris BREZILLON

This patch adds new at91 main oscillator clock implementation using common clk framework.

If rate is not provided during clock registration it is calculated using the slow clock (main clk parent in this case) rate and MCFR register.

---
 drivers/clk/at91/Makefile   |    1 +
 drivers/clk/at91/clk-main.c |  187 +++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.c      |    5 ++
 drivers/clk/at91/pmc.h      |    3 +
 4 files changed, 196 insertions(+)
 create mode 100644 drivers/clk/at91/clk-main.c
drivers/clk/at91/Makefile +1 -0
index 1d4fb21..44105bd 100644
@@ -3,3 +3,4 @@
 #
 
 obj-y += pmc.o
+obj-y += clk-main.o
drivers/clk/at91/clk-main.c new file +187 -0

187 lines not on this page · raw message

drivers/clk/at91/pmc.c +5 -0
index 69c116a..3d35b73 100644
@@ -229,6 +229,11 @@ out_free_pmc:
 }
 
 static const struct of_device_id pmc_clk_ids[] __initdata = {
+	/* Main clock */
+	{
+		.compatible = "atmel,at91rm9200-clk-main",
+		.data = of_at91rm9200_clk_main_setup,
+	},
 	{ /*sentinel*/ }
 };
 
drivers/clk/at91/pmc.h +3 -0
index d92b946..729aa46 100644
@@ -58,4 +58,7 @@ static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value)
 int of_at91_get_clk_range(struct device_node *np, const char *propname,
 			  struct clk_range *range);
 
+extern void __init of_at91rm9200_clk_main_setup(struct device_node *np,
+						struct at91_pmc *pmc);
+
 #endif /* __PMC_H_ */
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v6 6/16 clk: at91: add PMC pll clocks

In reply to Boris BREZILLON

This patch adds new at91 pll clock implementation using common clk framework.

The pll clock layout describe the PLLX register layout. There are four pll clock layouts:
- at91rm9200
- at91sam9g20
- at91sam9g45
- sama5d3

PLL clocks are given characteristics:
- min/max clock source rate
- ranges of valid clock output rates
- values to set in out and icpll fields for each supported output range

These characteristics are checked during rate change to avoid over/underclocking.

These characteristics are described in atmel's SoC datasheet in "Electrical Characteristics" paragraph.

---
 drivers/clk/at91/Makefile     |    2 +-
 drivers/clk/at91/clk-pll.c    |  537 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/clk-plldiv.c |  135 +++++++++++
 drivers/clk/at91/pmc.c        |   21 ++
 drivers/clk/at91/pmc.h        |   11 +
 include/linux/clk/at91_pmc.h  |    2 +
 6 files changed, 707 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/at91/clk-pll.c
 create mode 100644 drivers/clk/at91/clk-plldiv.c
drivers/clk/at91/Makefile +1 -1
index 44105bd..902bbf1 100644
@@ -3,4 +3,4 @@
 #
 
 obj-y += pmc.o
-obj-y += clk-main.o
+obj-y += clk-main.o clk-pll.o clk-plldiv.o
drivers/clk/at91/clk-pll.c new file +537 -0

537 lines not on this page · raw message

drivers/clk/at91/clk-plldiv.c new file +135 -0

135 lines not on this page · raw message

drivers/clk/at91/pmc.c +21 -0
index 3d35b73..5af3f2f 100644
@@ -234,6 +234,27 @@ static const struct of_device_id pmc_clk_ids[] __initdata = {
 		.compatible = "atmel,at91rm9200-clk-main",
 		.data = of_at91rm9200_clk_main_setup,
 	},
+	/* PLL clocks */
+	{
+		.compatible = "atmel,at91rm9200-clk-pll",
+		.data = of_at91rm9200_clk_pll_setup,
+	},
+	{
+		.compatible = "atmel,at91sam9g45-clk-pll",
+		.data = of_at91sam9g45_clk_pll_setup,
+	},
+	{
+		.compatible = "atmel,at91sam9g20-clk-pllb",
+		.data = of_at91sam9g20_clk_pllb_setup,
+	},
+	{
+		.compatible = "atmel,sama5d3-clk-pll",
+		.data = of_sama5d3_clk_pll_setup,
+	},
+	{
+		.compatible = "atmel,at91sam9x5-clk-plldiv",
+		.data = of_at91sam9x5_clk_plldiv_setup,
+	},
 	{ /*sentinel*/ }
 };
 
drivers/clk/at91/pmc.h +11 -0
index 729aa46..15aaf38 100644
@@ -61,4 +61,15 @@ int of_at91_get_clk_range(struct device_node *np, const char *propname,
 extern void __init of_at91rm9200_clk_main_setup(struct device_node *np,
 						struct at91_pmc *pmc);
 
+extern void __init of_at91rm9200_clk_pll_setup(struct device_node *np,
+					       struct at91_pmc *pmc);
+extern void __init of_at91sam9g45_clk_pll_setup(struct device_node *np,
+						struct at91_pmc *pmc);
+extern void __init of_at91sam9g20_clk_pllb_setup(struct device_node *np,
+						 struct at91_pmc *pmc);
+extern void __init of_sama5d3_clk_pll_setup(struct device_node *np,
+					    struct at91_pmc *pmc);
+extern void __init of_at91sam9x5_clk_plldiv_setup(struct device_node *np,
+						  struct at91_pmc *pmc);
+
 #endif /* __PMC_H_ */
include/linux/clk/at91_pmc.h +2 -0
index 00c45b3..a6911eb 100644
@@ -164,6 +164,8 @@ extern void __iomem *at91_pmc_base;
 #define		AT91_PMC_CFDEV		(1 << 18)		/* Clock Failure Detector Event [some SAM9] */
 #define	AT91_PMC_IMR		0x6c			/* Interrupt Mask Register */
 
+#define AT91_PMC_PLLICPR	0x80			/* PLL Charge Pump Current Register */
+
 #define AT91_PMC_PROT		0xe4			/* Write Protect Mode Register [some SAM9] */
 #define		AT91_PMC_WPEN		(0x1  <<  0)		/* Write Protect Enable */
 #define		AT91_PMC_WPKEY		(0xffffff << 8)		/* Write Protect Key */
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v6 7/16 clk: at91: add PMC master clock

In reply to Boris BREZILLON

This patch adds new at91 master clock implementation using common clk framework.

The master clock layout describe the MCKR register layout. There are 2 master clock layouts:
- at91rm9200
- at91sam9x5

Master clocks are given characteristics:
- min/max clock output rate

These characteristics are checked during rate change to avoid over/underclocking.

These characteristics are described in atmel's SoC datasheet in "Electrical Characteristics" paragraph.

---
 drivers/clk/at91/Makefile     |    2 +-
 drivers/clk/at91/clk-master.c |  270 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/clk-pll.c    |   10 +-
 drivers/clk/at91/pmc.c        |    9 ++
 drivers/clk/at91/pmc.h        |    5 +
 5 files changed, 287 insertions(+), 9 deletions(-)
 create mode 100644 drivers/clk/at91/clk-master.c
drivers/clk/at91/Makefile +1 -1
index 902bbf1..e28fb2b 100644
@@ -3,4 +3,4 @@
 #
 
 obj-y += pmc.o
-obj-y += clk-main.o clk-pll.o clk-plldiv.o
+obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o
drivers/clk/at91/clk-master.c new file +270 -0

270 lines not on this page · raw message

drivers/clk/at91/clk-pll.c +2 -8
index 5e23ee4..cf6ed02 100644
@@ -80,6 +80,8 @@ static int clk_pll_prepare(struct clk_hw *hw)
 	struct clk_pll *pll = to_clk_pll(hw);
 	struct at91_pmc *pmc = pll->pmc;
 	const struct clk_pll_layout *layout = pll->layout;
+	const struct clk_pll_characteristics *characteristics =
+							pll->characteristics;
 	u8 id = pll->id;
 	u32 mask = PLL_STATUS_MASK(id);
 	int offset = PLL_REG(id);
@@ -269,18 +271,10 @@ static int clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 			    unsigned long parent_rate)
 {
 	struct clk_pll *pll = to_clk_pll(hw);
-	struct at91_pmc *pmc = pll->pmc;
-	const struct clk_pll_layout *layout = pll->layout;
-	const struct clk_pll_characteristics *characteristics =
-						pll->characteristics;
-	u8 id = pll->id;
-	int offset = PLL_REG(id);
 	long ret;
 	u32 div;
 	u32 mul;
 	u32 index;
-	u32 tmp;
-	u8 out = 0;
 
 	ret = clk_pll_get_best_div_mul(pll, rate, parent_rate,
 				       &div, &mul, &index);
drivers/clk/at91/pmc.c +9 -0
index 5af3f2f..a311cf3 100644
@@ -255,6 +255,15 @@ static const struct of_device_id pmc_clk_ids[] __initdata = {
 		.compatible = "atmel,at91sam9x5-clk-plldiv",
 		.data = of_at91sam9x5_clk_plldiv_setup,
 	},
+	/* Master clock */
+	{
+		.compatible = "atmel,at91rm9200-clk-master",
+		.data = of_at91rm9200_clk_master_setup,
+	},
+	{
+		.compatible = "atmel,at91sam9x5-clk-master",
+		.data = of_at91sam9x5_clk_master_setup,
+	},
 	{ /*sentinel*/ }
 };
 
drivers/clk/at91/pmc.h +5 -0
index 15aaf38..be5c964 100644
@@ -72,4 +72,9 @@ extern void __init of_sama5d3_clk_pll_setup(struct device_node *np,
 extern void __init of_at91sam9x5_clk_plldiv_setup(struct device_node *np,
 						  struct at91_pmc *pmc);
 
+extern void __init of_at91rm9200_clk_master_setup(struct device_node *np,
+						  struct at91_pmc *pmc);
+extern void __init of_at91sam9x5_clk_master_setup(struct device_node *np,
+						  struct at91_pmc *pmc);
+
 #endif /* __PMC_H_ */
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v6 8/16 clk: at91: add PMC system clocks

In reply to Boris BREZILLON

This patch adds new at91 system clock implementation using common clk framework.

Some peripherals need to enable a "system" clock in order to work properly. Each system clock is given an id based on the bit position in SCER/SCDR registers.

---
 drivers/clk/at91/Makefile     |    1 +
 drivers/clk/at91/clk-system.c |  135 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.c        |    5 ++
 drivers/clk/at91/pmc.h        |    3 +
 4 files changed, 144 insertions(+)
 create mode 100644 drivers/clk/at91/clk-system.c
drivers/clk/at91/Makefile +1 -0
index e28fb2b..c2b7068 100644
@@ -4,3 +4,4 @@
 
 obj-y += pmc.o
 obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o
+obj-y += clk-system.o
drivers/clk/at91/clk-system.c new file +135 -0

135 lines not on this page · raw message

drivers/clk/at91/pmc.c +5 -0
index a311cf3..a97554f 100644
@@ -264,6 +264,11 @@ static const struct of_device_id pmc_clk_ids[] __initdata = {
 		.compatible = "atmel,at91sam9x5-clk-master",
 		.data = of_at91sam9x5_clk_master_setup,
 	},
+	/* System clocks */
+	{
+		.compatible = "atmel,at91rm9200-clk-system",
+		.data = of_at91rm9200_clk_sys_setup,
+	},
 	{ /*sentinel*/ }
 };
 
drivers/clk/at91/pmc.h +3 -0
index be5c964..9c8a397 100644
@@ -77,4 +77,7 @@ extern void __init of_at91rm9200_clk_master_setup(struct device_node *np,
 extern void __init of_at91sam9x5_clk_master_setup(struct device_node *np,
 						  struct at91_pmc *pmc);
 
+extern void __init of_at91rm9200_clk_sys_setup(struct device_node *np,
+					       struct at91_pmc *pmc);
+
 #endif /* __PMC_H_ */
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v6 9/16 clk: at91: add PMC peripheral clocks

In reply to Boris BREZILLON

This patch adds new at91 peripheral clock implementation using common clk framework.

Almost all peripherals provided by at91 SoCs need a clock to work properly. This clock is enabled/disabled using PCER/PCDR resgisters.

Each peripheral is given an id (see atmel's datasheets) which is used to define and reference peripheral clocks.

Some new SoCs (at91sam9x5 and sama5d3) provide a new register (PCR) where you can configure the peripheral clock as a division of the master clock. This will help reducing the peripherals power comsumption.

---
 drivers/clk/at91/Makefile         |    2 +-
 drivers/clk/at91/clk-peripheral.c |  410 +++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.c            |    9 +
 drivers/clk/at91/pmc.h            |    5 +
 4 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/at91/clk-peripheral.c
drivers/clk/at91/Makefile +1 -1
index c2b7068..04deba3 100644
@@ -4,4 +4,4 @@
 
 obj-y += pmc.o
 obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o
-obj-y += clk-system.o
+obj-y += clk-system.o clk-peripheral.o
drivers/clk/at91/clk-peripheral.c new file +410 -0

410 lines not on this page · raw message

drivers/clk/at91/pmc.c +9 -0
index a97554f..afdfeb2 100644
@@ -269,6 +269,15 @@ static const struct of_device_id pmc_clk_ids[] __initdata = {
 		.compatible = "atmel,at91rm9200-clk-system",
 		.data = of_at91rm9200_clk_sys_setup,
 	},
+	/* Peripheral clocks */
+	{
+		.compatible = "atmel,at91rm9200-clk-peripheral",
+		.data = of_at91rm9200_clk_periph_setup,
+	},
+	{
+		.compatible = "atmel,at91sam9x5-clk-peripheral",
+		.data = of_at91sam9x5_clk_periph_setup,
+	},
 	{ /*sentinel*/ }
 };
 
drivers/clk/at91/pmc.h +5 -0
index 9c8a397..a09212b 100644
@@ -80,4 +80,9 @@ extern void __init of_at91sam9x5_clk_master_setup(struct device_node *np,
 extern void __init of_at91rm9200_clk_sys_setup(struct device_node *np,
 					       struct at91_pmc *pmc);
 
+extern void __init of_at91rm9200_clk_periph_setup(struct device_node *np,
+						  struct at91_pmc *pmc);
+extern void __init of_at91sam9x5_clk_periph_setup(struct device_node *np,
+						  struct at91_pmc *pmc);
+
 #endif /* __PMC_H_ */
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v6 10/16 clk: at91: add PMC programmable clocks

In reply to Boris BREZILLON

This patch adds new at91 programmable clocks implementation using common clk framework.
A programmable clock is a clock which can be exported on a given pin to clock external devices.
Each programmable clock is given an id (from 0 to 8).
The number of available programmable clocks depends on the SoC you're using. Programmable clock driver only implements the clock setting (clock rate and parent setting). It must be chained to a system clock in order to enable/disable the generated clock.
The PCKX pins used to output the clock signals must be assigned to the appropriate peripheral (see atmel's datasheets).

---
 drivers/clk/at91/Makefile           |    2 +
 drivers/clk/at91/clk-programmable.c |  366 +++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.c              |   15 ++
 drivers/clk/at91/pmc.h              |    9 +
 4 files changed, 392 insertions(+)
 create mode 100644 drivers/clk/at91/clk-programmable.c
drivers/clk/at91/Makefile +2 -0
index 04deba3..3873b62 100644
@@ -5,3 +5,5 @@
 obj-y += pmc.o
 obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o
 obj-y += clk-system.o clk-peripheral.o
+
+obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS)	+= clk-programmable.o
drivers/clk/at91/clk-programmable.c new file +366 -0

366 lines not on this page · raw message

drivers/clk/at91/pmc.c +15 -0
index afdfeb2..d0a1f93 100644
@@ -278,6 +278,21 @@ static const struct of_device_id pmc_clk_ids[] __initdata = {
 		.compatible = "atmel,at91sam9x5-clk-peripheral",
 		.data = of_at91sam9x5_clk_periph_setup,
 	},
+	/* Programmable clocks */
+#if defined(CONFIG_AT91_PROGRAMMABLE_CLOCKS)
+	{
+		.compatible = "atmel,at91rm9200-clk-programmable",
+		.data = of_at91rm9200_clk_prog_setup,
+	},
+	{
+		.compatible = "atmel,at91sam9g45-clk-programmable",
+		.data = of_at91sam9g45_clk_prog_setup,
+	},
+	{
+		.compatible = "atmel,at91sam9x5-clk-programmable",
+		.data = of_at91sam9x5_clk_prog_setup,
+	},
+#endif
 	{ /*sentinel*/ }
 };
 
drivers/clk/at91/pmc.h +9 -0
index a09212b..6eeed49 100644
@@ -85,4 +85,13 @@ extern void __init of_at91rm9200_clk_periph_setup(struct device_node *np,
 extern void __init of_at91sam9x5_clk_periph_setup(struct device_node *np,
 						  struct at91_pmc *pmc);
 
+#if defined(CONFIG_AT91_PROGRAMMABLE_CLOCKS)
+extern void __init of_at91rm9200_clk_prog_setup(struct device_node *np,
+						struct at91_pmc *pmc);
+extern void __init of_at91sam9g45_clk_prog_setup(struct device_node *np,
+						 struct at91_pmc *pmc);
+extern void __init of_at91sam9x5_clk_prog_setup(struct device_node *np,
+						struct at91_pmc *pmc);
+#endif
+
 #endif /* __PMC_H_ */
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH v6 11/16 clk: at91: add PMC utmi clock

In reply to Boris BREZILLON

This adds new at91 utmi clock implementation using common clk framework.

This clock is a pll with a fixed factor (x40).
It is used as a source for usb clock.

---
 arch/arm/mach-at91/Kconfig  |    7 ++
 drivers/clk/at91/Makefile   |    1 +
 drivers/clk/at91/clk-utmi.c |  159 +++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.c      |    7 ++
 drivers/clk/at91/pmc.h      |    5 ++
 5 files changed, 179 insertions(+)
 create mode 100644 drivers/clk/at91/clk-utmi.c
arch/arm/mach-at91/Kconfig +7 -0
index 85b53a4..6ad37da 100644
@@ -1,5 +1,8 @@
 if ARCH_AT91
 
+config HAVE_AT91_UTMI
+	bool
+
 config HAVE_AT91_DBGU0
 	bool
 
@@ -78,6 +81,7 @@ config SOC_SAMA5D3
 	select HAVE_FB_ATMEL
 	select HAVE_AT91_DBGU1
 	select AT91_USE_OLD_CLK
+	select HAVE_AT91_UTMI
 	help
 	  Select this if you are using one of Atmel's SAMA5D3 family SoC.
 	  This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35.
@@ -124,6 +128,7 @@ config SOC_AT91SAM9RL
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
+	select HAVE_AT91_UTMI
 
 config SOC_AT91SAM9G45
 	bool "AT91SAM9G45 or AT91SAM9M10 families"
@@ -131,6 +136,7 @@ config SOC_AT91SAM9G45
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
+	select HAVE_AT91_UTMI
 	help
 	  Select this if you are using one of Atmel's AT91SAM9G45 family SoC.
 	  This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11.
@@ -141,6 +147,7 @@ config SOC_AT91SAM9X5
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
+	select HAVE_AT91_UTMI
 	help
 	  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
 	  This means that your SAM9 name finishes with a '5' (except if it is
drivers/clk/at91/Makefile +1 -0
index 3873b62..a824883 100644
@@ -7,3 +7,4 @@ obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o
 obj-y += clk-system.o clk-peripheral.o
 
 obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS)	+= clk-programmable.o
+obj-$(CONFIG_HAVE_AT91_UTMI)		+= clk-utmi.o
drivers/clk/at91/clk-utmi.c new file +159 -0

159 lines not on this page · raw message

drivers/clk/at91/pmc.c +7 -0
index d0a1f93..0f667fd 100644
@@ -293,6 +293,13 @@ static const struct of_device_id pmc_clk_ids[] __initdata = {
 		.data = of_at91sam9x5_clk_prog_setup,
 	},
 #endif
+	/* UTMI clock */
+#if defined(CONFIG_HAVE_AT91_UTMI)
+	{
+		.compatible = "atmel,at91sam9x5-clk-utmi",
+		.data = of_at91sam9x5_clk_utmi_setup,
+	},
+#endif
 	{ /*sentinel*/ }
 };
 
drivers/clk/at91/pmc.h +5 -0
index 6eeed49..8e18ab0 100644
@@ -94,4 +94,9 @@ extern void __init of_at91sam9x5_clk_prog_setup(struct device_node *np,
 						struct at91_pmc *pmc);
 #endif
 
+#if defined(CONFIG_HAVE_AT91_UTMI)
+extern void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np,
+						struct at91_pmc *pmc);
+#endif
+
 #endif /* __PMC_H_ */
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH v6 12/16 clk: at91: add PMC usb clock

In reply to Boris BREZILLON

This patch adds new at91 usb clock implementation using common clk framework. This clock is used to clock usb ports (ohci, ehci and udc).

---
 arch/arm/mach-at91/Kconfig |   11 ++
 drivers/clk/at91/Makefile  |    1 +
 drivers/clk/at91/clk-usb.c |  398 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.c     |   15 ++
 drivers/clk/at91/pmc.h     |    9 +
 5 files changed, 434 insertions(+)
 create mode 100644 drivers/clk/at91/clk-usb.c
arch/arm/mach-at91/Kconfig +11 -0
index 6ad37da..b76dc4c 100644
@@ -3,6 +3,9 @@ if ARCH_AT91
 config HAVE_AT91_UTMI
 	bool
 
+config HAVE_AT91_USB_CLK
+	bool
+
 config HAVE_AT91_DBGU0
 	bool
 
@@ -82,6 +85,7 @@ config SOC_SAMA5D3
 	select HAVE_AT91_DBGU1
 	select AT91_USE_OLD_CLK
 	select HAVE_AT91_UTMI
+	select HAVE_AT91_USB_CLK
 	help
 	  Select this if you are using one of Atmel's SAMA5D3 family SoC.
 	  This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35.
@@ -96,12 +100,14 @@ config SOC_AT91RM9200
 	select MULTI_IRQ_HANDLER
 	select SPARSE_IRQ
 	select AT91_USE_OLD_CLK
+	select HAVE_AT91_USB_CLK
 
 config SOC_AT91SAM9260
 	bool "AT91SAM9260, AT91SAM9XE or AT91SAM9G20"
 	select HAVE_AT91_DBGU0
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
+	select HAVE_AT91_USB_CLK
 	help
 	  Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE
 	  or AT91SAM9G20 SoC.
@@ -112,6 +118,7 @@ config SOC_AT91SAM9261
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
+	select HAVE_AT91_USB_CLK
 	help
 	  Select this if you are using one of Atmel's AT91SAM9261 or AT91SAM9G10 SoC.
 
@@ -121,6 +128,7 @@ config SOC_AT91SAM9263
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
+	select HAVE_AT91_USB_CLK
 
 config SOC_AT91SAM9RL
 	bool "AT91SAM9RL"
@@ -137,6 +145,7 @@ config SOC_AT91SAM9G45
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
 	select HAVE_AT91_UTMI
+	select HAVE_AT91_USB_CLK
 	help
 	  Select this if you are using one of Atmel's AT91SAM9G45 family SoC.
 	  This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11.
@@ -148,6 +157,7 @@ config SOC_AT91SAM9X5
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
 	select HAVE_AT91_UTMI
+	select HAVE_AT91_USB_CLK
 	help
 	  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
 	  This means that your SAM9 name finishes with a '5' (except if it is
@@ -161,6 +171,7 @@ config SOC_AT91SAM9N12
 	select HAVE_FB_ATMEL
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
+	select HAVE_AT91_USB_CLK
 	help
 	  Select this if you are using Atmel's AT91SAM9N12 SoC.
 
drivers/clk/at91/Makefile +1 -0
index a824883..61db058 100644
@@ -8,3 +8,4 @@ obj-y += clk-system.o clk-peripheral.o
 
 obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS)	+= clk-programmable.o
 obj-$(CONFIG_HAVE_AT91_UTMI)		+= clk-utmi.o
+obj-$(CONFIG_HAVE_AT91_USB_CLK)		+= clk-usb.o
drivers/clk/at91/clk-usb.c new file +398 -0

398 lines not on this page · raw message

drivers/clk/at91/pmc.c +15 -0
index 0f667fd..4fba500 100644
@@ -300,6 +300,21 @@ static const struct of_device_id pmc_clk_ids[] __initdata = {
 		.data = of_at91sam9x5_clk_utmi_setup,
 	},
 #endif
+	/* USB clock */
+#if defined(CONFIG_HAVE_AT91_USB_CLK)
+	{
+		.compatible = "atmel,at91rm9200-clk-usb",
+		.data = of_at91rm9200_clk_usb_setup,
+	},
+	{
+		.compatible = "atmel,at91sam9x5-clk-usb",
+		.data = of_at91sam9x5_clk_usb_setup,
+	},
+	{
+		.compatible = "atmel,at91sam9n12-clk-usb",
+		.data = of_at91sam9n12_clk_usb_setup,
+	},
+#endif
 	{ /*sentinel*/ }
 };
 
drivers/clk/at91/pmc.h +9 -0
index 8e18ab0..2483ddc 100644
@@ -99,4 +99,13 @@ extern void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np,
 						struct at91_pmc *pmc);
 #endif
 
+#if defined(CONFIG_HAVE_AT91_USB_CLK)
+extern void __init of_at91rm9200_clk_usb_setup(struct device_node *np,
+					       struct at91_pmc *pmc);
+extern void __init of_at91sam9x5_clk_usb_setup(struct device_node *np,
+					       struct at91_pmc *pmc);
+extern void __init of_at91sam9n12_clk_usb_setup(struct device_node *np,
+						struct at91_pmc *pmc);
+#endif
+
 #endif /* __PMC_H_ */
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH v6 13/16 clk: at91: add PMC smd clock

In reply to Boris BREZILLON

This patch adds at91 smd (Soft Modem) clock implementation using common clk framework.

Not used by any driver right now.

---
 arch/arm/mach-at91/Kconfig |    5 ++
 drivers/clk/at91/Makefile  |    1 +
 drivers/clk/at91/clk-smd.c |  171 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.c     |    7 ++
 drivers/clk/at91/pmc.h     |    5 ++
 5 files changed, 189 insertions(+)
 create mode 100644 drivers/clk/at91/clk-smd.c
arch/arm/mach-at91/Kconfig +5 -0
index b76dc4c..97033f7 100644
@@ -39,6 +39,9 @@ config AT91_SAM9G45_RESET
 config AT91_SAM9_TIME
 	bool
 
+config HAVE_AT91_SMD
+	bool
+
 config SOC_AT91SAM9
 	bool
 	select AT91_SAM9_TIME
@@ -85,6 +88,7 @@ config SOC_SAMA5D3
 	select HAVE_AT91_DBGU1
 	select AT91_USE_OLD_CLK
 	select HAVE_AT91_UTMI
+	select HAVE_AT91_SMD
 	select HAVE_AT91_USB_CLK
 	help
 	  Select this if you are using one of Atmel's SAMA5D3 family SoC.
@@ -157,6 +161,7 @@ config SOC_AT91SAM9X5
 	select SOC_AT91SAM9
 	select AT91_USE_OLD_CLK
 	select HAVE_AT91_UTMI
+	select HAVE_AT91_SMD
 	select HAVE_AT91_USB_CLK
 	help
 	  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
drivers/clk/at91/Makefile +1 -0
index 61db058..0e92b71 100644
@@ -9,3 +9,4 @@ obj-y += clk-system.o clk-peripheral.o
 obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS)	+= clk-programmable.o
 obj-$(CONFIG_HAVE_AT91_UTMI)		+= clk-utmi.o
 obj-$(CONFIG_HAVE_AT91_USB_CLK)		+= clk-usb.o
+obj-$(CONFIG_HAVE_AT91_SMD)		+= clk-smd.o
drivers/clk/at91/clk-smd.c new file +171 -0

171 lines not on this page · raw message

drivers/clk/at91/pmc.c +7 -0
index 4fba500..7b9db60 100644
@@ -315,6 +315,13 @@ static const struct of_device_id pmc_clk_ids[] __initdata = {
 		.data = of_at91sam9n12_clk_usb_setup,
 	},
 #endif
+	/* SMD clock */
+#if defined(CONFIG_HAVE_AT91_SMD)
+	{
+		.compatible = "atmel,at91sam9x5-clk-smd",
+		.data = of_at91sam9x5_clk_smd_setup,
+	},
+#endif
 	{ /*sentinel*/ }
 };
 
drivers/clk/at91/pmc.h +5 -0
index 2483ddc..ba8d142 100644
@@ -108,4 +108,9 @@ extern void __init of_at91sam9n12_clk_usb_setup(struct device_node *np,
 						struct at91_pmc *pmc);
 #endif
 
+#if defined(CONFIG_HAVE_AT91_SMD)
+extern void __init of_at91sam9x5_clk_smd_setup(struct device_node *np,
+					       struct at91_pmc *pmc);
+#endif
+
 #endif /* __PMC_H_ */
Signature · 1 line
1.7.9.5
#14 lore raw

PATCH v6 14/16 dt: binding: add at91 clks dt bindings documentation

In reply to Boris BREZILLON

This patch adds new at91 clks dt bindings documentation.

---
 .../devicetree/bindings/clock/at91-clock.txt       |  339 ++++++++++++++++++++
 1 file changed, 339 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/at91-clock.txt
Documentation/devicetree/bindings/clock/at91-clock.txt new file +339 -0
new file mode 100644
index 0000000..cd5e239
@@ -0,0 +1,339 @@
+Device Tree Clock bindings for arch-at91
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be one of the following:
+	"atmel,at91rm9200-pmc" or
+	"atmel,at91sam9g45-pmc" or
+	"atmel,at91sam9n12-pmc" or
+	"atmel,at91sam9x5-pmc" or
+	"atmel,sama5d3-pmc":
+		at91 PMC (Power Management Controller)
+		All at91 specific clocks (clocks defined below) must be child
+		node of the PMC node.
+
+	"atmel,at91rm9200-clk-main":
+		at91 main oscillator
+
+	"atmel,at91rm9200-clk-master" or
+	"atmel,at91sam9x5-clk-master":
+		at91 master clock
+
+	"atmel,at91sam9x5-clk-peripheral" or
+	"atmel,at91rm9200-clk-peripheral":
+		at91 peripheral clocks
+
+	"atmel,at91rm9200-clk-pll" or
+	"atmel,at91sam9g45-clk-pll" or
+	"atmel,at91sam9g20-clk-pllb" or
+	"atmel,sama5d3-clk-pll":
+		at91 pll clocks
+
+	"atmel,at91sam9x5-clk-plldiv":
+		at91 plla divisor
+
+	"atmel,at91rm9200-clk-programmable" or
+	"atmel,at91sam9g45-clk-programmable" or
+	"atmel,at91sam9x5-clk-programmable":
+		at91 programmable clocks
+
+	"atmel,at91sam9x5-clk-smd":
+		at91 SMD (Soft Modem) clock
+
+	"atmel,at91rm9200-clk-system":
+		at91 system clocks
+
+	"atmel,at91rm9200-clk-usb" or
+	"atmel,at91sam9x5-clk-usb" or
+	"atmel,at91sam9n12-clk-usb":
+		at91 usb clock
+
+	"atmel,at91sam9x5-clk-utmi":
+		at91 utmi clock
+
+Required properties for PMC node:
+- reg : defines the IO memory reserved for the PMC.
+- #size-cells : shall be 0 (reg is used to encode clk id).
+- #address-cells : shall be 1 (reg is used to encode clk id).
+- interrupts : shall be set to PMC interrupt line.
+- interrupt-controller : tell that the PMC is an interrupt controller.
+- #interrupt-cells : must be set to 1. The first cell encodes the interrupt id,
+	and reflect the bit position in the PMC_ER/DR/SR registers.
+	You can use the dt macros defined in dt-bindings/clk/at91.h.
+	0 (AT91_PMC_MOSCS) -> main oscillator ready
+	1 (AT91_PMC_LOCKA) -> PLL A ready
+	2 (AT91_PMC_LOCKB) -> PLL B ready
+	3 (AT91_PMC_MCKRDY) -> master clock ready
+	6 (AT91_PMC_LOCKU) -> UTMI PLL clock ready
+	8 .. 15 (AT91_PMC_PCKRDY(id)) -> programmable clock ready
+	16 (AT91_PMC_MOSCSELS) -> main oscillator selected
+	17 (AT91_PMC_MOSCRCS) -> RC main oscillator stabilized
+	18 (AT91_PMC_CFDEV) -> clock failure detected
+
+For example:
+	pmc: pmc at fffffc00 {
+		compatible = "atmel,sama5d3-pmc";
+		interrupts = <1 4 7>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+		#size-cells = <0>;
+		#address-cells = <1>;
+
+		/* put at91 clocks here */
+	};
+
+Required properties for main clock:
+- interrupt-parent : must reference the PMC node.
+- interrupts : shall be set to "<0>".
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks (optional if clock-frequency is provided) : shall be the slow clock
+	phandle. This clock is used to calculate the main clock rate if
+	"clock-frequency" is not provided.
+- clock-frequency : the main oscillator frequency.Prefer the use of
+	"clock-frequency" over automatic clock rate calculation.
+
+For example:
+	main: mainck {
+		compatible = "atmel,at91rm9200-clk-main";
+		interrupt-parent = <&pmc>;
+		interrupts = <0>;
+		#clock-cells = <0>;
+		clocks = <&ck32k>;
+		clock-frequency = <18432000>;
+	};
+
+Required properties for master clock:
+- interrupt-parent : must reference the PMC node.
+- interrupts : shall be set to "<3>".
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : shall be the master clock sources (see atmel datasheet) phandles.
+	e.g. "<&ck32k>, <&main>, <&plla>, <&pllb>".
+- atmel,clk-output-range : minimum and maximum clock frequency (two u32
+			   fields).
+	   e.g. output = <0 133000000>; <=> 0 to 133MHz.
+- atmel,clk-divisors : master clock divisors table (four u32 fields).
+		0 <=> reserved value.
+		e.g. divisors = <1 2 4 6>;
+- atmel,master-clk-have-div3-pres : some SoC use the reserved value 7 in the
+				    PRES field as CLOCK_DIV3 (e.g sam9x5).
+
+For example:
+	mck: mck {
+		compatible = "atmel,at91rm9200-clk-master";
+		interrupt-parent = <&pmc>;
+		interrupts = <3>;
+		#clock-cells = <0>;
+		atmel,clk-output-range = <0 133000000>;
+		atmel,clk-divisors = <1 2 4 0>;
+	};
+
+Required properties for peripheral clocks:
+- #size-cells : shall be 0 (reg is used to encode clk id).
+- #address-cells : shall be 1 (reg is used to encode clk id).
+- clocks : shall be the master clock phandle.
+	e.g. clocks = <&mck>;
+- name: device tree node describing a specific system clock.
+	* #clock-cells : from common clock binding; shall be set to 0.
+	* reg: peripheral id. See Atmel's datasheets to get a full
+	  list of peripheral ids.
+	* atmel,clk-output-range : minimum and maximum clock frequency
+	  (two u32 fields). Only valid on at91sam9x5-clk-peripheral
+	  compatible IPs.
+
+For example:
+	periph: periphck {
+		compatible = "atmel,at91sam9x5-clk-peripheral";
+		#size-cells = <0>;
+		#address-cells = <1>;
+		clocks = <&mck>;
+
+		ssc0_clk {
+			#clock-cells = <0>;
+			reg = <2>;
+			atmel,clk-output-range = <0 133000000>;
+		};
+
+		usart0_clk {
+			#clock-cells = <0>;
+			reg = <3>;
+			atmel,clk-output-range = <0 66000000>;
+		};
+	};
+
+
+Required properties for pll clocks:
+- interrupt-parent : must reference the PMC node.
+- interrupts : shall be set to "<1>".
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : shall be the main clock phandle.
+- reg : pll id.
+	0 -> PLL A
+	1 -> PLL B
+- atmel,clk-input-range : minimum and maximum source clock frequency (two u32
+			  fields).
+	  e.g. input = <1 32000000>; <=> 1 to 32MHz.
+- #atmel,pll-clk-output-range-cells : number of cells reserved for pll output
+				      range description. Sould be set to 2, 3
+				      or 4.
+	* 1st and 2nd cells represent the frequency range (min-max).
+	* 3rd cell is optional and represents the OUT field value for the given
+	  range.
+	* 4th cell is optional and represents the ICPLL field (PLLICPR
+	  register)
+- atmel,pll-clk-output-ranges : pll output frequency ranges + optional parameter
+				depending on #atmel,pll-output-range-cells
+				property value.
+
+For example:
+	plla: pllack {
+		compatible = "atmel,at91sam9g45-clk-pll";
+		interrupt-parent = <&pmc>;
+		interrupts = <1>;
+		#clock-cells = <0>;
+		clocks = <&main>;
+		reg = <0>;
+		atmel,clk-input-range = <2000000 32000000>;
+		#atmel,pll-clk-output-range-cells = <4>;
+		atmel,pll-clk-output-ranges = <74500000 800000000 0 0
+					       69500000 750000000 1 0
+					       64500000 700000000 2 0
+					       59500000 650000000 3 0
+					       54500000 600000000 0 1
+					       49500000 550000000 1 1
+					       44500000 500000000 2 1
+					       40000000 450000000 3 1>;
+	};
+
+Required properties for plldiv clocks (plldiv = pll / 2):
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : shall be the plla clock phandle.
+
+The pll divisor is equal to 2 and cannot be changed.
+
+For example:
+	plladiv: plladivck {
+		compatible = "atmel,at91sam9x5-clk-plldiv";
+		#clock-cells = <0>;
+		clocks = <&plla>;
+	};
+
+Required properties for programmable clocks:
+- interrupt-parent : must reference the PMC node.
+- #size-cells : shall be 0 (reg is used to encode clk id).
+- #address-cells : shall be 1 (reg is used to encode clk id).
+- clocks : shall be the programmable clock source phandles.
+	e.g. clocks = <&clk32k>, <&main>, <&plla>, <&pllb>;
+- name: device tree node describing a specific prog clock.
+	* #clock-cells : from common clock binding; shall be set to 0.
+	* reg : programmable clock id (register offset from  PCKx
+			 register).
+	* interrupts : shall be set to "<(8 + id)>".
+
+For example:
+	prog: progck {
+		compatible = "atmel,at91sam9g45-clk-programmable";
+		#size-cells = <0>;
+		#address-cells = <1>;
+		interrupt-parent = <&pmc>;
+		clocks = <&clk32k>, <&main>, <&plladiv>, <&utmi>, <&mck>;
+
+		prog0 {
+			#clock-cells = <0>;
+			reg = <0>;
+			interrupts = <8>;
+		};
+
+		prog1 {
+			#clock-cells = <0>;
+			reg = <1>;
+			interrupts = <9>;
+		};
+	};
+
+
+Required properties for smd clock:
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : shall be the smd clock source phandles.
+	e.g. clocks = <&plladiv>, <&utmi>;
+
+For example:
+	smd: smdck {
+		compatible = "atmel,at91sam9x5-clk-smd";
+		#clock-cells = <0>;
+		clocks = <&plladiv>, <&utmi>;
+	};
+
+Required properties for system clocks:
+- #size-cells : shall be 0 (reg is used to encode clk id).
+- #address-cells : shall be 1 (reg is used to encode clk id).
+- name: device tree node describing a specific system clock.
+	* #clock-cells : from common clock binding; shall be set to 0.
+	* reg: system clock id (bit position in SCER/SCDR/SCSR registers).
+	      See Atmel's datasheet to get a full list of system clock ids.
+
+For example:
+	system: systemck {
+		compatible = "atmel,at91rm9200-clk-system";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		ddrck {
+			#clock-cells = <0>;
+			reg = <2>;
+			clocks = <&mck>;
+		};
+
+		uhpck {
+			#clock-cells = <0>;
+			reg = <6>;
+			clocks = <&usb>;
+		};
+
+		udpck {
+			#clock-cells = <0>;
+			reg = <7>;
+			clocks = <&usb>;
+		};
+	};
+
+
+Required properties for usb clock:
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : shall be the smd clock source phandles.
+	e.g. clocks = <&pllb>;
+- atmel,clk-divisors (only available for "atmel,at91rm9200-clk-usb"):
+	usb clock divisor table.
+	e.g. divisors = <1 2 4 0>;
+
+For example:
+	usb: usbck {
+		compatible = "atmel,at91sam9x5-clk-usb";
+		#clock-cells = <0>;
+		clocks = <&plladiv>, <&utmi>;
+	};
+
+	usb: usbck {
+		compatible = "atmel,at91rm9200-clk-usb";
+		#clock-cells = <0>;
+		clocks = <&pllb>;
+		atmel,clk-divisors = <1 2 4 0>;
+	};
+
+
+Required properties for utmi clock:
+- interrupt-parent : must reference the PMC node.
+- interrupts : shall be set to "<AT91_PMC_LOCKU IRQ_TYPE_LEVEL_HIGH>".
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : shall be the main clock source phandle.
+
+For example:
+	utmi: utmick {
+		compatible = "atmel,at91sam9x5-clk-utmi";
+		interrupt-parent = <&pmc>;
+		interrupts = <AT91_PMC_LOCKU IRQ_TYPE_LEVEL_HIGH>;
+		#clock-cells = <0>;
+		clocks = <&main>;
+	};
Signature · 1 line
1.7.9.5
#15 lore raw

PATCH v6 15/16 ARM: at91: move pit timer to common clk framework

In reply to Boris BREZILLON

Use device tree to get the source clock of the PIT (Periodic Interval Timer). If the clock is not found in device tree (or dt is not enabled) we'll try to get it using clk_lookup definitions.

---
 arch/arm/mach-at91/at91sam926x_time.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm/mach-at91/at91sam926x_time.c +13 -1
index bb39232..0f04ffe 100644
@@ -39,6 +39,7 @@
 static u32 pit_cycle;		/* write-once */
 static u32 pit_cnt;		/* access only w/system irq blocked */
 static void __iomem *pit_base_addr __read_mostly;
+static struct clk *mck;
 
 static inline unsigned int pit_read(unsigned int reg_offset)
 {
@@ -195,10 +196,14 @@ static int __init of_at91sam926x_pit_init(void)
 	if (!pit_base_addr)
 		goto node_err;
 
+	mck = of_clk_get(np, 0);
+
 	/* Get the interrupts property */
 	ret = irq_of_parse_and_map(np, 0);
 	if (!ret) {
 		pr_crit("AT91: PIT: Unable to get IRQ from DT\n");
+		if (!IS_ERR(mck))
+			clk_put(mck);
 		goto ioremap_err;
 	}
 	at91sam926x_pit_irq.irq = ret;
@@ -230,6 +235,8 @@ void __init at91sam926x_pit_init(void)
 	unsigned	bits;
 	int		ret;
 
+	mck = ERR_PTR(-ENOENT);
+
 	/* For device tree enabled device: initialize here */
 	of_at91sam926x_pit_init();
 
@@ -237,7 +244,12 @@ void __init at91sam926x_pit_init(void)
 	 * Use our actual MCK to figure out how many MCK/16 ticks per
 	 * 1/HZ period (instead of a compile-time constant LATCH).
 	 */
-	pit_rate = clk_get_rate(clk_get(NULL, "mck")) / 16;
+	if (IS_ERR(mck))
+		mck = clk_get(NULL, "mck");
+
+	if (IS_ERR(mck))
+		panic("AT91: PIT: Unable to get mck clk\n");
+	pit_rate = clk_get_rate(mck) / 16;
 	pit_cycle = (pit_rate + HZ/2) / HZ;
 	WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0);
 
Signature · 1 line
1.7.9.5
#16 lore raw

PATCH v6 16/16 ARM: at91: add new compatible strings for pmc driver

In reply to Boris BREZILLON

This patch adds new compatible string for PMC node to prepare the transition to common clk.

These compatible string come from pmc driver in clk subsystem and are needed to provide new device tree compatibility with old at91 clks (device tree using common clks will use the new compatible strings).

---
 arch/arm/mach-at91/clock.c |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/mach-at91/clock.c +5 -0
index 5f02aea..72b2579 100644
@@ -884,6 +884,11 @@ static int __init at91_pmc_init(unsigned long main_clock)
 #if defined(CONFIG_OF)
 static struct of_device_id pmc_ids[] = {
 	{ .compatible = "atmel,at91rm9200-pmc" },
+	{ .compatible = "atmel,at91sam9260-pmc" },
+	{ .compatible = "atmel,at91sam9g45-pmc" },
+	{ .compatible = "atmel,at91sam9n12-pmc" },
+	{ .compatible = "atmel,at91sam9x5-pmc" },
+	{ .compatible = "atmel,sama5d3-pmc" },
 	{ /*sentinel*/ }
 };
 
Signature · 1 line
1.7.9.5
#17 lore raw
In reply to Boris BREZILLON

Quoting Boris BREZILLON (2013-11-28 04:36:24)

Quoted 4 lines

Hello,

This patch series is the 5th version of the at91 clk implementations using the Common Clk Framework.

Oops, I just replied to v5 of this series. Thanks for the fixes. Which tree do you want this to go through?

Regards,
Mike

Quoted 150 lines

Most of the clock provided by the PMC (Power Management Controller) are implemented :
- main clock (main oscillator)
- pll clocks
- master clock
- programmable clocks
- utmi clock
- peripheral clocks
- system clocks

Actually some clk drivers are missing (slow clk, main clk and processor clk), and some drivers only implement a subset of the hardware capabilities (master clk rate change is missing).
But this series implements all the already available clks, and I will hopefully add missing features in a near future.

This implementation is only compatible with device tree definition. The goal is to define the whole clock tree using the device tree.

Just a note to let you know these bindings are currently unstable and might change in the future.

Best Regards,
Boris

Changes since v5:
- remove peripheral divisors macros from dt binding include file
- remove file path from comment blocks
- replace pll and utmi disable function by unprepare function to avoid issue when disabling and reenabling a clk
- fix programmable clk interrupt retrieval
- fix OF_CLK_DECLARE names (xxx_clk_main -> xxx_clk_pmc)
- add missing comma in at91rm9200 main clk dt declaration
- fix num_parents check in smd clk driver

Changes since v4:
- rework dt bindings:
* replace "atmel,clk-id" property by the standard "reg" property
* reference system, peripheral and programmable clks using the direct clk node instead of the parent node plus a clk id
- provide a new helper function (of_at91_get_clk_range) to retrieve a clk range from the device tree

Changes since v3:
- simplify master clk implementation (drop set_rate/parent support)
- fix bug in set_rate function of pll driver
- fix coding style issues
- define macros and constants where needed
- remove peripheral id macro references
- remove sam9g35 specific handling (sam9g35 = sam9x5)
- rework main clk prepare function to handle automatic rate calculation

Changes since v2:
- fix several bugs in clk implementations
- drop non-dt boards support
- split the series to ease review and tests:
* 1 patch series for new clk implementations (this series)
* 1 patch series to move each at91 SoC to common clk framework (coming soon)
- modify dt-bindings (add atmel,clk- prefix to atmel specific properties)
- add clk macros for dt-bindings
- add pmc framework (helper function to access pmc registers)
- add interrupt support to enable passive wait in clk_prepare functions

Changes since v1:
- fix bugs in pll, programmable and system clock implementations (wrong bit position).
- add usb clock configuration support (ohci and udc drivers + clk_lookup for non dt boards)
- rework of the system clock interfaces (no need to define a parent clock, system clock is a gate with no rate info)
- change system, peripheral and programmable clk dt bindings (1 master node and multiple child nodes each defining a system/peripheral or prog clock)
- fix bugs in sama5 dt definition

Boris BREZILLON (16):
ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h
ARM: at91: add Kconfig options for common clk support
clk: at91: add PMC base support
clk: at91: add PMC macro file for dt definitions
clk: at91: add PMC main clock
clk: at91: add PMC pll clocks
clk: at91: add PMC master clock
clk: at91: add PMC system clocks
clk: at91: add PMC peripheral clocks
clk: at91: add PMC programmable clocks
clk: at91: add PMC utmi clock
clk: at91: add PMC usb clock
clk: at91: add PMC smd clock
dt: binding: add at91 clks dt bindings documentation
ARM: at91: move pit timer to common clk framework
ARM: at91: add new compatible strings for pmc driver

 .../devicetree/bindings/clock/at91-clock.txt       |  339 +++++++++++++
 arch/arm/mach-at91/Kconfig                         |   44 ++
 arch/arm/mach-at91/Kconfig.non_dt                  |    6 +
 arch/arm/mach-at91/Makefile                        |    2 +-
 arch/arm/mach-at91/at91rm9200.c                    |    2 +-
 arch/arm/mach-at91/at91sam9260.c                   |    2 +-
 arch/arm/mach-at91/at91sam9261.c                   |    2 +-
 arch/arm/mach-at91/at91sam9263.c                   |    2 +-
 arch/arm/mach-at91/at91sam926x_time.c              |   14 +-
 arch/arm/mach-at91/at91sam9g45.c                   |    2 +-
 arch/arm/mach-at91/at91sam9n12.c                   |    2 +-
 arch/arm/mach-at91/at91sam9rl.c                    |    2 +-
 arch/arm/mach-at91/at91sam9x5.c                    |    2 +-
 arch/arm/mach-at91/clock.c                         |    7 +-
 arch/arm/mach-at91/generic.h                       |    3 +-
 arch/arm/mach-at91/pm.c                            |    2 +-
 arch/arm/mach-at91/pm_slowclock.S                  |    2 +-
 arch/arm/mach-at91/sama5d3.c                       |    2 +-
 arch/arm/mach-at91/setup.c                         |    8 +-
 drivers/clk/Makefile                               |    1 +
 drivers/clk/at91/Makefile                          |   12 +
 drivers/clk/at91/clk-main.c                        |  187 +++++++
 drivers/clk/at91/clk-master.c                      |  270 ++++++++++
 drivers/clk/at91/clk-peripheral.c                  |  410 +++++++++++++++
 drivers/clk/at91/clk-pll.c                         |  531 ++++++++++++++++++++
 drivers/clk/at91/clk-plldiv.c                      |  135 +++++
 drivers/clk/at91/clk-programmable.c                |  366 ++++++++++++++
 drivers/clk/at91/clk-smd.c                         |  171 +++++++
 drivers/clk/at91/clk-system.c                      |  135 +++++
 drivers/clk/at91/clk-usb.c                         |  398 +++++++++++++++
 drivers/clk/at91/clk-utmi.c                        |  159 ++++++
 drivers/clk/at91/pmc.c                             |  397 +++++++++++++++
 drivers/clk/at91/pmc.h                             |  116 +++++
 drivers/usb/gadget/atmel_usba_udc.c                |    2 +-
 include/dt-bindings/clk/at91.h                     |   22 +
 .../include/mach => include/linux/clk}/at91_pmc.h  |    4 +-
 36 files changed, 3741 insertions(+), 20 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/at91-clock.txt
 create mode 100644 drivers/clk/at91/Makefile
 create mode 100644 drivers/clk/at91/clk-main.c
 create mode 100644 drivers/clk/at91/clk-master.c
 create mode 100644 drivers/clk/at91/clk-peripheral.c
 create mode 100644 drivers/clk/at91/clk-pll.c
 create mode 100644 drivers/clk/at91/clk-plldiv.c
 create mode 100644 drivers/clk/at91/clk-programmable.c
 create mode 100644 drivers/clk/at91/clk-smd.c
 create mode 100644 drivers/clk/at91/clk-system.c
 create mode 100644 drivers/clk/at91/clk-usb.c
 create mode 100644 drivers/clk/at91/clk-utmi.c
 create mode 100644 drivers/clk/at91/pmc.c
 create mode 100644 drivers/clk/at91/pmc.h
 create mode 100644 include/dt-bindings/clk/at91.h
 rename {arch/arm/mach-at91/include/mach => include/linux/clk}/at91_pmc.h (98%)
Signature · 1 line
1.7.9.5
#18 lore raw

Hi Mike,

Le 01/12/2013 00:05, Mike Turquette a ?crit :

Quoted 7 lines

Quoting Boris BREZILLON (2013-11-28 04:36:24)

Quoted 4 lines

Hello,

This patch series is the 5th version of the at91 clk implementations using the Common Clk Framework.

Oops, I just replied to v5 of this series. Thanks for the fixes. Which tree do you want this to go through?

I'm not sure: the "ARM: at91: move to common clk framework" series depends on this one.

Nicolas, what do you think ?
Do you want to take it into your tree ?

Quoted 152 lines

Regards,
Mike

Quoted 149 lines

Most of the clock provided by the PMC (Power Management Controller) are implemented :
- main clock (main oscillator)
- pll clocks
- master clock
- programmable clocks
- utmi clock
- peripheral clocks
- system clocks

Actually some clk drivers are missing (slow clk, main clk and processor clk), and some drivers only implement a subset of the hardware capabilities (master clk rate change is missing).
But this series implements all the already available clks, and I will hopefully add missing features in a near future.

This implementation is only compatible with device tree definition. The goal is to define the whole clock tree using the device tree.

Just a note to let you know these bindings are currently unstable and might change in the future.

Best Regards,
Boris

Changes since v5:
- remove peripheral divisors macros from dt binding include file
- remove file path from comment blocks
- replace pll and utmi disable function by unprepare function to avoid issue when disabling and reenabling a clk
- fix programmable clk interrupt retrieval
- fix OF_CLK_DECLARE names (xxx_clk_main -> xxx_clk_pmc)
- add missing comma in at91rm9200 main clk dt declaration
- fix num_parents check in smd clk driver

Changes since v4:
- rework dt bindings:
* replace "atmel,clk-id" property by the standard "reg" property
* reference system, peripheral and programmable clks using the direct clk node instead of the parent node plus a clk id
- provide a new helper function (of_at91_get_clk_range) to retrieve a clk range from the device tree

Changes since v3:
- simplify master clk implementation (drop set_rate/parent support)
- fix bug in set_rate function of pll driver
- fix coding style issues
- define macros and constants where needed
- remove peripheral id macro references
- remove sam9g35 specific handling (sam9g35 = sam9x5)
- rework main clk prepare function to handle automatic rate calculation

Changes since v2:
- fix several bugs in clk implementations
- drop non-dt boards support
- split the series to ease review and tests:
* 1 patch series for new clk implementations (this series)
* 1 patch series to move each at91 SoC to common clk framework (coming soon)
- modify dt-bindings (add atmel,clk- prefix to atmel specific properties)
- add clk macros for dt-bindings
- add pmc framework (helper function to access pmc registers)
- add interrupt support to enable passive wait in clk_prepare functions

Changes since v1:
- fix bugs in pll, programmable and system clock implementations (wrong bit position).
- add usb clock configuration support (ohci and udc drivers + clk_lookup for non dt boards)
- rework of the system clock interfaces (no need to define a parent clock, system clock is a gate with no rate info)
- change system, peripheral and programmable clk dt bindings (1 master node and multiple child nodes each defining a system/peripheral or prog clock)
- fix bugs in sama5 dt definition

Boris BREZILLON (16):
ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h
ARM: at91: add Kconfig options for common clk support
clk: at91: add PMC base support
clk: at91: add PMC macro file for dt definitions
clk: at91: add PMC main clock
clk: at91: add PMC pll clocks
clk: at91: add PMC master clock
clk: at91: add PMC system clocks
clk: at91: add PMC peripheral clocks
clk: at91: add PMC programmable clocks
clk: at91: add PMC utmi clock
clk: at91: add PMC usb clock
clk: at91: add PMC smd clock
dt: binding: add at91 clks dt bindings documentation
ARM: at91: move pit timer to common clk framework
ARM: at91: add new compatible strings for pmc driver

  .../devicetree/bindings/clock/at91-clock.txt       |  339 +++++++++++++
  arch/arm/mach-at91/Kconfig                         |   44 ++
  arch/arm/mach-at91/Kconfig.non_dt                  |    6 +
  arch/arm/mach-at91/Makefile                        |    2 +-
  arch/arm/mach-at91/at91rm9200.c                    |    2 +-
  arch/arm/mach-at91/at91sam9260.c                   |    2 +-
  arch/arm/mach-at91/at91sam9261.c                   |    2 +-
  arch/arm/mach-at91/at91sam9263.c                   |    2 +-
  arch/arm/mach-at91/at91sam926x_time.c              |   14 +-
  arch/arm/mach-at91/at91sam9g45.c                   |    2 +-
  arch/arm/mach-at91/at91sam9n12.c                   |    2 +-
  arch/arm/mach-at91/at91sam9rl.c                    |    2 +-
  arch/arm/mach-at91/at91sam9x5.c                    |    2 +-
  arch/arm/mach-at91/clock.c                         |    7 +-
  arch/arm/mach-at91/generic.h                       |    3 +-
  arch/arm/mach-at91/pm.c                            |    2 +-
  arch/arm/mach-at91/pm_slowclock.S                  |    2 +-
  arch/arm/mach-at91/sama5d3.c                       |    2 +-
  arch/arm/mach-at91/setup.c                         |    8 +-
  drivers/clk/Makefile                               |    1 +
  drivers/clk/at91/Makefile                          |   12 +
  drivers/clk/at91/clk-main.c                        |  187 +++++++
  drivers/clk/at91/clk-master.c                      |  270 ++++++++++
  drivers/clk/at91/clk-peripheral.c                  |  410 +++++++++++++++
  drivers/clk/at91/clk-pll.c                         |  531 ++++++++++++++++++++
  drivers/clk/at91/clk-plldiv.c                      |  135 +++++
  drivers/clk/at91/clk-programmable.c                |  366 ++++++++++++++
  drivers/clk/at91/clk-smd.c                         |  171 +++++++
  drivers/clk/at91/clk-system.c                      |  135 +++++
  drivers/clk/at91/clk-usb.c                         |  398 +++++++++++++++
  drivers/clk/at91/clk-utmi.c                        |  159 ++++++
  drivers/clk/at91/pmc.c                             |  397 +++++++++++++++
  drivers/clk/at91/pmc.h                             |  116 +++++
  drivers/usb/gadget/atmel_usba_udc.c                |    2 +-
  include/dt-bindings/clk/at91.h                     |   22 +
  .../include/mach => include/linux/clk}/at91_pmc.h  |    4 +-
  36 files changed, 3741 insertions(+), 20 deletions(-)

create mode 100644 Documentation/devicetree/bindings/clock/at91-clock.txt create mode 100644 drivers/clk/at91/Makefile
create mode 100644 drivers/clk/at91/clk-main.c
create mode 100644 drivers/clk/at91/clk-master.c
create mode 100644 drivers/clk/at91/clk-peripheral.c
create mode 100644 drivers/clk/at91/clk-pll.c
create mode 100644 drivers/clk/at91/clk-plldiv.c
create mode 100644 drivers/clk/at91/clk-programmable.c
create mode 100644 drivers/clk/at91/clk-smd.c
create mode 100644 drivers/clk/at91/clk-system.c
create mode 100644 drivers/clk/at91/clk-usb.c
create mode 100644 drivers/clk/at91/clk-utmi.c
create mode 100644 drivers/clk/at91/pmc.c
create mode 100644 drivers/clk/at91/pmc.h
create mode 100644 include/dt-bindings/clk/at91.h
rename {arch/arm/mach-at91/include/mach => include/linux/clk}/at91_pmc.h (98%)

Signature · 1 line
1.7.9.5
#19 lore raw
Quoted 4 lines · boris brezillon

Hi Mike,

Le 01/12/2013 00:05, Mike Turquette a ?crit :

Quoted 1 line

Quoting Boris BREZILLON (2013-11-28 04:36:24)

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Hello,

This patch series is the 5th version of the at91 clk implementations using the Common Clk Framework.

Oops, I just replied to v5 of this series. Thanks for the fixes. Which tree do you want this to go through?

I'm not sure: the "ARM: at91: move to common clk framework" series

Oops. I meant "ARM: at91: use new at91 clks for samad3 SoCs".

Quoted 179 lines

depends on this one.
"
Nicolas, what do you think ?
Do you want to take it into your tree ?

Quoted 172 lines

Regards,
Mike

Quoted 169 lines

Most of the clock provided by the PMC (Power Management Controller) are implemented :
- main clock (main oscillator)
- pll clocks
- master clock
- programmable clocks
- utmi clock
- peripheral clocks
- system clocks

Actually some clk drivers are missing (slow clk, main clk and processor clk), and some drivers only implement a subset of the hardware capabilities
(master clk rate change is missing).
But this series implements all the already available clks, and I will hopefully
add missing features in a near future.

This implementation is only compatible with device tree definition. The goal is to define the whole clock tree using the device tree.

Just a note to let you know these bindings are currently unstable and might
change in the future.

Best Regards,
Boris

Changes since v5:
- remove peripheral divisors macros from dt binding include file
- remove file path from comment blocks
- replace pll and utmi disable function by unprepare function to avoid issue when disabling and reenabling a clk
- fix programmable clk interrupt retrieval
- fix OF_CLK_DECLARE names (xxx_clk_main -> xxx_clk_pmc)
- add missing comma in at91rm9200 main clk dt declaration
- fix num_parents check in smd clk driver

Changes since v4:
- rework dt bindings:
* replace "atmel,clk-id" property by the standard "reg" property
* reference system, peripheral and programmable clks using the
direct
clk node instead of the parent node plus a clk id
- provide a new helper function (of_at91_get_clk_range) to
retrieve a clk
range from the device tree

Changes since v3:
- simplify master clk implementation (drop set_rate/parent support)
- fix bug in set_rate function of pll driver
- fix coding style issues
- define macros and constants where needed
- remove peripheral id macro references
- remove sam9g35 specific handling (sam9g35 = sam9x5)
- rework main clk prepare function to handle automatic rate
calculation

Changes since v2:
- fix several bugs in clk implementations
- drop non-dt boards support
- split the series to ease review and tests:
* 1 patch series for new clk implementations (this series)
* 1 patch series to move each at91 SoC to common clk framework
(coming soon)
- modify dt-bindings (add atmel,clk- prefix to atmel specific
properties)
- add clk macros for dt-bindings
- add pmc framework (helper function to access pmc registers)
- add interrupt support to enable passive wait in clk_prepare
functions

Changes since v1:
- fix bugs in pll, programmable and system clock implementations (wrong bit position).
- add usb clock configuration support (ohci and udc drivers + clk_lookup for non dt boards)
- rework of the system clock interfaces (no need to define a
parent clock,
system clock is a gate with no rate info)
- change system, peripheral and programmable clk dt bindings (1
master node
and multiple child nodes each defining a system/peripheral or
prog clock)
- fix bugs in sama5 dt definition

Boris BREZILLON (16):
ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h
ARM: at91: add Kconfig options for common clk support
clk: at91: add PMC base support
clk: at91: add PMC macro file for dt definitions
clk: at91: add PMC main clock
clk: at91: add PMC pll clocks
clk: at91: add PMC master clock
clk: at91: add PMC system clocks
clk: at91: add PMC peripheral clocks
clk: at91: add PMC programmable clocks
clk: at91: add PMC utmi clock
clk: at91: add PMC usb clock
clk: at91: add PMC smd clock
dt: binding: add at91 clks dt bindings documentation
ARM: at91: move pit timer to common clk framework
ARM: at91: add new compatible strings for pmc driver

  .../devicetree/bindings/clock/at91-clock.txt       |  339 
+++++++++++++
  arch/arm/mach-at91/Kconfig                         |   44 ++
  arch/arm/mach-at91/Kconfig.non_dt                  |    6 +
  arch/arm/mach-at91/Makefile                        |    2 +-
  arch/arm/mach-at91/at91rm9200.c                    |    2 +-
  arch/arm/mach-at91/at91sam9260.c                   |    2 +-
  arch/arm/mach-at91/at91sam9261.c                   |    2 +-
  arch/arm/mach-at91/at91sam9263.c                   |    2 +-
  arch/arm/mach-at91/at91sam926x_time.c              |   14 +-
  arch/arm/mach-at91/at91sam9g45.c                   |    2 +-
  arch/arm/mach-at91/at91sam9n12.c                   |    2 +-
  arch/arm/mach-at91/at91sam9rl.c                    |    2 +-
  arch/arm/mach-at91/at91sam9x5.c                    |    2 +-
  arch/arm/mach-at91/clock.c                         |    7 +-
  arch/arm/mach-at91/generic.h                       |    3 +-
  arch/arm/mach-at91/pm.c                            |    2 +-
  arch/arm/mach-at91/pm_slowclock.S                  |    2 +-
  arch/arm/mach-at91/sama5d3.c                       |    2 +-
  arch/arm/mach-at91/setup.c                         |    8 +-
  drivers/clk/Makefile                               |    1 +
  drivers/clk/at91/Makefile                          |   12 +
  drivers/clk/at91/clk-main.c                        |  187 +++++++
  drivers/clk/at91/clk-master.c                      |  270 ++++++++++
  drivers/clk/at91/clk-peripheral.c                  |  410 
+++++++++++++++
  drivers/clk/at91/clk-pll.c                         |  531 
++++++++++++++++++++
  drivers/clk/at91/clk-plldiv.c                      |  135 +++++
  drivers/clk/at91/clk-programmable.c                |  366 
++++++++++++++
  drivers/clk/at91/clk-smd.c                         |  171 +++++++
  drivers/clk/at91/clk-system.c                      |  135 +++++
  drivers/clk/at91/clk-usb.c                         |  398 
+++++++++++++++
  drivers/clk/at91/clk-utmi.c                        |  159 ++++++
  drivers/clk/at91/pmc.c                             |  397 
+++++++++++++++
  drivers/clk/at91/pmc.h                             |  116 +++++
  drivers/usb/gadget/atmel_usba_udc.c                |    2 +-
  include/dt-bindings/clk/at91.h                     |   22 +
  .../include/mach => include/linux/clk}/at91_pmc.h  |    4 +-
  36 files changed, 3741 insertions(+), 20 deletions(-)

create mode 100644
Documentation/devicetree/bindings/clock/at91-clock.txt
create mode 100644 drivers/clk/at91/Makefile create mode 100644 drivers/clk/at91/clk-main.c create mode 100644 drivers/clk/at91/clk-master.c create mode 100644 drivers/clk/at91/clk-peripheral.c create mode 100644 drivers/clk/at91/clk-pll.c create mode 100644 drivers/clk/at91/clk-plldiv.c create mode 100644 drivers/clk/at91/clk-programmable.c create mode 100644 drivers/clk/at91/clk-smd.c create mode 100644 drivers/clk/at91/clk-system.c create mode 100644 drivers/clk/at91/clk-usb.c create mode 100644 drivers/clk/at91/clk-utmi.c create mode 100644 drivers/clk/at91/pmc.c create mode 100644 drivers/clk/at91/pmc.h create mode 100644 include/dt-bindings/clk/at91.h rename {arch/arm/mach-at91/include/mach =>
include/linux/clk}/at91_pmc.h (98%)

Signature · 1 line
1.7.9.5
#20 lore raw
In reply to Mike Turquette

On 01/12/2013 00:05, Mike Turquette :

Quoted 8 lines

Quoting Boris BREZILLON (2013-11-28 04:36:24)

Quoted 4 lines

Hello,

This patch series is the 5th version of the at91 clk implementations using the Common Clk Framework.

Oops, I just replied to v5 of this series. Thanks for the fixes. Which tree do you want this to go through?

Mike, Boris,

I will take the series in the at91 git tree that will go through arm-soc.

This way, I can synchronize with the other series cooked by Boris which actually implements the CCF for sama5d3 SoCs.

Mike, I keep you in the CC list of my upcoming pull-request to Olof, Kevin and Arnd.

Thanks, bye,

Quoted 150 lines
Quoted 149 lines

Most of the clock provided by the PMC (Power Management Controller) are implemented :
- main clock (main oscillator)
- pll clocks
- master clock
- programmable clocks
- utmi clock
- peripheral clocks
- system clocks

Actually some clk drivers are missing (slow clk, main clk and processor clk), and some drivers only implement a subset of the hardware capabilities (master clk rate change is missing).
But this series implements all the already available clks, and I will hopefully add missing features in a near future.

This implementation is only compatible with device tree definition. The goal is to define the whole clock tree using the device tree.

Just a note to let you know these bindings are currently unstable and might change in the future.

Best Regards,
Boris

Changes since v5:
- remove peripheral divisors macros from dt binding include file
- remove file path from comment blocks
- replace pll and utmi disable function by unprepare function to avoid issue when disabling and reenabling a clk
- fix programmable clk interrupt retrieval
- fix OF_CLK_DECLARE names (xxx_clk_main -> xxx_clk_pmc)
- add missing comma in at91rm9200 main clk dt declaration
- fix num_parents check in smd clk driver

Changes since v4:
- rework dt bindings:
* replace "atmel,clk-id" property by the standard "reg" property
* reference system, peripheral and programmable clks using the direct clk node instead of the parent node plus a clk id
- provide a new helper function (of_at91_get_clk_range) to retrieve a clk range from the device tree

Changes since v3:
- simplify master clk implementation (drop set_rate/parent support)
- fix bug in set_rate function of pll driver
- fix coding style issues
- define macros and constants where needed
- remove peripheral id macro references
- remove sam9g35 specific handling (sam9g35 = sam9x5)
- rework main clk prepare function to handle automatic rate calculation

Changes since v2:
- fix several bugs in clk implementations
- drop non-dt boards support
- split the series to ease review and tests:
* 1 patch series for new clk implementations (this series)
* 1 patch series to move each at91 SoC to common clk framework (coming soon)
- modify dt-bindings (add atmel,clk- prefix to atmel specific properties)
- add clk macros for dt-bindings
- add pmc framework (helper function to access pmc registers)
- add interrupt support to enable passive wait in clk_prepare functions

Changes since v1:
- fix bugs in pll, programmable and system clock implementations (wrong bit position).
- add usb clock configuration support (ohci and udc drivers + clk_lookup for non dt boards)
- rework of the system clock interfaces (no need to define a parent clock, system clock is a gate with no rate info)
- change system, peripheral and programmable clk dt bindings (1 master node and multiple child nodes each defining a system/peripheral or prog clock)
- fix bugs in sama5 dt definition

Boris BREZILLON (16):
ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h
ARM: at91: add Kconfig options for common clk support
clk: at91: add PMC base support
clk: at91: add PMC macro file for dt definitions
clk: at91: add PMC main clock
clk: at91: add PMC pll clocks
clk: at91: add PMC master clock
clk: at91: add PMC system clocks
clk: at91: add PMC peripheral clocks
clk: at91: add PMC programmable clocks
clk: at91: add PMC utmi clock
clk: at91: add PMC usb clock
clk: at91: add PMC smd clock
dt: binding: add at91 clks dt bindings documentation
ARM: at91: move pit timer to common clk framework
ARM: at91: add new compatible strings for pmc driver

  .../devicetree/bindings/clock/at91-clock.txt       |  339 +++++++++++++
  arch/arm/mach-at91/Kconfig                         |   44 ++
  arch/arm/mach-at91/Kconfig.non_dt                  |    6 +
  arch/arm/mach-at91/Makefile                        |    2 +-
  arch/arm/mach-at91/at91rm9200.c                    |    2 +-
  arch/arm/mach-at91/at91sam9260.c                   |    2 +-
  arch/arm/mach-at91/at91sam9261.c                   |    2 +-
  arch/arm/mach-at91/at91sam9263.c                   |    2 +-
  arch/arm/mach-at91/at91sam926x_time.c              |   14 +-
  arch/arm/mach-at91/at91sam9g45.c                   |    2 +-
  arch/arm/mach-at91/at91sam9n12.c                   |    2 +-
  arch/arm/mach-at91/at91sam9rl.c                    |    2 +-
  arch/arm/mach-at91/at91sam9x5.c                    |    2 +-
  arch/arm/mach-at91/clock.c                         |    7 +-
  arch/arm/mach-at91/generic.h                       |    3 +-
  arch/arm/mach-at91/pm.c                            |    2 +-
  arch/arm/mach-at91/pm_slowclock.S                  |    2 +-
  arch/arm/mach-at91/sama5d3.c                       |    2 +-
  arch/arm/mach-at91/setup.c                         |    8 +-
  drivers/clk/Makefile                               |    1 +
  drivers/clk/at91/Makefile                          |   12 +
  drivers/clk/at91/clk-main.c                        |  187 +++++++
  drivers/clk/at91/clk-master.c                      |  270 ++++++++++
  drivers/clk/at91/clk-peripheral.c                  |  410 +++++++++++++++
  drivers/clk/at91/clk-pll.c                         |  531 ++++++++++++++++++++
  drivers/clk/at91/clk-plldiv.c                      |  135 +++++
  drivers/clk/at91/clk-programmable.c                |  366 ++++++++++++++
  drivers/clk/at91/clk-smd.c                         |  171 +++++++
  drivers/clk/at91/clk-system.c                      |  135 +++++
  drivers/clk/at91/clk-usb.c                         |  398 +++++++++++++++
  drivers/clk/at91/clk-utmi.c                        |  159 ++++++
  drivers/clk/at91/pmc.c                             |  397 +++++++++++++++
  drivers/clk/at91/pmc.h                             |  116 +++++
  drivers/usb/gadget/atmel_usba_udc.c                |    2 +-
  include/dt-bindings/clk/at91.h                     |   22 +
  .../include/mach => include/linux/clk}/at91_pmc.h  |    4 +-
  36 files changed, 3741 insertions(+), 20 deletions(-)

create mode 100644 Documentation/devicetree/bindings/clock/at91-clock.txt create mode 100644 drivers/clk/at91/Makefile
create mode 100644 drivers/clk/at91/clk-main.c
create mode 100644 drivers/clk/at91/clk-master.c
create mode 100644 drivers/clk/at91/clk-peripheral.c
create mode 100644 drivers/clk/at91/clk-pll.c
create mode 100644 drivers/clk/at91/clk-plldiv.c
create mode 100644 drivers/clk/at91/clk-programmable.c
create mode 100644 drivers/clk/at91/clk-smd.c
create mode 100644 drivers/clk/at91/clk-system.c
create mode 100644 drivers/clk/at91/clk-usb.c
create mode 100644 drivers/clk/at91/clk-utmi.c
create mode 100644 drivers/clk/at91/pmc.c
create mode 100644 drivers/clk/at91/pmc.h
create mode 100644 include/dt-bindings/clk/at91.h
rename {arch/arm/mach-at91/include/mach => include/linux/clk}/at91_pmc.h (98%)

--
1.7.9.5

Signature · 1 line
Nicolas Ferre