Flatness of residual representations associated to modular forms Let $f\in S_k(\Gamma_1(N),\chi)$ be a Hecke eigenform of weight $k\geq 2$, $p$ an odd prime not dividing $N$, and $K_f$ the number field generated by the Hecke eigenvalues of $f$. Fixing a prime $\lambda$ of $K_f$ over $p$, one has the continuous irreducible $p$-adic representation $\rho:G_\mathbf{Q}\rightarrow\mathrm{GL}_2(K_{f,\lambda})$ unramified outside $Np$. If $k$ is the residue field of $K_{f,\lambda}$, reducing a lattice and taking the semisimplification, we get the residual representation $\bar{\rho}:G_\mathbf{Q}\rightarrow\mathrm{GL}_2(k)$. I'm interested in the restriction of $\bar{\rho}$ to a decomposition group $D_p$ at $p$. Specifically, my question is: are there general conditions on $f$ that ensure that the restriction of $\bar{\rho}$ to $D_p$ is flat?
Definition: A finite $G_{\mathbf{Q}_p}$-module $M$ of $p$-power order is said to be flat if it is the generic fiber representation of a finite flat group scheme over $\mathbf{Z}_p$. 
The only example I know of is the following when $k=2$, and $f$ corresponds to an elliptic curve $E/\mathbf{Q}$ with good reduction at $p$. In this case the residual representation is just coming from $E[p]$, which is flat at $p$ (i.e. as a $G_{\mathbf{Q}_p}$-module) because it is the generic fiber representation of the $p$-torsion of the Neron model of $E$ over $\mathbf{Z}_p$, and good reduction means the Neron model is an abelian scheme, so its $p$-torsion is finite flat.
I know that the notion of flat representations is used in Wiles' proof of the modularity of semistable elliptic curves over $\mathbf{Q}$, but I don't know if any of the flat representations that are used actually are coming from the residual representations attached to modular forms. 
 A: If $f$ is a cuspidal newform, then the $p$-adic Galois representation attached to $f$ is flat (more precisely, each of the mod $p^n$ Galois representations attached to $f$ is flat) if and only if $f$ is of level prime to $p$ and of weight two.
In particular, if $f$ is of level prime to $p$ and weight two, then the mod $p$ Galois rep'n attached to $f$ is flat.  
We can't make an if and only if statement
when discussing just the mod $p$ Galois representation, because of the possibility of congruences of modular forms.   E.g. the (unique) newform of weight two and level $33$ is congruent mod $3$ to the (unique) newform of weight two and level $11$, and so their mod $3$ Galois rep's are the same.  The latter rep'n is finite flat (being attached to a weight two newform of prime-to-$3$ level), and hence so is the former.
Speaking more generally,
level lowering results (due primarily to Ribet) state that if $f$ is a newform such that mod $p$ Galois rep'n is finite flat, then there is a newform $g$ of weight two and level prime-to-$p$ such that $f$ and $g$ are congruent mod $p$ (i.e. have the same associated mod $p$ Galois representation).
In Wiles's argument, all the finite flat representations do come from weight two modular forms of level prime-to-$p$; indeed, the whole point of that condition is that it gives a Galois-representation-theoretic criterion for recognizing weight two modular forms of level prime-to-$p$.
