static int grlib_apbuart_configure(void) { struct device_node *np, *rp; const u32 *prop; int freq_khz, line = 0; /* Get bus frequency */ rp = of_find_node_by_path("/"); if (!rp) return -ENODEV; rp = of_get_next_child(rp, NULL); if (!rp) return -ENODEV; prop = of_get_property(rp, "clock-frequency", NULL); if (!prop) return -ENODEV; freq_khz = *prop; for_each_matching_node(np, apbuart_match) { const int *irqs, *ampopts; const struct amba_prom_registers *regs; struct uart_port *port; unsigned long addr; ampopts = of_get_property(np, "ampopts", NULL); if (ampopts && (*ampopts == 0)) continue; /* Ignore if used by another OS instance */ irqs = of_get_property(np, "interrupts", NULL); regs = of_get_property(np, "reg", NULL); if (!irqs || !regs) continue; grlib_apbuart_nodes[line] = np; addr = regs->phys_addr; port = &grlib_apbuart_ports[line]; port->mapbase = addr; port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); port->irq = *irqs; port->iotype = UPIO_MEM; port->ops = &grlib_apbuart_ops; port->flags = UPF_BOOT_AUTOCONF; port->line = line; port->uartclk = freq_khz * 1000; port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line); line++; /* We support maximum UART_NR uarts ... */ if (line == UART_NR) break; } grlib_apbuart_driver.nr = grlib_apbuart_port_nr = line; return line ? 0 : -ENODEV; }
static int __devinit apbuart_probe(struct of_device *op, const struct of_device_id *match) { struct console co; int node; int freq_khz; int baud_rates[UART_NR]; unsigned long clk; struct device_node *dp = op->node; int v = 0, d = 0; unsigned int addr; struct uart_leon_port *port; struct amba_prom_registers *regs; int irq, line, *irqs; int *vendor = of_get_property(dp, "vendor", NULL); int *device = of_get_property(dp, "device", NULL); regs = of_get_property(dp, "reg", NULL); irqs = of_get_property(dp, "interrupts", NULL); if (vendor) v = *vendor; if (device) d = *device; if (LEON3_GpTimer_Regs == 0 || irqs == 0 || regs == 0 || !(v == VENDOR_GAISLER && d == GAISLER_APBUART)) { return -ENODEV; } addr = regs->phys_addr ; irq = *irqs; port = kzalloc(sizeof(struct uart_leon_port), GFP_KERNEL); if (unlikely(!port)) return -ENOMEM; node = prom_getchild(prom_root_node); freq_khz = prom_getint(node, "clock-frequency"); clk = ((unsigned long)(((LEON3_BYPASS_LOAD_PA(&LEON3_GpTimer_Regs->scalar_reload)) + 1))); port->port.membase = (void *)addr; port->port.mapbase = addr; port->port.irq = irq; port->port.iotype = SERIAL_IO_MEM; port->port.uartclk = clk * 1000 * 1000; port->port.fifosize = 1; port->port.ops = &leon_pops; port->port.flags = ASYNC_BOOT_AUTOCONF; port->port.line = line = leon_line_nr++; port->port.uartclk = freq_khz * 1000; uart_add_one_port(&leon_reg, port); uart_set_options(port, &co, line >= UART_NR ? 9600 : baud_rates[line], 'n', 8, 'n'); port->port.fifosize = apbuart_scan_fifo_size(port, line); apbuart_flush_fifo(port); printk("---------------- Match %d: 0x%x@%d : %s ----------------\n",line,addr, irq,dp->path_component_name); return 0; }
static int __init grlib_apbuart_configure(void) { struct device_node *np; int line = 0; for_each_matching_node(np, apbuart_match) { const int *ampopts; const u32 *freq_hz; const struct amba_prom_registers *regs; struct uart_port *port; unsigned long addr; ampopts = of_get_property(np, "ampopts", NULL); if (ampopts && (*ampopts == 0)) continue; /* Ignore if used by another OS instance */ regs = of_get_property(np, "reg", NULL); /* Frequency of APB Bus is frequency of UART */ freq_hz = of_get_property(np, "freq", NULL); if (!regs || !freq_hz || (*freq_hz == 0)) continue; grlib_apbuart_nodes[line] = np; addr = regs->phys_addr; port = &grlib_apbuart_ports[line]; port->mapbase = addr; port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); port->irq = 0; port->iotype = UPIO_MEM; port->ops = &grlib_apbuart_ops; port->flags = UPF_BOOT_AUTOCONF; port->line = line; port->uartclk = *freq_hz; port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line); line++; /* We support maximum UART_NR uarts ... */ if (line == UART_NR) break; } grlib_apbuart_driver.nr = grlib_apbuart_port_nr = line; return line ? 0 : -ENODEV; }
static void grlib_apbuart_configure(void) { static int enum_done; struct device_node *np, *rp; struct uart_port *port = NULL; const u32 *prop; int freq_khz; int v = 0, d = 0; unsigned int addr; int irq, line; struct amba_prom_registers *regs; if (enum_done) return; /* Get bus frequency */ rp = of_find_node_by_path("/"); rp = of_get_next_child(rp, NULL); prop = of_get_property(rp, "clock-frequency", NULL); freq_khz = *prop; line = 0; for_each_matching_node(np, apbuart_match) { int *vendor = (int *) of_get_property(np, "vendor", NULL); int *device = (int *) of_get_property(np, "device", NULL); int *irqs = (int *) of_get_property(np, "interrupts", NULL); regs = (struct amba_prom_registers *) of_get_property(np, "reg", NULL); if (vendor) v = *vendor; if (device) d = *device; if (!irqs || !regs) return; grlib_apbuart_nodes[line] = np; addr = regs->phys_addr; irq = *irqs; port = &grlib_apbuart_ports[line]; port->mapbase = addr; port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); port->irq = irq; port->iotype = UPIO_MEM; port->ops = &grlib_apbuart_ops; port->flags = UPF_BOOT_AUTOCONF; port->line = line; port->uartclk = freq_khz * 1000; port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line); line++; /* We support maximum UART_NR uarts ... */ if (line == UART_NR) break; }