summaryrefslogtreecommitdiff
path: root/chip/stm32/usb-stream.c
Commit message (Collapse)AuthorAgeFilesLines
* servo_micro: Allow setting the baud rate for usartNicolas Boichat2018-08-291-1/+4
| | | | | | | | | | | | | | | | | | | | | We set the baud rate in increments of 100 baud, to avoid overflowing the 16-bit wValue integer (921600 is the highest we are likely to use). Also, increment the buffer size for USART3 to 1024 bytes. That helps a bit to avoid losing characters, but we still can't keep up if the host is printing at maximum speed. BRANCH=servo BUG=chromium:876651 TEST=baud usart2/3/4 115200 in servo_micro console TEST=dut-control cpu_uart_baudrate:921600 seq 1 1000 shows numbers 1 to 226 before buffer overflows Change-Id: Ifca266189f93def493f207dd29d2cceca4d8d68f Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1189782 Reviewed-by: Nick Sanders <nsanders@chromium.org>
* consumer: Remove flush operationNicolas Boichat2017-12-181-10/+0
| | | | | | | | | | | | | | | | Nobody is calling the flush function for consumer_ops structure, so let's remove it to save flash space, until we find a use for it. CQ-DEPEND=CL:*529221 BRANCH=none BUG=chromium:795624 TEST=make buildall -j, saves from 40 to 128 bytes on some boards. Change-Id: Iad18b30f419ccebc54a90914ec46da84b8d19601 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/826905 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* chip/stm32/usb: Replace reset handler by generic event handlerNicolas Boichat2017-08-161-2/+8
| | | | | | | | | | | | | | | | | | | Some USB interface handlers need to know when USB has been successfully resumed after a wake event. For example, this is useful so that HID keyboard can send the events at the right time. BRANCH=none BUG=b:35775048 TEST=Using USB HID keyboard patches to queue keys in a FIFO: After USB autosuspends, press a single key and hold it. Without this patch the endpoint data only gets reloaded on the _next_ event. TEST=On hammer, I2C passthrough still works. Change-Id: I9b52b9de16767c8a66c702a5ae70369334a3d590 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/569547 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* servo_micro: add parity settingNick Sanders2017-07-131-0/+36
| | | | | | | | | | | | | | Add a control interface to set parity for USB-UART bridge. BRANCH=None BUG=b:37513705 TEST=parity settable on command line or by servod Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: Ib859a70981162be58edfa79c7cb267e0084e05e6 Reviewed-on: https://chromium-review.googlesource.com/564150 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* chip/stm32/usb-stream: Fix rx_read queue space comparisonNicolas Boichat2017-03-221-1/+1
| | | | | | | | | | | | | | | There is no reason to reject the incoming USB packet if its size equals the amount of space in the queue. BRANCH=none BUG=b:35587171 TEST=usb_updater2 works fine, even with 64-byte USB packets. Change-Id: I2e54f1a758dd8a370dacdc8c2519bbd91e9cb4e5 Reviewed-on: https://chromium-review.googlesource.com/458042 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* usb: Cleanup headersNicolas Boichat2017-03-161-1/+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>
* 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-2/+7
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Producer/Consumer: Refactor to use Queue policiesAnton Staaf2015-05-261-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the Producer and Consumer interfaces tracked the Consumer and Producer respectively at the other end of the queue that they interacted with. This was done to avoid modifying the queue implementation, but resulted in a rougher interface that required additional initialization steps and prevented alternative configurations; many producers and one consumer for example. This commit uses the new queue policies to track this information. The new direct policy behaves as the old producer and consumers did. Now the producers and consumers are just named references to the queue that they work on and a convenient location for a notification callback when the queue is updated in a way that is relevent to the producer or consumer. All users of Producer and Consumer have been updated including the stream adaptors which are in use by the echo test code and the mcdp28x0 driver. Use of the stream adaptors has also been simplified. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Manual testing of Ryu (P5) and discovery board echo task Change-Id: I704be6378a31b4e20f5063295eff9943e4900409 Reviewed-on: https://chromium-review.googlesource.com/271792 Reviewed-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
* USB: Fix memcpy routinesAnton Staaf2015-04-131-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The memcpy like routines for moving to and from usb packet RAM couldn't deal with all unaligned uses, this fixes their behavior. In particular, a previous caller might assume that the packet RAM addresses were contiguous and attempt to break up a call into two separate chunks (as the queue insertion/removal code does). But this can lead to invalid pointers passed to these memcpy routines. A much cleaner solution is to make the packet RAM address space contiguous. To do so the memcpy routines take packet RAM addresses instead of AHB address space mapped addresses and __usb_ram_start needed to change to be of type usb_uint so that pointer arithmatic on it worked correctly on all platforms, this also allowed the usb_sram_addr macro to be simplified. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Verify that USB still works on Ryu and discovery-stm32f072 Change-Id: I479461f07a3203f1e6e0cf9705f512a5a43c4646 Reviewed-on: https://chromium-review.googlesource.com/264764 Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
* USB-Stream: Switch to handling packets in a deferred hookAnton Staaf2015-04-131-36/+27
| | | | | | | | | | | | | | | | | | | | | | | | Previously the TX and RX queues were being accessed from two different locations without locking, which is wrong. This moves the access to a single location in a deffered hook and calls that hook from the old locations. The result is correct, simpler, and not much slower. It also reduces time in the USB interrupt handler by moving the memcpy from packet to queue out to the deferred hook. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Verify that USB streams still work on Ryu and discovery-stm32f072 Change-Id: I6ea53d7c40b42c6112e86a7886f3b888408f72b7 Reviewed-on: https://chromium-review.googlesource.com/264763 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org>
* USB Stream: Make RX and TX buffer sizes configurableAnton Staaf2015-03-031-2/+10
| | | | | | | | | | | | | | | | | | | | | | | Previously the USB Stream buffer sizes were fixed at USB_MAX_PACKET_SIZE (currently 64 bytes). But that ended up using up too much packet RAM, a very limited resource. This change makes them configurable and adds asserts to insure that the sizes are valid for the underlying hardware. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Verify that USART forwarding on discovery works Change-Id: Ib19c0dcfa9b16f23c1d72a5a7fc18026ab103f05 Reviewed-on: https://chromium-review.googlesource.com/255232 Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
* Producer/Consumer: Convert USART and USB Stream driversAnton Staaf2015-03-021-102/+25
| | | | | | | | | | | | | | | | | | | | | | | Previously the USART and USB Stream drivers exposed in_stream and out_stream interfaces, which don't allow for sharing their queues easily. This change converts these drivers over to the producer/consumer model and updates the two uses. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Verify that the discovery echo functionality is unchanged. Change-Id: I29f043ab1712373f638e1621378df98647d736cf Reviewed-on: https://chromium-review.googlesource.com/252820 Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
* stm32-USB: Initial USB bulk endpoint stream driverAnton Staaf2014-09-231-0/+216
This stream driver works like the USART stream driver but connects to two bulk USB endpoints. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I9cbd2e54a811d3e32c68a820f7ab5de693c29569 Reviewed-on: https://chromium-review.googlesource.com/216002 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>