Commit Graph

426 Commits

Author SHA1 Message Date
p-szafonimateusz 8ab0785d71 drivers: add UART 16550 compatible PCI device support
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>
2024-09-15 03:37:58 +08:00
p-szafonimateusz ceb2921d79 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

- 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>
2024-09-15 03:37:58 +08:00
p-szafonimateusz c7e8fd43a4 drivers/uart_16550: configure MCR_OUT2 bit from Kconfig
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>
2024-09-15 03:37:58 +08:00
fangpeina 11f06eb0f5 drivers/serial: fix deadlock when executing rexec in a user task
CPU0                                                  CPU1
task:nsh_main     task:user_app                       rexecd
nsh_consolemain	  system
uart_read         rexec				      ---
got recv.lock     poll			              ---
	          uart_poll       rpmsg_socket_poll   rpmsg_socket_close
wait recvsem      get recv.lock   poll_notify
                  deadlock        routine work

the error accurs in CPU0 when waiting console input

resolve: unlock recv.lock when waiting recvsem

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2024-09-14 10:27:40 +08:00
zhanghu5 10e7d8fe44 set min read length in uart_ioctl
set min read length in uart_ioctl

Signed-off-by: zhanghu5 <zhanghu5@xiaomi.com>
2024-09-14 10:27:40 +08:00
chao an 7223a1d0d4 serial/uart_16550: remove up_putc spinlock
putc atomicity should be guaranteed by common code rather than add similar hack to lower half driver

Signed-off-by: chao an <anchao@lixiang.com>
2024-09-12 18:11:30 +08:00
chao an c19bdf204c serial/uart_pl011: default syslog needs to check flow control in up_putc
default syslog needs to check flow control in up_putc(), otherwise
up_puts() will lose character if the hardware fifo is full.
2024-09-12 17:15:40 +08:00
Petro Karashchenko 1528b8dcca nuttx: resolve various 'FAR' and 'CODE' issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-26 10:21:03 +08:00
yangsong8 6a38c37702 pty: use mutex to protect alloc minor
If failed in pty_register2, it is possible to enter unregister_driver
function, which eventually calls ptmx_minor_free, resulting in mutex
conflict.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2024-08-25 22:16:53 +08:00
Petro Karashchenko d499ac9d58 nuttx: fix multiple 'FAR', 'CODE' and style issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
Petro Karashchenko d252b6229f nuttx: use sizeof instead of define or number in snprintf
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
guohao15 458bab9ae7 fix:uart_rpmsg_dmareceive data copy to nbuffer should start from data + length
Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-08-22 09:23:12 -03:00
Lwazi Dube f3ddb3ffac drivers/serial: Make the 16550 rx trigger level configurable
To avoid breaking other configs, the default value 2 is equal to the original
hard coded value.
2024-08-03 10:31:36 +08:00
hujun5 a4fece3450 spin_lock: inline spin_lock
test:
We can use qemu for testing.
compiling
make distclean -j20; ./tools/configure.sh -l qemu-armv8a:nsh_smp ;make -j20
running
qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx
2024-07-15 02:29:30 +08:00
Huang Qi add8b71fee serial/gdbstub: Change GDBSTUB_ to GDB_
Fix nameing convention inconsistent

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-06-24 23:51:43 +08:00
TakuyaMiyasita d6445484fe drivers/serial/uart_pl011.c : add the bitmask according to PL011 spec. (Although almost no problem.) 2024-06-03 21:18:44 +08:00
TakuyaMiyasita c93383407b drivers/serial/uart_pl011.c : add the interface about clock and reset control for reducing power consumption. 2024-06-03 21:18:44 +08:00
TakuyaMiyasita 99dee09146 drivers/serial/uart_pl011.c : bug fix about the function : pl011_txready(). 2024-06-03 21:18:44 +08:00
hujun5 5cee996588 up_putc: int up_putc, enter_critical_section may be called
before kernel has been iniitialized,we use spin_lock_irqsave to replace.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-05-09 13:45:02 +08:00
chao an e4d4c67b78 serial/pl011: configurable clock frequency
move clock frequency into Kconfig

Signed-off-by: chao an <anchao@lixiang.com>
2024-04-30 17:26:39 +08:00
anjiahao 0040e9a239 drivers/serial:support arm cmsdk drivers
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-04-26 18:42:35 -03:00
dongjiuzhu1 9c55f21a6f drivers/cdcacm/serial: add release interface to release uart_dev resource
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-04-21 23:21:54 +08:00
chao an d11b1ba9cb drivers/serial/16550: remove unused function
drivers/serial/uart_16550.c:690:20: warning: unused function 'u16550_restoreuartint' [-Wunused-function]
static inline void u16550_restoreuartint(FAR struct u16550_s *priv,
                   ^

Signed-off-by: chao an <anchao@lixiang.com>
2024-04-19 20:13:16 +08:00
dongjiuzhu1 e0c18c05e8 fs/driver: using nx_unlink to call unlink ops to release some resource
if driver complete unlink ops, we need to call it to release some resource,
otherwise, it will only remove inode.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-03-14 11:53:30 +08:00
Bowen Wang 169f47beec rpmsg: make all the rpmsg services deponds on RPMSG
After decoupled the rpmsg and rptun, all the rpmsg service should
depends on the RPMSG.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-02-18 04:09:34 -08:00
chao an 5424ace1cf compiler/tasking: fix compiler warning on tasking
ctc W549: ["serial/serial.c" 877/37] condition is always true
ctc W549: ["inode/fs_inodesearch.c" 72/8] condition is always true
ctc W545: ["obstack/lib_obstack_malloc.c" 69/1] missing 'return'
ctc W545: ["obstack/lib_obstack_malloc.c" 82/1] missing 'return'

Signed-off-by: chao an <anchao@lixiang.com>
2024-01-31 05:02:56 -08:00
chao an 8ff97f6210 compiler/tasking: fix unreachable code on tasking toolchain
ctc W544: ["serial/serial.c" 284/3] unreachable code
ctc W544: ["vfs/fs_lseek.c" 96/13] unreachable code
ctc W544: ["wqueue/kwork_thread.c" 210/32] unreachable code
ctc W544: ["stdio/lib_fopen.c" 327/19] unreachable code
ctc W544: ["stdio/lib_fopen.c" 404/13] unreachable code
ctc W544: ["string/lib_strcasestr.c" 120/3] unreachable code
ctc W544: ["unistd/lib_getopt_common.c" 156/21] unreachable code
ctc W544: ["unistd/lib_getopt_common.c" 216/21] unreachable code
ctc W544: ["wctype/lib_iswctype.c" 155/3] unreachable code

Signed-off-by: chao an <anchao@lixiang.com>
2024-01-30 20:53:00 -08:00
chao an c04f1e7789 drivers/serial/pl011: add FAR specifier
Signed-off-by: chao an <anchao@lixiang.com>
2024-01-11 13:39:06 +01:00
chao an 1dd9f64287 drivers/serial/pl011: add support of uart0/2/3 port
Signed-off-by: chao an <anchao@lixiang.com>
2024-01-11 13:39:06 +01:00
chao an 5f51aba1be serial/pl011: rename serial_pl011 to uart_pl011
The lower half driver should be prefixed with "uart_"

Signed-off-by: chao an <anchao@lixiang.com>
2024-01-11 13:39:06 +01:00
anjiahao bf03bb557f support gdbstub use serial.
we can use uart to debug nuttx,like debugger:

1. read/write memory
2. Use watchpoint,breakpoint,single step.
    use up_debugpoint api

3. Ctrl+c to stop, continue, or single step.
    hold uart send and receive

4. register a panic event, when crash or assert/panic, we use uart to
   debug.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 08:43:26 -08:00
Xiang Xiao eddd90de78 poll: pollsetup should notify only one fd passd by caller
since it's redundant to iterate the whole fds array in setup

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-21 09:07:17 +01:00
Ville Juven b3f20d4bd6 uart_tcsendbreak: Remove cancel point, as tcsendbreak is not one
Reference:
https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html
2023-11-13 08:11:24 -08:00
chao an 85a375cd7d drivers/serial: check the remote device before get name
| #0 0x2119bf1 in rpmsg_get_cpuname rptun/rptun.c:1157
| #1 0x24f97bd in uart_rpmsg_device_destroy serial/uart_rpmsg.c:342
| #2 0x2117d56 in rptun_dev_stop rptun/rptun.c:883
| #3 0x21181d7 in rptun_do_ioctl rptun/rptun.c:922
| #4 0x2119721 in rptun_ioctl_foreach rptun/rptun.c:1086

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-07 18:27:05 +08:00
raiden00pl b565e28da3 Kconfigs: rename {Rpmsg|rpmsg} to RPMGS 2023-10-28 13:58:56 +08:00
hujun5 061be5f18e refine: move BIT Macro to nuttx/bits.h
The BIT macro is widely used in NuttX,
and to achieve a unified strategy,
we have placed the implementation of the BIT macro
in bits.h to simplify code implementation.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-10-12 14:52:56 +08:00
raiden00pl 0e01836f09 serial: add an option that selects uart rpmsg as console 2023-09-22 19:46:26 +08:00
wanggang26 e930476b4b enable O_CLOEXEC explicit
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-09-22 13:51:00 +08:00
yinshengkai 1d8e69700f drivers/serial: add ram uart driver
It uses the memory block as the serial communication medium, which can communicate between different processes or different CPUs

Using the following configuration, the cross-core communication rate of 200MHz cortex-M55 is about 461KB/s
RAM_UART_BUFSIZE=1024
RAM_UART_POLLING_INTERVAL=100

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-09-19 09:41:07 +08:00
yinshengkai 1d9097f1df drivers/serial: unmodify head and tail pointers
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-09-19 09:41:07 +08:00
chao an 664927c86e mm/alloc: remove all unnecessary cast for alloc
Fix the minor style issue and remove unnecessary cast

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-30 14:34:20 +08:00
dongjiuzhu1 c983aee38a driver/serial: fix race condition about calling rxflowcontrol in mutli thread
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-08-30 14:33:00 +08:00
dongjiuzhu1 ec4f6ecce2 driver/serial: fix error echo about VT100 escape sequence
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-08-30 14:26:11 +08:00
chao an 7aa45305b7 fs/inode: remove all unnecessary check for filep/inode
Since VFS layer already contains sanity checks, so remove unnecessary lower half checks

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 09:47:11 +08:00
chengkai d867c46bbc serial/uart/h5: add bt h5 uart serial driver
Signed-off-by: chengkai <chengkai@xiaomi.com>
2023-08-25 17:17:37 +08:00
xuwenjie 4af8927829 drivers/pty: Support get and set local mode of pty
Signed-off-by: xuwenjie <xuwenjie1@xiaomi.com>
2023-08-18 14:30:22 +08:00
xuxin19 f2f0d7fbad cmake:fix drivers build block during cmake reforming
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-08-16 22:38:52 +08:00
zhanghu5 305c213d15 filter out control character in pty echo
Signed-off-by: zhanghu5 <zhanghu5@xiaomi.com>
2023-08-11 13:58:54 +08:00
Lee Lup Yuen b2c1930825 serial/uart_16550: Wait before setting Line Control Register (Synopsys DesignWare 8250)
Some UART Controllers (Synopsys DesignWare 8250) will trigger spurious interrupts when the Line Control Register (LCR) is set while the UART is busy. This patch provides the option (16550_WAIT_LCR) to wait for UART until it's not busy, before setting the LCR. (16550_WAIT_LCR is disabled by default)

This patch fixes the spurious UART interrupts for the upcoming port of NuttX to StarFive JH7110 SoC (with Synopsys DesignWare 8250 UART). [The patch is explained here](https://lupyuen.github.io/articles/plic#appendix-fix-the-spurious-uart-interrupts)

drivers/serial/uart_16550.c: If 16550_WAIT_LCR is enabled, wait until UART is not busy before setting LCR

include/nuttx/serial/uart_16550.h: Define the UART Status Register (USR) for checking if UART is busy

drivers/serial/Kconfig-16550: Added option 16550_WAIT_LCR to 16550 UART Config, disabled by default
2023-08-03 08:38:07 +02:00
Xiang Xiao 82e76961cd serial: Simplify the echo process
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-08-01 15:59:28 -03:00