c628529e2d
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
178 lines
4.3 KiB
C
178 lines
4.3 KiB
C
/****************************************************************************
|
|
* boards/arm/stm32/axoloti/src/stm32_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 <nuttx/config.h>
|
|
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <debug.h>
|
|
#include <errno.h>
|
|
|
|
#include <nuttx/fs/fs.h>
|
|
|
|
#ifdef CONFIG_USBMONITOR
|
|
# include <nuttx/usb/usbmonitor.h>
|
|
#endif
|
|
|
|
#include "stm32.h"
|
|
|
|
#ifdef CONFIG_STM32_OTGHS
|
|
# include "stm32_usbhost.h"
|
|
#endif
|
|
|
|
#ifdef CONFIG_INPUT_BUTTONS
|
|
# include <nuttx/input/buttons.h>
|
|
#endif
|
|
|
|
#ifdef CONFIG_USERLED
|
|
# include <nuttx/leds/userled.h>
|
|
#endif
|
|
|
|
#include "axoloti.h"
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: stm32_bringup
|
|
*
|
|
* Description:
|
|
* Perform architecture-specific initialization
|
|
*
|
|
* CONFIG_BOARD_LATE_INITIALIZE=y :
|
|
* Called from board_late_initialize().
|
|
*
|
|
* CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y :
|
|
* Called from the NSH library
|
|
*
|
|
****************************************************************************/
|
|
|
|
int stm32_bringup(void)
|
|
{
|
|
#ifdef HAVE_RTC_DRIVER
|
|
struct rtc_lowerhalf_s *lower;
|
|
#endif
|
|
int ret = OK;
|
|
|
|
#ifdef HAVE_SDRAM
|
|
/* Initialize access to the SDRAM device */
|
|
|
|
ret = stm32_sdram_initialize();
|
|
if (ret != OK)
|
|
{
|
|
syslog(LOG_ERR, "stm32_sdram_initialize failed %d\n", ret);
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#ifdef HAVE_SDIO
|
|
/* Initialize the SDIO block driver */
|
|
|
|
ret = stm32_sdio_initialize();
|
|
if (ret != OK)
|
|
{
|
|
syslog(LOG_ERR, "stm32_sdio_initialize failed %d\n", ret);
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#ifdef HAVE_USBHOST
|
|
/* Initialize USB host operation. stm32_usbhost_initialize() starts a
|
|
* thread will monitor for USB connection and disconnection events.
|
|
*/
|
|
|
|
ret = stm32_usbhost_initialize();
|
|
if (ret != OK)
|
|
{
|
|
syslog(LOG_ERR, "stm32_usbhost_initialize failed %d\n", ret);
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#ifdef HAVE_USBMONITOR
|
|
/* Start the USB Monitor */
|
|
|
|
ret = usbmonitor_start();
|
|
if (ret != OK)
|
|
{
|
|
syslog(LOG_ERR, "usbmonitor_start failed %d\n", ret);
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_INPUT_BUTTONS
|
|
/* Register the BUTTON driver */
|
|
|
|
ret = btn_lower_initialize("/dev/buttons");
|
|
if (ret < 0)
|
|
{
|
|
syslog(LOG_ERR, "btn_lower_initialize failed %d\n", ret);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_INPUT_REI2C
|
|
/* Register the rei2c driver */
|
|
|
|
ret = rei2c_initialize("/dev/re0");
|
|
if (ret < 0)
|
|
{
|
|
syslog(LOG_ERR, "rei2c_initialize failed %d\n", ret);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_USERLED
|
|
/* Register the LED driver */
|
|
|
|
ret = userled_lower_initialize("/dev/userleds");
|
|
if (ret < 0)
|
|
{
|
|
syslog(LOG_ERR, "userled_lower_initialize failed %d\n", ret);
|
|
}
|
|
#endif
|
|
|
|
#ifdef HAVE_ADAU1961
|
|
/* Configure ADAU1961 audio */
|
|
|
|
ret = stm32_adau1961_initialize(1);
|
|
if (ret != OK)
|
|
{
|
|
syslog(LOG_ERR, "stm32_adau1961_initialize failed %d\n", ret);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_FS_PROCFS
|
|
/* Mount the procfs file system */
|
|
|
|
ret = nx_mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
|
|
if (ret < 0)
|
|
{
|
|
syslog(LOG_ERR, "failed to mount procfs at %s %d\n",
|
|
STM32_PROCFS_MOUNTPOINT, ret);
|
|
}
|
|
#endif
|
|
|
|
return ret;
|
|
}
|