diff options
Diffstat (limited to 'drivers/macintosh/via-pmu.c')
-rw-r--r-- | drivers/macintosh/via-pmu.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 06ca80bfd6b9..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,9 +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 | 63 | ||
67 | #include "via-pmu-event.h" | 64 | #include "via-pmu-event.h" |
68 | 65 | ||
@@ -177,10 +174,6 @@ static int query_batt_timer = BATTERY_POLLING_COUNT; | |||
177 | static struct adb_request batt_req; | 174 | static struct adb_request batt_req; |
178 | static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES]; | 175 | static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES]; |
179 | 176 | ||
180 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | ||
181 | extern int disable_kernel_backlight; | ||
182 | #endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ | ||
183 | |||
184 | int __fake_sleep; | 177 | int __fake_sleep; |
185 | int asleep; | 178 | int asleep; |
186 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); | 179 | BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); |
@@ -466,7 +459,7 @@ static int __init via_pmu_dev_init(void) | |||
466 | 459 | ||
467 | #ifdef CONFIG_PMAC_BACKLIGHT | 460 | #ifdef CONFIG_PMAC_BACKLIGHT |
468 | /* Initialize backlight */ | 461 | /* Initialize backlight */ |
469 | pmu_backlight_init(vias); | 462 | pmu_backlight_init(); |
470 | #endif | 463 | #endif |
471 | 464 | ||
472 | #ifdef CONFIG_PPC32 | 465 | #ifdef CONFIG_PPC32 |
@@ -1403,11 +1396,8 @@ next: | |||
1403 | else if ((1 << pirq) & PMU_INT_SNDBRT) { | 1396 | else if ((1 << pirq) & PMU_INT_SNDBRT) { |
1404 | #ifdef CONFIG_PMAC_BACKLIGHT | 1397 | #ifdef CONFIG_PMAC_BACKLIGHT |
1405 | if (len == 3) | 1398 | if (len == 3) |
1406 | #ifdef CONFIG_INPUT_ADBHID | 1399 | pmac_backlight_set_legacy_brightness_pmu(data[1] >> 4); |
1407 | if (!disable_kernel_backlight) | 1400 | #endif |
1408 | #endif /* CONFIG_INPUT_ADBHID */ | ||
1409 | pmac_backlight_set_legacy_brightness(data[1] >> 4); | ||
1410 | #endif /* CONFIG_PMAC_BACKLIGHT */ | ||
1411 | } | 1401 | } |
1412 | /* Tick interrupt */ | 1402 | /* Tick interrupt */ |
1413 | else if ((1 << pirq) & PMU_INT_TICK) { | 1403 | else if ((1 << pirq) & PMU_INT_TICK) { |
@@ -2005,6 +1995,8 @@ restore_via_state(void) | |||
2005 | out_8(&via[IER], IER_SET | SR_INT | CB1_INT); | 1995 | out_8(&via[IER], IER_SET | SR_INT | CB1_INT); |
2006 | } | 1996 | } |
2007 | 1997 | ||
1998 | extern void pmu_backlight_set_sleep(int sleep); | ||
1999 | |||
2008 | static int | 2000 | static int |
2009 | pmac_suspend_devices(void) | 2001 | pmac_suspend_devices(void) |
2010 | { | 2002 | { |
@@ -2042,6 +2034,11 @@ pmac_suspend_devices(void) | |||
2042 | return -EBUSY; | 2034 | return -EBUSY; |
2043 | } | 2035 | } |
2044 | 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 | |||
2045 | /* Call platform functions marked "on sleep" */ | 2042 | /* Call platform functions marked "on sleep" */ |
2046 | pmac_pfunc_i2c_suspend(); | 2043 | pmac_pfunc_i2c_suspend(); |
2047 | pmac_pfunc_base_suspend(); | 2044 | pmac_pfunc_base_suspend(); |
@@ -2100,6 +2097,11 @@ pmac_wakeup_devices(void) | |||
2100 | { | 2097 | { |
2101 | mdelay(100); | 2098 | mdelay(100); |
2102 | 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 | |||
2103 | /* Power back up system devices (including the PIC) */ | 2105 | /* Power back up system devices (including the PIC) */ |
2104 | device_power_up(); | 2106 | device_power_up(); |
2105 | 2107 | ||
@@ -2414,7 +2416,7 @@ struct pmu_private { | |||
2414 | spinlock_t lock; | 2416 | spinlock_t lock; |
2415 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | 2417 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) |
2416 | int backlight_locker; | 2418 | int backlight_locker; |
2417 | #endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ | 2419 | #endif |
2418 | }; | 2420 | }; |
2419 | 2421 | ||
2420 | static LIST_HEAD(all_pmu_pvt); | 2422 | static LIST_HEAD(all_pmu_pvt); |
@@ -2464,7 +2466,7 @@ pmu_open(struct inode *inode, struct file *file) | |||
2464 | spin_lock_irqsave(&all_pvt_lock, flags); | 2466 | spin_lock_irqsave(&all_pvt_lock, flags); |
2465 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | 2467 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) |
2466 | pp->backlight_locker = 0; | 2468 | pp->backlight_locker = 0; |
2467 | #endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ | 2469 | #endif |
2468 | list_add(&pp->list, &all_pmu_pvt); | 2470 | list_add(&pp->list, &all_pmu_pvt); |
2469 | spin_unlock_irqrestore(&all_pvt_lock, flags); | 2471 | spin_unlock_irqrestore(&all_pvt_lock, flags); |
2470 | file->private_data = pp; | 2472 | file->private_data = pp; |
@@ -2559,13 +2561,12 @@ pmu_release(struct inode *inode, struct file *file) | |||
2559 | spin_lock_irqsave(&all_pvt_lock, flags); | 2561 | spin_lock_irqsave(&all_pvt_lock, flags); |
2560 | list_del(&pp->list); | 2562 | list_del(&pp->list); |
2561 | spin_unlock_irqrestore(&all_pvt_lock, flags); | 2563 | spin_unlock_irqrestore(&all_pvt_lock, flags); |
2564 | |||
2562 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | 2565 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) |
2563 | if (pp->backlight_locker) { | 2566 | if (pp->backlight_locker) |
2564 | spin_lock_irqsave(&pmu_lock, flags); | 2567 | pmac_backlight_enable(); |
2565 | disable_kernel_backlight--; | 2568 | #endif |
2566 | spin_unlock_irqrestore(&pmu_lock, flags); | 2569 | |
2567 | } | ||
2568 | #endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ | ||
2569 | kfree(pp); | 2570 | kfree(pp); |
2570 | } | 2571 | } |
2571 | unlock_kernel(); | 2572 | unlock_kernel(); |
@@ -2642,18 +2643,18 @@ pmu_ioctl(struct inode * inode, struct file *filp, | |||
2642 | #ifdef CONFIG_INPUT_ADBHID | 2643 | #ifdef CONFIG_INPUT_ADBHID |
2643 | case PMU_IOC_GRAB_BACKLIGHT: { | 2644 | case PMU_IOC_GRAB_BACKLIGHT: { |
2644 | struct pmu_private *pp = filp->private_data; | 2645 | struct pmu_private *pp = filp->private_data; |
2645 | unsigned long flags; | ||
2646 | 2646 | ||
2647 | if (pp->backlight_locker) | 2647 | if (pp->backlight_locker) |
2648 | return 0; | 2648 | return 0; |
2649 | |||
2649 | pp->backlight_locker = 1; | 2650 | pp->backlight_locker = 1; |
2650 | spin_lock_irqsave(&pmu_lock, flags); | 2651 | pmac_backlight_disable(); |
2651 | disable_kernel_backlight++; | 2652 | |
2652 | spin_unlock_irqrestore(&pmu_lock, flags); | ||
2653 | return 0; | 2653 | return 0; |
2654 | } | 2654 | } |
2655 | #endif /* CONFIG_INPUT_ADBHID */ | 2655 | #endif /* CONFIG_INPUT_ADBHID */ |
2656 | #endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */ | 2656 | #endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */ |
2657 | |||
2657 | case PMU_IOC_GET_MODEL: | 2658 | case PMU_IOC_GET_MODEL: |
2658 | return put_user(pmu_kind, argp); | 2659 | return put_user(pmu_kind, argp); |
2659 | case PMU_IOC_HAS_ADB: | 2660 | case PMU_IOC_HAS_ADB: |