diff options
author | Thomas Abraham <thomas.ab@samsung.com> | 2011-06-14 06:12:26 -0400 |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2011-07-20 06:11:28 -0400 |
commit | f86c6660927614fcda257e083569bfb252fcf85e (patch) | |
tree | 69a3b8f88dbc47e150f4e72e7535ad38a8eebb3a /arch/arm/plat-samsung/clock.c | |
parent | 5822a5df5ee2bbb2a98a4baadf065829e191395f (diff) |
ARM: SAMSUNG: Add clkdev infrastructure
The struct clk definition for Samsung platforms is extended to include
a instance of struct clk_lookup and a device name. When clocks are
registered using s3c24xx_register_clock function, the dev_id, con_id
and clk members are initialized with information from the struct clk
instance and struct clk_lookup member is registered.
Signed-off-by: Thomas Abraham <thomas.ab@samsung.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm/plat-samsung/clock.c')
-rw-r--r-- | arch/arm/plat-samsung/clock.c | 88 |
1 files changed, 6 insertions, 82 deletions
diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c index 772892826ffc..e30bd4591a30 100644 --- a/arch/arm/plat-samsung/clock.c +++ b/arch/arm/plat-samsung/clock.c | |||
@@ -71,74 +71,6 @@ static int clk_null_enable(struct clk *clk, int enable) | |||
71 | return 0; | 71 | return 0; |
72 | } | 72 | } |
73 | 73 | ||
74 | static int dev_is_s3c_uart(struct device *dev) | ||
75 | { | ||
76 | struct platform_device **pdev = s3c24xx_uart_devs; | ||
77 | int i; | ||
78 | for (i = 0; i < ARRAY_SIZE(s3c24xx_uart_devs); i++, pdev++) | ||
79 | if (*pdev && dev == &(*pdev)->dev) | ||
80 | return 1; | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | /* | ||
85 | * Serial drivers call get_clock() very early, before platform bus | ||
86 | * has been set up, this requires a special check to let them get | ||
87 | * a proper clock | ||
88 | */ | ||
89 | |||
90 | static int dev_is_platform_device(struct device *dev) | ||
91 | { | ||
92 | return dev->bus == &platform_bus_type || | ||
93 | (dev->bus == NULL && dev_is_s3c_uart(dev)); | ||
94 | } | ||
95 | |||
96 | /* Clock API calls */ | ||
97 | |||
98 | struct clk *clk_get(struct device *dev, const char *id) | ||
99 | { | ||
100 | struct clk *p; | ||
101 | struct clk *clk = ERR_PTR(-ENOENT); | ||
102 | int idno; | ||
103 | |||
104 | if (dev == NULL || !dev_is_platform_device(dev)) | ||
105 | idno = -1; | ||
106 | else | ||
107 | idno = to_platform_device(dev)->id; | ||
108 | |||
109 | spin_lock(&clocks_lock); | ||
110 | |||
111 | list_for_each_entry(p, &clocks, list) { | ||
112 | if (p->id == idno && | ||
113 | strcmp(id, p->name) == 0 && | ||
114 | try_module_get(p->owner)) { | ||
115 | clk = p; | ||
116 | break; | ||
117 | } | ||
118 | } | ||
119 | |||
120 | /* check for the case where a device was supplied, but the | ||
121 | * clock that was being searched for is not device specific */ | ||
122 | |||
123 | if (IS_ERR(clk)) { | ||
124 | list_for_each_entry(p, &clocks, list) { | ||
125 | if (p->id == -1 && strcmp(id, p->name) == 0 && | ||
126 | try_module_get(p->owner)) { | ||
127 | clk = p; | ||
128 | break; | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | |||
133 | spin_unlock(&clocks_lock); | ||
134 | return clk; | ||
135 | } | ||
136 | |||
137 | void clk_put(struct clk *clk) | ||
138 | { | ||
139 | module_put(clk->owner); | ||
140 | } | ||
141 | |||
142 | int clk_enable(struct clk *clk) | 74 | int clk_enable(struct clk *clk) |
143 | { | 75 | { |
144 | if (IS_ERR(clk) || clk == NULL) | 76 | if (IS_ERR(clk) || clk == NULL) |
@@ -241,8 +173,6 @@ int clk_set_parent(struct clk *clk, struct clk *parent) | |||
241 | return ret; | 173 | return ret; |
242 | } | 174 | } |
243 | 175 | ||
244 | EXPORT_SYMBOL(clk_get); | ||
245 | EXPORT_SYMBOL(clk_put); | ||
246 | EXPORT_SYMBOL(clk_enable); | 176 | EXPORT_SYMBOL(clk_enable); |
247 | EXPORT_SYMBOL(clk_disable); | 177 | EXPORT_SYMBOL(clk_disable); |
248 | EXPORT_SYMBOL(clk_get_rate); | 178 | EXPORT_SYMBOL(clk_get_rate); |
@@ -346,14 +276,11 @@ int s3c24xx_register_clock(struct clk *clk) | |||
346 | if (clk->enable == NULL) | 276 | if (clk->enable == NULL) |
347 | clk->enable = clk_null_enable; | 277 | clk->enable = clk_null_enable; |
348 | 278 | ||
349 | /* add to the list of available clocks */ | 279 | /* fill up the clk_lookup structure and register it*/ |
350 | 280 | clk->lookup.dev_id = clk->devname; | |
351 | /* Quick check to see if this clock has already been registered. */ | 281 | clk->lookup.con_id = clk->name; |
352 | BUG_ON(clk->list.prev != clk->list.next); | 282 | clk->lookup.clk = clk; |
353 | 283 | clkdev_add(&clk->lookup); | |
354 | spin_lock(&clocks_lock); | ||
355 | list_add(&clk->list, &clocks); | ||
356 | spin_unlock(&clocks_lock); | ||
357 | 284 | ||
358 | return 0; | 285 | return 0; |
359 | } | 286 | } |
@@ -463,10 +390,7 @@ static int clk_debugfs_register_one(struct clk *c) | |||
463 | char s[255]; | 390 | char s[255]; |
464 | char *p = s; | 391 | char *p = s; |
465 | 392 | ||
466 | p += sprintf(p, "%s", c->name); | 393 | p += sprintf(p, "%s", c->devname); |
467 | |||
468 | if (c->id >= 0) | ||
469 | sprintf(p, ":%d", c->id); | ||
470 | 394 | ||
471 | d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root); | 395 | d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root); |
472 | if (!d) | 396 | if (!d) |