You can call either Tmobile and get the unlock code, or call AT&T and get it. FCC passed a law in 2006 that states "it's legal to use unlocked phones" also they stated that "if a customer/ consumer wants an unlock code for a phone then the provide must give it to them no questions asked".
Free codes does not work some times..So , You will get this subsidy code from your network provider or you may get it from online providers like Theunlockspot.com .They will help you to unlock your mobile easily.