mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-12 10:55:21 +00:00
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>
This commit is contained in:
committed by
chrome-bot
parent
e633c3c7db
commit
cb4338e289
@@ -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)))
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
13
chip/stm32/usb_dwc_i2c.h
Normal file
13
chip/stm32/usb_dwc_i2c.h
Normal file
@@ -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 */
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user