Star formation and environment in clusters up to z~2.2