mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-02 21:25:03 +00:00
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>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
23716f05aa
commit
df8ff35f79
@@ -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
|
||||
|
||||
116
board/honeybuns/hx3.c
Normal file
116
board/honeybuns/hx3.c
Normal file
@@ -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);
|
||||
Reference in New Issue
Block a user