aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2005-11-23 01:57:25 -0500
committerPaul Mackerras <paulus@samba.org>2006-01-08 22:49:54 -0500
commit51d3082fe6e55aecfa17113dbe98077c749f724c (patch)
tree9a1e2355d5988d8cc1ca511d53c1bb24b0baa17f /drivers
parent463ce0e103f419f51b1769111e73fe8bb305d0ec (diff)
[PATCH] powerpc: Unify udbg (#2)
This patch unifies udbg for both ppc32 and ppc64 when building the merged achitecture. xmon now has a single "back end". The powermac udbg stuff gets enriched with some ADB capabilities and btext output. In addition, the early_init callback is now called on ppc32 as well, approx. in the same order as ppc64 regarding device-tree manipulations. The init sequences of ppc32 and ppc64 are getting closer, I'll unify them in a later patch. For now, you can force udbg to the scc using "sccdbg" or to btext using "btextdbg" on powermacs. I'll implement a cleaner way of forcing udbg output to something else than the autodetected OF output device in a later patch. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/busses/i2c-keywest.c25
-rw-r--r--drivers/macintosh/via-cuda.c48
-rw-r--r--drivers/macintosh/via-pmu.c87
3 files changed, 93 insertions, 67 deletions
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c
index d61f748278fc..93e7080e3bc5 100644
--- a/drivers/i2c/busses/i2c-keywest.c
+++ b/drivers/i2c/busses/i2c-keywest.c
@@ -505,16 +505,23 @@ static int
505create_iface(struct device_node *np, struct device *dev) 505create_iface(struct device_node *np, struct device *dev)
506{ 506{
507 unsigned long steps; 507 unsigned long steps;
508 unsigned bsteps, tsize, i, nchan, addroffset; 508 unsigned bsteps, tsize, i, nchan;
509 struct keywest_iface* iface; 509 struct keywest_iface* iface;
510 u32 *psteps, *prate; 510 u32 *psteps, *prate, *addrp;
511 int rc; 511 int rc;
512 512
513 if (np->n_intrs < 1 || np->n_addrs < 1) { 513 if (np->n_intrs < 1) {
514 printk(KERN_ERR "%s: Missing interrupt or address !\n", 514 printk(KERN_ERR "%s: Missing interrupt !\n",
515 np->full_name); 515 np->full_name);
516 return -ENODEV; 516 return -ENODEV;
517 } 517 }
518 addrp = (u32 *)get_property(np, "AAPL,address", NULL);
519 if (addrp == NULL) {
520 printk(KERN_ERR "%s: Can't find address !\n",
521 np->full_name);
522 return -ENODEV;
523 }
524
518 if (pmac_low_i2c_lock(np)) 525 if (pmac_low_i2c_lock(np))
519 return -ENODEV; 526 return -ENODEV;
520 527
@@ -525,13 +532,10 @@ create_iface(struct device_node *np, struct device *dev)
525 for (bsteps = 0; (steps & 0x01) == 0; bsteps++) 532 for (bsteps = 0; (steps & 0x01) == 0; bsteps++)
526 steps >>= 1; 533 steps >>= 1;
527 534
528 if (np->parent->name[0] == 'u') { 535 if (np->parent->name[0] == 'u')
529 nchan = 2; 536 nchan = 2;
530 addroffset = 3; 537 else
531 } else {
532 addroffset = 0;
533 nchan = 1; 538 nchan = 1;
534 }
535 539
536 tsize = sizeof(struct keywest_iface) + 540 tsize = sizeof(struct keywest_iface) +
537 (sizeof(struct keywest_chan) + 4) * nchan; 541 (sizeof(struct keywest_chan) + 4) * nchan;
@@ -550,8 +554,7 @@ create_iface(struct device_node *np, struct device *dev)
550 iface->irq = np->intrs[0].line; 554 iface->irq = np->intrs[0].line;
551 iface->channels = (struct keywest_chan *) 555 iface->channels = (struct keywest_chan *)
552 (((unsigned long)(iface + 1) + 3UL) & ~3UL); 556 (((unsigned long)(iface + 1) + 3UL) & ~3UL);
553 iface->base = ioremap(np->addrs[0].address + addroffset, 557 iface->base = ioremap(*addrp, 0x1000);
554 np->addrs[0].size);
555 if (!iface->base) { 558 if (!iface->base) {
556 printk(KERN_ERR "i2c-keywest: can't map inteface !\n"); 559 printk(KERN_ERR "i2c-keywest: can't map inteface !\n");
557 kfree(iface); 560 kfree(iface);
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index d843a6c9c6df..18ff770ea668 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -127,39 +127,34 @@ struct adb_driver via_cuda_driver = {
127#endif /* CONFIG_ADB */ 127#endif /* CONFIG_ADB */
128 128
129#ifdef CONFIG_PPC 129#ifdef CONFIG_PPC
130int __init 130int __init find_via_cuda(void)
131find_via_cuda(void)
132{ 131{
133 int err;
134 struct adb_request req; 132 struct adb_request req;
133 phys_addr_t taddr;
134 u32 *reg;
135 int err;
135 136
136 if (vias != 0) 137 if (vias != 0)
137 return 1; 138 return 1;
138 vias = find_devices("via-cuda"); 139 vias = of_find_node_by_name(NULL, "via-cuda");
139 if (vias == 0) 140 if (vias == 0)
140 return 0; 141 return 0;
141 if (vias->next != 0)
142 printk(KERN_WARNING "Warning: only using 1st via-cuda\n");
143
144#if 0
145 { int i;
146
147 printk("find_via_cuda: node = %p, addrs =", vias->node);
148 for (i = 0; i < vias->n_addrs; ++i)
149 printk(" %x(%x)", vias->addrs[i].address, vias->addrs[i].size);
150 printk(", intrs =");
151 for (i = 0; i < vias->n_intrs; ++i)
152 printk(" %x", vias->intrs[i].line);
153 printk("\n"); }
154#endif
155 142
156 if (vias->n_addrs != 1 || vias->n_intrs != 1) { 143 reg = (u32 *)get_property(vias, "reg", NULL);
157 printk(KERN_ERR "via-cuda: expecting 1 address (%d) and 1 interrupt (%d)\n", 144 if (reg == NULL) {
158 vias->n_addrs, vias->n_intrs); 145 printk(KERN_ERR "via-cuda: No \"reg\" property !\n");
159 if (vias->n_addrs < 1 || vias->n_intrs < 1) 146 goto fail;
160 return 0; 147 }
148 taddr = of_translate_address(vias, reg);
149 if (taddr == 0) {
150 printk(KERN_ERR "via-cuda: Can't translate address !\n");
151 goto fail;
152 }
153 via = ioremap(taddr, 0x2000);
154 if (via == NULL) {
155 printk(KERN_ERR "via-cuda: Can't map address !\n");
156 goto fail;
161 } 157 }
162 via = ioremap(vias->addrs->address, 0x2000);
163 158
164 cuda_state = idle; 159 cuda_state = idle;
165 sys_ctrler = SYS_CTRLER_CUDA; 160 sys_ctrler = SYS_CTRLER_CUDA;
@@ -185,6 +180,11 @@ find_via_cuda(void)
185 cuda_poll(); 180 cuda_poll();
186 181
187 return 1; 182 return 1;
183
184 fail:
185 of_node_put(vias);
186 vias = NULL;
187 return 0;
188} 188}
189#endif /* CONFIG_PPC */ 189#endif /* CONFIG_PPC */
190 190
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