iPhone firmware comes in 2 parts, one of which is called the baseband. The baseband is the part that handles communication between your cell phone carrier and the rest of your phone.
The baseband that comes with firmware 2.2.1 cannot be uninstalled, and cannot be unlocked. So if you want to unlock your iPhone, with 2.2.1 installed, you need to find a custom made firmware package that has had the baseband component removed. You can find a custom firmware on several bit torrent sites.
Once you have a custom firmware image, you can install it by going into iTunes and doing a shift-click on the "Restore" button. This will let you choose the image file to install.
After iTunes installs the firmware, you should have a jailbroken iPhone with the baseband preserved. A preserved baseband will let you install Yellownsn0w via Cydia. Cydia will be on your phone after the firmware is installed, and Yellownsn0w is a piece of software that will unlock your phone.
Hope this helps.