clocksource: add enable() and disable() callbacks
[deliverable/linux.git] / include / linux / clocksource.h
index 0d96cde9ee5d90cc627ad901e7ab84870ee11de5..5a40d14daa9fab04bf641c1a11d82a1610ff7753 100644 (file)
@@ -144,6 +144,8 @@ extern u64 timecounter_cyc2time(struct timecounter *tc,
  *                             The ideal clocksource. A must-use where
  *                             available.
  * @read:              returns a cycle value, passes clocksource as argument
+ * @enable:            optional function to enable the clocksource
+ * @disable:           optional function to disable the clocksource
  * @mask:              bitmask for two's complement
  *                     subtraction of non 64 bit counters
  * @mult:              cycle to nanosecond multiplier (adjusted by NTP)
@@ -163,6 +165,8 @@ struct clocksource {
        struct list_head list;
        int rating;
        cycle_t (*read)(struct clocksource *cs);
+       int (*enable)(struct clocksource *cs);
+       void (*disable)(struct clocksource *cs);
        cycle_t mask;
        u32 mult;
        u32 mult_orig;
@@ -274,6 +278,33 @@ static inline cycle_t clocksource_read(struct clocksource *cs)
        return cs->read(cs);
 }
 
+/**
+ * clocksource_enable: - enable clocksource
+ * @cs:                pointer to clocksource
+ *
+ * Enables the specified clocksource. The clocksource callback
+ * function should start up the hardware and setup mult and field
+ * members of struct clocksource to reflect hardware capabilities.
+ */
+static inline int clocksource_enable(struct clocksource *cs)
+{
+       return cs->enable ? cs->enable(cs) : 0;
+}
+
+/**
+ * clocksource_disable: - disable clocksource
+ * @cs:                pointer to clocksource
+ *
+ * Disables the specified clocksource. The clocksource callback
+ * function should power down the now unused hardware block to
+ * save power.
+ */
+static inline void clocksource_disable(struct clocksource *cs)
+{
+       if (cs->disable)
+               cs->disable(cs);
+}
+
 /**
  * cyc2ns - converts clocksource cycles to nanoseconds
  * @cs:                Pointer to clocksource
This page took 0.024557 seconds and 5 git commands to generate.