summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* cortex-m0: optimize out unused assembly helpersstabilize-6680.79.Bstabilize-6680.78.Brelease-R41-6680.BVincent Palatin2015-01-303-32/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Put each assembly helper function in its own .text.__funcname__ section, so the linker can remove the unused ones. Also remove a few entrypoints used only by deprecated ABIs. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=none TEST=make buildall check the firmware size and see we are saving 88 bytes on Zinger. Original-Change-Id: I6714da671c3449220652780d47993d6c919c331c Reviewed-on: https://chromium-review.googlesource.com/240582 Reviewed-by: Alec Berg <alecaberg@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit e2355ff432dcef946b2f0b260e0de763c31288de) Reviewed-on: https://chromium-review.googlesource.com/240833 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 247fa806db512768fd48a53f5bbee8cd9d12a1c7) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I2deb6053014366ff6c83ed5d5f0981ae02560c60 Reviewed-on: https://chromium-review.googlesource.com/244236 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* fix off-by-one in flash size checkVincent Palatin2015-01-302-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __hey_flash_used is actually a size rather than an offset, it might be equal to flash if we use every single byte. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=none TEST=make buildall with the following CLs, samus_pd uses every single byte of flash. Original-Change-Id: I98ddac73fab80c44ca2743ab2847321d71746752 Reviewed-on: https://chromium-review.googlesource.com/240539 Reviewed-by: Alec Berg <alecaberg@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 03f66537a2bdd039341b03b073c63c6554b8cc10) Reviewed-on: https://chromium-review.googlesource.com/240835 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit a33bd4f9c8fa455bfdfdd8aff47dffb7f22656f0) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I69cfbb3c4bf06bc5753be9825e7086f12e9fe713 Reviewed-on: https://chromium-review.googlesource.com/244235 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* ectool: parse accessory logs for dingdong & hohoTodd Broch2015-01-302-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Todd Broch <tbroch@chromium.org> BUG=chrome-os-partner:35935 TEST=manual # With dingdong in C0 & hoho in C1 # Enter GFU mode for dingdong & hoho ectool --name cros_pd pdsetmode 0 0x18d1 1 1 ectool --name cros_pd pdsetmode 1 0x18d1 1 1 # read logs ectool --name cros_pd pdlog 2015-01-26 14:36:54.787 P0 SRC 2015-01-26 14:36:54.780 P1 SRC 2015-01-26 14:36:53.680 P0 DP mode enabled 2015-01-26 14:36:53.375 P1 HDMI Codec: family:000e chipid:0001 irom:1.0.0 fw:0.0.0 2015-01-26 14:36:53.771 P1 DP mode enabled # remove hoho & plug in zinger instead ectool --name cros_pd pdlog 2015-01-26 14:44:36.991 P1 SNK Charger Type-C 5153mV max 5000mV / 3000mA 2015-01-26 14:44:37.011 P1 SNK Charger PD 5021mV max 20000mV / 3000mA 2015-01-26 14:44:37.116 P1 SNK Charger PD 20211mV max 20000mV / 3000mA Original-Change-Id: I0289cfd1d43ef1a22123b437bc8df86920fbf1a7 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243469 (cherry picked from commit 96b74f1b95ef80d3689fb86baebb6b7db34bbdba) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: Ia5f49784d63b4f7e19af43758c8eab2344b77d80 Reviewed-on: https://chromium-review.googlesource.com/244234 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: Log events for dingdong & hohoTodd Broch2015-01-304-2/+14
| | | | | | | | | | | | | | | | | | | | | Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:35935 TEST=manual, see new events for dingdong & hoho. Note must be in GFU mode to facilitate. Original-Change-Id: I1b79237512748796cf98765a553af8c9978cb594 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243468 (cherry picked from commit db56aabe7019f7837f202df9eae3fbd4aeb8fb7b) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: Ib97ee161389f58a776a6633d997e179c2f2dfd1a Reviewed-on: https://chromium-review.googlesource.com/244233 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: Allow multiple mode entry.Todd Broch2015-01-308-140/+254
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current simplified implementation allows single mode entry. Specification allows multiple mode entry and its advantageous for things like flashing RW while staying in DisplayPort mode on video dongles. CL adds capability on DFP to track as many alternate modes as supported by the DFP. Initial mode entered is still the default supported mode ( 1st entry, 1st opos). Policy manager can then use host command, EC_CMD_USB_PD_SET_AMODE, to enter additional supported modes. On the UFP (hoho, dingdong) a small modification to track multiple svid mode entries was made. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:33946 TEST=manual, On hoho 1. Still successfully enter default mode DP 2. Using ectool's pdsetmode can successfully enter/exit multiple modes. For example, # port:1 svid:18d1 opos:1 cmd:1==enter ectool --name cros_pd pdsetmode 1 0x18d1 1 1 Checking with pdgetmode shows both modes entered. 3. Works across hard & soft resets 4. Can flash via ectool --name cros_pd flashpd 4 <port> <RW image> 5. Still drives external display. With bootarg drm.debug=0x6 and following command: 'tail -f /var/log/messages | grep "Received HPD" &' I see HPD assert & deassert when switching between GFU and DP mode. If both modes entered screen stays lit (after reboot) during write. Original-Change-Id: I7a21ebea377402eb1b0a0cf1d29df59694e301b1 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243466 (cherry picked from commit 4ed51e567c974f47ae39b90ac978e88ca843764c) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I65867b9c754ce8df645562629b94720894e74fdd Reviewed-on: https://chromium-review.googlesource.com/244232 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: Cleanup alternate mode access.Todd Broch2015-01-301-22/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In preparation for supporting multiple mode entry this CL cleans up access to the mode array via get_modep. Follow-on Cls will enhance that to include svid lookup for multi-mode support. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:33946 TEST=manual, On hoho 1. Still successfully enter default mode DP 2. Using ectool's pdsetmode can successfully enter/exit other modes (check w/ pdgetmode) 3. Works across hard & soft resets 4. Can flash via ectool --name cros_pd flashpd 4 <port> <RW image> 5. adding CONFIG_CMD_USB_PD_PE define still works for 'pe dump' 6. Still drives external display. With bootarg drm.debug=0x6 and following command: 'tail -f /var/log/messages | grep "Received HPD" &' I see HPD assert & deassert when switching between GFU and DP mode. Original-Change-Id: I7c50c76034bc0ae73b5b019361291c0ff2c21b2a Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243465 (cherry picked from commit 5ecfd9a7cf143e1b64739f3403de2ffd6852ffcd) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I9e4d865ef613713033a1d077b7c69a273b00183e Reviewed-on: https://chromium-review.googlesource.com/244231 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: refactor object position index.Todd Broch2015-01-304-23/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | Renaming this to 'opos' for consistency with USP-PD specifications 'object position' in VDM header. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:35495 TEST=manual, On hoho 1. Still successfully enter default mode DP 2. Using ectool's pdgetmode pdsetmode can successfully enter/exit other modes 3. Works across hard & soft resets Original-Change-Id: I08cb8e003ced4de481adcb503bcba3437ebb1ab7 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243464 (cherry picked from commit 3850a013f1bf39919633ea9e6a19d2800b52ef2c) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I395a36eee8f4403707dde08053ff98a2dbe6a3a6 Reviewed-on: https://chromium-review.googlesource.com/244230 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* ectool: more compact PD event log formatDuncan Laurie2015-01-301-31/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use one line per entry and display the real time for the events. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:33248 TEST=ectool --name=cros_pd pdlog and see a nice log like: 2015-01-20 15:14:02.974 P0 Disconnected 2015-01-20 15:14:05.676 P0 SNK Charger Type-C 4958mV max 5000mV / 500mA 2015-01-20 15:14:11.810 P1 SRC 2015-01-20 15:14:14.460 P0 Disconnected 2015-01-20 15:14:17.277 P0 SNK Charger Type-C 5185mV max 5000mV / 3000mA 2015-01-20 15:14:17.287 P0 SNK Charger PD 5015mV max 20000mV / 3000mA 2015-01-20 15:14:17.383 P0 SNK Charger PD 20198mV max 20000mV / 3000mA --- END OF LOG --- Reviewed-on: https://chromium-review.googlesource.com/242082 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 194bde63670528c456bcc3b5701d64fd01f8fc1d) Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Original-Change-Id: Ibf189cdb9e5d9ba74cb1fb241a2945439dfb50f7 Reviewed-on: https://chromium-review.googlesource.com/242201 Tested-by: Duncan Laurie <dlaurie@chromium.org> Commit-Queue: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org> (cherry picked from commit a21630e898caad8e9d500ed52c9dd8f628e735fa) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I9d9171d80f3e1a4041d6f78ac0d6f3177d9476ca Reviewed-on: https://chromium-review.googlesource.com/244229 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: export the data role to the APDuncan Laurie2015-01-303-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For dual-role USB ports (host/device), let the AP know whether we are currently DFP (USB host) or UFP (USB device) by exporting the data role in addition to the power role in the EC_CMD_USB_PD_CONTROL response. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=none TEST=ectool --name=cros_pd usbpd 0 plug various accessories on the port and see properly "SRC DFP" for the USB key, "SNK DFP" for the power supply and "SNK UFP" for a regular C-to-A charging cable. Reviewed-on: https://chromium-review.googlesource.com/242012 Reviewed-by: Alec Berg <alecaberg@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 9e07dfb6cb7391844dfd56ba856b30329318f05e) Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Original-Change-Id: I292da15fa8cf3566109dd05995ef1d00bed6f92d Reviewed-on: https://chromium-review.googlesource.com/242128 Tested-by: Duncan Laurie <dlaurie@chromium.org> Commit-Queue: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org> (cherry picked from commit 2808539c0ff1aa4ac693b85bcef70aa23a9e1cd5) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I8ccad1109b03a202c6bc0c43121f5f9a7f381759 Reviewed-on: https://chromium-review.googlesource.com/244228 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: ectool: fix bug in infopddev command.Duncan Laurie2015-01-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change 94515d9e failed to set ec param port prior to sending the host command. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=none TEST=manual, with two devices with different vid:pid see correct values now. Reviewed-on: https://chromium-review.googlesource.com/241951 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> (cherry picked from commit 815cb8486655ade011128c6a2948bda4324dff0f) Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Original-Change-Id: I6a0b9d30905509847c9481c222fa7e3c9a0264a1 Reviewed-on: https://chromium-review.googlesource.com/242132 Tested-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Commit-Queue: Duncan Laurie <dlaurie@chromium.org> (cherry picked from commit 1e162825ab995b3474fcb6faee15489b0680d314) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I7775175a85a0cb55c1cbf55be584b96db91b0ca7 Reviewed-on: https://chromium-review.googlesource.com/244227 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* ectool: Add enter_gfu to support PD flashing.Todd Broch2015-01-301-21/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Flashing PD devices works through ectool but only when device has already entered GFU alternate mode. This CL adds ability to force that entry for devices with default policy engine does not already do that. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:33947 TEST=manual, 1. On hoho flash RW successfully ectool --name cros_pd flashpd 4 1 hoho.ec.RW.bin Original-Change-Id: Idd320cf91644f0c1bff87767ab20049d86aa86c6 Reviewed-on: https://chromium-review.googlesource.com/236959 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> (cherry picked from commit 94515d9ee25c76c7813addff38599636d916931d) Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/241431 (cherry picked from commit a7a826c391ec20e4d9068318fcac053ed0c63cce) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I4cf96ca1f2286935e33fe8405bae118eff1af222 Reviewed-on: https://chromium-review.googlesource.com/244226 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* Add USB-PD mode commands.Todd Broch2015-01-304-13/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These commands (pdgetmode & pdsetmode) will provide host with ability to identify USB-PD alternate mode devices SVIDs and supported modes. It will also allow host to set mode on devices which support multiple alternate modes. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:33946 TEST=manual Plug hoho/dingdong into samus at port <port> ectool --name cros_pd pdgetmode <port> *SVID:0xff01 *0x00001085 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 SVID:0x18d1 0x00000001 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 ectool --name cros_pd pdsetmode <port> 0x18d1 1 ectool --name cros_pd pdgetmode <port> SVID:0xff01 0x00001085 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 *SVID:0x18d1 *0x00000001 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 ectool --name cros_pd infopddev <port> Port:1 DevId:4.1 Hash: 0x042cc79c 0x30cc12e3 0xe27a36e5 0x3f7eba5f 0x053c91d1 Port:1 ptype:5 vid:0x18d1 pid:0x5010 Also from samus_pd console see proper result for 'typec <port>' typec 1 Port C1: CC1 178 mV CC2 427 mV (polarity:CC2) No Superspeed connection Also visually inspect packets via twinkie. Originial-Change-Id: I4e442bcb39ec1ff3cb6efff196a660819077ad76 Reviewed-on: https://chromium-review.googlesource.com/231834 Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit abecc13a87fe445bb52194bc105cd70093bc8739) Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/241430 (cherry picked from commit 409466a7d7c5e30fb806decc3aadc258342fdb91) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: Ie1a314a04007794b1572d1a0830e173b6834b2c5 Reviewed-on: https://chromium-review.googlesource.com/244225 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: log important events for accessoriesVincent Palatin2015-01-305-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Record in the PD log when we fail to verify the RW signature and when the RW partition is erased. Also log the faults on the power supplies. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:32785 TEST=flash a bad rw on Zinger. Original-Change-Id: Ib62dcb0d407867151af0aaecc405533e894d773e Reviewed-on: https://chromium-review.googlesource.com/239913 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 64ada6e3d8220e51a64b30ff15878f1abff11a47) Reviewed-on: https://chromium-review.googlesource.com/240839 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit e5bffd3453b807556307c76bddf5ff52b3cd2208) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: Ie2322d4e9a3caa38786ff7194b7b2ce553695a6b Reviewed-on: https://chromium-review.googlesource.com/244224 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* charge_manager: Log charge-related change eventsShawn Nematbakhsh2015-01-302-138/+246
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the charging events to the PD event log FIFO and add an ectool to retrieve/decode them. BUG=chrome-os-partner:33248 TEST=Manual on Samus. Run `ectool --name cros_pd pdlog`, verify that all log entries are dumped and the content matches expectation. BRANCH=Samus Original-Change-Id: I65dd5696cc0487856ab42aff24134bcdfa1a8219 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238093 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit bd85bc46360e43b74aa1864565c5ad49b719a804) Reviewed-on: https://chromium-review.googlesource.com/240838 (cherry picked from commit 97fe3555e00d21f2e5691fb3a7f8eb3a1c371b62) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I46544529ba34ec57dee4940fa9bb834448e12875 Reviewed-on: https://chromium-review.googlesource.com/244223 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* Add PD events loggingVincent Palatin2015-01-3013-7/+302
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a FIFO to log important events on the PD MCU and coming from the PD accessories. The retrieval of the accessories log from the accessories by the PD MCU is not implemented yet. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:32785 TEST=execute "ectool --name=cros_pd pdlog" before and after plugging Zinger charger. Original-Change-Id: If96d73e711ff6ad64cfb99bd3e4d2d8f2643f19a Reviewed-on: https://chromium-review.googlesource.com/238854 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 4e75e20f4ec5cecda6742d821b1a4484952fd07e) Reviewed-on: https://chromium-review.googlesource.com/240837 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit d8563a8aa292bb225b7c9a1d998d01ef154a10fb) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I1b0b2b6fc5b9788ccd749626541181d62d185589 Reviewed-on: https://chromium-review.googlesource.com/244222 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* zinger: remove functions for analyzing bist resultsAlec Berg2015-01-302-27/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove functions for sending bist command and analyzing the resulting stream in order to save flash space. BUG=chrome-os-partner:32785 BRANCH=samus TEST=make -j buildall Original-Change-Id: I8fec2d632bce82b1cc344e674b48c5cf2b3a3647 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/240700 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 389ef0f90ff9318ced905d7a1ed8c025953aebc3) Reviewed-on: https://chromium-review.googlesource.com/240836 (cherry picked from commit 7f0e13f25fb14301364386d8d369ae9c148e4fcd) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: I0ff3621f7c941fa416f6744e6947149e716574f7 Reviewed-on: https://chromium-review.googlesource.com/244221 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* zinger: shrink text stringsVincent Palatin2015-01-302-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Save a hundred bytes by making the debug messages less verbose ... Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=none TEST=make buildall Original-Change-Id: I796bc2badc8f5756c1e44fceb5143e9e123d26b5 Reviewed-on: https://chromium-review.googlesource.com/240581 Reviewed-by: Alec Berg <alecaberg@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit f52ed342b952ecc4f342aadec278bc6e4372067e) Reviewed-on: https://chromium-review.googlesource.com/240832 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit b5e1d391c8f45844bc625f9e216247c2d5b0482b) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: Icf04a9d23db893c37a80c91dadd965018c4d9cb6 Reviewed-on: https://chromium-review.googlesource.com/244220 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* stm32: remove useless moduloVincent Palatin2015-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The RTC delay is always less than a day (see the assert at the beginning of set_rtc_alarm), so remove the useless module to save a few bytes of flash. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=none TEST=make buildall and see the zinger firmware is smaller by 16 bytes (more than the 8 bytes I need to submit the following CL) Original-Change-Id: If0374ff5897f13e69574018d2123428075b2264e Reviewed-on: https://chromium-review.googlesource.com/240564 Reviewed-by: Alec Berg <alecaberg@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 34f927724f22d79c8e4c752189dc19b7fd4f7735) Reviewed-on: https://chromium-review.googlesource.com/240834 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit d1daa2b3d96df27b53da7aeef5dabf8ebb877aec) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: Ib353cecd829ff787f4eeee9ef407757107630ef4 Reviewed-on: https://chromium-review.googlesource.com/244169 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* samus_pd: remove assertsVincent Palatin2015-01-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove assertions to save flash space : free up 1728 bytes. Removing the string in assertions saves 1.1kB. (aka CONFIG_DEBUG_ASSERT_BRIEF) Fully removing assertion checks saves an additional 576 bytes. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:34489 TEST=make buildall and check firmware size. BASELINE 93bb7195 === build/samus_pd/ === FLASH 59.5k / 60.0k [ text 48.7k rodat 10.7k data 0.1k ] RAM 11.8k / 16.0k [ data 0.1k bss 11.7k ] CONFIG_DEBUG_ASSERT_BRIEF === build/samus_pd/ === FLASH 58.4k / 60.0k [ text 48.5k rodat 9.8k data 0.1k ] RAM 11.8k / 16.0k [ data 0.1k bss 11.7k ] undef CONFIG_DEBUG_ASSERT === build/samus_pd/ === FLASH 57.8k / 60.0k [ text 48.0k rodat 9.7k data 0.1k ] RAM 11.8k / 16.0k [ data 0.1k bss 11.7k ] Reviewed-on: https://chromium-review.googlesource.com/241451 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit cd90837bb7009fa87e79e56f5497853ad4d2ea2e) Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Original-Change-Id: Iebcb54ffe2849d1ad911abe1a5e6e21f3120af86 Reviewed-on: https://chromium-review.googlesource.com/241848 Tested-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Commit-Queue: Duncan Laurie <dlaurie@chromium.org> (cherry picked from commit 3c26c7b4b6de17af6266d887e1287610bfa533c9) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: Ice680175297907497d60788af15a64c01eee6073 Reviewed-on: https://chromium-review.googlesource.com/244168 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* ec util: do not compile IO mapped memory related code for mips.Gwendal Grignou2015-01-302-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MIPS host CPU does not access IO registers using a separate address space. Remove for support of LPC for this host architecture. Confine x86 function to Intel Architecture only. BRANCH=none TEST=Compile: Test on ARM, MIPS and X86: using emerge... ec-utils. BUG=chromium:443783 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/236687 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit f352aae8b42fafaf8b468f932a7fee214c2a7c45) Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Original-Change-Id: I9d4276ec3588037adfcff96e596bbe8be74f22fd Reviewed-on: https://chromium-review.googlesource.com/240532 Commit-Queue: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Tested-by: Duncan Laurie <dlaurie@chromium.org> Trybot-Ready: Duncan Laurie <dlaurie@chromium.org> (cherry picked from commit 1660ea974276277dc7a04b18952b5b57ca9b52d1) Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: Ib2be8ed174a2ec7072cace83963f616f52404749 Reviewed-on: https://chromium-review.googlesource.com/244167 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* zinger: do an intermediate step when discharging from 20V to 5Vstabilize-storm-6683.BVincent Palatin2015-01-101-19/+54
| | | | | | | | | | | | | | | | | | | | | | If we discharge directly the output voltage from 20V to 5V under load, an undershot happens and we dip below the 5V UVP threshold. So when doing a down voltage transition from 20V to 5V, split it into 2 steps : a 20V->12V transition then once we are reached 12V, a 12V->5V transition. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:33794 TEST=connect Zinger to a Firefly and an electronic load. Using Firefly, ask for 20V->5V, 12V->5V and 20V->12V transitions, check the VBUS waveforms on the scope. Change-Id: Ie1e091ae6f1fee1fb7d4e3bd72edbe7491acd5ea Reviewed-on: https://chromium-review.googlesource.com/229732 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org>
* pd: make VDO responses fasterAlec Berg2015-01-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow VDO responses to be sent faster by taking out the check for incoming packet when a VDO is pending. This check isn't needed because we already check if the PD state machine is busy sending something. With this change, the turn around time for responding to Discover Identity on zinger is ~200us. BUG=chrome-os-partner:35327 BRANCH=samus TEST=loaded onto zinger and used twinkie to verify that discover identity is responded to in ~200us every time. used ectool to perform remote update on zinger, now takes ~18s (compared to ~55s). Also, used following bash loop to constantly sent PD voltage requests: while true; do dut-control "usbpd_uart_cmd:pd 1 dev 5"; sleep 0.3; dut-control "usbpd_uart_cmd:pd 1 dev 20"; sleep 0.3; done Used bash loop while updating zinger via ectool. I programmed zinger ~50 times and verified: - we never missed a PD voltage request - never got any PD protocol or phy layer errors (no collisions) - zinger successfully jumped to RW after each (no packets missed) Note: sending any other PD traffic while programming zinger does obviously slow down zinger update (~30s with my bash loop above). Change-Id: I94d1ac01440d096671972fa9c21c149ea432863f Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/240150 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: pre-compute RW hashVincent Palatin2015-01-101-6/+12
| | | | | | | | | | | | | | | | | To ensure we respond fast enough to the Discover Identity VDM (which timeout after 30ms), we need to pre-cache the RW hash at startup. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:35327 TEST=plug Zinger to a PD sink and check the PD protocol trace on Twinkie Change-Id: I9decdff358dd1ab9ac373ce8bfdd0402f5e21f04 Reviewed-on: https://chromium-review.googlesource.com/240080 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
* pd: ensure power role matches CC pull resistor after hard resetAlec Berg2015-01-101-0/+14
| | | | | | | | | | | | | | | | | | | | Make sure the power role and the CC pull resistor match after receiving hard reset command in the middle of a swap. BUG=none BRANCH=samus TEST=on samus connect left and right ports together with C to C cable. note that after some collisions and some hard resets, it eventually stabilizes with one port in SNK_READY, the other in SRC_READY. without this CL, we get stuck executing a power swap and our power role and CC resistor get out of sync, requiring a reboot. Change-Id: Ia1385eb3a1c503052ad5bfd0d1595ecc096cd5f4 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239976 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* pd: avoid multiple role swaps on connectAlec Berg2015-01-101-1/+11
| | | | | | | | | | | | | | | | | | Avoid multiple power and data swaps on connect by clearing our local flag for checking our role when we receive a role swap. This means if the port partner sends a role swap on connect before us and we accept, then we will not turn around and ask for another swap. BUG=none BRANCH=samus TEST=connect samus to samus and make sure only one swap on connect. Change-Id: I2414b5bd5ffc54701b5758047e5d7e51ca3ff596 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239951 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* pd: fix possible redundant requests (again)Alec Berg2015-01-103-17/+13
| | | | | | | | | | | | | | | | | | | Another fix for redundant requests. This time there can be redundant requests if the maximum allowed voltage changes, but we still fall into the samus PDO index and therefore are asking for the same voltage. This fixes by checking the voltage value we actually request vs. the max value we can request. BUG=none BRANCH=samus TEST=samus to samus was causing redundant requests and now it's not. Change-Id: Ie49add1a42b86de97cee87f9d4637dd0578e2ce3 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239950 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* pd: implement new type-C connect state machineAlec Berg2015-01-106-129/+279
| | | | | | | | | | | | | | | | | | | | | Implement the new type-C connect state machine which removes lock and hold times and adds a debounce time to make sure CC lines settle before going into the attached state. This also adds detection of accessories, but doesn't do anything when an accessory is detected. BUG=chrome-os-partner:33680 BRANCH=samus TEST=test samus connected zinger and samus connected to samus. make sure that the connection is always formed. also tested with a third party with old state machine implementation and formed a connection every time. Change-Id: I91a7a6031bc35082cc19d7697142e4aa92ef46f2 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238210 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: remove PWM moduleAlec Berg2015-01-102-1/+5
| | | | | | | | | | | | | | Remove PWM module which is not being used in order to save flash space. BUG=chrome-os-partner:34489 BRANCH=samus TEST=make -j buildall. view .map file and see we save ~760 bytes. Change-Id: Id107fb402a60c5ac7510982f8ace6bad46fb14d0 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239912 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* lightbar: Don't let EC control suspend/resume sequenceEric Caruso2015-01-103-4/+31
| | | | | | | | | | | | | | | | | | | If the EC controls the lightbar and sets the sequence when it notices the chipset transitioning between states, we can't make exceptions for cases where we don't want to activate the lightbar, such as in dark resume. Instead, let's make it a separate command that we expect from the kernel. BUG=chrome-os-partner:32181 TEST=build on samus, verify lightbar does correct thing with manual control set BRANCH=ToT Signed-off-by: Eric Caruso <ejcaruso@chromium.org> Change-Id: I5dc619cbbf2498e2ef03ce622831b33e14c7c495 Reviewed-on: https://chromium-review.googlesource.com/239215 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* samus_pd: Remove CONFIG_CONSOLE_HISTORY to save flash spaceShawn Nematbakhsh2015-01-091-0/+1
| | | | | | | | | | | | | | | | History is written by the victors, except when they run out of flash space. BUG=chrome-os-partner:34489 TEST=Build samus_pd, check ec.RO.map and verify 756 bytes were saved. Verify that 'history' no longer works on console and up arrow has no function. BRANCH=Samus Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: If512fe31f01cc35b0ef6fa60714b9df125818d64 Reviewed-on: https://chromium-review.googlesource.com/239971 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ryu: Debounce BC1.2 charger detection due to asynchronous pin contactVic Yang2015-01-092-37/+78
| | | | | | | | | | | | | | | | This is basically ryu version of CL:237241. BRANCH=ryu BUG=None TEST=Repeatedly plug in a DCP charger, and verify that it's detected correctly. Change-Id: I036d1b2a52249234f38428e98a3e5fd5db2354b9 Signed-off-by: Vic Yang <victoryang@google.com> Reviewed-on: https://chromium-review.googlesource.com/239914 Tested-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* ryu: add charge managerAlec Berg2015-01-098-10/+178
| | | | | | | | | | | | | | | | Add charge manager to ryu to set how much current to draw from the port. BUG=none BRANCH=samus TEST=make buildall Signed-off-by: Alec Berg <alecaberg@chromium.org> Change-Id: Ia545532e1bf6586566c0b964d966b5d69c0d4b61 Reviewed-on: https://chromium-review.googlesource.com/230760 Tested-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* samus: pd: fix potential junk at end of tx transmissionstabilize-6670.BAlec Berg2015-01-095-93/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix potential junk at end of PD TX transmit by adding to the DMA transmit complete interrupt a blocking wait for SPI to finish and then immediately disable SPI clock. This means we block in an interrupt function for approximately 45us at the end of every transmit. But, this is the highest priority thing going on anyway. Note, there is still a potential for junk if both ports are transmitting at the same time and finish very close to the same time. BUG=chrome-os-partner:34600 BRANCH=samus TEST=load onto samus and test communications with zinger. tested specifically with an old zinger CL, https://chromium-review.googlesource.com/#/c/226118/11, which watchdogs when samus has junk at end of transmit. Tested without this CL and verified we could never successfully flash zinger over PD due to this watchdog and verified on scope presence of junk. Then tested with this change and was able to successfully flash zinger using ectool on both ports in both polarities. Change-Id: If0cd9ab0551d36a7d7dc10232b6476dd56735972 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239244 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: Queue initial DFP HPD till after DP Config VDM.Todd Broch2015-01-093-5/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VESA DisplayPort Alt Mode on USB Type-C Standard specifies: When DisplayPort Configuration is not selected (and the converter is driving its HPD output low), the converter shall track the current state of HPD, ready for appropriate indication when DisplayPort Configuration is subsequently selected. Not only are we violating specification here but it also causes a race between enabling DPout muxes to AUX line which in turn causes GPU to timeout trying to read EDID/DPCD on occasion. Change adds post_config function for DFPs alternate mode and in the case of DP it sets the dp_on flag there. This allows attention function to correctly defer HPD_HI that may accompany 'DP status' VDM to be queued (deferred) until such time that AUX muxes are enabled properly. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:35219 TEST=manual, using hoho & dingdong With kernel bootarg drm.debug=0x6 following cases all show these drm debug lines: [drm:i915_hotplug_work_func], Connector DP-2 (pin 5) received hotplug event. [drm:intel_dp_get_dpcd], DPCD: 12 14 c4 01 01 00 01 00 02 02 06 00 00 00 00 [drm:intel_hpd_irq_event], [CONNECTOR:38:DP-2] status updated from disconnected to connected case1: boot connected to external display case2: attach dongle to external display then samus case3: attach dongle to samus then to external display case4: connect/disconnect rapidly on type-C side case5: connect/disconnect rapidly on external display side. Change-Id: I40eab797fdd5090c8ad13fae2cd053b740d9a307 Reviewed-on: https://chromium-review.googlesource.com/239420 Trybot-Ready: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* twinkie: build a combined firmwareVincent Palatin2015-01-087-10/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Build a Twinkie firmware image with the regular Twinkie sniffer firmware in the RO partition and a firmware behaving as a USB PD sink in the RW partition. The user can call the "twinkie sink" command to switch the USB PD sink firmware in the RW partition (and call "reboot" if he changes his mind and wants the sniffer back). Restore the ability of building different tasklists which was broken where the tests build was simplified. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make buildall ./board/twinkie/build_rw_variant Try "twinkie sink" command on a Twinkie with the combined firmware. Change-Id: Ie489ce97a774ae7a22ac639c49a3d6e412e62de8 Reviewed-on: https://chromium-review.googlesource.com/237221 Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* usb: fix sysjumpVincent Palatin2015-01-081-0/+2
| | | | | | | | | | | | | | | | | | | | Ensure that we can re-etablish a proper USB communication after a sysjump by properly disabling the USB stack before jumping. So the host sees a USB disconnection and can properly re-initialize the device when it re-appears. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=none TEST=On Twinkie, use the "sysjump RW" command on the USB console and see the prompt coming back after a few seconds. Change-Id: Iaf4498333eb4e7a1dda0f51ee8be19a0c9f10349 Reviewed-on: https://chromium-review.googlesource.com/239227 Reviewed-by: Anton Staaf <robotboy@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* disable DMA before sysjumpingVincent Palatin2015-01-085-0/+35
| | | | | | | | | | | | | | | | | | | | | It's not safe to sysjump with a DMA enabled as it can led to memory corruption after we have landed in the new image before that piece of hardware is re-configured. Implement and call dma_disable_all() on all platforms with generic DMA. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=all BUG=chrome-os-partner:34865 TEST=on various boards, call "sysjump rw". Change-Id: I2a6b63ff19c2d932a5e31bc375bf468bc8ae5125 Reviewed-on: https://chromium-review.googlesource.com/237340 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* twinkie: fix sink firmwareVincent Palatin2015-01-081-0/+6
| | | | | | | | | | | | | | | | | add a dummy pd_custom_vdm() function to be able to build again a Twinkie firmware in "PD sink" mode. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=./board/twinkie/build_rw_variant Change-Id: Ib0f82ecd1197300cf7b36f0f43c6b1cd03203557 Reviewed-on: https://chromium-review.googlesource.com/239234 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* twinkie: turn on/off VCONN INAVincent Palatin2015-01-081-0/+12
| | | | | | | | | | | | | | | | | | | | the VCONN INA is off by default to avoid a leakage path on CC2. Turn it on when asking for a VCONN measurement ("twinkie vconn"), then off aftwerwards. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=On the Twinkie command-line, "tw vconn" with the Twinkie interposed between a Samus and a DingDong. Change-Id: I8cd78b285512644af0824a44c735585b684fee66 Reviewed-on: https://chromium-review.googlesource.com/239212 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* charge_manager: fix initialization bug of best_port_powerAlec Berg2015-01-081-1/+1
| | | | | | | | | | | | | | Fix bug, local var best_port_power was uninitialized. BUG=none BRANCH=samus TEST=make -j buildall Change-Id: I15bcc52453e63dab8957625bf596dc2a7a0c4153 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239423 Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: Return immediately to host from erase RW.Todd Broch2015-01-083-16/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With CL: 5ef45ad pd: Add timeout for HC flash commands. I thought I'd licked the timeout related issues with flashing dingdong & hoho. With further testing however I found I was occassionally hitting the failure where I couldn't return from 'flash erase' on PD peripheral prior to the 1 second limit for host command timeout. That could be remedied by retrying the erase on the host side which then succeeds quickly. That solution seems non-optimal however. Additionally, even when erase does succeed in <1sec we have the shared i2c bus pending. That too is non-optimal. For those reasons I've decide to return immediately from flash erase command and instead put the burden of waiting the necessary time on the host which at least does have some wider perspective on what the system is attached to and doing. CL also adds following related changes: 1. corresponding ectool edit to delay 3sec after RW erase. 2. fixup to error returns from hc_remote_flash for timeouts. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:33947 TEST=flashing dingdong/hoho via ectool works reliably. Change-Id: I8fbfb592f760273b26bcb16b67210d569454eee2 Reviewed-on: https://chromium-review.googlesource.com/239253 Trybot-Ready: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: Refactor exit mode.Todd Broch2015-01-083-24/+33
| | | | | | | | | | | | | | | | | | | Refactor pd_exit_mode to be only a DFP function. Additionally make pe_init a public function and call it during hard reset. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:33946 TEST=manual, using pdsetmode from later patches see proper exit and resetting of pe struct. Change-Id: I45afe1f82926f1c32f4d84eb60c65f1f39b19d81 Reviewed-on: https://chromium-review.googlesource.com/236958 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* charge_manager: Prefer current active port in best port selectionShawn Nematbakhsh2015-01-082-5/+39
| | | | | | | | | | | | | | | | If two identical suppliers are capable of supplying equal power, select the port which is currently active. BUG=chrome-os-partner:34912 TEST=Manual on Samus. Plug Zinger into right port, verify that it becomes active. Plug a new Zinger into left port, verify that the right port stays active. BRANCH=Samus Change-Id: Ib1baf4bd3f619169f0e31ec509a2fe7dbd8c897e Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238766 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: remove clearing of type-c current limit in hard resetAlec Berg2015-01-081-1/+0
| | | | | | | | | | | | | | | | | | Remove clearing of the type-C pull-up supplier current limit on hard reset. Hard reset is a PD command and should clear the PD supplier current limit, but the type-C pull-up is independent and is still connected, so should not reset. BUG=none BRANCH=samus TEST=load on samus and plug in donette. without this CL, the charging icon flashes off then on. with this CL, it doesn't flash and still draws 3A. Change-Id: I90f87f3970754ca3618d87466412c97acc0a4d6f Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239269 Reviewed-by: Shawn N <shawnn@chromium.org>
* samus: Fix flaw in power up inhibitShawn Nematbakhsh2015-01-081-7/+9
| | | | | | | | | | | | | | | | | | | | | | | Power up inhibit is intended to stop the AP from booting when the battery is in certain states. It works most of the time, but sometimes IN_PCH_SLP_S5_DEASSERTED is already set by the time we get to S5 and we incorrectly boot the AP. Thinking about this more, it's better to check the battery state in G3, before we transition to S5, to prevent the needless transition back to G3 if power up is indeed inhibited. BUG=chrome-os-partner:35182 TEST=Manual on Samus. Drain battery to 1% and attach charger. Press power button multiple times and verify that AP doesn't boot. Charge better to 2% and press power button. Verify that AP boots. BRANCH=Samus Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ib03c3f707f9d90d0a9cb07ada3738d00e2728c32 Reviewed-on: https://chromium-review.googlesource.com/239352 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* samus: pd: reject power swap if not in dual-role modeAlec Berg2015-01-081-2/+6
| | | | | | | | | | | | | | | Samus should reject request for a power swap if it is not in a dual-role mode, for instance if in S3 or lower. BUG=chrome-os-partner:35141 BRANCH=samus TEST=load on two samus'. turn on samus off, then request a power swap from the samus that is on and see that it is rejected. Change-Id: Ifb23febac967c981251c3932856e1e942818694f Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238963 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: dingdong/hoho: Enable flash write-protectionVincent Palatin2015-01-086-13/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These USB type-C accessories don't have a write-protect GPIO. Add a configure flag (CONFIG_WP_ALWAYS) to force the flash write-protection on the dongles. Also set the read protection (by elevating RDP to level 1), so trying to unprotect the flash will trigger a full erase. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:35088 TEST=boot Hoho, check the flash OBR and WRPR registers: "rw 0x4002201c" / "rw 0x40022020" and the option bytes write-protect bits: "rw 0x1FFFF808" dump the logical state with "flashinfo" command. > rw 0x4002201c read 0x40022020 = 0xffff0002 > rw 0x40022020 read 0x40022020 = 0xffff0000 > rw 0x1FFFF808 read 0x1ffff808 = 0xff00ff00 > flashinfo Physical: 128 KB Usable: 128 KB Write: 2 B (ideal 2 B) Erase: 2048 B (to 1-bits) Protect: 4096 B Flags: wp_gpio_asserted ro_at_boot ro_now Protected now: YYYYYYYY YYYYYYYY ........ ........ Change-Id: I45bbc0bce40ecc174b6b8a1ebacf4f53d2fd372d Reviewed-on: https://chromium-review.googlesource.com/238893 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* Queue: Add methods that accept a memcpy routineAnton Staaf2015-01-084-13/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | These versions of the queue add and remove methods support using memcpy like routines to access regions of memory with specific requirements. In particular, this will allow for transfers between queues and USB packet RAM on the STM32 which has specific access requirements. This change also includes an update to the mem* util routines to make their prototypes compatible with C89 and POSIX standards. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Test USB Echo functionality on discovery-stm32f072 board to ensure that queues still function correctly. Change-Id: I557064d99abfc3e8cfc98099a1d94334a976550c Reviewed-on: https://chromium-review.googlesource.com/239217 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org>
* USB: Add memcpy_from_usbram and update existing memcpyAnton Staaf2015-01-084-16/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously there was just a memcpy_usbram that copied to USB packet memory, and no routine to copy out. This adds the "from" version and renames and improves to "to" version. The improvement is that the new "to" version correctly handles unaligned beginning and endings of the region to be copied. These need to be read/modify/write accesses since the USB packet ram has to be manipulated in 16-bit chunks. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Verify that discovery-stm32f072 still enumerates and communicates correctly over USB. Change-Id: I94353e66ad0248d4e674abb29f9a88e979767655 Reviewed-on: https://chromium-review.googlesource.com/238764 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org>
* lm4: Increase time to wake up from deep sleepShawn Nematbakhsh2015-01-081-2/+2
| | | | | | | | | | | | | | | | | | The recent change to decrease the time to wake up from deep sleep when not using LFIOSC was too agressive. Increase the time to wake up based upon the worst observed case. BUG=chrome-os-partner:35184 TEST=Manual on Samus. Go to deep sleep, verify that no "overslept by Xus" prints are seen. BRANCH=Samus Change-Id: Ib9fe2eba5e29a112e03fffaedbc5ae53d6d650ff Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/239242 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org>