summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2014-10-23 16:46:05 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-26 23:47:14 +0000
commit2eb6cba5bd049bc74f84691dda7abcec650a9d10 (patch)
treebfc545fb53f8121887b3837adf65dbc372a7a6a7 /board
parenta08c2d579e099580c033f99e56b2130ff8383a97 (diff)
downloadchrome-ec-2eb6cba5bd049bc74f84691dda7abcec650a9d10.tar.gz
charge_manager: Move supplier list and priority hierarchy to board
Allow the list of charge suppliers and port selection priority to be specified at the board level. BUG=chrome-os-partner:32650 TEST=Manual on samus_pd. Plug + unplug PD and BC1.2 chargers, verify that PD is always preferred and higher power port / supplier is always selected. BRANCH=Samus Change-Id: Ic867a40120c809111bf76bf290ed6f204eab1168 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225292 Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/samus_pd/board.c8
-rw-r--r--board/samus_pd/board.h12
-rw-r--r--board/samus_pd/usb_pd_policy.c1
3 files changed, 20 insertions, 1 deletions
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c
index 9c46b97952..74b0bf9b19 100644
--- a/board/samus_pd/board.c
+++ b/board/samus_pd/board.c
@@ -40,6 +40,14 @@ const struct pwm_t pwm_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+/* Charge supplier priority: lower number indicates higher priority. */
+const int supplier_priority[] = {
+ [CHARGE_SUPPLIER_PD] = 0,
+ [CHARGE_SUPPLIER_TYPEC] = 1,
+ [CHARGE_SUPPLIER_BC12] = 1,
+};
+BUILD_ASSERT(ARRAY_SIZE(supplier_priority) == CHARGE_SUPPLIER_COUNT);
+
void vbus0_evt(enum gpio_signal signal)
{
ccprintf("VBUS %d, %d!\n", signal, gpio_get_level(signal));
diff --git a/board/samus_pd/board.h b/board/samus_pd/board.h
index 8729cdc2a2..06fae2e79e 100644
--- a/board/samus_pd/board.h
+++ b/board/samus_pd/board.h
@@ -67,7 +67,6 @@
#define TIM_CLOCK32 2
#define TIM_ADC 3
-#include "charge_manager.h"
#include "gpio_signal.h"
/* ADC signal */
@@ -87,6 +86,17 @@ enum pwm_channel {
PWM_CH_COUNT
};
+/* Charge suppliers */
+enum charge_supplier {
+ CHARGE_SUPPLIER_PD,
+ CHARGE_SUPPLIER_TYPEC,
+ CHARGE_SUPPLIER_BC12,
+ CHARGE_SUPPLIER_COUNT
+};
+
+/* supplier_priority table defined in board.c */
+extern const int supplier_priority[];
+
/* Charge current limit min / max, based on PWM duty cycle */
#define PWM_0_MA 500
#define PWM_100_MA 4000
diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c
index ea297b8c13..99eebf3f0d 100644
--- a/board/samus_pd/usb_pd_policy.c
+++ b/board/samus_pd/usb_pd_policy.c
@@ -4,6 +4,7 @@
*/
#include "atomic.h"
+#include "charge_manager.h"
#include "common.h"
#include "console.h"
#include "gpio.h"