Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devices: MIMX8ML8: fixes for clock gating/ungating #229

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LaurentiuM1234
Copy link
Contributor

No description provided.

The AUDIOMIX_TUPLE_ROOT() macro returns the ID of the root clock,
while CCM_TUPLE_ROOT() returns the address of the register corresponding
to the root clock. As such, the 'rootClk' variable can't be directly used
with CCM_REG_CLR(), which expects the address of the CCM register for the
root clock.

Fix this by:

	1) Introducing 2 new macros: CCM_TUPLE_ROOT_ID() and
	CCM_TUPLE_ROOT_ID(), which extract the ID of the root clock.
	This way, we can use the resulting ID in the same way for clocks
	managed by the AUDIOMIX block control and the CCM.

	2) Translating the resulting root clock ID from step 1 to a
	CCM register.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
According to the TRM, the parent of the SAI3 bus clock is not
SAI3_ROOT, but AUDIO_AHB_CLK_ROOT. As such, the currently used
root parent ID (77) is wrong.

Furthermore, CLOCK_EnableClock() and CLOCK_DisableClock() also
attempt to ungate/gate the root parent of the AUDIOMIX clock.
Since AUDIO_AHB_CLK_ROOT is the parent of multiple SAI bus clocks,
allowing it to be gated during CLOCK_DisableClock() is not safe.

As such, set the parent of SAI3 bus clock to 0xFFFF. This way,
CLOCK_DisableClock() and CLOCK_EnableClock() will not attempt
to gate/ungate it. This means that gating/ungating AUDIO_AHB_CLK_ROOT
will have to be performed explicitly.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
@@ -635,7 +636,7 @@ typedef enum _clock_ip_name
kCLOCK_Sai3_Mclk3 = AUDIOMIX_TUPLE(0U, 11U, 0xFFFF), /*!< SAI3 MCLK3 clock gate */
kCLOCK_Sai3_Mclk2 = AUDIOMIX_TUPLE(0U, 10U, 0xFFFF), /*!< SAI3 MCLK2 clock gate */
kCLOCK_Sai3_Mclk1 = AUDIOMIX_TUPLE(0U, 9U, 0xFFFF), /*!< SAI3 MCLK1 clock gate */
kCLOCK_Sai3 = AUDIOMIX_TUPLE(0U, 8U, 77U), /*!< SAI3 clock gate */
kCLOCK_Sai3 = AUDIOMIX_TUPLE(0U, 8U, 0xFFFF), /*!< SAI3 clock gate */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Laurentiu,

From RM, sai3's clock root id is 77, any reason to modify it to 0xFFFF? if it's 0xFFFF, it means that sai3 doesn't have clock root.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAI3 (IPG)'s root is not SAI3_CLK_ROOT, but rather AUDIO_AHB_CLK_ROOT (34) so 77 is wrong.

We're setting it to 0xFFFF because we don't want CLOCK_EnableClock() and CLOCK_DisableClock() to touch AUDIO_AHB_CLK_ROOT as it's used by multiple SAI instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants