summaryrefslogtreecommitdiff
path: root/chip/g/usb_console.c
Commit message (Collapse)AuthorAgeFilesLines
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* Revert "g: consolidate USB console transfer codes to usb-stream"Namyoon Woo2019-06-181-74/+10
| | | | | | | | | | | | | | | | | | | | | This reverts commit 79e88d81f3e090d959669b4de6215cef96c2a3ed. Reason for revert: It slows down CR50 UART console response. The original plan was to consolidate CR50 console USB configuration into USB stream configuration, then optimize USB stream implementation. However, I am changing the plan: will commit this patch after USB stream is optimized. BUG=None BRANCH=None TEST=Downloaded the cr50 bin, and checked the cr50 console responding stable. Change-Id: I21ae8c4e043e10c4325bbf91123f2ee185faa413 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1662849 Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* g: minor fix in putting a character into usb_console tx queueNamyoon Woo2019-06-141-21/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When __tx_char attempts to push a character into tx_queue, it doesn't return an error if it fails. Eventually usb_puts() doesn't recognize tx queue getting full if it happens, and processes all characters, and always return EC_SUCCESS. BUG=None BRANCH=None TEST=ran uart_usb_tester on bob. uart_stress_tester.sh --pty="/dev/ttyUSB0 /dev/ttyUSB2 /dev/ttyUSB1" --min_char 400000 INFO : ChromeOS UART stress test starts. INFO : UART devices: /dev/ttyUSB0 /dev/ttyUSB2 /dev/ttyUSB1 ...................................................... INFO : /dev/ttyUSB0: 0 lost / 483415 : 0 % ERROR : /dev/ttyUSB2: 277497 lost / 415835 : 66.7 % ERROR : /dev/ttyUSB1: 244459 lost / 400575 : 61.0 % INFO : Test files are in /tmp/uart_stress_tester.sh_latest INFO : and also in /tmp/tmp.X7jwZfxNe2.uart_stress_tester.sh. ERROR : FAIL CR50 console (/dev/ttyUSB0) error rate got improved from 4~7% to 0 %. Change-Id: I5ae0b7bd494fbc29978ce3e87531e246a9be51f8 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1650622 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* g: consolidate USB console transfer codes to usb-streamNamyoon Woo2019-06-141-11/+75
| | | | | | | | | | | | | | | | | | | usb-console.c and usb_stream.c include some amount of copied/pasted code. This patch converts USB console implementation to USB stream to reduce the redundancy. Flash usage decreases by 260 bytes. BUG=None BRANCH=None TEST=Ran uart_stress_tester.sh (http://crrev.com/c/1586581/23) on bob. This CL slightly increases CR50 console char loss rate: 5.5% -> 6.5% in average. Change-Id: Ibdc16867618d67ae33574e802c1949aa6b5cf1a6 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1648921 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* chip/g: prevent USB read queue overflowNamyoon Woo2019-04-261-1/+5
| | | | | | | | | | | | | | | | | | | | CR50 should check whether USB RX queue has enough space for host data. If not, it schedules to retry it in another deferred call. BUG=b:130908211 BRANCH=cr50 TEST=manually ran "echo 'help' > /dev/ttyUSB0" more than 30 times. Without this CL, it used to break cr50 console input, and it worked as if it is 'read-only'. After applying this CL, cr50 console input works normal even after excessive input stream. Change-Id: Ieace84b51c31800b52d2c4a9334e6ffe7888e592 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1576326 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* g: add CONFIG_USB_CONSOLE_CRCMarius Schilder2018-02-241-0/+23
| | | | | | | | | | | | | | | | | This option will cause usb console output to block and also compute a crc32. Signed-off-by: mschilder@google.com TEST=make buildall -j BRANCH=none BUG=none Change-Id: Icf66d5ddbea52008a9c97094e7c83194caa7db79 Reviewed-on: https://chromium-review.googlesource.com/936281 Commit-Ready: Marius Schilder <mschilder@chromium.org> Tested-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* chip/g: Fix usb_console read-onlyRandall Spangler2017-09-011-4/+14
| | | | | | | | | | | | | | | | | | | | | Currently, the console inhibited output when is_readonly=1, and only inhibited input when is_enabled=0. That's harmless in the current implementation, because common/case_closed_debug() only ever calls it with enabled=0/readonly=1 or enabled=1/readonly=0. But if we ever do decide to use enabled=1/readonly=1, that would have acted like write-only, not read-only. Fix that. BUG=none BRANCH=cr50 TEST=Attach to cr50 USB console, console is read/write. Hack USB console to set is_readonly=1, console is read-only. Change-Id: I04258fe2b040a00f98067d8be48a0632eb16e9c1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/647336 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* usb: Cleanup headersNicolas Boichat2017-03-161-0/+1
| | | | | | | | | | | | | | | | | | | Let's split the usb headers in 3 different parts, instead of having usb_descriptor.h pull in usb_hw.h and usb_api.h. - usb_api.h: EC functions related to usb (e.g. connect/disconnect) - usb_descriptor.h: common USB names and structures - usb_hw.h: Functions required for interactive with EC's USB HW BRANCH=none BUG=b:35587171 TEST=make buildall -j Change-Id: I37ead61e3be5e7ae464f1c9137cf02eaab0ff92e Reviewed-on: https://chromium-review.googlesource.com/454861 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* g: increase usb console TX buffer size to 4KVadim Bendebury2016-08-011-1/+1
| | | | | | | | | | | | | | | | | | | Increasing the USB console TX buffer size allows to see pretty much all early startup messages generated before USB console is initialized. There is still plenty of room left in SRAM, 23K on cr50, much more on all other g based boards. BRANCH=none BUG=none TEST=observed better USB console output on cr50 restarts. Change-Id: I82f37ee7f3aecd8b7e95f3d421789c11375b2fd4 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/364811 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Nadim Taha <ntaha@chromium.org>
* Deferred: Use deferred_data instead of function pointerAnton Staaf2016-04-181-5/+5
| | | | | | | | | | | | | | | | | | | | | Previously calls to hook_call_deferred were passed the function to call, which was then looked up in the .rodata.deferred section with a linear search. This linear search can be replaced with a subtract by passing the pointer to the deferred_data object created when DECLARE_DEFERRED was invoked. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None CQ-DEPEND=CL:*255812 TEST=make buildall -j Change-Id: I951dd1541302875b102dd086154cf05591694440 Reviewed-on: https://chromium-review.googlesource.com/334315 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* g: fix usb console LF handlingVadim Bendebury2016-04-181-13/+9
| | | | | | | | | | | | | | | | | | | | | | | It was observed that when connecting to the CR50 console over USB, there the line feed (LF) characters are not supplemented by carriage return (CR), which causes weird console output. Detailed examination has shown that uart_putc() does not do the right thing itself and also bypasses __tx_char() used by uart_puts(), which does the right thing. The simplest solution is to have uart_putc() re-use all the smarts of uart_puts(). BRANCH=none BUG=none TEST=verified that usb console output does not suffer from the "lost CR" syndrome any more. Change-Id: I2a1f84b2524c41eb6e84186141b0b9ac55e87ee0 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/339217 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* cr50: forward console through USBMary Ruthven2016-04-071-90/+185
| | | | | | | | | | | | | | | | This change adds support for forwarding the EC console through USB. BUG=chrome-os-partner:49960 BRANCH=none TEST=load the google-serial udev rules in extra/usb_serial/, build the raiden.ko module, and then check that the console can be accessed from /dev/google/Cr50/serial/Shell Change-Id: I35e0bb39fdc8f9485a14c03eb3a4d2f024884e17 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/334132 Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* cleanup: Rename usb.h to usb_descriptor.hShawn Nematbakhsh2015-11-081-1/+1
| | | | | | | | | | | | | | | | Rename usb.h to usb_descriptor.h to prevent conflict with a commonly-used libusb header. BUG=chromium:552006 BRANCH=None TEST=`make buildall -j` Change-Id: I6145ce120e1fda41bc5c4d4da0313272e76839c7 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/311429 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* update case closed debugging partial mode policyVincent Palatin2015-09-081-3/+6
| | | | | | | | | | | | | | | | | | | | | | | When a debug accessory is connected to the type-C port while the write protection is enabled, put the case closed debugging in "partial" mode rather than "full". Update the "partial" mode to provide read-only access to the AP and EC consoles. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smaug BUG=chrome-os-partner:44700 TEST=check the EC console input/output over USB is still working with SuzyQ on a write-protected system, verify that the console input is disabled. Change-Id: I5baa03d6e738d06437c45469f46b286e76a755a4 Reviewed-on: https://chromium-review.googlesource.com/297141 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* Cr50: USB hardware uses 8-bit buffers, not 16-bitBill Richardson2015-05-291-10/+5
| | | | | | | | | | | | | | | Our USB buffers are just arrays of uint8_t in program RAM, so let's treat them that way. The DMA descriptors are in normal RAM, too. BUG=chrome-os-partner:40693 BRANCH=none TEST=make buildall Change-Id: Ibafe1a557a328bbf8cf37ce113675fcd35bad376 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/273918 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cr50: allow using ccprintf() early in the processVadim Bendebury2015-04-301-6/+5
| | | | | | | | | | | | | | | | | | | | Attempts to use ccprinf() before both uart and usb consoles have been initialized cause the device lock up. Luckily both console channels are buffered (and usb console buffering is about to be greatly improved), all what needs to be done is to hold on to the attempts to start transmit interrupts until hardware has been initialized. BRANCH=none BUG=none TEST=attempts to print something on the console early in the process do not cause the device to lock up any more, and the printouts show up where expected. Change-Id: I16cd1fab79bceaf7c2334a955fdb6046d21ed550 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/268379 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* cr50: add USB supportVincent Palatin2015-04-021-0/+266
Add a USB device driver for the Synopsys DWC USB device controller. The common USB protocol stack code still need to be de-duplicated with the STM32 implementation. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:33919 TEST=plug Cr50 to a Linux workstation and see USB descriptors using "lsusb -v -d 18d1:5014" Change-Id: I4a367241053de2c2d94aa06f82ea4bee51f9f89a Reviewed-on: https://chromium-review.googlesource.com/231160 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>