MCU Input Protection Comparison
Your requirements make it a difficult to design a circuit. And I think you'll have to compromise somewhere.
I have yet to encounter an IO port like you describe on something industrial. Which is what you're asking with the 24V rating. 

But, let's define the requirements: 


Pull-to-ground Digital Input. 
Digital 24Vdc input (eg: IEC1131-2)  
High Frequency 24V counter.  
TTL level UART. 


But let's add: 


Noise immunity, you don't want the input toggling at mains frequency due to noise or nearby events.


Now, this provides some serious challenges, the ranged your input threshold are &lt;0.8V and >2.0V, but also &lt;5V and >15V.
To add complications, the 24V input will need to sink some (~3mA) current, while the uart will need to pull-up the line since the transmitter pulls it down.

I think you can't make this without some selector switches.







simulate this circuit &ndash; Schematic created using CircuitLab

R1 should be low enough to allow uart to pass. R2 should provide enough current if the uart transmitter is not push-pull (they often are not). If not, lower R1 and R2, but keep an eye on the current and power. They're doing 50 mW already.
R3 should take enough current for 24 Volt to not excite the zener diode, and provide noise immunity since it requires current to get above the buffers threshold voltage.
C1 will provide some filtering for fast glitches, but won't be very effective. Since it can't slow down the signal below 10 kHz (uart baud rate).

The buffer is there as sacrificial component, or as component with stricter thresholds, or threshold with less spread between parts.
Schmitt trigger inputs are strongly recommended.

The compromise here is that a pull-to-ground might have a slow recovery due to R2. But you can't lower R2 much, since the low-level thresholds of will be a problem.

Simulations are great, but I would definitely put it on a breadboard before I order the PCB. Especially the UART part is tricky.