glkrvp: Allow system to boot using DC Jack

There are two Type-C ports and a DC Jack on GLKRVP. Added code
to allow system to boot from DC Jack also. This helps to boot
the device without Type-C connector during early stage of
software development.

BUG=b:69005234
BRANCH=glkrvp
TEST=GLKRVP can boot to OS without battery and DC Jack attached.
     Also VBATA is set to battery voltage max.
     When DC-Jack is present Type-C port is not enabled and
     vice-versa.

Change-Id: I0fe5631c40490c56fba6ed5f3ad7ba7f5248460a
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/757874
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:
Vijay Hiremath
2017-11-07 23:09:57 -08:00
committed by chrome-bot
parent e64f9b258a
commit cab93b613b
4 changed files with 103 additions and 19 deletions

View File

@@ -61,7 +61,20 @@ static const struct battery_info batt_info_smp_ca445 = {
const struct battery_info *battery_get_info(void)
{
return &batt_info_smp_ca445;
static struct battery_info batt_info;
if (battery_is_present() == BP_YES)
return &batt_info_smp_ca445;
/*
* In no battery condition, to avoid voltage drop on VBATA set
* the battery minimum voltage to the battery maximum voltage.
*/
batt_info = batt_info_smp_ca445;
batt_info.voltage_min = batt_info.voltage_max;
return &batt_info;
}
static const struct fast_charge_profile fast_charge_smp_ca445_info[] = {

View File

@@ -35,7 +35,6 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_NARROW_VDC
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_PROFILE_OVERRIDE_COMMON
#undef CONFIG_CHARGER_PROFILE_VOLTAGE_RANGES
@@ -47,6 +46,10 @@
#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
#define CONFIG_EXTPOWER_GPIO
/* DC Jack charge ports */
#undef CONFIG_DEDICATED_CHARGE_PORT_COUNT
#define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1
/* Keyboard */
#define CONFIG_KEYBOARD_PROTOCOL_8042
@@ -150,10 +153,11 @@ int board_get_version(void);
#define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */
/* Define typical operating power and max power */
#define PD_OPERATING_POWER_MW 15000
#define PD_MAX_POWER_MW 45000
#define PD_MAX_CURRENT_MA 3000
#define PD_MAX_VOLTAGE_MV 20000
#define PD_OPERATING_POWER_MW 15000
#define PD_MAX_POWER_MW 45000
#define PD_MAX_CURRENT_MA 3000
#define PD_MAX_VOLTAGE_MV 20000
#define DC_JACK_MAX_VOLTAGE_MV 19000
/* Reset PD MCU */
void board_reset_pd_mcu(void);

View File

@@ -24,6 +24,12 @@
#define PTN5110_EXT_GPIO_EN_SNK1 (1 << 4)
#define PTN5110_EXT_GPIO_IILIM_5V_VBUS_L (1 << 3)
enum glkrvp_charge_ports {
TYPE_C_PORT_0,
TYPE_C_PORT_1,
DC_JACK_PORT_0,
};
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
{NPCX_I2C_PORT0_1, 0xA0, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
{NPCX_I2C_PORT0_1, 0xA4, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
@@ -129,11 +135,54 @@ void board_reset_pd_mcu(void)
/* TODO: Add reset logic */
}
static inline int board_dc_jack_present(void)
{
return !gpio_get_level(GPIO_DC_JACK_PRESENT_L);
}
static void board_dc_jack_handle(void)
{
struct charge_port_info charge_dc_jack;
/* System is booted from DC Jack */
if (board_dc_jack_present()) {
charge_dc_jack.current = (PD_MAX_POWER_MW * 1000) /
DC_JACK_MAX_VOLTAGE_MV;
charge_dc_jack.voltage = DC_JACK_MAX_VOLTAGE_MV;
} else {
charge_dc_jack.current = 0;
charge_dc_jack.voltage = USB_CHARGER_VOLTAGE_MV;
}
charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED,
DC_JACK_PORT_0, &charge_dc_jack);
}
DECLARE_HOOK(HOOK_AC_CHANGE, board_dc_jack_handle, HOOK_PRIO_FIRST);
static void board_charge_init(void)
{
int port, supplier;
struct charge_port_info charge_init = {
.current = 0,
.voltage = USB_CHARGER_VOLTAGE_MV,
};
/* Initialize all charge suppliers to seed the charge manager */
for (port = 0; port < CHARGE_PORT_COUNT; port++) {
for (supplier = 0; supplier < CHARGE_SUPPLIER_COUNT; supplier++)
charge_manager_update_charge(supplier, port,
&charge_init);
}
board_dc_jack_handle();
}
DECLARE_HOOK(HOOK_INIT, board_charge_init, HOOK_PRIO_DEFAULT);
int board_set_active_charge_port(int port)
{
/* charge port is a realy physical port */
int is_real_port = (port >= 0 &&
port < CONFIG_USB_PD_PORT_COUNT);
port < CHARGE_PORT_COUNT);
/* check if we are source vbus on that port */
int source = board_charger_port_is_sourcing_vbus(port);
@@ -142,16 +191,33 @@ int board_set_active_charge_port(int port)
return EC_ERROR_INVAL;
}
CPRINTS("New chg p%d", port);
/*
* Do not enable Type-C port if the DC Jack is present.
* When the Type-C is active port, hardware circuit will
* block DC jack from enabling +VADP_OUT.
*/
if (port != DC_JACK_PORT_0 && board_dc_jack_present()) {
CPRINTS("DC Jack present, Skip enable p%d", port);
return EC_ERROR_INVAL;
}
if (port != CHARGE_PORT_NONE) {
/* Make sure non-charging port is disabled */
board_charging_enable(port, 1);
board_charging_enable(!port, 0);
} else {
/* Disable both ports */
board_charging_enable(0, 0);
board_charging_enable(1, 0);
/* Make sure non-charging port is disabled */
switch (port) {
case TYPE_C_PORT_0:
board_charging_enable(TYPE_C_PORT_1, 0);
board_charging_enable(TYPE_C_PORT_0, 1);
break;
case TYPE_C_PORT_1:
board_charging_enable(TYPE_C_PORT_0, 0);
board_charging_enable(TYPE_C_PORT_1, 1);
break;
case DC_JACK_PORT_0:
case CHARGE_PORT_NONE:
default:
/* Disable both Type-C ports */
board_charging_enable(TYPE_C_PORT_0, 0);
board_charging_enable(TYPE_C_PORT_1, 0);
break;
}
return EC_SUCCESS;

View File

@@ -42,8 +42,10 @@ GPIO(SMC_SHUTDOWN, PIN(3, 3), GPIO_OUT_LOW | GPIO_PULL_DOWN) /* A_RAIL_EN */
* normally driven by the PMIC. The EC can also drive this signal in the event
* that the ambient or charger temperature sensors exceeds their thresholds.
*/
GPIO(CPU_PROCHOT, PIN(A, 3), GPIO_INPUT) /* PCH_PROCHOT_ODL */
GPIO(EC_PCH_RTCRST, PIN(B, 7), GPIO_INPUT) /* EC_PCH_RTCRST TODO: Not used yet */
GPIO(CPU_PROCHOT, PIN(A, 3), GPIO_INPUT) /* PCH_PROCHOT_ODL */
GPIO(EC_PCH_RTCRST, PIN(B, 7), GPIO_INPUT) /* EC_PCH_RTCRST TODO: Not used yet */
GPIO(DC_JACK_PRESENT_L, PIN(7, 0), GPIO_INPUT) /* DC Jack presence coming from +V3P3_A_KBC */
/*
* I2C pins should be configured as inputs until I2C module is
@@ -75,7 +77,6 @@ GPIO(NC_60, PIN(6, 0), GPIO_INPUT)
GPIO(NC_61, PIN(6, 1), GPIO_INPUT)
GPIO(NC_67, PIN(6, 7), GPIO_INPUT)
GPIO(NC_70, PIN(7, 0), GPIO_INPUT)
GPIO(NC_71, PIN(7, 1), GPIO_INPUT)
GPIO(NC_73, PIN(7, 3), GPIO_INPUT)
GPIO(NC_74, PIN(7, 4), GPIO_INPUT)