diff options
Diffstat (limited to 'driver')
-rw-r--r-- | driver/build.mk | 1 | ||||
-rw-r--r-- | driver/tcpm/ps8751.c | 62 | ||||
-rw-r--r-- | driver/tcpm/ps8751.h | 18 |
3 files changed, 81 insertions, 0 deletions
diff --git a/driver/build.mk b/driver/build.mk index 6145bfbd22..cd4f377e28 100644 --- a/driver/build.mk +++ b/driver/build.mk @@ -80,6 +80,7 @@ driver-$(CONFIG_USB_PD_TCPM_TCPCI)+=tcpm/tcpci.o driver-$(CONFIG_USB_PD_TCPM_FUSB302)+=tcpm/fusb302.o driver-$(CONFIG_USB_PD_TCPM_ITE83XX)+=tcpm/it83xx.o driver-$(CONFIG_USB_PD_TCPM_ANX74XX)+=tcpm/anx74xx.o +driver-$(CONFIG_USB_PD_TCPM_PS8751)+=tcpm/ps8751.o # USB switches driver-$(CONFIG_USB_SWITCH_PI3USB9281)+=usb_switch_pi3usb9281.o diff --git a/driver/tcpm/ps8751.c b/driver/tcpm/ps8751.c new file mode 100644 index 0000000000..fdcb6416cf --- /dev/null +++ b/driver/tcpm/ps8751.c @@ -0,0 +1,62 @@ +/* Copyright 2016 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. + */ + +/* Type-C port manager for Parade PS8751 with integrated superspeed muxes */ + +#include "common.h" +#include "ps8751.h" +#include "tcpm.h" +#include "timer.h" + +#if !defined(CONFIG_USB_PD_TCPM_TCPCI) || \ + !defined(CONFIG_USB_PD_TCPM_MUX) || \ + !defined(CONFIG_USBC_SS_MUX) + +#error "PS8751 is using a standard TCPCI interface with integrated mux control" +#error "Please upgrade your board configuration" + +#endif + +static int dp_set_hpd(int port, int enable) +{ + int reg; + int rv; + + rv = tcpc_read(port, PS8751_REG_CTRL_1, ®); + if (rv) + return rv; + if (enable) + reg |= PS8751_REG_CTRL_1_HPD; + else + reg &= ~PS8751_REG_CTRL_1_HPD; + return tcpc_write(port, PS8751_REG_CTRL_1, reg); +} + +static int dp_set_irq(int port, int enable) +{ + + int reg; + int rv; + + rv = tcpc_read(port, PS8751_REG_CTRL_1, ®); + if (rv) + return rv; + if (enable) + reg |= PS8751_REG_CTRL_1_IRQ; + else + reg &= ~PS8751_REG_CTRL_1_IRQ; + return tcpc_write(port, PS8751_REG_CTRL_1, reg); +} + +void ps8751_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq) +{ + dp_set_hpd(port, hpd_lvl); + + if (hpd_irq) { + dp_set_irq(port, 0); + msleep(1); + dp_set_irq(port, hpd_irq); + } +} diff --git a/driver/tcpm/ps8751.h b/driver/tcpm/ps8751.h new file mode 100644 index 0000000000..765cc5c4f3 --- /dev/null +++ b/driver/tcpm/ps8751.h @@ -0,0 +1,18 @@ +/* Copyright 2016 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.. + */ + +/* Parade Tech Type-C controller vendor specific APIs*/ + +#ifndef __CROS_EC_USB_PD_TCPM_PS8751_H +#define __CROS_EC_USB_PD_TCPM_PS8751_H + +/* Vendor defined registers */ +#define PS8751_REG_CTRL_1 0xD0 +#define PS8751_REG_CTRL_1_HPD (1 << 0) +#define PS8751_REG_CTRL_1_IRQ (1 << 1) + +void ps8751_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq); +#endif /* __CROS_EC_USB_PD_TCPM_PS8751_H */ + |