diff options
author | Ruben Rodriguez Buchillon <coconutruben@chromium.org> | 2018-05-05 18:32:12 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-05-21 18:19:29 -0700 |
commit | cb4338e289389d699f26204c73aede4e24dd296e (patch) | |
tree | b9e0cc1882811a49ca36e72d3698e7a327cb1ff3 | |
parent | e633c3c7dbc28cf92ae541f1426d0dac7a80901d (diff) | |
download | chrome-ec-cb4338e289389d699f26204c73aede4e24dd296e.tar.gz |
sweetberry: expose i2c over usb
Expose the i2c interface through usb so that we can read power rails
through servod leveraging the work being done there.
BRANCH=none
BUG=chromium:806148
TEST=manual testing
- powerlog still works
- i2c over usb using servod code works (other CLs needed)
Change-Id: I48876bc4839509a397ce77376b337c37c556ae40
Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1051136
Reviewed-by: Nick Sanders <nsanders@chromium.org>
-rw-r--r-- | board/sweetberry/board.c | 11 | ||||
-rw-r--r-- | board/sweetberry/board.h | 23 | ||||
-rw-r--r-- | chip/stm32/build.mk | 1 | ||||
-rw-r--r-- | chip/stm32/usb_dwc_i2c.h | 13 | ||||
-rw-r--r-- | common/usb_i2c.c | 2 |
5 files changed, 36 insertions, 14 deletions
diff --git a/board/sweetberry/board.c b/board/sweetberry/board.c index 8131eb9b18..9488695e1e 100644 --- a/board/sweetberry/board.c +++ b/board/sweetberry/board.c @@ -16,11 +16,13 @@ #include "task.h" #include "update_fw.h" #include "usb_descriptor.h" -#include "util.h" #include "usb_dwc_console.h" +#include "usb_dwc_i2c.h" +#include "usb_dwc_stream.h" +#include "usb_dwc_update.h" #include "usb_hw.h" #include "usb_power.h" -#include "usb_dwc_update.h" +#include "util.h" /****************************************************************************** * Define the strings used in our USB descriptors. @@ -31,6 +33,7 @@ const void *const usb_strings[] = { [USB_STR_PRODUCT] = USB_STRING_DESC("Sweetberry"), [USB_STR_SERIALNO] = USB_STRING_DESC("1234-a"), [USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32), + [USB_STR_I2C_NAME] = USB_STRING_DESC("I2C"), [USB_STR_CONSOLE_NAME] = USB_STRING_DESC("Sweetberry EC Shell"), [USB_STR_UPDATE_NAME] = USB_STRING_DESC("Firmware update"), }; @@ -40,13 +43,13 @@ BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT); /* USB power interface. */ USB_POWER_CONFIG(sweetberry_power, USB_IFACE_POWER, USB_EP_POWER); - struct dwc_usb usb_ctl = { .ep = { &ep0_ctl, &ep_console_ctl, &usb_update_ep_ctl, &sweetberry_power_ep_ctl, + &i2c_usb__ep_ctl, }, .speed = USB_SPEED_FS, .phy_type = USB_PHY_ULPI, @@ -67,6 +70,8 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); +int usb_i2c_board_is_enabled(void) { return 1; } + #define GPIO_SET_HS(bank, number) \ (STM32_GPIO_OSPEEDR(GPIO_##bank) |= (0x3 << ((number) * 2))) diff --git a/board/sweetberry/board.h b/board/sweetberry/board.h index be661608c5..43503e096e 100644 --- a/board/sweetberry/board.h +++ b/board/sweetberry/board.h @@ -31,13 +31,6 @@ #define CONFIG_UART_TX_REQ_CH 4 #define CONFIG_UART_RX_REQ_CH 4 -#define CONFIG_I2C -#define CONFIG_I2C_MASTER -#define I2C_PORT_0 0 -#define I2C_PORT_1 1 -#define I2C_PORT_2 2 -#define FMPI2C_PORT_3 3 - /* USB Configuration */ #define CONFIG_USB #define CONFIG_USB_PID 0x5020 @@ -56,14 +49,25 @@ #define USB_IFACE_CONSOLE 0 #define USB_IFACE_UPDATE 1 #define USB_IFACE_POWER 2 -#define USB_IFACE_COUNT 3 +#define USB_IFACE_I2C 3 +#define USB_IFACE_COUNT 4 /* USB endpoint indexes (use define rather than enum to expand them) */ #define USB_EP_CONTROL 0 #define USB_EP_CONSOLE 1 #define USB_EP_UPDATE 2 #define USB_EP_POWER 3 -#define USB_EP_COUNT 4 +#define USB_EP_I2C 4 +#define USB_EP_COUNT 5 + +#define CONFIG_USB_I2C +#define CONFIG_I2C +#define CONFIG_I2C_MASTER +#define I2C_PORT_0 0 +#define I2C_PORT_1 1 +#define I2C_PORT_2 2 +#define FMPI2C_PORT_3 3 +#define I2C_PORT_COUNT 4 /* This is not actually a Chromium EC so disable some features. */ #undef CONFIG_WATCHDOG_HELP @@ -93,6 +97,7 @@ enum usb_strings { USB_STR_PRODUCT, USB_STR_SERIALNO, USB_STR_VERSION, + USB_STR_I2C_NAME, USB_STR_CONSOLE_NAME, USB_STR_UPDATE_NAME, USB_STR_COUNT diff --git a/chip/stm32/build.mk b/chip/stm32/build.mk index 9a6a280d81..e7f28309b3 100644 --- a/chip/stm32/build.mk +++ b/chip/stm32/build.mk @@ -75,7 +75,6 @@ chip-$(CONFIG_USB)+=usb_dwc.o usb_endpoints.o chip-$(CONFIG_USB_CONSOLE)+=usb_dwc_console.o chip-$(CONFIG_USB_POWER)+=usb_power.o chip-$(CONFIG_STREAM_USB)+=usb_dwc_stream.o -chip-$(CONFIG_USB_I2C)+=usb_dwc_i2c.o else chip-$(CONFIG_STREAM_USB)+=usb-stream.o chip-$(CONFIG_USB)+=usb.o usb-$(CHIP_FAMILY).o usb_endpoints.o diff --git a/chip/stm32/usb_dwc_i2c.h b/chip/stm32/usb_dwc_i2c.h new file mode 100644 index 0000000000..e44002268a --- /dev/null +++ b/chip/stm32/usb_dwc_i2c.h @@ -0,0 +1,13 @@ +/* Copyright 2018 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. + */ + +#ifndef __CROS_EC_USB_DWC_I2C_H +#define __CROS_EC_USB_DWC_I2C_H +#include "usb_i2c.h" + +/* I2C over USB interface. This gets declared in usb_i2c.c */ +extern struct dwc_usb_ep i2c_usb__ep_ctl; + +#endif /* __CROS_EC_USB_DWC_I2C_H */ diff --git a/common/usb_i2c.c b/common/usb_i2c.c index cd67f68a7a..4c17ff487e 100644 --- a/common/usb_i2c.c +++ b/common/usb_i2c.c @@ -13,9 +13,9 @@ #include "common.h" #include "console.h" #include "consumer.h" +#include "producer.h" #include "queue.h" #include "queue_policies.h" -#include "producer.h" #include "task.h" #include "usb-stream.h" #include "usb_i2c.h" |