Skip to content

Commit 65dc181

Browse files
committed
soc: riscv: telink_w91: create icmsg workqueue instead of system
Resolved IPC system workqueue conflict with drivers/samples Signed-off-by: Alex Tsitsiura <s07641069@gmail.com>
1 parent 0debef0 commit 65dc181

File tree

8 files changed

+71
-3
lines changed

8 files changed

+71
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_GPIO=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2024 Telink Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
key_matrix {
9+
compatible = "gpio-keys";
10+
11+
col {
12+
gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>,
13+
<&gpio0 17 GPIO_ACTIVE_HIGH>;
14+
};
15+
16+
row {
17+
gpios = <&gpio0 16 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
18+
<&gpio0 15 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
19+
};
20+
};
21+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_GPIO=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2024 Telink Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
/* Short TL_Key1 (J20 pin 11) to ground (J20 pin 25-35) */
9+
key_pool{
10+
compatible = "gpio-keys";
11+
12+
inp {
13+
gpios = <&gpio0 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
14+
<&gpio0 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
15+
};
16+
};
17+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_GPIO=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Telink Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
led_pool{
9+
compatible = "gpio-leds";
10+
11+
out {
12+
gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>,
13+
<&gpio0 19 GPIO_ACTIVE_HIGH>;
14+
};
15+
};
16+
};

soc/riscv/riscv-privilege/telink_w91/ipc/Kconfig.ipc

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ config TELINK_W91_IPC_DISPATCHER_BOUND_TIMEOUT_MS
4545
config IPC_SERVICE_ICMSG_CB_BUF_SIZE
4646
default 1024
4747

48+
config IPC_SERVICE_ICMSG_WORK_QUEUE_STACK_SIZE
49+
int "ICMSG work queue stack size"
50+
default 1024
51+
4852
if SPSC_PBUF_CACHE_FLAG || SPSC_PBUF_CACHE_ALWAYS
4953

5054
config SPSC_PBUF_REMOTE_DCACHE_LINE

subsys/ipc/ipc_service/lib/icmsg.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#define SEND_BUFFER_UNUSED 0
2121
#define SEND_BUFFER_RESERVED 1
2222

23+
static struct k_work_q icmsg_work_queue;
24+
K_THREAD_STACK_DEFINE(icmsg_work_queue_stack, CONFIG_IPC_SERVICE_ICMSG_WORK_QUEUE_STACK_SIZE);
25+
2326
static const uint8_t magic[] = {0x45, 0x6d, 0x31, 0x6c, 0x31, 0x4b,
2427
0x30, 0x72, 0x6e, 0x33, 0x6c, 0x69, 0x34};
2528
BUILD_ASSERT(sizeof(magic) <= RX_BUF_SIZE);
@@ -59,7 +62,7 @@ static void notify_process(struct k_work *item)
5962
if (state != ICMSG_STATE_READY) {
6063
int ret;
6164

62-
ret = k_work_reschedule(dwork, BOND_NOTIFY_REPEAT_TO);
65+
ret = k_work_reschedule_for_queue(&icmsg_work_queue, dwork, BOND_NOTIFY_REPEAT_TO);
6366
__ASSERT_NO_MSG(ret >= 0);
6467
(void)ret;
6568
}
@@ -127,7 +130,7 @@ static bool is_rx_data_available(struct icmsg_data_t *dev_data)
127130

128131
static void submit_mbox_work(struct icmsg_data_t *dev_data)
129132
{
130-
if (k_work_submit(&dev_data->mbox_work) < 0) {
133+
if (k_work_submit_to_queue(&icmsg_work_queue, &dev_data->mbox_work) < 0) {
131134
/* The mbox processing work is never canceled.
132135
* The negative error code should never be seen.
133136
*/
@@ -211,6 +214,10 @@ static int mbox_init(const struct icmsg_config_t *conf,
211214
{
212215
int err;
213216

217+
k_work_queue_start(&icmsg_work_queue, icmsg_work_queue_stack,
218+
K_THREAD_STACK_SIZEOF(icmsg_work_queue_stack),
219+
CONFIG_SYSTEM_WORKQUEUE_PRIORITY, NULL);
220+
214221
k_work_init(&dev_data->mbox_work, mbox_callback_process);
215222
k_work_init_delayable(&dev_data->notify_work, notify_process);
216223

@@ -263,7 +270,7 @@ int icmsg_open(const struct icmsg_config_t *conf,
263270
return ret;
264271
}
265272

266-
ret = k_work_schedule(&dev_data->notify_work, K_NO_WAIT);
273+
ret = k_work_schedule_for_queue(&icmsg_work_queue, &dev_data->notify_work, K_NO_WAIT);
267274
if (ret < 0) {
268275
return ret;
269276
}

0 commit comments

Comments
 (0)