Skip to content

A7-A11, T2 SoC cpufreq support#439

Merged
svenpeter42 merged 5 commits intoAsahiLinux:mainfrom
HoolockLinux:cpufreq-legacy
Feb 23, 2025
Merged

A7-A11, T2 SoC cpufreq support#439
svenpeter42 merged 5 commits intoAsahiLinux:mainfrom
HoolockLinux:cpufreq-legacy

Conversation

@asdfugil
Copy link
Contributor

@asdfugil asdfugil commented Feb 8, 2025

This adds the tunables required for cpufreq to work properly on A7-A11, T2 SoCs, most prominently a register poke to enable voltage changes when the state is changed, as iBoot leaves the voltage controls disabled.

@asdfugil
Copy link
Contributor Author

this is also a requirement for proper operation of the proxy with the physical uart, as the cpu is too slow otherwise

Some power domains are not referenced by other nodes through clock-gates
or power-gates, so this is needed.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
This is the 64-bit variant of poll32().

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
@asdfugil asdfugil force-pushed the cpufreq-legacy branch 2 times, most recently from ad865f8 to 9014dce Compare February 23, 2025 14:14
@asdfugil
Copy link
Contributor Author

Changes:

  • Switch to switch (chip_id) for chip-specific operations, this removes all the comparison operations.

@asdfugil asdfugil force-pushed the cpufreq-legacy branch 2 times, most recently from c126662 to f10335f Compare February 23, 2025 14:20
src/cpufreq.c Outdated
if (pstate_reg_to_pstate(val) != pstate) {
switch (chip_id) {
case S5L8960X:
case T7000 ... T7001:
Copy link
Member

Choose a reason for hiding this comment

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

This is now just hiding the comparisons that I'd like to avoid. Please get rid of the ... stuff as well and just open code all the chip_ids here.

case S8000 ... T8103:
case T6000 ... T6002:
val &= ~CLUSTER_PSTATE_DESIRED2;
val |= CLUSTER_PSTATE_SET | FIELD_PREP(CLUSTER_PSTATE_DESIRED2, pstate);
Copy link
Member

Choose a reason for hiding this comment

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

please add a // fallthrough comment here

src/cpufreq.c Outdated
case S5L8960X:
write32(pmgr_reg + PMGR_VOLTAGE_CTL_OFF_S5L8960X, 1);
break;
case T7000 ... T7001:
Copy link
Member

Choose a reason for hiding this comment

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

same as above: please don't rely on hidden comparisons here and just enumerate all chips

src/cpufreq.c Outdated
break;
case T8103 ... T8122:
case T6000 ... T6034:
default:
Copy link
Member

Choose a reason for hiding this comment

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

Please also separate out the default case and just print that the chip is unsupported

@asdfugil asdfugil force-pushed the cpufreq-legacy branch 6 times, most recently from 5af344c to 07ac6ce Compare February 23, 2025 14:50
The existing code is already confusing as is and support for more chips with
different requirements will be added, which would make the code even more
confusing. Instead, switch to a hardcoded list of chip_id's for operations
that are chip-specific or will be chip-speciifc.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
cpufreq support for Apple A9 will be added. It requires 64-bit access on the
CLUSTER_PSTATE register.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
- A7-A8X uses 3 bits only for pstate, and PS1 mask is GENMASK(24, 22)

- Add tunables, mainly the voltage control register in PMGR (iBoot boots us
with voltage changes seemingly disabled, with obvious disastrous outcome
trying to switch to high P-states)

- Skip writes to offset 0x4xxxx from cluster->base for A7-A11, T2. The range
starting from 0x40000 from cluster->base does not exist in ADT /arm-io/pmgr,
so it probably does not exist for those older chips. This includes the
0x440f8 and ppt-thrtl writes.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
@asdfugil
Copy link
Contributor Author

asdfugil commented Feb 23, 2025

Changes:

  • Remove all hidden comparison using switch (chip_id), including the existing ones, now every supported chip is explicitly stated.
    • Don't "support" T8122 and T6034
  • Use fallthrough comment for fallthroughs
  • Print chip is unsupported in default cases

@svenpeter42 svenpeter42 merged commit c49bc2c into AsahiLinux:main Feb 23, 2025
12 checks passed
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