aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/powermac
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2006-07-31 20:37:25 -0400
committerPaul Mackerras <paulus@samba.org>2006-07-31 20:37:25 -0400
commit57cad8084e0837e0f2c97da789ec9b3f36809be9 (patch)
treee9c790afb4286f78cb08d9664f58baa7e876fe55 /arch/powerpc/platforms/powermac
parentcb18bd40030c879cd93fef02fd579f74dbab473d (diff)
parent49b1e3ea19b1c95c2f012b8331ffb3b169e4c042 (diff)
Merge branch 'merge'
Diffstat (limited to 'arch/powerpc/platforms/powermac')
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c85
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_64.c14
-rw-r--r--arch/powerpc/platforms/powermac/pci.c13
-rw-r--r--arch/powerpc/platforms/powermac/pic.c8
4 files changed, 94 insertions, 26 deletions
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index 205b4a392862..afa593a8544a 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -10,11 +10,33 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/fb.h> 11#include <linux/fb.h>
12#include <linux/backlight.h> 12#include <linux/backlight.h>
13#include <linux/adb.h>
14#include <linux/pmu.h>
15#include <asm/atomic.h>
13#include <asm/prom.h> 16#include <asm/prom.h>
14#include <asm/backlight.h> 17#include <asm/backlight.h>
15 18
16#define OLD_BACKLIGHT_MAX 15 19#define OLD_BACKLIGHT_MAX 15
17 20
21static void pmac_backlight_key_worker(void *data);
22static void pmac_backlight_set_legacy_worker(void *data);
23
24static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker, NULL);
25static DECLARE_WORK(pmac_backlight_set_legacy_work, pmac_backlight_set_legacy_worker, NULL);
26
27/* Although these variables are used in interrupt context, it makes no sense to
28 * protect them. No user is able to produce enough key events per second and
29 * notice the errors that might happen.
30 */
31static int pmac_backlight_key_queued;
32static int pmac_backlight_set_legacy_queued;
33
34/* The via-pmu code allows the backlight to be grabbed, in which case the
35 * in-kernel control of the brightness needs to be disabled. This should
36 * only be used by really old PowerBooks.
37 */
38static atomic_t kernel_backlight_disabled = ATOMIC_INIT(0);
39
18/* Protect the pmac_backlight variable */ 40/* Protect the pmac_backlight variable */
19DEFINE_MUTEX(pmac_backlight_mutex); 41DEFINE_MUTEX(pmac_backlight_mutex);
20 42
@@ -72,8 +94,11 @@ int pmac_backlight_curve_lookup(struct fb_info *info, int value)
72 return level; 94 return level;
73} 95}
74 96
75static void pmac_backlight_key(int direction) 97static void pmac_backlight_key_worker(void *data)
76{ 98{
99 if (atomic_read(&kernel_backlight_disabled))
100 return;
101
77 mutex_lock(&pmac_backlight_mutex); 102 mutex_lock(&pmac_backlight_mutex);
78 if (pmac_backlight) { 103 if (pmac_backlight) {
79 struct backlight_properties *props; 104 struct backlight_properties *props;
@@ -83,7 +108,8 @@ static void pmac_backlight_key(int direction)
83 props = pmac_backlight->props; 108 props = pmac_backlight->props;
84 109
85 brightness = props->brightness + 110 brightness = props->brightness +
86 ((direction?-1:1) * (props->max_brightness / 15)); 111 ((pmac_backlight_key_queued?-1:1) *
112 (props->max_brightness / 15));
87 113
88 if (brightness < 0) 114 if (brightness < 0)
89 brightness = 0; 115 brightness = 0;
@@ -98,17 +124,20 @@ static void pmac_backlight_key(int direction)
98 mutex_unlock(&pmac_backlight_mutex); 124 mutex_unlock(&pmac_backlight_mutex);
99} 125}
100 126
101void pmac_backlight_key_up() 127/* This function is called in interrupt context */
128void pmac_backlight_key(int direction)
102{ 129{
103 pmac_backlight_key(0); 130 if (atomic_read(&kernel_backlight_disabled))
131 return;
132
133 /* we can receive multiple interrupts here, but the scheduled work
134 * will run only once, with the last value
135 */
136 pmac_backlight_key_queued = direction;
137 schedule_work(&pmac_backlight_key_work);
104} 138}
105 139
106void pmac_backlight_key_down() 140static int __pmac_backlight_set_legacy_brightness(int brightness)
107{
108 pmac_backlight_key(1);
109}
110
111int pmac_backlight_set_legacy_brightness(int brightness)
112{ 141{
113 int error = -ENXIO; 142 int error = -ENXIO;
114 143
@@ -137,6 +166,28 @@ int pmac_backlight_set_legacy_brightness(int brightness)
137 return error; 166 return error;
138} 167}
139 168
169static void pmac_backlight_set_legacy_worker(void *data)
170{
171 if (atomic_read(&kernel_backlight_disabled))
172 return;
173
174 __pmac_backlight_set_legacy_brightness(pmac_backlight_set_legacy_queued);
175}
176
177/* This function is called in interrupt context */
178void pmac_backlight_set_legacy_brightness_pmu(int brightness) {
179 if (atomic_read(&kernel_backlight_disabled))
180 return;
181
182 pmac_backlight_set_legacy_queued = brightness;
183 schedule_work(&pmac_backlight_set_legacy_work);
184}
185
186int pmac_backlight_set_legacy_brightness(int brightness)
187{
188 return __pmac_backlight_set_legacy_brightness(brightness);
189}
190
140int pmac_backlight_get_legacy_brightness() 191int pmac_backlight_get_legacy_brightness()
141{ 192{
142 int result = -ENXIO; 193 int result = -ENXIO;
@@ -158,3 +209,17 @@ int pmac_backlight_get_legacy_brightness()
158 209
159 return result; 210 return result;
160} 211}
212
213void pmac_backlight_disable()
214{
215 atomic_inc(&kernel_backlight_disabled);
216}
217
218void pmac_backlight_enable()
219{
220 atomic_dec(&kernel_backlight_disabled);
221}
222
223EXPORT_SYMBOL_GPL(pmac_backlight);
224EXPORT_SYMBOL_GPL(pmac_backlight_mutex);
225EXPORT_SYMBOL_GPL(pmac_has_backlight_type);
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/arch/powerpc/platforms/powermac/cpufreq_64.c
index c364c89adb4e..167cd3ce8a13 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_64.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_64.c
@@ -87,9 +87,9 @@ static int (*g5_query_freq)(void);
87static DEFINE_MUTEX(g5_switch_mutex); 87static DEFINE_MUTEX(g5_switch_mutex);
88 88
89 89
90#ifdef CONFIG_PPC_SMU 90#ifdef CONFIG_PMAC_SMU
91 91
92static const u32 *g5_pmode_data; 92static u32 *g5_pmode_data;
93static int g5_pmode_max; 93static int g5_pmode_max;
94 94
95static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */ 95static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */
@@ -216,7 +216,7 @@ static void g5_dummy_switch_volt(int speed_mode)
216{ 216{
217} 217}
218 218
219#endif /* CONFIG_PPC_SMU */ 219#endif /* CONFIG_PMAC_SMU */
220 220
221/* 221/*
222 * Platform function based voltage switching for PowerMac7,2 & 7,3 222 * Platform function based voltage switching for PowerMac7,2 & 7,3
@@ -383,7 +383,7 @@ static struct cpufreq_driver g5_cpufreq_driver = {
383}; 383};
384 384
385 385
386#ifdef CONFIG_PPC_SMU 386#ifdef CONFIG_PMAC_SMU
387 387
388static int __init g5_neo2_cpufreq_init(struct device_node *cpus) 388static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
389{ 389{
@@ -535,7 +535,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
535 return rc; 535 return rc;
536} 536}
537 537
538#endif /* CONFIG_PPC_SMU */ 538#endif /* CONFIG_PMAC_SMU */
539 539
540 540
541static int __init g5_pm72_cpufreq_init(struct device_node *cpus) 541static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
@@ -731,10 +731,10 @@ static int __init g5_cpufreq_init(void)
731 machine_is_compatible("PowerMac7,3") || 731 machine_is_compatible("PowerMac7,3") ||
732 machine_is_compatible("RackMac3,1")) 732 machine_is_compatible("RackMac3,1"))
733 rc = g5_pm72_cpufreq_init(cpus); 733 rc = g5_pm72_cpufreq_init(cpus);
734#ifdef CONFIG_PPC_SMU 734#ifdef CONFIG_PMAC_SMU
735 else 735 else
736 rc = g5_neo2_cpufreq_init(cpus); 736 rc = g5_neo2_cpufreq_init(cpus);
737#endif /* CONFIG_PPC_SMU */ 737#endif /* CONFIG_PMAC_SMU */
738 738
739 of_node_put(cpus); 739 of_node_put(cpus);
740 return rc; 740 return rc;
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 787ffd999bc2..9923adc5248e 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -16,6 +16,7 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/bootmem.h> 18#include <linux/bootmem.h>
19#include <linux/irq.h>
19 20
20#include <asm/sections.h> 21#include <asm/sections.h>
21#include <asm/io.h> 22#include <asm/io.h>
@@ -24,10 +25,7 @@
24#include <asm/machdep.h> 25#include <asm/machdep.h>
25#include <asm/pmac_feature.h> 26#include <asm/pmac_feature.h>
26#include <asm/grackle.h> 27#include <asm/grackle.h>
27#ifdef CONFIG_PPC64
28//#include <asm/iommu.h>
29#include <asm/ppc-pci.h> 28#include <asm/ppc-pci.h>
30#endif
31 29
32#undef DEBUG 30#undef DEBUG
33 31
@@ -46,7 +44,6 @@ static int has_uninorth;
46static struct pci_controller *u3_agp; 44static struct pci_controller *u3_agp;
47static struct pci_controller *u4_pcie; 45static struct pci_controller *u4_pcie;
48static struct pci_controller *u3_ht; 46static struct pci_controller *u3_ht;
49#define has_second_ohare 0
50#else 47#else
51static int has_second_ohare; 48static int has_second_ohare;
52#endif /* CONFIG_PPC64 */ 49#endif /* CONFIG_PPC64 */
@@ -996,6 +993,7 @@ void __init pmac_pcibios_fixup(void)
996 /* Read interrupt from the device-tree */ 993 /* Read interrupt from the device-tree */
997 pci_read_irq_line(dev); 994 pci_read_irq_line(dev);
998 995
996#ifdef CONFIG_PPC32
999 /* Fixup interrupt for the modem/ethernet combo controller. 997 /* Fixup interrupt for the modem/ethernet combo controller.
1000 * on machines with a second ohare chip. 998 * on machines with a second ohare chip.
1001 * The number in the device tree (27) is bogus (correct for 999 * The number in the device tree (27) is bogus (correct for
@@ -1005,8 +1003,11 @@ void __init pmac_pcibios_fixup(void)
1005 */ 1003 */
1006 if (has_second_ohare && 1004 if (has_second_ohare &&
1007 dev->vendor == PCI_VENDOR_ID_DEC && 1005 dev->vendor == PCI_VENDOR_ID_DEC &&
1008 dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) 1006 dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) {
1009 dev->irq = irq_create_mapping(NULL, 60, 0); 1007 dev->irq = irq_create_mapping(NULL, 60);
1008 set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW);
1009 }
1010#endif /* CONFIG_PPC32 */
1010 } 1011 }
1011} 1012}
1012 1013
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 3d328bc1f7e0..060789e31c67 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -291,7 +291,7 @@ static int pmac_pic_host_match(struct irq_host *h, struct device_node *node)
291} 291}
292 292
293static int pmac_pic_host_map(struct irq_host *h, unsigned int virq, 293static int pmac_pic_host_map(struct irq_host *h, unsigned int virq,
294 irq_hw_number_t hw, unsigned int flags) 294 irq_hw_number_t hw)
295{ 295{
296 struct irq_desc *desc = get_irq_desc(virq); 296 struct irq_desc *desc = get_irq_desc(virq);
297 int level; 297 int level;
@@ -318,6 +318,7 @@ static int pmac_pic_host_xlate(struct irq_host *h, struct device_node *ct,
318 unsigned int *out_flags) 318 unsigned int *out_flags)
319 319
320{ 320{
321 *out_flags = IRQ_TYPE_NONE;
321 *out_hwirq = *intspec; 322 *out_hwirq = *intspec;
322 return 0; 323 return 0;
323} 324}
@@ -434,7 +435,7 @@ static void __init pmac_pic_probe_oldstyle(void)
434 435
435 printk(KERN_INFO "irq: System has %d possible interrupts\n", max_irqs); 436 printk(KERN_INFO "irq: System has %d possible interrupts\n", max_irqs);
436#ifdef CONFIG_XMON 437#ifdef CONFIG_XMON
437 setup_irq(irq_create_mapping(NULL, 20, 0), &xmon_action); 438 setup_irq(irq_create_mapping(NULL, 20), &xmon_action);
438#endif 439#endif
439} 440}
440#endif /* CONFIG_PPC32 */ 441#endif /* CONFIG_PPC32 */
@@ -579,9 +580,10 @@ void __init pmac_pic_init(void)
579 flags |= OF_IMAP_OLDWORLD_MAC; 580 flags |= OF_IMAP_OLDWORLD_MAC;
580 if (get_property(of_chosen, "linux,bootx", NULL) != NULL) 581 if (get_property(of_chosen, "linux,bootx", NULL) != NULL)
581 flags |= OF_IMAP_NO_PHANDLE; 582 flags |= OF_IMAP_NO_PHANDLE;
582 of_irq_map_init(flags);
583#endif /* CONFIG_PPC_32 */ 583#endif /* CONFIG_PPC_32 */
584 584
585 of_irq_map_init(flags);
586
585 /* We first try to detect Apple's new Core99 chipset, since mac-io 587 /* We first try to detect Apple's new Core99 chipset, since mac-io
586 * is quite different on those machines and contains an IBM MPIC2. 588 * is quite different on those machines and contains an IBM MPIC2.
587 */ 589 */