ARM: tegra: clock: Support clock operations export
Alex Frid [Sat, 24 Aug 2013 03:21:44 +0000 (20:21 -0700)]
Added mechanism for clock producers outside of tegra clock-and-reset
module to register clock operations with tegra clock framework.

Bug 1320966

Change-Id: I5dd49dabd1624e042309f550d68cdf3de8ba2afe
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/265874
Reviewed-by: Kaz Fukuoka <kfukuoka@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>

arch/arm/mach-tegra/clock.c
arch/arm/mach-tegra/clock.h
include/linux/clk/tegra.h

index 2966c07..da83cc4 100644 (file)
@@ -1103,6 +1103,20 @@ void tegra_unregister_clk_rate_notifier(
        clk_unlock_restore(c, &flags);
 }
 
+int tegra_clk_register_export_ops(struct clk *c,
+                                 struct tegra_clk_export_ops *ops)
+{
+       unsigned long flags;
+
+       clk_lock_save(c, &flags);
+       c->u.export_clk.ops = ops;
+       if (c->ops && c->ops->init)
+               c->ops->init(c);
+       clk_unlock_restore(c, &flags);
+
+       return 0;
+}
+
 #define OSC_FREQ_DET                   0x58
 #define OSC_FREQ_DET_TRIG              BIT(31)
 
index 0101882..d692ba3 100644 (file)
@@ -260,6 +260,9 @@ struct clk {
                        enum shared_bus_users_mode      mode;
                        u32                             usage_flag;
                } shared_bus_user;
+               struct {
+                       struct tegra_clk_export_ops     *ops;
+               } export_clk;
        } u;
 
        struct raw_notifier_head                        *rate_change_nh;
index 714dfd8..642a912 100644 (file)
@@ -172,6 +172,18 @@ int tegra_is_clk_enabled(struct clk *clk);
 
 void tegra_cpu_user_cap_set(unsigned int speed_khz);
 
+struct tegra_clk_export_ops {
+       void            (*init)(void *data, unsigned long *rate, bool *state);
+       int             (*enable)(void *data);
+       void            (*disable)(void *data);
+       int             (*set_rate)(void *data, unsigned long *rate);
+       void            *data;
+};
+
+int tegra_clk_register_export_ops(struct clk *c,
+                                 struct tegra_clk_export_ops *ops);
+
+
 #ifdef CONFIG_TEGRA_CLOCK_DEBUG_FUNC
 int tegra_clk_set_max(struct clk *c, unsigned long rate);
 #else