Herschel-atlas galaxy counts and high-redshift luminosity functions: The formation of massive early-type galaxies