I believe SRG previously responded to a similar question. You always earn miles/TP for the paid cabin of travel. If you upgrade at the airport then you may not be automatically credited with the upgrade miles, but provided you keep your boarding pass you can ensure you get the correct miles added later.