An electronic device receives external power from an external device when connected to the external device via a cable. The electronic device detects the power supply capability of the external device, determines whether the cable is a predetermined type of cable, and sets a current value limit for the external power based on the detected power supply capability of the external device and on the result of determining whether the cable is the predetermined type of cable.