Skip to content

Commit df5ac64

Browse files
committed
Added a multiplied by 2 in the SDIO clock divider calculation to account for internal UDB divider.
Note: Fixes issues with intermittent WiFi firmware load failures on CY8CKIT_062_WIFI_BT, CYW943012P6EVB_01, CYW9P62S1_43012EVB_01, CYW9P62S1_43438EVB_01.
1 parent 5f496a6 commit df5ac64

File tree

16 files changed

+88
-68
lines changed

16 files changed

+88
-68
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/SDIO_HOST/SDIO_HOST.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
********************************************************************************
88
* \copyright
9-
* Copyright 2016-2019 Cypress Semiconductor Corporation
9+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1010
* SPDX-License-Identifier: Apache-2.0
1111
*
1212
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -111,7 +111,7 @@ cy_en_syspm_status_t SDIO_DeepSleepCallback(cy_stc_syspm_callback_params_t *para
111111
CY_UNUSED_PARAMETER(params);
112112
cy_en_syspm_status_t status = CY_SYSPM_FAIL;
113113

114-
switch (mode)
114+
switch (mode)
115115
{
116116
case CY_SYSPM_CHECK_READY:
117117
case CY_SYSPM_CHECK_FAIL:
@@ -656,7 +656,7 @@ en_sdio_result_t SDIO_SendCommandAndWait(stc_sdio_cmd_t *pstcCmd)
656656
cy_rslt_t result;
657657

658658
/* Initialize the semaphore. This is not done in init because init is called
659-
* in interrupt thread. cy_rtos_init_semaphore call is prohibited in
659+
* in interrupt thread. cy_rtos_init_semaphore call is prohibited in
660660
* interrupt thread.
661661
*/
662662
if(!sema_initialized)
@@ -770,16 +770,16 @@ en_sdio_result_t SDIO_SendCommandAndWait(stc_sdio_cmd_t *pstcCmd)
770770

771771
#ifdef CY_RTOS_AWARE
772772
/* Wait for the transfer to finish.
773-
* Acquire semaphore and wait until it will be released
773+
* Acquire semaphore and wait until it will be released
774774
* in SDIO_IRQ:
775-
* 1. sdio_transfer_finished_semaphore count is equal to
776-
* zero. cy_rtos_get_semaphore waits until semaphore
777-
* count is increased by cy_rtos_set_semaphore() in
775+
* 1. sdio_transfer_finished_semaphore count is equal to
776+
* zero. cy_rtos_get_semaphore waits until semaphore
777+
* count is increased by cy_rtos_set_semaphore() in
778778
* SDIO_IRQ.
779-
* 2. The cy_rtos_set_semaphore() increases
779+
* 2. The cy_rtos_set_semaphore() increases
780780
* sdio_transfer_finished_semaphore count.
781-
* 3. The cy_rtos_get_semaphore() function decreases
782-
* sdio_transfer_finished_semaphore back to zero
781+
* 3. The cy_rtos_get_semaphore() function decreases
782+
* sdio_transfer_finished_semaphore back to zero
783783
* and exit. Or timeout occurs
784784
*/
785785
result = cy_rtos_get_semaphore( &sdio_transfer_finished_semaphore, 10, false );
@@ -1080,7 +1080,12 @@ void SDIO_DisableSdClk(void)
10801080
void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz)
10811081
{
10821082
uint16_t u16Div;
1083-
u16Div = Cy_SysClk_ClkPeriGetFrequency() / u32SdClkFreqHz;
1083+
/*
1084+
* The UDB SDIO implemenation has a extra divider internally that divides the input clock to the UDB
1085+
* by 2. The desired clock frequency is hence intentionally multiplied by 2 in order to get the required
1086+
* SDIO operating frequency.
1087+
*/
1088+
u16Div = Cy_SysClk_ClkPeriGetFrequency() / (2 * u32SdClkFreqHz);
10841089
Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1));
10851090
}
10861091

@@ -1247,10 +1252,10 @@ void SDIO_IRQ(void)
12471252
{
12481253
pfnCardInt_count++;
12491254
}
1250-
1255+
12511256
/* Execute card interrupt callback if neccesary */
12521257
if (0 != pfnCardInt_count)
1253-
{
1258+
{
12541259
if (NULL != gstcInternalData.pstcCallBacks.pfnCardIntCb)
12551260
{
12561261
gstcInternalData.pstcCallBacks.pfnCardIntCb();
@@ -1277,7 +1282,7 @@ void SDIO_IRQ(void)
12771282
/* CRC was bad, set the flag */
12781283
gstcInternalData.stcEvents.u8CRCError++;
12791284
}
1280-
1285+
12811286
/* Set the done flag */
12821287

12831288
#ifdef CY_RTOS_AWARE

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/SDIO_HOST/SDIO_HOST.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
********************************************************************************
99
* \copyright
10-
* Copyright 2016-2019 Cypress Semiconductor Corporation
10+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1111
* SPDX-License-Identifier: Apache-2.0
1212
*
1313
* Licensed under the Apache License, Version 2.0 (the "License");

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/SDIO_HOST/SDIO_HOST_cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
********************************************************************************
88
* \copyright
9-
* Copyright 2016-2019 Cypress Semiconductor Corporation
9+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1010
* SPDX-License-Identifier: Apache-2.0
1111
*
1212
* Licensed under the Apache License, Version 2.0 (the "License");

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/SDIO_HOST/SDIO_HOST_cfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
********************************************************************************
88
* \copyright
9-
* Copyright 2016-2019 Cypress Semiconductor Corporation
9+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1010
* SPDX-License-Identifier: Apache-2.0
1111
*
1212
* Licensed under the Apache License, Version 2.0 (the "License");

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/SDIO_HOST/SDIO_HOST.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
********************************************************************************
88
* \copyright
9-
* Copyright 2016-2019 Cypress Semiconductor Corporation
9+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1010
* SPDX-License-Identifier: Apache-2.0
1111
*
1212
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -111,7 +111,7 @@ cy_en_syspm_status_t SDIO_DeepSleepCallback(cy_stc_syspm_callback_params_t *para
111111
CY_UNUSED_PARAMETER(params);
112112
cy_en_syspm_status_t status = CY_SYSPM_FAIL;
113113

114-
switch (mode)
114+
switch (mode)
115115
{
116116
case CY_SYSPM_CHECK_READY:
117117
case CY_SYSPM_CHECK_FAIL:
@@ -656,7 +656,7 @@ en_sdio_result_t SDIO_SendCommandAndWait(stc_sdio_cmd_t *pstcCmd)
656656
cy_rslt_t result;
657657

658658
/* Initialize the semaphore. This is not done in init because init is called
659-
* in interrupt thread. cy_rtos_init_semaphore call is prohibited in
659+
* in interrupt thread. cy_rtos_init_semaphore call is prohibited in
660660
* interrupt thread.
661661
*/
662662
if(!sema_initialized)
@@ -770,16 +770,16 @@ en_sdio_result_t SDIO_SendCommandAndWait(stc_sdio_cmd_t *pstcCmd)
770770

771771
#ifdef CY_RTOS_AWARE
772772
/* Wait for the transfer to finish.
773-
* Acquire semaphore and wait until it will be released
773+
* Acquire semaphore and wait until it will be released
774774
* in SDIO_IRQ:
775-
* 1. sdio_transfer_finished_semaphore count is equal to
776-
* zero. cy_rtos_get_semaphore waits until semaphore
777-
* count is increased by cy_rtos_set_semaphore() in
775+
* 1. sdio_transfer_finished_semaphore count is equal to
776+
* zero. cy_rtos_get_semaphore waits until semaphore
777+
* count is increased by cy_rtos_set_semaphore() in
778778
* SDIO_IRQ.
779-
* 2. The cy_rtos_set_semaphore() increases
779+
* 2. The cy_rtos_set_semaphore() increases
780780
* sdio_transfer_finished_semaphore count.
781-
* 3. The cy_rtos_get_semaphore() function decreases
782-
* sdio_transfer_finished_semaphore back to zero
781+
* 3. The cy_rtos_get_semaphore() function decreases
782+
* sdio_transfer_finished_semaphore back to zero
783783
* and exit. Or timeout occurs
784784
*/
785785
result = cy_rtos_get_semaphore( &sdio_transfer_finished_semaphore, 10, false );
@@ -1080,7 +1080,12 @@ void SDIO_DisableSdClk(void)
10801080
void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz)
10811081
{
10821082
uint16_t u16Div;
1083-
u16Div = Cy_SysClk_ClkPeriGetFrequency() / u32SdClkFreqHz;
1083+
/*
1084+
* The UDB SDIO implemenation has a extra divider internally that divides the input clock to the UDB
1085+
* by 2. The desired clock frequency is hence intentionally multiplied by 2 in order to get the required
1086+
* SDIO operating frequency.
1087+
*/
1088+
u16Div = Cy_SysClk_ClkPeriGetFrequency() / (2 * u32SdClkFreqHz);
10841089
Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1));
10851090
}
10861091

@@ -1247,10 +1252,10 @@ void SDIO_IRQ(void)
12471252
{
12481253
pfnCardInt_count++;
12491254
}
1250-
1255+
12511256
/* Execute card interrupt callback if neccesary */
12521257
if (0 != pfnCardInt_count)
1253-
{
1258+
{
12541259
if (NULL != gstcInternalData.pstcCallBacks.pfnCardIntCb)
12551260
{
12561261
gstcInternalData.pstcCallBacks.pfnCardIntCb();
@@ -1277,7 +1282,7 @@ void SDIO_IRQ(void)
12771282
/* CRC was bad, set the flag */
12781283
gstcInternalData.stcEvents.u8CRCError++;
12791284
}
1280-
1285+
12811286
/* Set the done flag */
12821287

12831288
#ifdef CY_RTOS_AWARE

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/SDIO_HOST/SDIO_HOST.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
********************************************************************************
99
* \copyright
10-
* Copyright 2016-2019 Cypress Semiconductor Corporation
10+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1111
* SPDX-License-Identifier: Apache-2.0
1212
*
1313
* Licensed under the Apache License, Version 2.0 (the "License");

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/SDIO_HOST/SDIO_HOST_cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
********************************************************************************
88
* \copyright
9-
* Copyright 2016-2019 Cypress Semiconductor Corporation
9+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1010
* SPDX-License-Identifier: Apache-2.0
1111
*
1212
* Licensed under the Apache License, Version 2.0 (the "License");

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW943012P6EVB_01/SDIO_HOST/SDIO_HOST_cfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
********************************************************************************
88
* \copyright
9-
* Copyright 2016-2019 Cypress Semiconductor Corporation
9+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1010
* SPDX-License-Identifier: Apache-2.0
1111
*
1212
* Licensed under the Apache License, Version 2.0 (the "License");

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW9P62S1_43012EVB_01/SDIO_HOST/SDIO_HOST.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
********************************************************************************
88
* \copyright
9-
* Copyright 2016-2019 Cypress Semiconductor Corporation
9+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1010
* SPDX-License-Identifier: Apache-2.0
1111
*
1212
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -111,7 +111,7 @@ cy_en_syspm_status_t SDIO_DeepSleepCallback(cy_stc_syspm_callback_params_t *para
111111
CY_UNUSED_PARAMETER(params);
112112
cy_en_syspm_status_t status = CY_SYSPM_FAIL;
113113

114-
switch (mode)
114+
switch (mode)
115115
{
116116
case CY_SYSPM_CHECK_READY:
117117
case CY_SYSPM_CHECK_FAIL:
@@ -656,7 +656,7 @@ en_sdio_result_t SDIO_SendCommandAndWait(stc_sdio_cmd_t *pstcCmd)
656656
cy_rslt_t result;
657657

658658
/* Initialize the semaphore. This is not done in init because init is called
659-
* in interrupt thread. cy_rtos_init_semaphore call is prohibited in
659+
* in interrupt thread. cy_rtos_init_semaphore call is prohibited in
660660
* interrupt thread.
661661
*/
662662
if(!sema_initialized)
@@ -770,16 +770,16 @@ en_sdio_result_t SDIO_SendCommandAndWait(stc_sdio_cmd_t *pstcCmd)
770770

771771
#ifdef CY_RTOS_AWARE
772772
/* Wait for the transfer to finish.
773-
* Acquire semaphore and wait until it will be released
773+
* Acquire semaphore and wait until it will be released
774774
* in SDIO_IRQ:
775-
* 1. sdio_transfer_finished_semaphore count is equal to
776-
* zero. cy_rtos_get_semaphore waits until semaphore
777-
* count is increased by cy_rtos_set_semaphore() in
775+
* 1. sdio_transfer_finished_semaphore count is equal to
776+
* zero. cy_rtos_get_semaphore waits until semaphore
777+
* count is increased by cy_rtos_set_semaphore() in
778778
* SDIO_IRQ.
779-
* 2. The cy_rtos_set_semaphore() increases
779+
* 2. The cy_rtos_set_semaphore() increases
780780
* sdio_transfer_finished_semaphore count.
781-
* 3. The cy_rtos_get_semaphore() function decreases
782-
* sdio_transfer_finished_semaphore back to zero
781+
* 3. The cy_rtos_get_semaphore() function decreases
782+
* sdio_transfer_finished_semaphore back to zero
783783
* and exit. Or timeout occurs
784784
*/
785785
result = cy_rtos_get_semaphore( &sdio_transfer_finished_semaphore, 10, false );
@@ -1080,7 +1080,12 @@ void SDIO_DisableSdClk(void)
10801080
void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz)
10811081
{
10821082
uint16_t u16Div;
1083-
u16Div = Cy_SysClk_ClkPeriGetFrequency() / u32SdClkFreqHz;
1083+
/*
1084+
* The UDB SDIO implemenation has a extra divider internally that divides the input clock to the UDB
1085+
* by 2. The desired clock frequency is hence intentionally multiplied by 2 in order to get the required
1086+
* SDIO operating frequency.
1087+
*/
1088+
u16Div = Cy_SysClk_ClkPeriGetFrequency() / (2 * u32SdClkFreqHz);
10841089
Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1));
10851090
}
10861091

@@ -1247,10 +1252,10 @@ void SDIO_IRQ(void)
12471252
{
12481253
pfnCardInt_count++;
12491254
}
1250-
1255+
12511256
/* Execute card interrupt callback if neccesary */
12521257
if (0 != pfnCardInt_count)
1253-
{
1258+
{
12541259
if (NULL != gstcInternalData.pstcCallBacks.pfnCardIntCb)
12551260
{
12561261
gstcInternalData.pstcCallBacks.pfnCardIntCb();
@@ -1277,7 +1282,7 @@ void SDIO_IRQ(void)
12771282
/* CRC was bad, set the flag */
12781283
gstcInternalData.stcEvents.u8CRCError++;
12791284
}
1280-
1285+
12811286
/* Set the done flag */
12821287

12831288
#ifdef CY_RTOS_AWARE

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW9P62S1_43012EVB_01/SDIO_HOST/SDIO_HOST.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
********************************************************************************
99
* \copyright
10-
* Copyright 2016-2019 Cypress Semiconductor Corporation
10+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1111
* SPDX-License-Identifier: Apache-2.0
1212
*
1313
* Licensed under the Apache License, Version 2.0 (the "License");

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW9P62S1_43012EVB_01/SDIO_HOST/SDIO_HOST_cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
********************************************************************************
88
* \copyright
9-
* Copyright 2016-2019 Cypress Semiconductor Corporation
9+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1010
* SPDX-License-Identifier: Apache-2.0
1111
*
1212
* Licensed under the Apache License, Version 2.0 (the "License");

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYW9P62S1_43012EVB_01/SDIO_HOST/SDIO_HOST_cfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
********************************************************************************
88
* \copyright
9-
* Copyright 2016-2019 Cypress Semiconductor Corporation
9+
* Copyright 2016-2020 Cypress Semiconductor Corporation
1010
* SPDX-License-Identifier: Apache-2.0
1111
*
1212
* Licensed under the Apache License, Version 2.0 (the "License");

0 commit comments

Comments
 (0)