1# Host command handler functionality
2
3# Copyright (c) 2020 Google LLC
4# SPDX-License-Identifier: Apache-2.0
5
6menu "Host command handler subsystem"
7
8config EC_HOST_CMD
9	bool "Support Embedded Controller host command handler subsystem"
10	help
11	  Enable host command processing for embedded controllers on notebook
12	  computers.
13
14if EC_HOST_CMD
15
16module = EC_HC
17module-str = ec-host-commands
18source "subsys/logging/Kconfig.template.log_config"
19
20config EC_HOST_CMD_HANDLER_STACK_SIZE
21	int "Stack size for the EC host command handler thread"
22	default 800
23
24config EC_HOST_CMD_HANDLER_TX_BUFFER_SIZE
25	int "Buffer size in bytes for TX buffer shared by all EC host commands"
26	default 0 if EC_HOST_CMD_BACKEND_ESPI
27	default 0 if EC_HOST_CMD_BACKEND_SHI
28	default 256 if EC_HOST_CMD_BACKEND_UART
29	default 552 if EC_HOST_CMD_BACKEND_SPI
30	default 256
31	help
32	  Buffer size in bytes for TX buffer defined by the host command handler.
33	  Some backend layers can define their own buffer, so the size can be zero to
34	  avoid duplicating buffers. If multiple backends are used, the size has to be
35	  set by user to the largest one.
36
37config EC_HOST_CMD_HANDLER_RX_BUFFER_SIZE
38	int "Buffer size in bytes for RX buffer shared by all EC host commands"
39	default 256 if EC_HOST_CMD_BACKEND_ESPI
40	default 0 if EC_HOST_CMD_BACKEND_SHI
41	default 544 if EC_HOST_CMD_BACKEND_UART
42	default 544 if EC_HOST_CMD_BACKEND_SPI
43	default 256
44	help
45	  Buffer size in bytes for TX buffer defined by the host command handler.
46	  Some backend layers can define their own buffer, so the size can be zero to
47	  avoid duplicating buffers. If multiple backends are used, the size has to be
48	  set by user to the largest one.
49
50config EC_HOST_CMD_HANDLER_BUFFER_ALIGN
51	int "Memory alignment for the tx/rx buffers"
52	default DCACHE_LINE_SIZE if (DCACHE_LINE_SIZE > 0) && EC_HOST_CMD_BACKEND_USB
53	default 4
54	help
55	  Some interfaces need a special memory alignment to work properly. Use that config
56	  to specify the alignment.
57
58config EC_HOST_CMD_HANDLER_PRIO
59	int "Priority of host command task"
60	default 13
61	help
62	  Priority of the kernel task that handles the host commands.
63	  If the priority is too low (high in value), the host commands handler may be unable to
64	  process the command on time and the AP will abort the waiting for response and be unable
65	  to boot the system properly.
66
67config EC_HOST_CMD_INIT_PRIORITY
68	int "Initialization priority"
69	default 80
70	range 0 99
71	help
72	  Initialization priority for Host Command. It must be higher than the initialization
73	  priority of the used backend device.
74
75config EC_HOST_CMD_HANDLER_TX_BUFFER_DEF
76	bool
77	default y if EC_HOST_CMD_HANDLER_TX_BUFFER_SIZE > 0
78	help
79	  The handler defines common tx buffer
80
81config EC_HOST_CMD_HANDLER_RX_BUFFER_DEF
82	bool
83	default y if EC_HOST_CMD_HANDLER_RX_BUFFER_SIZE > 0
84	help
85	  The handler defines common rx buffer
86
87config EC_HOST_CMD_NOCACHE_BUFFERS
88	bool "Place RX and TX buffers in __nocache section"
89	default y if DCACHE && DMA
90	depends on EC_HOST_CMD_HANDLER_TX_BUFFER_DEF || EC_HOST_CMD_HANDLER_RX_BUFFER_DEF
91	help
92	  DMA is often use for communication, however it usually requires
93	  uncached memory. Add possibility to place the RX and TX buffers in the
94	  __nocache section.
95
96config EC_HOST_CMD_INITIALIZE_AT_BOOT
97	bool "Initialize the host command subsystem automacitlly"
98	default y
99	help
100	  Automatically initialize the host command subsystem with the chosen backend.
101	  The ec_host_cmd_init function is called by the chosen backend.
102
103config EC_HOST_CMD_DEDICATED_THREAD
104	bool "Create a new task for host command"
105	help
106	  The ec_host_cmd_init function creates a new thread dedicated for Host Command.
107	  Otherwise the ec_host_cmd_task function has to be called within another thread.
108
109config EC_HOST_CMD_IN_PROGRESS_STATUS
110	bool "Save status of last IN_PROGRESS command"
111	default y if EC_HOST_CMD_BACKEND_SHI
112	help
113	  Enable support for saving final status of a last command that has sent
114	  EC_HOST_CMD_IN_PROGRESS status. The saved status can be get with the
115	  ec_host_cmd_send_in_progress_status function.
116
117source "subsys/mgmt/ec_host_cmd/Kconfig.logging"
118source "subsys/mgmt/ec_host_cmd/backends/Kconfig"
119
120endif # EC_HOST_CMD
121
122endmenu
123