summaryrefslogtreecommitdiff
path: root/include/usb_descriptor.h
Commit message (Collapse)AuthorAgeFilesLines
* servo: Adds USB SPI protocol V2 commands and responsesBrian J. Nemec2020-07-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the USB SPI protocol V2, this protocol supports larger SPI transfers that are delivered in multiple USB packets. This enables us to perform 2 optimizations on the USB SPI transfer speed for large USB packets: * USB packets can be grouped together reducing the total number of packets exchanged. The host can write multiple data sections sequentially without the device responding with a packet for each one. Going the other direction, the host can continue to poll the device for data until the transmission is complete. * Only a single SPI transaction is required, this eliminates overhead in setting up and getting data from SPI transactions. Benchmark results show a typical 35% improvement in performance on Servo Micro platforms with these changes on operations which involve large SPI transfers reading or writing from the flash. Signed-off-by: Brian Nemec <bnemec@chromium.org> Blocked on upstream changes to flashrom: Depends-On:https://review.coreboot.org/c/flashrom/+/41533 BUG=b:139058552 BRANCH=servo TEST=Tested with Servo Micro with the reading, erase, write, and verify operations with updated copies of flashrom. Change-Id: I04b6cf8449e32cc1b75d3501939958887eb57f5b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2224765 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> Tested-by: Brian Nemec <bnemec@chromium.org>
* cleanup: Fix common spelling typos in commentsTom Hughes2019-06-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | Used 'git grep' to fix the following misspelled words across the codebase: * woud * setion * cleand * independantly * dedup BRANCH=none BUG=none TEST=make buildall -j Change-Id: I95905c56221034cf3f9d286755d7e0c07f8c58b6 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1678246 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Sean Abraham <seanabraham@chromium.org>
* 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>
* common: replace 1 << digits, with BIT(digits)Gwendal Grignou2019-03-261-2/+2
| | | | | | | | | | | | | | | | Requested for linux integration, use BIT instead of 1 << First step replace bit operation with operand containing only digits. Fix an error in motion_lid try to set bit 31 of a signed integer. BUG=None BRANCH=None TEST=compile Change-Id: Ie843611f2f68e241f0f40d4067f7ade726951d29 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* touchpad heatmap: set subclass and protocolWei-Han Chen2018-08-311-0/+3
| | | | | | | | | | | | | | BRANCH=none TEST=make buildall -j TEST=test on whiskers BUG=b:70482333 Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: Ieadb743b428997ca1e7c9d45837f503d3023f779 Reviewed-on: https://chromium-review.googlesource.com/1198942 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* Add WebUSB descriptor supportVincent Palatin2017-09-221-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | The WebUSB specification defines a specific Platform Descriptor in the Binary Object Store: https://wicg.github.io/webusb/#webusb-platform-capability-descriptor This descriptor provides a special 'Landing page' URL to the host browser and associated privileges for it. Bump the USB version for BOS descriptors to 2.1 to be compatible with Chrome implementation. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=none BRANCH=twinkie TEST=manual: on Twinkie (chip/stm32) and HG proto2 (chip/g), enumerate WebUSB descriptors with lsusb and connect to a WebUSB page in Chrome R61+. Change-Id: I7211ab554f4a6c156c1e8e79a3d9f0d6644217c6 Reviewed-on: https://chromium-review.googlesource.com/664813 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Add OTP supportGwendal Grignou2017-07-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One Time Programmable memory can be used to store permanent data like serial numbers. Reorganize the code to support writing serial number to OTP, in addition to pstate (if using its own memory bank) or autogenerate from unique id (hammer). + Add CONFIG_OTP to enable OTP code + Add CONFIG_SERIALNO_LEN to indicate the size of the serial number string. Currently set to 28, when USB serial number is needed. + Expose flash_read|write_pstate_serial and add otp_read|write_serail, remove more generic flash_read|write_serial. + Make board_read|write_serial generic, declared outside of USB subsystem. Priority order to read|write serial string: - board definition (like hammer) - pstate location, if stored in its private memory bank - otp area If none of these methods are available, a compilation error is raised. BUG=chromium:746471 BRANCH=none TEST=compile Change-Id: I3d16125a6c0f424fb30e38123e63cf074b3cb2d3 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/580289 Reviewed-by: Nick Sanders <nsanders@chromium.org>
* hammer: Enable Link-Time-Optimization CONFIG_LTONicolas Boichat2017-07-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | We need to add __keep to the USB descriptors, otherwise they get thrown away. Also, for some reason the optimized RWSIG task uses a little bit more stack space, so account for that: 1 RWSIG 00000000 0.264350 1096/2048 BRANCH=none BUG=b:63610290 TEST=make BOARD=hammer -j make newsizes build/hammer/RO/ec.RO.flat shrank by 2052 bytes: (37336 to 35284) build/hammer/RW/ec.RW.flat shrank by 3172 bytes: (50508 to 47336) Flash hammer, touchpad, keyboard, update all still work fine. Change-Id: I39ffd320dae883596ce481efc4adec6e3c23000b Reviewed-on: https://chromium-review.googlesource.com/567909 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* hammer: Make keyboard work at firmware screenNicolas Boichat2017-05-181-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, libpayload expects the keyboard interface index to be 0. Then, hid_iface_request needs to reply to USB_HID_DT_HID request with the content of struct usb_hid_descriptor. With current code, the variable name is generated (and therefore hard to guess), so we create a new set of macros so that we can use a specific variable name. Also, add support for HID Get_Protocol and Set_Protocol, as they are compulsory for devices supporting boot protocol, even though those are mostly no-op for now. Finally, add a note regarding USB HID keyboard boot protocol, to make sure that we do not accidentally change the report format. BRANCH=none BUG=b:36538963 TEST=Keyboard works in FW screen, both trackpad and keyboard still work when AP has booted. TEST=hammer/staff can still be updated (both RO from RW, and RW from RO) Change-Id: Ibea4888385909c9ce3b430464e5805c039d4b9ed Reviewed-on: https://chromium-review.googlesource.com/505796 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* flash: ensure proper pstate alignmentVincent Palatin2017-03-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The pstate structure is written using the low-level flash_physical_write() function. As a consequence, it is supposed to meet the CONFIG_FLASH_WRITE_SIZE alignment constraint. Add a build-time assertion to avoid silent failures. Slightly decrease the maximum size of the serial number string, so the structure has a natural 32-byte alignment which is compatible with a large number of platforms (including STM32L4 which requires 64-bit alignment). Of course, this change is not fully backward-compatible. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chromium:571477 b:35648258 TEST=on STM32L442, build and run 'flashrom --wp-enable' without failure. Change-Id: Ia8f82790a61a6c7d2cf9bfeb95bfdaf7b8c52d11 Reviewed-on: https://chromium-review.googlesource.com/458201 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org>
* usb: Cleanup headersNicolas Boichat2017-03-161-3/+0
| | | | | | | | | | | | | | | | | | | 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>
* chip/stm32/usb: Add support for USB SET_FEATURE control requestsNicolas Boichat2017-03-081-0/+5
| | | | | | | | | | | | | | | | | | | | This is required so that the kernel can enable/disable remote wake-up capabilities, and in particular for the kernel to enable autosuspend. Also, properly implement GET_STATUS. BRANCH=none BUG=b:35579996 TEST=echo auto > /sys/bus/usb/drivers/usb/X-Y/power/control, device autosuspends after 2 seconds, and wakes on keypress. Note that this introduces other bugs, where keys are missing, repeated, see b/35775048. Change-Id: I7ddd257ac3877d27fb2da813f20583a614a0169b Reviewed-on: https://chromium-review.googlesource.com/450826 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* sweetberry: add usb power logging interfaceNick Sanders2016-11-111-0/+3
| | | | | | | | | | | | | This allows logging of power data over sweetberry BUG=chromium:608039 TEST=log power data BRANCH=None Change-Id: I6f642384cbf223959294c7bd99bca0f9206775b8 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/385540 Reviewed-by: Todd Broch <tbroch@chromium.org>
* sweetberry: add dwc usb supportNick Sanders2016-09-011-0/+14
| | | | | | | | | | | | | | | stm32f446 uses a synopsys designware USB block rather than the typical ST one. This change adds driver support for the new block, including usb console support. BUG=chromium:608039 TEST=usb console works BRANCH=None Change-Id: I0e143758ae0b5285f1c94ea2ec5aee159e22e00c Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/365448 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* servo_v4: copypasta usb updater code into commonNick Sanders2016-07-211-1/+5
| | | | | | | | | | | | | | | | | This copies the generic USB update code into common so it can be used on other platforms. There should be no functional change. cr50 folks want no change to their code so vbendeb@chomium.org will refactor this back together at a later date. BUG=chromium:571476 TEST=none BRANCH=none Change-Id: I710afb22940013e7db5d8694898b90c0ae245777 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/362131 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* servo_micro: add programmable serial numberNick Sanders2016-05-261-0/+18
| | | | | | | | | | | | | | | | This change provides a console command for setting, and loading a usb serial number from flash. This feature adds CONFIG_USB_SERIALNO, and currently only has a useful implementation when PSTATE is present. BUG=chromium:571477 TEST=serialno set abcdef; serialno load; reboot BRANCH=none Change-Id: I3b24cfa2d52d54118bc3fd54b276e3d95412d245 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/337359 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Cr50: Update the USB VID:PID:subclass constantsBill Richardson2016-04-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | | The device-specific subclass used for Non-HC firmware updates is in the spreadsheet now, so we can rename the macros to be "official". BUG=chrome-os-partner:49962 BRANCH=none TEST=make buildall; test on cr50 make BOARD=cr50 (plus whatever signing magic works for you) make -C extra/usb_updater ./extra/usb_updater/usb_updater build/cr50/ec.bin (sudo if needed) Note that you may need to rebuild ec.bin in order to see any difference after the update. If the A & B images are identical, the RO bootloader always picks A. Change-Id: I385ce89a9abe2059d52da2d82a0b92b9b3e3c93f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/339220 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* servo_micro: add USB I2C interfaceNick Sanders2016-03-151-0/+4
| | | | | | | | | | | | | | | | | | Add a usb endpoint and class for i2c control via USB. Used for servo micro and servo_v4 to export USB control through servod. BUG=chromium:571477 BRANCH=None TEST=updated servod is able to control gpio extender on servo_micro Signed-off-by: Nick Sanders <nsanders@google.com> Change-Id: Id44096f8c9e2da917c0574d28dfcbcc0adf31950 Reviewed-on: https://chromium-review.googlesource.com/329322 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb: Put HID descriptor in the correct orderBill Richardson2015-12-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From the "Device Class Definition for Human Interface Devices" spec: When a Get_Descriptor(Configuration) request is issued, it returns the Configuration descriptor, all Interface descriptors, all Endpoint descriptors, and the HID descriptor for each interface. It shall not return the String descriptor, HID Report descriptor or any of the optional HID class descriptors. The HID descriptor shall be interleaved between the Interface and Endpoint descriptors for HID Interfaces. That is, the order shall be: Configuration descriptor Interface descriptor (specifying HID Class) HID descriptor (associated with above Interface) Endpoint descriptor (for HID Interrupt In Endpoint) Optional Endpoint descriptor (for HID Interrupt Out Endpoint) This makes that happen. BUG=chrome-os-partner:34893 BRANCH=none TEST=manual "make buildall" works, this image seems to work on the Cr50. Also, before this CL, I see this: 0x00060f5c 0x00000000 .rodata g NOTYPE __usb_desc 0x00060f5c 0x00000009 .rodata g OBJECT usb_desc_conf 0x00060f65 0x00000009 .rodata g OBJECT usb_desc_iface0_0iface 0x00060f6e 0x00000007 .rodata g OBJECT usb_desc_iface0_1ep0 0x00060f75 0x00000007 .rodata g OBJECT usb_desc_iface0_1ep1 0x00060f7c 0x00000009 .rodata g OBJECT usb_desc_iface1_0iface 0x00060f85 0x00000007 .rodata g OBJECT usb_desc_iface1_1ep81 0x00060f8c 0x00000009 .rodata g OBJECT usb_desc_iface1_2hid 0x00060f95 0x00000000 .rodata g NOTYPE __usb_desc_end and after, this: 0x00060f5c 0x00000000 .rodata g NOTYPE __usb_desc 0x00060f5c 0x00000009 .rodata g OBJECT usb_desc_conf 0x00060f65 0x00000009 .rodata g OBJECT usb_desc_iface0_0iface 0x00060f6e 0x00000007 .rodata g OBJECT usb_desc_iface0_2ep0 0x00060f75 0x00000007 .rodata g OBJECT usb_desc_iface0_2ep1 0x00060f7c 0x00000009 .rodata g OBJECT usb_desc_iface1_0iface 0x00060f85 0x00000009 .rodata g OBJECT usb_desc_iface1_1hid 0x00060f8e 0x00000007 .rodata g OBJECT usb_desc_iface1_2ep81 0x00060f95 0x00000000 .rodata g NOTYPE __usb_desc_end The HID descriptor comes before the endpoint. Change-Id: I8035a4cc884d8bb900bc1eb25fd3e4e9aba05bf8 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/314832 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* cleanup: Rename usb.h to usb_descriptor.hShawn Nematbakhsh2015-11-081-0/+247
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>