Molecular dynamics in thin grafted and spin-coated polymer layers