All of lore.kernel.org
 help / color / mirror / Atom feed
From: hzpeterchen@gmail.com (Peter Chen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/3] usb: chipidea: Hook into mux framework to toggle usb switch
Date: Tue, 18 Jul 2017 12:41:11 +0800	[thread overview]
Message-ID: <20170718044111.GA13320@b29397-desktop> (raw)
In-Reply-To: <20170714214005.14967-3-stephen.boyd@linaro.org>

On Fri, Jul 14, 2017 at 02:40:04PM -0700, Stephen Boyd wrote:
>  
> @@ -175,6 +176,10 @@ static int host_start(struct ci_hdrc *ci)
>  		if (ci_otg_is_fsm_mode(ci)) {
>  			otg->host = &hcd->self;
>  			hcd->self.otg_port = 1;
> +		} else {
> +			ret = mux_control_select(ci->platdata->usb_switch, 1);

It is better to use MACRO for 1 and 0.

> +			if (ret)
> +				goto disable_reg;
>  		}
>  	}
>  
> @@ -195,6 +200,8 @@ static void host_stop(struct ci_hdrc *ci)
>  	struct usb_hcd *hcd = ci->hcd;
>  
>  	if (hcd) {
> +		if (!ci_otg_is_fsm_mode(ci))
> +			mux_control_deselect(ci->platdata->usb_switch);
>  		if (ci->platdata->notify_event)
>  			ci->platdata->notify_event(ci,
>  				CI_HDRC_CONTROLLER_STOPPED_EVENT);
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index d68b125796f9..deb18099e168 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -22,6 +22,7 @@
>  #include <linux/usb/gadget.h>
>  #include <linux/usb/otg-fsm.h>
>  #include <linux/usb/chipidea.h>
> +#include <linux/mux/consumer.h>
>  
>  #include "ci.h"
>  #include "udc.h"
> @@ -1964,16 +1965,26 @@ void ci_hdrc_gadget_destroy(struct ci_hdrc *ci)
>  
>  static int udc_id_switch_for_device(struct ci_hdrc *ci)
>  {
> +	int ret = 0;
> +
>  	if (ci->is_otg)
>  		/* Clear and enable BSV irq */
>  		hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
>  					OTGSC_BSVIS | OTGSC_BSVIE);
>  
> -	return 0;
> +	if (!ci_otg_is_fsm_mode(ci))
> +		ret = mux_control_select(ci->platdata->usb_switch, 0);
> +
> +	if (ci->is_otg && ret)
> +		hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS);

Should use !ret?

Peter

> +
> +	return ret;
>  }
>  
>  static void udc_id_switch_for_host(struct ci_hdrc *ci)
>  {
> +	mux_control_deselect(ci->platdata->usb_switch);
> +
>  	/*
>  	 * host doesn't care B_SESSION_VALID event
>  	 * so clear and disbale BSV irq
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index c5fdfcf99828..3b27e333de1d 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -9,6 +9,7 @@
>  #include <linux/usb/otg.h>
>  
>  struct ci_hdrc;
> +struct mux_control;
>  
>  /**
>   * struct ci_hdrc_cable - structure for external connector cable state tracking
> @@ -74,6 +75,7 @@ struct ci_hdrc_platform_data {
>  	/* VBUS and ID signal state tracking, using extcon framework */
>  	struct ci_hdrc_cable		vbus_extcon;
>  	struct ci_hdrc_cable		id_extcon;
> +	struct mux_control		*usb_switch;
>  	u32			phy_clkgate_delay_us;
>  };
>  
> -- 
> 2.10.0.297.gf6727b0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 

Best Regards,
Peter Chen

WARNING: multiple messages have this Message-ID (diff)
From: Peter Chen <hzpeterchen@gmail.com>
To: Stephen Boyd <stephen.boyd@linaro.org>
Cc: Peter Chen <Peter.Chen@nxp.com>,
	devicetree@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Rob Clark <robdclark@gmail.com>, Rob Herring <robh+dt@kernel.org>,
	devicetree@vger.infradead.org, Andy Gross <andy.gross@linaro.org>,
	Peter Rosin <peda@axentia.se>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 2/3] usb: chipidea: Hook into mux framework to toggle usb switch
Date: Tue, 18 Jul 2017 12:41:11 +0800	[thread overview]
Message-ID: <20170718044111.GA13320@b29397-desktop> (raw)
In-Reply-To: <20170714214005.14967-3-stephen.boyd@linaro.org>

On Fri, Jul 14, 2017 at 02:40:04PM -0700, Stephen Boyd wrote:
>  
> @@ -175,6 +176,10 @@ static int host_start(struct ci_hdrc *ci)
>  		if (ci_otg_is_fsm_mode(ci)) {
>  			otg->host = &hcd->self;
>  			hcd->self.otg_port = 1;
> +		} else {
> +			ret = mux_control_select(ci->platdata->usb_switch, 1);

It is better to use MACRO for 1 and 0.

> +			if (ret)
> +				goto disable_reg;
>  		}
>  	}
>  
> @@ -195,6 +200,8 @@ static void host_stop(struct ci_hdrc *ci)
>  	struct usb_hcd *hcd = ci->hcd;
>  
>  	if (hcd) {
> +		if (!ci_otg_is_fsm_mode(ci))
> +			mux_control_deselect(ci->platdata->usb_switch);
>  		if (ci->platdata->notify_event)
>  			ci->platdata->notify_event(ci,
>  				CI_HDRC_CONTROLLER_STOPPED_EVENT);
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index d68b125796f9..deb18099e168 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -22,6 +22,7 @@
>  #include <linux/usb/gadget.h>
>  #include <linux/usb/otg-fsm.h>
>  #include <linux/usb/chipidea.h>
> +#include <linux/mux/consumer.h>
>  
>  #include "ci.h"
>  #include "udc.h"
> @@ -1964,16 +1965,26 @@ void ci_hdrc_gadget_destroy(struct ci_hdrc *ci)
>  
>  static int udc_id_switch_for_device(struct ci_hdrc *ci)
>  {
> +	int ret = 0;
> +
>  	if (ci->is_otg)
>  		/* Clear and enable BSV irq */
>  		hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
>  					OTGSC_BSVIS | OTGSC_BSVIE);
>  
> -	return 0;
> +	if (!ci_otg_is_fsm_mode(ci))
> +		ret = mux_control_select(ci->platdata->usb_switch, 0);
> +
> +	if (ci->is_otg && ret)
> +		hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS);

Should use !ret?

Peter

> +
> +	return ret;
>  }
>  
>  static void udc_id_switch_for_host(struct ci_hdrc *ci)
>  {
> +	mux_control_deselect(ci->platdata->usb_switch);
> +
>  	/*
>  	 * host doesn't care B_SESSION_VALID event
>  	 * so clear and disbale BSV irq
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index c5fdfcf99828..3b27e333de1d 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -9,6 +9,7 @@
>  #include <linux/usb/otg.h>
>  
>  struct ci_hdrc;
> +struct mux_control;
>  
>  /**
>   * struct ci_hdrc_cable - structure for external connector cable state tracking
> @@ -74,6 +75,7 @@ struct ci_hdrc_platform_data {
>  	/* VBUS and ID signal state tracking, using extcon framework */
>  	struct ci_hdrc_cable		vbus_extcon;
>  	struct ci_hdrc_cable		id_extcon;
> +	struct mux_control		*usb_switch;
>  	u32			phy_clkgate_delay_us;
>  };
>  
> -- 
> 2.10.0.297.gf6727b0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 

Best Regards,
Peter Chen

WARNING: multiple messages have this Message-ID (diff)
From: Peter Chen <hzpeterchen@gmail.com>
To: Stephen Boyd <stephen.boyd@linaro.org>
Cc: Peter Chen <Peter.Chen@nxp.com>, <devicetree@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Rob Clark <robdclark@gmail.com>, Rob Herring <robh+dt@kernel.org>,
	<devicetree@vger.infradead.org>,
	Andy Gross <andy.gross@linaro.org>, Peter Rosin <peda@axentia.se>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v2 2/3] usb: chipidea: Hook into mux framework to toggle usb switch
Date: Tue, 18 Jul 2017 12:41:11 +0800	[thread overview]
Message-ID: <20170718044111.GA13320@b29397-desktop> (raw)
In-Reply-To: <20170714214005.14967-3-stephen.boyd@linaro.org>

On Fri, Jul 14, 2017 at 02:40:04PM -0700, Stephen Boyd wrote:
>  
> @@ -175,6 +176,10 @@ static int host_start(struct ci_hdrc *ci)
>  		if (ci_otg_is_fsm_mode(ci)) {
>  			otg->host = &hcd->self;
>  			hcd->self.otg_port = 1;
> +		} else {
> +			ret = mux_control_select(ci->platdata->usb_switch, 1);

It is better to use MACRO for 1 and 0.

> +			if (ret)
> +				goto disable_reg;
>  		}
>  	}
>  
> @@ -195,6 +200,8 @@ static void host_stop(struct ci_hdrc *ci)
>  	struct usb_hcd *hcd = ci->hcd;
>  
>  	if (hcd) {
> +		if (!ci_otg_is_fsm_mode(ci))
> +			mux_control_deselect(ci->platdata->usb_switch);
>  		if (ci->platdata->notify_event)
>  			ci->platdata->notify_event(ci,
>  				CI_HDRC_CONTROLLER_STOPPED_EVENT);
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index d68b125796f9..deb18099e168 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -22,6 +22,7 @@
>  #include <linux/usb/gadget.h>
>  #include <linux/usb/otg-fsm.h>
>  #include <linux/usb/chipidea.h>
> +#include <linux/mux/consumer.h>
>  
>  #include "ci.h"
>  #include "udc.h"
> @@ -1964,16 +1965,26 @@ void ci_hdrc_gadget_destroy(struct ci_hdrc *ci)
>  
>  static int udc_id_switch_for_device(struct ci_hdrc *ci)
>  {
> +	int ret = 0;
> +
>  	if (ci->is_otg)
>  		/* Clear and enable BSV irq */
>  		hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
>  					OTGSC_BSVIS | OTGSC_BSVIE);
>  
> -	return 0;
> +	if (!ci_otg_is_fsm_mode(ci))
> +		ret = mux_control_select(ci->platdata->usb_switch, 0);
> +
> +	if (ci->is_otg && ret)
> +		hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS);

Should use !ret?

Peter

> +
> +	return ret;
>  }
>  
>  static void udc_id_switch_for_host(struct ci_hdrc *ci)
>  {
> +	mux_control_deselect(ci->platdata->usb_switch);
> +
>  	/*
>  	 * host doesn't care B_SESSION_VALID event
>  	 * so clear and disbale BSV irq
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index c5fdfcf99828..3b27e333de1d 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -9,6 +9,7 @@
>  #include <linux/usb/otg.h>
>  
>  struct ci_hdrc;
> +struct mux_control;
>  
>  /**
>   * struct ci_hdrc_cable - structure for external connector cable state tracking
> @@ -74,6 +75,7 @@ struct ci_hdrc_platform_data {
>  	/* VBUS and ID signal state tracking, using extcon framework */
>  	struct ci_hdrc_cable		vbus_extcon;
>  	struct ci_hdrc_cable		id_extcon;
> +	struct mux_control		*usb_switch;
>  	u32			phy_clkgate_delay_us;
>  };
>  
> -- 
> 2.10.0.297.gf6727b0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 

Best Regards,
Peter Chen

  reply	other threads:[~2017-07-18  4:41 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-14 21:40 [PATCH v2 0/3] USB Mux support for Chipidea Stephen Boyd
2017-07-14 21:40 ` Stephen Boyd
2017-07-14 21:40 ` [PATCH v2 1/3] mux: Add mux_control_get_optional() API Stephen Boyd
2017-07-14 21:40   ` Stephen Boyd
2017-07-17  8:20   ` Peter Rosin
2017-07-17  8:20     ` Peter Rosin
2017-07-19  2:08     ` Stephen Boyd
2017-07-19  2:08       ` Stephen Boyd
2017-07-19  7:15       ` Peter Rosin
2017-07-19  7:15         ` Peter Rosin
2017-07-19  7:15         ` Peter Rosin
2017-07-19 18:02         ` Stephen Boyd
2017-07-19 18:02           ` Stephen Boyd
2017-07-14 21:40 ` [PATCH v2 2/3] usb: chipidea: Hook into mux framework to toggle usb switch Stephen Boyd
2017-07-14 21:40   ` Stephen Boyd
2017-07-18  4:41   ` Peter Chen [this message]
2017-07-18  4:41     ` Peter Chen
2017-07-18  4:41     ` Peter Chen
2017-07-19  1:47     ` Stephen Boyd
2017-07-19  1:47       ` Stephen Boyd
2017-07-19  2:05       ` Peter Chen
2017-07-19  2:05         ` Peter Chen
2017-07-19  2:05         ` Peter Chen
2017-07-31 10:33   ` Peter Rosin
2017-07-31 10:33     ` Peter Rosin
2017-07-31 10:33     ` Peter Rosin
2017-08-08  1:51     ` Stephen Boyd
2017-08-08  1:51       ` Stephen Boyd
2017-08-08 12:46       ` Peter Rosin
2017-08-08 12:46         ` Peter Rosin
2017-08-08 12:46         ` Peter Rosin
2017-08-11 22:26         ` Stephen Boyd
2017-08-11 22:26           ` Stephen Boyd
2017-08-15 11:36           ` Peter Rosin
2017-08-15 11:36             ` Peter Rosin
2017-08-15 11:36             ` Peter Rosin
2017-07-14 21:40 ` [PATCH v2 3/3] arm64: dts: qcom: Collapse usb support into one node Stephen Boyd
2017-07-14 21:40   ` Stephen Boyd
2017-08-17  6:43   ` Shawn Guo
2017-08-17  6:43     ` Shawn Guo
2017-08-30 20:45     ` Stephen Boyd
2017-08-30 20:45       ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170718044111.GA13320@b29397-desktop \
    --to=hzpeterchen@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.