| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Russell King | f8ce254 | 2006-01-07 16:15:52 +0000 | [diff] [blame] | 2 | *  linux/include/linux/clk.h | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * | 
|  | 4 | *  Copyright (C) 2004 ARM Limited. | 
|  | 5 | *  Written by Deep Blue Solutions Limited. | 
|  | 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 version 2 as | 
|  | 9 | * published by the Free Software Foundation. | 
|  | 10 | */ | 
| Todd Poynor | 686f8c5 | 2006-03-25 18:15:24 +0000 | [diff] [blame] | 11 | #ifndef __LINUX_CLK_H | 
|  | 12 | #define __LINUX_CLK_H | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 |  | 
|  | 14 | struct device; | 
|  | 15 |  | 
|  | 16 | /* | 
|  | 17 | * The base API. | 
|  | 18 | */ | 
|  | 19 |  | 
|  | 20 |  | 
|  | 21 | /* | 
|  | 22 | * struct clk - an machine class defined object / cookie. | 
|  | 23 | */ | 
|  | 24 | struct clk; | 
|  | 25 |  | 
|  | 26 | /** | 
|  | 27 | * clk_get - lookup and obtain a reference to a clock producer. | 
|  | 28 | * @dev: device for clock "consumer" | 
| Russell King | ea3f4ea | 2005-04-27 18:19:55 +0100 | [diff] [blame] | 29 | * @id: clock comsumer ID | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | * | 
|  | 31 | * Returns a struct clk corresponding to the clock producer, or | 
| Russell King | ea3f4ea | 2005-04-27 18:19:55 +0100 | [diff] [blame] | 32 | * valid IS_ERR() condition containing errno.  The implementation | 
|  | 33 | * uses @dev and @id to determine the clock consumer, and thereby | 
|  | 34 | * the clock producer.  (IOW, @id may be identical strings, but | 
|  | 35 | * clk_get may return different clock producers depending on @dev.) | 
| Russell King | f47fc0a | 2006-01-03 18:34:20 +0000 | [diff] [blame] | 36 | * | 
|  | 37 | * Drivers must assume that the clock source is not enabled. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | */ | 
|  | 39 | struct clk *clk_get(struct device *dev, const char *id); | 
|  | 40 |  | 
|  | 41 | /** | 
|  | 42 | * clk_enable - inform the system when the clock source should be running. | 
|  | 43 | * @clk: clock source | 
|  | 44 | * | 
|  | 45 | * If the clock can not be enabled/disabled, this should return success. | 
|  | 46 | * | 
|  | 47 | * Returns success (0) or negative errno. | 
|  | 48 | */ | 
|  | 49 | int clk_enable(struct clk *clk); | 
|  | 50 |  | 
|  | 51 | /** | 
|  | 52 | * clk_disable - inform the system when the clock source is no longer required. | 
|  | 53 | * @clk: clock source | 
| Russell King | f47fc0a | 2006-01-03 18:34:20 +0000 | [diff] [blame] | 54 | * | 
|  | 55 | * Inform the system that a clock source is no longer required by | 
|  | 56 | * a driver and may be shut down. | 
|  | 57 | * | 
|  | 58 | * Implementation detail: if the clock source is shared between | 
|  | 59 | * multiple drivers, clk_enable() calls must be balanced by the | 
|  | 60 | * same number of clk_disable() calls for the clock source to be | 
|  | 61 | * disabled. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | */ | 
|  | 63 | void clk_disable(struct clk *clk); | 
|  | 64 |  | 
|  | 65 | /** | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. | 
|  | 67 | *		  This is only valid once the clock source has been enabled. | 
|  | 68 | * @clk: clock source | 
|  | 69 | */ | 
|  | 70 | unsigned long clk_get_rate(struct clk *clk); | 
|  | 71 |  | 
|  | 72 | /** | 
|  | 73 | * clk_put	- "free" the clock source | 
|  | 74 | * @clk: clock source | 
| Russell King | f47fc0a | 2006-01-03 18:34:20 +0000 | [diff] [blame] | 75 | * | 
|  | 76 | * Note: drivers must ensure that all clk_enable calls made on this | 
|  | 77 | * clock source are balanced by clk_disable calls prior to calling | 
|  | 78 | * this function. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | */ | 
|  | 80 | void clk_put(struct clk *clk); | 
|  | 81 |  | 
|  | 82 |  | 
|  | 83 | /* | 
|  | 84 | * The remaining APIs are optional for machine class support. | 
|  | 85 | */ | 
|  | 86 |  | 
|  | 87 |  | 
|  | 88 | /** | 
|  | 89 | * clk_round_rate - adjust a rate to the exact rate a clock can provide | 
|  | 90 | * @clk: clock source | 
|  | 91 | * @rate: desired clock rate in Hz | 
|  | 92 | * | 
|  | 93 | * Returns rounded clock rate in Hz, or negative errno. | 
|  | 94 | */ | 
|  | 95 | long clk_round_rate(struct clk *clk, unsigned long rate); | 
|  | 96 |  | 
|  | 97 | /** | 
|  | 98 | * clk_set_rate - set the clock rate for a clock source | 
|  | 99 | * @clk: clock source | 
|  | 100 | * @rate: desired clock rate in Hz | 
|  | 101 | * | 
|  | 102 | * Returns success (0) or negative errno. | 
|  | 103 | */ | 
|  | 104 | int clk_set_rate(struct clk *clk, unsigned long rate); | 
|  | 105 |  | 
|  | 106 | /** | 
|  | 107 | * clk_set_parent - set the parent clock source for this clock | 
|  | 108 | * @clk: clock source | 
|  | 109 | * @parent: parent clock source | 
|  | 110 | * | 
|  | 111 | * Returns success (0) or negative errno. | 
|  | 112 | */ | 
|  | 113 | int clk_set_parent(struct clk *clk, struct clk *parent); | 
|  | 114 |  | 
|  | 115 | /** | 
|  | 116 | * clk_get_parent - get the parent clock source for this clock | 
|  | 117 | * @clk: clock source | 
|  | 118 | * | 
|  | 119 | * Returns struct clk corresponding to parent clock source, or | 
|  | 120 | * valid IS_ERR() condition containing errno. | 
|  | 121 | */ | 
|  | 122 | struct clk *clk_get_parent(struct clk *clk); | 
|  | 123 |  | 
|  | 124 | #endif |