To restore a password you must go the System Settings which you will find under the Settings within the XMB Menu. Press X on the Restore Defaults Setting and this should theoretically reset your password to 0000 or 9999 as this completely resets your PSP but is a small price to pay when you are locked out.
You will need to do a system factory default restore. This will wipe out the password and its saved connection for the wireless functions. Be sure you don't have a memory card in the system when you do this in case it accidentally erases the memory from that as well.
Simply go to "system settings," and click "restore default settings." This will not erase your memory card files, but it will restore all settings to the condition they were in when the PSP left the factory.