mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-11 18:35:28 +00:00
If the sn5s330 PPC is being used to detect VBUS presence (CONFIG_USB_PD_VBUS_DETECT_PPC), then enable interrupts and call usb_charger_vbus_change when VBUS_GOOD changes. BUG=b:72007153,b:72007492 BRANCH=none TEST=Connect 3A and 1A USB-A chargers to each of Grunt's USB-C ports, check that BC1.2 detection is working: With 1A: > chgsup port=0/1, type=7, cur=500mA, vtg=5000mV, lsm=1 With 3A: > chgsup port=0/1, type=7, cur=2400mA, vtg=5000mV, lsm=1 TEST=Boot Grunt to OS, then connect USB2 mouse or USB3 flash drive to each of Grunt's USB-C ports. Devices do not work due to b:71772180, but gpioget shows EC is setting USB_C0/1_BC12_VBUS_ON_L correctly. Change-Id: Iffc352105a321997adb364b9fbb8bafef248c224 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/887938 Reviewed-by: Jett Rink <jettrink@chromium.org>
169 lines
4.3 KiB
C
169 lines
4.3 KiB
C
/* Copyright 2017 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.
|
|
*/
|
|
|
|
#ifndef __CROS_EC_USBC_PPC_H
|
|
#define __CROS_EC_USBC_PPC_H
|
|
|
|
#include "common.h"
|
|
#include "usb_pd_tcpm.h"
|
|
|
|
/* Common APIs for USB Type-C Power Path Controllers (PPC) */
|
|
|
|
struct ppc_drv {
|
|
/**
|
|
* Initialize the PPC.
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @return EC_SUCCESS when init was successful, error otherwise.
|
|
*/
|
|
int (*init)(int port);
|
|
|
|
/**
|
|
* Is the port sourcing Vbus?
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @return 1 if sourcing Vbus, 0 if not.
|
|
*/
|
|
int (*is_sourcing_vbus)(int port);
|
|
|
|
/**
|
|
* Turn on/off the charge path FET, such that current flows into the
|
|
* system.
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @param enable: 1: Turn on the FET, 0: turn off the FET.
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int (*vbus_sink_enable)(int port, int enable);
|
|
|
|
/**
|
|
* Turn on/off the source path FET, such that current flows from the
|
|
* system.
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @param enable: 1: Turn on the FET, 0: turn off the FET.
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int (*vbus_source_enable)(int port, int enable);
|
|
|
|
/**
|
|
* Set the Vbus source path current limit
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @param rp: The Rp value which to approximately set the current limit.
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int (*set_vbus_source_current_limit)(int port, enum tcpc_rp_value rp);
|
|
|
|
/**
|
|
* Discharge PD VBUS on src/sink disconnect & power role swap
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @param enable: 1 -> discharge vbus, 0 -> stop discharging vbus
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int (*discharge_vbus)(int port, int enable);
|
|
|
|
#ifdef CONFIG_CMD_PPC_DUMP
|
|
/**
|
|
* Perform a register dump of the PPC.
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int (*reg_dump)(int port);
|
|
#endif /* defined(CONFIG_CMD_PPC_DUMP) */
|
|
|
|
#ifdef CONFIG_USB_PD_VBUS_DETECT_PPC
|
|
/**
|
|
* Determine if VBUS is present or not.
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @return 1 if VBUS is present, 0 if not.
|
|
*/
|
|
int (*is_vbus_present)(int port);
|
|
#endif /* defined(CONFIG_USB_PD_VBUS_DETECT_PPC) */
|
|
};
|
|
|
|
struct ppc_config_t {
|
|
int i2c_port;
|
|
int i2c_addr;
|
|
const struct ppc_drv *drv;
|
|
};
|
|
|
|
extern const struct ppc_config_t ppc_chips[];
|
|
extern const unsigned int ppc_cnt;
|
|
|
|
/**
|
|
* Initializes the PPC for the specified port.
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int ppc_init(int port);
|
|
|
|
/**
|
|
* Determine if VBUS is present or not.
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @return 1 if VBUS is present, 0 if not.
|
|
*/
|
|
int ppc_is_vbus_present(int port);
|
|
|
|
/**
|
|
* Is the port sourcing Vbus?
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @return 1 if sourcing Vbus, 0 if not.
|
|
*/
|
|
int ppc_is_sourcing_vbus(int port);
|
|
|
|
/**
|
|
* Set the Vbus source path current limit
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @param rp: The Rp value which to approximately set the current limit.
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int ppc_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp);
|
|
|
|
/**
|
|
* Discharge PD VBUS on src/sink disconnect & power role swap
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @param enable: 1 -> discharge vbus, 0 -> stop discharging vbus
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int ppc_discharge_vbus(int port, int enable);
|
|
|
|
/**
|
|
* Turn on/off the charge path FET, such that current flows into the
|
|
* system.
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @param enable: 1: Turn on the FET, 0: turn off the FET.
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int ppc_vbus_sink_enable(int port, int enable);
|
|
|
|
/**
|
|
* Turn on/off the source path FET, such that current flows from the
|
|
* system.
|
|
*
|
|
* @param port: The Type-C port number.
|
|
* @param enable: 1: Turn on the FET, 0: turn off the FET.
|
|
* @return EC_SUCCESS on success, error otherwise.
|
|
*/
|
|
int ppc_vbus_source_enable(int port, int enable);
|
|
|
|
/**
|
|
* Board specific callback when a port overcurrents.
|
|
*
|
|
* @param port: The Type-C port which overcurrented.
|
|
*/
|
|
void board_overcurrent_event(int port);
|
|
|
|
#endif /* !defined(__CROS_EC_USBC_PPC_H) */
|