Re: [PATCH resend 2/2] usb: phy: mxs: add usb charger type detection

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

 



On Mon, Sep 04, 2017 at 11:14:02PM +0800, Li Jun wrote:
>  }
>  
> +#define MXS_USB_CHARGER_DATA_CONTACT_TIME_OUT	100

How about using "DATA_CONTACT_TIMEOUT_LOOP"?

> +static int mxs_charger_data_contact_detect(struct mxs_phy *x)
> +{
> +	struct regmap *regmap = x->regmap_anatop;
> +	int i, stable_contact_count = 0;
> +	u32 val;
> +
> +	/* Check if vbus is valid */
> +	regmap_read(regmap, ANADIG_USB1_VBUS_DET_STAT, &val);
> +	if (!(val & ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID)) {
> +		dev_err(x->phy.dev, "vbus is not valid\n");
> +		return -EINVAL;
> +	}
> +
> +	/* Enable charger detector */
> +	regmap_write(regmap, ANADIG_USB1_CHRG_DETECT_CLR,
> +				ANADIG_USB1_CHRG_DETECT_EN_B);
> +	/*
> +	 * - Do not check whether a charger is connected to the USB port
> +	 * - Check whether the USB plug has been in contact with each other
> +	 */
> +	regmap_write(regmap, ANADIG_USB1_CHRG_DETECT_SET,
> +			ANADIG_USB1_CHRG_DETECT_CHK_CONTACT |
> +			ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B);
> +
> +	/* Check if plug is connected */
> +	for (i = 0; i < MXS_USB_CHARGER_DATA_CONTACT_TIME_OUT; i = i + 1) {

We use i++ at for-loop usually.

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux