Atwood's machine re-visited

Atwood's machine is a device where two masses, M and m, are connected by a string passing over a pulley. Assume that M > m. The pulley has a mass mp and a radius r.

What is the acceleration of the two masses?

Start with three free-body diagrams, one for each mass and one for the pulley.