cdns_uart_calc_baud_divs(9)
π« cdns_uart_calc_baud_divs π«
okay so we're in the Kernel API Manual bestie, and today's main character is cdns_uart_calc_baud_divs(9) β the little function that does the math so your UART can actually talk at the speed you asked for π«Ά
πΈ NAME πΈ
cdns_uart_calc_baud_divs β calculate baud rate divisors, no cap, that's literally the whole job β¨
π SYNOPSIS π
unsigned int cdns_uart_calc_baud_divs (unsigned int clk , unsigned int
baud , u32 *rbdiv , u32 *rcd , int *div8 );
π ARGUMENTS π
clkβ the UART module input clock, your starting vibe β°baudβ the desired baud rate, aka what you want π₯rbdivβ theBDIVvalue, and yes it's a return value, it gets filled in for you πrcdβ theCDvalue, also a return value, also getting filled in πdiv8β the value for theclk_selbit inmod, return value too, she's the third output bestie πΈ
π RETURN π
the baud rate π« β specifically: the requested baud when it's possible, or the actual baud when there was too much error, or zero if no valid divisors are found π (that last one is the sad ending, we don't speak of it)
π¦ DESCRIPTION π¦
okay so the formula to obtain the baud rate is right here and it's giving iconic:
baud_tx/rx rate = clk/CD * (BDIV + 1)
and the details, because they matter:
input_clk= (Uart User Defined Clock or Apb Clock) β which one it is depends onUCLKENin theMRReg π§clk=input_clkorinput_clk/8β depends onCLKSin theMRreg βCDandBDIVdepend on values in the baud rate generate register and the baud rate clock divisor register π
like. it's just divisors all the way down, and honestly? slay π
π SEE ALSO π
the kernel file ./drivers/tty/serial/xilinx_uartps.c, plus the whole friend group:
struct cdns_uart(9)cdns_uart_handle_rx(9)cdns_rts_gpio_enable(9)cdns_rs485_tx_setup(9)cdns_rs485_rx_setup(9)cdns_uart_tx_empty(9)cdns_rs485_rx_callback(9)cdns_calc_after_tx_delay(9)cdns_uart_handle_tx(9)cdns_uart_isr(9)cdns_uart_set_baud_rate(9)cdns_uart_clk_notifier_cb(9)cdns_rs485_tx_callback(9)cdns_uart_start_tx(9)cdns_uart_stop_tx(9)cdns_uart_stop_rx(9)cdns_uart_break_ctl(9)cdns_uart_set_termios(9)cdns_uart_startup(9)cdns_uart_shutdown(9)cdns_uart_type(9)cdns_uart_verify_port(9)cdns_uart_request_port(9)cdns_uart_release_port(9)cdns_uart_config_port(9)cdns_uart_get_mctrl(9)cdns_uart_console_putchar(9)cdns_uart_console_write(9)cdns_uart_console_setup(9)cdns_uart_suspend(9)cdns_uart_resume(9)cdns_rs485_config(9)cdns_uart_probe(9)cdns_uart_remove(9)
and that's the page!! πβ¨ brought to you straight outta ./drivers/tty/serial, dated October 2026 β mwah, go divide some clocks bestie ππ¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms