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
|
/* 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 "console.h"
#include "driver/usb_mux/amd_fp5.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
#include "ioexpander.h"
#include "usb_mux.h"
static void usba_retimer_on(void)
{
ioex_set_level(IOEX_USB_A1_RETIMER_EN, 1);
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, usba_retimer_on, HOOK_PRIO_DEFAULT);
static void usba_retimer_off(void)
{
ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0);
}
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usba_retimer_off, HOOK_PRIO_DEFAULT);
/*
* USB C0 port SBU mux use standalone FSUSB42UMX
* chip and it need a board specific driver.
* Overall, it will use chained mux framework.
*/
static int fsusb42umx_set_mux(const struct usb_mux *me, mux_state_t mux_state)
{
if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
ioex_set_level(IOEX_USB_C0_SBU_FLIP, 1);
else
ioex_set_level(IOEX_USB_C0_SBU_FLIP, 0);
return EC_SUCCESS;
}
/*
* .init is not necessary here because it has nothing
* to do. Primary mux will handle mux state so .get is
* not needed as well. usb_mux.c can handle the situation
* properly.
*/
const struct usb_mux_driver usbc0_sbu_mux_driver = {
.set = fsusb42umx_set_mux,
};
/*
* Since FSUSB42UMX is not a i2c device, .i2c_port and
* .i2c_addr_flags are not required here.
*/
const struct usb_mux usbc0_sbu_mux = {
.usb_port = USBC_PORT_C0,
.driver = &usbc0_sbu_mux_driver,
};
const struct usb_mux usb_muxes[] = {
[USBC_PORT_C0] = {
.usb_port = USBC_PORT_C0,
.i2c_port = I2C_PORT_USB_AP_MUX,
.i2c_addr_flags = AMD_FP5_MUX_I2C_ADDR_FLAGS,
.driver = &amd_fp5_usb_mux_driver,
.next_mux = &usbc0_sbu_mux,
},
[USBC_PORT_C1] = {
.usb_port = USBC_PORT_C1,
.i2c_port = I2C_PORT_TCPC1,
.i2c_addr_flags = 0x10,
.driver = &ps874x_usb_mux_driver,
}
};
BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
|