aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/macintosh')
-rw-r--r--drivers/macintosh/adb.c6
-rw-r--r--drivers/macintosh/via-cuda.c74
2 files changed, 45 insertions, 35 deletions
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index d840a109f833..1c4ee6e77937 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -317,9 +317,11 @@ static int __init adb_init(void)
317 break; 317 break;
318 } 318 }
319 } 319 }
320 if ((adb_controller == NULL) || adb_controller->init()) { 320 if (adb_controller != NULL && adb_controller->init &&
321 printk(KERN_WARNING "Warning: no ADB interface detected\n"); 321 adb_controller->init())
322 adb_controller = NULL; 322 adb_controller = NULL;
323 if (adb_controller == NULL) {
324 printk(KERN_WARNING "Warning: no ADB interface detected\n");
323 } else { 325 } else {
324#ifdef CONFIG_PPC 326#ifdef CONFIG_PPC
325 if (of_machine_is_compatible("AAPL,PowerBook1998") || 327 if (of_machine_is_compatible("AAPL,PowerBook1998") ||
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index 62dd1fdafecf..971bc9582a5f 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -89,7 +89,6 @@ static int cuda_fully_inited;
89 89
90#ifdef CONFIG_ADB 90#ifdef CONFIG_ADB
91static int cuda_probe(void); 91static int cuda_probe(void);
92static int cuda_init(void);
93static int cuda_send_request(struct adb_request *req, int sync); 92static int cuda_send_request(struct adb_request *req, int sync);
94static int cuda_adb_autopoll(int devs); 93static int cuda_adb_autopoll(int devs);
95static int cuda_reset_adb_bus(void); 94static int cuda_reset_adb_bus(void);
@@ -107,17 +106,42 @@ int cuda_request(struct adb_request *req,
107 106
108#ifdef CONFIG_ADB 107#ifdef CONFIG_ADB
109struct adb_driver via_cuda_driver = { 108struct adb_driver via_cuda_driver = {
110 "CUDA", 109 .name = "CUDA",
111 cuda_probe, 110 .probe = cuda_probe,
112 cuda_init, 111 .send_request = cuda_send_request,
113 cuda_send_request, 112 .autopoll = cuda_adb_autopoll,
114 cuda_adb_autopoll, 113 .poll = cuda_poll,
115 cuda_poll, 114 .reset_bus = cuda_reset_adb_bus,
116 cuda_reset_adb_bus
117}; 115};
118#endif /* CONFIG_ADB */ 116#endif /* CONFIG_ADB */
119 117
120#ifdef CONFIG_PPC 118#ifdef CONFIG_MAC
119int __init find_via_cuda(void)
120{
121 struct adb_request req;
122 int err;
123
124 if (macintosh_config->adb_type != MAC_ADB_CUDA)
125 return 0;
126
127 via = via1;
128 cuda_state = idle;
129
130 err = cuda_init_via();
131 if (err) {
132 printk(KERN_ERR "cuda_init_via() failed\n");
133 via = NULL;
134 return 0;
135 }
136
137 /* enable autopoll */
138 cuda_request(&req, NULL, 3, CUDA_PACKET, CUDA_AUTOPOLL, 1);
139 while (!req.complete)
140 cuda_poll();
141
142 return 1;
143}
144#else
121int __init find_via_cuda(void) 145int __init find_via_cuda(void)
122{ 146{
123 struct adb_request req; 147 struct adb_request req;
@@ -175,7 +199,7 @@ int __init find_via_cuda(void)
175 vias = NULL; 199 vias = NULL;
176 return 0; 200 return 0;
177} 201}
178#endif /* CONFIG_PPC */ 202#endif /* !defined CONFIG_MAC */
179 203
180static int __init via_cuda_start(void) 204static int __init via_cuda_start(void)
181{ 205{
@@ -184,14 +208,14 @@ static int __init via_cuda_start(void)
184 208
185#ifdef CONFIG_MAC 209#ifdef CONFIG_MAC
186 cuda_irq = IRQ_MAC_ADB; 210 cuda_irq = IRQ_MAC_ADB;
187#else /* CONFIG_MAC */ 211#else
188 cuda_irq = irq_of_parse_and_map(vias, 0); 212 cuda_irq = irq_of_parse_and_map(vias, 0);
189 if (cuda_irq == NO_IRQ) { 213 if (cuda_irq == NO_IRQ) {
190 printk(KERN_ERR "via-cuda: can't map interrupts for %s\n", 214 printk(KERN_ERR "via-cuda: can't map interrupts for %s\n",
191 vias->full_name); 215 vias->full_name);
192 return -ENODEV; 216 return -ENODEV;
193 } 217 }
194#endif /* CONFIG_MAC */ 218#endif
195 219
196 if (request_irq(cuda_irq, cuda_interrupt, 0, "ADB", cuda_interrupt)) { 220 if (request_irq(cuda_irq, cuda_interrupt, 0, "ADB", cuda_interrupt)) {
197 printk(KERN_ERR "via-cuda: can't request irq %d\n", cuda_irq); 221 printk(KERN_ERR "via-cuda: can't request irq %d\n", cuda_irq);
@@ -216,28 +240,10 @@ cuda_probe(void)
216#else 240#else
217 if (macintosh_config->adb_type != MAC_ADB_CUDA) 241 if (macintosh_config->adb_type != MAC_ADB_CUDA)
218 return -ENODEV; 242 return -ENODEV;
219 via = via1;
220#endif 243#endif
221 return 0;
222}
223
224static int __init
225cuda_init(void)
226{
227#ifdef CONFIG_PPC
228 if (via == NULL) 244 if (via == NULL)
229 return -ENODEV; 245 return -ENODEV;
230 return 0; 246 return 0;
231#else
232 int err = cuda_init_via();
233 if (err) {
234 printk(KERN_ERR "cuda_init_via() failed\n");
235 return -ENODEV;
236 }
237 out_8(&via[IER], IER_SET|SR_INT); /* enable interrupt from SR */
238
239 return via_cuda_start();
240#endif
241} 247}
242#endif /* CONFIG_ADB */ 248#endif /* CONFIG_ADB */
243 249
@@ -430,9 +436,11 @@ cuda_poll(void)
430 /* cuda_interrupt only takes a normal lock, we disable 436 /* cuda_interrupt only takes a normal lock, we disable
431 * interrupts here to avoid re-entering and thus deadlocking. 437 * interrupts here to avoid re-entering and thus deadlocking.
432 */ 438 */
433 disable_irq(cuda_irq); 439 if (cuda_irq)
440 disable_irq(cuda_irq);
434 cuda_interrupt(0, NULL); 441 cuda_interrupt(0, NULL);
435 enable_irq(cuda_irq); 442 if (cuda_irq)
443 enable_irq(cuda_irq);
436} 444}
437 445
438static irqreturn_t 446static irqreturn_t
@@ -446,7 +454,7 @@ cuda_interrupt(int irq, void *arg)
446 454
447 spin_lock(&cuda_lock); 455 spin_lock(&cuda_lock);
448 456
449 /* On powermacs, this handler is registered for the VIA IRQ. But it uses 457 /* On powermacs, this handler is registered for the VIA IRQ. But they use
450 * just the shift register IRQ -- other VIA interrupt sources are disabled. 458 * just the shift register IRQ -- other VIA interrupt sources are disabled.
451 * On m68k macs, the VIA IRQ sources are dispatched individually. Unless 459 * On m68k macs, the VIA IRQ sources are dispatched individually. Unless
452 * we are polling, the shift register IRQ flag has already been cleared. 460 * we are polling, the shift register IRQ flag has already been cleared.