driver/tcpm: add Type-C controller ps8751 DP alt mode API

BUG=chrome-os-partner:49431
BRANCH=none
TEST=On Amenia TR1.2, verified display port outptu is enabled on
exteneded display. Seperate patches are needed for testing.

Change-Id: I5ca54c91c566725c612a01a51f1af32e2a819e2d
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/351319
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
li feng
2016-06-09 18:22:15 -07:00
committed by chrome-bot
parent 77ef618929
commit a800ecfec6
4 changed files with 82 additions and 0 deletions

View File

@@ -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

62
driver/tcpm/ps8751.c Normal file
View File

@@ -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, &reg);
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, &reg);
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);
}
}

18
driver/tcpm/ps8751.h Normal file
View File

@@ -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 */

View File

@@ -1905,6 +1905,7 @@
#undef CONFIG_USB_PD_TCPM_FUSB302
#undef CONFIG_USB_PD_TCPM_ITE83XX
#undef CONFIG_USB_PD_TCPM_ANX74XX
#undef CONFIG_USB_PD_TCPM_PS8751
/*
* Use this option if the TCPC port controller supports the optional register