Re: [RESEND PATCH v11 1/4] gadget: Introduce the usb charger framework
Hi Felipe, On 21 June 2016 at 15:45, Felipe Balbi <ba...@kernel.org> wrote: > > Hi Baolin, > > Baolin Wang <baolin.w...@linaro.org> writes: >>>> -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 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. >>>> >>>> Signed-off-by: Baolin Wang <baolin.w...@linaro.org> >>> >>> Reviewed-by: Li Jun <jun...@nxp.com> >>> Tested-by: Li Jun <jun...@nxp.com> >> >> Do you have any comments about this patchset, if not I will resend it >> with testing by Li Jun (thanks for Jun reviewing and testing). Thanks. > > please resend. I don't have the series in my queue anymore, sorry. OK. I would like to resend this patchset. Thanks. -- Baolin.wang Best Regards -- 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 1/4] gadget: Introduce the usb charger framework
Hi Baolin, Baolin Wang <baolin.w...@linaro.org> writes: >>> -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 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. >>> >>> Signed-off-by: Baolin Wang <baolin.w...@linaro.org> >> >> Reviewed-by: Li Jun <jun...@nxp.com> >> Tested-by: Li Jun <jun...@nxp.com> > > Do you have any comments about this patchset, if not I will resend it > with testing by Li Jun (thanks for Jun reviewing and testing). Thanks. please resend. I don't have the series in my queue anymore, sorry. -- balbi signature.asc Description: PGP signature
Re: [RESEND PATCH v11 1/4] gadget: Introduce the usb charger framework
Hi Felipe, On 13 June 2016 at 23:13, Jun Li <jun...@nxp.com> wrote: > 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 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. >> >> Signed-off-by: Baolin Wang <baolin.w...@linaro.org> > > Reviewed-by: Li Jun <jun...@nxp.com> > Tested-by: Li Jun <jun...@nxp.com> Do you have any comments about this patchset, if not I will resend it with testing by Li Jun (thanks for Jun reviewing and testing). Thanks. > >> --- >> drivers/usb/gadget/Kconfig |7 + >> drivers/usb/gadget/udc/Makefile |1 + >> drivers/usb/gadget/udc/charger.c | 770 >> ++ >> include/linux/usb/charger.h | 191 ++ >> include/uapi/linux/usb/charger.h | 31 ++ >> 5 files changed, 1000 insertions(+) >> create mode 100644 drivers/usb/gadget/udc/charger.c create mode 100644 >> include/linux/usb/charger.h create mode 100644 >> include/uapi/linux/usb/charger.h -- Baolin.wang Best Regards -- 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 1/4] gadget: Introduce 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 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. > > 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/Kconfig |7 + > drivers/usb/gadget/udc/Makefile |1 + > drivers/usb/gadget/udc/charger.c | 770 > ++ > include/linux/usb/charger.h | 191 ++ > include/uapi/linux/usb/charger.h | 31 ++ > 5 files changed, 1000 insertions(+) > create mode 100644 drivers/usb/gadget/udc/charger.c create mode 100644 > include/linux/usb/charger.h create mode 100644 > include/uapi/linux/usb/charger.h -- 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
[RESEND PATCH v11 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. Signed-off-by: Baolin Wang--- drivers/usb/gadget/Kconfig |7 + drivers/usb/gadget/udc/Makefile |1 + drivers/usb/gadget/udc/charger.c | 770 ++ include/linux/usb/charger.h | 191 ++ include/uapi/linux/usb/charger.h | 31 ++ 5 files changed, 1000 insertions(+) create mode 100644 drivers/usb/gadget/udc/charger.c create mode 100644 include/linux/usb/charger.h create mode 100644 include/uapi/linux/usb/charger.h diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 2057add..89f4e9b 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -134,6 +134,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" # diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile index dfee534..0e9564c 100644 --- a/drivers/usb/gadget/udc/Makefile +++ b/drivers/usb/gadget/udc/Makefile @@ -2,6 +2,7 @@ # USB peripheral controller drivers # obj-$(CONFIG_USB_GADGET) += udc-core.o +obj-$(CONFIG_USB_CHARGER) += charger.o obj-$(CONFIG_USB_DUMMY_HCD)+= dummy_hcd.o obj-$(CONFIG_USB_NET2272) += net2272.o obj-$(CONFIG_USB_NET2280) += net2280.o diff --git a/drivers/usb/gadget/udc/charger.c b/drivers/usb/gadget/udc/charger.c new file mode 100644 index 000..7be4c76 --- /dev/null +++ b/drivers/usb/gadget/udc/charger.c @@ -0,0 +1,770 @@ +/* + * charger.c -- USB charger driver + * + * Copyright (C) 2015 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEFAULT_SDP_CUR_LIMIT 500 +#define DEFAULT_SDP_CUR_LIMIT_SS 900 +#define DEFAULT_DCP_CUR_LIMIT 1500 +#define DEFAULT_CDP_CUR_LIMIT 1500 +#define DEFAULT_ACA_CUR_LIMIT 1500 + +static DEFINE_IDA(usb_charger_ida); +struct class *usb_charger_class; +static unsigned int usb_charger_get_cur_limit(struct usb_charger *uchger); + +static struct usb_charger *dev_to_uchger(struct device *dev) +{ + return container_of(dev, struct usb_charger, dev); +} + +/* + * charger_current_show() - Show the charger current limit. + */ +static ssize_t charger_current_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct usb_charger *uchger = dev_to_uchger(dev); + + return sprintf(buf, "%u\n", usb_charger_get_cur_limit(uchger)); +} +static DEVICE_ATTR_RO(charger_current); + +/* + * charger_type_show() - Show the charger type. + * + * It can be SDP/DCP/CDP/ACA type, else for unknown type. + */ +static ssize_t charger_type_show(struct device *dev, +struct device_attribute *attr, +char *buf) +{ + struct usb_charger *uchger = dev_to_uchger(dev); + int cnt; + + switch (uchger->type) { + case SDP_TYPE: + cnt = sprintf(buf, "%s\n", "SDP"); + break; + case DCP_TYPE: + cnt = sprintf(buf, "%s\n", "DCP"); + break; + case CDP_TYPE: + cnt = sprintf(buf, "%s\n", "CDP"); + break; + case ACA_TYPE: + cnt = sprintf(buf, "%s\n", "ACA"); + break; + default:
[RESEND PATCH v11 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. Signed-off-by: Baolin Wang--- drivers/usb/gadget/Kconfig |7 + drivers/usb/gadget/udc/Makefile |1 + drivers/usb/gadget/udc/charger.c | 770 ++ include/linux/usb/charger.h | 191 ++ include/uapi/linux/usb/charger.h | 31 ++ 5 files changed, 1000 insertions(+) create mode 100644 drivers/usb/gadget/udc/charger.c create mode 100644 include/linux/usb/charger.h create mode 100644 include/uapi/linux/usb/charger.h diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 2057add..89f4e9b 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -134,6 +134,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" # diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile index dfee534..0e9564c 100644 --- a/drivers/usb/gadget/udc/Makefile +++ b/drivers/usb/gadget/udc/Makefile @@ -2,6 +2,7 @@ # USB peripheral controller drivers # obj-$(CONFIG_USB_GADGET) += udc-core.o +obj-$(CONFIG_USB_CHARGER) += charger.o obj-$(CONFIG_USB_DUMMY_HCD)+= dummy_hcd.o obj-$(CONFIG_USB_NET2272) += net2272.o obj-$(CONFIG_USB_NET2280) += net2280.o diff --git a/drivers/usb/gadget/udc/charger.c b/drivers/usb/gadget/udc/charger.c new file mode 100644 index 000..7be4c76 --- /dev/null +++ b/drivers/usb/gadget/udc/charger.c @@ -0,0 +1,770 @@ +/* + * charger.c -- USB charger driver + * + * Copyright (C) 2015 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEFAULT_SDP_CUR_LIMIT 500 +#define DEFAULT_SDP_CUR_LIMIT_SS 900 +#define DEFAULT_DCP_CUR_LIMIT 1500 +#define DEFAULT_CDP_CUR_LIMIT 1500 +#define DEFAULT_ACA_CUR_LIMIT 1500 + +static DEFINE_IDA(usb_charger_ida); +struct class *usb_charger_class; +static unsigned int usb_charger_get_cur_limit(struct usb_charger *uchger); + +static struct usb_charger *dev_to_uchger(struct device *dev) +{ + return container_of(dev, struct usb_charger, dev); +} + +/* + * charger_current_show() - Show the charger current limit. + */ +static ssize_t charger_current_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct usb_charger *uchger = dev_to_uchger(dev); + + return sprintf(buf, "%u\n", usb_charger_get_cur_limit(uchger)); +} +static DEVICE_ATTR_RO(charger_current); + +/* + * charger_type_show() - Show the charger type. + * + * It can be SDP/DCP/CDP/ACA type, else for unknown type. + */ +static ssize_t charger_type_show(struct device *dev, +struct device_attribute *attr, +char *buf) +{ + struct usb_charger *uchger = dev_to_uchger(dev); + int cnt; + + switch (uchger->type) { + case SDP_TYPE: + cnt = sprintf(buf, "%s\n", "SDP"); + break; + case DCP_TYPE: + cnt = sprintf(buf, "%s\n", "DCP"); + break; + case CDP_TYPE: + cnt = sprintf(buf, "%s\n", "CDP"); + break; + case ACA_TYPE: + cnt = sprintf(buf, "%s\n", "ACA"); + break; + default: