summaryrefslogtreecommitdiff
path: root/include/mock/tcpci_i2c_mock.h
blob: 1d4a986ebe7db0f40b243268a1b5f84453e4b631 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "common.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"

#define MOCK_TCPCI_I2C_ADDR_FLAGS 0x99

void mock_tcpci_reset(void);

void mock_tcpci_set_reg(int reg, uint16_t value);
void mock_tcpci_set_reg_bits(int reg_offset, uint16_t mask);
void mock_tcpci_clr_reg_bits(int reg_offset, uint16_t mask);

uint16_t mock_tcpci_get_reg(int reg_offset);

int verify_tcpci_transmit(enum tcpci_msg_type tx_type,
			  enum pd_ctrl_msg_type ctrl_msg,
			  enum pd_data_msg_type data_msg);

int verify_tcpci_tx_retry_count(enum tcpci_msg_type tx_type,
				enum pd_ctrl_msg_type ctrl_msg,
				enum pd_data_msg_type data_msg,
				int retry_count);

int verify_tcpci_tx_timeout(enum tcpci_msg_type tx_type,
			    enum pd_ctrl_msg_type ctrl_msg,
			    enum pd_data_msg_type data_msg,
			    int timeout);

int verify_tcpci_tx_with_data(enum tcpci_msg_type tx_type,
			      enum pd_data_msg_type data_msg,
			      uint8_t *data,
			      int data_bytes,
			      int *msg_len,
			      int timeout);

struct possible_tx {
	enum tcpci_msg_type tx_type;
	enum pd_ctrl_msg_type ctrl_msg;
	enum pd_data_msg_type data_msg;
};

int verify_tcpci_possible_tx(struct possible_tx possible[],
			     int possible_cnt,
			     int *found_index,
			     uint8_t *data,
			     int data_bytes,
			     int *msg_len,
			     int timeout);

void mock_tcpci_receive(enum tcpci_msg_type sop, uint16_t header,
			uint32_t *payload);

void tcpci_register_dump(void);