forked from Minki/linux
Immutable branch for QCOM Geni patches
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJbqGxAAAoJEFKiBbHx2RXVIYwQAIzgqbC7mt4dwLB22OW1PCwG f/cFBEAegy9tWMr1cMAR0u+6mXIYZ3kxgTYCZN665Qj44TwfJKeks15ysE+NaWog gOKr40cedtOoIyNqy0D3JmUm1lB0x1bmD9E0NA8eAytHm0/29Ab4Xf7k1S77K7Sl 6q+Bf/VnnxwFtQxvAd0dgpzIjptcOMfsJHt+O+PnyMONVb/aPFdQuA1MqSKO0Uwa kV7l1HRBg+sR6DlVvpx3b3LX73o9WDZfVziXvACb7tcVXuS4Z2BZ40k0Q8dMGeHJ dBcS7uDiyZ/PB7WqIqTDnS80lQAJkwiOY/pvwPYsjVxj4Ic+5YB4SUj6gSKwj46s k5pUvPZbcXaPri4klKGzMD7z8RfUjgWjg7bZTzrqE0VQCq7BxSUpeqkZ5Wc7GVro B2Mw9Q/0fAKMnP3wLpvp9roG6Pc135dm+RKHEsUZhNkOMnJRyKKgXs2AMV4ukhJk s4rcmADa8F6Vo0hIEUyHU/SzodJGFrQLDSmvzatmFiUgfHHlOysr6TCyldbBxBQz Tq40Jqz6oIl3bllt8dF7gEzh0bLlZnX88qFTuZJBV26IOfVRWBUfmZRs01Ls+0ba CcZtaKE9jRNFR3Eb6C86Nr3ua2TnoW+AnbG/0jySuGs+lOwHMA9fVl1Y6V3F0aPf QUvL/X6IXvneZ00wIaEg =tUbu -----END PGP SIGNATURE----- Merge tag 'qcom-geni-immutable-for-mark-brown' into drivers-for-4.20-final Immutable branch for QCOM Geni patches
This commit is contained in:
commit
bbd4b28bb8
@ -513,7 +513,7 @@ EXPORT_SYMBOL(geni_se_resources_on);
|
||||
*/
|
||||
int geni_se_clk_tbl_get(struct geni_se *se, unsigned long **tbl)
|
||||
{
|
||||
unsigned long freq = 0;
|
||||
long freq = 0;
|
||||
int i;
|
||||
|
||||
if (se->clk_perf_tbl) {
|
||||
@ -529,7 +529,7 @@ int geni_se_clk_tbl_get(struct geni_se *se, unsigned long **tbl)
|
||||
|
||||
for (i = 0; i < MAX_CLK_PERF_LEVEL; i++) {
|
||||
freq = clk_round_rate(se->clk, freq + 1);
|
||||
if (!freq || freq == se->clk_perf_tbl[i - 1])
|
||||
if (freq <= 0 || freq == se->clk_perf_tbl[i - 1])
|
||||
break;
|
||||
se->clk_perf_tbl[i] = freq;
|
||||
}
|
||||
@ -544,16 +544,17 @@ EXPORT_SYMBOL(geni_se_clk_tbl_get);
|
||||
* @se: Pointer to the concerned serial engine.
|
||||
* @req_freq: Requested clock frequency.
|
||||
* @index: Index of the resultant frequency in the table.
|
||||
* @res_freq: Resultant frequency which matches or is closer to the
|
||||
* requested frequency.
|
||||
* @res_freq: Resultant frequency of the source clock.
|
||||
* @exact: Flag to indicate exact multiple requirement of the requested
|
||||
* frequency.
|
||||
*
|
||||
* This function is called by the protocol drivers to determine the matching
|
||||
* or exact multiple of the requested frequency, as provided by the serial
|
||||
* engine clock in order to meet the performance requirements. If there is
|
||||
* no matching or exact multiple of the requested frequency found, then it
|
||||
* selects the closest floor frequency, if exact flag is not set.
|
||||
* This function is called by the protocol drivers to determine the best match
|
||||
* of the requested frequency as provided by the serial engine clock in order
|
||||
* to meet the performance requirements.
|
||||
*
|
||||
* If we return success:
|
||||
* - if @exact is true then @res_freq / <an_integer> == @req_freq
|
||||
* - if @exact is false then @res_freq / <an_integer> <= @req_freq
|
||||
*
|
||||
* Return: 0 on success, standard Linux error codes on failure.
|
||||
*/
|
||||
@ -564,6 +565,9 @@ int geni_se_clk_freq_match(struct geni_se *se, unsigned long req_freq,
|
||||
unsigned long *tbl;
|
||||
int num_clk_levels;
|
||||
int i;
|
||||
unsigned long best_delta;
|
||||
unsigned long new_delta;
|
||||
unsigned int divider;
|
||||
|
||||
num_clk_levels = geni_se_clk_tbl_get(se, &tbl);
|
||||
if (num_clk_levels < 0)
|
||||
@ -572,18 +576,21 @@ int geni_se_clk_freq_match(struct geni_se *se, unsigned long req_freq,
|
||||
if (num_clk_levels == 0)
|
||||
return -EINVAL;
|
||||
|
||||
*res_freq = 0;
|
||||
best_delta = ULONG_MAX;
|
||||
for (i = 0; i < num_clk_levels; i++) {
|
||||
if (!(tbl[i] % req_freq)) {
|
||||
divider = DIV_ROUND_UP(tbl[i], req_freq);
|
||||
new_delta = req_freq - tbl[i] / divider;
|
||||
if (new_delta < best_delta) {
|
||||
/* We have a new best! */
|
||||
*index = i;
|
||||
*res_freq = tbl[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(*res_freq) || ((tbl[i] > *res_freq) &&
|
||||
(tbl[i] < req_freq))) {
|
||||
*index = i;
|
||||
*res_freq = tbl[i];
|
||||
/* If the new best is exact then we're done */
|
||||
if (new_delta == 0)
|
||||
return 0;
|
||||
|
||||
/* Record how close we got */
|
||||
best_delta = new_delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,19 +225,14 @@ struct geni_se {
|
||||
#define HW_VER_MINOR_SHFT 16
|
||||
#define HW_VER_STEP_MASK GENMASK(15, 0)
|
||||
|
||||
#define GENI_SE_VERSION_MAJOR(ver) ((ver & HW_VER_MAJOR_MASK) >> HW_VER_MAJOR_SHFT)
|
||||
#define GENI_SE_VERSION_MINOR(ver) ((ver & HW_VER_MINOR_MASK) >> HW_VER_MINOR_SHFT)
|
||||
#define GENI_SE_VERSION_STEP(ver) (ver & HW_VER_STEP_MASK)
|
||||
|
||||
#if IS_ENABLED(CONFIG_QCOM_GENI_SE)
|
||||
|
||||
u32 geni_se_get_qup_hw_version(struct geni_se *se);
|
||||
|
||||
#define geni_se_get_wrapper_version(se, major, minor, step) do { \
|
||||
u32 ver; \
|
||||
\
|
||||
ver = geni_se_get_qup_hw_version(se); \
|
||||
major = (ver & HW_VER_MAJOR_MASK) >> HW_VER_MAJOR_SHFT; \
|
||||
minor = (ver & HW_VER_MINOR_MASK) >> HW_VER_MINOR_SHFT; \
|
||||
step = version & HW_VER_STEP_MASK; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* geni_se_read_proto() - Read the protocol configured for a serial engine
|
||||
* @se: Pointer to the concerned serial engine.
|
||||
|
Loading…
Reference in New Issue
Block a user