Maximal regularity for gradient systems with boundary degeneracy