diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-10-18 23:03:09 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-05 19:24:34 +0000 |
commit | a311557a3165950a5ef3d0a36e46764ecb428f32 (patch) | |
tree | bad21b73cb0cf601d06e1913a1d209096bdbb69e /baseboard | |
parent | c1c881e4c88b298f34a5e776ec2bb1291a4c3d4d (diff) | |
download | chrome-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 'baseboard')
-rw-r--r-- | baseboard/ite_evb/build.mk | 2 | ||||
-rw-r--r-- | baseboard/ite_evb/usb_pd_pdo.c | 23 | ||||
-rw-r--r-- | baseboard/ite_evb/usb_pd_pdo.h | 20 | ||||
-rw-r--r-- | baseboard/ite_evb/usb_pd_policy.c | 22 | ||||
-rw-r--r-- | baseboard/kalista/build.mk | 2 | ||||
-rw-r--r-- | baseboard/kalista/usb_pd_pdo.c | 17 | ||||
-rw-r--r-- | baseboard/kalista/usb_pd_pdo.h | 15 | ||||
-rw-r--r-- | baseboard/kalista/usb_pd_policy.c | 10 |
8 files changed, 79 insertions, 32 deletions
diff --git a/baseboard/ite_evb/build.mk b/baseboard/ite_evb/build.mk index 77352145ee..507222e6b3 100644 --- a/baseboard/ite_evb/build.mk +++ b/baseboard/ite_evb/build.mk @@ -7,4 +7,4 @@ # baseboard-y=baseboard.o -baseboard-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o +baseboard-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o usb_pd_pdo.o diff --git a/baseboard/ite_evb/usb_pd_pdo.c b/baseboard/ite_evb/usb_pd_pdo.c new file mode 100644 index 0000000000..24cbc8b996 --- /dev/null +++ b/baseboard/ite_evb/usb_pd_pdo.c @@ -0,0 +1,23 @@ +/* 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" + +#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP |\ + PDO_FIXED_UNCONSTRAINED | PDO_FIXED_COMM_CAP) + +const uint32_t pd_src_pdo[] = { + PDO_FIXED(5000, 1500, PDO_FIXED_FLAGS), +}; +const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); + +const uint32_t pd_snk_pdo[] = { + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), + PDO_BATT(4500, 14000, 10000), + PDO_VAR(4500, 14000, 3000), +}; +const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); diff --git a/baseboard/ite_evb/usb_pd_pdo.h b/baseboard/ite_evb/usb_pd_pdo.h new file mode 100644 index 0000000000..ce3300cc7d --- /dev/null +++ b/baseboard/ite_evb/usb_pd_pdo.h @@ -0,0 +1,20 @@ +/* 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_BASEBOARD_ITE_EVB_USB_PD_PDO_H +#define __CROS_EC_BASEBOARD_ITE_EVB_USB_PD_PDO_H + +#include "config.h" +#include "stdint.h" + +/* Threshold voltage of VBUS provided (mV) */ +#define PD_VBUS_PROVIDED_THRESHOLD 3900 + +extern const uint32_t pd_src_pdo[1]; +extern const int pd_src_pdo_cnt; +extern const uint32_t pd_snk_pdo[3]; +extern const int pd_snk_pdo_cnt; + +#endif /* __CROS_EC_BASEBOARD_ITE_EVB_USB_PD_PDO_H */ diff --git a/baseboard/ite_evb/usb_pd_policy.c b/baseboard/ite_evb/usb_pd_policy.c index 59f3da13f5..b5462bd1e2 100644 --- a/baseboard/ite_evb/usb_pd_policy.c +++ b/baseboard/ite_evb/usb_pd_policy.c @@ -18,31 +18,11 @@ #include "timer.h" #include "util.h" #include "usb_mux.h" +#include "usb_pd_pdo.h" #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) -/* ---------------- Power Data Objects (PDOs) ----------------- */ -#ifdef CONFIG_USB_PD_CUSTOM_PDO -#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP |\ - PDO_FIXED_UNCONSTRAINED | PDO_FIXED_COMM_CAP) - -/* Threshold voltage of VBUS provided (mV) */ -#define PD_VBUS_PROVIDED_THRESHOLD 3900 - -const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 1500, PDO_FIXED_FLAGS), -}; -const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); - -const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), - PDO_BATT(4500, 14000, 10000), - PDO_VAR(4500, 14000, 3000), -}; -const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); -#endif - int pd_is_max_request_allowed(void) { /* Max voltage request allowed */ diff --git a/baseboard/kalista/build.mk b/baseboard/kalista/build.mk index e64b6a2d71..85270d4bd4 100644 --- a/baseboard/kalista/build.mk +++ b/baseboard/kalista/build.mk @@ -8,4 +8,4 @@ baseboard-y=baseboard.o baseboard-y+=led.o -baseboard-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o
\ No newline at end of file +baseboard-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o usb_pd_pdo.o
\ No newline at end of file diff --git a/baseboard/kalista/usb_pd_pdo.c b/baseboard/kalista/usb_pd_pdo.c new file mode 100644 index 0000000000..0addbcc51c --- /dev/null +++ b/baseboard/kalista/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" + +#define PDO_FIXED_FLAGS (PDO_FIXED_UNCONSTRAINED | \ + PDO_FIXED_DATA_SWAP | \ + PDO_FIXED_COMM_CAP) + +const uint32_t pd_src_pdo[] = { + PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS), +}; +const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); diff --git a/baseboard/kalista/usb_pd_pdo.h b/baseboard/kalista/usb_pd_pdo.h new file mode 100644 index 0000000000..1dad035d3d --- /dev/null +++ b/baseboard/kalista/usb_pd_pdo.h @@ -0,0 +1,15 @@ +/* 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_BASEBOARD_KALISTA_USB_PD_PDO_H +#define __CROS_EC_BASEBOARD_KALISTA_USB_PD_PDO_H + +#include "config.h" +#include "stdint.h" + +extern const uint32_t pd_src_pdo[1]; +extern const int pd_src_pdo_cnt; + +#endif /* __CROS_EC_BASEBOARD_KALISTA_USB_PD_PDO_H */ diff --git a/baseboard/kalista/usb_pd_policy.c b/baseboard/kalista/usb_pd_policy.c index 89af4b50fb..85b26aac76 100644 --- a/baseboard/kalista/usb_pd_policy.c +++ b/baseboard/kalista/usb_pd_policy.c @@ -20,20 +20,12 @@ #include "util.h" #include "usb_mux.h" #include "usb_pd.h" +#include "usb_pd_pdo.h" #include "usb_pd_tcpm.h" #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) -#define PDO_FIXED_FLAGS (PDO_FIXED_UNCONSTRAINED | \ - PDO_FIXED_DATA_SWAP | \ - PDO_FIXED_COMM_CAP) - -const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS), -}; -const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); - int board_vbus_source_enabled(int port) { if (port != 0) |