aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/via-pmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/macintosh/via-pmu.c')
-rw-r--r--drivers/macintosh/via-pmu.c87
1 files changed, 55 insertions, 32 deletions
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 564043508569..13881f199607 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -147,6 +147,7 @@ static struct device_node *vias;
147static int pmu_kind = PMU_UNKNOWN; 147static int pmu_kind = PMU_UNKNOWN;
148static int pmu_fully_inited = 0; 148static int pmu_fully_inited = 0;
149static int pmu_has_adb; 149static int pmu_has_adb;
150static struct device_node *gpio_node;
150static unsigned char __iomem *gpio_reg = NULL; 151static unsigned char __iomem *gpio_reg = NULL;
151static int gpio_irq = -1; 152static int gpio_irq = -1;
152static int gpio_irq_enabled = -1; 153static int gpio_irq_enabled = -1;
@@ -295,22 +296,26 @@ static struct backlight_controller pmu_backlight_controller = {
295}; 296};
296#endif /* CONFIG_PMAC_BACKLIGHT */ 297#endif /* CONFIG_PMAC_BACKLIGHT */
297 298
298int 299int __init find_via_pmu(void)
299find_via_pmu(void)
300{ 300{
301 phys_addr_t taddr;
302 u32 *reg;
303
301 if (via != 0) 304 if (via != 0)
302 return 1; 305 return 1;
303 vias = find_devices("via-pmu"); 306 vias = of_find_node_by_name(NULL, "via-pmu");
304 if (vias == 0) 307 if (vias == NULL)
305 return 0; 308 return 0;
306 if (vias->next != 0)
307 printk(KERN_WARNING "Warning: only using 1st via-pmu\n");
308 309
309 if (vias->n_addrs < 1 || vias->n_intrs < 1) { 310 reg = (u32 *)get_property(vias, "reg", NULL);
310 printk(KERN_ERR "via-pmu: %d addresses, %d interrupts!\n", 311 if (reg == NULL) {
311 vias->n_addrs, vias->n_intrs); 312 printk(KERN_ERR "via-pmu: No \"reg\" property !\n");
312 if (vias->n_addrs < 1 || vias->n_intrs < 1) 313 goto fail;
313 return 0; 314 }
315 taddr = of_translate_address(vias, reg);
316 if (taddr == 0) {
317 printk(KERN_ERR "via-pmu: Can't translate address !\n");
318 goto fail;
314 } 319 }
315 320
316 spin_lock_init(&pmu_lock); 321 spin_lock_init(&pmu_lock);
@@ -331,7 +336,8 @@ find_via_pmu(void)
331 pmu_kind = PMU_HEATHROW_BASED; 336 pmu_kind = PMU_HEATHROW_BASED;
332 else if (device_is_compatible(vias->parent, "Keylargo") 337 else if (device_is_compatible(vias->parent, "Keylargo")
333 || device_is_compatible(vias->parent, "K2-Keylargo")) { 338 || device_is_compatible(vias->parent, "K2-Keylargo")) {
334 struct device_node *gpio, *gpiop; 339 struct device_node *gpiop;
340 phys_addr_t gaddr = 0;
335 341
336 pmu_kind = PMU_KEYLARGO_BASED; 342 pmu_kind = PMU_KEYLARGO_BASED;
337 pmu_has_adb = (find_type_devices("adb") != NULL); 343 pmu_has_adb = (find_type_devices("adb") != NULL);
@@ -341,19 +347,24 @@ find_via_pmu(void)
341 PMU_INT_TICK | 347 PMU_INT_TICK |
342 PMU_INT_ENVIRONMENT; 348 PMU_INT_ENVIRONMENT;
343 349
344 gpiop = find_devices("gpio"); 350 gpiop = of_find_node_by_name(NULL, "gpio");
345 if (gpiop && gpiop->n_addrs) { 351 if (gpiop) {
346 gpio_reg = ioremap(gpiop->addrs->address, 0x10); 352 reg = (u32 *)get_property(gpiop, "reg", NULL);
347 gpio = find_devices("extint-gpio1"); 353 if (reg)
348 if (gpio == NULL) 354 gaddr = of_translate_address(gpiop, reg);
349 gpio = find_devices("pmu-interrupt"); 355 if (gaddr != 0)
350 if (gpio && gpio->parent == gpiop && gpio->n_intrs) 356 gpio_reg = ioremap(gaddr, 0x10);
351 gpio_irq = gpio->intrs[0].line;
352 } 357 }
358 if (gpio_reg == NULL)
359 printk(KERN_ERR "via-pmu: Can't find GPIO reg !\n");
353 } else 360 } else
354 pmu_kind = PMU_UNKNOWN; 361 pmu_kind = PMU_UNKNOWN;
355 362
356 via = ioremap(vias->addrs->address, 0x2000); 363 via = ioremap(taddr, 0x2000);
364 if (via == NULL) {
365 printk(KERN_ERR "via-pmu: Can't map address !\n");
366 goto fail;
367 }
357 368
358 out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */ 369 out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */
359 out_8(&via[IFR], 0x7f); /* clear IFR */ 370 out_8(&via[IFR], 0x7f); /* clear IFR */
@@ -371,17 +382,19 @@ find_via_pmu(void)
371 sys_ctrler = SYS_CTRLER_PMU; 382 sys_ctrler = SYS_CTRLER_PMU;
372 383
373 return 1; 384 return 1;
385 fail:
386 of_node_put(vias);
387 vias = NULL;
388 return 0;
374} 389}
375 390
376#ifdef CONFIG_ADB 391#ifdef CONFIG_ADB
377static int 392static int pmu_probe(void)
378pmu_probe(void)
379{ 393{
380 return vias == NULL? -ENODEV: 0; 394 return vias == NULL? -ENODEV: 0;
381} 395}
382 396
383static int __init 397static int __init pmu_init(void)
384pmu_init(void)
385{ 398{
386 if (vias == NULL) 399 if (vias == NULL)
387 return -ENODEV; 400 return -ENODEV;
@@ -405,7 +418,7 @@ static int __init via_pmu_start(void)
405 bright_req_2.complete = 1; 418 bright_req_2.complete = 1;
406 batt_req.complete = 1; 419 batt_req.complete = 1;
407 420
408#if defined(CONFIG_PPC32) && !defined(CONFIG_PPC_MERGE) 421#ifndef CONFIG_PPC_MERGE
409 if (pmu_kind == PMU_KEYLARGO_BASED) 422 if (pmu_kind == PMU_KEYLARGO_BASED)
410 openpic_set_irq_priority(vias->intrs[0].line, 423 openpic_set_irq_priority(vias->intrs[0].line,
411 OPENPIC_PRIORITY_DEFAULT + 1); 424 OPENPIC_PRIORITY_DEFAULT + 1);
@@ -418,10 +431,22 @@ static int __init via_pmu_start(void)
418 return -EAGAIN; 431 return -EAGAIN;
419 } 432 }
420 433
421 if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) { 434 if (pmu_kind == PMU_KEYLARGO_BASED) {
422 if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1 ADB", (void *)0)) 435 gpio_node = of_find_node_by_name(NULL, "extint-gpio1");
423 printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq); 436 if (gpio_node == NULL)
424 gpio_irq_enabled = 1; 437 gpio_node = of_find_node_by_name(NULL,
438 "pmu-interrupt");
439 if (gpio_node && gpio_node->n_intrs > 0)
440 gpio_irq = gpio_node->intrs[0].line;
441
442 if (gpio_irq != -1) {
443 if (request_irq(gpio_irq, gpio1_interrupt, 0,
444 "GPIO1 ADB", (void *)0))
445 printk(KERN_ERR "pmu: can't get irq %d"
446 " (GPIO1)\n", gpio_irq);
447 else
448 gpio_irq_enabled = 1;
449 }
425 } 450 }
426 451
427 /* Enable interrupts */ 452 /* Enable interrupts */
@@ -1371,7 +1396,6 @@ next:
1371 } 1396 }
1372 pmu_done(req); 1397 pmu_done(req);
1373 } else { 1398 } else {
1374#if defined(CONFIG_XMON) && !defined(CONFIG_PPC64)
1375 if (len == 4 && data[1] == 0x2c) { 1399 if (len == 4 && data[1] == 0x2c) {
1376 extern int xmon_wants_key, xmon_adb_keycode; 1400 extern int xmon_wants_key, xmon_adb_keycode;
1377 if (xmon_wants_key) { 1401 if (xmon_wants_key) {
@@ -1379,7 +1403,6 @@ next:
1379 return; 1403 return;
1380 } 1404 }
1381 } 1405 }
1382#endif /* defined(CONFIG_XMON) && !defined(CONFIG_PPC64) */
1383#ifdef CONFIG_ADB 1406#ifdef CONFIG_ADB
1384 /* 1407 /*
1385 * XXX On the [23]400 the PMU gives us an up 1408 * XXX On the [23]400 the PMU gives us an up