ia64/linux-2.6.18-xen.hg

annotate drivers/macintosh/windfarm.h @ 893:f994bfe9b93b

linux/blktap2: reduce TLB flush scope

c/s 885 added very coarse TLB flushing. Since these flushes always
follow single page updates, single page flushes (when available) are
sufficient.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:32:57 2009 +0100 (2009-06-04)
parents 831230e53067
children
rev   line source
ian@0 1 /*
ian@0 2 * Windfarm PowerMac thermal control.
ian@0 3 *
ian@0 4 * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
ian@0 5 * <benh@kernel.crashing.org>
ian@0 6 *
ian@0 7 * Released under the term of the GNU GPL v2.
ian@0 8 */
ian@0 9
ian@0 10 #ifndef __WINDFARM_H__
ian@0 11 #define __WINDFARM_H__
ian@0 12
ian@0 13 #include <linux/kref.h>
ian@0 14 #include <linux/list.h>
ian@0 15 #include <linux/module.h>
ian@0 16 #include <linux/notifier.h>
ian@0 17 #include <linux/device.h>
ian@0 18
ian@0 19 /* Display a 16.16 fixed point value */
ian@0 20 #define FIX32TOPRINT(f) ((f) >> 16),((((f) & 0xffff) * 1000) >> 16)
ian@0 21
ian@0 22 /*
ian@0 23 * Control objects
ian@0 24 */
ian@0 25
ian@0 26 struct wf_control;
ian@0 27
ian@0 28 struct wf_control_ops {
ian@0 29 int (*set_value)(struct wf_control *ct, s32 val);
ian@0 30 int (*get_value)(struct wf_control *ct, s32 *val);
ian@0 31 s32 (*get_min)(struct wf_control *ct);
ian@0 32 s32 (*get_max)(struct wf_control *ct);
ian@0 33 void (*release)(struct wf_control *ct);
ian@0 34 struct module *owner;
ian@0 35 };
ian@0 36
ian@0 37 struct wf_control {
ian@0 38 struct list_head link;
ian@0 39 struct wf_control_ops *ops;
ian@0 40 char *name;
ian@0 41 int type;
ian@0 42 struct kref ref;
ian@0 43 struct device_attribute attr;
ian@0 44 };
ian@0 45
ian@0 46 #define WF_CONTROL_TYPE_GENERIC 0
ian@0 47 #define WF_CONTROL_RPM_FAN 1
ian@0 48 #define WF_CONTROL_PWM_FAN 2
ian@0 49
ian@0 50
ian@0 51 /* Note about lifetime rules: wf_register_control() will initialize
ian@0 52 * the kref and wf_unregister_control will decrement it, thus the
ian@0 53 * object creating/disposing a given control shouldn't assume it
ian@0 54 * still exists after wf_unregister_control has been called.
ian@0 55 * wf_find_control will inc the refcount for you
ian@0 56 */
ian@0 57 extern int wf_register_control(struct wf_control *ct);
ian@0 58 extern void wf_unregister_control(struct wf_control *ct);
ian@0 59 extern struct wf_control * wf_find_control(const char *name);
ian@0 60 extern int wf_get_control(struct wf_control *ct);
ian@0 61 extern void wf_put_control(struct wf_control *ct);
ian@0 62
ian@0 63 static inline int wf_control_set_max(struct wf_control *ct)
ian@0 64 {
ian@0 65 s32 vmax = ct->ops->get_max(ct);
ian@0 66 return ct->ops->set_value(ct, vmax);
ian@0 67 }
ian@0 68
ian@0 69 static inline int wf_control_set_min(struct wf_control *ct)
ian@0 70 {
ian@0 71 s32 vmin = ct->ops->get_min(ct);
ian@0 72 return ct->ops->set_value(ct, vmin);
ian@0 73 }
ian@0 74
ian@0 75 /*
ian@0 76 * Sensor objects
ian@0 77 */
ian@0 78
ian@0 79 struct wf_sensor;
ian@0 80
ian@0 81 struct wf_sensor_ops {
ian@0 82 int (*get_value)(struct wf_sensor *sr, s32 *val);
ian@0 83 void (*release)(struct wf_sensor *sr);
ian@0 84 struct module *owner;
ian@0 85 };
ian@0 86
ian@0 87 struct wf_sensor {
ian@0 88 struct list_head link;
ian@0 89 struct wf_sensor_ops *ops;
ian@0 90 char *name;
ian@0 91 struct kref ref;
ian@0 92 struct device_attribute attr;
ian@0 93 };
ian@0 94
ian@0 95 /* Same lifetime rules as controls */
ian@0 96 extern int wf_register_sensor(struct wf_sensor *sr);
ian@0 97 extern void wf_unregister_sensor(struct wf_sensor *sr);
ian@0 98 extern struct wf_sensor * wf_find_sensor(const char *name);
ian@0 99 extern int wf_get_sensor(struct wf_sensor *sr);
ian@0 100 extern void wf_put_sensor(struct wf_sensor *sr);
ian@0 101
ian@0 102 /* For use by clients. Note that we are a bit racy here since
ian@0 103 * notifier_block doesn't have a module owner field. I may fix
ian@0 104 * it one day ...
ian@0 105 *
ian@0 106 * LOCKING NOTE !
ian@0 107 *
ian@0 108 * All "events" except WF_EVENT_TICK are called with an internal mutex
ian@0 109 * held which will deadlock if you call basically any core routine.
ian@0 110 * So don't ! Just take note of the event and do your actual operations
ian@0 111 * from the ticker.
ian@0 112 *
ian@0 113 */
ian@0 114 extern int wf_register_client(struct notifier_block *nb);
ian@0 115 extern int wf_unregister_client(struct notifier_block *nb);
ian@0 116
ian@0 117 /* Overtemp conditions. Those are refcounted */
ian@0 118 extern void wf_set_overtemp(void);
ian@0 119 extern void wf_clear_overtemp(void);
ian@0 120 extern int wf_is_overtemp(void);
ian@0 121
ian@0 122 #define WF_EVENT_NEW_CONTROL 0 /* param is wf_control * */
ian@0 123 #define WF_EVENT_NEW_SENSOR 1 /* param is wf_sensor * */
ian@0 124 #define WF_EVENT_OVERTEMP 2 /* no param */
ian@0 125 #define WF_EVENT_NORMALTEMP 3 /* overtemp condition cleared */
ian@0 126 #define WF_EVENT_TICK 4 /* 1 second tick */
ian@0 127
ian@0 128 /* Note: If that driver gets more broad use, we could replace the
ian@0 129 * simplistic overtemp bits with "environmental conditions". That
ian@0 130 * could then be used to also notify of things like fan failure,
ian@0 131 * case open, battery conditions, ...
ian@0 132 */
ian@0 133
ian@0 134 #endif /* __WINDFARM_H__ */