123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- #ifndef ZEPHYR_INCLUDE_DRIVERS_PECI_H_
- #define ZEPHYR_INCLUDE_DRIVERS_PECI_H_
- #include <errno.h>
- #include <zephyr/types.h>
- #include <stddef.h>
- #include <device.h>
- #include <dt-bindings/pwm/pwm.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- enum peci_error_code {
- PECI_GENERAL_SENSOR_ERROR = 0x8000,
- PECI_UNDERFLOW_SENSOR_ERROR = 0x8002,
- PECI_OVERFLOW_SENSOR_ERROR = 0x8003,
- };
- enum peci_command_code {
- PECI_CMD_PING = 0x00,
- PECI_CMD_GET_TEMP0 = 0x01,
- PECI_CMD_GET_TEMP1 = 0x02,
- PECI_CMD_RD_PCI_CFG0 = 0x61,
- PECI_CMD_RD_PCI_CFG1 = 0x62,
- PECI_CMD_WR_PCI_CFG0 = 0x65,
- PECI_CMD_WR_PCI_CFG1 = 0x66,
- PECI_CMD_RD_PKG_CFG0 = 0xA1,
- PECI_CMD_RD_PKG_CFG1 = 0xA,
- PECI_CMD_WR_PKG_CFG0 = 0xA5,
- PECI_CMD_WR_PKG_CFG1 = 0xA6,
- PECI_CMD_RD_IAMSR0 = 0xB1,
- PECI_CMD_RD_IAMSR1 = 0xB2,
- PECI_CMD_WR_IAMSR0 = 0xB5,
- PECI_CMD_WR_IAMSR1 = 0xB6,
- PECI_CMD_RD_PCI_CFG_LOCAL0 = 0xE1,
- PECI_CMD_RD_PCI_CFG_LOCAL1 = 0xE2,
- PECI_CMD_WR_PCI_CFG_LOCAL0 = 0xE5,
- PECI_CMD_WR_PCI_CFG_LOCAL1 = 0xE6,
- PECI_CMD_GET_DIB = 0xF7,
- };
- #define PECI_CC_RSP_SUCCESS (0x40U)
- #define PECI_CC_RSP_TIMEOUT (0x80U)
- #define PECI_CC_OUT_OF_RESOURCES_TIMEOUT (0x81U)
- #define PECI_CC_RESOURCES_LOWPWR_TIMEOUT (0x82U)
- #define PECI_CC_ILLEGAL_REQUEST (0x90U)
- #define PECI_PING_WR_LEN (0U)
- #define PECI_PING_RD_LEN (0U)
- #define PECI_PING_LEN (3U)
- #define PECI_GET_DIB_WR_LEN (1U)
- #define PECI_GET_DIB_RD_LEN (8U)
- #define PECI_GET_DIB_CMD_LEN (4U)
- #define PECI_GET_DIB_DEVINFO (0U)
- #define PECI_GET_DIB_REVNUM (1U)
- #define PECI_GET_DIB_DOMAIN_BIT_MASK (0x4U)
- #define PECI_GET_DIB_MAJOR_REV_MASK 0xF0
- #define PECI_GET_DIB_MINOR_REV_MASK 0x0F
- #define PECI_GET_TEMP_WR_LEN (1U)
- #define PECI_GET_TEMP_RD_LEN (2U)
- #define PECI_GET_TEMP_CMD_LEN (4U)
- #define PECI_GET_TEMP_LSB (0U)
- #define PECI_GET_TEMP_MSB (1U)
- #define PECI_GET_TEMP_ERR_MSB (0x80U)
- #define PECI_GET_TEMP_ERR_LSB_GENERAL (0x0U)
- #define PECI_GET_TEMP_ERR_LSB_RES (0x1U)
- #define PECI_GET_TEMP_ERR_LSB_TEMP_LO (0x2U)
- #define PECI_GET_TEMP_ERR_LSB_TEMP_HI (0x3U)
- #define PECI_RD_PKG_WR_LEN (5U)
- #define PECI_RD_PKG_LEN_BYTE (2U)
- #define PECI_RD_PKG_LEN_WORD (3U)
- #define PECI_RD_PKG_LEN_DWORD (5U)
- #define PECI_RD_PKG_CMD_LEN (8U)
- #define PECI_WR_PKG_RD_LEN (1U)
- #define PECI_WR_PKG_LEN_BYTE (7U)
- #define PECI_WR_PKG_LEN_WORD (8U)
- #define PECI_WR_PKG_LEN_DWORD (10U)
- #define PECI_WR_PKG_CMD_LEN (9U)
- #define PECI_RD_IAMSR_WR_LEN (5U)
- #define PECI_RD_IAMSR_LEN_BYTE (2U)
- #define PECI_RD_IAMSR_LEN_WORD (3U)
- #define PECI_RD_IAMSR_LEN_DWORD (5U)
- #define PECI_RD_IAMSR_LEN_QWORD (9U)
- #define PECI_RD_IAMSR_CMD_LEN (8U)
- #define PECI_WR_IAMSR_RD_LEN (1U)
- #define PECI_WR_IAMSR_LEN_BYTE (7U)
- #define PECI_WR_IAMSR_LEN_WORD (8U)
- #define PECI_WR_IAMSR_LEN_DWORD (10U)
- #define PECI_WR_IAMSR_LEN_QWORD (14U)
- #define PECI_WR_IAMSR_CMD_LEN (9U)
- #define PECI_RD_PCICFG_WR_LEN (6U)
- #define PECI_RD_PCICFG_LEN_BYTE (2U)
- #define PECI_RD_PCICFG_LEN_WORD (3U)
- #define PECI_RD_PCICFG_LEN_DWORD (5U)
- #define PECI_RD_PCICFG_CMD_LEN (9U)
- #define PECI_WR_PCICFG_RD_LEN (1U)
- #define PECI_WR_PCICFG_LEN_BYTE (8U)
- #define PECI_WR_PCICFG_LEN_WORD (9U)
- #define PECI_WR_PCICFG_LEN_DWORD (11U)
- #define PECI_WR_PCICFG_CMD_LEN (10U)
- #define PECI_RD_PCICFGL_WR_LEN (5U)
- #define PECI_RD_PCICFGL_RD_LEN_BYTE (2U)
- #define PECI_RD_PCICFGL_RD_LEN_WORD (3U)
- #define PECI_RD_PCICFGL_RD_LEN_DWORD (5U)
- #define PECI_RD_PCICFGL_CMD_LEN (8U)
- #define PECI_WR_PCICFGL_RD_LEN (1U)
- #define PECI_WR_PCICFGL_WR_LEN_BYTE (7U)
- #define PECI_WR_PCICFGL_WR_LEN_WORD (8U)
- #define PECI_WR_PCICFGL_WR_LEN_DWORD (10U)
- #define PECI_WR_PCICFGL_CMD_LEN (9U)
- struct peci_buf {
- uint8_t *buf;
- size_t len;
- };
- struct peci_msg {
-
- uint8_t addr;
-
- enum peci_command_code cmd_code;
-
- struct peci_buf tx_buffer;
-
- struct peci_buf rx_buffer;
-
- uint8_t flags;
- };
- typedef int (*peci_config_t)(const struct device *dev, uint32_t bitrate);
- typedef int (*peci_transfer_t)(const struct device *dev, struct peci_msg *msg);
- typedef int (*peci_disable_t)(const struct device *dev);
- typedef int (*peci_enable_t)(const struct device *dev);
- struct peci_driver_api {
- peci_config_t config;
- peci_disable_t disable;
- peci_enable_t enable;
- peci_transfer_t transfer;
- };
- __syscall int peci_config(const struct device *dev, uint32_t bitrate);
- static inline int z_impl_peci_config(const struct device *dev,
- uint32_t bitrate)
- {
- struct peci_driver_api *api;
- api = (struct peci_driver_api *)dev->api;
- return api->config(dev, bitrate);
- }
- __syscall int peci_enable(const struct device *dev);
- static inline int z_impl_peci_enable(const struct device *dev)
- {
- struct peci_driver_api *api;
- api = (struct peci_driver_api *)dev->api;
- return api->enable(dev);
- }
- __syscall int peci_disable(const struct device *dev);
- static inline int z_impl_peci_disable(const struct device *dev)
- {
- struct peci_driver_api *api;
- api = (struct peci_driver_api *)dev->api;
- return api->disable(dev);
- }
- __syscall int peci_transfer(const struct device *dev, struct peci_msg *msg);
- static inline int z_impl_peci_transfer(const struct device *dev,
- struct peci_msg *msg)
- {
- struct peci_driver_api *api;
- api = (struct peci_driver_api *)dev->api;
- return api->transfer(dev, msg);
- }
- #ifdef __cplusplus
- }
- #endif
- #include <syscalls/peci.h>
- #endif
|