Cosmology from HI galaxy surveys with the SKA