aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:50:19 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:50:19 -0400
commitdf6d3916f3b7b7e2067567a256dd4f0c1ea854a2 (patch)
tree0fdeab1ab5d566605fc99aeb5ea3f621f11e7608 /drivers/macintosh
parent74add80cbd7fe246c893b93ee75ac59acdd01dd4 (diff)
parent197686dfe0038fd190326d118b743ff65ad20c0e (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc: (77 commits) [POWERPC] Abolish powerpc_flash_init() [POWERPC] Early serial debug support for PPC44x [POWERPC] Support for the Ebony 440GP reference board in arch/powerpc [POWERPC] Add device tree for Ebony [POWERPC] Add powerpc/platforms/44x, disable platforms/4xx for now [POWERPC] MPIC U3/U4 MSI backend [POWERPC] MPIC MSI allocator [POWERPC] Enable MSI mappings for MPIC [POWERPC] Tell Phyp we support MSI [POWERPC] RTAS MSI implementation [POWERPC] PowerPC MSI infrastructure [POWERPC] Rip out the existing powerpc msi stubs [POWERPC] Remove use of 4level-fixup.h for ppc32 [POWERPC] Add powerpc PCI-E reset API implementation [POWERPC] Holly bootwrapper [POWERPC] Holly DTS [POWERPC] Holly defconfig [POWERPC] Add support for 750CL Holly board [POWERPC] Generalize tsi108 PCI setup [POWERPC] Generalize tsi108 PHY types ... Fixed conflict in include/asm-powerpc/kdebug.h manually Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/macintosh')
-rw-r--r--drivers/macintosh/Kconfig12
-rw-r--r--drivers/macintosh/apm_emu.c521
-rw-r--r--drivers/macintosh/mac_hid.c8
-rw-r--r--drivers/macintosh/macio_sysfs.c27
-rw-r--r--drivers/macintosh/smu.c2
-rw-r--r--drivers/macintosh/therm_adt746x.c4
-rw-r--r--drivers/macintosh/via-pmu-led.c35
-rw-r--r--drivers/macintosh/via-pmu.c12
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c4
-rw-r--r--drivers/macintosh/windfarm_max6690_sensor.c2
-rw-r--r--drivers/macintosh/windfarm_smu_controls.c2
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c2
12 files changed, 81 insertions, 550 deletions
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 1a86387e23be..a32c91e27b3c 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -1,6 +1,10 @@
1 1
2menu "Macintosh device drivers" 2menuconfig MACINTOSH_DRIVERS
3 bool "Macintosh device drivers"
3 depends on PPC || MAC || X86 4 depends on PPC || MAC || X86
5 default y
6
7if MACINTOSH_DRIVERS
4 8
5config ADB 9config ADB
6 bool "Apple Desktop Bus (ADB) support" 10 bool "Apple Desktop Bus (ADB) support"
@@ -109,7 +113,9 @@ config PMAC_SMU
109 113
110config PMAC_APM_EMU 114config PMAC_APM_EMU
111 tristate "APM emulation" 115 tristate "APM emulation"
112 depends on PPC_PMAC && PPC32 && PM && ADB_PMU 116 select SYS_SUPPORTS_APM_EMULATION
117 select APM_EMULATION
118 depends on ADB_PMU && PM
113 119
114config PMAC_MEDIABAY 120config PMAC_MEDIABAY
115 bool "Support PowerBook hotswap media bay" 121 bool "Support PowerBook hotswap media bay"
@@ -234,4 +240,4 @@ config PMAC_RACKMETER
234 This driver procides some support to control the front panel 240 This driver procides some support to control the front panel
235 blue LEDs "vu-meter" of the XServer macs. 241 blue LEDs "vu-meter" of the XServer macs.
236 242
237endmenu 243endif # MACINTOSH_DRIVERS
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c
index cdb0bead9917..9821e6361e60 100644
--- a/drivers/macintosh/apm_emu.c
+++ b/drivers/macintosh/apm_emu.c
@@ -1,9 +1,7 @@
1/* APM emulation layer for PowerMac 1/*
2 * 2 * APM emulation for PMU-based machines
3 * Copyright 2001 Benjamin Herrenschmidt (benh@kernel.crashing.org)
4 * 3 *
5 * Lots of code inherited from apm.c, see appropriate notice in 4 * Copyright 2001 Benjamin Herrenschmidt (benh@kernel.crashing.org)
6 * arch/i386/kernel/apm.c
7 * 5 *
8 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the 7 * under the terms of the GNU General Public License as published by the
@@ -18,429 +16,39 @@
18 * 16 *
19 */ 17 */
20 18
21#include <linux/module.h>
22
23#include <linux/poll.h>
24#include <linux/types.h>
25#include <linux/stddef.h>
26#include <linux/timer.h>
27#include <linux/fcntl.h>
28#include <linux/slab.h>
29#include <linux/stat.h>
30#include <linux/proc_fs.h>
31#include <linux/miscdevice.h>
32#include <linux/apm_bios.h>
33#include <linux/init.h>
34#include <linux/sched.h>
35#include <linux/pm.h>
36#include <linux/kernel.h> 19#include <linux/kernel.h>
37#include <linux/smp_lock.h> 20#include <linux/module.h>
38 21#include <linux/apm-emulation.h>
39#include <linux/adb.h> 22#include <linux/adb.h>
40#include <linux/pmu.h> 23#include <linux/pmu.h>
41 24
42#include <asm/system.h>
43#include <asm/uaccess.h>
44#include <asm/machdep.h>
45
46#undef DEBUG
47
48#ifdef DEBUG
49#define DBG(args...) printk(KERN_DEBUG args)
50//#define DBG(args...) xmon_printf(args)
51#else
52#define DBG(args...) do { } while (0)
53#endif
54
55/*
56 * The apm_bios device is one of the misc char devices.
57 * This is its minor number.
58 */
59#define APM_MINOR_DEV 134
60
61/*
62 * Maximum number of events stored
63 */
64#define APM_MAX_EVENTS 20
65
66#define FAKE_APM_BIOS_VERSION 0x0101
67
68#define APM_USER_NOTIFY_TIMEOUT (5*HZ)
69
70/*
71 * The per-file APM data
72 */
73struct apm_user {
74 int magic;
75 struct apm_user * next;
76 int suser: 1;
77 int suspend_waiting: 1;
78 int suspends_pending;
79 int suspends_read;
80 int event_head;
81 int event_tail;
82 apm_event_t events[APM_MAX_EVENTS];
83};
84
85/*
86 * The magic number in apm_user
87 */
88#define APM_BIOS_MAGIC 0x4101
89
90/*
91 * Local variables
92 */
93static int suspends_pending;
94
95static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
96static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
97static struct apm_user * user_list;
98
99static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when);
100static struct pmu_sleep_notifier apm_sleep_notifier = {
101 apm_notify_sleep,
102 SLEEP_LEVEL_USERLAND,
103};
104
105static const char driver_version[] = "0.5"; /* no spaces */
106
107#ifdef DEBUG
108static char * apm_event_name[] = {
109 "system standby",
110 "system suspend",
111 "normal resume",
112 "critical resume",
113 "low battery",
114 "power status change",
115 "update time",
116 "critical suspend",
117 "user standby",
118 "user suspend",
119 "system standby resume",
120 "capabilities change"
121};
122#define NR_APM_EVENT_NAME \
123 (sizeof(apm_event_name) / sizeof(apm_event_name[0]))
124
125#endif
126
127static int queue_empty(struct apm_user *as)
128{
129 return as->event_head == as->event_tail;
130}
131
132static apm_event_t get_queued_event(struct apm_user *as)
133{
134 as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS;
135 return as->events[as->event_tail];
136}
137
138static void queue_event(apm_event_t event, struct apm_user *sender)
139{
140 struct apm_user * as;
141
142 DBG("apm_emu: queue_event(%s)\n", apm_event_name[event-1]);
143 if (user_list == NULL)
144 return;
145 for (as = user_list; as != NULL; as = as->next) {
146 if (as == sender)
147 continue;
148 as->event_head = (as->event_head + 1) % APM_MAX_EVENTS;
149 if (as->event_head == as->event_tail) {
150 static int notified;
151
152 if (notified++ == 0)
153 printk(KERN_ERR "apm_emu: an event queue overflowed\n");
154 as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS;
155 }
156 as->events[as->event_head] = event;
157 if (!as->suser)
158 continue;
159 switch (event) {
160 case APM_SYS_SUSPEND:
161 case APM_USER_SUSPEND:
162 as->suspends_pending++;
163 suspends_pending++;
164 break;
165 case APM_NORMAL_RESUME:
166 as->suspend_waiting = 0;
167 break;
168 }
169 }
170 wake_up_interruptible(&apm_waitqueue);
171}
172
173static int check_apm_user(struct apm_user *as, const char *func)
174{
175 if ((as == NULL) || (as->magic != APM_BIOS_MAGIC)) {
176 printk(KERN_ERR "apm_emu: %s passed bad filp\n", func);
177 return 1;
178 }
179 return 0;
180}
181
182static ssize_t do_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos)
183{
184 struct apm_user * as;
185 size_t i;
186 apm_event_t event;
187 DECLARE_WAITQUEUE(wait, current);
188
189 as = fp->private_data;
190 if (check_apm_user(as, "read"))
191 return -EIO;
192 if (count < sizeof(apm_event_t))
193 return -EINVAL;
194 if (queue_empty(as)) {
195 if (fp->f_flags & O_NONBLOCK)
196 return -EAGAIN;
197 add_wait_queue(&apm_waitqueue, &wait);
198repeat:
199 set_current_state(TASK_INTERRUPTIBLE);
200 if (queue_empty(as) && !signal_pending(current)) {
201 schedule();
202 goto repeat;
203 }
204 set_current_state(TASK_RUNNING);
205 remove_wait_queue(&apm_waitqueue, &wait);
206 }
207 i = count;
208 while ((i >= sizeof(event)) && !queue_empty(as)) {
209 event = get_queued_event(as);
210 DBG("apm_emu: do_read, returning: %s\n", apm_event_name[event-1]);
211 if (copy_to_user(buf, &event, sizeof(event))) {
212 if (i < count)
213 break;
214 return -EFAULT;
215 }
216 switch (event) {
217 case APM_SYS_SUSPEND:
218 case APM_USER_SUSPEND:
219 as->suspends_read++;
220 break;
221 }
222 buf += sizeof(event);
223 i -= sizeof(event);
224 }
225 if (i < count)
226 return count - i;
227 if (signal_pending(current))
228 return -ERESTARTSYS;
229 return 0;
230}
231
232static unsigned int do_poll(struct file *fp, poll_table * wait)
233{
234 struct apm_user * as;
235
236 as = fp->private_data;
237 if (check_apm_user(as, "poll"))
238 return 0;
239 poll_wait(fp, &apm_waitqueue, wait);
240 if (!queue_empty(as))
241 return POLLIN | POLLRDNORM;
242 return 0;
243}
244
245static int do_ioctl(struct inode * inode, struct file *filp,
246 u_int cmd, u_long arg)
247{
248 struct apm_user * as;
249 DECLARE_WAITQUEUE(wait, current);
250
251 as = filp->private_data;
252 if (check_apm_user(as, "ioctl"))
253 return -EIO;
254 if (!as->suser)
255 return -EPERM;
256 switch (cmd) {
257 case APM_IOC_SUSPEND:
258 /* If a suspend message was sent to userland, we
259 * consider this as a confirmation message
260 */
261 if (as->suspends_read > 0) {
262 as->suspends_read--;
263 as->suspends_pending--;
264 suspends_pending--;
265 } else {
266 // Route to PMU suspend ?
267 break;
268 }
269 as->suspend_waiting = 1;
270 add_wait_queue(&apm_waitqueue, &wait);
271 DBG("apm_emu: ioctl waking up sleep waiter !\n");
272 wake_up(&apm_suspend_waitqueue);
273 mb();
274 while(as->suspend_waiting && !signal_pending(current)) {
275 set_current_state(TASK_INTERRUPTIBLE);
276 schedule();
277 }
278 set_current_state(TASK_RUNNING);
279 remove_wait_queue(&apm_waitqueue, &wait);
280 break;
281 default:
282 return -EINVAL;
283 }
284 return 0;
285}
286
287static int do_release(struct inode * inode, struct file * filp)
288{
289 struct apm_user * as;
290
291 as = filp->private_data;
292 if (check_apm_user(as, "release"))
293 return 0;
294 filp->private_data = NULL;
295 lock_kernel();
296 if (as->suspends_pending > 0) {
297 suspends_pending -= as->suspends_pending;
298 if (suspends_pending <= 0)
299 wake_up(&apm_suspend_waitqueue);
300 }
301 if (user_list == as)
302 user_list = as->next;
303 else {
304 struct apm_user * as1;
305
306 for (as1 = user_list;
307 (as1 != NULL) && (as1->next != as);
308 as1 = as1->next)
309 ;
310 if (as1 == NULL)
311 printk(KERN_ERR "apm: filp not in user list\n");
312 else
313 as1->next = as->next;
314 }
315 unlock_kernel();
316 kfree(as);
317 return 0;
318}
319
320static int do_open(struct inode * inode, struct file * filp)
321{
322 struct apm_user * as;
323
324 as = kmalloc(sizeof(*as), GFP_KERNEL);
325 if (as == NULL) {
326 printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n",
327 sizeof(*as));
328 return -ENOMEM;
329 }
330 as->magic = APM_BIOS_MAGIC;
331 as->event_tail = as->event_head = 0;
332 as->suspends_pending = 0;
333 as->suspends_read = 0;
334 /*
335 * XXX - this is a tiny bit broken, when we consider BSD
336 * process accounting. If the device is opened by root, we
337 * instantly flag that we used superuser privs. Who knows,
338 * we might close the device immediately without doing a
339 * privileged operation -- cevans
340 */
341 as->suser = capable(CAP_SYS_ADMIN);
342 as->next = user_list;
343 user_list = as;
344 filp->private_data = as;
345
346 DBG("apm_emu: opened by %s, suser: %d\n", current->comm, (int)as->suser);
347
348 return 0;
349}
350
351/* Wait for all clients to ack the suspend request. APM API
352 * doesn't provide a way to NAK, but this could be added
353 * here.
354 */
355static void wait_all_suspend(void)
356{
357 DECLARE_WAITQUEUE(wait, current);
358
359 add_wait_queue(&apm_suspend_waitqueue, &wait);
360 DBG("apm_emu: wait_all_suspend(), suspends_pending: %d\n", suspends_pending);
361 while(suspends_pending > 0) {
362 set_current_state(TASK_UNINTERRUPTIBLE);
363 schedule();
364 }
365 set_current_state(TASK_RUNNING);
366 remove_wait_queue(&apm_suspend_waitqueue, &wait);
367
368 DBG("apm_emu: wait_all_suspend() - complete !\n");
369}
370
371static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when)
372{
373 switch(when) {
374 case PBOOK_SLEEP_REQUEST:
375 queue_event(APM_SYS_SUSPEND, NULL);
376 wait_all_suspend();
377 break;
378 case PBOOK_WAKE:
379 queue_event(APM_NORMAL_RESUME, NULL);
380 break;
381 }
382}
383
384#define APM_CRITICAL 10 25#define APM_CRITICAL 10
385#define APM_LOW 30 26#define APM_LOW 30
386 27
387static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length) 28static void pmu_apm_get_power_status(struct apm_power_info *info)
388{ 29{
389 /* Arguments, with symbols from linux/apm_bios.h. Information is 30 int percentage = -1;
390 from the Get Power Status (0x0a) call unless otherwise noted. 31 int batteries = 0;
32 int time_units = -1;
33 int real_count = 0;
34 int i;
35 char charging = 0;
36 long charge = -1;
37 long amperage = 0;
38 unsigned long btype = 0;
39
40 info->battery_status = APM_BATTERY_STATUS_UNKNOWN;
41 info->battery_flag = APM_BATTERY_FLAG_UNKNOWN;
42 info->units = APM_UNITS_MINS;
43
44 if (pmu_power_flags & PMU_PWR_AC_PRESENT)
45 info->ac_line_status = APM_AC_ONLINE;
46 else
47 info->ac_line_status = APM_AC_OFFLINE;
391 48
392 0) Linux driver version (this will change if format changes)
393 1) APM BIOS Version. Usually 1.0, 1.1 or 1.2.
394 2) APM flags from APM Installation Check (0x00):
395 bit 0: APM_16_BIT_SUPPORT
396 bit 1: APM_32_BIT_SUPPORT
397 bit 2: APM_IDLE_SLOWS_CLOCK
398 bit 3: APM_BIOS_DISABLED
399 bit 4: APM_BIOS_DISENGAGED
400 3) AC line status
401 0x00: Off-line
402 0x01: On-line
403 0x02: On backup power (BIOS >= 1.1 only)
404 0xff: Unknown
405 4) Battery status
406 0x00: High
407 0x01: Low
408 0x02: Critical
409 0x03: Charging
410 0x04: Selected battery not present (BIOS >= 1.2 only)
411 0xff: Unknown
412 5) Battery flag
413 bit 0: High
414 bit 1: Low
415 bit 2: Critical
416 bit 3: Charging
417 bit 7: No system battery
418 0xff: Unknown
419 6) Remaining battery life (percentage of charge):
420 0-100: valid
421 -1: Unknown
422 7) Remaining battery life (time units):
423 Number of remaining minutes or seconds
424 -1: Unknown
425 8) min = minutes; sec = seconds */
426
427 unsigned short ac_line_status;
428 unsigned short battery_status = 0;
429 unsigned short battery_flag = 0xff;
430 int percentage = -1;
431 int time_units = -1;
432 int real_count = 0;
433 int i;
434 char * p = buf;
435 char charging = 0;
436 long charge = -1;
437 long amperage = 0;
438 unsigned long btype = 0;
439
440 ac_line_status = ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0);
441 for (i=0; i<pmu_battery_count; i++) { 49 for (i=0; i<pmu_battery_count; i++) {
442 if (pmu_batteries[i].flags & PMU_BATT_PRESENT) { 50 if (pmu_batteries[i].flags & PMU_BATT_PRESENT) {
443 battery_status++; 51 batteries++;
444 if (percentage < 0) 52 if (percentage < 0)
445 percentage = 0; 53 percentage = 0;
446 if (charge < 0) 54 if (charge < 0)
@@ -456,9 +64,9 @@ static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length)
456 charging++; 64 charging++;
457 } 65 }
458 } 66 }
459 if (0 == battery_status) 67 if (batteries == 0)
460 ac_line_status = 1; 68 info->ac_line_status = APM_AC_ONLINE;
461 battery_status = 0xff; 69
462 if (real_count) { 70 if (real_count) {
463 if (amperage < 0) { 71 if (amperage < 0) {
464 if (btype == PMU_BATT_TYPE_SMART) 72 if (btype == PMU_BATT_TYPE_SMART)
@@ -468,85 +76,44 @@ static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length)
468 } 76 }
469 percentage /= real_count; 77 percentage /= real_count;
470 if (charging > 0) { 78 if (charging > 0) {
471 battery_status = 0x03; 79 info->battery_status = APM_BATTERY_STATUS_CHARGING;
472 battery_flag = 0x08; 80 info->battery_flag = APM_BATTERY_FLAG_CHARGING;
473 } else if (percentage <= APM_CRITICAL) { 81 } else if (percentage <= APM_CRITICAL) {
474 battery_status = 0x02; 82 info->battery_status = APM_BATTERY_STATUS_CRITICAL;
475 battery_flag = 0x04; 83 info->battery_flag = APM_BATTERY_FLAG_CRITICAL;
476 } else if (percentage <= APM_LOW) { 84 } else if (percentage <= APM_LOW) {
477 battery_status = 0x01; 85 info->battery_status = APM_BATTERY_STATUS_LOW;
478 battery_flag = 0x02; 86 info->battery_flag = APM_BATTERY_FLAG_LOW;
479 } else { 87 } else {
480 battery_status = 0x00; 88 info->battery_status = APM_BATTERY_STATUS_HIGH;
481 battery_flag = 0x01; 89 info->battery_flag = APM_BATTERY_FLAG_HIGH;
482 } 90 }
483 } 91 }
484 p += sprintf(p, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
485 driver_version,
486 (FAKE_APM_BIOS_VERSION >> 8) & 0xff,
487 FAKE_APM_BIOS_VERSION & 0xff,
488 0,
489 ac_line_status,
490 battery_status,
491 battery_flag,
492 percentage,
493 time_units,
494 "min");
495 92
496 return p - buf; 93 info->battery_life = percentage;
94 info->time = time_units;
497} 95}
498 96
499static const struct file_operations apm_bios_fops = {
500 .owner = THIS_MODULE,
501 .read = do_read,
502 .poll = do_poll,
503 .ioctl = do_ioctl,
504 .open = do_open,
505 .release = do_release,
506};
507
508static struct miscdevice apm_device = {
509 APM_MINOR_DEV,
510 "apm_bios",
511 &apm_bios_fops
512};
513
514static int __init apm_emu_init(void) 97static int __init apm_emu_init(void)
515{ 98{
516 struct proc_dir_entry *apm_proc; 99 apm_get_power_status = pmu_apm_get_power_status;
517
518 if (sys_ctrler != SYS_CTRLER_PMU) {
519 printk(KERN_INFO "apm_emu: Requires a machine with a PMU.\n");
520 return -ENODEV;
521 }
522
523 apm_proc = create_proc_info_entry("apm", 0, NULL, apm_emu_get_info);
524 if (apm_proc)
525 apm_proc->owner = THIS_MODULE;
526 100
527 if (misc_register(&apm_device) != 0) 101 printk(KERN_INFO "apm_emu: PMU APM Emulation initialized.\n");
528 printk(KERN_INFO "Could not create misc. device for apm\n");
529
530 pmu_register_sleep_notifier(&apm_sleep_notifier);
531
532 printk(KERN_INFO "apm_emu: APM Emulation %s initialized.\n", driver_version);
533 102
534 return 0; 103 return 0;
535} 104}
536 105
537static void __exit apm_emu_exit(void) 106static void __exit apm_emu_exit(void)
538{ 107{
539 pmu_unregister_sleep_notifier(&apm_sleep_notifier); 108 if (apm_get_power_status == pmu_apm_get_power_status)
540 misc_deregister(&apm_device); 109 apm_get_power_status = NULL;
541 remove_proc_entry("apm", NULL);
542 110
543 printk(KERN_INFO "apm_emu: APM Emulation removed.\n"); 111 printk(KERN_INFO "apm_emu: PMU APM Emulation removed.\n");
544} 112}
545 113
546module_init(apm_emu_init); 114module_init(apm_emu_init);
547module_exit(apm_emu_exit); 115module_exit(apm_emu_exit);
548 116
549MODULE_AUTHOR("Benjamin Herrenschmidt"); 117MODULE_AUTHOR("Benjamin Herrenschmidt");
550MODULE_DESCRIPTION("APM emulation layer for PowerMac"); 118MODULE_DESCRIPTION("APM emulation for PowerMac");
551MODULE_LICENSE("GPL"); 119MODULE_LICENSE("GPL");
552
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index 1599dc34f15f..76c1e8e4a487 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -24,7 +24,7 @@ static int mouse_last_keycode;
24 24
25#if defined(CONFIG_SYSCTL) 25#if defined(CONFIG_SYSCTL)
26/* file(s) in /proc/sys/dev/mac_hid */ 26/* file(s) in /proc/sys/dev/mac_hid */
27ctl_table mac_hid_files[] = { 27static ctl_table mac_hid_files[] = {
28 { 28 {
29 .ctl_name = DEV_MAC_HID_MOUSE_BUTTON_EMULATION, 29 .ctl_name = DEV_MAC_HID_MOUSE_BUTTON_EMULATION,
30 .procname = "mouse_button_emulation", 30 .procname = "mouse_button_emulation",
@@ -53,7 +53,7 @@ ctl_table mac_hid_files[] = {
53}; 53};
54 54
55/* dir in /proc/sys/dev */ 55/* dir in /proc/sys/dev */
56ctl_table mac_hid_dir[] = { 56static ctl_table mac_hid_dir[] = {
57 { 57 {
58 .ctl_name = DEV_MAC_HID, 58 .ctl_name = DEV_MAC_HID,
59 .procname = "mac_hid", 59 .procname = "mac_hid",
@@ -65,7 +65,7 @@ ctl_table mac_hid_dir[] = {
65}; 65};
66 66
67/* /proc/sys/dev itself, in case that is not there yet */ 67/* /proc/sys/dev itself, in case that is not there yet */
68ctl_table mac_hid_root_dir[] = { 68static ctl_table mac_hid_root_dir[] = {
69 { 69 {
70 .ctl_name = CTL_DEV, 70 .ctl_name = CTL_DEV,
71 .procname = "dev", 71 .procname = "dev",
@@ -127,7 +127,7 @@ static int emumousebtn_input_register(void)
127 return ret; 127 return ret;
128} 128}
129 129
130int __init mac_hid_init(void) 130static int __init mac_hid_init(void)
131{ 131{
132 int err; 132 int err;
133 133
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index cc8267912656..112e5ef728f1 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -41,28 +41,15 @@ compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
41static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, 41static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
42 char *buf) 42 char *buf)
43{ 43{
44 struct of_device *of; 44 struct of_device *ofdev = to_of_device(dev);
45 const char *compat; 45 int len;
46 int cplen;
47 int length;
48 46
49 of = &to_macio_device (dev)->ofdev; 47 len = of_device_get_modalias(ofdev, buf, PAGE_SIZE);
50 compat = of_get_property(of->node, "compatible", &cplen);
51 if (!compat) compat = "", cplen = 1;
52 length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type);
53 buf += length;
54 while (cplen > 0) {
55 int l;
56 l = sprintf (buf, "C%s", compat);
57 length += l;
58 buf += l;
59 l = strlen (compat) + 1;
60 compat += l;
61 cplen -= l;
62 }
63 length += sprintf(buf, "\n");
64 48
65 return length; 49 buf[len] = '\n';
50 buf[len+1] = 0;
51
52 return len+1;
66} 53}
67 54
68macio_config_of_attr (name, "%s\n"); 55macio_config_of_attr (name, "%s\n");
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index a98a328b1cfc..f8e1a135bf9d 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -606,7 +606,7 @@ static void smu_expose_childs(struct work_struct *unused)
606 struct device_node *np; 606 struct device_node *np;
607 607
608 for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;) 608 for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;)
609 if (device_is_compatible(np, "smu-sensors")) 609 if (of_device_is_compatible(np, "smu-sensors"))
610 of_platform_device_create(np, "smu-sensors", 610 of_platform_device_create(np, "smu-sensors",
611 &smu->of_dev->dev); 611 &smu->of_dev->dev);
612} 612}
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index 6c3734325f8e..bd55e6ab99fc 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -559,9 +559,9 @@ thermostat_init(void)
559 np = of_find_node_by_name(NULL, "fan"); 559 np = of_find_node_by_name(NULL, "fan");
560 if (!np) 560 if (!np)
561 return -ENODEV; 561 return -ENODEV;
562 if (device_is_compatible(np, "adt7460")) 562 if (of_device_is_compatible(np, "adt7460"))
563 therm_type = ADT7460; 563 therm_type = ADT7460;
564 else if (device_is_compatible(np, "adt7467")) 564 else if (of_device_is_compatible(np, "adt7467"))
565 therm_type = ADT7467; 565 therm_type = ADT7467;
566 else 566 else
567 return -ENODEV; 567 return -ENODEV;
diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index fc89a7047cd0..55ad95671387 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -31,7 +31,6 @@ static spinlock_t pmu_blink_lock;
31static struct adb_request pmu_blink_req; 31static struct adb_request pmu_blink_req;
32/* -1: no change, 0: request off, 1: request on */ 32/* -1: no change, 0: request off, 1: request on */
33static int requested_change; 33static int requested_change;
34static int sleeping;
35 34
36static void pmu_req_done(struct adb_request * req) 35static void pmu_req_done(struct adb_request * req)
37{ 36{
@@ -41,7 +40,7 @@ static void pmu_req_done(struct adb_request * req)
41 /* if someone requested a change in the meantime 40 /* if someone requested a change in the meantime
42 * (we only see the last one which is fine) 41 * (we only see the last one which is fine)
43 * then apply it now */ 42 * then apply it now */
44 if (requested_change != -1 && !sleeping) 43 if (requested_change != -1 && !pmu_sys_suspended)
45 pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change); 44 pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
46 /* reset requested change */ 45 /* reset requested change */
47 requested_change = -1; 46 requested_change = -1;
@@ -66,7 +65,7 @@ static void pmu_led_set(struct led_classdev *led_cdev,
66 break; 65 break;
67 } 66 }
68 /* if request isn't done, then don't do anything */ 67 /* if request isn't done, then don't do anything */
69 if (pmu_blink_req.complete && !sleeping) 68 if (pmu_blink_req.complete && !pmu_sys_suspended)
70 pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change); 69 pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
71 out: 70 out:
72 spin_unlock_irqrestore(&pmu_blink_lock, flags); 71 spin_unlock_irqrestore(&pmu_blink_lock, flags);
@@ -80,32 +79,6 @@ static struct led_classdev pmu_led = {
80 .brightness_set = pmu_led_set, 79 .brightness_set = pmu_led_set,
81}; 80};
82 81
83#ifdef CONFIG_PM
84static void pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
85{
86 unsigned long flags;
87
88 spin_lock_irqsave(&pmu_blink_lock, flags);
89
90 switch (when) {
91 case PBOOK_SLEEP_REQUEST:
92 sleeping = 1;
93 break;
94 case PBOOK_WAKE:
95 sleeping = 0;
96 break;
97 default:
98 /* do nothing */
99 break;
100 }
101 spin_unlock_irqrestore(&pmu_blink_lock, flags);
102}
103
104static struct pmu_sleep_notifier via_pmu_led_sleep_notif = {
105 .notifier_call = pmu_led_sleep_call,
106};
107#endif
108
109static int __init via_pmu_led_init(void) 82static int __init via_pmu_led_init(void)
110{ 83{
111 struct device_node *dt; 84 struct device_node *dt;
@@ -135,9 +108,7 @@ static int __init via_pmu_led_init(void)
135 /* no outstanding req */ 108 /* no outstanding req */
136 pmu_blink_req.complete = 1; 109 pmu_blink_req.complete = 1;
137 pmu_blink_req.done = pmu_req_done; 110 pmu_blink_req.done = pmu_req_done;
138#ifdef CONFIG_PM 111
139 pmu_register_sleep_notifier(&via_pmu_led_sleep_notif);
140#endif
141 return led_classdev_register(NULL, &pmu_led); 112 return led_classdev_register(NULL, &pmu_led);
142} 113}
143 114
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 1729d3fd7a11..157080b3b468 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -310,14 +310,14 @@ int __init find_via_pmu(void)
310 PMU_INT_TICK; 310 PMU_INT_TICK;
311 311
312 if (vias->parent->name && ((strcmp(vias->parent->name, "ohare") == 0) 312 if (vias->parent->name && ((strcmp(vias->parent->name, "ohare") == 0)
313 || device_is_compatible(vias->parent, "ohare"))) 313 || of_device_is_compatible(vias->parent, "ohare")))
314 pmu_kind = PMU_OHARE_BASED; 314 pmu_kind = PMU_OHARE_BASED;
315 else if (device_is_compatible(vias->parent, "paddington")) 315 else if (of_device_is_compatible(vias->parent, "paddington"))
316 pmu_kind = PMU_PADDINGTON_BASED; 316 pmu_kind = PMU_PADDINGTON_BASED;
317 else if (device_is_compatible(vias->parent, "heathrow")) 317 else if (of_device_is_compatible(vias->parent, "heathrow"))
318 pmu_kind = PMU_HEATHROW_BASED; 318 pmu_kind = PMU_HEATHROW_BASED;
319 else if (device_is_compatible(vias->parent, "Keylargo") 319 else if (of_device_is_compatible(vias->parent, "Keylargo")
320 || device_is_compatible(vias->parent, "K2-Keylargo")) { 320 || of_device_is_compatible(vias->parent, "K2-Keylargo")) {
321 struct device_node *gpiop; 321 struct device_node *gpiop;
322 struct device_node *adbp; 322 struct device_node *adbp;
323 u64 gaddr = OF_BAD_ADDR; 323 u64 gaddr = OF_BAD_ADDR;
@@ -2759,7 +2759,7 @@ pmu_polled_request(struct adb_request *req)
2759 2759
2760#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 2760#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
2761 2761
2762static int pmu_sys_suspended; 2762int pmu_sys_suspended;
2763 2763
2764static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state) 2764static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
2765{ 2765{
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index ab4d1b63f63e..a0fabf3c2008 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -188,10 +188,10 @@ static int wf_lm75_attach(struct i2c_adapter *adapter)
188 if (loc == NULL || addr == 0) 188 if (loc == NULL || addr == 0)
189 continue; 189 continue;
190 /* real lm75 */ 190 /* real lm75 */
191 if (device_is_compatible(dev, "lm75")) 191 if (of_device_is_compatible(dev, "lm75"))
192 wf_lm75_create(adapter, addr, 0, loc); 192 wf_lm75_create(adapter, addr, 0, loc);
193 /* ds1775 (compatible, better resolution */ 193 /* ds1775 (compatible, better resolution */
194 else if (device_is_compatible(dev, "ds1775")) 194 else if (of_device_is_compatible(dev, "ds1775"))
195 wf_lm75_create(adapter, addr, 1, loc); 195 wf_lm75_create(adapter, addr, 1, loc);
196 } 196 }
197 return 0; 197 return 0;
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c
index eaa74afa175b..5f03aab9fb5d 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -131,7 +131,7 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
131 */ 131 */
132 if (!pmac_i2c_match_adapter(dev, adapter)) 132 if (!pmac_i2c_match_adapter(dev, adapter))
133 continue; 133 continue;
134 if (!device_is_compatible(dev, "max6690")) 134 if (!of_device_is_compatible(dev, "max6690"))
135 continue; 135 continue;
136 addr = pmac_i2c_get_dev_addr(dev); 136 addr = pmac_i2c_get_dev_addr(dev);
137 loc = of_get_property(dev, "hwsensor-location", NULL); 137 loc = of_get_property(dev, "hwsensor-location", NULL);
diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c
index ff398adc0283..58c2590f05ec 100644
--- a/drivers/macintosh/windfarm_smu_controls.c
+++ b/drivers/macintosh/windfarm_smu_controls.c
@@ -263,7 +263,7 @@ static int __init smu_controls_init(void)
263 /* Look for RPM fans */ 263 /* Look for RPM fans */
264 for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;) 264 for (fans = NULL; (fans = of_get_next_child(smu, fans)) != NULL;)
265 if (!strcmp(fans->name, "rpm-fans") || 265 if (!strcmp(fans->name, "rpm-fans") ||
266 device_is_compatible(fans, "smu-rpm-fans")) 266 of_device_is_compatible(fans, "smu-rpm-fans"))
267 break; 267 break;
268 for (fan = NULL; 268 for (fan = NULL;
269 fans && (fan = of_get_next_child(fans, fan)) != NULL;) { 269 fans && (fan = of_get_next_child(fans, fan)) != NULL;) {
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index 9a6c2cf8fd0e..1043b39aa123 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -380,7 +380,7 @@ static int wf_sat_attach(struct i2c_adapter *adapter)
380 busnode = pmac_i2c_get_bus_node(bus); 380 busnode = pmac_i2c_get_bus_node(bus);
381 381
382 while ((dev = of_get_next_child(busnode, dev)) != NULL) 382 while ((dev = of_get_next_child(busnode, dev)) != NULL)
383 if (device_is_compatible(dev, "smu-sat")) 383 if (of_device_is_compatible(dev, "smu-sat"))
384 wf_sat_create(adapter, dev); 384 wf_sat_create(adapter, dev);
385 return 0; 385 return 0;
386} 386}