From d5d2a71c96438a5d545d2fb71f10678409f93c9e Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Thu, 2 Oct 2014 10:07:37 -0700 Subject: pd: zinger: move sending info VDM from UFP to DFP Changed sending of info VDM from the UFP side in SNK_DISCONNECTED to the DFP side in SRC_READY to match the PD spec. Only the DFP is supposed to send VDMs, and by default the power source is the DFP. This affects simple DFPs such as power adapters, they must initiate the info VDM once a power contract has been negotiated. BUG=none BRANCH=samus TEST=load onto samus_pd and zinger and make sure that when you attached zinger to samus, samus receives info VDM and prints out something like: VDM/7 [11] 18d1000b Dev:1 SW:2280 RW:0 Change-Id: I16ceac31939fdc1c74be7323e628dd8706e1283b Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/221174 Reviewed-by: Todd Broch --- board/zinger/board.h | 3 ++- board/zinger/usb_pd_policy.c | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'board/zinger') diff --git a/board/zinger/board.h b/board/zinger/board.h index e7e31232a0..93b7379d37 100644 --- a/board/zinger/board.h +++ b/board/zinger/board.h @@ -19,10 +19,11 @@ /* Optional features */ #define CONFIG_USB_POWER_DELIVERY +#define CONFIG_USB_PD_CUSTOM_VDM #undef CONFIG_USB_PD_DUAL_ROLE #undef CONFIG_USB_PD_INTERNAL_COMP -#define CONFIG_USB_PD_CUSTOM_VDM #undef CONFIG_USB_PD_RX_COMP_IRQ +#define CONFIG_USB_PD_SIMPLE_DFP #define CONFIG_HW_CRC #define CONFIG_RSA #define CONFIG_SHA256 diff --git a/board/zinger/usb_pd_policy.c b/board/zinger/usb_pd_policy.c index c15e79169e..177826bb51 100644 --- a/board/zinger/usb_pd_policy.c +++ b/board/zinger/usb_pd_policy.c @@ -374,10 +374,25 @@ void pd_adc_interrupt(void) DECLARE_IRQ(STM32_IRQ_ADC_COMP, pd_adc_interrupt, 1); /* ----------------- Vendor Defined Messages ------------------ */ +static uint32_t info_data[6]; +uint32_t *pd_get_info(void) +{ + void *hash; + + /* calculate RW hash */ + hash = flash_hash_rw(); + /* copy first 20 bytes of RW hash */ + memcpy(info_data, hash, 5 * sizeof(uint32_t)); + /* copy other info into data msg */ + info_data[5] = VDO_INFO(USB_PD_HARDWARE_DEVICE_ID, + ver_get_numcommits(), !is_ro_mode()); + + return info_data; +} + int pd_custom_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) { static int flash_offset; - void *hash; int cmd = PD_VDO_CMD(payload[0]); int rsize = 1; debug_printf("%T] VDM/%d [%d] %08x\n", cnt, cmd, payload[0]); @@ -394,13 +409,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) cpu_reset(); break; case VDO_CMD_READ_INFO: - hash = flash_hash_rw(); - /* copy the 20 first bytes of the hash into response */ - memcpy(payload + 1, hash, 5 * sizeof(uint32_t)); - /* copy other info into response */ - payload[6] = VDO_INFO(USB_PD_HARDWARE_DEVICE_ID, - ver_get_numcommits(), - !is_ro_mode()); + /* copy info into response */ + memcpy(payload + 1, pd_get_info(), 24); rsize = 7; break; case VDO_CMD_FLASH_ERASE: -- cgit v1.2.1