cancel
Showing results for 
Search instead for 
Did you mean: 

USB EZ-PD Type-C

PrRe_3492461
New Contributor II

Hello community,

I'm using ccg3pa as a SINK only product in my custom application.

I want to configure ccg3pa to respond for SOP1 vendor defined packets.

I have made required changes in configuration utility as well - "cable discovery enable" to YES but it didn't help.

Also tried calling dpm_update_def_cable_cap(300); in main function but it doesn't help either.

Can anyone let me know how to achieve this requirement.

Thanks and regards,

Pranay.

0 Likes
Reply
1 Solution
PranavaYN
Moderator
Moderator

Pranay,

/* Configure RX_ORDER_SET_CTRL pd->rx_order_set_ctrl|= EN_PRIME_SOP_DET_VAL;*/
pd->rx_order_set_ctrl = RX_ORDER_SET_CTRL_CFG;
pd->rx_order_set_ctrl |= EN_PRIME_SOP_DET_VAL; // Include this line
/* Configure CRC_COUNTER reg */
pd->crc_counter = CRC_COUNTER_CFG;

Please include pd->rx_order_set_ctrl |= EN_PRIME_SOP_DET_VAL;  in pd_phy_init() function in above shown location.

temp |= EN_PRIME_SOP_DET_VAL;  // include this line
pd->rx_order_set_ctrl = temp;

temp = pd->tx_ctrl;
temp &= ~PDSS_TX_CTRL_GOODCRC_MSG_BITS_MASK;

Also include temp |= EN_PRIME_SOP_DET_VAL;   in pd_phy_refresh_roles() funtions.

 

Both are present in pdss_mx_hal.c file.

I tried this and I am able to get APP_EVT_PKT_RCVD event in app_evt_handler()

Best regards,
Pranava

View solution in original post

20 Replies
PranavaYN
Moderator
Moderator

Hi Pranay,

I have made required changes in configuration utility as well - "cable discovery enable" to YES --> This will make CCG3PA send Discover ID message with SOP_PRIME addressing to detect whether emarker cable is present or not.

Also tried calling dpm_update_def_cable_cap(300); --> This function is used to set max current limit when no e-mark cable is present.

You can decode and respond to any packet in APP_EVT_PKT_RCVD case in app_evt_handler() function in app.c

May I know the exact reason why you want CCG3PA to respond to SOP_PRIME VDMs?

Best regards,

Pranava

Best regards,
Pranava
0 Likes
Reply
PrRe_3492461
New Contributor II

Thanks Pranava for the reply,

I want ccg3pa as a SNK to emulate as a Cable, that is the reason I want to respond for SOP1 packets that are from a source.

I want to respond with ACK for a SOP1 Disc ID initiated by a SRC DUT connected to ccg3pa(SNK).

Is that possible ?

Regards,

Pranay.

0 Likes
Reply
PranavaYN
Moderator
Moderator

Hi Pranay,

Please find a similar thread and response.CYPD3171 CCG3PA 100watt 5A Sink Capability with Captive Cable (NO EMCA)

Since significant effort is required in modifying both firmware and PD stack which is Cypress confidential. Therefore this modification is not recommended.

Best regards,

Pranava

Best regards,
Pranava
0 Likes
Reply
PrRe_3492461
New Contributor II

pranava,

So You mean that CCG3PA as a SNK can't initiate Disc ID SOP1 messages ?

I have also double verified that CCG3PA as SNK is not even getting an interrupt when a SRC initiates DiscID/ softreset/ Any other messages with SOP1.

Any other way to get that interrupt and decode,prepare and respond with GCRC & ACK.

Only way is to get the total cypress PD stack ?

--Pranay.

0 Likes
Reply
PrRe_3492461
New Contributor II

PranavaY_81 ,

I have gone through below knowledge based article :

Enabling Cable Discovery in CCGx Power SDK Firmware– KBA231210

It doesn't speak about the port power of the Ccg3pa ,

Is it also applicable when CCG3PA acting as a SNK ??

--Pranay.

0 Likes
Reply
PranavaYN
Moderator
Moderator

Hi,

Is it also applicable when CCG3PA acting as a SNK ??

>> According to PD 3.0 spec, Only Vconn source is allowed to send cable discovery message. Therefore Vconn support is a prerequisite in the article you have mentioned.  By default PD source is the Vconn source but it can be swapped using Vconn swap messages. Therefore this will be applicable to sink as well since it can also become Vconn source at any point of time.

The following function can be used to send Discover Identity message to the cable,

          dpm_pd_command (port, DPM_CMD_INITIATE_CBL_DISCOVERY, NULL, app_cbl_dsc_callback)

Any other way to get that interrupt and decode,prepare and respond with GCRC & ACK

>> Can you please check if event APP_EVT_PKT_RCVD in app_evt_handler() function in app.c is getting triggered upon reception of SOP1 messages?

Best regards,

Pranava

Best regards,
Pranava
0 Likes
Reply
PrRe_3492461
New Contributor II

Pranava,

As I told in my previous reply, I'm not getting any interrupt related to SOP1 packets.

Also note that our product won't able to initiate VCONN.

So A Sink that is unable unable to source Vconn can't be able to get SOP1 Interrupts ??

Edit 1:

I want to add one more point here,

When SNK sources Vconn , when DUT(Src) initiates SOP1 Disc ID - Snk is able to get an interrupt .

But I'm unable to configure it to respond with ACK.

Can you help me out here.

Thanks & Regards,

Pranay.

0 Likes
Reply
PranavaYN
Moderator
Moderator

Hi Pranay,

When SNK sources Vconn , when DUT(Src) initiates SOP1 Disc ID - Snk is able to get an interrupt .

>>  Assuming that you are getting an APP_EVT_PKT_RCVD event in epp_evt_handler() function, you can decode the packet using the parameter void *dat contains pd_packet_extd_t* formatted received data. You can decode the same and use dpm_pd_command() to send ACK back.

Best regards,

Pranava

Best regards,
Pranava
0 Likes
Reply
PrRe_3492461
New Contributor II

Hi PranavaY_81​,

I'm able to decode the packet but responding with ACK is the concern now.

I'm preparing packet as :

  static dpm_pd_cmd_buf_t VDM_cmd_buf ;

  VDM_cmd_buf. cmd_sop = SOP_PRIME;

  VDM_cmd_buf. no_of_cmd_do = 1;

  VDM_cmd_buf. cmd_do[0]. std_vdm_hdr. cmd_type = CMD_TYPE_RESP_ACK;

  VDM_cmd_buf. cmd_do[0]. std_vdm_hdr. cmd = VDM_CMD_DSC_IDENTITY;

  VDM_cmd_buf. cmd_do[0]. std_vdm_hdr. vdm_type = VDM_TYPE_STRUCTURED;

  VDM_cmd_buf. cmd_do[0]. std_vdm_hdr. svid = 0xFF00;

  VDM_cmd_buf. cmd_do[0]. std_vdm_hdr. st_ver = 0x01;

  VDM_cmd_buf. cmd_do[0]. std_vdm_hdr. obj_pos = 0;

  dpm_pd_command(G_PORT0, DPM_CMD_SEND_VDM,&VDM_cmd_buf, NULL);

BY using above snippet I'm unable to respond with ACK. Is this correct ?

Is this snippet supposed to work ?

Let me know If I'm missing anything

Regards,

pranay.

0 Likes
Reply
PranavaYN
Moderator
Moderator

Hi Pranay,

As per PD 3.0 spec response to Discover ID message must contain the following data objects,

pastedImage_0.png

Please refer to the referenced section in the above snippet and form the response in FW accordingly.

Can you please check CC logs to confirm if the current packet you are sending is getting sent to Src.

Best regards,

Pranava

Best regards,
Pranava
0 Likes
Reply
PrRe_3492461
New Contributor II

Hi Pranava,

     Please find the below code snippet :

     static dpm_pd_cmd_buf_t VDM_cmd_buf ;

     /*Preparing header**/

    VDM_cmd_buf.cmd_sop = SOP_PRIME;

    VDM_cmd_buf.no_of_cmd_do = 5;

     /***Preparing data objects*/

    VDM_cmd_buf.cmd_do[0].std_vdm_hdr.vdm_type = VDM_TYPE_STRUCTURED;

    VDM_cmd_buf.cmd_do[0].std_vdm_hdr.cmd_type = CMD_TYPE_RESP_ACK;

    VDM_cmd_buf.cmd_do[0].std_vdm_hdr.obj_pos = 0;

    VDM_cmd_buf.cmd_do[0].std_vdm_hdr.st_ver = 0;

    VDM_cmd_buf.cmd_do[0].std_vdm_hdr.svid = 0xFF00;

    VDM_cmd_buf.cmd_do[0].std_vdm_hdr.cmd = VDM_CMD_DSC_IDENTITY;

   

    VDM_cmd_buf.cmd_do[1].std_id_hdr.mod_support = 0x00;

    VDM_cmd_buf.cmd_do[1].std_id_hdr.prod_type = 0x03;

    VDM_cmd_buf.cmd_do[1].std_id_hdr.usb_dev = 0x00;

    VDM_cmd_buf.cmd_do[1].std_id_hdr.usb_host = 0x00;

    VDM_cmd_buf.cmd_do[1].std_id_hdr.usb_vid = 0x062E;

   

    VDM_cmd_buf.cmd_do[2].val = 0x0000014D;

   

    VDM_cmd_buf.cmd_do[3].std_prod_vdo.bcd_dev = 0x0000;

    VDM_cmd_buf.cmd_do[3].std_prod_vdo.usb_pid = 0x0000;

   

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.usb_ss_sup = 0x02;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.vbus_thru_cbl = 0x01;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.vbus_cur = 0x02;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.ssrx2 = 0x00;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.ssrx1 = 0x00;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.sstx2 = 0x00;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.sstx1 = 0x00;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.cbl_term = 0x00;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.cbl_latency = 0x01;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.typec_abc = 0x02;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.cbl_fw_ver = 0x00;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.cbl_hw_ver = 0x00;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.typec_plug = 0x00;

    VDM_cmd_buf.cmd_do[4].std_cbl_vdo.sop_dp = 0x00;

   

    dpm_pd_command(G_PORT0, DPM_CMD_SEND_VDM,&VDM_cmd_buf, NULL);

I have gone through the PD spec and prepared response as per requirement and initiating it using the dpm_pd_command().

Let me know the method I'm following works or not to initiate a ACK response for SOP1 DiscID packet.

I have gone through the CC line capture but there was no response sent to SRC.

Below is the image from CC line capture, clearly these is no response sent to SRC

pastedImage_9.png

Let me know how to initiate a ACK response as a SNK by sourcing Vconn.

Thanks and regards,

Pranay.

0 Likes
Reply
PranavaYN
Moderator
Moderator

Pranay,

Can you please make sure that you are using dp_pd_command() as shown below,

/* Initiate the command. Keep trying until accepted. */

while (dpm_pd_command(port, DPM_CMD_SEND_VDM,

&cmd_buf, pd_command_cb) != CCG_STAT_SUCCESS)

{

/* Can implement a timeout/abort here. */

if (abort_cmd)

return false;

}

Best regards,

Pranava

Best regards,
Pranava
0 Likes
Reply
PrRe_3492461
New Contributor II

PranavaY_81,

I have tried this already,

return status is CCG_STAT_SUCCESS always but still there is no response ACK from SNK to SRC.

Can you please try this on your end and get back.

Regards,

Pranay.

0 Likes
Reply
PranavaYN
Moderator
Moderator

Hi Pranay,

Happy new year!

 

Sorry for the delay in response.

can you please try pd_prot_send_data_msg(0, SOP_PRIME, DATA_MSG_VDM, 5, (VDM_cmd_buf.cmd_do)) instead of dpm command to send the response.

 

Best regards,
Pranava
PrRe_3492461
New Contributor II

Thanks for the response,

Yes I tried this while you were gone. It worked.

Only limitation we've is getting an SOP1 interrupt when not acting as a Vconn Source.

Any idea how to achieve this ?

--Pranay.

0 Likes
Reply
PranavaYN
Moderator
Moderator

 

Hi Pranay,

Please check if this helps.

Define the following function in pd_mx_hal.c and call it in main()

void enable_sop_prime_rx(uint8_t port)
{
PPDSS_REGS_T pd = gl_pdss[port];
pd->rx_order_set_ctrl|= EN_PRIME_SOP_DET_VAL;
}

Similar thread - https://community.cypress.com/t5/USB-EZ-PD-Type-C/How-to-use-pd-phy-api-get-EMCA-message/td-p/225254

Best regards,
Pranava
0 Likes
Reply
PrRe_3492461
New Contributor II

Hi Pranava,

Thanks for the response.

I have tried the above method as you suggested, It didn't worked.

also tried

temp |= (EN_DEFAULT_SOP_DET_VAL | EN_RX_HARD_RESET_DET_VAL | EN_PRIME_SOP_DET_VAL);//grl edit

in file @pdss_mx_hal.c in function pd_phy_refresh_roles();

it didn't help either.

 

I have gone through the link you provided for similar thread, it is talking all about initiation SOP1 DIscID and GCRC when acting as a SRC. But as already said above our requirement is different.

Requirement :

CCG3PA as a SNK has to get an SOP1 interrupt ; Vconn role(shall not matter Src/Snk) shouldn't be a concern for responding and for getting respective interrupts.

Let me know how can I achieve this ?

 

--Pranay

0 Likes
Reply
PranavaYN
Moderator
Moderator

Pranay,

/* Configure RX_ORDER_SET_CTRL pd->rx_order_set_ctrl|= EN_PRIME_SOP_DET_VAL;*/
pd->rx_order_set_ctrl = RX_ORDER_SET_CTRL_CFG;
pd->rx_order_set_ctrl |= EN_PRIME_SOP_DET_VAL; // Include this line
/* Configure CRC_COUNTER reg */
pd->crc_counter = CRC_COUNTER_CFG;

Please include pd->rx_order_set_ctrl |= EN_PRIME_SOP_DET_VAL;  in pd_phy_init() function in above shown location.

temp |= EN_PRIME_SOP_DET_VAL;  // include this line
pd->rx_order_set_ctrl = temp;

temp = pd->tx_ctrl;
temp &= ~PDSS_TX_CTRL_GOODCRC_MSG_BITS_MASK;

Also include temp |= EN_PRIME_SOP_DET_VAL;   in pd_phy_refresh_roles() funtions.

 

Both are present in pdss_mx_hal.c file.

I tried this and I am able to get APP_EVT_PKT_RCVD event in app_evt_handler()

Best regards,
Pranava

View solution in original post

PrRe_3492461
New Contributor II

Hi @PranavaYN ,

Yes I'm able to get a interrupt now irrespective of ccg3pa Vconn role.

But have you tried responding Preparing ACK packet and responding with it ?

Because when I tried to respond using

dpm_pd_command(G_PORT0, DPM_CMD_SEND_VDM,&VDM_cmd_buf, NULL); and

pd_prot_send_data_msg(0, SOP_PRIME, DATA_MSG_VDM, 5, (VDM_cmd_buf.cmd_do));

It didn't work when ccg3pa role is Vconn Sink but same code works when ccg3pa role is Vconn Source and the return status is CCG_STAT_SUCCESS all the time.

 

I believe there is a dependency similar to previous solution for initiation as well.

Please verify the solution and let us know. You can use the ACK packet that I posted above in one of the reply.

Meanwhile I'll also try from our end.

 

Thanks and regards,

Pranay.

0 Likes
Reply
PranavaYN
Moderator
Moderator

Hi,

DPM running would automatically reject/ not send a PD message that it is not intended to. Since SOP1 and SOP11 messages are only to be sent by Vconn source you are not able to achieve this.

Alternatively, You can manage to  send such VDMs using PHY level APIs but they may create DPM level conflicts and therefore not recommended.

Best regards,
Pranava
0 Likes
Reply