xref: /linux/drivers/macintosh/windfarm_smu_controls.c (revision ac171c46667c1cb2ee9e22312291df6ed78e1b6e)
175722d39SBenjamin Herrenschmidt /*
275722d39SBenjamin Herrenschmidt  * Windfarm PowerMac thermal control. SMU based controls
375722d39SBenjamin Herrenschmidt  *
475722d39SBenjamin Herrenschmidt  * (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
575722d39SBenjamin Herrenschmidt  *                    <benh@kernel.crashing.org>
675722d39SBenjamin Herrenschmidt  *
775722d39SBenjamin Herrenschmidt  * Released under the term of the GNU GPL v2.
875722d39SBenjamin Herrenschmidt  */
975722d39SBenjamin Herrenschmidt 
1075722d39SBenjamin Herrenschmidt #include <linux/types.h>
1175722d39SBenjamin Herrenschmidt #include <linux/errno.h>
1275722d39SBenjamin Herrenschmidt #include <linux/kernel.h>
1375722d39SBenjamin Herrenschmidt #include <linux/delay.h>
1475722d39SBenjamin Herrenschmidt #include <linux/slab.h>
1575722d39SBenjamin Herrenschmidt #include <linux/init.h>
1675722d39SBenjamin Herrenschmidt #include <linux/wait.h>
17de25968cSTim Schmielau #include <linux/completion.h>
1875722d39SBenjamin Herrenschmidt #include <asm/prom.h>
1975722d39SBenjamin Herrenschmidt #include <asm/machdep.h>
2075722d39SBenjamin Herrenschmidt #include <asm/io.h>
2175722d39SBenjamin Herrenschmidt #include <asm/system.h>
2275722d39SBenjamin Herrenschmidt #include <asm/sections.h>
2375722d39SBenjamin Herrenschmidt #include <asm/smu.h>
2475722d39SBenjamin Herrenschmidt 
2575722d39SBenjamin Herrenschmidt #include "windfarm.h"
2675722d39SBenjamin Herrenschmidt 
27*ac171c46SBenjamin Herrenschmidt #define VERSION "0.4"
2875722d39SBenjamin Herrenschmidt 
2975722d39SBenjamin Herrenschmidt #undef DEBUG
3075722d39SBenjamin Herrenschmidt 
3175722d39SBenjamin Herrenschmidt #ifdef DEBUG
3275722d39SBenjamin Herrenschmidt #define DBG(args...)	printk(args)
3375722d39SBenjamin Herrenschmidt #else
3475722d39SBenjamin Herrenschmidt #define DBG(args...)	do { } while(0)
3575722d39SBenjamin Herrenschmidt #endif
3675722d39SBenjamin Herrenschmidt 
37*ac171c46SBenjamin Herrenschmidt static int smu_supports_new_fans_ops = 1;
38*ac171c46SBenjamin Herrenschmidt 
3975722d39SBenjamin Herrenschmidt /*
4075722d39SBenjamin Herrenschmidt  * SMU fans control object
4175722d39SBenjamin Herrenschmidt  */
4275722d39SBenjamin Herrenschmidt 
4375722d39SBenjamin Herrenschmidt static LIST_HEAD(smu_fans);
4475722d39SBenjamin Herrenschmidt 
4575722d39SBenjamin Herrenschmidt struct smu_fan_control {
4675722d39SBenjamin Herrenschmidt 	struct list_head	link;
4775722d39SBenjamin Herrenschmidt 	int    			fan_type;	/* 0 = rpm, 1 = pwm */
4875722d39SBenjamin Herrenschmidt 	u32			reg;		/* index in SMU */
4975722d39SBenjamin Herrenschmidt 	s32			value;		/* current value */
5075722d39SBenjamin Herrenschmidt 	s32			min, max;	/* min/max values */
5175722d39SBenjamin Herrenschmidt 	struct wf_control	ctrl;
5275722d39SBenjamin Herrenschmidt };
5375722d39SBenjamin Herrenschmidt #define to_smu_fan(c) container_of(c, struct smu_fan_control, ctrl)
5475722d39SBenjamin Herrenschmidt 
5575722d39SBenjamin Herrenschmidt static int smu_set_fan(int pwm, u8 id, u16 value)
5675722d39SBenjamin Herrenschmidt {
5775722d39SBenjamin Herrenschmidt 	struct smu_cmd cmd;
5875722d39SBenjamin Herrenschmidt 	u8 buffer[16];
5975722d39SBenjamin Herrenschmidt 	DECLARE_COMPLETION(comp);
6075722d39SBenjamin Herrenschmidt 	int rc;
6175722d39SBenjamin Herrenschmidt 
6275722d39SBenjamin Herrenschmidt 	/* Fill SMU command structure */
6375722d39SBenjamin Herrenschmidt 	cmd.cmd = SMU_CMD_FAN_COMMAND;
64*ac171c46SBenjamin Herrenschmidt 
65*ac171c46SBenjamin Herrenschmidt 	/* The SMU has an "old" and a "new" way of setting the fan speed
66*ac171c46SBenjamin Herrenschmidt 	 * Unfortunately, I found no reliable way to know which one works
67*ac171c46SBenjamin Herrenschmidt 	 * on a given machine model. After some investigations it appears
68*ac171c46SBenjamin Herrenschmidt 	 * that MacOS X just tries the new one, and if it fails fallbacks
69*ac171c46SBenjamin Herrenschmidt 	 * to the old ones ... Ugh.
70*ac171c46SBenjamin Herrenschmidt 	 */
71*ac171c46SBenjamin Herrenschmidt  retry:
72*ac171c46SBenjamin Herrenschmidt 	if (smu_supports_new_fans_ops) {
73*ac171c46SBenjamin Herrenschmidt 		buffer[0] = 0x30;
74*ac171c46SBenjamin Herrenschmidt 		buffer[1] = id;
75*ac171c46SBenjamin Herrenschmidt 		*((u16 *)(&buffer[2])) = value;
76*ac171c46SBenjamin Herrenschmidt 		cmd.data_len = 4;
77*ac171c46SBenjamin Herrenschmidt 	} else {
78*ac171c46SBenjamin Herrenschmidt 		if (id > 7)
79*ac171c46SBenjamin Herrenschmidt 			return -EINVAL;
80*ac171c46SBenjamin Herrenschmidt 		/* Fill argument buffer */
81*ac171c46SBenjamin Herrenschmidt 		memset(buffer, 0, 16);
82*ac171c46SBenjamin Herrenschmidt 		buffer[0] = pwm ? 0x10 : 0x00;
83*ac171c46SBenjamin Herrenschmidt 		buffer[1] = 0x01 << id;
84*ac171c46SBenjamin Herrenschmidt 		*((u16 *)&buffer[2 + id * 2]) = value;
8575722d39SBenjamin Herrenschmidt 		cmd.data_len = 14;
86*ac171c46SBenjamin Herrenschmidt 	}
87*ac171c46SBenjamin Herrenschmidt 
8875722d39SBenjamin Herrenschmidt 	cmd.reply_len = 16;
8975722d39SBenjamin Herrenschmidt 	cmd.data_buf = cmd.reply_buf = buffer;
9075722d39SBenjamin Herrenschmidt 	cmd.status = 0;
9175722d39SBenjamin Herrenschmidt 	cmd.done = smu_done_complete;
9275722d39SBenjamin Herrenschmidt 	cmd.misc = &comp;
9375722d39SBenjamin Herrenschmidt 
9475722d39SBenjamin Herrenschmidt 	rc = smu_queue_cmd(&cmd);
9575722d39SBenjamin Herrenschmidt 	if (rc)
9675722d39SBenjamin Herrenschmidt 		return rc;
9775722d39SBenjamin Herrenschmidt 	wait_for_completion(&comp);
98*ac171c46SBenjamin Herrenschmidt 
99*ac171c46SBenjamin Herrenschmidt 	/* Handle fallback (see coment above) */
100*ac171c46SBenjamin Herrenschmidt 	if (cmd.status != 0 && smu_supports_new_fans_ops) {
101*ac171c46SBenjamin Herrenschmidt 		printk(KERN_WARNING "windfarm: SMU failed new fan command "
102*ac171c46SBenjamin Herrenschmidt 		       "falling back to old method\n");
103*ac171c46SBenjamin Herrenschmidt 		smu_supports_new_fans_ops = 0;
104*ac171c46SBenjamin Herrenschmidt 		goto retry;
105*ac171c46SBenjamin Herrenschmidt 	}
106*ac171c46SBenjamin Herrenschmidt 
10775722d39SBenjamin Herrenschmidt 	return cmd.status;
10875722d39SBenjamin Herrenschmidt }
10975722d39SBenjamin Herrenschmidt 
11075722d39SBenjamin Herrenschmidt static void smu_fan_release(struct wf_control *ct)
11175722d39SBenjamin Herrenschmidt {
11275722d39SBenjamin Herrenschmidt 	struct smu_fan_control *fct = to_smu_fan(ct);
11375722d39SBenjamin Herrenschmidt 
11475722d39SBenjamin Herrenschmidt 	kfree(fct);
11575722d39SBenjamin Herrenschmidt }
11675722d39SBenjamin Herrenschmidt 
11775722d39SBenjamin Herrenschmidt static int smu_fan_set(struct wf_control *ct, s32 value)
11875722d39SBenjamin Herrenschmidt {
11975722d39SBenjamin Herrenschmidt 	struct smu_fan_control *fct = to_smu_fan(ct);
12075722d39SBenjamin Herrenschmidt 
12175722d39SBenjamin Herrenschmidt 	if (value < fct->min)
12275722d39SBenjamin Herrenschmidt 		value = fct->min;
12375722d39SBenjamin Herrenschmidt 	if (value > fct->max)
12475722d39SBenjamin Herrenschmidt 		value = fct->max;
12575722d39SBenjamin Herrenschmidt 	fct->value = value;
12675722d39SBenjamin Herrenschmidt 
12775722d39SBenjamin Herrenschmidt 	return smu_set_fan(fct->fan_type, fct->reg, value);
12875722d39SBenjamin Herrenschmidt }
12975722d39SBenjamin Herrenschmidt 
13075722d39SBenjamin Herrenschmidt static int smu_fan_get(struct wf_control *ct, s32 *value)
13175722d39SBenjamin Herrenschmidt {
13275722d39SBenjamin Herrenschmidt 	struct smu_fan_control *fct = to_smu_fan(ct);
13375722d39SBenjamin Herrenschmidt 	*value = fct->value; /* todo: read from SMU */
13475722d39SBenjamin Herrenschmidt 	return 0;
13575722d39SBenjamin Herrenschmidt }
13675722d39SBenjamin Herrenschmidt 
13775722d39SBenjamin Herrenschmidt static s32 smu_fan_min(struct wf_control *ct)
13875722d39SBenjamin Herrenschmidt {
13975722d39SBenjamin Herrenschmidt 	struct smu_fan_control *fct = to_smu_fan(ct);
14075722d39SBenjamin Herrenschmidt 	return fct->min;
14175722d39SBenjamin Herrenschmidt }
14275722d39SBenjamin Herrenschmidt 
14375722d39SBenjamin Herrenschmidt static s32 smu_fan_max(struct wf_control *ct)
14475722d39SBenjamin Herrenschmidt {
14575722d39SBenjamin Herrenschmidt 	struct smu_fan_control *fct = to_smu_fan(ct);
14675722d39SBenjamin Herrenschmidt 	return fct->max;
14775722d39SBenjamin Herrenschmidt }
14875722d39SBenjamin Herrenschmidt 
14975722d39SBenjamin Herrenschmidt static struct wf_control_ops smu_fan_ops = {
15075722d39SBenjamin Herrenschmidt 	.set_value	= smu_fan_set,
15175722d39SBenjamin Herrenschmidt 	.get_value	= smu_fan_get,
15275722d39SBenjamin Herrenschmidt 	.get_min	= smu_fan_min,
15375722d39SBenjamin Herrenschmidt 	.get_max	= smu_fan_max,
15475722d39SBenjamin Herrenschmidt 	.release	= smu_fan_release,
15575722d39SBenjamin Herrenschmidt 	.owner		= THIS_MODULE,
15675722d39SBenjamin Herrenschmidt };
15775722d39SBenjamin Herrenschmidt 
15875722d39SBenjamin Herrenschmidt static struct smu_fan_control *smu_fan_create(struct device_node *node,
15975722d39SBenjamin Herrenschmidt 					      int pwm_fan)
16075722d39SBenjamin Herrenschmidt {
16175722d39SBenjamin Herrenschmidt 	struct smu_fan_control *fct;
16275722d39SBenjamin Herrenschmidt 	s32 *v; u32 *reg;
16375722d39SBenjamin Herrenschmidt 	char *l;
16475722d39SBenjamin Herrenschmidt 
16575722d39SBenjamin Herrenschmidt 	fct = kmalloc(sizeof(struct smu_fan_control), GFP_KERNEL);
16675722d39SBenjamin Herrenschmidt 	if (fct == NULL)
16775722d39SBenjamin Herrenschmidt 		return NULL;
16875722d39SBenjamin Herrenschmidt 	fct->ctrl.ops = &smu_fan_ops;
16975722d39SBenjamin Herrenschmidt 	l = (char *)get_property(node, "location", NULL);
17075722d39SBenjamin Herrenschmidt 	if (l == NULL)
17175722d39SBenjamin Herrenschmidt 		goto fail;
17275722d39SBenjamin Herrenschmidt 
17375722d39SBenjamin Herrenschmidt 	fct->fan_type = pwm_fan;
17475722d39SBenjamin Herrenschmidt 	fct->ctrl.type = pwm_fan ? WF_CONTROL_PWM_FAN : WF_CONTROL_RPM_FAN;
17575722d39SBenjamin Herrenschmidt 
17675722d39SBenjamin Herrenschmidt 	/* We use the name & location here the same way we do for SMU sensors,
17775722d39SBenjamin Herrenschmidt 	 * see the comment in windfarm_smu_sensors.c. The locations are a bit
17875722d39SBenjamin Herrenschmidt 	 * less consistent here between the iMac and the desktop models, but
17975722d39SBenjamin Herrenschmidt 	 * that is good enough for our needs for now at least.
18075722d39SBenjamin Herrenschmidt 	 *
18175722d39SBenjamin Herrenschmidt 	 * One problem though is that Apple seem to be inconsistent with case
18275722d39SBenjamin Herrenschmidt 	 * and the kernel doesn't have strcasecmp =P
18375722d39SBenjamin Herrenschmidt 	 */
18475722d39SBenjamin Herrenschmidt 
18575722d39SBenjamin Herrenschmidt 	fct->ctrl.name = NULL;
18675722d39SBenjamin Herrenschmidt 
18775722d39SBenjamin Herrenschmidt 	/* Names used on desktop models */
18875722d39SBenjamin Herrenschmidt 	if (!strcmp(l, "Rear Fan 0") || !strcmp(l, "Rear Fan") ||
189*ac171c46SBenjamin Herrenschmidt 	    !strcmp(l, "Rear fan 0") || !strcmp(l, "Rear fan") ||
190*ac171c46SBenjamin Herrenschmidt 	    !strcmp(l, "CPU A EXHAUST"))
19175722d39SBenjamin Herrenschmidt 		fct->ctrl.name = "cpu-rear-fan-0";
192*ac171c46SBenjamin Herrenschmidt 	else if (!strcmp(l, "Rear Fan 1") || !strcmp(l, "Rear fan 1") ||
193*ac171c46SBenjamin Herrenschmidt 		 !strcmp(l, "CPU B EXHAUST"))
19475722d39SBenjamin Herrenschmidt 		fct->ctrl.name = "cpu-rear-fan-1";
19575722d39SBenjamin Herrenschmidt 	else if (!strcmp(l, "Front Fan 0") || !strcmp(l, "Front Fan") ||
196*ac171c46SBenjamin Herrenschmidt 		 !strcmp(l, "Front fan 0") || !strcmp(l, "Front fan") ||
197*ac171c46SBenjamin Herrenschmidt 		 !strcmp(l, "CPU A INTAKE"))
19875722d39SBenjamin Herrenschmidt 		fct->ctrl.name = "cpu-front-fan-0";
199*ac171c46SBenjamin Herrenschmidt 	else if (!strcmp(l, "Front Fan 1") || !strcmp(l, "Front fan 1") ||
200*ac171c46SBenjamin Herrenschmidt 		 !strcmp(l, "CPU B INTAKE"))
20175722d39SBenjamin Herrenschmidt 		fct->ctrl.name = "cpu-front-fan-1";
202*ac171c46SBenjamin Herrenschmidt 	else if (!strcmp(l, "CPU A PUMP"))
203*ac171c46SBenjamin Herrenschmidt 		fct->ctrl.name = "cpu-pump-0";
204*ac171c46SBenjamin Herrenschmidt 	else if (!strcmp(l, "Slots Fan") || !strcmp(l, "Slots fan") ||
205*ac171c46SBenjamin Herrenschmidt 		 !strcmp(l, "EXPANSION SLOTS INTAKE"))
20675722d39SBenjamin Herrenschmidt 		fct->ctrl.name = "slots-fan";
207*ac171c46SBenjamin Herrenschmidt 	else if (!strcmp(l, "Drive Bay") || !strcmp(l, "Drive bay") ||
208*ac171c46SBenjamin Herrenschmidt 		 !strcmp(l, "DRIVE BAY A INTAKE"))
20975722d39SBenjamin Herrenschmidt 		fct->ctrl.name = "drive-bay-fan";
210*ac171c46SBenjamin Herrenschmidt 	else if (!strcmp(l, "BACKSIDE"))
211*ac171c46SBenjamin Herrenschmidt 		fct->ctrl.name = "backside-fan";
21275722d39SBenjamin Herrenschmidt 
21375722d39SBenjamin Herrenschmidt 	/* Names used on iMac models */
21475722d39SBenjamin Herrenschmidt 	if (!strcmp(l, "System Fan") || !strcmp(l, "System fan"))
21575722d39SBenjamin Herrenschmidt 		fct->ctrl.name = "system-fan";
21675722d39SBenjamin Herrenschmidt 	else if (!strcmp(l, "CPU Fan") || !strcmp(l, "CPU fan"))
21775722d39SBenjamin Herrenschmidt 		fct->ctrl.name = "cpu-fan";
21875722d39SBenjamin Herrenschmidt 	else if (!strcmp(l, "Hard Drive") || !strcmp(l, "Hard drive"))
21975722d39SBenjamin Herrenschmidt 		fct->ctrl.name = "drive-bay-fan";
22075722d39SBenjamin Herrenschmidt 
22175722d39SBenjamin Herrenschmidt 	/* Unrecognized fan, bail out */
22275722d39SBenjamin Herrenschmidt 	if (fct->ctrl.name == NULL)
22375722d39SBenjamin Herrenschmidt 		goto fail;
22475722d39SBenjamin Herrenschmidt 
22575722d39SBenjamin Herrenschmidt 	/* Get min & max values*/
22675722d39SBenjamin Herrenschmidt 	v = (s32 *)get_property(node, "min-value", NULL);
22775722d39SBenjamin Herrenschmidt 	if (v == NULL)
22875722d39SBenjamin Herrenschmidt 		goto fail;
22975722d39SBenjamin Herrenschmidt 	fct->min = *v;
23075722d39SBenjamin Herrenschmidt 	v = (s32 *)get_property(node, "max-value", NULL);
23175722d39SBenjamin Herrenschmidt 	if (v == NULL)
23275722d39SBenjamin Herrenschmidt 		goto fail;
23375722d39SBenjamin Herrenschmidt 	fct->max = *v;
23475722d39SBenjamin Herrenschmidt 
23575722d39SBenjamin Herrenschmidt 	/* Get "reg" value */
23675722d39SBenjamin Herrenschmidt 	reg = (u32 *)get_property(node, "reg", NULL);
23775722d39SBenjamin Herrenschmidt 	if (reg == NULL)
23875722d39SBenjamin Herrenschmidt 		goto fail;
23975722d39SBenjamin Herrenschmidt 	fct->reg = *reg;
24075722d39SBenjamin Herrenschmidt 
24175722d39SBenjamin Herrenschmidt 	if (wf_register_control(&fct->ctrl))
24275722d39SBenjamin Herrenschmidt 		goto fail;
24375722d39SBenjamin Herrenschmidt 
24475722d39SBenjamin Herrenschmidt 	return fct;
24575722d39SBenjamin Herrenschmidt  fail:
24675722d39SBenjamin Herrenschmidt 	kfree(fct);
24775722d39SBenjamin Herrenschmidt 	return NULL;
24875722d39SBenjamin Herrenschmidt }
24975722d39SBenjamin Herrenschmidt 
25075722d39SBenjamin Herrenschmidt 
25175722d39SBenjamin Herrenschmidt static int __init smu_controls_init(void)
25275722d39SBenjamin Herrenschmidt {
25375722d39SBenjamin Herrenschmidt 	struct device_node *smu, *fans, *fan;
25475722d39SBenjamin Herrenschmidt 
25575722d39SBenjamin Herrenschmidt 	if (!smu_present())
25675722d39SBenjamin Herrenschmidt 		return -ENODEV;
25775722d39SBenjamin Herrenschmidt 
25875722d39SBenjamin Herrenschmidt 	smu = of_find_node_by_type(NULL, "smu");
25975722d39SBenjamin Herrenschmidt 	if (smu == NULL)
26075722d39SBenjamin Herrenschmidt 		return -ENODEV;
26175722d39SBenjamin Herrenschmidt 
26275722d39SBenjamin Herrenschmidt 	/* Look for RPM fans */
26375722d39SBenjamin Herrenschmidt 	for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;)
264*ac171c46SBenjamin Herrenschmidt 		if (!strcmp(fans->name, "rpm-fans") ||
265*ac171c46SBenjamin Herrenschmidt 		    device_is_compatible(fans, "smu-rpm-fans"))
26675722d39SBenjamin Herrenschmidt 			break;
26775722d39SBenjamin Herrenschmidt 	for (fan = NULL;
26875722d39SBenjamin Herrenschmidt 	     fans && (fan = of_get_next_child(fans, fan)) != NULL;) {
26975722d39SBenjamin Herrenschmidt 		struct smu_fan_control *fct;
27075722d39SBenjamin Herrenschmidt 
27175722d39SBenjamin Herrenschmidt 		fct = smu_fan_create(fan, 0);
27275722d39SBenjamin Herrenschmidt 		if (fct == NULL) {
27375722d39SBenjamin Herrenschmidt 			printk(KERN_WARNING "windfarm: Failed to create SMU "
27475722d39SBenjamin Herrenschmidt 			       "RPM fan %s\n", fan->name);
27575722d39SBenjamin Herrenschmidt 			continue;
27675722d39SBenjamin Herrenschmidt 		}
27775722d39SBenjamin Herrenschmidt 		list_add(&fct->link, &smu_fans);
27875722d39SBenjamin Herrenschmidt 	}
27975722d39SBenjamin Herrenschmidt 	of_node_put(fans);
28075722d39SBenjamin Herrenschmidt 
28175722d39SBenjamin Herrenschmidt 
28275722d39SBenjamin Herrenschmidt 	/* Look for PWM fans */
28375722d39SBenjamin Herrenschmidt 	for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;)
28475722d39SBenjamin Herrenschmidt 		if (!strcmp(fans->name, "pwm-fans"))
28575722d39SBenjamin Herrenschmidt 			break;
28675722d39SBenjamin Herrenschmidt 	for (fan = NULL;
28775722d39SBenjamin Herrenschmidt 	     fans && (fan = of_get_next_child(fans, fan)) != NULL;) {
28875722d39SBenjamin Herrenschmidt 		struct smu_fan_control *fct;
28975722d39SBenjamin Herrenschmidt 
29075722d39SBenjamin Herrenschmidt 		fct = smu_fan_create(fan, 1);
29175722d39SBenjamin Herrenschmidt 		if (fct == NULL) {
29275722d39SBenjamin Herrenschmidt 			printk(KERN_WARNING "windfarm: Failed to create SMU "
29375722d39SBenjamin Herrenschmidt 			       "PWM fan %s\n", fan->name);
29475722d39SBenjamin Herrenschmidt 			continue;
29575722d39SBenjamin Herrenschmidt 		}
29675722d39SBenjamin Herrenschmidt 		list_add(&fct->link, &smu_fans);
29775722d39SBenjamin Herrenschmidt 	}
29875722d39SBenjamin Herrenschmidt 	of_node_put(fans);
29975722d39SBenjamin Herrenschmidt 	of_node_put(smu);
30075722d39SBenjamin Herrenschmidt 
30175722d39SBenjamin Herrenschmidt 	return 0;
30275722d39SBenjamin Herrenschmidt }
30375722d39SBenjamin Herrenschmidt 
30475722d39SBenjamin Herrenschmidt static void __exit smu_controls_exit(void)
30575722d39SBenjamin Herrenschmidt {
30675722d39SBenjamin Herrenschmidt 	struct smu_fan_control *fct;
30775722d39SBenjamin Herrenschmidt 
30875722d39SBenjamin Herrenschmidt 	while (!list_empty(&smu_fans)) {
30975722d39SBenjamin Herrenschmidt 		fct = list_entry(smu_fans.next, struct smu_fan_control, link);
31075722d39SBenjamin Herrenschmidt 		list_del(&fct->link);
31175722d39SBenjamin Herrenschmidt 		wf_unregister_control(&fct->ctrl);
31275722d39SBenjamin Herrenschmidt 	}
31375722d39SBenjamin Herrenschmidt }
31475722d39SBenjamin Herrenschmidt 
31575722d39SBenjamin Herrenschmidt 
31675722d39SBenjamin Herrenschmidt module_init(smu_controls_init);
31775722d39SBenjamin Herrenschmidt module_exit(smu_controls_exit);
31875722d39SBenjamin Herrenschmidt 
31975722d39SBenjamin Herrenschmidt MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
32075722d39SBenjamin Herrenschmidt MODULE_DESCRIPTION("SMU control objects for PowerMacs thermal control");
32175722d39SBenjamin Herrenschmidt MODULE_LICENSE("GPL");
32275722d39SBenjamin Herrenschmidt 
323