How do I differentiate two distinct frequencies? 24Mhz and 40Mhz
If the two frequencies of 24 and 40 MHz are fairly close tolerance (like not more than a small % off) then one way to detect which one is which is to do as follows. 


24MHz has a period of 41.66 nsec.
40MHz has a period of 25.00 nsec.
Connect the input clock to an edge re-triggerable RC delay circuit with a timeout period of about 33 nsec. The triggered pulse should go high.
Connect the output of the delay circuit to the D input of a flip flop. 
Connect the CLK of the flip flop to the input clock signal. 
If the Q pin of the flip flop stays high then the input clock is known to be 40 MHz. If the Q pin remains low then the input clock is 24 MHz. 
Use the flip flop output to control some type of analog switch or MUX that is designed to connect or disconnect components in the PLL filter circuit.