I am reading concepts of modern physics (by Arthur Beiser) where he calculates the de Broglie wave velocity. For that he uses the relation $v = fλ$ where $v$, $f$, and $λ$ are velocity (de Broglie wave), frequency, and wavelength, respectively. Now for the wavelength, he uses the de Broglie wavelength and for frequency he writes:
$E = \gamma mc^2 =hf$.
But can I apply $E=hf$ to a particle having mass? I thought it applied only to photons?