Step #1: A few questions. Is it old or new bootrom? Is phone still runing 3.1.2? Is it JB or not?
A) If it's old bootrom, running 3.1.2 and JB, create or find (google) custom 4.0.1 and use it to restore through Itunes.
B) If on old bootrom, 3.1.2 and not JB, use Redsn0w to JB phone, and then, create or find (google) custom 4.0.1 and use it to restore through Itunes.
C) If new bootrom, continue next step.
Step #2: Dealing with Apple's SHSH restoring security check. In short, Apple / Itunes will only allow you to restore to latest firmware, right now 4.0.2 and 4.1. If you have your SHSH hashes saved for older firmware, you can trick Itunes into allowing you to install them. Thus, big question. Do you have SHSH hashes saved?
A) If NO, you are SOL. Wait until possible 4.1 JB.
B) If YES, Download and run Tinyumbrella:
1) Make sure you Iphone is detected.
2) check "Advanced Options."
3) In new window, under "Device / Version," select the firmware version you want to downgrade to.
4) Click on "Save my SHSH." Pray Cydia has them. If you don't get an error, it has been saved onto your computer.
5) Repeat to save other firmware hashes if you wish.
6) Now, click on "Display SHSHs." It should listed all hashes you have saved on your computer and the firmware you can downgrade to.
7) Start "TSS server," download firmware file somewhere (google) and restore through iTunes with that file.
8) If you phone get stuck during restore, try "Kick out of recovery..."'in Tinyumbrella.
If you don't understand what I am saying, take few days Googling and start reading. And, file you downloaded, rename it from X.zip to X.iswp. Then, you can use it on Itunes.