Paint peeling off in thick sheets
Remove any remaining paint so the wall is all the same surface.
If you are not going to texture the wall then you will need to use Spackle or drywall mud to fill all holes and voids and  sand smooth.
If you are going to texture then no need to worry about small anomalies as the texture will hide them, but big ones will need to be filled.
Next you will need to apply a good  drywall sealer/primer  before you are ready to paint. If you are not texturing then use a sandable primer so you can sand the wall smooth before painting. Smooth walls take a lot of time and prep.
FYI. Next time you need to remove trim take a utility knife and firmly cut along the trim where it meets the wall so you break the bond between the paint and the trim.
Interesting read: How to Seal Damaged Drywall