summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
Diffstat (limited to 'board')
-rw-r--r--board/glados/board.c9
-rw-r--r--board/kunimitsu/board.c9
-rw-r--r--board/lucid/board.c10
-rw-r--r--board/oak/board.c10
-rw-r--r--board/ryu/board.c14
-rw-r--r--board/ryu_p4p5/board.c14
-rw-r--r--board/samus_pd/board.c17
7 files changed, 33 insertions, 50 deletions
diff --git a/board/glados/board.c b/board/glados/board.c
index 208357700d..7537558266 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -39,9 +39,6 @@
#define I2C_ADDR_BD99992 0x60
-/* Default input current limit when VBUS is present */
-#define DEFAULT_CURR_LIMIT 500 /* mA */
-
/* Exchange status with PD MCU. */
static void pd_mcu_interrupt(enum gpio_signal signal)
{
@@ -58,8 +55,8 @@ static void update_vbus_supplier(int port, int vbus_level)
* ourselves, then update the VBUS supplier.
*/
if (!vbus_level || !usb_charger_port_is_sourcing_vbus(port)) {
- charge.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge.current = vbus_level ? DEFAULT_CURR_LIMIT : 0;
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge.current = vbus_level ? USB_CHARGER_MIN_CURR_MA : 0;
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS,
port,
&charge);
@@ -226,7 +223,7 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_USB_C1_VBUS_WAKE_L);
/* Initialize all pericom charge suppliers to 0 */
- charge_none.voltage = USB_BC12_CHARGE_VOLTAGE;
+ charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
charge_none.current = 0;
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY,
diff --git a/board/kunimitsu/board.c b/board/kunimitsu/board.c
index 11ec67f3be..001a88059c 100644
--- a/board/kunimitsu/board.c
+++ b/board/kunimitsu/board.c
@@ -44,9 +44,6 @@
#define GPIO_KB_OUTPUT (GPIO_ODR_HIGH)
#define GPIO_KB_OUTPUT_COL2 (GPIO_OUT_LOW)
-/* Default input current limit when VBUS is present */
-#define DEFAULT_CURR_LIMIT 500 /* mA */
-
/* Exchange status with PD MCU. */
static void pd_mcu_interrupt(enum gpio_signal signal)
{
@@ -63,8 +60,8 @@ static void update_vbus_supplier(int port, int vbus_level)
* ourselves, then update the VBUS supplier.
*/
if (!vbus_level || !usb_charger_port_is_sourcing_vbus(port)) {
- charge.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge.current = vbus_level ? DEFAULT_CURR_LIMIT : 0;
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge.current = vbus_level ? USB_CHARGER_MIN_CURR_MA : 0;
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS,
port,
&charge);
@@ -317,7 +314,7 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_USB_C1_VBUS_WAKE_L);
/* Initialize all pericom charge suppliers to 0 */
- charge_none.voltage = USB_BC12_CHARGE_VOLTAGE;
+ charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
charge_none.current = 0;
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY,
diff --git a/board/lucid/board.c b/board/lucid/board.c
index 7379dfcc25..4fadc6083c 100644
--- a/board/lucid/board.c
+++ b/board/lucid/board.c
@@ -16,13 +16,11 @@
#include "i2c.h"
#include "registers.h"
#include "task.h"
+#include "usb_charge.h"
#include "util.h"
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-/* Default input current limit when VBUS is present */
-#define DEFAULT_CURR_LIMIT 500 /* mA */
-
void board_config_pre_init(void)
{
/* enable SYSCFG clock */
@@ -45,8 +43,8 @@ static void update_vbus_supplier(int vbus_level)
{
struct charge_port_info charge;
- charge.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge.current = vbus_level ? DEFAULT_CURR_LIMIT : 0;
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge.current = vbus_level ? USB_CHARGER_MIN_CURR_MA : 0;
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0, &charge);
}
@@ -99,7 +97,7 @@ static void board_init(void)
* TODO: use built-in USB peripheral to detect BC1.2 suppliers an
* update charge manager.
*/
- charge_none.voltage = USB_BC12_CHARGE_VOLTAGE;
+ charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
charge_none.current = 0;
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY,
diff --git a/board/oak/board.c b/board/oak/board.c
index bf94c726e2..1fef68fb3c 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -32,6 +32,7 @@
#include "temp_sensor_chip.h"
#include "thermal.h"
#include "timer.h"
+#include "usb_charge.h"
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
@@ -43,9 +44,6 @@
#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH)
#define GPIO_KB_OUTPUT GPIO_ODR_HIGH
-/* Default input current limit when VBUS is present */
-#define DEFAULT_CURR_LIMIT 500 /* mA */
-
/* Dispaly port hardware can connect to port 0, 1 or neither. */
#define PD_PORT_NONE -1
@@ -237,10 +235,10 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_AP_RESET_L);
#endif
- charge_none.voltage = USB_BC12_CHARGE_VOLTAGE;
+ charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
charge_none.current = 0;
- charge_vbus.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge_vbus.current = DEFAULT_CURR_LIMIT;
+ charge_vbus.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge_vbus.current = USB_CHARGER_MIN_CURR_MA;
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
/* Initialize all pericom charge suppliers to 0 */
charge_manager_update_charge(
diff --git a/board/ryu/board.c b/board/ryu/board.c
index 7fd2178cdc..f11d0c0763 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -31,6 +31,7 @@
#include "spi.h"
#include "task.h"
#include "usb.h"
+#include "usb_charge.h"
#include "usb_pd.h"
#include "usb_spi.h"
#include "usb-stm32f3.h"
@@ -41,9 +42,6 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-/* Default input current limit when VBUS is present */
-#define DEFAULT_CURR_LIMIT 500 /* mA */
-
/* VBUS too low threshold */
#define VBUS_LOW_THRESHOLD_MV 4600
@@ -81,8 +79,8 @@ void vbus_evt(enum gpio_signal signal)
* ourselves, then update the VBUS supplier.
*/
if (!vbus_level || !gpio_get_level(GPIO_CHGR_OTG)) {
- charge.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge.current = vbus_level ? DEFAULT_CURR_LIMIT : 0;
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge.current = vbus_level ? USB_CHARGER_MIN_CURR_MA : 0;
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0, &charge);
}
@@ -175,7 +173,7 @@ static void board_init(void)
struct charge_port_info charge_none, charge_vbus;
/* Initialize all pericom charge suppliers to 0 */
- charge_none.voltage = USB_BC12_CHARGE_VOLTAGE;
+ charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
charge_none.current = 0;
charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY,
0,
@@ -186,8 +184,8 @@ static void board_init(void)
charge_manager_update_charge(CHARGE_SUPPLIER_OTHER, 0, &charge_none);
/* Initialize VBUS supplier based on whether or not VBUS is present */
- charge_vbus.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge_vbus.current = DEFAULT_CURR_LIMIT;
+ charge_vbus.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge_vbus.current = USB_CHARGER_MIN_CURR_MA;
if (gpio_get_level(GPIO_CHGR_ACOK))
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0,
&charge_vbus);
diff --git a/board/ryu_p4p5/board.c b/board/ryu_p4p5/board.c
index 2432eac06e..7c1acf71e5 100644
--- a/board/ryu_p4p5/board.c
+++ b/board/ryu_p4p5/board.c
@@ -29,6 +29,7 @@
#include "spi.h"
#include "task.h"
#include "usb.h"
+#include "usb_charge.h"
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_spi.h"
@@ -40,9 +41,6 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-/* Default input current limit when VBUS is present */
-#define DEFAULT_CURR_LIMIT 500 /* mA */
-
/* VBUS too low threshold */
#define VBUS_LOW_THRESHOLD_MV 4600
@@ -80,8 +78,8 @@ void vbus_evt(enum gpio_signal signal)
* ourselves, then update the VBUS supplier.
*/
if (!vbus_level || !gpio_get_level(GPIO_USBC_5V_EN)) {
- charge.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge.current = vbus_level ? DEFAULT_CURR_LIMIT : 0;
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge.current = vbus_level ? USB_CHARGER_MIN_CURR_MA : 0;
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0, &charge);
}
@@ -185,7 +183,7 @@ static void board_init(void)
usb_muxes[0].driver = &p4_board_custom_usb_mux_driver;
/* Initialize all pericom charge suppliers to 0 */
- charge_none.voltage = USB_BC12_CHARGE_VOLTAGE;
+ charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
charge_none.current = 0;
charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY,
0,
@@ -196,8 +194,8 @@ static void board_init(void)
charge_manager_update_charge(CHARGE_SUPPLIER_OTHER, 0, &charge_none);
/* Initialize VBUS supplier based on whether or not VBUS is present */
- charge_vbus.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge_vbus.current = DEFAULT_CURR_LIMIT;
+ charge_vbus.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge_vbus.current = USB_CHARGER_MIN_CURR_MA;
if (gpio_get_level(GPIO_CHGR_ACOK))
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0,
&charge_vbus);
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c
index c162f760a1..2325f7090d 100644
--- a/board/samus_pd/board.c
+++ b/board/samus_pd/board.c
@@ -33,9 +33,6 @@
/* Amount to offset the input current limit when sending to EC */
#define INPUT_CURRENT_LIMIT_OFFSET_MA 192
-/* Default input current limit when VBUS is present */
-#define DEFAULT_CURR_LIMIT 500 /* mA */
-
/*
* When battery is high, system may not be pulling full current. Also, when
* high AND input voltage is below boost bypass, then limit input current
@@ -120,8 +117,8 @@ void vbus0_evt(enum gpio_signal signal)
* ourselves, then update the VBUS supplier.
*/
if (!vbus_level || !gpio_get_level(GPIO_USB_C0_5V_EN)) {
- charge.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge.current = vbus_level ? DEFAULT_CURR_LIMIT : 0;
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge.current = vbus_level ? USB_CHARGER_MIN_CURR_MA : 0;
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0, &charge);
}
@@ -146,8 +143,8 @@ void vbus1_evt(enum gpio_signal signal)
* ourselves, then update the VBUS supplier.
*/
if (!vbus_level || !gpio_get_level(GPIO_USB_C1_5V_EN)) {
- charge.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge.current = vbus_level ? DEFAULT_CURR_LIMIT : 0;
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge.current = vbus_level ? USB_CHARGER_MIN_CURR_MA : 0;
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 1, &charge);
}
@@ -288,7 +285,7 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_USB_C1_VBUS_WAKE);
/* Initialize all pericom charge suppliers to 0 */
- charge_none.voltage = USB_BC12_CHARGE_VOLTAGE;
+ charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
charge_none.current = 0;
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY,
@@ -309,8 +306,8 @@ static void board_init(void)
}
/* Initialize VBUS supplier based on whether or not VBUS is present */
- charge_vbus.voltage = USB_BC12_CHARGE_VOLTAGE;
- charge_vbus.current = DEFAULT_CURR_LIMIT;
+ charge_vbus.voltage = USB_CHARGER_VOLTAGE_MV;
+ charge_vbus.current = USB_CHARGER_MIN_CURR_MA;
if (gpio_get_level(GPIO_USB_C0_VBUS_WAKE))
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, 0,
&charge_vbus);