On Wed, May 27, 2015 at 07:50:08PM +0800, Li Jun wrote: > Set gadget's otg features according to controller's capability and usb property > in device tree. > > Signed-off-by: Li Jun <jun.li@xxxxxxxxxxxxx> > --- > drivers/usb/chipidea/core.c | 12 ++++++++++++ > drivers/usb/chipidea/udc.c | 19 ++++++++++++++++++- > include/linux/usb/chipidea.h | 3 +++ > 3 files changed, 33 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c > index 74fea4f..3a5e7b8 100644 > --- a/drivers/usb/chipidea/core.c > +++ b/drivers/usb/chipidea/core.c > @@ -588,6 +588,18 @@ static int ci_get_platdata(struct device *dev, > of_usb_host_tpl_support(dev->of_node); > } > > + if (platdata->dr_mode == USB_DR_MODE_OTG) { > + if (!platdata->srp_support) > + platdata->srp_support = > + of_usb_otg_srp_support(dev->of_node); > + if (!platdata->hnp_support) > + platdata->hnp_support = > + of_usb_otg_hnp_support(dev->of_node); > + if (!platdata->adp_support) > + platdata->adp_support = > + of_usb_otg_adp_support(dev->of_node); > + } > + > if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) > platdata->flags |= CI_HDRC_FORCE_FULLSPEED; > > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c > index 764f668..698f699 100644 > --- a/drivers/usb/chipidea/udc.c > +++ b/drivers/usb/chipidea/udc.c > @@ -1821,6 +1821,23 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci) > } > > /** > + * udc_update_otg_config: update gadget otg config > + * * @ci: chipidea controller > + */ > +static void udc_update_otg_config(struct ci_hdrc *ci) > +{ > + if (!ci->is_otg) > + return; > + > + ci->gadget.srp_support = ci->platdata->srp_support; > + ci->gadget.hnp_support = ci->platdata->hnp_support; > + ci->gadget.adp_support = ci->platdata->adp_support; > + if (ci->gadget.srp_support || ci->gadget.hnp_support || > + ci->gadget.adp_support) > + ci->gadget.is_otg = 1; > +} > + > +/** > * udc_start: initialize gadget role > * @ci: chipidea controller > */ > @@ -1834,9 +1851,9 @@ static int udc_start(struct ci_hdrc *ci) > ci->gadget.ops = &usb_gadget_ops; > ci->gadget.speed = USB_SPEED_UNKNOWN; > ci->gadget.max_speed = USB_SPEED_HIGH; > - ci->gadget.is_otg = ci->is_otg ? 1 : 0; > ci->gadget.name = ci->platdata->name; > > + udc_update_otg_config(ci); > INIT_LIST_HEAD(&ci->gadget.ep_list); > > /* alloc resources */ > diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h > index ab94f78..c0501bb 100644 > --- a/include/linux/usb/chipidea.h > +++ b/include/linux/usb/chipidea.h > @@ -35,6 +35,9 @@ struct ci_hdrc_platform_data { > void (*notify_event) (struct ci_hdrc *ci, unsigned event); > struct regulator *reg_vbus; > bool tpl_support; > + bool srp_support; > + bool hnp_support; > + bool adp_support; > }; > > /* Default offset of capability registers */ > -- > 1.9.1 > Acked-by: Peter Chen <peter.chen@xxxxxxxxxxxxx> -- 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