  We investigate the possibility that there is a first phase of partial
ionisation due to X-rays produced by black hole accretion in small-mass
galaxies at redshifts 7<z<20. This is followed by complete reionisation by
stellar sources at z~7. This scenario is motivated by the large optical depth
to Thompson scattering, tau_e=0.17, measured by WMAP. But it is also consistent
with the observed Gunn-Peterson trough in the spectra of quasars at z~5-6. We
use a semianalytic code to explore models with different black hole accretion
histories and cosmological parameters.We find that ``preionisation'' by X-rays
can increase the intergalactic medium (IGM) optical depth from tau_e~0.06 given
by stellar sources only, to 0.1<tau_e<0.2, if a fraction of baryons 5x10^-5 is
accreted onto seed black holes produced in the collapse of low metallicity,
high mass stars before z~15. To be effective, preionisation requires a
non-negligible star formation in the first small-mass galaxies in hich seed
black holes are formed.The model predicts that dwarf spheroidal galaxies may
host a mass in black holes that is 5-40% of their stellar mass. The redshifted
X-ray background produced by this early epoch of black hole accretion
constitutes about 5-10% of the X-ray background in the 2-50 keV bands and
roughtly half of the currently estimated black hole mass density was formed at
early times.Moreover, in most models, the photons from the redshifted
background are sufficient to fully reionise HeII at redshift z~3 without any
additional contribution from quasars at lower redshifts and the temperature of
the mean density intergalactic medium remains close to 10^4 K down to redshift
z~1.[abridged]
