summaryrefslogtreecommitdiff
path: root/board/sweetberry
diff options
context:
space:
mode:
authorRuben Rodriguez Buchillon <coconutruben@chromium.org>2018-05-05 18:32:12 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-05-21 18:19:29 -0700
commitcb4338e289389d699f26204c73aede4e24dd296e (patch)
treeb9e0cc1882811a49ca36e72d3698e7a327cb1ff3 /board/sweetberry
parente633c3c7dbc28cf92ae541f1426d0dac7a80901d (diff)
downloadchrome-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>
Diffstat (limited to 'board/sweetberry')
-rw-r--r--board/sweetberry/board.c11
-rw-r--r--board/sweetberry/board.h23
2 files changed, 22 insertions, 12 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