Re: Chipidea in device mode & VBUS

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

 



//adding cc to linux-usb ml

2016-03-29 7:55 GMT+03:00 Peter Chen <hzpeterchen@xxxxxxxxx>:
> Would you please try below patch to see if it works for you:

With the patch applied the code enters "ci_udc_vbus_session", but too early,
before the gadget driver is loaded - during the probe of ci_hdrc. This
means that
"ci->driver" is null, so it doesn't enter the gadget_active section.

Svet.


2016-03-29 7:55 GMT+03:00 Peter Chen <hzpeterchen@xxxxxxxxx>:
> On Mon, Mar 28, 2016 at 9:50 PM, Светослав Нейков <svetoslav@xxxxxxxxxxx> wrote:
>> Thanks for the quick response Peter. I am powering the board from the
>> host, so VBUS is on as long as the device is powered. In this case
>> extcon doesn't apply. But it's a nice option if alternative power is
>> provided.
>> This is not a commercial project, I am using a hacked WR-703N router,
>> so certification is not on the table.
>>
>
> Would you please try below patch to see if it works for you:
>
> From a1fe3d7c030168bfc41524158b46271cc0e9f9f3 Mon Sep 17 00:00:00 2001
> From: Peter Chen <peter.chen@xxxxxxx>
> Date: Tue, 29 Mar 2016 12:23:34 +0800
> Subject: [PATCH 1/1] usb: chipidea: add flag CI_HDRC_DP_ALWAYS_PULLUP
>
> For some platforms, the vbus status doesn't be known by system at
> device mode. So, there is no way to trigger pulling dp up. We add
> a platform flag CI_HDRC_DP_ALWAYS_PULLUP to cover this situation.
> With this flag set, the dp will be pulled up during the driver probe.
>
> Signed-off-by: Peter Chen <peter.chen@xxxxxxx>
> Cc: Svetoslav Neykov <svetoslav@xxxxxxxxxxx>
> ---
>  drivers/usb/chipidea/ci.h    |    2 ++
>  drivers/usb/chipidea/core.c  |    6 ++++--
>  drivers/usb/chipidea/otg.c   |    4 +++-
>  include/linux/usb/chipidea.h |    1 +
>  4 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
> index cd41455..f81dd3b 100644
> --- a/drivers/usb/chipidea/ci.h
> +++ b/drivers/usb/chipidea/ci.h
> @@ -199,6 +199,7 @@ struct hw_bank {
>   * @in_lpm: if the core in low power mode
>   * @wakeup_int: if wakeup interrupt occur
>   * @rev: The revision number for controller
> + * @dp_always_pullup: keep dp always pullup at device mode
>   */
>  struct ci_hdrc {
>   struct device *dev;
> @@ -248,6 +249,7 @@ struct ci_hdrc {
>   bool in_lpm;
>   bool wakeup_int;
>   enum ci_revision rev;
> + bool dp_always_pullup;
>  };
>
>  static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 1ca7b04..6f22c6c 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -897,7 +897,7 @@ static inline void ci_role_destroy(struct ci_hdrc *ci)
>  {
>   ci_hdrc_gadget_destroy(ci);
>   ci_hdrc_host_destroy(ci);
> - if (ci->is_otg)
> + if (!ci->dp_always_pullup && ci->roles[CI_ROLE_GADGET])
>   ci_hdrc_otg_destroy(ci);
>  }
>
> @@ -946,6 +946,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
>   CI_HDRC_IMX28_WRITE_FIX);
>   ci->supports_runtime_pm = !!(ci->platdata->flags &
>   CI_HDRC_SUPPORTS_RUNTIME_PM);
> + ci->dp_always_pullup = !!(ci->platdata->flags &
> + CI_HDRC_DP_ALWAYS_PULLUP);
>
>   ret = hw_device_init(ci, base);
>   if (ret < 0) {
> @@ -1012,7 +1014,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
>   goto deinit_phy;
>   }
>
> - if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
> + if (!ci->dp_always_pullup && ci->roles[CI_ROLE_GADGET]) {
>   ret = ci_hdrc_otg_init(ci);
>   if (ret) {
>   dev_err(dev, "init otg fails, ret = %d\n", ret);
> diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
> index 03b6743..58be59e 100644
> --- a/drivers/usb/chipidea/otg.c
> +++ b/drivers/usb/chipidea/otg.c
> @@ -95,8 +95,10 @@ enum ci_role ci_otg_role(struct ci_hdrc *ci)
>
>  void ci_handle_vbus_change(struct ci_hdrc *ci)
>  {
> - if (!ci->is_otg)
> + if (ci->dp_always_pullup) {
> + usb_gadget_vbus_connect(&ci->gadget);
>   return;
> + }
>
>   if (hw_read_otgsc(ci, OTGSC_BSV))
>   usb_gadget_vbus_connect(&ci->gadget);
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index 8649930..d21fef9 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -55,6 +55,7 @@ struct ci_hdrc_platform_data {
>  #define CI_HDRC_OVERRIDE_AHB_BURST BIT(9)
>  #define CI_HDRC_OVERRIDE_TX_BURST BIT(10)
>  #define CI_HDRC_OVERRIDE_RX_BURST BIT(11)
> +#define CI_HDRC_DP_ALWAYS_PULLUP BIT(12)
>   enum usb_dr_mode dr_mode;
>  #define CI_HDRC_CONTROLLER_RESET_EVENT 0
>  #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
> --
> 1.7.9.5
>
> --
> BR,
> 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