From f46298105a911902dacf0e843105673c771d9e3d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 7 Mar 2016 16:14:13 -0600 Subject: [PATCH] i.MX6: Add skeleton clockconfig file. Fix some naming problems. Add some warnings. --- arch/arm/src/imx6/Make.defs | 4 +- arch/arm/src/imx6/imx_boot.c | 13 +---- arch/arm/src/imx6/imx_clockconfig.c | 73 +++++++++++++++++++++++++++++ arch/arm/src/imx6/imx_clockconfig.h | 29 ------------ arch/arm/src/imx6/imx_lowputc.c | 19 ++++++-- arch/arm/src/imx6/imx_lowputc.h | 31 ++---------- arch/arm/src/imx6/imx_serial.c | 36 +++++++------- 7 files changed, 112 insertions(+), 93 deletions(-) create mode 100644 arch/arm/src/imx6/imx_clockconfig.c diff --git a/arch/arm/src/imx6/Make.defs b/arch/arm/src/imx6/Make.defs index a98d9d227f..ddf0a852d5 100644 --- a/arch/arm/src/imx6/Make.defs +++ b/arch/arm/src/imx6/Make.defs @@ -132,5 +132,5 @@ CHIP_ASRCS = # i.MX6-specific C source files -CHIP_CSRCS = imx_boot.c imx_memorymap.c imx_irq.c -CHIP_CSRCS = imx_gpio.c imx_iomuxc.c imx_serial.c imx_lowputc.c +CHIP_CSRCS = imx_boot.c imx_memorymap.c imx_clockconfig.c imx_irq.c +CHIP_CSRCS += imx_gpio.c imx_iomuxc.c imx_serial.c imx_lowputc.c diff --git a/arch/arm/src/imx6/imx_boot.c b/arch/arm/src/imx6/imx_boot.c index ae27f97990..7e380f6415 100644 --- a/arch/arm/src/imx6/imx_boot.c +++ b/arch/arm/src/imx6/imx_boot.c @@ -57,20 +57,13 @@ #include "up_internal.h" #include "up_arch.h" +#include "imx_config.h" #include "imx_clockconfig.h" #include "imx_memorymap.h" #include "imx_lowputc.h" #include "imx_serial.h" #include "imx_boot.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - /**************************************************************************** * Public Data ****************************************************************************/ @@ -80,10 +73,6 @@ extern uint32_t _vector_start; /* Beginning of vector block */ extern uint32_t _vector_end; /* End+1 of vector block */ -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ diff --git a/arch/arm/src/imx6/imx_clockconfig.c b/arch/arm/src/imx6/imx_clockconfig.c new file mode 100644 index 0000000000..fa42834207 --- /dev/null +++ b/arch/arm/src/imx6/imx_clockconfig.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * arch/arm/src/imx6/imx_clockconfig.c + * + * Copyright (C) 2016 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "imx_config.h" +#include "imx_clockconfig.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: imx_clockconfig + * + * Description: + * Called to initialize the i.MX6. This does whatever setup is needed to + * put the SoC in a usable state. This includes the initialization of + * clocking using the settings in board.h. + * + ****************************************************************************/ + +void imx_clockconfig(void) +{ + /* Don't change the current basic clock configuration if we are running + * from SDRAM. In this case, some bootloader logic has already configured + * clocking and SDRAM. We are pretty much committed to using things the + * way that the bootloader has left them. + */ + +#ifndef CONFIG_IMX_BOOT_SDRAM +# warning Missing logic +#endif + + /* Make certain that the ipg_clk is enabled */ +#warning Missing logic +} diff --git a/arch/arm/src/imx6/imx_clockconfig.h b/arch/arm/src/imx6/imx_clockconfig.h index 064b273300..b2b52bd16a 100644 --- a/arch/arm/src/imx6/imx_clockconfig.h +++ b/arch/arm/src/imx6/imx_clockconfig.h @@ -41,34 +41,6 @@ ****************************************************************************/ #include -#include "up_internal.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline Functions - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif /**************************************************************************** * Public Function Prototypes @@ -86,5 +58,4 @@ extern "C" void imx_clockconfig(void); -#endif /* __ASSEMBLY__ */ #endif /* __ARCH_ARM_SRC_IMX6_IMX_CLOCKCONFIG_H */ diff --git a/arch/arm/src/imx6/imx_lowputc.c b/arch/arm/src/imx6/imx_lowputc.c index cfa31b99d6..09e036d227 100644 --- a/arch/arm/src/imx6/imx_lowputc.c +++ b/arch/arm/src/imx6/imx_lowputc.c @@ -42,15 +42,17 @@ #include #include -#include "chip/imx_iomuxc.h" /* Order matters with these three */ -#include "chip/imx_pinmux.h" -#include - #include "up_arch.h" + +#include "chip/imx_iomuxc.h" +#include "chip/imx_pinmux.h" #include "chip/imx_uart.h" +#include "imx_config.h" #include "imx_gpio.h" #include "imx_lowputc.h" +#include /* Include last: has dependencies */ + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -154,6 +156,12 @@ static const struct uart_config_s g_console_config = void imx_lowsetup(void) { +#ifdef IMX_HAVE_UART + /* Make certain that the ipg_perclk is enabled. The ipg_clk should already + * have been enabled. + */ +#warning Missing logic + #ifdef CONFIG_IMX6_UART1 /* Disable and configure UART1 */ @@ -269,6 +277,7 @@ void imx_lowsetup(void) (void)imx_uart_configure(IMX_CONSOLE_VBASE, &g_console_config); #endif +#endif /* IMX_HAVE_UART */ } /************************************************************************************ @@ -279,6 +288,7 @@ void imx_lowsetup(void) * ************************************************************************************/ +#ifdef IMX_HAVE_UART int imx_uart_configure(uint32_t base, FAR const struct uart_config_s *config) { #ifndef CONFIG_SUPPRESS_UART_CONFIG @@ -468,3 +478,4 @@ int imx_uart_configure(uint32_t base, FAR const struct uart_config_s *config) return OK; } +#endif /* IMX_HAVE_UART */ \ No newline at end of file diff --git a/arch/arm/src/imx6/imx_lowputc.h b/arch/arm/src/imx6/imx_lowputc.h index a9ff01ba38..d70f408029 100644 --- a/arch/arm/src/imx6/imx_lowputc.h +++ b/arch/arm/src/imx6/imx_lowputc.h @@ -51,9 +51,10 @@ #include "chip.h" /**************************************************************************** - * Pre-processor Definitions + * Public Types ****************************************************************************/ +#ifdef IMX_HAVE_UART /* This structure describes the configuration of an UART */ struct uart_config_s @@ -63,28 +64,6 @@ struct uart_config_s uint8_t bits; /* Number of bits (5-9) */ bool stopbits2; /* true: Configure with 2 stop bits instead of 1 */ }; - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline Functions - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern #endif /**************************************************************************** @@ -112,12 +91,8 @@ void imx_lowsetup(void); * ************************************************************************************/ +#ifdef IMX_HAVE_UART int imx_uart_configure(uint32_t base, FAR const struct uart_config_s *config); - -#undef EXTERN -#if defined(__cplusplus) -} #endif -#endif /* __ASSEMBLY__ */ #endif /* __ARCH_ARM_SRC_IMX6_IMX_LOWPUTC_H */ diff --git a/arch/arm/src/imx6/imx_serial.c b/arch/arm/src/imx6/imx_serial.c index 62c2d38ed4..daf8187446 100644 --- a/arch/arm/src/imx6/imx_serial.c +++ b/arch/arm/src/imx6/imx_serial.c @@ -930,12 +930,12 @@ static bool imx_txempty(struct uart_dev_s *dev) ****************************************************************************/ /**************************************************************************** - * Name: imx_serialinit + * Name: imx_earlyserialinit * * Description: * Performs the low level UART initialization early in * debug so that the serial console will be available - * during bootup. This must be called before imx_serialinit. + * during bootup. This must be called before up_serialinit. * ****************************************************************************/ @@ -957,7 +957,7 @@ void imx_earlyserialinit(void) } /**************************************************************************** - * Name: imx_serialinit + * Name: up_serialinit * * Description: * Register serial console and serial ports. This assumes @@ -965,7 +965,7 @@ void imx_earlyserialinit(void) * ****************************************************************************/ -void imx_serialinit(void) +void up_serialinit(void) { #ifdef CONSOLE_DEV (void)uart_register("/dev/console", &CONSOLE_DEV); @@ -989,7 +989,7 @@ void imx_serialinit(void) } /**************************************************************************** - * Name: imx_putc + * Name: up_putc * * Description: * Provide priority, low-level access to support OS debug @@ -997,7 +997,7 @@ void imx_serialinit(void) * ****************************************************************************/ -int imx_putc(int ch) +int up_putc(int ch) { struct imx_uart_s *priv = (struct imx_uart_s *)CONSOLE_DEV.priv; uint32_t ier; @@ -1027,24 +1027,24 @@ int imx_putc(int ch) * Pre-processor Definitions ****************************************************************************/ -# undef IMX_REGISTER_BASE +# undef IMX_CONSOLE_VBASE # if defined(CONFIG_UART1_SERIAL_CONSOLE) -# define IMX_REGISTER_BASE IMX_UART1_VBASE +# define IMX_CONSOLE_VBASE IMX_UART1_VBASE # elif defined(CONFIG_UART2_SERIAL_CONSOLE) -# define IMX_REGISTER_BASE IMX_UART2_VBASE +# define IMX_CONSOLE_VBASE IMX_UART2_VBASE # elif defined(CONFIG_UART3_SERIAL_CONSOLE) -# define IMX_REGISTER_BASE IMX_UART3_VBASE +# define IMX_CONSOLE_VBASE IMX_UART3_VBASE # elif defined(CONFIG_UART4_SERIAL_CONSOLE) -# define IMX_REGISTER_BASE IMX_UART4_VBASE +# define IMX_CONSOLE_VBASE IMX_UART4_VBASE # elif defined(CONFIG_UART5_SERIAL_CONSOLE) -# define IMX_REGISTER_BASE IMX_UART5_VBASE +# define IMX_CONSOLE_VBASE IMX_UART5_VBASE # endif /**************************************************************************** * Private Functions ****************************************************************************/ -#ifdef IMX_REGISTER_BASE +#ifdef IMX_CONSOLE_VBASE static inline void imx_waittxready(void) { int tmp; @@ -1055,7 +1055,7 @@ static inline void imx_waittxready(void) * in the TX FIFO. */ - if ((getreg32(IMX_REGISTER_BASE + UART_UTS) & UART_UTS_TXFULL) == 0) + if ((getreg32(IMX_CONSOLE_VBASE + UART_UTS) & UART_UTS_TXFULL) == 0) { break; } @@ -1067,9 +1067,9 @@ static inline void imx_waittxready(void) * Public Functions ****************************************************************************/ -int imx_putc(int ch) +int up_putc(int ch) { -#ifdef IMX_REGISTER_BASE +#ifdef IMX_CONSOLE_VBASE imx_waittxready(); /* Check for LF */ @@ -1078,11 +1078,11 @@ int imx_putc(int ch) { /* Add CR */ - putreg32((uint16_t)'\r', IMX_REGISTER_BASE + UART_TXD_OFFSET); + putreg32((uint16_t)'\r', IMX_CONSOLE_VBASE + UART_TXD_OFFSET); imx_waittxready(); } - putreg32((uint16_t)ch, IMX_REGISTER_BASE + UART_TXD_OFFSET); + putreg32((uint16_t)ch, IMX_CONSOLE_VBASE + UART_TXD_OFFSET); #endif return ch;