Introduce usb charger framework to deal with the usb gadget power negotation
Subsystems (3)
v8 cover Introduce usb charger framework to deal with the usb gadget power negotation
Currently the Linux kernel does not provide any standard integration of this feature that integrates the USB subsystem with the system power regulation provided by PMICs meaning that either vendors must add this in their kernels or USB gadget devices based on Linux (such as mobile phones) may not behave as they should. Thus provide a standard framework for doing this in kernel.
Now introduce one user with wm831x_power to support and test the usb charger, which is pending testing. Moreover there may be other potential users will use it in future.
Changes since v7:
- Add documentations for sysfs attributes.
Other prominent improvements since v5:
- Remove the notifier chain things from the gadget and introduce one callback function to report to the usb charger when the gadget state is changed.
- Flesh out the port type detection which combines the USB negotiation and PMICs detection.
- Supply the notification mechanism to userspace when charger state is changed.
- Integrate with the vbus staff in the gadget API.
Baolin Wang (4):
gadget: Introduce the usb charger framework
gadget: Support for the usb charger framework
gadget: Integrate with the usb gadget supporting for usb charger
power: wm831x_power: Support USB charger current limit management
drivers/power/wm831x_power.c | 69 ++++ drivers/usb/gadget/Kconfig | 7 + drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/charger.c | 714 +++++++++++++++++++++++++++++++++++++ drivers/usb/gadget/udc/udc-core.c | 11 + include/linux/mfd/wm831x/pdata.h | 3 + include/linux/usb/gadget.h | 11 + include/linux/usb/usb_charger.h | 164 +++++++++ 8 files changed, 980 insertions(+) create mode 100644 drivers/usb/gadget/charger.c create mode 100644 include/linux/usb/usb_charger.h
Signature · 1 line
1.7.9.5
PATCH v8 1/4 gadget: Introduce the usb charger framework
This patch introduces the usb charger driver based on usb gadget that makes an enhancement to a power driver. It works well in practice but that requires a system with suitable hardware.
The basic conception of the usb charger is that, when one usb charger is added or removed by reporting from the usb gadget state change or the extcon device state change, the usb charger will report to power user to set the current limitation.
The usb charger will register notifiees on the usb gadget or the extcon device to get notified the usb charger state. It also supplies the notification mechanism to userspace When the usb charger state is changed.
Power user will register a notifiee on the usb charger to get notified by status changes from the usb charger. It will report to power user to set the current limitation when detecting the usb charger is added or removed from extcon device state or usb gadget state.
This patch doesn't yet integrate with the gadget code, so some functions which rely on the 'gadget' are not completed, that will be implemented in the following patches.
--- drivers/usb/gadget/Kconfig | 7 + drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/charger.c | 675 +++++++++++++++++++++++++++++++++++++++ include/linux/usb/usb_charger.h | 164 ++++++++++ 4 files changed, 847 insertions(+) create mode 100644 drivers/usb/gadget/charger.c create mode 100644 include/linux/usb/usb_charger.h
drivers/usb/gadget/Kconfig +7 -0
@@ -133,6 +133,13 @@ config U_SERIAL_CONSOLE help It supports the serial gadget can be used as a console. +config USB_CHARGER + bool "USB charger support" + help + The usb charger driver based on the usb gadget that makes an + enhancement to a power driver which can set the current limitation + when the usb charger is added or removed. + source "drivers/usb/gadget/udc/Kconfig" #
drivers/usb/gadget/Makefile +1 -0
@@ -10,3 +10,4 @@ libcomposite-y := usbstring.o config.o epautoconf.o libcomposite-y += composite.o functions.o configfs.o u_f.o obj-$(CONFIG_USB_GADGET) += udc/ function/ legacy/ +obj-$(CONFIG_USB_CHARGER) += charger.o
drivers/usb/gadget/charger.c new file +675 -0
675 lines not on this page · raw message
include/linux/usb/usb_charger.h new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v8 1/4] gadget: Introduce the usb charger framework
Hi!
Quoted 5 lines
drivers/usb/gadget/charger.c new file +5
-0+/* +* Sysfs attributes: +* +* These sysfs attributes are used for showing and setting different type +* (SDP/DCP/CDP/ACA) chargers' current limitation.
drivers/usb/gadget/charger.c line 60
Quoted 10 lines
drivers/usb/gadget/charger.c new file +10
-0+*/ +static ssize_t sdp_limit_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct usb_charger *uchger =dev_to_uchger (dev); + +return sprintf (buf,"%d\n" , uchger->cur_limit.sdp_cur_limit); +} +
Sysfs attributes... can we get appropriate documentation for them?
Thanks,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v8 1/4] gadget: Introduce the usb charger framework
Hi Pavel,
Quoted 11 lines · Pavel Machek
Hi!
Quoted 9 lines
drivers/usb/gadget/charger.c new file +9
-0+/* +* Sysfs attributes: +* +* These sysfs attributes are used for showing and setting different type +* (SDP/DCP/CDP/ACA) chargers' current limitation. +*/ +static ssize_t sdp_limit_show (struct device *dev, +struct device_attribute *attr, +char *buf)
Quoted 8 lines
drivers/usb/gadget/charger.c line 60
Quoted 6 lines
drivers/usb/gadget/charger.c new file +6
-0+{ +struct usb_charger *uchger =dev_to_uchger (dev); + +return sprintf (buf,"%d\n" , uchger->cur_limit.sdp_cur_limit); +} +Sysfs attributes... can we get appropriate documentation for them?
I've send out the v10 patchset which fixed this issue. Thanks.
Quoted 6 lines
Thanks,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Signature · 2 lines
Baolin.wang Best Regards
PATCH v8 2/4 gadget: Support for the usb charger framework
In reply to Baolin WangFor 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.
Introduce a callback 'get_charger_type' which will implemented by user for usb gadget operations to get the usb charger type.
--- drivers/usb/gadget/udc/udc-core.c | 11 +++++++++++ include/linux/usb/gadget.h | 11 +++++++++++ 2 files changed, 22 insertions(+)
drivers/usb/gadget/udc/udc-core.c +11 -0
@@ -28,6 +28,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb.h> +#include <linux/usb/usb_charger.h> /** * 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 (&udc->dev.kobj,NULL ,"state" ); }
@@ -423,8 +427,14 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,mutex_unlock (&udc_lock); + ret =usb_charger_init (gadget); +if (ret) + goto err5; +return 0 ; +err5: +device_del (&udc->dev); err4:list_del (&udc->list);mutex_unlock (&udc_lock);
@@ -503,6 +513,7 @@ void usb_del_gadget_udc(struct usb_gadget *gadget)kobject_uevent (&udc->dev.kobj,KOBJ_REMOVE );flush_work (&gadget->work);device_unregister (&udc->dev); +usb_charger_exit (gadget);device_unregister (&gadget->dev); }EXPORT_SYMBOL_GPL (usb_del_gadget_udc);
include/linux/usb/gadget.h +11 -0
@@ -24,6 +24,7 @@#include <linux/types.h> #include <linux/workqueue.h> #include <linux/usb/ch9.h> +#include <linux/usb/usb_charger.h> struct usb_ep ;
@@ -563,6 +564,7 @@ struct usb_gadget_ops {struct usb_ep *(*match_ep)(struct usb_gadget *,struct usb_endpoint_descriptor *,struct usb_ss_ep_comp_descriptor *); +enum usb_charger_type (*get_charger_type)(struct usb_gadget *); };/**
@@ -635,6 +637,8 @@ struct usb_gadget {unsigned out_epnum;unsigned in_epnum;struct usb_otg_caps *otg_caps; +/* negotiate the power with the usb charger */ +struct usb_charger *charger; unsigned sg_supported:1; unsigned is_otg:1;
@@ -839,10 +843,17 @@ 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, +usb_charger_detect_type (gadget->charger), mA); +if (!gadget->ops->vbus_draw)return -EOPNOTSUPP ;return gadget->ops->vbus_draw (gadget, mA);
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
kbuild test robot
build botRe: [PATCH v8 2/4] gadget: Support for the usb charger framework
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Baolin,
[auto build test ERROR on v4.5-rc7]
[also build test ERROR on next-20160324]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-usb-charger-framework-to-deal-with-the-usb-gadget-power-negotation/20160324-204018 config: m68k-allmodconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68k
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_detect_type" [drivers/usb/gadget/libcomposite.ko] undefined! >> ERROR: "usb_charger_set_cur_limit_by_type" [drivers/usb/gadget/legacy/gadgetfs.ko] undefined! >> ERROR: "usb_charger_detect_type" [drivers/usb/gadget/legacy/gadgetfs.ko] undefined!
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v8 3/4 gadget: Integrate with the usb gadget supporting for usb charger
In reply to Baolin WangWhen the usb gadget supporting for usb charger is ready, the usb charger should get the type by the 'get_charger_type' callback which is implemented by the usb gadget operations, and get the usb charger pointer from struct 'usb_gadget'.
--- drivers/usb/gadget/charger.c | 43 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-)
drivers/usb/gadget/charger.c +41 -2
@@ -278,7 +278,11 @@ EXPORT_SYMBOL_GPL(usb_charger_unregister_notify);enum usb_charger_type usb_charger_detect_type (struct usb_charger *uchger) { -if (uchger->psy) { +if (uchger->gadget && uchger->gadget->ops + && uchger->gadget->ops->get_charger_type) { + uchger->type = + uchger->gadget->ops->get_charger_type (uchger->gadget); + }else if (uchger->psy) {union power_supply_propval val; power_supply_get_property(uchger->psy,
@@ -485,6 +489,29 @@ usb_charger_plug_by_extcon(struct notifier_block *nb,int usb_charger_plug_by_gadget (struct usb_gadget *gadget,unsigned long state) { +struct usb_charger *uchger = gadget->charger; +enum usb_charger_state uchger_state; + +if (!uchger) +return -EINVAL ; + +/* Report event to power to setting the current limitation +* for this usb charger when one usb charger state is changed +* with detecting by usb gadget state. +*/ +if (uchger->old_gadget_state != state) { + uchger->old_gadget_state = state; + +if (state >=USB_STATE_ATTACHED ) + uchger_state =USB_CHARGER_PRESENT ; +else if (state ==USB_STATE_NOTATTACHED ) + uchger_state =USB_CHARGER_REMOVE ; +else + uchger_state =USB_CHARGER_DEFAULT ; + +usb_charger_notify_others (uchger, uchger_state); + } +return 0 ; }EXPORT_SYMBOL_GPL (usb_charger_plug_by_gadget);
@@ -641,6 +668,7 @@ int usb_charger_init(struct usb_gadget *ugadget)/* register a notifier on a usb gadget device */ uchger->gadget = ugadget; + ugadget->charger = uchger; uchger->old_gadget_state = ugadget->state;/* register a new usb charger */
@@ -661,7 +689,18 @@ fail:int usb_charger_exit (struct usb_gadget *ugadget) { -return 0 ; +struct usb_charger *uchger = ugadget->charger; + +if (!uchger) +return -EINVAL ; + +if (uchger->extcon_dev) +extcon_unregister_notifier (uchger->extcon_dev, +EXTCON_USB , &uchger->extcon_nb.nb); + +ida_simple_remove (&usb_charger_ida, uchger->id); + +return usb_charger_unregister (uchger); }static int __init usb_charger_sysfs_init (void )
Signature · 1 line
1.7.9.5
PATCH v8 4/4 power: wm831x_power: Support USB charger current limit management
In reply to Baolin WangIntegrate with the newly added USB charger interface to limit the current we draw from the USB input based on the input device configuration identified by the USB stack, allowing us to charge more quickly from high current inputs without drawing more current than specified from others.
--- drivers/power/wm831x_power.c | 69 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/wm831x/pdata.h | 3 ++ 2 files changed, 72 insertions(+)
drivers/power/wm831x_power.c +69 -0
@@ -13,6 +13,7 @@#include <linux/platform_device.h> #include <linux/power_supply.h> #include <linux/slab.h> +#include <linux/usb/usb_charger.h> #include <linux/mfd/wm831x/core.h> #include <linux/mfd/wm831x/auxadc.h>
@@ -31,6 +32,8 @@ struct wm831x_power {char usb_name[20 ];char battery_name[20 ];bool have_battery; +struct usb_charger *usb_charger; +struct notifier_block usb_notify; }; static int wm831x_power_check_online(struct wm831x *wm831x, int supply,
@@ -125,6 +128,43 @@ static enum power_supply_property wm831x_usb_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, }; +/* In milliamps */ +static unsigned int wm831x_usb_limits[] = { +0 , +2 , +100 , +500 , +900 , +1500 , +1800 , +550 , +}; + +static int wm831x_usb_limit_change (struct notifier_block *nb, +unsigned long limit,void *data) +{ +struct wm831x_power *wm831x_power =container_of (nb, + struct wm831x_power, + usb_notify); +int i, best; + +/* Find the highest supported limit */ + best =0 ; +for (i =0 ; i <ARRAY_SIZE (wm831x_usb_limits); i++) { +if (limit >= wm831x_usb_limits[i] && + wm831x_usb_limits[best] < wm831x_usb_limits[i]) + best = i; + } + +dev_dbg (wm831x_power->wm831x->dev, +"Limiting USB current to %dmA" , wm831x_usb_limits[best]); + +wm831x_set_bits (wm831x_power->wm831x,WM831X_POWER_STATE , +WM831X_USB_ILIM_MASK , best); + +return 0 ; +} +/********************************************************************* * Battery properties *********************************************************************/
@@ -607,8 +647,31 @@ static int wm831x_power_probe(struct platform_device *pdev) } } +if (wm831x_pdata && wm831x_pdata->usb_gadget) { + power->usb_charger = +usb_charger_find_by_name (wm831x_pdata->usb_gadget); +if (IS_ERR (power->usb_charger)) { + ret =PTR_ERR (power->usb_charger); +dev_err (&pdev->dev, +"Failed to find USB gadget: %d\n" , ret); + goto err_bat_irq; + } + + power->usb_notify.notifier_call = wm831x_usb_limit_change; + + ret =usb_charger_register_notify (power->usb_charger, + &power->usb_notify); +if (ret !=0 ) { +dev_err (&pdev->dev, +"Failed to register notifier: %d\n" , ret); + goto err_usb_charger; + } + } +return ret; +err_usb_charger: +/* put_device on charger */ err_bat_irq: --i;for (; i >=0 ; i--) {
@@ -637,6 +700,12 @@ static int wm831x_power_remove(struct platform_device *pdev)struct wm831x *wm831x = wm831x_power->wm831x;int irq, i; +if (wm831x_power->usb_charger) { +usb_charger_unregister_notify (wm831x_power->usb_charger, + &wm831x_power->usb_notify); +/* Free charger */ + } +for (i =0 ; i <ARRAY_SIZE (wm831x_bat_irqs); i++) { irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev,
include/linux/mfd/wm831x/pdata.h +3 -0
@@ -126,6 +126,9 @@ struct wm831x_pdata {/** The driver should initiate a power off sequence during shutdown */ bool soft_shutdown; +/** dev_name of USB charger gadget to integrate with */ +const char *usb_gadget; +int irq_base;int gpio_base;int gpio_defaults[WM831X_GPIO_NUM ];
Signature · 1 line
1.7.9.5
kbuild test robot
build botRe: [PATCH v8 4/4] power: wm831x_power: Support USB charger current limit management
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Baolin,
[auto build test ERROR on v4.5-rc7]
[also build test ERROR on next-20160324]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-usb-charger-framework-to-deal-with-the-usb-gadget-power-negotation/20160324-204018 config: m68k-allmodconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68k
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_detect_type" [drivers/usb/gadget/libcomposite.ko] undefined!
ERROR: "usb_charger_set_cur_limit_by_type" [drivers/usb/gadget/legacy/gadgetfs.ko] undefined!
ERROR: "usb_charger_detect_type" [drivers/usb/gadget/legacy/gadgetfs.ko] undefined!
>> ERROR: "usb_charger_register_notify" [drivers/power/wm831x_power.ko] undefined! >> ERROR: "usb_charger_find_by_name" [drivers/power/wm831x_power.ko] undefined! >> ERROR: "usb_charger_unregister_notify" [drivers/power/wm831x_power.ko] undefined!
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v8 4/4] power: wm831x_power: Support USB charger current limit management
In reply to Baolin WangQuoted 20 lines · Baolin Wang
drivers/power/wm831x_power.c +3
-0@@ -13,6 +13,7 @@#include <linux/platform_device.h> #include <linux/power_supply.h> #include <linux/slab.h> +#include <linux/usb/usb_charger.h> #include <linux/mfd/wm831x/core.h> #include <linux/mfd/wm831x/auxadc.h> @@ -31,6 +32,8 @@ struct wm831x_power {char usb_name[20 ];char battery_name[20 ];bool have_battery; +struct usb_charger *usb_charger; +struct notifier_block usb_notify; }; static int wm831x_power_check_online(struct wm831x *wm831x, int supply,
drivers/power/wm831x_power.c static enum power_supply_property wm831x_usb_props[] = { · line 132
Quoted 5 lines
drivers/power/wm831x_power.c +2
-0@@ -125,6 +128,43 @@ static enum power_supply_property wm831x_usb_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, }; +/* In milliamps */ +static unsigned int wm831x_usb_limits[] = {
const
Quoted 7 lines
drivers/power/wm831x_power.c +7
-0+0 , +2 , +100 , +500 , +900 , +1500 , + 1800,
drivers/power/wm831x_power.c static enum power_supply_property wm831x_usb_props[] = { · line 149
Quoted 10 lines
drivers/power/wm831x_power.c +10
-0+ 550, +}; + +static int wm831x_usb_limit_change (struct notifier_block *nb, +unsigned long limit,void *data) +{ +struct wm831x_power *wm831x_power =container_of (nb, + struct wm831x_power, + usb_notify); +int i, best;
unsigned int
drivers/power/wm831x_power.c static enum power_supply_property wm831x_usb_props[] = { · line 160
Quoted 11 lines
drivers/power/wm831x_power.c +11
-0+ +/* Find the highest supported limit */ + best =0 ; +for (i =0 ; i <ARRAY_SIZE (wm831x_usb_limits); i++) { +if (limit >= wm831x_usb_limits[i] && + wm831x_usb_limits[best] < wm831x_usb_limits[i]) + best = i; + } + +dev_dbg (wm831x_power->wm831x->dev, +"Limiting USB current to %dmA" , wm831x_usb_limits[best]);
%u
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH v8 4/4] power: wm831x_power: Support USB charger current limit management
Quoted 24 lines · Geert Uytterhoeven
Quoted 23 lines · Baolin Wang
drivers/power/wm831x_power.c +3
-0@@ -13,6 +13,7 @@#include <linux/platform_device.h> #include <linux/power_supply.h> #include <linux/slab.h> +#include <linux/usb/usb_charger.h> #include <linux/mfd/wm831x/core.h> #include <linux/mfd/wm831x/auxadc.h> @@ -31,6 +32,8 @@ struct wm831x_power {char usb_name[20 ];char battery_name[20 ];bool have_battery; +struct usb_charger *usb_charger; +struct notifier_block usb_notify; }; static int wm831x_power_check_online(struct wm831x *wm831x, int supply,@@ -125,6 +128,43 @@ static enum power_supply_property wm831x_usb_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, };
Quoted 4 lines
drivers/power/wm831x_power.c static enum power_supply_property wm831x_usb_props[] = { · line 132
Quoted 2 lines
drivers/power/wm831x_power.c +2
-0+/* In milliamps */ +static unsigned int wm831x_usb_limits[] = {const
OK.
Quoted 12 lines
Quoted 12 lines
drivers/power/wm831x_power.c +11
-0+0 , +2 , +100 , +500 , +900 , +1500 , +1800 , + 550, +}; + +static int wm831x_usb_limit_change(struct notifier_block *nb,
Quoted 8 lines
drivers/power/wm831x_power.c static enum power_supply_property wm831x_usb_props[] = { · line 149
Quoted 6 lines
drivers/power/wm831x_power.c +6
-0+ unsigned long limit, void *data) +{ + struct wm831x_power *wm831x_power = container_of(nb, + struct wm831x_power, + usb_notify); +int i, best;unsigned int
OK.
Quoted 14 lines
drivers/power/wm831x_power.c static enum power_supply_property wm831x_usb_props[] = { · line 160
Quoted 12 lines
drivers/power/wm831x_power.c +11
-0+ +/* Find the highest supported limit */ + best =0 ; +for (i =0 ; i <ARRAY_SIZE (wm831x_usb_limits); i++) { +if (limit >= wm831x_usb_limits[i] && + wm831x_usb_limits[best] < wm831x_usb_limits[i]) + best = i; + } + +dev_dbg (wm831x_power->wm831x->dev, +"Limiting USB current to %dmA" , wm831x_usb_limits[best]);%u
OK. Thanks for your comments.
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Signature · 2 lines
Baolin.wang Best Regards
Quoted 10 lines · Baolin Wang
Currently the Linux kernel does not provide any standard integration of this feature that integrates the USB subsystem with the system power regulation provided by PMICs meaning that either vendors must add this in their kernels or USB gadget devices based on Linux (such as mobile phones) may not behave as they should. Thus provide a standard framework for doing this in kernel.
Now introduce one user with
wm831x_powerto support and test the usb charger, which is pending testing. Moreover there may be other potential users will use it in future.
I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
Signature · 6 lines
Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Peter Chen
Quoted 6 lines · Baolin Wang
Currently the Linux kernel does not provide any standard integration of this feature that integrates the USB subsystem with the system power regulation provided by PMICs meaning that either vendors must add this in their kernels or USB gadget devices based on Linux (such as mobile phones) may not behave as they should. Thus provide a standard framework for doing this in kernel.
Quoted 8 lines
Quoted 4 lines
Now introduce one user with
wm831x_powerto support and test the usb charger, which is pending testing. Moreover there may be other potential users will use it in future.I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Quoted 4 lines
--
Best Regards,
Peter Chen
Signature · 2 lines
Baolin.wang Best Regards
Quoted 13 lines · Baolin Wang
Quoted 12 lines · Peter Chen
Quoted 10 lines · Baolin Wang
Currently the Linux kernel does not provide any standard integration of this feature that integrates the USB subsystem with the system power regulation provided by PMICs meaning that either vendors must add this in their kernels or USB gadget devices based on Linux (such as mobile phones) may not behave as they should. Thus provide a standard framework for doing this in kernel.
Now introduce one user with
wm831x_powerto support and test the usb charger, which is pending testing. Moreover there may be other potential users will use it in future.
Quoted 7 lines
Quoted 3 lines
I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Then, where is the code the test user to decide what kinds of USB charger (SDP, CDP, DCP) is connecting now?
Signature · 2 lines
Best Regards, Peter Chen
Quoted 18 lines · Peter Chen
Quoted 17 lines · Baolin Wang
Quoted 15 lines · Peter Chen
Quoted 10 lines · Baolin Wang
Currently the Linux kernel does not provide any standard integration of this feature that integrates the USB subsystem with the system power regulation provided by PMICs meaning that either vendors must add this in their kernels or USB gadget devices based on Linux (such as mobile phones) may not behave as they should. Thus provide a standard framework for doing this in kernel.
Now introduce one user with
wm831x_powerto support and test the usb charger, which is pending testing. Moreover there may be other potential users will use it in future.I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
Quoted 6 lines
Quoted 3 lines
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Then, where is the code the test user to decide what kinds of USB charger (SDP, CDP, DCP) is connecting now?
Users can choose to implement multiple ways to get the charger type In 'usb_charger_detect_type()' function.
Quoted 4 lines
--
Best Regards,
Peter Chen
Signature · 2 lines
Baolin.wang Best Regards
IA0KPiANCj4gT24gMjggTWFyY2ggMjAxNiBhdCAxNToxMywgUGV0ZXIgQ2hlbiA8aHpwZXRlcmNo ZW5AZ21haWwuY29tPiB3cm90ZToNCj4gPiBPbiBNb24sIE1hciAyOCwgMjAxNiBhdCAwMjo1MTo0 MFBNICswODAwLCBCYW9saW4gV2FuZyB3cm90ZToNCj4gPj4gT24gMjUgTWFyY2ggMjAxNiBhdCAx NTowOSwgUGV0ZXIgQ2hlbiA8aHpwZXRlcmNoZW5AZ21haWwuY29tPiB3cm90ZToNCj4gPj4gPiBP biBUaHUsIE1hciAyNCwgMjAxNiBhdCAwODozNTo1M1BNICswODAwLCBCYW9saW4gV2FuZyB3cm90 ZToNCj4gPj4gPj4gQ3VycmVudGx5IHRoZSBMaW51eCBrZXJuZWwgZG9lcyBub3QgcHJvdmlkZSBh bnkgc3RhbmRhcmQNCj4gPj4gPj4gaW50ZWdyYXRpb24gb2YgdGhpcyBmZWF0dXJlIHRoYXQgaW50 ZWdyYXRlcyB0aGUgVVNCIHN1YnN5c3RlbSB3aXRoDQo+ID4+ID4+IHRoZSBzeXN0ZW0gcG93ZXIg cmVndWxhdGlvbiBwcm92aWRlZCBieSBQTUlDcyBtZWFuaW5nIHRoYXQgZWl0aGVyDQo+ID4+ID4+ IHZlbmRvcnMgbXVzdCBhZGQgdGhpcyBpbiB0aGVpciBrZXJuZWxzIG9yIFVTQiBnYWRnZXQgZGV2 aWNlcyBiYXNlZA0KPiA+PiA+PiBvbiBMaW51eCAoc3VjaCBhcyBtb2JpbGUgcGhvbmVzKSBtYXkg bm90IGJlaGF2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FuIGNob29zZSB0byBp bXBsZW1lbnQgbXVsdGlwbGUgd2F5cyB0byBnZXQgdGhlIGNoYXJnZXIgdHlwZSBJbg0KPiAndXNi X2NoYXJnZXJfZGV0ZWN0X3R5cGUoKScgZnVuY3Rpb24uDQo+IA0KPiA+DQogDQpUaGVuLCBob3cg eW91IHRlc3QgeW91ciBjb2RlPyBXaGVuIHdlIGludHJvZHVjZSBhbiBBUEksIGF0IGxlYXN0LCB0 aGVyZSBpcyBvbmUNCnVzZXIgZm9yIGl0Lg0KDQpQZXRlcg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 29 lines · Peter Chen
Quoted 29 lines · Peter Chen
Quoted 8 lines · Baolin Wang
Quoted 7 lines · Peter Chen
Quoted 6 lines · Baolin Wang
Quoted 5 lines
Currently the Linux kernel does not provide any standard integration of this feature that integrates the USB subsystem with the system power regulation provided by PMICs meaning that either vendors must add this in their kernels or USB gadget devices based on Linux (such as mobile phones) may not behave as they should. Thus
provide a standard framework for doing this in kernel.
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Now introduce one user with
wm831x_powerto support and test the usb charger, which is pending testing. Moreover there may be other potential users will use it in future.Quoted 7 lines
Quoted 3 lines
I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Then, where is the code the test user to decide what kinds of USB charger (SDP, CDP, DCP) is connecting now?
Quoted 7 lines
Quoted 4 lines
Users can choose to implement multiple ways to get the charger type In '
usb_charger_detect_type()' function.Quoted 1 line
Then, how you test your code? When we introduce an API, at least, there is one user for it.
At first I've tested the API on my board to make sure it can work well, another hand we introduce one user 'wm831x_power' to support and test the usb charger.
Yes, The user 'wm831x_power' did not implement any callbacks in 'usb_charger_detect_type()' function, but in 'usb_charger_detect_type()' function it just supplies different callbacks to get the charger type with simple logic. Anyway we can try to implement one callback to get the charger type and test the API. Thanks.
Quoted 2 lines
Peter
Signature · 2 lines
Baolin.wang Best Regards
Quoted 5 lines · Baolin Wang
Yes, The user '
wm831x_power' did not implement any callbacks in 'usb_charger_detect_type()' function, but in 'usb_charger_detect_type()' function it just supplies different callbacks to get the charger type with simple logic. Anyway we can try to implement one callback to get the charger type and test the API.
The wm831x doesn't have any charger detection features, what it does have is hardware for implementing a current limit on the power drawn from USB. What it's looking for from this framework is for something to tell it how much current it should draw from USB so it can program the hardware appropriately to impose that limit.
Quoted 11 lines · Peter Chen
Quoted 6 lines · Baolin Wang
Quoted 3 lines
I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Then, where is the code the test user to decide what kinds of USB charger (SDP, CDP, DCP) is connecting now?
Even without detection of CDP and DCP we have configurability within SDP
- there's the 2.5mA suspended limit, the 100mA default limit and the higher 500mA limit which can be negotiated.
Quoted 10 lines · Mark Brown
Quoted 8 lines · Peter Chen
Quoted 6 lines · Baolin Wang
Quoted 3 lines
I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Quoted 6 lines
Quoted 2 lines
Then, where is the code the test user to decide what kinds of USB charger (SDP, CDP, DCP) is connecting now?
Even without detection of CDP and DCP we have configurability within SDP
- there's the 2.5mA suspended limit, the 100mA default limit and the higher 500mA limit which can be negotiated.
Well, things may be a little complicated.
- First, how to design get_charger_type for each udc driver? Since the charger detection process affects dp/dm signal, it can't be done during the enumeration or after that. So, the detection process can be only done after vbus has detected and before udc pull up dp.
Then, when the get_charger_type do real charger detection? My suggestion is, if the charger type is unknown, we do real one, else, we just return the stored type value.
- Second, When to notify charger IC to charger:
For SDP and CDP, it needs to notify charger IC after set configuration has finished.
For DCP (and ACA, I am not sure), can notify charger IC after charger detection has finished or later.
So, when we get charger is present, we need to notify charger IC at once for DCP (and ACA); But for SDP and CDP, we need to let the gadget composite core to notify charger IC after set configuration has finished, like the patch 2/4 does.
- Third, since composite driver covers 500mA (and more for CDP) after set configuration and 2mA after suspend, and vbus handler covers connect and disconnect. I can't see any reasons we need to notify gadget state for power driver, do we really need to have usb_charger_plug_by_gadget?
Signature · 2 lines
Best Regards, eter Chen
Quoted 11 lines · Peter Chen
Quoted 10 lines · Mark Brown
Quoted 8 lines · Peter Chen
Quoted 6 lines · Baolin Wang
Quoted 3 lines
I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Then, where is the code the test user to decide what kinds of USB charger (SDP, CDP, DCP) is connecting now?
Even without detection of CDP and DCP we have configurability within SDP
- there's the 2.5mA suspended limit, the 100mA default limit and the higher 500mA limit which can be negotiated.Well, things may be a little complicated.
I try to address your comments, maybe Mark need to do some complements. Thanks.
Quoted 9 lines
- First, how to design
get_charger_typefor each udc driver? Since the charger detection process affects dp/dm signal, it can't be done during the enumeration or after that. So, the detection process can be only done after vbus has detected and before udc pull up dp.Then, when the
get_charger_typedo real charger detection? My suggestion is, if the charger type is unknown, we do real one, else, we just return the stored type value.
I think that is why we let udc driver to implement the 'gadget->ops->get_charger_type()' callback, which can be controlled by udc driver.
Quoted 11 lines
- Second, When to notify charger IC to charger:
For SDP and CDP, it needs to notify charger IC after set configuration has finished.
For DCP (and ACA, I am not sure), can notify charger IC after charger detection has finished or later.So, when we get charger is present, we need to notify charger IC at once for DCP (and ACA); But for SDP and CDP, we need to let the gadget composite core to notify charger IC after set configuration has finished, like the patch 2/4 does.
But mostly charger IC is separate with gadget, so the charger IC doesn't need to worry about the gadget status.
Quoted 5 lines
- Third, since composite driver covers 500mA (and more for CDP) after set configuration and 2mA after suspend, and vbus handler covers connect and disconnect. I can't see any reasons we need to notify gadget state for power driver, do we really need to have
usb_charger_plug_by_gadget?
In some solutions, gadget does not negotiate with the current. They just send out one signal to power driver to set the current when the gadget state is changed (plugin or not). So we need to check the charger state by the gadget state to notify the charger IC to set current.
Quoted 4 lines
--
Best Regards,
eter Chen
Signature · 6 lines
Baolin.wang Best Regards -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 44 lines · Baolin Wang
Quoted 11 lines · Peter Chen
Quoted 10 lines · Mark Brown
Quoted 8 lines · Peter Chen
Quoted 6 lines · Baolin Wang
Quoted 3 lines
I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Then, where is the code the test user to decide what kinds of USB charger (SDP, CDP, DCP) is connecting now?
Even without detection of CDP and DCP we have configurability within SDP
- there's the 2.5mA suspended limit, the 100mA default limit and the higher 500mA limit which can be negotiated.Well, things may be a little complicated.
I try to address your comments, maybe Mark need to do some complements. Thanks.
Quoted 9 lines
- First, how to design
get_charger_typefor each udc driver? Since the charger detection process affects dp/dm signal, it can't be done during the enumeration or after that. So, the detection process can be only done after vbus has detected and before udc pull up dp.Then, when the
get_charger_typedo real charger detection? My suggestion is, if the charger type is unknown, we do real one, else, we just return the stored type value.I think that is why we let udc driver to implement the '
gadget->ops->get_charger_type()' callback, which can be controlled by udc driver.Quoted 7 lines
- Second, When to notify charger IC to charger:
For SDP and CDP, it needs to notify charger IC after set configuration has finished.
For DCP (and ACA, I am not sure), can notify charger IC after charger detection has finished or later.
Quoted 8 lines
Quoted 4 lines
So, when we get charger is present, we need to notify charger IC at once for DCP (and ACA); But for SDP and CDP, we need to let the gadget composite core to notify charger IC after set configuration has finished, like the patch 2/4 does.
But mostly charger IC is separate with gadget, so the charger IC doesn't need to worry about the gadget status.
The reason why we need to combine charger IC with USB gadget (charger) driver is the charger IC should not charge as much as it wants, it needs to consider USB charger style and USB connection (un-configuration vs configuration) situation.
Quoted 6 lines
Quoted 5 lines
- Third, since composite driver covers 500mA (and more for CDP) after set configuration and 2mA after suspend, and vbus handler covers connect and disconnect. I can't see any reasons we need to notify gadget state for power driver, do we really need to have
usb_charger_plug_by_gadget?
Quoted 6 lines
In some solutions, gadget does not negotiate with the current. They just send out one signal to power driver to set the current when the gadget state is changed (plugin or not). So we need to check the charger state by the gadget state to notify the charger IC to set current.
Would you give some examples?
Signature · 6 lines
Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 50 lines · Peter Chen
Quoted 49 lines · Baolin Wang
Quoted 11 lines · Peter Chen
Quoted 10 lines · Mark Brown
Quoted 8 lines · Peter Chen
Quoted 6 lines · Baolin Wang
Quoted 3 lines
I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Then, where is the code the test user to decide what kinds of USB charger (SDP, CDP, DCP) is connecting now?
Even without detection of CDP and DCP we have configurability within SDP
- there's the 2.5mA suspended limit, the 100mA default limit and the higher 500mA limit which can be negotiated.Well, things may be a little complicated.
I try to address your comments, maybe Mark need to do some complements. Thanks.
Quoted 9 lines
- First, how to design
get_charger_typefor each udc driver? Since the charger detection process affects dp/dm signal, it can't be done during the enumeration or after that. So, the detection process can be only done after vbus has detected and before udc pull up dp.Then, when the
get_charger_typedo real charger detection? My suggestion is, if the charger type is unknown, we do real one, else, we just return the stored type value.I think that is why we let udc driver to implement the '
gadget->ops->get_charger_type()' callback, which can be controlled by udc driver.Quoted 11 lines
- Second, When to notify charger IC to charger:
For SDP and CDP, it needs to notify charger IC after set configuration has finished.
For DCP (and ACA, I am not sure), can notify charger IC after charger detection has finished or later.So, when we get charger is present, we need to notify charger IC at once for DCP (and ACA); But for SDP and CDP, we need to let the gadget composite core to notify charger IC after set configuration has finished, like the patch 2/4 does.
Quoted 8 lines
Quoted 3 lines
But mostly charger IC is separate with gadget, so the charger IC doesn't need to worry about the gadget status.
The reason why we need to combine charger IC with USB gadget (charger) driver is the charger IC should not charge as much as it wants, it needs to consider USB charger style and USB connection (un-configuration vs configuration) situation.
Yes, I agree with the charger IC should not charge as much as it wants, but we don't want to combine two separated things. Like you said, udc driver can implement 'get_charger_type()' callback to check the charger type at the right time, then set the current after checking the charger type (now the gadget has been set configuration).
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
- Third, since composite driver covers 500mA (and more for CDP) after set configuration and 2mA after suspend, and vbus handler covers connect and disconnect. I can't see any reasons we need to notify gadget state for power driver, do we really need to have
usb_charger_plug_by_gadget?
Quoted 8 lines
Quoted 6 lines
In some solutions, gadget does not negotiate with the current. They just send out one signal to power driver to set the current when the gadget state is changed (plugin or not). So we need to check the charger state by the gadget state to notify the charger IC to set current.
Would you give some examples?
OK. I explain it in detail. Now charger detection can be from gadget itself or PMIC, and we focus on gadget detection. Charger IC (charger driver) is separate with gadget.
When the usb cable is plugin, we need to report the plugin event to charger driver to set current after setting configuration for gadget. The usb charger is responsible for reporting plugin event to charger driver. But how usb charger get the plugin event? It can get the plugin event from gadget state (if the gadget state is more than 'USB_STATE_ATTACHED', it means one cable plugin). So we need notify gadget state to usb charger.
Quoted 4 lines
--
Best Regards,
Peter Chen
Signature · 2 lines
Baolin.wang Best Regards
Quoted 14 lines · Baolin Wang
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
- Third, since composite driver covers 500mA (and more for CDP) after set configuration and 2mA after suspend, and vbus handler covers connect and disconnect. I can't see any reasons we need to notify gadget state for power driver, do we really need to have
usb_charger_plug_by_gadget?Quoted 8 lines
Quoted 6 lines
In some solutions, gadget does not negotiate with the current. They just send out one signal to power driver to set the current when the gadget state is changed (plugin or not). So we need to check the charger state by the gadget state to notify the charger IC to set current.
Would you give some examples?
Quoted 11 lines
OK. I explain it in detail. Now charger detection can be from gadget itself or PMIC, and we focus on gadget detection. Charger IC (charger driver) is separate with gadget.
When the usb cable is plugin, we need to report the plugin event to charger driver to set current after setting configuration for gadget. The usb charger is responsible for reporting plugin event to charger driver. But how usb charger get the plugin event? It can get the plugin event from gadget state (if the gadget state is more than 'USB_STATE_ATTACHED', it means one cable plugin). So we need notify gadget state to usb charger.
Ok, I see, it only changes current limit at function usb_gadget_vbus_draw in your patch 2/4. Then, we need to make sure usb_charger_set_cur_limit_by_type is called before calling usb_gadget_set_state(gadget, USB_STATE_CONFIGURED).
It seems you have not implemented usb_charger_plug_by_gadget in your patch set.
Signature · 2 lines
Best Regards, Peter Chen
Quoted 27 lines · Peter Chen
Quoted 14 lines · Baolin Wang
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
- Third, since composite driver covers 500mA (and more for CDP) after set configuration and 2mA after suspend, and vbus handler covers connect and disconnect. I can't see any reasons we need to notify gadget state for power driver, do we really need to have
usb_charger_plug_by_gadget?Quoted 8 lines
Quoted 6 lines
In some solutions, gadget does not negotiate with the current. They just send out one signal to power driver to set the current when the gadget state is changed (plugin or not). So we need to check the charger state by the gadget state to notify the charger IC to set current.
Would you give some examples?
Quoted 11 lines
OK. I explain it in detail. Now charger detection can be from gadget itself or PMIC, and we focus on gadget detection. Charger IC (charger driver) is separate with gadget.
When the usb cable is plugin, we need to report the plugin event to charger driver to set current after setting configuration for gadget. The usb charger is responsible for reporting plugin event to charger driver. But how usb charger get the plugin event? It can get the plugin event from gadget state (if the gadget state is more than 'USB_STATE_ATTACHED', it means one cable plugin). So we need notify gadget state to usb charger.
Quoted 3 lines
Ok, I see, it only changes current limit at function
usb_gadget_vbus_drawin your patch 2/4. Then, we need to make sureusb_charger_set_cur_limit_by_typeis called before callingusb_gadget_set_state(gadget, USB_STATE_CONFIGURED).
That's right.
Quoted 2 lines
It seems you have not implemented
usb_charger_plug_by_gadgetin your patch set.
It is implemented in patch 3/4.
Quoted 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N0 IFJlZ2FyZHMsDQo+ID4gUGV0ZXIgQ2hlbg0KPiANCj4gDQo+IA0KPiAtLQ0KPiBCYW9saW4ud2Fu Zw0KPiBCZXN0IFJlZ2FyZHMNCj4gLS0NCj4gVG8gdW5zdWJzY3JpYmUgZnJvbSB0aGlzIGxpc3Q6 IHNlbmQgdGhlIGxpbmUgInVuc3Vic2NyaWJlIGxpbnV4LXVzYiIgaW4NCj4gdGhlIGJvZHkgb2Yg YSBtZXNzYWdlIHRvIG1ham9yZG9tb0B2Z2VyLmtlcm5lbC5vcmcgTW9yZSBtYWpvcmRvbW8gaW5m byBhdA0KPiBodHRwOi8vdmdlci5rZXJuZWwub3JnL21ham9yZG9tby1pbmZvLmh0bWwNCg== --
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 39 lines · Jun Li
Quoted 39 lines
-----Original Message-----
From: [email protected] [mailto:linux-usb- [email protected]] On Behalf Of Baolin Wang
Sent: Monday, March 28, 2016 2:52 PM
To: Peter Chen <[email protected]>
Cc: Felipe Balbi <[email protected]>; Greg KH <[email protected]>; Sebastian Reichel <[email protected]>; Dmitry Eremin-Solenikov <[email protected]>; David Woodhouse <[email protected]>; Peter Chen <[email protected]>; Alan Stern <[email protected]>; [email protected]; Yoshihiro Shimoda <[email protected]>; Lee Jones <[email protected]>; Mark Brown <[email protected]>; Charles Keepax <[email protected]>; [email protected]; Linux PM list <[email protected]>; USB <[email protected]>; [email protected]; LKML <linux- [email protected]>
Subject: Re: [PATCH v8 0/4] Introduce usb charger framework to deal with the usb gadget power negotationQuoted 6 lines · Peter Chen
Quoted 5 lines · Baolin Wang
Currently the Linux kernel does not provide any standard integration of this feature that integrates the USB subsystem with the system power regulation provided by PMICs meaning that either vendors must add this in their kernels or USB gadget devices based on Linux (such as mobile phones) may not behave as they should. Thus provide a
standard framework for doing this in kernel.
Quoted 9 lines
Quoted 5 lines
Now introduce one user with
wm831x_powerto support and test the usb charger, which is pending testing. Moreover there may be other potential users will use it in future.I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
Quoted 7 lines
Quoted 3 lines
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb state changes.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.
Quoted 16 lines
Li Jun
Quoted 14 lines
Quoted 4 lines
--
Best Regards,
Peter Chen--
Baolin.wang
Best Regards
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Baolin.wang Best Regards
Quoted 70 lines
-----Original Message-----
From: Baolin Wang [mailto:[email protected]]
Sent: Tuesday, March 29, 2016 5:49 PM
To: Jun Li <[email protected]>
Cc: Peter Chen <[email protected]>; Felipe Balbi <[email protected]>; Greg KH <[email protected]>; Sebastian Reichel <[email protected]>; Dmitry Eremin-Solenikov <[email protected]>; David Woodhouse <[email protected]>; Peter Chen <[email protected]>; Alan Stern <[email protected]>; [email protected]; Yoshihiro Shimoda <[email protected]>; Lee Jones <[email protected]>; Mark Brown <[email protected]>; Charles Keepax <[email protected]>; [email protected]; Linux PM list <[email protected]>; USB <[email protected]>; [email protected]; LKML <linux- [email protected]>
Subject: Re: [PATCH v8 0/4] Introduce usb charger framework to deal with the usb gadget power negotationQuoted 42 lines · Jun Li
Quoted 42 lines
-----Original Message-----
From: [email protected] [mailto:linux-usb- [email protected]] On Behalf Of Baolin Wang
Sent: Monday, March 28, 2016 2:52 PM
To: Peter Chen <[email protected]>
Cc: Felipe Balbi <[email protected]>; Greg KH <[email protected]>; Sebastian Reichel <[email protected]>; Dmitry Eremin-Solenikov <[email protected]>; David Woodhouse <[email protected]>; Peter Chen <[email protected]>; Alan Stern <[email protected]>; [email protected]; Yoshihiro Shimoda <[email protected]>; Lee Jones <[email protected]>; Mark Brown <[email protected]>; Charles Keepax <[email protected]>; [email protected];
Linux PM list <[email protected]>; USB <[email protected]>; [email protected]; LKML <linux- [email protected]>
Subject: Re: [PATCH v8 0/4] Introduce usb charger framework to deal with the usb gadget power negotationQuoted 7 lines · Peter Chen
Quoted 6 lines · Baolin Wang
Currently the Linux kernel does not provide any standard integration of this feature that integrates the USB subsystem with the system power regulation provided by PMICs meaning that either vendors must add this in their kernels or USB gadget devices based on Linux (such as mobile phones) may not behave as they should. Thus provide a
standard framework for doing this in kernel.
Quoted 9 lines
Quoted 5 lines
Now introduce one user with
wm831x_powerto support and test the usb charger, which is pending testing. Moreover there may be other potential users will use it in future.I am afraid I still not find the user (udc driver) for this framework, I would like to see how udc driver block the enumeration until the charger detection has finished, or am I missing something?
Quoted 7 lines
Quoted 3 lines
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb state
Quoted 8 lines
changes.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget _connection_(pullup DP), also I don't think it's necessary to check charger type at every event from usb gadget. Something in gadget driver you can utilize is only vbus detection, and report diff current by diff usb state if it's a SDP.
Quoted 22 lines
Quoted 16 lines
Li Jun
Quoted 14 lines
Quoted 4 lines
--
Best Regards,
Peter Chen--
Baolin.wang
Best Regards
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
Baolin.wang
Best Regards
Quoted 16 lines · Jun Li
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb stateQuoted 8 lines
changes.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.
Quoted 2 lines
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget
_connection_(pullup DP), also I don't
Why can not? Charger detection is usually from PMIC.
Quoted 1 line
think it's necessary to check charger type at every event from usb gadget.
My meaning is not every event from usb gadget. When the usb gadget state changes or the extcon device (maybe GPIO detection) state changes, which means charger plugin or pullup, we need to check the charger type to set current.
Quoted 2 lines
Something in gadget driver you can utilize is only vbus detection, and report diff current by diff usb state if it's a SDP.
Signature · 2 lines
Baolin.wang Best Regards
Hi
Quoted 35 lines
-----Original Message-----
From: Baolin Wang [mailto:[email protected]]
Sent: Wednesday, March 30, 2016 2:15 PM
To: Jun Li <[email protected]>
Cc: Peter Chen <[email protected]>; Felipe Balbi <[email protected]>; Greg KH <[email protected]>; Sebastian Reichel <[email protected]>; Dmitry Eremin-Solenikov <[email protected]>; David Woodhouse <[email protected]>; Peter Chen <[email protected]>; Alan Stern <[email protected]>; [email protected]; Yoshihiro Shimoda <[email protected]>; Lee Jones <[email protected]>; Mark Brown <[email protected]>; Charles Keepax <[email protected]>; [email protected]; Linux PM list <[email protected]>; USB <[email protected]>; [email protected]; LKML <linux- [email protected]>
Subject: Re: [PATCH v8 0/4] Introduce usb charger framework to deal with the usb gadget power negotationQuoted 16 lines · Jun Li
Quoted 15 lines
Quoted 7 lines
Quoted 3 lines
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb statechanges.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.
Quoted 5 lines
Quoted 3 lines
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget
_connection_(pullup DP), also I don'tWhy can not? Charger detection is usually from PMIC.
Charger detection process will impact DP/DM line state, see usb charger spec v1.2 for detail detection process, section 4.6.3 says:
"A PD is allowed to *disconnect* and repeat the charger detection process multiple times while attached. The PD is required to wait for a time of at least TCP_VDM_EN max between disconnecting and restarting the charger detection process."
As Peter mentioned, the charger detection should happen between VBUS detection and gadget pull up DP for first plug in case. So when&after gadget connect (pullup DP), you should already know the charger type.
Li Jun
Quoted 8 lines
Quoted 2 lines
think it's necessary to check charger type at every event from usb
gadget.
My meaning is not every event from usb gadget. When the usb gadget state changes or the extcon device (maybe GPIO detection) state changes, which means charger plugin or pullup, we need to check the charger type to set current.
From your below code, you call usb_charger_notify_others() in every state change.
if (uchger->old_gadget_state != state) {
uchger->old_gadget_state = state;
if (state >= USB_STATE_ATTACHED)
uchger_state = USB_CHARGER_PRESENT;
else if (state == USB_STATE_NOTATTACHED)
uchger_state = USB_CHARGER_REMOVE;
else
/* this else will never happen */
uchger_state = USB_CHARGER_DEFAULT;
usb_charger_notify_others(uchger, uchger_state);
}Quoted 7 lines
Quoted 3 lines
Something in gadget driver you can utilize is only vbus detection, and report diff current by diff usb state if it's a SDP.
--
Baolin.wang
Best Regards
Quoted 28 lines · Jun Li
Hi
Quoted 17 lines · Jun Li
Quoted 16 lines
Quoted 15 lines
Quoted 7 lines
Quoted 3 lines
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb statechanges.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.Quoted 5 lines
Quoted 3 lines
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget
_connection_(pullup DP), also I don'tWhy can not? Charger detection is usually from PMIC.
Charger detection process will impact DP/DM line state, see usb charger spec v1.2 for detail detection process, section 4.6.3 says:
Quoted 8 lines
"A PD is allowed to *disconnect* and repeat the charger detection process multiple times while attached. The PD is required to wait for a time of at least
TCP_VDM_ENmax between disconnecting and restarting the charger detection process."As Peter mentioned, the charger detection should happen between VBUS detection and gadget pull up DP for first plug in case. So when&after gadget connect (pullup DP), you should already know the charger type.
Make sense. In our company's solution, charger detection can be done by hardware from PMIC at first, then it will not affect the DP/DM line when gadget starts to enumeration. In the 'usb_charger_detect_type()', it usually get the charger type from type registers has been done by hardware from PMIC, which can not affect the DP/DM line.
Quoted 7 lines
Li Jun
Quoted 4 lines
Quoted 2 lines
think it's necessary to check charger type at every event from usb
gadget.
Quoted 7 lines
Quoted 4 lines
My meaning is not every event from usb gadget. When the usb gadget state changes or the extcon device (maybe GPIO detection) state changes, which means charger plugin or pullup, we need to check the charger type to set current.
From your below code, you call
usb_charger_notify_others()in every state change.
I think it does not matter. In case the usb charger missed some gadget state changes. Or I replace it with 'USB_STATE_CONFIGURED' state. Thanks.
Quoted 22 lines
if (uchger->old_gadget_state != state) { uchger->old_gadget_state = state; if (state >= USB_STATE_ATTACHED) uchger_state = USB_CHARGER_PRESENT; else if (state == USB_STATE_NOTATTACHED) uchger_state = USB_CHARGER_REMOVE; else /* this else will never happen */ uchger_state = USB_CHARGER_DEFAULT; usb_charger_notify_others(uchger, uchger_state); }Quoted 7 lines
Quoted 3 lines
Something in gadget driver you can utilize is only vbus detection, and report diff current by diff usb state if it's a SDP.
--
Baolin.wang
Best Regards
Signature · 2 lines
Baolin.wang Best Regards
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogQmFvbGluIFdhbmcgW21h aWx0bzpiYW9saW4ud2FuZ0BsaW5hcm8ub3JnXQ0KPiBTZW50OiBXZWRuZXNkYXksIE1hcmNoIDMw LCAyMDE2IDU6MzEgUE0NCj4gVG86IEp1biBMaSA8anVuLmxpQG54cC5jb20+DQo+IENjOiBQZXRl ciBDaGVuIDxoenBldGVyY2hlbkBnbWFpbC5jb20+OyBGZWxpcGUgQmFsYmkgPGJhbGJpQGtlcm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GF0ZSA+PSBVU0Jf U1RBVEVfQVRUQUNIRUQpDQo+ID4gICAgICAgICAgICAgICAgIHVjaGdlcl9zdGF0ZSA9IFVTQl9D SEFSR0VSX1BSRVNFTlQ7DQo+ID4gICAgICAgICBlbHNlIGlmIChzdGF0ZSA9PSBVU0JfU1RBVEVf Tk9UQVRUQUNIRUQpDQo+ID4gICAgICAgICAgICAgICAgIHVjaGdlcl9zdGF0ZSA9IFVTQl9DSEFS R0VSX1JFTU9WRTsNCj4gPiAgICAgICAgIGVsc2UNCj4gPiAvKiB0aGlzIGVsc2Ugd2lsbCBuZXZl ciBoYXBwZW4gKi8NCj4gPiAgICAgICAgICAgICAgICAgdWNoZ2VyX3N0YXRlID0gVVNCX0NIQVJH RVJfREVGQVVMVDsNCj4gPg0KPiA+ICAgICAgICAgdXNiX2NoYXJnZXJfbm90aWZ5X290aGVycyh1 Y2hnZXIsIHVjaGdlcl9zdGF0ZSk7IH0NCj4gPg0KPiA+Pg0KPiA+PiA+IFNvbWV0aGluZyBpbiBn YWRnZXQgZHJpdmVyIHlvdSBjYW4gdXRpbGl6ZSBpcyBvbmx5IHZidXMgZGV0ZWN0aW9uLA0KPiA+ PiA+IGFuZCByZXBvcnQgZGlmZiBjdXJyZW50IGJ5IGRpZmYgdXNiIHN0YXRlIGlmIGl0J3MgYSBT RFAuDQo+ID4+DQo+ID4+IC0tDQo+ID4+IEJhb2xpbi53YW5nDQo+ID4+IEJlc3QgUmVnYXJkcw0K PiANCj4gDQo+IA0KPiAtLQ0KPiBCYW9saW4ud2FuZw0KPiBCZXN0IFJlZ2FyZHMNCg== --
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Quoted 57 lines · Jun Li
Quoted 57 lines
-----Original Message-----
From: Baolin Wang [mailto:[email protected]]
Sent: Wednesday, March 30, 2016 5:31 PM
To: Jun Li <[email protected]>
Cc: Peter Chen <[email protected]>; Felipe Balbi <[email protected]>; Greg KH <[email protected]>; Sebastian Reichel <[email protected]>; Dmitry Eremin-Solenikov <[email protected]>; David Woodhouse <[email protected]>; Peter Chen <[email protected]>; Alan Stern <[email protected]>; [email protected]; Yoshihiro Shimoda <[email protected]>; Lee Jones <[email protected]>; Mark Brown <[email protected]>; Charles Keepax <[email protected]>; [email protected]; Linux PM list <[email protected]>; USB <[email protected]>; [email protected]; LKML <linux- [email protected]>
Subject: Re: [PATCH v8 0/4] Introduce usb charger framework to deal with the usb gadget power negotationQuoted 37 lines · Jun Li
Hi
Quoted 18 lines · Jun Li
Quoted 17 lines
Quoted 16 lines
Quoted 8 lines
Quoted 3 lines
It is not for udc driver but for power users who want to negotiate with USB subsystem.
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb statechanges.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.Quoted 5 lines
Quoted 3 lines
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget
_connection_(pullup DP), also I don'tWhy can not? Charger detection is usually from PMIC.
Charger detection process will impact DP/DM line state, see usb charger spec v1.2 for detail detection process, section 4.6.3 says:
"A PD is allowed to *disconnect* and repeat the charger detection process multiple times while attached. The PD is required to wait for a time of at least
TCP_VDM_ENmax between disconnecting and restarting the charger detection process."As Peter mentioned, the charger detection should happen between VBUS detection and gadget pull up DP for first plug in case. So when&after gadget connect (pullup DP), you should already know the charger type.
Quoted 6 lines
Quoted 3 lines
Make sense. In our company's solution, charger detection can be done by hardware from PMIC at first, then it will not affect the DP/DM line when gadget starts to enumeration.
I see, charger type detection is done automatically by PMIC when VBUS is detected in your case, you just assume the process is complete
assuming this finishes before gadget starts is a bad idea. It would've been much more robust to delay usb_gadget_connect() until we KNOW charger detection has completed.
Signature · 1 line
balbi
Quoted 36 lines · Felipe Balbi
Quoted 36 lines
Quoted 35 lines
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 5 lines
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb statechanges.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.Quoted 5 lines
Quoted 3 lines
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget
_connection_(pullup DP), also I don'tWhy can not? Charger detection is usually from PMIC.
Charger detection process will impact DP/DM line state, see usb charger spec v1.2 for detail detection process, section 4.6.3 says:
Quoted 8 lines
"A PD is allowed to *disconnect* and repeat the charger detection process multiple times while attached. The PD is required to wait for a time of at least
TCP_VDM_ENmax between disconnecting and restarting the charger detection process."As Peter mentioned, the charger detection should happen between VBUS detection and gadget pull up DP for first plug in case. So when&after gadget connect (pullup DP), you should already know the charger type.
Make sense. In our company's solution, charger detection can be done by hardware from PMIC at first, then it will not affect the DP/DM line when gadget starts to enumeration.
Quoted 6 lines
Quoted 2 lines
I see, charger type detection is done automatically by PMIC when VBUS is detected in your case, you just assume the process is complete
assuming this finishes before gadget starts is a bad idea. It would've been much more robust to delay
usb_gadget_connect()until we KNOW charger detection has completed.
It is hardware action to detect the charger type quickly. It actually *gets* the charger type and does not means *detect* charger type in 'usb_charger_detect_type()' function. Maybe I need to change the function name as 'usb_charger_get_type()'.
If some udc drivers want to detect charger type in 'gadget->ops->get_charger_type()' callback, they should avoid impacting DP/DM line state at the right gadget state. Thanks.
Quoted 3 lines
--
balbi
Signature · 2 lines
Baolin.wang Best Regards
Hi,
Quoted 41 lines · Baolin Wang
[ text/plain ]
Quoted 39 lines · Felipe Balbi
Quoted 38 lines
Quoted 28 lines
Quoted 28 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 5 lines
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb statechanges.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.Quoted 5 lines
Quoted 3 lines
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget
_connection_(pullup DP), also I don'tWhy can not? Charger detection is usually from PMIC.
Charger detection process will impact DP/DM line state, see usb charger spec v1.2 for detail detection process, section 4.6.3 says:
"A PD is allowed to *disconnect* and repeat the charger detection process multiple times while attached. The PD is required to wait for a time of at least
TCP_VDM_ENmax between disconnecting and restarting the charger detection process."Quoted 7 lines
Quoted 3 lines
As Peter mentioned, the charger detection should happen between VBUS detection and gadget pull up DP for first plug in case. So when&after gadget connect (pullup DP), you should already know the charger type.
Make sense. In our company's solution, charger detection can be done by hardware from PMIC at first, then it will not affect the DP/DM line when gadget starts to enumeration.
I see, charger type detection is done automatically by PMIC when VBUS is detected in your case, you just assume the process is complete
Quoted 8 lines
Quoted 3 lines
assuming this finishes before gadget starts is a bad idea. It would've been much more robust to delay
usb_gadget_connect()until we KNOW charger detection has completed.It is hardware action to detect the charger type quickly. It actually *gets* the charger type and does not means *detect* charger type in '
usb_charger_detect_type()' function. Maybe I need to change the function name as 'usb_charger_get_type()'.
yes.
Quoted 3 lines
If some udc drivers want to detect charger type in '
gadget->ops->get_charger_type()' callback, they should avoid impacting DP/DM line state at the right gadget state. Thanks.
they shouldn't detect is get_type(), the semantics doesn't work. If, at some point, we have to do SW detection of the charger, then a new ->charger_detect() method will have to be added.
Signature · 1 line
balbi
Quoted 56 lines · Felipe Balbi
Hi,
Quoted 41 lines · Baolin Wang
[ text/plain ]
Quoted 39 lines · Felipe Balbi
Quoted 38 lines
Quoted 28 lines
Quoted 28 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 5 lines
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb statechanges.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.Quoted 5 lines
Quoted 3 lines
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget
_connection_(pullup DP), also I don'tWhy can not? Charger detection is usually from PMIC.
Charger detection process will impact DP/DM line state, see usb charger spec v1.2 for detail detection process, section 4.6.3 says:
"A PD is allowed to *disconnect* and repeat the charger detection process multiple times while attached. The PD is required to wait for a time of at least
TCP_VDM_ENmax between disconnecting and restarting the charger detection process."Quoted 7 lines
Quoted 3 lines
As Peter mentioned, the charger detection should happen between VBUS detection and gadget pull up DP for first plug in case. So when&after gadget connect (pullup DP), you should already know the charger type.
Make sense. In our company's solution, charger detection can be done by hardware from PMIC at first, then it will not affect the DP/DM line when gadget starts to enumeration.
I see, charger type detection is done automatically by PMIC when VBUS is detected in your case, you just assume the process is complete
Quoted 8 lines
Quoted 3 lines
assuming this finishes before gadget starts is a bad idea. It would've been much more robust to delay
usb_gadget_connect()until we KNOW charger detection has completed.It is hardware action to detect the charger type quickly. It actually *gets* the charger type and does not means *detect* charger type in '
usb_charger_detect_type()' function. Maybe I need to change the function name as 'usb_charger_get_type()'.yes.
Quoted 7 lines
Quoted 3 lines
If some udc drivers want to detect charger type in '
gadget->ops->get_charger_type()' callback, they should avoid impacting DP/DM line state at the right gadget state. Thanks.they shouldn't detect is
get_type(), the semantics doesn't work. If, at some point, we have to do SW detection of the charger, then a new ->charger_detect() method will have to be added.
Make sense.
Quoted 3 lines
--
balbi
Signature · 6 lines
Baolin.wang Best Regards -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 31 lines · Jun Li
Quoted 31 lines
Quoted 30 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 4 lines
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb statechanges.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.Quoted 5 lines
Quoted 3 lines
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget
_connection_(pullup DP), also I don'tWhy can not? Charger detection is usually from PMIC.
Charger detection process will impact DP/DM line state, see usb charger spec v1.2 for detail detection process, section 4.6.3 says:
"A PD is allowed to *disconnect* and repeat the charger detection process multiple times while attached. The PD is required to wait for a time of at least
TCP_VDM_ENmax between disconnecting and restarting the charger detection process."As Peter mentioned, the charger detection should happen between VBUS detection and gadget pull up DP for first plug in case. So when&after gadget connect (pullup DP), you should already know the charger type.
Quoted 7 lines
Quoted 3 lines
Make sense. In our company's solution, charger detection can be done by hardware from PMIC at first, then it will not affect the DP/DM line when gadget starts to enumeration.
I see, charger type detection is done automatically by PMIC when VBUS is
detected in your case, you just assume the process is complete before SW
do gadget connect. To make the framework common, you may do one time charger type check when vbus is on, and save it to avoid repeat charger type check.
OK. I'll add one judgement to check if the charger type is set in 'usb_charger_detect_type()' function.
Signature · 6 lines
Baolin.wang Best Regards -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
SGkNCg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBCYW9saW4gV2FuZyBb bWFpbHRvOmJhb2xpbi53YW5nQGxpbmFyby5vcmddDQo+IFNlbnQ6IFRodXJzZGF5LCBNYXJjaCAz MSwgMjAxNiAxOjIzIFBNDQo+IFRvOiBKdW4gTGkgPGp1bi5saUBueHAuY29tPg0KPiBDYzogUGV0 ZXIgQ2hlbiA8aHpwZXRlcmNoZW5AZ21haWwuY29tPjsgRmVsaXBlIEJhbGJpIDxiYWxiaUBrZXJu ZWwub3JnPjsNCj4gR3JlZyBLSCA8Z3JlZ2toQGxpbnV4Zm91bmRhdGlvbi5vcmc+OyBTZWJhc3Rp YW4gUmVpY2hlbCA8c3JlQGtlcm5lbC5vcmc+Ow0KPiBEbWl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oYXJnZXIgdHlwZSBmcm9tIHRoZSBzYXZlZCB2YWx1ZS4NClRoZSBy ZWFsIGNoYXJnZXIgdHlwZSBkZXRlY3Rpb24gZG9uZSBieSB1c2JfY2hhcmdlcl9kZXRlY3RfdHlw ZSgpIGNhbg0KYmUgY2FsbGVkIG9ubHkgd2hlbiB2YnVzIGlzIG9uLg0KZS5nLiBtYXliZSBpbiB1 c2JfdWRjX3ZidXNfaGFuZGxlcigpIGJlZm9yZSB1c2JfdWRjX2Nvbm5lY3RfY29udHJvbCgpLg0K DQo+IA0KPiAtLQ0KPiBCYW9saW4ud2FuZw0KPiBCZXN0IFJlZ2FyZHMNCg==
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 66 lines · Jun Li
Hi
Quoted 55 lines
-----Original Message-----
From: Baolin Wang [mailto:[email protected]]
Sent: Thursday, March 31, 2016 1:23 PM
To: Jun Li <[email protected]>
Cc: Peter Chen <[email protected]>; Felipe Balbi <[email protected]>; Greg KH <[email protected]>; Sebastian Reichel <[email protected]>; Dmitry Eremin-Solenikov <[email protected]>; David Woodhouse <[email protected]>; Peter Chen <[email protected]>; Alan Stern <[email protected]>; [email protected]; Yoshihiro Shimoda <[email protected]>; Lee Jones <[email protected]>; Mark Brown <[email protected]>; Charles Keepax <[email protected]>; [email protected]; Linux PM list <[email protected]>; USB <[email protected]>; [email protected]; LKML <linux- [email protected]>
Subject: Re: [PATCH v8 0/4] Introduce usb charger framework to deal with the usb gadget power negotationQuoted 22 lines · Jun Li
Quoted 22 lines
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 4 lines
Seems you don't want to guarantee charger type detection is done before gadget connection(pullup DP), right?
I see you callusb_charger_detect_type()in each gadget usb statechanges.
I am not sure I get your point correctly, please correct me if I misunderstand you.
We need to check the charger type at every event comes from the usb gadget state changes or the extcon device state changes, which means a new charger plugin or pullup.Quoted 5 lines
Quoted 3 lines
According to usb charger spec, my understanding is you can't do real charger detection procedure *after* gadget
_connection_(pullup DP), also I don'tWhy can not? Charger detection is usually from PMIC.
Charger detection process will impact DP/DM line state, see usb charger spec v1.2 for detail detection process, section 4.6.3 says:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
"A PD is allowed to *disconnect* and repeat the charger detection process multiple times while attached. The PD is required to wait for a time of at least
TCP_VDM_ENmax between disconnecting and restarting the charger detection process."As Peter mentioned, the charger detection should happen between VBUS detection and gadget pull up DP for first plug in case. So when&after gadget connect (pullup DP), you should already know the
charger type.
Quoted 5 lines
Quoted 4 lines
Make sense. In our company's solution, charger detection can be done by hardware from PMIC at first, then it will not affect the DP/DM line when gadget starts to enumeration.
Quoted 8 lines
Quoted 3 lines
I see, charger type detection is done automatically by PMIC when VBUS is detected in your case, you just assume the process is complete before SW do gadget connect. To make the framework common, you may do
one time charger type check when vbus is on, and save it to avoid repeat charger type check.
OK. I'll add one judgement to check if the charger type is set in '
usb_charger_detect_type()' function.
Quoted 6 lines
Just adding a judgement isn't enough here, your framework should make sure
usb_charger_detect_type()is called before gadget connect, with that, the existing caller place just gets the charger type from the saved value. The real charger type detection done byusb_charger_detect_type()can be called only when vbus is on.
e.g. maybe inusb_udc_vbus_handler()beforeusb_udc_connect_control().
Yeah, Like Felipe suggested, I think we need to introduce one 'charger_detect()' method to do the SW charger type detection at the right gadget state. Thanks for your comments.
Quoted 4 lines
Quoted 4 lines
--
Baolin.wang
Best Regards
Signature · 2 lines
Baolin.wang Best Regards
Hi Baolin,
Quoted 20 lines · Baolin Wang
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Make sense. In our company's solution, charger detection can be done by hardware from PMIC at first, then it will not affect the DP/DM line when gadget starts to enumeration.
Quoted 8 lines
Quoted 3 lines
I see, charger type detection is done automatically by PMIC when VBUS is detected in your case, you just assume the process is complete before SW do gadget connect. To make the framework common, you may do
one time charger type check when vbus is on, and save it to avoid repeat charger type check.
OK. I'll add one judgement to check if the charger type is set in '
usb_charger_detect_type()' function.Quoted 6 lines
Just adding a judgement isn't enough here, your framework should make sure
usb_charger_detect_type()is called before gadget connect, with that, the existing caller place just gets the charger type from the saved value. The real charger type detection done byusb_charger_detect_type()can be called only when vbus is on.
e.g. maybe inusb_udc_vbus_handler()beforeusb_udc_connect_control().
Quoted 3 lines
Yeah, Like Felipe suggested, I think we need to introduce one '
charger_detect()' method to do the SW charger type detection at the right gadget state. Thanks for your comments.
Just to be clear, we add ->charger_detect() when we know of a platform which needs to manually detect the charger type. Until then, we ignore that situation. It might be a good idea, however, do document this in comments on your structure definition stating that if we need to detect charger type, a new method should be added ;-)
cheers
Signature · 1 line
balbi
Quoted 28 lines · Felipe Balbi
Hi Baolin,
Quoted 20 lines · Baolin Wang
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Make sense. In our company's solution, charger detection can be done by hardware from PMIC at first, then it will not affect the DP/DM line when gadget starts to enumeration.
Quoted 8 lines
Quoted 3 lines
I see, charger type detection is done automatically by PMIC when VBUS is detected in your case, you just assume the process is complete before SW do gadget connect. To make the framework common, you may do
one time charger type check when vbus is on, and save it to avoid repeat charger type check.
OK. I'll add one judgement to check if the charger type is set in '
usb_charger_detect_type()' function.Quoted 6 lines
Just adding a judgement isn't enough here, your framework should make sure
usb_charger_detect_type()is called before gadget connect, with that, the existing caller place just gets the charger type from the saved value. The real charger type detection done byusb_charger_detect_type()can be called only when vbus is on.
e.g. maybe inusb_udc_vbus_handler()beforeusb_udc_connect_control().Quoted 3 lines
Yeah, Like Felipe suggested, I think we need to introduce one '
charger_detect()' method to do the SW charger type detection at the right gadget state. Thanks for your comments.
Quoted 5 lines
Just to be clear, we add ->charger_detect() when we know of a platform which needs to manually detect the charger type. Until then, we ignore that situation. It might be a good idea, however, do document this in comments on your structure definition stating that if we need to detect charger type, a new method should be added ;-)
Make sense. Thanks.
Quoted 5 lines
cheers
--
balbi
Signature · 6 lines
Baolin.wang Best Regards -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html