mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
usb_i2c: refactor into common
This combines stm32 and chip/g usb_i2c interfaces so they will not diverge. Note that this fixes the chip/g implementation to use 8-bit i2c addresses. BUG=chrome-os-partner:57059 BRANCH=none TEST=servod interacts with servo_micro and servo_v4 Change-Id: Ibff217d84b132556202c8a71e3d42c07d546c634 Reviewed-on: https://chromium-review.googlesource.com/405108 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
This commit is contained in:
@@ -130,6 +130,7 @@ const void *const usb_strings[] = {
|
||||
[USB_STR_PRODUCT] = USB_STRING_DESC("Servo Micro"),
|
||||
[USB_STR_SERIALNO] = 0,
|
||||
[USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32),
|
||||
[USB_STR_I2C_NAME] = USB_STRING_DESC("I2C"),
|
||||
[USB_STR_USART4_STREAM_NAME] = USB_STRING_DESC("Servo UART3"),
|
||||
[USB_STR_CONSOLE_NAME] = USB_STRING_DESC("Servo EC Shell"),
|
||||
[USB_STR_USART3_STREAM_NAME] = USB_STRING_DESC("Servo UART2"),
|
||||
@@ -198,7 +199,8 @@ const struct i2c_port_t i2c_ports[] = {
|
||||
};
|
||||
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
|
||||
|
||||
USB_I2C_CONFIG(usb_i2c, USB_IFACE_I2C, USB_EP_I2C);
|
||||
int usb_i2c_board_enable(void) {return EC_SUCCESS; }
|
||||
void usb_i2c_board_disable(int debounce) {}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
@@ -100,6 +100,7 @@ enum usb_strings {
|
||||
USB_STR_PRODUCT,
|
||||
USB_STR_SERIALNO,
|
||||
USB_STR_VERSION,
|
||||
USB_STR_I2C_NAME,
|
||||
USB_STR_USART4_STREAM_NAME,
|
||||
USB_STR_CONSOLE_NAME,
|
||||
USB_STR_USART3_STREAM_NAME,
|
||||
|
||||
@@ -180,6 +180,7 @@ const void *const usb_strings[] = {
|
||||
[USB_STR_PRODUCT] = USB_STRING_DESC("Servo V4"),
|
||||
[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("Servo EC Shell"),
|
||||
[USB_STR_USART3_STREAM_NAME] = USB_STRING_DESC("DUT UART"),
|
||||
[USB_STR_USART4_STREAM_NAME] = USB_STRING_DESC("Atmega UART"),
|
||||
@@ -202,8 +203,8 @@ const struct i2c_port_t i2c_ports[] = {
|
||||
};
|
||||
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
|
||||
|
||||
USB_I2C_CONFIG(usb_i2c, USB_IFACE_I2C, USB_EP_I2C);
|
||||
|
||||
int usb_i2c_board_enable(void) {return EC_SUCCESS; }
|
||||
void usb_i2c_board_disable(int debounce) {}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
@@ -93,6 +93,7 @@ enum usb_strings {
|
||||
USB_STR_PRODUCT,
|
||||
USB_STR_SERIALNO,
|
||||
USB_STR_VERSION,
|
||||
USB_STR_I2C_NAME,
|
||||
USB_STR_CONSOLE_NAME,
|
||||
USB_STR_USART3_STREAM_NAME,
|
||||
USB_STR_USART4_STREAM_NAME,
|
||||
|
||||
@@ -56,7 +56,6 @@ chip-$(CONFIG_WATCHDOG)+=watchdog.o
|
||||
chip-$(CONFIG_USB)+=usb.o usb_endpoints.o
|
||||
chip-$(CONFIG_USB_CONSOLE)+=usb_console.o
|
||||
chip-$(CONFIG_USB_HID)+=usb_hid.o
|
||||
chip-$(CONFIG_USB_I2C)+=usb_i2c.o
|
||||
chip-$(CONFIG_USB_BLOB)+=blob.o
|
||||
chip-$(CONFIG_USB_SPI)+=usb_spi.o
|
||||
chip-$(CONFIG_RDD)+=rdd.o
|
||||
|
||||
@@ -70,5 +70,4 @@ chip-$(CONFIG_USB_GPIO)+=usb_gpio.o
|
||||
chip-$(CONFIG_USB_HID)+=usb_hid.o
|
||||
chip-$(CONFIG_USB_PD_TCPC)+=usb_pd_phy.o
|
||||
chip-$(CONFIG_USB_SPI)+=usb_spi.o
|
||||
chip-$(CONFIG_USB_I2C)+=usb_i2c.o
|
||||
endif
|
||||
|
||||
@@ -87,13 +87,14 @@ common-$(CONFIG_SW_CRC)+=crc.o
|
||||
common-$(CONFIG_TEMP_SENSOR)+=temp_sensor.o
|
||||
common-$(CONFIG_THROTTLE_AP)+=thermal.o throttle_ap.o
|
||||
common-$(CONFIG_TPM_I2CS)+=i2cs_tpm.o
|
||||
common-$(CONFIG_USB_I2C)+=usb_i2c.o
|
||||
common-$(CONFIG_USB_CHARGER)+=usb_charger.o
|
||||
common-$(CONFIG_USB_PORT_POWER_DUMB)+=usb_port_power_dumb.o
|
||||
common-$(CONFIG_USB_PORT_POWER_SMART)+=usb_port_power_smart.o
|
||||
common-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_protocol.o usb_pd_policy.o
|
||||
common-$(CONFIG_USB_PD_LOGGING)+=pd_log.o
|
||||
common-$(CONFIG_USB_PD_TCPC)+=usb_pd_tcpc.o
|
||||
common-$(CONFIG_USB_UPDATE)+= usb_update.o update_fw.o
|
||||
common-$(CONFIG_USB_UPDATE)+=usb_update.o update_fw.o
|
||||
common-$(CONFIG_VBOOT_HASH)+=sha256.o vboot_hash.o
|
||||
common-$(CONFIG_VSTORE)+=vstore.o
|
||||
common-$(CONFIG_WIRELESS)+=wireless.o
|
||||
|
||||
@@ -58,7 +58,8 @@ void usb_i2c_deferred(struct usb_i2c_config const *config)
|
||||
*/
|
||||
uint8_t count = usb_i2c_read_packet(config);
|
||||
int portindex = (config->buffer[0] >> 0) & 0xff;
|
||||
uint8_t slave_addr = (config->buffer[0] >> 8) & 0xff;
|
||||
/* Convert 7-bit slave address to chromium EC 8-bit address. */
|
||||
uint8_t slave_addr = (config->buffer[0] >> 7) & 0xfe;
|
||||
int write_count = (config->buffer[1] >> 0) & 0xff;
|
||||
int read_count = (config->buffer[1] >> 8) & 0xff;
|
||||
int port;
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "registers.h"
|
||||
#include "task.h"
|
||||
#include "usb_descriptor.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifndef __CROS_USB_I2C_H
|
||||
#define __CROS_USB_I2C_H
|
||||
Reference in New Issue
Block a user