Zephyr Project API
3.4.0
A Scalable Open Source RTOS
peci.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 Intel Corporation.
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
12
#ifndef ZEPHYR_INCLUDE_DRIVERS_PECI_H_
13
#define ZEPHYR_INCLUDE_DRIVERS_PECI_H_
14
22
#include <
errno.h
>
23
#include <
zephyr/types.h
>
24
#include <stddef.h>
25
#include <
zephyr/device.h
>
26
27
#ifdef __cplusplus
28
extern
"C"
{
29
#endif
30
34
enum
peci_error_code
{
35
PECI_GENERAL_SENSOR_ERROR
= 0x8000,
36
PECI_UNDERFLOW_SENSOR_ERROR
= 0x8002,
37
PECI_OVERFLOW_SENSOR_ERROR
= 0x8003,
38
};
39
43
enum
peci_command_code
{
44
PECI_CMD_PING
= 0x00,
45
PECI_CMD_GET_TEMP0
= 0x01,
46
PECI_CMD_GET_TEMP1
= 0x02,
47
PECI_CMD_RD_PCI_CFG0
= 0x61,
48
PECI_CMD_RD_PCI_CFG1
= 0x62,
49
PECI_CMD_WR_PCI_CFG0
= 0x65,
50
PECI_CMD_WR_PCI_CFG1
= 0x66,
51
PECI_CMD_RD_PKG_CFG0
= 0xA1,
52
PECI_CMD_RD_PKG_CFG1
= 0xA,
53
PECI_CMD_WR_PKG_CFG0
= 0xA5,
54
PECI_CMD_WR_PKG_CFG1
= 0xA6,
55
PECI_CMD_RD_IAMSR0
= 0xB1,
56
PECI_CMD_RD_IAMSR1
= 0xB2,
57
PECI_CMD_WR_IAMSR0
= 0xB5,
58
PECI_CMD_WR_IAMSR1
= 0xB6,
59
PECI_CMD_RD_PCI_CFG_LOCAL0
= 0xE1,
60
PECI_CMD_RD_PCI_CFG_LOCAL1
= 0xE2,
61
PECI_CMD_WR_PCI_CFG_LOCAL0
= 0xE5,
62
PECI_CMD_WR_PCI_CFG_LOCAL1
= 0xE6,
63
PECI_CMD_GET_DIB
= 0xF7,
64
};
65
67
#define PECI_CC_RSP_SUCCESS (0x40U)
68
#define PECI_CC_RSP_TIMEOUT (0x80U)
69
#define PECI_CC_OUT_OF_RESOURCES_TIMEOUT (0x81U)
70
#define PECI_CC_RESOURCES_LOWPWR_TIMEOUT (0x82U)
71
#define PECI_CC_ILLEGAL_REQUEST (0x90U)
72
74
#define PECI_PING_WR_LEN (0U)
75
#define PECI_PING_RD_LEN (0U)
76
#define PECI_PING_LEN (3U)
77
79
#define PECI_GET_DIB_WR_LEN (1U)
80
#define PECI_GET_DIB_RD_LEN (8U)
81
#define PECI_GET_DIB_CMD_LEN (4U)
82
#define PECI_GET_DIB_DEVINFO (0U)
83
#define PECI_GET_DIB_REVNUM (1U)
84
#define PECI_GET_DIB_DOMAIN_BIT_MASK (0x4U)
85
#define PECI_GET_DIB_MAJOR_REV_MASK 0xF0
86
#define PECI_GET_DIB_MINOR_REV_MASK 0x0F
87
89
#define PECI_GET_TEMP_WR_LEN (1U)
90
#define PECI_GET_TEMP_RD_LEN (2U)
91
#define PECI_GET_TEMP_CMD_LEN (4U)
92
#define PECI_GET_TEMP_LSB (0U)
93
#define PECI_GET_TEMP_MSB (1U)
94
#define PECI_GET_TEMP_ERR_MSB (0x80U)
95
#define PECI_GET_TEMP_ERR_LSB_GENERAL (0x0U)
96
#define PECI_GET_TEMP_ERR_LSB_RES (0x1U)
97
#define PECI_GET_TEMP_ERR_LSB_TEMP_LO (0x2U)
98
#define PECI_GET_TEMP_ERR_LSB_TEMP_HI (0x3U)
99
101
#define PECI_RD_PKG_WR_LEN (5U)
102
#define PECI_RD_PKG_LEN_BYTE (2U)
103
#define PECI_RD_PKG_LEN_WORD (3U)
104
#define PECI_RD_PKG_LEN_DWORD (5U)
105
#define PECI_RD_PKG_CMD_LEN (8U)
106
108
#define PECI_WR_PKG_RD_LEN (1U)
109
#define PECI_WR_PKG_LEN_BYTE (7U)
110
#define PECI_WR_PKG_LEN_WORD (8U)
111
#define PECI_WR_PKG_LEN_DWORD (10U)
112
#define PECI_WR_PKG_CMD_LEN (9U)
113
115
#define PECI_RD_IAMSR_WR_LEN (5U)
116
#define PECI_RD_IAMSR_LEN_BYTE (2U)
117
#define PECI_RD_IAMSR_LEN_WORD (3U)
118
#define PECI_RD_IAMSR_LEN_DWORD (5U)
119
#define PECI_RD_IAMSR_LEN_QWORD (9U)
120
#define PECI_RD_IAMSR_CMD_LEN (8U)
121
123
#define PECI_WR_IAMSR_RD_LEN (1U)
124
#define PECI_WR_IAMSR_LEN_BYTE (7U)
125
#define PECI_WR_IAMSR_LEN_WORD (8U)
126
#define PECI_WR_IAMSR_LEN_DWORD (10U)
127
#define PECI_WR_IAMSR_LEN_QWORD (14U)
128
#define PECI_WR_IAMSR_CMD_LEN (9U)
129
131
#define PECI_RD_PCICFG_WR_LEN (6U)
132
#define PECI_RD_PCICFG_LEN_BYTE (2U)
133
#define PECI_RD_PCICFG_LEN_WORD (3U)
134
#define PECI_RD_PCICFG_LEN_DWORD (5U)
135
#define PECI_RD_PCICFG_CMD_LEN (9U)
136
138
#define PECI_WR_PCICFG_RD_LEN (1U)
139
#define PECI_WR_PCICFG_LEN_BYTE (8U)
140
#define PECI_WR_PCICFG_LEN_WORD (9U)
141
#define PECI_WR_PCICFG_LEN_DWORD (11U)
142
#define PECI_WR_PCICFG_CMD_LEN (10U)
143
145
#define PECI_RD_PCICFGL_WR_LEN (5U)
146
#define PECI_RD_PCICFGL_RD_LEN_BYTE (2U)
147
#define PECI_RD_PCICFGL_RD_LEN_WORD (3U)
148
#define PECI_RD_PCICFGL_RD_LEN_DWORD (5U)
149
#define PECI_RD_PCICFGL_CMD_LEN (8U)
150
152
#define PECI_WR_PCICFGL_RD_LEN (1U)
153
#define PECI_WR_PCICFGL_WR_LEN_BYTE (7U)
154
#define PECI_WR_PCICFGL_WR_LEN_WORD (8U)
155
#define PECI_WR_PCICFGL_WR_LEN_DWORD (10U)
156
#define PECI_WR_PCICFGL_CMD_LEN (9U)
157
168
struct
peci_buf
{
169
uint8_t
*
buf
;
170
size_t
len
;
171
};
172
176
struct
peci_msg
{
178
uint8_t
addr
;
180
enum
peci_command_code
cmd_code
;
182
struct
peci_buf
tx_buffer
;
184
struct
peci_buf
rx_buffer
;
186
uint8_t
flags
;
187
};
188
196
typedef
int (*peci_config_t)(
const
struct
device
*dev,
uint32_t
bitrate);
197
typedef
int (*peci_transfer_t)(
const
struct
device
*dev,
struct
peci_msg
*
msg
);
198
typedef
int (*peci_disable_t)(
const
struct
device
*dev);
199
typedef
int (*peci_enable_t)(
const
struct
device
*dev);
200
201
__subsystem
struct
peci_driver_api {
202
peci_config_t config;
203
peci_disable_t disable;
204
peci_enable_t enable;
205
peci_transfer_t transfer;
206
};
207
222
__syscall
int
peci_config
(
const
struct
device
*dev,
uint32_t
bitrate);
223
224
static
inline
int
z_impl_peci_config(
const
struct
device
*dev,
225
uint32_t
bitrate)
226
{
227
struct
peci_driver_api *api;
228
229
api = (
struct
peci_driver_api *)dev->
api
;
230
return
api->config(dev, bitrate);
231
}
232
241
__syscall
int
peci_enable
(
const
struct
device
*dev);
242
243
static
inline
int
z_impl_peci_enable(
const
struct
device
*dev)
244
{
245
struct
peci_driver_api *api;
246
247
api = (
struct
peci_driver_api *)dev->
api
;
248
return
api->enable(dev);
249
}
250
259
__syscall
int
peci_disable
(
const
struct
device
*dev);
260
261
static
inline
int
z_impl_peci_disable(
const
struct
device
*dev)
262
{
263
struct
peci_driver_api *api;
264
265
api = (
struct
peci_driver_api *)dev->
api
;
266
return
api->disable(dev);
267
}
268
279
__syscall
int
peci_transfer
(
const
struct
device
*dev,
struct
peci_msg
*
msg
);
280
281
static
inline
int
z_impl_peci_transfer(
const
struct
device
*dev,
282
struct
peci_msg
*
msg
)
283
{
284
struct
peci_driver_api *api;
285
286
api = (
struct
peci_driver_api *)dev->
api
;
287
return
api->transfer(dev,
msg
);
288
}
289
290
291
#ifdef __cplusplus
292
}
293
#endif
294
299
#include <syscalls/peci.h>
300
301
#endif
/* ZEPHYR_INCLUDE_DRIVERS_PECI_H_ */
device.h
errno.h
System error numbers.
peci_error_code
peci_error_code
PECI error codes.
Definition:
peci.h:34
peci_config
int peci_config(const struct device *dev, uint32_t bitrate)
Configures the PECI interface.
peci_enable
int peci_enable(const struct device *dev)
Enable PECI interface.
peci_command_code
peci_command_code
PECI commands.
Definition:
peci.h:43
peci_transfer
int peci_transfer(const struct device *dev, struct peci_msg *msg)
Performs a PECI transaction.
peci_disable
int peci_disable(const struct device *dev)
Disable PECI interface.
PECI_UNDERFLOW_SENSOR_ERROR
@ PECI_UNDERFLOW_SENSOR_ERROR
Definition:
peci.h:36
PECI_GENERAL_SENSOR_ERROR
@ PECI_GENERAL_SENSOR_ERROR
Definition:
peci.h:35
PECI_OVERFLOW_SENSOR_ERROR
@ PECI_OVERFLOW_SENSOR_ERROR
Definition:
peci.h:37
PECI_CMD_GET_DIB
@ PECI_CMD_GET_DIB
Definition:
peci.h:63
PECI_CMD_GET_TEMP1
@ PECI_CMD_GET_TEMP1
Definition:
peci.h:46
PECI_CMD_RD_PCI_CFG_LOCAL0
@ PECI_CMD_RD_PCI_CFG_LOCAL0
Definition:
peci.h:59
PECI_CMD_RD_PKG_CFG1
@ PECI_CMD_RD_PKG_CFG1
Definition:
peci.h:52
PECI_CMD_WR_IAMSR0
@ PECI_CMD_WR_IAMSR0
Definition:
peci.h:57
PECI_CMD_WR_PKG_CFG1
@ PECI_CMD_WR_PKG_CFG1
Definition:
peci.h:54
PECI_CMD_RD_PKG_CFG0
@ PECI_CMD_RD_PKG_CFG0
Definition:
peci.h:51
PECI_CMD_WR_PCI_CFG1
@ PECI_CMD_WR_PCI_CFG1
Definition:
peci.h:50
PECI_CMD_RD_IAMSR1
@ PECI_CMD_RD_IAMSR1
Definition:
peci.h:56
PECI_CMD_RD_PCI_CFG1
@ PECI_CMD_RD_PCI_CFG1
Definition:
peci.h:48
PECI_CMD_WR_PCI_CFG_LOCAL1
@ PECI_CMD_WR_PCI_CFG_LOCAL1
Definition:
peci.h:62
PECI_CMD_RD_PCI_CFG0
@ PECI_CMD_RD_PCI_CFG0
Definition:
peci.h:47
PECI_CMD_WR_IAMSR1
@ PECI_CMD_WR_IAMSR1
Definition:
peci.h:58
PECI_CMD_WR_PKG_CFG0
@ PECI_CMD_WR_PKG_CFG0
Definition:
peci.h:53
PECI_CMD_WR_PCI_CFG0
@ PECI_CMD_WR_PCI_CFG0
Definition:
peci.h:49
PECI_CMD_RD_PCI_CFG_LOCAL1
@ PECI_CMD_RD_PCI_CFG_LOCAL1
Definition:
peci.h:60
PECI_CMD_RD_IAMSR0
@ PECI_CMD_RD_IAMSR0
Definition:
peci.h:55
PECI_CMD_PING
@ PECI_CMD_PING
Definition:
peci.h:44
PECI_CMD_WR_PCI_CFG_LOCAL0
@ PECI_CMD_WR_PCI_CFG_LOCAL0
Definition:
peci.h:61
PECI_CMD_GET_TEMP0
@ PECI_CMD_GET_TEMP0
Definition:
peci.h:45
types.h
uint32_t
__UINT32_TYPE__ uint32_t
Definition:
stdint.h:90
uint8_t
__UINT8_TYPE__ uint8_t
Definition:
stdint.h:88
device
Runtime device structure (in ROM) per driver instance.
Definition:
device.h:380
device::api
const void * api
Definition:
device.h:386
peci_buf
PECI buffer structure.
Definition:
peci.h:168
peci_buf::len
size_t len
Definition:
peci.h:170
peci_buf::buf
uint8_t * buf
Definition:
peci.h:169
peci_msg
PECI transaction packet format.
Definition:
peci.h:176
peci_msg::flags
uint8_t flags
Definition:
peci.h:186
peci_msg::cmd_code
enum peci_command_code cmd_code
Definition:
peci.h:180
peci_msg::tx_buffer
struct peci_buf tx_buffer
Definition:
peci.h:182
peci_msg::addr
uint8_t addr
Definition:
peci.h:178
peci_msg::rx_buffer
struct peci_buf rx_buffer
Definition:
peci.h:184
msg
static void msg(uint64_t c64)
Definition:
main.c:17
include
zephyr
drivers
peci.h
Generated on Sat Jun 17 2023 07:48:27 for Zephyr Project API by
1.9.2