Hi Geert, > On May 8, 2015, at 16:20 , Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote: > > Kalimera Pantelis, > > I'm trying to use an overlay to enable an additional serial port on an > expansion port. The serial driver relies on of_alias_get_id() to find the > serial index, so I have to update /aliases. > Ugh, yeah, aliases are ‘special’. > My first naive try: > > fragment@0 { > target-path = "/aliases"; > > __overlay__ { > serial3 = <&scif3>; > }; > }; > > didn't work, as now /aliases/serial3 is a phandle, not a string. > > Next try: > > serial3 = &scif3; > > That one isn't liked by dtc: > > ERROR (path_references): Reference to non-existent node or label "scif3" > > Am I correct in assuming that fixup_path_references() needs updating to > support this, cfr. fixup_phandle_references()? > > Finally, let's hardcode the path: > > serial3 = "/serial@e6ea8000"; > > Now /sys/firmware/devicetree/base/aliases/serial3 is correct, but it > still doesn't > work, as the list of aliases is created only once (by of_alias_scan_aliases()), > after unpacking the device tree. I guess of_alias_add() should be called when > adding a property to /aliases. > Yes, you should be updating the aliases when adding something there. I’ve run into the same problem with the omap-serial driver but I’ve handled it differently. Here’s how I’ve handled it. > commit cc9d3f8406c8058dd5d0bd254d2452189365aac3 > Author: Pantelis Antoniou <pantelis.antoniou@xxxxxxxxxxxx> > Date: Thu Nov 6 14:12:14 2014 +0200 > > serial: omap: Fix port line number without aliases > > Having an omap serial device without a serial aliases doesn't > work. For now fallback to using the hwmod instance. > > Signed-off-by: Pantelis Antoniou <pantelis.antoniou@xxxxxxxxxxxx> > > diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c > index 211479a..d839418 100644 > --- a/drivers/tty/serial/omap-serial.c > +++ b/drivers/tty/serial/omap-serial.c > @@ -1616,6 +1616,31 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, > return 0; > } > > +static int serial_omap_of_get_port_line(struct device_node *np) > +{ > + unsigned long val; > + const char *hwmod; > + int ret; > + > + /* first try the serial alias */ > + ret = of_alias_get_id(np, "serial"); > + if (ret >= 0) > + return ret; > + > + /* no? calculate it from hwmods */ > + ret = of_property_read_string(np, "ti,hwmods", &hwmod); > + if (ret != 0 || strncmp(hwmod, "uart", 4) || > + kstrtoul(hwmod + 4, 10, &val)) > + return -ENODEV; > + > + /* numbering of hwmods is +1 */ > + ret = (int)val - 1; > + if (ret < 0) > + return -ENODEV; > + > + return ret; > +} > + > static int serial_omap_probe(struct platform_device *pdev) > { > struct omap_uart_port_info *omap_up_info = dev_get_platdata(&pdev->dev); > @@ -1659,7 +1684,7 @@ static int serial_omap_probe(struct platform_device *pdev) > up->port.ops = &serial_omap_pops; > > if (pdev->dev.of_node) > - ret = of_alias_get_id(pdev->dev.of_node, "serial"); > + ret = serial_omap_of_get_port_line(pdev->dev.of_node); > else > ret = pdev->id; > > It is possible for this to be fixed when adding something under aliases; give it a shot! > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds Regards — Pantelis -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html