diff options
Diffstat (limited to 'drivers/macintosh/via-pmu.c')
-rw-r--r-- | drivers/macintosh/via-pmu.c | 84 |
1 files changed, 40 insertions, 44 deletions
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index c1193d34ec9e..14610a63f580 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -16,7 +16,6 @@ | |||
16 | * a sleep or a freq. switch | 16 | * a sleep or a freq. switch |
17 | * - Move sleep code out of here to pmac_pm, merge into new | 17 | * - Move sleep code out of here to pmac_pm, merge into new |
18 | * common PM infrastructure | 18 | * common PM infrastructure |
19 | * - Move backlight code out as well | ||
20 | * - Save/Restore PCI space properly | 19 | * - Save/Restore PCI space properly |
21 | * | 20 | * |
22 | */ | 21 | */ |
@@ -60,13 +59,7 @@ | |||
60 | #include <asm/mmu_context.h> | 59 | #include <asm/mmu_context.h> |
61 | #include <asm/cputable.h> | 60 | #include <asm/cputable.h> |
62 | #include <asm/time.h> | 61 | #include <asm/time.h> |
63 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
64 | #include <asm/backlight.h> | 62 | #include <asm/backlight.h> |
65 | #endif | ||
66 | |||
67 | #ifdef CONFIG_PPC32 | ||
68 | #include <asm/open_pic.h> | ||
69 | #endif | ||
70 | 63 | ||
71 | #include "via-pmu-event.h" | 64 | #include "via-pmu-event.h" |
72 | 65 | ||
@@ -151,7 +144,7 @@ static int pmu_fully_inited = 0; | |||
151 | static int pmu_has_adb; | 144 | static int pmu_has_adb; |
152 | static struct device_node *gpio_node; | 145 | static struct device_node *gpio_node; |
153 | static unsigned char __iomem *gpio_reg = NULL; | 146 | static unsigned char __iomem *gpio_reg = NULL; |
154 | static int gpio_irq = -1; | 147 | static int gpio_irq = NO_IRQ; |
155 | static int gpio_irq_enabled = -1; | 148 | static int gpio_irq_enabled = -1; |
156 | static volatile int pmu_suspended = 0; | 149 | static volatile int pmu_suspended = 0; |
157 | static spinlock_t pmu_lock; | 150 | static spinlock_t pmu_lock; |
@@ -181,10 +174,6 @@ static int query_batt_timer = BATTERY_POLLING_COUNT; | |||
181 | static struct adb_request batt_req; | 174 | static struct adb_request batt_req; |
182 | static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES]; | 175 | static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES]; |
183 | 176 | ||
184 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | ||
185 | extern int disable_kernel_backlight; | ||
186 | #endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ | ||
187 | |||
188 | int __fake_sleep; | 177 | int __fake_sleep; |
189 | int asleep; | 178 | int asleep; |
190 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); | 179 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); |
@@ -403,22 +392,21 @@ static int __init pmu_init(void) | |||
403 | */ | 392 | */ |
404 | static int __init via_pmu_start(void) | 393 | static int __init via_pmu_start(void) |
405 | { | 394 | { |
395 | unsigned int irq; | ||
396 | |||
406 | if (vias == NULL) | 397 | if (vias == NULL) |
407 | return -ENODEV; | 398 | return -ENODEV; |
408 | 399 | ||
409 | batt_req.complete = 1; | 400 | batt_req.complete = 1; |
410 | 401 | ||
411 | #ifndef CONFIG_PPC_MERGE | 402 | irq = irq_of_parse_and_map(vias, 0); |
412 | if (pmu_kind == PMU_KEYLARGO_BASED) | 403 | if (irq == NO_IRQ) { |
413 | openpic_set_irq_priority(vias->intrs[0].line, | 404 | printk(KERN_ERR "via-pmu: can't map interruptn"); |
414 | OPENPIC_PRIORITY_DEFAULT + 1); | 405 | return -ENODEV; |
415 | #endif | 406 | } |
416 | 407 | if (request_irq(irq, via_pmu_interrupt, 0, "VIA-PMU", (void *)0)) { | |
417 | if (request_irq(vias->intrs[0].line, via_pmu_interrupt, 0, "VIA-PMU", | 408 | printk(KERN_ERR "via-pmu: can't request irq %d\n", irq); |
418 | (void *)0)) { | 409 | return -ENODEV; |
419 | printk(KERN_ERR "VIA-PMU: can't get irq %d\n", | ||
420 | vias->intrs[0].line); | ||
421 | return -EAGAIN; | ||
422 | } | 410 | } |
423 | 411 | ||
424 | if (pmu_kind == PMU_KEYLARGO_BASED) { | 412 | if (pmu_kind == PMU_KEYLARGO_BASED) { |
@@ -426,10 +414,10 @@ static int __init via_pmu_start(void) | |||
426 | if (gpio_node == NULL) | 414 | if (gpio_node == NULL) |
427 | gpio_node = of_find_node_by_name(NULL, | 415 | gpio_node = of_find_node_by_name(NULL, |
428 | "pmu-interrupt"); | 416 | "pmu-interrupt"); |
429 | if (gpio_node && gpio_node->n_intrs > 0) | 417 | if (gpio_node) |
430 | gpio_irq = gpio_node->intrs[0].line; | 418 | gpio_irq = irq_of_parse_and_map(gpio_node, 0); |
431 | 419 | ||
432 | if (gpio_irq != -1) { | 420 | if (gpio_irq != NO_IRQ) { |
433 | if (request_irq(gpio_irq, gpio1_interrupt, 0, | 421 | if (request_irq(gpio_irq, gpio1_interrupt, 0, |
434 | "GPIO1 ADB", (void *)0)) | 422 | "GPIO1 ADB", (void *)0)) |
435 | printk(KERN_ERR "pmu: can't get irq %d" | 423 | printk(KERN_ERR "pmu: can't get irq %d" |
@@ -471,7 +459,7 @@ static int __init via_pmu_dev_init(void) | |||
471 | 459 | ||
472 | #ifdef CONFIG_PMAC_BACKLIGHT | 460 | #ifdef CONFIG_PMAC_BACKLIGHT |
473 | /* Initialize backlight */ | 461 | /* Initialize backlight */ |
474 | pmu_backlight_init(vias); | 462 | pmu_backlight_init(); |
475 | #endif | 463 | #endif |
476 | 464 | ||
477 | #ifdef CONFIG_PPC32 | 465 | #ifdef CONFIG_PPC32 |
@@ -1408,11 +1396,8 @@ next: | |||
1408 | else if ((1 << pirq) & PMU_INT_SNDBRT) { | 1396 | else if ((1 << pirq) & PMU_INT_SNDBRT) { |
1409 | #ifdef CONFIG_PMAC_BACKLIGHT | 1397 | #ifdef CONFIG_PMAC_BACKLIGHT |
1410 | if (len == 3) | 1398 | if (len == 3) |
1411 | #ifdef CONFIG_INPUT_ADBHID | 1399 | pmac_backlight_set_legacy_brightness_pmu(data[1] >> 4); |
1412 | if (!disable_kernel_backlight) | 1400 | #endif |
1413 | #endif /* CONFIG_INPUT_ADBHID */ | ||
1414 | pmac_backlight_set_legacy_brightness(data[1] >> 4); | ||
1415 | #endif /* CONFIG_PMAC_BACKLIGHT */ | ||
1416 | } | 1401 | } |
1417 | /* Tick interrupt */ | 1402 | /* Tick interrupt */ |
1418 | else if ((1 << pirq) & PMU_INT_TICK) { | 1403 | else if ((1 << pirq) & PMU_INT_TICK) { |
@@ -2010,6 +1995,8 @@ restore_via_state(void) | |||
2010 | out_8(&via[IER], IER_SET | SR_INT | CB1_INT); | 1995 | out_8(&via[IER], IER_SET | SR_INT | CB1_INT); |
2011 | } | 1996 | } |
2012 | 1997 | ||
1998 | extern void pmu_backlight_set_sleep(int sleep); | ||
1999 | |||
2013 | static int | 2000 | static int |
2014 | pmac_suspend_devices(void) | 2001 | pmac_suspend_devices(void) |
2015 | { | 2002 | { |
@@ -2047,6 +2034,11 @@ pmac_suspend_devices(void) | |||
2047 | return -EBUSY; | 2034 | return -EBUSY; |
2048 | } | 2035 | } |
2049 | 2036 | ||
2037 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
2038 | /* Tell backlight code not to muck around with the chip anymore */ | ||
2039 | pmu_backlight_set_sleep(1); | ||
2040 | #endif | ||
2041 | |||
2050 | /* Call platform functions marked "on sleep" */ | 2042 | /* Call platform functions marked "on sleep" */ |
2051 | pmac_pfunc_i2c_suspend(); | 2043 | pmac_pfunc_i2c_suspend(); |
2052 | pmac_pfunc_base_suspend(); | 2044 | pmac_pfunc_base_suspend(); |
@@ -2105,6 +2097,11 @@ pmac_wakeup_devices(void) | |||
2105 | { | 2097 | { |
2106 | mdelay(100); | 2098 | mdelay(100); |
2107 | 2099 | ||
2100 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
2101 | /* Tell backlight code it can use the chip again */ | ||
2102 | pmu_backlight_set_sleep(0); | ||
2103 | #endif | ||
2104 | |||
2108 | /* Power back up system devices (including the PIC) */ | 2105 | /* Power back up system devices (including the PIC) */ |
2109 | device_power_up(); | 2106 | device_power_up(); |
2110 | 2107 | ||
@@ -2419,7 +2416,7 @@ struct pmu_private { | |||
2419 | spinlock_t lock; | 2416 | spinlock_t lock; |
2420 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | 2417 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) |
2421 | int backlight_locker; | 2418 | int backlight_locker; |
2422 | #endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ | 2419 | #endif |
2423 | }; | 2420 | }; |
2424 | 2421 | ||
2425 | static LIST_HEAD(all_pmu_pvt); | 2422 | static LIST_HEAD(all_pmu_pvt); |
@@ -2469,7 +2466,7 @@ pmu_open(struct inode *inode, struct file *file) | |||
2469 | spin_lock_irqsave(&all_pvt_lock, flags); | 2466 | spin_lock_irqsave(&all_pvt_lock, flags); |
2470 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | 2467 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) |
2471 | pp->backlight_locker = 0; | 2468 | pp->backlight_locker = 0; |
2472 | #endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ | 2469 | #endif |
2473 | list_add(&pp->list, &all_pmu_pvt); | 2470 | list_add(&pp->list, &all_pmu_pvt); |
2474 | spin_unlock_irqrestore(&all_pvt_lock, flags); | 2471 | spin_unlock_irqrestore(&all_pvt_lock, flags); |
2475 | file->private_data = pp; | 2472 | file->private_data = pp; |
@@ -2564,13 +2561,12 @@ pmu_release(struct inode *inode, struct file *file) | |||
2564 | spin_lock_irqsave(&all_pvt_lock, flags); | 2561 | spin_lock_irqsave(&all_pvt_lock, flags); |
2565 | list_del(&pp->list); | 2562 | list_del(&pp->list); |
2566 | spin_unlock_irqrestore(&all_pvt_lock, flags); | 2563 | spin_unlock_irqrestore(&all_pvt_lock, flags); |
2564 | |||
2567 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | 2565 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) |
2568 | if (pp->backlight_locker) { | 2566 | if (pp->backlight_locker) |
2569 | spin_lock_irqsave(&pmu_lock, flags); | 2567 | pmac_backlight_enable(); |
2570 | disable_kernel_backlight--; | 2568 | #endif |
2571 | spin_unlock_irqrestore(&pmu_lock, flags); | 2569 | |
2572 | } | ||
2573 | #endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ | ||
2574 | kfree(pp); | 2570 | kfree(pp); |
2575 | } | 2571 | } |
2576 | unlock_kernel(); | 2572 | unlock_kernel(); |
@@ -2647,18 +2643,18 @@ pmu_ioctl(struct inode * inode, struct file *filp, | |||
2647 | #ifdef CONFIG_INPUT_ADBHID | 2643 | #ifdef CONFIG_INPUT_ADBHID |
2648 | case PMU_IOC_GRAB_BACKLIGHT: { | 2644 | case PMU_IOC_GRAB_BACKLIGHT: { |
2649 | struct pmu_private *pp = filp->private_data; | 2645 | struct pmu_private *pp = filp->private_data; |
2650 | unsigned long flags; | ||
2651 | 2646 | ||
2652 | if (pp->backlight_locker) | 2647 | if (pp->backlight_locker) |
2653 | return 0; | 2648 | return 0; |
2649 | |||
2654 | pp->backlight_locker = 1; | 2650 | pp->backlight_locker = 1; |
2655 | spin_lock_irqsave(&pmu_lock, flags); | 2651 | pmac_backlight_disable(); |
2656 | disable_kernel_backlight++; | 2652 | |
2657 | spin_unlock_irqrestore(&pmu_lock, flags); | ||
2658 | return 0; | 2653 | return 0; |
2659 | } | 2654 | } |
2660 | #endif /* CONFIG_INPUT_ADBHID */ | 2655 | #endif /* CONFIG_INPUT_ADBHID */ |
2661 | #endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */ | 2656 | #endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */ |
2657 | |||
2662 | case PMU_IOC_GET_MODEL: | 2658 | case PMU_IOC_GET_MODEL: |
2663 | return put_user(pmu_kind, argp); | 2659 | return put_user(pmu_kind, argp); |
2664 | case PMU_IOC_HAS_ADB: | 2660 | case PMU_IOC_HAS_ADB: |