adsp充电框架梳理
ovp设置:QXXXX_chipset_modem/vendor/qcom/nonhlos/ADSP.HT.5.5/adsp_proc/core/battman/battmngr/charger/main/src/charger_detection.c
关键字:
sw_set_ovp_threshold
函数:charger_detection_handle_charger_attach
SSDEV_MODULE_TYPEC: sw_set_ovp_threshold(PM_SCHG_CFG_OVP_VSNS_OVPTRIP_13P8V);
SSDEV_MODULE_USB: sw_set_ovp_threshold(PM_SCHG_CFG_OVP_VSNS_OVPTRIP_13P8V);
函数:charger_detection_handle_charger_detach
SSDEV_MODULE_TYPEC: sw_set_ovp_threshold(PM_SCHG_CFG_OVP_VSNS_OVPTRIP_6P9V);
SSDEV_MODULE_USB: sw_set_ovp_threshold(PM_SCHG_CFG_OVP_VSNS_OVPTRIP_6P9V);
函数: charger_detection_inital_detection
SSDEV_MODULE_USB: sw_set_ovp_threshold(PM_SCHG_CFG_OVP_VSNS_OVPTRIP_13P8V);
端口防烧:vendor/HHHH/chipset_common/plugins/kernel/hwpower/cc_hardware_monitor/uscp/uscp.c
关键字:uscp_check_work
vendor/qcom/proprietary/devicetree/qcom/yupik/FBE/common/HHHH_charger.dtsi
open_mosfet_temp usb和battery温度差
open_mosfet_temp =
;
端口防烧温控节点:
usb port就是CONN_THERM(PM7250B),ADC_INPUT_CONN_THERM
温度曲线表:
QXXXX_chipset_modem/vendor/qcom/nonhlos/ADSP.HT.5.5/adsp_proc/core/settings/pmic/adc/config/kodiak/VAdcSettings.c
ADC_INPUT_CONN_THERM(PM_03)
#ifdef CONFIG_HHHHH_POWER_EMBEDDED_ISOLATION
static const AdcMapPtInt32toInt32Type adcMap_NTC30K[] =
{
{ 195652, -40 },
{ 148171, -35 },
{ 113347, -30 },
{ 87559, -25 },
{ 68237, -20 },
{ 53650, -15 },
{ 42506, -10 },
{ 33892, -5 },
{ 27219, 0 },
{ 22021, 5 },
{ 17926, 10 },
{ 14674, 15 },
{ 12081, 20 },
{ 10000, 25 },
{ 8315, 30 },
{ 6948, 35 },
{ 5834, 40 },
{ 4917, 45 },
{ 4161, 50 },
{ 3535, 55 },
{ 3014, 60 },
{ 2586, 65 },
{ 2228, 70 },
{ 1925, 75 },
{ 1669, 80 },
{ 1452, 85 },
{ 1268, 90 },
{ 1110, 95 },
{ 974, 100 },
{ 858, 105 },
{ 758, 110 },
{ 672, 115 },
{ 596, 120 },
{ 531, 125 }
};
const AdcIntTableType gVAdcSys30KThermTable =
{
.pTable = adcMap_NTC30K,
.uLength = ARRAY_LENGTH(adcMap_NTC30K),
};
#ifdef CONFIG_HHHHH_POWER_EMBEDDED_ISOLATION
{
.pszName = ADC_INPUT_CONN_THERM(PM_03),
.uAdcHardwareChannel = 0x27,
.eSettlingDelay = VADC_SETTLING_DELAY_100_US,
.eAverageMode = VADC_AVERAGE_1_SAMPLE,
.eDecimationRatio = VADC_DECIMATION_RATIO_1024,
.eCalMethod = VADC_CAL_METHOD_RATIOMETRIC,
.scalingFactor = {1, 1}, /* {num, den} */
.eScalingMethod = VADC_SCALE_THERMISTOR,
.uPullUp = 30000,
.pIntTable = &gVAdcSys30KThermTable,
},
温度曲线在battman_adc_init函数中载入,通过battman_adc_read函数获取温度:QXXXX_chipset_modem/vendor/qcom/nonhlos/ADSP.HT.5.5/adsp_proc/core/battman/framework/osservice/osa/src/battman_adc.c
pmic_glink.c:
pmic_glink_tx 发送数据到AP
pmic_glink_process_rx_data 处理AP发过来的读写请求PMIC_GLINK_MSG_OWNER_CHARGER遍历操作码PMIC_GLINK_MSG_OWNER_USB_TYPE_C遍历操作码UCSI_READ_BUFFER_REQUCSI_WRITE_BUFFER_REQPMIC_GLINK_MSG_OWNER_USBC_PAN遍历操作码USBC_CMD_READ_REQUSBC_CMD_WRITE_REQPMIC_GLINK_MSG_OWNER_OEM遍历操作码OEM_OPCODE_READ_BUFFEROEM_OPCODE_WRITE_BUFFERpmic_glink_send_oem_notification 发送OEM通知(oem厂家的)pmic_glink_send_notification 发送通知msg_owner = PMIC_GLINK_MSG_OWNER_USB_TYPE_C (32779要和AP侧的ID一样)msg_type = PMIC_GLINK_MSG_TYPE_NOTIFICATIONopcode = UCSI_NOTIFY_INDnotification= notificationreceiver = receiver//只有USB接口和USBCUCSI_USBC_NOTIFY_RECEIVER_UCSI 0x0UCSI_USBC_NOTIFY_RECEIVER_USBC 0x1pmic_glink_send_usbc_notification 发送通知msg_owner = PMIC_GLINK_MSG_OWNER_USBC_PAN (32780要和AP侧的ID一样)msg_type = PMIC_GLINK_MSG_TYPE_NOTIFICATIONopcode = (USBC_NOTIFY_IND & 0xFFFF)| (svid<<16) //通知码和SVID拼接,USBPD_SVID_DISPLAYPORT/USBPD_SVID_DEFAULTpayload[*] = pdatapmic_glink_send_power_supply_notification 发送通知msg_owner = PMIC_GLINK_MSG_OWNER_CHARGER (32778要和AP侧的ID一样)msg_type = PMIC_GLINK_MSG_TYPE_NOTIFICATIONopcode = UCSI_NOTIFY_INDnotification= notificationreceiver = receiver// pmic_glink_msg.hBATT_MNGR_XXXUSB_POWER_SUPPLY_XXXDC_POWER_SUPPLY_XXX三方
ADSP处理结果或状态变化反馈给AP:
TYPC -> LPM -> PPM -> DPM -> BM -> ADSP -> AP
dpm_mainloop
|
|—等到event
|
|—dpm_process_event
|
|判断"EventHeader.EvtDest"的目的地
|
|—USBPD_MODULE_PPM(要发往PPM的事件)
| |
| |----ppm_state_run
| |
| |----pState->Context.bNotify == 1? (如果需要发送通知)
| |
| |----ppm_notify_opm(通知UCSI)
| |
| |----pmic_glink_send_notification
| |
| |----通知UCSI && 打印"OPM Notification Success"
|
|----USBPD_MODULE_DPM(发给自己的事件)
|
|----dpm_event_handler
|
|处理cable事件和来自bm的请求事件
|
|----USBPD_DPM_EVENT_DPM_CABLE_EVENT
| |
| |----dpm_handle_cable_event
| |
| |----pDpmCtx->PwrMgr.PortStatus[pEvent->Payload.AsyncEvent.PortIndex]
| |----charger_notify(CHARGER_EVENT_DETECTION_UPDATE)
|
|----USBPD_DPM_EVENT_BM_REQUEST
|
|----dpm_handle_bm_request_event
|
|----解析请求类型发送数据到LPM
lpm_mainloop
|
|----转换事件
|
|----lpm_process_event
| |
| |----协议层处理
| | |
| | |----USBPD_MODULE_LPM_PRL_XX
| | |----USBPD_MODULE_LPM_PRL_RTR
| | |----USBPD_MODULE_LPM_PRL_RCH
| | |----USBPD_MODULE_LPM_PRL_TCH
| |
| |----Policy Engine层
| | |
| | |----USBPD_MODULE_LPM_PE
| |
| |----端口管理层
| | |
| | |—USBPD_MODULE_LPM_PM
| |
| |----物理层
| |
| |—USBPD_MODULE_TCPC_PHY
|
|----LPM_EVENTS_NOTIFY_DPM(需要发给DPM的)
|
|----dpm_notify(USBPD_DPM_EVENT_LPM_ASYNC_EVENT)
ppm_state_ppm_proccess_async_event_init
|
|----pStateContext->NotifyEn.AsUINT16 && CONNETOR_STATUS_MASK
| &&
| sPortPendingAsyncEvent >= pStateContext->config.capability.bNumConnector
|
|----状态变化通知为连接器变化且端口不能大于设置的最大下标
|
|----ppm_set_cci_for_connector_change(sPortPendingAsyncEvent)
|
|----sMailbox.cci.ConnectorChangeIndicator = (port_index + 1)
(更新变化位)
pmic_glink_send_notification(sMailbox.cci.AsUINT32, UCSI_USBC_NOTIFY_RECEIVER_UCSI)
CCI不同状态位设置:
ppm_set_cci_for_connector_change:只设置ConnectorChangeIndicator “Invalid port_index=%d”/“CCI=0x%08X”
ppm_set_cci: 设置所有的CCi状态位置 “Update CCI=0x%08X”
typedef union _USBPD_UCSI_NOTIFICATION_ENABLE_DATA
{unsigned short AsUINT16;struct{unsigned char CommandCompleted : 1; /*bit [ 0: 0]*/unsigned char ExternalSupplyChange : 1; /*bit [ 1: 1]*/unsigned char PowerOperationModeChange : 1; /*bit [ 2: 2]*/unsigned char : 1; /*bit [ 3: 3]*/unsigned char : 1; /*bit [ 4: 4]*/unsigned char SupportedProviderCapChange : 1; /*bit [ 5: 5]*/unsigned char NegotiatedPowerLevelChange : 1; /*bit [ 6: 6]*/unsigned char PDResetComplete : 1; /*bit [ 7: 7]*/unsigned char SupportCAMChange : 1; /*bit [ 8: 8]*/unsigned char BatteryChargingStatusChange : 1; /*bit [ 9: 9]*/unsigned char : 1; /*bit [10:10]*/unsigned char ConnectorPartnerChange : 1; /*bit [11:11]*/unsigned char PowerDirectionChange : 1; /*bit [12:12]*/unsigned char : 1; /*bit [13:13]*/unsigned char ConnectorChange : 1; /*bit [14:14]*/unsigned char Error : 1; /*bit [15:15]*/};
}USBPD_UCSI_NOTIFICATION_ENABLE_DATA,*PUSBPD_UCSI_NOTIFICATION_ENABLE_DATA;
//CC信息,输入/输出/控制数据
typedef struct _USBPD_UCSI_DATA
{
USBPD_UCSI_VERSION_DATA version; //VERSION(16 bits)
unsigned short reserve; //RESERVE(16 bits)
USBPD_UCSI_CCI_DATA cci; //CCI(32 bits)
USBPD_UCSI_GENERIC_CONTROL_DATA control; //CONTROL(64 bits)
USBPD_UCSI_GENERIC_MESSAGE_DATA message_in; //MESSAGE_IN(128 bits) In to OPM/OS
USBPD_UCSI_GENERIC_MESSAGE_DATA message_out; //MESSAGE_OUT(128 bits) Out to OPM/OS
}USBPD_UCSI_DATA, *PUSBPD_UCSI_DATA;
typedef union _USBPD_UCSI_CCI_DATA
{unsigned long AsUINT32;struct{unsigned short : 1; /*bit [ 0: 0]*/unsigned short ConnectorChangeIndicator : 7; /*bit [ 7: 1]*/ -> 端口是否变化unsigned short DataLength : 8; /*bit [15: 8]*/unsigned short : 9; /*bit [24:16]*/unsigned short NotSupportedIndicator : 1; /*bit [25:25]*/unsigned short CancelCompletedIndicator : 1; /*bit [26:26]*/unsigned short ResetCompletedIndicator : 1; /*bit [27:27]*/unsigned short BusyIndicator : 1; /*bit [28:28]*/unsigned short AckCommandIndicator : 1; /*bit [29:29]*/unsigned short ErrorIndicator : 1; /*bit [30:30]*/unsigned short CommandCompletedIndicator : 1; /*bit [31:31]*/};
}USBPD_UCSI_CCI_DATA, *PUSBPD_UCSI_CCI_DATA;typedef union _USBPD_UCSI_CONTROL_DATA
{unsigned long long AsUINT64;struct{unsigned long long Command : 8; /*bit [ 7: 0]*/unsigned long long DataLength : 8; /*bit [15: 8]*/unsigned long long : 48; /*bit [63:16]*/};
}USBPD_UCSI_GENERIC_CONTROL_DATA, *PUSBPD_UCSI_GENERIC_CONTROL_DATA;typedef union _USBPD_UCSI_MESSAGE_DATA
{unsigned char AsUINT8[16];
}
USBPD_UCSI_GENERIC_MESSAGE_DATA, *PUSBPD_UCSI_GENERIC_MESSAGE_DATA;
static USBPD_UCSI_DATA sMailbox
dpm_mainloop
|
|----被唤醒
|
|----dpm_update_new_events_to_queue(构建"USBPD_DPM_EVENT_“到新的EventHeader)
|
|----指定src->dst(比如"USBPD_MODULE_OPM -> USBPD_MODULE_PPM”)
|
|----event_handler_add_new_event
dpm_process_event
|
|----区分发往的目的地
|
|----ppm_state_run
|
|-----USBPD_DPM_EVENT_OPM_COMMAND && USBPD_UCSI_COMMAND_CODE_PPM_RESET
| |
| |----重置
| |
| |----pState->Context.StateMachine.prevState
| |----pState->Context.StateMachine.currState
| |----pState->Context.StateMachine.nextState
| |----pState->Context.NotifyEn.AsUINT16
| |----pState->Context.bCommandPending
| |----pState->Context.bAsyncEventPending
| |----pState->Context.bNotify
| |----ppm_set_cci(重置sMailbox)
|
|----usbtypec_statemachine_state_run
| |
| |----运行状态机处理event
| |
| |----idle_notify_disable_main状态
| | |
| | |----USBPD_DPM_EVENT_OPM_COMMAND && USBPD_UCSI_COMMAND_CODE_GET_CONNECTOR_STATUS (返回连接器状态)
| | | |
| | | |----pStateContext->status.Ports[port_num-1].ConnectorStatus
| | |
| | |----USBPD_DPM_EVENT_OPM_COMMAND && USBPD_UCSI_COMMAND_CODE_SET_NOTIFICATION_ENABLE(使能通知)
| | |
| | |----pStateContext->StateMachine.nextState = USBPD_PPM_STATE_PPM_PROCESS_COMMAND(进入处理命令状态处理)
| |
| |
| |----idle_notify_enable_main状态
| | |
| | |----USBPD_DPM_EVENT_OPM_COMMAND
| | |
| | |----USBPD_DPM_EVENT_OPM_COMMAND && USBPD_UCSI_COMMAND_CODE_ACK_CC_CI(应答信息要立即反馈不能pending)
| | | |
| | | |----应答反馈(AP获取信息后的答复)
| | | |
| | | |----ConnectorChangeAck(AP获取到信息后反馈之后的应答要把状态清空)
| | | | |
| | | | |----pStateContext->status.Ports[proccessed_port_num-1].ConnectorStatus.ConnectorStatusChange
| | | | |----pStateContext->bAsyncEventPending = false
| | | | |----sPortPendingAsyncEvent
| | | |
| | | |----CommandCompletedAck(AP发送指令得到结果后,再反馈的应答)
| | | |
| | | |----USBPD_UCSI_COMMAND_CODE_GET_ERROR_STATUS(如果是获取错误指令的话,获取应答后清空错误位)
| | | |
| | | |----sMailbox.cci.ErrorIndicator
| | | |----sErrorInformation.AsUINT16
| | |
| | |
| | |----USBPD_DPM_EVENT_OPM_COMMAND && *(其他命令先pending进入下个状态处理)
| | |
| | |-----pStateContext->bCommandPending = true
| | |-----pStateContext->StateMachine.nextState = USBPD_PPM_STATE_PPM_PROCESS_COMMAND
| |
| |----wait_for_command_completion_main状态
| | |
| | |----USBPD_DPM_EVENT_OPM_COMMAND && USBPD_UCSI_COMMAND_CODE_ACK_CC_CI
| | |
| | |----等待命令完成状态时收到应答指令,处理应答
| | |
| | |----pStateContext->StateMachine.nextState = USBPD_PPM_STATE_PPM_IDLE_NOTIFY_ENABLE(进入通知使能的idle状态)
| |
| |----process_command_init状态
| | |
| | |----刚进入处理命令初始化状态需要区分命令
| | |
| | |----立即要处理的命令
| | | |
| | | |----USBPD_UCSI_COMMAND_CODE_SET_NOTIFICATION_ENABLE (pStateContext->NotifyEn.AsUINT16 = pControlData->set_notify_en.NotificationEnable)
| | | |----USBPD_UCSI_COMMAND_CODE_GET_CAPABILITY
| | | |----USBPD_UCSI_COMMAND_CODE_GET_CONNECTOR_CAPABILITY
| | | |----USBPD_UCSI_COMMAND_CODE_GET_CONNECTOR_STATUS
| | | |----USBPD_UCSI_COMMAND_CODE_GET_ERROR_STATUS
| | | |----USBPD_UCSI_COMMAND_CODE_GET_CAM_SUPPORTED
| | | |----USBPD_UCSI_COMMAND_CODE_GET_CURRENT_CAM
| | | |----USBPD_UCSI_COMMAND_CODE_CANCEL
| | | |
| | | |—ppm_proccess_immediate_command
| | | |
| | | |----获取各个状态pStateContext->NotifyEn.AsUINT16
| | | |----刷新pStateContext->NotifyEn.AsUINT16
| | | |----刷新cci ppm_set_cci
| | |
| | |----USBPD_UCSI_COMMAND_CODE_GET_PDOS
| | |----USBPD_UCSI_COMMAND_CODE_CONNECTOR_RESET
| | |----USBPD_UCSI_COMMAND_CODE_SET_UOR
| | |----USBPD_UCSI_COMMAND_CODE_SET_PDR
| | |----USBPD_UCSI_COMMAND_CODE_GET_ALTERNATE_MODE
| |
| |
| |----process_command_main状态
| | |
| | |----USBPD_DPM_EVENT_OPM_COMMAND && USBPD_UCSI_COMMAND_CODE_CANCEL(搜到OPM的取消指令,设置告知LPM取消状态,同时进入等待命令完成应答)
| | |
| | |----pStateContext->Request2LPM.RequestInProgress = false
| | |----pStateContext->Request2LPM.ReqeustType = USBPD_DPM2LPM_REQUEST_NONE
| | |----pStateContext->StateMachine.nextState = USBPD_PPM_STATE_PPM_WAIT_FOR_COMMAND_COMPLETION_ACK
| |
| |----proccess_async_event_init(同步事件一般比较急)
| | |
| | |—检查端口异常?
| | |
| | |----无异常
| | |
| | |----刷新"sPortPendingAsyncEvent"到sMailbox.cci.ConnectorChangeIndicator"
| | |----pStateContext->bNotify = true(直接设置运行通知)
| |
| |----proccess_async_event_main
| |
| |----USBPD_DPM_EVENT_OPM_COMMAND && sMailbox.cci.ConnectorChangeIndicator != 0 && USBPD_UCSI_COMMAND_CODE_ACK_CC_CI
| |
| |----端口变化时的应答反馈
| |
| |----处理应答
|
|----pState->Context.bNotify?
|
|----对应的状态机运行完毕后,判断下是否需要通知
|
|----是的话,发给OPM,之后关闭通知以便下次调用
|
|----ppm_notify_opm
|----pState->Context.bNotify = false
USBPD_UCSI_COMMAND_CODE_SET_NOTIFICATION_ENABLE很关键,其表示UCSI处理的情况
会更新到"pStateContext->NotifyEn.AsUINT16",每个bit的定义如下:
/* SET_NOTIFICATION_ENABLE command bits */
#define UCSI_ENABLE_NTFY_CMD_COMPLETE BIT(16)
#define UCSI_ENABLE_NTFY_EXT_PWR_SRC_CHANGE BIT(17)
#define UCSI_ENABLE_NTFY_PWR_OPMODE_CHANGE BIT(18)
#define UCSI_ENABLE_NTFY_CAP_CHANGE BIT(21)
#define UCSI_ENABLE_NTFY_PWR_LEVEL_CHANGE BIT(22)
#define UCSI_ENABLE_NTFY_PD_RESET_COMPLETE BIT(23)
#define UCSI_ENABLE_NTFY_CAM_CHANGE BIT(24)
#define UCSI_ENABLE_NTFY_BAT_STATUS_CHANGE BIT(25)
#define UCSI_ENABLE_NTFY_PARTNER_CHANGE BIT(27)
#define UCSI_ENABLE_NTFY_PWR_DIR_CHANGE BIT(28)
#define UCSI_ENABLE_NTFY_CONNECTOR_CHANGE BIT(30)
#define UCSI_ENABLE_NTFY_ERROR BIT(31)
#define UCSI_ENABLE_NTFY_ALL 0xdbe70000
dpm_mainloop
|
|----USBPD_DPM_EVENT_LPM_RTN4REQUEST(LPM真对DPM请求的返回值,DPM请求后,LPM处理完,需要告知DPM返回结果)
| |
| |----dpm_queue_lpm_rtn4request_event
| |
| |----遍历端口
| |
| |----evt_data_buffer.EventHeader.EvtType (LPM_RTN4REQUEST)
| |----evt_data_buffer.EventHeader.EvtDest (USBPD_MODULE_PPM)
| |----evt_data_buffer.EventHeader.PayloadType (LPM2DPM_RTN4REQUEST)
| |----evt_data_buffer.EventHeader.Rtn4Request (pDpmCtx->LpmInterface[port_index].NotifyBuffer.NotifyData.Rtn4Request)
| |
| |----event_handler_add_new_event
|
|----dpm_process_event
|
|----ppm_state_run
|
|----process_command_main状态
|
|----USBPD_DPM2LPM_REQUEST
|
|—区分LPM的返回带不带负载
|
|----不带负载
| |
| |----USBPD_DPM2LPM_REQUEST_PD_DR_UFP
| |----USBPD_DPM2LPM_REQUEST_PD_DR_DFP
| |----USBPD_DPM2LPM_REQUEST_PD_PR_SNK
| |----USBPD_DPM2LPM_REQUEST_PD_PR_SRC
| |----USBPD_DPM2LPM_REQUEST_PD_SOFTRESET
| |----USBPD_DPM2LPM_REQUEST_PD_HARDRESET
| |
| |----ppm_set_cci更新成功或错误标记位(ErrorIndicator/CommandCompletedIndicator)
|
|----带负载
|
|----USBPD_DPM2LPM_REQUEST_PD_PARNTER_GET_SRC_CAP
|----USBPD_DPM2LPM_REQUEST_PD_PARNTER_GET_SNK_CAP:
|
|----pMsgIn->get_pdos.PDOs
(更新到返回信息的对应位置)
dpm_mainloop
|
|----USBPD_DPM_EVENT_LPM_BM_SYNC(LPM要发给BM的,一般是LPM处理BM的请求出现异常时直接发给BM)
| |
| |----event_handler_set_event(pDpmCtx->PwrMgr.pBattMngrEvtHandler, BATTMNGR_DRV_HEARTBEAT_EVENT)
| (出发心跳事件直接到BM)
|
|----dpm_process_event
|
|----ppm_state_run
dpm_mainloop
|
|----USBPD_DPM_EVENT_LPM_MISC_EVENT(LPM的杂项事件)
|
|----dpm_queue_lpm_misc_event
|
|—sink休眠事件,更新相关状态,并通知充电线程
|
|----pDpmCtx->PwrMgr.PortStatus[port_index].bSinkPowerStandby
|----charger_notify(CHARGER_EVENT_DETECTION_UPDATE)
1.1 非"PE/TYPE-C"事件
外部请求的LPM事件
|
|----lpm_request
|
|----USBPD_LPM_EVENT_PM_REQUEST
|----USBPD_LPM_EVENT_PM_ACK
|----USBPD_LPM_EVENT_PAN_ACK
|----USBPD_LPM_EVENT_EXIT
|
|----event_handler_set_event
|
|----调用BM接口发出信号
lpm_mainloop
|
|----事件添加
| |
| |----USBPD_LPM_EVENT_PM_REQUEST
| | |
| | |----lpm_add_dpm_request_event
| | |
| | |----区分请求类型
| | |
| | |----bValidEvent?有效事件判断
| | | |
| | | |----USBPD_DPM2LPM_REQUEST_RDO_UPDATE
| | | | |
| | | | |----EvtDest = USBPD_MODULE_LPM_PE
| | | | |----PayloadType = USBPD_EVENT_PAYLOAD_PD_RDO
| | | |
| | | |----USBPD_DPM2LPM_REQUEST_PD_DR_UFP
| | | |----USBPD_DPM2LPM_REQUEST_PD_DR_DFP
| | | |----USBPD_DPM2LPM_REQUEST_PD_RR_SINK
| | | |----USBPD_DPM2LPM_REQUEST_PD_PR_SRC
| | | |----USBPD_DPM2LPM_REQUEST_PD_PARNTER_GET_SRC_CAP
| | | |----USBPD_DPM2LPM_REQUEST_PD_PARNTER_GET_SNK_CAP
| | | |----USBPD_DPM2LPM_REQUEST_PD_HARDRESET
| | | |----USBPD_DPM2LPM_REQUEST_PD_SOFTRESET
| | | |----USBPD_DPM2LPM_REQUEST_GET_PPS_STATUS
| | | |----USBPD_DPM2LPM_REQUEST_EMARK_DETECT
| | | |----USBPD_DPM2LPM_REQUEST_UVDM_SEND
| | | |
| | | |----EvtDest = USBPD_MODULE_LPM_PE
| | | |----PayloadType = USBPD_EVENT_PAYLOAD_DPM2LPM_REQUEST
| | |
| | |----USBPD_DPM2LPM_REQUEST_DP_OVERRIDE
| | | |
| | | |----更新"pLpmCtx->pPDCtx->PE.Context.Policies.VdmPolicy.DisplayPort.DPOverride"
| | |
| | |----USBPD_DPM2LPM_REQUEST_TYPECUV_THRESHOLD_OVERRIDE
| | | |
| | | |----pe_set_typec_uv_threshold_override(跟新typec的欠压阈值)
| | |
| | |----USBPD_DPM2LPM_REQUEST_LPD_CHECK
| | |
| | |----tcpm_set_lpd_check_request(调用tcpc接口进行lpd检测)
| |
| |----USBPD_LPM_EVENT_EXIT
| | |
| | |----tcpci_deinit (先退出下游的循环)
| | |----event_handler_deinit (销毁所有的事件)
| | |----break (推出当前的loop)
| |
| |----lpm_update_new_events_to_queue
| |
| |----USBPD_LPM_EVENT_PAN_ACK(收到PAN的应答就清空相关置位标志)
| |
| |----pLpmCtx->bPANPending = false
|
|----事件处理
|
|----lpm_process_event
|
|----USBPD_MODULE_LPM_PM
| |
| |----发给DPM的
| |
| |----USBPD_LPM_EVENT_PE_REQUEST_SIGNAL
| |----USBPD_LPM_EVENT_ALERT_RECEIVE_HARDRESET_STATUS
| | |
| | |----lpm_process_hardreset_event
| | |
| | |----重置LPM的协议层相关状态
| | |----更新事件"pEvent->EventHeader.EvtDest"到"USBPD_MODULE_LPM_PRL_HR"(转给协议层处理硬重置)
| |
| |----USBPD_LPM_EVENT_PE_PM_REQUEST_RTN
| | |
| | |----lpm_process_event2dpm(TCPC针对DPM请求的返回事件)
| |
| |----其他事件不处理(不支持),让tcpm自行处理
| |
| |----tcpm_state_run
|
|----USBPD_MODULE_LPM_PE && pLpmCtx->bSupportPD
|
|----先判断硬重置或软重置
| |
| |----重置相关状态
|
|----pe_state_run(运行PE状态机处理事件----处理核心)
|
|----usbtypec_statemachine_state_run
|
|----运行指定的状态进入初始化函数、main函数、退出函数
|
|----USBPD_PE_STATE_TYPE定义的PD协议规范定义的状态
1.2 “TYPE-C/PHY"置位事件
lpm_mainloop
|
|----事件添加
| |
| |----lpm_update_new_events_to_queue
| |
| |----USBPD_LPM_EVENT_ALERT
| |
| |----tcpm_get_events_from_alert
| |
| |----获取置位信息
| |
| |----EvtSrc = USBPD_MODULE_TCPC_PHY
| |----EvtDest = USBPD_MODULE_LPM_PM/_LPM_PRL_HR/_LPM_PRL_RX/_LPM_PRL_TX
| |----EvtType = USBPD_LPM_EVENT_ALERT_XXX(扩展置位类型)
| |----PayloadType = USBPD_EVENT_PAYLOAD_LPM_HWSTATUS
| |
| |添加事件
| |
| |----event_handler_add_new_event
|
|----事件处理
| |
| |----lpm_process_event
| |
| |----USBPD_MODULE_LPM_PM
| |
| |----发给DPM的
| |
| |----USBPD_LPM_EVENT_PE_REQUEST_SIGNAL
| |----USBPD_LPM_EVENT_ALERT_RECEIVE_HARDRESET_STATUS
| | |
| | |----lpm_process_hardreset_event
| | |
| | |----重置LPM的协议层相关状态
| | |----更新事件"pEvent->EventHeader.EvtDest"到"USBPD_MODULE_LPM_PRL_HR”(转给协议层处理硬重置)
| |
| |----USBPD_LPM_EVENT_PE_PM_REQUEST_RTN
| | |
| | |----lpm_process_event2dpm(TCPC针对DPM请求的返回事件)
| |
| |----其他事件不处理由"TEPE-C的状态机"处理(注意不是PD的状态机)
| |
| |----tcpm_state_run
|
|----LpmEvent & LPM_EVENTS_NOTIFY_DPM
|
|LPM_EVENTS_NOTIFY_DPM = USBPD_LPM_EVENT_PM_ACK|USBPD_LPM_EVENT_PAN_ACK|USBPD_LPM_EVENT_ALERT|LPM_EVENTS_PD|USBPD_LPM_EVENT_HKTIMER_TO
|LPM_EVENTS_PD = USBPD_LPM_EVENT_PE_TIMEOUT|USBPD_LPM_EVENT_PE_PDPOLICY_TIMEOUT|USBPD_LPM_EVENT_PE_VDM_TIMEOUT|USBPD_LPM_EVENT_PPS_REQUEST_TIMEOUT|USBPD_LPM_EVENT_PRL_TIMEOUT
|
|----lpm_notify_dpm
|
|----"pLpmCtx->bPANEn"是否使能
| |
| |----使能则获取PIN变化
| | |
| | |----pLpmCtx->PinAssignment.changed && !pLpmCtx->bPANPending (变化但是没有pending说明新的事件通知变化)
| | | |
| | | |----dpm_notify(pLpmCtx->pDPMInterface->pNotifyListener, USBPD_DPM_EVENT_LPM_PAN)
| | |
| | |----!pLpmCtx->PinAssignment.changed && !pLpmCtx->bPANPending (没有变化则同步事件即刷新下连接器状态)
| | |
| | |----lpm_async_event_update
| | |----bNotifyAsyncEvent = true
| |
| |----没有使能则刷新下连接器状态
| |
| |----lpm_async_event_update
| | |
| | |----判断要同步哪些信息
| | |
| | |----pLpmCtx->Tcpm.Context.ConnectorStatus.ConnectStatus?
| | |
| | |----没有变化则只同步TypeC信息
| | | |
| | | |----lpm_async_event_update_from_tcpm
| | |
| | |----变化
| | |
| | |----lpm_async_event_update_from_tcpm
| | |
| | |----pLpmCtx->pPDCtx->PE.Context.PDConnectorStatus.ConnectStatus
| | |
| | |—PE也有变化则也需要同步PE信息
| |
| |----bNotifyAsyncEvent = true
|
|----bNotifyAsyncEvent && (连接器状态变化 || PD状态变化 || bLiquidDetected使能)
|
|----刷新"pLpmCtx->pDPMInterface->NotifyBuffer"的所有成员数据
|----dpm_notify(pLpmCtx->pDPMInterface->pNotifyListener, USBPD_DPM_EVENT_LPM_ASYNC_EVENT)
|
|----DPM传给PPM
|
|----ppm_state_run
|
|----状态机运行
| |
| |----ppm_state_ppm_proccess_async_event_init
| |
| |----处理事件
| |----pStateContext->bNotify = true (要通知OPM)
|
|----pState->Context.bNotify?
|
|----ppm_notify_opm(AP侧的UCSI处理------AP于ADSP通信核心)
1.3 PE协议层和物理层事件
lpm_mainloop
|
|----PE事件不用添加(alert处理阶段会构建事件对象)
|
|----事件处理
|
|----lpm_process_event
|
|----发往协议层
| |
| |----USBPD_MODULE_LPM_PRL_RX && pLpmCtx->bSupportPD
| |----USBPD_MODULE_LPM_PRL_TX && pLpmCtx->bSupportPD
| |----USBPD_MODULE_LPM_PRL_HR && pLpmCtx->bSupportPD
| |
| |----usbtypec_statemachine_state_run
| |
| |----运行指定的状态的初始化函数、main函数、退出函数
| |
| |----USBPD_PRLRX_STATE_TYPE定义的类型(用于解析PHY层发到协议层的数据)
| |----USBPD_PRLTX_STATE_TYPE定义的类型(用于构造要发往PHY层的数据)
| |----USBPD_PRLHR_STATE_TYPE定义的类型(用于构造和解析收发的reset数据)
|
|----发往物理层
| |
| |----USBPD_MODULE_LPM_RTR && pLpmCtx->bSupportPD
| | |
| | |----见协议
| |
| |----USBPD_MODULE_LPM_RCH && pLpmCtx->bSupportPD
| | |
| | |----见协议
| |
| |----USBPD_MODULE_LPM_TCH && pLpmCtx->bSupportPD
| |
| |----见协议
|
|----pLpmCtx->Tcpm.Context.bAlertForwarding?(检测中是否需要开启PD,比如旧的A2C线就不需要开启)
|
|----开启
| |
| |----pLpmCtx->bSupportPD && !pLpmCtx->bPDInit(支持PD且PD还没有初始化)
| |
| |----pe_state_start
|
|----不开启
|
|----pLpmCtx->bSupportPD && pLpmCtx->bPDInit(支持PD且PD已经初始化过了)
|
|----pe_state_stop
1.4 “定时超时"和"通信超时"事件
lpm_mainloop
|
|----事件添加
| |
| |----USBPD_LPM_EVENT_HKTIMER_TO(HK-House Keeping事件)
| | |
| | |----队列长时间没有activity(事件)
| | |
| | |----尝试从DeferEvent取出event添加到Queue
| |
| |—lpm_update_new_events_to_queue(构建事件)
| |
| |----USBPD_LPM_EVENT_PE_TIMEOUT
| |----USBPD_LPM_EVENT_PE_PDPOLICY_TIMEOUT
| |----USBPD_LPM_EVENT_PE_VDM_TIMEOUT
| |----USBPD_LPM_EVENT_PPS_REQUEST_TIMEOUT
| | |
| | |----EvtDest = USBPD_MODULE_LPM_PE
| |
| |----USBPD_LPM_EVENT_PRL_TIMEOUT
| |
| |----PRLTimer.TimerID(根据定时ID确定目的地)
| |
| |----EvtDest = USBPD_MODULE_LPM_RCH
| |----EvtDest = USBPD_MODULE_LPM_TCH
| |----EvtDest = USBPD_MODULE_LPM_PRL_TX
|
|----事件处理
|
|----lpm_process_event(走上面PE和协议层物理层)
|
|—处理"USBPD_MODULE_LPM_PE”
|—处理"USBPD_MODULE_LPM_RCH"
|—处理"USBPD_MODULE_LPM_TCH"
|—处理"USBPD_MODULE_LPM_PRL_TX"
PmicTccStateMachine_Main_Thread
|
|----usbpd_tcpc_event_exit(收到退出事件)
| |
| |----pmictccstatemachine_deinit(pdevicecontext)
|
|
|----usbpd_tcpc_event_regwrite(收到寄存器写入事件–一般是配置寄存器值)
| |
| |----pmictccregister_write
| |
| |----PMIC/ChargerIC的子模块"Type-C"的接口
|
|----pmictccstatemachinelevels_run_statemachine
|
|----此处只讲"USBPD_TCPC_EVENT_CABLE"
|
|----PmicTccStateMachineLevels_Offline_State_Main
| |
| |----CC是否变化?
| |
| |----有变化
| | |
| | |----进入"PMICTCC_STATE_ID_STANDBY"新状态进行处理
| |
| |----没有变化
| |
| |----USBPD_TCPC_EVENT_CABLE && pogopin
| |
| |----判断是否进入DC充电(无限充电)
| |
| |----pmic_glink_send_oem_notification
|
|----其他状态
| |
| |----PmicTccRegister_UpdateStatusAlert
|
|----PmicTccRegister_UpdateAlert
|
|----PmicTccRegister_Send_Alert_Notification
|
|----生成"USBPD_LPM_EVENT_ALERT"事件并触发
BattMngrStateMachine_Main_Thread
|
|
|
|
|
|
|
|
|
|
|
|
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
