I have a pi4 with the "official" fan case and I would like to write my own fan control code. I have looked online for a datasheet for the fan but haven't found it yet. I see on the case fan page that it is controlled by "Pulse width modulation control via user-selectable GPIO pin." Does anyone know the PWM frequency is? Bonus points if anyone knows the duty cycle to RPM mapping.
Ok I think I got the answer: 25kHz
I found this slide deck (download link) from ADDA (the manufacturer) that says the frequency is 25k. To verify this, I hooked up the official fan to a pi 3b+ I use for GPIO testing. I plugged the blue wire into GPIO 12 since the standard pin (GPIO 14) doesn't have the hardware PWM you need to exceed 7kHz. Then I used sysfs to enable PWM control and verified that I could fine-tune the fan speed by changing the duty cycle.
A couple more notes:
I still don't know the RPM profile of the fan. I am not really concerned about this but still curious in case anyone knows it.
It's interesting that the fan instructions have you use GPIO 14, which is incapable of PWM control other than duty cycles of 0% (off) and 100% (on). This seems to indicate that the fan is not really intended to be used with fine-tuned control, only to be turned on and off by the OS. Simply plugging the blue wire into GPIO 18 two pins over would have enabled this, and I confirmed you can fit the lead there in the official fan and official case, but someone clearly chose not to put that in the instructions, so I think anyone wanting to fine-tune their fan control is clearly going to be on their own!