Let p be an odd prime. In this paper, we consider the equation and we describe all its solutions. Moreover, we prove that this equation has no solution (x,y,m,n) when n>3 is an odd prime and y is not the sum of two consecutive squares. This extends the work of Tengely [On the diophantine equation x2+q2m=2yp, Acta Arith.127(1) (2007), 71–86].