From bc1690366776fb65d8fa773c2f74c4f71f5059e5 Mon Sep 17 00:00:00 2001 From: Todd Broch Date: Mon, 24 Nov 2014 10:20:41 -0800 Subject: pd: Re-factor common flash vdms. CL to migrate the flashing VDMs from zinger's custom vdm to common/usb_pd_flash.c such that other updateable type-C devices can share. Additionally adds gaskets to call standard runtime flashing facilities for USB-PD devices using it. Signed-off-by: Todd Broch BRANCH=samus BUG=chrome-os-partner:31192,chrome-os-partner:31193 TEST=manual, Try following: 1. From samus_pd console w/ zinger in port 1 pd 1 flash version pd 1 flash reboot pd 1 flash info 2. From samus linux prompt w/ zinger in port 1 ectool --name cros_pd flashpd 1 1 Reading 16384 bytes from /usr/local/zinger_v1.1.2528-d809e42.ec.RW.bin... Erasing expected RW hash Rebooting Erasing RW flash Writing RW flash Rebooting PD into new RW Complete 3. Repeat 1&2 above on hoho & dingdong. Change-Id: I018055fa9de128f937c57debdc21dea026137bcf Reviewed-on: https://chromium-review.googlesource.com/231835 Reviewed-by: Vincent Palatin Reviewed-by: Alec Berg Tested-by: Todd Broch Commit-Queue: Todd Broch --- board/dingdong/usb_pd_policy.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'board/dingdong') diff --git a/board/dingdong/usb_pd_policy.c b/board/dingdong/usb_pd_policy.c index a09a432492..2a3c027e61 100644 --- a/board/dingdong/usb_pd_policy.c +++ b/board/dingdong/usb_pd_policy.c @@ -287,23 +287,18 @@ static int pd_custom_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) { int cmd = PD_VDO_CMD(payload[0]); - int rsize = 1; + int rsize; + + if (PD_VDO_VID(payload[0]) != USB_VID_GOOGLE || !gfu_mode) + return 0; + CPRINTF("VDM/%d [%d] %08x\n", cnt, cmd, payload[0]); *rpayload = payload; - switch (cmd) { - case VDO_CMD_VERSION: - memcpy(payload + 1, &version_data.version, 24); - rsize = 7; - break; - case VDO_CMD_READ_INFO: - /* copy info into response */ - pd_get_info(payload + 1); - rsize = 7; - break; - default: - rsize = 0; - } + + rsize = pd_custom_flash_vdm(port, cnt, payload); + if (!rsize) + return 0; CPRINTS("DONE"); /* respond (positively) to the request */ -- cgit v1.2.1