powerpc/powermac: Fixup default serial port device for pmac_zilog

This removes the non-working code in legacy_serial that tried to handle
the powermac SCC ports, and instead add a (now working) function to the
powermac platform code to find the default serial console if any.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

+90 -28
+18 -28
arch/powerpc/kernel/legacy_serial.c
··· 493 493 device_initcall(serial_dev_init); 494 494 495 495 496 + #ifdef CONFIG_SERIAL_8250_CONSOLE 496 497 /* 497 498 * This is called very early, as part of console_init() (typically just after 498 499 * time_init()). This function is respondible for trying to find a good 499 500 * default console on serial ports. It tries to match the open firmware 500 - * default output with one of the available serial console drivers, either 501 - * one of the platform serial ports that have been probed earlier by 502 - * find_legacy_serial_ports() or some more platform specific ones. 501 + * default output with one of the available serial console drivers that have 502 + * been probed earlier by find_legacy_serial_ports() 503 503 */ 504 504 static int __init check_legacy_serial_console(void) 505 505 { 506 506 struct device_node *prom_stdout = NULL; 507 - int speed = 0, offset = 0; 507 + int i, speed = 0, offset = 0; 508 508 const char *name; 509 509 const u32 *spd; 510 510 ··· 548 548 if (spd) 549 549 speed = *spd; 550 550 551 - if (0) 552 - ; 553 - #ifdef CONFIG_SERIAL_8250_CONSOLE 554 - else if (strcmp(name, "serial") == 0) { 555 - int i; 556 - /* Look for it in probed array */ 557 - for (i = 0; i < legacy_serial_count; i++) { 558 - if (prom_stdout != legacy_serial_infos[i].np) 559 - continue; 560 - offset = i; 561 - speed = legacy_serial_infos[i].speed; 562 - break; 563 - } 564 - if (i >= legacy_serial_count) 565 - goto not_found; 566 - } 567 - #endif /* CONFIG_SERIAL_8250_CONSOLE */ 568 - #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE 569 - else if (strcmp(name, "ch-a") == 0) 570 - offset = 0; 571 - else if (strcmp(name, "ch-b") == 0) 572 - offset = 1; 573 - #endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */ 574 - else 551 + if (strcmp(name, "serial") != 0) 575 552 goto not_found; 553 + 554 + /* Look for it in probed array */ 555 + for (i = 0; i < legacy_serial_count; i++) { 556 + if (prom_stdout != legacy_serial_infos[i].np) 557 + continue; 558 + offset = i; 559 + speed = legacy_serial_infos[i].speed; 560 + break; 561 + } 562 + if (i >= legacy_serial_count) 563 + goto not_found; 564 + 576 565 of_node_put(prom_stdout); 577 566 578 567 DBG("Found serial console at ttyS%d\n", offset); ··· 580 591 } 581 592 console_initcall(check_legacy_serial_console); 582 593 594 + #endif /* CONFIG_SERIAL_8250_CONSOLE */
+72
arch/powerpc/platforms/powermac/setup.c
··· 541 541 } 542 542 machine_device_initcall(powermac, pmac_declare_of_platform_devices); 543 543 544 + #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE 545 + /* 546 + * This is called very early, as part of console_init() (typically just after 547 + * time_init()). This function is respondible for trying to find a good 548 + * default console on serial ports. It tries to match the open firmware 549 + * default output with one of the available serial console drivers. 550 + */ 551 + static int __init check_pmac_serial_console(void) 552 + { 553 + struct device_node *prom_stdout = NULL; 554 + int offset = 0; 555 + const char *name; 556 + #ifdef CONFIG_SERIAL_PMACZILOG_TTYS 557 + char *devname = "ttyS"; 558 + #else 559 + char *devname = "ttyPZ"; 560 + #endif 561 + 562 + pr_debug(" -> check_pmac_serial_console()\n"); 563 + 564 + /* The user has requested a console so this is already set up. */ 565 + if (strstr(boot_command_line, "console=")) { 566 + pr_debug(" console was specified !\n"); 567 + return -EBUSY; 568 + } 569 + 570 + if (!of_chosen) { 571 + pr_debug(" of_chosen is NULL !\n"); 572 + return -ENODEV; 573 + } 574 + 575 + /* We are getting a weird phandle from OF ... */ 576 + /* ... So use the full path instead */ 577 + name = of_get_property(of_chosen, "linux,stdout-path", NULL); 578 + if (name == NULL) { 579 + pr_debug(" no linux,stdout-path !\n"); 580 + return -ENODEV; 581 + } 582 + prom_stdout = of_find_node_by_path(name); 583 + if (!prom_stdout) { 584 + pr_debug(" can't find stdout package %s !\n", name); 585 + return -ENODEV; 586 + } 587 + pr_debug("stdout is %s\n", prom_stdout->full_name); 588 + 589 + name = of_get_property(prom_stdout, "name", NULL); 590 + if (!name) { 591 + pr_debug(" stdout package has no name !\n"); 592 + goto not_found; 593 + } 594 + 595 + if (strcmp(name, "ch-a") == 0) 596 + offset = 0; 597 + else if (strcmp(name, "ch-b") == 0) 598 + offset = 1; 599 + else 600 + goto not_found; 601 + of_node_put(prom_stdout); 602 + 603 + pr_debug("Found serial console at %s%d\n", devname, offset); 604 + 605 + return add_preferred_console(devname, offset, NULL); 606 + 607 + not_found: 608 + pr_debug("No preferred console found !\n"); 609 + of_node_put(prom_stdout); 610 + return -ENODEV; 611 + } 612 + console_initcall(check_pmac_serial_console); 613 + 614 + #endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */ 615 + 544 616 /* 545 617 * Called very early, MMU is off, device-tree isn't unflattened 546 618 */