OSDN Git Service

phy: ti: tusb1210: Add charger detection
authorStephan Gerhold <stephan@gerhold.net>
Sun, 13 Feb 2022 13:05:24 +0000 (14:05 +0100)
committerVinod Koul <vkoul@kernel.org>
Fri, 25 Feb 2022 08:58:07 +0000 (14:28 +0530)
commit48969a5623ed918713552e2b4f9d391c89b5e838
tree6daefae0cca99cceded1279b2dd77ad3486b428a
parentdf37c99815d9e0775e67276d70c93cbc25f31c70
phy: ti: tusb1210: Add charger detection

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: Stephan Gerhold <stephan@gerhold.net>
Co-developed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220213130524.18748-10-hdegoede@redhat.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/ti/phy-tusb1210.c