When you are sleeping do you get normal penile erections especially in the early mornings? If not, you need to be examined by a urologist
and if an organic cause is suspected you require a few tests like Doppler scan of penis.
How is your libido (sexual urge)? Is it decreased? Even it needs evaluation to see if it is psychogenic or hormonal