Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 1 | /* |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 2 | * Clock and PLL control for DaVinci devices |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 3 | * |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 4 | * Copyright (C) 2006-2007 Texas Instruments. |
| 5 | * Copyright (C) 2008-2009 Deep Root Systems, LLC |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/errno.h> |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 17 | #include <linux/clk.h> |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 18 | #include <linux/err.h> |
| 19 | #include <linux/mutex.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 20 | #include <linux/io.h> |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 21 | #include <linux/delay.h> |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 22 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 23 | #include <mach/hardware.h> |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 24 | |
Kevin Hilman | 28552c2 | 2010-02-25 15:36:38 -0800 | [diff] [blame] | 25 | #include <mach/clock.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 26 | #include <mach/psc.h> |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 27 | #include <mach/cputype.h> |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 28 | #include "clock.h" |
| 29 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 30 | static LIST_HEAD(clocks); |
| 31 | static DEFINE_MUTEX(clocks_mutex); |
| 32 | static DEFINE_SPINLOCK(clockfw_lock); |
| 33 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 34 | static void __clk_enable(struct clk *clk) |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 35 | { |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 36 | if (clk->parent) |
| 37 | __clk_enable(clk->parent); |
Philip Avinash | c6007ff | 2013-03-25 15:07:48 +0530 | [diff] [blame] | 38 | if (clk->usecount++ == 0) { |
| 39 | if (clk->flags & CLK_PSC) |
| 40 | davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, |
| 41 | true, clk->flags); |
| 42 | else if (clk->clk_enable) |
| 43 | clk->clk_enable(clk); |
| 44 | } |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static void __clk_disable(struct clk *clk) |
| 48 | { |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 49 | if (WARN_ON(clk->usecount == 0)) |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 50 | return; |
Philip Avinash | c6007ff | 2013-03-25 15:07:48 +0530 | [diff] [blame] | 51 | if (--clk->usecount == 0) { |
| 52 | if (!(clk->flags & CLK_PLL) && (clk->flags & CLK_PSC)) |
| 53 | davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, |
| 54 | false, clk->flags); |
| 55 | else if (clk->clk_disable) |
| 56 | clk->clk_disable(clk); |
| 57 | } |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 58 | if (clk->parent) |
| 59 | __clk_disable(clk->parent); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 60 | } |
| 61 | |
Robert Tivy | af47e6b | 2013-01-10 16:23:23 -0800 | [diff] [blame] | 62 | int davinci_clk_reset(struct clk *clk, bool reset) |
| 63 | { |
| 64 | unsigned long flags; |
| 65 | |
| 66 | if (clk == NULL || IS_ERR(clk)) |
| 67 | return -EINVAL; |
| 68 | |
| 69 | spin_lock_irqsave(&clockfw_lock, flags); |
| 70 | if (clk->flags & CLK_PSC) |
| 71 | davinci_psc_reset(clk->gpsc, clk->lpsc, reset); |
| 72 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | EXPORT_SYMBOL(davinci_clk_reset); |
| 77 | |
| 78 | int davinci_clk_reset_assert(struct clk *clk) |
| 79 | { |
| 80 | if (clk == NULL || IS_ERR(clk) || !clk->reset) |
| 81 | return -EINVAL; |
| 82 | |
| 83 | return clk->reset(clk, true); |
| 84 | } |
| 85 | EXPORT_SYMBOL(davinci_clk_reset_assert); |
| 86 | |
| 87 | int davinci_clk_reset_deassert(struct clk *clk) |
| 88 | { |
| 89 | if (clk == NULL || IS_ERR(clk) || !clk->reset) |
| 90 | return -EINVAL; |
| 91 | |
| 92 | return clk->reset(clk, false); |
| 93 | } |
| 94 | EXPORT_SYMBOL(davinci_clk_reset_deassert); |
| 95 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 96 | int clk_enable(struct clk *clk) |
| 97 | { |
| 98 | unsigned long flags; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 99 | |
Peter Ujfalusi | f6c1a8a | 2015-09-14 12:29:39 +0300 | [diff] [blame] | 100 | if (!clk) |
| 101 | return 0; |
| 102 | else if (IS_ERR(clk)) |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 103 | return -EINVAL; |
| 104 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 105 | spin_lock_irqsave(&clockfw_lock, flags); |
| 106 | __clk_enable(clk); |
| 107 | spin_unlock_irqrestore(&clockfw_lock, flags); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 108 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 109 | return 0; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 110 | } |
| 111 | EXPORT_SYMBOL(clk_enable); |
| 112 | |
| 113 | void clk_disable(struct clk *clk) |
| 114 | { |
| 115 | unsigned long flags; |
| 116 | |
| 117 | if (clk == NULL || IS_ERR(clk)) |
| 118 | return; |
| 119 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 120 | spin_lock_irqsave(&clockfw_lock, flags); |
| 121 | __clk_disable(clk); |
| 122 | spin_unlock_irqrestore(&clockfw_lock, flags); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 123 | } |
| 124 | EXPORT_SYMBOL(clk_disable); |
| 125 | |
| 126 | unsigned long clk_get_rate(struct clk *clk) |
| 127 | { |
| 128 | if (clk == NULL || IS_ERR(clk)) |
Peter Ujfalusi | f6c1a8a | 2015-09-14 12:29:39 +0300 | [diff] [blame] | 129 | return 0; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 130 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 131 | return clk->rate; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 132 | } |
| 133 | EXPORT_SYMBOL(clk_get_rate); |
| 134 | |
| 135 | long clk_round_rate(struct clk *clk, unsigned long rate) |
| 136 | { |
| 137 | if (clk == NULL || IS_ERR(clk)) |
Paul Walmsley | 4408c26 | 2013-11-26 16:56:27 -0800 | [diff] [blame] | 138 | return 0; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 139 | |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 140 | if (clk->round_rate) |
| 141 | return clk->round_rate(clk, rate); |
| 142 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 143 | return clk->rate; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 144 | } |
| 145 | EXPORT_SYMBOL(clk_round_rate); |
| 146 | |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 147 | /* Propagate rate to children */ |
| 148 | static void propagate_rate(struct clk *root) |
| 149 | { |
| 150 | struct clk *clk; |
| 151 | |
| 152 | list_for_each_entry(clk, &root->children, childnode) { |
| 153 | if (clk->recalc) |
| 154 | clk->rate = clk->recalc(clk); |
| 155 | propagate_rate(clk); |
| 156 | } |
| 157 | } |
| 158 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 159 | int clk_set_rate(struct clk *clk, unsigned long rate) |
| 160 | { |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 161 | unsigned long flags; |
| 162 | int ret = -EINVAL; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 163 | |
Peter Ujfalusi | f6c1a8a | 2015-09-14 12:29:39 +0300 | [diff] [blame] | 164 | if (!clk) |
| 165 | return 0; |
| 166 | else if (IS_ERR(clk)) |
| 167 | return -EINVAL; |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 168 | |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 169 | if (clk->set_rate) |
| 170 | ret = clk->set_rate(clk, rate); |
Sekhar Nori | 3b43cd6 | 2010-01-12 18:55:35 +0530 | [diff] [blame] | 171 | |
| 172 | spin_lock_irqsave(&clockfw_lock, flags); |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 173 | if (ret == 0) { |
| 174 | if (clk->recalc) |
| 175 | clk->rate = clk->recalc(clk); |
| 176 | propagate_rate(clk); |
| 177 | } |
| 178 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 179 | |
| 180 | return ret; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 181 | } |
| 182 | EXPORT_SYMBOL(clk_set_rate); |
| 183 | |
Sekhar Nori | b82a51e | 2009-08-31 15:48:04 +0530 | [diff] [blame] | 184 | int clk_set_parent(struct clk *clk, struct clk *parent) |
| 185 | { |
| 186 | unsigned long flags; |
| 187 | |
Peter Ujfalusi | f6c1a8a | 2015-09-14 12:29:39 +0300 | [diff] [blame] | 188 | if (!clk) |
| 189 | return 0; |
| 190 | else if (IS_ERR(clk)) |
Sekhar Nori | b82a51e | 2009-08-31 15:48:04 +0530 | [diff] [blame] | 191 | return -EINVAL; |
| 192 | |
| 193 | /* Cannot change parent on enabled clock */ |
| 194 | if (WARN_ON(clk->usecount)) |
| 195 | return -EINVAL; |
| 196 | |
| 197 | mutex_lock(&clocks_mutex); |
| 198 | clk->parent = parent; |
| 199 | list_del_init(&clk->childnode); |
| 200 | list_add(&clk->childnode, &clk->parent->children); |
| 201 | mutex_unlock(&clocks_mutex); |
| 202 | |
| 203 | spin_lock_irqsave(&clockfw_lock, flags); |
| 204 | if (clk->recalc) |
| 205 | clk->rate = clk->recalc(clk); |
| 206 | propagate_rate(clk); |
| 207 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | EXPORT_SYMBOL(clk_set_parent); |
| 212 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 213 | int clk_register(struct clk *clk) |
| 214 | { |
| 215 | if (clk == NULL || IS_ERR(clk)) |
| 216 | return -EINVAL; |
| 217 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 218 | if (WARN(clk->parent && !clk->parent->rate, |
| 219 | "CLK: %s parent %s has no rate!\n", |
| 220 | clk->name, clk->parent->name)) |
| 221 | return -EINVAL; |
| 222 | |
Sekhar Nori | f02bf3b | 2009-08-31 15:48:01 +0530 | [diff] [blame] | 223 | INIT_LIST_HEAD(&clk->children); |
| 224 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 225 | mutex_lock(&clocks_mutex); |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 226 | list_add_tail(&clk->node, &clocks); |
Sekhar Nori | f02bf3b | 2009-08-31 15:48:01 +0530 | [diff] [blame] | 227 | if (clk->parent) |
| 228 | list_add_tail(&clk->childnode, &clk->parent->children); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 229 | mutex_unlock(&clocks_mutex); |
| 230 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 231 | /* If rate is already set, use it */ |
| 232 | if (clk->rate) |
| 233 | return 0; |
| 234 | |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 235 | /* Else, see if there is a way to calculate it */ |
| 236 | if (clk->recalc) |
| 237 | clk->rate = clk->recalc(clk); |
| 238 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 239 | /* Otherwise, default to parent rate */ |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 240 | else if (clk->parent) |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 241 | clk->rate = clk->parent->rate; |
| 242 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 243 | return 0; |
| 244 | } |
| 245 | EXPORT_SYMBOL(clk_register); |
| 246 | |
| 247 | void clk_unregister(struct clk *clk) |
| 248 | { |
| 249 | if (clk == NULL || IS_ERR(clk)) |
| 250 | return; |
| 251 | |
| 252 | mutex_lock(&clocks_mutex); |
| 253 | list_del(&clk->node); |
Sekhar Nori | f02bf3b | 2009-08-31 15:48:01 +0530 | [diff] [blame] | 254 | list_del(&clk->childnode); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 255 | mutex_unlock(&clocks_mutex); |
| 256 | } |
| 257 | EXPORT_SYMBOL(clk_unregister); |
| 258 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 259 | #ifdef CONFIG_DAVINCI_RESET_CLOCKS |
| 260 | /* |
| 261 | * Disable any unused clocks left on by the bootloader |
| 262 | */ |
Shawn Guo | 3aa3e84 | 2012-04-26 09:45:39 +0800 | [diff] [blame] | 263 | int __init davinci_clk_disable_unused(void) |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 264 | { |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 265 | struct clk *ck; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 266 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 267 | spin_lock_irq(&clockfw_lock); |
| 268 | list_for_each_entry(ck, &clocks, node) { |
| 269 | if (ck->usecount > 0) |
| 270 | continue; |
| 271 | if (!(ck->flags & CLK_PSC)) |
| 272 | continue; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 273 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 274 | /* ignore if in Disabled or SwRstDisable states */ |
Sergei Shtylyov | 789a785 | 2009-09-30 19:48:03 +0400 | [diff] [blame] | 275 | if (!davinci_psc_is_clk_active(ck->gpsc, ck->lpsc)) |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 276 | continue; |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 277 | |
Kevin Hilman | c89f168 | 2010-08-05 10:55:16 -0700 | [diff] [blame] | 278 | pr_debug("Clocks: disable unused %s\n", ck->name); |
Cyril Chemparathy | 52958be | 2010-03-25 17:43:47 -0400 | [diff] [blame] | 279 | |
Murali Karicheri | 12221d4 | 2011-11-15 01:42:09 +0530 | [diff] [blame] | 280 | davinci_psc_config(ck->domain, ck->gpsc, ck->lpsc, |
Sekhar Nori | a51ca38 | 2011-07-06 06:01:21 +0000 | [diff] [blame] | 281 | false, ck->flags); |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 282 | } |
| 283 | spin_unlock_irq(&clockfw_lock); |
| 284 | |
| 285 | return 0; |
| 286 | } |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 287 | #endif |
| 288 | |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 289 | static unsigned long clk_sysclk_recalc(struct clk *clk) |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 290 | { |
| 291 | u32 v, plldiv; |
| 292 | struct pll_data *pll; |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 293 | unsigned long rate = clk->rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 294 | |
| 295 | /* If this is the PLL base clock, no more calculations needed */ |
| 296 | if (clk->pll_data) |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 297 | return rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 298 | |
| 299 | if (WARN_ON(!clk->parent)) |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 300 | return rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 301 | |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 302 | rate = clk->parent->rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 303 | |
| 304 | /* Otherwise, the parent must be a PLL */ |
| 305 | if (WARN_ON(!clk->parent->pll_data)) |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 306 | return rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 307 | |
| 308 | pll = clk->parent->pll_data; |
| 309 | |
| 310 | /* If pre-PLL, source clock is before the multiplier and divider(s) */ |
| 311 | if (clk->flags & PRE_PLL) |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 312 | rate = pll->input_rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 313 | |
| 314 | if (!clk->div_reg) |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 315 | return rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 316 | |
| 317 | v = __raw_readl(pll->base + clk->div_reg); |
| 318 | if (v & PLLDIV_EN) { |
Cyril Chemparathy | d6961e6 | 2010-04-14 14:44:49 -0400 | [diff] [blame] | 319 | plldiv = (v & pll->div_ratio_mask) + 1; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 320 | if (plldiv) |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 321 | rate /= plldiv; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 322 | } |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 323 | |
| 324 | return rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Sekhar Nori | b39639b | 2010-07-20 16:46:49 +0530 | [diff] [blame] | 327 | int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate) |
| 328 | { |
| 329 | unsigned v; |
| 330 | struct pll_data *pll; |
| 331 | unsigned long input; |
| 332 | unsigned ratio = 0; |
| 333 | |
| 334 | /* If this is the PLL base clock, wrong function to call */ |
| 335 | if (clk->pll_data) |
| 336 | return -EINVAL; |
| 337 | |
| 338 | /* There must be a parent... */ |
| 339 | if (WARN_ON(!clk->parent)) |
| 340 | return -EINVAL; |
| 341 | |
| 342 | /* ... the parent must be a PLL... */ |
| 343 | if (WARN_ON(!clk->parent->pll_data)) |
| 344 | return -EINVAL; |
| 345 | |
| 346 | /* ... and this clock must have a divider. */ |
| 347 | if (WARN_ON(!clk->div_reg)) |
| 348 | return -EINVAL; |
| 349 | |
| 350 | pll = clk->parent->pll_data; |
| 351 | |
| 352 | input = clk->parent->rate; |
| 353 | |
| 354 | /* If pre-PLL, source clock is before the multiplier and divider(s) */ |
| 355 | if (clk->flags & PRE_PLL) |
| 356 | input = pll->input_rate; |
| 357 | |
| 358 | if (input > rate) { |
| 359 | /* |
| 360 | * Can afford to provide an output little higher than requested |
| 361 | * only if maximum rate supported by hardware on this sysclk |
| 362 | * is known. |
| 363 | */ |
| 364 | if (clk->maxrate) { |
| 365 | ratio = DIV_ROUND_CLOSEST(input, rate); |
| 366 | if (input / ratio > clk->maxrate) |
| 367 | ratio = 0; |
| 368 | } |
| 369 | |
| 370 | if (ratio == 0) |
| 371 | ratio = DIV_ROUND_UP(input, rate); |
| 372 | |
| 373 | ratio--; |
| 374 | } |
| 375 | |
Cyril Chemparathy | b1d05be | 2010-10-20 17:49:56 -0400 | [diff] [blame] | 376 | if (ratio > pll->div_ratio_mask) |
Sekhar Nori | b39639b | 2010-07-20 16:46:49 +0530 | [diff] [blame] | 377 | return -EINVAL; |
| 378 | |
| 379 | do { |
| 380 | v = __raw_readl(pll->base + PLLSTAT); |
| 381 | } while (v & PLLSTAT_GOSTAT); |
| 382 | |
| 383 | v = __raw_readl(pll->base + clk->div_reg); |
Cyril Chemparathy | b1d05be | 2010-10-20 17:49:56 -0400 | [diff] [blame] | 384 | v &= ~pll->div_ratio_mask; |
Sekhar Nori | b39639b | 2010-07-20 16:46:49 +0530 | [diff] [blame] | 385 | v |= ratio | PLLDIV_EN; |
| 386 | __raw_writel(v, pll->base + clk->div_reg); |
| 387 | |
| 388 | v = __raw_readl(pll->base + PLLCMD); |
| 389 | v |= PLLCMD_GOSET; |
| 390 | __raw_writel(v, pll->base + PLLCMD); |
| 391 | |
| 392 | do { |
| 393 | v = __raw_readl(pll->base + PLLSTAT); |
| 394 | } while (v & PLLSTAT_GOSTAT); |
| 395 | |
| 396 | return 0; |
| 397 | } |
| 398 | EXPORT_SYMBOL(davinci_set_sysclk_rate); |
| 399 | |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 400 | static unsigned long clk_leafclk_recalc(struct clk *clk) |
| 401 | { |
| 402 | if (WARN_ON(!clk->parent)) |
| 403 | return clk->rate; |
| 404 | |
| 405 | return clk->parent->rate; |
| 406 | } |
| 407 | |
Sekhar Nori | 56e580d | 2011-06-14 15:33:20 +0000 | [diff] [blame] | 408 | int davinci_simple_set_rate(struct clk *clk, unsigned long rate) |
| 409 | { |
| 410 | clk->rate = rate; |
| 411 | return 0; |
| 412 | } |
| 413 | |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 414 | static unsigned long clk_pllclk_recalc(struct clk *clk) |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 415 | { |
| 416 | u32 ctrl, mult = 1, prediv = 1, postdiv = 1; |
| 417 | u8 bypass; |
| 418 | struct pll_data *pll = clk->pll_data; |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 419 | unsigned long rate = clk->rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 420 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 421 | ctrl = __raw_readl(pll->base + PLLCTL); |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 422 | rate = pll->input_rate = clk->parent->rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 423 | |
| 424 | if (ctrl & PLLCTL_PLLEN) { |
| 425 | bypass = 0; |
| 426 | mult = __raw_readl(pll->base + PLLM); |
Sandeep Paulraj | fb8fcb8 | 2009-06-11 09:41:05 -0400 | [diff] [blame] | 427 | if (cpu_is_davinci_dm365()) |
| 428 | mult = 2 * (mult & PLLM_PLLM_MASK); |
| 429 | else |
| 430 | mult = (mult & PLLM_PLLM_MASK) + 1; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 431 | } else |
| 432 | bypass = 1; |
| 433 | |
| 434 | if (pll->flags & PLL_HAS_PREDIV) { |
| 435 | prediv = __raw_readl(pll->base + PREDIV); |
| 436 | if (prediv & PLLDIV_EN) |
Cyril Chemparathy | d6961e6 | 2010-04-14 14:44:49 -0400 | [diff] [blame] | 437 | prediv = (prediv & pll->div_ratio_mask) + 1; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 438 | else |
| 439 | prediv = 1; |
| 440 | } |
| 441 | |
| 442 | /* pre-divider is fixed, but (some?) chips won't report that */ |
| 443 | if (cpu_is_davinci_dm355() && pll->num == 1) |
| 444 | prediv = 8; |
| 445 | |
| 446 | if (pll->flags & PLL_HAS_POSTDIV) { |
| 447 | postdiv = __raw_readl(pll->base + POSTDIV); |
| 448 | if (postdiv & PLLDIV_EN) |
Cyril Chemparathy | d6961e6 | 2010-04-14 14:44:49 -0400 | [diff] [blame] | 449 | postdiv = (postdiv & pll->div_ratio_mask) + 1; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 450 | else |
| 451 | postdiv = 1; |
| 452 | } |
| 453 | |
| 454 | if (!bypass) { |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 455 | rate /= prediv; |
| 456 | rate *= mult; |
| 457 | rate /= postdiv; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | pr_debug("PLL%d: input = %lu MHz [ ", |
| 461 | pll->num, clk->parent->rate / 1000000); |
| 462 | if (bypass) |
| 463 | pr_debug("bypass "); |
| 464 | if (prediv > 1) |
| 465 | pr_debug("/ %d ", prediv); |
| 466 | if (mult > 1) |
| 467 | pr_debug("* %d ", mult); |
| 468 | if (postdiv > 1) |
| 469 | pr_debug("/ %d ", postdiv); |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 470 | pr_debug("] --> %lu MHz output.\n", rate / 1000000); |
| 471 | |
| 472 | return rate; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 475 | /** |
| 476 | * davinci_set_pllrate - set the output rate of a given PLL. |
| 477 | * |
| 478 | * Note: Currently tested to work with OMAP-L138 only. |
| 479 | * |
| 480 | * @pll: pll whose rate needs to be changed. |
| 481 | * @prediv: The pre divider value. Passing 0 disables the pre-divider. |
| 482 | * @pllm: The multiplier value. Passing 0 leads to multiply-by-one. |
| 483 | * @postdiv: The post divider value. Passing 0 disables the post-divider. |
| 484 | */ |
| 485 | int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv, |
| 486 | unsigned int mult, unsigned int postdiv) |
| 487 | { |
| 488 | u32 ctrl; |
| 489 | unsigned int locktime; |
Sekhar Nori | 3b43cd6 | 2010-01-12 18:55:35 +0530 | [diff] [blame] | 490 | unsigned long flags; |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 491 | |
| 492 | if (pll->base == NULL) |
| 493 | return -EINVAL; |
| 494 | |
| 495 | /* |
| 496 | * PLL lock time required per OMAP-L138 datasheet is |
| 497 | * (2000 * prediv)/sqrt(pllm) OSCIN cycles. We approximate sqrt(pllm) |
| 498 | * as 4 and OSCIN cycle as 25 MHz. |
| 499 | */ |
| 500 | if (prediv) { |
| 501 | locktime = ((2000 * prediv) / 100); |
| 502 | prediv = (prediv - 1) | PLLDIV_EN; |
| 503 | } else { |
Sekhar Nori | 9a219a9 | 2009-11-16 17:21:33 +0530 | [diff] [blame] | 504 | locktime = PLL_LOCK_TIME; |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 505 | } |
| 506 | if (postdiv) |
| 507 | postdiv = (postdiv - 1) | PLLDIV_EN; |
| 508 | if (mult) |
| 509 | mult = mult - 1; |
| 510 | |
Sekhar Nori | 3b43cd6 | 2010-01-12 18:55:35 +0530 | [diff] [blame] | 511 | /* Protect against simultaneous calls to PLL setting seqeunce */ |
| 512 | spin_lock_irqsave(&clockfw_lock, flags); |
| 513 | |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 514 | ctrl = __raw_readl(pll->base + PLLCTL); |
| 515 | |
| 516 | /* Switch the PLL to bypass mode */ |
| 517 | ctrl &= ~(PLLCTL_PLLENSRC | PLLCTL_PLLEN); |
| 518 | __raw_writel(ctrl, pll->base + PLLCTL); |
| 519 | |
Sekhar Nori | 9a219a9 | 2009-11-16 17:21:33 +0530 | [diff] [blame] | 520 | udelay(PLL_BYPASS_TIME); |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 521 | |
| 522 | /* Reset and enable PLL */ |
| 523 | ctrl &= ~(PLLCTL_PLLRST | PLLCTL_PLLDIS); |
| 524 | __raw_writel(ctrl, pll->base + PLLCTL); |
| 525 | |
| 526 | if (pll->flags & PLL_HAS_PREDIV) |
| 527 | __raw_writel(prediv, pll->base + PREDIV); |
| 528 | |
| 529 | __raw_writel(mult, pll->base + PLLM); |
| 530 | |
| 531 | if (pll->flags & PLL_HAS_POSTDIV) |
| 532 | __raw_writel(postdiv, pll->base + POSTDIV); |
| 533 | |
Sekhar Nori | 9a219a9 | 2009-11-16 17:21:33 +0530 | [diff] [blame] | 534 | udelay(PLL_RESET_TIME); |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 535 | |
| 536 | /* Bring PLL out of reset */ |
| 537 | ctrl |= PLLCTL_PLLRST; |
| 538 | __raw_writel(ctrl, pll->base + PLLCTL); |
| 539 | |
| 540 | udelay(locktime); |
| 541 | |
| 542 | /* Remove PLL from bypass mode */ |
| 543 | ctrl |= PLLCTL_PLLEN; |
| 544 | __raw_writel(ctrl, pll->base + PLLCTL); |
| 545 | |
Sekhar Nori | 3b43cd6 | 2010-01-12 18:55:35 +0530 | [diff] [blame] | 546 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 547 | |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 548 | return 0; |
| 549 | } |
| 550 | EXPORT_SYMBOL(davinci_set_pllrate); |
| 551 | |
Sekhar Nori | 56e580d | 2011-06-14 15:33:20 +0000 | [diff] [blame] | 552 | /** |
| 553 | * davinci_set_refclk_rate() - Set the reference clock rate |
| 554 | * @rate: The new rate. |
| 555 | * |
| 556 | * Sets the reference clock rate to a given value. This will most likely |
| 557 | * result in the entire clock tree getting updated. |
| 558 | * |
| 559 | * This is used to support boards which use a reference clock different |
| 560 | * than that used by default in <soc>.c file. The reference clock rate |
| 561 | * should be updated early in the boot process; ideally soon after the |
| 562 | * clock tree has been initialized once with the default reference clock |
| 563 | * rate (davinci_common_init()). |
| 564 | * |
| 565 | * Returns 0 on success, error otherwise. |
| 566 | */ |
| 567 | int davinci_set_refclk_rate(unsigned long rate) |
| 568 | { |
| 569 | struct clk *refclk; |
| 570 | |
| 571 | refclk = clk_get(NULL, "ref"); |
| 572 | if (IS_ERR(refclk)) { |
Joe Perches | a7ca2bc | 2014-10-31 17:51:51 -0700 | [diff] [blame] | 573 | pr_err("%s: failed to get reference clock\n", __func__); |
Sekhar Nori | 56e580d | 2011-06-14 15:33:20 +0000 | [diff] [blame] | 574 | return PTR_ERR(refclk); |
| 575 | } |
| 576 | |
| 577 | clk_set_rate(refclk, rate); |
| 578 | |
| 579 | clk_put(refclk); |
| 580 | |
| 581 | return 0; |
| 582 | } |
| 583 | |
Kevin Hilman | 08aca08 | 2010-01-11 08:22:23 -0800 | [diff] [blame] | 584 | int __init davinci_clk_init(struct clk_lookup *clocks) |
Robert Tivy | af47e6b | 2013-01-10 16:23:23 -0800 | [diff] [blame] | 585 | { |
Kevin Hilman | 08aca08 | 2010-01-11 08:22:23 -0800 | [diff] [blame] | 586 | struct clk_lookup *c; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 587 | struct clk *clk; |
Kevin Hilman | 08aca08 | 2010-01-11 08:22:23 -0800 | [diff] [blame] | 588 | size_t num_clocks = 0; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 589 | |
Kevin Hilman | 08aca08 | 2010-01-11 08:22:23 -0800 | [diff] [blame] | 590 | for (c = clocks; c->clk; c++) { |
| 591 | clk = c->clk; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 592 | |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 593 | if (!clk->recalc) { |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 594 | |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 595 | /* Check if clock is a PLL */ |
| 596 | if (clk->pll_data) |
| 597 | clk->recalc = clk_pllclk_recalc; |
| 598 | |
| 599 | /* Else, if it is a PLL-derived clock */ |
| 600 | else if (clk->flags & CLK_PLL) |
| 601 | clk->recalc = clk_sysclk_recalc; |
| 602 | |
| 603 | /* Otherwise, it is a leaf clock (PSC clock) */ |
| 604 | else if (clk->parent) |
| 605 | clk->recalc = clk_leafclk_recalc; |
| 606 | } |
| 607 | |
Cyril Chemparathy | e4c822c | 2010-05-07 17:06:36 -0400 | [diff] [blame] | 608 | if (clk->pll_data) { |
| 609 | struct pll_data *pll = clk->pll_data; |
| 610 | |
| 611 | if (!pll->div_ratio_mask) |
| 612 | pll->div_ratio_mask = PLLDIV_RATIO_MASK; |
| 613 | |
| 614 | if (pll->phys_base && !pll->base) { |
| 615 | pll->base = ioremap(pll->phys_base, SZ_4K); |
| 616 | WARN_ON(!pll->base); |
| 617 | } |
| 618 | } |
Cyril Chemparathy | d6961e6 | 2010-04-14 14:44:49 -0400 | [diff] [blame] | 619 | |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 620 | if (clk->recalc) |
| 621 | clk->rate = clk->recalc(clk); |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 622 | |
| 623 | if (clk->lpsc) |
| 624 | clk->flags |= CLK_PSC; |
| 625 | |
Robert Tivy | af47e6b | 2013-01-10 16:23:23 -0800 | [diff] [blame] | 626 | if (clk->flags & PSC_LRST) |
| 627 | clk->reset = davinci_clk_reset; |
| 628 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 629 | clk_register(clk); |
Kevin Hilman | 08aca08 | 2010-01-11 08:22:23 -0800 | [diff] [blame] | 630 | num_clocks++; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 631 | |
| 632 | /* Turn on clocks that Linux doesn't otherwise manage */ |
| 633 | if (clk->flags & ALWAYS_ENABLED) |
| 634 | clk_enable(clk); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 635 | } |
| 636 | |
Kevin Hilman | 08aca08 | 2010-01-11 08:22:23 -0800 | [diff] [blame] | 637 | clkdev_add_table(clocks, num_clocks); |
| 638 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 639 | return 0; |
| 640 | } |
| 641 | |
Sekhar Nori | 2f72e8d | 2009-12-03 15:36:52 +0530 | [diff] [blame] | 642 | #ifdef CONFIG_DEBUG_FS |
| 643 | |
| 644 | #include <linux/debugfs.h> |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 645 | #include <linux/seq_file.h> |
| 646 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 647 | #define CLKNAME_MAX 10 /* longest clock name */ |
| 648 | #define NEST_DELTA 2 |
| 649 | #define NEST_MAX 4 |
| 650 | |
| 651 | static void |
| 652 | dump_clock(struct seq_file *s, unsigned nest, struct clk *parent) |
| 653 | { |
| 654 | char *state; |
| 655 | char buf[CLKNAME_MAX + NEST_DELTA * NEST_MAX]; |
| 656 | struct clk *clk; |
| 657 | unsigned i; |
| 658 | |
| 659 | if (parent->flags & CLK_PLL) |
| 660 | state = "pll"; |
| 661 | else if (parent->flags & CLK_PSC) |
| 662 | state = "psc"; |
| 663 | else |
| 664 | state = ""; |
| 665 | |
| 666 | /* <nest spaces> name <pad to end> */ |
| 667 | memset(buf, ' ', sizeof(buf) - 1); |
| 668 | buf[sizeof(buf) - 1] = 0; |
| 669 | i = strlen(parent->name); |
| 670 | memcpy(buf + nest, parent->name, |
| 671 | min(i, (unsigned)(sizeof(buf) - 1 - nest))); |
| 672 | |
| 673 | seq_printf(s, "%s users=%2d %-3s %9ld Hz\n", |
| 674 | buf, parent->usecount, state, clk_get_rate(parent)); |
| 675 | /* REVISIT show device associations too */ |
| 676 | |
| 677 | /* cost is now small, but not linear... */ |
Sekhar Nori | f02bf3b | 2009-08-31 15:48:01 +0530 | [diff] [blame] | 678 | list_for_each_entry(clk, &parent->children, childnode) { |
| 679 | dump_clock(s, nest + NEST_DELTA, clk); |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 680 | } |
| 681 | } |
| 682 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 683 | static int davinci_ck_show(struct seq_file *m, void *v) |
| 684 | { |
Sekhar Nori | f979aa6 | 2009-12-03 15:36:51 +0530 | [diff] [blame] | 685 | struct clk *clk; |
| 686 | |
| 687 | /* |
| 688 | * Show clock tree; We trust nonzero usecounts equate to PSC enables... |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 689 | */ |
| 690 | mutex_lock(&clocks_mutex); |
Sekhar Nori | f979aa6 | 2009-12-03 15:36:51 +0530 | [diff] [blame] | 691 | list_for_each_entry(clk, &clocks, node) |
| 692 | if (!clk->parent) |
| 693 | dump_clock(m, 0, clk); |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 694 | mutex_unlock(&clocks_mutex); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 695 | |
| 696 | return 0; |
| 697 | } |
| 698 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 699 | static int davinci_ck_open(struct inode *inode, struct file *file) |
| 700 | { |
Sekhar Nori | 2f72e8d | 2009-12-03 15:36:52 +0530 | [diff] [blame] | 701 | return single_open(file, davinci_ck_show, NULL); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 702 | } |
| 703 | |
Sekhar Nori | 2f72e8d | 2009-12-03 15:36:52 +0530 | [diff] [blame] | 704 | static const struct file_operations davinci_ck_operations = { |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 705 | .open = davinci_ck_open, |
| 706 | .read = seq_read, |
| 707 | .llseek = seq_lseek, |
Sekhar Nori | 2f72e8d | 2009-12-03 15:36:52 +0530 | [diff] [blame] | 708 | .release = single_release, |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 709 | }; |
| 710 | |
Sekhar Nori | 2f72e8d | 2009-12-03 15:36:52 +0530 | [diff] [blame] | 711 | static int __init davinci_clk_debugfs_init(void) |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 712 | { |
Sekhar Nori | 2f72e8d | 2009-12-03 15:36:52 +0530 | [diff] [blame] | 713 | debugfs_create_file("davinci_clocks", S_IFREG | S_IRUGO, NULL, NULL, |
| 714 | &davinci_ck_operations); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 715 | return 0; |
| 716 | |
| 717 | } |
Sekhar Nori | 2f72e8d | 2009-12-03 15:36:52 +0530 | [diff] [blame] | 718 | device_initcall(davinci_clk_debugfs_init); |
| 719 | #endif /* CONFIG_DEBUG_FS */ |