From 6be378221ac01b1d2700bbeeb02f223d9e79608e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 14 Feb 2020 10:26:03 -0600 Subject: [PATCH] tiva/lm3s6965-ek: Add bringup() function A shrinked copy of the sim version. I changed the license to apache 2.0 with a permisson from @patacongo. --- boards/arm/tiva/lm3s6965-ek/src/Makefile | 6 ++ boards/arm/tiva/lm3s6965-ek/src/lm3s6965-ek.h | 24 +++++- boards/arm/tiva/lm3s6965-ek/src/lm_appinit.c | 4 + boards/arm/tiva/lm3s6965-ek/src/lm_boot.c | 20 +++++ boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c | 81 +++++++++++++++++++ 5 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c diff --git a/boards/arm/tiva/lm3s6965-ek/src/Makefile b/boards/arm/tiva/lm3s6965-ek/src/Makefile index ff159a753e4..9da9b434be8 100644 --- a/boards/arm/tiva/lm3s6965-ek/src/Makefile +++ b/boards/arm/tiva/lm3s6965-ek/src/Makefile @@ -46,4 +46,10 @@ ifeq ($(CONFIG_NX_LCDDRIVER),y) CSRCS += lm_oled.c endif +ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y) + CSRCS += lm_bringup.c +else ifeq ($(CONFIG_LIB_BOARDCTL),y) + CSRCS += lm_bringup.c +endif + include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/tiva/lm3s6965-ek/src/lm3s6965-ek.h b/boards/arm/tiva/lm3s6965-ek/src/lm3s6965-ek.h index e43f71b4e9e..be5aba76efe 100644 --- a/boards/arm/tiva/lm3s6965-ek/src/lm3s6965-ek.h +++ b/boards/arm/tiva/lm3s6965-ek/src/lm3s6965-ek.h @@ -62,7 +62,7 @@ # undef CONFIG_TIVA_SSI1 #endif -/* LM3S6965 Eval Kit ***************************************************************/ +/* LM3S6965 Eval Kit ********************************************************/ /* GPIO Usage * @@ -112,12 +112,32 @@ #define OLEDEN_GPIO (GPIO_FUNC_OUTPUT | GPIO_PADTYPE_STD | GPIO_STRENGTH_8MA | \ GPIO_VALUE_ONE | GPIO_PORTC | 6) +/* procfs File System */ + +#ifdef CONFIG_FS_PROCFS +# ifdef CONFIG_NSH_PROC_MOUNTPOINT +# define LM_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT +# else +# define LM_PROCFS_MOUNTPOINT "/proc" +# endif +#endif + /**************************************************************************** - * Public Functions + * Public Function Prototypes ****************************************************************************/ #ifndef __ASSEMBLY__ +/**************************************************************************** + * Name: lm_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int lm_bringup(void); + /**************************************************************************** * Name: lm_ssidev_initialize * diff --git a/boards/arm/tiva/lm3s6965-ek/src/lm_appinit.c b/boards/arm/tiva/lm3s6965-ek/src/lm_appinit.c index 5732a72f9e2..3ee75c506c2 100644 --- a/boards/arm/tiva/lm3s6965-ek/src/lm_appinit.c +++ b/boards/arm/tiva/lm3s6965-ek/src/lm_appinit.c @@ -48,6 +48,7 @@ #include #include +#include "lm3s6965-ek.h" #include "tiva_ssi.h" /**************************************************************************** @@ -152,6 +153,9 @@ int board_app_initialize(uintptr_t arg) mcinfo("Successfully bound SPI port %d to MMC/SD slot %d\n", CONFIG_NSH_MMCSDSPIPORTNO, CONFIG_NSH_MMCSDSLOTNO); +#endif +#ifndef CONFIG_BOARD_LATE_INITIALIZE + lm_bringup(); #endif return OK; } diff --git a/boards/arm/tiva/lm3s6965-ek/src/lm_boot.c b/boards/arm/tiva/lm3s6965-ek/src/lm_boot.c index 372472e1820..9e6171cafb2 100644 --- a/boards/arm/tiva/lm3s6965-ek/src/lm_boot.c +++ b/boards/arm/tiva/lm3s6965-ek/src/lm_boot.c @@ -94,3 +94,23 @@ void tiva_boardinitialize(void) board_autoled_initialize(); #endif } + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will be + * called immediately after up_initialize() is called and just before the + * initial application is started. This additional initialization phase + * may be used, for example, to initialize board-specific device drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + lm_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c b/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c new file mode 100644 index 00000000000..07127add9f2 --- /dev/null +++ b/boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c @@ -0,0 +1,81 @@ +/**************************************************************************** + * boards/arm/tiva/lm3s6965-ek/src/lm_bringup.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "lm3s6965-ek.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lm_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int lm_bringup(void) +{ + int ret = 0; + +#ifdef CONFIG_FS_BINFS + /* Mount the binfs file system */ + + ret = mount(NULL, "/bin", "binfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount binfs at /bin: %d\n", ret); + } +#endif + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = mount(NULL, LM_PROCFS_MOUNTPOINT, "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n", + LM_PROCFS_MOUNTPOINT, ret); + } +#endif + +#ifdef CONFIG_FS_TMPFS + /* Mount the tmpfs file system */ + + ret = mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at %s: %d\n", + CONFIG_LIBC_TMPDIR, ret); + } +#endif + + return ret; +}