summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-03-11 13:02:54 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-26 01:46:55 +0000
commit7067007b214c8d4973b58531e5e40830ed8c9e7b (patch)
treea680623c05582c801bc2cb82789fff73db7bc996 /board
parentddf77bbe785a5ae1c701ef70fb6e41a89168e341 (diff)
downloadchrome-ec-7067007b214c8d4973b58531e5e40830ed8c9e7b.tar.gz
honeybuns: transform into a real multi-voltage PD source
Switch it to a source-only PD device (as it is) and add the voltage selection code. For now, output 12V only for 20V request as the 5V->20V transition is not monotonic, triggering disconnection detection. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:37078 chrome-os-partner:41860 TEST=connect to Samus and see it negotiate 5V then 20V, then manually switch to 12V. Change-Id: I4fc198245999ff9ce8fec929f305681043d72965 Reviewed-on: https://chromium-review.googlesource.com/259113 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/honeybuns/board.h2
-rw-r--r--board/honeybuns/gpio.inc2
-rw-r--r--board/honeybuns/usb_pd_policy.c50
3 files changed, 39 insertions, 15 deletions
diff --git a/board/honeybuns/board.h b/board/honeybuns/board.h
index ec336bfd66..085c057d91 100644
--- a/board/honeybuns/board.h
+++ b/board/honeybuns/board.h
@@ -27,7 +27,7 @@
#define CONFIG_USB_PD_ALT_MODE
#undef CONFIG_USB_PD_ALT_MODE_DFP
#define CONFIG_USB_PD_CUSTOM_VDM
-#define CONFIG_USB_PD_DUAL_ROLE
+#undef CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_INTERNAL_COMP
#define CONFIG_USB_PD_PORT_COUNT 1
#define CONFIG_USB_PD_TCPC
diff --git a/board/honeybuns/gpio.inc b/board/honeybuns/gpio.inc
index 94b136acfb..e18f30ff11 100644
--- a/board/honeybuns/gpio.inc
+++ b/board/honeybuns/gpio.inc
@@ -17,6 +17,7 @@ GPIO(PD_TX_DATA, PIN(B, 4), GPIO_OUT_LOW)
/* Power and muxes control */
GPIO(PP20000_EN, PIN(A, 8), GPIO_OUT_LOW)
+GPIO(PP12000_EN, PIN(A, 14), GPIO_OUT_LOW)
GPIO(PPVAR_VBUS_EN, PIN(B, 12), GPIO_OUT_LOW)
GPIO(SS_MUX_OE_L, PIN(B, 13), GPIO_OUT_HIGH)
GPIO(SS_MUX_SEL, PIN(B, 14), GPIO_OUT_LOW)
@@ -40,7 +41,6 @@ GPIO(MASTER_I2C_SDA, PIN(B, 7), GPIO_INPUT)
/* Test points */
GPIO(TP6, PIN(A, 13), GPIO_OUT_HIGH /*GPIO_ODR_HIGH*/)
-GPIO(TP7, PIN(A, 14), GPIO_OUT_LOW /*GPIO_ODR_HIGH*/)
/* Unimplemented signals which we need to emulate for now */
UNIMPLEMENTED(ENTERING_RW)
diff --git a/board/honeybuns/usb_pd_policy.c b/board/honeybuns/usb_pd_policy.c
index 1debb03ed6..f9d6caf858 100644
--- a/board/honeybuns/usb_pd_policy.c
+++ b/board/honeybuns/usb_pd_policy.c
@@ -19,20 +19,24 @@
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args)
-#define PDO_FIXED_FLAGS (PDO_FIXED_EXTERNAL | PDO_FIXED_DUAL_ROLE | \
- PDO_FIXED_DATA_SWAP)
+#define PDO_FIXED_FLAGS (PDO_FIXED_EXTERNAL | PDO_FIXED_DATA_SWAP)
-const uint32_t pd_src_pdo[] = {
- PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS),
- PDO_FIXED(12000, 3000, PDO_FIXED_FLAGS),
- PDO_FIXED(20000, 3000, PDO_FIXED_FLAGS),
+/* Voltage indexes for the PDOs */
+enum volt_idx {
+ PDO_IDX_5V = 0,
+ PDO_IDX_12V = 1,
+ PDO_IDX_20V = 2,
+
+ PDO_IDX_COUNT
};
-const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo);
-const uint32_t pd_snk_pdo[] = {
- PDO_FIXED(5000, 500, PDO_FIXED_FLAGS),
+const uint32_t pd_src_pdo[] = {
+ [PDO_IDX_5V] = PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS),
+ [PDO_IDX_12V] = PDO_FIXED(12000, 3000, PDO_FIXED_FLAGS),
+ [PDO_IDX_20V] = PDO_FIXED(20000, 3000, PDO_FIXED_FLAGS),
};
-const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo);
+const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo);
+BUILD_ASSERT(ARRAY_SIZE(pd_src_pdo) == PDO_IDX_COUNT);
/* Holds valid object position (opos) for entered mode */
static int alt_mode[PD_AMODE_COUNT];
@@ -78,7 +82,25 @@ int pd_check_requested_voltage(uint32_t rdo)
void pd_transition_voltage(int idx)
{
- /* No-operation: we are always 5V */
+ /* PDO index are starting from 1 */
+ switch (idx - 1) {
+ case PDO_IDX_20V:
+#if 0
+ gpio_set_level(GPIO_PPVAR_VBUS_EN, 0);
+ gpio_set_level(GPIO_PP20000_EN, 1);
+ break;
+#endif /* 20V transition is broken, putting 12V instead: fall-through */
+ case PDO_IDX_12V:
+ gpio_set_level(GPIO_PP12000_EN, 1);
+ gpio_set_level(GPIO_PP20000_EN, 0);
+ gpio_set_level(GPIO_PPVAR_VBUS_EN, 1);
+ break;
+ case PDO_IDX_5V:
+ default:
+ gpio_set_level(GPIO_PP12000_EN, 0);
+ gpio_set_level(GPIO_PP20000_EN, 0);
+ gpio_set_level(GPIO_PPVAR_VBUS_EN, 1);
+ }
}
int pd_set_power_supply_ready(int port)
@@ -92,6 +114,8 @@ void pd_power_supply_reset(int port)
{
/* Kill VBUS */
gpio_set_level(GPIO_PPVAR_VBUS_EN, 0);
+ gpio_set_level(GPIO_PP12000_EN, 0);
+ gpio_set_level(GPIO_PP20000_EN, 0);
}
int pd_snk_is_vbus_provided(int port)
@@ -106,8 +130,8 @@ int pd_board_checks(void)
int pd_check_power_swap(int port)
{
- /* Always allow power swap */
- return 1;
+ /* We are source-only */
+ return 0;
}
int pd_check_data_swap(int port, int data_role)