A cycle and the NLA
Simplest way would be to change to Euler rotation and use the method in @moonboot's answer
To remain with quaternions Another option is to make a cycle and use the (oft forgotten) NLA to scale and repeat the action.
Here I've made an action to rotate using quaternions, about Y axis one revolution in 24 frames. Rotated in two parts from 0 to 180 and from 180 to 360 (0). Converted to linear interpolation.
At 24 fps is 1 rev per second or 60 rpm. Switched the frame range to 1 to 23 to test.
One rev in Y in quaternion. Have removed the non required X and Z and the middle keyframe of W
When happy with cycle, "push down" the action to the NLA.

Switch to NLA editor. In Action Clip panel set the end frame to 23 (one less so next frame is back to 0 or 360 degrees)

Use repeat for revolutions and scale for speed, reversed for switching direction. These properties can be animated.