Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sparc32,leon: Fixed APBUART frequency detection

The UARTs may be located on different APB buses, thus have

different UART clock frequency. The system frequency is not
the same (but often) as the UART frequency, rather the APB bus
frequency that the APBUART is located at has the same
frequency, so this looks at the "freq" property instead.

Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Hellstrom and committed by
David S. Miller
c897dcf6 10544f12

+7 -17
+7 -17
drivers/tty/serial/apbuart.c
··· 598 598 599 599 static int grlib_apbuart_configure(void) 600 600 { 601 - struct device_node *np, *rp; 602 - const u32 *prop; 603 - int freq_khz, line = 0; 604 - 605 - /* Get bus frequency */ 606 - rp = of_find_node_by_path("/"); 607 - if (!rp) 608 - return -ENODEV; 609 - rp = of_get_next_child(rp, NULL); 610 - if (!rp) 611 - return -ENODEV; 612 - prop = of_get_property(rp, "clock-frequency", NULL); 613 - if (!prop) 614 - return -ENODEV; 615 - freq_khz = *prop; 601 + struct device_node *np; 602 + int line = 0; 616 603 617 604 for_each_matching_node(np, apbuart_match) { 618 605 const int *ampopts; 606 + const u32 *freq_hz; 619 607 const struct amba_prom_registers *regs; 620 608 struct uart_port *port; 621 609 unsigned long addr; ··· 612 624 if (ampopts && (*ampopts == 0)) 613 625 continue; /* Ignore if used by another OS instance */ 614 626 regs = of_get_property(np, "reg", NULL); 627 + /* Frequency of APB Bus is frequency of UART */ 628 + freq_hz = of_get_property(np, "freq", NULL); 615 629 616 - if (!regs) 630 + if (!regs || !freq_hz || (*freq_hz == 0)) 617 631 continue; 618 632 619 633 grlib_apbuart_nodes[line] = np; ··· 631 641 port->ops = &grlib_apbuart_ops; 632 642 port->flags = UPF_BOOT_AUTOCONF; 633 643 port->line = line; 634 - port->uartclk = freq_khz * 1000; 644 + port->uartclk = *freq_hz; 635 645 port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line); 636 646 line++; 637 647