@@ -1601,6 +1601,89 @@ int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable)
16011601}
16021602EXPORT_SYMBOL_GPL (cppc_set_epp_perf );
16031603
1604+ /**
1605+ * cppc_set_epp() - Write the EPP register.
1606+ * @cpu: CPU on which to write register.
1607+ * @epp_val: Value to write to the EPP register.
1608+ */
1609+ int cppc_set_epp (int cpu , u64 epp_val )
1610+ {
1611+ if (epp_val > CPPC_ENERGY_PERF_MAX )
1612+ return - EINVAL ;
1613+
1614+ return cppc_set_reg_val (cpu , ENERGY_PERF , epp_val );
1615+ }
1616+ EXPORT_SYMBOL_GPL (cppc_set_epp );
1617+
1618+ /**
1619+ * cppc_get_auto_act_window() - Read autonomous activity window register.
1620+ * @cpu: CPU from which to read register.
1621+ * @auto_act_window: Return address.
1622+ *
1623+ * According to ACPI 6.5, s8.4.6.1.6, the value read from the autonomous
1624+ * activity window register consists of two parts: a 7 bits value indicate
1625+ * significand and a 3 bits value indicate exponent.
1626+ */
1627+ int cppc_get_auto_act_window (int cpu , u64 * auto_act_window )
1628+ {
1629+ unsigned int exp ;
1630+ u64 val , sig ;
1631+ int ret ;
1632+
1633+ if (auto_act_window == NULL )
1634+ return - EINVAL ;
1635+
1636+ ret = cppc_get_reg_val (cpu , AUTO_ACT_WINDOW , & val );
1637+ if (ret )
1638+ return ret ;
1639+
1640+ sig = val & CPPC_AUTO_ACT_WINDOW_MAX_SIG ;
1641+ exp = (val >> CPPC_AUTO_ACT_WINDOW_SIG_BIT_SIZE ) & CPPC_AUTO_ACT_WINDOW_MAX_EXP ;
1642+ * auto_act_window = sig * int_pow (10 , exp );
1643+
1644+ return 0 ;
1645+ }
1646+ EXPORT_SYMBOL_GPL (cppc_get_auto_act_window );
1647+
1648+ /**
1649+ * cppc_set_auto_act_window() - Write autonomous activity window register.
1650+ * @cpu: CPU on which to write register.
1651+ * @auto_act_window: usec value to write to the autonomous activity window register.
1652+ *
1653+ * According to ACPI 6.5, s8.4.6.1.6, the value to write to the autonomous
1654+ * activity window register consists of two parts: a 7 bits value indicate
1655+ * significand and a 3 bits value indicate exponent.
1656+ */
1657+ int cppc_set_auto_act_window (int cpu , u64 auto_act_window )
1658+ {
1659+ /* The max value to store is 1270000000 */
1660+ u64 max_val = CPPC_AUTO_ACT_WINDOW_MAX_SIG * int_pow (10 , CPPC_AUTO_ACT_WINDOW_MAX_EXP );
1661+ int exp = 0 ;
1662+ u64 val ;
1663+
1664+ if (auto_act_window > max_val )
1665+ return - EINVAL ;
1666+
1667+ /*
1668+ * The max significand is 127, when auto_act_window is larger than
1669+ * 129, discard the precision of the last digit and increase the
1670+ * exponent by 1.
1671+ */
1672+ while (auto_act_window > CPPC_AUTO_ACT_WINDOW_SIG_CARRY_THRESH ) {
1673+ auto_act_window /= 10 ;
1674+ exp += 1 ;
1675+ }
1676+
1677+ /* For 128 and 129, cut it to 127. */
1678+ if (auto_act_window > CPPC_AUTO_ACT_WINDOW_MAX_SIG )
1679+ auto_act_window = CPPC_AUTO_ACT_WINDOW_MAX_SIG ;
1680+
1681+ val = (exp << CPPC_AUTO_ACT_WINDOW_SIG_BIT_SIZE ) + auto_act_window ;
1682+
1683+ return cppc_set_reg_val (cpu , AUTO_ACT_WINDOW , val );
1684+ }
1685+ EXPORT_SYMBOL_GPL (cppc_set_auto_act_window );
1686+
16041687/**
16051688 * cppc_get_auto_sel() - Read autonomous selection register.
16061689 * @cpu: CPU from which to read register.
0 commit comments