12c162f9bSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2a78a4a03SBenjamin Herrenschmidt /*
3a78a4a03SBenjamin Herrenschmidt * Windfarm PowerMac thermal control. FCU fan control
4a78a4a03SBenjamin Herrenschmidt *
5a78a4a03SBenjamin Herrenschmidt * Copyright 2012 Benjamin Herrenschmidt, IBM Corp.
6a78a4a03SBenjamin Herrenschmidt */
7a78a4a03SBenjamin Herrenschmidt #undef DEBUG
8a78a4a03SBenjamin Herrenschmidt
9a78a4a03SBenjamin Herrenschmidt #include <linux/types.h>
10a78a4a03SBenjamin Herrenschmidt #include <linux/errno.h>
11a78a4a03SBenjamin Herrenschmidt #include <linux/kernel.h>
12a78a4a03SBenjamin Herrenschmidt #include <linux/delay.h>
13a78a4a03SBenjamin Herrenschmidt #include <linux/slab.h>
14a78a4a03SBenjamin Herrenschmidt #include <linux/init.h>
15a78a4a03SBenjamin Herrenschmidt #include <linux/wait.h>
16a78a4a03SBenjamin Herrenschmidt #include <linux/i2c.h>
17a486e512SChristophe Leroy
18a78a4a03SBenjamin Herrenschmidt #include <asm/machdep.h>
19a78a4a03SBenjamin Herrenschmidt #include <asm/io.h>
20a78a4a03SBenjamin Herrenschmidt #include <asm/sections.h>
21a78a4a03SBenjamin Herrenschmidt
22a78a4a03SBenjamin Herrenschmidt #include "windfarm.h"
23a78a4a03SBenjamin Herrenschmidt #include "windfarm_mpu.h"
24a78a4a03SBenjamin Herrenschmidt
25a78a4a03SBenjamin Herrenschmidt #define VERSION "1.0"
26a78a4a03SBenjamin Herrenschmidt
27a78a4a03SBenjamin Herrenschmidt #ifdef DEBUG
28a78a4a03SBenjamin Herrenschmidt #define DBG(args...) printk(args)
29a78a4a03SBenjamin Herrenschmidt #else
30a78a4a03SBenjamin Herrenschmidt #define DBG(args...) do { } while(0)
31a78a4a03SBenjamin Herrenschmidt #endif
32a78a4a03SBenjamin Herrenschmidt
33a78a4a03SBenjamin Herrenschmidt /*
34a78a4a03SBenjamin Herrenschmidt * This option is "weird" :) Basically, if you define this to 1
35a78a4a03SBenjamin Herrenschmidt * the control loop for the RPMs fans (not PWMs) will apply the
36a78a4a03SBenjamin Herrenschmidt * correction factor obtained from the PID to the actual RPM
37a78a4a03SBenjamin Herrenschmidt * speed read from the FCU.
38a78a4a03SBenjamin Herrenschmidt *
39a78a4a03SBenjamin Herrenschmidt * If you define the below constant to 0, then it will be
40a78a4a03SBenjamin Herrenschmidt * applied to the setpoint RPM speed, that is basically the
41a78a4a03SBenjamin Herrenschmidt * speed we proviously "asked" for.
42a78a4a03SBenjamin Herrenschmidt *
436cd32099SBenjamin Herrenschmidt * I'm using 0 for now which is what therm_pm72 used to do and
446cd32099SBenjamin Herrenschmidt * what Darwin -apparently- does based on observed behaviour.
45a78a4a03SBenjamin Herrenschmidt */
466cd32099SBenjamin Herrenschmidt #define RPM_PID_USE_ACTUAL_SPEED 0
47a78a4a03SBenjamin Herrenschmidt
48a78a4a03SBenjamin Herrenschmidt /* Default min/max for pumps */
49a78a4a03SBenjamin Herrenschmidt #define CPU_PUMP_OUTPUT_MAX 3200
50a78a4a03SBenjamin Herrenschmidt #define CPU_PUMP_OUTPUT_MIN 1250
51a78a4a03SBenjamin Herrenschmidt
52a78a4a03SBenjamin Herrenschmidt #define FCU_FAN_RPM 0
53a78a4a03SBenjamin Herrenschmidt #define FCU_FAN_PWM 1
54a78a4a03SBenjamin Herrenschmidt
55a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv {
56a78a4a03SBenjamin Herrenschmidt struct kref ref;
57a78a4a03SBenjamin Herrenschmidt struct i2c_client *i2c;
58a78a4a03SBenjamin Herrenschmidt struct mutex lock;
59a78a4a03SBenjamin Herrenschmidt struct list_head fan_list;
60a78a4a03SBenjamin Herrenschmidt int rpm_shift;
61a78a4a03SBenjamin Herrenschmidt };
62a78a4a03SBenjamin Herrenschmidt
63a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan {
64a78a4a03SBenjamin Herrenschmidt struct list_head link;
65a78a4a03SBenjamin Herrenschmidt int id;
66a78a4a03SBenjamin Herrenschmidt s32 min, max, target;
67a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv *fcu_priv;
68a78a4a03SBenjamin Herrenschmidt struct wf_control ctrl;
69a78a4a03SBenjamin Herrenschmidt };
70a78a4a03SBenjamin Herrenschmidt
wf_fcu_release(struct kref * ref)71a78a4a03SBenjamin Herrenschmidt static void wf_fcu_release(struct kref *ref)
72a78a4a03SBenjamin Herrenschmidt {
73a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv *pv = container_of(ref, struct wf_fcu_priv, ref);
74a78a4a03SBenjamin Herrenschmidt
75a78a4a03SBenjamin Herrenschmidt kfree(pv);
76a78a4a03SBenjamin Herrenschmidt }
77a78a4a03SBenjamin Herrenschmidt
wf_fcu_fan_release(struct wf_control * ct)78a78a4a03SBenjamin Herrenschmidt static void wf_fcu_fan_release(struct wf_control *ct)
79a78a4a03SBenjamin Herrenschmidt {
80a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan *fan = ct->priv;
81a78a4a03SBenjamin Herrenschmidt
82a78a4a03SBenjamin Herrenschmidt kref_put(&fan->fcu_priv->ref, wf_fcu_release);
83a78a4a03SBenjamin Herrenschmidt kfree(fan);
84a78a4a03SBenjamin Herrenschmidt }
85a78a4a03SBenjamin Herrenschmidt
wf_fcu_read_reg(struct wf_fcu_priv * pv,int reg,unsigned char * buf,int nb)86a78a4a03SBenjamin Herrenschmidt static int wf_fcu_read_reg(struct wf_fcu_priv *pv, int reg,
87a78a4a03SBenjamin Herrenschmidt unsigned char *buf, int nb)
88a78a4a03SBenjamin Herrenschmidt {
89a78a4a03SBenjamin Herrenschmidt int tries, nr, nw;
90a78a4a03SBenjamin Herrenschmidt
91a78a4a03SBenjamin Herrenschmidt mutex_lock(&pv->lock);
92a78a4a03SBenjamin Herrenschmidt
93a78a4a03SBenjamin Herrenschmidt buf[0] = reg;
94a78a4a03SBenjamin Herrenschmidt tries = 0;
95a78a4a03SBenjamin Herrenschmidt for (;;) {
96a78a4a03SBenjamin Herrenschmidt nw = i2c_master_send(pv->i2c, buf, 1);
97a78a4a03SBenjamin Herrenschmidt if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
98a78a4a03SBenjamin Herrenschmidt break;
99a78a4a03SBenjamin Herrenschmidt msleep(10);
100a78a4a03SBenjamin Herrenschmidt ++tries;
101a78a4a03SBenjamin Herrenschmidt }
102a78a4a03SBenjamin Herrenschmidt if (nw <= 0) {
103a78a4a03SBenjamin Herrenschmidt pr_err("Failure writing address to FCU: %d", nw);
104a78a4a03SBenjamin Herrenschmidt nr = nw;
105a78a4a03SBenjamin Herrenschmidt goto bail;
106a78a4a03SBenjamin Herrenschmidt }
107a78a4a03SBenjamin Herrenschmidt tries = 0;
108a78a4a03SBenjamin Herrenschmidt for (;;) {
109a78a4a03SBenjamin Herrenschmidt nr = i2c_master_recv(pv->i2c, buf, nb);
110a78a4a03SBenjamin Herrenschmidt if (nr > 0 || (nr < 0 && nr != -ENODEV) || tries >= 100)
111a78a4a03SBenjamin Herrenschmidt break;
112a78a4a03SBenjamin Herrenschmidt msleep(10);
113a78a4a03SBenjamin Herrenschmidt ++tries;
114a78a4a03SBenjamin Herrenschmidt }
115a78a4a03SBenjamin Herrenschmidt if (nr <= 0)
116a78a4a03SBenjamin Herrenschmidt pr_err("wf_fcu: Failure reading data from FCU: %d", nw);
117a78a4a03SBenjamin Herrenschmidt bail:
118a78a4a03SBenjamin Herrenschmidt mutex_unlock(&pv->lock);
119a78a4a03SBenjamin Herrenschmidt return nr;
120a78a4a03SBenjamin Herrenschmidt }
121a78a4a03SBenjamin Herrenschmidt
wf_fcu_write_reg(struct wf_fcu_priv * pv,int reg,const unsigned char * ptr,int nb)122a78a4a03SBenjamin Herrenschmidt static int wf_fcu_write_reg(struct wf_fcu_priv *pv, int reg,
123a78a4a03SBenjamin Herrenschmidt const unsigned char *ptr, int nb)
124a78a4a03SBenjamin Herrenschmidt {
125a78a4a03SBenjamin Herrenschmidt int tries, nw;
126a78a4a03SBenjamin Herrenschmidt unsigned char buf[16];
127a78a4a03SBenjamin Herrenschmidt
128a78a4a03SBenjamin Herrenschmidt buf[0] = reg;
129a78a4a03SBenjamin Herrenschmidt memcpy(buf+1, ptr, nb);
130a78a4a03SBenjamin Herrenschmidt ++nb;
131a78a4a03SBenjamin Herrenschmidt tries = 0;
132a78a4a03SBenjamin Herrenschmidt for (;;) {
133a78a4a03SBenjamin Herrenschmidt nw = i2c_master_send(pv->i2c, buf, nb);
134a78a4a03SBenjamin Herrenschmidt if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
135a78a4a03SBenjamin Herrenschmidt break;
136a78a4a03SBenjamin Herrenschmidt msleep(10);
137a78a4a03SBenjamin Herrenschmidt ++tries;
138a78a4a03SBenjamin Herrenschmidt }
139a78a4a03SBenjamin Herrenschmidt if (nw < 0)
140a78a4a03SBenjamin Herrenschmidt pr_err("wf_fcu: Failure writing to FCU: %d", nw);
141a78a4a03SBenjamin Herrenschmidt return nw;
142a78a4a03SBenjamin Herrenschmidt }
143a78a4a03SBenjamin Herrenschmidt
wf_fcu_fan_set_rpm(struct wf_control * ct,s32 value)144a78a4a03SBenjamin Herrenschmidt static int wf_fcu_fan_set_rpm(struct wf_control *ct, s32 value)
145a78a4a03SBenjamin Herrenschmidt {
146a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan *fan = ct->priv;
147a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv *pv = fan->fcu_priv;
148a78a4a03SBenjamin Herrenschmidt int rc, shift = pv->rpm_shift;
149a78a4a03SBenjamin Herrenschmidt unsigned char buf[2];
150a78a4a03SBenjamin Herrenschmidt
151a78a4a03SBenjamin Herrenschmidt if (value < fan->min)
152a78a4a03SBenjamin Herrenschmidt value = fan->min;
153a78a4a03SBenjamin Herrenschmidt if (value > fan->max)
154a78a4a03SBenjamin Herrenschmidt value = fan->max;
155a78a4a03SBenjamin Herrenschmidt
156a78a4a03SBenjamin Herrenschmidt fan->target = value;
157a78a4a03SBenjamin Herrenschmidt
158a78a4a03SBenjamin Herrenschmidt buf[0] = value >> (8 - shift);
159a78a4a03SBenjamin Herrenschmidt buf[1] = value << shift;
160a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_write_reg(pv, 0x10 + (fan->id * 2), buf, 2);
161a78a4a03SBenjamin Herrenschmidt if (rc < 0)
162a78a4a03SBenjamin Herrenschmidt return -EIO;
163a78a4a03SBenjamin Herrenschmidt return 0;
164a78a4a03SBenjamin Herrenschmidt }
165a78a4a03SBenjamin Herrenschmidt
wf_fcu_fan_get_rpm(struct wf_control * ct,s32 * value)166a78a4a03SBenjamin Herrenschmidt static int wf_fcu_fan_get_rpm(struct wf_control *ct, s32 *value)
167a78a4a03SBenjamin Herrenschmidt {
168a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan *fan = ct->priv;
169a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv *pv = fan->fcu_priv;
170a78a4a03SBenjamin Herrenschmidt int rc, reg_base, shift = pv->rpm_shift;
171a78a4a03SBenjamin Herrenschmidt unsigned char failure;
172a78a4a03SBenjamin Herrenschmidt unsigned char active;
173a78a4a03SBenjamin Herrenschmidt unsigned char buf[2];
174a78a4a03SBenjamin Herrenschmidt
175a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_read_reg(pv, 0xb, &failure, 1);
176a78a4a03SBenjamin Herrenschmidt if (rc != 1)
177a78a4a03SBenjamin Herrenschmidt return -EIO;
178a78a4a03SBenjamin Herrenschmidt if ((failure & (1 << fan->id)) != 0)
179a78a4a03SBenjamin Herrenschmidt return -EFAULT;
180a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_read_reg(pv, 0xd, &active, 1);
181a78a4a03SBenjamin Herrenschmidt if (rc != 1)
182a78a4a03SBenjamin Herrenschmidt return -EIO;
183a78a4a03SBenjamin Herrenschmidt if ((active & (1 << fan->id)) == 0)
184a78a4a03SBenjamin Herrenschmidt return -ENXIO;
185a78a4a03SBenjamin Herrenschmidt
186a78a4a03SBenjamin Herrenschmidt /* Programmed value or real current speed */
187a78a4a03SBenjamin Herrenschmidt #if RPM_PID_USE_ACTUAL_SPEED
188a78a4a03SBenjamin Herrenschmidt reg_base = 0x11;
189a78a4a03SBenjamin Herrenschmidt #else
190a78a4a03SBenjamin Herrenschmidt reg_base = 0x10;
191a78a4a03SBenjamin Herrenschmidt #endif
192a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_read_reg(pv, reg_base + (fan->id * 2), buf, 2);
193a78a4a03SBenjamin Herrenschmidt if (rc != 2)
194a78a4a03SBenjamin Herrenschmidt return -EIO;
195a78a4a03SBenjamin Herrenschmidt
196a78a4a03SBenjamin Herrenschmidt *value = (buf[0] << (8 - shift)) | buf[1] >> shift;
197a78a4a03SBenjamin Herrenschmidt
198a78a4a03SBenjamin Herrenschmidt return 0;
199a78a4a03SBenjamin Herrenschmidt }
200a78a4a03SBenjamin Herrenschmidt
wf_fcu_fan_set_pwm(struct wf_control * ct,s32 value)201a78a4a03SBenjamin Herrenschmidt static int wf_fcu_fan_set_pwm(struct wf_control *ct, s32 value)
202a78a4a03SBenjamin Herrenschmidt {
203a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan *fan = ct->priv;
204a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv *pv = fan->fcu_priv;
205a78a4a03SBenjamin Herrenschmidt unsigned char buf[2];
206a78a4a03SBenjamin Herrenschmidt int rc;
207a78a4a03SBenjamin Herrenschmidt
208a78a4a03SBenjamin Herrenschmidt if (value < fan->min)
209a78a4a03SBenjamin Herrenschmidt value = fan->min;
210a78a4a03SBenjamin Herrenschmidt if (value > fan->max)
211a78a4a03SBenjamin Herrenschmidt value = fan->max;
212a78a4a03SBenjamin Herrenschmidt
213a78a4a03SBenjamin Herrenschmidt fan->target = value;
214a78a4a03SBenjamin Herrenschmidt
215a78a4a03SBenjamin Herrenschmidt value = (value * 2559) / 1000;
216a78a4a03SBenjamin Herrenschmidt buf[0] = value;
217a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_write_reg(pv, 0x30 + (fan->id * 2), buf, 1);
218a78a4a03SBenjamin Herrenschmidt if (rc < 0)
219a78a4a03SBenjamin Herrenschmidt return -EIO;
220a78a4a03SBenjamin Herrenschmidt return 0;
221a78a4a03SBenjamin Herrenschmidt }
222a78a4a03SBenjamin Herrenschmidt
wf_fcu_fan_get_pwm(struct wf_control * ct,s32 * value)223a78a4a03SBenjamin Herrenschmidt static int wf_fcu_fan_get_pwm(struct wf_control *ct, s32 *value)
224a78a4a03SBenjamin Herrenschmidt {
225a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan *fan = ct->priv;
226a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv *pv = fan->fcu_priv;
227a78a4a03SBenjamin Herrenschmidt unsigned char failure;
228a78a4a03SBenjamin Herrenschmidt unsigned char active;
229a78a4a03SBenjamin Herrenschmidt unsigned char buf[2];
230a78a4a03SBenjamin Herrenschmidt int rc;
231a78a4a03SBenjamin Herrenschmidt
232a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_read_reg(pv, 0x2b, &failure, 1);
233a78a4a03SBenjamin Herrenschmidt if (rc != 1)
234a78a4a03SBenjamin Herrenschmidt return -EIO;
235a78a4a03SBenjamin Herrenschmidt if ((failure & (1 << fan->id)) != 0)
236a78a4a03SBenjamin Herrenschmidt return -EFAULT;
237a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_read_reg(pv, 0x2d, &active, 1);
238a78a4a03SBenjamin Herrenschmidt if (rc != 1)
239a78a4a03SBenjamin Herrenschmidt return -EIO;
240a78a4a03SBenjamin Herrenschmidt if ((active & (1 << fan->id)) == 0)
241a78a4a03SBenjamin Herrenschmidt return -ENXIO;
242a78a4a03SBenjamin Herrenschmidt
243a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_read_reg(pv, 0x30 + (fan->id * 2), buf, 1);
244a78a4a03SBenjamin Herrenschmidt if (rc != 1)
245a78a4a03SBenjamin Herrenschmidt return -EIO;
246a78a4a03SBenjamin Herrenschmidt
247a78a4a03SBenjamin Herrenschmidt *value = (((s32)buf[0]) * 1000) / 2559;
248a78a4a03SBenjamin Herrenschmidt
249a78a4a03SBenjamin Herrenschmidt return 0;
250a78a4a03SBenjamin Herrenschmidt }
251a78a4a03SBenjamin Herrenschmidt
wf_fcu_fan_min(struct wf_control * ct)252a78a4a03SBenjamin Herrenschmidt static s32 wf_fcu_fan_min(struct wf_control *ct)
253a78a4a03SBenjamin Herrenschmidt {
254a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan *fan = ct->priv;
255a78a4a03SBenjamin Herrenschmidt
256a78a4a03SBenjamin Herrenschmidt return fan->min;
257a78a4a03SBenjamin Herrenschmidt }
258a78a4a03SBenjamin Herrenschmidt
wf_fcu_fan_max(struct wf_control * ct)259a78a4a03SBenjamin Herrenschmidt static s32 wf_fcu_fan_max(struct wf_control *ct)
260a78a4a03SBenjamin Herrenschmidt {
261a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan *fan = ct->priv;
262a78a4a03SBenjamin Herrenschmidt
263a78a4a03SBenjamin Herrenschmidt return fan->max;
264a78a4a03SBenjamin Herrenschmidt }
265a78a4a03SBenjamin Herrenschmidt
266a78a4a03SBenjamin Herrenschmidt static const struct wf_control_ops wf_fcu_fan_rpm_ops = {
267a78a4a03SBenjamin Herrenschmidt .set_value = wf_fcu_fan_set_rpm,
268a78a4a03SBenjamin Herrenschmidt .get_value = wf_fcu_fan_get_rpm,
269a78a4a03SBenjamin Herrenschmidt .get_min = wf_fcu_fan_min,
270a78a4a03SBenjamin Herrenschmidt .get_max = wf_fcu_fan_max,
271a78a4a03SBenjamin Herrenschmidt .release = wf_fcu_fan_release,
272a78a4a03SBenjamin Herrenschmidt .owner = THIS_MODULE,
273a78a4a03SBenjamin Herrenschmidt };
274a78a4a03SBenjamin Herrenschmidt
275a78a4a03SBenjamin Herrenschmidt static const struct wf_control_ops wf_fcu_fan_pwm_ops = {
276a78a4a03SBenjamin Herrenschmidt .set_value = wf_fcu_fan_set_pwm,
277a78a4a03SBenjamin Herrenschmidt .get_value = wf_fcu_fan_get_pwm,
278a78a4a03SBenjamin Herrenschmidt .get_min = wf_fcu_fan_min,
279a78a4a03SBenjamin Herrenschmidt .get_max = wf_fcu_fan_max,
280a78a4a03SBenjamin Herrenschmidt .release = wf_fcu_fan_release,
281a78a4a03SBenjamin Herrenschmidt .owner = THIS_MODULE,
282a78a4a03SBenjamin Herrenschmidt };
283a78a4a03SBenjamin Herrenschmidt
wf_fcu_get_pump_minmax(struct wf_fcu_fan * fan)2841da42fb6SGreg Kroah-Hartman static void wf_fcu_get_pump_minmax(struct wf_fcu_fan *fan)
285a78a4a03SBenjamin Herrenschmidt {
286a78a4a03SBenjamin Herrenschmidt const struct mpu_data *mpu = wf_get_mpu(0);
287a78a4a03SBenjamin Herrenschmidt u16 pump_min = 0, pump_max = 0xffff;
288a78a4a03SBenjamin Herrenschmidt u16 tmp[4];
289a78a4a03SBenjamin Herrenschmidt
290a78a4a03SBenjamin Herrenschmidt /* Try to fetch pumps min/max infos from eeprom */
291a78a4a03SBenjamin Herrenschmidt if (mpu) {
292a78a4a03SBenjamin Herrenschmidt memcpy(&tmp, mpu->processor_part_num, 8);
293a78a4a03SBenjamin Herrenschmidt if (tmp[0] != 0xffff && tmp[1] != 0xffff) {
294a78a4a03SBenjamin Herrenschmidt pump_min = max(pump_min, tmp[0]);
295a78a4a03SBenjamin Herrenschmidt pump_max = min(pump_max, tmp[1]);
296a78a4a03SBenjamin Herrenschmidt }
297a78a4a03SBenjamin Herrenschmidt if (tmp[2] != 0xffff && tmp[3] != 0xffff) {
298a78a4a03SBenjamin Herrenschmidt pump_min = max(pump_min, tmp[2]);
299a78a4a03SBenjamin Herrenschmidt pump_max = min(pump_max, tmp[3]);
300a78a4a03SBenjamin Herrenschmidt }
301a78a4a03SBenjamin Herrenschmidt }
302a78a4a03SBenjamin Herrenschmidt
303a78a4a03SBenjamin Herrenschmidt /* Double check the values, this _IS_ needed as the EEPROM on
304a78a4a03SBenjamin Herrenschmidt * some dual 2.5Ghz G5s seem, at least, to have both min & max
305a78a4a03SBenjamin Herrenschmidt * same to the same value ... (grrrr)
306a78a4a03SBenjamin Herrenschmidt */
307a78a4a03SBenjamin Herrenschmidt if (pump_min == pump_max || pump_min == 0 || pump_max == 0xffff) {
308a78a4a03SBenjamin Herrenschmidt pump_min = CPU_PUMP_OUTPUT_MIN;
309a78a4a03SBenjamin Herrenschmidt pump_max = CPU_PUMP_OUTPUT_MAX;
310a78a4a03SBenjamin Herrenschmidt }
311a78a4a03SBenjamin Herrenschmidt
312a78a4a03SBenjamin Herrenschmidt fan->min = pump_min;
313a78a4a03SBenjamin Herrenschmidt fan->max = pump_max;
314a78a4a03SBenjamin Herrenschmidt
315a78a4a03SBenjamin Herrenschmidt DBG("wf_fcu: pump min/max for %s set to: [%d..%d] RPM\n",
316a78a4a03SBenjamin Herrenschmidt fan->ctrl.name, pump_min, pump_max);
317a78a4a03SBenjamin Herrenschmidt }
318a78a4a03SBenjamin Herrenschmidt
wf_fcu_get_rpmfan_minmax(struct wf_fcu_fan * fan)3191da42fb6SGreg Kroah-Hartman static void wf_fcu_get_rpmfan_minmax(struct wf_fcu_fan *fan)
320a78a4a03SBenjamin Herrenschmidt {
321a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv *pv = fan->fcu_priv;
322a78a4a03SBenjamin Herrenschmidt const struct mpu_data *mpu0 = wf_get_mpu(0);
323a78a4a03SBenjamin Herrenschmidt const struct mpu_data *mpu1 = wf_get_mpu(1);
324a78a4a03SBenjamin Herrenschmidt
325a78a4a03SBenjamin Herrenschmidt /* Default */
326a78a4a03SBenjamin Herrenschmidt fan->min = 2400 >> pv->rpm_shift;
327a78a4a03SBenjamin Herrenschmidt fan->max = 56000 >> pv->rpm_shift;
328a78a4a03SBenjamin Herrenschmidt
329a78a4a03SBenjamin Herrenschmidt /* CPU fans have min/max in MPU */
330a78a4a03SBenjamin Herrenschmidt if (mpu0 && !strcmp(fan->ctrl.name, "cpu-front-fan-0")) {
331a78a4a03SBenjamin Herrenschmidt fan->min = max(fan->min, (s32)mpu0->rminn_intake_fan);
332a78a4a03SBenjamin Herrenschmidt fan->max = min(fan->max, (s32)mpu0->rmaxn_intake_fan);
333a78a4a03SBenjamin Herrenschmidt goto bail;
334a78a4a03SBenjamin Herrenschmidt }
335a78a4a03SBenjamin Herrenschmidt if (mpu1 && !strcmp(fan->ctrl.name, "cpu-front-fan-1")) {
336a78a4a03SBenjamin Herrenschmidt fan->min = max(fan->min, (s32)mpu1->rminn_intake_fan);
337a78a4a03SBenjamin Herrenschmidt fan->max = min(fan->max, (s32)mpu1->rmaxn_intake_fan);
338a78a4a03SBenjamin Herrenschmidt goto bail;
339a78a4a03SBenjamin Herrenschmidt }
340a78a4a03SBenjamin Herrenschmidt if (mpu0 && !strcmp(fan->ctrl.name, "cpu-rear-fan-0")) {
341a78a4a03SBenjamin Herrenschmidt fan->min = max(fan->min, (s32)mpu0->rminn_exhaust_fan);
342a78a4a03SBenjamin Herrenschmidt fan->max = min(fan->max, (s32)mpu0->rmaxn_exhaust_fan);
343a78a4a03SBenjamin Herrenschmidt goto bail;
344a78a4a03SBenjamin Herrenschmidt }
345a78a4a03SBenjamin Herrenschmidt if (mpu1 && !strcmp(fan->ctrl.name, "cpu-rear-fan-1")) {
346a78a4a03SBenjamin Herrenschmidt fan->min = max(fan->min, (s32)mpu1->rminn_exhaust_fan);
347a78a4a03SBenjamin Herrenschmidt fan->max = min(fan->max, (s32)mpu1->rmaxn_exhaust_fan);
348a78a4a03SBenjamin Herrenschmidt goto bail;
349a78a4a03SBenjamin Herrenschmidt }
350a78a4a03SBenjamin Herrenschmidt /* Rackmac variants, we just use mpu0 intake */
351a78a4a03SBenjamin Herrenschmidt if (!strncmp(fan->ctrl.name, "cpu-fan", 7)) {
352a78a4a03SBenjamin Herrenschmidt fan->min = max(fan->min, (s32)mpu0->rminn_intake_fan);
353a78a4a03SBenjamin Herrenschmidt fan->max = min(fan->max, (s32)mpu0->rmaxn_intake_fan);
354a78a4a03SBenjamin Herrenschmidt goto bail;
355a78a4a03SBenjamin Herrenschmidt }
356a78a4a03SBenjamin Herrenschmidt bail:
357a78a4a03SBenjamin Herrenschmidt DBG("wf_fcu: fan min/max for %s set to: [%d..%d] RPM\n",
358a78a4a03SBenjamin Herrenschmidt fan->ctrl.name, fan->min, fan->max);
359a78a4a03SBenjamin Herrenschmidt }
360a78a4a03SBenjamin Herrenschmidt
wf_fcu_add_fan(struct wf_fcu_priv * pv,const char * name,int type,int id)3611da42fb6SGreg Kroah-Hartman static void wf_fcu_add_fan(struct wf_fcu_priv *pv, const char *name,
362a78a4a03SBenjamin Herrenschmidt int type, int id)
363a78a4a03SBenjamin Herrenschmidt {
364a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan *fan;
365a78a4a03SBenjamin Herrenschmidt
366a78a4a03SBenjamin Herrenschmidt fan = kzalloc(sizeof(*fan), GFP_KERNEL);
367a78a4a03SBenjamin Herrenschmidt if (!fan)
368a78a4a03SBenjamin Herrenschmidt return;
369a78a4a03SBenjamin Herrenschmidt fan->fcu_priv = pv;
370a78a4a03SBenjamin Herrenschmidt fan->id = id;
371a78a4a03SBenjamin Herrenschmidt fan->ctrl.name = name;
372a78a4a03SBenjamin Herrenschmidt fan->ctrl.priv = fan;
373a78a4a03SBenjamin Herrenschmidt
374a78a4a03SBenjamin Herrenschmidt /* min/max is oddball but the code comes from
375a78a4a03SBenjamin Herrenschmidt * therm_pm72 which seems to work so ...
376a78a4a03SBenjamin Herrenschmidt */
377a78a4a03SBenjamin Herrenschmidt if (type == FCU_FAN_RPM) {
378a78a4a03SBenjamin Herrenschmidt if (!strncmp(name, "cpu-pump", strlen("cpu-pump")))
379a78a4a03SBenjamin Herrenschmidt wf_fcu_get_pump_minmax(fan);
380a78a4a03SBenjamin Herrenschmidt else
381a78a4a03SBenjamin Herrenschmidt wf_fcu_get_rpmfan_minmax(fan);
382a78a4a03SBenjamin Herrenschmidt fan->ctrl.type = WF_CONTROL_RPM_FAN;
383a78a4a03SBenjamin Herrenschmidt fan->ctrl.ops = &wf_fcu_fan_rpm_ops;
384a78a4a03SBenjamin Herrenschmidt } else {
385a78a4a03SBenjamin Herrenschmidt fan->min = 10;
386a78a4a03SBenjamin Herrenschmidt fan->max = 100;
387a78a4a03SBenjamin Herrenschmidt fan->ctrl.type = WF_CONTROL_PWM_FAN;
388a78a4a03SBenjamin Herrenschmidt fan->ctrl.ops = &wf_fcu_fan_pwm_ops;
389a78a4a03SBenjamin Herrenschmidt }
390a78a4a03SBenjamin Herrenschmidt
391a78a4a03SBenjamin Herrenschmidt if (wf_register_control(&fan->ctrl)) {
392a78a4a03SBenjamin Herrenschmidt pr_err("wf_fcu: Failed to register fan %s\n", name);
393a78a4a03SBenjamin Herrenschmidt kfree(fan);
394a78a4a03SBenjamin Herrenschmidt return;
395a78a4a03SBenjamin Herrenschmidt }
396a78a4a03SBenjamin Herrenschmidt list_add(&fan->link, &pv->fan_list);
397a78a4a03SBenjamin Herrenschmidt kref_get(&pv->ref);
398a78a4a03SBenjamin Herrenschmidt }
399a78a4a03SBenjamin Herrenschmidt
wf_fcu_lookup_fans(struct wf_fcu_priv * pv)4001da42fb6SGreg Kroah-Hartman static void wf_fcu_lookup_fans(struct wf_fcu_priv *pv)
401a78a4a03SBenjamin Herrenschmidt {
402a78a4a03SBenjamin Herrenschmidt /* Translation of device-tree location properties to
403a78a4a03SBenjamin Herrenschmidt * windfarm fan names
404a78a4a03SBenjamin Herrenschmidt */
405a78a4a03SBenjamin Herrenschmidt static const struct {
406a78a4a03SBenjamin Herrenschmidt const char *dt_name; /* Device-tree name */
407a78a4a03SBenjamin Herrenschmidt const char *ct_name; /* Control name */
408a78a4a03SBenjamin Herrenschmidt } loc_trans[] = {
409a78a4a03SBenjamin Herrenschmidt { "BACKSIDE", "backside-fan", },
410a78a4a03SBenjamin Herrenschmidt { "SYS CTRLR FAN", "backside-fan", },
411a78a4a03SBenjamin Herrenschmidt { "DRIVE BAY", "drive-bay-fan", },
412a78a4a03SBenjamin Herrenschmidt { "SLOT", "slots-fan", },
413a78a4a03SBenjamin Herrenschmidt { "PCI FAN", "slots-fan", },
414a78a4a03SBenjamin Herrenschmidt { "CPU A INTAKE", "cpu-front-fan-0", },
415a78a4a03SBenjamin Herrenschmidt { "CPU A EXHAUST", "cpu-rear-fan-0", },
416a78a4a03SBenjamin Herrenschmidt { "CPU B INTAKE", "cpu-front-fan-1", },
417a78a4a03SBenjamin Herrenschmidt { "CPU B EXHAUST", "cpu-rear-fan-1", },
418a78a4a03SBenjamin Herrenschmidt { "CPU A PUMP", "cpu-pump-0", },
419a78a4a03SBenjamin Herrenschmidt { "CPU B PUMP", "cpu-pump-1", },
420a78a4a03SBenjamin Herrenschmidt { "CPU A 1", "cpu-fan-a-0", },
421a78a4a03SBenjamin Herrenschmidt { "CPU A 2", "cpu-fan-b-0", },
422a78a4a03SBenjamin Herrenschmidt { "CPU A 3", "cpu-fan-c-0", },
423a78a4a03SBenjamin Herrenschmidt { "CPU B 1", "cpu-fan-a-1", },
424a78a4a03SBenjamin Herrenschmidt { "CPU B 2", "cpu-fan-b-1", },
425a78a4a03SBenjamin Herrenschmidt { "CPU B 3", "cpu-fan-c-1", },
426a78a4a03SBenjamin Herrenschmidt };
42715b680c4SRob Herring struct device_node *np, *fcu = pv->i2c->dev.of_node;
428a78a4a03SBenjamin Herrenschmidt int i;
429a78a4a03SBenjamin Herrenschmidt
430a78a4a03SBenjamin Herrenschmidt DBG("Looking up FCU controls in device-tree...\n");
431a78a4a03SBenjamin Herrenschmidt
43215b680c4SRob Herring for_each_child_of_node(fcu, np) {
433a78a4a03SBenjamin Herrenschmidt int id, type = -1;
434a78a4a03SBenjamin Herrenschmidt const char *loc;
435a78a4a03SBenjamin Herrenschmidt const char *name;
436a78a4a03SBenjamin Herrenschmidt const u32 *reg;
437a78a4a03SBenjamin Herrenschmidt
43815b680c4SRob Herring DBG(" control: %pOFn, type: %s\n", np, of_node_get_device_type(np));
439a78a4a03SBenjamin Herrenschmidt
440a78a4a03SBenjamin Herrenschmidt /* Detect control type */
441bf82d375SRob Herring if (of_node_is_type(np, "fan-rpm-control") ||
442bf82d375SRob Herring of_node_is_type(np, "fan-rpm"))
443a78a4a03SBenjamin Herrenschmidt type = FCU_FAN_RPM;
444bf82d375SRob Herring if (of_node_is_type(np, "fan-pwm-control") ||
445bf82d375SRob Herring of_node_is_type(np, "fan-pwm"))
446a78a4a03SBenjamin Herrenschmidt type = FCU_FAN_PWM;
447a78a4a03SBenjamin Herrenschmidt /* Only care about fans for now */
448a78a4a03SBenjamin Herrenschmidt if (type == -1)
449a78a4a03SBenjamin Herrenschmidt continue;
450a78a4a03SBenjamin Herrenschmidt
451a78a4a03SBenjamin Herrenschmidt /* Lookup for a matching location */
452a78a4a03SBenjamin Herrenschmidt loc = of_get_property(np, "location", NULL);
453a78a4a03SBenjamin Herrenschmidt reg = of_get_property(np, "reg", NULL);
454a78a4a03SBenjamin Herrenschmidt if (loc == NULL || reg == NULL)
455a78a4a03SBenjamin Herrenschmidt continue;
456a78a4a03SBenjamin Herrenschmidt DBG(" matching location: %s, reg: 0x%08x\n", loc, *reg);
457a78a4a03SBenjamin Herrenschmidt
458a78a4a03SBenjamin Herrenschmidt for (i = 0; i < ARRAY_SIZE(loc_trans); i++) {
459a78a4a03SBenjamin Herrenschmidt if (strncmp(loc, loc_trans[i].dt_name,
460a78a4a03SBenjamin Herrenschmidt strlen(loc_trans[i].dt_name)))
461a78a4a03SBenjamin Herrenschmidt continue;
462a78a4a03SBenjamin Herrenschmidt name = loc_trans[i].ct_name;
463a78a4a03SBenjamin Herrenschmidt
464a78a4a03SBenjamin Herrenschmidt DBG(" location match, name: %s\n", name);
465a78a4a03SBenjamin Herrenschmidt
466a78a4a03SBenjamin Herrenschmidt if (type == FCU_FAN_RPM)
467a78a4a03SBenjamin Herrenschmidt id = ((*reg) - 0x10) / 2;
468a78a4a03SBenjamin Herrenschmidt else
469a78a4a03SBenjamin Herrenschmidt id = ((*reg) - 0x30) / 2;
470a78a4a03SBenjamin Herrenschmidt if (id > 7) {
4712ee9a0dbSKefeng Wang pr_warn("wf_fcu: Can't parse fan ID in device-tree for %pOF\n", np);
472a78a4a03SBenjamin Herrenschmidt break;
473a78a4a03SBenjamin Herrenschmidt }
474a78a4a03SBenjamin Herrenschmidt wf_fcu_add_fan(pv, name, type, id);
475a78a4a03SBenjamin Herrenschmidt break;
476a78a4a03SBenjamin Herrenschmidt }
477a78a4a03SBenjamin Herrenschmidt }
478a78a4a03SBenjamin Herrenschmidt }
479a78a4a03SBenjamin Herrenschmidt
wf_fcu_default_fans(struct wf_fcu_priv * pv)4801da42fb6SGreg Kroah-Hartman static void wf_fcu_default_fans(struct wf_fcu_priv *pv)
481a78a4a03SBenjamin Herrenschmidt {
482a78a4a03SBenjamin Herrenschmidt /* We only support the default fans for PowerMac7,2 */
483a78a4a03SBenjamin Herrenschmidt if (!of_machine_is_compatible("PowerMac7,2"))
484a78a4a03SBenjamin Herrenschmidt return;
485a78a4a03SBenjamin Herrenschmidt
486a78a4a03SBenjamin Herrenschmidt wf_fcu_add_fan(pv, "backside-fan", FCU_FAN_PWM, 1);
487a78a4a03SBenjamin Herrenschmidt wf_fcu_add_fan(pv, "drive-bay-fan", FCU_FAN_RPM, 2);
488a78a4a03SBenjamin Herrenschmidt wf_fcu_add_fan(pv, "slots-fan", FCU_FAN_PWM, 2);
489a78a4a03SBenjamin Herrenschmidt wf_fcu_add_fan(pv, "cpu-front-fan-0", FCU_FAN_RPM, 3);
490a78a4a03SBenjamin Herrenschmidt wf_fcu_add_fan(pv, "cpu-rear-fan-0", FCU_FAN_RPM, 4);
491a78a4a03SBenjamin Herrenschmidt wf_fcu_add_fan(pv, "cpu-front-fan-1", FCU_FAN_RPM, 5);
492a78a4a03SBenjamin Herrenschmidt wf_fcu_add_fan(pv, "cpu-rear-fan-1", FCU_FAN_RPM, 6);
493a78a4a03SBenjamin Herrenschmidt }
494a78a4a03SBenjamin Herrenschmidt
wf_fcu_init_chip(struct wf_fcu_priv * pv)4951da42fb6SGreg Kroah-Hartman static int wf_fcu_init_chip(struct wf_fcu_priv *pv)
496a78a4a03SBenjamin Herrenschmidt {
497a78a4a03SBenjamin Herrenschmidt unsigned char buf = 0xff;
498a78a4a03SBenjamin Herrenschmidt int rc;
499a78a4a03SBenjamin Herrenschmidt
500a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_write_reg(pv, 0xe, &buf, 1);
501a78a4a03SBenjamin Herrenschmidt if (rc < 0)
502a78a4a03SBenjamin Herrenschmidt return -EIO;
503a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_write_reg(pv, 0x2e, &buf, 1);
504a78a4a03SBenjamin Herrenschmidt if (rc < 0)
505a78a4a03SBenjamin Herrenschmidt return -EIO;
506a78a4a03SBenjamin Herrenschmidt rc = wf_fcu_read_reg(pv, 0, &buf, 1);
507a78a4a03SBenjamin Herrenschmidt if (rc < 0)
508a78a4a03SBenjamin Herrenschmidt return -EIO;
509a78a4a03SBenjamin Herrenschmidt pv->rpm_shift = (buf == 1) ? 2 : 3;
510a78a4a03SBenjamin Herrenschmidt
511a78a4a03SBenjamin Herrenschmidt pr_debug("wf_fcu: FCU Initialized, RPM fan shift is %d\n",
512a78a4a03SBenjamin Herrenschmidt pv->rpm_shift);
513a78a4a03SBenjamin Herrenschmidt
514a78a4a03SBenjamin Herrenschmidt return 0;
515a78a4a03SBenjamin Herrenschmidt }
516a78a4a03SBenjamin Herrenschmidt
wf_fcu_probe(struct i2c_client * client)517472e4c61SUwe Kleine-König static int wf_fcu_probe(struct i2c_client *client)
518a78a4a03SBenjamin Herrenschmidt {
519a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv *pv;
520a78a4a03SBenjamin Herrenschmidt
521a78a4a03SBenjamin Herrenschmidt pv = kzalloc(sizeof(*pv), GFP_KERNEL);
522a78a4a03SBenjamin Herrenschmidt if (!pv)
523a78a4a03SBenjamin Herrenschmidt return -ENOMEM;
524a78a4a03SBenjamin Herrenschmidt
525a78a4a03SBenjamin Herrenschmidt kref_init(&pv->ref);
526a78a4a03SBenjamin Herrenschmidt mutex_init(&pv->lock);
527a78a4a03SBenjamin Herrenschmidt INIT_LIST_HEAD(&pv->fan_list);
528a78a4a03SBenjamin Herrenschmidt pv->i2c = client;
529a78a4a03SBenjamin Herrenschmidt
530a78a4a03SBenjamin Herrenschmidt /*
531a78a4a03SBenjamin Herrenschmidt * First we must start the FCU which will query the
532a78a4a03SBenjamin Herrenschmidt * shift value to apply to RPMs
533a78a4a03SBenjamin Herrenschmidt */
534a78a4a03SBenjamin Herrenschmidt if (wf_fcu_init_chip(pv)) {
535a78a4a03SBenjamin Herrenschmidt pr_err("wf_fcu: Initialization failed !\n");
536a78a4a03SBenjamin Herrenschmidt kfree(pv);
537a78a4a03SBenjamin Herrenschmidt return -ENXIO;
538a78a4a03SBenjamin Herrenschmidt }
539a78a4a03SBenjamin Herrenschmidt
540a78a4a03SBenjamin Herrenschmidt /* First lookup fans in the device-tree */
541a78a4a03SBenjamin Herrenschmidt wf_fcu_lookup_fans(pv);
542a78a4a03SBenjamin Herrenschmidt
543a78a4a03SBenjamin Herrenschmidt /*
544a78a4a03SBenjamin Herrenschmidt * Older machines don't have the device-tree entries
545a78a4a03SBenjamin Herrenschmidt * we are looking for, just hard code the list
546a78a4a03SBenjamin Herrenschmidt */
547a78a4a03SBenjamin Herrenschmidt if (list_empty(&pv->fan_list))
548a78a4a03SBenjamin Herrenschmidt wf_fcu_default_fans(pv);
549a78a4a03SBenjamin Herrenschmidt
550a78a4a03SBenjamin Herrenschmidt /* Still no fans ? FAIL */
551a78a4a03SBenjamin Herrenschmidt if (list_empty(&pv->fan_list)) {
552a78a4a03SBenjamin Herrenschmidt pr_err("wf_fcu: Failed to find fans for your machine\n");
553a78a4a03SBenjamin Herrenschmidt kfree(pv);
554a78a4a03SBenjamin Herrenschmidt return -ENODEV;
555a78a4a03SBenjamin Herrenschmidt }
556a78a4a03SBenjamin Herrenschmidt
557a78a4a03SBenjamin Herrenschmidt dev_set_drvdata(&client->dev, pv);
558a78a4a03SBenjamin Herrenschmidt
559a78a4a03SBenjamin Herrenschmidt return 0;
560a78a4a03SBenjamin Herrenschmidt }
561a78a4a03SBenjamin Herrenschmidt
wf_fcu_remove(struct i2c_client * client)562ed5c2f5fSUwe Kleine-König static void wf_fcu_remove(struct i2c_client *client)
563a78a4a03SBenjamin Herrenschmidt {
564a78a4a03SBenjamin Herrenschmidt struct wf_fcu_priv *pv = dev_get_drvdata(&client->dev);
565a78a4a03SBenjamin Herrenschmidt struct wf_fcu_fan *fan;
566a78a4a03SBenjamin Herrenschmidt
567a78a4a03SBenjamin Herrenschmidt while (!list_empty(&pv->fan_list)) {
568a78a4a03SBenjamin Herrenschmidt fan = list_first_entry(&pv->fan_list, struct wf_fcu_fan, link);
569a78a4a03SBenjamin Herrenschmidt list_del(&fan->link);
570a78a4a03SBenjamin Herrenschmidt wf_unregister_control(&fan->ctrl);
571a78a4a03SBenjamin Herrenschmidt }
572a78a4a03SBenjamin Herrenschmidt kref_put(&pv->ref, wf_fcu_release);
573a78a4a03SBenjamin Herrenschmidt }
574a78a4a03SBenjamin Herrenschmidt
575a78a4a03SBenjamin Herrenschmidt static const struct i2c_device_id wf_fcu_id[] = {
576a78a4a03SBenjamin Herrenschmidt { "MAC,fcu", 0 },
577a78a4a03SBenjamin Herrenschmidt { }
578a78a4a03SBenjamin Herrenschmidt };
579a78a4a03SBenjamin Herrenschmidt MODULE_DEVICE_TABLE(i2c, wf_fcu_id);
580a78a4a03SBenjamin Herrenschmidt
581bcf3588dSWolfram Sang static const struct of_device_id wf_fcu_of_id[] = {
582bcf3588dSWolfram Sang { .compatible = "fcu", },
583bcf3588dSWolfram Sang { }
584bcf3588dSWolfram Sang };
585bcf3588dSWolfram Sang MODULE_DEVICE_TABLE(of, wf_fcu_of_id);
586bcf3588dSWolfram Sang
587a78a4a03SBenjamin Herrenschmidt static struct i2c_driver wf_fcu_driver = {
588a78a4a03SBenjamin Herrenschmidt .driver = {
589a78a4a03SBenjamin Herrenschmidt .name = "wf_fcu",
590bcf3588dSWolfram Sang .of_match_table = wf_fcu_of_id,
591a78a4a03SBenjamin Herrenschmidt },
592*922db7c5SUwe Kleine-König .probe = wf_fcu_probe,
593a78a4a03SBenjamin Herrenschmidt .remove = wf_fcu_remove,
594a78a4a03SBenjamin Herrenschmidt .id_table = wf_fcu_id,
595a78a4a03SBenjamin Herrenschmidt };
596a78a4a03SBenjamin Herrenschmidt
597f7fb862bSWei Yongjun module_i2c_driver(wf_fcu_driver);
598a78a4a03SBenjamin Herrenschmidt
599a78a4a03SBenjamin Herrenschmidt MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
600a78a4a03SBenjamin Herrenschmidt MODULE_DESCRIPTION("FCU control objects for PowerMacs thermal control");
601a78a4a03SBenjamin Herrenschmidt MODULE_LICENSE("GPL");
602a78a4a03SBenjamin Herrenschmidt
603