mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
cr50: connect to AP phy on reef when not in ccd
Cr50 needs to connect to the AP phy when not in ccd so cr50 can be updated and used as a gnubby. This change uses the strapping options to detect when it is on reef and modifies the ccd behavior to initialize usb on the AP phy when ccd is disabled. On gru the cr50 behavior is unchanged. In RDD this change removes the checks that the current_map is the correct one based on the detected debug state. rdd_init calls rdd_interrupt to set up the usb and ccd state correctly. Having that check prevents that initial rdd_interrupt from calling rdd_detached. Before rdd_detached just disabled usb and we knew during init it would already be disabled. Now we want to make sure it is called if a debug accessory is not attached to initialize usb on the AP PHY. BUG=chrome-os-partner:56098 BRANCH=none TEST=manual verify ccd still works on gru disconnect suzyq and reset reef. run lsusb on the AP and verify it shows cr50 as a device. connect suzyq and check that the AP no longer sees cr50. disconnect suzyq and verify the AP sees it again Change-Id: I3c1ccc54895835bce12302f3ea43fc2e751b4c97 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/372920 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
This commit is contained in:
@@ -532,14 +532,17 @@ static void detect_slave_config(void)
|
||||
* This must be a power on reset or maybe restart due to a software
|
||||
* update from a version not setting the register.
|
||||
*/
|
||||
if (!properties) {
|
||||
if (!properties || system_get_reset_flags() & RESET_FLAG_HARD) {
|
||||
/* Read DIOA1 strap pin */
|
||||
if (gpio_get_level(GPIO_STRAP0))
|
||||
/* Strap is pulled high -> Kevin SPI TPM option */
|
||||
properties |= BOARD_SLAVE_CONFIG_SPI;
|
||||
else
|
||||
else {
|
||||
/* Strap is low -> Reef I2C TPM option */
|
||||
properties |= BOARD_SLAVE_CONFIG_I2C;
|
||||
/* One PHY is connected to the AP */
|
||||
properties |= BOARD_USB_AP;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now save the properties value for future use.
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "gpio.h"
|
||||
#include "rdd.h"
|
||||
#include "registers.h"
|
||||
#include "system.h"
|
||||
#include "uartn.h"
|
||||
#include "usb_api.h"
|
||||
|
||||
@@ -123,6 +124,30 @@ void rdd_detached(void)
|
||||
ccd_set_mode(CCD_MODE_DISABLED);
|
||||
}
|
||||
|
||||
void ccd_phy_init(int enable_ccd)
|
||||
{
|
||||
uint32_t properties = system_get_board_properties();
|
||||
/*
|
||||
* For boards that have one phy connected to the AP and one to the
|
||||
* external port PHY0 is for the AP and PHY1 is for CCD.
|
||||
*/
|
||||
uint32_t which_phy = enable_ccd ? USB_SEL_PHY1 : USB_SEL_PHY0;
|
||||
|
||||
/*
|
||||
* TODO: if both PHYs are connected to the external port select the
|
||||
* PHY based on the detected polarity
|
||||
*/
|
||||
usb_select_phy(which_phy);
|
||||
|
||||
/*
|
||||
* If the board has the non-ccd phy connected to the AP initialize the
|
||||
* phy no matter what. Otherwise only initialized the phy if ccd is
|
||||
* enabled.
|
||||
*/
|
||||
if ((properties & BOARD_USB_AP) || enable_ccd)
|
||||
usb_init();
|
||||
}
|
||||
|
||||
static int command_ccd(int argc, char **argv)
|
||||
{
|
||||
int val;
|
||||
|
||||
@@ -33,14 +33,13 @@ int debug_cable_is_attached(void)
|
||||
|
||||
void rdd_interrupt(void)
|
||||
{
|
||||
int is_debug, current_map;
|
||||
int is_debug;
|
||||
|
||||
delay_sleep_by(1 * SECOND);
|
||||
|
||||
current_map = 0xffff & GREAD(RDD, PROG_DEBUG_STATE_MAP);
|
||||
is_debug = debug_cable_is_attached();
|
||||
|
||||
if (is_debug && (current_map == DETECT_DEBUG)) {
|
||||
if (is_debug) {
|
||||
disable_sleep(SLEEP_MASK_RDD);
|
||||
|
||||
CPRINTS("Debug Accessory connected");
|
||||
@@ -49,7 +48,7 @@ void rdd_interrupt(void)
|
||||
GWRITE(RDD, PROG_DEBUG_STATE_MAP, DETECT_DISCONNECT);
|
||||
|
||||
rdd_attached();
|
||||
} else if (!is_debug && (current_map == DETECT_DISCONNECT)) {
|
||||
} else if (!is_debug) {
|
||||
CPRINTS("Debug Accessory disconnected");
|
||||
|
||||
/* Detect when debug cable is connected */
|
||||
|
||||
@@ -28,14 +28,16 @@
|
||||
USB_SPI_CONFIG(ccd_usb_spi, USB_IFACE_SPI, USB_EP_SPI);
|
||||
#endif
|
||||
|
||||
static enum ccd_mode current_mode = CCD_MODE_DISABLED;
|
||||
static enum ccd_mode current_mode = CCD_MODE_COUNT;
|
||||
|
||||
void ccd_set_mode(enum ccd_mode new_mode)
|
||||
{
|
||||
if (new_mode == current_mode)
|
||||
return;
|
||||
|
||||
#ifndef CONFIG_USB_SELECT_PHY
|
||||
if (current_mode != CCD_MODE_DISABLED)
|
||||
#endif
|
||||
usb_release();
|
||||
|
||||
current_mode = new_mode;
|
||||
@@ -51,6 +53,10 @@ void ccd_set_mode(enum ccd_mode new_mode)
|
||||
usb_spi_enable(&ccd_usb_spi, new_mode == CCD_MODE_ENABLED);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_SELECT_PHY
|
||||
ccd_phy_init(new_mode != CCD_MODE_DISABLED);
|
||||
#else
|
||||
if (new_mode != CCD_MODE_DISABLED)
|
||||
usb_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ enum ccd_mode {
|
||||
* device over CCD.
|
||||
*/
|
||||
CCD_MODE_ENABLED,
|
||||
|
||||
CCD_MODE_COUNT,
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -33,4 +35,6 @@ enum ccd_mode {
|
||||
*/
|
||||
void ccd_set_mode(enum ccd_mode new_mode);
|
||||
|
||||
/* Initialize the PHY based on CCD state */
|
||||
void ccd_phy_init(int enable_ccd);
|
||||
#endif /* __CROS_EC_CASE_CLOSED_DEBUG_H */
|
||||
|
||||
@@ -465,6 +465,8 @@ int system_process_retry_counter(void);
|
||||
/* Board properties options */
|
||||
#define BOARD_SLAVE_CONFIG_SPI (1 << 0) /* Slave SPI interface */
|
||||
#define BOARD_SLAVE_CONFIG_I2C (1 << 1) /* Slave I2C interface */
|
||||
#define BOARD_USB_AP (1 << 2) /* One of the PHYs is */
|
||||
/* connected to the AP */
|
||||
/**
|
||||
* Get board properites
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user