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 2023 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/fff.h>
#include <zephyr/ztest.h>
#include <gpio.h>
#include <usbc_ppc.h>
FAKE_VOID_FUNC(aoz1380_interrupt, int);
FAKE_VOID_FUNC(nx20p348x_interrupt, int);
static void ppc_config_before(void *fixture)
{
ARG_UNUSED(fixture);
RESET_FAKE(aoz1380_interrupt);
RESET_FAKE(nx20p348x_interrupt);
}
void ppc_interrupt(enum gpio_signal signal);
int board_aoz1380_set_vbus_source_current_limit(int port,
enum tcpc_rp_value rp);
ZTEST_SUITE(ppc_config, NULL, NULL, ppc_config_before, NULL, NULL);
ZTEST(ppc_config, board_aoz1380_set_vbus_source_current_limit)
{
int rv;
const struct gpio_dt_spec *gpio =
GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en);
/*
* board_aoz1380_set_vbus_source_current_limit should set
* ioex_usb_c0_ilim_3a_en to 1 for 3A, 0 otherwise.
*/
rv = board_aoz1380_set_vbus_source_current_limit(0, TYPEC_RP_3A0);
zassert_equal(rv, EC_SUCCESS);
zassert_equal(gpio_emul_output_get(gpio->port, gpio->pin), 1);
rv = board_aoz1380_set_vbus_source_current_limit(0, TYPEC_RP_1A5);
zassert_equal(rv, EC_SUCCESS);
zassert_equal(gpio_emul_output_get(gpio->port, gpio->pin), 0);
}
ZTEST(ppc_config, ppc_interrupt)
{
ppc_interrupt(GPIO_USB_C0_PPC_INT_ODL);
zassert_equal(aoz1380_interrupt_fake.call_count, 1);
/* port */
zassert_equal(aoz1380_interrupt_fake.arg0_val, 0);
ppc_interrupt(GPIO_USB_C1_PPC_INT_ODL);
zassert_equal(nx20p348x_interrupt_fake.call_count, 1);
/* port */
zassert_equal(nx20p348x_interrupt_fake.arg0_val, 1);
}
|