Texas Instruments | TPS65987D and TPS65988 User Alternate Modes (Rev. A) | Application notes | Texas Instruments TPS65987D and TPS65988 User Alternate Modes (Rev. A) Application notes

Texas Instruments TPS65987D and TPS65988 User Alternate Modes (Rev. A) Application notes
Application Report
SLVAE16A – July 2018 – Revised April 2019
TPS65987D and TPS65988 User Alternate Modes
ABSTRACT
The TPS65987D(DX) and TPS65988(DX) is a fully-integrated USB power delivery (PD) management
device providing cable plug and orientation detection for USB Type-C and PD plug or receptacle. Each
Type-C port that is controlled by the device is functionally identical and supports the full range of the USB
Type-C and PD standards. The device supports multiple alternate modes which include DisplayPort, TBT
and User alternate mode and so forth. This document describes the procedure for enabling and
configuring a user alternate mode using the software tools and an optional host controller.
1
2
3
4
5
Contents
Introduction ...................................................................................................................
Configuration Registers ....................................................................................................
Basic Configuration .........................................................................................................
Advanced Configuration ....................................................................................................
Advanced Configurations with EC ........................................................................................
1
2
2
4
9
List of Figures
............................................................. 3
.............................................................. 3
Advanced Configuration - User Alternate Mode Configuration ....................................................... 5
Advanced Configuration - App Configuration Register ................................................................ 6
Advanced Configuration - Configuration Data Sets .................................................................... 6
Advanced Configuration - Virtual Device Settings ...................................................................... 7
Advanced Configuration - Virtual Device Settings ...................................................................... 8
Advanced Configuration with EC - User Alternate Mode Register .................................................. 10
Advanced Configuration with EC - Interrupt Mask Register ......................................................... 11
Advanced Configuration with EC - User Alternate Mode Register .................................................. 16
Advanced Configuration with EC - Interrupt Mask Register ......................................................... 17
1
Basic Configuration - User Alternate Mode Configuration
2
Basic Configuration - User Altenate Mode Configuration
3
4
5
6
7
8
9
10
11
List of Tables
Trademarks
All trademarks are the property of their respective owners.
1
Introduction
The user alternate mode allows users to configure a custom SVID with up to four independently
configurable mode numbers. When enabled, the device adds this custom SVID to the list of supported
SVIDs, and is shared with the port partner in the acknowledgment to the ‘Discover SVIDs’ command. The
DFP can then command the port partner to enter a specified mode of operation, and exchange proprietary
messages after entering the custom mode.
The user alternate mode can be used either with or without an external microcontroller. Without an
external microcontroller, the capabilities of the user alternate mode are limited to entering the mode,
optionally sending a predefined unstructured VDM upon mode entry, and optionally reconfiguring the
device registers and executing up to two host interface commands.
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
1
Configuration Registers
www.ti.com
The ability to send a predefined unstructured VDM upon mode entry is generally used to advertise an
identity. For instance, vendors can define a custom alternate mode used to communicate between
supported power supplies and devices. A power supply that does not contain an external microcontroller
could configure the device to automatically send an unstructured VDM, advertising information about the
power supply such as the model number, revision, serial number, and other information.
The ability to reconfigure the device on mode entry allows modification of any of the configuration registers
of the host interface without an external microcontroller. This ability can be used, for instance, to modify
the power sourcing and sinking capabilities of the PD port when recognized and supported devices are
attached. After reconfiguration of host interface registers, up to two host interface commands can be
executed. These commands can be used to drive a GPIO, or force a renegotiation of the power contract,
or execute a data/power role swap.
The primary limitation of the user alternate mode, when used without an external microcontroller, is its lack
of decision-making capability. The user alternate mode can be configured to send an arbitrary message or
to change the capabilities of the device, but this is a static configuration that is based only on mode entry
and exit. With the addition of an external microcontroller, the capabilities of the user alternate mode can
be greatly extended.
2
Configuration Registers
The user alternate mode is configured using the ‘User Alternate Mode (0x4A)’ configuration register. If the
user is enabling the User Alternate Mode to reconfigure the behavior of the device or to issue host
interface commands upon mode entry, then these capabilities are set in the ‘App Configuration Register
(0x6C)’.
‘User VID Status (0x57)’ register provides status information of the user alternate mode. This can be used
by an external microcontroller for decision making at runtime.
The device stores the last received attention and non-attention VDM in ‘Rx User VID Attention VDM
(0x60)’ and ‘Rx User VID Other VDM (0x61)’ registers respectively. These two registers are dedicated to
the user alternate mode and are not overwritten by other alternate mode messages such as DisplayPort or
TBT, which may be running concurrently. These registers may be used by an external microcontroller in
order to extend the capabilities of the user alternate mode.
The interrupt registers (0x14 - 0x17) may be configured to generate an interrupt to the external
microcontroller, whenever a new attention or non-attention VDM is received on the user SVID channel.
Refer to SLVUBH2 for more details on the register definitions.
3
Basic Configuration
The basic configuration of the user alternate mode is handled in the ‘User Alternate Mode (0x4A)’
configuration register. The example in this section configures the device to support a structured CustomVID ‘0xFEDC’ with four alternate modes. All four alternate modes are enabled and their mode values are
0x1F1F1F1F, 0x2F2F2F2F, 0x3F3F3F3F and 0x4F4F4F4F. Auto-Entry is enabled for Mode-1 and Mode4, and Mode-4 is additionally configured to send a predefined unstructured message upon mode entry
2
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Basic Configuration
www.ti.com
Figure 1. Basic Configuration - User Alternate Mode Configuration
Figure 2. Basic Configuration - User Altenate Mode Configuration
When this port is connected to a PD partner that supports all these modes, the port negotiate the alternate
mode contract, and the PD message exchange between the ports will be as below:
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
3
Advanced Configuration
www.ti.com
1. The port-partner will share the information about all the SVIDs that it supports in the acknowledgment
to the device’s ‘Discover SVIDs’ command
2. The port partner will share the information about all the modes that it supports for custom SVID
‘0xFEDC’ in the acknowledgment to the device’s ‘Discover Modes’ command. The mode numbers
returned by the UFP correspond to the ‘Mode Value’ field of the configuration register.
3. The device automatically enters Mode-1 and Mode-4, and sends a predefined unstructured message
on entering Mode-4 as per the above configuration.
4. Mode-2 and Mode-3 were not marked for auto-entry. Hence the device doesn’t automatically enter
these modes. The host can explicitly command the device to enter these modes using ‘AMEn’
command
4
Advanced Configuration
In addition to advertising and automatically entering the user alternate modes, the device can be
configured to load configuration sets and issue up to two host interface commands on mode entry and
exit. The loading of configuration sets is enabled by ‘User VID Mode Load App Config Data’ flag of the
corresponding ‘User Alternate Mode #N Settings’ in the configuration register 0x4A. In this example, the
basic configuration set of the previous section is slightly modified as below to load an application
configuration on Mode-2 entry:
4
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Advanced Configuration
www.ti.com
Figure 3. Advanced Configuration - User Alternate Mode Configuration
The configuration set that is to be loaded and the optional host interface commands to be executed (after
the configuration set is loaded) are specified in the App Configuration Register (0x6C). This configuration
register has three sections, namely ‘App Config GPIO Group 1 Settings’, ‘App Config GPIO Group 2
Settings’ and ‘App Config GPIO Group 3 Settings’. These three sections allow the user to add
configuration sets (to be loaded on the entry or exit) for the first three user alternate modes respectively.
The fourth user alternate mode does not support configuration set loading. Since Mode-2 is configured to
load an application configuration in this example, the settings in ‘App Config GPIO Group 2 Settings’ shall
be configured. The example in this section configures the device to load ‘Virtual Device 1 (0x1)’ settings
on mode entry, and ‘Virtual Device 2 (0x2)’ settings on mode exit. The device is also configured to
execute ‘GPsh’ and ‘SSrC’ command after the settings are loaded. ‘GPsh’ is executed on mode entry only,
and ‘SSrC’ is executed on mode entry and exit.
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
5
Advanced Configuration
www.ti.com
Figure 4. Advanced Configuration - App Configuration Register
In this configuration example, ‘App Config Mask, GPIO Low Transition or User AM Exit’ and ‘App Config
Mask, GPIO High Transition or User AM Enter’ is mapped to virtual identifiers 0x2 and 0x1 respectively.
These identifiers are determined from the ‘(Virtual) Pin Strap Setting’ field associated with each
‘Configuration Data Sets’ on the ‘General Settings’ tab.
Figure 5. Advanced Configuration - Configuration Data Sets
Configuration settings tab for ‘Virtual Device 1 (0x1)’ and ‘Virtual Device 2 (0x2)’ shows that they specify
settings for the CMD2 Data Register and Transmit Source Capabilities Register (0x32). Registers may be
added to or removed from this set by selecting the ‘Adjust Registers’ button that appears above the
register list in the left pane.
6
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Advanced Configuration
www.ti.com
Figure 6. Advanced Configuration - Virtual Device Settings
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
7
Advanced Configuration
www.ti.com
Figure 7. Advanced Configuration - Virtual Device Settings
Comparison of the Transmit Source Capabilities registers as specified in ‘Virtual Device 1’ and ‘Virtual
Device 2’ shows that upon entry into the user alternate Mode-2, the Transmit Source Capabilities register
will be populated with two source PDOs (fixed 5 V and variable 5 V — 20), and upon exit, the Transmit
Source Capabilities register will be populated with one source PDO (fixed 5 V). It can also be verified that
the initialization parameters for this register, specified in the ‘Common Settings’ tab match those of ‘Virtual
Device 2’ since the system is always initialized in a state where no alternate modes have been entered.
When this port is connected to a PD partner that supports all these modes, the ports negotiate the
alternate mode contract, and the PD message exchange between the ports will be as below:
1. The port-partner will share the information about all the SVIDs that it supports in the acknowledgment
to the device’s ‘Discover SVIDs’ command
2. The port partner will share the information about all the modes that it supports for this custom SVID
‘0xFEDC’ in the acknowledgment to the device’s ‘Discover Modes’ command. The mode numbers
returned by the UFP correspond to the ‘Mode Value’ field of the configuration register.
3. The device automatically enters Mode-1, Mode-2 and Mode-4. The device sends the ‘Source
Capabilities’ on entering Mode-2 (thereby renegotiate the PD contract) and sends a predefined
unstructured message on entering Mode-4 as per the above configuration.
8
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Advanced Configurations with EC
www.ti.com
4. The device does not automatically enter Mode-3 as this mode was not marked for auto-entry. The host
application can explicitly command the device to enter this mode using ‘AMEn’ command.
The preceding section explains the method for reconfiguring the host interface register settings
automatically upon entry into or exit from user alternate modes. In the example presented, the Transmit
Source Capabilities register was modified upon entry into and exit from user alternate Mode-2. Overwriting
the Transmit Source Capabilities register does not, however, force a retransmission of source capabilities.
This is accomplished by issuing the host interface command ‘SSrC’. As many as one Host Interface
Command and one Host Interface Task may be executed upon user alternate mode entry and exit. These
may be individually specified for entry and exit. For instance, a mode could issue the ‘SWSr’ (SWap to
Source) task upon entering a given mode but issue the ‘SWSk’ (SWap to Sink) task upon exiting the same
mode.
5
Advanced Configurations with EC
The user alternate mode capabilities and example configurations presented in the previous sections of this
document are static configurations based on mode entry and/or exit. The capabilities of the user alternate
mode can be greatly expanded with the addition of an external microcontroller, and the subsequent
sections present few simple use-cases that can be implemented using the user alternate modes.
5.1
Example 1
This example defines a Custom-VID ‘0x0055’ which supports two alternate modes with their mode values
as 0x1 and 0x2 respectively. The port partner is assumed to support this custom VID and its modes.
1. Using Mode-1, Port-A commands Port-B to drive a GPIO(s) on receiving an external trigger. The
example uses unstructured VDM for exchanging messages between the port partners, and the
message construct can be entirely defined by the vendors. This simple use-case is particularly
applicable to applications such as laptop docking stations, where a push button event can be used to
send status information from one device to another.
2. Using Mode-2, Port-A queries the status information of Port-B. This simple example demonstrates the
ability of the user alternate modes to exchange proprietary information and build complex use-cases
around it, for instance, to modify the power sinking capabilities of a laptop depending on its battery
charging properties when connected to a recognized and supported PD adapter.
Both these mode examples use an unstructured VDM to exchange proprietary information with their port
partner. Per PD specification, Bit-14:0 of an ‘Unstructured VDM Header’ is available for vendor’s use, and
the content of this field can be defined by the vendors.
This example defines Bit-14:0 of the unstructured VDM header as below:
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
9
Advanced Configurations with EC
www.ti.com
/*!
* \brief UVDM Header Structure
*/
typedef struct __attribute__((packed))
{
uint32_t
cmdtype
: 2;
uint32_t
mode
: 3;
uint32_t
reserved
: 3;
uint32_t
command
: 4;
uint32_t
totalvdos
: 3;
uint32_t
vdmtype
: 1;
uint32_t
svid
: 16;
}s_TPS_uvdmHeader;
The example in this section configures the device to support a Custom-VID ‘0x55’ with two alternate
modes. The two alternate modes are enabled and their mode values are 0x1 and 0x2. Auto-Entry is
enabled for both the modes.
Figure 8. Advanced Configuration with EC - User Alternate Mode Register
The device is also configured to generate below events and notify the host on mode entry/exit and the
reception of the vendor defined message. The host application shall read and process the content of ‘Rx
User VID Attention VDM (0x60)’ and ‘Rx User VID Other VDM (0x61)’ registers depending on the
generated event.
10
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Advanced Configurations with EC
www.ti.com
Figure 9. Advanced Configuration with EC - Interrupt Mask Register
When this port is connected to a PD partner that supports all these modes, the ports negotiate the
alternate mode contract, and the PD message exchange between the ports will be as below:
1. The port-partner will share the information about all the SVIDs that it supports in the acknowledgment
to the device’s ‘Discover SVIDs’ command.
2. The port partner will share the information about all the modes that it supports for this custom SVID
‘0x0055’ in the acknowledgment to the device’s ‘Discover Modes’ command, and the device
automatically enters Mode-1 and Mode-2. The mode numbers returned by the UFP correspond to the
‘Mode Value’ field of the configuration register.
The device generates an interrupt on mode entry/exit and on receiving user defined attention/nonattention message – The host application shall read ‘User VID Status (0x57)’, ‘Rx User VID
Attention VDM (0x60)’ and ‘Rx User VID Other VDM (0x61)’ registers depending on the generated
events and process the content.
The below example code demonstrates how the events shall be used for the host application:
/*
* I2Cx_IRQ Handler
*/
static int32_t ProcessEvent()
{
s_TPS_intevent *pSetEvent
s_TPS_intevent *pClrEvent
uint8_t
= NULL;
= NULL;
outdata[MAX_BUF_BSIZE] = {0};
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
11
Advanced Configurations with EC
www.ti.com
uint8_t
indata[MAX_BUF_BSIZE]
int32_t
retVal = -1;
= {0};
retVal = ReadReg(REG_ADDR_INTEVENT1, REG_LEN_INTEVENT1, &outdata[0]);
ASSERT_ON_ERROR(retVal);
pSetEvent = (s_TPS_intevent*)((uint8_t*)&outdata[1]);
pClrEvent = (s_TPS_intevent *)&indata[0];
if(0 != pSetEvent->uservidaltmodeentered)
{
SignalEvent(APP_EVENT_USER_AM_ENTERED);
pClrEvent->uservidaltmodeentered = 1;
}
if(0 != pSetEvent->uservidaltmodeothervdm)
{
SignalEvent(APP_EVENT_UVDM_RCVD);
pClrEvent->uservidaltmodeothervdm = 1;
}
if(0 != pSetEvent->uservidaltmodeattnvdm)
{
SignalEvent(APP_EVENT_ATTN_RCVD);
pClrEvent->uservidaltmodeattnvdm = 1;
}
if(0 != pSetEvent->uservidaltmodeexited)
{
SignalEvent(APP_EVENT_USER_AM_EXITED);
pClrEvent->uservidaltmodeexited = 1;
}
retVal = WriteReg(REG_ADDR_INTCLEAR1, REG_LEN_INTCLEAR1, &indata[0]);
RETURN_ON_ERROR(retVal);
return retVal;
}
/*
* Called by application on receiving 'uservidaltmodeentered' event
* from the device
*/
static int32_t UserAMEntry()
{
s_TPS_uservidstatus *p_uservidstatus
= NULL;
uint8_t outdata[MAX_BUF_BSIZE] = {0};
int32_t retVal = -1;
retVal = ReadReg(REG_ADDR_USERVIDSTATUS, REG_LEN_USERVIDSTATUS,&outdata[0]);
RETURN_ON_ERROR(retVal);
p_uservidstatus = (s_TPS_uservidstatus *)&outdata[1];
/*!
* Configure application according to the entered mode
*/
if(ACTIVE == p_uservidstatus->usermode1status)
{
/*
* Application specific configuration #1
*/
}
if(ACTIVE == p_uservidstatus->usermode2status)
{
12
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Advanced Configurations with EC
www.ti.com
/*
* Application specific configuration #2
*/
}
return 0;
}
/*
* Called by application on receiving 'uservidaltmodeattnvdm' event
* from the device
*/
static int32_t ProcessRxVDMAttnEvents()
{
s_TPS_uservidstatus
*p_uservidstatus
= NULL;
s_TPS_uvdmHeader
*p_uvdmheader
= NULL;
s_TPS_rxattention
*p_rxattention
= NULL;
uint8_t
outdata[MAX_BUF_BSIZE] = {0} ;
uint32_t
uint32_t
rxattentiondo1
rxattentiondo2
int32_t
retVal
= 0;
= 0;
= -1;
/*
* Read the contents of received VDM packet
*/
retVal = ReadReg(REG_ADDR_RXUSERVIDATTENTIONVDM,\
REG_LEN_RXUSERVIDATTENTIONVDM, &outdata[0]);
RETURN_ON_ERROR(retVal);
/* outdata[0] has size */
p_rxattention = (s_TPS_rxattention *)(&outdata[1]);
rxattentiondo1 = p_rxattention->rxattentiondo1;
rxattentiondo2 = p_rxattention->rxattentiondo2;
/*
* User defined UVDM Header - See Table 6-24 of the PD specification
*/
p_uvdmheader = (s_TPS_uvdmHeader *)rxattentiondo1;
/*
* Application specific implementation
*/
return retVal;
}
/*
* Called by application on receiving 'uservidaltmodeothervdm' event
* from the device
*/
static int32_t ProcessRxVDMEvents()
{
s_TPS_uservidstatus
*p_uservidstatus
= NULL;
s_TPS_uvdmHeader
*p_uvdmheader
= NULL;
s_TPS_rxvdm
*p_rxvdm
= NULL;
uint8_t
outdata[MAX_BUF_BSIZE] = {0} ;
uint32_t
uint32_t
rxvdmdo1
rxvdmdo2
int32_t
retVal
= 0;
= 0;
= -1;
/*!
* Read the contents of received VDM packet
*/
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
13
Advanced Configurations with EC
www.ti.com
retVal = ReadReg(REG_ADDR_RXUSERVIDOTHERVDM,\
REG_LEN_RXUSERVIDOTHERVDM, &outdata[0]);
RETURN_ON_ERROR(retVal);
/* outdata[0] has size */
p_rxvdm = (s_TPS_rxvdm *)(&outdata[1]);
rxvdmdo1 = p_rxvdm->rxvdmdo1;
rxvdmdo2 = p_rxvdm->rxvdmdo2;
/*
* User defined UVDM Header - See Table 6-24 of the PD specification
*/
p_uvdmheader = (s_TPS_uvdmHeader *)rxvdmdo1;
/*
* Application specific implementation
*/
return retVal;
}
/*
* Example code showning how the device could be commanded (using VDMs)
* to send a unstructured message to the far-end.
* Application Specific Example - Switch-1 triggers Port-A to send
* unstructured VDM command to Port-B for toggling LED1
*/
static int32_t Switch1Event(void)
{
s_TPS_uvdmHeader
*p_uvdmheader = NULL;
s_TPS_vdms vdmsInData = {0};
uint8_t
outdata[MAX_BUF_BSIZE] = {0} ;
uint32_t
int32_t
uvdmheader =
retVal = -1;
0;
UART_PRINT(" SW1 - Command the far-end to drive a GPIO\n\r");
uvdmheader = vdmsInData.vdmheader;
p_uvdmheader = (s_TPS_uvdmHeader *)&uvdmheader;
p_uvdmheader->cmdtype
p_uvdmheader->mode
p_uvdmheader->command
p_uvdmheader->totalvdos
p_uvdmheader->vdmtype
p_uvdmheader->svid
=
=
=
=
=
=
REQ;
Mode_1;
TOGGLE_LED;
1;
UNSTRUCTURED_VDM;
USER_SVID;
vdmsInData.numdos
vdmsInData.soptarget
vdmsInData.vdmheader
vdmsInData.vdo2
=
=
=
=
2;
/* (userheader.totalvdos) + 1 */
SOP;
uvdmheader;
LED1;
retVal = ExecCmd(VDMs, sizeof(s_TPS_vdms), (int8_t *)&vdmsInData,\
TASK_RETURN_STATUS_LEN, &outdata[0]);
RETURN_ON_ERROR(retVal);
if(0 != outdata[1])
{
UART_PRINT("[%d]: Operation Failed.!\n", outdata[1]);
return -1;
}
return 0;
}
/*
14
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Advanced Configurations with EC
www.ti.com
* Example code showning how Port-B shall process the received
* unstructured VDM
* Application Specific Example - Port-B received the 'Toggle-LED' command
* from Port-A, and below snippet processes it
*/
static int32_t Mode1Events() /* Like 'ProcessRxVDMEvents' above */
{
s_TPS_status
*p_status_reg
= NULL;
s_TPS_rxvdm
*p_rxvdm_reg
= NULL;
s_TPS_uvdmHeader
*p_uvdmheader
= NULL;
s_TPS_vdms
vdmsInData
= {0};
uint8_t
outdata[MAX_BUF_BSIZE] = {0} ;
uint32_t
int32_t
int32_t
uvdmheader
retVal
dataRole
= 0;
= -1;
= -1;
UART_PRINT("Received UDVM Mode-1 Event - Process it\n\r");
retVal = ReadReg(REG_ADDR_STATUS, REG_LEN_STATUS, &outdata[0]);
p_status_reg = (s_TPS_status *)(&outdata[1]);
dataRole = p_status_reg->datarole ;
/* DFP sent the command, and UFP is processing it here in this example */
if(UFP_DATA_ROLE == dataRole)
{
retVal = ReadReg(REG_ADDR_RXVDM, REG_LEN_RXVDM, &outdata[0]);
p_rxvdm_reg = (s_TPS_rxvdm *)(&outdata[1]);
/*
* 'rxvdmdo2' was populated w/ LED1 in function 'Switch1Event' above
* 'rxvdmdo1' contains VDM header - Application can interpret as
* type 's_TPS_uvdmHeader' and ensure the received command is
* TOGGLE_LED'
*/
if(LED1 == p_rxvdm_reg->rxvdmdo2)
{
GPIO_IF_LedToggle(LED1);
}
/*
* ACK the incoming message.!
*/
p_uvdmheader
= (s_TPS_uvdmHeader *)&uvdmheader;
p_uvdmheader->cmdtype
= ACK;
p_uvdmheader->mode
= Mode_1;
p_uvdmheader->command
= TOGGLE_LED;
p_uvdmheader->totalvdos = 1;
p_uvdmheader->vdmtype
= UNSTRUCTURED_VDM;
p_uvdmheader->svid
= USER_SVID;
vdmsInData.numdos
= 1;
vdmsInData.soptarget
= SOP;
vdmsInData.vdmheader
= (int32_t)uvdmheader;
retVal = ExecCmd(VDMs, sizeof(s_TPS_vdms), (int8_t *)&vdmsInData,\
TASK_RETURN_STATUS_LEN, &outdata[0]);
RETURN_ON_ERROR(retVal);
}
return 0;
}
The PD message exchanges between Port-A and Port-B when the above example code is executed on
the host application(s) is as below:
1. Port-A sends 'TOGGLE_LED' command to Port-B with 'Object 1' as 'LED1', and Port-B acknowledges
the request
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
15
Advanced Configurations with EC
www.ti.com
2. Port-A sends 'READ_REG' command to Port-B with 'Object 1' as 'REGISTER-NUMBER', and Port-B
responds with its PD firmware version '0xF7070001
5.2
Example 2
The previous generation PD controllers from TI ( TPS65981, TPS65982 and so forth) had support for
PDIO Alternate Mode which allows users to transmit or receive up to four unique digital signals between
two systems connected through USB Type-C. The support for this alternate mode is removed from this
variant of the device as vendors have an option to implement PDIO-like functionality using user alternate
mode as detailed in this section.
The device will however need to support TI’s PDIO mode to inter-operate with the earlier generation
devices supporting this feature. This example lists the steps for implementing this feature using user
alternate modes. This mode uses both structured and unstructured VDM to exchange proprietary
information with their port partner.
The example in this section configures the device to support TI SVID ‘0x0451' with one alternate modes.
The alternate modes is enabled and its mode values is 0x1/TI-PDIO. Auto-Entry is enabled for this mode.
Figure 10. Advanced Configuration with EC - User Alternate Mode Register
The device is also configured to generate below events and notify the host on mode entry/exit and the
reception of the vendor defined message. The host application shall read and process the content of ‘Rx
User VID Attention VDM (0x60)’ and ‘Rx User VID Other VDM (0x61)’ registers depending on the
generated event.
16
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Advanced Configurations with EC
www.ti.com
Figure 11. Advanced Configuration with EC - Interrupt Mask Register
When this port is connected to a PD partner that supports legacy TI-PDIO mode, the ports negotiate the
alternate mode contract, and the PD message exchange between the ports will be as below:
1. The port-partner will share the information about all the SVIDs that it supports in the acknowledgment
to the device’s ‘Discover SVIDs’ command
2. The port partner will share the information about all the modes that it supports TI-SVID ‘0x0451’ in the
acknowledgment to the device’s ‘Discover Modes’ command, and the device automatically enters TIPDIO mode if its supported by the port partner
The device generates an interrupt on mode entry/exit and on receiving user defined attention/non-attention
message – The host application shall read ‘User VID Status (0x57)’, ‘Rx User VID Attention VDM (0x60)’
and ‘Rx User VID Other VDM (0x61)’ registers depending on the generated events and process the
content.
The below example code demonstrates how the events shall be used for the host application:
/*
* I2Cx_IRQ Handler
*/
static int32_t ProcessEvent()
{
s_TPS_intevent *pSetEvent
s_TPS_intevent *pClrEvent
= NULL;
= NULL;
uint8_t
uint8_t
outdata[MAX_BUF_BSIZE] = {0};
indata[MAX_BUF_BSIZE] = {0};
int32_t
retVal = -1;
retVal = ReadReg(REG_ADDR_INTEVENT1, REG_LEN_INTEVENT1, &outdata[0]);
ASSERT_ON_ERROR(retVal);
pSetEvent = (s_TPS_intevent*)((uint8_t*)&outdata[1]);
pClrEvent = (s_TPS_intevent *)&indata[0];
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
17
Advanced Configurations with EC
www.ti.com
if(0 != pSetEvent->uservidaltmodeentered)
{
SignalEvent(APP_EVENT_USER_AM_ENTERED);
pClrEvent->uservidaltmodeentered = 1;
}
if(0 != pSetEvent->uservidaltmodeothervdm)
{
SignalEvent(APP_EVENT_UVDM_RCVD);
pClrEvent->uservidaltmodeothervdm = 1;
}
if(0 != pSetEvent->uservidaltmodeattnvdm)
{
SignalEvent(APP_EVENT_ATTN_RCVD);
pClrEvent->uservidaltmodeattnvdm = 1;
}
if(0 != pSetEvent->uservidaltmodeexited)
{
SignalEvent(APP_EVENT_USER_AM_EXITED);
pClrEvent->uservidaltmodeexited = 1;
}
retVal = WriteReg(REG_ADDR_INTCLEAR1, REG_LEN_INTCLEAR1, &indata[0]);
RETURN_ON_ERROR(retVal);
return retVal;
}
/*
* Called by application on receiving 'uservidaltmodeentered' event
* from the device
*/
static int32_t UserAMEntry()
{
s_TPS_uservidstatus *p_uservidstatus
= NULL;
uint8_t outdata[MAX_BUF_BSIZE] = {0};
int32_t retVal = -1;
retVal = ReadReg(REG_ADDR_USERVIDSTATUS,REG_LEN_USERVIDSTATUS,&outdata[0]);
RETURN_ON_ERROR(retVal);
p_uservidstatus = (s_TPS_uservidstatus *)&outdata[1];
/*!
* Check if User Alternate Mode 1 is entered.
* Send PDIO Status to far-end on entering the mode
* if the port's data-role is DFP - Not shown here.!
*/
if(ACTIVE == p_uservidstatus->usermode1status)
{
UART_PRINT("User Alternate Mode - Mode 1 entered.\n\r");
retVal = SendPDIOStatus();
RETURN_ON_ERROR(retVal);
}
return 0;
}
/*
* Sends PDIO status to the far-end/UFP on entering the mode
*/
static int32_t SendPDIOStatus()
{
18
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Advanced Configurations with EC
www.ti.com
s_TPS_vdmheadersstruct
s_TPS_vdms
*p_vdmheader
vdmsInData
uint8_t
outdata[MAX_BUF_BSIZE]
uint32_t
int32_t
vdmheader
=
retVal = -1;
= NULL;
= {0};
= {0};
0;
UART_PRINT("Send PDIO Status\n\r");
vdmheader = vdmsInData.vdmheader;
p_vdmheader = (s_TPS_vdmheadersstruct *)&vdmheader;
p_vdmheader->command = SVDM_SendPDIO_Status;
p_vdmheader->commandtype = CMD_TYPE_REQ;
p_vdmheader->objpos = 0x1;
p_vdmheader->structuredvdmversion = 0x1;
p_vdmheader->vdmtype = 0x1;
p_vdmheader->svid = TI_SVID;
//0x0451
//0x14
//0x0
vdmsInData.numdos
= 2;
vdmsInData.vdmheader
= vdmheader;
/*
* PDIO_IN<x> is 1 for enable, and 0 for disable
* #define PDIO_IN_EVENTS ((PDIO_IN3 << 3) | (PDIO_IN2 << 2) |
*
(PDIO_IN1 << 1) |(PDIO_IN0 << 0))
*/
vdmsInData.vdo2
= ((PDIO_IN_EVENTS) << 16);
retVal = ExecCmd(VDMs, sizeof(s_TPS_vdms), (int8_t *)&vdmsInData,\
TASK_RETURN_STATUS_LEN, (int8_t *)&outdata[0]);
RETURN_ON_ERROR(retVal);
return retVal;
}
/*
* SwitchEvtHandler, ProcessPDIOInEvents and SendTxPDIOStatus demonstrate
* how PDIO_IN<x> status shall be sent to the far-end as DFP
*/
static int32_t SwitchEvtHandler(void)
{
s_AppContext *const pCtx = &gAppCtx;
e_BoardSwitch
switchstate = 0;
switchstate = GPIO_IF_SwitchStatus();
pCtx->switchstate = switchstate;
GPIO_IF_SwitchIntDisable();
ProcessPDIOInEvents();
GPIO_IF_SwitchIntEnable();
return 0;
}
/**/
static int32_t ProcessPDIOInEvents()
{
s_AppContext *const pCtx = &gAppCtx;
int32_t retVal = -1;
if(SWITCH1 == (pCtx->switchstate & SWITCH1))
{
retVal = SendTxPDIOStatus(0x1);
RETURN_ON_ERROR(retVal);
}
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
19
Advanced Configurations with EC
www.ti.com
if(SWITCH2 == (pCtx->switchstate & SWITCH2))
{
retVal = SendTxPDIOStatus(0x2);
RETURN_ON_ERROR(retVal);
}
return retVal;
}
/**/
static int32_t SendTxPDIOStatus(uint8_t switchstate)
{
s_TPS_vdmheadersstruct *p_vdmheader
= NULL;
s_TPS_vdms
vdmsInData
= {0};
uint8_t
outdata[MAX_BUF_BSIZE]
uint32_t
int32_t
vdmheader
=
retVal = -1;
= {0};
0;
UART_PRINT("Send TxPDIO Status\n\r");
vdmheader = vdmsInData.vdmheader;
p_vdmheader = (s_TPS_vdmheadersstruct *)&vdmheader;
p_vdmheader->command = SVDM_SendPDIO_Status;
p_vdmheader->commandtype = CMD_TYPE_REQ;
p_vdmheader->objpos = 0x1;
p_vdmheader->structuredvdmversion = 0x1;
p_vdmheader->vdmtype = 0x1;
p_vdmheader->svid = TI_SVID;
//0x0451
//0x14
//0x0
vdmsInData.numdos
= 2;
vdmsInData.vdmheader
= vdmheader;
/*
* Send the PDIO_IN status to far-end.
* SW1 is PDIO_IN0/Bit0, SW2 is PDIO_IN1/Bit1 of vdo2
*/
vdmsInData.vdo2
= (((PDIO_IN_EVENTS) << 16) | switchstate);
retVal = ExecCmd(VDMs, sizeof(s_TPS_vdms), (int8_t *)&vdmsInData,\
TASK_RETURN_STATUS_LEN, (int8_t *)&outdata[0]);
RETURN_ON_ERROR(retVal);
return retVal;
}
/*
* Called by application on receiving 'uservidaltmodeattnvdm' event
* from the device.
* This fucntion processes the PDIO message sent by far-end/UFP
*/
static int32_t ProcessAttnEvents()
{
s_TPS_uservidstatus
*p_uservidstatus
= NULL;
s_TPS_vdmheadersstruct *p_vdmheader
= NULL;
s_TPS_rxattention
*p_rxattention
= NULL;
uint8_t
outdata[MAX_BUF_BSIZE] = {0} ;
uint32_t
uint32_t
rxattentiondo1
rxattentiondo2
int32_t
retVal
= 0;
= 0;
= -1;
/*!
* Read the contents of received VDM packet
20
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
Advanced Configurations with EC
www.ti.com
*/
retVal = ReadReg(REG_ADDR_RXUSERVIDATTENTIONVDM,
REG_LEN_RXUSERVIDATTENTIONVDM, &outdata[0]);
RETURN_ON_ERROR(retVal);
/* outdata[0] has length */
p_rxattention = (s_TPS_rxattention *)(&outdata[1]);
rxattentiondo1 = p_rxattention->rxattentiondo1;
rxattentiondo2 = p_rxattention->rxattentiondo2;
/*!
* Check whether the VDM Rx is for SVID of User Alternate Mode
* In this case, TI_SVID is used for User Alternate Mode
* Note : The SVID of User Alternate Mode may differ
*/
p_vdmheader = (s_TPS_vdmheadersstruct *)&rxattentiondo1;
if( (TI_SVID != p_vdmheader->svid) ||
(1 == p_rxattention->rxattentionnumvalid) )
{
UART_PRINT("\n\nProcess Attn - Error1.");
return 0 ;
}
/*!
* Check for which Mode is VDM Rx, depending on that,
* Call the function that will execute the events.
*/
retVal = ReadReg(REG_ADDR_USERVIDSTATUS,REG_LEN_USERVIDSTATUS,&outdata[0]);
RETURN_ON_ERROR(retVal);
p_uservidstatus = (s_TPS_uservidstatus *)&outdata[1];
if(ACTIVE == p_uservidstatus->usermode1status)
{
/*
* Toggling LED here, but application shall interpret rxattentiondo2,
* and take action per their requirement - Not shown here.!
* Bit-3:0 indicate which PDIO_IN was set by the far-end
*/
GPIO_IF_LedToggle(PDIO_OUT0);
SendRxPDIOStatus();
}
UNUSED(rxattentiondo2);
return retVal;
}
/* Send ACK to UFP's TI-SVID-Attention */
static int32_t SendRxPDIOStatus()
{
s_TPS_vdmheadersstruct *p_vdmheader
s_TPS_vdms
vdmsInData
uint8_t
outdata[MAX_BUF_BSIZE]
uint32_t
int32_t
vdmheader
=
retVal = -1;
= NULL;
= {0};
= {0};
0;
UART_PRINT("Send RxPDIO Status\n\r");
vdmheader = vdmsInData.vdmheader;
p_vdmheader = (s_TPS_vdmheadersstruct *)&vdmheader;
p_vdmheader->command = SVDM_RxPDIO_Status;
p_vdmheader->commandtype = CMD_TYPE_ACK;
p_vdmheader->objpos = 0x1;
p_vdmheader->structuredvdmversion = 0x1;
p_vdmheader->vdmtype = 0x1;
p_vdmheader->svid = TI_SVID;
//0x0451
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
//0x15
//0x1
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
21
Advanced Configurations with EC
vdmsInData.numdos
vdmsInData.vdmheader
www.ti.com
= 1;
= vdmheader;
retVal = ExecCmd(VDMs, sizeof(s_TPS_vdms), (int8_t *)&vdmsInData,\
TASK_RETURN_STATUS_LEN, (int8_t *)&outdata[0]);
RETURN_ON_ERROR(retVal);
return retVal;
}
The PD message exchanges between Port-A and Port-B when the above example code is executed on
the host application(s) is shown below. The logs snippets show the ports exchanging status messages
after entering TI-PDIO mode indicating which PDIO_IN are enabled on either sides. Port-A/DFP then
sends two 'REQ' with 'Object 1' as 0x30001/PDIO_IN0 and 0x30002/PDIO_IN1 to Port-B/UFP, and Port-B
acknowledges these message. Then, Port-B/UFP sends 'Attention' with 'Object 1' as 0x70001/PDIO_IN0,
and Port-A acknowledges this message.
The example code and log snippets presented in this section assume that the port enters a PD contract as
a DFP. If the port is UFP, the host application shall take care of sending 'Attention'/0x06 message (and
not 'SVID Specific Cmd'/0x14) to indicate the port-partner about its PDIO_IN status.
22
TPS65987D and TPS65988 User Alternate Modes
Copyright © 2018–2019, Texas Instruments Incorporated
SLVAE16A – July 2018 – Revised April 2019
Submit Documentation Feedback
IMPORTANT NOTICE AND DISCLAIMER
TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATASHEETS), DESIGN RESOURCES (INCLUDING REFERENCE
DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS”
AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD
PARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate
TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable
standards, and any other safety, security, or other requirements. These resources are subject to change without notice. TI grants you
permission to use these resources only for development of an application that uses the TI products described in the resource. Other
reproduction and display of these resources is prohibited. No license is granted to any other TI intellectual property right or to any third
party intellectual property right. TI disclaims responsibility for, and you will fully indemnify TI and its representatives against, any claims,
damages, costs, losses, and liabilities arising out of your use of these resources.
TI’s products are provided subject to TI’s Terms of Sale (www.ti.com/legal/termsofsale.html) or other applicable terms available either on
ti.com or provided in conjunction with such TI products. TI’s provision of these resources does not expand or otherwise alter TI’s applicable
warranties or warranty disclaimers for TI products.
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2019, Texas Instruments Incorporated
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Related manuals

Download PDF

advertising