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

Add support for IPQ8064 SoC #22

Merged
merged 5 commits into from
Nov 8, 2023
Merged

Add support for IPQ8064 SoC #22

merged 5 commits into from
Nov 8, 2023

Conversation

Ansuel
Copy link
Contributor

@Ansuel Ansuel commented Jun 13, 2023

Add support for IPQ8064 SoC. All the debug vector are taken from old
pre-dt linux-msm source.

To correctly setup the debug oscillator, it's required to operate on 2
different clk, the CXO oscillator and the PDM clock. Then we operate ton
the CLK_TEST reg and we setup the required vector. With the use of
define we abstract everything for the high speed and the low speed
clocks.

The CXO oscillator runs at 25Mhz and a different xo_rate is required
than the current default one.

We can also test the 2 CPU speed and the current L2 speed using the APCS
CLK_DIAG reg. To test this we need to setup a special test vector in
CLK_TEST and then operate on the APCS reg.

For these special clock a different fixed_div is needed to be set and a
different sample_ticks is required to correctly calculate the reported
freq.

There is currently a bug (probably a hw bug) where the CPU clock of the
2 core is half broken, the correct clock is reported but only for one of
the core, the other core will always report a wrong clock. Operating on
the CPU mux makes the CLK_DIAG report the correct freq on one of the 2
core from the test vector.

Also the L2 clock seems to be half broken with high speed freq. (still
has to be confirmed and maybe it's the L2 HFPLL wrongly configured for
some reason and on high frequency > 1GHz reports not precise frequency)

Note that we currently use a fixed_div of 8 for these special clock.
This should be used only for ipq8064 v3 SoC but it was never found an
ipq8064 v1 SoC, where 2 should be used as fixed_div.

Signed-off-by: Christian Marangi [email protected]


Additional patch were required to the generic code to support this legacy SoC.
The testing vector I found are from an old linux-msm source before it was dropped.
The implementation is 1:1 to the apq8064 so I expect more vector can be supported but I prefer to stick to the original definition.

debugcc.c Outdated Show resolved Hide resolved
ipq8064.c Outdated Show resolved Hide resolved
ipq8064.c Outdated Show resolved Hide resolved
debugcc.c Outdated Show resolved Hide resolved
debugcc.c Outdated Show resolved Hide resolved
@Ansuel
Copy link
Contributor Author

Ansuel commented Jun 14, 2023

@lumag I tried to implement the suggestion of using additional leaf... Hope it's not a problem for the funny implementation of &gcc, 0x0. I wanted to keep more clear that there is a hs mux and a ls mux.

If required I can merge gcc and hs but I think it may be confusing since there are also test bus regs there... Chance for apq8064 to recycle this implementation if it does have test bus stuff defined.

Indeed with the current implementation the vector table is much cleaner

@lumag
Copy link
Collaborator

lumag commented Jun 14, 2023

My opinion is that it is much better now. I'd like to take a look at reworking the primary/leaf muxes, but this will take some time (and ipq8064 serves a perfect example here). apq8064 is even more complex, it has separate mm muxes.

@lumag
Copy link
Collaborator

lumag commented Nov 7, 2023

@Ansuel we have landed support for chained muxes. Could you please rebased your patches on top of the current master branch? We can work on merging it afterwards.

@Ansuel
Copy link
Contributor Author

Ansuel commented Nov 7, 2023

Sure!

Unsigned long have a different size in 32 bit system and this cause the
malfunction of debugcc returning wrong frequency. Use 64bit unsigned int
to correctly support 32 bit system and provide correct frequency.

Signed-off-by: Christian Marangi <[email protected]>
Some xo require special value to set it to /4 divisor. Introduce
xo_div4_val to handle this special implementation.

Signed-off-by: Christian Marangi <[email protected]>
Some device have a different rate for the xo debug oscillator. Add
support for defining custom xo rate in the primary debug mux.

Signed-off-by: Christian Marangi <[email protected]>
@Ansuel
Copy link
Contributor Author

Ansuel commented Nov 7, 2023

@lumag rebased and tested. Values match the old implementation and very nice code cleanup with the new parent way!

ipq8064.c Outdated Show resolved Hide resolved
Add convenient macro GENMASK to calculate masks from bits similar to how
it's implemented in kernel linux tools.

This is useful to better describe some specific define instead of using
comments and raw HEX values.

Signed-off-by: Christian Marangi <[email protected]>
Add support for IPQ8064 SoC. All the debug vector are taken from old
pre-dt linux-msm source.

To correctly setup the debug oscillator, it's required to operate on 2
different clk, the CXO oscillator and the PDM clock. Then we operate ton
the CLK_TEST reg and we setup the required vector. With the use of
define we abstract everything for the high speed and the low speed
clocks.

The CXO oscillator runs at 25Mhz and a different xo_rate is required
than the current default one.

We can also test the 2 CPU speed and the current L2 speed using the APCS
CLK_DIAG reg. To test this we need to setup a special test vector in
CLK_TEST and then operate on the APCS reg.

For these special clock a different fixed_div is needed to be set.

There is currently a bug (probably a hw bug) where the CPU clock of the
2 core is half broken, the correct clock is reported but only for one of
the core, the other core will always report a wrong clock. Operating on
the CPU mux makes the CLK_DIAG report the correct freq on one of the 2
core from the test vector.

Also the L2 clock seems to be half broken with high speed freq. (still
has to be confirmed and maybe it's the L2 HFPLL wrongly configured for
some reason and on high frequency > 1GHz reports not precise frequency)

Note that we currently use a fixed_div of 8 for these special clock.
This should be used only for ipq8064 v3 SoC but it was never found an
ipq8064 v1 SoC, where 2 should be used as fixed_div.

Signed-off-by: Christian Marangi <[email protected]>
@Ansuel
Copy link
Contributor Author

Ansuel commented Nov 8, 2023

@lumag sorry for changing this again... but since it's 99% ready I also decided to add the GENMASK commit and switch to it. (took the define from linux kernel tools)

@lumag
Copy link
Collaborator

lumag commented Nov 8, 2023

@Ansuel no problem. I agree with you, GENMASK makes it better.

@lumag lumag merged commit d15bea7 into linux-msm:master Nov 8, 2023
12 checks passed
@lumag
Copy link
Collaborator

lumag commented Nov 8, 2023

... and merged. Thanks a lot!

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.

2 participants