You will need to remove what ever is peeling and loose. Try to minimize the damage to the underlying wall surface. When this scraping is done, sand the entire area with a pole sander and 150 grit paper/screen. Wipe it off to remove the dust then prime everything with a good oil based primer, Kilz or Cover Stain will work well. Allow the primer to dry overnight then do any needed repairs. Make sure to prime the repairs before painting.
The new paint should stick to the newly primed surface. A good oil based primer will do a good job sticking to the damaged wall surfaces.