via-pmu.c (c70c35da52c064983199b1b1cbd4daa5a07ef60c) via-pmu.c (c16a85a5aad47d712860b42f0ca989b0cb62257a)
1// SPDX-License-Identifier: GPL-2.0
2/*
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Device driver for the via-pmu on Apple Powermacs.
3 * Device driver for the PMU in Apple PowerBooks and PowerMacs.
4 *
5 * The VIA (versatile interface adapter) interfaces to the PMU,
6 * a 6805 microprocessor core whose primary function is to control
7 * battery charging and system power on the PowerBook 3400 and 2400.
8 * The PMU also controls the ADB (Apple Desktop Bus) which connects
9 * to the keyboard and mouse, as well as the non-volatile RAM
10 * and the RTC (real time clock) chip.
11 *

--- 32 unchanged lines hidden (view full) ---

44#include <linux/syscore_ops.h>
45#include <linux/freezer.h>
46#include <linux/syscalls.h>
47#include <linux/suspend.h>
48#include <linux/cpu.h>
49#include <linux/compat.h>
50#include <linux/of_address.h>
51#include <linux/of_irq.h>
4 *
5 * The VIA (versatile interface adapter) interfaces to the PMU,
6 * a 6805 microprocessor core whose primary function is to control
7 * battery charging and system power on the PowerBook 3400 and 2400.
8 * The PMU also controls the ADB (Apple Desktop Bus) which connects
9 * to the keyboard and mouse, as well as the non-volatile RAM
10 * and the RTC (real time clock) chip.
11 *

--- 32 unchanged lines hidden (view full) ---

44#include <linux/syscore_ops.h>
45#include <linux/freezer.h>
46#include <linux/syscalls.h>
47#include <linux/suspend.h>
48#include <linux/cpu.h>
49#include <linux/compat.h>
50#include <linux/of_address.h>
51#include <linux/of_irq.h>
52#include <asm/prom.h>
52#include <linux/uaccess.h>
53#include <asm/machdep.h>
54#include <asm/io.h>
55#include <asm/pgtable.h>
56#include <asm/sections.h>
57#include <asm/irq.h>
53#include <asm/machdep.h>
54#include <asm/io.h>
55#include <asm/pgtable.h>
56#include <asm/sections.h>
57#include <asm/irq.h>
58#ifdef CONFIG_PPC_PMAC
58#include <asm/pmac_feature.h>
59#include <asm/pmac_pfunc.h>
60#include <asm/pmac_low_i2c.h>
59#include <asm/pmac_feature.h>
60#include <asm/pmac_pfunc.h>
61#include <asm/pmac_low_i2c.h>
61#include <linux/uaccess.h>
62#include <asm/prom.h>
62#include <asm/mmu_context.h>
63#include <asm/cputable.h>
64#include <asm/time.h>
65#include <asm/backlight.h>
63#include <asm/mmu_context.h>
64#include <asm/cputable.h>
65#include <asm/time.h>
66#include <asm/backlight.h>
67#else
68#include <asm/macintosh.h>
69#include <asm/macints.h>
70#include <asm/mac_via.h>
71#endif
66
67#include "via-pmu-event.h"
68
69/* Some compile options */
70#undef DEBUG_SLEEP
71
72/* Misc minor number allocated for /dev/pmu */
73#define PMU_MINOR 154

--- 18 unchanged lines hidden (view full) ---

92#define SR (10*RS) /* Shift register */
93#define ACR (11*RS) /* Auxiliary control register */
94#define PCR (12*RS) /* Peripheral control register */
95#define IFR (13*RS) /* Interrupt flag register */
96#define IER (14*RS) /* Interrupt enable register */
97#define ANH (15*RS) /* A-side data, no handshake */
98
99/* Bits in B data register: both active low */
72
73#include "via-pmu-event.h"
74
75/* Some compile options */
76#undef DEBUG_SLEEP
77
78/* Misc minor number allocated for /dev/pmu */
79#define PMU_MINOR 154

--- 18 unchanged lines hidden (view full) ---

98#define SR (10*RS) /* Shift register */
99#define ACR (11*RS) /* Auxiliary control register */
100#define PCR (12*RS) /* Peripheral control register */
101#define IFR (13*RS) /* Interrupt flag register */
102#define IER (14*RS) /* Interrupt enable register */
103#define ANH (15*RS) /* A-side data, no handshake */
104
105/* Bits in B data register: both active low */
106#ifdef CONFIG_PPC_PMAC
100#define TACK 0x08 /* Transfer acknowledge (input) */
101#define TREQ 0x10 /* Transfer request (output) */
107#define TACK 0x08 /* Transfer acknowledge (input) */
108#define TREQ 0x10 /* Transfer request (output) */
109#else
110#define TACK 0x02
111#define TREQ 0x04
112#endif
102
103/* Bits in ACR */
104#define SR_CTRL 0x1c /* Shift register control bits */
105#define SR_EXT 0x0c /* Shift on external clock */
106#define SR_OUT 0x10 /* Shift out if 1 */
107
108/* Bits in IFR and IER */
109#define IER_SET 0x80 /* set bits in IER */

--- 25 unchanged lines hidden (view full) ---

135static unsigned char interrupt_data[2][32];
136static int interrupt_data_len[2];
137static int int_data_last;
138static unsigned char *reply_ptr;
139static int data_index;
140static int data_len;
141static volatile int adb_int_pending;
142static volatile int disable_poll;
113
114/* Bits in ACR */
115#define SR_CTRL 0x1c /* Shift register control bits */
116#define SR_EXT 0x0c /* Shift on external clock */
117#define SR_OUT 0x10 /* Shift out if 1 */
118
119/* Bits in IFR and IER */
120#define IER_SET 0x80 /* set bits in IER */

--- 25 unchanged lines hidden (view full) ---

146static unsigned char interrupt_data[2][32];
147static int interrupt_data_len[2];
148static int int_data_last;
149static unsigned char *reply_ptr;
150static int data_index;
151static int data_len;
152static volatile int adb_int_pending;
153static volatile int disable_poll;
143static struct device_node *vias;
144static int pmu_kind = PMU_UNKNOWN;
145static int pmu_fully_inited;
146static int pmu_has_adb;
154static int pmu_kind = PMU_UNKNOWN;
155static int pmu_fully_inited;
156static int pmu_has_adb;
157#ifdef CONFIG_PPC_PMAC
147static volatile unsigned char __iomem *via1;
148static volatile unsigned char __iomem *via2;
158static volatile unsigned char __iomem *via1;
159static volatile unsigned char __iomem *via2;
160static struct device_node *vias;
149static struct device_node *gpio_node;
161static struct device_node *gpio_node;
162#endif
150static unsigned char __iomem *gpio_reg;
151static int gpio_irq = 0;
152static int gpio_irq_enabled = -1;
153static volatile int pmu_suspended;
154static spinlock_t pmu_lock;
155static u8 pmu_intr_mask;
156static int pmu_version;
157static int drop_interrupts;

--- 110 unchanged lines hidden (view full) ---

268 "PowerBook 2400/3400/3500(G3)",
269 "PowerBook G3 Series",
270 "1999 PowerBook G3",
271 "Core99"
272};
273
274int __init find_via_pmu(void)
275{
163static unsigned char __iomem *gpio_reg;
164static int gpio_irq = 0;
165static int gpio_irq_enabled = -1;
166static volatile int pmu_suspended;
167static spinlock_t pmu_lock;
168static u8 pmu_intr_mask;
169static int pmu_version;
170static int drop_interrupts;

--- 110 unchanged lines hidden (view full) ---

281 "PowerBook 2400/3400/3500(G3)",
282 "PowerBook G3 Series",
283 "1999 PowerBook G3",
284 "Core99"
285};
286
287int __init find_via_pmu(void)
288{
289#ifdef CONFIG_PPC_PMAC
276 u64 taddr;
277 const u32 *reg;
278
279 if (pmu_state != uninitialized)
280 return 1;
281 vias = of_find_node_by_name(NULL, "via-pmu");
282 if (vias == NULL)
283 return 0;

--- 66 unchanged lines hidden (view full) ---

350 out_8(&via1[IER], IER_CLR | 0x7f); /* disable all intrs */
351 out_8(&via1[IFR], 0x7f); /* clear IFR */
352
353 pmu_state = idle;
354
355 if (!init_pmu())
356 goto fail_init;
357
290 u64 taddr;
291 const u32 *reg;
292
293 if (pmu_state != uninitialized)
294 return 1;
295 vias = of_find_node_by_name(NULL, "via-pmu");
296 if (vias == NULL)
297 return 0;

--- 66 unchanged lines hidden (view full) ---

364 out_8(&via1[IER], IER_CLR | 0x7f); /* disable all intrs */
365 out_8(&via1[IFR], 0x7f); /* clear IFR */
366
367 pmu_state = idle;
368
369 if (!init_pmu())
370 goto fail_init;
371
358 printk(KERN_INFO "PMU driver v%d initialized for %s, firmware: %02x\n",
359 PMU_DRIVER_VERSION, pbook_type[pmu_kind], pmu_version);
360
361 sys_ctrler = SYS_CTRLER_PMU;
362
363 return 1;
364
365 fail_init:
366 iounmap(via1);
367 via1 = via2 = NULL;
368 fail_via_remap:
369 iounmap(gpio_reg);
370 gpio_reg = NULL;
371 fail:
372 of_node_put(vias);
373 vias = NULL;
374 pmu_state = uninitialized;
375 return 0;
372 sys_ctrler = SYS_CTRLER_PMU;
373
374 return 1;
375
376 fail_init:
377 iounmap(via1);
378 via1 = via2 = NULL;
379 fail_via_remap:
380 iounmap(gpio_reg);
381 gpio_reg = NULL;
382 fail:
383 of_node_put(vias);
384 vias = NULL;
385 pmu_state = uninitialized;
386 return 0;
387#else
388 if (macintosh_config->adb_type != MAC_ADB_PB2)
389 return 0;
390
391 pmu_kind = PMU_UNKNOWN;
392
393 spin_lock_init(&pmu_lock);
394
395 pmu_has_adb = 1;
396
397 pmu_intr_mask = PMU_INT_PCEJECT |
398 PMU_INT_SNDBRT |
399 PMU_INT_ADB |
400 PMU_INT_TICK;
401
402 pmu_state = idle;
403
404 if (!init_pmu()) {
405 pmu_state = uninitialized;
406 return 0;
407 }
408
409 return 1;
410#endif /* !CONFIG_PPC_PMAC */
376}
377
378#ifdef CONFIG_ADB
379static int pmu_probe(void)
380{
381 return pmu_state == uninitialized ? -ENODEV : 0;
382}
383

--- 7 unchanged lines hidden (view full) ---

391 * We can't wait until pmu_init gets called, that happens too late.
392 * It happens after IDE and SCSI initialization, which can take a few
393 * seconds, and by that time the PMU could have given up on us and
394 * turned us off.
395 * Thus this is called with arch_initcall rather than device_initcall.
396 */
397static int __init via_pmu_start(void)
398{
411}
412
413#ifdef CONFIG_ADB
414static int pmu_probe(void)
415{
416 return pmu_state == uninitialized ? -ENODEV : 0;
417}
418

--- 7 unchanged lines hidden (view full) ---

426 * We can't wait until pmu_init gets called, that happens too late.
427 * It happens after IDE and SCSI initialization, which can take a few
428 * seconds, and by that time the PMU could have given up on us and
429 * turned us off.
430 * Thus this is called with arch_initcall rather than device_initcall.
431 */
432static int __init via_pmu_start(void)
433{
399 unsigned int irq;
434 unsigned int __maybe_unused irq;
400
401 if (pmu_state == uninitialized)
402 return -ENODEV;
403
404 batt_req.complete = 1;
405
435
436 if (pmu_state == uninitialized)
437 return -ENODEV;
438
439 batt_req.complete = 1;
440
441#ifdef CONFIG_PPC_PMAC
406 irq = irq_of_parse_and_map(vias, 0);
407 if (!irq) {
408 printk(KERN_ERR "via-pmu: can't map interrupt\n");
409 return -ENODEV;
410 }
411 /* We set IRQF_NO_SUSPEND because we don't want the interrupt
412 * to be disabled between the 2 passes of driver suspend, we
413 * control our own disabling for that one

--- 20 unchanged lines hidden (view full) ---

434 " (GPIO1)\n", gpio_irq);
435 else
436 gpio_irq_enabled = 1;
437 }
438 }
439
440 /* Enable interrupts */
441 out_8(&via1[IER], IER_SET | SR_INT | CB1_INT);
442 irq = irq_of_parse_and_map(vias, 0);
443 if (!irq) {
444 printk(KERN_ERR "via-pmu: can't map interrupt\n");
445 return -ENODEV;
446 }
447 /* We set IRQF_NO_SUSPEND because we don't want the interrupt
448 * to be disabled between the 2 passes of driver suspend, we
449 * control our own disabling for that one

--- 20 unchanged lines hidden (view full) ---

470 " (GPIO1)\n", gpio_irq);
471 else
472 gpio_irq_enabled = 1;
473 }
474 }
475
476 /* Enable interrupts */
477 out_8(&via1[IER], IER_SET | SR_INT | CB1_INT);
478#else
479 if (request_irq(IRQ_MAC_ADB_SR, via_pmu_interrupt, IRQF_NO_SUSPEND,
480 "VIA-PMU-SR", NULL)) {
481 pr_err("%s: couldn't get SR irq\n", __func__);
482 return -ENODEV;
483 }
484 if (request_irq(IRQ_MAC_ADB_CL, via_pmu_interrupt, IRQF_NO_SUSPEND,
485 "VIA-PMU-CL", NULL)) {
486 pr_err("%s: couldn't get CL irq\n", __func__);
487 free_irq(IRQ_MAC_ADB_SR, NULL);
488 return -ENODEV;
489 }
490#endif /* !CONFIG_PPC_PMAC */
442
443 pmu_fully_inited = 1;
444
445 /* Make sure PMU settle down before continuing. This is _very_ important
446 * since the IDE probe may shut interrupts down for quite a bit of time. If
447 * a PMU communication is pending while this happens, the PMU may timeout
448 * Not that on Core99 machines, the PMU keeps sending us environement
449 * messages, we should find a way to either fix IDE or make it call

--- 134 unchanged lines hidden (view full) ---

584 pmu_wait_complete(&req);
585 if (req.reply_len == 2) {
586 if (req.reply[1] & PMU_PWR_WAKEUP_AC_INSERT)
587 option_server_mode = 1;
588 printk(KERN_INFO "via-pmu: Server Mode is %s\n",
589 option_server_mode ? "enabled" : "disabled");
590 }
591 }
491
492 pmu_fully_inited = 1;
493
494 /* Make sure PMU settle down before continuing. This is _very_ important
495 * since the IDE probe may shut interrupts down for quite a bit of time. If
496 * a PMU communication is pending while this happens, the PMU may timeout
497 * Not that on Core99 machines, the PMU keeps sending us environement
498 * messages, we should find a way to either fix IDE or make it call

--- 134 unchanged lines hidden (view full) ---

633 pmu_wait_complete(&req);
634 if (req.reply_len == 2) {
635 if (req.reply[1] & PMU_PWR_WAKEUP_AC_INSERT)
636 option_server_mode = 1;
637 printk(KERN_INFO "via-pmu: Server Mode is %s\n",
638 option_server_mode ? "enabled" : "disabled");
639 }
640 }
641
642 printk(KERN_INFO "PMU driver v%d initialized for %s, firmware: %02x\n",
643 PMU_DRIVER_VERSION, pbook_type[pmu_kind], pmu_version);
644
592 return 1;
593}
594
595int
596pmu_get_model(void)
597{
598 return pmu_kind;
599}

--- 22 unchanged lines hidden (view full) ---

622}
623
624/* This new version of the code for 2400/3400/3500 powerbooks
625 * is inspired from the implementation in gkrellm-pmu
626 */
627static void
628done_battery_state_ohare(struct adb_request* req)
629{
645 return 1;
646}
647
648int
649pmu_get_model(void)
650{
651 return pmu_kind;
652}

--- 22 unchanged lines hidden (view full) ---

675}
676
677/* This new version of the code for 2400/3400/3500 powerbooks
678 * is inspired from the implementation in gkrellm-pmu
679 */
680static void
681done_battery_state_ohare(struct adb_request* req)
682{
683#ifdef CONFIG_PPC_PMAC
630 /* format:
631 * [0] : flags
632 * 0x01 : AC indicator
633 * 0x02 : charging
634 * 0x04 : battery exist
635 * 0x08 :
636 * 0x10 :
637 * 0x20 : full charged

--- 65 unchanged lines hidden (view full) ---

703 charge = max = amperage = voltage = time = 0;
704
705 pmu_batteries[pmu_cur_battery].flags = bat_flags;
706 pmu_batteries[pmu_cur_battery].charge = charge;
707 pmu_batteries[pmu_cur_battery].max_charge = max;
708 pmu_batteries[pmu_cur_battery].amperage = amperage;
709 pmu_batteries[pmu_cur_battery].voltage = voltage;
710 pmu_batteries[pmu_cur_battery].time_remaining = time;
684 /* format:
685 * [0] : flags
686 * 0x01 : AC indicator
687 * 0x02 : charging
688 * 0x04 : battery exist
689 * 0x08 :
690 * 0x10 :
691 * 0x20 : full charged

--- 65 unchanged lines hidden (view full) ---

757 charge = max = amperage = voltage = time = 0;
758
759 pmu_batteries[pmu_cur_battery].flags = bat_flags;
760 pmu_batteries[pmu_cur_battery].charge = charge;
761 pmu_batteries[pmu_cur_battery].max_charge = max;
762 pmu_batteries[pmu_cur_battery].amperage = amperage;
763 pmu_batteries[pmu_cur_battery].voltage = voltage;
764 pmu_batteries[pmu_cur_battery].time_remaining = time;
765#endif /* CONFIG_PPC_PMAC */
711
712 clear_bit(0, &async_req_locks);
713}
714
715static void
716done_battery_state_smart(struct adb_request* req)
717{
718 /* format:

--- 632 unchanged lines hidden (view full) ---

1351 if (len <= 2)
1352 req->reply_len = 0;
1353 else {
1354 memcpy(req->reply, data + 1, len - 1);
1355 req->reply_len = len - 1;
1356 }
1357 pmu_done(req);
1358 } else {
766
767 clear_bit(0, &async_req_locks);
768}
769
770static void
771done_battery_state_smart(struct adb_request* req)
772{
773 /* format:

--- 632 unchanged lines hidden (view full) ---

1406 if (len <= 2)
1407 req->reply_len = 0;
1408 else {
1409 memcpy(req->reply, data + 1, len - 1);
1410 req->reply_len = len - 1;
1411 }
1412 pmu_done(req);
1413 } else {
1414#ifdef CONFIG_XMON
1359 if (len == 4 && data[1] == 0x2c) {
1360 extern int xmon_wants_key, xmon_adb_keycode;
1361 if (xmon_wants_key) {
1362 xmon_adb_keycode = data[2];
1363 return;
1364 }
1365 }
1415 if (len == 4 && data[1] == 0x2c) {
1416 extern int xmon_wants_key, xmon_adb_keycode;
1417 if (xmon_wants_key) {
1418 xmon_adb_keycode = data[2];
1419 return;
1420 }
1421 }
1422#endif /* CONFIG_XMON */
1366#ifdef CONFIG_ADB
1367 /*
1368 * XXX On the [23]400 the PMU gives us an up
1369 * event for keycodes 0x74 or 0x75 when the PC
1370 * card eject buttons are released, so we
1371 * ignore those events.
1372 */
1373 if (!(pmu_kind == PMU_OHARE_BASED && len == 4

--- 151 unchanged lines hidden (view full) ---

1525 struct adb_request *req = NULL;
1526 int handled = 0;
1527
1528 /* This is a bit brutal, we can probably do better */
1529 spin_lock_irqsave(&pmu_lock, flags);
1530 ++disable_poll;
1531
1532 for (;;) {
1423#ifdef CONFIG_ADB
1424 /*
1425 * XXX On the [23]400 the PMU gives us an up
1426 * event for keycodes 0x74 or 0x75 when the PC
1427 * card eject buttons are released, so we
1428 * ignore those events.
1429 */
1430 if (!(pmu_kind == PMU_OHARE_BASED && len == 4

--- 151 unchanged lines hidden (view full) ---

1582 struct adb_request *req = NULL;
1583 int handled = 0;
1584
1585 /* This is a bit brutal, we can probably do better */
1586 spin_lock_irqsave(&pmu_lock, flags);
1587 ++disable_poll;
1588
1589 for (;;) {
1533 intr = in_8(&via1[IFR]) & (SR_INT | CB1_INT);
1590 /* On 68k Macs, VIA interrupts are dispatched individually.
1591 * Unless we are polling, the relevant IRQ flag has already
1592 * been cleared.
1593 */
1594 intr = 0;
1595 if (IS_ENABLED(CONFIG_PPC_PMAC) || !irq) {
1596 intr = in_8(&via1[IFR]) & (SR_INT | CB1_INT);
1597 out_8(&via1[IFR], intr);
1598 }
1599#ifndef CONFIG_PPC_PMAC
1600 switch (irq) {
1601 case IRQ_MAC_ADB_CL:
1602 intr = CB1_INT;
1603 break;
1604 case IRQ_MAC_ADB_SR:
1605 intr = SR_INT;
1606 break;
1607 }
1608#endif
1534 if (intr == 0)
1535 break;
1536 handled = 1;
1537 if (++nloop > 1000) {
1538 printk(KERN_DEBUG "PMU: stuck in intr loop, "
1539 "intr=%x, ier=%x pmu_state=%d\n",
1540 intr, in_8(&via1[IER]), pmu_state);
1541 break;
1542 }
1609 if (intr == 0)
1610 break;
1611 handled = 1;
1612 if (++nloop > 1000) {
1613 printk(KERN_DEBUG "PMU: stuck in intr loop, "
1614 "intr=%x, ier=%x pmu_state=%d\n",
1615 intr, in_8(&via1[IER]), pmu_state);
1616 break;
1617 }
1543 out_8(&via1[IFR], intr);
1544 if (intr & CB1_INT) {
1545 adb_int_pending = 1;
1546 pmu_irq_stats[0]++;
1547 }
1548 if (intr & SR_INT) {
1549 req = pmu_sr_intr();
1550 if (req)
1551 break;
1552 }
1618 if (intr & CB1_INT) {
1619 adb_int_pending = 1;
1620 pmu_irq_stats[0]++;
1621 }
1622 if (intr & SR_INT) {
1623 req = pmu_sr_intr();
1624 if (req)
1625 break;
1626 }
1627#ifndef CONFIG_PPC_PMAC
1628 break;
1629#endif
1553 }
1554
1555recheck:
1556 if (pmu_state == idle) {
1557 if (adb_int_pending) {
1558 if (int_data_state[0] == int_data_empty)
1559 int_data_last = 0;
1560 else if (int_data_state[1] == int_data_empty)

--- 50 unchanged lines hidden (view full) ---

1611 spin_lock_irqsave(&pmu_lock, flags);
1612 if (pmu_state == locked)
1613 pmu_state = idle;
1614 adb_int_pending = 1;
1615 spin_unlock_irqrestore(&pmu_lock, flags);
1616}
1617
1618
1630 }
1631
1632recheck:
1633 if (pmu_state == idle) {
1634 if (adb_int_pending) {
1635 if (int_data_state[0] == int_data_empty)
1636 int_data_last = 0;
1637 else if (int_data_state[1] == int_data_empty)

--- 50 unchanged lines hidden (view full) ---

1688 spin_lock_irqsave(&pmu_lock, flags);
1689 if (pmu_state == locked)
1690 pmu_state = idle;
1691 adb_int_pending = 1;
1692 spin_unlock_irqrestore(&pmu_lock, flags);
1693}
1694
1695
1619static irqreturn_t
1696static __maybe_unused irqreturn_t
1620gpio1_interrupt(int irq, void *arg)
1621{
1622 unsigned long flags;
1623
1624 if ((in_8(gpio_reg + 0x9) & 0x02) == 0) {
1625 spin_lock_irqsave(&pmu_lock, flags);
1626 if (gpio_irq_enabled > 0) {
1627 disable_irq_nosync(gpio_irq);

--- 617 unchanged lines hidden (view full) ---

2245
2246static int pmu_ioctl(struct file *filp,
2247 u_int cmd, u_long arg)
2248{
2249 __u32 __user *argp = (__u32 __user *)arg;
2250 int error = -EINVAL;
2251
2252 switch (cmd) {
1697gpio1_interrupt(int irq, void *arg)
1698{
1699 unsigned long flags;
1700
1701 if ((in_8(gpio_reg + 0x9) & 0x02) == 0) {
1702 spin_lock_irqsave(&pmu_lock, flags);
1703 if (gpio_irq_enabled > 0) {
1704 disable_irq_nosync(gpio_irq);

--- 617 unchanged lines hidden (view full) ---

2322
2323static int pmu_ioctl(struct file *filp,
2324 u_int cmd, u_long arg)
2325{
2326 __u32 __user *argp = (__u32 __user *)arg;
2327 int error = -EINVAL;
2328
2329 switch (cmd) {
2330#ifdef CONFIG_PPC_PMAC
2253 case PMU_IOC_SLEEP:
2254 if (!capable(CAP_SYS_ADMIN))
2255 return -EACCES;
2256 return pm_suspend(PM_SUSPEND_MEM);
2257 case PMU_IOC_CAN_SLEEP:
2258 if (pmac_call_feature(PMAC_FTR_SLEEP_STATE, NULL, 0, -1) < 0)
2259 return put_user(0, argp);
2260 else
2261 return put_user(1, argp);
2331 case PMU_IOC_SLEEP:
2332 if (!capable(CAP_SYS_ADMIN))
2333 return -EACCES;
2334 return pm_suspend(PM_SUSPEND_MEM);
2335 case PMU_IOC_CAN_SLEEP:
2336 if (pmac_call_feature(PMAC_FTR_SLEEP_STATE, NULL, 0, -1) < 0)
2337 return put_user(0, argp);
2338 else
2339 return put_user(1, argp);
2340#endif
2262
2263#ifdef CONFIG_PMAC_BACKLIGHT_LEGACY
2264 /* Compatibility ioctl's for backlight */
2265 case PMU_IOC_GET_BACKLIGHT:
2266 {
2267 int brightness;
2268
2269 brightness = pmac_backlight_get_legacy_brightness();

--- 289 unchanged lines hidden ---
2341
2342#ifdef CONFIG_PMAC_BACKLIGHT_LEGACY
2343 /* Compatibility ioctl's for backlight */
2344 case PMU_IOC_GET_BACKLIGHT:
2345 {
2346 int brightness;
2347
2348 brightness = pmac_backlight_get_legacy_brightness();

--- 289 unchanged lines hidden ---