From 8e18e8ae54f7faeb4712b615dea59f4a89bdedf2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 17 Nov 2018 15:36:40 -0600 Subject: [PATCH] arch/arm/src/max326xx: Get's past a few initial compile problems. Still a long road ahead. --- arch/arm/include/max326xx/irq.h | 11 +- arch/arm/src/max326xx/Make.defs | 14 +++ .../max326xx/{ => common}/max326_clrpend.c | 0 .../src/max326xx/{ => common}/max326_idle.c | 0 .../src/max326xx/{ => common}/max326_irq.c | 2 +- .../max326xx/{ => common}/max326_mpuinit.c | 2 +- .../src/max326xx/{ => common}/max326_start.c | 19 +-- .../max326xx/{ => common}/max326_timerisr.c | 2 +- .../max326xx/{ => common}/max326_userspace.c | 2 +- .../max326xx/{ => max32660}/max32660_gpio.h | 8 +- arch/arm/src/max326xx/max326_config.h | 12 +- arch/arm/src/max326xx/max326_gpio.h | 6 +- arch/arm/src/max326xx/max326_lowputc.h | 118 ++++++++++++++++++ arch/arm/src/max326xx/max326_serial.h | 66 ++++++++++ 14 files changed, 225 insertions(+), 37 deletions(-) rename arch/arm/src/max326xx/{ => common}/max326_clrpend.c (100%) rename arch/arm/src/max326xx/{ => common}/max326_idle.c (100%) rename arch/arm/src/max326xx/{ => common}/max326_irq.c (99%) rename arch/arm/src/max326xx/{ => common}/max326_mpuinit.c (98%) rename arch/arm/src/max326xx/{ => common}/max326_start.c (91%) rename arch/arm/src/max326xx/{ => common}/max326_timerisr.c (99%) rename arch/arm/src/max326xx/{ => common}/max326_userspace.c (98%) rename arch/arm/src/max326xx/{ => max32660}/max32660_gpio.h (97%) create mode 100644 arch/arm/src/max326xx/max326_lowputc.h create mode 100644 arch/arm/src/max326xx/max326_serial.h diff --git a/arch/arm/include/max326xx/irq.h b/arch/arm/include/max326xx/irq.h index 8dcb380516b..a3b4d654461 100644 --- a/arch/arm/include/max326xx/irq.h +++ b/arch/arm/include/max326xx/irq.h @@ -58,9 +58,10 @@ /* Common Processor Exceptions (vectors 0-15) */ -#define MAX326_IRQ_RESERVED (0) /* Reserved vector (only used with CONFIG_DEBUG_FEATURES) */ - /* Vector 0: Reset stack pointer value */ - /* Vector 1: Reset (not handler as an IRQ) */ +#define MAX326_IRQ_RESERVED (0) /* Reserved vector (only used with + * CONFIG_DEBUG_FEATURES) */ + /* Vector 0: Reset stack pointer value */ + /* Vector 1: Reset (not handler as an IRQ) */ #define MAX326_IRQ_NMI (2) /* Vector 2: Non-Maskable Interrupt (NMI) */ #define MAX326_IRQ_HARDFAULT (3) /* Vector 3: Hard fault */ #define MAX326_IRQ_MEMFAULT (4) /* Vector 4: Memory management (MPU) */ @@ -68,7 +69,7 @@ #define MAX326_IRQ_USAGEFAULT (6) /* Vector 6: Usage fault */ #define MAX326_IRQ_SVCALL (11) /* Vector 11: SVC call */ #define MAX326_IRQ_DBGMONITOR (12) /* Vector 12: Debug Monitor */ - /* Vector 13: Reserved */ + /* Vector 13: Reserved */ #define MAX326_IRQ_PENDSV (14) /* Vector 14: Pendable system service request */ #define MAX326_IRQ_SYSTICK (15) /* Vector 15: System tick */ @@ -78,7 +79,7 @@ #if defined(CONFIG_ARCH_FAMILY_MAX32620) || defined(CONFIG_ARCH_FAMILY_MAX32630) # include -#if defined(CONFIG_ARCH_FAMILY_MAX32660) +#elif defined(CONFIG_ARCH_FAMILY_MAX32660) # include #else # error "Unsupported MAX326XX family" diff --git a/arch/arm/src/max326xx/Make.defs b/arch/arm/src/max326xx/Make.defs index 81bc93fce04..9c9bed602c4 100644 --- a/arch/arm/src/max326xx/Make.defs +++ b/arch/arm/src/max326xx/Make.defs @@ -153,3 +153,17 @@ endif ifeq ($(CONFIG_MAX326XX_HAVE_SPIM),y) CHIP_CSRCS += max326_spim.c endif + +# Paths to source files + +VPATH += chip/common + +ifeq ($(CONFIG_ARCH_FAMILY_MAX32620),y) +VPATH += chip/max32620_30 +else ifeq ($(CONFIG_ARCH_FAMILY_MAX32630),y) +VPATH += chip/max32620_30 +endif +ifeq ($(CONFIG_ARCH_FAMILY_MAX32660),y) +VPATH += chip/max32660 +endif + diff --git a/arch/arm/src/max326xx/max326_clrpend.c b/arch/arm/src/max326xx/common/max326_clrpend.c similarity index 100% rename from arch/arm/src/max326xx/max326_clrpend.c rename to arch/arm/src/max326xx/common/max326_clrpend.c diff --git a/arch/arm/src/max326xx/max326_idle.c b/arch/arm/src/max326xx/common/max326_idle.c similarity index 100% rename from arch/arm/src/max326xx/max326_idle.c rename to arch/arm/src/max326xx/common/max326_idle.c diff --git a/arch/arm/src/max326xx/max326_irq.c b/arch/arm/src/max326xx/common/max326_irq.c similarity index 99% rename from arch/arm/src/max326xx/max326_irq.c rename to arch/arm/src/max326xx/common/max326_irq.c index e7d8807ea2b..c9a048811a3 100644 --- a/arch/arm/src/max326xx/max326_irq.c +++ b/arch/arm/src/max326xx/common/max326_irq.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/max326xx/max326_irq.c + * arch/arm/src/max326xx/common/max326_irq.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/arch/arm/src/max326xx/max326_mpuinit.c b/arch/arm/src/max326xx/common/max326_mpuinit.c similarity index 98% rename from arch/arm/src/max326xx/max326_mpuinit.c rename to arch/arm/src/max326xx/common/max326_mpuinit.c index a66177b2039..81f64744602 100644 --- a/arch/arm/src/max326xx/max326_mpuinit.c +++ b/arch/arm/src/max326xx/common/max326_mpuinit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/max326xx/max326_mpuinit.c + * arch/arm/src/max326xx/common/max326_mpuinit.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/arch/arm/src/max326xx/max326_start.c b/arch/arm/src/max326xx/common/max326_start.c similarity index 91% rename from arch/arm/src/max326xx/max326_start.c rename to arch/arm/src/max326xx/common/max326_start.c index 83e1ea5ea64..9418952bb96 100644 --- a/arch/arm/src/max326xx/max326_start.c +++ b/arch/arm/src/max326xx/common/max326_start.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/max326xx/max326_start.c + * arch/arm/src/max326xx/common/max326_start.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -47,7 +47,6 @@ #include "up_internal.h" #include "nvic.h" -#include "chip/max326_syscon.h" #include "max326_clockconfig.h" #include "max326_userspace.h" #include "max326_lowputc.h" @@ -78,18 +77,9 @@ /* This describes the initial PLL configuration */ -static const struct pll_setup_s g_initial_pll_setup = +static const struct clock_setup_s g_initial_clock_setup = { - .pllclksel = BOARD_PLL_CLKSEL, - .pllctrl = SYSCON_SYSPLLCTRL_SELR(BOARD_PLL_SELR) | - SYSCON_SYSPLLCTRL_SELI(BOARD_PLL_SELI) | - SYSCON_SYSPLLCTRL_SELP(BOARD_PLL_SELP), - .pllmdec = (SYSCON_SYSPLLMDEC_MDEC(BOARD_PLL_MDEC)), - .pllndec = (SYSCON_SYSPLLNDEC_NDEC(BOARD_PLL_NDEC)), - .pllpdec = (SYSCON_SYSPLLPDEC_PDEC(BOARD_PLL_PDEC)), - .pllfout = BOARD_PLL_FOUT, - .pllflags = PLL_SETUPFLAG_WAITLOCK | PLL_SETUPFLAG_POWERUP, - .ahbdiv = SYSCON_AHBCLKDIV_DIV(BOARD_AHBCLKDIV) +#warning Missing logic }; /**************************************************************************** @@ -198,7 +188,6 @@ void __start(void) { const uint32_t *src; uint32_t *dest; - uint32_t regval; /* Make sure that interrupts are disabled */ @@ -209,7 +198,7 @@ void __start(void) * .bss or .data have been initialized. */ - max326_clockconfig(&g_initial_pll_setup); + max326_clockconfig(&g_initial_clock_setup); max326_lowsetup(); showprogress('A'); diff --git a/arch/arm/src/max326xx/max326_timerisr.c b/arch/arm/src/max326xx/common/max326_timerisr.c similarity index 99% rename from arch/arm/src/max326xx/max326_timerisr.c rename to arch/arm/src/max326xx/common/max326_timerisr.c index 2326edc7c41..58acc11ab3a 100644 --- a/arch/arm/src/max326xx/max326_timerisr.c +++ b/arch/arm/src/max326xx/common/max326_timerisr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/max326xx/max326_timerisr.c + * arch/arm/src/max326xx/common/max326_timerisr.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/arch/arm/src/max326xx/max326_userspace.c b/arch/arm/src/max326xx/common/max326_userspace.c similarity index 98% rename from arch/arm/src/max326xx/max326_userspace.c rename to arch/arm/src/max326xx/common/max326_userspace.c index 36805b68d08..ce105ec482c 100644 --- a/arch/arm/src/max326xx/max326_userspace.c +++ b/arch/arm/src/max326xx/common/max326_userspace.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/max326xx/max326_userspace.c + * arch/arm/src/max326xx/common/max326_userspace.c * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/arch/arm/src/max326xx/max32660_gpio.h b/arch/arm/src/max326xx/max32660/max32660_gpio.h similarity index 97% rename from arch/arm/src/max326xx/max32660_gpio.h rename to arch/arm/src/max326xx/max32660/max32660_gpio.h index ecce6280445..378f0e58cb7 100644 --- a/arch/arm/src/max326xx/max32660_gpio.h +++ b/arch/arm/src/max326xx/max32660/max32660_gpio.h @@ -1,5 +1,5 @@ /************************************************************************************ - * arch/arm/src/max326xx/max32660_gpio.h + * arch/arm/src/max326xx/max32660/max32660_gpio.h * * Copyright (C) 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ************************************************************************************/ -#ifndef __ARCH_ARM_SRC_MAX326XX_MAX32660_GPIO_H -#define __ARCH_ARM_SRC_MAX326XX_MAX32660_GPIO_H +#ifndef __ARCH_ARM_SRC_MAX326XX_MAX32660_MAX32660_GPIO_H +#define __ARCH_ARM_SRC_MAX326XX_MAX32660_MAX32660_GPIO_H /************************************************************************************ * Included Files @@ -186,4 +186,4 @@ typedef uint16_t max326_pinset_t; -#endif /* __ARCH_ARM_SRC_MAX326XX_MAX32660_GPIO_H */ +#endif /* __ARCH_ARM_SRC_MAX326XX_MAX32660_MAX32660_GPIO_H */ diff --git a/arch/arm/src/max326xx/max326_config.h b/arch/arm/src/max326xx/max326_config.h index a80ac88551b..9e2b0049f52 100644 --- a/arch/arm/src/max326xx/max326_config.h +++ b/arch/arm/src/max326xx/max326_config.h @@ -68,8 +68,8 @@ #undef HAVE_UART_DEVICE -#if defined(CONFIG_MAX326XX_UART0) || CONFIG_MAX326XX_UART3(HAVE_UART1) || \ - defined(CONFIG_MAX326XX_UART1) || defined(CONFIG_MAX326XX_UART3)) +#if defined(CONFIG_MAX326XX_UART0) || defined(CONFIG_MAX326XX_UART2) || \ + defined(CONFIG_MAX326XX_UART1) || defined(CONFIG_MAX326XX_UART3) # define HAVE_UART_DEVICE 1 #endif @@ -79,22 +79,22 @@ #undef HAVE_UART_CONSOLE -#if defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(HAVE_UART0) +#if defined(CONFIG_UART0_SERIAL_CONSOLE) # undef CONFIG_UART1_SERIAL_CONSOLE # undef CONFIG_UART2_SERIAL_CONSOLE # undef CONFIG_UART3_SERIAL_CONSOLE # define HAVE_UART_CONSOLE 1 -#elif defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(HAVE_UART1) +#elif defined(CONFIG_UART1_SERIAL_CONSOLE) # undef CONFIG_UART0_SERIAL_CONSOLE # undef CONFIG_UART2_SERIAL_CONSOLE # undef CONFIG_UART3_SERIAL_CONSOLE # define HAVE_UART_CONSOLE 1 -#elif defined(CONFIG_UART2_SERIAL_CONSOLE) && defined(HAVE_UART2) +#elif defined(CONFIG_UART2_SERIAL_CONSOLE) # undef CONFIG_UART0_SERIAL_CONSOLE # undef CONFIG_UART1_SERIAL_CONSOLE # undef CONFIG_UART3_SERIAL_CONSOLE # define HAVE_UART_CONSOLE 1 -#elif defined(CONFIG_UART3_SERIAL_CONSOLE) && defined(HAVE_UART3) +#elif defined(CONFIG_UART3_SERIAL_CONSOLE) # undef CONFIG_UART0_SERIAL_CONSOLE # undef CONFIG_UART1_SERIAL_CONSOLE # undef CONFIG_UART2_SERIAL_CONSOLE diff --git a/arch/arm/src/max326xx/max326_gpio.h b/arch/arm/src/max326xx/max326_gpio.h index 7fde688311c..c857842cb40 100644 --- a/arch/arm/src/max326xx/max326_gpio.h +++ b/arch/arm/src/max326xx/max326_gpio.h @@ -51,12 +51,12 @@ * Pre-processor Definitions ************************************************************************************/ -/* Bit-encoded input to max326_gpio_config() ******************************************/ +/* Bit-encoded input to max326_gpio_config() ****************************************/ #if defined(CONFIG_ARCH_FAMILY_MAX32620) || defined(CONFIG_ARCH_FAMILY_MAX32630) -# include "max32620_30_gpio.h" +# include "max32620_30/max32620_30_gpio.h" #if defined(CONFIG_ARCH_FAMILY_MAX32660) -# include "max32660_gpio.h" +# include "max32660/max32660_gpio.h" #else # error "Unsupported MAX326XX family" #endif diff --git a/arch/arm/src/max326xx/max326_lowputc.h b/arch/arm/src/max326xx/max326_lowputc.h new file mode 100644 index 00000000000..2493ae8dca5 --- /dev/null +++ b/arch/arm/src/max326xx/max326_lowputc.h @@ -0,0 +1,118 @@ +/**************************************************************************** + * arch/arm/src/max326xx/max326_lowputc.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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_MAX326XX_MAX326_LOWPUTC_H +#define __ARCH_ARM_SRC_MAX326XX_MAX326_LOWPUTC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "max326_config.h" + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifdef HAVE_UART_DEVICE +/* This structure describes the configuration of an UART */ + +struct uart_config_s +{ + uint32_t baud; /* Configured baud */ + uint32_t fclk; /* Input UART function clock frequency */ + uint8_t parity; /* 0=none, 1=odd, 2=even */ + uint8_t bits; /* Number of bits (5-9) */ + uint8_t txlevel; /* TX level for event generation */ + uint8_t rxlevel; /* RX level for event generation */ + bool stopbits2; /* true: Configure with 2 stop bits instead of 1 */ +#ifdef CONFIG_SERIAL_IFLOWCONTROL + bool iflow; /* true: Input flow control supported */ +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + bool oflow; /* true: Output flow control supported. */ +#endif +}; +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: max326_lowsetup + * + * Description: + * Called at the very beginning of _start. Performs low level + * initialization including setup of the console UART. This UART + * initialization is done early so that the serial console is available + * for debugging very early in the boot sequence. + * + ****************************************************************************/ + +void max326_lowsetup(void); + +/**************************************************************************** + * Name: max326_usart_configure + * + * Description: + * Configure a UART for non-interrupt driven operation + * + ****************************************************************************/ + +#ifdef HAVE_UART_DEVICE +void max326_usart_configure(uintptr_t base, + FAR const struct uart_config_s *config); +#endif + +/**************************************************************************** + * Name: max326_usart_disable + * + * Description: + * Disable a UART. it will be necessary to again call + * max326_usart_configure() in order to use this UART channel again. + * + ****************************************************************************/ + +#ifdef HAVE_UART_DEVICE +void max326_usart_disable(uintptr_t base); +#endif + +#endif /* __ARCH_ARM_SRC_MAX326XX_MAX326_LOWPUTC_H */ diff --git a/arch/arm/src/max326xx/max326_serial.h b/arch/arm/src/max326xx/max326_serial.h new file mode 100644 index 00000000000..889bcac285b --- /dev/null +++ b/arch/arm/src/max326xx/max326_serial.h @@ -0,0 +1,66 @@ +/**************************************************************************** + * arch/arm/src/max326xx/max326_serial.h + * + * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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_MAX326XX_MAX326_SERIAL_H +#define __ARCH_ARM_SRC_MAX326XX_MAX326_SERIAL_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include "max326_config.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: max326_earlyserialinit + * + * Description: + * Performs the low level USART initialization early in debug so that the + * serial console will be available during bootup. This must be called + * before max326_serialinit. NOTE: This function depends on GPIO pin + * configuration performed in xmc_lowsetup() and main clock initialization + * performed in xmc_clock_configure(). + * + ****************************************************************************/ + +#ifdef USE_EARLYSERIALINIT +void max326_earlyserialinit(void); +#endif + +#endif /* __ARCH_ARM_SRC_MAX326XX_MAX326_SERIAL_H */