Skip to contentSkip to conversation

clk: Move clk-gate2 to clock driver directory

PATCH New Sean Anderson 2 participants 4 messages Dec 25, 2019 – Jan 27, 2020

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

PATCH 1/2 clk: Move clk-gate2 to clock driver directory

Make clk-gate2 available for use outside of imx.

---
 drivers/clk/Makefile              |  1 +
 drivers/clk/{imx => }/clk-gate2.c | 20 ++++----------------
 drivers/clk/imx/Makefile          |  2 +-
 drivers/clk/imx/clk.h             |  5 -----
 include/linux/clk-provider.h      | 24 ++++++++++++++++++++----
 5 files changed, 26 insertions(+), 26 deletions(-)
 rename drivers/clk/{imx => }/clk-gate2.c (85%)
drivers/clk/Makefile +1 -0
index 06131edb9f..fef3280f16 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_rate.o
 obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o
 obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk.o clk-divider.o clk-mux.o clk-gate.o
 obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-fixed-factor.o
+obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-gate2.o
 obj-$(CONFIG_$(SPL_TPL_)CLK_COMPOSITE_CCF) += clk-composite.o
 
 obj-y += analogbits/
drivers/clk/clk-gate2.c renamed from drivers/clk/imx/clk-gate2.c +4 -16
similarity index 85%
rename from drivers/clk/imx/clk-gate2.c
rename to drivers/clk/clk-gate2.c
index 1b9db6e791..cfe21e5496 100644
@@ -10,8 +10,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * Gated clock implementation
- *
+ * Gated clock which redirects rate functions to its parent clock
  */
 
 #include <common.h>
@@ -21,19 +20,8 @@
 #include <dm/device.h>
 #include <linux/clk-provider.h>
 #include <clk.h>
-#include "clk.h"
-
-#define UBOOT_DM_CLK_IMX_GATE2 "imx_clk_gate2"
-
-struct clk_gate2 {
-	struct clk clk;
-	void __iomem	*reg;
-	u8		bit_idx;
-	u8		cgr_val;
-	u8		flags;
-};
 
-#define to_clk_gate2(_clk) container_of(_clk, struct clk_gate2, clk)
+#define UBOOT_DM_CLK_GATE2 "clk_gate2"
 
 static int clk_gate2_enable(struct clk *clk)
 {
@@ -97,7 +85,7 @@ struct clk *clk_register_gate2(struct device *dev, const char *name,
 
 	clk = &gate->clk;
 
-	ret = clk_register(clk, UBOOT_DM_CLK_IMX_GATE2, name, parent_name);
+	ret = clk_register(clk, UBOOT_DM_CLK_GATE2, name, parent_name);
 	if (ret) {
 		kfree(gate);
 		return ERR_PTR(ret);
@@ -107,7 +95,7 @@ struct clk *clk_register_gate2(struct device *dev, const char *name,
 }
 
 U_BOOT_DRIVER(clk_gate2) = {
-	.name	= UBOOT_DM_CLK_IMX_GATE2,
+	.name	= UBOOT_DM_CLK_GATE2,
 	.id	= UCLASS_CLK,
 	.ops	= &clk_gate2_ops,
 	.flags = DM_FLAG_PRE_RELOC,
drivers/clk/imx/Makefile +1 -1
index 222c5a4e08..5328e9265a 100644
@@ -2,7 +2,7 @@
 #
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-gate2.o clk-pllv3.o clk-pfd.o
+obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-pllv3.o clk-pfd.o
 obj-$(CONFIG_$(SPL_TPL_)CLK_IMX6Q) += clk-imx6q.o
 obj-$(CONFIG_CLK_IMX8) += clk-imx8.o
 
drivers/clk/imx/clk.h +0 -5
index 07dcf94ea5..c46570e9f4 100644
@@ -45,11 +45,6 @@ struct clk *imx_clk_pll14xx(const char *name, const char *parent_name,
 			    void __iomem *base,
 			    const struct imx_pll14xx_clk *pll_clk);
 
-struct clk *clk_register_gate2(struct device *dev, const char *name,
-		const char *parent_name, unsigned long flags,
-		void __iomem *reg, u8 bit_idx, u8 cgr_val,
-		u8 clk_gate_flags);
-
 struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
 			  const char *parent_name, void __iomem *base,
 			  u32 div_mask);
include/linux/clk-provider.h +20 -4
index 0ef6e685ad..f510291018 100644
@@ -90,10 +90,6 @@ struct clk_gate {
 #define CLK_GATE_HIWORD_MASK		BIT(1)
 
 extern const struct clk_ops clk_gate_ops;
-struct clk *clk_register_gate(struct device *dev, const char *name,
-			      const char *parent_name, unsigned long flags,
-			      void __iomem *reg, u8 bit_idx,
-			      u8 clk_gate_flags, spinlock_t *lock);
 
 struct clk_div_table {
 	unsigned int	val;
@@ -159,6 +155,16 @@ struct clk_composite {
 
 #define to_clk_composite(_clk) container_of(_clk, struct clk_composite, clk)
 
+struct clk_gate2 {
+	struct clk clk;
+	void __iomem	*reg;
+	u8		bit_idx;
+	u8		cgr_val;
+	u8		flags;
+};
+
+#define to_clk_gate2(_clk) container_of(_clk, struct clk_gate2, clk)
+
 struct clk *clk_register_composite(struct device *dev, const char *name,
 		const char * const *parent_names, int num_parents,
 		struct clk *mux_clk, const struct clk_ops *mux_ops,
@@ -184,6 +190,16 @@ struct clk *clk_register_mux(struct device *dev, const char *name,
 		void __iomem *reg, u8 shift, u8 width,
 		u8 clk_mux_flags);
 
+struct clk *clk_register_gate(struct device *dev, const char *name,
+			      const char *parent_name, unsigned long flags,
+			      void __iomem *reg, u8 bit_idx,
+			      u8 clk_gate_flags, spinlock_t *lock);
+
+struct clk *clk_register_gate2(struct device *dev, const char *name,
+			       const char *parent_name, unsigned long flags,
+			       void __iomem *reg, u8 bit_idx, u8 cgr_val,
+			       u8 clk_gate_flags);
+
 const char *clk_hw_get_name(const struct clk *hw);
 ulong clk_generic_get_rate(struct clk *clk);
 
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/2 clk: Move clk-gate2 to clock driver directory

Hi Sean

Quoted 12 lines

Make clk-gate2 available for use outside of imx.

---
 drivers/clk/Makefile              |  1 +
 drivers/clk/{imx => }/clk-gate2.c | 20 ++++----------------
 drivers/clk/imx/Makefile          |  2 +-
 drivers/clk/imx/clk.h             |  5 -----
 include/linux/clk-provider.h      | 24 ++++++++++++++++++++----
 5 files changed, 26 insertions(+), 26 deletions(-)
 rename drivers/clk/{imx => }/clk-gate2.c (85%)

This patch is OK.

Unfortunately, it causes buildman errors for sandbox:
https://travis-ci.org/lmajewski/u-boot-dfu/jobs/641984485

The problem is with local sandbox copy of struct clk_gate2

In the clk_sandbox_ccf.c file we can re-use the 'flags' member (instead of defined for sandbox 'state') of now widely exposed struct clk_gate2 (@ clk-provider.h) and

#define SANDBOX_CCF_ENABLE (1UL << 31)
#define SANDBOX_CCF_DISABLE (0UL << 31)

and remove the local sandbox copy.

How to reproduce:

make mrproper; make sandbox_defconfig; make -j4
./u-boot -i -d arch/sandbox/dts/test.dtb
=> ut dm clk

(I'm going to drop this patch from PR which I'm preparing now and depending on it "clk: Add option to restrict clk-gate2 to one bit toggle").

Quoted 150 lines
drivers/clk/Makefile +0 -0
index 06131edb9f..fef3280f16 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_rate.o
 obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o
 obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk.o clk-divider.o clk-mux.o

clk-gate.o obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-fixed-factor.o

drivers/clk/Makefile +1 -0
+obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-gate2.o
 obj-$(CONFIG_$(SPL_TPL_)CLK_COMPOSITE_CCF) += clk-composite.o
 
 obj-y += analogbits/
drivers/clk/clk-gate2.c renamed from drivers/clk/imx/clk-gate2.c +3 -15
similarity index 85%
rename from drivers/clk/imx/clk-gate2.c
rename to drivers/clk/clk-gate2.c
index 1b9db6e791..cfe21e5496 100644
@@ -10,8 +10,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * Gated clock implementation
- *
+ * Gated clock which redirects rate functions to its parent clock
  */
 
 #include <common.h>
@@ -21,19 +20,8 @@
 #include <dm/device.h>
 #include <linux/clk-provider.h>
 #include <clk.h>
-#include "clk.h"
-
-#define UBOOT_DM_CLK_IMX_GATE2 "imx_clk_gate2"
-
-struct clk_gate2 {
-	struct clk clk;
-	void __iomem	*reg;
-	u8		bit_idx;
-	u8		cgr_val;
-	u8		flags;
-};
 
-#define to_clk_gate2(_clk) container_of(_clk, struct clk_gate2, clk)
+#define UBOOT_DM_CLK_GATE2 "clk_gate2"
 
 static int clk_gate2_enable(struct clk *clk)
 {
@@ -97,7 +85,7 @@ struct clk *clk_register_gate2(struct device *dev,
 const char *name,
 
 	clk = &gate->clk;
 
-	ret = clk_register(clk, UBOOT_DM_CLK_IMX_GATE2, name,
 parent_name);
+	ret = clk_register(clk, UBOOT_DM_CLK_GATE2, name,
 parent_name); if (ret) {
drivers/clk/clk-gate2.c renamed from drivers/clk/imx/clk-gate2.c +1 -1
 		kfree(gate);
 		return ERR_PTR(ret);
@@ -107,7 +95,7 @@ struct clk *clk_register_gate2(struct device *dev,
 const char *name, }
 
 U_BOOT_DRIVER(clk_gate2) = {
-	.name	= UBOOT_DM_CLK_IMX_GATE2,
+	.name	= UBOOT_DM_CLK_GATE2,
 	.id	= UCLASS_CLK,
 	.ops	= &clk_gate2_ops,
 	.flags = DM_FLAG_PRE_RELOC,
drivers/clk/imx/Makefile +1 -1
index 222c5a4e08..5328e9265a 100644
@@ -2,7 +2,7 @@
 #
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-gate2.o clk-pllv3.o clk-pfd.o
+obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-pllv3.o clk-pfd.o
 obj-$(CONFIG_$(SPL_TPL_)CLK_IMX6Q) += clk-imx6q.o
 obj-$(CONFIG_CLK_IMX8) += clk-imx8.o
 
drivers/clk/imx/clk.h +0 -5
index 07dcf94ea5..c46570e9f4 100644
@@ -45,11 +45,6 @@ struct clk *imx_clk_pll14xx(const char *name,
 const char *parent_name, void __iomem *base,
 			    const struct imx_pll14xx_clk *pll_clk);
 
-struct clk *clk_register_gate2(struct device *dev, const char *name,
-		const char *parent_name, unsigned long flags,
-		void __iomem *reg, u8 bit_idx, u8 cgr_val,
-		u8 clk_gate_flags);
-
 struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
 			  const char *parent_name, void __iomem
 *base, u32 div_mask);
(quoted diff) +0 -0

b/include/linux/clk-provider.h index 0ef6e685ad..f510291018 100644

include/linux/clk-provider.h +0 -4
@@ -90,10 +90,6 @@ struct clk_gate {
 #define CLK_GATE_HIWORD_MASK		BIT(1)
 
 extern const struct clk_ops clk_gate_ops;
-struct clk *clk_register_gate(struct device *dev, const char *name,
-			      const char *parent_name, unsigned long
 flags,
-			      void __iomem *reg, u8 bit_idx,
-			      u8 clk_gate_flags, spinlock_t *lock);
 
 struct clk_div_table {
include/linux/clk-provider.h +10 -0
 	unsigned int	val;
@@ -159,6 +155,16 @@ struct clk_composite {
 
 #define to_clk_composite(_clk) container_of(_clk, struct
 clk_composite, clk)
 
+struct clk_gate2 {
+	struct clk clk;
+	void __iomem	*reg;
+	u8		bit_idx;
+	u8		cgr_val;
+	u8		flags;
+};
+
+#define to_clk_gate2(_clk) container_of(_clk, struct clk_gate2, clk)
+
 struct clk *clk_register_composite(struct device *dev, const char
 *name, const char * const *parent_names, int num_parents,
include/linux/clk-provider.h +10 -0
 		struct clk *mux_clk, const struct clk_ops *mux_ops,
@@ -184,6 +190,16 @@ struct clk *clk_register_mux(struct device *dev,
 const char *name, void __iomem *reg, u8 shift, u8 width,
 		u8 clk_mux_flags);
 
+struct clk *clk_register_gate(struct device *dev, const char *name,
+			      const char *parent_name, unsigned long
 flags,
+			      void __iomem *reg, u8 bit_idx,
+			      u8 clk_gate_flags, spinlock_t *lock);
+
+struct clk *clk_register_gate2(struct device *dev, const char *name,
+			       const char *parent_name, unsigned
 long flags,
+			       void __iomem *reg, u8 bit_idx, u8
 cgr_val,
+			       u8 clk_gate_flags);
+
Quoted 3 lines

const char *clk_hw_get_name(const struct clk *hw); ulong clk_generic_get_rate(struct clk *clk);

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200126/e33a295f/attachment.sig>

#2 lore raw

PATCH 1/2 clk: Move clk-gate2 to clock driver directory

Quoted 34 lines · Lukasz Majewski

Hi Sean

Quoted 12 lines

Make clk-gate2 available for use outside of imx.

---
 drivers/clk/Makefile              |  1 +
 drivers/clk/{imx => }/clk-gate2.c | 20 ++++----------------
 drivers/clk/imx/Makefile          |  2 +-
 drivers/clk/imx/clk.h             |  5 -----
 include/linux/clk-provider.h      | 24 ++++++++++++++++++++----
 5 files changed, 26 insertions(+), 26 deletions(-)
 rename drivers/clk/{imx => }/clk-gate2.c (85%)

This patch is OK.

Unfortunately, it causes buildman errors for sandbox:
https://travis-ci.org/lmajewski/u-boot-dfu/jobs/641984485

The problem is with local sandbox copy of struct clk_gate2

In the clk_sandbox_ccf.c file we can re-use the 'flags' member (instead of defined for sandbox 'state') of now widely exposed struct clk_gate2 (@ clk-provider.h) and

#define SANDBOX_CCF_ENABLE (1UL << 31)
#define SANDBOX_CCF_DISABLE (0UL << 31)

and remove the local sandbox copy.

How to reproduce:

Quoted 8 lines

make mrproper; make sandbox_defconfig; make -j4
./u-boot -i -d arch/sandbox/dts/test.dtb
=> ut dm clk

(I'm going to drop this patch from PR which I'm preparing now and depending on it "clk: Add option to restrict clk-gate2 to one bit toggle").

That's fine. This may be a bit of duplicate effort wrt the patches I submitted regarding clk_composite. I originally used clk_gate2 in my k210 patch series, but I switched over to using clk_composite because it could function in the same manner.

#3 lore raw

PATCH 1/2 clk: Move clk-gate2 to clock driver directory

Hi Sean,

Quoted 40 lines · Lukasz Majewski
Quoted 39 lines

Hi Sean

Quoted 12 lines

Make clk-gate2 available for use outside of imx.

---
 drivers/clk/Makefile              |  1 +
 drivers/clk/{imx => }/clk-gate2.c | 20 ++++----------------
 drivers/clk/imx/Makefile          |  2 +-
 drivers/clk/imx/clk.h             |  5 -----
 include/linux/clk-provider.h      | 24 ++++++++++++++++++++----
 5 files changed, 26 insertions(+), 26 deletions(-)
 rename drivers/clk/{imx => }/clk-gate2.c (85%)

This patch is OK.

Unfortunately, it causes buildman errors for sandbox:
https://travis-ci.org/lmajewski/u-boot-dfu/jobs/641984485

The problem is with local sandbox copy of struct clk_gate2

In the clk_sandbox_ccf.c file we can re-use the 'flags' member (instead of defined for sandbox 'state') of now widely exposed struct clk_gate2 (@ clk-provider.h) and

#define SANDBOX_CCF_ENABLE (1UL << 31)
#define SANDBOX_CCF_DISABLE (0UL << 31)

and remove the local sandbox copy.

How to reproduce:

make mrproper; make sandbox_defconfig; make -j4
./u-boot -i -d arch/sandbox/dts/test.dtb
=> ut dm clk

Quoted 9 lines
Quoted 3 lines

(I'm going to drop this patch from PR which I'm preparing now and depending on it "clk: Add option to restrict clk-gate2 to one bit toggle").

That's fine. This may be a bit of duplicate effort wrt the patches I submitted regarding clk_composite. I originally used clk_gate2 in my k210 patch series, but I switched over to using clk_composite because it could function in the same manner.

Thanks for the update.

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200127/56f383fa/attachment.sig>