Re: [PATCH v4 06/10] power: supply: max77693: Add support for detecting and enabling OTG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16/08/2024 10:19, Artur Weber wrote:
> Building upon the newly added extcon detection support, add detection
> for USB OTG cables (EXTCON_USB_HOST type), and enable/disable the OTG
> bits as needed.
> 
> Acked-by: Lee Jones <lee@xxxxxxxxxx>
> Tested-by: Henrik Grimler <henrik@xxxxxxxxxx>
> Signed-off-by: Artur Weber <aweber.kernel@xxxxxxxxx>
> ---
> Changes in v3:
> - Dropped CHARGER regulator in favor of enabling charging directly
> 
> Changes in v2:
> - Added CHGIN OTG current limit value
> - Squashed MFD header register changes into this commit
> ---
>  drivers/power/supply/max77693_charger.c | 53 ++++++++++++++++++++++++++-------
>  include/linux/mfd/max77693-private.h    |  5 ++++
>  2 files changed, 48 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c
> index d67857d2aa0b..bf156544fe1b 100644
> --- a/drivers/power/supply/max77693_charger.c
> +++ b/drivers/power/supply/max77693_charger.c
> @@ -692,11 +692,30 @@ static int max77693_set_charging(struct max77693_charger *chg, bool enable)
>  			data);
>  }
>  
> +static int max77693_set_otg(struct max77693_charger *chg, bool enable)
> +{
> +	unsigned int data;
> +
> +	if (enable)
> +		data = CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK |
> +				CHG_CNFG_00_DIS_MUIC_CTRL_MASK;
> +	else
> +		data = ~(CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK |
> +				CHG_CNFG_00_DIS_MUIC_CTRL_MASK);
> +
> +	return regmap_update_bits(chg->max77693->regmap,
> +			MAX77693_CHG_REG_CHG_CNFG_00,
> +			CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK |
> +			CHG_CNFG_00_DIS_MUIC_CTRL_MASK,
> +			data);
> +}
> +
>  static void max77693_charger_extcon_work(struct work_struct *work)
>  {
>  	struct max77693_charger *chg = container_of(work, struct max77693_charger,
>  						  cable.work);
>  	struct extcon_dev *edev = chg->cable.edev;
> +	bool set_charging, set_otg;
>  	int connector, state;
>  	int ret;
>  
> @@ -715,25 +734,39 @@ static void max77693_charger_extcon_work(struct work_struct *work)
>  	case EXTCON_CHG_USB_FAST:
>  	case EXTCON_CHG_USB_SLOW:
>  	case EXTCON_CHG_USB_PD:
> -		ret = max77693_set_charging(chg, true);
> -		if (ret) {
> -			dev_err(chg->dev, "failed to enable charging\n");
> -			break;
> -		}
> +		set_charging = true;
> +		set_otg = false;
> +
>  		dev_info(chg->dev, "charging. connector type: %d\n",
>  			 connector);

Same comments as for other patch - dev_dbg.


Best regards,
Krzysztof





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux