Commit Graph

261 Commits

Author SHA1 Message Date
yintao 37a30023f5 nuttx/drivers: add ept_release_cb for destroy server resource
use ept_release_cb to destory rpmsg services server dile resource
to avoid the used-after-free issue

Signed-off-by: yintao <yintao@xiaomi.com>
2024-10-10 08:44:29 +08:00
liwenxiang1 fa48d9e972 drivers/timers:Arch_alarm and arch_timer add up_ndelay interface
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2024-10-09 22:11:03 +08:00
buxiasen a6b12eb29c goldfinsh: fix timer compile issue
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 15:27:33 +08:00
ligd 39bfdb95e1 timers: add goldfish timer support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-08 15:27:33 +08:00
ligd aff700f8ca timer: set g_timer.lower after TIMER_START()
in case of up_perf_gettime() get non-start value

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-08 08:59:39 +08:00
Xiang Xiao 7c839d7a09 rptun: Remove include/nuttx/rptun/openamp.h
and use include/nuttx/rpmsg/rpmsg.h instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-07 00:44:28 +08:00
Jukka Laitinen 6f7477ab63 drivers/timers/arch_alarm.c: Clean-up oneshot_callback for non-tickless build
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-09-30 19:23:01 +08:00
yangguangcai 9a84484df5 capture:add multiple register.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-09-28 13:11:52 +08:00
yangguangcai fd47add2a3 capture:add CAPIOC_ALL for ioctl.
When monitoring multiple capture channels, the `ioctl` function
is called three times, leading to significant overhead mainly due
to VFS and `nxmutex_lock/unlock`. Adding a new interface can save
the overhead of two `ioctl` calls.

Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-09-28 13:11:52 +08:00
ligd 6a2c03732f clock: Replace all ts and tick conversion functions
Using the ts/tick conversion functions provided in clock.h

Do this caused we want speed up the time calculation, so change:
clock_time2ticks, clock_ticks2time, clock_timespec_add,
clock_timespec_compare, clock_timespec_subtract... to MACRO

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd ccd87767da timers: add weak function up_timer_gettime()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-10 23:32:30 +08:00
yangguangcai 45625cbe3b timer driver:support poll.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-08-28 13:46:47 +08:00
yangguangcai 3fa6cfc41e rpmsg_rtc:Update g_basetime from rpmsg.
When ipc is busy, g_basetime may be inconsistent
on different cores.

Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-08-27 21:35:17 +08:00
yangguangcai 234c7d58bf rtc alarm:fix doesn't call nxsig_notification
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-08-27 10:18:10 -03:00
yangguangcai d6cd95313d pl031:change mktime to timegm.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-08-27 00:15:29 +08:00
zhangkai25 9e388d1d00 Capture adds the function of edges counting
Description: Add the function of counting cap edges

Signed-off-by: zhangkai25 <zhangkai25@xiaomi.com>
2024-08-24 11:18:05 +08:00
buxiasen 30188dc587 watchdog: fix idle callback maybe not upperhalf
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-06-08 11:59:26 +08:00
Michal Lenc 3cc65d5d35 timers/mcp794xx: add option to digital trimming
MCP794XX supports digital trimming that periodically adds or subtracts
clock cycles, resulting in small adjustments in the internal timing.
This way inaccuracies of clock source can be compensated.

This commit adds option to set the trimming register for MCP794XX.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2024-05-28 16:34:41 -03:00
Michal Lenc c59b48355c timers/mcp794xx: add possibility to store datetime in UTC
This commit adds configuration option CONFIG_MCP794XX_DATETIME_UTC.
If set, the datetime is stored in UTC instead of local time. The
default value is kept at local time to keep backwards compatibility
with devices currently using the RTC.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2024-05-28 16:34:41 -03:00
chao an 6d50274ebe nuttx/list: rename container_of to list_container_of from public header
Use private naming to avoid conflicts with user applications

In file included from libuv/src/unix/internal.h:25,
                 from libuv/src/unix/udp.c:23:
libuv/src/uv-common.h:57: warning: "container_of" redefined
   57 | #define container_of(ptr, type, member) \
      |
In file included from nuttx/include/nuttx/list.h:47,
                 from nuttx/include/nuttx/tls.h:40,
                 from nuttx/include/nuttx/sched.h:48,
                 from nuttx/include/nuttx/arch.h:87,
                 from nuttx/include/nuttx/userspace.h:35,
                 from nuttx/include/nuttx/mm/mm.h:30,
                 from nuttx/include/nuttx/kmalloc.h:34,
                 from nuttx/include/nuttx/lib/lib.h:31,
                 from nuttx/include/stdio.h:35,
                 from apps/system/libuv/libuv/include/uv.h:59,
                 from libuv/src/unix/udp.c:22:
nuttx/include/nuttx/nuttx.h:48: note: this is the location of the previous definition
   48 | #define container_of(ptr, type, member) \
      |

Signed-off-by: chao an <anchao@lixiang.com>
2024-02-29 19:44:54 +08:00
Bowen Wang 169f47beec rpmsg: make all the rpmsg services deponds on RPMSG
After decoupled the rpmsg and rptun, all the rpmsg service should
depends on the RPMSG.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-02-18 04:09:34 -08:00
Xiang Xiao 11b3adf17f drivers/rtc/rpmsg: Move clock_synchronize rpmsg_rtc_server_settime
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-20 13:28:09 +01:00
Xiang Xiao 67bff06a24 drivers/rtc: Skip clock_synchronize if settime return positive value
so driver implementer could call clock_synchronize by self

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-20 13:28:09 +01:00
Xiang Xiao e6ebcb62b1 drivers/rtc: Return -ENOTTY if lower half doesn't implement the corresponding callback
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-20 13:28:09 +01:00
Petteri Aimonen 1825f9534c adjtime: Rewrite implementation to work for RTC and tickless kernel
Previous adjtime() implementation was limited to adjusting system
timer tick period. This commit reimplements the internals to use
a kernel watchdog timer. Platform-independent part of the code now
works also for adjusting hires RTC and tickless timer rate.

User code facing API is unchanged. Architecture code API has changed:
up_adj_timer_period() is replaced by up_adjtime().

Other improvements:

- Support query of remaining adjustment by passing NULL to first
  argument of adjtime(). This matches Linux behavior.

- Improve resolution available for architecture driver, previously
  limited to 1 microsecond per tick. Now 1 nanosecond per second.
2023-11-14 19:47:40 -08:00
raiden00pl b565e28da3 Kconfigs: rename {Rpmsg|rpmsg} to RPMGS 2023-10-28 13:58:56 +08:00
Petro Karashchenko dbc37a0165 nuttx: fix nxstyle issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-16 14:17:47 +08:00
yinshengkai 15f88804ca drivers/alarm: modify the default precision of up_perf_gettime to ns
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-09-08 01:09:02 +03:00
zhangyuan21 aa9f15d635 arch_alarm: change tick to g_current_tick
When the system starts up, the hw count may not start counting from 0,
which can cause the processing time of the first oneshot handler to be
too long. Therefore, the current tick value should be set based on the
hw count during initialization.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-09-06 17:28:26 +08:00
Jukka Laitinen 7ec3cad5af drivers/timers/pcf85263.c: Fix compilation
Add the missing semicolons

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-09-06 12:20:57 +08:00
chao an 664927c86e mm/alloc: remove all unnecessary cast for alloc
Fix the minor style issue and remove unnecessary cast

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-30 14:34:20 +08:00
chao an b60f01a55b inode/i_private: remove all unnecessary cast for i_private
Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 08:58:07 +02:00
chao an 7aa45305b7 fs/inode: remove all unnecessary check for filep/inode
Since VFS layer already contains sanity checks, so remove unnecessary lower half checks

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 09:47:11 +08:00
Michal Lenc 00128ff2fe pwm: fix incorrect documentation for PWMIOC_SETCHARACTERISTICS IOCTL
Documentation for PWMIOC_SETCHARACTERISTICS ioctl command mentioned
that this command will neither start nor stop the pulsed output. This
however is incorrect as PWMIOC_SETCHARACTERISTICS command leads to
pwm_start() function which starts the pulsed output.

While this might not be the correct behaviour (I would probably welcome
the option to set PWM characteristics without starting the pulsed output)
it is the way the PWM driver is coded for many architectures. Future
enhancement might be to add function pwm_setchar() for example to just
set characteristics without starting the PWM output.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-08-24 01:37:40 +08:00
xucheng5 417207678e driver/capture : add capture debug, fixed compile warning
Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
2023-08-18 09:21:46 +02:00
xuxin19 f2f0d7fbad cmake:fix drivers build block during cmake reforming
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-08-16 22:38:52 +08:00
wangming9 c928acc9ff perf: The new configuration supports hardware performance counting
Adding the CONFIG_ARCH_PERF_EVENTS configuration to enable
hardware performance counting,solve the problem that some platform
hardware counting support is not perfect, you can choose to use
software interface.

This is configured using CONFIG_ARCH_PERF_EVENTS, so weak_functions
are removed to prevent confusion

To use hardware performance counting, must:
1. Configure CONFIG_ARCH_PERF_EVENTS, default selection
2. Call up_perf_init for initialization

Signed-off-by: wangming9 <wangming9@xiaomi.com>
2023-08-12 02:20:44 +08:00
Petro Karashchenko 1b0baa8337 nuttx: use lib_free for memory de-allocation after strdup or asprintf
The memory allocated with strdup and asprintf is done via lib_malloc
so we need to use lib_free to deallocate memory otherwise the assertion
"Free memory from the wrong heap" is hit with flat mode and user separated
heap enabled mode.

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-08 11:58:29 -03:00
yangguangcai 05af311e68 qemu:add qemu rtc driver.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2023-08-02 03:27:55 -07:00
Bowen Wang 835a2a8801 watchdog: add CONFIG_WATCHDOG_PANIC_NOTIFIER for panic notifier
wdog_notifier() will be called in _assert to keep the crash scene
as mush as possible, which is useful for debug.

But once disable the watchdog, the hardware watchdog can not reboot
the system too. If a crash happened in the _assert (e.g. the tcb sp
has been corrupted, system will crash again in tack stack dump),
system will crashing forever and can not reboot.

So add a config to disable this feature by default and can be enable
if anyone need it.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-07-31 14:45:18 +02:00
chao an ee6e2ce149 arch/perf: add ARCH_HAVE_PERF_EVENTS to support hardware perf events
The implementation of up_perf_*() is in a different static library in nuttx:

Hardware: libarch.a
Software: libdrivers.a (weak function)

Since functions with weak attributes cannot be correctly replaced in multiple static libraries,
this PR will use macros to replace whether the arch supports hardware perf events

Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-21 20:43:30 +08:00
yinshengkai 81553deb53 time: add up_perf_init weak_function
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-07-11 10:09:25 -03:00
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
simbit18 e4ffce3355 Fix Kconfig style
Remove spaces from Kconfig files
2023-05-23 00:03:25 +08:00
Fotis Panagiotopoulos 4231938892 rtc: Fix compiler warning in driver initialization. 2023-05-11 22:18:10 +03:00
Xiang Xiao 51dc67ad5f fs: Add g_ prefix for all global file_operations instances
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-04-24 16:13:29 +02:00
wangming9 a7fc26124d arch/arm64: the arm64 perf interface supports pmu
Summary:
- Support arm64 pmu api, Currently only the cycle counter function is supported.
- Using ARM64 PMU hardware capability to implement perf interface, modify all
  perf interface related code.
- Support for pmu init under smp.

Signed-off-by: wangming9 <wangming9@xiaomi.com>
2023-04-10 16:23:49 -03:00
zhangyuan21 443c4c46b0 arch_timer: fixed build issue when enable tickless
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-03-15 11:52:52 +01:00
Michal Lenc 88f3d89920 pwm: add configuration option for dead time generators
PWM drivers usually supports dead time generators that automatically
insert output activation delay for complementary PWM outputs. This
is usefull for some control purposes as control of H bridge for example.

This commit adds an application to driver interface that can be used
to set up those delays (if supported by the selected architecture)
directly from the application. The set up remains the same as for duty
cycle value.

The whole addition is by default disabled. It can be enabled by config
option PWM_DEADTIME.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-03-07 01:30:01 +08:00
Michal Lenc 333707e101 pwm: add PWM overwrite under CONFIG_PWM_OVERWRITE option
Generic drivers shoud not use architecture related config options like
CONFIG_SAMV7_PWM. This commit adds PWM pin overwrite under generic
configuration option CONFIG_PWM_OVERWRITE.

Now the overwrite can be used on other architectures as well or can be
completely disabled for SAMv7.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-02-19 00:16:41 +08:00