Skip to contentSkip to conversation

clk: at91: add sama7g5 support

PATCH New Claudiu Beznea 2 participants 23 messages Sep 7, 2020 – Sep 8, 2020

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

v3 cover clk: at91: add sama7g5 support

The purpose of this series is to add clock support for SAMA7G5. Along with this, clock drivers were switched to CCF and aligned with their corresponding versions present in Linux.
Some changes were done for CCF, patches 1, 3, 4, 5 (I don't know if they were as is by intention of a fixes tag is needed in there).

Also patch 3/21 has been added to support clock re-reparenting (this is minimal support and hope it doesn't break anything if used).

Thank you,
Claudiu Beznea

Changes in v3:
- collected remaining Reviewed-by tags
- rebase on top of latest master branch:
e5df264e7aac ("Merge https://gitlab.denx.de/u-boot/custodians/u-boot-marvell")
to adapt patch 8/21 at changes from commit
702e57e113d8 ("treewide: convert devfdt_get_addr_ptr() to dev_read_addr_ptr()")

Changes in v2:
- use assert() in patch 1/21
- drop patch 2/22 from previous series
- add sandbox tests for clock reparenting, device reparenting and critical clocks
- adapt review comments
- collected Reviewed-by tags

Claudiu Beznea (21):
clk: check hw and hw->dev before dereference it
dm: core: add support for device re-parenting
clk: bind clk to new parent device
clk: do not disable clock if it is critical
clk: get clock pointer before proceeding
clk: at91: add pre-requisite headers for AT91 clock architecture
clk: at91: pmc: add helpers for clock drivers
clk: at91: move clock code to compat.c
clk: at91: sckc: add driver compatible with ccf
clk: at91: clk-main: add driver compatible with ccf
clk: at91: sam9x60-pll: add driver compatible with ccf
clk: at91: clk-master: add driver compatible with ccf
clk: at91: clk-master: add support for sama7g5
clk: at91: clk-utmi: add driver compatible with ccf
clk: at91: clk-utmi: add support for sama7g5
clk: at91: clk-programmable: add driver compatible with ccf
clk: at91: clk-system: add driver compatible with ccf
clk: at91: clk-peripheral: add driver compatible with ccf
clk: at91: clk-generic: add driver compatible with ccf
clk: at91: pmc: add generic clock ops
clk: at91: sama7g5: add clock support

 drivers/clk/at91/Kconfig            |    7 +
 drivers/clk/at91/Makefile           |   15 +-
 drivers/clk/at91/clk-generated.c    |  178 -----
 drivers/clk/at91/clk-generic.c      |  202 +++++
 drivers/clk/at91/clk-h32mx.c        |   56 --
 drivers/clk/at91/clk-main.c         |  381 +++++++++-
 drivers/clk/at91/clk-master.c       |  331 ++++++++-
 drivers/clk/at91/clk-peripheral.c   |  291 ++++++--
 drivers/clk/at91/clk-plla.c         |   54 --
 drivers/clk/at91/clk-plladiv.c      |   85 ---
 drivers/clk/at91/clk-programmable.c |  208 ++++++
 drivers/clk/at91/clk-sam9x60-pll.c  |  442 +++++++++++
 drivers/clk/at91/clk-slow.c         |   36 -
 drivers/clk/at91/clk-system.c       |  143 ++--
 drivers/clk/at91/clk-usb.c          |  147 ----
 drivers/clk/at91/clk-utmi.c         |  234 ++++--
 drivers/clk/at91/compat.c           | 1023 +++++++++++++++++++++++++
 drivers/clk/at91/pmc.c              |  218 +++---
 drivers/clk/at91/pmc.h              |  140 +++-
 drivers/clk/at91/sama7g5.c          | 1401 +++++++++++++++++++++++++++++++++++
 drivers/clk/at91/sckc.c             |  169 ++++-
 drivers/clk/clk-uclass.c            |   51 +-
 drivers/clk/clk.c                   |    3 +
 drivers/core/device.c               |   22 +
 include/dm/device-internal.h        |    9 +
 include/dt-bindings/clk/at91.h      |   22 +
 include/linux/clk/at91_pmc.h        |  247 ++++++
 test/dm/clk_ccf.c                   |   57 ++
 test/dm/core.c                      |  160 ++++
 29 files changed, 5407 insertions(+), 925 deletions(-)
 delete mode 100644 drivers/clk/at91/clk-generated.c
 create mode 100644 drivers/clk/at91/clk-generic.c
 delete mode 100644 drivers/clk/at91/clk-h32mx.c
 delete mode 100644 drivers/clk/at91/clk-plla.c
 delete mode 100644 drivers/clk/at91/clk-plladiv.c
 create mode 100644 drivers/clk/at91/clk-programmable.c
 create mode 100644 drivers/clk/at91/clk-sam9x60-pll.c
 delete mode 100644 drivers/clk/at91/clk-slow.c
 delete mode 100644 drivers/clk/at91/clk-usb.c
 create mode 100644 drivers/clk/at91/compat.c
 create mode 100644 drivers/clk/at91/sama7g5.c
 create mode 100644 include/dt-bindings/clk/at91.h
 create mode 100644 include/linux/clk/at91_pmc.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/21 clk: check hw and hw->dev before dereference it

Check hw and hw->dev before dereference it.

---
 drivers/clk/clk.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/clk/clk.c +3 -0
index 786f4e887e7a..319808d433f5 100644
@@ -57,6 +57,9 @@ ulong clk_generic_get_rate(struct clk *clk)
 
 const char *clk_hw_get_name(const struct clk *hw)
 {
+	assert(hw);
+	assert(hw->dev);
+
 	return hw->dev->name;
 }
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 2/21 dm: core: add support for device re-parenting

In reply to Claudiu Beznea

In common clock framework the relation b/w parent and child clocks is determined based on the udevice parent/child information. A clock parent could be changed based on devices needs. In case this is happen the functionalities for clock who's parent is changed are broken. Add a function that reparent a device. This will be used in clk-uclass.c to reparent a clock device.

---
 drivers/core/device.c        |  22 ++++++
 include/dm/device-internal.h |   9 +++
 test/dm/core.c               | 160 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 191 insertions(+)
drivers/core/device.c +22 -0
index 355dbd147a9e..e90d70101c20 100644
@@ -276,6 +276,28 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
 	return ret;
 }
 
+int device_reparent(struct udevice *dev, struct udevice *new_parent)
+{
+	struct udevice *pos, *n;
+
+	assert(dev);
+	assert(new_parent);
+
+	list_for_each_entry_safe(pos, n, &dev->parent->child_head,
+				 sibling_node) {
+		if (pos->driver != dev->driver)
+			continue;
+
+		list_del(&dev->sibling_node);
+		list_add_tail(&dev->sibling_node, &new_parent->child_head);
+		dev->parent = new_parent;
+
+		break;
+	}
+
+	return 0;
+}
+
 static void *alloc_priv(int size, uint flags)
 {
 	void *priv;
include/dm/device-internal.h +9 -0
index 5145fb4e1459..1dcc22f68915 100644
@@ -84,6 +84,15 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
 			struct driver_info *info, struct udevice **devp);
 
 /**
+ * device_reparent: reparent the device to a new parent
+ *
+ * @dev: pointer to device to be reparented
+ * @new_parent: pointer to new parent device
+ * @return 0 if OK, -ve on error
+ */
+int device_reparent(struct udevice *dev, struct udevice *new_parent);
+
+/**
  * device_ofdata_to_platdata() - Read platform data for a device
  *
  * Read platform data for a device (typically from the device tree) so that
test/dm/core.c +160 -0

166 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

PATCH v3 3/21 clk: bind clk to new parent device

In reply to Claudiu Beznea

Clock re-parenting is not binding the clock's device to its new parent device, it only calls the clock's ops->set_parent() API. The changes in this commit re-parent the clock device to its new parent so that subsequent operations like clk_get_parent() to point to the proper parent.

---
 drivers/clk/clk-uclass.c | 11 ++++++++++-
 test/dm/clk_ccf.c        | 27 +++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
drivers/clk/clk-uclass.c +10 -1
index 934cd5787a5c..5e0c8419d65b 100644
@@ -14,6 +14,7 @@
 #include <errno.h>
 #include <log.h>
 #include <malloc.h>
+#include <dm/device-internal.h>
 #include <dm/devres.h>
 #include <dm/read.h>
 #include <linux/bug.h>
@@ -512,6 +513,7 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
 int clk_set_parent(struct clk *clk, struct clk *parent)
 {
 	const struct clk_ops *ops;
+	int ret;
 
 	debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent);
 	if (!clk_valid(clk))
@@ -521,7 +523,14 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 	if (!ops->set_parent)
 		return -ENOSYS;
 
-	return ops->set_parent(clk, parent);
+	ret = ops->set_parent(clk, parent);
+	if (ret)
+		return ret;
+
+	if (CONFIG_IS_ENABLED(CLK_CCF))
+		ret = device_reparent(clk->dev, parent->dev);
+
+	return ret;
 }
 
 int clk_enable(struct clk *clk)
test/dm/clk_ccf.c +27 -0
index 32bc4d2b8a0c..1ce28d747dbe 100644
@@ -22,6 +22,10 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
 	struct udevice *dev;
 	long long rate;
 	int ret;
+#if CONFIG_IS_ENABLED(CLK_CCF)
+	const char *clkname;
+	int clkid;
+#endif
 
 	/* Get the device using the clk device */
 	ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-ccf", &dev));
@@ -130,6 +134,29 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
 
 	ret = sandbox_clk_enable_count(pclk);
 	ut_asserteq(ret, 0);
+
+	/* Test clock re-parenting. */
+	ret = clk_get_by_id(SANDBOX_CLK_USDHC1_SEL, &clk);
+	ut_assertok(ret);
+	ut_asserteq_str("usdhc1_sel", clk->dev->name);
+
+	pclk = clk_get_parent(clk);
+	ut_assertok_ptr(pclk);
+	if (!strcmp(pclk->dev->name, "pll3_60m")) {
+		clkname = "pll3_80m";
+		clkid = SANDBOX_CLK_PLL3_80M;
+	} else {
+		clkname = "pll3_60m";
+		clkid = SANDBOX_CLK_PLL3_60M;
+	}
+
+	ret = clk_get_by_id(clkid, &pclk);
+	ut_assertok(ret);
+	ret = clk_set_parent(clk, pclk);
+	ut_assertok(ret);
+	pclk = clk_get_parent(clk);
+	ut_assertok_ptr(pclk);
+	ut_asserteq_str(clkname, pclk->dev->name);
 #endif
 
 	return 1;
Signature · 1 line
2.7.4
#4 lore raw

PATCH v3 4/21 clk: do not disable clock if it is critical

In reply to Claudiu Beznea

Do not disable clock if it is a critical one.

---
 drivers/clk/clk-uclass.c |  3 +++
 test/dm/clk_ccf.c        | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/clk/clk-uclass.c +3 -0
index 5e0c8419d65b..b8538f342a0c 100644
@@ -606,6 +606,9 @@ int clk_disable(struct clk *clk)
 
 	if (CONFIG_IS_ENABLED(CLK_CCF)) {
 		if (clk->id && !clk_get_by_id(clk->id, &clkp)) {
+			if (clkp->flags & CLK_IS_CRITICAL)
+				return 0;
+
 			if (clkp->enable_count == 0) {
 				printf("clk %s already disabled\n",
 				       clkp->dev->name);
test/dm/clk_ccf.c +31 -1
index 1ce28d747dbe..e4ebb93cdad4 100644
@@ -24,7 +24,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
 	int ret;
 #if CONFIG_IS_ENABLED(CLK_CCF)
 	const char *clkname;
-	int clkid;
+	int clkid, i;
 #endif
 
 	/* Get the device using the clk device */
@@ -157,6 +157,36 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
 	pclk = clk_get_parent(clk);
 	ut_assertok_ptr(pclk);
 	ut_asserteq_str(clkname, pclk->dev->name);
+
+	/* Test disabling critical clock. */
+	ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
+	ut_assertok(ret);
+	ut_asserteq_str("i2c_root", clk->dev->name);
+
+	/* Disable it, if any. */
+	ret = sandbox_clk_enable_count(clk);
+	for (i = 0; i < ret; i++) {
+		ret = clk_disable(clk);
+		ut_assertok(ret);
+	}
+
+	ret = sandbox_clk_enable_count(clk);
+	ut_asserteq(ret, 0);
+
+	clk->flags = CLK_IS_CRITICAL;
+	ret = clk_enable(clk);
+	ut_assertok(ret);
+
+	ret = clk_disable(clk);
+	ut_assertok(ret);
+	ret = sandbox_clk_enable_count(clk);
+	ut_asserteq(ret, 1);
+	clk->flags &= ~CLK_IS_CRITICAL;
+
+	ret = clk_disable(clk);
+	ut_assertok(ret);
+	ret = sandbox_clk_enable_count(clk);
+	ut_asserteq(ret, 0);
 #endif
 
 	return 1;
Signature · 1 line
2.7.4
#5 lore raw

PATCH v3 5/21 clk: get clock pointer before proceeding

In reply to Claudiu Beznea

clk_get_by_indexed_prop() retrieves a clock with dev member being set with the pointer to the udevice for the clock controller driver. But in case of CCF each clock driver has set in dev member the reference to its parent (the root of the clock tree is a fixed clock, every node in clock tree is a clock registered with clk_register()). In this case the subsequent operations like dev_get_clk_ptr() on clocks retrieved by clk_get_by_indexed_prop() will fail. For this, get the pointer to the proper clock registered (with clk_register()) using clk_get_by_id() before proceeding.

Fixes 1d7993d1d0ef ("clk: Port Linux common clock framework [CCF] for imx6q to U-boot (tag: v5.1.12)")
---
 drivers/clk/clk-uclass.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)
drivers/clk/clk-uclass.c +33 -4
index b8538f342a0c..4076535271b1 100644
@@ -188,9 +188,26 @@ bulk_get_err:
 	return ret;
 }
 
+static struct clk *clk_set_default_get_by_id(struct clk *clk)
+{
+	struct clk *c = clk;
+
+	if (CONFIG_IS_ENABLED(CLK_CCF)) {
+		int ret = clk_get_by_id(clk->id, &c);
+
+		if (ret) {
+			debug("%s(): could not get parent clock pointer, id %lu\n",
+			      __func__, clk->id);
+			ERR_PTR(ret);
+		}
+	}
+
+	return c;
+}
+
 static int clk_set_default_parents(struct udevice *dev, int stage)
 {
-	struct clk clk, parent_clk;
+	struct clk clk, parent_clk, *c, *p;
 	int index;
 	int num_parents;
 	int ret;
@@ -216,6 +233,10 @@ static int clk_set_default_parents(struct udevice *dev, int stage)
 			return ret;
 		}
 
+		p = clk_set_default_get_by_id(&parent_clk);
+		if (IS_ERR(p))
+			return PTR_ERR(p);
+
 		ret = clk_get_by_indexed_prop(dev, "assigned-clocks",
 					      index, &clk);
 		if (ret) {
@@ -235,7 +256,11 @@ static int clk_set_default_parents(struct udevice *dev, int stage)
 			/* do not setup twice the parent clocks */
 			continue;
 
-		ret = clk_set_parent(&clk, &parent_clk);
+		c = clk_set_default_get_by_id(&clk);
+		if (IS_ERR(c))
+			return PTR_ERR(c);
+
+		ret = clk_set_parent(c, p);
 		/*
 		 * Not all drivers may support clock-reparenting (as of now).
 		 * Ignore errors due to this.
@@ -255,7 +280,7 @@ static int clk_set_default_parents(struct udevice *dev, int stage)
 
 static int clk_set_default_rates(struct udevice *dev, int stage)
 {
-	struct clk clk;
+	struct clk clk, *c;
 	int index;
 	int num_rates;
 	int size;
@@ -299,7 +324,11 @@ static int clk_set_default_rates(struct udevice *dev, int stage)
 			/* do not setup twice the parent clocks */
 			continue;
 
-		ret = clk_set_rate(&clk, rates[index]);
+		c = clk_set_default_get_by_id(&clk);
+		if (IS_ERR(c))
+			return PTR_ERR(c);
+
+		ret = clk_set_rate(c, rates[index]);
 
 		if (ret < 0) {
 			debug("%s: failed to set rate on clock index %d (%ld) for %s\n",
Signature · 1 line
2.7.4
#6 lore raw

PATCH v3 6/21 clk: at91: add pre-requisite headers for AT91 clock architecture

In reply to Claudiu Beznea

Add pre-requisite headers for AT91 clock architecture. These are based on already present files on Linux and will be used by following commits for AT91 CCF clock drivers.

---
 include/dt-bindings/clk/at91.h |  22 ++++
 include/linux/clk/at91_pmc.h   | 247 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 269 insertions(+)
 create mode 100644 include/dt-bindings/clk/at91.h
 create mode 100644 include/linux/clk/at91_pmc.h
include/dt-bindings/clk/at91.h new file +22 -0
new file mode 100644
index 000000000000..e30756b2804a
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * This header provides constants for AT91 pmc status.
+ * The constants defined in this header are being used in dts and PMC code.
+ *
+ * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries
+ *
+ * Author: Claudiu Beznea <[email protected]>
+ *
+ * Based on include/dt-bindings/clock/at91.h on Linux.
+ */
+
+#ifndef _DT_BINDINGS_CLK_AT91_H
+#define _DT_BINDINGS_CLK_AT91_H
+
+#define PMC_TYPE_CORE		1
+#define PMC_TYPE_SYSTEM		2
+#define PMC_TYPE_PERIPHERAL	3
+#define PMC_TYPE_GCK		4
+#define PMC_TYPE_SLOW		5
+
+#endif
include/linux/clk/at91_pmc.h new file +247 -0

247 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

PATCH v3 7/21 clk: at91: pmc: add helpers for clock drivers

In reply to Claudiu Beznea

Add helper for clock drivers. These will be used by following commits in the process of switching AT91 clock drivers to CCF.

---
 drivers/clk/at91/pmc.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h | 13 ++++++++
 2 files changed, 104 insertions(+)
drivers/clk/at91/pmc.c +91 -0
index ca90abef2d53..e403baea0efd 100644
@@ -120,3 +120,94 @@ int at91_clk_probe(struct udevice *dev)
 
 	return 0;
 }
+
+/**
+ * pmc_read() - read content at address base + off into val
+ *
+ * @base: base address
+ * @off: offset to read from
+ * @val: where the content of base + off is stored
+ *
+ * @return: void
+ */
+void pmc_read(void __iomem *base, unsigned int off, unsigned int *val)
+{
+	*val = readl(base + off);
+}
+
+/**
+ * pmc_write() - write content of val at address base + off
+ *
+ * @base: base address
+ * @off: offset to write to
+ * @val: content to be written at base + off
+ *
+ * @return: void
+ */
+void pmc_write(void __iomem *base, unsigned int off, unsigned int val)
+{
+	writel(val, base + off);
+}
+
+/**
+ * pmc_update_bits() - update a set of bits at address base + off
+ *
+ * @base: base address
+ * @off: offset to be updated
+ * @mask: mask of bits to be updated
+ * @bits: the new value to be updated
+ *
+ * @return: void
+ */
+void pmc_update_bits(void __iomem *base, unsigned int off,
+		     unsigned int mask, unsigned int bits)
+{
+	unsigned int tmp;
+
+	tmp = readl(base + off);
+	tmp &= ~mask;
+	writel(tmp | (bits & mask), base + off);
+}
+
+/**
+ * at91_clk_mux_val_to_index() - get parent index in mux table
+ *
+ * @table: clock mux table
+ * @num_parents: clock number of parents
+ * @val: clock id who's mux index should be retrieved
+ *
+ * @return: clock index in mux table or a negative error number in case of
+ *		failure
+ */
+int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val)
+{
+	int i;
+
+	if (!table || !num_parents)
+		return -EINVAL;
+
+	for (i = 0; i < num_parents; i++) {
+		if (table[i] == val)
+			return i;
+	}
+
+	return -EINVAL;
+}
+
+/**
+ * at91_clk_mux_index_to_val() - get parent ID corresponding to an entry in
+ *	clock's mux table
+ *
+ * @table: clock's mux table
+ * @num_parents: clock's number of parents
+ * @index: index in mux table which clock's ID should be retrieved
+ *
+ * @return: clock ID or a negative error number in case of failure
+ */
+int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index)
+{
+	if (!table || !num_parents || index < 0 || index > num_parents)
+		return -EINVAL;
+
+	return table[index];
+}
drivers/clk/at91/pmc.h +13 -0
index 517ba1d6b452..b1ab0a95c855 100644
@@ -8,6 +8,12 @@
 #define __AT91_PMC_H__
 
 #include <regmap.h>
+#include <linux/bitops.h>
+#include <linux/io.h>
+
+/* Keep a range of 256 available clocks for every clock type. */
+#define AT91_TO_CLK_ID(_t, _i)		(((_t) << 8) | ((_i) & 0xff))
+#define AT91_CLK_ID_TO_DID(_i)		((_i) & 0xff)
 
 struct pmc_platdata {
 	struct at91_pmc *reg_base;
@@ -20,4 +26,11 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name);
 int at91_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args);
 int at91_clk_probe(struct udevice *dev);
 
+int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
+int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
+
+void pmc_read(void __iomem *base, unsigned int off, unsigned int *val);
+void pmc_write(void __iomem *base, unsigned int off, unsigned int val);
+void pmc_update_bits(void __iomem *base, unsigned int off, unsigned int mask,
+			unsigned int bits);
 #endif
Signature · 1 line
2.7.4
#8 lore raw

PATCH v3 8/21 clk: at91: move clock code to compat.c

In reply to Claudiu Beznea

Move clock code to compat.c to allow switching to CCF without mixing CCF code with non CCF code. This prepares the field for next commits.

---
 drivers/clk/at91/Makefile         |   13 +-
 drivers/clk/at91/clk-generated.c  |  178 -------
 drivers/clk/at91/clk-h32mx.c      |   56 --
 drivers/clk/at91/clk-main.c       |   54 --
 drivers/clk/at91/clk-master.c     |   33 --
 drivers/clk/at91/clk-peripheral.c |  113 ----
 drivers/clk/at91/clk-plla.c       |   54 --
 drivers/clk/at91/clk-plladiv.c    |   85 ---
 drivers/clk/at91/clk-slow.c       |   36 --
 drivers/clk/at91/clk-system.c     |  111 ----
 drivers/clk/at91/clk-usb.c        |  147 ------
 drivers/clk/at91/clk-utmi.c       |  142 -----
 drivers/clk/at91/compat.c         | 1023 +++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.c            |  116 +----
 drivers/clk/at91/pmc.h            |   13 +-
 drivers/clk/at91/sckc.c           |   19 -
 16 files changed, 1030 insertions(+), 1163 deletions(-)
 delete mode 100644 drivers/clk/at91/clk-generated.c
 delete mode 100644 drivers/clk/at91/clk-h32mx.c
 delete mode 100644 drivers/clk/at91/clk-main.c
 delete mode 100644 drivers/clk/at91/clk-master.c
 delete mode 100644 drivers/clk/at91/clk-peripheral.c
 delete mode 100644 drivers/clk/at91/clk-plla.c
 delete mode 100644 drivers/clk/at91/clk-plladiv.c
 delete mode 100644 drivers/clk/at91/clk-slow.c
 delete mode 100644 drivers/clk/at91/clk-system.c
 delete mode 100644 drivers/clk/at91/clk-usb.c
 delete mode 100644 drivers/clk/at91/clk-utmi.c
 create mode 100644 drivers/clk/at91/compat.c
 delete mode 100644 drivers/clk/at91/sckc.c
drivers/clk/at91/Makefile +5 -8
index 8c197ff949a8..e2413af40360 100644
@@ -2,11 +2,8 @@
 # Makefile for at91 specific clk
 #
 
-obj-y += pmc.o sckc.o
-obj-y += clk-slow.o clk-main.o clk-plla.o clk-plladiv.o clk-master.o
-obj-y += clk-system.o clk-peripheral.o
-
-obj-$(CONFIG_AT91_UTMI)		+= clk-utmi.o
-obj-$(CONFIG_AT91_USB_CLK)	+= clk-usb.o
-obj-$(CONFIG_AT91_H32MX)	+= clk-h32mx.o
-obj-$(CONFIG_AT91_GENERIC_CLK)	+= clk-generated.o
+ifdef CONFIG_CLK_CCF
+obj-y += pmc.o
+else
+obj-y += compat.o
+endif
drivers/clk/at91/clk-generated.c deleted +0 -178

178 lines not on this page · raw message

drivers/clk/at91/clk-h32mx.c deleted +0 -56

56 lines not on this page · raw message

drivers/clk/at91/clk-main.c deleted +0 -54

54 lines not on this page · raw message

drivers/clk/at91/clk-master.c deleted +0 -33
deleted file mode 100644
index e078fab7b415..000000000000
@@ -1,33 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2016 Atmel Corporation
- *               Wenyou.Yang <[email protected]>
- */
-
-#include <common.h>
-#include <clk-uclass.h>
-#include <dm.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static ulong at91_master_clk_get_rate(struct clk *clk)
-{
-	return gd->arch.mck_rate_hz;
-}
-
-static struct clk_ops at91_master_clk_ops = {
-	.get_rate = at91_master_clk_get_rate,
-};
-
-static const struct udevice_id at91_master_clk_match[] = {
-	{ .compatible = "atmel,at91rm9200-clk-master" },
-	{ .compatible = "atmel,at91sam9x5-clk-master" },
-	{}
-};
-
-U_BOOT_DRIVER(atmel_at91rm9200_clk_master) = {
-	.name = "atmel_at91rm9200_clk_master",
-	.id = UCLASS_CLK,
-	.of_match = at91_master_clk_match,
-	.ops = &at91_master_clk_ops,
-};
drivers/clk/at91/clk-peripheral.c deleted +0 -113

113 lines not on this page · raw message

drivers/clk/at91/clk-plla.c deleted +0 -54

54 lines not on this page · raw message

drivers/clk/at91/clk-plladiv.c deleted +0 -85

85 lines not on this page · raw message

drivers/clk/at91/clk-slow.c deleted +0 -36
deleted file mode 100644
index 1f8665768b00..000000000000
@@ -1,36 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2016 Atmel Corporation
- *               Wenyou.Yang <[email protected]>
- */
-
-#include <common.h>
-#include <clk-uclass.h>
-#include <dm.h>
-
-static int at91_slow_clk_enable(struct clk *clk)
-{
-	return 0;
-}
-
-static ulong at91_slow_clk_get_rate(struct clk *clk)
-{
-	return CONFIG_SYS_AT91_SLOW_CLOCK;
-}
-
-static struct clk_ops at91_slow_clk_ops = {
-	.enable = at91_slow_clk_enable,
-	.get_rate = at91_slow_clk_get_rate,
-};
-
-static const struct udevice_id at91_slow_clk_match[] = {
-	{ .compatible = "atmel,at91sam9x5-clk-slow" },
-	{}
-};
-
-U_BOOT_DRIVER(at91_slow_clk) = {
-	.name = "at91-slow-clk",
-	.id = UCLASS_CLK,
-	.of_match = at91_slow_clk_match,
-	.ops = &at91_slow_clk_ops,
-};
drivers/clk/at91/clk-system.c deleted +0 -111

111 lines not on this page · raw message

drivers/clk/at91/clk-usb.c deleted +0 -147

147 lines not on this page · raw message

drivers/clk/at91/clk-utmi.c deleted +0 -142

142 lines not on this page · raw message

drivers/clk/at91/compat.c new file +1023 -0

1,023 lines not on this page · raw message

drivers/clk/at91/pmc.c +1 -115

123 lines not on this page · raw message

drivers/clk/at91/pmc.h +1 -12
index b1ab0a95c855..33ded02156c8 100644
@@ -7,7 +7,6 @@
 #ifndef __AT91_PMC_H__
 #define __AT91_PMC_H__
 
-#include <regmap.h>
 #include <linux/bitops.h>
 #include <linux/io.h>
 
@@ -15,17 +14,6 @@
 #define AT91_TO_CLK_ID(_t, _i)		(((_t) << 8) | ((_i) & 0xff))
 #define AT91_CLK_ID_TO_DID(_i)		((_i) & 0xff)
 
-struct pmc_platdata {
-	struct at91_pmc *reg_base;
-	struct regmap *regmap_sfr;
-};
-
-int at91_pmc_core_probe(struct udevice *dev);
-int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name);
-
-int at91_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args);
-int at91_clk_probe(struct udevice *dev);
-
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
 
@@ -33,4 +21,5 @@ void pmc_read(void __iomem *base, unsigned int off, unsigned int *val);
 void pmc_write(void __iomem *base, unsigned int off, unsigned int val);
 void pmc_update_bits(void __iomem *base, unsigned int off, unsigned int mask,
 			unsigned int bits);
+
 #endif
drivers/clk/at91/sckc.c deleted +0 -19
deleted file mode 100644
index a879b008ffd6..000000000000
@@ -1,19 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2016 Atmel Corporation
- *               Wenyou.Yang <[email protected]>
- */
-
-#include <common.h>
-#include <dm.h>
-
-static const struct udevice_id at91_sckc_match[] = {
-	{ .compatible = "atmel,at91sam9x5-sckc" },
-	{}
-};
-
-U_BOOT_DRIVER(at91_sckc) = {
-	.name = "at91-sckc",
-	.id = UCLASS_SIMPLE_BUS,
-	.of_match = at91_sckc_match,
-};
Signature · 1 line
2.7.4
#9 lore raw

PATCH v3 9/21 clk: at91: sckc: add driver compatible with ccf

In reply to Claudiu Beznea

Add sckc driver compatible with common clock framework. Driver implements slow clock support for SAM9X60 compatible IPs (in this list it is also present SAMA7G5's slow clock IP).

---
 drivers/clk/at91/Makefile |   2 +-
 drivers/clk/at91/sckc.c   | 172 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 173 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/at91/sckc.c
drivers/clk/at91/Makefile +1 -1
index e2413af40360..7083ce2890d6 100644
@@ -3,7 +3,7 @@
 #
 
 ifdef CONFIG_CLK_CCF
-obj-y += pmc.o
+obj-y += pmc.o sckc.o
 else
 obj-y += compat.o
 endif
drivers/clk/at91/sckc.c new file +172 -0

172 lines not on this page · raw message

Signature · 1 line
2.7.4
#10 lore raw

PATCH v3 10/21 clk: at91: clk-main: add driver compatible with ccf

In reply to Claudiu Beznea

Add clk-main driver compatible with common clock framework.

---
 drivers/clk/at91/Makefile   |   2 +-
 drivers/clk/at91/clk-main.c | 387 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h      |  10 ++
 3 files changed, 398 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/at91/clk-main.c
drivers/clk/at91/Makefile +1 -1
index 7083ce2890d6..805f67677a9b 100644
@@ -3,7 +3,7 @@
 #
 
 ifdef CONFIG_CLK_CCF
-obj-y += pmc.o sckc.o
+obj-y += pmc.o sckc.o clk-main.o
 else
 obj-y += compat.o
 endif
drivers/clk/at91/clk-main.c new file +387 -0

387 lines not on this page · raw message

drivers/clk/at91/pmc.h +10 -0
index 33ded02156c8..62bfc4b3054c 100644
@@ -14,6 +14,16 @@
 #define AT91_TO_CLK_ID(_t, _i)		(((_t) << 8) | ((_i) & 0xff))
 #define AT91_CLK_ID_TO_DID(_i)		((_i) & 0xff)
 
+struct clk *at91_clk_main_rc(void __iomem *reg, const char *name,
+			const char *parent_name);
+struct clk *at91_clk_main_osc(void __iomem *reg, const char *name,
+			const char *parent_name, bool bypass);
+struct clk *at91_clk_rm9200_main(void __iomem *reg, const char *name,
+			const char *parent_name);
+struct clk *at91_clk_sam9x5_main(void __iomem *reg, const char *name,
+			const char * const *parent_names, int num_parents,
+			const u32 *mux_table, int type);
+
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
 
Signature · 1 line
2.7.4
#11 lore raw

PATCH v3 11/21 clk: at91: sam9x60-pll: add driver compatible with ccf

In reply to Claudiu Beznea

Add sam9x60-pll driver compatible with common clock framework.

---
 drivers/clk/at91/Kconfig           |   7 +
 drivers/clk/at91/Makefile          |   1 +
 drivers/clk/at91/clk-sam9x60-pll.c | 442 +++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h             |  36 +++
 4 files changed, 486 insertions(+)
 create mode 100644 drivers/clk/at91/clk-sam9x60-pll.c
drivers/clk/at91/Kconfig +7 -0
index 8d482a275239..4abc8026b4da 100644
@@ -54,3 +54,10 @@ config AT91_GENERIC_CLK
 	  that may be different from the system clock. This second
 	  clock is the generic clock (GCLK) and is managed by
 	  the PMC via PMC_PCR register.
+
+config AT91_SAM9X60_PLL
+	bool "PLL support for SAM9X60 SoCs"
+	depends on CLK_AT91
+	help
+	  This option is used to enable the AT91 SAM9X60's PLL clock
+	  driver.
drivers/clk/at91/Makefile +1 -0
index 805f67677a9b..338582b88aee 100644
@@ -4,6 +4,7 @@
 
 ifdef CONFIG_CLK_CCF
 obj-y += pmc.o sckc.o clk-main.o
+obj-$(CONFIG_AT91_SAM9X60_PLL)	+= clk-sam9x60-pll.o
 else
 obj-y += compat.o
 endif
drivers/clk/at91/clk-sam9x60-pll.c new file +442 -0

442 lines not on this page · raw message

drivers/clk/at91/pmc.h +36 -0
index 62bfc4b3054c..b24d2d89903d 100644
@@ -14,6 +14,32 @@
 #define AT91_TO_CLK_ID(_t, _i)		(((_t) << 8) | ((_i) & 0xff))
 #define AT91_CLK_ID_TO_DID(_i)		((_i) & 0xff)
 
+struct clk_range {
+	unsigned long min;
+	unsigned long max;
+};
+
+struct clk_pll_characteristics {
+	struct clk_range input;
+	int num_output;
+	const struct clk_range *output;
+	u16 *icpll;
+	u8 *out;
+	u8 upll : 1;
+};
+
+struct clk_pll_layout {
+	u32 pllr_mask;
+	u32 mul_mask;
+	u32 frac_mask;
+	u32 div_mask;
+	u32 endiv_mask;
+	u8 mul_shift;
+	u8 frac_shift;
+	u8 div_shift;
+	u8 endiv_shift;
+};
+
 struct clk *at91_clk_main_rc(void __iomem *reg, const char *name,
 			const char *parent_name);
 struct clk *at91_clk_main_osc(void __iomem *reg, const char *name,
@@ -23,6 +49,16 @@ struct clk *at91_clk_rm9200_main(void __iomem *reg, const char *name,
 struct clk *at91_clk_sam9x5_main(void __iomem *reg, const char *name,
 			const char * const *parent_names, int num_parents,
 			const u32 *mux_table, int type);
+struct clk *
+sam9x60_clk_register_div_pll(void __iomem *base, const char *name,
+			const char *parent_name, u8 id,
+			const struct clk_pll_characteristics *characteristics,
+			const struct clk_pll_layout *layout, bool critical);
+struct clk *
+sam9x60_clk_register_frac_pll(void __iomem *base, const char *name,
+			const char *parent_name, u8 id,
+			const struct clk_pll_characteristics *characteristics,
+			const struct clk_pll_layout *layout, bool critical);
 
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
Signature · 1 line
2.7.4
#12 lore raw

PATCH v3 12/21 clk: at91: clk-master: add driver compatible with ccf

In reply to Claudiu Beznea

Add clk-master driver compatible with common clock framework.

---
 drivers/clk/at91/Makefile     |   2 +-
 drivers/clk/at91/clk-master.c | 156 ++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h        |  21 ++++++
 3 files changed, 178 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/at91/clk-master.c
drivers/clk/at91/Makefile +1 -1
index 338582b88aee..a4e397066e1e 100644
@@ -3,7 +3,7 @@
 #
 
 ifdef CONFIG_CLK_CCF
-obj-y += pmc.o sckc.o clk-main.o
+obj-y += pmc.o sckc.o clk-main.o clk-master.o
 obj-$(CONFIG_AT91_SAM9X60_PLL)	+= clk-sam9x60-pll.o
 else
 obj-y += compat.o
drivers/clk/at91/clk-master.c new file +156 -0

156 lines not on this page · raw message

drivers/clk/at91/pmc.h +21 -0
index b24d2d89903d..33c7a66e84b5 100644
@@ -19,6 +19,21 @@ struct clk_range {
 	unsigned long max;
 };
 
+struct clk_master_layout {
+	u32 offset;
+	u32 mask;
+	u8 pres_shift;
+};
+
+extern const struct clk_master_layout at91rm9200_master_layout;
+extern const struct clk_master_layout at91sam9x5_master_layout;
+
+struct clk_master_characteristics {
+	struct clk_range output;
+	u32 divisors[4];
+	u8 have_div3_pres;
+};
+
 struct clk_pll_characteristics {
 	struct clk_range input;
 	int num_output;
@@ -59,6 +74,12 @@ sam9x60_clk_register_frac_pll(void __iomem *base, const char *name,
 			const char *parent_name, u8 id,
 			const struct clk_pll_characteristics *characteristics,
 			const struct clk_pll_layout *layout, bool critical);
+struct clk *
+at91_clk_register_master(void __iomem *base, const char *name,
+			const char * const *parent_names, int num_parents,
+			const struct clk_master_layout *layout,
+			const struct clk_master_characteristics *characteristics,
+			const u32 *mux_table);
 
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
Signature · 1 line
2.7.4
#13 lore raw

PATCH v3 13/21 clk: at91: clk-master: add support for sama7g5

In reply to Claudiu Beznea

Add master clock (MCK1..MCK4) support for SAMA7G5. SAMA7G5's PMC has multiple master clocks feeding different subsystems. One of them feeds image subsystem and is changeable based on image subsystem needs.

---
 drivers/clk/at91/clk-master.c | 178 +++++++++++++++++++++++++++++++++++++++++-
 drivers/clk/at91/pmc.h        |   5 ++
 2 files changed, 182 insertions(+), 1 deletion(-)
drivers/clk/at91/clk-master.c +177 -1
index 1d388b6b2519..759df93697d2 100644
@@ -19,12 +19,25 @@
 #include "pmc.h"
 
 #define UBOOT_DM_CLK_AT91_MASTER		"at91-master-clk"
+#define UBOOT_DM_CLK_AT91_SAMA7G5_MASTER	"at91-sama7g5-master-clk"
 
 #define MASTER_PRES_MASK	0x7
 #define MASTER_PRES_MAX		MASTER_PRES_MASK
 #define MASTER_DIV_SHIFT	8
 #define MASTER_DIV_MASK		0x3
 
+#define PMC_MCR			0x30
+#define PMC_MCR_ID_MSK		GENMASK(3, 0)
+#define PMC_MCR_CMD		BIT(7)
+#define PMC_MCR_DIV		GENMASK(10, 8)
+#define PMC_MCR_CSS		GENMASK(20, 16)
+#define PMC_MCR_CSS_SHIFT	(16)
+#define PMC_MCR_EN		BIT(28)
+
+#define PMC_MCR_ID(x)		((x) & PMC_MCR_ID_MSK)
+
+#define MASTER_MAX_ID		4
+
 struct clk_master {
 	void __iomem *base;
 	const struct clk_master_layout *layout;
@@ -40,11 +53,12 @@ struct clk_master {
 
 static inline bool clk_master_ready(struct clk_master *master)
 {
+	unsigned int bit = master->id ? AT91_PMC_MCKXRDY : AT91_PMC_MCKRDY;
 	unsigned int status;
 
 	pmc_read(master->base, AT91_PMC_SR, &status);
 
-	return !!(status & AT91_PMC_MCKRDY);
+	return !!(status & bit);
 }
 
 static int clk_master_enable(struct clk *clk)
@@ -143,6 +157,168 @@ U_BOOT_DRIVER(at91_master_clk) = {
 	.flags = DM_FLAG_PRE_RELOC,
 };
 
+static int clk_sama7g5_master_set_parent(struct clk *clk, struct clk *parent)
+{
+	struct clk_master *master = to_clk_master(clk);
+	int index;
+
+	index = at91_clk_mux_val_to_index(master->clk_mux_table,
+					  master->num_parents, parent->id);
+	if (index < 0)
+		return index;
+
+	index = at91_clk_mux_index_to_val(master->mux_table,
+					  master->num_parents, index);
+	if (index < 0)
+		return index;
+
+	pmc_write(master->base, PMC_MCR, PMC_MCR_ID(master->id));
+	pmc_update_bits(master->base, PMC_MCR,
+			PMC_MCR_CSS | PMC_MCR_CMD | PMC_MCR_ID_MSK,
+			(index << PMC_MCR_CSS_SHIFT) | PMC_MCR_CMD |
+			PMC_MCR_ID(master->id));
+	return 0;
+}
+
+static int clk_sama7g5_master_enable(struct clk *clk)
+{
+	struct clk_master *master = to_clk_master(clk);
+
+	pmc_write(master->base, PMC_MCR, PMC_MCR_ID(master->id));
+	pmc_update_bits(master->base, PMC_MCR,
+			PMC_MCR_EN | PMC_MCR_CMD | PMC_MCR_ID_MSK,
+			PMC_MCR_EN | PMC_MCR_CMD | PMC_MCR_ID(master->id));
+
+	return 0;
+}
+
+static int clk_sama7g5_master_disable(struct clk *clk)
+{
+	struct clk_master *master = to_clk_master(clk);
+
+	pmc_write(master->base, PMC_MCR, master->id);
+	pmc_update_bits(master->base, PMC_MCR,
+			PMC_MCR_EN | PMC_MCR_CMD | PMC_MCR_ID_MSK,
+			PMC_MCR_CMD | PMC_MCR_ID(master->id));
+
+	return 0;
+}
+
+static ulong clk_sama7g5_master_set_rate(struct clk *clk, ulong rate)
+{
+	struct clk_master *master = to_clk_master(clk);
+	ulong parent_rate = clk_get_parent_rate(clk);
+	ulong div, rrate;
+
+	if (!parent_rate)
+		return 0;
+
+	div = DIV_ROUND_CLOSEST(parent_rate, rate);
+	if ((div > (1 << (MASTER_PRES_MAX - 1))) || (div & (div - 1))) {
+		return 0;
+	} else if (div == 3) {
+		rrate = DIV_ROUND_CLOSEST(parent_rate, MASTER_PRES_MAX);
+		div = MASTER_PRES_MAX;
+	} else {
+		rrate = DIV_ROUND_CLOSEST(parent_rate, div);
+		div = ffs(div) - 1;
+	}
+
+	pmc_write(master->base, PMC_MCR, master->id);
+	pmc_update_bits(master->base, PMC_MCR,
+			PMC_MCR_DIV | PMC_MCR_CMD | PMC_MCR_ID_MSK,
+			(div << MASTER_DIV_SHIFT) | PMC_MCR_CMD |
+			PMC_MCR_ID(master->id));
+
+	return rrate;
+}
+
+static ulong clk_sama7g5_master_get_rate(struct clk *clk)
+{
+	struct clk_master *master = to_clk_master(clk);
+	ulong parent_rate = clk_get_parent_rate(clk);
+	unsigned int val;
+	ulong div;
+
+	if (!parent_rate)
+		return 0;
+
+	pmc_write(master->base, PMC_MCR, master->id);
+	pmc_read(master->base, PMC_MCR, &val);
+
+	div = (val >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
+
+	if (div == MASTER_PRES_MAX)
+		div = 3;
+	else
+		div = 1 << div;
+
+	return DIV_ROUND_CLOSEST(parent_rate, div);
+}
+
+static const struct clk_ops sama7g5_master_ops = {
+	.enable = clk_sama7g5_master_enable,
+	.disable = clk_sama7g5_master_disable,
+	.set_rate = clk_sama7g5_master_set_rate,
+	.get_rate = clk_sama7g5_master_get_rate,
+	.set_parent = clk_sama7g5_master_set_parent,
+};
+
+struct clk *at91_clk_sama7g5_register_master(void __iomem *base,
+		const char *name, const char * const *parent_names,
+		int num_parents, const u32 *mux_table, const u32 *clk_mux_table,
+		bool critical, u8 id)
+{
+	struct clk_master *master;
+	struct clk *clk;
+	u32 val, index;
+	int ret;
+
+	if (!base || !name || !num_parents || !parent_names ||
+	    !mux_table || !clk_mux_table || id > MASTER_MAX_ID)
+		return ERR_PTR(-EINVAL);
+
+	master = kzalloc(sizeof(*master), GFP_KERNEL);
+	if (!master)
+		return ERR_PTR(-ENOMEM);
+
+	master->base = base;
+	master->id = id;
+	master->mux_table = mux_table;
+	master->clk_mux_table = clk_mux_table;
+	master->num_parents = num_parents;
+
+	pmc_write(master->base, PMC_MCR, master->id);
+	pmc_read(master->base, PMC_MCR, &val);
+
+	index = at91_clk_mux_val_to_index(master->mux_table,
+				master->num_parents,
+				(val & PMC_MCR_CSS) >> PMC_MCR_CSS_SHIFT);
+	if (index < 0) {
+		kfree(master);
+		return ERR_PTR(index);
+	}
+
+	clk = &master->clk;
+	clk->flags = CLK_GET_RATE_NOCACHE | (critical ? CLK_IS_CRITICAL : 0);
+
+	ret = clk_register(clk, UBOOT_DM_CLK_AT91_SAMA7G5_MASTER, name,
+			   parent_names[index]);
+	if (ret) {
+		kfree(master);
+		clk = ERR_PTR(ret);
+	}
+
+	return clk;
+}
+
+U_BOOT_DRIVER(at91_sama7g5_master_clk) = {
+	.name = UBOOT_DM_CLK_AT91_SAMA7G5_MASTER,
+	.id = UCLASS_CLK,
+	.ops = &sama7g5_master_ops,
+	.flags = DM_FLAG_PRE_RELOC,
+};
+
 const struct clk_master_layout at91rm9200_master_layout = {
 	.mask = 0x31F,
 	.pres_shift = 2,
drivers/clk/at91/pmc.h +5 -0
index 33c7a66e84b5..49e1e372b897 100644
@@ -80,6 +80,11 @@ at91_clk_register_master(void __iomem *base, const char *name,
 			const struct clk_master_layout *layout,
 			const struct clk_master_characteristics *characteristics,
 			const u32 *mux_table);
+struct clk *
+at91_clk_sama7g5_register_master(void __iomem *base, const char *name,
+			const char * const *parent_names, int num_parents,
+			const u32 *mux_table, const u32 *clk_mux_table,
+			bool critical, u8 id);
 
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
Signature · 1 line
2.7.4
#14 lore raw

PATCH v3 14/21 clk: at91: clk-utmi: add driver compatible with ccf

In reply to Claudiu Beznea

Add clk-utmi driver compatible with common clock framework.

---
 drivers/clk/at91/Makefile   |   1 +
 drivers/clk/at91/clk-utmi.c | 165 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h      |   3 +
 3 files changed, 169 insertions(+)
 create mode 100644 drivers/clk/at91/clk-utmi.c
drivers/clk/at91/Makefile +1 -0
index a4e397066e1e..9c38bda5e6b7 100644
@@ -4,6 +4,7 @@
 
 ifdef CONFIG_CLK_CCF
 obj-y += pmc.o sckc.o clk-main.o clk-master.o
+obj-$(CONFIG_AT91_UTMI)		+= clk-utmi.o
 obj-$(CONFIG_AT91_SAM9X60_PLL)	+= clk-sam9x60-pll.o
 else
 obj-y += compat.o
drivers/clk/at91/clk-utmi.c new file +165 -0

165 lines not on this page · raw message

drivers/clk/at91/pmc.h +3 -0
index 49e1e372b897..264b36c7b4f5 100644
@@ -85,6 +85,9 @@ at91_clk_sama7g5_register_master(void __iomem *base, const char *name,
 			const char * const *parent_names, int num_parents,
 			const u32 *mux_table, const u32 *clk_mux_table,
 			bool critical, u8 id);
+struct clk *
+at91_clk_register_utmi(void __iomem *base, struct udevice *dev,
+			const char *name, const char *parent_name);
 
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
Signature · 1 line
2.7.4
#15 lore raw

PATCH v3 15/21 clk: at91: clk-utmi: add support for sama7g5

In reply to Claudiu Beznea

Add UTMI support for SAMA7G5. SAMA7G5's UTMI control is done via XTALF register. Values written at bits 2..0 in this register correspond to the on board crystal oscillator frequency.

---
 drivers/clk/at91/clk-utmi.c | 71 ++++++++++++++++++++++++++++++++++++++++++++-
 drivers/clk/at91/pmc.h      |  3 ++
 2 files changed, 73 insertions(+), 1 deletion(-)
drivers/clk/at91/clk-utmi.c +70 -1
index b60fd35b6b6a..7c8bcfb51dba 100644
@@ -20,7 +20,8 @@
 
 #include "pmc.h"
 
-#define UBOOT_DM_CLK_AT91_UTMI		"at91-utmi-clk"
+#define UBOOT_DM_CLK_AT91_UTMI			"at91-utmi-clk"
+#define UBOOT_DM_CLK_AT91_SAMA7G5_UTMI		"at91-sama7g5-utmi-clk"
 
 /*
  * The purpose of this clock is to generate a 480 MHz signal. A different
@@ -163,3 +164,71 @@ U_BOOT_DRIVER(at91_utmi_clk) = {
 	.ops = &utmi_ops,
 	.flags = DM_FLAG_PRE_RELOC,
 };
+
+static int clk_utmi_sama7g5_enable(struct clk *clk)
+{
+	struct clk_utmi *utmi = to_clk_utmi(clk);
+	ulong parent_rate = clk_get_parent_rate(clk);
+	unsigned int val;
+
+	switch (parent_rate) {
+	case 16000000:
+		val = 0;
+		break;
+	case 20000000:
+		val = 2;
+		break;
+	case 24000000:
+		val = 3;
+		break;
+	case 32000000:
+		val = 5;
+		break;
+	default:
+		debug("UTMICK: unsupported main_xtal rate\n");
+		return -EINVAL;
+	}
+
+	pmc_write(utmi->base, AT91_PMC_XTALF, val);
+
+	return 0;
+}
+
+static const struct clk_ops sama7g5_utmi_ops = {
+	.enable = clk_utmi_sama7g5_enable,
+	.get_rate = clk_utmi_get_rate,
+};
+
+struct clk *at91_clk_sama7g5_register_utmi(void __iomem *base,
+		const char *name, const char *parent_name)
+{
+	struct clk_utmi *utmi;
+	struct clk *clk;
+	int ret;
+
+	if (!base || !name || !parent_name)
+		return ERR_PTR(-EINVAL);
+
+	utmi = kzalloc(sizeof(*utmi), GFP_KERNEL);
+	if (!utmi)
+		return ERR_PTR(-ENOMEM);
+
+	utmi->base = base;
+
+	clk = &utmi->clk;
+	ret = clk_register(clk, UBOOT_DM_CLK_AT91_SAMA7G5_UTMI, name,
+			   parent_name);
+	if (ret) {
+		kfree(utmi);
+		clk = ERR_PTR(ret);
+	}
+
+	return clk;
+}
+
+U_BOOT_DRIVER(at91_sama7g5_utmi_clk) = {
+	.name = UBOOT_DM_CLK_AT91_SAMA7G5_UTMI,
+	.id = UCLASS_CLK,
+	.ops = &sama7g5_utmi_ops,
+	.flags = DM_FLAG_PRE_RELOC,
+};
drivers/clk/at91/pmc.h +3 -0
index 264b36c7b4f5..d34005f6986c 100644
@@ -88,6 +88,9 @@ at91_clk_sama7g5_register_master(void __iomem *base, const char *name,
 struct clk *
 at91_clk_register_utmi(void __iomem *base, struct udevice *dev,
 			const char *name, const char *parent_name);
+struct clk *
+at91_clk_sama7g5_register_utmi(void __iomem *base, const char *name,
+			const char *parent_name);
 
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
Signature · 1 line
2.7.4
#16 lore raw

PATCH v3 16/21 clk: at91: clk-programmable: add driver compatible with ccf

In reply to Claudiu Beznea

Add clk-programmable driver compatible with common clock framework.

---
 drivers/clk/at91/Makefile           |   2 +-
 drivers/clk/at91/clk-programmable.c | 208 ++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h              |  17 +++
 3 files changed, 226 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/at91/clk-programmable.c
drivers/clk/at91/Makefile +1 -1
index 9c38bda5e6b7..8951052eb0f3 100644
@@ -3,7 +3,7 @@
 #
 
 ifdef CONFIG_CLK_CCF
-obj-y += pmc.o sckc.o clk-main.o clk-master.o
+obj-y += pmc.o sckc.o clk-main.o clk-master.o clk-programmable.o
 obj-$(CONFIG_AT91_UTMI)		+= clk-utmi.o
 obj-$(CONFIG_AT91_SAM9X60_PLL)	+= clk-sam9x60-pll.o
 else
drivers/clk/at91/clk-programmable.c new file +208 -0

208 lines not on this page · raw message

drivers/clk/at91/pmc.h +17 -0
index d34005f6986c..a443b65257b9 100644
@@ -55,6 +55,18 @@ struct clk_pll_layout {
 	u8 endiv_shift;
 };
 
+struct clk_programmable_layout {
+	u8 pres_mask;
+	u8 pres_shift;
+	u8 css_mask;
+	u8 have_slck_mck;
+	u8 is_pres_direct;
+};
+
+extern const struct clk_programmable_layout at91rm9200_programmable_layout;
+extern const struct clk_programmable_layout at91sam9g45_programmable_layout;
+extern const struct clk_programmable_layout at91sam9x5_programmable_layout;
+
 struct clk *at91_clk_main_rc(void __iomem *reg, const char *name,
 			const char *parent_name);
 struct clk *at91_clk_main_osc(void __iomem *reg, const char *name,
@@ -91,6 +103,11 @@ at91_clk_register_utmi(void __iomem *base, struct udevice *dev,
 struct clk *
 at91_clk_sama7g5_register_utmi(void __iomem *base, const char *name,
 			const char *parent_name);
+struct clk *
+at91_clk_register_programmable(void __iomem *base, const char *name,
+			const char * const *parent_names, u8 num_parents, u8 id,
+			const struct clk_programmable_layout *layout,
+			const u32 *clk_mux_table, const u32 *mux_table);
 
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
Signature · 1 line
2.7.4
#17 lore raw

PATCH v3 17/21 clk: at91: clk-system: add driver compatible with ccf

In reply to Claudiu Beznea

Add clk-system driver compatible with common clock framework.

---
 drivers/clk/at91/Makefile     |   2 +-
 drivers/clk/at91/clk-system.c | 112 ++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h        |   3 ++
 3 files changed, 116 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/at91/clk-system.c
drivers/clk/at91/Makefile +1 -1
index 8951052eb0f3..1d59531e0c42 100644
@@ -3,7 +3,7 @@
 #
 
 ifdef CONFIG_CLK_CCF
-obj-y += pmc.o sckc.o clk-main.o clk-master.o clk-programmable.o
+obj-y += pmc.o sckc.o clk-main.o clk-master.o clk-programmable.o clk-system.o
 obj-$(CONFIG_AT91_UTMI)		+= clk-utmi.o
 obj-$(CONFIG_AT91_SAM9X60_PLL)	+= clk-sam9x60-pll.o
 else
drivers/clk/at91/clk-system.c new file +112 -0

112 lines not on this page · raw message

drivers/clk/at91/pmc.h +3 -0
index a443b65257b9..c372f39fc9f6 100644
@@ -108,6 +108,9 @@ at91_clk_register_programmable(void __iomem *base, const char *name,
 			const char * const *parent_names, u8 num_parents, u8 id,
 			const struct clk_programmable_layout *layout,
 			const u32 *clk_mux_table, const u32 *mux_table);
+struct clk *
+at91_clk_register_system(void __iomem *base, const char *name,
+			const char *parent_name, u8 id);
 
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
Signature · 1 line
2.7.4
#18 lore raw

PATCH v3 18/21 clk: at91: clk-peripheral: add driver compatible with ccf

In reply to Claudiu Beznea

Add clk-peripheral compatible with common clock framework.

---
 drivers/clk/at91/Makefile         |   2 +
 drivers/clk/at91/clk-peripheral.c | 254 ++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h            |  16 +++
 3 files changed, 272 insertions(+)
 create mode 100644 drivers/clk/at91/clk-peripheral.c
drivers/clk/at91/Makefile +2 -0
index 1d59531e0c42..b5529065b5c4 100644
@@ -4,6 +4,8 @@
 
 ifdef CONFIG_CLK_CCF
 obj-y += pmc.o sckc.o clk-main.o clk-master.o clk-programmable.o clk-system.o
+obj-y += clk-peripheral.o
+
 obj-$(CONFIG_AT91_UTMI)		+= clk-utmi.o
 obj-$(CONFIG_AT91_SAM9X60_PLL)	+= clk-sam9x60-pll.o
 else
drivers/clk/at91/clk-peripheral.c new file +254 -0

254 lines not on this page · raw message

drivers/clk/at91/pmc.h +16 -0
index c372f39fc9f6..5e80f353e6c2 100644
@@ -63,6 +63,14 @@ struct clk_programmable_layout {
 	u8 is_pres_direct;
 };
 
+struct clk_pcr_layout {
+	u32 offset;
+	u32 cmd;
+	u32 div_mask;
+	u32 gckcss_mask;
+	u32 pid_mask;
+};
+
 extern const struct clk_programmable_layout at91rm9200_programmable_layout;
 extern const struct clk_programmable_layout at91sam9g45_programmable_layout;
 extern const struct clk_programmable_layout at91sam9x5_programmable_layout;
@@ -111,6 +119,14 @@ at91_clk_register_programmable(void __iomem *base, const char *name,
 struct clk *
 at91_clk_register_system(void __iomem *base, const char *name,
 			const char *parent_name, u8 id);
+struct clk *
+at91_clk_register_peripheral(void __iomem *base, const char *name,
+			const char *parent_name, u32 id);
+struct clk *
+at91_clk_register_sam9x5_peripheral(void __iomem *base,
+			const struct clk_pcr_layout *layout,
+			const char *name, const char *parent_name,
+			u32 id, const struct clk_range *range);
 
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
Signature · 1 line
2.7.4
#19 lore raw

PATCH v3 19/21 clk: at91: clk-generic: add driver compatible with ccf

In reply to Claudiu Beznea

Add clk-generic driver compatible with common clock framework.

---
 drivers/clk/at91/Makefile      |   1 +
 drivers/clk/at91/clk-generic.c | 202 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h         |   6 ++
 3 files changed, 209 insertions(+)
 create mode 100644 drivers/clk/at91/clk-generic.c
drivers/clk/at91/Makefile +1 -0
index b5529065b5c4..2cd840af3859 100644
@@ -6,6 +6,7 @@ ifdef CONFIG_CLK_CCF
 obj-y += pmc.o sckc.o clk-main.o clk-master.o clk-programmable.o clk-system.o
 obj-y += clk-peripheral.o
 
+obj-$(CONFIG_AT91_GENERIC_CLK)	+= clk-generic.o
 obj-$(CONFIG_AT91_UTMI)		+= clk-utmi.o
 obj-$(CONFIG_AT91_SAM9X60_PLL)	+= clk-sam9x60-pll.o
 else
drivers/clk/at91/clk-generic.c new file +202 -0

202 lines not on this page · raw message

drivers/clk/at91/pmc.h +6 -0
index 5e80f353e6c2..176855e7a0ed 100644
@@ -127,6 +127,12 @@ at91_clk_register_sam9x5_peripheral(void __iomem *base,
 			const struct clk_pcr_layout *layout,
 			const char *name, const char *parent_name,
 			u32 id, const struct clk_range *range);
+struct clk *
+at91_clk_register_generic(void __iomem *base,
+			const struct clk_pcr_layout *layout, const char *name,
+			const char * const *parent_names,
+			const u32 *clk_mux_table, const u32 *mux_table,
+			u8 num_parents, u8 id, const struct clk_range *range);
 
 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
Signature · 1 line
2.7.4
#20 lore raw

PATCH v3 20/21 clk: at91: pmc: add generic clock ops

In reply to Claudiu Beznea

Add generic clock ops to be used by every AT91 PMC driver built on top of CCF.

---
 drivers/clk/at91/pmc.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/at91/pmc.h |  2 ++
 2 files changed, 73 insertions(+)
drivers/clk/at91/pmc.c +71 -0
index 29c6452497b7..660e23192149 100644
@@ -5,8 +5,79 @@
  */
 
 #include <asm/io.h>
+#include <clk-uclass.h>
 #include <common.h>
 
+#include "pmc.h"
+
+static int at91_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args)
+{
+	if (args->args_count != 2) {
+		debug("AT91: clk: Invalid args_count: %d\n", args->args_count);
+		return -EINVAL;
+	}
+
+	clk->id = AT91_TO_CLK_ID(args->args[0], args->args[1]);
+
+	return 0;
+}
+
+static ulong at91_clk_get_rate(struct clk *clk)
+{
+	struct clk *c;
+	int ret;
+
+	ret = clk_get_by_id(clk->id, &c);
+	if (ret)
+		return ret;
+
+	return clk_get_rate(c);
+}
+
+static ulong at91_clk_set_rate(struct clk *clk, ulong rate)
+{
+	struct clk *c;
+	int ret;
+
+	ret = clk_get_by_id(clk->id, &c);
+	if (ret)
+		return ret;
+
+	return clk_set_rate(c, rate);
+}
+
+static int at91_clk_enable(struct clk *clk)
+{
+	struct clk *c;
+	int ret;
+
+	ret = clk_get_by_id(clk->id, &c);
+	if (ret)
+		return ret;
+
+	return clk_enable(c);
+}
+
+static int at91_clk_disable(struct clk *clk)
+{
+	struct clk *c;
+	int ret;
+
+	ret = clk_get_by_id(clk->id, &c);
+	if (ret)
+		return ret;
+
+	return clk_disable(c);
+}
+
+const struct clk_ops at91_clk_ops = {
+	.of_xlate	= at91_clk_of_xlate,
+	.set_rate	= at91_clk_set_rate,
+	.get_rate	= at91_clk_get_rate,
+	.enable		= at91_clk_enable,
+	.disable	= at91_clk_disable,
+};
+
 /**
  * pmc_read() - read content at address base + off into val
  *
drivers/clk/at91/pmc.h +2 -0
index 176855e7a0ed..a6a714fd220b 100644
@@ -75,6 +75,8 @@ extern const struct clk_programmable_layout at91rm9200_programmable_layout;
 extern const struct clk_programmable_layout at91sam9g45_programmable_layout;
 extern const struct clk_programmable_layout at91sam9x5_programmable_layout;
 
+extern const struct clk_ops at91_clk_ops;
+
 struct clk *at91_clk_main_rc(void __iomem *reg, const char *name,
 			const char *parent_name);
 struct clk *at91_clk_main_osc(void __iomem *reg, const char *name,
Signature · 1 line
2.7.4
#21 lore raw

PATCH v3 21/21 clk: at91: sama7g5: add clock support

In reply to Claudiu Beznea

Add clock support for SAMA7G5.

---
 drivers/clk/at91/Makefile  |    1 +
 drivers/clk/at91/sama7g5.c | 1401 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 1402 insertions(+)
 create mode 100644 drivers/clk/at91/sama7g5.c
drivers/clk/at91/Makefile +1 -0
index 2cd840af3859..2453c38af1aa 100644
@@ -9,6 +9,7 @@ obj-y += clk-peripheral.o
 obj-$(CONFIG_AT91_GENERIC_CLK)	+= clk-generic.o
 obj-$(CONFIG_AT91_UTMI)		+= clk-utmi.o
 obj-$(CONFIG_AT91_SAM9X60_PLL)	+= clk-sam9x60-pll.o
+obj-$(CONFIG_SAMA7G5)		+= sama7g5.o
 else
 obj-y += compat.o
 endif
drivers/clk/at91/sama7g5.c new file +1401 -0

1,401 lines not on this page · raw message

Signature · 1 line
2.7.4
#22 lore raw

v3 cover clk: at91: add sama7g5 support

In reply to Claudiu Beznea
Quoted 80 lines · Claudiu Beznea

The purpose of this series is to add clock support for SAMA7G5. Along with this, clock drivers were switched to CCF and aligned with their corresponding versions present in Linux.
Some changes were done for CCF, patches 1, 3, 4, 5 (I don't know if they were as is by intention of a fixes tag is needed in there).

Also patch 3/21 has been added to support clock re-reparenting (this is minimal support and hope it doesn't break anything if used).

Thank you,
Claudiu Beznea

Changes in v3:
- collected remaining Reviewed-by tags
- rebase on top of latest master branch:

   e5df264e7aac ("Merge https://gitlab.denx.de/u-boot/custodians/u-boot-marvell")
   to adapt patch 8/21 at changes from commit
   702e57e113d8 ("treewide: convert devfdt_get_addr_ptr() to dev_read_addr_ptr()")

Changes in v2:
- use assert() in patch 1/21
- drop patch 2/22 from previous series
- add sandbox tests for clock reparenting, device reparenting and critical clocks
- adapt review comments
- collected Reviewed-by tags

Claudiu Beznea (21):
clk: check hw and hw->dev before dereference it
dm: core: add support for device re-parenting
clk: bind clk to new parent device
clk: do not disable clock if it is critical
clk: get clock pointer before proceeding
clk: at91: add pre-requisite headers for AT91 clock architecture
clk: at91: pmc: add helpers for clock drivers
clk: at91: move clock code to compat.c
clk: at91: sckc: add driver compatible with ccf
clk: at91: clk-main: add driver compatible with ccf
clk: at91: sam9x60-pll: add driver compatible with ccf
clk: at91: clk-master: add driver compatible with ccf
clk: at91: clk-master: add support for sama7g5
clk: at91: clk-utmi: add driver compatible with ccf
clk: at91: clk-utmi: add support for sama7g5
clk: at91: clk-programmable: add driver compatible with ccf
clk: at91: clk-system: add driver compatible with ccf
clk: at91: clk-peripheral: add driver compatible with ccf
clk: at91: clk-generic: add driver compatible with ccf
clk: at91: pmc: add generic clock ops
clk: at91: sama7g5: add clock support

  drivers/clk/at91/Kconfig            |    7 +
  drivers/clk/at91/Makefile           |   15 +-
  drivers/clk/at91/clk-generated.c    |  178 -----
  drivers/clk/at91/clk-generic.c      |  202 +++++
  drivers/clk/at91/clk-h32mx.c        |   56 --
  drivers/clk/at91/clk-main.c         |  381 +++++++++-
  drivers/clk/at91/clk-master.c       |  331 ++++++++-
  drivers/clk/at91/clk-peripheral.c   |  291 ++++++--
  drivers/clk/at91/clk-plla.c         |   54 --
  drivers/clk/at91/clk-plladiv.c      |   85 ---
  drivers/clk/at91/clk-programmable.c |  208 ++++++
  drivers/clk/at91/clk-sam9x60-pll.c  |  442 +++++++++++
  drivers/clk/at91/clk-slow.c         |   36 -
  drivers/clk/at91/clk-system.c       |  143 ++--
  drivers/clk/at91/clk-usb.c          |  147 ----
  drivers/clk/at91/clk-utmi.c         |  234 ++++--
  drivers/clk/at91/compat.c           | 1023 +++++++++++++++++++++++++
  drivers/clk/at91/pmc.c              |  218 +++---
  drivers/clk/at91/pmc.h              |  140 +++-
  drivers/clk/at91/sama7g5.c          | 1401 +++++++++++++++++++++++++++++++++++
  drivers/clk/at91/sckc.c             |  169 ++++-
  drivers/clk/clk-uclass.c            |   51 +-
  drivers/clk/clk.c                   |    3 +
  drivers/core/device.c               |   22 +
  include/dm/device-internal.h        |    9 +
  include/dt-bindings/clk/at91.h      |   22 +
  include/linux/clk/at91_pmc.h        |  247 ++++++
  test/dm/clk_ccf.c                   |   57 ++
  test/dm/core.c                      |  160 ++++
  29 files changed, 5407 insertions(+), 925 deletions(-)
Quoted 14 lines

delete mode 100644 drivers/clk/at91/clk-generated.c create mode 100644 drivers/clk/at91/clk-generic.c delete mode 100644 drivers/clk/at91/clk-h32mx.c delete mode 100644 drivers/clk/at91/clk-plla.c delete mode 100644 drivers/clk/at91/clk-plladiv.c create mode 100644 drivers/clk/at91/clk-programmable.c create mode 100644 drivers/clk/at91/clk-sam9x60-pll.c delete mode 100644 drivers/clk/at91/clk-slow.c delete mode 100644 drivers/clk/at91/clk-usb.c create mode 100644 drivers/clk/at91/compat.c create mode 100644 drivers/clk/at91/sama7g5.c create mode 100644 include/dt-bindings/clk/at91.h create mode 100644 include/linux/clk/at91_pmc.h

Applied whole series to u-boot-atmel/next, thanks !