diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2015-03-05 13:03:45 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-03-12 03:42:18 +0000 |
commit | df8ff35f79ca88bc75785a8e3f8d3b6b7ec9948d (patch) | |
tree | 3967a8c3349e37aa2daac21903969e01e5b962b0 | |
parent | 23716f05aa2261f3c8f75c25a1ee30c795b96e98 (diff) | |
download | chrome-ec-df8ff35f79ca88bc75785a8e3f8d3b6b7ec9948d.tar.gz |
honeybuns: add HX3 hub configuration
Send the Cypress HX3 Hub configuration over I2C.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=chrome-os-partner:37078
TEST=see the Hub booting in normal mode and enumerating.
Change-Id: I7e32eecd1d69ba0899b726c0405d392602e7d8b7
Reviewed-on: https://chromium-review.googlesource.com/256697
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/honeybuns/build.mk | 2 | ||||
-rw-r--r-- | board/honeybuns/hx3.c | 116 |
2 files changed, 117 insertions, 1 deletions
diff --git a/board/honeybuns/build.mk b/board/honeybuns/build.mk index 7058e7ca57..ff4b39a2ce 100644 --- a/board/honeybuns/build.mk +++ b/board/honeybuns/build.mk @@ -10,5 +10,5 @@ CHIP:=stm32 CHIP_FAMILY:=stm32f0 CHIP_VARIANT:=stm32f07x -board-y=board.o +board-y=board.o hx3.o board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o diff --git a/board/honeybuns/hx3.c b/board/honeybuns/hx3.c new file mode 100644 index 0000000000..df9bcfe121 --- /dev/null +++ b/board/honeybuns/hx3.c @@ -0,0 +1,116 @@ +/* Copyright 2015 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/* Cypress HX3 USB Hub configuration */ + +#include "common.h" +#include "console.h" +#include "ec_version.h" +#include "gpio.h" +#include "hooks.h" +#include "i2c.h" +#include "timer.h" +#include "usb.h" +#include "util.h" + +/* Cypress HX3 I2C address */ +#define HX3_I2C_ADDR (0x60 << 1) + +/* Full size setting blob */ +#define HX3_SETTINGS_SIZE 192 + +/* USB PID assigned the HX3 USB Hub */ +#define USB_PID_HUB 0x5016 + +/* represent a 16-bit integer as 2 uint8_t in little endian */ +#define U16(n) ((n) & 0xff), ((n) >> 8) + +/* Cypress HX3 hub settings blob */ +const uint8_t hx3_settings[5 + HX3_SETTINGS_SIZE] = { + 'C', 'Y', /* Cypress magic signature */ + 0x30, /* I2C speed : 100kHz */ + 0xd4, /* Image type: Only settings, no firmware */ + HX3_SETTINGS_SIZE, /* 192 bytes payload */ + U16(USB_VID_GOOGLE), U16(USB_PID_HUB), /* USB VID:PID 0x18d1:0x5016 */ + U16(0x0100), /* bcdDevice 1.00 */ + 0x00, /* Reserved */ + 0x0f, /* 4 SuperSpeed ports, no shared link */ + 0x32, /* bPwrOn2PwrGood : 100 ms */ + 0xef, /* 4 Downstream ports : DS4 is non-removable (MCU) */ + 0x10, + 0xa0, /* Suspend indicator disabled, Power switch : active HIGH */ + 0x15, /* BC1.2 + ACA Dock + Ghost charging */ + 0xf0, /* CDP enabled, DCP disabled */ + 0x68, + 0x00, /* Reserved */ + 0x08, /* USB String descriptors enabled */ + 0x00, 0x00, + 0x12, 0x00, 0x2c, + 0x66, 0x66, /* USB3.0 TX driver de-emphasis */ + 0x69, 0x29, 0x29, 0x29, 0x29, /* TX amplitude */ + 0x00, /* Reserved */ + U16(USB_PID_HUB), /* USB2.0 PID: 0x5016 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Reserved */ + 0x04, USB_DT_STRING, 0x09, 0x04, /* LangID = 0x0409 US English */ + + 0x18, USB_DT_STRING, /* Manufacturer string descriptor */ + 0x47, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x67, 0x00, /* Google Inc. */ + 0x6c, 0x00, 0x65, 0x00, 0x20, 0x00, 0x49, 0x00, /* as UTF-8 */ + 0x6e, 0x00, 0x63, 0x00, 0x2e, 0x00, + + 0x1C, USB_DT_STRING, /* Product string descriptor */ + 0x48, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x65, 0x00, /* HoneyBuns Hub */ + 0x79, 0x00, 0x62, 0x00, 0x75, 0x00, 0x6e, 0x00, /* as UTF-8 */ + 0x73, 0x00, 0x20, 0x00, 0x48, 0x00, 0x75, 0x00, + 0x62, 0x00, + + 0x02, USB_DT_STRING, /* Serial string descriptor : empty */ + /* Free space for more strings */ +}; + +static void configure_hx3(void) +{ + int ret; + int remaining, len; + uint8_t *data = (uint8_t *)hx3_settings; + uint16_t addr = 0x0000; + + /* Reset the bridge to put it back in bootloader mode */ + gpio_set_level(GPIO_HUB_RESET_L, 0); + /* Keep the reset low at least 10ms (same as the RC) */ + msleep(50); + gpio_set_level(GPIO_HUB_RESET_L, 1); + msleep(50); + + remaining = sizeof(hx3_settings); + while (remaining) { + /* do 64-byte Page Write */ + len = MIN(remaining, 64); + i2c_lock(0, 1); + /* send Page Write address */ + ret = i2c_xfer(0, HX3_I2C_ADDR, (uint8_t *)&addr, 2, + NULL, 0, I2C_XFER_START); + /* send page data */ + ret |= i2c_xfer(0, HX3_I2C_ADDR, data, len, + NULL, 0, I2C_XFER_STOP); + i2c_lock(0, 0); + if (ret != EC_SUCCESS) + ccprintf("HX3 transfer failed %d\n", ret); + remaining -= len; + data += len; + } +} +DECLARE_HOOK(HOOK_INIT, configure_hx3, HOOK_PRIO_DEFAULT); + + +static int command_hx3(int argc, char **argv) +{ + configure_hx3(); + + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(hx3, command_hx3, + "", + "Reset and Send HX3 Hub settings over I2C", + NULL); |