RE: [RESEND PATCH v11 2/4] gadget: Support for the usb charger framework
Hi > -Original Message- > From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > ow...@vger.kernel.org] On Behalf Of Baolin Wang > Sent: Monday, June 13, 2016 4:47 PM > To: ba...@kernel.org; gre...@linuxfoundation.org; s...@kernel.org; > dbarysh...@gmail.com; dw...@infradead.org > Cc: r...@kernel.org; m.szyprow...@samsung.com; ruslan.bilo...@gmail.com; > peter.c...@freescale.com; st...@rowland.harvard.edu; r.bald...@samsung.com; > yoshihiro.shimoda...@renesas.com; lee.jo...@linaro.org; broo...@kernel.org; > ckee...@opensource.wolfsonmicro.com; patc...@opensource.wolfsonmicro.com; > baolin.w...@linaro.org; linux...@vger.kernel.org; linux- > u...@vger.kernel.org; device-mainlin...@lists.linuxfoundation.org; linux- > ker...@vger.kernel.org > Subject: [RESEND PATCH v11 2/4] gadget: Support for the usb charger > framework > > For supporting the usb charger, it adds the usb_charger_init() and > usb_charger_exit() functions for usb charger initialization and exit. > > It will report to the usb charger when the gadget state is changed, then > the usb charger can do the power things. > > Signed-off-by: Baolin Wang <baolin.w...@linaro.org> Reviewed-by: Li Jun <jun...@nxp.com> Tested-by: Li Jun <jun...@nxp.com> > --- > drivers/usb/gadget/udc/udc-core.c | 11 +++ > include/linux/usb/gadget.h| 11 +++ > 2 files changed, 22 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RESEND PATCH v11 2/4] gadget: Support for the usb charger framework
Hi, [auto build test ERROR on balbi-usb/next] [also build test ERROR on v4.7-rc3 next-20160609] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-usb-charger-framework-to-deal-with-the-usb-gadget-power-negotation/20160613-165523 base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next config: x86_64-allmodconfig (attached as .config) compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): >> ERROR: "usb_charger_init" [drivers/usb/gadget/udc/udc-core.ko] undefined! >> ERROR: "usb_charger_plug_by_gadget" [drivers/usb/gadget/udc/udc-core.ko] >> undefined! >> ERROR: "usb_charger_exit" [drivers/usb/gadget/udc/udc-core.ko] undefined! >> ERROR: "usb_charger_set_cur_limit_by_type" >> [drivers/usb/gadget/libcomposite.ko] undefined! >> ERROR: "usb_charger_set_cur_limit_by_type" >> [drivers/usb/gadget/legacy/gadgetfs.ko] undefined! --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: [RESEND PATCH v11 2/4] gadget: Support for the usb charger framework
Hi, [auto build test WARNING on balbi-usb/next] [also build test WARNING on v4.7-rc3 next-20160609] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-usb-charger-framework-to-deal-with-the-usb-gadget-power-negotation/20160613-165523 base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next reproduce: make htmldocs All warnings (new ones prefixed by >>): include/linux/usb/gadget.h:228: warning: No description found for parameter 'claimed' include/linux/usb/gadget.h:228: warning: No description found for parameter 'enabled' >> include/linux/usb/gadget.h:661: warning: No description found for parameter >> 'charger' include/linux/usb/gadget.h:661: warning: No description found for parameter 'quirk_altset_not_supp' include/linux/usb/gadget.h:661: warning: No description found for parameter 'quirk_stall_not_supp' include/linux/usb/gadget.h:661: warning: No description found for parameter 'quirk_zlp_not_supp' include/linux/usb/composite.h:507: warning: Excess struct/union/enum/typedef member 'setup_pending' description in 'usb_composite_dev' include/linux/usb/composite.h:507: warning: Excess struct/union/enum/typedef member 'os_desc_pending' description in 'usb_composite_dev' drivers/usb/gadget/function/f_acm.c:1: warning: no structured comments found drivers/usb/gadget/function/f_ecm.c:1: warning: no structured comments found drivers/usb/gadget/function/f_subset.c:1: warning: no structured comments found drivers/usb/gadget/function/f_obex.c:1: warning: no structured comments found drivers/usb/gadget/function/f_serial.c:1: warning: no structured comments found vim +/charger +661 include/linux/usb/gadget.h d8318d7f include/linux/usb/gadget.h David Cohen 2013-12-09 645 898c6086 include/linux/usb/gadget.h Felipe Balbi2011-11-22 646 unsignedsg_supported:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 647 unsignedis_otg:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 648 unsignedis_a_peripheral:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 649 unsignedb_hnp_enable:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 650 unsigneda_hnp_support:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 651 unsigneda_alt_hnp_support:1; 75a9c82a include/linux/usb/gadget.h Li Jun 2016-02-19 652 unsignedhnp_polling_support:1; 75a9c82a include/linux/usb/gadget.h Li Jun 2016-02-19 653 unsignedhost_request_flag:1; 0b2d2bba include/linux/usb/gadget.h David Cohen 2013-12-09 654 unsignedquirk_ep_out_aligned_size:1; ffd9a0fc include/linux/usb/gadget.h Robert Baldyga 2015-07-28 655 unsignedquirk_altset_not_supp:1; 02ded1b0 include/linux/usb/gadget.h Robert Baldyga 2015-07-28 656 unsignedquirk_stall_not_supp:1; ca1023c8 include/linux/usb/gadget.h Robert Baldyga 2015-07-28 657 unsignedquirk_zlp_not_supp:1; 80b2502c include/linux/usb/gadget.h Peter Chen 2015-01-28 658 unsignedis_selfpowered:1; ccdf138f include/linux/usb/gadget.h Robert Baldyga 2015-05-04 659 unsigneddeactivated:1; ccdf138f include/linux/usb/gadget.h Robert Baldyga 2015-05-04 660 unsignedconnected:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 @661 }; 5702f753 include/linux/usb/gadget.h Felipe Balbi2013-07-17 662 #define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 663 ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 664 static inline void set_gadget_data(struct usb_gadget *gadget, void *data) ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 665 { dev_set_drvdata(>dev, data); } ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 666 static inline void *get_gadget_data(struct usb_gadget *gadget) ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 667 { return dev_get_drvdata(>dev); } f48cf80f include/linux/usb/gadget.h Fabien Chouteau 2010-04-23 668 static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) f48cf80f include/linux/usb/gadget.h Fabien Chouteau 2010-04-23 669 { :: The code at line 661 was first introduced by commit :: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2 :: TO: Linus Torvalds:: CC: Linus Torvalds --- 0-DAY kernel test
[RESEND PATCH v11 2/4] gadget: Support for the usb charger framework
For supporting the usb charger, it adds the usb_charger_init() and usb_charger_exit() functions for usb charger initialization and exit. It will report to the usb charger when the gadget state is changed, then the usb charger can do the power things. Signed-off-by: Baolin Wang--- drivers/usb/gadget/udc/udc-core.c | 11 +++ include/linux/usb/gadget.h| 11 +++ 2 files changed, 22 insertions(+) diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index 6e8300d..84c098c 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -28,6 +28,7 @@ #include #include #include +#include /** * struct usb_udc - describes one usb device controller @@ -242,6 +243,9 @@ static void usb_gadget_state_work(struct work_struct *work) struct usb_gadget *gadget = work_to_gadget(work); struct usb_udc *udc = gadget->udc; + /* when the gadget state is changed, then report to USB charger */ + usb_charger_plug_by_gadget(gadget, gadget->state); + if (udc) sysfs_notify(>dev.kobj, NULL, "state"); } @@ -411,6 +415,10 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, if (ret) goto err4; + ret = usb_charger_init(gadget); + if (ret) + goto err5; + usb_gadget_set_state(gadget, USB_STATE_NOTATTACHED); udc->vbus = true; @@ -431,6 +439,8 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, return 0; +err5: + device_del(>dev); err4: list_del(>list); mutex_unlock(_lock); @@ -539,6 +549,7 @@ void usb_del_gadget_udc(struct usb_gadget *gadget) kobject_uevent(>dev.kobj, KOBJ_REMOVE); flush_work(>work); device_unregister(>dev); + usb_charger_exit(gadget); device_unregister(>dev); } EXPORT_SYMBOL_GPL(usb_del_gadget_udc); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 457651b..40390ec 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -24,6 +24,7 @@ #include #include #include +#include struct usb_ep; @@ -639,6 +640,8 @@ struct usb_gadget { unsignedout_epnum; unsignedin_epnum; struct usb_otg_caps *otg_caps; + /* negotiate the power with the usb charger */ + struct usb_charger *charger; unsignedsg_supported:1; unsignedis_otg:1; @@ -855,10 +858,18 @@ static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget) * reporting how much power the device may consume. For example, this * could affect how quickly batteries are recharged. * + * It will also notify the USB charger how much power the device may + * consume if there is a USB charger linking with the gadget. + * * Returns zero on success, else negative errno. */ static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) { + if (gadget->charger) + usb_charger_set_cur_limit_by_type(gadget->charger, + gadget->charger->type, + mA); + if (!gadget->ops->vbus_draw) return -EOPNOTSUPP; return gadget->ops->vbus_draw(gadget, mA); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v11 2/4] gadget: Support for the usb charger framework
For supporting the usb charger, it adds the usb_charger_init() and usb_charger_exit() functions for usb charger initialization and exit. It will report to the usb charger when the gadget state is changed, then the usb charger can do the power things. Signed-off-by: Baolin Wang--- drivers/usb/gadget/udc/udc-core.c | 11 +++ include/linux/usb/gadget.h| 11 +++ 2 files changed, 22 insertions(+) diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index e4e70e1..58207d0 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -28,6 +28,7 @@ #include #include #include +#include /** * struct usb_udc - describes one usb device controller @@ -230,6 +231,9 @@ static void usb_gadget_state_work(struct work_struct *work) struct usb_gadget *gadget = work_to_gadget(work); struct usb_udc *udc = gadget->udc; + /* when the gadget state is changed, then report to USB charger */ + usb_charger_plug_by_gadget(gadget, gadget->state); + if (udc) sysfs_notify(>dev.kobj, NULL, "state"); } @@ -399,6 +403,10 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, if (ret) goto err4; + ret = usb_charger_init(gadget); + if (ret) + goto err5; + usb_gadget_set_state(gadget, USB_STATE_NOTATTACHED); udc->vbus = true; @@ -419,6 +427,8 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, return 0; +err5: + device_del(>dev); err4: list_del(>list); mutex_unlock(_lock); @@ -527,6 +537,7 @@ void usb_del_gadget_udc(struct usb_gadget *gadget) kobject_uevent(>dev.kobj, KOBJ_REMOVE); flush_work(>work); device_unregister(>dev); + usb_charger_exit(gadget); device_unregister(>dev); } EXPORT_SYMBOL_GPL(usb_del_gadget_udc); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 5d4e151..9735309 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -24,6 +24,7 @@ #include #include #include +#include struct usb_ep; @@ -639,6 +640,8 @@ struct usb_gadget { unsignedout_epnum; unsignedin_epnum; struct usb_otg_caps *otg_caps; + /* negotiate the power with the usb charger */ + struct usb_charger *charger; unsignedsg_supported:1; unsignedis_otg:1; @@ -855,10 +858,18 @@ static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget) * reporting how much power the device may consume. For example, this * could affect how quickly batteries are recharged. * + * It will also notify the USB charger how much power the device may + * consume if there is a USB charger linking with the gadget. + * * Returns zero on success, else negative errno. */ static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) { + if (gadget->charger) + usb_charger_set_cur_limit_by_type(gadget->charger, + gadget->charger->type, + mA); + if (!gadget->ops->vbus_draw) return -EOPNOTSUPP; return gadget->ops->vbus_draw(gadget, mA); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html