2022-03-11 15:52:32 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/drivers_initialize.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
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-08-10 02:40:43 +02:00
|
|
|
#include <nuttx/clk/clk_provider.h>
|
2022-03-11 15:52:32 +01:00
|
|
|
#include <nuttx/crypto/crypto.h>
|
|
|
|
#include <nuttx/drivers/drivers.h>
|
2022-08-09 10:20:26 +02:00
|
|
|
#include <nuttx/drivers/rpmsgdev.h>
|
2022-10-26 07:14:49 +02:00
|
|
|
#include <nuttx/drivers/rpmsgblk.h>
|
2022-03-11 15:52:32 +01:00
|
|
|
#include <nuttx/fs/loop.h>
|
2023-01-29 16:43:43 +01:00
|
|
|
#include <nuttx/fs/smart.h>
|
2023-02-06 16:05:12 +01:00
|
|
|
#include <nuttx/fs/loopmtd.h>
|
2022-03-19 16:37:11 +01:00
|
|
|
#include <nuttx/input/uinput.h>
|
2022-09-05 03:46:44 +02:00
|
|
|
#include <nuttx/mtd/mtd.h>
|
2022-03-11 15:52:32 +01:00
|
|
|
#include <nuttx/net/loopback.h>
|
|
|
|
#include <nuttx/net/tun.h>
|
|
|
|
#include <nuttx/net/telnet.h>
|
|
|
|
#include <nuttx/note/note_driver.h>
|
2024-08-27 06:08:33 +02:00
|
|
|
#include <nuttx/pci/pci.h>
|
2022-03-11 15:52:32 +01:00
|
|
|
#include <nuttx/power/pm.h>
|
2022-08-10 03:10:28 +02:00
|
|
|
#include <nuttx/power/regulator.h>
|
2023-09-27 12:43:15 +02:00
|
|
|
#include <nuttx/reset/reset-controller.h>
|
2023-07-06 16:09:05 +02:00
|
|
|
#include <nuttx/segger/rtt.h>
|
2022-04-14 06:21:45 +02:00
|
|
|
#include <nuttx/sensors/sensor.h>
|
|
|
|
#include <nuttx/serial/pty.h>
|
2023-08-21 05:33:01 +02:00
|
|
|
#include <nuttx/serial/uart_ram.h>
|
2022-03-11 15:52:32 +01:00
|
|
|
#include <nuttx/syslog/syslog.h>
|
|
|
|
#include <nuttx/syslog/syslog_console.h>
|
2023-10-13 17:10:56 +02:00
|
|
|
#include <nuttx/thermal.h>
|
2023-02-22 04:08:22 +01:00
|
|
|
#include <nuttx/trace.h>
|
2023-01-03 03:54:07 +01:00
|
|
|
#include <nuttx/usrsock/usrsock_rpmsg.h>
|
2023-03-22 04:49:43 +01:00
|
|
|
#include <nuttx/virtio/virtio.h>
|
2023-11-20 14:23:56 +01:00
|
|
|
#include <nuttx/drivers/optee.h>
|
2022-03-11 15:52:32 +01:00
|
|
|
|
2024-07-25 14:39:11 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* Check if only one console device is selected.
|
|
|
|
* If you get this errro, search your .config file for CONSOLE_XXX_CONSOLE
|
|
|
|
* options and remove what is not needed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if (defined(CONFIG_LWL_CONSOLE) + defined(CONFIG_SERIAL_CONSOLE) + \
|
|
|
|
defined(CONFIG_CDCACM_CONSOLE) + defined(CONFIG_PL2303_CONSOLE) + \
|
|
|
|
defined(CONFIG_SERIAL_RTT_CONSOLE) + defined(CONFIG_RPMSG_UART_CONSOLE)) > 1
|
|
|
|
# error More than one console driver selected. Check your configuration !
|
|
|
|
#endif
|
|
|
|
|
2022-03-11 15:52:32 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2024-07-06 13:04:04 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: drivers_early_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* drivers_early_initialize will be called once before OS initialization
|
|
|
|
* when no system resource is ready to use.
|
|
|
|
*
|
|
|
|
* drivers_early_initialize serves the purpose of bringing up drivers as
|
|
|
|
* early as possible, so they can be used even during OS initialization.
|
|
|
|
* It must not rely on any system resources, such as heap memory.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void drivers_early_initialize(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_DRIVERS_NOTE
|
|
|
|
note_early_initialize();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-03-11 15:52:32 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: drivers_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* drivers_initialize will be called once during OS initialization after
|
|
|
|
* the basic OS services have been initialized.
|
|
|
|
*
|
|
|
|
* drivers_initialize is called after the OS initialized but before the
|
|
|
|
* user initialization logic has been started and before the libraries
|
|
|
|
* have been initialized. OS services and driver services are available.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void drivers_initialize(void)
|
|
|
|
{
|
2023-02-22 04:08:22 +01:00
|
|
|
drivers_trace_begin();
|
|
|
|
|
2022-03-11 15:52:32 +01:00
|
|
|
/* Register devices */
|
|
|
|
|
|
|
|
syslog_initialize();
|
|
|
|
|
2023-07-06 16:09:05 +02:00
|
|
|
#ifdef CONFIG_SERIAL_RTT
|
|
|
|
serial_rtt_initialize();
|
|
|
|
#endif
|
|
|
|
|
2022-03-11 15:52:32 +01:00
|
|
|
#if defined(CONFIG_DEV_NULL)
|
|
|
|
devnull_register(); /* Standard /dev/null */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_DEV_RANDOM)
|
|
|
|
devrandom_register(); /* Standard /dev/random */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_DEV_URANDOM)
|
|
|
|
devurandom_register(); /* Standard /dev/urandom */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_DEV_ZERO)
|
|
|
|
devzero_register(); /* Standard /dev/zero */
|
|
|
|
#endif
|
|
|
|
|
2023-09-14 04:31:11 +02:00
|
|
|
#ifdef CONFIG_DEV_MEM
|
|
|
|
devmem_register();
|
|
|
|
#endif
|
|
|
|
|
2022-03-11 15:52:32 +01:00
|
|
|
#if defined(CONFIG_DEV_LOOP)
|
|
|
|
loop_register(); /* Standard /dev/loop */
|
|
|
|
#endif
|
|
|
|
|
2023-06-14 06:14:31 +02:00
|
|
|
#if defined(CONFIG_DEV_ASCII)
|
|
|
|
devascii_register(); /* Non-standard /dev/ascii */
|
|
|
|
#endif
|
|
|
|
|
2023-02-20 08:21:31 +01:00
|
|
|
#if defined(CONFIG_DRIVERS_NOTE)
|
2022-12-11 13:45:20 +01:00
|
|
|
note_initialize(); /* Non-standard /dev/note */
|
2022-03-11 15:52:32 +01:00
|
|
|
#endif
|
|
|
|
|
2022-08-10 02:40:43 +02:00
|
|
|
#if defined(CONFIG_CLK_RPMSG)
|
|
|
|
clk_rpmsg_server_initialize();
|
|
|
|
#endif
|
|
|
|
|
2022-08-10 03:10:28 +02:00
|
|
|
#if defined(CONFIG_REGULATOR_RPMSG)
|
|
|
|
regulator_rpmsg_server_init();
|
|
|
|
#endif
|
|
|
|
|
2023-09-27 12:43:15 +02:00
|
|
|
#if defined(CONFIG_RESET_RPMSG)
|
|
|
|
reset_rpmsg_server_init();
|
|
|
|
#endif
|
|
|
|
|
2022-03-11 15:52:32 +01:00
|
|
|
/* Initialize the serial device driver */
|
|
|
|
|
|
|
|
#ifdef CONFIG_RPMSG_UART
|
|
|
|
rpmsg_serialinit();
|
|
|
|
#endif
|
|
|
|
|
2023-08-21 05:33:01 +02:00
|
|
|
#ifdef CONFIG_RAM_UART
|
|
|
|
ram_serialinit();
|
|
|
|
#endif
|
|
|
|
|
2022-03-11 15:52:32 +01:00
|
|
|
/* Initialize the console device driver (if it is other than the standard
|
|
|
|
* serial driver).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(CONFIG_LWL_CONSOLE)
|
|
|
|
lwlconsole_init();
|
|
|
|
#elif defined(CONFIG_CONSOLE_SYSLOG)
|
|
|
|
syslog_console_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PSEUDOTERM_SUSV1
|
|
|
|
/* Register the master pseudo-terminal multiplexor device */
|
|
|
|
|
|
|
|
ptmx_register();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_CRYPTO)
|
|
|
|
/* Initialize the HW crypto and /dev/crypto */
|
|
|
|
|
|
|
|
up_cryptoinitialize();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_CRYPTO_CRYPTODEV
|
|
|
|
devcrypto_register();
|
|
|
|
#endif
|
|
|
|
|
2022-03-19 16:37:11 +01:00
|
|
|
#ifdef CONFIG_UINPUT_TOUCH
|
2022-03-19 16:58:19 +01:00
|
|
|
uinput_touch_initialize();
|
2022-03-19 16:37:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_UINPUT_BUTTONS
|
2022-03-19 16:58:19 +01:00
|
|
|
uinput_button_initialize();
|
2022-03-19 16:37:11 +01:00
|
|
|
#endif
|
|
|
|
|
2022-03-19 17:18:46 +01:00
|
|
|
#ifdef CONFIG_UINPUT_KEYBOARD
|
|
|
|
uinput_keyboard_initialize();
|
|
|
|
#endif
|
|
|
|
|
2022-03-11 15:52:32 +01:00
|
|
|
#ifdef CONFIG_NET_LOOPBACK
|
|
|
|
/* Initialize the local loopback device */
|
|
|
|
|
|
|
|
localhost_initialize();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_TUN
|
|
|
|
/* Initialize the TUN device */
|
|
|
|
|
|
|
|
tun_initialize();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_NETDEV_TELNET
|
|
|
|
/* Initialize the Telnet session factory */
|
|
|
|
|
|
|
|
telnet_initialize();
|
|
|
|
#endif
|
2022-04-14 06:21:45 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_USENSOR
|
|
|
|
usensor_initialize();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SENSORS_RPMSG
|
|
|
|
sensor_rpmsg_initialize();
|
|
|
|
#endif
|
2022-08-09 10:20:26 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEV_RPMSG_SERVER
|
|
|
|
rpmsgdev_server_init();
|
|
|
|
#endif
|
2022-09-05 03:46:44 +02:00
|
|
|
|
2022-10-26 07:14:49 +02:00
|
|
|
#ifdef CONFIG_BLK_RPMSG_SERVER
|
|
|
|
rpmsgblk_server_init();
|
|
|
|
#endif
|
|
|
|
|
2022-09-05 03:46:44 +02:00
|
|
|
#ifdef CONFIG_RPMSGMTD_SERVER
|
|
|
|
rpmsgmtd_server_init();
|
|
|
|
#endif
|
2023-01-03 03:54:07 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_NET_USRSOCK_RPMSG_SERVER
|
|
|
|
/* Initialize the user socket rpmsg server */
|
|
|
|
|
|
|
|
usrsock_rpmsg_server_initialize();
|
|
|
|
#endif
|
2023-01-29 16:43:43 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMART_DEV_LOOP
|
|
|
|
smart_loop_register_driver();
|
|
|
|
#endif
|
2023-02-06 16:05:12 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_MTD_LOOP
|
|
|
|
mtd_loop_register();
|
|
|
|
#endif
|
2023-03-22 04:49:43 +01:00
|
|
|
|
2024-03-11 17:15:05 +01:00
|
|
|
#if defined(CONFIG_PCI) && !defined(CONFIG_PCI_LATE_DRIVERS_REGISTER)
|
2024-08-27 06:08:33 +02:00
|
|
|
pci_register_drivers();
|
|
|
|
#endif
|
|
|
|
|
2023-03-22 04:49:43 +01:00
|
|
|
#ifdef CONFIG_DRIVERS_VIRTIO
|
|
|
|
virtio_register_drivers();
|
|
|
|
#endif
|
2023-02-22 04:08:22 +01:00
|
|
|
|
2023-11-20 14:23:56 +01:00
|
|
|
#ifndef CONFIG_DEV_OPTEE_NONE
|
|
|
|
optee_register();
|
|
|
|
#endif
|
|
|
|
|
2023-10-13 17:10:56 +02:00
|
|
|
#ifdef CONFIG_THERMAL
|
|
|
|
thermal_init();
|
|
|
|
#endif
|
|
|
|
|
2023-02-22 04:08:22 +01:00
|
|
|
drivers_trace_end();
|
2022-03-11 15:52:32 +01:00
|
|
|
}
|