zephyr/drivers/ps2/ps2_npcx_controller.h
Jun Lin ba39c47187 driver: PS/2: npcx: add driver support for Nuvoton npcx family
The PS/2 module in npcx provides a hardware accelerator mechanism
including an 8-bit shift register, a state machine, and control logic
that handle both the incoming and outgoing data. The hardware
accelerator mechanism is shared by 4 PS/2 channels. To support it,
this CL separates the PS/2 driver into channel and controller drivers.
The controller driver is in charge of the PS/2 transaction. The channel
driver is in charge of the connection between the Zehpyr PS/2 API
interface and controller driver.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2021-07-02 15:41:28 -04:00

59 lines
1.7 KiB
C

/*
* Copyright (c) 2021 Nuvoton Technology Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_DRIVERS_PS2_PS2_NPCX_CONTROLLER_H_
#define ZEPHYR_DRIVERS_PS2_PS2_NPCX_CONTROLLER_H_
#include <device.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Write @p value to a PS/2 device via the PS/2 controller.
*
* @param dev Pointer to the device structure for PS/2 controller instance.
* @param channel_id Channel ID of the PS/2 to write data.
* @param value the data write to the PS/2 device.
*
* @retval 0 If successful.
* @retval -EINVAL Channel ID is invlaid.
* @retval -ETIMEDOUT Timeout occurred for a PS/2 write transaction.
*/
int ps2_npcx_ctrl_write(const struct device *dev, uint8_t channel_id,
uint8_t value);
/**
* @brief Set the PS/2 controller to turn on/off the PS/2 channel.
*
* @param dev Pointer to the device structure for PS/2 controller instance.
* @param channel_id Channel ID of the PS/2 to enable or disable.
* @param enable True to enable channel, false to disable channel.
*
* @retval 0 If successful.
* @retval -EINVAL Channel ID is invlaid.
*/
int ps2_npcx_ctrl_enable_interface(const struct device *dev, uint8_t channel,
bool enable);
/**
* @brief Record the callback_isr function pointer for the given PS/2 channel.
*
* @param dev Pointer to the device structure for PS/2 controller instance.
* @param channel_id Channel ID of the PS/2 to configure the callback_isr.
* @param callback_isr Pointer to the callback_isr.
*
* @retval 0 If successful.
* @retval -EINVAL callback_isr is NULL.
*/
int ps2_npcx_ctrl_configure(const struct device *dev, uint8_t channel_id,
ps2_callback_t callback_isr);
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_DRIVERS_PS2_PS2_NPCX_CONTROLLER_H_ */