Skip to content

Commit 83e350b

Browse files
JasonLin-RealTekjhedberg
authored andcommitted
sensor: rts5912: reduce Tachometer wake up frequency
Adjusted RTS5912 tachometer behavior to reduce interference with CPU sleep. Signed-off-by: Lin Yu-Cheng <[email protected]>
1 parent e213815 commit 83e350b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/sensor/realtek/rts5912/rts5912.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ struct tach_rts5912_data {
3434
uint16_t count;
3535
};
3636

37-
#define COUNT_100KHZ_SEC 100000U
38-
#define SEC_TO_MINUTE 60U
39-
#define PIN_STUCK_TIMEOUT (100U * USEC_PER_MSEC)
37+
#define COUNT_100KHZ_SEC 100000U
38+
#define SEC_TO_MINUTE 60U
39+
/* Reduced PIN_STUCK checks from 100 to 25 to reduce disruption of the cpu sleep */
40+
#define PIN_STUCK_TIMEOUT (50U * USEC_PER_MSEC)
41+
#define PIN_STUCK_CHECK_INTERVAL (2)
4042

4143
int tach_rts5912_sample_fetch(const struct device *dev, enum sensor_channel chan)
4244
{
@@ -50,7 +52,8 @@ int tach_rts5912_sample_fetch(const struct device *dev, enum sensor_channel chan
5052

5153
tach->status = TACHO_STS_CNTRDY;
5254

53-
if (WAIT_FOR(tach->status & TACHO_STS_CNTRDY, PIN_STUCK_TIMEOUT, k_msleep(1))) {
55+
if (WAIT_FOR(tach->status & TACHO_STS_CNTRDY, PIN_STUCK_TIMEOUT,
56+
k_msleep(PIN_STUCK_CHECK_INTERVAL))) {
5457
/* See whether internal counter is already latched */
5558
if (tach->status & TACHO_STS_CNTRDY) {
5659
tach->status = TACHO_STS_CNTRDY;

0 commit comments

Comments
 (0)