So I've been watching a few shows and this kinda came to mind. I know of a few things from an art history course that may have led up to it but no scholarly works or anything like that. The stone of madness, a 15th century work by Bosch showing the idiocy of nonprofessional doctors drilling in people's heads to treat them of their mental problems thinking there was a stone in there or something.
Then there's also exorcism. Maybe witch trials has something to do with mental health as well?
Foucault in Madness and Civilization doesn't touch on religion specifically that I remember, but he does argue that the pre-Renaissance period referred to mental illness as 'madness' in a sense that could be seen as divinely inspired. The rise of asylums and the institutions of psychiatry marks a departure from this paradigm of madness + religion.
Joan Brumberg also writes specifically about holy anorexia in her study of the disorder.