/* get clock freq. if present */
clk = of_get_property(np, "clock-frequency", NULL); if (clk && *clk)
clock = be32_to_cpup(clk);
/* get default speed if present */
spd = of_get_property(np, "current-speed", NULL);
/* get register shift if present */
rs = of_get_property(np, "reg-shift", NULL); if (rs && *rs)
shift = be32_to_cpup(rs);
/* If we have a location index, then try to use it */ if (want_index >= 0 && want_index < MAX_LEGACY_SERIAL_PORTS)
index = want_index; else
index = legacy_serial_count;
/* if our index is still out of range, that mean that *arrayisfull,wecouldscanforafreeslotbutthat *makelittlesensetobother,justskiptheport
*/ if (index >= MAX_LEGACY_SERIAL_PORTS) return -1; if (index >= legacy_serial_count)
legacy_serial_count = index + 1;
/* Check if there is a port who already claimed our slot */ if (legacy_info->np != NULL) { /* if we still have some room, move it, else override */ if (legacy_serial_count < MAX_LEGACY_SERIAL_PORTS) {
printk(KERN_DEBUG "Moved legacy port %d -> %d\n",
index, legacy_serial_count);
legacy_serial_ports[legacy_serial_count] = *legacy_port;
legacy_serial_infos[legacy_serial_count] = *legacy_info;
legacy_serial_count++;
} else {
printk(KERN_DEBUG "Replacing legacy port %d\n", index);
}
}
/* Now fill the entry */
memset(legacy_port, 0, sizeof(*legacy_port)); if (iotype == UPIO_PORT)
legacy_port->iobase = base; else
legacy_port->mapbase = base;
/* We only support ports that have a clock frequency properly *encodedinthedevice-tree.
*/ if (!of_property_present(np, "clock-frequency")) return -1;
/* if reg-offset don't try to use it */ if (of_property_present(np, "reg-offset")) return -1;
/* if rtas uses this device, don't try to use it as well */ if (of_property_read_bool(np, "used-by-rtas")) return -1;
/* Get the address */
addrp = of_get_address(soc_dev, 0, NULL, NULL); if (addrp == NULL) return -1;
addr = of_translate_address(soc_dev, addrp); if (addr == OF_BAD_ADDR) return -1;
/* Add port, irq will be dealt with later. We passed a translated *IOportvalue.Itwillbefixeduplateralongwiththeirq
*/ if (of_node_is_type(tsi, "tsi-bridge")) return add_legacy_port(np, -1, UPIO_TSI, addr, addr, 0, legacy_port_flags, 0); else return add_legacy_port(np, -1, UPIO_MEM, addr, addr, 0, legacy_port_flags, 0);
}
staticint __init add_legacy_isa_port(struct device_node *np, struct device_node *isa_brg)
{ const __be32 *reg; constchar *typep; int index = -1;
u64 taddr;
DBG(" -> add_legacy_isa_port(%pOF)\n", np);
/* Get the ISA port number */
reg = of_get_property(np, "reg", NULL); if (reg == NULL) return -1;
/* Verify it's an IO port, we don't support anything else */ if (!(be32_to_cpu(reg[0]) & 0x00000001)) return -1;
/* Now look for an "ibm,aix-loc" property that gives us ordering *ifany...
*/
typep = of_get_property(np, "ibm,aix-loc", NULL);
/* If we have a location index, then use it */ if (typep && *typep == 'S')
index = simple_strtol(typep+1, NULL, 0) - 1;
/* Translate ISA address. If it fails, we still register the port *withnotranslatedaddresssothatitcanbepickedupasanIO *portlaterbytheserialdriver * *Note:Don'teventryonP8lpc,weknowit'snotdirectlymapped
*/ if (!of_device_is_compatible(isa_brg, "ibm,power8-lpc") ||
of_property_present(isa_brg, "ranges")) {
taddr = of_translate_address(np, reg); if (taddr == OF_BAD_ADDR)
taddr = 0;
} else
taddr = 0;
/* Add port, irq will be dealt with later */ return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]),
taddr, 0, legacy_port_flags, 0);
/* We only support ports that have a clock frequency properly *encodedinthedevice-tree(thatishaveanfcode).Anything *elsecan'tbeusedthatearlyandwillbenormallyprobedby *thegeneric8250_pcidriverlateron.Thereasonisthat8250 *compatibleUARTsonPCIneedallsortofquirks(portoffsets *etc...)thatthiscodedoesn'tknowabout
*/ if (!of_property_present(np, "clock-frequency")) return -1;
/* Get the PCI address. Assume BAR 0 */
addrp = of_get_pci_address(pci_dev, 0, NULL, &flags); if (addrp == NULL) return -1;
/* We only support BAR 0 for now */
iotype = (flags & IORESOURCE_MEM) ? UPIO_MEM : UPIO_PORT;
addr = of_translate_address(pci_dev, addrp); if (addr == OF_BAD_ADDR) return -1;
/* Set the IO base to the same as the translated address for MMIO, *ortothedomainlocalIObaseforPIO(itwillbefixeduplater)
*/ if (iotype == UPIO_MEM)
base = addr; else
base = of_read_number(&addrp[2], 1);
/* Try to guess an index... If we have subdevices of the pci dev, *wegettotheir"reg"property
*/ if (np != pci_dev) { const __be32 *reg = of_get_property(np, "reg", NULL); if (reg && (be32_to_cpup(reg) < 4))
index = lindex = be32_to_cpup(reg);
}
/* Local index means it's the Nth port in the PCI chip. Unfortunately *theoffsettoaddhereisdevicespecific.Weknowaboutthose *EXARportsandwedefaulttothemostcommoncase.IfyourUART *doesn'tworkforthesesettings,you'llhavetoaddyourownspecial *caseshere
*/ if (of_device_is_compatible(pci_dev, "pci13a8,152") ||
of_device_is_compatible(pci_dev, "pci13a8,154") ||
of_device_is_compatible(pci_dev, "pci13a8,158")) {
addr += 0x200 * lindex;
base += 0x200 * lindex;
} else {
addr += 8 * lindex;
base += 8 * lindex;
}
/* Add port, irq will be dealt with later. We passed a translated *IOportvalue.Itwillbefixeduplateralongwiththeirq
*/ return add_legacy_port(np, index, iotype, base, addr, 0,
legacy_port_flags, np != pci_dev);
} #endif
/* Check if a translated MMIO address has been found */ if (info->taddr) {
info->early_addr = early_ioremap(info->taddr, 0x1000); if (info->early_addr == NULL) return;
udbg_uart_init_mmio(info->early_addr, stride);
} else { /* Check if it's PIO and we support untranslated PIO */ if (port->iotype == UPIO_PORT && isa_io_special)
udbg_uart_init_pio(port->iobase, stride); else return;
}
/* Try to query the current speed */ if (info->speed == 0)
info->speed = udbg_probe_uart_speed(info->clock);
/* Set it up */
DBG("default console speed = %d\n", info->speed);
udbg_uart_setup(info->speed, info->clock);
}
/* Now find out if one of these is out firmware console */
path = of_get_property(of_chosen, "linux,stdout-path", NULL); if (path == NULL)
path = of_get_property(of_chosen, "stdout-path", NULL); if (path != NULL) {
stdout = of_find_node_by_path(path); if (stdout)
DBG("stdout is %pOF\n", stdout);
} else {
DBG(" no linux,stdout-path !\n");
}
/* Iterate over all the 16550 ports, looking for known parents */
for_each_compatible_node(np, "serial", "ns16550") { struct device_node *parent = of_get_parent(np); if (!parent) continue; if (of_match_node(legacy_serial_parents, parent) != NULL) { if (of_device_is_available(np)) {
index = add_legacy_soc_port(np, np); if (index >= 0 && np == stdout)
legacy_serial_console = index;
}
}
of_node_put(parent);
}
/* Next, fill our array with ISA ports */
for_each_node_by_type(np, "serial") { struct device_node *isa = of_get_parent(np); if (of_node_name_eq(isa, "isa") || of_node_name_eq(isa, "lpc")) { if (of_device_is_available(np)) {
index = add_legacy_isa_port(np, isa); if (index >= 0 && np == stdout)
legacy_serial_console = index;
}
}
of_node_put(isa);
}
#ifdef CONFIG_PCI /* Next, try to locate PCI ports */ for (np = NULL; (np = of_find_all_nodes(np));) { struct device_node *pci, *parent = of_get_parent(np); if (of_node_name_eq(parent, "isa")) {
of_node_put(parent); continue;
} if (!of_node_name_eq(np, "serial") &&
!of_node_is_type(np, "serial")) {
of_node_put(parent); continue;
} /* Check for known pciclass, and also check whether we have *adevicewithchildnodesforportsornot
*/ if (of_device_is_compatible(np, "pciclass,0700") ||
of_device_is_compatible(np, "pciclass,070002"))
pci = np; elseif (of_device_is_compatible(parent, "pciclass,0700") ||
of_device_is_compatible(parent, "pciclass,070002"))
pci = parent; else {
of_node_put(parent); continue;
}
index = add_legacy_pci_port(np, pci); if (index >= 0 && np == stdout)
legacy_serial_console = index;
of_node_put(parent);
} #endif
/* The user has requested a console so this is already set up. */ if (strstr(boot_command_line, "console=")) {
DBG(" console was specified !\n"); return -EBUSY;
}
if (!of_chosen) {
DBG(" of_chosen is NULL !\n"); return -ENODEV;
}
if (legacy_serial_console < 0) {
DBG(" legacy_serial_console not found !\n"); return -ENODEV;
} /* We are getting a weird phandle from OF ... */ /* ... So use the full path instead */
name = of_get_property(of_chosen, "linux,stdout-path", NULL); if (name == NULL)
name = of_get_property(of_chosen, "stdout-path", NULL); if (name == NULL) {
DBG(" no stdout-path !\n"); return -ENODEV;
}
prom_stdout = of_find_node_by_path(name); if (!prom_stdout) {
DBG(" can't find stdout package %s !\n", name); return -ENODEV;
}
DBG("stdout is %pOF\n", prom_stdout);
name = of_get_property(prom_stdout, "name", NULL); if (!name) {
DBG(" stdout package has no name !\n"); goto not_found;
}
spd = of_get_property(prom_stdout, "current-speed", NULL); if (spd)
speed = be32_to_cpup(spd);
if (strcmp(name, "serial") != 0) goto not_found;
/* Look for it in probed array */ for (i = 0; i < legacy_serial_count; i++) { if (prom_stdout != legacy_serial_infos[i].np) continue;
offset = i;
speed = legacy_serial_infos[i].speed; break;
} if (i >= legacy_serial_count) goto not_found;
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.8Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.