Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion boards/riscv/tl321x/tl3218x-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@
};
storage_partition: partition@f4000 {
label = "storage";
reg = <0xf4000 0x0000a000>;
reg = <0xf4000 0x00009000>;
};
user_para_partition: partition@fd000 {
label = "user-para";
reg = <0xfd000 0x1000>;
};

/* region <0xfe000 0x2000> is used for Telink TLx RF parameters */
Expand Down
6 changes: 5 additions & 1 deletion boards/riscv/tl721x/tl7218x-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@
};
storage_partition: partition@f4000 {
label = "storage";
reg = <0xf4000 0x0000a000>;
reg = <0xf4000 0x00009000>;
};
user_para_partition: partition@fd000 {
label = "user-para";
reg = <0xfd000 0x1000>;
};

/* region <0xfe000 0x2000> is used for Telink TLx RF parameters */
Expand Down
6 changes: 5 additions & 1 deletion boards/riscv/tlsr9528a/tlsr9528a-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@
};
storage_partition: partition@f4000 {
label = "storage";
reg = <0xf4000 0x0000a000>;
reg = <0xf4000 0x00009000>;
};
user_para_partition: partition@fd000 {
label = "user-para";
reg = <0xfd000 0x1000>;
};

/* region <0xfe000 0x2000> is used for Telink B9x RF parameters */
Expand Down
14 changes: 14 additions & 0 deletions drivers/gpio/gpio_b9x.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,20 @@ static void gpio_b9x_irq_connect_4(void)
}
#endif

#if CONFIG_SOC_RISCV_TELINK_B92
/* If instance 5 is present and has interrupt enabled, connect IRQ */
#if DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) > 5
static void gpio_b9x_irq_connect_5(void)
{
#if IS_INST_IRQ_EN(5)
IRQ_CONNECT(DT_INST_IRQN(5), DT_INST_IRQ(5, priority),
gpio_b9x_irq_handler,
DEVICE_DT_INST_GET(5), 0);
#endif
}
#endif
#endif

#if CONFIG_PM_DEVICE && CONFIG_SOC_SERIES_RISCV_TELINK_B9X_RETENTION
#define PM_DEVICE_INST_DEFINE(n, gpio_b9x_pm_action) \
PM_DEVICE_DT_INST_DEFINE(n, gpio_b9x_pm_action);
Expand Down
17 changes: 17 additions & 0 deletions drivers/watchdog/wdt_b9x.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#define DT_DRV_COMPAT telink_b9x_watchdog

#include <zephyr/kernel.h>
#include <clock.h>
#include <watchdog.h>
#include <zephyr/drivers/watchdog.h>
Expand All @@ -20,14 +21,29 @@
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

struct k_timer WdtTimer;

void WdtTimerTimeoutCallback(struct k_timer *timer)
{
if (!timer) {
return;
}
/*printk("Interval:(%d)ms to feeding watchdog\n", CONFIG_TELINK_WDT_FEED_TIME);*/
wd_clear_cnt();
}

static int wdt_b9x_setup(const struct device *dev, uint8_t options)
{
ARG_UNUSED(dev);
ARG_UNUSED(options);

wd_stop();
wd_start();

k_timer_stop(&WdtTimer);
k_timer_init(&WdtTimer, &WdtTimerTimeoutCallback, NULL);
k_timer_start(&WdtTimer, K_MSEC(CONFIG_TELINK_WDT_FEED_TIME),
K_MSEC(CONFIG_TELINK_WDT_FEED_TIME));
LOG_INF("HW watchdog started");

return 0;
Expand All @@ -38,6 +54,7 @@ static int wdt_b9x_disable(const struct device *dev)
ARG_UNUSED(dev);

wd_stop();
k_timer_stop(&WdtTimer);

LOG_INF("HW watchdog stopped");

Expand Down
17 changes: 17 additions & 0 deletions drivers/watchdog/wdt_tlx.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#define DT_DRV_COMPAT telink_tlx_watchdog

#include <zephyr/kernel.h>
#include <clock.h>
#include <watchdog.h>
#include <zephyr/drivers/watchdog.h>
Expand All @@ -20,14 +21,29 @@
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

struct k_timer WdtTimer;

void WdtTimerTimeoutCallback(struct k_timer *timer)
{
if (!timer) {
return;
}
/*printk("Interval:(%d)ms to feeding watchdog\n", CONFIG_TELINK_WDT_FEED_TIME);*/
wd_clear_cnt();
}

static int wdt_tlx_setup(const struct device *dev, uint8_t options)
{
ARG_UNUSED(dev);
ARG_UNUSED(options);

wd_stop();
wd_start();

k_timer_stop(&WdtTimer);
k_timer_init(&WdtTimer, &WdtTimerTimeoutCallback, NULL);
k_timer_start(&WdtTimer, K_MSEC(CONFIG_TELINK_WDT_FEED_TIME),
K_MSEC(CONFIG_TELINK_WDT_FEED_TIME));
LOG_INF("HW watchdog started");

return 0;
Expand All @@ -38,6 +54,7 @@ static int wdt_tlx_disable(const struct device *dev)
ARG_UNUSED(dev);

wd_stop();
k_timer_stop(&WdtTimer);

LOG_INF("HW watchdog stopped");

Expand Down
52 changes: 52 additions & 0 deletions kernel/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ static void z_sys_init_run_level(enum init_level level)

extern void boot_banner(void);

#if CONFIG_WATCHDOG
#include <watchdog.h>
#include <zephyr/drivers/watchdog.h>
#include "ext_driver/ext_pm.h"
#if CONFIG_SOC_RISCV_TELINK_B92
#include "lib/include/pm.h"
#elif CONFIG_SOC_RISCV_TELINK_TL321X || CONFIG_SOC_RISCV_TELINK_TL721X
#include "lib/include/pm/pm.h"
#endif /* CONFIG_SOC_RISCV_TELINK_B92 */
#endif /* CONFIG_WATCHDOG */

/**
* @brief Mainline for kernel's background thread
*
Expand Down Expand Up @@ -338,6 +349,47 @@ static void bg_thread_main(void *unused1, void *unused2, void *unused3)
z_mem_manage_boot_finish();
#endif /* CONFIG_MMU */

#if CONFIG_WATCHDOG && CONFIG_MCUBOOT
#if CONFIG_SOC_RISCV_TELINK_B92
if ((pm_get_mcu_status() == MCU_STATUS_REBOOT_BACK) && wd_get_status())
#elif CONFIG_SOC_RISCV_TELINK_TL321X || CONFIG_SOC_RISCV_TELINK_TL721X
/* Needs to be manually refresh MCU status */
pm_update_status_info(1);

if (pm_get_mcu_status() == MCU_HW_REBOOT_TIMER_WATCHDOG)
#endif /* CONFIG_SOC_RISCV_TELINK_B92 */
{
printk("### Watchdog Reset ###\r\n");
}
#endif /* CONFIG_WATCHDOG && CONFIG_MCUBOOT */

#if CONFIG_WATCHDOG
int err;
int wdt_channel_id;
const struct device *const wdt = DEVICE_DT_GET(DT_ALIAS(watchdog0));

struct wdt_timeout_cfg wdt_config = {
/* Reset SoC when watchdog timer expires. */
.flags = WDT_FLAG_RESET_SOC,

/* Expire watchdog after max window */
.window.min = 0,
.window.max = CONFIG_TELINK_WDT_TIMEOUT,
};

wdt_channel_id = wdt_install_timeout(wdt, &wdt_config);
if (wdt_channel_id < 0) {
printk("Watchdog install error\n");
return;
}

err = wdt_setup(wdt, WDT_OPT_PAUSE_HALTED_BY_DBG);
if (err < 0) {
printk("Watchdog setup error\n");
return;
}
#endif /* CONFIG_WATCHDOG */

extern int main(void);

(void)main();
Expand Down
24 changes: 22 additions & 2 deletions soc/riscv/riscv-privilege/telink_b9x/Kconfig.soc
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,31 @@ config COMPRESS_LZMA
select BOOT_IMAGE_ACCESS_HOOKS
depends on BOOTLOADER_MCUBOOT || MCUBOOT
help
This option enables LZMA compression with MCUBoot
This option enables LZMA compression with MCUBoot

config COMPRESS_LZMA_DICTIONARY_SIZE
int "Set LZMA compression dictionary size"
default 32768
depends on COMPRESS_LZMA
help
This option sets LZMA compression dictionary size
This option sets LZMA compression dictionary size

config DUAL_MODE
bool "Support dual-mode switch"
default n
help
This option enables dual mode

config TELINK_WDT_TIMEOUT
int "Watchdog timeout in milliseconds"
depends on WATCHDOG
default 30000
help
This option supports setting the watchdog timeout

config TELINK_WDT_FEED_TIME
int "Feed watchdog time in milliseconds"
depends on WATCHDOG
default 1000
help
This option supports feeding the watchdog
11 changes: 11 additions & 0 deletions soc/riscv/riscv-privilege/telink_b9x/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ static int soc_b9x_init(void)
blc_pm_select_internal_32k_crystal();
#endif /* CONFIG_PM */

/* Clean rf module after switch from zigbee */
#if CONFIG_DUAL_MODE
/* Reset Radio */
rf_radio_reset();
#if CONFIG_SOC_RISCV_TELINK_B91 || CONFIG_SOC_RISCV_TELINK_B92
rf_reset_dma();
rf_baseband_reset();
#endif /* CONFIG_SOC_RISCV_TELINK_B91 || CONFIG_SOC_RISCV_TELINK_B92 */
rf_clr_irq_status(FLD_RF_IRQ_ALL);
#endif /* CONFIG_DUAL_MODE */

/* system init */
#if CONFIG_SOC_RISCV_TELINK_B91
sys_init(POWER_MODE, VBAT_TYPE);
Expand Down
24 changes: 22 additions & 2 deletions soc/riscv/riscv-privilege/telink_tlx/Kconfig.soc
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,31 @@ config COMPRESS_LZMA
select BOOT_IMAGE_ACCESS_HOOKS
depends on BOOTLOADER_MCUBOOT || MCUBOOT
help
This option enables LZMA compression with MCUBoot
This option enables LZMA compression with MCUBoot

config COMPRESS_LZMA_DICTIONARY_SIZE
int "Set LZMA compression dictionary size"
default 32768
depends on COMPRESS_LZMA
help
This option sets LZMA compression dictionary size
This option sets LZMA compression dictionary size

config DUAL_MODE
bool "Support dual-mode switch"
default n
help
This option enables dual mode

config TELINK_WDT_TIMEOUT
int "Watchdog timeout in milliseconds"
depends on WATCHDOG
default 30000
help
This option supports setting the watchdog timeout

config TELINK_WDT_FEED_TIME
int "Feed watchdog time in milliseconds"
depends on WATCHDOG
default 1000
help
This option supports feeding the watchdog
11 changes: 11 additions & 0 deletions soc/riscv/riscv-privilege/telink_tlx/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ static int soc_tlx_init(void)
blc_pm_select_internal_32k_crystal();
#endif /* CONFIG_PM */

/* Clean rf module after switch from zigbee */
#if CONFIG_DUAL_MODE
/* Reset Radio */
rf_radio_reset();
#if CONFIG_SOC_RISCV_TELINK_TL321X || CONFIG_SOC_RISCV_TELINK_TL721X
rf_reset_dma();
rf_baseband_reset();
#endif /* CONFIG_SOC_RISCV_TELINK_TL321X || CONFIG_SOC_RISCV_TELINK_TL721X */
rf_clr_irq_status(FLD_RF_IRQ_ALL);
#endif /* CONFIG_DUAL_MODE */

/* system init */
sys_init(POWER_MODE, VBAT_TYPE, INTERNAL_CAP_XTAL24M);

Expand Down
5 changes: 3 additions & 2 deletions west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ manifest:
- hal
- name: hal_telink
url: https://github.com/telink-semi/hal_telink
revision: 72cff600a9a60d84761e6ece823b0725001a43b6
revision: 2abd901ef24eb46c3fb0b44b8db04bccfea793ba
path: modules/hal/telink
groups:
- hal
Expand Down Expand Up @@ -193,7 +193,8 @@ manifest:
groups:
- crypto
- name: mcuboot
revision: 1558e7ab0aadb4eac11f03befb5ccd3fa3f0aafe
url: https://github.com/telink-semi/mcuboot
revision: 9c8c7cdfe264e9d07e47c624c91581407bc0c538
path: bootloader/mcuboot
- name: mipi-sys-t
path: modules/debug/mipi-sys-t
Expand Down