Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c09b858 authored by Maxime Ripard's avatar Maxime Ripard
Browse files

clk: sunxi-ng: Implement global pre-divider



Some clocks have a global pre-divider that applies to all their parents.

Since it might also apply to clocks that have a single parent, this is
merged in the ccu_common structure, unlike the other pre-divider settings
that are tied to a specific index, and thus a specific parent.

Acked-by: default avatarChen-Yu Tsai <wens@csie.org>
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
parent 0c3c8e13
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#define CCU_FEATURE_VARIABLE_PREDIV	BIT(1)
#define CCU_FEATURE_FIXED_PREDIV	BIT(2)
#define CCU_FEATURE_FIXED_POSTDIV	BIT(3)
#define CCU_FEATURE_ALL_PREDIV		BIT(4)

struct device_node;

@@ -56,6 +57,7 @@ struct device_node;
struct ccu_common {
	void __iomem	*base;
	u16		reg;
	u32		prediv;

	unsigned long	features;
	spinlock_t	*lock;
+7 −1
Original line number Diff line number Diff line
@@ -25,9 +25,15 @@ void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common,
	int i;

	if (!((common->features & CCU_FEATURE_FIXED_PREDIV) ||
	      (common->features & CCU_FEATURE_VARIABLE_PREDIV)))
	      (common->features & CCU_FEATURE_VARIABLE_PREDIV) ||
	      (common->features & CCU_FEATURE_ALL_PREDIV)))
		return;

	if (common->features & CCU_FEATURE_ALL_PREDIV) {
		*parent_rate = *parent_rate / common->prediv;
		return;
	}

	reg = readl(common->base + common->reg);
	if (parent_index < 0) {
		parent_index = reg >> cm->shift;