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.
pull/12394/head
midd 2020-02-06 14:16:41 -08:00
parent 5f496a694c
commit df5ac6483b
16 changed files with 88 additions and 68 deletions

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -1080,7 +1080,12 @@ void SDIO_DisableSdClk(void)
void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz) void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz)
{ {
uint16_t u16Div; uint16_t u16Div;
u16Div = Cy_SysClk_ClkPeriGetFrequency() / u32SdClkFreqHz; /*
* The UDB SDIO implemenation has a extra divider internally that divides the input clock to the UDB
* by 2. The desired clock frequency is hence intentionally multiplied by 2 in order to get the required
* SDIO operating frequency.
*/
u16Div = Cy_SysClk_ClkPeriGetFrequency() / (2 * u32SdClkFreqHz);
Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1)); Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1));
} }

View File

@ -7,7 +7,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -1080,7 +1080,12 @@ void SDIO_DisableSdClk(void)
void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz) void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz)
{ {
uint16_t u16Div; uint16_t u16Div;
u16Div = Cy_SysClk_ClkPeriGetFrequency() / u32SdClkFreqHz; /*
* The UDB SDIO implemenation has a extra divider internally that divides the input clock to the UDB
* by 2. The desired clock frequency is hence intentionally multiplied by 2 in order to get the required
* SDIO operating frequency.
*/
u16Div = Cy_SysClk_ClkPeriGetFrequency() / (2 * u32SdClkFreqHz);
Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1)); Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1));
} }

View File

@ -7,7 +7,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -1080,7 +1080,12 @@ void SDIO_DisableSdClk(void)
void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz) void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz)
{ {
uint16_t u16Div; uint16_t u16Div;
u16Div = Cy_SysClk_ClkPeriGetFrequency() / u32SdClkFreqHz; /*
* The UDB SDIO implemenation has a extra divider internally that divides the input clock to the UDB
* by 2. The desired clock frequency is hence intentionally multiplied by 2 in order to get the required
* SDIO operating frequency.
*/
u16Div = Cy_SysClk_ClkPeriGetFrequency() / (2 * u32SdClkFreqHz);
Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1)); Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1));
} }

View File

@ -7,7 +7,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -1080,7 +1080,12 @@ void SDIO_DisableSdClk(void)
void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz) void SDIO_SetSdClkFrequency(uint32_t u32SdClkFreqHz)
{ {
uint16_t u16Div; uint16_t u16Div;
u16Div = Cy_SysClk_ClkPeriGetFrequency() / u32SdClkFreqHz; /*
* The UDB SDIO implemenation has a extra divider internally that divides the input clock to the UDB
* by 2. The desired clock frequency is hence intentionally multiplied by 2 in order to get the required
* SDIO operating frequency.
*/
u16Div = Cy_SysClk_ClkPeriGetFrequency() / (2 * u32SdClkFreqHz);
Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1)); Cy_SysClk_PeriphSetDivider(SDIO_HOST_Internal_Clock_DIV_TYPE, SDIO_HOST_Internal_Clock_DIV_NUM, (u16Div-1));
} }

View File

@ -7,7 +7,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -6,7 +6,7 @@
* *
******************************************************************************** ********************************************************************************
* \copyright * \copyright
* Copyright 2016-2019 Cypress Semiconductor Corporation * Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");