forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/arch/mips/include/asm/timex.h
....@@ -40,9 +40,9 @@
4040 typedef unsigned int cycles_t;
4141
4242 /*
43
- * On R4000/R4400 before version 5.0 an erratum exists such that if the
44
- * cycle counter is read in the exact moment that it is matching the
45
- * compare register, no interrupt will be generated.
43
+ * On R4000/R4400 an erratum exists such that if the cycle counter is
44
+ * read in the exact moment that it is matching the compare register,
45
+ * no interrupt will be generated.
4646 *
4747 * There is a suggested workaround and also the erratum can't strike if
4848 * the compare interrupt isn't being used as the clock source device.
....@@ -63,7 +63,7 @@
6363 if (!__builtin_constant_p(cpu_has_counter))
6464 asm volatile("" : "=m" (cpu_data[0].options));
6565 if (likely(cpu_has_counter &&
66
- prid >= (PRID_IMP_R4000 | PRID_REV_ENCODE_44(5, 0))))
66
+ prid > (PRID_IMP_R4000 | PRID_REV_ENCODE_44(15, 15))))
6767 return 1;
6868 else
6969 return 0;
....@@ -76,25 +76,24 @@
7676 else
7777 return 0; /* no usable counter */
7878 }
79
+#define get_cycles get_cycles
7980
8081 /*
8182 * Like get_cycles - but where c0_count is not available we desperately
8283 * use c0_random in an attempt to get at least a little bit of entropy.
83
- *
84
- * R6000 and R6000A neither have a count register nor a random register.
85
- * That leaves no entropy source in the CPU itself.
8684 */
8785 static inline unsigned long random_get_entropy(void)
8886 {
89
- unsigned int prid = read_c0_prid();
90
- unsigned int imp = prid & PRID_IMP_MASK;
87
+ unsigned int c0_random;
9188
92
- if (can_use_mips_counter(prid))
89
+ if (can_use_mips_counter(read_c0_prid()))
9390 return read_c0_count();
94
- else if (likely(imp != PRID_IMP_R6000 && imp != PRID_IMP_R6000A))
95
- return read_c0_random();
91
+
92
+ if (cpu_has_3kex)
93
+ c0_random = (read_c0_random() >> 8) & 0x3f;
9694 else
97
- return 0; /* no usable register */
95
+ c0_random = read_c0_random() & 0x3f;
96
+ return (random_get_entropy_fallback() << 6) | (0x3f - c0_random);
9897 }
9998 #define random_get_entropy random_get_entropy
10099