We combine observational data on a dozen independent cosmic properties at high-$z$ with the information on reionization drawn from the spectra of distant luminous sources and the cosmic microwave background (CMB) to constrain the interconnected evolution of galaxies and the intergalactic medium since the dark ages. The only acceptable solutions are concentrated in two narrow sets. In one of them reionization proceeds in two phases: a first one driven by Population III stars, completed at $zsim 10$, and after a short recombination period a second one driven by normal galaxies, completed at $zsim 6$. In the other set both kinds of sources work in parallel until full reionization at $zsim 6$. The best solution with double reionization gives excellent fits to all the observed cosmic histories, but the CMB optical depth is 3-$sigma$ larger than the recent estimate from the Planck data. Alternatively, the best solution with single reionization gives less good fits to the observed star formation rate density and cold gas mass density histories, but the CMB optical depth is consistent with that estimate. We make several predictions, testable with future observations, that should discriminate between the two reionization scenarios. As a byproduct our models provide a natural explanation to some characteristic features of the cosmic properties at high-$z$, as well as to the origin of globular clusters.