mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
cleanup: Remove usb_switch_tsu6721 driver
This driver is not in use for any recent board and doesn't implement the soon-to-be standard usb_switch interface routine. BUG=chrome-os-partner:53363 BRANCH=None TEST=`make buildall -j` Change-Id: I7469dab42e52d9d02425ad4e7bacb81b2489ffc4 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/344417 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
4bc7964f5b
commit
7d8964614d
@@ -744,10 +744,6 @@ static int host_command_get_features(struct host_cmd_handler_args *args)
|
||||
#ifdef CONFIG_CHARGE_MANAGER
|
||||
| EC_FEATURE_MASK_0(EC_FEATURE_USB_PD)
|
||||
#endif
|
||||
/* should be more generic */
|
||||
#ifdef CONFIG_USB_SWITCH_TSU6721
|
||||
| EC_FEATURE_MASK_0(EC_FEATURE_USB_MUX)
|
||||
#endif
|
||||
#ifdef CONFIG_ACCEL_FIFO
|
||||
| EC_FEATURE_MASK_0(EC_FEATURE_MOTION_SENSE_FIFO)
|
||||
#endif
|
||||
|
||||
@@ -81,7 +81,6 @@ driver-$(CONFIG_USB_PD_TCPM_ITE83XX)+=tcpm/it83xx.o
|
||||
|
||||
# USB switches
|
||||
driver-$(CONFIG_USB_SWITCH_PI3USB9281)+=usb_switch_pi3usb9281.o
|
||||
driver-$(CONFIG_USB_SWITCH_TSU6721)+=usb_switch_tsu6721.o
|
||||
|
||||
# USB mux high-level driver
|
||||
driver-$(CONFIG_USBC_SS_MUX)+=usb_mux.o
|
||||
|
||||
118
driver/tsu6721.h
118
driver/tsu6721.h
@@ -1,118 +0,0 @@
|
||||
/* Copyright (c) 2012 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.
|
||||
*
|
||||
* TI TSU6721 USB port switch.
|
||||
*/
|
||||
|
||||
#ifndef __CROS_EC_TSU6721_H
|
||||
#define __CROS_EC_TSU6721_H
|
||||
|
||||
#define TSU6721_REG_DEV_ID 0x01
|
||||
#define TSU6721_REG_CONTROL 0x02
|
||||
#define TSU6721_REG_INT1 0x03
|
||||
#define TSU6721_REG_INT2 0x04
|
||||
#define TSU6721_REG_INT_MASK1 0x05
|
||||
#define TSU6721_REG_INT_MASK2 0x06
|
||||
#define TSU6721_REG_ADC 0x07
|
||||
#define TSU6721_REG_TIMING1 0x08
|
||||
#define TSU6721_REG_TIMING2 0x09
|
||||
#define TSU6721_REG_DEV_TYPE1 0x0A
|
||||
#define TSU6721_REG_DEV_TYPE2 0x0B
|
||||
#define TSU6721_REG_BUTTON1 0x0C
|
||||
#define TSU6721_REG_BUTTON2 0x0D
|
||||
#define TSU6721_REG_MANUAL1 0x13
|
||||
#define TSU6721_REG_MANUAL2 0x14
|
||||
#define TSU6721_REG_DEV_TYPE3 0x15
|
||||
#define TSU6721_REG_RESET 0x1B
|
||||
#define TSU6721_REG_TIMER 0x20
|
||||
#define TSU6721_REG_OCP1 0x21
|
||||
#define TSU6721_REG_OCP2 0x22
|
||||
|
||||
#define TSU6721_CTRL_AUTO (1 << 2)
|
||||
|
||||
enum tsu6721_mux {
|
||||
TSU6721_MUX_AUTO = 0x00,
|
||||
TSU6721_MUX_USB = 0x24,
|
||||
TSU6721_MUX_AUDIO = 0x48,
|
||||
TSU6721_MUX_UART = 0x6C,
|
||||
};
|
||||
|
||||
#define TSU6721_PIN_MANUAL2_JIG (1 << 2)
|
||||
#define TSU6721_PIN_MANUAL2_BOOT (1 << 3)
|
||||
#define TSU6721_PIN_MANUAL2_ISET (1 << 4)
|
||||
|
||||
#define TSU6721_INT_ATTACH 0x0001
|
||||
#define TSU6721_INT_DETACH 0x0002
|
||||
#define TSU6721_INT_KP 0x0004
|
||||
#define TSU6721_INT_LKP 0x0008
|
||||
#define TSU6721_INT_LKR 0x0010
|
||||
#define TSU6721_INT_OVP_EN 0x0020
|
||||
#define TSU6721_INT_OCP_EN 0x0040
|
||||
#define TSU6721_INT_OVP_OCP_OTP_DIS 0x0080
|
||||
#define TSU6721_INT_AV_CHANGE 0x0100
|
||||
#define TSU6721_INT_RES_ATTACH 0x0200
|
||||
#define TSU6721_INT_ADC_CHANGE 0x0400
|
||||
#define TSU6721_INT_STUCK_KEY 0x0800
|
||||
#define TSU6721_INT_STUCK_KEY_RCV 0x1000
|
||||
#define TSU6721_INT_CONNECT 0x2000
|
||||
#define TSU6721_INT_OTP_EN 0x4000
|
||||
#define TSU6721_INT_VBUS 0x8000
|
||||
|
||||
#define TSU6721_TYPE_NONE 0x000000
|
||||
#define TSU6721_TYPE_OTG 0x000080
|
||||
#define TSU6721_TYPE_DCP 0x000040
|
||||
#define TSU6721_TYPE_CDP 0x000020
|
||||
#define TSU6721_TYPE_CHG12 0x000010
|
||||
#define TSU6721_TYPE_UART 0x000008
|
||||
#define TSU6721_TYPE_USB_HOST 0x000004
|
||||
#define TSU6721_TYPE_AUDIO2 0x000002
|
||||
#define TSU6721_TYPE_AUDIO1 0x000001
|
||||
#define TSU6721_TYPE_AUDIO3 0x008000
|
||||
#define TSU6721_TYPE_JIG_UART_ON 0x000400
|
||||
#define TSU6721_TYPE_U200_CHG 0x400000
|
||||
#define TSU6721_TYPE_APPLE_CHG 0x200000
|
||||
#define TSU6721_TYPE_NON_STD_CHG 0x040000
|
||||
/* VBUS_DEBOUNCED might show up together with other type */
|
||||
#define TSU6721_TYPE_VBUS_DEBOUNCED 0x020000
|
||||
|
||||
/* Initialize TSU6721. */
|
||||
int tsu6721_init(void);
|
||||
|
||||
/* Read TSU6721 register. */
|
||||
uint8_t tsu6721_read(uint8_t reg);
|
||||
|
||||
/* Write TSU6721 register. */
|
||||
int tsu6721_write(uint8_t reg, uint8_t val);
|
||||
|
||||
/* Enable interrupts. */
|
||||
int tsu6721_enable_interrupts(void);
|
||||
|
||||
/* Disable all interrupts. */
|
||||
int tsu6721_disable_interrupts(void);
|
||||
|
||||
/* Set interrupt mask. */
|
||||
int tsu6721_set_interrupt_mask(uint16_t mask);
|
||||
|
||||
/* Get and clear current interrupt status. Return value is a combination of
|
||||
* TSU6721_INT_* */
|
||||
int tsu6721_get_interrupts(void);
|
||||
|
||||
/* Get but keep interrupt status. Return value is a combination of
|
||||
* TSU6721_INT_* */
|
||||
int tsu6721_peek_interrupts(void);
|
||||
|
||||
/* Get attached device type. Return value is one or a combination of
|
||||
* TSU6721_TYPE_* */
|
||||
int tsu6721_get_device_type(void);
|
||||
|
||||
/* Control TSU6721 mux. */
|
||||
int tsu6721_mux(enum tsu6721_mux sel);
|
||||
|
||||
/* Set bits to enable pins in SW2 register */
|
||||
void tsu6721_set_pins(int mask);
|
||||
|
||||
/* Reset TSU6721. */
|
||||
void tsu6721_reset(void);
|
||||
|
||||
#endif /* __CROS_EC_TSU6721_H */
|
||||
@@ -1,257 +0,0 @@
|
||||
/* Copyright (c) 2012 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.
|
||||
*
|
||||
* TI TSU6721 USB port switch driver.
|
||||
*/
|
||||
|
||||
#include "console.h"
|
||||
#include "ec_commands.h"
|
||||
#include "hooks.h"
|
||||
#include "host_command.h"
|
||||
#include "i2c.h"
|
||||
#include "system.h"
|
||||
#include "timer.h"
|
||||
#include "tsu6721.h"
|
||||
#include "util.h"
|
||||
|
||||
/* Console output macros */
|
||||
#define CPUTS(outstr) cputs(CC_USBCHARGE, outstr)
|
||||
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
|
||||
|
||||
/* 8-bit I2C address */
|
||||
#define TSU6721_I2C_ADDR (0x25 << 1)
|
||||
|
||||
/* Delay values */
|
||||
#define TSU6721_SW_RESET_DELAY 15
|
||||
|
||||
/* Number of retries when reset fails */
|
||||
#define TSU6721_SW_RESET_RETRY 3
|
||||
|
||||
static int saved_interrupts;
|
||||
|
||||
uint8_t tsu6721_read(uint8_t reg)
|
||||
{
|
||||
int res;
|
||||
int val;
|
||||
|
||||
res = i2c_read8(I2C_PORT_MASTER, TSU6721_I2C_ADDR, reg, &val);
|
||||
if (res)
|
||||
return 0xee;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
int tsu6721_write(uint8_t reg, uint8_t val)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = i2c_write8(I2C_PORT_MASTER, TSU6721_I2C_ADDR, reg, val);
|
||||
if (res)
|
||||
CPRINTS("TSU6721 I2C write failed");
|
||||
return res;
|
||||
}
|
||||
|
||||
int tsu6721_enable_interrupts(void)
|
||||
{
|
||||
int ctrl = tsu6721_read(TSU6721_REG_CONTROL);
|
||||
return tsu6721_write(TSU6721_REG_CONTROL, ctrl & 0x1e);
|
||||
}
|
||||
|
||||
int tsu6721_disable_interrupts(void)
|
||||
{
|
||||
int ctrl = tsu6721_read(TSU6721_REG_CONTROL);
|
||||
int rv;
|
||||
|
||||
rv = tsu6721_write(TSU6721_REG_CONTROL, ctrl | 0x1);
|
||||
tsu6721_get_interrupts();
|
||||
return rv;
|
||||
}
|
||||
|
||||
int tsu6721_set_interrupt_mask(uint16_t mask)
|
||||
{
|
||||
return tsu6721_write(TSU6721_REG_INT_MASK1, (~mask) & 0xff) |
|
||||
tsu6721_write(TSU6721_REG_INT_MASK2, ((~mask) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
int tsu6721_get_interrupts(void)
|
||||
{
|
||||
int ret = tsu6721_peek_interrupts();
|
||||
saved_interrupts = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int tsu6721_peek_interrupts(void)
|
||||
{
|
||||
saved_interrupts |= (tsu6721_read(TSU6721_REG_INT2) << 8) |
|
||||
(tsu6721_read(TSU6721_REG_INT1));
|
||||
return saved_interrupts;
|
||||
}
|
||||
|
||||
int tsu6721_get_device_type(void)
|
||||
{
|
||||
return (tsu6721_read(TSU6721_REG_DEV_TYPE3) << 16) |
|
||||
(tsu6721_read(TSU6721_REG_DEV_TYPE2) << 8) |
|
||||
(tsu6721_read(TSU6721_REG_DEV_TYPE1));
|
||||
}
|
||||
|
||||
void tsu6721_reset(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < TSU6721_SW_RESET_RETRY; ++i) {
|
||||
if (i != 0) {
|
||||
CPRINTS("TSU6721 init failed. Retrying");
|
||||
msleep(500);
|
||||
}
|
||||
if (tsu6721_write(TSU6721_REG_RESET, 0x1))
|
||||
continue;
|
||||
/* TSU6721 reset takes ~10ms. Let's wait for 15ms to be safe. */
|
||||
msleep(TSU6721_SW_RESET_DELAY);
|
||||
if (tsu6721_init() == EC_SUCCESS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int tsu6721_mux(enum tsu6721_mux sel)
|
||||
{
|
||||
uint8_t id = tsu6721_read(TSU6721_REG_ADC);
|
||||
uint8_t vbus1 = tsu6721_read(TSU6721_REG_DEV_TYPE1) & 0x74;
|
||||
uint8_t vbus3 = tsu6721_read(TSU6721_REG_DEV_TYPE3) & 0x74;
|
||||
uint8_t ctrl = tsu6721_read(TSU6721_REG_CONTROL);
|
||||
|
||||
/*
|
||||
* silicon limitation: the chip stays in low power mode and cannot
|
||||
* activate manual mode if it is not detecting either a VBUS or
|
||||
* something known on the ID pin
|
||||
*/
|
||||
if (sel != TSU6721_MUX_AUTO && (id == 0x1f) && !vbus1 && !vbus3) {
|
||||
CPRINTS("TSU6721 cannot use manual mode: no VBUS or ID");
|
||||
return EC_ERROR_INVAL;
|
||||
}
|
||||
|
||||
if (sel == TSU6721_MUX_AUTO) {
|
||||
tsu6721_write(TSU6721_REG_CONTROL, ctrl | TSU6721_CTRL_AUTO);
|
||||
} else {
|
||||
tsu6721_write(TSU6721_REG_MANUAL1, sel);
|
||||
tsu6721_write(TSU6721_REG_CONTROL, ctrl & ~TSU6721_CTRL_AUTO);
|
||||
}
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
void tsu6721_set_pins(int mask)
|
||||
{
|
||||
tsu6721_write(TSU6721_REG_MANUAL2, mask);
|
||||
}
|
||||
|
||||
int tsu6721_init(void)
|
||||
{
|
||||
uint8_t settings;
|
||||
uint8_t dev_id = tsu6721_read(TSU6721_REG_DEV_ID);
|
||||
int res = 0;
|
||||
|
||||
if ((dev_id != 0x0a) && (dev_id != 0x12)) {
|
||||
CPRINTS("TSU6721 invalid device ID 0x%02x", dev_id);
|
||||
return EC_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/* set USB charger detection timeout to 600ms */
|
||||
settings = tsu6721_read(TSU6721_REG_TIMER);
|
||||
if (settings == 0xee)
|
||||
return EC_ERROR_UNKNOWN;
|
||||
settings = (settings & ~0x38);
|
||||
res |= tsu6721_write(TSU6721_REG_TIMER, settings);
|
||||
|
||||
res |= tsu6721_set_interrupt_mask(TSU6721_INT_ATTACH |
|
||||
TSU6721_INT_DETACH |
|
||||
TSU6721_INT_ADC_CHANGE |
|
||||
TSU6721_INT_VBUS);
|
||||
res |= tsu6721_enable_interrupts();
|
||||
|
||||
return res ? EC_ERROR_UNKNOWN : EC_SUCCESS;
|
||||
}
|
||||
/*
|
||||
* TODO(crosbug.com/p/23741): Using I2C early in the HOOK_INIT currently
|
||||
* triggers all sort of badness. Debug this before re-activating
|
||||
* initialization in HOOK_INIT.
|
||||
*/
|
||||
#if 0
|
||||
DECLARE_HOOK(HOOK_INIT, tsu6721_init, HOOK_PRIO_DEFAULT);
|
||||
#endif
|
||||
|
||||
static void tsu6721_dump(void)
|
||||
{
|
||||
int i;
|
||||
uint8_t id = tsu6721_read(TSU6721_REG_ADC);
|
||||
uint8_t ctrl = tsu6721_read(TSU6721_REG_CONTROL);
|
||||
|
||||
if (ctrl & TSU6721_CTRL_AUTO)
|
||||
ccprintf("Auto: %02x %02x %02x\n",
|
||||
tsu6721_read(TSU6721_REG_DEV_TYPE1),
|
||||
tsu6721_read(TSU6721_REG_DEV_TYPE2),
|
||||
tsu6721_read(TSU6721_REG_DEV_TYPE3));
|
||||
else
|
||||
ccprintf("Manual: %02x %02x\n",
|
||||
tsu6721_read(TSU6721_REG_MANUAL1),
|
||||
tsu6721_read(TSU6721_REG_MANUAL2));
|
||||
ccprintf("ID: 0x%02x\n", id);
|
||||
for (i = 1; i < 0x24; i++)
|
||||
ccprintf("%02x ", tsu6721_read(i));
|
||||
ccprintf("\n");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Console commands */
|
||||
#ifdef CONFIG_CMD_USBMUX
|
||||
static int command_usbmux(int argc, char **argv)
|
||||
{
|
||||
if (1 == argc) { /* dump all registers */
|
||||
tsu6721_dump();
|
||||
return EC_SUCCESS;
|
||||
} else if (2 == argc) {
|
||||
if (!strcasecmp(argv[1], "usb")) {
|
||||
tsu6721_mux(TSU6721_MUX_USB);
|
||||
} else if (!strcasecmp(argv[1], "uart1")) {
|
||||
tsu6721_mux(TSU6721_MUX_UART);
|
||||
} else if (!strcasecmp(argv[1], "uart2")) {
|
||||
tsu6721_mux(TSU6721_MUX_AUDIO);
|
||||
} else if (!strcasecmp(argv[1], "auto")) {
|
||||
tsu6721_mux(TSU6721_MUX_AUTO);
|
||||
} else { /* read one register */
|
||||
ccprintf("Invalid mux value: %s\n", argv[1]);
|
||||
return EC_ERROR_INVAL;
|
||||
}
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
return EC_ERROR_INVAL;
|
||||
}
|
||||
DECLARE_CONSOLE_COMMAND(usbmux, command_usbmux,
|
||||
"[usb|uart1|uart2|auto]",
|
||||
"TSU6721 USB mux control",
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Host commands */
|
||||
|
||||
static int usb_command_mux(struct host_cmd_handler_args *args)
|
||||
{
|
||||
const struct ec_params_usb_mux *p = args->params;
|
||||
|
||||
if (system_is_locked())
|
||||
return EC_RES_ACCESS_DENIED;
|
||||
|
||||
/* Safety check */
|
||||
if (p->mux != TSU6721_MUX_AUTO &&
|
||||
p->mux != TSU6721_MUX_USB &&
|
||||
p->mux != TSU6721_MUX_UART &&
|
||||
p->mux != TSU6721_MUX_AUDIO)
|
||||
return EC_RES_ERROR;
|
||||
|
||||
if (tsu6721_mux(p->mux))
|
||||
return EC_RES_ERROR;
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
DECLARE_HOST_COMMAND(EC_CMD_USB_MUX, usb_command_mux, EC_VER_MASK(0));
|
||||
@@ -2011,12 +2011,6 @@
|
||||
/******************************************************************************/
|
||||
/* USB port switch */
|
||||
|
||||
/* 8-bit USB type-C switch I2C addresses */
|
||||
#undef CONFIG_USB_SWITCH_I2C_ADDRS
|
||||
|
||||
/* Support the TSU6721 I2C smart switch */
|
||||
#undef CONFIG_USB_SWITCH_TSU6721
|
||||
|
||||
/* Support the Pericom PI3USB9281 I2C USB switch */
|
||||
#undef CONFIG_USB_SWITCH_PI3USB9281
|
||||
|
||||
|
||||
Reference in New Issue
Block a user