• Stephan Gerhold's avatar
    phy: ti: tusb1210: Add charger detection · 48969a56
    Stephan Gerhold authored
    Some Android x86 tablets with a Bay Trail (BYT) SoC and a Crystal Cove
    PMIC, which does not support charger-detection, rely on a TUSB1211
    phy for charger-detection.
    
    Add support for charger detection on TUSB1211 phy-s and export
    the information about the detected charger through the standard
    power_supply class interface. power_supply class charger IC drivers
    like the bq24190_charger.c driver will then pick this up and set
    their input_current_limit based on this.
    
    Note the "linux,phy_charger_detect" property used to enable this is
    a special kernel-internal (so not part of the dt-bindings) property
    used by dwc3 platform code to indicate that the phy needs to do
    charger-detection.
    
    Changes by Hans de Goede:
    - Use "linux,phy_charger_detect" property to enable charger-detect
    - Switch from a linear flow to a state-machine, with retries on
      ulpi communication errors
    - Use SW_CONTROL bit to disable the FSM when detection is finished
    - Do a phy-reset on disconnect to work around the phy often refusing
      ulpi_read()/_write() commands after a disconnect
    - Use power_supply_reg_notifier() for Vbus monitoring
    - Export the detection result through a power_supply class device
    Signed-off-by: default avatarStephan Gerhold <stephan@gerhold.net>
    Co-developed-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20220213130524.18748-10-hdegoede@redhat.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
    48969a56
phy-tusb1210.c 16 KB