diff options
Diffstat (limited to 'drivers/macintosh/via-pmu.c')
-rw-r--r-- | drivers/macintosh/via-pmu.c | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 5375df03c6f3..4a0a0ad2d03c 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -155,10 +155,10 @@ static spinlock_t pmu_lock; | |||
155 | static u8 pmu_intr_mask; | 155 | static u8 pmu_intr_mask; |
156 | static int pmu_version; | 156 | static int pmu_version; |
157 | static int drop_interrupts; | 157 | static int drop_interrupts; |
158 | #ifdef CONFIG_PMAC_PBOOK | 158 | #ifdef CONFIG_PM |
159 | static int option_lid_wakeup = 1; | 159 | static int option_lid_wakeup = 1; |
160 | static int sleep_in_progress; | 160 | static int sleep_in_progress; |
161 | #endif /* CONFIG_PMAC_PBOOK */ | 161 | #endif /* CONFIG_PM */ |
162 | static unsigned long async_req_locks; | 162 | static unsigned long async_req_locks; |
163 | static unsigned int pmu_irq_stats[11]; | 163 | static unsigned int pmu_irq_stats[11]; |
164 | 164 | ||
@@ -168,7 +168,6 @@ static struct proc_dir_entry *proc_pmu_irqstats; | |||
168 | static struct proc_dir_entry *proc_pmu_options; | 168 | static struct proc_dir_entry *proc_pmu_options; |
169 | static int option_server_mode; | 169 | static int option_server_mode; |
170 | 170 | ||
171 | #ifdef CONFIG_PMAC_PBOOK | ||
172 | int pmu_battery_count; | 171 | int pmu_battery_count; |
173 | int pmu_cur_battery; | 172 | int pmu_cur_battery; |
174 | unsigned int pmu_power_flags; | 173 | unsigned int pmu_power_flags; |
@@ -176,7 +175,6 @@ struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES]; | |||
176 | static int query_batt_timer = BATTERY_POLLING_COUNT; | 175 | static int query_batt_timer = BATTERY_POLLING_COUNT; |
177 | static struct adb_request batt_req; | 176 | static struct adb_request batt_req; |
178 | static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES]; | 177 | static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES]; |
179 | #endif /* CONFIG_PMAC_PBOOK */ | ||
180 | 178 | ||
181 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | 179 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) |
182 | extern int disable_kernel_backlight; | 180 | extern int disable_kernel_backlight; |
@@ -210,11 +208,9 @@ static int proc_get_irqstats(char *page, char **start, off_t off, | |||
210 | static int pmu_set_backlight_level(int level, void* data); | 208 | static int pmu_set_backlight_level(int level, void* data); |
211 | static int pmu_set_backlight_enable(int on, int level, void* data); | 209 | static int pmu_set_backlight_enable(int on, int level, void* data); |
212 | #endif /* CONFIG_PMAC_BACKLIGHT */ | 210 | #endif /* CONFIG_PMAC_BACKLIGHT */ |
213 | #ifdef CONFIG_PMAC_PBOOK | ||
214 | static void pmu_pass_intr(unsigned char *data, int len); | 211 | static void pmu_pass_intr(unsigned char *data, int len); |
215 | static int proc_get_batt(char *page, char **start, off_t off, | 212 | static int proc_get_batt(char *page, char **start, off_t off, |
216 | int count, int *eof, void *data); | 213 | int count, int *eof, void *data); |
217 | #endif /* CONFIG_PMAC_PBOOK */ | ||
218 | static int proc_read_options(char *page, char **start, off_t off, | 214 | static int proc_read_options(char *page, char **start, off_t off, |
219 | int count, int *eof, void *data); | 215 | int count, int *eof, void *data); |
220 | static int proc_write_options(struct file *file, const char __user *buffer, | 216 | static int proc_write_options(struct file *file, const char __user *buffer, |
@@ -407,9 +403,7 @@ static int __init via_pmu_start(void) | |||
407 | 403 | ||
408 | bright_req_1.complete = 1; | 404 | bright_req_1.complete = 1; |
409 | bright_req_2.complete = 1; | 405 | bright_req_2.complete = 1; |
410 | #ifdef CONFIG_PMAC_PBOOK | ||
411 | batt_req.complete = 1; | 406 | batt_req.complete = 1; |
412 | #endif | ||
413 | 407 | ||
414 | #ifdef CONFIG_PPC32 | 408 | #ifdef CONFIG_PPC32 |
415 | if (pmu_kind == PMU_KEYLARGO_BASED) | 409 | if (pmu_kind == PMU_KEYLARGO_BASED) |
@@ -468,7 +462,7 @@ static int __init via_pmu_dev_init(void) | |||
468 | register_backlight_controller(&pmu_backlight_controller, NULL, "pmu"); | 462 | register_backlight_controller(&pmu_backlight_controller, NULL, "pmu"); |
469 | #endif /* CONFIG_PMAC_BACKLIGHT */ | 463 | #endif /* CONFIG_PMAC_BACKLIGHT */ |
470 | 464 | ||
471 | #ifdef CONFIG_PMAC_PBOOK | 465 | #ifdef CONFIG_PPC32 |
472 | if (machine_is_compatible("AAPL,3400/2400") || | 466 | if (machine_is_compatible("AAPL,3400/2400") || |
473 | machine_is_compatible("AAPL,3500")) { | 467 | machine_is_compatible("AAPL,3500")) { |
474 | int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, | 468 | int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, |
@@ -496,20 +490,19 @@ static int __init via_pmu_dev_init(void) | |||
496 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; | 490 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; |
497 | } | 491 | } |
498 | } | 492 | } |
499 | #endif /* CONFIG_PMAC_PBOOK */ | 493 | #endif /* CONFIG_PPC32 */ |
494 | |||
500 | /* Create /proc/pmu */ | 495 | /* Create /proc/pmu */ |
501 | proc_pmu_root = proc_mkdir("pmu", NULL); | 496 | proc_pmu_root = proc_mkdir("pmu", NULL); |
502 | if (proc_pmu_root) { | 497 | if (proc_pmu_root) { |
503 | #ifdef CONFIG_PMAC_PBOOK | 498 | long i; |
504 | int i; | ||
505 | 499 | ||
506 | for (i=0; i<pmu_battery_count; i++) { | 500 | for (i=0; i<pmu_battery_count; i++) { |
507 | char title[16]; | 501 | char title[16]; |
508 | sprintf(title, "battery_%d", i); | 502 | sprintf(title, "battery_%ld", i); |
509 | proc_pmu_batt[i] = create_proc_read_entry(title, 0, proc_pmu_root, | 503 | proc_pmu_batt[i] = create_proc_read_entry(title, 0, proc_pmu_root, |
510 | proc_get_batt, (void *)i); | 504 | proc_get_batt, (void *)i); |
511 | } | 505 | } |
512 | #endif /* CONFIG_PMAC_PBOOK */ | ||
513 | 506 | ||
514 | proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root, | 507 | proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root, |
515 | proc_get_info, NULL); | 508 | proc_get_info, NULL); |
@@ -629,8 +622,6 @@ static void pmu_set_server_mode(int server_mode) | |||
629 | pmu_wait_complete(&req); | 622 | pmu_wait_complete(&req); |
630 | } | 623 | } |
631 | 624 | ||
632 | #ifdef CONFIG_PMAC_PBOOK | ||
633 | |||
634 | /* This new version of the code for 2400/3400/3500 powerbooks | 625 | /* This new version of the code for 2400/3400/3500 powerbooks |
635 | * is inspired from the implementation in gkrellm-pmu | 626 | * is inspired from the implementation in gkrellm-pmu |
636 | */ | 627 | */ |
@@ -813,8 +804,6 @@ query_battery_state(void) | |||
813 | 2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1); | 804 | 2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1); |
814 | } | 805 | } |
815 | 806 | ||
816 | #endif /* CONFIG_PMAC_PBOOK */ | ||
817 | |||
818 | static int __pmac | 807 | static int __pmac |
819 | proc_get_info(char *page, char **start, off_t off, | 808 | proc_get_info(char *page, char **start, off_t off, |
820 | int count, int *eof, void *data) | 809 | int count, int *eof, void *data) |
@@ -823,11 +812,9 @@ proc_get_info(char *page, char **start, off_t off, | |||
823 | 812 | ||
824 | p += sprintf(p, "PMU driver version : %d\n", PMU_DRIVER_VERSION); | 813 | p += sprintf(p, "PMU driver version : %d\n", PMU_DRIVER_VERSION); |
825 | p += sprintf(p, "PMU firmware version : %02x\n", pmu_version); | 814 | p += sprintf(p, "PMU firmware version : %02x\n", pmu_version); |
826 | #ifdef CONFIG_PMAC_PBOOK | ||
827 | p += sprintf(p, "AC Power : %d\n", | 815 | p += sprintf(p, "AC Power : %d\n", |
828 | ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0)); | 816 | ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0)); |
829 | p += sprintf(p, "Battery count : %d\n", pmu_battery_count); | 817 | p += sprintf(p, "Battery count : %d\n", pmu_battery_count); |
830 | #endif /* CONFIG_PMAC_PBOOK */ | ||
831 | 818 | ||
832 | return p - page; | 819 | return p - page; |
833 | } | 820 | } |
@@ -859,12 +846,11 @@ proc_get_irqstats(char *page, char **start, off_t off, | |||
859 | return p - page; | 846 | return p - page; |
860 | } | 847 | } |
861 | 848 | ||
862 | #ifdef CONFIG_PMAC_PBOOK | ||
863 | static int __pmac | 849 | static int __pmac |
864 | proc_get_batt(char *page, char **start, off_t off, | 850 | proc_get_batt(char *page, char **start, off_t off, |
865 | int count, int *eof, void *data) | 851 | int count, int *eof, void *data) |
866 | { | 852 | { |
867 | int batnum = (int)data; | 853 | long batnum = (long)data; |
868 | char *p = page; | 854 | char *p = page; |
869 | 855 | ||
870 | p += sprintf(p, "\n"); | 856 | p += sprintf(p, "\n"); |
@@ -883,7 +869,6 @@ proc_get_batt(char *page, char **start, off_t off, | |||
883 | 869 | ||
884 | return p - page; | 870 | return p - page; |
885 | } | 871 | } |
886 | #endif /* CONFIG_PMAC_PBOOK */ | ||
887 | 872 | ||
888 | static int __pmac | 873 | static int __pmac |
889 | proc_read_options(char *page, char **start, off_t off, | 874 | proc_read_options(char *page, char **start, off_t off, |
@@ -891,11 +876,11 @@ proc_read_options(char *page, char **start, off_t off, | |||
891 | { | 876 | { |
892 | char *p = page; | 877 | char *p = page; |
893 | 878 | ||
894 | #ifdef CONFIG_PMAC_PBOOK | 879 | #ifdef CONFIG_PM |
895 | if (pmu_kind == PMU_KEYLARGO_BASED && | 880 | if (pmu_kind == PMU_KEYLARGO_BASED && |
896 | pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) | 881 | pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) |
897 | p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup); | 882 | p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup); |
898 | #endif /* CONFIG_PMAC_PBOOK */ | 883 | #endif |
899 | if (pmu_kind == PMU_KEYLARGO_BASED) | 884 | if (pmu_kind == PMU_KEYLARGO_BASED) |
900 | p += sprintf(p, "server_mode=%d\n", option_server_mode); | 885 | p += sprintf(p, "server_mode=%d\n", option_server_mode); |
901 | 886 | ||
@@ -932,12 +917,12 @@ proc_write_options(struct file *file, const char __user *buffer, | |||
932 | *(val++) = 0; | 917 | *(val++) = 0; |
933 | while(*val == ' ') | 918 | while(*val == ' ') |
934 | val++; | 919 | val++; |
935 | #ifdef CONFIG_PMAC_PBOOK | 920 | #ifdef CONFIG_PM |
936 | if (pmu_kind == PMU_KEYLARGO_BASED && | 921 | if (pmu_kind == PMU_KEYLARGO_BASED && |
937 | pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) | 922 | pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) |
938 | if (!strcmp(label, "lid_wakeup")) | 923 | if (!strcmp(label, "lid_wakeup")) |
939 | option_lid_wakeup = ((*val) == '1'); | 924 | option_lid_wakeup = ((*val) == '1'); |
940 | #endif /* CONFIG_PMAC_PBOOK */ | 925 | #endif |
941 | if (pmu_kind == PMU_KEYLARGO_BASED && !strcmp(label, "server_mode")) { | 926 | if (pmu_kind == PMU_KEYLARGO_BASED && !strcmp(label, "server_mode")) { |
942 | int new_value; | 927 | int new_value; |
943 | new_value = ((*val) == '1'); | 928 | new_value = ((*val) == '1'); |
@@ -1432,7 +1417,6 @@ next: | |||
1432 | } | 1417 | } |
1433 | /* Tick interrupt */ | 1418 | /* Tick interrupt */ |
1434 | else if ((1 << pirq) & PMU_INT_TICK) { | 1419 | else if ((1 << pirq) & PMU_INT_TICK) { |
1435 | #ifdef CONFIG_PMAC_PBOOK | ||
1436 | /* Environement or tick interrupt, query batteries */ | 1420 | /* Environement or tick interrupt, query batteries */ |
1437 | if (pmu_battery_count) { | 1421 | if (pmu_battery_count) { |
1438 | if ((--query_batt_timer) == 0) { | 1422 | if ((--query_batt_timer) == 0) { |
@@ -1447,7 +1431,6 @@ next: | |||
1447 | pmu_pass_intr(data, len); | 1431 | pmu_pass_intr(data, len); |
1448 | } else { | 1432 | } else { |
1449 | pmu_pass_intr(data, len); | 1433 | pmu_pass_intr(data, len); |
1450 | #endif /* CONFIG_PMAC_PBOOK */ | ||
1451 | } | 1434 | } |
1452 | goto next; | 1435 | goto next; |
1453 | } | 1436 | } |
@@ -2062,7 +2045,7 @@ pmu_i2c_simple_write(int bus, int addr, u8* data, int len) | |||
2062 | return -1; | 2045 | return -1; |
2063 | } | 2046 | } |
2064 | 2047 | ||
2065 | #ifdef CONFIG_PMAC_PBOOK | 2048 | #ifdef CONFIG_PM |
2066 | 2049 | ||
2067 | static LIST_HEAD(sleep_notifiers); | 2050 | static LIST_HEAD(sleep_notifiers); |
2068 | 2051 | ||
@@ -2715,6 +2698,8 @@ powerbook_sleep_3400(void) | |||
2715 | return 0; | 2698 | return 0; |
2716 | } | 2699 | } |
2717 | 2700 | ||
2701 | #endif /* CONFIG_PM */ | ||
2702 | |||
2718 | /* | 2703 | /* |
2719 | * Support for /dev/pmu device | 2704 | * Support for /dev/pmu device |
2720 | */ | 2705 | */ |
@@ -2894,11 +2879,11 @@ static int __pmac | |||
2894 | pmu_ioctl(struct inode * inode, struct file *filp, | 2879 | pmu_ioctl(struct inode * inode, struct file *filp, |
2895 | u_int cmd, u_long arg) | 2880 | u_int cmd, u_long arg) |
2896 | { | 2881 | { |
2897 | struct pmu_private *pp = filp->private_data; | ||
2898 | __u32 __user *argp = (__u32 __user *)arg; | 2882 | __u32 __user *argp = (__u32 __user *)arg; |
2899 | int error; | 2883 | int error = -EINVAL; |
2900 | 2884 | ||
2901 | switch (cmd) { | 2885 | switch (cmd) { |
2886 | #ifdef CONFIG_PM | ||
2902 | case PMU_IOC_SLEEP: | 2887 | case PMU_IOC_SLEEP: |
2903 | if (!capable(CAP_SYS_ADMIN)) | 2888 | if (!capable(CAP_SYS_ADMIN)) |
2904 | return -EACCES; | 2889 | return -EACCES; |
@@ -2920,12 +2905,13 @@ pmu_ioctl(struct inode * inode, struct file *filp, | |||
2920 | error = -ENOSYS; | 2905 | error = -ENOSYS; |
2921 | } | 2906 | } |
2922 | sleep_in_progress = 0; | 2907 | sleep_in_progress = 0; |
2923 | return error; | 2908 | break; |
2924 | case PMU_IOC_CAN_SLEEP: | 2909 | case PMU_IOC_CAN_SLEEP: |
2925 | if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0) | 2910 | if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0) |
2926 | return put_user(0, argp); | 2911 | return put_user(0, argp); |
2927 | else | 2912 | else |
2928 | return put_user(1, argp); | 2913 | return put_user(1, argp); |
2914 | #endif /* CONFIG_PM */ | ||
2929 | 2915 | ||
2930 | #ifdef CONFIG_PMAC_BACKLIGHT | 2916 | #ifdef CONFIG_PMAC_BACKLIGHT |
2931 | /* Backlight should have its own device or go via | 2917 | /* Backlight should have its own device or go via |
@@ -2946,11 +2932,13 @@ pmu_ioctl(struct inode * inode, struct file *filp, | |||
2946 | error = get_user(value, argp); | 2932 | error = get_user(value, argp); |
2947 | if (!error) | 2933 | if (!error) |
2948 | error = set_backlight_level(value); | 2934 | error = set_backlight_level(value); |
2949 | return error; | 2935 | break; |
2950 | } | 2936 | } |
2951 | #ifdef CONFIG_INPUT_ADBHID | 2937 | #ifdef CONFIG_INPUT_ADBHID |
2952 | case PMU_IOC_GRAB_BACKLIGHT: { | 2938 | case PMU_IOC_GRAB_BACKLIGHT: { |
2939 | struct pmu_private *pp = filp->private_data; | ||
2953 | unsigned long flags; | 2940 | unsigned long flags; |
2941 | |||
2954 | if (pp->backlight_locker) | 2942 | if (pp->backlight_locker) |
2955 | return 0; | 2943 | return 0; |
2956 | pp->backlight_locker = 1; | 2944 | pp->backlight_locker = 1; |
@@ -2966,7 +2954,7 @@ pmu_ioctl(struct inode * inode, struct file *filp, | |||
2966 | case PMU_IOC_HAS_ADB: | 2954 | case PMU_IOC_HAS_ADB: |
2967 | return put_user(pmu_has_adb, argp); | 2955 | return put_user(pmu_has_adb, argp); |
2968 | } | 2956 | } |
2969 | return -EINVAL; | 2957 | return error; |
2970 | } | 2958 | } |
2971 | 2959 | ||
2972 | static struct file_operations pmu_device_fops __pmacdata = { | 2960 | static struct file_operations pmu_device_fops __pmacdata = { |
@@ -2982,14 +2970,16 @@ static struct miscdevice pmu_device __pmacdata = { | |||
2982 | PMU_MINOR, "pmu", &pmu_device_fops | 2970 | PMU_MINOR, "pmu", &pmu_device_fops |
2983 | }; | 2971 | }; |
2984 | 2972 | ||
2985 | void pmu_device_init(void) | 2973 | static int pmu_device_init(void) |
2986 | { | 2974 | { |
2987 | if (!via) | 2975 | if (!via) |
2988 | return; | 2976 | return 0; |
2989 | if (misc_register(&pmu_device) < 0) | 2977 | if (misc_register(&pmu_device) < 0) |
2990 | printk(KERN_ERR "via-pmu: cannot register misc device.\n"); | 2978 | printk(KERN_ERR "via-pmu: cannot register misc device.\n"); |
2979 | return 0; | ||
2991 | } | 2980 | } |
2992 | #endif /* CONFIG_PMAC_PBOOK */ | 2981 | device_initcall(pmu_device_init); |
2982 | |||
2993 | 2983 | ||
2994 | #ifdef DEBUG_SLEEP | 2984 | #ifdef DEBUG_SLEEP |
2995 | static inline void __pmac | 2985 | static inline void __pmac |
@@ -3157,12 +3147,12 @@ EXPORT_SYMBOL(pmu_i2c_combined_read); | |||
3157 | EXPORT_SYMBOL(pmu_i2c_stdsub_write); | 3147 | EXPORT_SYMBOL(pmu_i2c_stdsub_write); |
3158 | EXPORT_SYMBOL(pmu_i2c_simple_read); | 3148 | EXPORT_SYMBOL(pmu_i2c_simple_read); |
3159 | EXPORT_SYMBOL(pmu_i2c_simple_write); | 3149 | EXPORT_SYMBOL(pmu_i2c_simple_write); |
3160 | #ifdef CONFIG_PMAC_PBOOK | 3150 | #ifdef CONFIG_PM |
3161 | EXPORT_SYMBOL(pmu_register_sleep_notifier); | 3151 | EXPORT_SYMBOL(pmu_register_sleep_notifier); |
3162 | EXPORT_SYMBOL(pmu_unregister_sleep_notifier); | 3152 | EXPORT_SYMBOL(pmu_unregister_sleep_notifier); |
3163 | EXPORT_SYMBOL(pmu_enable_irled); | 3153 | EXPORT_SYMBOL(pmu_enable_irled); |
3164 | EXPORT_SYMBOL(pmu_battery_count); | 3154 | EXPORT_SYMBOL(pmu_battery_count); |
3165 | EXPORT_SYMBOL(pmu_batteries); | 3155 | EXPORT_SYMBOL(pmu_batteries); |
3166 | EXPORT_SYMBOL(pmu_power_flags); | 3156 | EXPORT_SYMBOL(pmu_power_flags); |
3167 | #endif /* CONFIG_PMAC_PBOOK */ | 3157 | #endif /* CONFIG_PM */ |
3168 | 3158 | ||