For supported methods of upgrade to 5.1 you can refer the below KB Article
VMware KB: Methods for upgrading to ESXi 5.1
There are a few important factors here. Are you using ESX or ESXi on the 4.0 servers? Also is your vCenter server running on a 64 bit platform, this is required for later versions of vCenter?
You can manage ESX/ESXi 4.0U4 hosts with vCenter 5.x. One thing you really want to make sure that you do is use the vCenter 5.5 SSO version, don't install the vCenter 5.1 SSO.
After your vCenter is upgraded you have a choice on how you deal with ESX(i) hosts. You'll need to make sure that your hardware will support the new versions of ESXi that are out with 5.1 and 5.5, so check the HCL. If you are using ESXi you shouldn't have a big problem doing Update manager upgrades to the hosts. The ESX hosts might work, some of them will do in place conversions.
If you are adding new hosts you may have EVC to contend with as well