I have rpm, max_rpm and a variable x.
When rpm aproaches max_rpm -> x tends to 0
When rpm aproaches 0 -> x tends to 255
x = (rpm/rpm_max)*255;
If I understood your question correctly then maybe this?
x = (1 - rpm/rpm_max)*255
UPDATE: as mentioned by CandiedOrange - rpm and rpm_max need to be float or double for it to work. Otherwise the value of x would simply switch back and forth between 0 and 255.