We develop a self-consistent approach to study the spectral properties of a class of quantum mechanical operators by using the knowledge about monodromies of $$2\times 2$$
2
×
2
linear systems (Riemann–Hilbert correspondence). Our technique applies to a variety of problems, though in this paper we only analyse in detail two examples. First we review the case of the (modified) Mathieu operator, which corresponds to a certain linear system on the sphere and makes contact with the Painlevé $$\mathrm {III}_3$$
III
3
equation. Then we extend the analysis to the 2-particle elliptic Calogero–Moser operator, which corresponds to a linear system on the torus. By using the Kyiv formula for the isomonodromic tau functions, we obtain the spectrum of such operators in terms of self-dual Nekrasov functions ($$\epsilon _1+\epsilon _2=0$$
ϵ
1
+
ϵ
2
=
0
). Through blowup relations, we also find Nekrasov–Shatashvili type of quantizations ($$\epsilon _2=0$$
ϵ
2
=
0
). In the case of the torus with one regular singularity we obtain certain results which are interesting by themselves. Namely, we derive blowup equations (filling some gaps in the literature) and we relate them to the bilinear form of the isomonodromic deformation equations. In addition, we extract the $$\epsilon _2\rightarrow 0$$
ϵ
2
→
0
limit of the blowup relations from the regularized action functional and CFT arguments.