summaryrefslogtreecommitdiff
path: root/util/comm-lpc.c
Commit message (Collapse)AuthorAgeFilesLines
* Move protocol v2 constants to ec_commands.hRandall Spangler2013-07-031-3/+5
| | | | | | | | | | | | | | | | These constants are scattered around the various interface implementations and should be in one place. This will also clean up the u-boot side when ec_commands.h is copied there. BUG=chrome-os-partner:20257 BRANCH=none TEST=build link, spring, pit; test 'ectool hello' Change-Id: Ib1425db00ec8220538d8c5c65107ac9548009516 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60810 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* Comm interface now provides max I/O sizes and preallocated buffersRandall Spangler2013-07-011-1/+8
| | | | | | | | | | | | | | | | | | | | The maximum packet / param size differs depending on interface and protocol version. Commands can now ask the comm interface what the limits are, and can use preallocated buffers to avoid needless malloc/free. BUG=chrome-os-partner:20571 BRANCH=none TEST=the following all work on link burn_my_ec ectool version ectool chargedump ectool console ectool i2cxfer 5 0x41 2 Change-Id: Ib847994da3f79721e7fb4e347231b9147a3f485f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60275
* Rename LPC packet size constant for version 3 protocolRandall Spangler2013-06-261-1/+1
| | | | | | | | | | | | | | The maximum packet length for LPC is limited by the I/O space window size. But that's not the case for SPI or LPC. Rename LPC constant before adding a SPI constant. BUG=chrome-os-partner:20257 BRANCH=none TEST=build link Change-Id: I088327a11eff18d401c773db953700a36f9c1bb4 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/59959
* Refactor host command interface to support version 3 packetsRandall Spangler2013-06-201-6/+108
| | | | | | | | | | | | | | | | | | | | | | | | | This will fix EC flash commands on pit, once the host side (u-boot and cros_ec driver) are upgraded to match. This change is backwards-compatible the EC still supports the existing version 2 protocols for talking to existing AP/kernel/ectool. Once the AP-side supports version 3 for SPI (and existing systems are upgraded), we will remove older SPI support since we haven't shipped a product which uses SPI. BUG=chrome-os-partner:20257 BRANCH=none TEST=disable cros_ec driver support in ectool; 'ectool hello' works on link And with an old ectool which predates this CL, 'ectool hello' also works. On pit, from u-boot prompt, 'crosec test' and 'crosec version' work, and keyboard works. Change-Id: I01f193e316e9aa442fe50d632dc8a4681723e282 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/58908 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Doug Anderson <dianders@chromium.org>
* ectool prefers /dev/cros_ec, then falls back to i2c, lpcBill Richardson2013-06-051-78/+77
| | | | | | | | | | | | | | | This is preparation for the common userspace EC interface. If/when that appears, this will be ready. BUG=chromium:239197 BRANCH=all TEST=manual Build, install, run it. Shouldn't be any change. Change-Id: I9fa78515ec5443ba659f10a66bbaadcb7f4802b0 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/56131
* Strip out old LPC command protocolRandall Spangler2013-04-111-68/+12
| | | | | | | | | | | | | | | | | | | | | | Nothing has used this since link EVT, so it's just dead code at this point. BUG=chrome-os-partner:13213 BRANCH=none TEST=manual - Update ectool but leave old firmware - ectool version -> works - ectool flashread 0 0x10000 foo -> puts the first 64KB of EC flash into foo - Update firmware - ectool version -> works - ectool flashread 0 0x10000 foo -> puts the first 64KB of EC flash into foo - power+esc+refresh -> recovery mode Change-Id: Ib25a705bcd8280d5295c8e7890969d796542b6c9 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47866 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Clean up ectoolRandall Spangler2012-07-221-37/+27
| | | | | | | | | | | | | Assorted minor cleanup; make protocol a bit more efficient, and add a missing line of output to flash protect status. BUG=none TEST=ectool flashprotect; should print valid bits = 0x3f on link Change-Id: I9bea78506b3ed367df731d358982d3e2febb13af Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28097 Reviewed-by: Vic Yang <victoryang@chromium.org>
* Support new-style LPC command interface in EC, ectoolRandall Spangler2012-07-121-5/+115
| | | | | | | | | | | | | | | | | | Both EC and ectool are still backwards-compatible to the old interface. BUG=chrome-os-partner:11275 TEST=manual From U-boot prompt: mkbp hash // test old host talking to new EC From root shell: ectool echash // test new host talking to new EC You can also update just the OS and use an old EC, and verify that 'ectool echash' still works, which tests a new host talking to an old EC. Change-Id: I2afbb208cb16836f842ba119b74b1ab6a38ce5d5 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27313
* Map 256 bytes of data for host command args/paramsRandall Spangler2012-07-121-12/+15
| | | | | | | | | | | | | And retain compatibility for old requests. BUG=chrome-os-partner:11275 TEST=from u-boot prompt, 'mkbp hash' from root shell, 'ectool flashread 0 68084 /tmp/foo' then compare to first 68084 bytes of ec.bin Change-Id: Id82068773703543febde79fc820af7486502e01f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27226
* Add memory-mapped data support for I2C and SPI protocolsRandall Spangler2012-07-071-2/+2
| | | | | | | | | | | | | | | And fix returning memory-mapped string length on LPC as well. BUG=chrome-os-partner:11090 TEST=manual from EC, 'hostevent set 0x40000' from host, 'ectool eventget' --> should print 0x40000 Signed-off-by: Randall Spangler <rspangler@chromium.org> Change-Id: I9edbd0a1468b5d4160ce67c471332226e51fa868 Reviewed-on: https://gerrit.chromium.org/gerrit/26719 Reviewed-by: Simon Glass <sjg@chromium.org>
* Tidy util headers and make ec_commands.h not include other headersRandall Spangler2012-06-291-1/+0
| | | | | | | | | | | | | In preparation for being able to copy ec_commands.h to u-boot, which is itself in preparation for u-boot picking it up from /usr/src/ec/ BUG=none TEST=make link, snow, bds Change-Id: If256434b6722ff0787ce21a8ed4c7035c28024a8 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/26451 Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
* Change ec_command() to return negative values for errorsRandall Spangler2012-06-291-23/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is more compatible with kernel and u-boot, and will make it easier to share code between the ec project and those. BUG=none TEST=manual: ectool version -> should work normally on ec, do 'hostevent set 0x40000'. Then at root shell ectool queryec EC returned error result code 19 ectool flashread 0x100000 16 foo Reading 16 bytes at offset 1048576... EC returned error result code 2 Read error at offset 0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Change-Id: I5e2a85f96c874d0730c14e1438a533649cd594f8 Reviewed-on: https://gerrit.chromium.org/gerrit/26359 Commit-Ready: Randall Spangler <rspangler@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org>
* Optimize performance of flash reads/writesRandall Spangler2012-06-181-5/+6
| | | | | | | | | | | | | | | 1) Smaller start delay for commands 2) Reads can use the entire 128 byte parameter space This improves read speed from 350ms/64kb to 210ms/64kb. BUG=none TEST=ectool flashread 81920 81920 then compare with ec.A.bin Change-Id: I53d460bace5f21db845a3f8ec681507fca0f7b0e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/25562 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Improve the timeout when running on non-Google EC boards.Louis Yung-Chieh Lo2012-05-301-2/+36
| | | | | | | | | | | | | | | | | | The udelay() has big overhead so that repeating calling leads big errors (expect 1 sec of timeout, but actually 12 secs of timeout). So, the improvement is to double the udelay count when BUSY bit is set. Even better, if we can check the I/O port content before really running the EC command, it can save more time. BUG=chrome-os-partner:10003 TEST=tested on link, alex, zgb, lumpy, stumpy and mario. Only mario takes 1 second to timeout. Others stop when checking ports (takes around 0.01 second). Change-Id: I96c6d8cbe6226d05428a2ab126815e934942f5a9 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
* Split communication functions from host toolsVincent Palatin2012-05-241-0/+119
Preparatory work to re-use the tools on ARM boards using I2C communications. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=None TEST=make BOARD=link && make BOARD=bds && make BOard=DAISY Change-Id: I31d41f30c3231a4a9349b939bf6bba871ed4c383