  It is well established that the properties of supermassive black holes and
their host galaxies are correlated through scaling relations. While
hydrodynamical cosmological simulations have begun to account for the
co-evolution of BHs and galaxies, they typically have neglected the BH spin,
even though it may play an important role in modulating the growth and feedback
of BHs. Here we introduce a new sub-grid model for the BH spin evolution in the
moving-mesh code {\small AREPO} in order to improve the physical faithfulness
of the BH modelling in galaxy formation simulations. We account for several
different channels of spin evolution, in particular gas accretion through a
Shakura-Sunyaev $\alpha$-disc, chaotic accretion, and BH mergers. For BH
feedback, we extend the IllustrisTNG model, which considers two different BH
feedback modes, a thermal quasar mode for high accretion states and a kinetic
mode for low Eddington ratios, with a self-consistent accounting of
spin-dependent radiative efficiencies and thus feedback strength. We find that
BHs with mass $M_{\rm{bh}}\lesssim 10^{8}\, {\rm M}_\odot$ reach high spin
values as they typically evolve in the coherent gas accretion regime. On the
other hand, BHs with mass $M_{\rm{bh}}\gtrsim 10^{8}\, {\rm M}_\odot$ have
lower spins as BH mergers become more frequent, and their accretion discs
fragment due to self-gravity, inducing chaotic accretion. We also explore the
hypothesis that the transition between the quasar and kinetic feedback modes is
mediated by the accretion mode of the BH disc itself, i.e.~the kinetic feedback
mode is activated when the disc enters the self-gravity regime. We find
excellent agreement between the galaxy and BH populations for this approach and
the fiducial TNG model with no spin evolution. Furthermore, our new approach
alleviates a tension in the galaxy morphology -- colour relation of the
original TNG model.
