[PATCH] hid: migrate Dream Cheeky LED driver from USB misc to HID
The Dream Cheeky Webmail Notifier and Friends Alert are supported as part of usb/misc/usbled driver currently. This patch migrates the driver for these devices to the HID subsystem. Benefits: - Avoid using USB low-level calls and use the HID subsystem instead (as this device provides a USB HID interface) - Use standard LED subsystem instead of proprietary sysfs entries, this allows e.g. to use the device with features like triggers There might be users of the current driver, therefore so far allow compilation of the new driver only if the old one is disabled. Successfully tested with a Dream Cheeky Webmail Notifier. Signed-off-by: Heiner Kallweit--- drivers/hid/Kconfig| 8 ++ drivers/hid/Makefile | 1 + drivers/hid/hid-core.c | 6 +- drivers/hid/hid-dream-cheeky.c | 177 + drivers/hid/hid-ids.h | 2 + 5 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 drivers/hid/hid-dream-cheeky.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 16fe27d..5618a61 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -247,6 +247,14 @@ config DRAGONRISE_FF Say Y here if you want to enable force feedback support for DragonRise Inc. game controllers. +config HID_DREAM_CHEEKY + tristate "Dream Cheeky Webmail Notifier USB RGB LED" + depends on HID + depends on USB_LED = 'n' + ---help--- + Support for the Dream Cheeky Webmail Notifier. This driver registers + a LED class instance for red, green, and blue color component. + config HID_EMS_FF tristate "EMS Production Inc. force feedback support" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 90300f3..2878739 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -35,6 +35,7 @@ obj-$(CONFIG_HID_CORSAIR) += hid-corsair.o obj-$(CONFIG_HID_CP2112) += hid-cp2112.o obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o obj-$(CONFIG_HID_DRAGONRISE) += hid-dr.o +obj-$(CONFIG_HID_DREAM_CHEEKY) += hid-dream-cheeky.o obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o obj-$(CONFIG_HID_ELECOM) += hid-elecom.o obj-$(CONFIG_HID_ELO) += hid-elo.o diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 730589a..c24f758 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1879,6 +1879,8 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_WN) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_FA) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) }, { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0030) }, @@ -2349,8 +2351,6 @@ static const struct hid_device_id hid_ignore_list[] = { { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, - { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) }, - { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x000a) }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, 0x0400) }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, 0x0401) }, { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, @@ -2489,6 +2489,8 @@ static const struct hid_device_id hid_ignore_list[] = { { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, #if IS_ENABLED(CONFIG_USB_LED) { HID_USB_DEVICE(USB_VENDOR_ID_RISO_KAGAKU, USB_DEVICE_ID_RI_KA_WEBMAIL) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_WN) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_FA) }, #endif { } }; diff --git a/drivers/hid/hid-dream-cheeky.c b/drivers/hid/hid-dream-cheeky.c new file mode 100644 index 000..8c228f9 --- /dev/null +++ b/drivers/hid/hid-dream-cheeky.c @@ -0,0 +1,177 @@ +/* + * Dream Cheeka Webmail Notifier USB RGB LED driver + * + * Copyright 2016 Heiner Kallweit + * Based on drivers/hid/hid-thingm.c and + * drivers/usb/misc/usbled.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + */ + +#include +#include +#include +#include +#include + +#include "hid-ids.h" + +#define REPORT_SIZE9 +#define REPORT_ID 0 + +#define
Re: [PATCH v10 00/14] USB OTG/dual-role framework
On Fri, Jun 10, 2016 at 04:07:09PM +0300, Roger Quadros wrote: > Hi, > > This series centralizes OTG/Dual-role functionality in the kernel. > As of now I've got Dual-role functionality working pretty reliably on > dra7-evm and am437x-gp-evm. > > DWC3 controller and TI platform related patches will be sent separately. > > Series is based on v4.7-rc1 + balbi/usb.git testing/next > commit 4a2786c10462df650965785462ca82c185164d98. > Roger, I have acked for all your patches. You can send v11 for all patches. When you get Felipe's ack for gadget part, Alan's ack for hcd part, and your dwc3 and platform related patches ack, you can let Felipe help to queue this patch set since some of the code based on his tree. Thank you for your hard work for it. Peter > Why?: > > > Currently there is no central location where OTG/dual-role functionality is > implemented in the Linux USB stack and every USB controller driver is > doing their own thing for OTG/dual-role. We can benefit from code-reuse > and simplicity by adding the OTG/dual-role core driver. > > Newer OTG cores support standard host interface (e.g. xHCI) so > host and gadget functionality are no longer closely knit like older > cores. There needs to be a way to co-ordinate the operation of the > host and gadget controllers in dual-role mode. i.e. to stop and start them > from a central location. This central location should be the > USB OTG/dual-role core. > > Host and gadget controllers might be sharing resources and can't > be always running. One has to be stopped for the other to run. > This couldn't be done till now but can be done from the OTG core. > > What?: > - > > The OTG/dual-role core consists of a set of APIs that allow > registration of OTG controller device and OTG capable host and gadget > controllers. > > - The OTG controller driver can provide the OTG capabilities and the > Finite State Machine work function via 'struct usb_otg_config' > at the time of registration i.e. usb_otg_register(); > > struct usb_otg *usb_otg_register(struct device *dev, >struct usb_otg_config *config); > int usb_otg_unregister(struct device *dev); > /** >* struct usb_otg_config - otg controller configuration >* @caps: otg capabilities of the controller >* @ops: otg fsm operations >* @otg_work: optional custom otg state machine work function >*/ > struct usb_otg_config { > struct usb_otg_caps *otg_caps; > struct otg_fsm_ops *fsm_ops; > void (*otg_work)(struct work_struct *work); > }; > > The dual-role state machine is built-into the OTG core so nothing > special needs to be provided if only dual-role functionality is desired. > The low level OTG controller driver ops are povided via > 'struct otg_fsm_ops *fsm_ops' in the 'struct usb_otg_config'. > > After registration, the OTG core waits for host, gadget controller > and the gadget function driver to be registered. Once all resources are > available it instantiates the Finite State Machine (FSM). > The host/gadget controllers are started/stopped according to the FSM. > > - Host and gadget controllers that are a part of OTG/dual-role port must > use the OTG core provided APIs to add/remove the host/gadget. > i.e. hosts must use usb_otg_add_hcd() usb_otg_remove_hcd(),, > gadgets must use usb_otg_add_gadget_udc() usb_del_gadget_udc(). > This ensures that the host and gadget controllers are not started till > the state machine is ready and the right bus conditions are met. > It also allows the host and gadget controllers to provide the OTG > controller device to link them together. For Device tree boots > the related OTG controller is automatically picked up via the > 'otg-controller' property in the Host/Gadget controller nodes. > > int usb_otg_add_hcd(struct usb_hcd *hcd, > unsigned int irqnum, unsigned long irqflags, > struct device *otg_dev); > void usb_otg_remove_hcd(struct usb_hcd *hcd); > > int usb_otg_add_gadget_udc(struct device *parent, > struct usb_gadget *gadget, > struct device *otg_dev); > usb_del_gadget_udc() must be used for removal. > > > - During the lifetime of the FSM, the OTG controller driver can provide > inputs event changes using usb_otg_sync_inputs(). The OTG core will > then schedule the FSM work function (or internal dual-role state machine) > to update the FSM state. The FSM then calls the OTG controller > operations (fsm_ops) as necessary. > void usb_otg_sync_inputs(struct usb_otg *otg); > > - The following 2 functions are provided as helpers for use by the > OTG controller driver to start/stop the host/gadget controllers. > int usb_otg_start_host(struct usb_otg *otg, int on); > int usb_otg_start_gadget(struct usb_otg *otg, int on); > > - The following
Re: [PATCH v3,1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode
On Mon, 2016-06-13 at 13:54 -0500, Rob Herring wrote: > On Fri, Jun 10, 2016 at 03:32:38PM +0800, Chunfeng Yun wrote: > > Some resources, such as IPPC register etc, shared with device > > driver are moved into common glue layer when xHCI driver is the > > host side of dual-role mode and they should be changed as optional > > properties if they are required ones before. For clarity, add > > a new part of binding to support host side of dual-role mode. > > > > Additionally add optional properties of pinctrl for host only mode > > > > Signed-off-by: Chunfeng Yun> > --- > > .../devicetree/bindings/usb/mt8173-xhci.txt| 48 > > > > 1 file changed, 48 insertions(+) > > Acked-by: Rob Herring Thank you -- 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: [PATCH v3,2/5] dt-bindings: mt8173-mtu3: add devicetree bindings
On Fri, 2016-06-10 at 12:21 +0300, Felipe Balbi wrote: > Hi, > > Chunfeng Yunwrites: > > + - enable-manual-drd : supports manual dual-role switch via sysfs; only > > used > > + when receptacle is TYPE-A and also wants to support dual-role mode. > > sorry, but this manual-drd can't be accepted. You should rely on a DT > property for this and you shouldn't expose it to sysfs. Use DebugFS for > that. I will make use of debugfs instead Thanks a lot > > -- 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: [PATCH v3] usb: phy: mxs: Add DT bindings to configure TX settings
On Mon, Jun 13, 2016 at 04:40:55PM -0400, Jaret Cantu wrote: > > > >According to your previous information, the single formula can't be used > >to get D_CAL value, do you have any good ways except for using a table? > > That is not exactly what I said: > > "I can't find any formula which would hit all of those same > percentages **without rounding up.**" > Sorry, my careless. > I did find a formula that hits all of the percentages with rounding > up, and I listed this formula (in shell form) previously. The > rounding (+ (119-80)/2) just makes it look a little more awkward > than I would like: > > $ for d in 119 116 114 112 109 106 103 100 97 95 93 90 88 86 83 79; > do echo "$d="$(( ( (119-$d) * 0xf + (119-80)/2 ) / (119-80) )); > d=$((d+1)); done > 119=0 > 116=1 > 114=2 > 112=3 > 109=4 > 106=5 > 103=6 > 100=7 > 97=8 > 95=9 > 93=10 > 90=11 > 88=12 > 86=13 > 83=14 > 79=15 > > These current percentage/register value pairs match the D_CAL table. > > > > Sending the patch for new algorithm to speed up this issue please. > > > There were also some Documentation changes from between when I > created this patch and the current HOL for which I had to modify the > patch. I will review and test your v4 patch, thanks. -- Best Regards, Peter Chen -- 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: [PATCH] USB: core: fix missing include
On Tue, Jun 07, 2016 at 07:20:33PM +0100, Ben Dooks wrote: > The helper function usb_of_get_child_node() is defined in the > header but this was not included. Fix the warning > about usb_of_get_child_node() not being declared by adding the > right include. Fixes: > > drivers/usb/core/of.c:31:20: warning: symbol 'usb_of_get_child_node' was not > declared. Should it be static? > > Signed-off-by: Ben DooksGiven that the kbuild robot broke with this patch, I'm not going to take it... -- 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: uac2: diagnosing uac2 audio gadget problems
On Mon, Jun 13, 2016 at 4:04 PM, Caleb Cromewrote: > On Mon, Jun 13, 2016 at 2:53 AM, Peter Chen wrote: >> On Wed, Jun 08, 2016 at 04:11:11PM -0700, Caleb Crome wrote: >>> >>> Here is the script I use for starting the gadget interface: >>> >>> cd /sys/kernel/config/usb_gadget >>> mkdir g1 >>> cd g1 >>> echo "0x1d6b" > idVendor >>> echo "0x0104" > idProduct >>> mkdir strings/0x409 >>> echo "0123456789" > strings/0x409/serialnumber >>> echo "Foo Inc." > strings/0x409/manufacturer >>> echo "Bar Gadget" > strings/0x409/product >>> mkdir functions/uac2.aud0 >>> mkdir functions/ecm.usb0 >>> #echo 64000 > functions/uac2.aud0/c_srate >>> #echo 64000 > functions/uac2.aud0/p_srate >>> mkdir configs/c.1 >>> mkdir configs/c.1/strings/0x409 >>> echo "CDC ECM + audio" > configs/c.1/strings/0x409/configuration >>> ln -s functions/uac2.aud0 configs/c.1 >>> ln -s functions/ecm.usb0 configs/c.1 >>> echo `ls /sys/class/udc/` > /sys/kernel/config/usb_gadget/g1/UDC >>> >> >> Try to use below command to see if it works, it works at my i.mx6 board. >> >> 1. List of PLAYBACK Hardware Devices >> root@imx6sxsabresd:~# aplay -l >> List of PLAYBACK Hardware Devices >> card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 [] >> Subdevices: 1/1 >> Subdevice #0: subdevice #0 >> card 1: imxspdif [imx-spdif], device 0: S/PDIF PCM Playback dit-hifi-0 [] >> Subdevices: 1/1 >> Subdevice #0: subdevice #0 >> card 2: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM] >> Subdevices: 1/1 >> Subdevice #0: subdevice #0 >> 2. List of CAPTURE Hardware Devices >> root@imx6sxsabresd:~# arecord -l >> List of CAPTURE Hardware Devices >> card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 [] >> Subdevices: 1/1 >> Subdevice #0: subdevice #0 >> card 2: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM] >> Subdevices: 1/1 >> Subdevice #0: subdevice #0 >> 3. Using below command to play (it is playback, the audio file is from >> PC) >> root@imx6sxsabresd:~# arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 & >> >> NOTE: arecord uses uac2_gadget to record, aplay uses real codec to play >> > > Great to hear that it works on your board, that gives me hope :-) > > 2 questions: > 1) What kernel version do you use? > 2) What are the commands you send to configfs to get it working? Does > it look like mine? > > The command you suggest > # arecord -f dat -t wav -D hw:2,0 > > does not work for me: again, I get an error message: > > # arecord: pcm_read:2031: read error: Input/output error > > >>> >>> When I run the script above I get the following dumped into /var/log/syslog: >>> Jun 8 23:08:14 wandboard kernel: [ 139.994081] using random self >>> ethernet address >>> Jun 8 23:08:14 wandboard kernel: [ 139.994107] using random host >>> ethernet address >>> Jun 8 23:08:14 wandboard NetworkManager[359]: >>> nm_device_get_device_type: assertion 'NM_IS_DEVICE (self)' failed >>> Jun 8 23:08:14 wandboard NetworkManager[359]: (usb0): new >>> Generic device (carrier: OFF, driver: 'g_ether', ifindex: 4) >>> Jun 8 23:08:14 wandboard kernel: [ 140.125255] usb0: HOST MAC >>> 3e:52:2d:0d:98:fe >>> Jun 8 23:08:14 wandboard kernel: [ 140.153803] usb0: MAC 0e:cf:aa:06:aa:8a >>> Jun 8 23:08:14 wandboard systemd-udevd[773]: Failed to apply ACL on >>> /dev/snd/controlC3: Operation not supported >>> Jun 8 23:08:14 wandboard systemd-udevd[776]: Failed to apply ACL on >>> /dev/snd/pcmC3D0c: Operation not supported >>> Jun 8 23:08:14 wandboard systemd-udevd[775]: Failed to apply ACL on >>> /dev/snd/pcmC3D0p: Operation not supported >>> Jun 8 23:08:14 wandboard systemd-udevd[773]: Process >>> '/usr/sbin/alsactl -E HOME=/var/run/alsa restore 3' failed with exit >>> code 99. >>> Jun 8 23:08:14 wandboard NetworkManager[359]: devices added >>> (path: >>> /sys/devices/soc0/soc/210.aips-bus/2184000.usb/ci_hdrc.0/gadget/net/usb0, >>> iface: usb0) >>> Jun 8 23:08:14 wandboard NetworkManager[359]: device added >>> (path: >>> /sys/devices/soc0/soc/210.aips-bus/2184000.usb/ci_hdrc.0/gadget/net/usb0, >>> iface: usb0): no ifupdown configuration found. >>> >>> >>> Any idea what could be wrong?Is the 'Failed to apply ACL' relavent? >> >> Sorry, I don't know what that mean, do that mean there is something >> wrong with your local codec? > > No, I'm not trying to use a local codec at all. I'm trying to capture > to a .wav file. I'm just getting the above messages that look like > this: > >>> Jun 8 23:08:14 wandboard systemd-udevd[773]: Failed to apply ACL on >>> /dev/snd/controlC3: Operation not supported > > Any idea why that is? It's the UAC2 audio device. Do you get that > message in your syslog? Ah, I found that setting CONFIG_TMPFS_POSIX_ACL in the kernel config fixed the ACL problem, but did nothing for my input/output error. I still get arecord: pcm_read:2031: read error: Input/output error -Caleb -- To unsubscribe from this list:
Re: uac2: diagnosing uac2 audio gadget problems
On Mon, Jun 13, 2016 at 2:53 AM, Peter Chenwrote: > On Wed, Jun 08, 2016 at 04:11:11PM -0700, Caleb Crome wrote: >> >> Here is the script I use for starting the gadget interface: >> >> cd /sys/kernel/config/usb_gadget >> mkdir g1 >> cd g1 >> echo "0x1d6b" > idVendor >> echo "0x0104" > idProduct >> mkdir strings/0x409 >> echo "0123456789" > strings/0x409/serialnumber >> echo "Foo Inc." > strings/0x409/manufacturer >> echo "Bar Gadget" > strings/0x409/product >> mkdir functions/uac2.aud0 >> mkdir functions/ecm.usb0 >> #echo 64000 > functions/uac2.aud0/c_srate >> #echo 64000 > functions/uac2.aud0/p_srate >> mkdir configs/c.1 >> mkdir configs/c.1/strings/0x409 >> echo "CDC ECM + audio" > configs/c.1/strings/0x409/configuration >> ln -s functions/uac2.aud0 configs/c.1 >> ln -s functions/ecm.usb0 configs/c.1 >> echo `ls /sys/class/udc/` > /sys/kernel/config/usb_gadget/g1/UDC >> > > Try to use below command to see if it works, it works at my i.mx6 board. > > 1. List of PLAYBACK Hardware Devices > root@imx6sxsabresd:~# aplay -l > List of PLAYBACK Hardware Devices > card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 [] > Subdevices: 1/1 > Subdevice #0: subdevice #0 > card 1: imxspdif [imx-spdif], device 0: S/PDIF PCM Playback dit-hifi-0 [] > Subdevices: 1/1 > Subdevice #0: subdevice #0 > card 2: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM] > Subdevices: 1/1 > Subdevice #0: subdevice #0 > 2. List of CAPTURE Hardware Devices > root@imx6sxsabresd:~# arecord -l > List of CAPTURE Hardware Devices > card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 [] > Subdevices: 1/1 > Subdevice #0: subdevice #0 > card 2: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM] > Subdevices: 1/1 > Subdevice #0: subdevice #0 > 3. Using below command to play (it is playback, the audio file is from > PC) > root@imx6sxsabresd:~# arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 & > > NOTE: arecord uses uac2_gadget to record, aplay uses real codec to play > Great to hear that it works on your board, that gives me hope :-) 2 questions: 1) What kernel version do you use? 2) What are the commands you send to configfs to get it working? Does it look like mine? The command you suggest # arecord -f dat -t wav -D hw:2,0 does not work for me: again, I get an error message: # arecord: pcm_read:2031: read error: Input/output error >> >> When I run the script above I get the following dumped into /var/log/syslog: >> Jun 8 23:08:14 wandboard kernel: [ 139.994081] using random self >> ethernet address >> Jun 8 23:08:14 wandboard kernel: [ 139.994107] using random host >> ethernet address >> Jun 8 23:08:14 wandboard NetworkManager[359]: >> nm_device_get_device_type: assertion 'NM_IS_DEVICE (self)' failed >> Jun 8 23:08:14 wandboard NetworkManager[359]: (usb0): new >> Generic device (carrier: OFF, driver: 'g_ether', ifindex: 4) >> Jun 8 23:08:14 wandboard kernel: [ 140.125255] usb0: HOST MAC >> 3e:52:2d:0d:98:fe >> Jun 8 23:08:14 wandboard kernel: [ 140.153803] usb0: MAC 0e:cf:aa:06:aa:8a >> Jun 8 23:08:14 wandboard systemd-udevd[773]: Failed to apply ACL on >> /dev/snd/controlC3: Operation not supported >> Jun 8 23:08:14 wandboard systemd-udevd[776]: Failed to apply ACL on >> /dev/snd/pcmC3D0c: Operation not supported >> Jun 8 23:08:14 wandboard systemd-udevd[775]: Failed to apply ACL on >> /dev/snd/pcmC3D0p: Operation not supported >> Jun 8 23:08:14 wandboard systemd-udevd[773]: Process >> '/usr/sbin/alsactl -E HOME=/var/run/alsa restore 3' failed with exit >> code 99. >> Jun 8 23:08:14 wandboard NetworkManager[359]: devices added >> (path: >> /sys/devices/soc0/soc/210.aips-bus/2184000.usb/ci_hdrc.0/gadget/net/usb0, >> iface: usb0) >> Jun 8 23:08:14 wandboard NetworkManager[359]: device added >> (path: >> /sys/devices/soc0/soc/210.aips-bus/2184000.usb/ci_hdrc.0/gadget/net/usb0, >> iface: usb0): no ifupdown configuration found. >> >> >> Any idea what could be wrong?Is the 'Failed to apply ACL' relavent? > > Sorry, I don't know what that mean, do that mean there is something > wrong with your local codec? No, I'm not trying to use a local codec at all. I'm trying to capture to a .wav file. I'm just getting the above messages that look like this: >> Jun 8 23:08:14 wandboard systemd-udevd[773]: Failed to apply ACL on >> /dev/snd/controlC3: Operation not supported Any idea why that is? It's the UAC2 audio device. Do you get that message in your syslog? Thanks, -Caleb > > -- > > Best Regards, > Peter Chen -- 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: [PATCH v3] usb: phy: mxs: Add DT bindings to configure TX settings
On 06/11/2016 11:25 PM, Peter Chen wrote: On Thu, Jun 09, 2016 at 02:07:52PM -0400, Justin Waters wrote: Peter, On Wed, Jun 8, 2016 at 10:41 PM, Peter Chenwrote: On Thu, Jun 9, 2016 at 5:27 AM, Jaret Cantu wrote: On 03/23/2016 10:21 PM, Peter Chen wrote: On Wed, Mar 23, 2016 at 02:17:27PM -0400, Jaret Cantu wrote: On 03/23/2016 01:37 PM, Jaret Cantu wrote: On 03/23/2016 12:36 AM, Peter Chen wrote: On Mon, Mar 21, 2016 at 12:32:27PM -0400, Jaret Cantu wrote: The TX settings can be calibrated for particular hardware. The phy is reset by Linux, so this cannot be handled by the bootloader. The TRM mentions that the maximum resistance should be used for the DN/DP calibration in order to pass USB certification. The values for the TX registers are poorly described in the TRM. The meanings of the register values were taken from another Freescale-provided document: https://community.freescale.com/message/566147#comment-566912 Signed-off-by: Jaret Cantu --- v3. Added unit suffix (-ohms) to tx-cal-45-d* v2. Copying devicetree list Removed prettifying extra whitespace Removed unnecessary register rewrite on resume Use min and max constants for clarity .../devicetree/bindings/phy/mxs-usb-phy.txt| 10 drivers/usb/phy/phy-mxs-usb.c | 58 2 files changed, 68 insertions(+) diff --git a/Documentation/devicetree/bindings/phy/mxs-usb-phy.txt b/Documentation/devicetree/bindings/phy/mxs-usb-phy.txt index 379b84a..1d25b04 100644 --- a/Documentation/devicetree/bindings/phy/mxs-usb-phy.txt +++ b/Documentation/devicetree/bindings/phy/mxs-usb-phy.txt @@ -12,6 +12,16 @@ Required properties: - interrupts: Should contain phy interrupt - fsl,anatop: phandle for anatop register, it is only for imx6 SoC series + +if (!of_property_read_u32(np, "fsl,tx-d-cal", ) && +val >= MXS_PHY_TX_D_CAL_MIN && val <= MXS_PHY_TX_D_CAL_MAX) { +/* scale to 4-bit value */ +val = (MXS_PHY_TX_D_CAL_MAX - val) * 0xF +/ (MXS_PHY_TX_D_CAL_MAX - MXS_PHY_TX_D_CAL_MIN); +mxs_phy->tx_reg_mask |= GM_USBPHY_TX_D_CAL(~0); +mxs_phy->tx_reg_set |= GM_USBPHY_TX_D_CAL(val); +} + I have tested "tx-d-cal", but it seems incorrect according to the xls you have provided, would you please check it again or am I wrong? Gah! You're right. Some of the D_CAL values need to be rounded up to match the xls. And even then, the value for 86 still doesn't play nice. I was really hoping to avoid using a table for these values. The TXCALDP/DN values use a much simpler 1-to-1 scale across the 16 possible register values and so are unaffected by a similar issue. I rechecked their numbers just to be sure. The solution looks to be to scale D_CAL starting from 80 instead of 79. If you look at the xls listing, the jump from 79 to 83 is the only time two adjacent register values result in a change greater than 2% or 3%. This will result in some code ugliness as the minimum allowed percentage (79), per the Freescale document, and the point at which we are scaling the percentage values to register values (80) are different. And, as mentioned before, the values will also have to be rounded up. This quick shell code confirms that these sorts of calculations match up with the values in the spreadsheet: for d in 119 116 114 112 109 106 103 100 97 95 93 90 88 86 83 79; do echo "$d="$(( ( (119-$d) * 0xf + (119-80)/2 ) / (119-80) )); d=$((d+1)); done I can't find any formula which would hit all of those same percentages without rounding up. Then, we had to use table for it. Besides, IC team confirms the default value and the step for TXCAL45DP/DN are changed at next generation SoCs, so I am wondering how we describe it at binding doc. Which next gen SoC would this be? The MX7? The documentation for the USB PHY in that reference manual is even sparser than the one for the MX6 in regards to these register values. Here, I mean i.mx8 Currently, there is no support in the mainline kernel for the i.MX8. Do you mean to say that this feature is blocked until the i.MX8 is supported in the mainline kernel? Or that we would be required to add the register definitions for the i.MX8 as a prerequisite? Wouldn't it make more sense to add support to the driver as part of the i.MX8 enablement, especially considering no documentation is freely available at this time? The MX7 manual does still mention that HW_USBPHY_TX_TXCAL45DP and HW_USBPHY_TX_TXCAL45DN should both be set to zero, but there is no listing as to the location of these registers, let alone their defaults/step values. Do you know where we could get the default and step values for the TXCAL registers on the new SoC? This information had to come from a Freescale community thread for the MX6 since it wasn't defined clearly elsewhere. In theory, these information should be
Re: [PATCH v3,1/5] dt-bindings: mt8173-xhci: support host side of dual-role mode
On Fri, Jun 10, 2016 at 03:32:38PM +0800, Chunfeng Yun wrote: > Some resources, such as IPPC register etc, shared with device > driver are moved into common glue layer when xHCI driver is the > host side of dual-role mode and they should be changed as optional > properties if they are required ones before. For clarity, add > a new part of binding to support host side of dual-role mode. > > Additionally add optional properties of pinctrl for host only mode > > Signed-off-by: Chunfeng Yun> --- > .../devicetree/bindings/usb/mt8173-xhci.txt| 48 > > 1 file changed, 48 insertions(+) Acked-by: Rob Herring -- 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 4/4] power: wm831x_power: Support USB charger current limit management
Hi, [auto build test ERROR on balbi-usb/next] [also build test ERROR on v4.7-rc3 next-20160609] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-usb-charger-framework-to-deal-with-the-usb-gadget-power-negotation/20160613-165523 base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next config: x86_64-allmodconfig (attached as .config) compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): ERROR: "usb_charger_init" [drivers/usb/gadget/udc/udc-core.ko] undefined! ERROR: "usb_charger_plug_by_gadget" [drivers/usb/gadget/udc/udc-core.ko] undefined! ERROR: "usb_charger_exit" [drivers/usb/gadget/udc/udc-core.ko] undefined! ERROR: "usb_charger_set_cur_limit_by_type" [drivers/usb/gadget/libcomposite.ko] undefined! ERROR: "usb_charger_set_cur_limit_by_type" [drivers/usb/gadget/legacy/gadgetfs.ko] undefined! >> 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 infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH] usb: common: otg-fsm: add license to usb-otg-fsm
Fix warning about tainted kernel because usb-otg-fsm has no license. WARNING: with this patch usb-otg-fsm module can be loaded but then the kernel will hang. Tested with a udoo quad board. Signed-off-by: Oscar Curero--- drivers/usb/common/usb-otg-fsm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c index 9059b7d..2f537bb 100644 --- a/drivers/usb/common/usb-otg-fsm.c +++ b/drivers/usb/common/usb-otg-fsm.c @@ -21,6 +21,7 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include #include @@ -450,3 +451,4 @@ int otg_statemachine(struct otg_fsm *fsm) return fsm->state_changed; } EXPORT_SYMBOL_GPL(otg_statemachine); +MODULE_LICENSE("GPL"); -- 2.8.4 -- 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: [PATCH] USB: remove race condition in usbfs/libusb when using reap-after-disconnect
From: Alan Stern > Sent: 10 June 2016 19:43 > Hans de Goede has reported a difficulty in the Linux port of libusb. > When a device is removed, the poll() system call in usbfs starts > returning POLLERR as soon as udev->state is set to > USB_STATE_NOTATTACHED, but the outstanding URBs are not available for > reaping until some time later (after usbdev_remove() has been called). > This is awkward for libusb or other usbfs clients, although not an > insuperable problem. > > At any rate, it's easy to change usbfs so that it returns POLLHUP as > soon as the state becomes USB_STATE_NOTATTACHED but it doesn't return > POLLERR until after the outstanding URBs have completed. That's what > this patch does; it uses the fact that ps->list is always on the > dev->filelist list until usbdev_remove() takes it off, which happens > after all the outstanding URBs have been cancelled. You need some way for the application to clear the POLLHUP indication (at least temporarily) so that it can wait for a further change - be it notification that a URB is now reapable or that all the tidyup is complete. Personally I'd use POLLHUP for device disconnect type errors and leave POLLERR for serious things (like bad fd numbers). David -- 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 WangReviewed-by: Li Jun Tested-by: Li Jun > --- > 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
Re: [RESENDING] dwc2: Using internal phy (fs mode) for STM32F4x9 platform
Hi On Mon, Jun 13, 2016 at 9:19 AM, Maxime Coquelinwrote: > Hi, > > 2016-06-10 8:56 GMT+02:00 Felipe Balbi : >> >> Hi, >> >> John Youn writes: >>> On 6/9/2016 10:18 AM, Bruno Herrera wrote: Hello all, I'm bringing the linux kernel for the STM32F4 MCU (mmu-less). This MCU has two DWC2 cores on it:one for USB OTG HS and one for USB OTG FS. I was able to make the DWC2 driver to work in FS mode using a internal phy in both cores (HS and FS), but I had to patch it (in a bad way, see bellow). Basically STM32 uses a GGPIO register to control the POWER state of the internal phy as it describes in the reference manual: OTG general core configuration register (OTG_GCCFG) Address offset: 0x038 Reset value: 0x Powerdown -> BIT(16) Used to activate the transceiver in transmission/reception 0: Power down active 1: Power down deactivated (“Transceiver active”) So far what I did was in the dwc2_core_init + /* Program the GGPIO register */ + usbgpio = dwc2_readl(hsotg->regs + GGPIO); + usbgpio |= GGPIO_PWRDWN; + dwc2_writel(usbgpio, hsotg->regs + GGPIO); So I would like to check what would be you recommendation to implement in it in the right way. As it is a internal USB core register I could not find a way to implement a phy that access it. Syscon is also not the case (I guess) for the same reason. One way I thought would be to create a new property like: - snps,ggpio-reg: the value of GGPIO register for specific SoC/Vendor in my STM32 case could be something like that: snps,ggpio-reg = <0x10> The problem with this approach is that it could not be toggled "logicaly" from let say some phy on/off code. please share you thoughts on this. >>> >>> Hi Bruno, >>> >>> Unfortunately I'm not familiar enough with devicetree or the PHY >>> framework to think of a good solution. >>> >>> Felipe, >>> >>> Do you have any advice on the best way to handle this? >>> >>> Looks like soc-specific PHY controls are mapped to the controller >>> GPIO. We can add SOC specific code directly in the driver, but is >>> there a better way? >> >> the best scenario would be to runtime detection of this based on some >> register. If that's not possible, then a DT flag would be nice, but I >> would call the flag by something more human readable such as >> "snps,activate-transceiver" or something like that. > > In case auto-detection is not possible, shouldn't be better to have a > stm32 compatible, > and associate it with dedicated params as done for other platforms? > See drivers/usb/dwc2/platform.c > > Regards, > Maxime looking into the documentation I could not find a way to auto detect the core is running on STM32. And the register used by ST is GGPIO, so it could be used for different purposes according to the SoC vendor. We will need to have a stm32 complatible dwc2_core_params because the parameters for the FS core are not the hw detected ones. So in this case I see 2 options: 1 - We create a param in the dwc2_core_params that is only for ST: int stm_activate_transceiver; 2 - We create a ST specific DT option for that: - stm32, activate-transceiver: br., Bruno -- 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 3/4] gadget: Integrate with the usb gadget supporting for usb charger
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 3/4] gadget: Integrate with the usb gadget > supporting for usb charger > > When the usb gadget supporting for usb charger is ready, the usb charger > can implement the usb_charger_plug_by_gadget() function and > usb_charger_exit() function by getting 'struct usb_charger' from 'struct > gadget'. > > Signed-off-by: Baolin WangReviewed-by: Li Jun Tested-by: Li Jun > --- > drivers/usb/gadget/udc/charger.c | 39 > +- > 1 file changed, 38 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [RESEND PATCH v11 2/4] gadget: Support for the usb charger framework
Hi > -Original Message- > From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > ow...@vger.kernel.org] On Behalf Of Baolin Wang > Sent: Monday, June 13, 2016 4:47 PM > To: ba...@kernel.org; gre...@linuxfoundation.org; s...@kernel.org; > dbarysh...@gmail.com; dw...@infradead.org > Cc: r...@kernel.org; m.szyprow...@samsung.com; ruslan.bilo...@gmail.com; > peter.c...@freescale.com; st...@rowland.harvard.edu; r.bald...@samsung.com; > yoshihiro.shimoda...@renesas.com; lee.jo...@linaro.org; broo...@kernel.org; > ckee...@opensource.wolfsonmicro.com; patc...@opensource.wolfsonmicro.com; > baolin.w...@linaro.org; linux...@vger.kernel.org; linux- > u...@vger.kernel.org; device-mainlin...@lists.linuxfoundation.org; linux- > ker...@vger.kernel.org > Subject: [RESEND PATCH v11 2/4] gadget: Support for the usb charger > framework > > For supporting the usb charger, it adds the usb_charger_init() and > usb_charger_exit() functions for usb charger initialization and exit. > > It will report to the usb charger when the gadget state is changed, then > the usb charger can do the power things. > > Signed-off-by: Baolin WangReviewed-by: Li Jun Tested-by: Li Jun > --- > drivers/usb/gadget/udc/udc-core.c | 11 +++ > include/linux/usb/gadget.h| 11 +++ > 2 files changed, 22 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/2] mfd: ti-smusbdig: Add support for the TI SM-USB-DIG
The TI SM-USB-DIG is a USB to SPI/I2C/1Wire/GPIO adapter. Add MFD core support. Signed-off-by: Andrew F. Davis--- Changes from v2: - Add missing dependency on USB, thanks kbuild test robot drivers/mfd/Kconfig | 9 +++ drivers/mfd/Makefile| 2 + drivers/mfd/ti-smusbdig.c | 138 include/linux/mfd/ti-smusbdig.h | 75 ++ 4 files changed, 224 insertions(+) create mode 100644 drivers/mfd/ti-smusbdig.c create mode 100644 include/linux/mfd/ti-smusbdig.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 1bcf601..af50230 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1373,6 +1373,15 @@ config MFD_LM3533 additional drivers must be enabled in order to use the LED, backlight or ambient-light-sensor functionality of the device. +config MFD_TI_SMUSBDIG + tristate "Texas Instruments SM-USB-DIG interface adapter" + depends on USB + select MFD_CORE + help + Support for the TI SM-USB-DIG USB to SPI/I2C/1Wire/GPIO adapter. + Additional drivers such as SPI_TI_SMUSBDIG, I2C_TI_SMUSBDIG, etc. must + be enabled in order to use the functionality of the device. + config MFD_TIMBERDALE tristate "Timberdale FPGA" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 42a66e1..4533b95 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -68,6 +68,8 @@ obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o wm8994-objs:= wm8994-core.o wm8994-irq.o wm8994-regmap.o obj-$(CONFIG_MFD_WM8994) += wm8994.o +obj-$(CONFIG_MFD_TI_SMUSBDIG) += ti-smusbdig.o + obj-$(CONFIG_TPS6105X) += tps6105x.o obj-$(CONFIG_TPS65010) += tps65010.o obj-$(CONFIG_TPS6507X) += tps6507x.o diff --git a/drivers/mfd/ti-smusbdig.c b/drivers/mfd/ti-smusbdig.c new file mode 100644 index 000..19f48c6 --- /dev/null +++ b/drivers/mfd/ti-smusbdig.c @@ -0,0 +1,138 @@ +/* + * MFD Core driver for TI SM-USB-DIG + * + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ + * Andrew F. Davis + * + * 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. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether expressed or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License version 2 for more details. + */ + +#include +#include +#include +#include + +#define TI_USB_VENDOR_ID0x0451 +#define TI_USB_DEVICE_ID_SM_USB_DIG 0x2f90 + +#define TI_SMUSBDIG_USB_TIMEOUT_MS 1000 + +struct ti_smusbdig_device { + struct usb_device *usb_dev; + struct usb_interface *interface; +}; + +int ti_smusbdig_xfer(struct ti_smusbdig_device *ti_smusbdig, +u8 *buffer, int size) +{ + struct device *dev = _smusbdig->interface->dev; + int actual_length, ret; + + if (!ti_smusbdig || !buffer || size <= 0) + return -EINVAL; + + ret = usb_interrupt_msg(ti_smusbdig->usb_dev, + usb_sndctrlpipe(ti_smusbdig->usb_dev, 1), + buffer, size, _length, + TI_SMUSBDIG_USB_TIMEOUT_MS); + if (ret) { + dev_err(dev, "USB transaction failed\n"); + return ret; + } + + ret = usb_interrupt_msg(ti_smusbdig->usb_dev, + usb_rcvctrlpipe(ti_smusbdig->usb_dev, 1), + buffer, TI_SMUSBDIG_PACKET_SIZE, _length, + TI_SMUSBDIG_USB_TIMEOUT_MS); + if (ret) { + dev_err(dev, "USB transaction failed\n"); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(ti_smusbdig_xfer); + +static const struct mfd_cell ti_smusbdig_mfd_cells[] = { + { .name = "ti-sm-usb-dig-gpio", }, + { .name = "ti-sm-usb-dig-i2c", }, + { .name = "ti-sm-usb-dig-spi", }, + { .name = "ti-sm-usb-dig-w1", }, +}; + +static int ti_smusbdig_probe(struct usb_interface *interface, +const struct usb_device_id *usb_id) +{ + struct usb_host_interface *hostif = interface->cur_altsetting; + struct device *dev = >dev; + struct ti_smusbdig_device *ti_smusbdig; + u8 buffer[TI_SMUSBDIG_PACKET_SIZE]; + int ret; + + if (hostif->desc.bInterfaceNumber != 0 || + hostif->desc.bNumEndpoints < 2) + return -ENODEV; + + ti_smusbdig = devm_kzalloc(dev, sizeof(*ti_smusbdig), GFP_KERNEL); + if (!ti_smusbdig) + return -ENOMEM; + + ti_smusbdig->usb_dev = usb_get_dev(interface_to_usbdev(interface)); +
[PATCH v3 2/2] i2c: ti-smusbdig: add TI SM-USB-DIG I2C bus driver
Add support for the I2C bus functionality of the TI SM-USB-DIG. Signed-off-by: Andrew F. Davis--- drivers/i2c/busses/Kconfig | 10 ++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-ti-smusbdig.c | 189 +++ 3 files changed, 200 insertions(+) create mode 100644 drivers/i2c/busses/i2c-ti-smusbdig.c diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index f167021..82be651 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -1076,6 +1076,16 @@ config I2C_ROBOTFUZZ_OSIF This driver can also be built as a module. If so, the module will be called i2c-osif. +config I2C_TI_SMUSBDIG + tristate "Texas Instruments SM-USB-DIG I2C interface" + depends on MFD_TI_SMUSBDIG + help + This adds support for the I2C bus functionality of the + TI SM-USB-DIG USB interface adapter. + + This driver can also be built as a module. If so, the module + will be called i2c-ti-smusbdig. + config I2C_TAOS_EVM tristate "TAOS evaluation module" depends on TTY diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 37f2819..38c0d87 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -103,6 +103,7 @@ obj-$(CONFIG_I2C_DLN2) += i2c-dln2.o obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o obj-$(CONFIG_I2C_PARPORT_LIGHT)+= i2c-parport-light.o obj-$(CONFIG_I2C_ROBOTFUZZ_OSIF) += i2c-robotfuzz-osif.o +obj-$(CONFIG_I2C_TI_SMUSBDIG) += i2c-ti-smusbdig.o obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o diff --git a/drivers/i2c/busses/i2c-ti-smusbdig.c b/drivers/i2c/busses/i2c-ti-smusbdig.c new file mode 100644 index 000..dfd3ca0 --- /dev/null +++ b/drivers/i2c/busses/i2c-ti-smusbdig.c @@ -0,0 +1,189 @@ +/* + * I2C bus driver for TI SM-USB-DIG + * + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ + * Andrew F. Davis + * + * 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. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether expressed or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License version 2 for more details. + */ + +#include +#include +#include +#include + +/* (data size - start condition - address - ACK) / ACK after data byte */ +#define TI_SMUSBDIG_I2C_MAX_MSG ((TI_SMUSBDIG_DATA_SIZE - 3) / 2) + +struct ti_smusbdig_i2c { + struct device *dev; + struct ti_smusbdig_device *ti_smusbdig; + struct i2c_adapter adapter; +}; + +enum ti_smusbdig_i2c_command { + TI_SMUSBDIG_I2C_START = 0x3, + TI_SMUSBDIG_I2C_STOP = 0x4, + TI_SMUSBDIG_I2C_ACKM = 0x5, + TI_SMUSBDIG_I2C_ACKS = 0x6, +}; + +static void ti_smusbdig_i2c_packet_init(struct ti_smusbdig_packet *packet) +{ + memset(packet, 0, sizeof(*packet)); + packet->function = TI_SMUSBDIG_I2C; + packet->channel = 0x1; +} + +static int ti_smusbdig_i2c_xfer(struct i2c_adapter *adapter, + struct i2c_msg *msgs, int num) +{ + struct ti_smusbdig_i2c *ti_smusbdig_i2c = i2c_get_adapdata(adapter); + struct ti_smusbdig_packet packet; + int i, j, k, ret; + + for (i = 0; i < num; i++) { + ti_smusbdig_i2c_packet_init(); + ti_smusbdig_packet_add_command(, TI_SMUSBDIG_I2C_START); + /* add read bit to address if needed */ + msgs[i].addr <<= 1; + if (msgs[i].flags & I2C_M_RD) + msgs[i].addr |= BIT(0); + ti_smusbdig_packet_add_data(, msgs[i].addr); + ti_smusbdig_packet_add_command(, TI_SMUSBDIG_I2C_ACKS); + if (msgs[i].flags & I2C_M_RD) { + for (j = 0; j < msgs[i].len; j++) { + ti_smusbdig_packet_add_data(, 0xff); + ti_smusbdig_packet_add_command(, TI_SMUSBDIG_I2C_ACKM); + } + } else { + for (j = 0; j < msgs[i].len; j++) { + ti_smusbdig_packet_add_data(, msgs[i].buf[j]); + ti_smusbdig_packet_add_command(, TI_SMUSBDIG_I2C_ACKS); + } + } + + ret = ti_smusbdig_xfer(ti_smusbdig_i2c->ti_smusbdig, + (u8 *), sizeof(packet)); + if (ret) + return ret; + + /* +* now we read in any data we got during read MSGs +* and check ACKS +
Re: [RESEND PATCH v11 2/4] gadget: Support for the usb charger framework
Hi, [auto build test ERROR on balbi-usb/next] [also build test ERROR on v4.7-rc3 next-20160609] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-usb-charger-framework-to-deal-with-the-usb-gadget-power-negotation/20160613-165523 base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next config: x86_64-allmodconfig (attached as .config) compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): >> ERROR: "usb_charger_init" [drivers/usb/gadget/udc/udc-core.ko] undefined! >> ERROR: "usb_charger_plug_by_gadget" [drivers/usb/gadget/udc/udc-core.ko] >> undefined! >> ERROR: "usb_charger_exit" [drivers/usb/gadget/udc/udc-core.ko] undefined! >> ERROR: "usb_charger_set_cur_limit_by_type" >> [drivers/usb/gadget/libcomposite.ko] undefined! >> ERROR: "usb_charger_set_cur_limit_by_type" >> [drivers/usb/gadget/legacy/gadgetfs.ko] undefined! --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: Multiple chatty devices on Intel 5 Series/3400 USB2 EHCI controller act erratic
On Sun, 12 Jun 2016, Sean M. Pappalardo wrote: > > > On 06/12/2016 06:05 PM, Alan Stern wrote: > > Okay, thanks. I just wanted to be sure the patch was behaving as > > intended. It was, but since it didn't fix your problem the whole > > thing's a moot point. > > Anything else you'd like me to try or gather if you're interested in > fixing the underlying problem? (Even though I now have a workable > workaround for my problem.) I can't think of anything to try. If something comes up, I'll let you know. Alan Stern -- 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: [PATCH] input: tablet: pegasus_notetaker: USB PM fixes
On Mon, 2016-06-13 at 15:31 +0200, Martin Kepplinger wrote: > In close() we only need usb_autopm_put_interface(), in reset_resume() Sorry, that is a misunderstanding. You need not carry about power management in close() at all. But it must be balanced of course. Regards Oliver -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] input: tablet: pegasus_notetaker: USB PM fixes
In close() we only need usb_autopm_put_interface(), in reset_resume() we need to set the device mode, and in suspend(), we must cancel the workqueue's work. Signed-off-by: Martin Kepplinger--- Thanks Oliver for these changes. For me, everything works as before. Dmitry, do you want a new version of the whole thing instead of this fix? thanks martin drivers/input/tablet/pegasus_notetaker.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/input/tablet/pegasus_notetaker.c b/drivers/input/tablet/pegasus_notetaker.c index 83aa583..0c339e7 100644 --- a/drivers/input/tablet/pegasus_notetaker.c +++ b/drivers/input/tablet/pegasus_notetaker.c @@ -211,14 +211,11 @@ static int pegasus_open(struct input_dev *dev) static void pegasus_close(struct input_dev *dev) { struct pegasus *pegasus = input_get_drvdata(dev); - int autopm_error; - autopm_error = usb_autopm_get_interface(pegasus->intf); usb_kill_urb(pegasus->irq); cancel_work_sync(>init); - if (!autopm_error) - usb_autopm_put_interface(pegasus->intf); + usb_autopm_put_interface(pegasus->intf); } static int pegasus_probe(struct usb_interface *intf, @@ -364,6 +361,7 @@ static int pegasus_suspend(struct usb_interface *intf, pm_message_t message) mutex_lock(>dev->mutex); usb_kill_urb(pegasus->irq); + cancel_work_sync(>init); mutex_unlock(>dev->mutex); return 0; @@ -384,6 +382,11 @@ static int pegasus_resume(struct usb_interface *intf) static int pegasus_reset_resume(struct usb_interface *intf) { + struct pegasus *pegasus = usb_get_intfdata(intf); + + if (pegasus->dev->users) + pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE); + return pegasus_resume(intf); } -- 2.1.4 -- 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: BUG: using smp_processor_id() in preemptible [00000000] code]
Hi, On Mon, Jun 13, 2016 at 4:06 PM, M G Berberichwrote: > Hello, > >> >> With 4.7-rc2, after detecting a USB Mass Storage device >> >> >> >> [ 11.589843] usb-storage 4-2:1.0: USB Mass Storage device detected >> >> >> >> a constant flow of kernel-BUGS is reported (several per second). > > […] > >> > This looks like a bug in the memory management subsystem. It should be >> > reported on the linux-mm mailing list (CC'ed). >> >> This bug is IOMMU related (mailing list CC’ed) and IIUC already fixed. > > Not fixed in 4.7-rc3 These patches should fix the issue: https://lkml.org/lkml/2016/6/1/310 https://lkml.org/lkml/2016/6/1/311 I'm not sure why they weren't applied... will ping the maintainers. -- 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: BUG: using smp_processor_id() in preemptible [00000000] code]
Hello, Am Donnerstag, den 09. Juni schrieb Nadav Amit: > Alan Sternwrote: > > > On Thu, 9 Jun 2016, M G Berberich wrote: > > > >> With 4.7-rc2, after detecting a USB Mass Storage device > >> > >> [ 11.589843] usb-storage 4-2:1.0: USB Mass Storage device detected > >> > >> a constant flow of kernel-BUGS is reported (several per second). […] > > This looks like a bug in the memory management subsystem. It should be > > reported on the linux-mm mailing list (CC'ed). > > This bug is IOMMU related (mailing list CC’ed) and IIUC already fixed. Not fixed in 4.7-rc3 MfG bmg -- „Des is völlig wurscht, was heut beschlos- | M G Berberich sen wird: I bin sowieso dagegn!“ | m...@m-berberich.de (SPD-Stadtrat Kurt Schindler; Regensburg) | -- 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: [PATCH resend] USB: uas: Fix slave queue_depth not being set
Hi, On 13-06-16 14:05, Oliver Neukum wrote: On Tue, 2016-05-31 at 09:18 +0200, Hans de Goede wrote: Commit 198de51dbc34 ("USB: uas: Limit qdepth at the scsi-host level") removed the scsi_change_queue_depth() call from uas_slave_configure() assuming that the slave would inherit the host's queue_depth, which that commit sets to the same value. This is incorrect, without the scsi_change_queue_depth() call the slave's queue_depth defaults to 1, introducing a performance regression. Hans, may I ask what become of this patch? I don't see it in the queue. It is here: https://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/commit/?h=usb-linus=593224ea77b1ca842f45cf76f4deeef44dfbacd1 Which is part of: https://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/log/?h=usb-linus Regards, Hans -- 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: [RESENDING] dwc2: Using internal phy (fs mode) for STM32F4x9 platform
Hi, 2016-06-10 8:56 GMT+02:00 Felipe Balbi: > > Hi, > > John Youn writes: >> On 6/9/2016 10:18 AM, Bruno Herrera wrote: >>> Hello all, >>> I'm bringing the linux kernel for the STM32F4 MCU (mmu-less). This MCU >>> has two DWC2 cores on it:one for USB OTG HS and one for USB OTG FS. >>> I was able to make the DWC2 driver to work in FS mode using a internal >>> phy in both cores (HS and FS), but I had to patch it (in a bad way, >>> see bellow). >>> Basically STM32 uses a GGPIO register to control the POWER state of >>> the internal phy as it describes in the reference manual: >>> >>> OTG general core configuration register (OTG_GCCFG) >>> Address offset: 0x038 >>> Reset value: 0x >>> >>> Powerdown -> BIT(16) >>> Used to activate the transceiver in transmission/reception >>> 0: Power down active >>> 1: Power down deactivated (“Transceiver active”) >>> >>> So far what I did was in the dwc2_core_init >>> >>> + /* Program the GGPIO register */ >>> + usbgpio = dwc2_readl(hsotg->regs + GGPIO); >>> + usbgpio |= GGPIO_PWRDWN; >>> + dwc2_writel(usbgpio, hsotg->regs + GGPIO); >>> >>> So I would like to check what would be you recommendation to implement >>> in it in the right way. >>> As it is a internal USB core register I could not find a way to >>> implement a phy that access it. >>> Syscon is also not the case (I guess) for the same reason. >>> >>> One way I thought would be to create a new property like: >>> >>> - snps,ggpio-reg: the value of GGPIO register for specific SoC/Vendor >>> >>> in my STM32 case could be something like that: >>> >>> snps,ggpio-reg = <0x10> >>> >>> The problem with this approach is that it could not be toggled >>> "logicaly" from let say some phy on/off code. >>> >>> please share you thoughts on this. >>> >> >> Hi Bruno, >> >> Unfortunately I'm not familiar enough with devicetree or the PHY >> framework to think of a good solution. >> >> Felipe, >> >> Do you have any advice on the best way to handle this? >> >> Looks like soc-specific PHY controls are mapped to the controller >> GPIO. We can add SOC specific code directly in the driver, but is >> there a better way? > > the best scenario would be to runtime detection of this based on some > register. If that's not possible, then a DT flag would be nice, but I > would call the flag by something more human readable such as > "snps,activate-transceiver" or something like that. In case auto-detection is not possible, shouldn't be better to have a stm32 compatible, and associate it with dedicated params as done for other platforms? See drivers/usb/dwc2/platform.c Regards, Maxime -- 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: [PATCH resend] USB: uas: Fix slave queue_depth not being set
On Tue, 2016-05-31 at 09:18 +0200, Hans de Goede wrote: > Commit 198de51dbc34 ("USB: uas: Limit qdepth at the scsi-host level") > removed the scsi_change_queue_depth() call from uas_slave_configure() > assuming that the slave would inherit the host's queue_depth, which > that commit sets to the same value. > > This is incorrect, without the scsi_change_queue_depth() call the slave's > queue_depth defaults to 1, introducing a performance regression. Hans, may I ask what become of this patch? I don't see it in the queue. Regards Oliver -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RESEND PATCH v11 2/4] gadget: Support for the usb charger framework
Hi, [auto build test WARNING on balbi-usb/next] [also build test WARNING on v4.7-rc3 next-20160609] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Baolin-Wang/Introduce-usb-charger-framework-to-deal-with-the-usb-gadget-power-negotation/20160613-165523 base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next reproduce: make htmldocs All warnings (new ones prefixed by >>): include/linux/usb/gadget.h:228: warning: No description found for parameter 'claimed' include/linux/usb/gadget.h:228: warning: No description found for parameter 'enabled' >> include/linux/usb/gadget.h:661: warning: No description found for parameter >> 'charger' include/linux/usb/gadget.h:661: warning: No description found for parameter 'quirk_altset_not_supp' include/linux/usb/gadget.h:661: warning: No description found for parameter 'quirk_stall_not_supp' include/linux/usb/gadget.h:661: warning: No description found for parameter 'quirk_zlp_not_supp' include/linux/usb/composite.h:507: warning: Excess struct/union/enum/typedef member 'setup_pending' description in 'usb_composite_dev' include/linux/usb/composite.h:507: warning: Excess struct/union/enum/typedef member 'os_desc_pending' description in 'usb_composite_dev' drivers/usb/gadget/function/f_acm.c:1: warning: no structured comments found drivers/usb/gadget/function/f_ecm.c:1: warning: no structured comments found drivers/usb/gadget/function/f_subset.c:1: warning: no structured comments found drivers/usb/gadget/function/f_obex.c:1: warning: no structured comments found drivers/usb/gadget/function/f_serial.c:1: warning: no structured comments found vim +/charger +661 include/linux/usb/gadget.h d8318d7f include/linux/usb/gadget.h David Cohen 2013-12-09 645 898c6086 include/linux/usb/gadget.h Felipe Balbi2011-11-22 646 unsignedsg_supported:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 647 unsignedis_otg:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 648 unsignedis_a_peripheral:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 649 unsignedb_hnp_enable:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 650 unsigneda_hnp_support:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 651 unsigneda_alt_hnp_support:1; 75a9c82a include/linux/usb/gadget.h Li Jun 2016-02-19 652 unsignedhnp_polling_support:1; 75a9c82a include/linux/usb/gadget.h Li Jun 2016-02-19 653 unsignedhost_request_flag:1; 0b2d2bba include/linux/usb/gadget.h David Cohen 2013-12-09 654 unsignedquirk_ep_out_aligned_size:1; ffd9a0fc include/linux/usb/gadget.h Robert Baldyga 2015-07-28 655 unsignedquirk_altset_not_supp:1; 02ded1b0 include/linux/usb/gadget.h Robert Baldyga 2015-07-28 656 unsignedquirk_stall_not_supp:1; ca1023c8 include/linux/usb/gadget.h Robert Baldyga 2015-07-28 657 unsignedquirk_zlp_not_supp:1; 80b2502c include/linux/usb/gadget.h Peter Chen 2015-01-28 658 unsignedis_selfpowered:1; ccdf138f include/linux/usb/gadget.h Robert Baldyga 2015-05-04 659 unsigneddeactivated:1; ccdf138f include/linux/usb/gadget.h Robert Baldyga 2015-05-04 660 unsignedconnected:1; ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 @661 }; 5702f753 include/linux/usb/gadget.h Felipe Balbi2013-07-17 662 #define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 663 ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 664 static inline void set_gadget_data(struct usb_gadget *gadget, void *data) ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 665 { dev_set_drvdata(>dev, data); } ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 666 static inline void *get_gadget_data(struct usb_gadget *gadget) ^1da177e include/linux/usb_gadget.h Linus Torvalds 2005-04-16 667 { return dev_get_drvdata(>dev); } f48cf80f include/linux/usb/gadget.h Fabien Chouteau 2010-04-23 668 static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) f48cf80f include/linux/usb/gadget.h Fabien Chouteau 2010-04-23 669 { :: The code at line 661 was first introduced by commit :: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2 :: TO: Linus Torvalds <torva...@ppc970.osdl.org> :: CC: Linus Torvalds <torva...@ppc970
Re: [BUG] cdc-acm: no data available after port open
On Mon, Jun 13, 2016 at 11:02:19AM +0200, Oliver Neukum wrote: > On Mon, 2016-06-13 at 00:37 +0200, Ladislav Michl wrote: > > On Sun, Jun 12, 2016 at 11:03:45PM +0200, Ladislav Michl wrote: > > > Once ttyACM0 starts behave strangely, read() returns only what's in > > > buffer before > > > ttyACM0 was opened and then hangs infinitely. As this bug is hard to > > > trigger, has > > > anyone clue where to start debugging? > > > > Forgot to mention, once this happens "usb 3-1.4: clear tt 1 (9061) error > > -75" > > starts showing in the syslog. Also "cdc_acm 3-1.4.3:1.0: failed to set > > dtr/rts", > > but this one is there normally. > > The translation transactor in the hub is reporting an error. > That should be reported to the driver, but there is no good > error handling. Hmm, assuming that error comes from ehci-q.c:qtd_copy_status() there is one more disturbing FIXME: static int qtd_copy_status ( struct ehci_hcd *ehci, struct urb *urb, size_t length, u32 token ) { int status = -EINPROGRESS; /* count IN/OUT bytes, not SETUP (even short packets) */ if (likely (QTD_PID (token) != 2)) urb->actual_length += length - QTD_LENGTH (token); /* don't modify error codes */ if (unlikely(urb->unlinked)) return status; /* force cleanup after short read; not always an error */ if (unlikely (IS_SHORT_READ (token))) status = -EREMOTEIO; /* serious "can't proceed" faults reported by the hardware */ if (token & QTD_STS_HALT) { if (token & QTD_STS_BABBLE) { /* FIXME "must" disable babbling device's port too */ status = -EOVERFLOW; /* CERR nonzero + halt --> stall */ } else if (QTD_CERR(token)) { status = -EPIPE; /* In theory, more than one of the following bits can be set * since they are sticky and the transaction is retried. * Which to test first is rather arbitrary. */ } else if (token & QTD_STS_MMF) { /* fs/ls interrupt xfer missed the complete-split */ status = -EPROTO; } else if (token & QTD_STS_DBE) { status = (QTD_PID (token) == 1) /* IN ? */ ? -ENOSR /* hc couldn't read data */ : -ECOMM; /* hc couldn't write data */ } else if (token & QTD_STS_XACT) { /* timeout, bad CRC, wrong PID, etc */ ehci_dbg(ehci, "devpath %s ep%d%s 3strikes\n", urb->dev->devpath, usb_pipeendpoint(urb->pipe), usb_pipein(urb->pipe) ? "in" : "out"); status = -EPROTO; } else {/* unknown */ status = -EPROTO; } } return status; } > static void acm_read_bulk_callback(struct urb *urb) > { > struct acm_rb *rb = urb->context; > struct acm *acm = rb->instance; > unsigned long flags; > int status = urb->status; > > dev_vdbg(>data->dev, "%s - urb %d, len %d\n", __func__, > rb->index, urb->actual_length); > > if (!acm->dev) { > set_bit(rb->index, >read_urbs_free); > dev_dbg(>data->dev, "%s - disconnected\n", __func__); > return; > } > > if (status) { > set_bit(rb->index, >read_urbs_free); > dev_dbg(>data->dev, "%s - non-zero urb status: %d\n", > __func__, status); > if ((status != -ENOENT) || (urb->actual_length == 0)) > return; > } > > Can you please switch on dynamic debugging for cdc_acm to see what > is being reported? Yes, just recompiled with CONFIG_DYNAMIC_DEBUG. It'll take some until that behaviour shows up. Thanks, ladis -- 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: uac2: diagnosing uac2 audio gadget problems
On Wed, Jun 08, 2016 at 04:11:11PM -0700, Caleb Crome wrote: > > Here is the script I use for starting the gadget interface: > > cd /sys/kernel/config/usb_gadget > mkdir g1 > cd g1 > echo "0x1d6b" > idVendor > echo "0x0104" > idProduct > mkdir strings/0x409 > echo "0123456789" > strings/0x409/serialnumber > echo "Foo Inc." > strings/0x409/manufacturer > echo "Bar Gadget" > strings/0x409/product > mkdir functions/uac2.aud0 > mkdir functions/ecm.usb0 > #echo 64000 > functions/uac2.aud0/c_srate > #echo 64000 > functions/uac2.aud0/p_srate > mkdir configs/c.1 > mkdir configs/c.1/strings/0x409 > echo "CDC ECM + audio" > configs/c.1/strings/0x409/configuration > ln -s functions/uac2.aud0 configs/c.1 > ln -s functions/ecm.usb0 configs/c.1 > echo `ls /sys/class/udc/` > /sys/kernel/config/usb_gadget/g1/UDC > Try to use below command to see if it works, it works at my i.mx6 board. 1. List of PLAYBACK Hardware Devices root@imx6sxsabresd:~# aplay -l List of PLAYBACK Hardware Devices card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: imxspdif [imx-spdif], device 0: S/PDIF PCM Playback dit-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM] Subdevices: 1/1 Subdevice #0: subdevice #0 2. List of CAPTURE Hardware Devices root@imx6sxsabresd:~# arecord -l List of CAPTURE Hardware Devices card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM] Subdevices: 1/1 Subdevice #0: subdevice #0 3. Using below command to play (it is playback, the audio file is from PC) root@imx6sxsabresd:~# arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 & NOTE: arecord uses uac2_gadget to record, aplay uses real codec to play > > When I run the script above I get the following dumped into /var/log/syslog: > Jun 8 23:08:14 wandboard kernel: [ 139.994081] using random self > ethernet address > Jun 8 23:08:14 wandboard kernel: [ 139.994107] using random host > ethernet address > Jun 8 23:08:14 wandboard NetworkManager[359]: > nm_device_get_device_type: assertion 'NM_IS_DEVICE (self)' failed > Jun 8 23:08:14 wandboard NetworkManager[359]: (usb0): new > Generic device (carrier: OFF, driver: 'g_ether', ifindex: 4) > Jun 8 23:08:14 wandboard kernel: [ 140.125255] usb0: HOST MAC > 3e:52:2d:0d:98:fe > Jun 8 23:08:14 wandboard kernel: [ 140.153803] usb0: MAC 0e:cf:aa:06:aa:8a > Jun 8 23:08:14 wandboard systemd-udevd[773]: Failed to apply ACL on > /dev/snd/controlC3: Operation not supported > Jun 8 23:08:14 wandboard systemd-udevd[776]: Failed to apply ACL on > /dev/snd/pcmC3D0c: Operation not supported > Jun 8 23:08:14 wandboard systemd-udevd[775]: Failed to apply ACL on > /dev/snd/pcmC3D0p: Operation not supported > Jun 8 23:08:14 wandboard systemd-udevd[773]: Process > '/usr/sbin/alsactl -E HOME=/var/run/alsa restore 3' failed with exit > code 99. > Jun 8 23:08:14 wandboard NetworkManager[359]: devices added > (path: > /sys/devices/soc0/soc/210.aips-bus/2184000.usb/ci_hdrc.0/gadget/net/usb0, > iface: usb0) > Jun 8 23:08:14 wandboard NetworkManager[359]: device added > (path: > /sys/devices/soc0/soc/210.aips-bus/2184000.usb/ci_hdrc.0/gadget/net/usb0, > iface: usb0): no ifupdown configuration found. > > > Any idea what could be wrong?Is the 'Failed to apply ACL' relavent? Sorry, I don't know what that mean, do that mean there is something wrong with your local codec? -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next 0/3] r8152: code adjustment for PHY
These patches are for adjusting the code about PHY and setting speed. Hayes Wang (3): r8152: move the settings of PHY to a work queue r8152: move the setting for the default speed r8152: save the speed drivers/net/usb/r8152.c | 53 ++--- 1 file changed, 41 insertions(+), 12 deletions(-) -- 2.4.11 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next 1/3] r8152: move the settings of PHY to a work queue
Move the settings of PHY to a work queue and schedule it after rtl_ops.init(). There are some reasons for this. First, the settings are only needed for the first time initialization or after the power down occurs. Second, the settings are independent with the others. Last, the settings may take more time than the others. Leave they in probe() or open() may delay the following flows. Signed-off-by: Hayes Wang--- drivers/net/usb/r8152.c | 32 +++- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 161c25e..46fe9a7 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -602,7 +602,7 @@ struct r8152 { struct list_head rx_done, tx_free; struct sk_buff_head tx_queue, rx_queue; spinlock_t rx_lock, tx_lock; - struct delayed_work schedule; + struct delayed_work schedule, hw_phy_work; struct mii_if_info mii; struct mutex control; /* use for hw setting */ #ifdef CONFIG_PM_SLEEP @@ -619,6 +619,7 @@ struct r8152 { int (*eee_get)(struct r8152 *, struct ethtool_eee *); int (*eee_set)(struct r8152 *, struct ethtool_eee *); bool (*in_nway)(struct r8152 *); + void (*hw_phy_cfg)(struct r8152 *); } rtl_ops; int intr_interval; @@ -2499,8 +2500,6 @@ static void r8152b_exit_oob(struct r8152 *tp) rxdy_gated_en(tp, true); r8153_teredo_off(tp); - r8152b_hw_phy_cfg(tp); - ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, 0x00); @@ -2678,8 +2677,6 @@ static void r8153_first_init(struct r8152 *tp) ocp_data &= ~RCR_ACPT_ALL; ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); - r8153_hw_phy_cfg(tp); - rtl8152_nic_reset(tp); ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); @@ -3040,6 +3037,25 @@ out1: usb_autopm_put_interface(tp->intf); } +static void rtl_hw_phy_work_func_t(struct work_struct *work) +{ + struct r8152 *tp = container_of(work, struct r8152, hw_phy_work.work); + + if (test_bit(RTL8152_UNPLUG, >flags)) + return; + + if (usb_autopm_get_interface(tp->intf) < 0) + return; + + mutex_lock(>control); + + tp->rtl_ops.hw_phy_cfg(tp); + + mutex_unlock(>control); + + usb_autopm_put_interface(tp->intf); +} + #ifdef CONFIG_PM_SLEEP static int rtl_notifier(struct notifier_block *nb, unsigned long action, void *data) @@ -3518,6 +3534,7 @@ static int rtl8152_resume(struct usb_interface *intf) if (!test_bit(SELECTIVE_SUSPEND, >flags)) { tp->rtl_ops.init(tp); + queue_delayed_work(system_long_wq, >hw_phy_work, 0); netif_device_attach(tp->netdev); } @@ -4122,6 +4139,7 @@ static int rtl_ops_init(struct r8152 *tp) ops->eee_get= r8152_get_eee; ops->eee_set= r8152_set_eee; ops->in_nway= rtl8152_in_nway; + ops->hw_phy_cfg = r8152b_hw_phy_cfg; break; case RTL_VER_03: @@ -4137,6 +4155,7 @@ static int rtl_ops_init(struct r8152 *tp) ops->eee_get= r8153_get_eee; ops->eee_set= r8153_set_eee; ops->in_nway= rtl8153_in_nway; + ops->hw_phy_cfg = r8153_hw_phy_cfg; break; default: @@ -4183,6 +4202,7 @@ static int rtl8152_probe(struct usb_interface *intf, mutex_init(>control); INIT_DELAYED_WORK(>schedule, rtl_work_func_t); + INIT_DELAYED_WORK(>hw_phy_work, rtl_hw_phy_work_func_t); netdev->netdev_ops = _netdev_ops; netdev->watchdog_timeo = RTL8152_TX_TIMEOUT; @@ -4225,6 +4245,7 @@ static int rtl8152_probe(struct usb_interface *intf, intf->needs_remote_wakeup = 1; tp->rtl_ops.init(tp); + queue_delayed_work(system_long_wq, >hw_phy_work, 0); set_ethernet_addr(tp); usb_set_intfdata(intf, tp); @@ -4270,6 +4291,7 @@ static void rtl8152_disconnect(struct usb_interface *intf) netif_napi_del(>napi); unregister_netdev(tp->netdev); + cancel_delayed_work_sync(>hw_phy_work); tp->rtl_ops.unload(tp); free_netdev(tp->netdev); } -- 2.4.11 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next 2/3] r8152: move the setting for the default speed
Move calling set_speed() from open() to rtl_hw_phy_work_func_t(). Then, we would set the default speed only for first initialization or after resuming. Besides, the set_speed() could handle the flag of PHY_RESET which would be set in rtl_ops.hw_phy_cfg(). Signed-off-by: Hayes Wang--- drivers/net/usb/r8152.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 46fe9a7..dcdc4fa 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -3051,6 +3051,10 @@ static void rtl_hw_phy_work_func_t(struct work_struct *work) tp->rtl_ops.hw_phy_cfg(tp); + rtl8152_set_speed(tp, AUTONEG_ENABLE, + tp->mii.supports_gmii ? SPEED_1000 : SPEED_100, + DUPLEX_FULL); + mutex_unlock(>control); usb_autopm_put_interface(tp->intf); @@ -3104,9 +3108,6 @@ static int rtl8152_open(struct net_device *netdev) tp->rtl_ops.up(tp); - rtl8152_set_speed(tp, AUTONEG_ENABLE, - tp->mii.supports_gmii ? SPEED_1000 : SPEED_100, - DUPLEX_FULL); netif_carrier_off(netdev); netif_start_queue(netdev); set_bit(WORK_ENABLE, >flags); @@ -3549,10 +3550,6 @@ static int rtl8152_resume(struct usb_interface *intf) napi_enable(>napi); } else { tp->rtl_ops.up(tp); - rtl8152_set_speed(tp, AUTONEG_ENABLE, - tp->mii.supports_gmii ? - SPEED_1000 : SPEED_100, - DUPLEX_FULL); netif_carrier_off(tp->netdev); set_bit(WORK_ENABLE, >flags); } -- 2.4.11 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next 3/3] r8152: save the speed
The user may change the speed. Use it to replace the default one. Signed-off-by: Hayes Wang--- drivers/net/usb/r8152.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index dcdc4fa..69d1bbfd 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -628,8 +628,11 @@ struct r8152 { u32 tx_qlen; u32 coalesce; u16 ocp_base; + u16 speed; u8 *intr_buff; u8 version; + u8 duplex; + u8 autoneg; }; enum rtl_version { @@ -3051,9 +3054,7 @@ static void rtl_hw_phy_work_func_t(struct work_struct *work) tp->rtl_ops.hw_phy_cfg(tp); - rtl8152_set_speed(tp, AUTONEG_ENABLE, - tp->mii.supports_gmii ? SPEED_1000 : SPEED_100, - DUPLEX_FULL); + rtl8152_set_speed(tp, tp->autoneg, tp->speed, tp->duplex); mutex_unlock(>control); @@ -3679,6 +3680,11 @@ static int rtl8152_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) mutex_lock(>control); ret = rtl8152_set_speed(tp, cmd->autoneg, cmd->speed, cmd->duplex); + if (!ret) { + tp->autoneg = cmd->autoneg; + tp->speed = cmd->speed; + tp->duplex = cmd->duplex; + } mutex_unlock(>control); @@ -4239,6 +4245,10 @@ static int rtl8152_probe(struct usb_interface *intf, break; } + tp->autoneg = AUTONEG_ENABLE; + tp->speed = tp->mii.supports_gmii ? SPEED_1000 : SPEED_100; + tp->duplex = DUPLEX_FULL; + intf->needs_remote_wakeup = 1; tp->rtl_ops.init(tp); -- 2.4.11 -- 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: [PATCH] usb: gadget: udc: atmel: Also get regmap for at91sam9x5-pmc
On 13/06/2016 at 10:56:08 +0200, Uwe Kleine-König wrote : > Hello, > > On Mon, Jun 13, 2016 at 10:47:30AM +0200, Alexandre Belloni wrote: > > The "atmel,at91sam9g45-udc" compatible UDC is also used on at91sam9x5 so it > > is also necessary to try to get the syscon for at91sam9x5-pmc. > > > > Fixes: 4747639f01c9 ("usb: gadget: atmel: access the PMC using regmap") > > Reported-by: Uwe Kleine-König> > I played with the AT91 during my non-work time, so please use > u...@kleine-koenig.org as my email address. > > > Signed-off-by: Alexandre Belloni > > --- > > drivers/usb/gadget/udc/atmel_usba_udc.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c > > b/drivers/usb/gadget/udc/atmel_usba_udc.c > > index 18569de06b04..bb1f6c8f0f01 100644 > > --- a/drivers/usb/gadget/udc/atmel_usba_udc.c > > +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c > > @@ -1920,6 +1920,8 @@ static struct usba_ep * atmel_udc_of_init(struct > > platform_device *pdev, > > > > udc->errata = match->data; > > udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc"); > > + if (IS_ERR(udc->pmc)) > > + udc->pmc = > > syscon_regmap_lookup_by_compatible("atmel,at91sam9x5-pmc"); > > if (udc->errata && IS_ERR(udc->pmc)) > > return ERR_CAST(udc->pmc); > > I didn't retest but I'm sure this makes usb gadget work on my AT91. > Still I'm unsure if the patch is correct. Can > > syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc") > > return -EPROBE_DEFER? Are there other error codes that should be fatal > enough to not try to look for a sam9x5-pmc? > Well, if finding the PMC fails, you are probably not far enough in the boot process to care about USB :) Also, looking up the syscon will never return -EPROBE_DEFER because it will create the regmap on first lookup, it doesn't matter where it is coming from. > Nearly orthogonal to the issue: An error message on failure would be > nice. When I saw usb gadget broken I first had to add messages to this > driver to see where it failed. > Good point, this can probably go in a separate, less urgent patch. -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- 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: [BUG] cdc-acm: no data available after port open
On Mon, 2016-06-13 at 00:37 +0200, Ladislav Michl wrote: > On Sun, Jun 12, 2016 at 11:03:45PM +0200, Ladislav Michl wrote: > > Once ttyACM0 starts behave strangely, read() returns only what's in buffer > > before > > ttyACM0 was opened and then hangs infinitely. As this bug is hard to > > trigger, has > > anyone clue where to start debugging? > > Forgot to mention, once this happens "usb 3-1.4: clear tt 1 (9061) error -75" > starts showing in the syslog. Also "cdc_acm 3-1.4.3:1.0: failed to set > dtr/rts", > but this one is there normally. The translation transactor in the hub is reporting an error. That should be reported to the driver, but there is no good error handling. static void acm_read_bulk_callback(struct urb *urb) { struct acm_rb *rb = urb->context; struct acm *acm = rb->instance; unsigned long flags; int status = urb->status; dev_vdbg(>data->dev, "%s - urb %d, len %d\n", __func__, rb->index, urb->actual_length); if (!acm->dev) { set_bit(rb->index, >read_urbs_free); dev_dbg(>data->dev, "%s - disconnected\n", __func__); return; } if (status) { set_bit(rb->index, >read_urbs_free); dev_dbg(>data->dev, "%s - non-zero urb status: %d\n", __func__, status); if ((status != -ENOENT) || (urb->actual_length == 0)) return; } Can you please switch on dynamic debugging for cdc_acm to see what is being reported? Regards Oliver -- 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: [PATCH] usb: gadget: udc: atmel: Also get regmap for at91sam9x5-pmc
Hello, On Mon, Jun 13, 2016 at 10:47:30AM +0200, Alexandre Belloni wrote: > The "atmel,at91sam9g45-udc" compatible UDC is also used on at91sam9x5 so it > is also necessary to try to get the syscon for at91sam9x5-pmc. > > Fixes: 4747639f01c9 ("usb: gadget: atmel: access the PMC using regmap") > Reported-by: Uwe Kleine-KönigI played with the AT91 during my non-work time, so please use u...@kleine-koenig.org as my email address. > Signed-off-by: Alexandre Belloni > --- > drivers/usb/gadget/udc/atmel_usba_udc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c > b/drivers/usb/gadget/udc/atmel_usba_udc.c > index 18569de06b04..bb1f6c8f0f01 100644 > --- a/drivers/usb/gadget/udc/atmel_usba_udc.c > +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c > @@ -1920,6 +1920,8 @@ static struct usba_ep * atmel_udc_of_init(struct > platform_device *pdev, > > udc->errata = match->data; > udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc"); > + if (IS_ERR(udc->pmc)) > + udc->pmc = > syscon_regmap_lookup_by_compatible("atmel,at91sam9x5-pmc"); > if (udc->errata && IS_ERR(udc->pmc)) > return ERR_CAST(udc->pmc); I didn't retest but I'm sure this makes usb gadget work on my AT91. Still I'm unsure if the patch is correct. Can syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc") return -EPROBE_DEFER? Are there other error codes that should be fatal enough to not try to look for a sam9x5-pmc? Nearly orthogonal to the issue: An error message on failure would be nice. When I saw usb gadget broken I first had to add messages to this driver to see where it failed. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König| Industrial Linux Solutions | http://www.pengutronix.de/ | -- 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 0/4] 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 v10: - Introduce usb_charger_get_state() function to check charger state. - Remove the mutex lock in usb_charger_set_cur_limit_by_type() function in case will be issued in atomic context. 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/udc/Makefile |1 + drivers/usb/gadget/udc/charger.c | 807 + drivers/usb/gadget/udc/udc-core.c | 11 + include/linux/mfd/wm831x/pdata.h |3 + include/linux/usb/charger.h | 191 + include/linux/usb/gadget.h| 11 + include/uapi/linux/usb/charger.h | 31 ++ 9 files changed, 1131 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 -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND PATCH v11 2/4] gadget: Support for the usb charger framework
For supporting the usb charger, it adds the usb_charger_init() and usb_charger_exit() functions for usb charger initialization and exit. It will report to the usb charger when the gadget state is changed, then the usb charger can do the power things. Signed-off-by: Baolin Wang--- drivers/usb/gadget/udc/udc-core.c | 11 +++ include/linux/usb/gadget.h| 11 +++ 2 files changed, 22 insertions(+) diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index 6e8300d..84c098c 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -28,6 +28,7 @@ #include #include #include +#include /** * struct usb_udc - describes one usb device controller @@ -242,6 +243,9 @@ static void usb_gadget_state_work(struct work_struct *work) struct usb_gadget *gadget = work_to_gadget(work); struct usb_udc *udc = gadget->udc; + /* when the gadget state is changed, then report to USB charger */ + usb_charger_plug_by_gadget(gadget, gadget->state); + if (udc) sysfs_notify(>dev.kobj, NULL, "state"); } @@ -411,6 +415,10 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, if (ret) goto err4; + ret = usb_charger_init(gadget); + if (ret) + goto err5; + usb_gadget_set_state(gadget, USB_STATE_NOTATTACHED); udc->vbus = true; @@ -431,6 +439,8 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, return 0; +err5: + device_del(>dev); err4: list_del(>list); mutex_unlock(_lock); @@ -539,6 +549,7 @@ void usb_del_gadget_udc(struct usb_gadget *gadget) kobject_uevent(>dev.kobj, KOBJ_REMOVE); flush_work(>work); device_unregister(>dev); + usb_charger_exit(gadget); device_unregister(>dev); } EXPORT_SYMBOL_GPL(usb_del_gadget_udc); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 457651b..40390ec 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -24,6 +24,7 @@ #include #include #include +#include struct usb_ep; @@ -639,6 +640,8 @@ struct usb_gadget { unsignedout_epnum; unsignedin_epnum; struct usb_otg_caps *otg_caps; + /* negotiate the power with the usb charger */ + struct usb_charger *charger; unsignedsg_supported:1; unsignedis_otg:1; @@ -855,10 +858,18 @@ static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget) * reporting how much power the device may consume. For example, this * could affect how quickly batteries are recharged. * + * It will also notify the USB charger how much power the device may + * consume if there is a USB charger linking with the gadget. + * * Returns zero on success, else negative errno. */ static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) { + if (gadget->charger) + usb_charger_set_cur_limit_by_type(gadget->charger, + gadget->charger->type, + mA); + if (!gadget->ops->vbus_draw) return -EOPNOTSUPP; return gadget->ops->vbus_draw(gadget, mA); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND PATCH v11 3/4] gadget: Integrate with the usb gadget supporting for usb charger
When the usb gadget supporting for usb charger is ready, the usb charger can implement the usb_charger_plug_by_gadget() function and usb_charger_exit() function by getting 'struct usb_charger' from 'struct gadget'. Signed-off-by: Baolin Wang--- drivers/usb/gadget/udc/charger.c | 39 +- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/charger.c b/drivers/usb/gadget/udc/charger.c index 7be4c76..949396f 100644 --- a/drivers/usb/gadget/udc/charger.c +++ b/drivers/usb/gadget/udc/charger.c @@ -568,6 +568,30 @@ 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 (WARN(!uchger, "charger can not be NULL")) + 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); @@ -724,6 +748,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 = USB_STATE_NOTATTACHED; /* register a new usb charger */ @@ -744,7 +769,19 @@ fail: int usb_charger_exit(struct usb_gadget *ugadget) { - return 0; + struct usb_charger *uchger = ugadget->charger; + + if (WARN(!uchger, "charger can not be NULL")) + return -EINVAL; + + if (uchger->extcon_dev) + extcon_unregister_notifier(uchger->extcon_dev, + EXTCON_USB, + >extcon_nb.nb); + + ida_simple_remove(_charger_ida, uchger->id); + + return usb_charger_unregister(uchger); } static int __init usb_charger_class_init(void) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: gadget: udc: atmel: Also get regmap for at91sam9x5-pmc
The "atmel,at91sam9g45-udc" compatible UDC is also used on at91sam9x5 so it is also necessary to try to get the syscon for at91sam9x5-pmc. Fixes: 4747639f01c9 ("usb: gadget: atmel: access the PMC using regmap") Reported-by: Uwe Kleine-KönigSigned-off-by: Alexandre Belloni --- drivers/usb/gadget/udc/atmel_usba_udc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 18569de06b04..bb1f6c8f0f01 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -1920,6 +1920,8 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, udc->errata = match->data; udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc"); + if (IS_ERR(udc->pmc)) + udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9x5-pmc"); if (udc->errata && IS_ERR(udc->pmc)) return ERR_CAST(udc->pmc); -- 2.8.1 -- 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 4/4] power: wm831x_power: Support USB charger current limit management
Integrate 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. Signed-off-by: Mark BrownSigned-off-by: Baolin Wang Acked-by: Lee Jones Acked-by: Charles Keepax Acked-by: Peter Chen Acked-by: Sebastian Reichel --- drivers/power/wm831x_power.c | 69 ++ include/linux/mfd/wm831x/pdata.h |3 ++ 2 files changed, 72 insertions(+) diff --git a/drivers/power/wm831x_power.c b/drivers/power/wm831x_power.c index 7082301..cef1812 100644 --- a/drivers/power/wm831x_power.c +++ b/drivers/power/wm831x_power.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -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 const 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); + unsigned 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 %umA", 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(>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, + >usb_notify); + if (ret != 0) { + dev_err(>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, + _power->usb_notify); + /* Free charger */ + } + for (i = 0; i < ARRAY_SIZE(wm831x_bat_irqs); i++) { irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, diff --git a/include/linux/mfd/wm831x/pdata.h b/include/linux/mfd/wm831x/pdata.h index dcc9631..5af8399 100644 --- a/include/linux/mfd/wm831x/pdata.h +++ b/include/linux/mfd/wm831x/pdata.h @@ -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]; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe
[RESEND PATCH v11 0/4] Introduce usb charger framework to deal with the usb gadget power negotation
From: Baolin WangCurrently 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 v10: - Introduce usb_charger_get_state() function to check charger state. - Remove the mutex lock in usb_charger_set_cur_limit_by_type() function in case will be issued in atomic context. 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/udc/Makefile |1 + drivers/usb/gadget/udc/charger.c | 807 + drivers/usb/gadget/udc/udc-core.c | 11 + include/linux/mfd/wm831x/pdata.h |3 + include/linux/usb/charger.h | 191 + include/linux/usb/gadget.h| 11 + include/uapi/linux/usb/charger.h | 31 ++ 9 files changed, 1131 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 -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[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:
Re: [PATCH v5 1/2] Documentation: bindings: add DT documentation for Rockchip USB2PHY
Am Montag, 13. Juni 2016, 10:10:09 schrieb Frank Wang: > Signed-off-by: Frank Wanglooks really cool now, thanks for addressing all the review comments Reviewed-by: Heiko Stuebner > --- > > Changes in v5: > - Added 'reg' property to identify the different phy-blocks. > > Changes in v4: > - Used 'phy-supply' instead of 'vbus_*-supply'. > > Changes in v3: > - Added 'clocks' and 'clock-names' optional properties. > - Specified 'otg-port' and 'host-port' as the sub-node name. > > Changes in v2: > - Changed vbus_host optional property from gpio to regulator. > - Specified vbus_otg-supply optional property. > - Specified otg_id and otg_bvalid property. > > .../bindings/phy/phy-rockchip-inno-usb2.txt| 64 > 1 file changed, 64 insertions(+) > create mode 100644 > Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt > > diff --git > a/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt > b/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt new file > mode 100644 > index 000..48bb5de > --- /dev/null > +++ b/Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt > @@ -0,0 +1,64 @@ > +ROCKCHIP USB2.0 PHY WITH INNO IP BLOCK > + > +Required properties (phy (parent) node): > + - compatible : should be one of the listed compatibles: > + * "rockchip,rk3366-usb2phy" > + * "rockchip,rk3399-usb2phy" > + - reg : the address offset of grf for usb-phy configuration. > + - #clock-cells : should be 0. > + - clock-output-names : specify the 480m output clock name. > + > +Optional properties: > + - clocks : phandle + phy specifier pair, for the input clock of phy. > + - clock-names : input clock name of phy, must be "phyclk". > + > +Required nodes : a sub-node is required for each port the phy provides. > + The sub-node name is used to identify host or otg port, > + and shall be the following entries: > + * "otg-port" : the name of otg port. > + * "host-port" : the name of host port. > + > +Required properties (port (child) node): > + - #phy-cells : must be 0. See ./phy-bindings.txt for details. > + - interrupts : specify an interrupt for each entry in interrupt-names. > + - interrupt-names : a list which shall be the following entries: > + * "otg_id" : for the otg id interrupt. > + * "otg_bvalid" : for the otg vbus interrupt. > + * "linestate" : for the host/otg linestate interrupt. > + > +Optional properties: > + - phy-supply : phandle to a regulator that provides power to VBUS. > + See ./phy-bindings.txt for details. > + > +Example: > + > +grf: syscon@ff77 { > + compatible = "rockchip,rk3366-grf", "syscon", "simple-mfd"; > + #address-cells = <1>; > + #size-cells = <1>; > + > +... > + > + u2phy: usb2-phy@700 { > + compatible = "rockchip,rk3366-usb2phy"; > + reg = <0x700 0x2c>; > + #clock-cells = <0>; > + clock-output-names = "sclk_otgphy0_480m"; > + > + u2phy_otg: otg-port { > + #phy-cells = <0>; > + interrupts = , > + , > + ; > + interrupt-names = "otg_id", "otg_bvalid", "linestate"; > + status = "okay"; > + }; > + > + u2phy_host: host-port { > + #phy-cells = <0>; > + interrupts = ; > + interrupt-names = "linestate"; > + status = "okay"; > + }; > + }; > +}; -- 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: [PATCH v7 2/4] usb: dwc3: add dual-role support
On 13/06/16 10:09, Roger Quadros wrote: > Peter, > > On 12/06/16 12:11, Peter Chen wrote: >> On Fri, Jun 10, 2016 at 04:17:28PM +0300, Roger Quadros wrote: >>> Register with the USB OTG/DRD core. Since we don't support >>> OTG yet we just work as a dual-role device even >>> if device tree says "otg". >>> >>> Get ID and VBUS information from the OTG controller >>> and kick the OTG state machine. >>> >> >> Hi Roger, >> >> I can't apply it after rebase usb-next rc1 and felipe's testing/next. >> How to apply it? > > You just need to apply the series on Felipe's testing/next + this one patch > http://article.gmane.org/gmane.linux.kernel/2240761 You can also use the below repo as balbi testing/next is a moving target https://github.com/rogerq/linux/commits/for-v4.8/otg-drd-v11-core-dwc3-v7 -- cheers, -roger -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v11 09/14] usb: of: add an API to get OTG device from USB controller node
The OTG controller and the USB controller can be linked via the 'otg-controller' property in the USB controller's device node. of_usb_get_otg() can be used to get the OTG controller device from the USB controller's device node. Signed-off-by: Roger QuadrosAcked-by: Peter Chen Acked-by: Rob Herring --- v11: - removed unnecessary @otg_caps from documentation of of_usb_get_otg() Documentation/devicetree/bindings/usb/generic.txt | 3 +++ drivers/usb/common/common.c | 26 +++ include/linux/usb/of.h| 9 3 files changed, 38 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt index bba8257..f6866c1 100644 --- a/Documentation/devicetree/bindings/usb/generic.txt +++ b/Documentation/devicetree/bindings/usb/generic.txt @@ -24,6 +24,9 @@ Optional properties: optional for OTG device. - adp-disable: tells OTG controllers we want to disable OTG ADP, ADP is optional for OTG device. + - otg-controller: phandle to otg controller. Host or gadget controllers can + contain this property to link it to a particular OTG + controller. This is an attribute to a USB controller such as: diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index e3d0161..d0c104c 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -238,6 +238,32 @@ int of_usb_update_otg_caps(struct device_node *np, } EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); +#ifdef CONFIG_USB_OTG +/** + * of_usb_get_otg - get the OTG controller linked to the USB controller + * @np: Pointer to the device_node of the USB controller + * + * Return: The OTG controller device or NULL on error. + */ +struct device *of_usb_get_otg(struct device_node *np) +{ + struct device_node *otg_np; + struct platform_device *pdev; + + otg_np = of_parse_phandle(np, "otg-controller", 0); + if (!otg_np) + return NULL; + + pdev = of_find_device_by_node(otg_np); + of_node_put(otg_np); + if (!pdev) + return NULL; + + return >dev; +} +EXPORT_SYMBOL_GPL(of_usb_get_otg); +#endif + #endif MODULE_LICENSE("GPL"); diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index de3237f..499a4e8 100644 --- a/include/linux/usb/of.h +++ b/include/linux/usb/of.h @@ -40,6 +40,15 @@ static inline struct device_node *usb_of_get_child_node } #endif +#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_OTG) +struct device *of_usb_get_otg(struct device_node *np); +#else +static inline struct device *of_usb_get_otg(struct device_node *np) +{ + return NULL; +} +#endif + #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np); #else -- 2.7.4 -- 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: [PATCH v10 09/14] usb: of: add an API to get OTG device from USB controller node
On 13/06/16 11:13, Jun Li wrote: > Hi > >> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c >> index e3d0161..d7ec471 100644 >> --- a/drivers/usb/common/common.c >> +++ b/drivers/usb/common/common.c >> @@ -238,6 +238,33 @@ int of_usb_update_otg_caps(struct device_node *np, } >> EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); >> >> +#ifdef CONFIG_USB_OTG >> +/** >> + * of_usb_get_otg - get the OTG controller linked to the USB controller >> + * @np: Pointer to the device_node of the USB controller >> + * @otg_caps: Pointer to the target usb_otg_caps to be set > > Remove otg_caps. Sure. > >> + * >> + * Returns the OTG controller device or NULL on error. >> + */ >> +struct device *of_usb_get_otg(struct device_node *np) { >> +struct device_node *otg_np; >> +struct platform_device *pdev; >> + >> +otg_np = of_parse_phandle(np, "otg-controller", 0); >> +if (!otg_np) >> +return NULL; >> + >> +pdev = of_find_device_by_node(otg_np); >> +of_node_put(otg_np); >> +if (!pdev) >> +return NULL; >> + >> +return >dev; >> +} >> +EXPORT_SYMBOL_GPL(of_usb_get_otg); >> +#endif >> + >> #endif >> >> MODULE_LICENSE("GPL"); >> diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index >> de3237f..499a4e8 100644 >> --- a/include/linux/usb/of.h >> +++ b/include/linux/usb/of.h >> @@ -40,6 +40,15 @@ static inline struct device_node >> *usb_of_get_child_node } #endif >> >> +#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_OTG) struct device >> +*of_usb_get_otg(struct device_node *np); #else static inline struct >> +device *of_usb_get_otg(struct device_node *np) { >> +return NULL; >> +} >> +#endif >> + >> #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) enum >> usb_phy_interface of_usb_get_phy_mode(struct device_node *np); #else >> -- >> 2.7.4 > -- cheers, -roger -- 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: [PATCH v10 09/14] usb: of: add an API to get OTG device from USB controller node
Hi > diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c > index e3d0161..d7ec471 100644 > --- a/drivers/usb/common/common.c > +++ b/drivers/usb/common/common.c > @@ -238,6 +238,33 @@ int of_usb_update_otg_caps(struct device_node *np, } > EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); > > +#ifdef CONFIG_USB_OTG > +/** > + * of_usb_get_otg - get the OTG controller linked to the USB controller > + * @np: Pointer to the device_node of the USB controller > + * @otg_caps: Pointer to the target usb_otg_caps to be set Remove otg_caps. Li Jun > + * > + * Returns the OTG controller device or NULL on error. > + */ > +struct device *of_usb_get_otg(struct device_node *np) { > + struct device_node *otg_np; > + struct platform_device *pdev; > + > + otg_np = of_parse_phandle(np, "otg-controller", 0); > + if (!otg_np) > + return NULL; > + > + pdev = of_find_device_by_node(otg_np); > + of_node_put(otg_np); > + if (!pdev) > + return NULL; > + > + return >dev; > +} > +EXPORT_SYMBOL_GPL(of_usb_get_otg); > +#endif > + > #endif > > MODULE_LICENSE("GPL"); > diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index > de3237f..499a4e8 100644 > --- a/include/linux/usb/of.h > +++ b/include/linux/usb/of.h > @@ -40,6 +40,15 @@ static inline struct device_node > *usb_of_get_child_node } #endif > > +#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_OTG) struct device > +*of_usb_get_otg(struct device_node *np); #else static inline struct > +device *of_usb_get_otg(struct device_node *np) { > + return NULL; > +} > +#endif > + > #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) enum > usb_phy_interface of_usb_get_phy_mode(struct device_node *np); #else > -- > 2.7.4 -- 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: [PATCH v11 13/14] usb: gadget: udc: adapt to OTG core
On 13/06/16 10:56, Peter Chen wrote: > On Mon, Jun 13, 2016 at 10:55:12AM +0300, Roger Quadros wrote: >> err1: >> -if (ret != -EISNAM) >> +if ((ret != -EISNAM)) > > Since you do not need above change. Ah :P, will fix it. > > Expect above, I am ok with this patch. > > Acked-by: Peter ChenThanks for the patient review of this entire series :). cheers, -roger -- 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: [PATCH v11 08/14] usb: otg: add OTG/dual-role core
On Mon, Jun 13, 2016 at 10:56:30AM +0300, Roger Quadros wrote: > It provides APIs for the following tasks > > - Registering an OTG/dual-role capable controller > - Registering Host and Gadget controllers to OTG core > - Providing inputs to and kicking the OTG state machine > > Provide a dual-role device (DRD) state machine. > DRD mode is a reduced functionality OTG mode. In this mode > we don't support SRP, HNP and dynamic role-swap. > > In DRD operation, the controller mode (Host or Peripheral) > is decided based on the ID pin status. Once a cable plug (Type-A > or Type-B) is attached the controller selects the state > and doesn't change till the cable in unplugged and a different > cable type is inserted. > > As we don't need most of the complex OTG states and OTG timers > we implement a lean DRD state machine in usb-otg.c. > The DRD state machine is only interested in 2 hardware inputs > 'id' and 'b_sess_vld'. > > Signed-off-by: Roger Quadros> --- > v11: > - remove usb_otg_kick_fsm(). > - typo fixes: structa/structure, upto/up to. > - remove "obj-$(CONFIG_USB_OTG_CORE) += common/" from Makefile. Acked-by: Peter Chen > > drivers/usb/Kconfig | 18 + > drivers/usb/common/Makefile | 6 +- > drivers/usb/common/usb-otg.c | 877 > +++ > drivers/usb/core/Kconfig | 14 - > drivers/usb/gadget/Kconfig | 1 + > include/linux/usb/gadget.h | 2 + > include/linux/usb/hcd.h | 1 + > include/linux/usb/otg-fsm.h | 7 + > include/linux/usb/otg.h | 174 - > 9 files changed, 1070 insertions(+), 30 deletions(-) > create mode 100644 drivers/usb/common/usb-otg.c > > diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig > index 8689dcb..ed596ec 100644 > --- a/drivers/usb/Kconfig > +++ b/drivers/usb/Kconfig > @@ -32,6 +32,23 @@ if USB_SUPPORT > config USB_COMMON > tristate > > +config USB_OTG_CORE > + tristate > + > +config USB_OTG > + bool "OTG/Dual-role support" > + depends on PM && USB && USB_GADGET > + default n > + ---help--- > + The most notable feature of USB OTG is support for a > + "Dual-Role" device, which can act as either a device > + or a host. The initial role is decided by the type of > + plug inserted and can be changed later when two dual > + role devices talk to each other. > + > + Select this only if your board has Mini-AB/Micro-AB > + connector. > + > config USB_ARCH_HAS_HCD > def_bool y > > @@ -40,6 +57,7 @@ config USB > tristate "Support for Host-side USB" > depends on USB_ARCH_HAS_HCD > select USB_COMMON > + select USB_OTG_CORE > select NLS # for UTF-8 strings > ---help--- > Universal Serial Bus (USB) is a specification for a serial bus > diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile > index f8f2c88..5122b3f 100644 > --- a/drivers/usb/common/Makefile > +++ b/drivers/usb/common/Makefile > @@ -7,5 +7,7 @@ usb-common-y+= common.o > usb-common-$(CONFIG_USB_LED_TRIG) += led.o > > obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o > -usbotg-y := usb-otg-fsm.o > -obj-$(CONFIG_USB_OTG)+= usbotg.o > +ifeq ($(CONFIG_USB_OTG),y) > +usbotg-y := usb-otg.o usb-otg-fsm.o > +obj-$(CONFIG_USB_OTG_CORE) += usbotg.o > +endif > diff --git a/drivers/usb/common/usb-otg.c b/drivers/usb/common/usb-otg.c > new file mode 100644 > index 000..a23ab1e > --- /dev/null > +++ b/drivers/usb/common/usb-otg.c > @@ -0,0 +1,877 @@ > +/** > + * drivers/usb/common/usb-otg.c - USB OTG core > + * > + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com > + * Author: Roger Quadros > + * > + * 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. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* OTG device list */ > +LIST_HEAD(otg_list); > +static DEFINE_MUTEX(otg_list_mutex); > + > +static int usb_otg_hcd_is_primary_hcd(struct usb_hcd *hcd) > +{ > + if (!hcd->primary_hcd) > + return 1; > + return hcd == hcd->primary_hcd; > +} > + > +/** > + * usb_otg_get_data() - get usb_otg data structure > + * @otg_dev: OTG controller device > + * > + * Check if the OTG device is in our OTG list and return > + * usb_otg data, else NULL. > + * > + * otg_list_mutex must be held. > + * > + * Return: usb_otg data on success, NULL otherwise. > + */ > +static struct usb_otg *usb_otg_get_data(struct
Re: [PATCH v11 13/14] usb: gadget: udc: adapt to OTG core
On Mon, Jun 13, 2016 at 10:55:12AM +0300, Roger Quadros wrote: > err1: > - if (ret != -EISNAM) > + if ((ret != -EISNAM)) Since you do not need above change. Expect above, I am ok with this patch. Acked-by: Peter Chen> dev_err(>dev, "failed to start %s: %d\n", > udc->driver->function, ret); > udc->driver = NULL; > @@ -1389,6 +1565,12 @@ static ssize_t usb_udc_softconn_store(struct device > *dev, > return -EOPNOTSUPP; > } > > + /* In OTG/dual-role mode, soft-connect should be handled by OTG core */ > + if (udc->gadget->otg_dev) { > + dev_err(dev, "soft-connect not supported in OTG mode\n"); > + return -EOPNOTSUPP; > + } > + > if (sysfs_streq(buf, "connect")) { > usb_gadget_udc_start(udc); > usb_gadget_connect(udc->gadget); > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h > index 1d74fb8..8c6880d 100644 > --- a/include/linux/usb/gadget.h > +++ b/include/linux/usb/gadget.h > @@ -701,6 +701,10 @@ extern int usb_add_gadget_udc(struct device *parent, > struct usb_gadget *gadget); > extern void usb_del_gadget_udc(struct usb_gadget *gadget); > extern char *usb_get_gadget_udc_name(void); > > +extern int usb_otg_add_gadget_udc(struct device *parent, > + struct usb_gadget *gadget, > + struct device *otg_dev); > + > /*-*/ > > /* utility to simplify dealing with string descriptors */ > -- > 2.7.4 > > > -- > 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 -- Best Regards, Peter Chen -- 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: usb: common: otg-fsm: add license to usb-otg-fsm
On Sun, Jun 12, 2016 at 01:06:45PM +0200, Oscar wrote: > usb: common: otg-fsm: add license to usb-otg-fsm. > > Fix warning about tainted kernel because usb-otg-fsm has no license. > WARNING: with this patch usb-otg-fsm module can be loaded > but then the kernel hangs. Tested with a udoo quad board. > > Signed-off-by: Oscar Curero> --- > > --- a/drivers/usb/common/usb-otg-fsm.c.orig 2016-06-12 > 12:02:09.269814317 +0200 > +++ b/drivers/usb/common/usb-otg-fsm.c 2016-06-12 > 12:01:54.473000410 +0200 > @@ -21,6 +21,7 @@ > * 675 Mass Ave, Cambridge, MA 02139, USA. > */ > > +#include > #include > #include > #include > @@ -452,3 +453,4 @@ int otg_statemachine(struct otg_fsm *fsm > return state_changed; > } > EXPORT_SYMBOL_GPL(otg_statemachine); > +MODULE_LICENSE("GPL"); > -- > 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 Good catch, but would you please create the patch using "git format-patch", I can't apply it directly. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v11 08/14] usb: otg: add OTG/dual-role core
It provides APIs for the following tasks - Registering an OTG/dual-role capable controller - Registering Host and Gadget controllers to OTG core - Providing inputs to and kicking the OTG state machine Provide a dual-role device (DRD) state machine. DRD mode is a reduced functionality OTG mode. In this mode we don't support SRP, HNP and dynamic role-swap. In DRD operation, the controller mode (Host or Peripheral) is decided based on the ID pin status. Once a cable plug (Type-A or Type-B) is attached the controller selects the state and doesn't change till the cable in unplugged and a different cable type is inserted. As we don't need most of the complex OTG states and OTG timers we implement a lean DRD state machine in usb-otg.c. The DRD state machine is only interested in 2 hardware inputs 'id' and 'b_sess_vld'. Signed-off-by: Roger Quadros--- v11: - remove usb_otg_kick_fsm(). - typo fixes: structa/structure, upto/up to. - remove "obj-$(CONFIG_USB_OTG_CORE) += common/" from Makefile. drivers/usb/Kconfig | 18 + drivers/usb/common/Makefile | 6 +- drivers/usb/common/usb-otg.c | 877 +++ drivers/usb/core/Kconfig | 14 - drivers/usb/gadget/Kconfig | 1 + include/linux/usb/gadget.h | 2 + include/linux/usb/hcd.h | 1 + include/linux/usb/otg-fsm.h | 7 + include/linux/usb/otg.h | 174 - 9 files changed, 1070 insertions(+), 30 deletions(-) create mode 100644 drivers/usb/common/usb-otg.c diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 8689dcb..ed596ec 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -32,6 +32,23 @@ if USB_SUPPORT config USB_COMMON tristate +config USB_OTG_CORE + tristate + +config USB_OTG + bool "OTG/Dual-role support" + depends on PM && USB && USB_GADGET + default n + ---help--- + The most notable feature of USB OTG is support for a + "Dual-Role" device, which can act as either a device + or a host. The initial role is decided by the type of + plug inserted and can be changed later when two dual + role devices talk to each other. + + Select this only if your board has Mini-AB/Micro-AB + connector. + config USB_ARCH_HAS_HCD def_bool y @@ -40,6 +57,7 @@ config USB tristate "Support for Host-side USB" depends on USB_ARCH_HAS_HCD select USB_COMMON + select USB_OTG_CORE select NLS # for UTF-8 strings ---help--- Universal Serial Bus (USB) is a specification for a serial bus diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile index f8f2c88..5122b3f 100644 --- a/drivers/usb/common/Makefile +++ b/drivers/usb/common/Makefile @@ -7,5 +7,7 @@ usb-common-y += common.o usb-common-$(CONFIG_USB_LED_TRIG) += led.o obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o -usbotg-y := usb-otg-fsm.o -obj-$(CONFIG_USB_OTG) += usbotg.o +ifeq ($(CONFIG_USB_OTG),y) +usbotg-y := usb-otg.o usb-otg-fsm.o +obj-$(CONFIG_USB_OTG_CORE) += usbotg.o +endif diff --git a/drivers/usb/common/usb-otg.c b/drivers/usb/common/usb-otg.c new file mode 100644 index 000..a23ab1e --- /dev/null +++ b/drivers/usb/common/usb-otg.c @@ -0,0 +1,877 @@ +/** + * drivers/usb/common/usb-otg.c - USB OTG core + * + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com + * Author: Roger Quadros + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* OTG device list */ +LIST_HEAD(otg_list); +static DEFINE_MUTEX(otg_list_mutex); + +static int usb_otg_hcd_is_primary_hcd(struct usb_hcd *hcd) +{ + if (!hcd->primary_hcd) + return 1; + return hcd == hcd->primary_hcd; +} + +/** + * usb_otg_get_data() - get usb_otg data structure + * @otg_dev: OTG controller device + * + * Check if the OTG device is in our OTG list and return + * usb_otg data, else NULL. + * + * otg_list_mutex must be held. + * + * Return: usb_otg data on success, NULL otherwise. + */ +static struct usb_otg *usb_otg_get_data(struct device *otg_dev) +{ + struct usb_otg *otg; + + if (!otg_dev) + return NULL; + + list_for_each_entry(otg, _list, list) { + if (otg->dev == otg_dev) + return otg; + } + + return NULL; +} + +/** + * usb_otg_start_host() - start/stop the host controller + * @otg:
[PATCH v11 13/14] usb: gadget: udc: adapt to OTG core
The OTG state machine needs a mechanism to start and stop the gadget controller as well as connect/disconnect from the bus. Add usb_gadget_start(), usb_gadget_stop() and usb_gadget_connect_control(). Introduce usb_otg_add_gadget_udc() to allow controller drivers to register a gadget controller that is part of an OTG instance. Register with OTG core when UDC is added in usb_add_gadget_udc_release() and unregister on usb_del_gadget_udc(). Notify the OTG core when gadget function driver is available on udc_bind_to_driver() and when it is removed in usb_gadget_remove_driver(). We need to unlock the usb_lock mutex before calling usb_otg_register_gadget() else it will cause a circular locking dependency. Ignore softconnect sysfs control when we're in OTG mode as OTG FSM should care of gadget softconnect using the b_bus_req mechanism. Signed-off-by: Roger Quadros--- v11: - removed left over -EPROBE_DEFER in udc_bind_to_driver(). drivers/usb/gadget/udc/core.c | 202 +++--- include/linux/usb/gadget.h| 4 + 2 files changed, 196 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index 42756d7..1290f03 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -28,6 +28,11 @@ #include #include #include +#include +#include + +#include +#include #include "trace.h" @@ -1060,6 +1065,113 @@ static inline void usb_gadget_udc_stop(struct usb_udc *udc) } /** + * usb_gadget_to_udc - get the UDC owning the gadget + * + * udc_lock must be held. + * Returs NULL if UDC is not found. + */ +static struct usb_udc *usb_gadget_to_udc(struct usb_gadget *gadget) +{ + struct usb_udc *udc; + + list_for_each_entry(udc, _list, list) + if (udc->gadget == gadget) + return udc; + + return NULL; +} + +/** + * usb_gadget_start - start the usb gadget controller + * @gadget: the gadget device to start + * + * This is external API for use by OTG core. + * + * Start the usb device controller. Does not connect to the bus. + */ +static int usb_gadget_start(struct usb_gadget *gadget) +{ + int ret; + struct usb_udc *udc; + + mutex_lock(_lock); + udc = usb_gadget_to_udc(gadget); + if (!udc) { + dev_err(gadget->dev.parent, "%s: gadget not registered.\n", + __func__); + mutex_unlock(_lock); + return -EINVAL; + } + + ret = usb_gadget_udc_start(udc); + if (ret) + dev_err(>dev, "USB Device Controller didn't start: %d\n", + ret); + + mutex_unlock(_lock); + + return ret; +} + +/** + * usb_gadget_stop - stop the usb gadget controller + * @gadget: the gadget device we want to stop + * + * This is external API for use by OTG core. + * + * Stop the gadget controller. Does not disconnect from the bus. + * Caller must ensure that gadget has disconnected from the bus + * before calling usb_gadget_stop(). + */ +static int usb_gadget_stop(struct usb_gadget *gadget) +{ + struct usb_udc *udc; + + mutex_lock(_lock); + udc = usb_gadget_to_udc(gadget); + if (!udc) { + dev_err(gadget->dev.parent, "%s: gadget not registered.\n", + __func__); + mutex_unlock(_lock); + return -EINVAL; + } + + if (gadget->connected) + dev_dbg(gadget->dev.parent, + "%s: called while still connected\n", __func__); + + usb_gadget_udc_stop(udc); + mutex_unlock(_lock); + + return 0; +} + +static int usb_gadget_connect_control(struct usb_gadget *gadget, bool connect) +{ + struct usb_udc *udc; + + mutex_lock(_lock); + udc = usb_gadget_to_udc(gadget); + if (!udc) { + dev_err(gadget->dev.parent, "%s: gadget not registered.\n", + __func__); + mutex_unlock(_lock); + return -EINVAL; + } + + if (connect) { + usb_gadget_connect(udc->gadget); + } else { + usb_gadget_disconnect(udc->gadget); + udc->driver->disconnect(udc->gadget); + } + + mutex_unlock(_lock); + + return 0; +} + +/** * usb_udc_release - release the usb_udc struct * @dev: the dev member within usb_udc * @@ -1082,6 +1194,12 @@ static void usb_udc_nop_release(struct device *dev) dev_vdbg(dev, "%s\n", __func__); } +struct otg_gadget_ops otg_gadget_intf = { + .start = usb_gadget_start, + .stop = usb_gadget_stop, + .connect_control = usb_gadget_connect_control, +}; + /** * usb_add_gadget_udc_release - adds a new gadget to the udc class driver list * @parent: the parent device to this udc. Usually the controller driver's @@ -1137,6 +1255,14 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
Re: [RFC PATCHv3] usb: USB Type-C Connector Class
On Sat, Jun 11, 2016 at 11:03:53AM -0700, Guenter Roeck wrote: > On 06/11/2016 12:05 AM, Oliver Neukum wrote: > > On Fri, 2016-06-10 at 17:34 +0300, Heikki Krogerus wrote: > > > +static ssize_t > > > +preferred_role_store(struct device *dev, struct device_attribute > > > *attr, > > > +const char *buf, size_t size) > > > +{ > > > + struct typec_port *port = to_typec_port(dev); > > > + enum typec_role role; > > > + int ret; > > > + > > > + mutex_lock(>lock); > > > + > > > + if (port->cap->type != TYPEC_PORT_DRP) { > > > + dev_dbg(dev, "Try.SRC/SNK only supported with DRP > > > ports\n"); > > > + ret = -EOPNOTSUPP; > > > + goto out; > > > + } > > > > I think Try.SNK with an UFP should fail differently from > > Try.SRC and vice versa. > > > > I think the message should not even mention Try.src or Try.snk > in the first place, since both are optional and really orthogonal > to how the role is set (it can also be changed with pd messages). > On top of that, the specification states that Try.{src/snk} are > optional if there is no PD support, and NA if PD is supported > (see table 4.10). Kind of interesting, and I wonder how this > is supposed to be implemented in practice, since Try.{src/snk} > runs before it is established that/if the partner supports PD. > > A better message would be something like "Setting preferred > role only supported with DRP ports", and leave implementation > details to the port driver. Works for me. Thanks, -- heikki -- 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: [RFC PATCHv3] usb: USB Type-C Connector Class
On Sat, Jun 11, 2016 at 09:05:46AM +0200, Oliver Neukum wrote: > On Fri, 2016-06-10 at 17:34 +0300, Heikki Krogerus wrote: > > +static ssize_t > > +preferred_role_store(struct device *dev, struct device_attribute > > *attr, > > +const char *buf, size_t size) > > +{ > > + struct typec_port *port = to_typec_port(dev); > > + enum typec_role role; > > + int ret; > > + > > + mutex_lock(>lock); > > + > > + if (port->cap->type != TYPEC_PORT_DRP) { > > + dev_dbg(dev, "Try.SRC/SNK only supported with DRP > > ports\n"); > > + ret = -EOPNOTSUPP; > > + goto out; > > + } > > I think Try.SNK with an UFP should fail differently from > Try.SRC and vice versa. > > And, even more importantly, this offeres no way to cancel > a preference. Well, no way that would actually work. I'll fix that. Thanks, -- heikki -- 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: [PATCH v10 13/14] usb: gadget: udc: adapt to OTG core
On Mon, Jun 13, 2016 at 10:37:59AM +0300, Roger Quadros wrote: > On 13/06/16 10:20, Peter Chen wrote: > > On Mon, Jun 13, 2016 at 10:14:31AM +0300, Roger Quadros wrote: > >> On 12/06/16 14:36, Peter Chen wrote: > >>> On Fri, Jun 10, 2016 at 04:07:22PM +0300, Roger Quadros wrote: > > +/** > + * usb_otg_add_gadget_udc - adds a new gadget to the udc class driver > list > + * @parent: the parent device to this udc. Usually the controller > + * driver's device. > >>> > >>> It seems it should be udc device > >> > >> Parent and udc->dev are not the same right? > > > > Sure, udc's parent is otg device. > > > >> > >> I guess i'll omit the second statement to avoid confusion. So. > >> > >> @parent: the parent device to this udc. > > > > Where you call below APIs? It seems to be a udc driver, right? > > So, when you try to get "otg-controller" from the node, this node > > should be udc. > > @parent is actually the device that represents the USB Device controller > in the device tree. When you call usb_add_gadget_udc_release() a new > udc->dev device is created as it's child. > > See explanation for the @parent argument in usb_add_gadget_udc_release(). > As we want to keep the parent argument identical to that I will not make > any changes then. Oh, yes. The parent should be glue layer udc device or the dual-role controller device. Peter > > > > > /** > > * usb_otg_add_gadget_udc - adds a new gadget to the udc class driver list > > * @parent: the parent device to this udc. Usually the controller > > * driver's device. > > * @gadget: the gadget to be added to the list > > * @otg_dev: the OTG controller device > > * > > * If otg_dev is NULL then device tree node is checked > > * for OTG controller via the otg-controller property. > > * Returns zero on success, negative errno otherwise. > > */ > > int usb_otg_add_gadget_udc(struct device *parent, struct usb_gadget *gadget, > >struct device *otg_dev) > > { > > if (!otg_dev) { > > gadget->otg_dev = of_usb_get_otg(parent->of_node); > > if (!gadget->otg_dev) > > return -ENODEV; > > } else { > > gadget->otg_dev = otg_dev; > > } > > > > return usb_add_gadget_udc_release(parent, gadget, NULL); > > } > > EXPORT_SYMBOL_GPL(usb_otg_add_gadget_udc); > > > > -- > cheers, > -roger -- Best Regards, Peter Chen -- 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: [PATCH v10 08/14] usb: otg: add OTG/dual-role core
On 12/06/16 14:21, Peter Chen wrote: > On Fri, Jun 10, 2016 at 04:07:17PM +0300, Roger Quadros wrote: >> index dca7856..03f7204 100644 >> --- a/drivers/usb/Makefile >> +++ b/drivers/usb/Makefile >> @@ -59,5 +59,6 @@ obj-$(CONFIG_USB_RENESAS_USBHS)+= renesas_usbhs/ >> obj-$(CONFIG_USB_GADGET)+= gadget/ >> >> obj-$(CONFIG_USB_COMMON)+= common/ >> +obj-$(CONFIG_USB_OTG_CORE) += common/ > > I don't think you need to make above change, why you do it? You are right. I no longer get undefined symbol errors during build. I'll remove this change. > >> + >> +/** >> + * usb_otg_get_data() - get usb_otg data structa > > %s/structa/structure OK. > >> + >> +/** >> + * usb_otg_kick_fsm() - Kick the OTG state machine >> + * @otg_dev:OTG controller device >> + * >> + * Used by USB host/gadget stack to sync OTG related >> + * events to the OTG state machine. >> + * e.g. change in host_bus->b_hnp_enable, gadget->b_hnp_enable >> + * >> + * Return: 0 on success, error value otherwise. >> + */ >> +int usb_otg_kick_fsm(struct device *otg_dev) >> +{ >> +struct usb_otg *otg; >> + >> +mutex_lock(_list_mutex); >> +otg = usb_otg_get_data(otg_dev); >> +mutex_unlock(_list_mutex); >> +if (!otg) { >> +dev_dbg(otg_dev, "otg: %s: invalid otg device\n", >> +__func__); >> +return -ENODEV; >> +} >> + >> +usb_otg_sync_inputs(otg); >> + >> +return 0; >> +} >> +EXPORT_SYMBOL_GPL(usb_otg_kick_fsm); > > Do you have any users for this API? If no, please delete it in this > version. I'll remove it. > >> + >> +/** >> + * usb_otg_register_hcd() - Register the host controller to OTG core >> + * @hcd:host controller >> + * @irqnum: interrupt number >> + * @irqflags: interrupt flags >> + * @ops:HCD ops to interface with the HCD >> + * >> + * This is used by the USB Host stack to register the host controller >> + * to the OTG core. Host controller must not be started by the >> + * caller as it is left upto the OTG state machine to do so. > > %s/upto/up to > >> + >> +/** >> + * usb_otg_register_gadget() - Register the gadget controller to OTG core >> + * @gadget: gadget controller instance >> + * @ops:gadget interface ops >> + * >> + * This is used by the USB gadget stack to register the gadget controller >> + * to the OTG core. Gadget controller must not be started by the >> + * caller as it is left upto the OTG state machine to do so. >> + * > > %s/upto/up to > OK for both. -- cheers, -roger -- 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: [PATCH v10 13/14] usb: gadget: udc: adapt to OTG core
On 13/06/16 10:20, Peter Chen wrote: > On Mon, Jun 13, 2016 at 10:14:31AM +0300, Roger Quadros wrote: >> On 12/06/16 14:36, Peter Chen wrote: >>> On Fri, Jun 10, 2016 at 04:07:22PM +0300, Roger Quadros wrote: +/** + * usb_otg_add_gadget_udc - adds a new gadget to the udc class driver list + * @parent: the parent device to this udc. Usually the controller + * driver's device. >>> >>> It seems it should be udc device >> >> Parent and udc->dev are not the same right? > > Sure, udc's parent is otg device. > >> >> I guess i'll omit the second statement to avoid confusion. So. >> >> @parent: the parent device to this udc. > > Where you call below APIs? It seems to be a udc driver, right? > So, when you try to get "otg-controller" from the node, this node > should be udc. @parent is actually the device that represents the USB Device controller in the device tree. When you call usb_add_gadget_udc_release() a new udc->dev device is created as it's child. See explanation for the @parent argument in usb_add_gadget_udc_release(). As we want to keep the parent argument identical to that I will not make any changes then. > > /** > * usb_otg_add_gadget_udc - adds a new gadget to the udc class driver list > * @parent: the parent device to this udc. Usually the controller > * driver's device. > * @gadget: the gadget to be added to the list > * @otg_dev: the OTG controller device > * > * If otg_dev is NULL then device tree node is checked > * for OTG controller via the otg-controller property. > * Returns zero on success, negative errno otherwise. > */ > int usb_otg_add_gadget_udc(struct device *parent, struct usb_gadget *gadget, > struct device *otg_dev) > { > if (!otg_dev) { > gadget->otg_dev = of_usb_get_otg(parent->of_node); > if (!gadget->otg_dev) > return -ENODEV; > } else { > gadget->otg_dev = otg_dev; > } > > return usb_add_gadget_udc_release(parent, gadget, NULL); > } > EXPORT_SYMBOL_GPL(usb_otg_add_gadget_udc); > -- cheers, -roger -- 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: [PATCH v10 13/14] usb: gadget: udc: adapt to OTG core
On Mon, Jun 13, 2016 at 10:14:31AM +0300, Roger Quadros wrote: > On 12/06/16 14:36, Peter Chen wrote: > > On Fri, Jun 10, 2016 at 04:07:22PM +0300, Roger Quadros wrote: > >> > >> +/** > >> + * usb_otg_add_gadget_udc - adds a new gadget to the udc class driver list > >> + * @parent: the parent device to this udc. Usually the controller > >> + * driver's device. > > > > It seems it should be udc device > > Parent and udc->dev are not the same right? Sure, udc's parent is otg device. > > I guess i'll omit the second statement to avoid confusion. So. > > @parent: the parent device to this udc. Where you call below APIs? It seems to be a udc driver, right? So, when you try to get "otg-controller" from the node, this node should be udc. /** * usb_otg_add_gadget_udc - adds a new gadget to the udc class driver list * @parent: the parent device to this udc. Usually the controller * driver's device. * @gadget: the gadget to be added to the list * @otg_dev: the OTG controller device * * If otg_dev is NULL then device tree node is checked * for OTG controller via the otg-controller property. * Returns zero on success, negative errno otherwise. */ int usb_otg_add_gadget_udc(struct device *parent, struct usb_gadget *gadget, struct device *otg_dev) { if (!otg_dev) { gadget->otg_dev = of_usb_get_otg(parent->of_node); if (!gadget->otg_dev) return -ENODEV; } else { gadget->otg_dev = otg_dev; } return usb_add_gadget_udc_release(parent, gadget, NULL); } EXPORT_SYMBOL_GPL(usb_otg_add_gadget_udc); -- Best Regards, Peter Chen -- 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: [PATCH v10 13/14] usb: gadget: udc: adapt to OTG core
On 12/06/16 14:36, Peter Chen wrote: > On Fri, Jun 10, 2016 at 04:07:22PM +0300, Roger Quadros wrote: >> >> +/** >> + * usb_otg_add_gadget_udc - adds a new gadget to the udc class driver list >> + * @parent: the parent device to this udc. Usually the controller >> + * driver's device. > > It seems it should be udc device Parent and udc->dev are not the same right? I guess i'll omit the second statement to avoid confusion. So. @parent: the parent device to this udc. > >> +/* udc_lock must be held */ >> static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver >> *driver) >> { >> int ret; >> @@ -1282,17 +1449,26 @@ static int udc_bind_to_driver(struct usb_udc *udc, >> struct usb_gadget_driver *dri >> ret = driver->bind(udc->gadget, driver); >> if (ret) >> goto err1; >> -ret = usb_gadget_udc_start(udc); >> -if (ret) { >> -driver->unbind(udc->gadget); >> -goto err1; >> + >> +/* If OTG/dual-role, the otg core manages UDC start/stop */ >> +if (udc->gadget->otg_dev) { >> +mutex_unlock(_lock); >> +usb_otg_gadget_ready(udc->gadget, true); >> +mutex_lock(_lock); >> +} else { >> +ret = usb_gadget_udc_start(udc); >> +if (ret) { >> +mutex_unlock(_lock); >> +driver->unbind(udc->gadget); >> +goto err1; >> +} >> +usb_udc_connect_control(udc); >> } >> -usb_udc_connect_control(udc); >> >> kobject_uevent(>dev.kobj, KOBJ_CHANGE); >> return 0; >> err1: >> -if (ret != -EISNAM) >> +if ((ret != -EISNAM) && (ret != -EPROBE_DEFER)) > > It seems it will not introduce -EPROBE_DEFER with your changes > in udc_bind_to_driver > Good catch. Left over bit when I moved defer probing out of here. -- cheers, -roger -- 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: [PATCH v7 2/4] usb: dwc3: add dual-role support
Peter, On 12/06/16 12:11, Peter Chen wrote: > On Fri, Jun 10, 2016 at 04:17:28PM +0300, Roger Quadros wrote: >> Register with the USB OTG/DRD core. Since we don't support >> OTG yet we just work as a dual-role device even >> if device tree says "otg". >> >> Get ID and VBUS information from the OTG controller >> and kick the OTG state machine. >> > > Hi Roger, > > I can't apply it after rebase usb-next rc1 and felipe's testing/next. > How to apply it? You just need to apply the series on Felipe's testing/next + this one patch http://article.gmane.org/gmane.linux.kernel/2240761 -- cheers, -roger -- 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: [balbi-usb:testing/next 64/67] otg.c:undefined reference to `usb_gadget_vbus_disconnect'
On Mon, Jun 13, 2016 at 09:01:55AM +0300, Felipe Balbi wrote: > Felipe Balbiwrites: > > Here's an updated version: > > From d45bdfafc3143dc7acc9d71131807d3e30ab7bcd Mon Sep 17 00:00:00 2001 > From: Felipe Balbi > Date: Tue, 31 May 2016 13:07:47 +0300 > Subject: [PATCH] usb: gadget: move gadget API functions to udc-core > > instead of defining all functions as static inlines, > let's move them to udc-core and export them with > EXPORT_SYMBOL_GPL, that way we can make sure that > only GPL drivers will use them. > > As a side effect, it'll be nicer to add tracepoints > to the gadget API. > > While at that, also fix Kconfig dependencies to > avoid randconfig build failures. > > Signed-off-by: Felipe Balbi Acked-by: Peter Chen > --- > drivers/phy/Kconfig | 1 + > drivers/power/Kconfig | 1 + > drivers/usb/gadget/udc/udc-core.c | 573 + > drivers/usb/host/Kconfig | 2 +- > drivers/usb/phy/Kconfig | 11 +- > include/linux/usb/gadget.h| 585 > -- > 6 files changed, 645 insertions(+), 528 deletions(-) > > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig > index b869b98835f4..8d1cfb7f3ea2 100644 > --- a/drivers/phy/Kconfig > +++ b/drivers/phy/Kconfig > @@ -176,6 +176,7 @@ config TWL4030_USB > tristate "TWL4030 USB Transceiver Driver" > depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS > depends on USB_SUPPORT > + depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't 'y' > select GENERIC_PHY > select USB_PHY > help > diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig > index 421770ddafa3..0f11a0f4c369 100644 > --- a/drivers/power/Kconfig > +++ b/drivers/power/Kconfig > @@ -309,6 +309,7 @@ config BATTERY_RX51 > config CHARGER_ISP1704 > tristate "ISP1704 USB Charger Detection" > depends on USB_PHY > + depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't be > 'y' > help > Say Y to enable support for USB Charger Detection with > ISP1707/ISP1704 USB transceivers. > diff --git a/drivers/usb/gadget/udc/udc-core.c > b/drivers/usb/gadget/udc/udc-core.c > index 6e8300d6a737..d2f28bb6dbda 100644 > --- a/drivers/usb/gadget/udc/udc-core.c > +++ b/drivers/usb/gadget/udc/udc-core.c > @@ -59,6 +59,579 @@ static int udc_bind_to_driver(struct usb_udc *udc, > > /* - > */ > > +/** > + * usb_ep_set_maxpacket_limit - set maximum packet size limit for endpoint > + * @ep:the endpoint being configured > + * @maxpacket_limit:value of maximum packet size limit > + * > + * This function should be used only in UDC drivers to initialize endpoint > + * (usually in probe function). > + */ > +void usb_ep_set_maxpacket_limit(struct usb_ep *ep, > + unsigned maxpacket_limit) > +{ > + ep->maxpacket_limit = maxpacket_limit; > + ep->maxpacket = maxpacket_limit; > +} > +EXPORT_SYMBOL_GPL(usb_ep_set_maxpacket_limit); > + > +/** > + * usb_ep_enable - configure endpoint, making it usable > + * @ep:the endpoint being configured. may not be the endpoint named "ep0". > + * drivers discover endpoints through the ep_list of a usb_gadget. > + * > + * When configurations are set, or when interface settings change, the driver > + * will enable or disable the relevant endpoints. while it is enabled, an > + * endpoint may be used for i/o until the driver receives a disconnect() from > + * the host or until the endpoint is disabled. > + * > + * the ep0 implementation (which calls this routine) must ensure that the > + * hardware capabilities of each endpoint match the descriptor provided > + * for it. for example, an endpoint named "ep2in-bulk" would be usable > + * for interrupt transfers as well as bulk, but it likely couldn't be used > + * for iso transfers or for endpoint 14. some endpoints are fully > + * configurable, with more generic names like "ep-a". (remember that for > + * USB, "in" means "towards the USB master".) > + * > + * returns zero, or a negative error code. > + */ > +int usb_ep_enable(struct usb_ep *ep) > +{ > + int ret; > + > + if (ep->enabled) > + return 0; > + > + ret = ep->ops->enable(ep, ep->desc); > + if (ret) > + return ret; > + > + ep->enabled = true; > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(usb_ep_enable); > + > +/** > + * usb_ep_disable - endpoint is no longer usable > + * @ep:the endpoint being unconfigured. may not be the endpoint named "ep0". > + * > + * no other task may be using this endpoint when this is called. > + * any pending and uncompleted requests will complete with status > + * indicating disconnect (-ESHUTDOWN) before this call returns. > + * gadget
Re: [balbi-usb:testing/next 64/67] otg.c:undefined reference to `usb_gadget_vbus_disconnect'
Felipe Balbiwrites: > [ Unknown signature status ] > > Hi, > > Peter Chen writes: >> On Wed, Jun 08, 2016 at 12:59:51PM +0300, Felipe Balbi wrote: >>> >>> Hi, >>> >>> kbuild test robot writes: >>> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git >>> > testing/next >>> > head: fc4d1f3f522648d92d0c046beedbc1469979499a >>> > commit: 74e51eb7b5b4f7ab33c099c20def3dce0c699006 [64/67] usb: gadget: >>> > move gadget API functions to udc-core >>> > config: i386-randconfig-h1-06081244 (attached as .config) >>> > compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430 >>> > reproduce: >>> > git checkout 74e51eb7b5b4f7ab33c099c20def3dce0c699006 >>> > # save the attached .config to linux build tree >>> > make ARCH=i386 >>> > >>> > All errors (new ones prefixed by >>): >>> > >>> >drivers/built-in.o: In function `nop_set_peripheral': >>> >phy-generic.c:(.text+0x59f7a6): undefined reference to >>> > `usb_gadget_vbus_connect' >>> >drivers/built-in.o: In function `nop_gpio_vbus_thread': >>> >phy-generic.c:(.text+0x59f8a1): undefined reference to >>> > `usb_gadget_vbus_connect' >>> >phy-generic.c:(.text+0x59f925): undefined reference to >>> > `usb_gadget_vbus_disconnect' >>> >drivers/built-in.o: In function `gpio_vbus_set_peripheral': >>> >phy-gpio-vbus-usb.c:(.text+0x59ff45): undefined reference to >>> > `usb_gadget_vbus_disconnect' >>> >drivers/built-in.o: In function `gpio_vbus_work': >>> >phy-gpio-vbus-usb.c:(.text+0x5a02dd): undefined reference to >>> > `usb_gadget_vbus_disconnect' >>> >phy-gpio-vbus-usb.c:(.text+0x5a0333): undefined reference to >>> > `usb_gadget_vbus_connect' >>> >drivers/built-in.o: In function `ci_handle_vbus_change.part.6': >>> >>> otg.c:(.text+0x605e3b): undefined reference to >>> >>> `usb_gadget_vbus_disconnect' >>> >>> otg.c:(.text+0x605e49): undefined reference to `usb_gadget_vbus_connect' >>> >drivers/built-in.o: In function `isp1704_charger_work': >>> >isp1704_charger.c:(.text+0x648335): undefined reference to >>> > `usb_gadget_disconnect' >>> >isp1704_charger.c:(.text+0x64839d): undefined reference to >>> > `usb_gadget_connect' >>> >drivers/built-in.o: In function `isp1704_charger_probe': >>> >isp1704_charger.c:(.text+0x648760): undefined reference to >>> > `usb_gadget_disconnect' >>> >>> thanks, fixed: >>> >> >> Hi Felipe, >> >> Your patch does not fix above issue, I have tried. At least, I can >> reproduce phy-gpio-vbus-usb build error if it is build in, and >> USB_GADGET is module. > > alright, I'll look at this today. Here's an updated version: From d45bdfafc3143dc7acc9d71131807d3e30ab7bcd Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 31 May 2016 13:07:47 +0300 Subject: [PATCH] usb: gadget: move gadget API functions to udc-core instead of defining all functions as static inlines, let's move them to udc-core and export them with EXPORT_SYMBOL_GPL, that way we can make sure that only GPL drivers will use them. As a side effect, it'll be nicer to add tracepoints to the gadget API. While at that, also fix Kconfig dependencies to avoid randconfig build failures. Signed-off-by: Felipe Balbi --- drivers/phy/Kconfig | 1 + drivers/power/Kconfig | 1 + drivers/usb/gadget/udc/udc-core.c | 573 + drivers/usb/host/Kconfig | 2 +- drivers/usb/phy/Kconfig | 11 +- include/linux/usb/gadget.h| 585 -- 6 files changed, 645 insertions(+), 528 deletions(-) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index b869b98835f4..8d1cfb7f3ea2 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -176,6 +176,7 @@ config TWL4030_USB tristate "TWL4030 USB Transceiver Driver" depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS depends on USB_SUPPORT + depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't 'y' select GENERIC_PHY select USB_PHY help diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 421770ddafa3..0f11a0f4c369 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -309,6 +309,7 @@ config BATTERY_RX51 config CHARGER_ISP1704 tristate "ISP1704 USB Charger Detection" depends on USB_PHY + depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't be 'y' help Say Y to enable support for USB Charger Detection with ISP1707/ISP1704 USB transceivers. diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index 6e8300d6a737..d2f28bb6dbda 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -59,6 +59,579 @@ static int udc_bind_to_driver(struct usb_udc *udc, /*