Skip to content

Commit

Permalink
drivers/reset: support rpmsg reset
Browse files Browse the repository at this point in the history
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
  • Loading branch information
Donny9 committed Sep 14, 2024
1 parent 401a06f commit 334fa7a
Show file tree
Hide file tree
Showing 6 changed files with 893 additions and 2 deletions.
5 changes: 5 additions & 0 deletions drivers/drivers_initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <nuttx/pci/pci.h>
#include <nuttx/power/pm.h>
#include <nuttx/power/regulator.h>
#include <nuttx/reset/reset-controller.h>
#include <nuttx/segger/rtt.h>
#include <nuttx/sensors/sensor.h>
#include <nuttx/serial/pty.h>
Expand Down Expand Up @@ -154,6 +155,10 @@ void drivers_initialize(void)
regulator_rpmsg_server_init();
#endif

#if defined(CONFIG_RESET_RPMSG)
reset_rpmsg_server_init();
#endif

/* Initialize the serial device driver */

#ifdef CONFIG_RPMSG_UART
Expand Down
7 changes: 7 additions & 0 deletions drivers/reset/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ menuconfig RESET
default n
---help---
This selection enables building of the "upper-half" reset driver.

config RESET_RPMSG
bool "Reset rpmsg driver support"
depends on RESET && RPTUN
default n
---help---
This selection enables rpmsg support for reset.
6 changes: 6 additions & 0 deletions drivers/reset/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ ifeq ($(CONFIG_RESET),y)

CSRCS += core.c

ifeq ($(CONFIG_RESET_RPMSG),y)

CSRCS += reset_rpmsg.c

endif

DEPPATH += --dep-path reset
VPATH += :reset
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)drivers$(DELIM)reset
Expand Down
35 changes: 35 additions & 0 deletions drivers/reset/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ reset_control_get_internal(FAR struct reset_controller_dev *rcdev,
unsigned int index, bool shared, bool acquired)
{
FAR struct reset_control *rstc;
int ret;

DEBUGASSERT(nxmutex_is_locked(&g_reset_list_mutex));

Expand Down Expand Up @@ -288,6 +289,21 @@ reset_control_get_internal(FAR struct reset_controller_dev *rcdev,
return NULL;
}

#if defined(CONFIG_RESET_RPMSG)

/* Only client defines this function */

if (rcdev->ops->acquire)
{
ret = rcdev->ops->acquire(rcdev, index, shared, acquired);
if (ret < 0)
{
kmm_free(rstc);
return NULL;
}
}
#endif

rstc->rcdev = rcdev;
list_add_after(&rcdev->reset_control_head, &rstc->list);
rstc->id = index;
Expand Down Expand Up @@ -317,6 +333,17 @@ static void reset_control_put_internal(FAR struct reset_control *rstc)
{
DEBUGASSERT(nxmutex_is_locked(&g_reset_list_mutex));
list_delete(&rstc->list);

#if defined(CONFIG_RESET_RPMSG)

/* Only client defines this function */

if (rstc->rcdev->ops->release)
{
rstc->rcdev->ops->release(rstc->rcdev, rstc->id);
}
#endif

kmm_free(rstc);
}
}
Expand Down Expand Up @@ -378,6 +405,14 @@ reset_controller_get_by_name(FAR const char *name)
}

nxmutex_unlock(&g_reset_list_mutex);

#if defined(CONFIG_RESET_RPMSG)
if (strchr(name, '/'))
{
return reset_rpmsg_get(name);
}
#endif

return NULL;
}

Expand Down
Loading

0 comments on commit 334fa7a

Please sign in to comment.