Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 16550 compatible PCI serial cards #13393

Merged
merged 9 commits into from
Sep 14, 2024

Conversation

szafonimateusz-mi
Copy link
Contributor

@szafonimateusz-mi szafonimateusz-mi commented Sep 12, 2024

Summary

  • drivers: prepare 16550 UART driver to support PCI

    prepare 16550 UART driver to support PCI:

    • [breaking change] change argument of uart_ioctl() from struct file *filep to FAR struct u16550_s *priv
      Also fix moxart_16550.c build related to this change

    • [breaking change] change argument of uart_getreg() and uart_putreg() from uart_addrwidth_t base to FAR struct u16550_s *priv
      Also fix arch/x86/src/qemu/qemu_serial.c and arch/x86_64/src/intel64/intel64_serial.c related to this change

    • [breaking change] change argument of uart_dmachan() from uart_addrwidth_t base to FAR struct u16550_s *priv

    • move struct u16550_s to public header

    • generalize UART_XXX_OFFSET so we can use it with any register increment

    • make u16550_bind(), u16550_interrupt(), u16550_interrupt() public

    • remove arch/or1k/src/common/or1k_uart.c and use common 16550 MIMO interfacve

  • drivers: add UART 16550 compatible PCI device support
    add support for UART 16550 compatible PCI device

  • arch/intel64: add support for PCI serial

  • boards/x86_64/qemu-intel64: add configs with PCI serial console
    add configs with PCI serial console for qemu-intel64 so we can run NuttX on bare
    metal Intel HW with serial port card

  • drivers: fix gcc14 errors for PCI

[DONE] Depends on #13391

Impact

out of tree arch that use UART 16550 may need to update interfaces used according to these changes:

  • change argument of uart_ioctl() from struct file *filep to FAR struct u16550_s *priv
    look at moxart_16550.c modifed in this PR

  • change argument of uart_getreg() and uart_putreg from uart_addrwidth_t base to FAR struct u16550_s *priv
    look at arch/x86/src/qemu/qemu_serial.c and arch/x86_64/src/intel64/intel64_serial.c modifed in this PR

  • change argument of uart_dmachan() from uart_addrwidth_t base to FAR struct u16550_s *priv
    uart_dmachan() not used in upstream.

Testing

tested on intel HW with serial PCI card and tested on qemu with command:

qemu-system-x86_64 -m 2048M -cpu host -enable-kvm -kernel nuttx.elf -nographic -chardev pty,id=ch1 -device pci-serial,chardev=ch1 

@raiden00pl raiden00pl added Type: Enhancement New feature or request breaking change This change requires a mitigation entry in the release notes. labels Sep 12, 2024
@raiden00pl
Copy link
Contributor

@ldube FYI since it seems you are using a device with 16550 UART

@szafonimateusz-mi
Copy link
Contributor Author

tested on qemu and real HW, it's ready to review

drivers/pci/Kconfig Outdated Show resolved Hide resolved
drivers/pci/Kconfig Outdated Show resolved Hide resolved
xiaoxiang781216 and others added 2 commits September 13, 2024 16:41
so driver writer could save the private data here
and get it back in the probe function.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
initialize ret to avoid compiler warnings in pci_drivers.c

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
Some of PCI drivers require OS interfaces that can't be executed in the INIT context.
In that case we have to postpone PCI drivers probing and call it for example
in board initialization logic.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
move MCR_OUT2 configuration from qemu-intel64/src/qemu_boot.c to common code
also leave this option disabled for qemu-intel64 as it's not required

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
prepare 16550 UART driver to support PCI:

- [breaking change] change argument of uart_ioctl() from `struct file *filep` to `FAR struct u16550_s *priv`
  Also fix moxart_16550.c build related to this change

- [breaking change] change argument of uart_getreg() and uart_putreg from `uart_addrwidth_t base` to `FAR struct u16550_s *priv`
  Also fix arch/x86/src/qemu/qemu_serial.c and arch/x86_64/src/intel64/intel64_serial.c related to this change

- [breaking change] change argument of uart_dmachan() from `uart_addrwidth_t base` to `FAR struct u16550_s *priv`

- move `struct u16550_s` to public header

- generalize UART_XXX_OFFSET so we can use it with any register increment

- make u16550_bind(), u16550_interrupt(), u16550_interrupt() public

- remove arch/or1k/src/common/or1k_uart.c and use common 16550 MIMO interfacve

- change irq type in `struct u16550_s` from uint8_t to int to match MSI API

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
add support for UART 16550 compatible PCI device.
For now we support qemu serial PCI devices and AX99100 based cards.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
intel64 can work with PCI serial cards now

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
add configs with PCI serial console for qemu-intel64 so we can run NuttX on bare
metal Intel HW with serial port card

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
fix gcc14 errors for PCI

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit 51909ed into apache:master Sep 14, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This change requires a mitigation entry in the release notes. Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants