Previously all devices could be unlocked, but, with the baseband that was included with iOS 4.1 and higher, Apple released an update to avoid this. What you can do is to install the old baseband of the iPad (version 6.15.00) onto your iPhone 3G or 3GS. This is possible because the baseband of the iPad has a higher version number than the iPhone 3G or 3GS (but is still older). But be aware that there is no way back, so you will lose your warranty, you can only install custom firmware in the future (normal restores won't work anymore) and some users reported that they have lost their GPS functionality (maybe forever). So use this only if you really need an unlock. To do this, use the redsn0w
[1] tool.