BCM2708: Add support for AUX interrupts.
This commit is contained in:
parent
d160ae8a32
commit
477a8d1aa7
@ -22,7 +22,13 @@ config BCM2708_MINI_UART
|
||||
bool "Mini-UART"
|
||||
|
||||
config BCM2708_PL011_UART
|
||||
bool "PL011UART"
|
||||
bool "PL011 UART"
|
||||
|
||||
config BCM2708_SPI1
|
||||
bool "SPI1"
|
||||
|
||||
config BCM2708_SPI2
|
||||
bool "SPI2"
|
||||
|
||||
endmenu # BCM2708 Peripheral Selections
|
||||
|
||||
|
@ -72,7 +72,7 @@ endif
|
||||
# BCM2708-specific source files.
|
||||
|
||||
CHIP_CSRCS = bcm_boot.c bcm_memorymap.c bcm_clockconfig.c bcm_irq.c
|
||||
CHIP_CSRCS += bcm_tickless.c bcm_gpio.c bcm_lowputc.c
|
||||
CHIP_CSRCS += bcm_tickless.c bcm_gpio.c bcm_aux.c bcm_lowputc.c
|
||||
|
||||
ifeq ($(CONFIG_BCM2708_GPIO_IRQ),y)
|
||||
CHIP_CSRCS += bcm_gpioint.c
|
||||
|
220
arch/arm/src/bcm2708/bcm_aux.c
Normal file
220
arch/arm/src/bcm2708/bcm_aux.c
Normal file
@ -0,0 +1,220 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/bcm2708/bcm_aux.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "bcm_config.h"
|
||||
#include "chip/bcm2708_aux.h"
|
||||
#include "bcm_aux.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bcm_aux_interrupt
|
||||
*
|
||||
* Description:
|
||||
* AUX interrupt handler
|
||||
*
|
||||
* Input Parameters:
|
||||
* Standard interrupt input parameters
|
||||
*
|
||||
* Returned Value:
|
||||
* Always returns OK
|
||||
*
|
||||
* Assumptions:
|
||||
* Interrupts ar disabled
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int bcm_aux_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
uint32_t auxirq;
|
||||
|
||||
/* Read the pending AUX interrupts */
|
||||
|
||||
auxirq = getreg32(BCM_AUX_IRQ);
|
||||
|
||||
#ifdef CONFIG_BCM2708_MINI_UART
|
||||
if ((auxirq & BCM_AUX_IRQ_MU) != 0)
|
||||
{
|
||||
(void)bcm_mu_interrupt(irq, context, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BCM2708_SPI1
|
||||
if ((auxirq & BCM_AUX_IRQ_SPI1) != 0)
|
||||
{
|
||||
(void)bcm_spi1_interrupt(irq, context, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BCM2708_SPI2
|
||||
if ((auxirq & BCM_AUX_IRQ_SPI2) != 0)
|
||||
{
|
||||
(void)bcm_spi2_interrupt(irq, context, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bcm_aux_irqinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called during IRQ initialize to initialize the shard AUX interrupt
|
||||
* logic.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void bcm_aux_irqinitialize(void)
|
||||
{
|
||||
/* Disable all AUX interrupt sources (Also disables all peripheral
|
||||
* register accesses).
|
||||
*/
|
||||
|
||||
putreg32(0, BCM_AUX_ENB);
|
||||
|
||||
/* Attach and enable the AUX interrupt */
|
||||
|
||||
(void)irq_attach(BCM_IRQ_AUX, bcm_aux_interrupt, NULL);
|
||||
up_enable_irq(BCM_IRQ_AUX);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bcm_aux_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable the specified AUX interrupt (also enables access to peripheral
|
||||
* registers).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void bcm_aux_enable(enum bcm_aux_peripheral_e periph, FAR void *arg)
|
||||
{
|
||||
uint32_t setbits;
|
||||
|
||||
/* Read the AUX perpheral enable */
|
||||
|
||||
#ifdef CONFIG_BCM2708_MINI_UART
|
||||
if (periph == BCM_AUX_MINI_UART)
|
||||
{
|
||||
setbits = BCM_AUX_ENB_MU;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BCM2708_SPI1
|
||||
if (periph == BCM_AUX_MINI_UART)
|
||||
{
|
||||
setbits = BCM_AUX_ENB_SPI1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BCM2708_SPI2
|
||||
if (periph == BCM_AUX_MINI_UART)
|
||||
{
|
||||
setbits = BCM_AUX_ENB_SPI1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
modifyreg32(BCM_AUX_ENB, 0, setbits);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bcm_aux_disable
|
||||
*
|
||||
* Description:
|
||||
* Disable the specified AUX interrupt (also disables access to peripheral
|
||||
* registers).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void bcm_aux_disable(enum bcm_aux_peripheral_e periph)
|
||||
{
|
||||
uint32_t clrbits;
|
||||
|
||||
/* Read the AUX perpheral enable */
|
||||
|
||||
#ifdef CONFIG_BCM2708_MINI_UART
|
||||
if (periph == BCM_AUX_MINI_UART)
|
||||
{
|
||||
clrbits = BCM_AUX_ENB_MU;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BCM2708_SPI1
|
||||
if (periph == BCM_AUX_MINI_UART)
|
||||
{
|
||||
clrbits = BCM_AUX_ENB_SPI1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BCM2708_SPI2
|
||||
if (periph == BCM_AUX_MINI_UART)
|
||||
{
|
||||
clrbits = BCM_AUX_ENB_SPI1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
modifyreg32(BCM_AUX_ENB, clrbits, 0);
|
||||
}
|
114
arch/arm/src/bcm2708/bcm_aux.h
Normal file
114
arch/arm/src/bcm2708/bcm_aux.h
Normal file
@ -0,0 +1,114 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/bcm2708/bcm_aux.h
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_BCM2708_BCM_AUX_H
|
||||
#define __ARCH_ARM_SRC_BCM2708_BCM_AUX_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
enum bcm_aux_peripheral_e
|
||||
{
|
||||
BCM_AUX_MINI_UART = 0, /* Mini UART peripheral */
|
||||
BCM_AUX_MINI_SPI1, /* SPI1 peripheral */
|
||||
BCM_AUX_MINI_SPI2, /* SPI2 peripheral */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bcm_aux_irqinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called during IRQ initialize to initialize the shard AUX interrupt
|
||||
* logic.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void bcm_aux_irqinitialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bcm_aux_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable the specified AUX interrupt (also enables access to peripheral
|
||||
* registers).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void bcm_aux_enable(enum bcm_aux_peripheral_e periph, FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bcm_aux_disable
|
||||
*
|
||||
* Description:
|
||||
* Disable the specified AUX interrupt (also disables access to peripheral
|
||||
* registers).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void bcm_aux_disable(enum bcm_aux_peripheral_e periph);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bcm_[mu|spi1|spi2]_interupt
|
||||
*
|
||||
* Description:
|
||||
* These callbacks must be provided by Mini-UART, SPI1, and SPI2 logic
|
||||
* when those peripherals are configured. These callbacks will be invoked
|
||||
* from interrupt level processing when an interrupt for one of those
|
||||
* peripherals is received (with interrupts disabled)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BCM2708_MINI_UART
|
||||
int bcm_mu_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||
#endif
|
||||
#ifdef CONFIG_BCM2708_SPI1
|
||||
int bcm_spi1_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||
#endif
|
||||
#ifdef CONFIG_BCM2708_SPI2
|
||||
int bcm_spi2_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_BCM2708_BCM_AUX_H */
|
@ -52,6 +52,7 @@
|
||||
#include "up_internal.h"
|
||||
#include "group/group.h"
|
||||
|
||||
#include "bcm_aux.h"
|
||||
#include "bcm_gpio.h"
|
||||
#include "chip/bcm2708_irq.h"
|
||||
|
||||
@ -93,6 +94,10 @@ void up_irqinitialize(void)
|
||||
|
||||
CURRENT_REGS = NULL;
|
||||
|
||||
/* Intitialize AUX interrupts */
|
||||
|
||||
bcm_aux_irqinitialize();
|
||||
|
||||
#ifdef CONFIG_BCM2708_GPIO_IRQ
|
||||
/* Initialize GPIO interrrupts */
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
#include "up_arch.h"
|
||||
|
||||
#include "chip/bcm2708_uart_spi.h"
|
||||
#include "chip/bcm2708_aux.h"
|
||||
#include "bcm_config.h"
|
||||
#include "bcm_lowputc.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/************************************************************************************
|
||||
* arch/arm/src/bcm2708/chip/bcm2708_uart.h
|
||||
* arch/arm/src/bcm2708/chip/bcm2708_aux.h
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
@ -33,8 +33,8 @@
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_BCM_CHIP_BCM_UART_H
|
||||
#define __ARCH_ARM_SRC_BCM_CHIP_BCM_UART_H
|
||||
#ifndef __ARCH_ARM_SRC_BCM_CHIP_BCM_AUX_H
|
||||
#define __ARCH_ARM_SRC_BCM_CHIP_BCM_AUX_H
|
||||
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
@ -208,4 +208,4 @@
|
||||
#define BCM_AUX_SPI_STAT_TXLEVEL_SHIFT 24 /* Data units in the FX FIFO */
|
||||
#define BCM_AUX_SPI_STAT_TXLEVEL_MASK (0xff << BCM_AUX_SPI_STAT_TXLEVEL_SHIFT)
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_BCM_CHIP_BCM_UART_H */
|
||||
#endif /* __ARCH_ARM_SRC_BCM_CHIP_BCM_AUX_H */
|
Loading…
Reference in New Issue
Block a user