mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
BD99955: Get the VBUS provided status from individual ports
BUG=chrome-os-partner:53786
BRANCH=none
TEST=Manually tested on Amenia. VBUS provide status is updated
properly for inividual ports.
Change-Id: I59c41988438543033db2322029169f405f347869
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/347895
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
0c5782495d
commit
52fdd95321
@@ -204,7 +204,8 @@ void board_set_charge_limit(int port, int supplier, int charge_ma)
|
||||
|
||||
int extpower_is_present(void)
|
||||
{
|
||||
return bd99955_extpower_is_present();
|
||||
/* Check VBUS on either port */
|
||||
return bd99955_is_vbus_provided(BD99955_CHARGE_PORT_BOTH);
|
||||
}
|
||||
|
||||
static void board_init(void)
|
||||
|
||||
@@ -412,7 +412,8 @@ void board_set_charge_limit(int port, int supplier, int charge_ma)
|
||||
|
||||
int extpower_is_present(void)
|
||||
{
|
||||
return bd99955_extpower_is_present();
|
||||
/* Check VBUS on either port */
|
||||
return bd99955_is_vbus_provided(BD99955_CHARGE_PORT_BOTH);
|
||||
}
|
||||
|
||||
int usb_charger_port_is_sourcing_vbus(int port)
|
||||
|
||||
@@ -106,7 +106,25 @@ void typec_set_input_current_limit(int port, uint32_t max_ma,
|
||||
|
||||
int pd_snk_is_vbus_provided(int port)
|
||||
{
|
||||
return extpower_is_present();
|
||||
enum bd99955_charge_port bd99955_port;
|
||||
|
||||
/*
|
||||
* TODO: Add a compile-time mapping to prevent
|
||||
* duplication of this code.
|
||||
*/
|
||||
switch (port) {
|
||||
case 0:
|
||||
bd99955_port = BD99955_CHARGE_PORT_VBUS;
|
||||
break;
|
||||
case 1:
|
||||
bd99955_port = BD99955_CHARGE_PORT_VCC;
|
||||
break;
|
||||
default:
|
||||
panic("Invalid charge port\n");
|
||||
break;
|
||||
}
|
||||
|
||||
return bd99955_is_vbus_provided(bd99955_port);
|
||||
}
|
||||
|
||||
int pd_board_checks(void)
|
||||
|
||||
@@ -437,7 +437,7 @@ int charger_get_status(int *status)
|
||||
}
|
||||
|
||||
/* source of power */
|
||||
if (bd99955_extpower_is_present())
|
||||
if (bd99955_is_vbus_provided(BD99955_CHARGE_PORT_BOTH))
|
||||
*status |= CHARGER_AC_PRESENT;
|
||||
|
||||
return EC_SUCCESS;
|
||||
@@ -550,7 +550,7 @@ static void bd99995_init(void)
|
||||
(bi->voltage_max + 500) & 0x7ff0,
|
||||
BD99955_EXTENDED_COMMAND);
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, bd99995_init, HOOK_PRIO_DEFAULT);
|
||||
DECLARE_HOOK(HOOK_INIT, bd99995_init, HOOK_PRIO_INIT_EXTPOWER);
|
||||
|
||||
int charger_post_init(void)
|
||||
{
|
||||
@@ -578,7 +578,7 @@ int charger_discharge_on_ac(int enable)
|
||||
|
||||
/*** Non-standard interface functions ***/
|
||||
|
||||
int bd99955_extpower_is_present(void)
|
||||
int bd99955_is_vbus_provided(int port)
|
||||
{
|
||||
int reg;
|
||||
|
||||
@@ -586,8 +586,17 @@ int bd99955_extpower_is_present(void)
|
||||
BD99955_EXTENDED_COMMAND))
|
||||
return 0;
|
||||
|
||||
reg &= (BD99955_CMD_VBUS_VCC_STATUS_VCC_DETECT |
|
||||
BD99955_CMD_VBUS_VCC_STATUS_VBUS_DETECT);
|
||||
if (port == BD99955_CHARGE_PORT_VBUS)
|
||||
reg &= BD99955_CMD_VBUS_VCC_STATUS_VBUS_DETECT;
|
||||
else if (port == BD99955_CHARGE_PORT_VCC)
|
||||
reg &= BD99955_CMD_VBUS_VCC_STATUS_VCC_DETECT;
|
||||
else if (port == BD99955_CHARGE_PORT_BOTH) {
|
||||
/* Check VBUS on either port */
|
||||
reg &= (BD99955_CMD_VBUS_VCC_STATUS_VCC_DETECT |
|
||||
BD99955_CMD_VBUS_VCC_STATUS_VBUS_DETECT);
|
||||
} else
|
||||
reg = 0;
|
||||
|
||||
return !!reg;
|
||||
}
|
||||
|
||||
|
||||
@@ -247,8 +247,8 @@ enum bd99955_charge_port {
|
||||
* functionality not part of the standard charger interface.
|
||||
*/
|
||||
|
||||
/* Return true if extpower is present on their input port. */
|
||||
int bd99955_extpower_is_present(void);
|
||||
/* Is VBUS provided or external power present */
|
||||
int bd99955_is_vbus_provided(int port);
|
||||
/* Select input port from {VCC, VBUS, VCC&VBUS, NONE}. */
|
||||
int bd99955_select_input_port(enum bd99955_charge_port port);
|
||||
/* Enable/Disable charging triggered by BC1.2 */
|
||||
|
||||
Reference in New Issue
Block a user