diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2006-12-08 01:07:56 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-12-08 01:07:56 -0500 |
commit | bef986502fa398b1785a3979b1aa17cd902d3527 (patch) | |
tree | b59c1afe7b1dfcc001b86e54863f550d7ddc8c34 /drivers/macintosh | |
parent | 4bdbd2807deeccc0793d57fb5120d7a53f2c0b3c (diff) | |
parent | c99767974ebd2a719d849fdeaaa1674456f5283f (diff) |
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
drivers/usb/input/hid.h
Diffstat (limited to 'drivers/macintosh')
-rw-r--r-- | drivers/macintosh/Kconfig | 7 | ||||
-rw-r--r-- | drivers/macintosh/Makefile | 1 | ||||
-rw-r--r-- | drivers/macintosh/adb.c | 4 | ||||
-rw-r--r-- | drivers/macintosh/apm_emu.c | 3 | ||||
-rw-r--r-- | drivers/macintosh/rack-meter.c | 616 | ||||
-rw-r--r-- | drivers/macintosh/smu.c | 7 | ||||
-rw-r--r-- | drivers/macintosh/therm_adt746x.c | 3 | ||||
-rw-r--r-- | drivers/macintosh/therm_pm72.c | 5 | ||||
-rw-r--r-- | drivers/macintosh/therm_windtunnel.c | 7 | ||||
-rw-r--r-- | drivers/macintosh/via-pmu.c | 2 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_core.c | 1 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_pm112.c | 11 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_pm81.c | 1 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_pm91.c | 1 |
14 files changed, 656 insertions, 13 deletions
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig index 31015d55d353..a9e747c39791 100644 --- a/drivers/macintosh/Kconfig +++ b/drivers/macintosh/Kconfig | |||
@@ -227,4 +227,11 @@ config ANSLCD | |||
227 | tristate "Support for ANS LCD display" | 227 | tristate "Support for ANS LCD display" |
228 | depends on ADB_CUDA && PPC_PMAC | 228 | depends on ADB_CUDA && PPC_PMAC |
229 | 229 | ||
230 | config PMAC_RACKMETER | ||
231 | tristate "Support for Apple XServe front panel LEDs" | ||
232 | depends on PPC_PMAC | ||
233 | help | ||
234 | This driver procides some support to control the front panel | ||
235 | blue LEDs "vu-meter" of the XServer macs. | ||
236 | |||
230 | endmenu | 237 | endmenu |
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile index b53d45f87b0b..2dfc3f4eaf42 100644 --- a/drivers/macintosh/Makefile +++ b/drivers/macintosh/Makefile | |||
@@ -42,3 +42,4 @@ obj-$(CONFIG_WINDFARM_PM112) += windfarm_pm112.o windfarm_smu_sat.o \ | |||
42 | windfarm_smu_sensors.o \ | 42 | windfarm_smu_sensors.o \ |
43 | windfarm_max6690_sensor.o \ | 43 | windfarm_max6690_sensor.o \ |
44 | windfarm_lm75_sensor.o windfarm_pid.o | 44 | windfarm_lm75_sensor.o windfarm_pid.o |
45 | obj-$(CONFIG_PMAC_RACKMETER) += rack-meter.o | ||
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index be0bd34ff6f9..d43ea81d6df9 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
@@ -267,12 +267,12 @@ adb_probe_task(void *x) | |||
267 | } | 267 | } |
268 | 268 | ||
269 | static void | 269 | static void |
270 | __adb_probe_task(void *data) | 270 | __adb_probe_task(struct work_struct *bullshit) |
271 | { | 271 | { |
272 | adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL); | 272 | adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL); |
273 | } | 273 | } |
274 | 274 | ||
275 | static DECLARE_WORK(adb_reset_work, __adb_probe_task, NULL); | 275 | static DECLARE_WORK(adb_reset_work, __adb_probe_task); |
276 | 276 | ||
277 | int | 277 | int |
278 | adb_reset_bus(void) | 278 | adb_reset_bus(void) |
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c index 1293876a2ebd..8862a83b8d84 100644 --- a/drivers/macintosh/apm_emu.c +++ b/drivers/macintosh/apm_emu.c | |||
@@ -529,7 +529,8 @@ static int __init apm_emu_init(void) | |||
529 | if (apm_proc) | 529 | if (apm_proc) |
530 | apm_proc->owner = THIS_MODULE; | 530 | apm_proc->owner = THIS_MODULE; |
531 | 531 | ||
532 | misc_register(&apm_device); | 532 | if (misc_register(&apm_device) != 0) |
533 | printk(KERN_INFO "Could not create misc. device for apm\n"); | ||
533 | 534 | ||
534 | pmu_register_sleep_notifier(&apm_sleep_notifier); | 535 | pmu_register_sleep_notifier(&apm_sleep_notifier); |
535 | 536 | ||
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c new file mode 100644 index 000000000000..5ed41fe84e57 --- /dev/null +++ b/drivers/macintosh/rack-meter.c | |||
@@ -0,0 +1,616 @@ | |||
1 | /* | ||
2 | * RackMac vu-meter driver | ||
3 | * | ||
4 | * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp. | ||
5 | * <benh@kernel.crashing.org> | ||
6 | * | ||
7 | * Released under the term of the GNU GPL v2. | ||
8 | * | ||
9 | * Support the CPU-meter LEDs of the Xserve G5 | ||
10 | * | ||
11 | * TODO: Implement PWM to do variable intensity and provide userland | ||
12 | * interface for fun. Also, the CPU-meter could be made nicer by being | ||
13 | * a bit less "immediate" but giving instead a more average load over | ||
14 | * time. Patches welcome :-) | ||
15 | * | ||
16 | */ | ||
17 | #undef DEBUG | ||
18 | |||
19 | #include <linux/types.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/pci.h> | ||
25 | #include <linux/dma-mapping.h> | ||
26 | #include <linux/kernel_stat.h> | ||
27 | |||
28 | #include <asm/io.h> | ||
29 | #include <asm/prom.h> | ||
30 | #include <asm/machdep.h> | ||
31 | #include <asm/pmac_feature.h> | ||
32 | #include <asm/dbdma.h> | ||
33 | #include <asm/dbdma.h> | ||
34 | #include <asm/macio.h> | ||
35 | #include <asm/keylargo.h> | ||
36 | |||
37 | /* Number of samples in a sample buffer */ | ||
38 | #define SAMPLE_COUNT 256 | ||
39 | |||
40 | /* CPU meter sampling rate in ms */ | ||
41 | #define CPU_SAMPLING_RATE 250 | ||
42 | |||
43 | struct rackmeter_dma { | ||
44 | struct dbdma_cmd cmd[4] ____cacheline_aligned; | ||
45 | u32 mark ____cacheline_aligned; | ||
46 | u32 buf1[SAMPLE_COUNT] ____cacheline_aligned; | ||
47 | u32 buf2[SAMPLE_COUNT] ____cacheline_aligned; | ||
48 | } ____cacheline_aligned; | ||
49 | |||
50 | struct rackmeter_cpu { | ||
51 | struct delayed_work sniffer; | ||
52 | struct rackmeter *rm; | ||
53 | cputime64_t prev_wall; | ||
54 | cputime64_t prev_idle; | ||
55 | int zero; | ||
56 | } ____cacheline_aligned; | ||
57 | |||
58 | struct rackmeter { | ||
59 | struct macio_dev *mdev; | ||
60 | unsigned int irq; | ||
61 | struct device_node *i2s; | ||
62 | u8 *ubuf; | ||
63 | struct dbdma_regs __iomem *dma_regs; | ||
64 | void __iomem *i2s_regs; | ||
65 | dma_addr_t dma_buf_p; | ||
66 | struct rackmeter_dma *dma_buf_v; | ||
67 | int stale_irq; | ||
68 | struct rackmeter_cpu cpu[2]; | ||
69 | int paused; | ||
70 | struct mutex sem; | ||
71 | }; | ||
72 | |||
73 | /* To be set as a tunable */ | ||
74 | static int rackmeter_ignore_nice; | ||
75 | |||
76 | /* This GPIO is whacked by the OS X driver when initializing */ | ||
77 | #define RACKMETER_MAGIC_GPIO 0x78 | ||
78 | |||
79 | /* This is copied from cpufreq_ondemand, maybe we should put it in | ||
80 | * a common header somewhere | ||
81 | */ | ||
82 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu) | ||
83 | { | ||
84 | cputime64_t retval; | ||
85 | |||
86 | retval = cputime64_add(kstat_cpu(cpu).cpustat.idle, | ||
87 | kstat_cpu(cpu).cpustat.iowait); | ||
88 | |||
89 | if (rackmeter_ignore_nice) | ||
90 | retval = cputime64_add(retval, kstat_cpu(cpu).cpustat.nice); | ||
91 | |||
92 | return retval; | ||
93 | } | ||
94 | |||
95 | static void rackmeter_setup_i2s(struct rackmeter *rm) | ||
96 | { | ||
97 | struct macio_chip *macio = rm->mdev->bus->chip; | ||
98 | |||
99 | /* First whack magic GPIO */ | ||
100 | pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, RACKMETER_MAGIC_GPIO, 5); | ||
101 | |||
102 | |||
103 | /* Call feature code to enable the sound channel and the proper | ||
104 | * clock sources | ||
105 | */ | ||
106 | pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, rm->i2s, 0, 1); | ||
107 | |||
108 | /* Power i2s and stop i2s clock. We whack MacIO FCRs directly for now. | ||
109 | * This is a bit racy, thus we should add new platform functions to | ||
110 | * handle that. snd-aoa needs that too | ||
111 | */ | ||
112 | MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_ENABLE); | ||
113 | MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT); | ||
114 | (void)MACIO_IN32(KEYLARGO_FCR1); | ||
115 | udelay(10); | ||
116 | |||
117 | /* Then setup i2s. For now, we use the same magic value that | ||
118 | * the OS X driver seems to use. We might want to play around | ||
119 | * with the clock divisors later | ||
120 | */ | ||
121 | out_le32(rm->i2s_regs + 0x10, 0x01fa0000); | ||
122 | (void)in_le32(rm->i2s_regs + 0x10); | ||
123 | udelay(10); | ||
124 | |||
125 | /* Fully restart i2s*/ | ||
126 | MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE | | ||
127 | KL1_I2S0_CLK_ENABLE_BIT); | ||
128 | (void)MACIO_IN32(KEYLARGO_FCR1); | ||
129 | udelay(10); | ||
130 | } | ||
131 | |||
132 | static void rackmeter_set_default_pattern(struct rackmeter *rm) | ||
133 | { | ||
134 | int i; | ||
135 | |||
136 | for (i = 0; i < 16; i++) { | ||
137 | if (i < 8) | ||
138 | rm->ubuf[i] = (i & 1) * 255; | ||
139 | else | ||
140 | rm->ubuf[i] = ((~i) & 1) * 255; | ||
141 | } | ||
142 | } | ||
143 | |||
144 | static void rackmeter_do_pause(struct rackmeter *rm, int pause) | ||
145 | { | ||
146 | struct rackmeter_dma *rdma = rm->dma_buf_v; | ||
147 | |||
148 | pr_debug("rackmeter: %s\n", pause ? "paused" : "started"); | ||
149 | |||
150 | rm->paused = pause; | ||
151 | if (pause) { | ||
152 | DBDMA_DO_STOP(rm->dma_regs); | ||
153 | return; | ||
154 | } | ||
155 | memset(rdma->buf1, 0, SAMPLE_COUNT & sizeof(u32)); | ||
156 | memset(rdma->buf2, 0, SAMPLE_COUNT & sizeof(u32)); | ||
157 | |||
158 | rm->dma_buf_v->mark = 0; | ||
159 | |||
160 | mb(); | ||
161 | out_le32(&rm->dma_regs->cmdptr_hi, 0); | ||
162 | out_le32(&rm->dma_regs->cmdptr, rm->dma_buf_p); | ||
163 | out_le32(&rm->dma_regs->control, (RUN << 16) | RUN); | ||
164 | } | ||
165 | |||
166 | static void rackmeter_setup_dbdma(struct rackmeter *rm) | ||
167 | { | ||
168 | struct rackmeter_dma *db = rm->dma_buf_v; | ||
169 | struct dbdma_cmd *cmd = db->cmd; | ||
170 | |||
171 | /* Make sure dbdma is reset */ | ||
172 | DBDMA_DO_RESET(rm->dma_regs); | ||
173 | |||
174 | pr_debug("rackmeter: mark offset=0x%lx\n", | ||
175 | offsetof(struct rackmeter_dma, mark)); | ||
176 | pr_debug("rackmeter: buf1 offset=0x%lx\n", | ||
177 | offsetof(struct rackmeter_dma, buf1)); | ||
178 | pr_debug("rackmeter: buf2 offset=0x%lx\n", | ||
179 | offsetof(struct rackmeter_dma, buf2)); | ||
180 | |||
181 | /* Prepare 4 dbdma commands for the 2 buffers */ | ||
182 | memset(cmd, 0, 4 * sizeof(struct dbdma_cmd)); | ||
183 | st_le16(&cmd->req_count, 4); | ||
184 | st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM); | ||
185 | st_le32(&cmd->phy_addr, rm->dma_buf_p + | ||
186 | offsetof(struct rackmeter_dma, mark)); | ||
187 | st_le32(&cmd->cmd_dep, 0x02000000); | ||
188 | cmd++; | ||
189 | |||
190 | st_le16(&cmd->req_count, SAMPLE_COUNT * 4); | ||
191 | st_le16(&cmd->command, OUTPUT_MORE); | ||
192 | st_le32(&cmd->phy_addr, rm->dma_buf_p + | ||
193 | offsetof(struct rackmeter_dma, buf1)); | ||
194 | cmd++; | ||
195 | |||
196 | st_le16(&cmd->req_count, 4); | ||
197 | st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM); | ||
198 | st_le32(&cmd->phy_addr, rm->dma_buf_p + | ||
199 | offsetof(struct rackmeter_dma, mark)); | ||
200 | st_le32(&cmd->cmd_dep, 0x01000000); | ||
201 | cmd++; | ||
202 | |||
203 | st_le16(&cmd->req_count, SAMPLE_COUNT * 4); | ||
204 | st_le16(&cmd->command, OUTPUT_MORE | BR_ALWAYS); | ||
205 | st_le32(&cmd->phy_addr, rm->dma_buf_p + | ||
206 | offsetof(struct rackmeter_dma, buf2)); | ||
207 | st_le32(&cmd->cmd_dep, rm->dma_buf_p); | ||
208 | |||
209 | rackmeter_do_pause(rm, 0); | ||
210 | } | ||
211 | |||
212 | static void rackmeter_do_timer(struct work_struct *work) | ||
213 | { | ||
214 | struct rackmeter_cpu *rcpu = | ||
215 | container_of(work, struct rackmeter_cpu, sniffer.work); | ||
216 | struct rackmeter *rm = rcpu->rm; | ||
217 | unsigned int cpu = smp_processor_id(); | ||
218 | cputime64_t cur_jiffies, total_idle_ticks; | ||
219 | unsigned int total_ticks, idle_ticks; | ||
220 | int i, offset, load, cumm, pause; | ||
221 | |||
222 | cur_jiffies = jiffies64_to_cputime64(get_jiffies_64()); | ||
223 | total_ticks = (unsigned int)cputime64_sub(cur_jiffies, | ||
224 | rcpu->prev_wall); | ||
225 | rcpu->prev_wall = cur_jiffies; | ||
226 | |||
227 | total_idle_ticks = get_cpu_idle_time(cpu); | ||
228 | idle_ticks = (unsigned int) cputime64_sub(total_idle_ticks, | ||
229 | rcpu->prev_idle); | ||
230 | rcpu->prev_idle = total_idle_ticks; | ||
231 | |||
232 | /* We do a very dumb calculation to update the LEDs for now, | ||
233 | * we'll do better once we have actual PWM implemented | ||
234 | */ | ||
235 | load = (9 * (total_ticks - idle_ticks)) / total_ticks; | ||
236 | |||
237 | offset = cpu << 3; | ||
238 | cumm = 0; | ||
239 | for (i = 0; i < 8; i++) { | ||
240 | u8 ub = (load > i) ? 0xff : 0; | ||
241 | rm->ubuf[i + offset] = ub; | ||
242 | cumm |= ub; | ||
243 | } | ||
244 | rcpu->zero = (cumm == 0); | ||
245 | |||
246 | /* Now check if LEDs are all 0, we can stop DMA */ | ||
247 | pause = (rm->cpu[0].zero && rm->cpu[1].zero); | ||
248 | if (pause != rm->paused) { | ||
249 | mutex_lock(&rm->sem); | ||
250 | pause = (rm->cpu[0].zero && rm->cpu[1].zero); | ||
251 | rackmeter_do_pause(rm, pause); | ||
252 | mutex_unlock(&rm->sem); | ||
253 | } | ||
254 | schedule_delayed_work_on(cpu, &rcpu->sniffer, | ||
255 | msecs_to_jiffies(CPU_SAMPLING_RATE)); | ||
256 | } | ||
257 | |||
258 | static void __devinit rackmeter_init_cpu_sniffer(struct rackmeter *rm) | ||
259 | { | ||
260 | unsigned int cpu; | ||
261 | |||
262 | /* This driver works only with 1 or 2 CPUs numbered 0 and 1, | ||
263 | * but that's really all we have on Apple Xserve. It doesn't | ||
264 | * play very nice with CPU hotplug neither but we don't do that | ||
265 | * on those machines yet | ||
266 | */ | ||
267 | |||
268 | rm->cpu[0].rm = rm; | ||
269 | INIT_DELAYED_WORK(&rm->cpu[0].sniffer, rackmeter_do_timer); | ||
270 | rm->cpu[1].rm = rm; | ||
271 | INIT_DELAYED_WORK(&rm->cpu[1].sniffer, rackmeter_do_timer); | ||
272 | |||
273 | for_each_online_cpu(cpu) { | ||
274 | struct rackmeter_cpu *rcpu; | ||
275 | |||
276 | if (cpu > 1) | ||
277 | continue; | ||
278 | rcpu = &rm->cpu[cpu];; | ||
279 | rcpu->prev_idle = get_cpu_idle_time(cpu); | ||
280 | rcpu->prev_wall = jiffies64_to_cputime64(get_jiffies_64()); | ||
281 | schedule_delayed_work_on(cpu, &rm->cpu[cpu].sniffer, | ||
282 | msecs_to_jiffies(CPU_SAMPLING_RATE)); | ||
283 | } | ||
284 | } | ||
285 | |||
286 | static void __devexit rackmeter_stop_cpu_sniffer(struct rackmeter *rm) | ||
287 | { | ||
288 | cancel_rearming_delayed_work(&rm->cpu[0].sniffer); | ||
289 | cancel_rearming_delayed_work(&rm->cpu[1].sniffer); | ||
290 | } | ||
291 | |||
292 | static int rackmeter_setup(struct rackmeter *rm) | ||
293 | { | ||
294 | pr_debug("rackmeter: setting up i2s..\n"); | ||
295 | rackmeter_setup_i2s(rm); | ||
296 | |||
297 | pr_debug("rackmeter: setting up default pattern..\n"); | ||
298 | rackmeter_set_default_pattern(rm); | ||
299 | |||
300 | pr_debug("rackmeter: setting up dbdma..\n"); | ||
301 | rackmeter_setup_dbdma(rm); | ||
302 | |||
303 | pr_debug("rackmeter: start CPU measurements..\n"); | ||
304 | rackmeter_init_cpu_sniffer(rm); | ||
305 | |||
306 | printk(KERN_INFO "RackMeter initialized\n"); | ||
307 | |||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | /* XXX FIXME: No PWM yet, this is 0/1 */ | ||
312 | static u32 rackmeter_calc_sample(struct rackmeter *rm, unsigned int index) | ||
313 | { | ||
314 | int led; | ||
315 | u32 sample = 0; | ||
316 | |||
317 | for (led = 0; led < 16; led++) { | ||
318 | sample >>= 1; | ||
319 | sample |= ((rm->ubuf[led] >= 0x80) << 15); | ||
320 | } | ||
321 | return (sample << 17) | (sample >> 15); | ||
322 | } | ||
323 | |||
324 | static irqreturn_t rackmeter_irq(int irq, void *arg) | ||
325 | { | ||
326 | struct rackmeter *rm = arg; | ||
327 | struct rackmeter_dma *db = rm->dma_buf_v; | ||
328 | unsigned int mark, i; | ||
329 | u32 *buf; | ||
330 | |||
331 | /* Flush PCI buffers with an MMIO read. Maybe we could actually | ||
332 | * check the status one day ... in case things go wrong, though | ||
333 | * this never happened to me | ||
334 | */ | ||
335 | (void)in_le32(&rm->dma_regs->status); | ||
336 | |||
337 | /* Make sure the CPU gets us in order */ | ||
338 | rmb(); | ||
339 | |||
340 | /* Read mark */ | ||
341 | mark = db->mark; | ||
342 | if (mark != 1 && mark != 2) { | ||
343 | printk(KERN_WARNING "rackmeter: Incorrect DMA mark 0x%08x\n", | ||
344 | mark); | ||
345 | /* We allow for 3 errors like that (stale DBDMA irqs) */ | ||
346 | if (++rm->stale_irq > 3) { | ||
347 | printk(KERN_ERR "rackmeter: Too many errors," | ||
348 | " stopping DMA\n"); | ||
349 | DBDMA_DO_RESET(rm->dma_regs); | ||
350 | } | ||
351 | return IRQ_HANDLED; | ||
352 | } | ||
353 | |||
354 | /* Next buffer we need to fill is mark value */ | ||
355 | buf = mark == 1 ? db->buf1 : db->buf2; | ||
356 | |||
357 | /* Fill it now. This routine converts the 8 bits depth sample array | ||
358 | * into the PWM bitmap for each LED. | ||
359 | */ | ||
360 | for (i = 0; i < SAMPLE_COUNT; i++) | ||
361 | buf[i] = rackmeter_calc_sample(rm, i); | ||
362 | |||
363 | |||
364 | return IRQ_HANDLED; | ||
365 | } | ||
366 | |||
367 | static int __devinit rackmeter_probe(struct macio_dev* mdev, | ||
368 | const struct of_device_id *match) | ||
369 | { | ||
370 | struct device_node *i2s = NULL, *np = NULL; | ||
371 | struct rackmeter *rm = NULL; | ||
372 | struct resource ri2s, rdma; | ||
373 | int rc = -ENODEV; | ||
374 | |||
375 | pr_debug("rackmeter_probe()\n"); | ||
376 | |||
377 | /* Get i2s-a node */ | ||
378 | while ((i2s = of_get_next_child(mdev->ofdev.node, i2s)) != NULL) | ||
379 | if (strcmp(i2s->name, "i2s-a") == 0) | ||
380 | break; | ||
381 | if (i2s == NULL) { | ||
382 | pr_debug(" i2s-a child not found\n"); | ||
383 | goto bail; | ||
384 | } | ||
385 | /* Get lightshow or virtual sound */ | ||
386 | while ((np = of_get_next_child(i2s, np)) != NULL) { | ||
387 | if (strcmp(np->name, "lightshow") == 0) | ||
388 | break; | ||
389 | if ((strcmp(np->name, "sound") == 0) && | ||
390 | get_property(np, "virtual", NULL) != NULL) | ||
391 | break; | ||
392 | } | ||
393 | if (np == NULL) { | ||
394 | pr_debug(" lightshow or sound+virtual child not found\n"); | ||
395 | goto bail; | ||
396 | } | ||
397 | |||
398 | /* Create and initialize our instance data */ | ||
399 | rm = kzalloc(sizeof(struct rackmeter), GFP_KERNEL); | ||
400 | if (rm == NULL) { | ||
401 | printk(KERN_ERR "rackmeter: failed to allocate memory !\n"); | ||
402 | rc = -ENOMEM; | ||
403 | goto bail_release; | ||
404 | } | ||
405 | rm->mdev = mdev; | ||
406 | rm->i2s = i2s; | ||
407 | mutex_init(&rm->sem); | ||
408 | dev_set_drvdata(&mdev->ofdev.dev, rm); | ||
409 | /* Check resources availability. We need at least resource 0 and 1 */ | ||
410 | #if 0 /* Use that when i2s-a is finally an mdev per-se */ | ||
411 | if (macio_resource_count(mdev) < 2 || macio_irq_count(mdev) < 2) { | ||
412 | printk(KERN_ERR | ||
413 | "rackmeter: found match but lacks resources: %s" | ||
414 | " (%d resources, %d interrupts)\n", | ||
415 | mdev->ofdev.node->full_name); | ||
416 | rc = -ENXIO; | ||
417 | goto bail_free; | ||
418 | } | ||
419 | if (macio_request_resources(mdev, "rackmeter")) { | ||
420 | printk(KERN_ERR | ||
421 | "rackmeter: failed to request resources: %s\n", | ||
422 | mdev->ofdev.node->full_name); | ||
423 | rc = -EBUSY; | ||
424 | goto bail_free; | ||
425 | } | ||
426 | rm->irq = macio_irq(mdev, 1); | ||
427 | #else | ||
428 | rm->irq = irq_of_parse_and_map(i2s, 1); | ||
429 | if (rm->irq == NO_IRQ || | ||
430 | of_address_to_resource(i2s, 0, &ri2s) || | ||
431 | of_address_to_resource(i2s, 1, &rdma)) { | ||
432 | printk(KERN_ERR | ||
433 | "rackmeter: found match but lacks resources: %s", | ||
434 | mdev->ofdev.node->full_name); | ||
435 | rc = -ENXIO; | ||
436 | goto bail_free; | ||
437 | } | ||
438 | #endif | ||
439 | |||
440 | pr_debug(" i2s @0x%08x\n", (unsigned int)ri2s.start); | ||
441 | pr_debug(" dma @0x%08x\n", (unsigned int)rdma.start); | ||
442 | pr_debug(" irq %d\n", rm->irq); | ||
443 | |||
444 | rm->ubuf = (u8 *)__get_free_page(GFP_KERNEL); | ||
445 | if (rm->ubuf == NULL) { | ||
446 | printk(KERN_ERR | ||
447 | "rackmeter: failed to allocate samples page !\n"); | ||
448 | rc = -ENOMEM; | ||
449 | goto bail_release; | ||
450 | } | ||
451 | |||
452 | rm->dma_buf_v = dma_alloc_coherent(&macio_get_pci_dev(mdev)->dev, | ||
453 | sizeof(struct rackmeter_dma), | ||
454 | &rm->dma_buf_p, GFP_KERNEL); | ||
455 | if (rm->dma_buf_v == NULL) { | ||
456 | printk(KERN_ERR | ||
457 | "rackmeter: failed to allocate dma buffer !\n"); | ||
458 | rc = -ENOMEM; | ||
459 | goto bail_free_samples; | ||
460 | } | ||
461 | #if 0 | ||
462 | rm->i2s_regs = ioremap(macio_resource_start(mdev, 0), 0x1000); | ||
463 | #else | ||
464 | rm->i2s_regs = ioremap(ri2s.start, 0x1000); | ||
465 | #endif | ||
466 | if (rm->i2s_regs == NULL) { | ||
467 | printk(KERN_ERR | ||
468 | "rackmeter: failed to map i2s registers !\n"); | ||
469 | rc = -ENXIO; | ||
470 | goto bail_free_dma; | ||
471 | } | ||
472 | #if 0 | ||
473 | rm->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x100); | ||
474 | #else | ||
475 | rm->dma_regs = ioremap(rdma.start, 0x100); | ||
476 | #endif | ||
477 | if (rm->dma_regs == NULL) { | ||
478 | printk(KERN_ERR | ||
479 | "rackmeter: failed to map dma registers !\n"); | ||
480 | rc = -ENXIO; | ||
481 | goto bail_unmap_i2s; | ||
482 | } | ||
483 | |||
484 | rc = rackmeter_setup(rm); | ||
485 | if (rc) { | ||
486 | printk(KERN_ERR | ||
487 | "rackmeter: failed to initialize !\n"); | ||
488 | rc = -ENXIO; | ||
489 | goto bail_unmap_dma; | ||
490 | } | ||
491 | |||
492 | rc = request_irq(rm->irq, rackmeter_irq, 0, "rackmeter", rm); | ||
493 | if (rc != 0) { | ||
494 | printk(KERN_ERR | ||
495 | "rackmeter: failed to request interrupt !\n"); | ||
496 | goto bail_stop_dma; | ||
497 | } | ||
498 | of_node_put(np); | ||
499 | return 0; | ||
500 | |||
501 | bail_stop_dma: | ||
502 | DBDMA_DO_RESET(rm->dma_regs); | ||
503 | bail_unmap_dma: | ||
504 | iounmap(rm->dma_regs); | ||
505 | bail_unmap_i2s: | ||
506 | iounmap(rm->i2s_regs); | ||
507 | bail_free_dma: | ||
508 | dma_free_coherent(&macio_get_pci_dev(mdev)->dev, | ||
509 | sizeof(struct rackmeter_dma), | ||
510 | rm->dma_buf_v, rm->dma_buf_p); | ||
511 | bail_free_samples: | ||
512 | free_page((unsigned long)rm->ubuf); | ||
513 | bail_release: | ||
514 | #if 0 | ||
515 | macio_release_resources(mdev); | ||
516 | #endif | ||
517 | bail_free: | ||
518 | kfree(rm); | ||
519 | bail: | ||
520 | of_node_put(i2s); | ||
521 | of_node_put(np); | ||
522 | dev_set_drvdata(&mdev->ofdev.dev, NULL); | ||
523 | return rc; | ||
524 | } | ||
525 | |||
526 | static int __devexit rackmeter_remove(struct macio_dev* mdev) | ||
527 | { | ||
528 | struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev); | ||
529 | |||
530 | /* Stop CPU sniffer timer & work queues */ | ||
531 | rackmeter_stop_cpu_sniffer(rm); | ||
532 | |||
533 | /* Clear reference to private data */ | ||
534 | dev_set_drvdata(&mdev->ofdev.dev, NULL); | ||
535 | |||
536 | /* Stop/reset dbdma */ | ||
537 | DBDMA_DO_RESET(rm->dma_regs); | ||
538 | |||
539 | /* Release the IRQ */ | ||
540 | free_irq(rm->irq, rm); | ||
541 | |||
542 | /* Unmap registers */ | ||
543 | iounmap(rm->dma_regs); | ||
544 | iounmap(rm->i2s_regs); | ||
545 | |||
546 | /* Free DMA */ | ||
547 | dma_free_coherent(&macio_get_pci_dev(mdev)->dev, | ||
548 | sizeof(struct rackmeter_dma), | ||
549 | rm->dma_buf_v, rm->dma_buf_p); | ||
550 | |||
551 | /* Free samples */ | ||
552 | free_page((unsigned long)rm->ubuf); | ||
553 | |||
554 | #if 0 | ||
555 | /* Release resources */ | ||
556 | macio_release_resources(mdev); | ||
557 | #endif | ||
558 | |||
559 | /* Get rid of me */ | ||
560 | kfree(rm); | ||
561 | |||
562 | return 0; | ||
563 | } | ||
564 | |||
565 | static int rackmeter_shutdown(struct macio_dev* mdev) | ||
566 | { | ||
567 | struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev); | ||
568 | |||
569 | if (rm == NULL) | ||
570 | return -ENODEV; | ||
571 | |||
572 | /* Stop CPU sniffer timer & work queues */ | ||
573 | rackmeter_stop_cpu_sniffer(rm); | ||
574 | |||
575 | /* Stop/reset dbdma */ | ||
576 | DBDMA_DO_RESET(rm->dma_regs); | ||
577 | |||
578 | return 0; | ||
579 | } | ||
580 | |||
581 | static struct of_device_id rackmeter_match[] = { | ||
582 | { .name = "i2s" }, | ||
583 | { } | ||
584 | }; | ||
585 | |||
586 | static struct macio_driver rackmeter_drv = { | ||
587 | .name = "rackmeter", | ||
588 | .owner = THIS_MODULE, | ||
589 | .match_table = rackmeter_match, | ||
590 | .probe = rackmeter_probe, | ||
591 | .remove = rackmeter_remove, | ||
592 | .shutdown = rackmeter_shutdown, | ||
593 | }; | ||
594 | |||
595 | |||
596 | static int __init rackmeter_init(void) | ||
597 | { | ||
598 | pr_debug("rackmeter_init()\n"); | ||
599 | |||
600 | return macio_register_driver(&rackmeter_drv); | ||
601 | } | ||
602 | |||
603 | static void __exit rackmeter_exit(void) | ||
604 | { | ||
605 | pr_debug("rackmeter_exit()\n"); | ||
606 | |||
607 | macio_unregister_driver(&rackmeter_drv); | ||
608 | } | ||
609 | |||
610 | module_init(rackmeter_init); | ||
611 | module_exit(rackmeter_exit); | ||
612 | |||
613 | |||
614 | MODULE_LICENSE("GPL"); | ||
615 | MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>"); | ||
616 | MODULE_DESCRIPTION("RackMeter: Support vu-meter on XServe front panel"); | ||
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index ade25b3fbb35..6dde27ab79a8 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <asm/abs_addr.h> | 46 | #include <asm/abs_addr.h> |
47 | #include <asm/uaccess.h> | 47 | #include <asm/uaccess.h> |
48 | #include <asm/of_device.h> | 48 | #include <asm/of_device.h> |
49 | #include <asm/of_platform.h> | ||
49 | 50 | ||
50 | #define VERSION "0.7" | 51 | #define VERSION "0.7" |
51 | #define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." | 52 | #define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." |
@@ -600,7 +601,7 @@ core_initcall(smu_late_init); | |||
600 | * sysfs visibility | 601 | * sysfs visibility |
601 | */ | 602 | */ |
602 | 603 | ||
603 | static void smu_expose_childs(void *unused) | 604 | static void smu_expose_childs(struct work_struct *unused) |
604 | { | 605 | { |
605 | struct device_node *np; | 606 | struct device_node *np; |
606 | 607 | ||
@@ -610,7 +611,7 @@ static void smu_expose_childs(void *unused) | |||
610 | &smu->of_dev->dev); | 611 | &smu->of_dev->dev); |
611 | } | 612 | } |
612 | 613 | ||
613 | static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL); | 614 | static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs); |
614 | 615 | ||
615 | static int smu_platform_probe(struct of_device* dev, | 616 | static int smu_platform_probe(struct of_device* dev, |
616 | const struct of_device_id *match) | 617 | const struct of_device_id *match) |
@@ -653,7 +654,7 @@ static int __init smu_init_sysfs(void) | |||
653 | * I'm a bit too far from figuring out how that works with those | 654 | * I'm a bit too far from figuring out how that works with those |
654 | * new chipsets, but that will come back and bite us | 655 | * new chipsets, but that will come back and bite us |
655 | */ | 656 | */ |
656 | of_register_driver(&smu_of_platform_driver); | 657 | of_register_platform_driver(&smu_of_platform_driver); |
657 | return 0; | 658 | return 0; |
658 | } | 659 | } |
659 | 660 | ||
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index a0f30d0853ea..3d3bf1643e73 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c | |||
@@ -24,13 +24,14 @@ | |||
24 | #include <linux/suspend.h> | 24 | #include <linux/suspend.h> |
25 | #include <linux/kthread.h> | 25 | #include <linux/kthread.h> |
26 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
27 | #include <linux/freezer.h> | ||
27 | 28 | ||
28 | #include <asm/prom.h> | 29 | #include <asm/prom.h> |
29 | #include <asm/machdep.h> | 30 | #include <asm/machdep.h> |
30 | #include <asm/io.h> | 31 | #include <asm/io.h> |
31 | #include <asm/system.h> | 32 | #include <asm/system.h> |
32 | #include <asm/sections.h> | 33 | #include <asm/sections.h> |
33 | #include <asm/of_device.h> | 34 | #include <asm/of_platform.h> |
34 | 35 | ||
35 | #undef DEBUG | 36 | #undef DEBUG |
36 | 37 | ||
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index d00c0c37a12e..2e4ad44a8636 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c | |||
@@ -129,6 +129,7 @@ | |||
129 | #include <asm/sections.h> | 129 | #include <asm/sections.h> |
130 | #include <asm/of_device.h> | 130 | #include <asm/of_device.h> |
131 | #include <asm/macio.h> | 131 | #include <asm/macio.h> |
132 | #include <asm/of_platform.h> | ||
132 | 133 | ||
133 | #include "therm_pm72.h" | 134 | #include "therm_pm72.h" |
134 | 135 | ||
@@ -2236,14 +2237,14 @@ static int __init therm_pm72_init(void) | |||
2236 | return -ENODEV; | 2237 | return -ENODEV; |
2237 | } | 2238 | } |
2238 | 2239 | ||
2239 | of_register_driver(&fcu_of_platform_driver); | 2240 | of_register_platform_driver(&fcu_of_platform_driver); |
2240 | 2241 | ||
2241 | return 0; | 2242 | return 0; |
2242 | } | 2243 | } |
2243 | 2244 | ||
2244 | static void __exit therm_pm72_exit(void) | 2245 | static void __exit therm_pm72_exit(void) |
2245 | { | 2246 | { |
2246 | of_unregister_driver(&fcu_of_platform_driver); | 2247 | of_unregister_platform_driver(&fcu_of_platform_driver); |
2247 | 2248 | ||
2248 | if (of_dev) | 2249 | if (of_dev) |
2249 | of_device_unregister(of_dev); | 2250 | of_device_unregister(of_dev); |
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index 738faab1b22c..a1d3a987cb3a 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c | |||
@@ -36,12 +36,13 @@ | |||
36 | #include <linux/i2c.h> | 36 | #include <linux/i2c.h> |
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <linux/init.h> | 38 | #include <linux/init.h> |
39 | |||
39 | #include <asm/prom.h> | 40 | #include <asm/prom.h> |
40 | #include <asm/machdep.h> | 41 | #include <asm/machdep.h> |
41 | #include <asm/io.h> | 42 | #include <asm/io.h> |
42 | #include <asm/system.h> | 43 | #include <asm/system.h> |
43 | #include <asm/sections.h> | 44 | #include <asm/sections.h> |
44 | #include <asm/of_device.h> | 45 | #include <asm/of_platform.h> |
45 | #include <asm/macio.h> | 46 | #include <asm/macio.h> |
46 | 47 | ||
47 | #define LOG_TEMP 0 /* continously log temperature */ | 48 | #define LOG_TEMP 0 /* continously log temperature */ |
@@ -511,14 +512,14 @@ g4fan_init( void ) | |||
511 | return -ENODEV; | 512 | return -ENODEV; |
512 | } | 513 | } |
513 | 514 | ||
514 | of_register_driver( &therm_of_driver ); | 515 | of_register_platform_driver( &therm_of_driver ); |
515 | return 0; | 516 | return 0; |
516 | } | 517 | } |
517 | 518 | ||
518 | static void __exit | 519 | static void __exit |
519 | g4fan_exit( void ) | 520 | g4fan_exit( void ) |
520 | { | 521 | { |
521 | of_unregister_driver( &therm_of_driver ); | 522 | of_unregister_platform_driver( &therm_of_driver ); |
522 | 523 | ||
523 | if( x.of_dev ) | 524 | if( x.of_dev ) |
524 | of_device_unregister( x.of_dev ); | 525 | of_device_unregister( x.of_dev ); |
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index e63ea1c1f3c1..c8558d4ed506 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #include <linux/interrupt.h> | 42 | #include <linux/interrupt.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
44 | #include <linux/sysdev.h> | 44 | #include <linux/sysdev.h> |
45 | #include <linux/suspend.h> | 45 | #include <linux/freezer.h> |
46 | #include <linux/syscalls.h> | 46 | #include <linux/syscalls.h> |
47 | #include <linux/cpu.h> | 47 | #include <linux/cpu.h> |
48 | #include <asm/prom.h> | 48 | #include <asm/prom.h> |
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c index ab3faa702d58..e947af982f93 100644 --- a/drivers/macintosh/windfarm_core.c +++ b/drivers/macintosh/windfarm_core.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/device.h> | 34 | #include <linux/device.h> |
35 | #include <linux/platform_device.h> | 35 | #include <linux/platform_device.h> |
36 | #include <linux/mutex.h> | 36 | #include <linux/mutex.h> |
37 | #include <linux/freezer.h> | ||
37 | 38 | ||
38 | #include <asm/prom.h> | 39 | #include <asm/prom.h> |
39 | 40 | ||
diff --git a/drivers/macintosh/windfarm_pm112.c b/drivers/macintosh/windfarm_pm112.c index fa4b13f89369..b3fbb45bc90a 100644 --- a/drivers/macintosh/windfarm_pm112.c +++ b/drivers/macintosh/windfarm_pm112.c | |||
@@ -685,6 +685,17 @@ static int __init wf_pm112_init(void) | |||
685 | ++nr_cores; | 685 | ++nr_cores; |
686 | 686 | ||
687 | printk(KERN_INFO "windfarm: initializing for dual-core desktop G5\n"); | 687 | printk(KERN_INFO "windfarm: initializing for dual-core desktop G5\n"); |
688 | |||
689 | #ifdef MODULE | ||
690 | request_module("windfarm_smu_controls"); | ||
691 | request_module("windfarm_smu_sensors"); | ||
692 | request_module("windfarm_smu_sat"); | ||
693 | request_module("windfarm_lm75_sensor"); | ||
694 | request_module("windfarm_max6690_sensor"); | ||
695 | request_module("windfarm_cpufreq_clamp"); | ||
696 | |||
697 | #endif /* MODULE */ | ||
698 | |||
688 | platform_driver_register(&wf_pm112_driver); | 699 | platform_driver_register(&wf_pm112_driver); |
689 | return 0; | 700 | return 0; |
690 | } | 701 | } |
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c index 2a944851b8e1..f24fa734046a 100644 --- a/drivers/macintosh/windfarm_pm81.c +++ b/drivers/macintosh/windfarm_pm81.c | |||
@@ -788,6 +788,7 @@ static int __init wf_smu_init(void) | |||
788 | request_module("windfarm_smu_controls"); | 788 | request_module("windfarm_smu_controls"); |
789 | request_module("windfarm_smu_sensors"); | 789 | request_module("windfarm_smu_sensors"); |
790 | request_module("windfarm_lm75_sensor"); | 790 | request_module("windfarm_lm75_sensor"); |
791 | request_module("windfarm_cpufreq_clamp"); | ||
791 | 792 | ||
792 | #endif /* MODULE */ | 793 | #endif /* MODULE */ |
793 | platform_driver_register(&wf_smu_driver); | 794 | platform_driver_register(&wf_smu_driver); |
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c index 9961a67b4f85..26eee69ebe6d 100644 --- a/drivers/macintosh/windfarm_pm91.c +++ b/drivers/macintosh/windfarm_pm91.c | |||
@@ -719,6 +719,7 @@ static int __init wf_smu_init(void) | |||
719 | request_module("windfarm_smu_controls"); | 719 | request_module("windfarm_smu_controls"); |
720 | request_module("windfarm_smu_sensors"); | 720 | request_module("windfarm_smu_sensors"); |
721 | request_module("windfarm_lm75_sensor"); | 721 | request_module("windfarm_lm75_sensor"); |
722 | request_module("windfarm_cpufreq_clamp"); | ||
722 | 723 | ||
723 | #endif /* MODULE */ | 724 | #endif /* MODULE */ |
724 | platform_driver_register(&wf_smu_driver); | 725 | platform_driver_register(&wf_smu_driver); |