__uart_read_properties(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– __uart_read_properties(9) πŸ’–

okay so this is a page from the Kernel API Manual, and bestie, it's literally about reading the firmware properties of a UART port. let's get into it πŸŽ€


✨ NAME ✨

__uart_read_properties β€” read firmware properties of the given UART port πŸ¦‹


🌸 SYNOPSIS 🌸

int __uart_read_properties (struct uart_port *port , bool use_defaults
);

πŸŽ€ ARGUMENTS πŸŽ€

  • port β€” the corresponding port πŸ‘‘
  • use_defaults β€” apply defaults (when true) or validate the values (when false) 🫢

πŸ’… DESCRIPTION πŸ’…

so these are the device properties that are supported, no cap:

  • clock-frequency (optional)
  • fifo-size (optional)
  • no-loopback-test (optional)
  • reg-shift (defaults may apply)
  • reg-offset (value may be validated)
  • reg-io-width (defaults may apply or value may be validated)
  • interrupts (OF only)
  • serial [alias ID] (OF only)

so if the port->dev is of struct platform_device type, the interrupt line gets retrieved via the platform_get_irq call against that device. otherwise it gets assigned by the fwnode_irq_get call. either way, index 0 of the resource is the one used fr fr. ⭐

the caller is responsible for initializing the following fields of the port->dev (must be valid): ->flags, ->iobase, ->mapbase, ->mapsize, ->regshift (if use_defaults is false) before calling this function. alternatively those same fields may be zeroed, and in that case the only ones that have associated properties found will be set to the respective values. πŸ’œ

if no error happened, then ->irq, ->mapbase, ->mapsize will be altered. the ->iotype is always altered. periodt. πŸ”₯

okay so when use_defaults is true and the respective property is not found, the following values will be applied: ->regshift = 0. In this case IRQ must be provided, otherwise an error will be returned. 😭

and when use_defaults is false and the respective property is found, the following values will be validated:

  • reg-io-width (->iotype)
  • reg-offset (->mapsize against ->mapbase)

🌈 RETURN 🌈

0 on success, or negative errno on failure πŸ’€


πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./drivers/tty/serial/serial_port.c β€” go read it, iykyk πŸ“–


aaaand that's the whole thing bestie, slay πŸ’…βœ¨ this page is from the ./drivers/tty/serial corner of the kernel, dated October 2026 β€” mwah, iconic, no notes πŸ“πŸ§šπŸ’–

πŸ“¦ where this page comes from