mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 02:20:48 +00:00
scarlet: Add rt946x charger for the new board
BUG=b:63739819 BRANCH=none TEST=build scarlet Change-Id: I8710412a591170d077dc217c192ec3b231e54659 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/573585 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "battery_smart.h"
|
||||
#include "charge_state.h"
|
||||
#include "console.h"
|
||||
#include "driver/charger/rt946x.h"
|
||||
#include "ec_commands.h"
|
||||
#include "extpower.h"
|
||||
#include "util.h"
|
||||
@@ -45,15 +46,7 @@ enum battery_present battery_is_present(void)
|
||||
|
||||
int board_cut_off_battery(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
/* Ship mode command must be sent twice to take effect */
|
||||
rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
|
||||
if (rv != EC_SUCCESS)
|
||||
return EC_RES_ERROR;
|
||||
|
||||
rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
|
||||
return rv ? EC_RES_ERROR : EC_RES_SUCCESS;
|
||||
return rt946x_cutoff_battery();
|
||||
}
|
||||
|
||||
enum battery_disconnect_state battery_get_disconnect_state(void)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "console.h"
|
||||
#include "ec_commands.h"
|
||||
#include "driver/accelgyro_bmi160.h"
|
||||
#include "driver/charger/bd9995x.h"
|
||||
#include "driver/charger/rt946x.h"
|
||||
#include "driver/baro_bmp280.h"
|
||||
#include "driver/tcpm/fusb302.h"
|
||||
#include "driver/temp_sensor/tmp432.h"
|
||||
@@ -173,8 +173,6 @@ uint16_t tcpc_get_alert_status(void)
|
||||
|
||||
int board_set_active_charge_port(int charge_port)
|
||||
{
|
||||
enum bd9995x_charge_port bd9995x_port;
|
||||
int bd9995x_port_select = 1;
|
||||
static int initialized;
|
||||
|
||||
/*
|
||||
@@ -197,11 +195,10 @@ int board_set_active_charge_port(int charge_port)
|
||||
/* Don't charge from a source port */
|
||||
if (board_vbus_source_enabled(charge_port))
|
||||
return -1;
|
||||
bd9995x_port = bd9995x_pd_port_to_chg_port(charge_port);
|
||||
rt946x_enable_charger_boost(1);
|
||||
break;
|
||||
case CHARGE_PORT_NONE:
|
||||
bd9995x_port_select = 0;
|
||||
bd9995x_port = BD9995X_CHARGE_PORT_BOTH;
|
||||
rt946x_enable_charger_boost(0);
|
||||
break;
|
||||
default:
|
||||
panic("Invalid charge port\n");
|
||||
@@ -209,7 +206,7 @@ int board_set_active_charge_port(int charge_port)
|
||||
}
|
||||
|
||||
initialized = 1;
|
||||
return bd9995x_select_input_port(bd9995x_port, bd9995x_port_select);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
void board_set_charge_limit(int port, int supplier, int charge_ma,
|
||||
@@ -240,7 +237,7 @@ int extpower_is_present(void)
|
||||
if (board_vbus_source_enabled(0))
|
||||
return 0;
|
||||
else
|
||||
return bd9995x_is_vbus_provided(BD9995X_CHARGE_PORT_VBUS);
|
||||
return rt946x_is_vbus_ready();
|
||||
}
|
||||
|
||||
int pd_snk_is_vbus_provided(int port)
|
||||
@@ -248,7 +245,7 @@ int pd_snk_is_vbus_provided(int port)
|
||||
if (port)
|
||||
panic("Invalid charge port\n");
|
||||
|
||||
return bd9995x_is_vbus_provided(BD9995X_CHARGE_PORT_VBUS);
|
||||
return rt946x_is_vbus_ready();
|
||||
}
|
||||
|
||||
static void board_spi_enable(void)
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#define CONFIG_VBOOT_HASH
|
||||
|
||||
#define CONFIG_CHARGER
|
||||
#define CONFIG_CHARGER_BD99955
|
||||
#define CONFIG_CHARGER_RT9466
|
||||
#define CONFIG_CHARGER_INPUT_CURRENT 512
|
||||
#define CONFIG_CHARGER_MAINTAIN_VBAT
|
||||
#define CONFIG_CHARGER_V2
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
*/
|
||||
|
||||
#include "atomic.h"
|
||||
#include "charger.h"
|
||||
#include "charge_manager.h"
|
||||
#include "common.h"
|
||||
#include "console.h"
|
||||
#include "driver/charger/bd9995x.h"
|
||||
#include "driver/charger/rt946x.h"
|
||||
#include "gpio.h"
|
||||
#include "hooks.h"
|
||||
#include "host_command.h"
|
||||
@@ -53,33 +54,21 @@ void pd_transition_voltage(int idx)
|
||||
}
|
||||
|
||||
static uint8_t vbus_en;
|
||||
static uint8_t vbus_rp = TYPEC_RP_1A5;
|
||||
|
||||
int board_vbus_source_enabled(int port)
|
||||
{
|
||||
return vbus_en;
|
||||
}
|
||||
|
||||
static void board_vbus_update_source_current(int port)
|
||||
{
|
||||
/*
|
||||
* TODO(philipchen): Remove this function and fix wherever
|
||||
* this function is called after RT946x driver is hooked up.
|
||||
*/
|
||||
}
|
||||
|
||||
int pd_set_power_supply_ready(int port)
|
||||
{
|
||||
/* Ensure we're not charging from this port */
|
||||
bd9995x_select_input_port(bd9995x_pd_port_to_chg_port(port), 0);
|
||||
|
||||
/* Ensure we advertise the proper available current quota */
|
||||
charge_manager_source_port(port, 1);
|
||||
|
||||
pd_set_vbus_discharge(port, 0);
|
||||
/* Provide VBUS */
|
||||
vbus_en = 1;
|
||||
board_vbus_update_source_current(port);
|
||||
charger_enable_otg_power(1);
|
||||
|
||||
/* notify host of power info change */
|
||||
pd_send_host_event(PD_EVENT_POWER_CHANGE);
|
||||
@@ -94,7 +83,7 @@ void pd_power_supply_reset(int port)
|
||||
prev_en = vbus_en;
|
||||
/* Disable VBUS */
|
||||
vbus_en = 0;
|
||||
board_vbus_update_source_current(port);
|
||||
charger_enable_otg_power(0);
|
||||
/* Enable discharge if we were previously sourcing 5V */
|
||||
if (prev_en)
|
||||
pd_set_vbus_discharge(port, 1);
|
||||
@@ -132,10 +121,7 @@ void typec_set_input_current_limit(int port, uint32_t max_ma,
|
||||
|
||||
void typec_set_source_current_limit(int port, int rp)
|
||||
{
|
||||
vbus_rp = rp;
|
||||
|
||||
/* change the GPIO driving the load switch if needed */
|
||||
board_vbus_update_source_current(port);
|
||||
/* No-operation */
|
||||
}
|
||||
|
||||
int pd_board_checks(void)
|
||||
|
||||
Reference in New Issue
Block a user