summaryrefslogtreecommitdiff
path: root/common/mock/usb_prl_mock.c
blob: 1e9c9c957613d16f7f3377961a052084808363c0 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* Copyright 2019 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.
 *
 * Fake Protocol Layer module.
 */
#include <string.h>
#include "common.h"
#include "usb_emsg.h"
#include "usb_prl_sm.h"
#include "mock/usb_prl_mock.h"

/* Defaults should all be 0 values. */
struct extended_msg rx_emsg[CONFIG_USB_PD_PORT_MAX_COUNT];
struct extended_msg tx_emsg[CONFIG_USB_PD_PORT_MAX_COUNT];

void mock_prl_reset(void)
{
	/* Reset all values to 0. */
	memset(rx_emsg, 0, sizeof(rx_emsg));
	memset(tx_emsg, 0, sizeof(tx_emsg));
}

void prl_end_ams(int port)
{}

void prl_execute_hard_reset(int port)
{}

enum pd_rev_type prl_get_rev(int port, enum tcpm_transmit_type partner)
{
	return PD_REV30;
}

void prl_hard_reset_complete(int port)
{}

int prl_is_running(int port)
{
	return 1;
}

__overridable bool prl_is_busy(int port)
{
	return false;
}

void prl_reset(int port)
{}

void prl_reset_soft(int port)
{}

static enum pd_ctrl_msg_type last_ctrl_msg[CONFIG_USB_PD_PORT_MAX_COUNT];
static enum pd_data_msg_type last_data_msg_type[CONFIG_USB_PD_PORT_MAX_COUNT];

void prl_send_ctrl_msg(int port, enum tcpm_transmit_type type,
	enum pd_ctrl_msg_type msg)
{
	last_ctrl_msg[port] = msg;
}

void prl_send_data_msg(int port, enum tcpm_transmit_type type,
	enum pd_data_msg_type msg)
{
	last_data_msg_type[port] = msg;
}

void prl_send_ext_data_msg(int port, enum tcpm_transmit_type type,
	enum pd_ext_msg_type msg)
{}

void prl_set_rev(int port, enum tcpm_transmit_type partner,
	enum pd_rev_type rev)
{}


enum pd_ctrl_msg_type fake_prl_get_last_sent_ctrl_msg(int port)
{
	return last_ctrl_msg[port];
}

void fake_prl_clear_last_sent_ctrl_msg(int port)
{
	last_ctrl_msg[port] = 0;
}

enum pd_data_msg_type fake_prl_get_last_sent_data_msg_type(int port)
{
	return last_data_msg_type[port];
}

void fake_prl_clear_last_sent_data_msg(int port)
{
	last_data_msg_type[port] = 0;
}