Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Thomas Abraham and committed by
Kukjin Kim
f86c6660 5822a5df

+9 -82
+6 -82
arch/arm/plat-samsung/clock.c
··· 71 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 74 int clk_enable(struct clk *clk) 143 75 { 144 76 if (IS_ERR(clk) || clk == NULL) ··· 173 241 return ret; 174 242 } 175 243 176 - EXPORT_SYMBOL(clk_get); 177 - EXPORT_SYMBOL(clk_put); 178 244 EXPORT_SYMBOL(clk_enable); 179 245 EXPORT_SYMBOL(clk_disable); 180 246 EXPORT_SYMBOL(clk_get_rate); ··· 276 346 if (clk->enable == NULL) 277 347 clk->enable = clk_null_enable; 278 348 279 - /* add to the list of available clocks */ 280 - 281 - /* Quick check to see if this clock has already been registered. */ 282 - BUG_ON(clk->list.prev != clk->list.next); 283 - 284 - spin_lock(&clocks_lock); 285 - list_add(&clk->list, &clocks); 286 - spin_unlock(&clocks_lock); 349 + /* fill up the clk_lookup structure and register it*/ 350 + clk->lookup.dev_id = clk->devname; 351 + clk->lookup.con_id = clk->name; 352 + clk->lookup.clk = clk; 353 + clkdev_add(&clk->lookup); 287 354 288 355 return 0; 289 356 } ··· 390 463 char s[255]; 391 464 char *p = s; 392 465 393 - p += sprintf(p, "%s", c->name); 394 - 395 - if (c->id >= 0) 396 - sprintf(p, ":%d", c->id); 466 + p += sprintf(p, "%s", c->devname); 397 467 398 468 d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root); 399 469 if (!d)
+3
arch/arm/plat-samsung/include/plat/clock.h
··· 10 10 */ 11 11 12 12 #include <linux/spinlock.h> 13 + #include <linux/clkdev.h> 13 14 14 15 struct clk; 15 16 ··· 41 40 struct module *owner; 42 41 struct clk *parent; 43 42 const char *name; 43 + const char *devname; 44 44 int id; 45 45 int usage; 46 46 unsigned long rate; ··· 49 47 50 48 struct clk_ops *ops; 51 49 int (*enable)(struct clk *, int enable); 50 + struct clk_lookup lookup; 52 51 #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) 53 52 struct dentry *dent; /* For visible tree hierarchy */ 54 53 #endif