[PATCH net] r8152: clear LINK_OFF_WAKE_EN after autoresume
LINK_OFF_WAKE_EN should be cleared after autoresume, otherwise after system suspend, the system would wake up when linking off occurs. Signed-off-by: Hayes Wang --- drivers/net/usb/r8152.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 4e257b8..d7f20a9 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -2421,7 +2421,18 @@ static void rtl_runtime_suspend_enable(struct r8152 *tp, bool enable) ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); } else { + u32 ocp_data; + __rtl_set_wol(tp, tp->saved_wolopts); + + ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG); + + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CONFIG34); + ocp_data &= ~LINK_OFF_WAKE_EN; + ocp_write_word(tp, MCU_TYPE_PLA, PLA_CONFIG34, ocp_data); + + ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); + r8153_u2p3en(tp, true); r8153_u1u2en(tp, true); } -- 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] usb: host: Allow EHCI_OMAP to be built-in when USB_GADGET is 'm'
NOP_USB_XCEIV is used not only by gadget drivers but by host drivers as well e.g. EHCI_OMAP. commit 5a8d651a2bde ("usb: gadget: move gadget API functions to udc-core") made it so that NOP_USB_XCEIV can't be built-in if USB_GADGET is 'm'. But this prevents EHCI_OMAP to be built-in if USB_GADGET is 'm'. Fix this undesired behaviour by moving usb_gadget_vbus_connect/disconnect() to usb/gadget.h so that NOP_USB_XCEIV has no build dependency on USB_GADGET. Retain the original Kconfig behaviour i.e. NOP_USB_XCEIV is selected by drivers that need it. Fixes: 5a8d651a2bde ("usb: gadget: move gadget API functions to udc-core") Signed-off-by: Roger Quadros --- drivers/usb/gadget/udc/core.c | 60 --- drivers/usb/host/Kconfig | 2 +- drivers/usb/phy/Kconfig | 5 ++-- include/linux/usb/gadget.h| 44 ++- 4 files changed, 41 insertions(+), 70 deletions(-) diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index ff8685e..687828d 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -538,37 +538,6 @@ out: EXPORT_SYMBOL_GPL(usb_gadget_clear_selfpowered); /** - * usb_gadget_vbus_connect - Notify controller that VBUS is powered - * @gadget:The device which now has VBUS power. - * Context: can sleep - * - * This call is used by a driver for an external transceiver (or GPIO) - * that detects a VBUS power session starting. Common responses include - * resuming the controller, activating the D+ (or D-) pullup to let the - * host detect that a USB device is attached, and starting to draw power - * (8mA or possibly more, especially after SET_CONFIGURATION). - * - * Returns zero on success, else negative errno. - */ -int usb_gadget_vbus_connect(struct usb_gadget *gadget) -{ - int ret = 0; - - if (!gadget->ops->vbus_session) { - ret = -EOPNOTSUPP; - goto out; - } - - ret = gadget->ops->vbus_session(gadget, 1); - -out: - trace_usb_gadget_vbus_connect(gadget, ret); - - return ret; -} -EXPORT_SYMBOL_GPL(usb_gadget_vbus_connect); - -/** * usb_gadget_vbus_draw - constrain controller's VBUS power usage * @gadget:The device whose VBUS usage is being described * @mA:How much current to draw, in milliAmperes. This should be twice @@ -601,35 +570,6 @@ out: EXPORT_SYMBOL_GPL(usb_gadget_vbus_draw); /** - * usb_gadget_vbus_disconnect - notify controller about VBUS session end - * @gadget:the device whose VBUS supply is being described - * Context: can sleep - * - * This call is used by a driver for an external transceiver (or GPIO) - * that detects a VBUS power session ending. Common responses include - * reversing everything done in usb_gadget_vbus_connect(). - * - * Returns zero on success, else negative errno. - */ -int usb_gadget_vbus_disconnect(struct usb_gadget *gadget) -{ - int ret = 0; - - if (!gadget->ops->vbus_session) { - ret = -EOPNOTSUPP; - goto out; - } - - ret = gadget->ops->vbus_session(gadget, 0); - -out: - trace_usb_gadget_vbus_disconnect(gadget, ret); - - return ret; -} -EXPORT_SYMBOL_GPL(usb_gadget_vbus_disconnect); - -/** * usb_gadget_connect - software-controlled connect to USB host * @gadget:the peripheral being connected * diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 2e710a4..d8f5674 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -180,7 +180,7 @@ config USB_EHCI_MXC config USB_EHCI_HCD_OMAP tristate "EHCI support for OMAP3 and later chips" depends on ARCH_OMAP - depends on NOP_USB_XCEIV + select NOP_USB_XCEIV default y ---help--- Enables support for the on-chip EHCI controller on diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index b9c409a..fe94bbc 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -45,7 +45,7 @@ config ISP1301_OMAP config KEYSTONE_USB_PHY tristate "Keystone USB PHY Driver" depends on ARCH_KEYSTONE || COMPILE_TEST - depends on NOP_USB_XCEIV + select NOP_USB_XCEIV help Enable this to support Keystone USB phy. This driver provides interface to interact with USB 2.0 and USB 3.0 PHY that is part @@ -53,7 +53,6 @@ config KEYSTONE_USB_PHY config NOP_USB_XCEIV tristate "NOP USB Transceiver Driver" - depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, NOP can't be built-in select USB_PHY help This driver is to be used by all the usb transceiver which are either @@ -66,7 +65,7 @@ config AM335X_CONTROL_USB config AM335X_PHY_USB tristate "AM335x USB PHY Driver" depends on ARM || COMPILE_TEST - depends on NOP_USB_XCEIV + select NOP_USB_XCEIV select USB_PHY select AM335X_CONTROL_USB select USB_COMMON diff --git a/include/linux/usb/gadget
RE: [PATCH 3/3] usb: renesas_usbhs: Use devm_usb_get_phy_by_phandle()
Hi, > From: Rob Herring > Sent: Wednesday, June 29, 2016 5:57 AM > > On Mon, Jun 27, 2016 at 09:09:19PM +0900, Yoshihiro Shimoda wrote: > > This patch uses devm_usb_get_phy_by_phandle() instead of usb_get_phy() > > for device tree environment. This change is not compabile with the > > previous code, but it is no problem because nobody calls usb_bind_phy() > > for this driver now. > > > > Signed-off-by: Yoshihiro Shimoda > > --- > > Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 3 ++- > > drivers/usb/renesas_usbhs/mod_gadget.c | 7 ++- > > 2 files changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt > b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt > > index b604056..a419aea 100644 > > --- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt > > +++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt > > @@ -24,8 +24,9 @@ Optional properties: > >- renesas,buswait: Integer to use BUSWAIT register > >- renesas,enable-gpio: A gpio specifier to check GPIO determining if USB > > function should be enabled > > - - phys: phandle + phy specifier pair > > + - phys: phandle of *Generic PHY* + phy specifier pair > >- phy-names: must be "usb" > > + - usb-phy: phandle of usb phy > > No. The binding should not change based on which kernel subsystem > handles this. The USB-PHY code should learn to parse 'phys' if you want > to use that subsystem. Thank you for the review. The "phys" is for Generic PHY even if this patch is applied. So, I think that I should make a patch to revise the explanation at first? I would to write overview of renesas_usbhs driver and a question below: < phys > - This is a generic phy property. - The renesas_usbhs driver will use it to turn on/off the PHY - Almost all platforms use this generic phy instance. < usb-phy > - This is a USB-PHY property. - The renesas_usbhs driver will use it to call an OTG related function. (otg_set_peripheral) - The renesas_usbhs driver will NOT use it to turn the power on/off. - Some platforms don't use this USB-PHY instance. - In other words, some platforms use both a generic phy and USB-PHY. - Is it not suitable from the device tree point of view? Best regards, Yoshihiro Shimoda > >- dmas: Must contain a list of references to DMA specifiers. > >- dma-names : named "ch%d", where %d is the channel number ranging from > > zero > > to the number of channels (DnFIFOs) minus one. -- 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 16/21] usb: chipidea: msm: Restore wrapper settings after reset
On Wed, Jun 29, 2016 at 12:13:45PM -0700, Stephen Boyd wrote: > Quoting Peter Chen (2016-06-29 01:26:48) > > On Sun, Jun 26, 2016 at 12:28:33AM -0700, Stephen Boyd wrote: > > > When the RESET bit is set in the USBCMD register it resets quite > > > @@ -21,11 +23,22 @@ > > > #define HS_PHY_SEC_CTRL 0x0278 > > > # define HS_PHY_DIG_CLAMP_N BIT(16) > > > > > > +#define HS_PHY_GENCONFIG 0x009c > > > +# define HS_PHY_TXFIFO_IDLE_FORCE_DISBIT(4) > > > + > > > +#define HS_PHY_GENCONFIG_2 0x00a0 > > > +# define HS_PHY_SESS_VLD_CTRL_EN BIT(7) > > > +# define HS_PHY_ULPI_TX_PKT_EN_CLR_FIX BIT(19) > > > + > > > +#define HSPHY_SESS_VLD_CTRL BIT(25) > > > + > > > > Keep alignment please. > > I take it this means it should look like: > > #define HS_PHY_GENCONFIG > #define HS_PHY_TXFIFO_IDLE_FORCE_DIS > > ? > Yes > > > @@ -141,6 +172,13 @@ static int ci_hdrc_msm_probe(struct platform_device > > > *pdev) > > > if (!base) > > > return -ENOMEM; > > > > > > + ci->vbus_edev = extcon_get_edev_by_phandle(&pdev->dev, 0); > > > + if (IS_ERR(ci->vbus_edev)) { > > > + if (PTR_ERR(ci->vbus_edev) != -ENODEV) > > > + return PTR_ERR(ci->vbus_edev); > > > + ci->vbus_edev = NULL; > > > + } > > > + > > > > Why not using ci->platdata->vbus_extcon directly? > > Because ci->platdata->vbus_extcon is assigned after the child platform > driver probes, and we have no idea when that will happen from the > ci_hdrc_msm driver probe. If we try after ci_hdrc_add_device() we'll > race with the driver probe and only get the pointer sometimes. ci->platdata->vbus_extcon->edev is assigned at ci_get_platdata which is called before ci core device is created. > > > > > > reset_control_assert(reset); > > > usleep_range(1, 12000); > > > reset_control_deassert(reset); > > > @@ -157,6 +195,14 @@ static int ci_hdrc_msm_probe(struct platform_device > > > *pdev) > > > if (ret) > > > goto err_mux; > > > > > > + ulpi_node = of_find_node_by_name(pdev->dev.of_node, "ulpi"); > > > + if (ulpi_node) { > > > + phy_node = of_get_next_available_child(ulpi_node, NULL); > > > + ci->hsic = of_device_is_compatible(phy_node, > > > "qcom,usb-hsic-phy"); > > > + of_node_put(phy_node); > > > + } > > > + of_node_put(ulpi_node); > > > + > > > > Just confirm with you that ci->platdata->phy_mode is not enough? > > Right. The phy_mode is never set to HSIC. It's always ULPI. Ok -- 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] usb: gadget: Add the gserial port checking in gs_start_tx()
When usb gadget is set gadget serial function, it will be crash in below situation. It will clean the 'port->port_usb' pointer in gserial_disconnect() function when usb link is inactive, but it will release lock for disabling the endpoints in this function. Druing the lock release period, it maybe complete one request to issue gs_write_complete()--->gs_start_tx() function, but the 'port->port_usb' pointer had been set NULL, thus it will be crash in gs_start_tx() function. This patch adds the 'port->port_usb' pointer checking in gs_start_tx() function to avoid this situation. Signed-off-by: Baolin Wang --- drivers/usb/gadget/function/u_serial.c |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 3580f19..66a0910 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -375,10 +375,15 @@ __acquires(&port->port_lock) */ { struct list_head*pool = &port->write_pool; - struct usb_ep *in = port->port_usb->in; + struct usb_ep *in; int status = 0; booldo_tty_wake = false; + if (!port->port_usb) + return status; + + in = port->port_usb->in; + while (!port->write_busy && !list_empty(pool)) { struct usb_request *req; int len; -- 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
Re: [PATCH 17/21] usb: chipidea: msm: Make platform data driver local instead of global
On Wed, Jun 29, 2016 at 12:17:12PM -0700, Stephen Boyd wrote: > Quoting Peter Chen (2016-06-29 04:29:25) > > On Sun, Jun 26, 2016 at 12:28:34AM -0700, Stephen Boyd wrote: > > > @@ -204,7 +201,7 @@ static int ci_hdrc_msm_probe(struct platform_device > > > *pdev) > > > of_node_put(ulpi_node); > > > > > > plat_ci = ci_hdrc_add_device(&pdev->dev, pdev->resource, > > > - pdev->num_resources, > > > &ci_hdrc_msm_platdata); > > > + pdev->num_resources, &ci->pdata); > > > if (IS_ERR(plat_ci)) { > > > dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n"); > > > ret = PTR_ERR(plat_ci); > > > > You can do something like ci_hdrc_usb2.c, it looks simpler. > > > > Do what exactly? I'd rather not do a structure copy because that wastes > some memory for a structure that is just a template. We add some more > code here to assign values directly, but that is smaller size wise than > the large platdata structure that only has a few values set in it. But you add one struct ci_hdrc_platform_data pdata entry at struct ci_hdrc_msm which needs to allocate the memory too. Anyway, it is not a big problem. Acked-by: Peter Chen -- 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: otg-fsm: Cancel HNP polling work when not used
On Wed, Jun 29, 2016 at 07:02:32PM -0700, Stephen Boyd wrote: > Quoting Peter Chen (2016-06-29 02:43:47) > > On Mon, Jun 27, 2016 at 06:18:27PM -0700, Stephen Boyd wrote: > > It introduces circular locking after applying it, otg_statemachine calls > > otg_leave_state, and otg_leave_state calls otg_statemachine again due > > to flush work, see below dump: > > > > I suggest moving initialization/flush hnp polling work to chipidea driver. > > > > [ 183.086987] == > > [ 183.093183] [ INFO: possible circular locking dependency detected ] > > [ 183.099471] 4.7.0-rc4-00012-gf1f333f-dirty #856 Not tainted > > [ 183.105059] --- > > [ 183.111341] kworker/0:2/114 is trying to acquire lock: > > [ 183.116492] (&ci->fsm.lock){+.+.+.}, at: [<806118dc>] > > otg_statemachine+0x20/0x470 > > [ 183.124199] > > [ 183.124199] but task is already holding lock: > > [ 183.130052] ((&(&fsm->hnp_polling_work)->work)){+.+...}, at: > > [<80140368>] process_one_work+0x128/0x418 > > [ 183.139568] > > [ 183.139568] which lock already depends on the new lock. > > [ 183.139568] > > [ 183.147765] > > [ 183.147765] the existing dependency chain (in reverse order) is: > > [ 183.155265] > > -> #1 ((&(&fsm->hnp_polling_work)->work)){+.+...}: > > [ 183.161371][<8013e97c>] flush_work+0x44/0x234 > > [ 183.166469][<801411a8>] __cancel_work_timer+0x98/0x1c8 > > [ 183.172347][<80141304>] cancel_delayed_work_sync+0x14/0x18 > > [ 183.178570][<80610ef8>] otg_set_state+0x290/0xc54 > > [ 183.184011][<806119d0>] otg_statemachine+0x114/0x470 > > [ 183.189712][<8060a590>] ci_otg_fsm_work+0x40/0x190 > > [ 183.195239][<806054d0>] ci_otg_work+0xcc/0x1e4 > > [ 183.200430][<801403d4>] process_one_work+0x194/0x418 > > [ 183.206136][<8014068c>] worker_thread+0x34/0x4fc > > [ 183.211489][<80146d08>] kthread+0xdc/0xf8 > > [ 183.216238][<80108ab0>] ret_from_fork+0x14/0x24 > > [ 183.221514] > > -> #0 (&ci->fsm.lock){+.+.+.}: > > [ 183.225880][<8016ff94>] lock_acquire+0x78/0x98 > > [ 183.231062][<80947c18>] mutex_lock_nested+0x54/0x3ec > > [ 183.236773][<806118dc>] otg_statemachine+0x20/0x470 > > [ 183.242388][<80611df4>] otg_hnp_polling_work+0xc8/0x1a4 > > [ 183.248352][<801403d4>] process_one_work+0x194/0x418 > > [ 183.254055][<8014068c>] worker_thread+0x34/0x4fc > > [ 183.259409][<80146d08>] kthread+0xdc/0xf8 > > [ 183.264154][<80108ab0>] ret_from_fork+0x14/0x24 > > [ 183.269424] > > [ 183.269424] other info that might help us debug this: > > [ 183.269424] > > [ 183.277451] Possible unsafe locking scenario: > > [ 183.277451] > > [ 183.283389]CPU0CPU1 > > [ 183.287931] > > [ 183.292473] lock((&(&fsm->hnp_polling_work)->work)); > > [ 183.297665]lock(&ci->fsm.lock); > > [ 183.303639] > > lock((&(&fsm->hnp_polling_work)->work)); > > [ 183.311347] lock(&ci->fsm.lock); > > [ 183.314801] > > Hm.. perhaps we should do cancel_delayed_work() then and not require any > sync? That would require some locking in the polling worker, but that > looks racy anyway as it runs in parallel to the state machine so it > probably needs to lock with the FSM. Completely untested patch as I'm > going home from work now. > Wait your tested patch:) Peter > 8< > diff --git a/drivers/usb/common/usb-otg-fsm.c > b/drivers/usb/common/usb-otg-fsm.c > index 73eec8c12235..6f4b7f0c81ff 100644 > --- a/drivers/usb/common/usb-otg-fsm.c > +++ b/drivers/usb/common/usb-otg-fsm.c > @@ -70,7 +70,11 @@ static void otg_stop_hnp_polling(struct otg_fsm *fsm) > if (!fsm->host_req_flag) > return; > > - cancel_delayed_work_sync(&fsm->hnp_polling_work); > + /* > + * We don't call cancel_delayed_work_sync() here because the > + * worker is synchronized to this function via the fsm lock. > + */ > + cancel_delayed_work(&fsm->hnp_polling_work); > } > > /* Called when leaving a state. Do state clean up jobs here */ > @@ -136,23 +140,27 @@ static void otg_leave_state(struct otg_fsm *fsm, enum > usb_otg_state old_state) > } > } > > +static int __otg_statemachine(struct otg_fsm *fsm); > + > static void otg_hnp_polling_work(struct work_struct *work) > { > struct otg_fsm *fsm = container_of(to_delayed_work(work), > struct otg_fsm, hnp_polling_work); > struct usb_device *udev; > - enum usb_otg_state state = fsm->otg->state; > + enum usb_otg_state state; > u8 flag; > int retval; > > + mutex_lock(&fsm->lock); > + state = fsm->otg->state; > if (state != OTG_STATE_A_HOST && state != OTG_STATE_B_HOST) > - return; > + goto unlock; > >
Re: [PATCH RFC 3/4] usb: chipidea: udc: Avoid busy wait in reset ISR
On Sat, Jun 25, 2016 at 08:38:58AM +, Stefan Wahren wrote: > Since there is no dependency from this busy wait in the reset ISR > we could remove it. > > Signed-off-by: Stefan Wahren > --- > drivers/usb/chipidea/udc.c |4 > 1 file changed, 4 deletions(-) > > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c > index fdcdcc6..bb51ae8 100644 > --- a/drivers/usb/chipidea/udc.c > +++ b/drivers/usb/chipidea/udc.c > @@ -323,10 +323,6 @@ static int hw_usb_reset(struct ci_hdrc *ci) > /* clear complete status */ > hw_write(ci, OP_ENDPTCOMPLETE, 0, 0); > > - /* wait until all bits cleared */ > - while (hw_read(ci, OP_ENDPTPRIME, ~0)) > - udelay(10); /* not RTOS friendly */ > - I think this wait is needed, you can add timeout (100ms) as an improvement. -- 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 RFC 0/4] Improvements to Chipidea UDC
On Sat, Jun 25, 2016 at 08:38:55AM +, Stefan Wahren wrote: > This patch series aim to improve the ChipIdea UDC driver in regards to > readability and runtime behavior. > > Stefan Wahren (4): > usb: chipidea: udc: move write barrier into hw_ep_prime > usb: chipidea: udc: Don't flush endpoint fifo twice > usb: chipidea: udc: Avoid busy wait in reset ISR > usb: chipidea: udc: Use direction flags consequently > > drivers/usb/chipidea/udc.c | 31 --- > 1 file changed, 12 insertions(+), 19 deletions(-) > Except the patch 3/4, others are ok. -- 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: [GIT PULL] usb patches for v4.8
Hi, Greg Kroah-Hartman writes: > On Wed, Jun 29, 2016 at 04:11:31PM +0300, Felipe Balbi wrote: >> >> Hi Greg, >> >> here's the big pull request for gadget API and related UDC drivers. >> >> Nothing really scary lately. Patches have been in linux-next for a while >> without outstanding reports. >> >> Let me know if you want any changes, but things seem to be calming >> down. I have, however, a few patches pending in my linux-usb inbox but I >> won't have time to really work on them in time for current merge window, >> so I decided to cut my tree short and send you a pull request. >> >> Anyway, here's the good stuff >> >> The following changes since commit 33688abb2802ff3a230bd2441f765477b94cc89e: >> >> Linux 4.7-rc4 (2016-06-19 21:30:02 -0700) >> >> are available in the git repository at: >> >> git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git >> tags/usb-for-v4.8 > > I got a merge issue in drivers/usb/dwc3/host.c that I had to fix up by > hand. Can you verify I got the merge correct? It builds for me here :) looks okay and still passes my tests. Then again, Intel's SoCs don't use dwc3/host.c, Roger or Bin, can you test AM437x with greg/usb-next to make sure it still works for you guys? -- balbi signature.asc Description: PGP signature
Re: [PATCH] usb: host: Allow EHCI_OMAP to be built-in when USB_GADGET is 'm'
Hi, Roger Quadros writes: > NOP_USB_XCEIV is used not only by gadget drivers but by > host drivers as well e.g. EHCI_OMAP. > > commit 5a8d651a2bde ("usb: gadget: move gadget API functions to udc-core") > made it so that NOP_USB_XCEIV can't be built-in if USB_GADGET is 'm'. > But this prevents EHCI_OMAP to be built-in if USB_GADGET is 'm'. > > Fix this undesired behaviour by moving usb_gadget_vbus_connect/disconnect() > to usb/gadget.h so that NOP_USB_XCEIV has no build dependency > on USB_GADGET. > > Retain the original Kconfig behaviour i.e. NOP_USB_XCEIV is selected > by drivers that need it. no, this is the wrong way to fix this. NOP _has_ a dependency on the Gadget API if it calls Gadget API functions. Dependencies are proper. Maybe the reason for the problem is that we ended up adding far too much code to phy-generic.c itself. Maybe it shouldn't know about clks and interrupts. The original idea of that driver was to simply satisfy a requirement to have a valid transceiver by some platforms. Maybe we should fix that instead. Moving functions around to workaround a problem is not the way to go, sorry. -- balbi signature.asc Description: PGP signature
Re: [GIT PULL] usb patches for v4.8
On 30/06/16 13:04, Felipe Balbi wrote: > > Hi, > > Greg Kroah-Hartman writes: >> On Wed, Jun 29, 2016 at 04:11:31PM +0300, Felipe Balbi wrote: >>> >>> Hi Greg, >>> >>> here's the big pull request for gadget API and related UDC drivers. >>> >>> Nothing really scary lately. Patches have been in linux-next for a while >>> without outstanding reports. >>> >>> Let me know if you want any changes, but things seem to be calming >>> down. I have, however, a few patches pending in my linux-usb inbox but I >>> won't have time to really work on them in time for current merge window, >>> so I decided to cut my tree short and send you a pull request. >>> >>> Anyway, here's the good stuff >>> >>> The following changes since commit 33688abb2802ff3a230bd2441f765477b94cc89e: >>> >>> Linux 4.7-rc4 (2016-06-19 21:30:02 -0700) >>> >>> are available in the git repository at: >>> >>> git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git >>> tags/usb-for-v4.8 >> >> I got a merge issue in drivers/usb/dwc3/host.c that I had to fix up by >> hand. Can you verify I got the merge correct? It builds for me here :) > > looks okay and still passes my tests. Then again, Intel's SoCs don't use > dwc3/host.c, Roger or Bin, can you test AM437x with greg/usb-next to > make sure it still works for you guys? > Unfortunately USB host is broken for TI platforms on greg/usb-next. Works fine on balbi/next though. cheers, -roger signature.asc Description: OpenPGP digital signature
Re: [PATCH v14 1/4] usb: gadget: Introduce the usb charger framework
Hi, Baolin Wang writes: > +static ssize_t charger_state_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct usb_charger *uchger = dev_to_uchger(dev); > + int cnt; > + > + switch (uchger->state) { > + case USB_CHARGER_PRESENT: > + cnt = sprintf(buf, "%s\n", "PRESENT"); > + break; > + case USB_CHARGER_REMOVE: > + cnt = sprintf(buf, "%s\n", "REMOVE"); > + break; > + default: > + cnt = sprintf(buf, "%s\n", "UNKNOWN"); > + break; are these the only states we need? Don't we need at least "CHARGING" and "ERROR" or something like that? Maybe those are exposed elsewhere, dunno. > +static int __usb_charger_set_cur_limit_by_type(struct usb_charger *uchger, > +enum usb_charger_type type, > +unsigned int cur_limit) > +{ > + if (WARN(!uchger, "charger can not be NULL")) > + return -EINVAL; IIRC, I mentioned that this should assume charger to be a valid pointer. Look at this, for a second: You check that you have a valid pointer here... > +int usb_charger_set_cur_limit_by_type(struct usb_charger *uchger, > + enum usb_charger_type type, > + unsigned int cur_limit) > +{ > + int ret; > + > + if (WARN(!uchger, "charger can not be NULL")) > + return -EINVAL; ... and here, before calling the other function. This is the only place which should check for valid uchger. > + mutex_lock(&uchger->lock); > + ret = __usb_charger_set_cur_limit_by_type(uchger, type, cur_limit); > + mutex_unlock(&uchger->lock); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(usb_charger_set_cur_limit_by_type); > + > +/* > + * usb_charger_set_cur_limit() - Set the current limitation. > + * @uchger - the usb charger instance. > + * @cur_limit_set - the current limitation. > + */ > +int usb_charger_set_cur_limit(struct usb_charger *uchger, > + struct usb_charger_cur_limit *cur_limit_set) > +{ > + if (WARN(!uchger || !cur_limit_set, "charger or setting can't be NULL")) > + return -EINVAL; I can see a pattern here. Not *all* errors need a splat. Sometimes a simple pr_err() or dev_err() (when you have a valid dev pointer) are enough. > diff --git a/include/linux/usb/charger.h b/include/linux/usb/charger.h > new file mode 100644 > index 000..d2e745e > --- /dev/null > +++ b/include/linux/usb/charger.h > @@ -0,0 +1,164 @@ > +#ifndef __LINUX_USB_CHARGER_H__ > +#define __LINUX_USB_CHARGER_H__ > + > +#include > +#include > + > +#define CHARGER_NAME_MAX 30 > + > +/* Current limitation by charger type */ > +struct usb_charger_cur_limit { > + unsigned int sdp_cur_limit; > + unsigned int dcp_cur_limit; > + unsigned int cdp_cur_limit; > + unsigned int aca_cur_limit; > +}; > + > +struct usb_charger_nb { > + struct notifier_block nb; > + struct usb_charger *uchger; > +}; > + please add KernelDoc here. And mention the fields which aren't supposed to be accessed directly but should rely on the accessor functions. At least type and state prefer to be accessed by their respective getter/setter methods. > +struct usb_charger { > + charname[CHARGER_NAME_MAX]; > + struct list_headlist; > + struct raw_notifier_headuchger_nh; > + /* protect the notifier head and charger */ > + struct mutexlock; > + int id; > + enum usb_charger_type type; > + enum usb_charger_state state; > + > + /* for supporting extcon usb gpio */ > + struct extcon_dev *extcon_dev; > + struct usb_charger_nb extcon_nb; > + > + /* for supporting usb gadget */ > + struct usb_gadget *gadget; > + enum usb_device_state old_gadget_state; > + > + /* for supporting power supply */ > + struct power_supply *psy; > + > + /* user can get charger type by implementing this callback */ > + enum usb_charger_type (*get_charger_type)(struct usb_charger *); > + /* > + * charger detection method can be implemented if you need to > + * manually detect the charger type. > + */ > + enum usb_charger_type (*charger_detect)(struct usb_charger *); > + > + /* current limitation */ > + struct usb_charger_cur_limitcur_limit; > + /* to check if it is needed to change the SDP charger default current */ > + unsigned intsdp_default_cur_change; > +}; -- balbi signature.asc Description: PGP signature
Re: [GIT PULL] usb patches for v4.8
Hi, Roger Quadros writes: here's the big pull request for gadget API and related UDC drivers. Nothing really scary lately. Patches have been in linux-next for a while without outstanding reports. Let me know if you want any changes, but things seem to be calming down. I have, however, a few patches pending in my linux-usb inbox but I won't have time to really work on them in time for current merge window, so I decided to cut my tree short and send you a pull request. Anyway, here's the good stuff The following changes since commit 33688abb2802ff3a230bd2441f765477b94cc89e: Linux 4.7-rc4 (2016-06-19 21:30:02 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git tags/usb-for-v4.8 >>> >>> I got a merge issue in drivers/usb/dwc3/host.c that I had to fix up by >>> hand. Can you verify I got the merge correct? It builds for me here :) >> >> looks okay and still passes my tests. Then again, Intel's SoCs don't use >> dwc3/host.c, Roger or Bin, can you test AM437x with greg/usb-next to >> make sure it still works for you guys? >> > Unfortunately USB host is broken for TI platforms on greg/usb-next. > Works fine on balbi/next though. got some logs to aid debugging there? Tracepoints? dmesg? Anything which could hint at the problem? -- balbi signature.asc Description: PGP signature
Re: [GIT PULL] usb patches for v4.8
On 30/06/16 13:32, Felipe Balbi wrote: > > Hi, > > Roger Quadros writes: > here's the big pull request for gadget API and related UDC drivers. > > Nothing really scary lately. Patches have been in linux-next for a while > without outstanding reports. > > Let me know if you want any changes, but things seem to be calming > down. I have, however, a few patches pending in my linux-usb inbox but I > won't have time to really work on them in time for current merge window, > so I decided to cut my tree short and send you a pull request. > > Anyway, here's the good stuff > > The following changes since commit > 33688abb2802ff3a230bd2441f765477b94cc89e: > > Linux 4.7-rc4 (2016-06-19 21:30:02 -0700) > > are available in the git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git > tags/usb-for-v4.8 I got a merge issue in drivers/usb/dwc3/host.c that I had to fix up by hand. Can you verify I got the merge correct? It builds for me here :) >>> >>> looks okay and still passes my tests. Then again, Intel's SoCs don't use >>> dwc3/host.c, Roger or Bin, can you test AM437x with greg/usb-next to >>> make sure it still works for you guys? >>> >> Unfortunately USB host is broken for TI platforms on greg/usb-next. >> Works fine on balbi/next though. > > got some logs to aid debugging there? Tracepoints? dmesg? Anything which > could hint at the problem? > xhci driver hasn't been loaded so > lsusb unable to initialize libusb: -99 cheers, -roger signature.asc Description: OpenPGP digital signature
Re: [GIT PULL] usb patches for v4.8
Greg, Felipe, On 30/06/16 13:45, Roger Quadros wrote: > On 30/06/16 13:32, Felipe Balbi wrote: >> >> Hi, >> >> Roger Quadros writes: >> here's the big pull request for gadget API and related UDC drivers. >> >> Nothing really scary lately. Patches have been in linux-next for a while >> without outstanding reports. >> >> Let me know if you want any changes, but things seem to be calming >> down. I have, however, a few patches pending in my linux-usb inbox but I >> won't have time to really work on them in time for current merge window, >> so I decided to cut my tree short and send you a pull request. >> >> Anyway, here's the good stuff >> >> The following changes since commit >> 33688abb2802ff3a230bd2441f765477b94cc89e: >> >> Linux 4.7-rc4 (2016-06-19 21:30:02 -0700) >> >> are available in the git repository at: >> >> git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git >> tags/usb-for-v4.8 > > I got a merge issue in drivers/usb/dwc3/host.c that I had to fix up by > hand. Can you verify I got the merge correct? It builds for me here :) looks okay and still passes my tests. Then again, Intel's SoCs don't use dwc3/host.c, Roger or Bin, can you test AM437x with greg/usb-next to make sure it still works for you guys? >>> Unfortunately USB host is broken for TI platforms on greg/usb-next. >>> Works fine on balbi/next though. >> >> got some logs to aid debugging there? Tracepoints? dmesg? Anything which >> could hint at the problem? >> > xhci driver hasn't been loaded so > >> lsusb > unable to initialize libusb: -99 > > cheers, > -roger > The following patch fixes it for me. Looks like we lost all changes related to commit 9522def40065 ("usb: dwc3: core: cleanup IRQ resources") in host.c during the merge. diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 67f90d7..f6533c6 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -23,7 +23,48 @@ int dwc3_host_init(struct dwc3 *dwc) { struct property_entry props[2]; struct platform_device *xhci; - int ret; + int ret, irq; + struct resource *res; + struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); + + irq = platform_get_irq_byname(dwc3_pdev, "host"); + if (irq == -EPROBE_DEFER) + return irq; + + if (irq <= 0) { + irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3"); + if (irq == -EPROBE_DEFER) + return irq; + + if (irq <= 0) { + irq = platform_get_irq(dwc3_pdev, 0); + if (irq <= 0) { + if (irq != -EPROBE_DEFER) { + dev_err(dwc->dev, + "missing host IRQ\n"); + } + if (!irq) + irq = -EINVAL; + return irq; + } else { + res = platform_get_resource(dwc3_pdev, + IORESOURCE_IRQ, 0); + } + } else { + res = platform_get_resource_byname(dwc3_pdev, + IORESOURCE_IRQ, + "dwc_usb3"); + } + + } else { + res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ, + "host"); + } + + dwc->xhci_resources[1].start = irq; + dwc->xhci_resources[1].end = irq; + dwc->xhci_resources[1].flags = res->flags; + dwc->xhci_resources[1].name = res->name; xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO); if (!xhci) { signature.asc Description: OpenPGP digital signature
Re: [PATCH v14 1/4] usb: gadget: Introduce the usb charger framework
Hi Felipe, On 30 June 2016 at 18:30, Felipe Balbi wrote: > > Hi, > > Baolin Wang writes: >> +static ssize_t charger_state_show(struct device *dev, >> + struct device_attribute *attr, >> + char *buf) >> +{ >> + struct usb_charger *uchger = dev_to_uchger(dev); >> + int cnt; >> + >> + switch (uchger->state) { >> + case USB_CHARGER_PRESENT: >> + cnt = sprintf(buf, "%s\n", "PRESENT"); >> + break; >> + case USB_CHARGER_REMOVE: >> + cnt = sprintf(buf, "%s\n", "REMOVE"); >> + break; >> + default: >> + cnt = sprintf(buf, "%s\n", "UNKNOWN"); >> + break; > > are these the only states we need? Don't we need at least "CHARGING" and > "ERROR" or something like that? Maybe those are exposed elsewhere, > dunno. Present state means we are charging. For charging error, I think it can be exposed in power driver, which is more proper. Until now I only see PRESENT and REMOVE state are useful. > >> +static int __usb_charger_set_cur_limit_by_type(struct usb_charger *uchger, >> +enum usb_charger_type type, >> +unsigned int cur_limit) >> +{ >> + if (WARN(!uchger, "charger can not be NULL")) >> + return -EINVAL; > > IIRC, I mentioned that this should assume charger to be a valid > pointer. Look at this, for a second: > > You check that you have a valid pointer here... Okay. I will remove this. > >> +int usb_charger_set_cur_limit_by_type(struct usb_charger *uchger, >> + enum usb_charger_type type, >> + unsigned int cur_limit) >> +{ >> + int ret; >> + >> + if (WARN(!uchger, "charger can not be NULL")) >> + return -EINVAL; > > ... and here, before calling the other function. This is the only place > which should check for valid uchger. Okay. > >> + mutex_lock(&uchger->lock); >> + ret = __usb_charger_set_cur_limit_by_type(uchger, type, cur_limit); >> + mutex_unlock(&uchger->lock); >> + >> + return ret; >> +} >> +EXPORT_SYMBOL_GPL(usb_charger_set_cur_limit_by_type); >> + >> +/* >> + * usb_charger_set_cur_limit() - Set the current limitation. >> + * @uchger - the usb charger instance. >> + * @cur_limit_set - the current limitation. >> + */ >> +int usb_charger_set_cur_limit(struct usb_charger *uchger, >> + struct usb_charger_cur_limit *cur_limit_set) >> +{ >> + if (WARN(!uchger || !cur_limit_set, "charger or setting can't be >> NULL")) >> + return -EINVAL; > > I can see a pattern here. Not *all* errors need a splat. Sometimes a > simple pr_err() or dev_err() (when you have a valid dev pointer) are > enough. Make sense. > >> diff --git a/include/linux/usb/charger.h b/include/linux/usb/charger.h >> new file mode 100644 >> index 000..d2e745e >> --- /dev/null >> +++ b/include/linux/usb/charger.h >> @@ -0,0 +1,164 @@ >> +#ifndef __LINUX_USB_CHARGER_H__ >> +#define __LINUX_USB_CHARGER_H__ >> + >> +#include >> +#include >> + >> +#define CHARGER_NAME_MAX 30 >> + >> +/* Current limitation by charger type */ >> +struct usb_charger_cur_limit { >> + unsigned int sdp_cur_limit; >> + unsigned int dcp_cur_limit; >> + unsigned int cdp_cur_limit; >> + unsigned int aca_cur_limit; >> +}; >> + >> +struct usb_charger_nb { >> + struct notifier_block nb; >> + struct usb_charger *uchger; >> +}; >> + > > please add KernelDoc here. And mention the fields which aren't supposed > to be accessed directly but should rely on the accessor functions. At > least type and state prefer to be accessed by their respective > getter/setter methods. Will add kernel doc for struct usb_charger. Thanks for your comments. > >> +struct usb_charger { >> + charname[CHARGER_NAME_MAX]; >> + struct list_headlist; >> + struct raw_notifier_headuchger_nh; >> + /* protect the notifier head and charger */ >> + struct mutexlock; >> + int id; >> + enum usb_charger_type type; >> + enum usb_charger_state state; >> + >> + /* for supporting extcon usb gpio */ >> + struct extcon_dev *extcon_dev; >> + struct usb_charger_nb extcon_nb; >> + >> + /* for supporting usb gadget */ >> + struct usb_gadget *gadget; >> + enum usb_device_state old_gadget_state; >> + >> + /* for supporting power supply */ >> + struct power_supply *psy; >> + >> + /* user can get charger type by implementing this callback */ >> + enum usb_charger_type (*get_charger_type)(struct usb_charger *); >> + /* >> + * charger detection method can be implemented if you need to >> + * manually detect the charger type. >> + */ >> + enum usb_charger_type (*charger_detect)(struct usb_charger *); >> + >> + /*
[PATCH v5 3/5] usb: dwc3: add phyif_utmi_quirk
Add a quirk to configure the core to support the UTMI+ PHY with an 8- or 16-bit interface. UTMI+ PHY interface is hardware property, and it's platform dependent. Normall, the PHYIf can be configured during coreconsultant. But for some specific usb cores(e.g. rk3399 soc dwc3), the default PHYIf configuration value is fault, so we need to reconfigure it by software. And refer to the dwc3 databook, the GUSB2PHYCFG.USBTRDTIM must be set to the corresponding value according to the UTMI+ PHY interface. Signed-off-by: William Wu --- Changes in v5: - None Changes in v4: - rebase on top of balbi testing/next, remove pdata (balbi) Changes in v3: - None Changes in v2: - add a quirk for phyif_utmi (balbi) Documentation/devicetree/bindings/usb/dwc3.txt | 4 drivers/usb/dwc3/core.c| 19 +++ drivers/usb/dwc3/core.h| 12 3 files changed, 35 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 1ada121..34d13a5 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -42,6 +42,10 @@ Optional properties: - snps,dis_u2_freeclk_exists_quirk: when set, clear the u2_freeclk_exists in GUSB2PHYCFG, specify that USB2 PHY doesn't provide a free-running PHY clock. + - snps,phyif_utmi_quirk: when set core will set phyif UTMI+ interface. + - snps,phyif_utmi: the value to configure the core to support a UTMI+ PHY + with an 8- or 16-bit interface. Value 0 select 8-bit + interface, value 1 select 16-bit interface. - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal utmi_l1_suspend_n, false when asserts utmi_sleep_n - snps,hird-threshold: HIRD threshold diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 34ab9c3..e880686 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -408,6 +408,7 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc) static int dwc3_phy_setup(struct dwc3 *dwc) { u32 reg; + u32 usbtrdtim; int ret; reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); @@ -503,6 +504,15 @@ static int dwc3_phy_setup(struct dwc3 *dwc) if (dwc->dis_u2_freeclk_exists_quirk) reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS; + if (dwc->phyif_utmi_quirk) { + reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK | + DWC3_GUSB2PHYCFG_USBTRDTIM_MASK); + usbtrdtim = dwc->phyif_utmi ? USBTRDTIM_UTMI_16_BIT : + USBTRDTIM_UTMI_8_BIT; + reg |= DWC3_GUSB2PHYCFG_PHYIF(dwc->phyif_utmi) | + DWC3_GUSB2PHYCFG_USBTRDTIM(usbtrdtim); + } + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); return 0; @@ -834,6 +844,7 @@ static int dwc3_probe(struct platform_device *pdev) struct resource *res; struct dwc3 *dwc; u8 lpm_nyet_threshold; + u8 phyif_utmi; u8 tx_de_emphasis; u8 hird_threshold; @@ -880,6 +891,9 @@ static int dwc3_probe(struct platform_device *pdev) /* default to highest possible threshold */ lpm_nyet_threshold = 0xff; + /* default to UTMI+ 8-bit interface */ + phyif_utmi = 0; + /* default to -3.5dB de-emphasis */ tx_de_emphasis = 1; @@ -929,6 +943,10 @@ static int dwc3_probe(struct platform_device *pdev) "snps,dis_rxdet_inp3_quirk"); dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev, "snps,dis_u2_freeclk_exists_quirk"); + dwc->phyif_utmi_quirk = device_property_read_bool(dev, + "snps,phyif_utmi_quirk"); + device_property_read_u8(dev, "snps,phyif_utmi", + &phyif_utmi); dwc->tx_de_emphasis_quirk = device_property_read_bool(dev, "snps,tx_de_emphasis_quirk"); @@ -940,6 +958,7 @@ static int dwc3_probe(struct platform_device *pdev) &dwc->fladj); dwc->lpm_nyet_threshold = lpm_nyet_threshold; + dwc->phyif_utmi = phyif_utmi; dwc->tx_de_emphasis = tx_de_emphasis; dwc->hird_threshold = hird_threshold diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index f321a5c..cf6696c 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -203,6 +203,12 @@ #define DWC3_GUSB2PHYCFG_SUSPHY(1 << 6) #define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4) #define DWC3_GUSB2PHYCFG_ENBLSLPM (1 << 8) +#define DWC3_GUSB2PHYCFG_PHYIF(n) (n << 3) +#define DWC3_GUSB2PHYCFG_PHYIF_MASKDWC3_GUSB2PHYCFG_PHYIF(1) +#define DW
[PATCH v5 2/5] usb: dwc3: add dis_u2_freeclk_exists_quirk
Add a quirk to clear the GUSB2PHYCFG.U2_FREECLK_EXISTS bit, which specifies whether the USB2.0 PHY provides a free-running PHY clock, which is active when the clock control input is active. Signed-off-by: William Wu --- Changes in v5: - None Changes in v4: - rebase on top of balbi testing/next, remove pdata (balbi) Changes in v3: - None Changes in v2: - None Documentation/devicetree/bindings/usb/dwc3.txt | 3 +++ drivers/usb/dwc3/core.c| 5 + drivers/usb/dwc3/core.h| 5 + 3 files changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 7d7ce08..1ada121 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -39,6 +39,9 @@ Optional properties: disabling the suspend signal to the PHY. - snps,dis_rxdet_inp3_quirk: when set core will disable receiver detection in PHY P3 power state. + - snps,dis_u2_freeclk_exists_quirk: when set, clear the u2_freeclk_exists + in GUSB2PHYCFG, specify that USB2 PHY doesn't provide + a free-running PHY clock. - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal utmi_l1_suspend_n, false when asserts utmi_sleep_n - snps,hird-threshold: HIRD threshold diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 9466431..34ab9c3 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -500,6 +500,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc) if (dwc->dis_enblslpm_quirk) reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM; + if (dwc->dis_u2_freeclk_exists_quirk) + reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS; + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); return 0; @@ -924,6 +927,8 @@ static int dwc3_probe(struct platform_device *pdev) "snps,dis_enblslpm_quirk"); dwc->dis_rxdet_inp3_quirk = device_property_read_bool(dev, "snps,dis_rxdet_inp3_quirk"); + dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev, + "snps,dis_u2_freeclk_exists_quirk"); dwc->tx_de_emphasis_quirk = device_property_read_bool(dev, "snps,tx_de_emphasis_quirk"); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 45d6de5..f321a5c 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -199,6 +199,7 @@ /* Global USB2 PHY Configuration Register */ #define DWC3_GUSB2PHYCFG_PHYSOFTRST(1 << 31) +#define DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS (1 << 30) #define DWC3_GUSB2PHYCFG_SUSPHY(1 << 6) #define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4) #define DWC3_GUSB2PHYCFG_ENBLSLPM (1 << 8) @@ -799,6 +800,9 @@ struct dwc3_scratchpad_array { * @dis_u2_susphy_quirk: set if we disable usb2 suspend phy * @dis_enblslpm_quirk: set if we clear enblslpm in GUSB2PHYCFG, * disabling the suspend signal to the PHY. + * @dis_u2_freeclk_exists_quirk : set if we clear u2_freeclk_exists + * in GUSB2PHYCFG, specify that USB2 PHY doesn't + * provide a free-running PHY clock. * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk * @tx_de_emphasis: Tx de-emphasis value * 0 - -6dB de-emphasis @@ -942,6 +946,7 @@ struct dwc3 { unsigneddis_u2_susphy_quirk:1; unsigneddis_enblslpm_quirk:1; unsigneddis_rxdet_inp3_quirk:1; + unsigneddis_u2_freeclk_exists_quirk:1; unsignedtx_de_emphasis_quirk:1; unsignedtx_de_emphasis:2; -- 1.9.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
[PATCH v5 4/5] usb: dwc3: add dis_del_phy_power_chg_quirk
Add a quirk to clear the GUSB3PIPECTL.DELAYP1TRANS bit, which specifies whether disable delay PHY power change from P0 to P1/P2/P3 when link state changing from U0 to U1/U2/U3 respectively. Signed-off-by: William Wu --- Changes in v5: - None Changes in v4: - rebase on top of balbi testing/next, remove pdata (balbi) Changes in v3: - None Changes in v2: - None Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++ drivers/usb/dwc3/core.c| 5 + drivers/usb/dwc3/core.h| 3 +++ 3 files changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 34d13a5..bd5bef0 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -42,6 +42,8 @@ Optional properties: - snps,dis_u2_freeclk_exists_quirk: when set, clear the u2_freeclk_exists in GUSB2PHYCFG, specify that USB2 PHY doesn't provide a free-running PHY clock. + - snps,dis_del_phy_power_chg_quirk: when set core will change PHY power + from P0 to P1/P2/P3 without delay. - snps,phyif_utmi_quirk: when set core will set phyif UTMI+ interface. - snps,phyif_utmi: the value to configure the core to support a UTMI+ PHY with an 8- or 16-bit interface. Value 0 select 8-bit diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index e880686..320a50f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -449,6 +449,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc) if (dwc->dis_u3_susphy_quirk) reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; + if (dwc->dis_del_phy_power_chg_quirk) + reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE; + dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); @@ -943,6 +946,8 @@ static int dwc3_probe(struct platform_device *pdev) "snps,dis_rxdet_inp3_quirk"); dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev, "snps,dis_u2_freeclk_exists_quirk"); + dwc->dis_del_phy_power_chg_quirk = device_property_read_bool(dev, + "snps,dis_del_phy_power_chg_quirk"); dwc->phyif_utmi_quirk = device_property_read_bool(dev, "snps,phyif_utmi_quirk"); device_property_read_u8(dev, "snps,phyif_utmi", diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index cf6696c..55e136d 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -809,6 +809,8 @@ struct dwc3_scratchpad_array { * @dis_u2_freeclk_exists_quirk : set if we clear u2_freeclk_exists * in GUSB2PHYCFG, specify that USB2 PHY doesn't * provide a free-running PHY clock. + * @dis_del_phy_power_chg_quirk: set if we disable delay phy power + * change quirk. * @phyif_utmi_quirk: set if we enable phyif UTMI+ quirk * @phyif_utmi: UTMI+ PHY interface value * 0 - 8 bits @@ -957,6 +959,7 @@ struct dwc3 { unsigneddis_enblslpm_quirk:1; unsigneddis_rxdet_inp3_quirk:1; unsigneddis_u2_freeclk_exists_quirk:1; + unsigneddis_del_phy_power_chg_quirk:1; unsignedphyif_utmi_quirk:1; unsignedphyif_utmi:1; -- 1.9.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
[PATCH v5 0/5] support rockchip dwc3 driver
This series add support for rockchip dwc3 driver, and add additional optional properties for specific platforms (e.g., rockchip rk3399 platform). William Wu (5): usb: dwc3: of-simple: add compatible for rockchip rk3399 usb: dwc3: add dis_u2_freeclk_exists_quirk usb: dwc3: add phyif_utmi_quirk usb: dwc3: add dis_del_phy_power_chg_quirk usb: dwc3: rockchip: add devicetree bindings documentation Documentation/devicetree/bindings/usb/dwc3.txt | 9 + .../devicetree/bindings/usb/rockchip,dwc3.txt | 40 ++ drivers/usb/dwc3/core.c| 29 drivers/usb/dwc3/core.h| 20 +++ drivers/usb/dwc3/dwc3-of-simple.c | 1 + 5 files changed, 99 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/rockchip,dwc3.txt -- 1.9.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
[PATCH v5 1/5] usb: dwc3: of-simple: add compatible for rockchip rk3399
Rockchip platform merely enable usb3 clocks and populate its children. So we can use this generic glue layer to support Rockchip dwc3. Signed-off-by: William Wu --- Changes in v5: - change compatible from "rockchip,dwc3" to "rockchip,rk3399-dwc3" (Heiko) Changes in v4: - None Changes in v3: - None Changes in v2: - sort the list of_dwc3_simple_match (Doug) drivers/usb/dwc3/dwc3-of-simple.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index 9743353..05c9349 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -161,6 +161,7 @@ static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = { static const struct of_device_id of_dwc3_simple_match[] = { { .compatible = "qcom,dwc3" }, + { .compatible = "rockchip,rk3399-dwc3" }, { .compatible = "xlnx,zynqmp-dwc3" }, { /* Sentinel */ } }; -- 1.9.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
[PATCH v5 5/5] usb: dwc3: rockchip: add devicetree bindings documentation
This patch adds the devicetree documentation required for Rockchip USB3.0 core wrapper consisting of USB3.0 IP from Synopsys. It supports DRD mode, and could operate in device mode (SS, HS, FS) and host mode (SS, HS, FS, LS). Signed-off-by: William Wu --- Changes in v5: - rename clock-names, and remove unnecessary clocks (Heiko) Changes in v4: - modify commit log, and add phy documentation location (Sergei) Changes in v3: - add dwc3 address (balbi) Changes in v2: - add rockchip,dwc3.txt to Documentation/devicetree/bindings/ (balbi, Brian) .../devicetree/bindings/usb/rockchip,dwc3.txt | 40 ++ 1 file changed, 40 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/rockchip,dwc3.txt diff --git a/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt new file mode 100644 index 000..9c85e19 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt @@ -0,0 +1,40 @@ +Rockchip SuperSpeed DWC3 USB SoC controller + +Required properties: +- compatible: should contain "rockchip,rk3399-dwc3" for rk3399 SoC +- clocks: A list of phandle + clock-specifier pairs for the + clocks listed in clock-names +- clock-names: Should contain the following: + "ref_clk"Controller reference clk, have to be 24 MHz + "suspend_clk"Controller suspend clk, have to be 24 MHz or 32 KHz + "bus_clk_otg0"Master/Core clock, have to be >= 62.5 MHz for SS + operation and >= 60MHz for HS operation + "grf_clk"Controller grf clk + +Required child node: +A child node must exist to represent the core DWC3 IP block. The name of +the node is not important. The content of the node is defined in dwc3.txt. + +Phy documentation is provided in the following places: +Documentation/devicetree/bindings/phy/rockchip,dwc3-usb-phy.txt + +Example device nodes: + + usbdrd3_0: usb@fe80 { + compatible = "rockchip,rk3399-dwc3"; + clocks = <&cru SCLK_USB3OTG0_REF>, <&cru SCLK_USB3OTG0_SUSPEND>, +<&cru ACLK_USB3OTG0>, <&cru ACLK_USB3_GRF>; + clock-names = "ref_clk", "suspend_clk", + "bus_clk_otg0", "grf_clk"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + status = "disabled"; + usbdrd_dwc3_0: dwc3@fe80 { + compatible = "snps,dwc3"; + reg = <0x0 0xfe80 0x0 0x10>; + interrupts = ; + dr_mode = "otg"; + status = "disabled"; + }; + }; -- 1.9.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
Re: [GIT PULL] usb patches for v4.8
Hi, Roger Quadros writes: >>> Roger Quadros writes: >>> here's the big pull request for gadget API and related UDC drivers. >>> >>> Nothing really scary lately. Patches have been in linux-next for a while >>> without outstanding reports. >>> >>> Let me know if you want any changes, but things seem to be calming >>> down. I have, however, a few patches pending in my linux-usb inbox but I >>> won't have time to really work on them in time for current merge window, >>> so I decided to cut my tree short and send you a pull request. >>> >>> Anyway, here's the good stuff >>> >>> The following changes since commit >>> 33688abb2802ff3a230bd2441f765477b94cc89e: >>> >>> Linux 4.7-rc4 (2016-06-19 21:30:02 -0700) >>> >>> are available in the git repository at: >>> >>> git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git >>> tags/usb-for-v4.8 >> >> I got a merge issue in drivers/usb/dwc3/host.c that I had to fix up by >> hand. Can you verify I got the merge correct? It builds for me here :) > > looks okay and still passes my tests. Then again, Intel's SoCs don't use > dwc3/host.c, Roger or Bin, can you test AM437x with greg/usb-next to > make sure it still works for you guys? > Unfortunately USB host is broken for TI platforms on greg/usb-next. Works fine on balbi/next though. >>> >>> got some logs to aid debugging there? Tracepoints? dmesg? Anything which >>> could hint at the problem? >>> >> xhci driver hasn't been loaded so >> >>> lsusb >> unable to initialize libusb: -99 >> >> cheers, >> -roger >> > > The following patch fixes it for me. Looks like we lost all changes related > to commit 9522def40065 ("usb: dwc3: core: cleanup IRQ resources") in host.c > during the merge. okay, thanks. Can you send below as a proper patch on top of greg/usb-next so it can be acked and merged? Thanks -- balbi signature.asc Description: PGP signature
[PATCH] usb: dwc3: host: Fix broken XHCI host
Looks like we lost all changes related to commit 9522def40065 ("usb: dwc3: core: cleanup IRQ resources") in host.c when Felipe's next branch was merged into Greg's next branch. Fixes 215db948181 ("Merge tag 'usb-for-v4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next") Signed-off-by: Roger Quadros --- drivers/usb/dwc3/host.c | 43 ++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 67f90d7..f6533c6 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -23,7 +23,48 @@ int dwc3_host_init(struct dwc3 *dwc) { struct property_entry props[2]; struct platform_device *xhci; - int ret; + int ret, irq; + struct resource *res; + struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); + + irq = platform_get_irq_byname(dwc3_pdev, "host"); + if (irq == -EPROBE_DEFER) + return irq; + + if (irq <= 0) { + irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3"); + if (irq == -EPROBE_DEFER) + return irq; + + if (irq <= 0) { + irq = platform_get_irq(dwc3_pdev, 0); + if (irq <= 0) { + if (irq != -EPROBE_DEFER) { + dev_err(dwc->dev, + "missing host IRQ\n"); + } + if (!irq) + irq = -EINVAL; + return irq; + } else { + res = platform_get_resource(dwc3_pdev, + IORESOURCE_IRQ, 0); + } + } else { + res = platform_get_resource_byname(dwc3_pdev, + IORESOURCE_IRQ, + "dwc_usb3"); + } + + } else { + res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ, + "host"); + } + + dwc->xhci_resources[1].start = irq; + dwc->xhci_resources[1].end = irq; + dwc->xhci_resources[1].flags = res->flags; + dwc->xhci_resources[1].name = res->name; xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO); if (!xhci) { -- 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] usb: dwc3: host: Fix broken XHCI host
Hi, Roger Quadros writes: > Looks like we lost all changes related to > commit 9522def40065 ("usb: dwc3: core: cleanup IRQ resources") in host.c > when Felipe's next branch was merged into Greg's next branch. > > Fixes 215db948181 ("Merge tag 'usb-for-v4.8' of > git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next") > Signed-off-by: Roger Quadros looks good to me. Acked-by: Felipe Balbi -- balbi signature.asc Description: PGP signature
Re: [PATCH v5 5/5] usb: dwc3: rockchip: add devicetree bindings documentation
Hi William, Am Donnerstag, 30. Juni 2016, 19:16:40 schrieb William Wu: > This patch adds the devicetree documentation required for Rockchip > USB3.0 core wrapper consisting of USB3.0 IP from Synopsys. > > It supports DRD mode, and could operate in device mode (SS, HS, FS) > and host mode (SS, HS, FS, LS). > > Signed-off-by: William Wu > --- > Changes in v5: > - rename clock-names, and remove unnecessary clocks (Heiko) > > Changes in v4: > - modify commit log, and add phy documentation location (Sergei) > > Changes in v3: > - add dwc3 address (balbi) > > Changes in v2: > - add rockchip,dwc3.txt to Documentation/devicetree/bindings/ (balbi, > Brian) > > .../devicetree/bindings/usb/rockchip,dwc3.txt | 40 > ++ 1 file changed, 40 insertions(+) > create mode 100644 > Documentation/devicetree/bindings/usb/rockchip,dwc3.txt > > diff --git a/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt > b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt new file mode > 100644 > index 000..9c85e19 > --- /dev/null > +++ b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt > @@ -0,0 +1,40 @@ > +Rockchip SuperSpeed DWC3 USB SoC controller > + > +Required properties: > +- compatible:should contain "rockchip,rk3399-dwc3" for rk3399 SoC > +- clocks:A list of phandle + clock-specifier pairs for the > + clocks listed in clock-names > +- clock-names: Should contain the following: > + "ref_clk" Controller reference clk, have to be 24 MHz > + "suspend_clk" Controller suspend clk, have to be 24 MHz or 32 KHz > + "bus_clk_otg0"Master/Core clock, have to be >= 62.5 MHz for SS > + operation and >= 60MHz for HS operation why is it called "bus_clk_otg0" not just simply "bus_clk". As far as I understand it (and see it in the TRM), you have two dwc3 controllers (otg0 and otg1) and clock-names are always meant from the perspective of the individual ip-block. So a devicetree would have: usbdrd3_0: usb@fe80 { compatible = "rockchip,rk3399-dwc3"; clocks = <&cru SCLK_USB3OTG0_REF>, <&cru SCLK_USB3OTG0_SUSPEND>, <&cru ACLK_USB3OTG0>, <&cru ACLK_USB3_GRF>; clock-names = "ref_clk", "suspend_clk", "bus_clk", "grf_clk"; ... }; usbdrd3_1: usb@fe90 { compatible = "rockchip,rk3399-dwc3"; clocks = <&cru SCLK_USB3OTG1_REF>, <&cru SCLK_USB3OTG1_SUSPEND>, <&cru ACLK_USB3OTG1>, <&cru ACLK_USB3_GRF>; clock-names = "ref_clk", "suspend_clk", "bus_clk", "grf_clk"; ... }; The rest looks really nice now. Heiko > + "grf_clk" Controller grf clk > + > +Required child node: > +A child node must exist to represent the core DWC3 IP block. The name of > +the node is not important. The content of the node is defined in > dwc3.txt. + > +Phy documentation is provided in the following places: > +Documentation/devicetree/bindings/phy/rockchip,dwc3-usb-phy.txt > + > +Example device nodes: > + > + usbdrd3_0: usb@fe80 { > + compatible = "rockchip,rk3399-dwc3"; > + clocks = <&cru SCLK_USB3OTG0_REF>, <&cru SCLK_USB3OTG0_SUSPEND>, > + <&cru ACLK_USB3OTG0>, <&cru ACLK_USB3_GRF>; > + clock-names = "ref_clk", "suspend_clk", > + "bus_clk_otg0", "grf_clk"; > + #address-cells = <2>; > + #size-cells = <2>; > + ranges; > + status = "disabled"; > + usbdrd_dwc3_0: dwc3@fe80 { > + compatible = "snps,dwc3"; > + reg = <0x0 0xfe80 0x0 0x10>; > + interrupts = ; > + dr_mode = "otg"; > + status = "disabled"; > + }; > + }; > -- > 1.9.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
[PATCH] xhci: free the correct ring
gcc warns about what first looks like a reference to an uninitialized variable: drivers/usb/host/xhci-ring.c: In function 'handle_cmd_completion': drivers/usb/host/xhci-ring.c:753:4: error: 'ep_ring' may be used uninitialized in this function [-Werror=maybe-uninitialized] xhci_unmap_td_bounce_buffer(xhci, ep_ring, cur_td); ^~ drivers/usb/host/xhci-ring.c:647:20: note: 'ep_ring' was declared here struct xhci_ring *ep_ring; ^~~ It's clear to see that the list_empty() check means it can never be uninitialized, however it still looks wrong: When ep->cancelled_td_list contains more than one entry, the ep_ring variable will point to the ring that was retrieved from the last urb, and we have to look it up again in the second loop instead, which fixes the behavior and gets rid of the warning too. Signed-off-by: Arnd Bergmann Fixes: f9c589e142d0 ("xhci: TD-fragment, align the unsplittable case with a bounce buffer") --- drivers/usb/host/xhci-ring.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 21e1dd62ebf8..918e0c739b79 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -749,6 +749,7 @@ remove_finished_td: /* Doesn't matter what we pass for status, since the core will * just overwrite it (because the URB has been unlinked). */ + ep_ring = xhci_urb_to_transfer_ring(xhci, cur_td->urb); if (ep_ring && cur_td->bounce_seg) xhci_unmap_td_bounce_buffer(xhci, ep_ring, cur_td); xhci_giveback_urb_in_irq(xhci, cur_td, 0); -- 2.9.0 -- 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: host: Allow EHCI_OMAP to be built-in when USB_GADGET is 'm'
Hi Felipe, On 30/06/16 13:14, Felipe Balbi wrote: > > Hi, > > Roger Quadros writes: >> NOP_USB_XCEIV is used not only by gadget drivers but by >> host drivers as well e.g. EHCI_OMAP. >> >> commit 5a8d651a2bde ("usb: gadget: move gadget API functions to udc-core") >> made it so that NOP_USB_XCEIV can't be built-in if USB_GADGET is 'm'. >> But this prevents EHCI_OMAP to be built-in if USB_GADGET is 'm'. >> >> Fix this undesired behaviour by moving usb_gadget_vbus_connect/disconnect() >> to usb/gadget.h so that NOP_USB_XCEIV has no build dependency >> on USB_GADGET. >> >> Retain the original Kconfig behaviour i.e. NOP_USB_XCEIV is selected >> by drivers that need it. > > no, this is the wrong way to fix this. NOP _has_ a dependency on the > Gadget API if it calls Gadget API functions. Dependencies are proper. > > Maybe the reason for the problem is that we ended up adding far too much > code to phy-generic.c itself. Maybe it shouldn't know about clks and > interrupts. The original idea of that driver was to simply satisfy a > requirement to have a valid transceiver by some platforms. Maybe we > should fix that instead. Moving functions around to workaround a problem > is not the way to go, sorry. > OK but something that was working all these years is broken by your patch. Do you mind fixing it please? Or at least let me know how you want to get it fixed. 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 3/3] dt-bindings: Document the STM32 USB OTG DWC2 core binding
On Wed, Jun 29, 2016 at 03:56:23PM -0300, Bruno Herrera wrote: > On Tue, Jun 28, 2016 at 5:54 PM, Rob Herring wrote: > > On Fri, Jun 24, 2016 at 03:51:18PM -0300, Bruno Herrera wrote: > >> On Fri, Jun 24, 2016 at 12:41 PM, Rob Herring wrote: > >> > On Tue, Jun 21, 2016 at 11:25:49PM -0300, Bruno Herrera wrote: > >> >> Signed-off-by: Bruno Herrera > >> >> --- > >> >> Documentation/devicetree/bindings/usb/dwc2.txt | 1 + > >> >> 1 file changed, 1 insertion(+) > >> >> > >> >> diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt > >> >> b/Documentation/devicetree/bindings/usb/dwc2.txt > >> >> index 20a68bf..79e5370 100644 > >> >> --- a/Documentation/devicetree/bindings/usb/dwc2.txt > >> >> +++ b/Documentation/devicetree/bindings/usb/dwc2.txt > >> >> @@ -11,6 +11,7 @@ Required properties: > >> >>- "lantiq,arx100-usb": The DWC2 USB controller instance in Lantiq > >> >> ARX SoCs; > >> >>- "lantiq,xrx200-usb": The DWC2 USB controller instance in Lantiq > >> >> XRX SoCs; > >> >>- snps,dwc2: A generic DWC2 USB controller with default parameters. > >> >> + - st,stm32-fsotg: The DWC2 USB controller instance in STM32F4 SoCs > >> >> in FS mode; > >> > > >> > This should go above snps,dwc2. > >> > > >> Ok, tks! > >> > >> > What determines FS mode vs. HS? > >> > > >> Its more HW design decision. > >> STM32F429/439/469 has two OTG controllers, one that is FS (internal > >> phy) and other that is HS (but can also work in FS mode with > >> internal/external phy) > >> This bind work with both cores FS and HS working with the internal PHY. > >> > >> I tested the following configurations: > >> 1 - STM32F429I-DISCOv1 board (OTG HS working in FS mode internal PHY) > >> 2 - STM32F469I-DISCO board (OTG FS) > >> > >> I did not tested OTG HS core working in FS mode with external PHY (I2C). > > > > You shouldn't be setting the compatible string based on which mode you > > want. So for the HS block, you need a different compatible string than > > the FS block and set the speed in another way (not sure if we have a > > standard way). Or perhaps the phy should determine the speed. > > I understand but I dont see how to fix it properly unless we add a > some specific STM32 properties in the DT or in the dwc2_core_params. > In fact there are two cores, and they are different in terms of > functionality (despite of the type of the PHY). > One core is for FS and other is for HS, so they could/should have > different compatible strings because they have different > configurations and are different piece of IP/Hardware(The buffer size > are different, the number of end points and so one, DMA) Then it is perfectly fine to have 2 compatible strings: one for the FS block and one for the HS block. > > But the problem is that the HS core can also support the the FS mode > and in this case is misleading to have a HS core with an FS compatible > string. But as you said, there are other differences in the 2 blocks, so just changing to the FS compatible string would not work. You could just have a high-speed-disable property or something, but look thru existing bindings and see if one exists already. If not, propose a common one. > Something like that (real case for STM32F429I-DISCO): > > &usbotg_hs { > compatible = "st,stm32-fsotg", "snps,dwc2"; > dr_mode = "host"; > pinctrl-0 = <&usbotg_fs_pins_b>; > pinctrl-names = "default"; > status = "okay"; > }; > > Even if the decision is phy based it would lead to a STM32 specific > logic and we would need to figure out how to represent the internal > PHY. Most SoCs end up describing the phys at least for USB 2 and 3 as they vary a lot eventhough everyone licenses one of the few IP blocks. Rob -- 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] xhci: free the correct ring
On 30.06.2016 15:26, Arnd Bergmann wrote: gcc warns about what first looks like a reference to an uninitialized variable: drivers/usb/host/xhci-ring.c: In function 'handle_cmd_completion': drivers/usb/host/xhci-ring.c:753:4: error: 'ep_ring' may be used uninitialized in this function [-Werror=maybe-uninitialized] xhci_unmap_td_bounce_buffer(xhci, ep_ring, cur_td); ^~ drivers/usb/host/xhci-ring.c:647:20: note: 'ep_ring' was declared here struct xhci_ring *ep_ring; ^~~ It's clear to see that the list_empty() check means it can never be uninitialized, however it still looks wrong: When ep->cancelled_td_list contains more than one entry, the ep_ring variable will point to the ring that was retrieved from the last urb, and we have to look it up again in the second loop instead, which fixes the behavior and gets rid of the warning too. Signed-off-by: Arnd Bergmann Fixes: f9c589e142d0 ("xhci: TD-fragment, align the unsplittable case with a bounce buffer") --- drivers/usb/host/xhci-ring.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 21e1dd62ebf8..918e0c739b79 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -749,6 +749,7 @@ remove_finished_td: /* Doesn't matter what we pass for status, since the core will * just overwrite it (because the URB has been unlinked). */ + ep_ring = xhci_urb_to_transfer_ring(xhci, cur_td->urb); if (ep_ring && cur_td->bounce_seg) xhci_unmap_td_bounce_buffer(xhci, ep_ring, cur_td); xhci_giveback_urb_in_irq(xhci, cur_td, 0); Thanks, Acked-by: Mathias Nyman In most cases each endpoint has only one ring and one list of canceled TDs, so each TD on a cancelled_td_list is for the same ring. But with streams in use that might no longer be the case. This does ensure that the streams work properly. Greg, any chance to get this into usb-next and 4.8? -Mathias -- 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 16/21] usb: chipidea: msm: Restore wrapper settings after reset
On 30 June 2016 at 01:54, Peter Chen wrote: > On Wed, Jun 29, 2016 at 12:13:45PM -0700, Stephen Boyd wrote: >> Quoting Peter Chen (2016-06-29 01:26:48 >> > Why not using ci->platdata->vbus_extcon directly? >> >> Because ci->platdata->vbus_extcon is assigned after the child platform >> driver probes, and we have no idea when that will happen from the >> ci_hdrc_msm driver probe. If we try after ci_hdrc_add_device() we'll >> race with the driver probe and only get the pointer sometimes. > > ci->platdata->vbus_extcon->edev is assigned at ci_get_platdata which is > called before ci core device is created. > Ok. -- 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: [PATCHv4 1/2] usb: USB Type-C connector class
On Wed, Jun 29, 2016 at 04:38:37PM +0300, Heikki Krogerus wrote: > The purpose of USB Type-C connector class is to provide > unified interface for the user space to get the status and > basic information about USB Type-C connectors on a system, > control over data role swapping, and when the port supports > USB Power Delivery, also control over power role swapping > and Alternate Modes. > > Signed-off-by: Heikki Krogerus > --- [ ... ] > + > +What: > /sys/class/typec/-partner/supports_usb_power_delivery > +Date:June 2016 > +Contact: Heikki Krogerus > +Description: > + Shows if the partner supports USB Power Delivery. > + - 1 if USB Power Delivery is supported > + - 0 when it's not > + > + > +What:/sys/class/typec/-partner/id_header_vdo > +Date:June 2016 > +Contact: Heikki Krogerus > +Description: > + If the partner supports USB Power Deliver, shows the VDO > + returned from Discover Identity USB Power Delivery command. > + > + If the partner does not support USB Power Delivery, the > + attribute is hidden. > + On second thought, and after merging the code (and realizing that I don't get the raw data from the Type-C Port Manager), I am not sure if a raw attribute is that useful here. It also doesn't provide all information either. Would it make sense to split it into multiple decoded attributes ? - vendor-id [bit 0..15 of ID header VDO] - product-type (undefined, hub, peripheral, alternate mode adapter for ufp; passive/active for cable plugs) Might map into typec_partner_type, but I don't see a 1:1 match. [bit 27..29 of ID header VDO] - alternate-mode-supported [bit 26 of ID header VDO] - capabilities (ufp, dfp, drp, none (?)) [bit 30/31 of ID header VDO] - product-id [bit 16..31 of Product VDO] Does this make any sense ? Thanks, Guenter -- 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 05/12] usb: musb: add tracepoints to dump interrupt events
This adds tracepoints to dump musb interrupt events. Signed-off-by: Bin Liu --- drivers/usb/musb/musb_core.c | 4 +--- drivers/usb/musb/musb_trace.h | 21 + 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index c0c81ae..74fc306 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1588,9 +1588,7 @@ irqreturn_t musb_interrupt(struct musb *musb) devctl = musb_readb(musb->mregs, MUSB_DEVCTL); - dev_dbg(musb->controller, "** IRQ %s usb%04x tx%04x rx%04x\n", - is_host_active(musb) ? "host" : "peripheral", - musb->int_usb, musb->int_tx, musb->int_rx); + trace_musb_isr(musb); /** * According to Mentor Graphics' documentation, flowchart on page 98, diff --git a/drivers/usb/musb/musb_trace.h b/drivers/usb/musb/musb_trace.h index c974f48..98acc1e 100644 --- a/drivers/usb/musb/musb_trace.h +++ b/drivers/usb/musb/musb_trace.h @@ -128,6 +128,27 @@ DEFINE_EVENT(musb_regl, musb_writel, TP_ARGS(caller, addr, offset, data) ); +TRACE_EVENT(musb_isr, + TP_PROTO(struct musb *musb), + TP_ARGS(musb), + TP_STRUCT__entry( + __string(name, dev_name(musb->controller)) + __field(u8, int_usb) + __field(u16, int_tx) + __field(u16, int_rx) + ), + TP_fast_assign( + __assign_str(name, dev_name(musb->controller)); + __entry->int_usb = musb->int_usb; + __entry->int_tx = musb->int_tx; + __entry->int_rx = musb->int_rx; + ), + TP_printk("%s: usb %02x, tx %04x, rx %04x", + __get_str(name), __entry->int_usb, + __entry->int_tx, __entry->int_rx + ) +); + #endif /* __MUSB_TRACE_H */ /* this part has to be here */ -- 1.9.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
[PATCH 03/12] usb: musb: dsps: use musb register read/write wrappers instead
musb core already exports the register read/write wrappers, so clean up the duplication in dsps glue. Signed-off-by: Bin Liu --- drivers/usb/musb/musb_dsps.c | 112 +-- 1 file changed, 44 insertions(+), 68 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index eeb7d9e..2537179 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -52,30 +52,6 @@ static const struct of_device_id musb_dsps_of_match[]; /** - * avoid using musb_readx()/musb_writex() as glue layer should not be - * dependent on musb core layer symbols. - */ -static inline u8 dsps_readb(const void __iomem *addr, unsigned offset) -{ - return __raw_readb(addr + offset); -} - -static inline u32 dsps_readl(const void __iomem *addr, unsigned offset) -{ - return __raw_readl(addr + offset); -} - -static inline void dsps_writeb(void __iomem *addr, unsigned offset, u8 data) -{ - __raw_writeb(data, addr + offset); -} - -static inline void dsps_writel(void __iomem *addr, unsigned offset, u32 data) -{ - __raw_writel(data, addr + offset); -} - -/** * DSPS musb wrapper register offset. * FIXME: This should be expanded to have all the wrapper registers from TI DSPS * musb ips. @@ -223,8 +199,8 @@ static void dsps_musb_enable(struct musb *musb) ((musb->epmask & wrp->rxep_mask) << wrp->rxep_shift); coremask = (wrp->usb_bitmap & ~MUSB_INTR_SOF); - dsps_writel(reg_base, wrp->epintr_set, epmask); - dsps_writel(reg_base, wrp->coreintr_set, coremask); + musb_writel(reg_base, wrp->epintr_set, epmask); + musb_writel(reg_base, wrp->coreintr_set, coremask); /* start polling for ID change in dual-role idle mode */ if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) @@ -244,10 +220,10 @@ static void dsps_musb_disable(struct musb *musb) const struct dsps_musb_wrapper *wrp = glue->wrp; void __iomem *reg_base = musb->ctrl_base; - dsps_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap); - dsps_writel(reg_base, wrp->epintr_clear, + musb_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap); + musb_writel(reg_base, wrp->epintr_clear, wrp->txep_bitmap | wrp->rxep_bitmap); - dsps_writeb(musb->mregs, MUSB_DEVCTL, 0); + musb_writeb(musb->mregs, MUSB_DEVCTL, 0); } static void otg_timer(unsigned long _musb) @@ -265,14 +241,14 @@ static void otg_timer(unsigned long _musb) * We poll because DSPS IP's won't expose several OTG-critical * status change events (from the transceiver) otherwise. */ - devctl = dsps_readb(mregs, MUSB_DEVCTL); + devctl = musb_readb(mregs, MUSB_DEVCTL); dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl, usb_otg_state_string(musb->xceiv->otg->state)); spin_lock_irqsave(&musb->lock, flags); switch (musb->xceiv->otg->state) { case OTG_STATE_A_WAIT_BCON: - dsps_writeb(musb->mregs, MUSB_DEVCTL, 0); + musb_writeb(musb->mregs, MUSB_DEVCTL, 0); skip_session = 1; /* fall */ @@ -286,13 +262,13 @@ static void otg_timer(unsigned long _musb) MUSB_HST_MODE(musb); } if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session) - dsps_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION); + musb_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION); mod_timer(&glue->timer, jiffies + msecs_to_jiffies(wrp->poll_timeout)); break; case OTG_STATE_A_WAIT_VFALL: musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; - dsps_writel(musb->ctrl_base, wrp->coreintr_set, + musb_writel(musb->ctrl_base, wrp->coreintr_set, MUSB_INTR_VBUSERROR << wrp->usb_shift); break; default: @@ -315,29 +291,29 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) spin_lock_irqsave(&musb->lock, flags); /* Get endpoint interrupts */ - epintr = dsps_readl(reg_base, wrp->epintr_status); + epintr = musb_readl(reg_base, wrp->epintr_status); musb->int_rx = (epintr & wrp->rxep_bitmap) >> wrp->rxep_shift; musb->int_tx = (epintr & wrp->txep_bitmap) >> wrp->txep_shift; if (epintr) - dsps_writel(reg_base, wrp->epintr_status, epintr); + musb_writel(reg_base, wrp->epintr_status, epintr); /* Get usb core interrupts */ - usbintr = dsps_readl(reg_base, wrp->coreintr_status); + usbintr = musb_readl(reg_base, wrp->coreintr_status); if (!usbintr && !epintr) goto out; musb->int_usb = (usbintr & wrp->usb_bitmap) >> wrp->u
[PATCH v2 02/12] usb: musb: switch dev_dbg to tracepoints
Switch dev_dbg() to tracepoint debug musb_dbg(). Signed-off-by: Bin Liu --- drivers/usb/musb/cppi_dma.c| 50 + drivers/usb/musb/musb_core.c | 64 +++--- drivers/usb/musb/musb_cppi41.c | 12 ++--- drivers/usb/musb/musb_gadget.c | 97 - drivers/usb/musb/musb_gadget_ep0.c | 22 drivers/usb/musb/musb_host.c | 107 ++--- drivers/usb/musb/musb_virthub.c| 24 - drivers/usb/musb/musbhsdma.c | 10 ++-- 8 files changed, 187 insertions(+), 199 deletions(-) diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c index cc13410..5da93ec 100644 --- a/drivers/usb/musb/cppi_dma.c +++ b/drivers/usb/musb/cppi_dma.c @@ -232,7 +232,7 @@ static void cppi_controller_stop(struct cppi *controller) musb_writel(tibase, DAVINCI_RXCPPI_INTCLR_REG, DAVINCI_DMA_ALL_CHANNELS_ENABLE); - dev_dbg(musb->controller, "Tearing down RX and TX Channels\n"); + musb_dbg(musb, "Tearing down RX and TX Channels"); for (i = 0; i < ARRAY_SIZE(controller->tx); i++) { /* FIXME restructure of txdma to use bds like rxdma */ controller->tx[i].last_processed = NULL; @@ -297,13 +297,13 @@ cppi_channel_allocate(struct dma_controller *c, */ if (transmit) { if (index >= ARRAY_SIZE(controller->tx)) { - dev_dbg(musb->controller, "no %cX%d CPPI channel\n", 'T', index); + musb_dbg(musb, "no %cX%d CPPI channel", 'T', index); return NULL; } cppi_ch = controller->tx + index; } else { if (index >= ARRAY_SIZE(controller->rx)) { - dev_dbg(musb->controller, "no %cX%d CPPI channel\n", 'R', index); + musb_dbg(musb, "no %cX%d CPPI channel", 'R', index); return NULL; } cppi_ch = controller->rx + index; @@ -314,13 +314,13 @@ cppi_channel_allocate(struct dma_controller *c, * with the other DMA engine too */ if (cppi_ch->hw_ep) - dev_dbg(musb->controller, "re-allocating DMA%d %cX channel %p\n", + musb_dbg(musb, "re-allocating DMA%d %cX channel %p", index, transmit ? 'T' : 'R', cppi_ch); cppi_ch->hw_ep = ep; cppi_ch->channel.status = MUSB_DMA_STATUS_FREE; cppi_ch->channel.max_len = 0x7fff; - dev_dbg(musb->controller, "Allocate CPPI%d %cX\n", index, transmit ? 'T' : 'R'); + musb_dbg(musb, "Allocate CPPI%d %cX", index, transmit ? 'T' : 'R'); return &cppi_ch->channel; } @@ -335,8 +335,8 @@ static void cppi_channel_release(struct dma_channel *channel) c = container_of(channel, struct cppi_channel, channel); tibase = c->controller->tibase; if (!c->hw_ep) - dev_dbg(c->controller->musb->controller, - "releasing idle DMA channel %p\n", c); + musb_dbg(c->controller->musb, + "releasing idle DMA channel %p", c); else if (!c->transmit) core_rxirq_enable(tibase, c->index + 1); @@ -354,11 +354,10 @@ cppi_dump_rx(int level, struct cppi_channel *c, const char *tag) musb_ep_select(base, c->index + 1); - dev_dbg(c->controller->musb->controller, + musb_dbg(c->controller->musb, "RX DMA%d%s: %d left, csr %04x, " "%08x H%08x S%08x C%08x, " - "B%08x L%08x %08x .. %08x" - "\n", + "B%08x L%08x %08x .. %08x", c->index, tag, musb_readl(c->controller->tibase, DAVINCI_RXCPPI_BUFCNT0_REG + 4 * c->index), @@ -385,11 +384,10 @@ cppi_dump_tx(int level, struct cppi_channel *c, const char *tag) musb_ep_select(base, c->index + 1); - dev_dbg(c->controller->musb->controller, + musb_dbg(c->controller->musb, "TX DMA%d%s: csr %04x, " "H%08x S%08x C%08x %08x, " - "F%08x L%08x .. %08x" - "\n", + "F%08x L%08x .. %08x", c->index, tag, musb_readw(c->hw_ep->regs, MUSB_TXCSR), @@ -590,7 +588,7 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx) length = min(n_bds * maxpacket, length); } - dev_dbg(musb->controller, "TX DMA%d, pktSz %d %s bds %d dma 0x%llx len %u\n", + musb_dbg(musb, "TX DMA%d, pktSz %d %s bds %d dma 0x%llx len %u", tx->index, maxpacket, rndis ? "rndis" : "transparent", @@ -647,7 +645,7 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx) bd->hw_options |= CPPI_ZERO_SET; }
[PATCH 04/12] usb: musb: add tracepoints for register access
This adds tracepoints to musb register read/write wrappers to get trace log for register access. The default tacepoint log prefix here would be musb_readX/writeX(), which is not much helpful. So this patch let the tracepoints use __buildin_return_address(0) to print the caller funciton name to provide more context of the register access. Signed-off-by: Bin Liu --- drivers/usb/musb/musb_core.c | 19 -- drivers/usb/musb/musb_trace.h | 87 +++ 2 files changed, 103 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index d2bc45c..c0c81ae 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -102,6 +102,7 @@ #include #include "musb_core.h" +#include "musb_trace.h" #define TA_WAIT_BCON(m) max_t(int, (m)->a_wait_bcon, OTG_TIME_A_WAIT_BCON) @@ -258,31 +259,43 @@ static u32 musb_default_busctl_offset(u8 epnum, u16 offset) static u8 musb_default_readb(const void __iomem *addr, unsigned offset) { - return __raw_readb(addr + offset); + u8 data = __raw_readb(addr + offset); + + trace_musb_readb(__builtin_return_address(0), addr, offset, data); + return data; } static void musb_default_writeb(void __iomem *addr, unsigned offset, u8 data) { + trace_musb_writeb(__builtin_return_address(0), addr, offset, data); __raw_writeb(data, addr + offset); } static u16 musb_default_readw(const void __iomem *addr, unsigned offset) { - return __raw_readw(addr + offset); + u16 data = __raw_readw(addr + offset); + + trace_musb_readw(__builtin_return_address(0), addr, offset, data); + return data; } static void musb_default_writew(void __iomem *addr, unsigned offset, u16 data) { + trace_musb_writew(__builtin_return_address(0), addr, offset, data); __raw_writew(data, addr + offset); } static u32 musb_default_readl(const void __iomem *addr, unsigned offset) { - return __raw_readl(addr + offset); + u32 data = __raw_readl(addr + offset); + + trace_musb_readl(__builtin_return_address(0), addr, offset, data); + return data; } static void musb_default_writel(void __iomem *addr, unsigned offset, u32 data) { + trace_musb_writel(__builtin_return_address(0), addr, offset, data); __raw_writel(data, addr + offset); } diff --git a/drivers/usb/musb/musb_trace.h b/drivers/usb/musb/musb_trace.h index c6c593e..c974f48 100644 --- a/drivers/usb/musb/musb_trace.h +++ b/drivers/usb/musb/musb_trace.h @@ -41,6 +41,93 @@ TRACE_EVENT(musb_log, TP_printk("%s: %s", __get_str(name), __get_str(msg)) ); +DECLARE_EVENT_CLASS(musb_regb, + TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data), + TP_ARGS(caller, addr, offset, data), + TP_STRUCT__entry( + __field(void *, caller) + __field(const void *, addr) + __field(unsigned int, offset) + __field(u8, data) + ), + TP_fast_assign( + __entry->caller = caller; + __entry->addr = addr; + __entry->offset = offset; + __entry->data = data; + ), + TP_printk("%pS: %p + %04x: %02x", + __entry->caller, __entry->addr, __entry->offset, __entry->data) +); + +DEFINE_EVENT(musb_regb, musb_readb, + TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data), + TP_ARGS(caller, addr, offset, data) +); + +DEFINE_EVENT(musb_regb, musb_writeb, + TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data), + TP_ARGS(caller, addr, offset, data) +); + +DECLARE_EVENT_CLASS(musb_regw, + TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data), + TP_ARGS(caller, addr, offset, data), + TP_STRUCT__entry( + __field(void *, caller) + __field(const void *, addr) + __field(unsigned int, offset) + __field(u16, data) + ), + TP_fast_assign( + __entry->caller = caller; + __entry->addr = addr; + __entry->offset = offset; + __entry->data = data; + ), + TP_printk("%pS: %p + %04x: %04x", + __entry->caller, __entry->addr, __entry->offset, __entry->data) +); + +DEFINE_EVENT(musb_regw, musb_readw, + TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data), + TP_ARGS(caller, addr, offset, data) +); + +DEFINE_EVENT(musb_regw, musb_writew, + TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data), + TP_ARGS(caller, addr, offset, data) +); + +DECLARE_EVENT_CLASS(musb_regl, + TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data), + TP_ARGS(caller, addr, offset, data), + TP_STRUCT__entry( + __field(void *, caller) + __field(const void *, addr) +
[PATCH 06/12] usb: musb: host: add urb tracepoints
Add urb tracepoints for host mode. Signed-off-by: Bin Liu --- drivers/usb/musb/musb_host.c | 34 ++- drivers/usb/musb/musb_trace.h | 63 +++ 2 files changed, 71 insertions(+), 26 deletions(-) diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 7601ada..53bc4ce 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -44,6 +44,7 @@ #include "musb_core.h" #include "musb_host.h" +#include "musb_trace.h" /* MUSB HOST status 22-mar-2006 * @@ -225,8 +226,6 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) void*buf = urb->transfer_buffer; u32 offset = 0; struct musb_hw_ep *hw_ep = qh->hw_ep; - unsignedpipe = urb->pipe; - u8 address = usb_pipedevice(pipe); int epnum = hw_ep->epnum; /* initialize software qh state */ @@ -254,16 +253,7 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) len = urb->transfer_buffer_length - urb->actual_length; } - musb_dbg(musb, "qh %p urb %p dev%d ep%d%s%s, hw_ep %d, %p/%d", - qh, urb, address, qh->epnum, - is_in ? "in" : "out", - ({char *s; switch (qh->type) { - case USB_ENDPOINT_XFER_CONTROL: s = ""; break; - case USB_ENDPOINT_XFER_BULK:s = "-bulk"; break; - case USB_ENDPOINT_XFER_ISOC:s = "-iso"; break; - default:s = "-intr"; break; - } s; }), - epnum, buf + offset, len); + trace_musb_urb_start(musb, urb); /* Configure endpoint */ musb_ep_set_qh(hw_ep, is_in, qh); @@ -314,13 +304,7 @@ static void musb_giveback(struct musb *musb, struct urb *urb, int status) __releases(musb->lock) __acquires(musb->lock) { - musb_dbg(musb, "complete %p %pF (%d), dev%d ep%d%s, %d/%d", - urb, urb->complete, status, - usb_pipedevice(urb->pipe), - usb_pipeendpoint(urb->pipe), - usb_pipein(urb->pipe) ? "in" : "out", - urb->actual_length, urb->transfer_buffer_length - ); + trace_musb_urb_gb(musb, urb); usb_hcd_unlink_urb_from_ep(musb->hcd, urb); spin_unlock(&musb->lock); @@ -1296,6 +1280,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) pipe = urb->pipe; dma = is_dma_capable() ? hw_ep->tx_channel : NULL; + trace_musb_urb_tx(musb, urb); musb_dbg(musb, "OUT/TX%d end, csr %04x%s", epnum, tx_csr, dma ? ", dma" : ""); @@ -1853,9 +1838,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) pipe = urb->pipe; - musb_dbg(musb, "<== hw %d rxcsr %04x, urb actual %d (+dma %zu)", - epnum, rx_csr, urb->actual_length, - dma ? dma->actual_len : 0); + trace_musb_urb_rx(musb, urb); /* check for errors, concurrent stall & unlink is not really * handled yet! */ @@ -2208,6 +2191,8 @@ static int musb_urb_enqueue( if (!is_host_active(musb) || !musb->is_active) return -ENODEV; + trace_musb_urb_enq(musb, urb); + spin_lock_irqsave(&musb->lock, flags); ret = usb_hcd_link_urb_to_ep(hcd, urb); qh = ret ? NULL : hep->hcpriv; @@ -2444,10 +2429,7 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) int is_in = usb_pipein(urb->pipe); int ret; - musb_dbg(musb, "urb=%p, dev%d ep%d%s", urb, - usb_pipedevice(urb->pipe), - usb_pipeendpoint(urb->pipe), - is_in ? "in" : "out"); + trace_musb_urb_deq(musb, urb); spin_lock_irqsave(&musb->lock, flags); ret = usb_hcd_check_unlink_urb(hcd, urb, status); diff --git a/drivers/usb/musb/musb_trace.h b/drivers/usb/musb/musb_trace.h index 98acc1e..39258f6 100644 --- a/drivers/usb/musb/musb_trace.h +++ b/drivers/usb/musb/musb_trace.h @@ -23,6 +23,7 @@ #include #include +#include #include "musb_core.h" #define MUSB_MSG_MAX 500 @@ -149,6 +150,68 @@ TRACE_EVENT(musb_isr, ) ); +DECLARE_EVENT_CLASS(musb_urb, + TP_PROTO(struct musb *musb, struct urb *urb), + TP_ARGS(musb, urb), + TP_STRUCT__entry( + __string(name, dev_name(musb->controller)) + __field(struct urb *, urb) + __field(unsigned int, pipe) + __field(int, status) + __field(unsigned int, flag) + __field(u32, buf_len) + __field(u32, actual_len) + ), + TP_fast_assign( + __assign_
[PATCH 01/12] usb: musb: add tracepoints support for debugging
To avoid printk() overhead while debugging, this patch implements the foundation of tracepoints logging for musb driver to make debug easier. Signed-off-by: Bin Liu --- drivers/usb/musb/Makefile | 5 +++- drivers/usb/musb/musb_debug.h | 2 ++ drivers/usb/musb/musb_trace.c | 33 ++ drivers/usb/musb/musb_trace.h | 54 +++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb/musb_trace.c create mode 100644 drivers/usb/musb/musb_trace.h diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index f95befe..689d42a 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -2,9 +2,12 @@ # for USB OTG silicon based on Mentor Graphics INVENTRA designs # +# define_trace.h needs to know how to find our header +CFLAGS_musb_trace.o:= -I$(src) + obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o -musb_hdrc-y := musb_core.o +musb_hdrc-y := musb_core.o musb_trace.o musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_virthub.o musb_host.o musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_gadget_ep0.o musb_gadget.o diff --git a/drivers/usb/musb/musb_debug.h b/drivers/usb/musb/musb_debug.h index 27ba8f7..9a78877a 100644 --- a/drivers/usb/musb/musb_debug.h +++ b/drivers/usb/musb/musb_debug.h @@ -42,6 +42,8 @@ #define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args) #define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args) +void musb_dbg(struct musb *musb, const char *fmt, ...); + #ifdef CONFIG_DEBUG_FS int musb_init_debugfs(struct musb *musb); void musb_exit_debugfs(struct musb *musb); diff --git a/drivers/usb/musb/musb_trace.c b/drivers/usb/musb/musb_trace.c new file mode 100644 index 000..70973d9 --- /dev/null +++ b/drivers/usb/musb/musb_trace.c @@ -0,0 +1,33 @@ +/* + * musb_trace.c - MUSB Controller Trace Support + * + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com + * + * Author: Bin Liu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 of + * the License 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. + */ + +#define CREATE_TRACE_POINTS +#include "musb_trace.h" + +void musb_dbg(struct musb *musb, const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + + va_start(args, fmt); + vaf.fmt = fmt; + vaf.va = &args; + + trace_musb_log(musb, &vaf); + + va_end(args); +} diff --git a/drivers/usb/musb/musb_trace.h b/drivers/usb/musb/musb_trace.h new file mode 100644 index 000..c6c593e --- /dev/null +++ b/drivers/usb/musb/musb_trace.h @@ -0,0 +1,54 @@ +/* + * musb_trace.h - MUSB Controller Trace Support + * + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com + * + * Author: Bin Liu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 of + * the License 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. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM musb + +#if !defined(__MUSB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define __MUSB_TRACE_H + +#include +#include +#include "musb_core.h" + +#define MUSB_MSG_MAX 500 + +TRACE_EVENT(musb_log, + TP_PROTO(struct musb *musb, struct va_format *vaf), + TP_ARGS(musb, vaf), + TP_STRUCT__entry( + __string(name, dev_name(musb->controller)) + __dynamic_array(char, msg, MUSB_MSG_MAX) + ), + TP_fast_assign( + __assign_str(name, dev_name(musb->controller)); + vsnprintf(__get_str(msg), MUSB_MSG_MAX, vaf->fmt, *vaf->va); + ), + TP_printk("%s: %s", __get_str(name), __get_str(msg)) +); + +#endif /* __MUSB_TRACE_H */ + +/* this part has to be here */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . + +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE musb_trace + +#include -- 1.9.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
[PATCH v2 00/12] musb patches for v4.8-rc1
Hi Greg, This musb patch set is for next v4.8. It adds tracepoints to musb drivers to help debugging. This v2 is rebased on v4.7-rc4, to solve a merge conflict, and adds two more patches for musb sunxi glue layer. Please let me know if any change is needed. Regards, -Bin. --- Ben Dooks (1): usb: musb: sunxi: make unexported symbols static Bin Liu (10): usb: musb: add tracepoints support for debugging usb: musb: switch dev_dbg to tracepoints usb: musb: dsps: use musb register read/write wrappers instead usb: musb: add tracepoints for register access usb: musb: add tracepoints to dump interrupt events usb: musb: host: add urb tracepoints usb: musb: gadget: add usb-request tracepoints usb: musb: cleanup cppi_dma header usb: musb: cppi41: move struct cppi41_dma_channel to header usb: musb: cppi41: add dma channel tracepoints Hans de Goede (1): usb: musb: sunxi: Simplify dr_mode handling drivers/usb/musb/Makefile | 5 +- drivers/usb/musb/cppi_dma.c| 51 +++-- drivers/usb/musb/cppi_dma.h| 31 +++- drivers/usb/musb/musb_core.c | 87 + drivers/usb/musb/musb_cppi41.c | 47 ++--- drivers/usb/musb/musb_debug.h | 2 + drivers/usb/musb/musb_dsps.c | 112 +-- drivers/usb/musb/musb_gadget.c | 122 ++-- drivers/usb/musb/musb_gadget_ep0.c | 22 +-- drivers/usb/musb/musb_host.c | 133 ++--- drivers/usb/musb/musb_trace.c | 33 drivers/usb/musb/musb_trace.h | 371 + drivers/usb/musb/musb_virthub.c| 24 ++- drivers/usb/musb/musbhsdma.c | 10 +- drivers/usb/musb/sunxi.c | 74 +++- 15 files changed, 729 insertions(+), 395 deletions(-) create mode 100644 drivers/usb/musb/musb_trace.c create mode 100644 drivers/usb/musb/musb_trace.h -- 1.9.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
[PATCH 08/12] usb: musb: cleanup cppi_dma header
davinci.h is not required by cppi_dma.h but cppi_dma.c, so move the include to the right place. Signed-off-by: Bin Liu --- drivers/usb/musb/cppi_dma.c | 1 + drivers/usb/musb/cppi_dma.h | 8 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c index 5da93ec..1ae48e6 100644 --- a/drivers/usb/musb/cppi_dma.c +++ b/drivers/usb/musb/cppi_dma.c @@ -14,6 +14,7 @@ #include "musb_core.h" #include "musb_debug.h" #include "cppi_dma.h" +#include "davinci.h" /* CPPI DMA status 7-mar-2006: diff --git a/drivers/usb/musb/cppi_dma.h b/drivers/usb/musb/cppi_dma.h index 59bf949..40c31ce 100644 --- a/drivers/usb/musb/cppi_dma.h +++ b/drivers/usb/musb/cppi_dma.h @@ -11,14 +11,6 @@ #include "musb_dma.h" #include "musb_core.h" - -/* FIXME fully isolate CPPI from DaVinci ... the "CPPI generic" registers - * would seem to be shared with the TUSB6020 (over VLYNQ). - */ - -#include "davinci.h" - - /* CPPI RX/TX state RAM */ struct cppi_tx_stateram { -- 1.9.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
[PATCH 10/12] usb: musb: cppi41: add dma channel tracepoints
Add tracepoints for cppi41 dma channels. Signed-off-by: Bin Liu --- drivers/usb/musb/musb_cppi41.c | 22 ++--- drivers/usb/musb/musb_trace.h | 70 ++ 2 files changed, 80 insertions(+), 12 deletions(-) diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index 602a230..d4d7c56 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -7,6 +7,7 @@ #include "cppi_dma.h" #include "musb_core.h" +#include "musb_trace.h" #define RNDIS_REG(x) (0x80 + ((x - 1) * 4)) @@ -126,6 +127,8 @@ static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel) csr = MUSB_TXCSR_MODE | MUSB_TXCSR_TXPKTRDY; musb_writew(epio, MUSB_TXCSR, csr); } + + trace_musb_cppi41_done(cppi41_channel); musb_dma_completion(musb, hw_ep->epnum, cppi41_channel->is_tx); } else { /* next iteration, reload */ @@ -154,6 +157,7 @@ static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel) dma_desc->callback = cppi41_dma_callback; dma_desc->callback_param = &cppi41_channel->channel; cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); + trace_musb_cppi41_cont(cppi41_channel); dma_async_issue_pending(dc); if (!cppi41_channel->is_tx) { @@ -221,10 +225,7 @@ static void cppi41_dma_callback(void *private_data) transferred = cppi41_channel->prog_len - txstate.residue; cppi41_channel->transferred += transferred; - musb_dbg(musb, "DMA transfer done on hw_ep=%d bytes=%d/%d", - hw_ep->epnum, cppi41_channel->transferred, - cppi41_channel->total_len); - + trace_musb_cppi41_gb(cppi41_channel); update_rx_toggle(cppi41_channel); if (cppi41_channel->transferred == cppi41_channel->total_len || @@ -355,12 +356,6 @@ static bool cppi41_configure_channel(struct dma_channel *channel, struct musb *musb = cppi41_channel->controller->musb; unsigned use_gen_rndis = 0; - musb_dbg(musb, - "configure ep%d/%x packet_sz=%d, mode=%d, dma_addr=0x%llx, len=%d is_tx=%d", - cppi41_channel->port_num, RNDIS_REG(cppi41_channel->port_num), - packet_sz, mode, (unsigned long long) dma_addr, - len, cppi41_channel->is_tx); - cppi41_channel->buf_addr = dma_addr; cppi41_channel->total_len = len; cppi41_channel->transferred = 0; @@ -412,6 +407,8 @@ static bool cppi41_configure_channel(struct dma_channel *channel, cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); cppi41_channel->channel.rx_packet_done = false; + trace_musb_cppi41_config(cppi41_channel); + save_rx_toggle(cppi41_channel); dma_async_issue_pending(dc); return true; @@ -442,6 +439,7 @@ static struct dma_channel *cppi41_dma_channel_allocate(struct dma_controller *c, cppi41_channel->hw_ep = hw_ep; cppi41_channel->is_allocated = 1; + trace_musb_cppi41_alloc(cppi41_channel); return &cppi41_channel->channel; } @@ -449,6 +447,7 @@ static void cppi41_dma_channel_release(struct dma_channel *channel) { struct cppi41_dma_channel *cppi41_channel = channel->private_data; + trace_musb_cppi41_free(cppi41_channel); if (cppi41_channel->is_allocated) { cppi41_channel->is_allocated = 0; channel->status = MUSB_DMA_STATUS_FREE; @@ -518,8 +517,7 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel) u16 csr; is_tx = cppi41_channel->is_tx; - musb_dbg(musb, "abort channel=%d, is_tx=%d", - cppi41_channel->port_num, is_tx); + trace_musb_cppi41_abort(cppi41_channel); if (cppi41_channel->channel.status == MUSB_DMA_STATUS_FREE) return 0; diff --git a/drivers/usb/musb/musb_trace.h b/drivers/usb/musb/musb_trace.h index 27d1a9b..f031c9e 100644 --- a/drivers/usb/musb/musb_trace.h +++ b/drivers/usb/musb/musb_trace.h @@ -25,6 +25,9 @@ #include #include #include "musb_core.h" +#ifdef CONFIG_USB_TI_CPPI41_DMA +#include "cppi_dma.h" +#endif #define MUSB_MSG_MAX 500 @@ -288,6 +291,73 @@ DEFINE_EVENT(musb_req, musb_req_deq, TP_ARGS(req) ); +#ifdef CONFIG_USB_TI_CPPI41_DMA +DECLARE_EVENT_CLASS(musb_cppi41, + TP_PROTO(struct cppi41_dma_channel *ch), + TP_ARGS(ch), + TP_STRUCT__entry( + __field(struct cppi41_dma_channel *, ch) + __string(name, dev_name(ch->hw_ep->musb->controller)) + __field(u8, hwep) + __field(u8, port) + __field(u8, is_tx) + __field(u32, len) + __field(u32, prog_len) + __field(u32, xferred) + ), + TP_fast_assign( + __entry->
[PATCH 09/12] usb: musb: cppi41: move struct cppi41_dma_channel to header
Move struct cppi41_dma_channel to the header file so other modules can use it. Signed-off-by: Bin Liu --- drivers/usb/musb/cppi_dma.h| 23 ++- drivers/usb/musb/musb_cppi41.c | 21 + 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/usb/musb/cppi_dma.h b/drivers/usb/musb/cppi_dma.h index 40c31ce..7fdfb71 100644 --- a/drivers/usb/musb/cppi_dma.h +++ b/drivers/usb/musb/cppi_dma.h @@ -7,9 +7,10 @@ #include #include #include +#include -#include "musb_dma.h" #include "musb_core.h" +#include "musb_dma.h" /* CPPI RX/TX state RAM */ @@ -123,4 +124,24 @@ struct cppi { /* CPPI IRQ handler */ extern irqreturn_t cppi_interrupt(int, void *); +struct cppi41_dma_channel { + struct dma_channel channel; + struct cppi41_dma_controller *controller; + struct musb_hw_ep *hw_ep; + struct dma_chan *dc; + dma_cookie_t cookie; + u8 port_num; + u8 is_tx; + u8 is_allocated; + u8 usb_toggle; + + dma_addr_t buf_addr; + u32 total_len; + u32 prog_len; + u32 transferred; + u32 packet_sz; + struct list_head tx_check; + int tx_zlp; +}; + #endif /* end of ifndef _CPPI_DMA_H_ */ diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index f7bad72..602a230 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -5,6 +5,7 @@ #include #include +#include "cppi_dma.h" #include "musb_core.h" #define RNDIS_REG(x) (0x80 + ((x - 1) * 4)) @@ -22,26 +23,6 @@ #define USB_CTRL_AUTOREQ 0xd0 #define USB_TDOWN 0xd8 -struct cppi41_dma_channel { - struct dma_channel channel; - struct cppi41_dma_controller *controller; - struct musb_hw_ep *hw_ep; - struct dma_chan *dc; - dma_cookie_t cookie; - u8 port_num; - u8 is_tx; - u8 is_allocated; - u8 usb_toggle; - - dma_addr_t buf_addr; - u32 total_len; - u32 prog_len; - u32 transferred; - u32 packet_sz; - struct list_head tx_check; - int tx_zlp; -}; - #define MUSB_DMA_NUM_CHANNELS 15 struct cppi41_dma_controller { -- 1.9.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
[PATCH 12/12] usb: musb: sunxi: Simplify dr_mode handling
From: Hans de Goede phy-sun4i-usb now has proper dr_mode handling, it always registers an extcon, and sends a notify with the mode (even when in peripheral- / host-only mode) at least once. So we can simply the sunxi musb glue by always registering its extcon notifier and relying on sunxi_musb_work() to enable vbus when in host-only mode. This also enables host- and peripheral-only mode with vbus monitoring. Tested-by: Maxime Ripard Signed-off-by: Hans de Goede Signed-off-by: Bin Liu --- drivers/usb/musb/sunxi.c | 68 ++-- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c index 8522081..c6ee166 100644 --- a/drivers/usb/musb/sunxi.c +++ b/drivers/usb/musb/sunxi.c @@ -256,12 +256,10 @@ static int sunxi_musb_init(struct musb *musb) writeb(SUNXI_MUSB_VEND0_PIO_MODE, musb->mregs + SUNXI_MUSB_VEND0); /* Register notifier before calling phy_init() */ - if (musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) { - ret = extcon_register_notifier(glue->extcon, EXTCON_USB_HOST, - &glue->host_nb); - if (ret) - goto error_reset_assert; - } + ret = extcon_register_notifier(glue->extcon, EXTCON_USB_HOST, + &glue->host_nb); + if (ret) + goto error_reset_assert; ret = phy_init(glue->phy); if (ret) @@ -275,9 +273,8 @@ static int sunxi_musb_init(struct musb *musb) return 0; error_unregister_notifier: - if (musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) - extcon_unregister_notifier(glue->extcon, EXTCON_USB_HOST, - &glue->host_nb); + extcon_unregister_notifier(glue->extcon, EXTCON_USB_HOST, + &glue->host_nb); error_reset_assert: if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) reset_control_assert(glue->rst); @@ -301,9 +298,8 @@ static int sunxi_musb_exit(struct musb *musb) phy_exit(glue->phy); - if (musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) - extcon_unregister_notifier(glue->extcon, EXTCON_USB_HOST, - &glue->host_nb); + extcon_unregister_notifier(glue->extcon, EXTCON_USB_HOST, + &glue->host_nb); if (test_bit(SUNXI_MUSB_FL_HAS_RESET, &glue->flags)) reset_control_assert(glue->rst); @@ -315,25 +311,6 @@ static int sunxi_musb_exit(struct musb *musb) return 0; } -static int sunxi_set_mode(struct musb *musb, u8 mode) -{ - struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); - int ret; - - if (mode == MUSB_HOST) { - ret = phy_power_on(glue->phy); - if (ret) - return ret; - - set_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); - /* Stop musb work from turning vbus off again */ - set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); - musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; - } - - return 0; -} - static void sunxi_musb_enable(struct musb *musb) { struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); @@ -582,7 +559,6 @@ static const struct musb_platform_ops sunxi_musb_ops = { .exit = sunxi_musb_exit, .enable = sunxi_musb_enable, .disable= sunxi_musb_disable, - .set_mode = sunxi_set_mode, .fifo_offset= sunxi_musb_fifo_offset, .ep_offset = sunxi_musb_ep_offset, .busctl_offset = sunxi_musb_busctl_offset, @@ -638,10 +614,6 @@ static int sunxi_musb_probe(struct platform_device *pdev) return -EINVAL; } - glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); - if (!glue) - return -ENOMEM; - memset(&pdata, 0, sizeof(pdata)); switch (usb_get_dr_mode(&pdev->dev)) { #if defined CONFIG_USB_MUSB_DUAL_ROLE || defined CONFIG_USB_MUSB_HOST @@ -649,15 +621,13 @@ static int sunxi_musb_probe(struct platform_device *pdev) pdata.mode = MUSB_PORT_MODE_HOST; break; #endif +#if defined CONFIG_USB_MUSB_DUAL_ROLE || defined CONFIG_USB_MUSB_GADGET + case USB_DR_MODE_PERIPHERAL: + pdata.mode = MUSB_PORT_MODE_GADGET; + break; +#endif #ifdef CONFIG_USB_MUSB_DUAL_ROLE case USB_DR_MODE_OTG: - glue->extcon = extcon_get_edev_by_phandle(&pdev->dev, 0); - if (IS_ERR(glue->extcon)) { - if (PTR_ERR(glue->extcon) == -EPROBE_DEFER) - return -EPROBE_DEFER; - dev_err(&pdev->dev, "Invalid or missing extcon\n"); - return PTR_ERR(glue->extcon); -
[PATCH 07/12] usb: musb: gadget: add usb-request tracepoints
Add usb_request tracepoints for gadget mode. Signed-off-by: Bin Liu --- drivers/usb/musb/musb_gadget.c | 35 --- drivers/usb/musb/musb_trace.h | 76 ++ 2 files changed, 90 insertions(+), 21 deletions(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 9616059..6d1e975 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -44,6 +44,7 @@ #include #include "musb_core.h" +#include "musb_trace.h" /* --- */ @@ -167,15 +168,7 @@ __acquires(ep->musb->lock) if (!dma_mapping_error(&musb->g.dev, request->dma)) unmap_dma_buffer(req, musb); - if (request->status == 0) - musb_dbg(musb, "%s done request %p, %d/", - ep->end_point.name, request, - req->request.actual, req->request.length); - else - musb_dbg(musb, "%s request %p, %d/%d fault %d", - ep->end_point.name, request, - req->request.actual, req->request.length, - request->status); + trace_musb_req_gb(req); usb_gadget_giveback_request(&req->ep->end_point, &req->request); spin_lock(&musb->lock); ep->busy = busy; @@ -449,6 +442,7 @@ void musb_g_tx(struct musb *musb, u8 epnum) req = next_request(musb_ep); request = &req->request; + trace_musb_req_tx(req); csr = musb_readw(epio, MUSB_TXCSR); musb_dbg(musb, "<== %s, txcsr %04x", musb_ep->end_point.name, csr); @@ -847,6 +841,7 @@ void musb_g_rx(struct musb *musb, u8 epnum) if (!req) return; + trace_musb_req_rx(req); request = &req->request; csr = musb_readw(epio, MUSB_RXCSR); @@ -892,11 +887,6 @@ void musb_g_rx(struct musb *musb, u8 epnum) request->actual += musb_ep->dma->actual_len; - musb_dbg(musb, "RXCSR%d %04x, dma off, %04x, len %zu, req %p", - epnum, csr, - musb_readw(epio, MUSB_RXCSR), - musb_ep->dma->actual_len, request); - #if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_TUSB_OMAP_DMA) || \ defined(CONFIG_USB_UX500_DMA) /* Autoclear doesn't clear RxPktRdy for short packets */ @@ -1194,6 +1184,7 @@ struct usb_request *musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) request->epnum = musb_ep->current_epnum; request->ep = musb_ep; + trace_musb_req_alloc(request); return &request->request; } @@ -1203,7 +1194,10 @@ struct usb_request *musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) */ void musb_free_request(struct usb_ep *ep, struct usb_request *req) { - kfree(to_musb_request(req)); + struct musb_request *request = to_musb_request(req); + + trace_musb_req_free(request); + kfree(request); } static LIST_HEAD(buffers); @@ -1220,10 +1214,7 @@ struct free_record { */ void musb_ep_restart(struct musb *musb, struct musb_request *req) { - musb_dbg(musb, "<== %s request %p len %u on hw_ep%d", - req->tx ? "TX/IN" : "RX/OUT", - &req->request, req->request.length, req->epnum); - + trace_musb_req_start(req); musb_ep_select(musb->mregs, req->epnum); if (req->tx) txstate(musb, req); @@ -1254,7 +1245,7 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req, if (request->ep != musb_ep) return -EINVAL; - musb_dbg(musb, "<== to %s request=%p", ep->name, req); + trace_musb_req_enq(request); /* request is mine now... */ request->request.actual = 0; @@ -1296,9 +1287,11 @@ static int musb_gadget_dequeue(struct usb_ep *ep, struct usb_request *request) int status = 0; struct musb *musb = musb_ep->musb; - if (!ep || !request || to_musb_request(request)->ep != musb_ep) + if (!ep || !request || req->ep != musb_ep) return -EINVAL; + trace_musb_req_deq(req); + spin_lock_irqsave(&musb->lock, flags); list_for_each_entry(r, &musb_ep->req_list, list) { diff --git a/drivers/usb/musb/musb_trace.h b/drivers/usb/musb/musb_trace.h index 39258f6..27d1a9b 100644 --- a/drivers/usb/musb/musb_trace.h +++ b/drivers/usb/musb/musb_trace.h @@ -212,6 +212,82 @@ DEFINE_EVENT(musb_urb, musb_urb_deq, TP_ARGS(musb, urb) ); +DECLARE_EVENT_CLASS(musb_req, + TP_PROTO(struct musb_request *req), + TP_ARGS(req), + TP_STRUCT__entry( + __field(struct usb_request *, req) + __field(u8, is_tx) + __field(u8, epnum) + __field(int, status) + __field(unsigned int, buf_len) + _
[PATCH 11/12] usb: musb: sunxi: make unexported symbols static
From: Ben Dooks The sunxi_musb_dma_controller_create and _destroy are not exported or used outside the driver, so fix sparse warnings by making these two static: drivers/usb/musb/sunxi.c:357:23: warning: symbol 'sunxi_musb_dma_controller_create' was not declared. Should it be static? drivers/usb/musb/sunxi.c:363:6: warning: symbol 'sunxi_musb_dma_controller_destroy' was not declared. Should it be static? Signed-off-by: Ben Dooks Signed-off-by: Bin Liu --- drivers/usb/musb/sunxi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c index 7650051..8522081 100644 --- a/drivers/usb/musb/sunxi.c +++ b/drivers/usb/musb/sunxi.c @@ -354,13 +354,13 @@ static void sunxi_musb_disable(struct musb *musb) clear_bit(SUNXI_MUSB_FL_ENABLED, &glue->flags); } -struct dma_controller *sunxi_musb_dma_controller_create(struct musb *musb, - void __iomem *base) +static struct dma_controller * +sunxi_musb_dma_controller_create(struct musb *musb, void __iomem *base) { return NULL; } -void sunxi_musb_dma_controller_destroy(struct dma_controller *c) +static void sunxi_musb_dma_controller_destroy(struct dma_controller *c) { } -- 1.9.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
Re: [GIT PULL] usb patches for v4.8
On Thu, Jun 30, 2016 at 02:00:40PM +0300, Roger Quadros wrote: > Greg, Felipe, > > On 30/06/16 13:45, Roger Quadros wrote: > > On 30/06/16 13:32, Felipe Balbi wrote: > >> > >> Hi, > >> > >> Roger Quadros writes: > >> here's the big pull request for gadget API and related UDC drivers. > >> > >> Nothing really scary lately. Patches have been in linux-next for a > >> while > >> without outstanding reports. > >> > >> Let me know if you want any changes, but things seem to be calming > >> down. I have, however, a few patches pending in my linux-usb inbox but > >> I > >> won't have time to really work on them in time for current merge > >> window, > >> so I decided to cut my tree short and send you a pull request. > >> > >> Anyway, here's the good stuff > >> > >> The following changes since commit > >> 33688abb2802ff3a230bd2441f765477b94cc89e: > >> > >> Linux 4.7-rc4 (2016-06-19 21:30:02 -0700) > >> > >> are available in the git repository at: > >> > >> git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git > >> tags/usb-for-v4.8 > > > > I got a merge issue in drivers/usb/dwc3/host.c that I had to fix up by > > hand. Can you verify I got the merge correct? It builds for me here :) > > looks okay and still passes my tests. Then again, Intel's SoCs don't use > dwc3/host.c, Roger or Bin, can you test AM437x with greg/usb-next to > make sure it still works for you guys? > > >>> Unfortunately USB host is broken for TI platforms on greg/usb-next. > >>> Works fine on balbi/next though. > >> > >> got some logs to aid debugging there? Tracepoints? dmesg? Anything which > >> could hint at the problem? > >> > > xhci driver hasn't been loaded so > > > >> lsusb > > unable to initialize libusb: -99 > > > > cheers, > > -roger > > > > The following patch fixes it for me. Looks like we lost all changes related > to commit 9522def40065 ("usb: dwc3: core: cleanup IRQ resources") in host.c > during the merge. > > diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c > index 67f90d7..f6533c6 100644 > --- a/drivers/usb/dwc3/host.c > +++ b/drivers/usb/dwc3/host.c > @@ -23,7 +23,48 @@ int dwc3_host_init(struct dwc3 *dwc) > { > struct property_entry props[2]; > struct platform_device *xhci; > - int ret; > + int ret, irq; > + struct resource *res; > + struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); > + > + irq = platform_get_irq_byname(dwc3_pdev, "host"); > + if (irq == -EPROBE_DEFER) > + return irq; > + > + if (irq <= 0) { > + irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3"); > + if (irq == -EPROBE_DEFER) > + return irq; > + > + if (irq <= 0) { > + irq = platform_get_irq(dwc3_pdev, 0); > + if (irq <= 0) { > + if (irq != -EPROBE_DEFER) { > + dev_err(dwc->dev, > + "missing host IRQ\n"); > + } > + if (!irq) > + irq = -EINVAL; > + return irq; > + } else { > + res = platform_get_resource(dwc3_pdev, > + IORESOURCE_IRQ, 0); > + } > + } else { > + res = platform_get_resource_byname(dwc3_pdev, > +IORESOURCE_IRQ, > +"dwc_usb3"); > + } > + > + } else { > + res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ, > +"host"); > + } > + > + dwc->xhci_resources[1].start = irq; > + dwc->xhci_resources[1].end = irq; > + dwc->xhci_resources[1].flags = res->flags; > + dwc->xhci_resources[1].name = res->name; > > xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO); > if (!xhci) { > Yes, I picked the "other side" of that merge, sorry, my fault. greg k-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: [PATCHv4 1/2] usb: USB Type-C connector class
On Wed, Jun 29, 2016 at 04:38:37PM +0300, Heikki Krogerus wrote: > The purpose of USB Type-C connector class is to provide > unified interface for the user space to get the status and > basic information about USB Type-C connectors on a system, > control over data role swapping, and when the port supports > USB Power Delivery, also control over power role swapping > and Alternate Modes. > > Signed-off-by: Heikki Krogerus > --- > Documentation/ABI/testing/sysfs-class-typec | 236 + > Documentation/usb/typec.txt | 103 +++ > MAINTAINERS |9 + > drivers/usb/Kconfig |2 + > drivers/usb/Makefile|2 + > drivers/usb/typec/Kconfig |7 + > drivers/usb/typec/Makefile |1 + > drivers/usb/typec/typec.c | 1277 > +++ > include/linux/usb/typec.h | 260 ++ > 9 files changed, 1897 insertions(+) > create mode 100644 Documentation/ABI/testing/sysfs-class-typec > create mode 100644 Documentation/usb/typec.txt > create mode 100644 drivers/usb/typec/Kconfig > create mode 100644 drivers/usb/typec/Makefile > create mode 100644 drivers/usb/typec/typec.c > create mode 100644 include/linux/usb/typec.h > > diff --git a/Documentation/ABI/testing/sysfs-class-typec > b/Documentation/ABI/testing/sysfs-class-typec > new file mode 100644 > index 000..7cd40e5 > --- /dev/null > +++ b/Documentation/ABI/testing/sysfs-class-typec > @@ -0,0 +1,236 @@ > +USB Type-C port devices (eg. /sys/class/typec/usbc0/) > + > +What:/sys/class/typec//current_data_role > +Date:June 2016 > +Contact: Heikki Krogerus > +Description: > + The current USB data role the port is operating in. This > + attribute can be used for requesting data role swapping on the > + port. > + > + Valid values: > + - host > + - device > + > +What:/sys/class/typec//current_power_role > +Date:June 2016 > +Contact: Heikki Krogerus > +Description: > + The current power role of the port. This attribute can be used > + to request power role swap on the port when the port supports > + USB Power Delivery. > + > + Valid values: > + - source > + - sink > + > +What:/sys/class/typec//current_vconn_role > +Date:June 2016 > +Contact: Heikki Krogerus > +Description: > + Shows the current VCONN role of the port. This attribute can be > + used to request VCONN role swap on the port when the port > + supports USB Power Delivery. > + > + Valid values are: > + - source > + - sink > + > +What:/sys/class/typec//power_operation_mode > +Date:June 2016 > +Contact: Heikki Krogerus > +Description: > + Shows the current power operational mode the port is in. > + > + Valid values: > + - USB - Normal power levels defined in USB specifications > + - BC1.2 - Power levels defined in Battery Charging Specification > + v1.2 > + - USB Type-C 1.5A - Higher 1.5A current defined in USB Type-C > + specification. > + - USB Type-C 3.0A - Higher 3A current defined in USB Type-C > + specification. > +- USB Power Delivery - The voltages and currents defined in > USB > +Power Delivery specification > + > +What:/sys/class/typec//preferred_role > +Date:June 2016 > +Contact: Heikki Krogerus > +Description: > + The user space can notify the driver about the preferred role. > + It should be handled as enabling of Try.SRC or Try.SNK, as > + defined in USB Type-C specification, in the port drivers. By > + default there is no preferred role. > + > + Valid values: > + - host > + - device > + - For example "none" to remove preference (anything else except > + "host" or "device") > + > +What:/sys/class/typec//supported_accessory_modes > +Date:June 2016 > +Contact: Heikki Krogerus > +Description: > + Lists the Accessory Modes, defined in the USB Type-C > + specification, the port supports. > + > +What:/sys/class/typec//supported_data_roles > +Date:June 2016 > +Contact: Heikki Krogerus > +Description: > + Lists the USB data roles the port is capable of supporting. > + > + Valid values: > + - device > + - host > + - device, host (DRD as defined in
Re: [PATCH 02/21] usb: ulpi: Support device discovery via DT
On Tue, Jun 28, 2016 at 03:09:21PM -0700, Stephen Boyd wrote: > Quoting Rob Herring (2016-06-28 13:56:42) > > On Sun, Jun 26, 2016 at 12:28:19AM -0700, Stephen Boyd wrote: > > > The qcom HSIC ulpi phy doesn't have any bits set in the vendor or > > > product id ulpi registers. This makes it impossible to make a > > > ulpi driver match against the id registers. Add support to > > > discover the ulpi phys via DT to help alleviate this problem. > > > We'll look for a ulpi bus node underneath the device registering > > > the ulpi viewport (or the parent of that device to support > > > chipidea's device layout) and then match up the phy node > > > underneath that with the ulpi device that's created. > > > > > > The side benefit of this is that we can use standard DT > > > properties in the phy node like clks, regulators, gpios, etc. > > > because we don't have firmware like ACPI to turn these things on > > > for us. And we can use the DT phy binding to point our phy > > > consumer to the phy provider. > > > > > > Cc: Greg Kroah-Hartman > > > Cc: Heikki Krogerus > > > Cc: > > > Cc: Rob Herring > > > Signed-off-by: Stephen Boyd > > > --- > > > Documentation/devicetree/bindings/usb/ulpi.txt | 20 + > > > drivers/usb/common/ulpi.c | 56 > > > +- > > > 2 files changed, 74 insertions(+), 2 deletions(-) > > > create mode 100644 Documentation/devicetree/bindings/usb/ulpi.txt > > > > > > diff --git a/Documentation/devicetree/bindings/usb/ulpi.txt > > > b/Documentation/devicetree/bindings/usb/ulpi.txt > > > new file mode 100644 > > > index ..ca179dc4bd50 > > > --- /dev/null > > > +++ b/Documentation/devicetree/bindings/usb/ulpi.txt > > > @@ -0,0 +1,20 @@ > > > +ULPI bus binding > > > + > > > + > > > +Phys that are behind a ULPI connection can be described with the > > > following > > > +binding. The host controller shall have a "ulpi" named node as a child, > > > and > > > +that node shall have one enabled node underneath it representing the ulpi > > > +device on the bus. > > > > This needs to co-exist with the USB bus binding which has the controller > > ports for the child nodes. Maybe use the phy binding? > > Which binding is that? bindings/usb/usb-device.txt? Yes. > This ulpi binding is > to describe phys that are accessed through the ulpi "viewport" in the > usb controller. So controller ports don't come into the picture here. You just need to confirm that there's no collision with child nodes like it assumes all children are ports. Rob -- 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 v5 5/5] usb: dwc3: rockchip: add devicetree bindings documentation
Dear Heiko, On 06/30/2016 08:15 PM, Heiko Stuebner wrote: Hi William, Am Donnerstag, 30. Juni 2016, 19:16:40 schrieb William Wu: This patch adds the devicetree documentation required for Rockchip USB3.0 core wrapper consisting of USB3.0 IP from Synopsys. It supports DRD mode, and could operate in device mode (SS, HS, FS) and host mode (SS, HS, FS, LS). Signed-off-by: William Wu --- Changes in v5: - rename clock-names, and remove unnecessary clocks (Heiko) Changes in v4: - modify commit log, and add phy documentation location (Sergei) Changes in v3: - add dwc3 address (balbi) Changes in v2: - add rockchip,dwc3.txt to Documentation/devicetree/bindings/ (balbi, Brian) .../devicetree/bindings/usb/rockchip,dwc3.txt | 40 ++ 1 file changed, 40 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/rockchip,dwc3.txt diff --git a/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt new file mode 100644 index 000..9c85e19 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt @@ -0,0 +1,40 @@ +Rockchip SuperSpeed DWC3 USB SoC controller + +Required properties: +- compatible: should contain "rockchip,rk3399-dwc3" for rk3399 SoC +- clocks: A list of phandle + clock-specifier pairs for the + clocks listed in clock-names +- clock-names: Should contain the following: + "ref_clk" Controller reference clk, have to be 24 MHz + "suspend_clk" Controller suspend clk, have to be 24 MHz or 32 KHz + "bus_clk_otg0"Master/Core clock, have to be >= 62.5 MHz for SS + operation and >= 60MHz for HS operation why is it called "bus_clk_otg0" not just simply "bus_clk". As far as I understand it (and see it in the TRM), you have two dwc3 controllers (otg0 and otg1) and clock-names are always meant from the perspective of the individual ip-block. So a devicetree would have: usbdrd3_0: usb@fe80 { compatible = "rockchip,rk3399-dwc3"; clocks = <&cru SCLK_USB3OTG0_REF>, <&cru SCLK_USB3OTG0_SUSPEND>, <&cru ACLK_USB3OTG0>, <&cru ACLK_USB3_GRF>; clock-names = "ref_clk", "suspend_clk", "bus_clk", "grf_clk"; ... }; usbdrd3_1: usb@fe90 { compatible = "rockchip,rk3399-dwc3"; clocks = <&cru SCLK_USB3OTG1_REF>, <&cru SCLK_USB3OTG1_SUSPEND>, <&cru ACLK_USB3OTG1>, <&cru ACLK_USB3_GRF>; clock-names = "ref_clk", "suspend_clk", "bus_clk", "grf_clk"; ... }; The rest looks really nice now. Ah, it looks very goog to me. I'll fix it immediately. Thank you very much! Heiko + "grf_clk" Controller grf clk + +Required child node: +A child node must exist to represent the core DWC3 IP block. The name of +the node is not important. The content of the node is defined in dwc3.txt. + +Phy documentation is provided in the following places: +Documentation/devicetree/bindings/phy/rockchip,dwc3-usb-phy.txt + +Example device nodes: + + usbdrd3_0: usb@fe80 { + compatible = "rockchip,rk3399-dwc3"; + clocks = <&cru SCLK_USB3OTG0_REF>, <&cru SCLK_USB3OTG0_SUSPEND>, +<&cru ACLK_USB3OTG0>, <&cru ACLK_USB3_GRF>; + clock-names = "ref_clk", "suspend_clk", + "bus_clk_otg0", "grf_clk"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + status = "disabled"; + usbdrd_dwc3_0: dwc3@fe80 { + compatible = "snps,dwc3"; + reg = <0x0 0xfe80 0x0 0x10>; + interrupts = ; + dr_mode = "otg"; + status = "disabled"; + }; + }; -- 1.9.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
[GIT PULL] usb: chipidea changes for v4.8-rc1
The following changes since commit aa5e94a2e13377e374795de5400e346c978f46be: Revert "usb: ohci-at91: Forcibly suspend ports while USB suspend" (2016-06-20 07:42:07 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git/ tags/usb-v4.8-rc1 for you to fetch changes up to ebfad91c5da3b32d83aaad280d6918867aea501c: dt-bindings: ci-hdrc-usb2: s/gadget-itc-setting/itc-setting in example (2016-06-21 12:28:08 +0800) Hi Greg, Below are changes for v4.8-rc1, none is important, only the documentation update for chipidea. Jisheng Zhang (1): dt-bindings: ci-hdrc-usb2: s/gadget-itc-setting/itc-setting in example Peter Chen (1): usb: chipidea: Kconfig: improve Kconfig help text Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 2 +- drivers/usb/chipidea/Kconfig | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) -- 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 v5 2/5] usb: dwc3: add dis_u2_freeclk_exists_quirk
On Thu, Jun 30, 2016 at 07:12:53PM +0800, William Wu wrote: > Add a quirk to clear the GUSB2PHYCFG.U2_FREECLK_EXISTS bit, > which specifies whether the USB2.0 PHY provides a free-running > PHY clock, which is active when the clock control input is active. > > Signed-off-by: William Wu > --- > Changes in v5: > - None > > Changes in v4: > - rebase on top of balbi testing/next, remove pdata (balbi) > > Changes in v3: > - None > > Changes in v2: > - None > > Documentation/devicetree/bindings/usb/dwc3.txt | 3 +++ > drivers/usb/dwc3/core.c| 5 + > drivers/usb/dwc3/core.h| 5 + > 3 files changed, 13 insertions(+) > > diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt > b/Documentation/devicetree/bindings/usb/dwc3.txt > index 7d7ce08..1ada121 100644 > --- a/Documentation/devicetree/bindings/usb/dwc3.txt > +++ b/Documentation/devicetree/bindings/usb/dwc3.txt > @@ -39,6 +39,9 @@ Optional properties: > disabling the suspend signal to the PHY. > - snps,dis_rxdet_inp3_quirk: when set core will disable receiver detection > in PHY P3 power state. > + - snps,dis_u2_freeclk_exists_quirk: when set, clear the u2_freeclk_exists Use '-', not '_'. > + in GUSB2PHYCFG, specify that USB2 PHY doesn't provide > + a free-running PHY clock. > - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal > utmi_l1_suspend_n, false when asserts utmi_sleep_n > - snps,hird-threshold: HIRD threshold -- 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 v5 3/5] usb: dwc3: add phyif_utmi_quirk
On Thu, Jun 30, 2016 at 07:12:54PM +0800, William Wu wrote: > Add a quirk to configure the core to support the > UTMI+ PHY with an 8- or 16-bit interface. UTMI+ PHY > interface is hardware property, and it's platform > dependent. Normall, the PHYIf can be configured > during coreconsultant. But for some specific usb > cores(e.g. rk3399 soc dwc3), the default PHYIf > configuration value is fault, so we need to > reconfigure it by software. > > And refer to the dwc3 databook, the GUSB2PHYCFG.USBTRDTIM > must be set to the corresponding value according to > the UTMI+ PHY interface. > > Signed-off-by: William Wu > --- > Changes in v5: > - None > > Changes in v4: > - rebase on top of balbi testing/next, remove pdata (balbi) > > Changes in v3: > - None > > Changes in v2: > - add a quirk for phyif_utmi (balbi) > > Documentation/devicetree/bindings/usb/dwc3.txt | 4 > drivers/usb/dwc3/core.c| 19 +++ > drivers/usb/dwc3/core.h| 12 > 3 files changed, 35 insertions(+) > > diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt > b/Documentation/devicetree/bindings/usb/dwc3.txt > index 1ada121..34d13a5 100644 > --- a/Documentation/devicetree/bindings/usb/dwc3.txt > +++ b/Documentation/devicetree/bindings/usb/dwc3.txt > @@ -42,6 +42,10 @@ Optional properties: > - snps,dis_u2_freeclk_exists_quirk: when set, clear the u2_freeclk_exists > in GUSB2PHYCFG, specify that USB2 PHY doesn't provide > a free-running PHY clock. > + - snps,phyif_utmi_quirk: when set core will set phyif UTMI+ interface. This isn't really what I'd call a quirk. > + - snps,phyif_utmi: the value to configure the core to support a UTMI+ PHY > + with an 8- or 16-bit interface. Value 0 select 8-bit > + interface, value 1 select 16-bit interface. These seem like they should be standard properties for setting the phy type/mode. I think we already have something defined in fact. Rob -- 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 v5 2/5] usb: dwc3: add dis_u2_freeclk_exists_quirk[Involving remittance information, please pay attention to the safety of property]
Dear Rob, On 07/01/2016 10:32 AM, Rob Herring wrote: On Thu, Jun 30, 2016 at 07:12:53PM +0800, William Wu wrote: Add a quirk to clear the GUSB2PHYCFG.U2_FREECLK_EXISTS bit, which specifies whether the USB2.0 PHY provides a free-running PHY clock, which is active when the clock control input is active. Signed-off-by: William Wu --- Changes in v5: - None Changes in v4: - rebase on top of balbi testing/next, remove pdata (balbi) Changes in v3: - None Changes in v2: - None Documentation/devicetree/bindings/usb/dwc3.txt | 3 +++ drivers/usb/dwc3/core.c| 5 + drivers/usb/dwc3/core.h| 5 + 3 files changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 7d7ce08..1ada121 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -39,6 +39,9 @@ Optional properties: disabling the suspend signal to the PHY. - snps,dis_rxdet_inp3_quirk: when set core will disable receiver detection in PHY P3 power state. + - snps,dis_u2_freeclk_exists_quirk: when set, clear the u2_freeclk_exists Use '-', not '_'. OK, I'll fix them in next patch. Thanks very much for your help. + in GUSB2PHYCFG, specify that USB2 PHY doesn't provide + a free-running PHY clock. - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal utmi_l1_suspend_n, false when asserts utmi_sleep_n - snps,hird-threshold: HIRD threshold -- 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 v5 4/5] usb: dwc3: add dis_del_phy_power_chg_quirk[Involving remittance information, please pay attention to the safety of property]
Dear Rob, On 07/01/2016 10:38 AM, Rob Herring wrote: On Thu, Jun 30, 2016 at 07:12:55PM +0800, William Wu wrote: Add a quirk to clear the GUSB3PIPECTL.DELAYP1TRANS bit, which specifies whether disable delay PHY power change from P0 to P1/P2/P3 when link state changing from U0 to U1/U2/U3 respectively. Signed-off-by: William Wu --- Changes in v5: - None Changes in v4: - rebase on top of balbi testing/next, remove pdata (balbi) Changes in v3: - None Changes in v2: - None Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++ drivers/usb/dwc3/core.c| 5 + drivers/usb/dwc3/core.h| 3 +++ 3 files changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 34d13a5..bd5bef0 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -42,6 +42,8 @@ Optional properties: - snps,dis_u2_freeclk_exists_quirk: when set, clear the u2_freeclk_exists in GUSB2PHYCFG, specify that USB2 PHY doesn't provide a free-running PHY clock. + - snps,dis_del_phy_power_chg_quirk: when set core will change PHY power + from P0 to P1/P2/P3 without delay. Use '-', not '_'. OK, I'll fix it in next patch. Thanks~:-) Best regards, William Wu - snps,phyif_utmi_quirk: when set core will set phyif UTMI+ interface. - snps,phyif_utmi: the value to configure the core to support a UTMI+ PHY with an 8- or 16-bit interface. Value 0 select 8-bit -- 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 v5 4/5] usb: dwc3: add dis_del_phy_power_chg_quirk
On Thu, Jun 30, 2016 at 07:12:55PM +0800, William Wu wrote: > Add a quirk to clear the GUSB3PIPECTL.DELAYP1TRANS bit, > which specifies whether disable delay PHY power change > from P0 to P1/P2/P3 when link state changing from U0 > to U1/U2/U3 respectively. > > Signed-off-by: William Wu > --- > Changes in v5: > - None > > Changes in v4: > - rebase on top of balbi testing/next, remove pdata (balbi) > > Changes in v3: > - None > > Changes in v2: > - None > > Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++ > drivers/usb/dwc3/core.c| 5 + > drivers/usb/dwc3/core.h| 3 +++ > 3 files changed, 10 insertions(+) > > diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt > b/Documentation/devicetree/bindings/usb/dwc3.txt > index 34d13a5..bd5bef0 100644 > --- a/Documentation/devicetree/bindings/usb/dwc3.txt > +++ b/Documentation/devicetree/bindings/usb/dwc3.txt > @@ -42,6 +42,8 @@ Optional properties: > - snps,dis_u2_freeclk_exists_quirk: when set, clear the u2_freeclk_exists > in GUSB2PHYCFG, specify that USB2 PHY doesn't provide > a free-running PHY clock. > + - snps,dis_del_phy_power_chg_quirk: when set core will change PHY power > + from P0 to P1/P2/P3 without delay. Use '-', not '_'. > - snps,phyif_utmi_quirk: when set core will set phyif UTMI+ interface. > - snps,phyif_utmi: the value to configure the core to support a UTMI+ PHY > with an 8- or 16-bit interface. Value 0 select 8-bit -- 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 12/21] usb: chipidea: msm: Keep device runtime enabled
On Thu, Jun 30, 2016 at 01:30:54PM -0700, Stephen Boyd wrote: > Quoting Peter Chen (2016-06-29 18:39:01) > > On Wed, Jun 29, 2016 at 05:43:30PM -0700, Stephen Boyd wrote: > > > Quoting Peter Chen (2016-06-28 23:46:00) > > > > On Sun, Jun 26, 2016 at 12:28:29AM -0700, Stephen Boyd wrote: > > > > > Sometimes the usb wrapper device is part of a power domain that > > > > > needs to stay on as long as the device is active. Let's get and > > > > > put the device in driver probe/remove so that we keep the power > > > > > domain powered as long as the device is attached. We can fine > > > > > tune this later to handle wakeup interrupts, etc. for finer grain > > > > > power management later, but this is necessary to make sure we can > > > > > keep accessing the device right now. > > > > > > > > Since some of the controllers work abnormal if we enables runtime > > > > pm unconditionally, so I use one system flag CI_HDRC_SUPPORTS_RUNTIME_PM > > > > for it. I can't understand why you can't access device without enable > > > > parent's runtime pm, the controller will not enter runtime suspend > > > > without that flag. > > > > > > Correct, the child device of ci_hdrc_msm will be able to do runtime PM > > > and keep the parent enabled if the CI_HDRC_SUPPORTS_RUNTIME_PM flag is > > > set. But even if that flag isn't set, the ci_hdrc_msm driver is calling > > > pm_runtime_enable() on the same device that it would be called on if the > > > CI_HDRC_SUPPORTS_RUNTIME_PM flag was set. That allows runtime PM > > > transition of child devices such as the usb ports (usb1-port1 for > > > example) to propagate up all the way to the ci_hdrc_msm device and > > > disable any attached power domains. > > > > Sorry, I can't get you. > > > > If the chipidea core's runtime is disabled, the port under the > > controller will not be in runtime suspended, only the bus will > > be in suspended due to USB core enables runtime PM by default. > > Hmm sorry, I was confused too. > > From what I can tell, if I don't call pm_runtime_set_active() on the > glue device, it will runtime suspend once I call pm_runtime_enable() on > it (which we do in ci_hdrc_mms_probe()). When we runtime suspend the > glue device, we turn off the power domain associated with it too. The > runtime pm enabled state of the core device doesn't seem to matter > either way here. So perhaps I should be calling pm_runtime_set_active() > before pm_runtime_enable() there instead of doing the get/put? It isn't > clear to me when we should be calling pm_runtime_get() vs. > pm_runtime_set_active() though. > > > > > > > > > Why don't we call runtime PM functions on the ci->dev for all cases of > > > ci->supports_runtime_pm? It seems like the glue drivers should be > > > managing their own device power states and the ci->dev should be managed > > > by core.c code. > > > > > > > This is current design. Chipidea core manages portsc.phcd and PHY's PM > > (through PHY's API), and glue layer manages its own clocks on the system > > bus for register visit (and data transfer if necessary). > > > > Sorry, I mean this code in core.c > > pm_runtime_set_active(&pdev->dev); > pm_runtime_enable(&pdev->dev); > pm_runtime_set_autosuspend_delay(&pdev->dev, 2000); > pm_runtime_mark_last_busy(ci->dev); > pm_runtime_use_autosuspend(&pdev->dev); > > which confused me. I thought pdev->dev was the glue device, but it's the > same as ci->dev, the core device. I get it now, but I'd like to change > all the calls there to use ci->dev to be clearer. Yes, please do it. Glue device is the parent for core device, and at core.c, only ci_hdrc_add_device and ci_get_platdata will touch glue device. -- 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 v15 2/4] usb: 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 Reviewed-by: Li Jun Tested-by: Li Jun --- drivers/usb/gadget/udc/core.c | 17 + include/linux/usb/gadget.h|3 +++ 2 files changed, 20 insertions(+) diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index ff8685e..bdf1874 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -578,12 +579,17 @@ EXPORT_SYMBOL_GPL(usb_gadget_vbus_connect); * 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. */ int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) { int ret = 0; + usb_charger_set_cur_limit_by_gadget(gadget, mA); + if (!gadget->ops->vbus_draw) { ret = -EOPNOTSUPP; goto out; @@ -965,6 +971,9 @@ static void usb_gadget_state_work(struct work_struct *work) struct usb_gadget *gadget = work_to_gadget(work); struct usb_udc *udc = gadget->udc; + /* when the gadget state is changed, then report to USB charger */ + usb_charger_plug_by_gadget(gadget, gadget->state); + if (udc) sysfs_notify(&udc->dev.kobj, NULL, "state"); } @@ -1134,6 +1143,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; @@ -1154,6 +1167,9 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget, return 0; +err5: + device_del(&udc->dev); + err4: list_del(&udc->list); mutex_unlock(&udc_lock); @@ -1262,6 +1278,7 @@ void usb_del_gadget_udc(struct usb_gadget *gadget) kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE); flush_work(&gadget->work); device_unregister(&udc->dev); + usb_charger_exit(gadget); device_unregister(&gadget->dev); } EXPORT_SYMBOL_GPL(usb_del_gadget_udc); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 612dbdf..c864b51 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -24,6 +24,7 @@ #include #include #include +#include #define UDC_TRACE_STR_MAX 512 @@ -328,6 +329,7 @@ struct usb_gadget_ops { * @in_epnum: last used in ep number * @mA: last set mA value * @otg_caps: OTG capabilities of this gadget. + * @charger: Negotiate the power with the usb charger. * @sg_supported: true if we can handle scatter-gather * @is_otg: True if the USB device port uses a Mini-AB jack, so that the * gadget driver must provide a USB OTG descriptor. @@ -385,6 +387,7 @@ struct usb_gadget { unsignedin_epnum; unsignedmA; struct usb_otg_caps *otg_caps; + struct usb_charger *charger; unsignedsg_supported:1; unsignedis_otg:1; -- 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 v15 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 Brown Signed-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(&pdev->dev, + "Failed to find USB gadget: %d\n", ret); + goto err_bat_irq; + } + + power->usb_notify.notifier_call = wm831x_usb_limit_change; + + ret = usb_charger_register_notify(power->usb_charger, + &power->usb_notify); + if (ret != 0) { + dev_err(&pdev->dev, + "Failed to register notifier: %d\n", ret); + goto err_usb_charger; + } + } + return ret; +err_usb_charger: + /* put_device on charger */ err_bat_irq: --i; for (; i >= 0; i--) { @@ -637,6 +700,12 @@ static int wm831x_power_remove(struct platform_device *pdev) struct wm831x *wm831x = wm831x_power->wm831x; int irq, i; + if (wm831x_power->usb_charger) { + usb_charger_unregister_notify(wm831x_power->usb_charger, + &wm831x_power->usb_notify); + /* Free charger */ + } + for (i = 0; i < ARRAY_SIZE(wm831x_bat_irqs); i++) { irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, 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 linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.h
[PATCH v15 1/4] usb: 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 Reviewed-by: Li Jun Tested-by: Li Jun --- drivers/usb/gadget/Kconfig |8 + drivers/usb/gadget/udc/Makefile |1 + drivers/usb/gadget/udc/charger.c | 677 ++ include/linux/usb/charger.h | 183 +++ include/uapi/linux/usb/charger.h | 31 ++ 5 files changed, 900 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 3c3f31c..acea3f7 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -134,6 +134,14 @@ config U_SERIAL_CONSOLE help It supports the serial gadget can be used as a console. +config USB_CHARGER + bool "USB charger support" + select EXTCON + 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 98e74ed..ede2351 100644 --- a/drivers/usb/gadget/udc/Makefile +++ b/drivers/usb/gadget/udc/Makefile @@ -2,6 +2,7 @@ CFLAGS_trace.o := -I$(src) udc-core-y := core.o trace.o +udc-core-$(CONFIG_USB_CHARGER) += charger.o # # USB peripheral controller drivers diff --git a/drivers/usb/gadget/udc/charger.c b/drivers/usb/gadget/udc/charger.c new file mode 100644 index 000..54c1712f --- /dev/null +++ b/drivers/usb/gadget/udc/charger.c @@ -0,0 +1,677 @@ +/* + * charger.c -- USB charger driver + * + * Copyright (C) 2016 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 + +/* Default current limit by charger type. */ +#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); +static LIST_HEAD(charger_list); +static DEFINE_MUTEX(charger_lock); + +static unsigned int __usb_charger_get_cur_limit(struct usb_charger *uchger); + +static struct usb_charger *dev_to_uchger(struct device *dev) +{ + return NULL; +} + +/* + * 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; +
[PATCH v15 3/4] usb: 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, usb_charger_exit() function and dev_to_uchger() function by getting 'struct usb_charger' from 'struct gadget'. Signed-off-by: Baolin Wang Reviewed-by: Li Jun Tested-by: Li Jun --- drivers/usb/gadget/udc/charger.c | 67 -- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/udc/charger.c b/drivers/usb/gadget/udc/charger.c index 54c1712f..57f9fd2 100644 --- a/drivers/usb/gadget/udc/charger.c +++ b/drivers/usb/gadget/udc/charger.c @@ -36,7 +36,9 @@ static unsigned int __usb_charger_get_cur_limit(struct usb_charger *uchger); static struct usb_charger *dev_to_uchger(struct device *dev) { - return NULL; + struct usb_gadget *gadget = container_of(dev, struct usb_gadget, dev); + + return gadget->charger; } /* @@ -305,7 +307,13 @@ static int __usb_charger_set_cur_limit_by_type(struct usb_charger *uchger, int usb_charger_set_cur_limit_by_gadget(struct usb_gadget *gadget, unsigned int cur_limit) { - return 0; + struct usb_charger *uchger = gadget->charger; + + if (!uchger) + return -EINVAL; + + return __usb_charger_set_cur_limit_by_type(uchger, uchger->type, + cur_limit); } EXPORT_SYMBOL_GPL(usb_charger_set_cur_limit_by_gadget); @@ -563,11 +571,52 @@ 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); /* + * usb_charger_unregister() - Unregister a usb charger. + * @uchger - the usb charger to be unregistered. + */ +static int usb_charger_unregister(struct usb_charger *uchger) +{ + ida_simple_remove(&usb_charger_ida, uchger->id); + sysfs_remove_groups(&uchger->gadget->dev.kobj, usb_charger_groups); + + mutex_lock(&charger_lock); + list_del(&uchger->list); + mutex_unlock(&charger_lock); + + kfree(uchger); + return 0; +} + +/* * usb_charger_register() - Register a new usb charger. * @uchger - the new usb charger instance. */ @@ -647,6 +696,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 */ @@ -669,7 +719,18 @@ fail: int usb_charger_exit(struct usb_gadget *ugadget) { - return 0; + struct usb_charger *uchger = ugadget->charger; + + if (!uchger) + return -EINVAL; + + ugadget->charger = NULL; + if (uchger->extcon_dev) + extcon_unregister_notifier(uchger->extcon_dev, + EXTCON_USB, + &uchger->extcon_nb.nb); + + return usb_charger_unregister(uchger); } MODULE_AUTHOR("Baolin Wang "); -- 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 v15 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 v14: - Add kernel documentation for struct usb_cahrger. - Remove some redundant WARN() functions. Changes since v13: - Remove the charger checking in usb_gadget_vbus_draw() function. - Rename some functions in charger.c file. - Rebase on git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git tags/usb-for-v4.8 Changes since v12: - Remove the class and device things. - Link usb charger to udc-core.ko. - Create one "charger" subdirectory which holds all charger-related attributes. Changes since v11: - Reviewed and tested by Li Jun. 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): usb: gadget: Introduce the usb charger framework usb: gadget: Support for the usb charger framework usb: 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 |8 + drivers/usb/gadget/udc/Makefile |1 + drivers/usb/gadget/udc/charger.c | 738 ++ drivers/usb/gadget/udc/core.c| 17 + include/linux/mfd/wm831x/pdata.h |3 + include/linux/usb/charger.h | 183 ++ include/linux/usb/gadget.h |3 + include/uapi/linux/usb/charger.h | 31 ++ 9 files changed, 1053 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