2016年4月19日 星期二

USB Type-C Port Controller


USB Org defined the Port Controller and its architecture in Oct 2015. The Type-C
port Manager is moved out from PD controller.  The MCU or EC(embeded
controller) can be the Type-C port Manager, it can control many Type-C Port
Controllers by I2C at the same time.


The TCPM (Type-C Port Manger) is used to decide these Type-C PD port function
and behavior, The TCPC (Type-C Port Controller) is passive and is used for Type-C
logic and PD data transceiver. Many registers are defined in TCPC spec, the TCPM
can read /write these register to get status of Type-C port and control TCPC.


The following are how the TCPM and TCPC finish the Type-C connection and 
VBUS 5V to HighVoltage transition.  

DRP Type-C port initialize and CC connection.



1. Before the connection. TCPC set TCPC to be DRP.
Write ROLE_CONTROLROLE_CONTROL.DRP = 1b ;TCPM set TCPC to be DRP. 
ROLE_CONTROL.CC2=01b or 10b ;set initial status of CC1 and CC2 to be Rp or Rd.
ROLE_CONTROL.CC1=01b or 10b  
ROLE_CONTROL.CC1=ROLE_CONTROL.CC2
POWER_CONTROL.AutoDischargeDisconnect=0 ;set no autodischarge when CC Disconnect.
Write COMMAND.Look4Connection TCPM wrote Look4Connection to TCPC to ask TCPC start to detect connection according to Role_Control register setting and toggle Rp/Rd.
Set CC_STATUS.Looking4Connection=1b ;After TCPC received Look4Connection command, the TCPC register CC_STATUS.Looking4Connection would be "1b". And then TCPC start to toggling the CC.

2. After the connection.
Potential_Connect_as_Source ; When TCPC to be Source
Either CC line = Src.Rd or both CC lines = Src.Ra ; if  One of the CC pin voltage is vRd or both CC pin voltage are vRa.
for >tTCPCFilter  ;Debounce time(4~500us)
Set Source Status
CC_STATUS.Looking4Connnection=0b ;TCPC stop to detect connection.
CC_STATUS.ConnectResult=0b ; TCPC set this CC pin is to be Rp.


Potential_Connect_as_Sink ;When TCPC to be Sink
Either CC line != Snk.Open ;if  One of the CC pin voltage >vRa. 
for >tTCPCFilter  ;Debounce time(4~500us)
CC_STATUS.Looking4Connection=0b ;TCPC stop to detect connection.
CC_STATUS.ConnectResult=1b  ;TCPC set CC to be Rd.

3. TCPC alert the TCPM 
TCPC Set ALERT.CcStatus=1b   ;TCPC Alert register's b0 =>CC status=1 mean the status of CC has been changed.
TCPM read ALERT      ;TCPM detect Alert and then read the Alert register
TCPM check if "ALERT.CcStatus=1b?" ;check if the status of CC have been changed
Yes=>TCPM check if "C_STATUS.Looking4Connection=0 ?" ; If yes, check if TCPC stop to detect connection. If yes, enter debounce time.
Read CC_STATUSDebounce for tCCDebounce  ;Debounce time (100ms~200ms)
Write ROLE_CONTROL.CC1 & CC2 per decision ;TCPM set TCPC's Role_control register CC1 or CC2 to be Ra,Rd or Rp.
Write TCPC_CONTROl.PlugOrientation  ;TCPM set PlugOrientation of TCPC_control register to be CC1 or CC2. 
Write POWER_CONTROL.AutoDischargeDisconnect=1 & POWER_CONTROL.EnableVconnConnection
;TCPM enable TCPC VBUS Autodischarge, The TCPC would discharge VBUS when the VBUS was under vSafe0V(max) or VBUS_STOP_Discharge_Threshold. TCPM set TCPC to output VCONN if one of CC is Ra.
Write Alert.CcStatus=0b ;Clear the CcStatus of Alert register.

4.Connection Established, TCPM monitor the Alert signal




Support USB PD and change the VBUS voltage.



1. Currently the TCPC is output VBUS 5V
Sourcing 5V over VBUS ;VBUS output 5V
POWER_STATUS.SourcingVBUS=1  ;the status SourcingVBUS=1 mean this TCPC output VBUS 5V now.
POWER_STATUS.SourcingHighVoltage=0  ;the SourcingHighVoltage=0 mean the VBUS is 5V not high voltage now. 

2. After TCPM accepted the request from far end Sink side for High voltage VBUS. TCPM would send Vendor Defined command to set the target voltage of HighVoltage. 

3.Write command.SourceVbusHighVoltage ;TCPM write SourceVbusHighVoltage to command register 

4.After TCPC received the SourceVbusHighVoltage, TCPC change the VBUS from 5V to HighVoltage.And then..
 TCPC set POWER_STATUS.SourcingHighVoltage=1  ;TCPC set register Power_Status SourcingHighVoltage bit to be "1b"。
 TCPC set ALERT.PowerStatus     ;TCPC set register Alert Power status bit to be "1b".

5.TCPM read alert register and recognize the TCPC has finished the HighVoltage VBUS transition.




1.USB 3.1 spec http://www.usb.org/developers/docs/