From e18e8573d1ca4acf3139e05061353494735143b2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 18 Oct 2017 13:57:54 -0600 Subject: [PATCH] BCM2708: Allow pass parameters with AUX interrupts; Add mini-UART break capability. --- arch/arm/src/bcm2708/Kconfig | 6 +++++ arch/arm/src/bcm2708/bcm_aux.c | 14 +++++++--- arch/arm/src/bcm2708/bcm_miniuart.c | 40 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/bcm2708/Kconfig b/arch/arm/src/bcm2708/Kconfig index 02bc61e46d6..51692074c11 100644 --- a/arch/arm/src/bcm2708/Kconfig +++ b/arch/arm/src/bcm2708/Kconfig @@ -91,6 +91,12 @@ config BCM2708_MINI_UART_OFLOWCONTROL ---help--- Enable BCM2708_MINI_UART CTS flow control +config BCM2708_MINI_UART_BREAKS + bool "Break support" + default n + ---help--- + Support BSD style BREAK IOCTL commands + endmenu # BCM2708 Mini-UART Configuration menu "BCM2708 PL011 UART Configuration" diff --git a/arch/arm/src/bcm2708/bcm_aux.c b/arch/arm/src/bcm2708/bcm_aux.c index b378da16741..f44b93b21eb 100644 --- a/arch/arm/src/bcm2708/bcm_aux.c +++ b/arch/arm/src/bcm2708/bcm_aux.c @@ -49,6 +49,12 @@ #include "chip/bcm2708_aux.h" #include "bcm_aux.h" +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static FAR void *g_aux_arg[3]; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -81,21 +87,21 @@ static int bcm_aux_interrupt(int irq, FAR void *context, FAR void *arg) #ifdef CONFIG_BCM2708_MINI_UART if ((auxirq & BCM_AUX_IRQ_MU) != 0) { - (void)bcm_mu_interrupt(irq, context, arg); + (void)bcm_mu_interrupt(irq, context, g_aux_arg[(int)BCM_AUX_MINI_UART]); } #endif #ifdef CONFIG_BCM2708_SPI1 if ((auxirq & BCM_AUX_IRQ_SPI1) != 0) { - (void)bcm_spi1_interrupt(irq, context, arg); + (void)bcm_spi1_interrupt(irq, context, g_aux_arg[(int)BCM_AUX_MINI_SPI1]); } #endif #ifdef CONFIG_BCM2708_SPI2 if ((auxirq & BCM_AUX_IRQ_SPI2) != 0) { - (void)bcm_spi2_interrupt(irq, context, arg); + (void)bcm_spi2_interrupt(irq, context, g_aux_arg[(int)BCM_AUX_MINI_SPI2]); } #endif @@ -178,6 +184,7 @@ void bcm_aux_enable(enum bcm_aux_peripheral_e periph, FAR void *arg) return; } + g_aux_arg[(int)periph] = arg; modifyreg32(BCM_AUX_ENB, 0, setbits); } @@ -223,5 +230,6 @@ void bcm_aux_disable(enum bcm_aux_peripheral_e periph) return; } + g_aux_arg[(int)periph] = NULL; modifyreg32(BCM_AUX_ENB, clrbits, 0); } diff --git a/arch/arm/src/bcm2708/bcm_miniuart.c b/arch/arm/src/bcm2708/bcm_miniuart.c index d91400d17b3..a88a22a7a8f 100644 --- a/arch/arm/src/bcm2708/bcm_miniuart.c +++ b/arch/arm/src/bcm2708/bcm_miniuart.c @@ -511,6 +511,46 @@ static int bcm_ioctl(struct file *filep, int cmd, unsigned long arg) break; #endif /* CONFIG_SERIAL_TERMIOS */ +#ifdef CONFIG_BCM2708_MINI_UART_BREAKS + case TIOCSBRK: + { + irqstate_t flags; + uint8_t lcr; + + /* Send a break signal */ + + flags = enter_critical_section(); + lcr = getreg8(BCM_AUX_MU_LCR); + lcr |= BCM_AUX_MU_LCR_BREAK; + putreg8(lcd, BCM_AUX_MU_LCR); + + /* Disable TX activity */ + + bcm_txint(dev, false); + leave_critical_section(flags); + } + break; + + case TIOCCBRK: + { + irqstate_t flags; + uint8_t lcr; + + /* Configure TX back to UART */ + + flags = enter_critical_section(); + lcr = getreg8(BCM_AUX_MU_LCR); + lcr &= ~BCM_AUX_MU_LCR_BREAK; + putreg8(lcd, BCM_AUX_MU_LCR); + + /* Enable further TX activity */ + + bcm_txint(dev, true); + leave_critical_section(flags); + } + break; +#endif /* CONFIG_BCM2708_MINI_UART_BREAKS */ + default: ret = -ENOTTY; break;