Commit Graph

12 Commits

Author SHA1 Message Date
Nicolas Boichat
11237d5e91 hammer: Make keyboard work at firmware screen
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>
2017-05-18 06:03:52 -07:00
Vincent Palatin
d9afaba9b4 flash: ensure proper pstate alignment
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>
2017-03-24 09:32:53 -07:00
Nicolas Boichat
391056f9ee usb: Cleanup headers
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>
2017-03-16 11:25:50 -07:00
Nicolas Boichat
3898267abb chip/stm32/usb: Add support for USB SET_FEATURE control requests
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>
2017-03-08 03:13:19 -08:00
Nick Sanders
bb3ab2fbc4 sweetberry: add usb power logging interface
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>
2016-11-11 17:20:19 -08:00
Nick Sanders
a4bfc663a3 sweetberry: add dwc usb support
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>
2016-09-01 22:56:22 -07:00
Nick Sanders
14dbcb829e servo_v4: copypasta usb updater code into common
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>
2016-07-21 13:13:35 -07:00
Nick Sanders
56ee8aefc3 servo_micro: add programmable serial number
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>
2016-05-26 16:17:26 -07:00
Bill Richardson
b28ed970c4 Cr50: Update the USB VID:PID:subclass constants
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>
2016-04-15 15:09:08 -07:00
Nick Sanders
750b4525da servo_micro: add USB I2C interface
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>
2016-03-15 21:49:35 -07:00
Bill Richardson
9167ce0232 usb: Put HID descriptor in the correct order
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>
2015-12-01 18:52:52 -08:00
Shawn Nematbakhsh
6f4595ff7a cleanup: Rename usb.h to usb_descriptor.h
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>
2015-11-08 17:31:11 -08:00