arch/arm/src/imxrt: ADD GPIO Support Input daisy selection

This commit is contained in:
David Sidrane 2019-01-16 18:03:10 -06:00 committed by Gregory Nutt
parent 042f057463
commit d6fa328d27
8 changed files with 15680 additions and 11 deletions

View File

@ -93,7 +93,8 @@ endif
CHIP_ASRCS =
CHIP_CSRCS = imxrt_allocateheap.c imxrt_start.c imxrt_clockconfig.c
CHIP_CSRCS += imxrt_periphclks.c imxrt_irq.c imxrt_clrpend.c imxrt_gpio.c
CHIP_CSRCS += imxrt_wdog.c imxrt_iomuxc.c imxrt_serial.c imxrt_lowputc.c
CHIP_CSRCS += imxrt_daisy.c imxrt_wdog.c imxrt_iomuxc.c imxrt_serial.c
CHIP_CSRCS += imxrt_lowputc.c
# Configuration-dependent i.MX RT files

View File

@ -623,6 +623,9 @@
/* Select Input Daisy Register Offsets */
#define IMXRT_INPUT_INDEX2OFFSET(n) (0x03f4 + ((unsigned int)(n) << 2))
#define IMXRT_INPUT_OFFSET2INDEX(o) (((unsigned int)(o) - 0x03f4) >> 2)
#define IMXRT_INPUT_ANATOP_USB_OTG1_ID_OFFSET 0x03f4
#define IMXRT_INPUT_ANATOP_USB_OTG2_ID_OFFSET 0x03f8
#define IMXRT_INPUT_CCM_PMIC_READY_OFFSET 0x03fc

View File

@ -732,6 +732,9 @@
/* Select Input Daisy Register Offsets */
#define IMXRT_INPUT_INDEX2OFFSET(n) (0x03f4 + ((unsigned int)(n) << 2))
#define IMXRT_INPUT_OFFSET2INDEX(o) (((unsigned int)(o) - 0x03f4) >> 2)
#define IMXRT_INPUT_ANATOP_USB_OTG1_ID_OFFSET 0x03f4
#define IMXRT_INPUT_ANATOP_USB_OTG2_ID_OFFSET 0x03f8
#define IMXRT_INPUT_CCM_PMIC_READY_OFFSET 0x03fc

View File

@ -0,0 +1,62 @@
/************************************************************************************
* arch/arm/src/imxrt/chip/imxrt_daisy.h
*
* Copyright (C) 2018-2019 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* David Sidrane <david_s5@nscdg.com>
*
* 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_IMXRT_CHIP_IMXRT_DAISY_H
#define __ARCH_ARM_SRC_IMXRT_CHIP_IMXRT_DAISY_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: imxrt_daisy_select
*
* Description:
* Initialize logic to support a daisy chain input selection for GPIO pins.
*
************************************************************************************/
void imxrt_daisy_select(unsigned int index, unsigned int alt);
#endif /* __ARCH_ARM_SRC_IMXRT_CHIP_IMXRT_DAISY_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,111 @@
/****************************************************************************
* arch/arm/src/imxrt/imxrt_daisy.c
*
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: David Sidrane <david_s5@nscdg.com>
*
* 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 <stdint.h>
#include "chip.h"
#include "up_arch.h"
#include "chip/imxrt_daisy.h"
#include "imxrt_iomuxc.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define DAISY_INDEX_INVALID 255
#define DAISY_SEL_INVALID 255
#define ALT0 0
#define ALT1 1
#define ALT2 2
#define ALT3 3
#define ALT4 4
#define ALT5 5
#define ALT6 6
#define ALT7 7
#define ALT8 8
#define ALT9 9
/****************************************************************************
* Private Data
****************************************************************************/
struct imxrt_daisy_entry_t
{
uint8_t index;
uint8_t sel;
};
struct imxrt_daisy_t
{
struct imxrt_daisy_entry_t alts[10];
};
/* Include chip-specific daisy input selection */
#if defined(CONFIG_ARCH_FAMILY_IMXRT105x)
# include "imxrt105x_daisy.c"
#elif defined(CONFIG_ARCH_FAMILY_IMXRT106x)
# include "imxrt106x_daisy.c"
#else
# error Unrecognized i.MX RT architecture
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: imxrt_daisy_select
****************************************************************************/
void imxrt_daisy_select(unsigned int index, unsigned int alt)
{
uintptr_t address;
const struct imxrt_daisy_t *daisy = &g_daisy_select[index];
index = daisy->alts[alt].index;
if (index != DAISY_INDEX_INVALID)
{
alt = daisy->alts[alt].sel;
address = IMXRT_IOMUXC_BASE + IMXRT_INPUT_INDEX2OFFSET(index);
putreg32(alt, address);
}
}

View File

@ -50,6 +50,7 @@
#include "up_arch.h"
#include "imxrt_iomuxc.h"
#include "imxrt_gpio.h"
#include "chip/imxrt_daisy.h"
/****************************************************************************
* Pre-processor Definitions
@ -534,25 +535,25 @@ static inline int imxrt_gpio_configperiph(gpio_pinset_t pinset)
iomux_pinset_t ioset;
uintptr_t regaddr;
uint32_t regval;
uint32_t value;
uint32_t alt;
unsigned int index;
/* Configure pin as a peripheral */
/* Configure pin as a peripheral via SW MUX Control Register */
index = ((pinset & GPIO_PADMUX_MASK) >> GPIO_PADMUX_SHIFT);
regaddr = imxrt_padmux_address(index);
value = ((pinset & GPIO_ALT_MASK) >> GPIO_ALT_SHIFT);
#if GPIO_SION_SHIFT >= PADMUX_SION_SHIFT
value |= ((pinset & GPIO_SION_MASK) >> (GPIO_SION_SHIFT - PADMUX_SION_SHIFT));
#else
value |= ((pinset & GPIO_SION_MASK) << (PADMUX_SION_SHIFT - GPIO_SION_SHIFT));
#endif
regval = (value << PADMUX_MUXMODE_SHIFT);
alt = (pinset & GPIO_ALT_MASK) >> GPIO_ALT_SHIFT;
regval = alt << PADMUX_MUXMODE_SHIFT;
regval |= (pinset & GPIO_SION_MASK) ? PADMUX_SION : 0;
putreg32(regval, regaddr);
/* Configure pin pad settings */
/* Configure pin Daisy Select Input Daisy Register */
imxrt_daisy_select(index, alt);
/* Configure pin pad settings SW PAD Control Register*/
index = imxrt_padmux_map(index);
if (index >= IMXRT_PADCTL_NREGISTERS)