Replace or tighten a screwless hinge
That is a pintle and gudgeon hinge. Usually the pintle is on the wall and the gudgeon is on the door, so that the gudgeon cup does not fill up with debris. 

Search term "gudgeon", or "pintle", or "pintle and gudgeon hinge". 

It is designed to come apart by lifting the door straight up. Then the individual parts (the "gudgeon" and the "pintle") can be unscrewed from their pilot holes. 

In your case, you would remove the door, screw the top fitting further into the wall, and replace the door. 

This will be complicated by whatever caused the fitting to start from the wall in the first place, which probably will require removing the fitting and repairing the hole.