How to know physical problem or mental

Any guidance please on how do I know if my ED is a medical issue or mental. Get hard sometimes on my own and morning wood sometimes and with porn but with partner often canโ€™t keep an erection. Where best to get specific guidance please.