API: eSPI: Add two more APIs for eSPI

eSPI is an aggregator device which is used by other blocks
to communicate with the master. This new APIs allows LPC
peripherals to communicate with eSPI master.

Signed-off-by: Francisco Munoz <francisco.munoz.ruiz@intel.com>
This commit is contained in:
Francisco Munoz 2019-10-18 13:58:37 -07:00 committed by Anas Nashif
commit 11f01dd682

View file

@ -135,6 +135,9 @@ enum espi_bus_event {
#define ESPI_PERIPHERAL_NODATA 0ul #define ESPI_PERIPHERAL_NODATA 0ul
#define E8042_START_OPCODE 0x50
#define E8042_MAX_OPCODE 0x5F
/** @endcond */ /** @endcond */
/** /**
@ -145,7 +148,7 @@ enum espi_bus_event {
*/ */
enum espi_virtual_peripheral { enum espi_virtual_peripheral {
ESPI_PERIPHERAL_UART, ESPI_PERIPHERAL_UART,
ESPI_PERIPHERAL_8042_KEYBOARD, ESPI_PERIPHERAL_8042_KBC,
ESPI_PERIPHERAL_HOST_IO, ESPI_PERIPHERAL_HOST_IO,
ESPI_PERIPHERAL_DEBUG_PORT80 ESPI_PERIPHERAL_DEBUG_PORT80
}; };
@ -205,6 +208,20 @@ enum espi_vwire_signal {
ESPI_VWIRE_SIGNAL_SUS_ACK, ESPI_VWIRE_SIGNAL_SUS_ACK,
}; };
/* eSPI LPC peripherals. */
enum lpc_peripheral_opcode {
/* Read transactions */
E8042_OBF_HAS_CHAR = 0x50,
E8042_IBF_HAS_CHAR,
/* Write transactions */
E8042_WRITE_KB_CHAR,
E8042_WRITE_MB_CHAR,
/* Write transactions without input parameters */
E8042_RESUME_IRQ,
E8042_PAUSE_IRQ,
E8042_CLEAR_OBF,
};
/** /**
* @brief eSPI event * @brief eSPI event
*/ */
@ -313,6 +330,10 @@ typedef int (*espi_api_read_request)(struct device *dev,
struct espi_request_packet); struct espi_request_packet);
typedef int (*espi_api_write_request)(struct device *dev, typedef int (*espi_api_write_request)(struct device *dev,
struct espi_request_packet); struct espi_request_packet);
typedef int (*espi_api_lpc_read_request)(struct device *dev,
enum lpc_peripheral_opcode op, u32_t *data);
typedef int (*espi_api_lpc_write_request)(struct device *dev,
enum lpc_peripheral_opcode op, u32_t *data);
/* Logical Channel 1 APIs */ /* Logical Channel 1 APIs */
typedef int (*espi_api_send_vwire)(struct device *dev, typedef int (*espi_api_send_vwire)(struct device *dev,
enum espi_vwire_signal vw, enum espi_vwire_signal vw,
@ -339,9 +360,11 @@ typedef int (*espi_api_manage_callback)(struct device *dev,
struct espi_driver_api { struct espi_driver_api {
espi_api_config config; espi_api_config config;
espi_api_get_channel_status get_channel_status; espi_api_get_channel_status get_channel_status;
espi_api_read_request read_request; espi_api_read_request read_request;
espi_api_write_request write_request; espi_api_write_request write_request;
espi_api_lpc_read_request read_lpc_request;
espi_api_lpc_write_request write_lpc_request;
espi_api_send_vwire send_vwire; espi_api_send_vwire send_vwire;
espi_api_receive_vwire receive_vwire; espi_api_receive_vwire receive_vwire;
espi_api_send_oob send_oob; espi_api_send_oob send_oob;
@ -477,7 +500,7 @@ static inline int z_impl_espi_read_request(struct device *dev,
* @retval 0 If successful. * @retval 0 If successful.
* @retval -ENOTSUP if eSPI controller doesn't support raw packets and instead * @retval -ENOTSUP if eSPI controller doesn't support raw packets and instead
* low memory transactions are handled by controller hardware directly. * low memory transactions are handled by controller hardware directly.
* @retval -EIO General input / output error, failed to send over the bus. * @retval -EINVAL General input / output error, failed to send over the bus.
*/ */
__syscall int espi_write_request(struct device *dev, __syscall int espi_write_request(struct device *dev,
struct espi_request_packet req); struct espi_request_packet req);
@ -495,6 +518,72 @@ static inline int z_impl_espi_write_request(struct device *dev,
return api->write_request(dev, req); return api->write_request(dev, req);
} }
/**
* @brief Reads SOC data from a LPC peripheral with information
* updated over eSPI.
*
* This routine provides a generic interface to read a block whose
* information was updated by an eSPI transaction. Reading may trigger
* a transaction. The eSPI packet is assembled by the HW block.
*
* @param dev Pointer to the device structure for the driver instance.
* @param op Enum representing opcode for peripheral type and read request.
* @param data Parameter to be read from to the LPC peripheral.
*
* @retval 0 If successful.
* @retval -ENOTSUP if eSPI peripheral is off or not supported.
* @retval -EINVAL for unimplemented lpc opcode, but in range.
*/
__syscall int espi_read_lpc_request(struct device *dev,
enum lpc_peripheral_opcode op, u32_t *data);
static inline int z_impl_espi_read_lpc_request(struct device *dev,
enum lpc_peripheral_opcode op,
u32_t *data)
{
const struct espi_driver_api *api =
(const struct espi_driver_api *)dev->driver_api;
if (!api->read_lpc_request) {
return -ENOTSUP;
}
return api->read_lpc_request(dev, op, data);
}
/**
* @brief Writes data to a LPC peripheral which generates an eSPI transaction.
*
* This routine provides a generic interface to write data to a block which
* triggers an eSPI transacion. The eSPI packet is assembled by the HW
* block.
*
* @param dev Pointer to the device structure for the driver instance.
* @param op Enum representing an opcode for peripheral type and write request.
* @param data Represents the parameter passed to the LPC peripheral.
*
* @retval 0 If successful.
* @retval -ENOTSUP if eSPI peripheral is off or not supported.
* @retval -EINVAL for unimplemented lpc opcode, but in range.
*/
__syscall int espi_write_lpc_request(struct device *dev,
enum lpc_peripheral_opcode op,
u32_t *data);
static inline int z_impl_espi_write_lpc_request(struct device *dev,
enum lpc_peripheral_opcode op,
u32_t *data)
{
const struct espi_driver_api *api =
(const struct espi_driver_api *)dev->driver_api;
if (!api->write_lpc_request) {
return -ENOTSUP;
}
return api->write_lpc_request(dev, op, data);
}
/** /**
* @brief Sends system/platform signal as a virtual wire packet. * @brief Sends system/platform signal as a virtual wire packet.
* *