From 1bb74504a8f1c605019e76ae1806297c14c05d49 Mon Sep 17 00:00:00 2001 From: "Anton D. Kachalov" Date: Mon, 3 Aug 2015 15:32:51 +0300 Subject: [PATCH] Add support for custom platform IOCTL on UART Signed-off-by: Anton D. Kachalov --- drivers/serial/Kconfig | 4 ++++ drivers/serial/uart_16550.c | 10 +++++++++- include/nuttx/serial/uart_16550.h | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index b2b3b20a55..6e7d7865e5 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -318,6 +318,10 @@ config 16550_SUPRESS_CONFIG that configures the 16550_UART. In that case, you may want to just leave the existing console configuration in place. Default: n +config SERIAL_UART_ARCH_IOCTL + bool "Platform has own custom IOCTL" + default n + config 16550_REGINCR int "Address increment between 16550 registers" default 1 diff --git a/drivers/serial/uart_16550.c b/drivers/serial/uart_16550.c index 5b7401c7a2..ffa7f7a4c9 100644 --- a/drivers/serial/uart_16550.c +++ b/drivers/serial/uart_16550.c @@ -864,7 +864,15 @@ static int u16550_ioctl(struct file *filep, int cmd, unsigned long arg) struct inode *inode = filep->f_inode; struct uart_dev_s *dev = inode->i_private; struct u16550_s *priv = (struct u16550_s*)dev->priv; - int ret = OK; + +#ifdef CONFIG_SERIAL_UART_ARCH_IOCTL + int ret = uart_ioctl(filep, cmd, arg); + + if (ret != -ENOTTY) + { + return ret; + } +#endif switch (cmd) { diff --git a/include/nuttx/serial/uart_16550.h b/include/nuttx/serial/uart_16550.h index de37fb5502..9a35d99286 100644 --- a/include/nuttx/serial/uart_16550.h +++ b/include/nuttx/serial/uart_16550.h @@ -336,16 +336,18 @@ typedef uint32_t uart_addrwidth_t; ************************************************************************************/ /************************************************************************************ - * Name: uart_getreg(), uart_putreg() + * Name: uart_getreg(), uart_putreg(), uart_ioctl() * * Description: * These functions must be provided by the processor-specific code in order to * correctly access 16550 registers + * uart_ioctl() is optional to provide custom IOCTLs * ************************************************************************************/ uart_datawidth_t uart_getreg(uart_addrwidth_t base, unsigned int offset); void uart_putreg(uart_addrwidth_t base, unsigned int offset, uart_datawidth_t value); +int uart_ioctl(struct file *filep, int cmd, unsigned long arg); #endif /* CONFIG_16550_UART */ #endif /* __INCLUDE_NUTTX_SERIAL_UART_16550_H */