1 /*
2  * Copyright (c) 2021 Nuvoton Technology Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_DRIVERS_PS2_PS2_NPCX_CONTROLLER_H_
8 #define ZEPHYR_DRIVERS_PS2_PS2_NPCX_CONTROLLER_H_
9 
10 #include <zephyr/device.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * @brief Write @p value to a PS/2 device via the PS/2 controller.
18  *
19  * @param dev Pointer to the device structure for PS/2 controller instance.
20  * @param channel_id Channel ID of the PS/2 to write data.
21  * @param value the data write to the PS/2 device.
22  *
23  * @retval 0 If successful.
24  * @retval -EINVAL Channel ID is invalid.
25  * @retval -ETIMEDOUT Timeout occurred for a PS/2 write transaction.
26  */
27 int ps2_npcx_ctrl_write(const struct device *dev, uint8_t channel_id,
28 			uint8_t value);
29 
30 /**
31  * @brief Set the PS/2 controller to turn on/off the PS/2 channel.
32  *
33  * @param dev Pointer to the device structure for PS/2 controller instance.
34  * @param channel_id Channel ID of the PS/2 to enable or disable.
35  * @param enable True to enable channel, false to disable channel.
36  *
37  * @retval 0 If successful.
38  * @retval -EINVAL Channel ID is invalid.
39  */
40 int ps2_npcx_ctrl_enable_interface(const struct device *dev, uint8_t channel,
41 				   bool enable);
42 
43 /**
44  * @brief Record the callback_isr function pointer for the given PS/2 channel.
45  *
46  * @param dev Pointer to the device structure for PS/2 controller instance.
47  * @param channel_id Channel ID of the PS/2 to configure the callback_isr.
48  * @param callback_isr Pointer to the callback_isr.
49  *
50  * @retval 0 If successful.
51  * @retval -EINVAL callback_isr is NULL.
52  */
53 int ps2_npcx_ctrl_configure(const struct device *dev, uint8_t channel_id,
54 			    ps2_callback_t callback_isr);
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 #endif /* ZEPHYR_DRIVERS_PS2_PS2_NPCX_CONTROLLER_H_ */
60