[PATCH v1 5/6] ARM: davinci: convert to common clock framework

2017-12-01 Thread David Lechner
This converts the clocks in mach-davinci to the common clock framework.

Most of the patch just involves renaming struct clk to struct davinci_clk.
There is also a struct clk_hw added to provide the bridge between the
existing clock implementation and the common clock framework.

In clock.c:
* The clk_get_parent and clk_set_parent callbacks are dropped because
  all clocks currently (effectively) have a single parent, in which
  case the common clock framework does not want you to implement these
  functions yourself.
* clk_unregister() is dropped because it is not used anywhere in
  mach-davinci.
* EXPORT_SYMBOL() is removed from functions not used outside of
  mach-davinci.

Signed-off-by: David Lechner 
---
 arch/arm/Kconfig   |   2 +-
 arch/arm/mach-davinci/clock.c  | 162 -
 arch/arm/mach-davinci/clock.h  |  40 ---
 arch/arm/mach-davinci/da830.c  | 100 +-
 arch/arm/mach-davinci/da850.c  | 153 +--
 arch/arm/mach-davinci/devices-da8xx.c  |   6 +-
 arch/arm/mach-davinci/dm355.c  |  84 +++
 arch/arm/mach-davinci/dm365.c  | 112 ++--
 arch/arm/mach-davinci/dm644x.c |  72 ++---
 arch/arm/mach-davinci/dm646x.c |  78 +++---
 arch/arm/mach-davinci/include/mach/clock.h |   3 -
 arch/arm/mach-davinci/usb-da8xx.c  |  48 +
 12 files changed, 425 insertions(+), 435 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7888c98..1bd667d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -611,7 +611,7 @@ config ARCH_S3C24XX
 config ARCH_DAVINCI
bool "TI DaVinci"
select ARCH_HAS_HOLES_MEMORYMODEL
-   select CLKDEV_LOOKUP
+   select COMMON_CLK
select CPU_ARM926T
select GENERIC_ALLOCATOR
select GENERIC_CLOCKEVENTS
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index c149b24..0e63d93 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -31,7 +31,7 @@ static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
 static DEFINE_SPINLOCK(clockfw_lock);
 
-void davinci_clk_enable(struct clk *clk)
+void davinci_clk_enable(struct davinci_clk *clk)
 {
if (clk->parent)
davinci_clk_enable(clk->parent);
@@ -44,7 +44,7 @@ void davinci_clk_enable(struct clk *clk)
}
 }
 
-void davinci_clk_disable(struct clk *clk)
+void davinci_clk_disable(struct davinci_clk *clk)
 {
if (WARN_ON(clk->usecount == 0))
return;
@@ -59,7 +59,7 @@ void davinci_clk_disable(struct clk *clk)
davinci_clk_disable(clk->parent);
 }
 
-static int davinci_clk_reset(struct clk *clk, bool reset)
+static int davinci_clk_reset(struct davinci_clk *clk, bool reset)
 {
unsigned long flags;
 
@@ -76,24 +76,29 @@ static int davinci_clk_reset(struct clk *clk, bool reset)
 
 int davinci_clk_reset_assert(struct clk *clk)
 {
-   if (clk == NULL || IS_ERR(clk) || !clk->reset)
+   struct davinci_clk *dclk = to_davinci_clk(__clk_get_hw(clk));
+
+   if (IS_ERR_OR_NULL(dclk) || !dclk->reset)
return -EINVAL;
 
-   return clk->reset(clk, true);
+   return dclk->reset(dclk, true);
 }
 EXPORT_SYMBOL(davinci_clk_reset_assert);
 
 int davinci_clk_reset_deassert(struct clk *clk)
 {
-   if (clk == NULL || IS_ERR(clk) || !clk->reset)
+   struct davinci_clk *dclk = to_davinci_clk(__clk_get_hw(clk));
+
+   if (IS_ERR_OR_NULL(dclk) || !dclk->reset)
return -EINVAL;
 
-   return clk->reset(clk, false);
+   return dclk->reset(dclk, false);
 }
 EXPORT_SYMBOL(davinci_clk_reset_deassert);
 
-int clk_enable(struct clk *clk)
+static int _clk_enable(struct clk_hw *hw)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
unsigned long flags;
 
if (!clk)
@@ -107,10 +112,10 @@ int clk_enable(struct clk *clk)
 
return 0;
 }
-EXPORT_SYMBOL(clk_enable);
 
-void clk_disable(struct clk *clk)
+static void _clk_disable(struct clk_hw *hw)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
unsigned long flags;
 
if (clk == NULL || IS_ERR(clk))
@@ -120,19 +125,26 @@ void clk_disable(struct clk *clk)
davinci_clk_disable(clk);
spin_unlock_irqrestore(_lock, flags);
 }
-EXPORT_SYMBOL(clk_disable);
 
-unsigned long clk_get_rate(struct clk *clk)
+static unsigned long _clk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
+
if (clk == NULL || IS_ERR(clk))
return 0;
 
+   if (clk->recalc)
+   return clk->recalc(clk);
+
return clk->rate;
 }
-EXPORT_SYMBOL(clk_get_rate);
 
-long clk_round_rate(struct clk *clk, unsigned long rate)
+static 

[PATCH v1 5/6] ARM: davinci: convert to common clock framework

2017-12-01 Thread David Lechner
This converts the clocks in mach-davinci to the common clock framework.

Most of the patch just involves renaming struct clk to struct davinci_clk.
There is also a struct clk_hw added to provide the bridge between the
existing clock implementation and the common clock framework.

In clock.c:
* The clk_get_parent and clk_set_parent callbacks are dropped because
  all clocks currently (effectively) have a single parent, in which
  case the common clock framework does not want you to implement these
  functions yourself.
* clk_unregister() is dropped because it is not used anywhere in
  mach-davinci.
* EXPORT_SYMBOL() is removed from functions not used outside of
  mach-davinci.

Signed-off-by: David Lechner 
---
 arch/arm/Kconfig   |   2 +-
 arch/arm/mach-davinci/clock.c  | 162 -
 arch/arm/mach-davinci/clock.h  |  40 ---
 arch/arm/mach-davinci/da830.c  | 100 +-
 arch/arm/mach-davinci/da850.c  | 153 +--
 arch/arm/mach-davinci/devices-da8xx.c  |   6 +-
 arch/arm/mach-davinci/dm355.c  |  84 +++
 arch/arm/mach-davinci/dm365.c  | 112 ++--
 arch/arm/mach-davinci/dm644x.c |  72 ++---
 arch/arm/mach-davinci/dm646x.c |  78 +++---
 arch/arm/mach-davinci/include/mach/clock.h |   3 -
 arch/arm/mach-davinci/usb-da8xx.c  |  48 +
 12 files changed, 425 insertions(+), 435 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7888c98..1bd667d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -611,7 +611,7 @@ config ARCH_S3C24XX
 config ARCH_DAVINCI
bool "TI DaVinci"
select ARCH_HAS_HOLES_MEMORYMODEL
-   select CLKDEV_LOOKUP
+   select COMMON_CLK
select CPU_ARM926T
select GENERIC_ALLOCATOR
select GENERIC_CLOCKEVENTS
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index c149b24..0e63d93 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -31,7 +31,7 @@ static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
 static DEFINE_SPINLOCK(clockfw_lock);
 
-void davinci_clk_enable(struct clk *clk)
+void davinci_clk_enable(struct davinci_clk *clk)
 {
if (clk->parent)
davinci_clk_enable(clk->parent);
@@ -44,7 +44,7 @@ void davinci_clk_enable(struct clk *clk)
}
 }
 
-void davinci_clk_disable(struct clk *clk)
+void davinci_clk_disable(struct davinci_clk *clk)
 {
if (WARN_ON(clk->usecount == 0))
return;
@@ -59,7 +59,7 @@ void davinci_clk_disable(struct clk *clk)
davinci_clk_disable(clk->parent);
 }
 
-static int davinci_clk_reset(struct clk *clk, bool reset)
+static int davinci_clk_reset(struct davinci_clk *clk, bool reset)
 {
unsigned long flags;
 
@@ -76,24 +76,29 @@ static int davinci_clk_reset(struct clk *clk, bool reset)
 
 int davinci_clk_reset_assert(struct clk *clk)
 {
-   if (clk == NULL || IS_ERR(clk) || !clk->reset)
+   struct davinci_clk *dclk = to_davinci_clk(__clk_get_hw(clk));
+
+   if (IS_ERR_OR_NULL(dclk) || !dclk->reset)
return -EINVAL;
 
-   return clk->reset(clk, true);
+   return dclk->reset(dclk, true);
 }
 EXPORT_SYMBOL(davinci_clk_reset_assert);
 
 int davinci_clk_reset_deassert(struct clk *clk)
 {
-   if (clk == NULL || IS_ERR(clk) || !clk->reset)
+   struct davinci_clk *dclk = to_davinci_clk(__clk_get_hw(clk));
+
+   if (IS_ERR_OR_NULL(dclk) || !dclk->reset)
return -EINVAL;
 
-   return clk->reset(clk, false);
+   return dclk->reset(dclk, false);
 }
 EXPORT_SYMBOL(davinci_clk_reset_deassert);
 
-int clk_enable(struct clk *clk)
+static int _clk_enable(struct clk_hw *hw)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
unsigned long flags;
 
if (!clk)
@@ -107,10 +112,10 @@ int clk_enable(struct clk *clk)
 
return 0;
 }
-EXPORT_SYMBOL(clk_enable);
 
-void clk_disable(struct clk *clk)
+static void _clk_disable(struct clk_hw *hw)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
unsigned long flags;
 
if (clk == NULL || IS_ERR(clk))
@@ -120,19 +125,26 @@ void clk_disable(struct clk *clk)
davinci_clk_disable(clk);
spin_unlock_irqrestore(_lock, flags);
 }
-EXPORT_SYMBOL(clk_disable);
 
-unsigned long clk_get_rate(struct clk *clk)
+static unsigned long _clk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
+
if (clk == NULL || IS_ERR(clk))
return 0;
 
+   if (clk->recalc)
+   return clk->recalc(clk);
+
return clk->rate;
 }
-EXPORT_SYMBOL(clk_get_rate);
 
-long clk_round_rate(struct clk *clk, unsigned long rate)
+static long