summaryrefslogtreecommitdiff
path: root/lib/utils/serial/uart8250.c
AgeCommit message (Collapse)Author
2025-12-21lib: utils/serial: Support multiple UART8250 devicesBo Gan
Previously we assume only 1 UART8250 instance can be used. Now we support multiple instances by introducing counterpart functions to putc/getc/init which take an extra *dev parameter, and name them as uart8250_device_xyz() The original functions without the *dev parameter will operate on the default instance exactly the same as before, so no changes on the caller is required. Note: uart8250_device_init only does device initialization without the console registration logic. Signed-off-by: Bo Gan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-11-10lib: utils/serial: typo RecieveHeinrich Schuchardt
%s/Recieve/Receive/ Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-07-20lib: utils/serial: Clear LSR status and check RBR statusYi Pei
On some platforms, read RBR when it is empty may result in an error. Signed-off-by: Yi Pei <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/CAFPVDjQZ1gpf8-u--RBbAL1Y0FfDN2vZ3g=wBw+Bp-8ppuz3HA@mail.gmail.com Signed-off-by: Anup Patel <[email protected]>
2025-03-27lib: utils/serial: Add PXA UARTs supportJunhui Liu
The PXA variant of the uart8250 adds the UART Unit Enable bit (UUE) that needs to be set to enable the XScale PXA UART. And it is required for some RISC-V SoCs like the Spacemit K1 that implement the PXA UART. This introduces the "intel,xscale-uart" compatible to handle setting the UUE bit. Signed-off-by: Junhui Liu <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2023-10-06lib: utils/serial: Ensure proper allocation of PMP entries for uart8250Yu Chien Peter Lin
The added memory region should start from the base address. Otherwise, the range will be shifted by reg_offset and not able to merge consecutive NAPOT regions in the root domain, resulting in wasted PMP entries. Fixes: e8bc1621 ("lib: utils/serial: Add shared regions for serial drivers") Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-09-24lib: utils/serial: Add shared regions for serial driversMayuresh Chitale
The serial driver regions used by OpenSBI should be marked as a shared read-write regions between M-mode and SU-mode as those are accessed by earlycon and the corresponding tty serial drivers running in 'S' mode. When the smepmp extension is enabled, PMP entries for these shared regions will get programmed. Signed-off-by: Mayuresh Chitale <[email protected]> Signed-off-by: Anup Patel <[email protected]>
2022-07-30lib: utils/serial: Ensure baudrate is non-zero before usingAndrew Jones
RISC-V doesn't generate exceptions on divide-by-zero, but the result, all bits set, is not likely what people expect either. In all cases where we divide by baudrate there's a chance it's zero (when the DT it came from is "bad"). To avoid difficult to debug situations, leave baudrate dependent registers alone when baudrate is zero, as, also in all cases, it appears we can skip initialization of those registers and still [hopefully] have a functioning UART. Signed-off-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-04-17lib: utils/serial: support 'reg-offset' propertyZong Li
reg-offset property is used for offset to apply to the mapbase from the start of the registers in 8250 UART. In Linux kernel, it has been handled in 8250 UART driver. dt-bindings: <linux>/Documentation/devicetree/bindings/serial/8250.yaml Signed-off-by: Zong Li <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-02-04lib: utils/serial: Round UART8250 baud rate divisor to nearest integerJakub Luzny
Previously, it was rounded down and that gives suboptimal results when non-standard clock sources or baud rates are used. Signed-off-by: Jakub Luzny <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-01-21lib: fix pointer of type 'void *' used in arithmeticJukka Laitinen
Using "void *" in arithmetic causes errors with strict compiler settings: "error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]" Avoid these by calculating on "char *" where 1-byte data size is assumed. Signed-off-by: Jukka Laitinen <[email protected]> Reviewed-by: Dong Du <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2021-04-28lib: sbi: Simplify console platform operationsAnup Patel
Instead of having console_putc() and console_getc() callbacks in platform operations, it will be much simpler for console driver to directly register these operations as device to the sbi_console implementation. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Reviewed-by: Xiang W <[email protected]>
2020-05-01lib: utils/serial: Skip baudrate config if input frequency is zeroAnup Patel
We should skip baudrate config for UART8250 and SiFive UART when input frequency is zero. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Alistair Francis <[email protected]>
2020-03-10lib: serial: Fix coding style issuesBin Meng
This fixes various coding style issues found in the serial codes. No functional changes. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2019-06-19platform: Move platform common to lib/utils.Atish Patra
Currently, platform/common contains platform/non-platform specific common minimal drivers and libraries. This is helpful is all platforms are built within opensbi framework. Move them to lib/utils so that any external platform code also can reuse the minimalistic drivers or other common libraries. This patch doesn't introduce any functional changes. Signed-off-by: Atish Patra <[email protected]> Acked-by: Anup Patel <[email protected]>