summaryrefslogtreecommitdiff
path: root/board/zinger
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-10-18 23:03:09 +0000
committerCommit Bot <commit-bot@chromium.org>2021-11-05 19:24:34 +0000
commita311557a3165950a5ef3d0a36e46764ecb428f32 (patch)
treebad21b73cb0cf601d06e1913a1d209096bdbb69e /board/zinger
parentc1c881e4c88b298f34a5e776ec2bb1291a4c3d4d (diff)
downloadchrome-ec-a311557a3165950a5ef3d0a36e46764ecb428f32.tar.gz
tree: Create usb_pd_pdo.c
genvif depends on usb_pd_policy.c. However, the usb_pd_policy.c files often depend on other symbols that are not included when building genvif. genvif only needs the pd_src_pdo and pd_src_pdo_count variables (and charge_manager_get_source_pdo() in one case). Extract these variables into their own files. BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=zinger -j TEST=make buildall TEST=compare generated *_vif.xml files before and after change: => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I765750cd86243a0a355dcc6a29b80fc23403d99f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3231026 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/zinger')
-rw-r--r--board/zinger/build.mk2
-rw-r--r--board/zinger/usb_pd_pdo.c17
-rw-r--r--board/zinger/usb_pd_pdo.h30
-rw-r--r--board/zinger/usb_pd_policy.c28
4 files changed, 49 insertions, 28 deletions
diff --git a/board/zinger/build.mk b/board/zinger/build.mk
index 566cf34ce0..c85eb9df4b 100644
--- a/board/zinger/build.mk
+++ b/board/zinger/build.mk
@@ -10,4 +10,4 @@ CHIP:=stm32
CHIP_FAMILY:=stm32f0
CHIP_VARIANT:=stm32f03x
-board-y=board.o hardware.o runtime.o usb_pd_policy.o
+board-y=board.o hardware.o runtime.o usb_pd_policy.o usb_pd_pdo.o
diff --git a/board/zinger/usb_pd_pdo.c b/board/zinger/usb_pd_pdo.c
new file mode 100644
index 0000000000..13f8407d6d
--- /dev/null
+++ b/board/zinger/usb_pd_pdo.c
@@ -0,0 +1,17 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "compile_time_macros.h"
+#include "usb_pd.h"
+#include "usb_pd_pdo.h"
+
+/* Power Delivery Objects */
+const uint32_t pd_src_pdo[] = {
+ [PDO_IDX_5V] = PDO_FIXED(5000, RATED_CURRENT, PDO_FIXED_FLAGS),
+ [PDO_IDX_12V] = PDO_FIXED(12000, RATED_CURRENT, PDO_FIXED_FLAGS),
+ [PDO_IDX_20V] = PDO_FIXED(20000, RATED_CURRENT, PDO_FIXED_FLAGS),
+};
+const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo);
+BUILD_ASSERT(ARRAY_SIZE(pd_src_pdo) == PDO_IDX_COUNT);
diff --git a/board/zinger/usb_pd_pdo.h b/board/zinger/usb_pd_pdo.h
new file mode 100644
index 0000000000..07b7129202
--- /dev/null
+++ b/board/zinger/usb_pd_pdo.h
@@ -0,0 +1,30 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_BOARD_ZINGER_USB_PD_PDO_H
+#define __CROS_EC_BOARD_ZINGER_USB_PD_PDO_H
+
+/* Max current */
+#if defined(BOARD_ZINGER)
+#define RATED_CURRENT 3000
+#elif defined(BOARD_MINIMUFFIN)
+#define RATED_CURRENT 2250
+#endif
+
+/* Voltage indexes for the PDOs */
+enum volt_idx {
+ PDO_IDX_5V = 0,
+ PDO_IDX_12V = 1,
+ PDO_IDX_20V = 2,
+
+ PDO_IDX_COUNT
+};
+
+#define PDO_FIXED_FLAGS (PDO_FIXED_UNCONSTRAINED | PDO_FIXED_DATA_SWAP)
+
+extern const uint32_t pd_src_pdo[3];
+extern const int pd_src_pdo_cnt;
+
+#endif /* __CROS_EC_BOARD_ZINGER_USB_PD_PDO_H */
diff --git a/board/zinger/usb_pd_policy.c b/board/zinger/usb_pd_policy.c
index f47789e063..098bb13c0f 100644
--- a/board/zinger/usb_pd_policy.c
+++ b/board/zinger/usb_pd_policy.c
@@ -15,6 +15,7 @@
#include "timer.h"
#include "util.h"
#include "usb_pd.h"
+#include "usb_pd_pdo.h"
/* ------------------------- Power supply control ------------------------ */
@@ -88,13 +89,6 @@ static timestamp_t fault_deadline;
/* convert raw ADC value to mV */
#define ADC_TO_VOLT_MV(vbus) ((vbus)*VOLT_DIV*VDDA_MV/ADC_SCALE)
-/* Max current */
-#if defined(BOARD_ZINGER)
-#define RATED_CURRENT 3000
-#elif defined(BOARD_MINIMUFFIN)
-#define RATED_CURRENT 2250
-#endif
-
/* Max current : 20% over rated current */
#define MAX_CURRENT VBUS_MA(RATED_CURRENT * 6/5)
/* Fast short circuit protection : 50% over rated current */
@@ -154,26 +148,6 @@ static void discharge_voltage(int target_volt)
/* ----------------------- USB Power delivery policy ---------------------- */
-#define PDO_FIXED_FLAGS (PDO_FIXED_UNCONSTRAINED | PDO_FIXED_DATA_SWAP)
-
-/* Voltage indexes for the PDOs */
-enum volt_idx {
- PDO_IDX_5V = 0,
- PDO_IDX_12V = 1,
- PDO_IDX_20V = 2,
-
- PDO_IDX_COUNT
-};
-
-/* Power Delivery Objects */
-const uint32_t pd_src_pdo[] = {
- [PDO_IDX_5V] = PDO_FIXED(5000, RATED_CURRENT, PDO_FIXED_FLAGS),
- [PDO_IDX_12V] = PDO_FIXED(12000, RATED_CURRENT, PDO_FIXED_FLAGS),
- [PDO_IDX_20V] = PDO_FIXED(20000, RATED_CURRENT, PDO_FIXED_FLAGS),
-};
-const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo);
-BUILD_ASSERT(ARRAY_SIZE(pd_src_pdo) == PDO_IDX_COUNT);
-
/* PDO voltages (should match the table above) */
static const struct {
enum volt select; /* GPIO configuration to select the voltage */