system hang
Hi Greg/All, This is Narasimharao working for a s/wcompany HCLT.. I am working a issue and the description is below: system stops booting and needs a series of console inputs (space bar or return) to continue booting. Each input advances the process a little bit. Actually I am trying to upgrade the s/w from usb pendrive, part of this upgrade having multiple times we are disconnecting and connecting the usb pen drive. system stops booting and needs a series of console inputs (space bar or return) to continue booting. Each input advances the process a little bit. I have tried to find the root cause for the issue but not get success, can you help me regarding to this what is the root cause and how i can fix this? One more thing i observed that the space allocated for tty by 'tty_write_room' is suddenly consumed by more than 2k at the time of issue occurs and gradually consuming remaining memory and when reaches to zero upgrade completely hangs and when console inputs (space bar or return) to continue booting, Each input advances the process a little bit. This console i/p's creating some space for the same . Is this problem in tty? one more thing we observed that whenever we increase the logging then this problem happens regularly. [ 66.233676] EXT3-fs (sda14): using internal journal [ 66.233691] EXT3-fs (sda14): mounted filesystem with ordered data mode [ 76.822878] par.que...par_queue_user_receive: Freeze check =0 [ 76.828711] par.que...par_queue_user_receive: * returned -ERESTARTSYS * event =-512 [ 76.837241] par_ldisc_open:record is found for ttyS4 [ 76.842766] par.que...par_queue_user_receive: Freeze check =0 [ 76.848594] par.que...par_queue_user_receive: * returned -ERESTARTSYS * event =-512 [ 101.781654] usb 1-1.3: USB disconnect, address 3 [ 104.029178] usb 1-1.3: new high speed USB device using fsl-ehci and address 4 [ 104.159085] scsi2 : usb-storage 1-1.3:1.0 [ 105.163726] scsi 2:0:0:0: Direct-Access Kingston DataTraveler 2.0 1.00 PQ: 0 ANSI: 2 [ 105.173202] sd 2:0:0:0: Attached scsi generic sg1 type 0 [ 105.173686] sd 2:0:0:0: [sdb] 4006912 512-byte logical blocks: (2.05 GB/1.91 GiB) [ 105.174177] sd 2:0:0:0: [sdb] Write Protect is off [ 105.174188] sd 2:0:0:0: [sdb] Mode Sense: 23 00 00 00 [ 105.174197] sd 2:0:0:0: [sdb] Assuming drive cache: write through [ 105.178804] sd 2:0:0:0: [sdb] Assuming drive cache: write through [ 105.178825] sdb: sdb1 [ 105.295052] sd 2:0:0:0: [sdb] Assuming drive cache: write through [ 105.301142] sd 2:0:0:0: [sdb] Attached SCSI removable disk - Hangs at this place and console i/p’s to continue booting. I have tried with different sizes and different vendors pen drives but problem is the same and occurs at the same place. Your valuable inputs and suggetions are helpful to fix this issue. My kernel version is: 2.6.35.6-45.fc14.i686 Thanks in advance for helping and replying. Regards, Narasimharao B ::DISCLAIMER:: The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects. -- 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: system hang
Hi, I have checked the same in the recent kernel versions also. Issue is still remain. Regards, Narasimharao B -Original Message- From: Willy Tarreau [mailto:w...@1wt.eu] Sent: 10 April 2014 13:26 To: narasimharo bolisetti Cc: linux-ker...@vger.kernel.org; kernelnewb...@nl.linux.org; de...@linuxdriverproject.org; linux-ser...@vger.kernel.org; linux-hotp...@vger.kernel.org; g...@kroah.com; Narasimharao Bolisetti; nrbolise...@gmail.com; sta...@vger.kernel.org; linux-...@vger.kernel.org; linux-usb@vger.kernel.org Subject: Re: system hang On Thu, Apr 10, 2014 at 12:05:52AM -0700, narasimharo bolisetti wrote: My kernel version is: 2.6.35.6-45.fc14.i686 Maintenance for this kernel has been dropped years ago, so it very likely contains many bugs that were fixed in more recent ones. You should definitely upgrade. Hoping this helps, Willy ::DISCLAIMER:: The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects. -- 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] cdc-acm: some enhancement on acm delayed write
On Wed, 2014-04-09 at 22:57 +0800, Xiao Jin wrote: Thanks all for the review. We meet with the problems when developing product. I would like to explain my understanding. On 04/08/2014 11:05 AM, Xiao Jin wrote: We find two problems on acm tty write delayed mechanism. (1) When acm resume, the delayed wb will be started. But now only one write can be saved during acm suspend. More acm write may be abandoned. The scenario usually happened when user space write series AT after acm suspend. If acm accept the first AT, what's the reason for acm to refuse the second AT? If write return 0, user space will try repeatedly until resume. It looks simpler that acm accept all the data and sent out urb when resume. No. We cannot accept an arbitrary amount of data. It would let any user OOM the system. There will have to be an arbitrary limit. The simplest limit is 1 urb. And that is because we said that we are ready to accept data. (2) acm tty port ASYNCB_INITIALIZED flag will be cleared when close. If acm resume callback run after ASYNCB_INITIALIZED flag cleared, there will have no chance for delayed write to start. That lead to acm_wb.use can't be cleared. If user space open acm tty again and try to setd, tty will be blocked in tty_wait_until_sent for ever. We see tty write and close concurrently after acm suspend in this case. It looks no method to avoid it from tty layer. acm_tty_write and There is a delay user space can set. acm_resume call after acm_port_shutdown. It looks any action in acm_port_shutdown can't solve the problem. As acm has accepted the user space data, we can only find a way to send out urb. I feel anyway to discard the data looks like a lie to user space. In my understanding acm should accept data as much as possible, and send out urb as soon as possible. What do you think of? There's certainly no problem with sending out the data. Yet simply resuming the device in shutdown() should do the job. Regards Oliver -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: system hang
On Thu, Apr 10, 2014 at 12:05:52AM -0700, narasimharo bolisetti wrote: My kernel version is: 2.6.35.6-45.fc14.i686 Maintenance for this kernel has been dropped years ago, so it very likely contains many bugs that were fixed in more recent ones. You should definitely upgrade. Hoping this helps, Willy -- 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: Fwd: Isochronos audio
From: Alan Stern ... Furthermore, I clearly recall Sarah Sharp (the original maintainer for xhci-hcd) saying that the support for isochronous transfers needed attention. This may well be an example. You also definitely don't want to cancel an isoc urb. Doing so is likely to corrupt the kernel heap. If an isoc urb generates multiple TRB the code allocates a little structure 'per TRB' and links it to the urb. This seems to be done so that it can tell when all the TRB have finished so that it can complete the urb. However if a transfer is aborted they get freed individually, but they were allocated as a single item. I actually suspect the driver doesn't care about the early TRB, so shouldn't need the list at all. David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] phy: exynos5-usbdrd: Add facility to toggle vbus gpio on/off
Hi. On Wednesday 09 April 2014 05:24 PM, Vivek Gautam wrote: Adding support to enable/disable VBUS hooked to a gpio to enable vbus supply on the port. Signed-off-by: Vivek Gautam gautam.vi...@samsung.com --- Based on 'phy-exynos5-usbdrd' patches: [PATCH V4 0/5] Add Exynos5 USB 3.0 phy driver based on generic PHY framework http://www.spinics.net/lists/linux-usb/msg105507.html drivers/phy/phy-exynos5-usbdrd.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c index ff54a7c..5ca7485 100644 --- a/drivers/phy/phy-exynos5-usbdrd.c +++ b/drivers/phy/phy-exynos5-usbdrd.c @@ -18,6 +18,7 @@ #include linux/module.h #include linux/of.h #include linux/of_address.h +#include linux/of_gpio.h #include linux/phy/phy.h #include linux/platform_device.h #include linux/mutex.h @@ -176,6 +177,7 @@ struct exynos5_usbdrd_phy { struct clk *ref_clk; unsigned long ref_rate; unsigned int refclk_reg; + int gpio; }; #define to_usbdrd_phy(inst) \ @@ -460,6 +462,9 @@ static int exynos5_usbdrd_phy_power_on(struct phy *phy) if (!IS_ERR(phy_drd-usb30_sclk)) clk_prepare_enable(phy_drd-usb30_sclk); + /* Toggle VBUS gpio - on */ + gpio_set_value(phy_drd-gpio, 1); + /* Power-on PHY*/ inst-phy_cfg-phy_isol(inst, 0); @@ -476,6 +481,9 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy) /* Power-off the PHY */ inst-phy_cfg-phy_isol(inst, 1); + /* Toggle VBUS gpio - off */ + gpio_set_value(phy_drd-gpio, 0); + if (!IS_ERR(phy_drd-usb30_sclk)) clk_disable_unprepare(phy_drd-usb30_sclk); @@ -585,6 +593,16 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev) phy_drd-drv_data = drv_data; + /* Get required GPIO for vbus */ + phy_drd-gpio = of_get_named_gpio(dev-of_node, + samsung,vbus-gpio, 0); Is this dt property documented somewhere? + if (!gpio_is_valid(phy_drd-gpio)) + dev_dbg(dev, no usbdrd-phy vbus gpio defined\n); No return here? Can the PHY be functional even without the VBUS? Thanks Kishon -- 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 v8 00/11] Add USB OTG HNP and SRP support on Chipidea usb driver
On Wed, Apr 09, 2014 at 08:29:30PM +0800, Li Jun wrote: From: Li Jun b47...@freescale.com This patchset adds USB OTG HNP and SRP support on chipidea usb driver, existing OTG port role swtich function by ID pin status kept unchanged, based on that, if select CONFIG_USB_OTG_FSM, OTG HNP and SRP will be supported. Reference to: On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification July 27, 2012 Revision 2.0 version 1.1a Changes since v7: - move role start special handling in ci_hdrc_otg_fsm_start() this can make start host/gadget clean. - move ci_hdrc_otg_fsm_init() into ci_hdrc_otg_init() - Remain ci_role_start() in ci_hdrc_probe because host role start need be done before request_irq. - Revert the otg-host set change since fsm init will be fixed before role start. - Remove fsm-protocol init in ci_hdrc_otg_fsm_init(). Hi Jun, you have considered all cases well, but we do need the code flow to reflect otg state machine, otg fsm code is the common code, it is better to let the otg fsm code to handle device's initialization. Eg, from undef-b_idle-b_peripheral. Below changes you may need to consider: 1. At ci_hdrc_probe, if (ci_otg_is_fsm_mode(ci)) do ci_hdrc_otg_fsm_start() else do ci_role_start(ci, ci-role); ... call request_irq 2. At ci_udc_start if (ci_otg_is_fsm_mode(ci)) do ci_hdrc_otg_fsm_start() else do enable_device_mode(); 3. At ci_otg_fsm_work, we need to call the second level otg_statemachine async since the irq is still not enabled after the first otg_statemachine. It is reasonable we enable interrupt after the controller's init has finished. Any problems, let me know. Peter Changes since v6: - Move ci_hdrc_otg_fsm_start() into ci_hdrc_otg_fsm_init() - Call ci_hdrc_otg_fsm_init() in ci_hdrc_probe() - Add fsm-protocol init in ci_hdrc_otg_fsm_init() - Remove role check in start/stop host/gadget. - Add ci_otg_is_fsm_mode() check when start fsm in ci_udc_start(). - Add struct usb_otg *otg in ci_hdrc_otg_fsm_init() for easy read when do init, set otg-host if host role start before otg fsm init(power up with ID is 0). - set otg-host in host_start() if otg fsm init happens before host start (power up with ID is 1) in host.c - Add comments of ci_hdrc structure for added fileds(fsm and fsm_timer) in ci.h Changes since v5: - Move ci_otg_is_fsm_mode() check into caller functions. - Update comments alignment in otg_fsm.h - Revert the ci_hdrc_otg_fsm_start() change to be v4 - Revert the role check removal of start host/gadget to be v4 since ci_start_role may be called out of otg fsm. - Set controller to be device mode after stop host, to be able to generate data pulse correctly. - Update some fsm variables to align with otg state. - Update test documents for A device start new seesion in step 6): need set a_bus_drop to be 0 and set a_bus_req to be 1. - Typo fix. Changes since v4: - Fix compile warnings if USB_OTG_FSM is not enabled. - Add ci_otg_is_fsm_mode() to replace ci-is_otg for checking if ci is in OTG FSM mode. - Move ci_hdrc_otg_fsm_start() at end of ci_hdrc_otg_fsm_init(). - Fix patch splict problem(a later patch changes a previous one). - Remove unnecessary role check in start host/gadget. - Add {} in start_host.c to fix Coding style problem and declar a variable equal to ci-transceiver-otg firstly when init otg port number. - Update some driver comments of chipidea drivers if this patchset applied. Changes since v3: - Move out 2 patches from this patchset, as which are not directly related to otg fsm. - Add a new file chipidea.txt under Documentation/usb/ to show how to test OTG HNP and SRP. - Directly embed struct otg_fsm into ci_hdrc instead of pointer of otg_fsm. - Remove flag check in ci_otg_del_timer(). - Remove ADP related code and comments since ADP is not supported by chip. - Start OTG fsm before request_irq. - For B-device, do not do OTG fsm transitions when gadget driver is not registered, and start OTG fsm in register gadget driver. - Directly call ci_otg_fsm_work() in ci_hdrc_otg_fsm_start(). - Enable data pulse when a_wait_vfall timer time out. - Update a_wait_vrise time out function. - UPdate comments of OTG time macro definitions in otg_fsm.h according to OTG and EH 2.0. - Some typo and comments format changes. Changes since v2: - Add ABI document for sysfs input files description: Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg - Add a debug file for show some USB registers value. - Split host driver change to be 2 patches, one for otg_port number init; the other one for vbus control change. - Export interrupt enable and status read functions from udc driver. - Only enable AVV irq in otg fsm init. - Remove duplicated USBSTS bits definitions. - Add HowTo demo role switch with 2 Freescale i.MX6Q sabre SD boards in cover letter. - typo correction. Changes since v1: - Move
RE: [PATCH 1/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'
From: Sergei Shtylyov It doesn't do any pin muxing. It switches SoC internal USB signals between USB controllers. The pins remain the same. Doesn't something like that already happen for the companion USB1 controllers for USB2 ports? That also doesn't sound like you are changing the PHY. I'd have thought that would happen if you had a single controller that select between multiply PHY. David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/2] usb: ehci-platform: Return immediately from suspend if ehci_suspend fails
Patch 'b8efdaf USB: EHCI: add check for wakeup/suspend race' adds a check for possible race between suspend and wakeup interrupt, and thereby it returns -EBUSY as error code if there's a wakeup interrupt. So the platform host controller should not proceed further with its suspend callback, rather should return immediately to avoid powering down the essential things, like phy. Signed-off-by: Vivek Gautam gautam.vi...@samsung.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Hauke Mehrtens ha...@hauke-m.de Cc: Hans de Goede hdego...@redhat.com --- Changes from v1: -- Removed unnecessary change 'return 0' drivers/usb/host/ehci-platform.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index b3a0e11..c7dd93a 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -303,6 +303,8 @@ static int ehci_platform_suspend(struct device *dev) int ret; ret = ehci_suspend(hcd, do_wakeup); + if (ret) + return ret; if (pdata-power_suspend) pdata-power_suspend(pdev); -- 1.7.10.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 0/3] Fix USB deadlock caused by SCSI error handling
That patch appears to work in preventing the crashes, judged on one repeated appearance of the bug. dmesg had the usual [ 215.229903] usb 4-2: usb_disable_lpm called, do nothing [ 215.336941] usb 4-2: reset SuperSpeed USB device number 3 using xhci_hcd [ 215.350296] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b829c0 [ 215.350305] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b82a08 [ 215.350621] usb 4-2: usb_enable_lpm called, do nothing repeated five times, followed by one [ 282.795801] sd 8:0:0:0: Device offlined - not ready after error recovery and then as often as something tried to read from it: [ 295.585472] sd 8:0:0:0: rejecting I/O to offline device The stick could then be properly un- and remounted (the latter if it had been physically replugged) without issue — for the bug to reoccur after one to three minutes. I tried this three times, no dmesg difference except the ep addresses varied on two of that. Andreas Reis On 09.04.2014 20:02, Alan Stern wrote: On Wed, 9 Apr 2014, Hannes Reinecke wrote: I finally got a chance to try it out. It does seem to do what we want. I didn't track the flow of control in complete detail, but the command definitely got aborted both times it was issued. Good, so it is as I thought. James, can we include this patch instead of your prior solution? First, we should have the original bug reporter try it out. Andreas, the patch in question can be found here: http://marc.info/?l=linux-usbm=13962706597w=2 Can you try this in place of the 1/3 patch posted by James? It should have the same effect, of preventing your system from crashing when the READ command fails. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'
On 10/04/14 11:49, Sergei Shtylyov wrote: On 10-04-2014 13:20, David Laight wrote: It doesn't do any pin muxing. It switches SoC internal USB signals between USB controllers. The pins remain the same. Doesn't something like that already happen for the companion USB1 controllers for USB2 ports? Did you mean USB 1.1 and USB 2.0 controllers by USB1 and USB2? That also doesn't sound like you are changing the PHY. I am changing one of the PHY registers that controls USB port (Renesas calls it channel) multiplexing. I'd have thought that would happen if you had a single controller that select between multiply PHY. No, it's not the case. There is an interesting case, the USB3 shares a PHY with a SATA and the PCIE and SATA also share a PHY on the R8A7790. -- Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius -- 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 1/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'
From: Ben Dooks On 10/04/14 11:49, Sergei Shtylyov wrote: On 10-04-2014 13:20, David Laight wrote: It doesn't do any pin muxing. It switches SoC internal USB signals between USB controllers. The pins remain the same. Doesn't something like that already happen for the companion USB1 controllers for USB2 ports? Did you mean USB 1.1 and USB 2.0 controllers by USB1 and USB2? Yes. Why do you care which USB controller is driving the pins? That also doesn't sound like you are changing the PHY. I am changing one of the PHY registers that controls USB port (Renesas calls it channel) multiplexing. I'd have thought that would happen if you had a single controller that select between multiply PHY. No, it's not the case. I realised that wasn't what you were doing, but at first it did seem to be what you were doing. There is an interesting case, the USB3 shares a PHY with a SATA and the PCIE and SATA also share a PHY on the R8A7790. Some of those look like pcb design decisions - so there is no dynamic changing, just config time plumbing. OTOH we are carrying PCIe using two SATA cables (the second carries the clock) so I suspect some SoC system pcbs may be able to support SATA or PCIe on the same connector). David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'
On 10/04/14 12:14, David Laight wrote: From: Ben Dooks On 10/04/14 11:49, Sergei Shtylyov wrote: On 10-04-2014 13:20, David Laight wrote: It doesn't do any pin muxing. It switches SoC internal USB signals between USB controllers. The pins remain the same. Doesn't something like that already happen for the companion USB1 controllers for USB2 ports? Did you mean USB 1.1 and USB 2.0 controllers by USB1 and USB2? Yes. Why do you care which USB controller is driving the pins? That also doesn't sound like you are changing the PHY. I am changing one of the PHY registers that controls USB port (Renesas calls it channel) multiplexing. I'd have thought that would happen if you had a single controller that select between multiply PHY. No, it's not the case. I realised that wasn't what you were doing, but at first it did seem to be what you were doing. There is an interesting case, the USB3 shares a PHY with a SATA and the PCIE and SATA also share a PHY on the R8A7790. Some of those look like pcb design decisions - so there is no dynamic changing, just config time plumbing. OTOH we are carrying PCIe using two SATA cables (the second carries the clock) so I suspect some SoC system pcbs may be able to support SATA or PCIe on the same connector). Yes, which means we will probably want to support the case where the USB3 is routed out of the PCIe lanes. -- Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius -- 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 V4 1/5] phy: Add new Exynos5 USB 3.0 PHY driver
On Wed, Apr 9, 2014 at 7:03 PM, Tomasz Figa t.f...@samsung.com wrote: On 09.04.2014 13:49, Vivek Gautam wrote: Hi, On Wed, Apr 9, 2014 at 4:36 PM, Tomasz Figa t.f...@samsung.com wrote: Hi Vivek, Please see my comments inline. On 08.04.2014 16:36, Vivek Gautam wrote: Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs. The new driver uses the generic PHY framework and will interact with DWC3 controller present on Exynos5 series of SoCs. Thereby, removing old phy-samsung-usb3 driver and related code used untill now which was based on usb/phy framework. Signed-off-by: Vivek Gautam gautam.vi...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 42 ++ drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5-usbdrd.c | 668 4 files changed, 722 insertions(+) create mode 100644 drivers/phy/phy-exynos5-usbdrd.c [snip] + Additional clock required for Exynos5420: + - usb30_sclk_100m: Additional special clock used for PHY operation + depicted as 'sclk_usbphy30' in CMU of Exynos5420. Are you sure this isn't simply a gate for the ref clock, as it can be found on another SoC that is not upstream yet? I don't have documentation for Exynos 5420 so I can't tell, but I'd like to ask you to recheck this. From what i can see in the manual : sclk_usbphy30 is derived from OSCCLK. It is coming from a MUX (default input line to this is OSCCLK) and then through a DIV there's this gate. {OSCCLK + other sources} ---[MUX] --- [DIV] -- [GATE for sclk_usbphy30] the {rate of sclk_usbphy30} == OSCCLK However the 'ref' clock that we have been using is the actual oscillator clock. And on SoC Exynos5250, we don't have any such gate (sclk_usbphy30). So should this mean that ref clock and sclk_usbphy30 are still be controlled by two different gates ? Is there maybe a diagram of PHY input clocks in the datasheet, like for USB 2.0 PHY in Exynos4210/4412/5250 datasheets in the chapter about USB2.0 Device? Something like: || | ___| XusbXTI | Phy_fsel[2:0]| ___ | ___[X]___|| __|_|___|\__|_| | | _v___ | _ ^ | |/ | | _ | | || | | | | ___ | | ___| | || | | | | | |_|_| |___| | | X 0 ||_| PLL |__|_|_|CLK|_|_| _ | | | | || |DIV|_|_| |___[X] | |_| 12 |_|480 | |___| | | | MHz MHz |Digital| | XusbXTO | USB PHY|___| | || Below is the block diagram given for DRD controller. ___ || | | | | PHY | | | | controller |-|--- | |__ | | | || | | USB 3.0 | V | DRD | --- |Controller | | | ||USB30_SCLK_100M| USB 3.0 DRD | | | --- | PHY | | | Link cont. | | | | | - | | | |___| |_| Does this help ? So, USB30_SCLK_100M is the SCLK that we are talking in the driver. I don't see any reference to XXTI in the USB 3.0 DRD controller chapter (in both Exynos5250 and 5420) In addition to this there's one more point to be noticed here. On Exynos5420 system, the sclk_usbphy300 (which is the sclk_usbphy30 for USB DRD channel 0), is also the PICO phy clock, i.e. USB 2.0 phy clock. So we should add a similar clk_get() for this clock in the phy-exynos5250-usb2 driver too, to support Exynos5420. Best regards, Tomasz -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- Best Regards Vivek Gautam Samsung RD Institute, Bangalore India -- 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
Re: [PATCH 0/3] Fix USB deadlock caused by SCSI error handling
Only your 0/3 patch to which Alan linked, along with two other patches by Mathias Nyman (disable usb3 on intel hosts and disable all lpm related control transfers, one of which is the source of the do nothings). I'll revert the latter two and apply the rest of the set. Which I'm guessing currently consists of said 0/3 patch — http://www.spinics.net/lists/linux-scsi/msg73502.html — plus 2/3 and 3/3? Or should I just omit 0/3 and try whichever of the two in 1/3 works best? Rather confusing ATM. Anyway, for whatever reason the bug is happening rather frequently now. I've spotted the following occurring after the Device offlined line two times now: [ 206.901385] sd 11:0:0:0: [sdg] Unhandled error code [ 206.901394] sd 11:0:0:0: [sdg] [ 206.901397] Result: hostbyte=0x01 driverbyte=0x00 [ 206.901400] sd 11:0:0:0: [sdg] CDB: [ 206.901403] cdb[0]=0x2a: 2a 00 02 25 1b 50 00 00 08 00 [ 206.901419] end_request: I/O error, dev sdg, sector 35986256 The second time had sd 12:0:0:0, cdb[0]=0x28: 28 00 03 94 77 20 00 00 08 00 and a different sector. Andreas Reis On 10.04.2014 13:37, Hannes Reinecke wrote: On 04/10/2014 12:58 PM, Andreas Reis wrote: That patch appears to work in preventing the crashes, judged on one repeated appearance of the bug. dmesg had the usual [ 215.229903] usb 4-2: usb_disable_lpm called, do nothing [ 215.336941] usb 4-2: reset SuperSpeed USB device number 3 using xhci_hcd [ 215.350296] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b829c0 [ 215.350305] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b82a08 [ 215.350621] usb 4-2: usb_enable_lpm called, do nothing repeated five times, followed by one [ 282.795801] sd 8:0:0:0: Device offlined - not ready after error recovery and then as often as something tried to read from it: [ 295.585472] sd 8:0:0:0: rejecting I/O to offline device The stick could then be properly un- and remounted (the latter if it had been physically replugged) without issue — for the bug to reoccur after one to three minutes. I tried this three times, no dmesg difference except the ep addresses varied on two of that. Was this just that patch you've tested with or the entire patch series? If the latter, Alan, is this the expected outcome? I would've thought the error recover should _not_ run into offlining devices here, but rather the device should be recovered eventually. Andreas, can you test with the entire patch series and enable 'scsi_logging_level -s -E 5' prior to running the tests? THX. Cheers, Hannes -- 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
USB: serial: option: add support for Novatel E371 PCIe card
Adds product ID for the Novatel E371 PCI Express Mini Card. $ lsusb Bus 001 Device 024: ID 1410:9011 Novatel Wireless $ usb-devices T: Bus=01 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#= 24 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=1410 ProdID=9011 Rev=00.03 S: Manufacturer=Novatel Wireless, Inc. S: Product=Novatel Wireless HSPA S: SerialNumber=012773002115811 C: #Ifs= 6 Cfg#= 1 Atr=e0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option I: If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option I: If#= 6 Alt= 0 #EPs= 1 Cls=02(commc) Sub=06 Prot=00 Driver=cdc_ether I: If#= 7 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether Tested with kernel 3.2.0. Patch: --- a/drivers/usb/serial/option.c 2014-01-03 05:33:36.0 +0100 +++ b/drivers/usb/serial/option.c 2014-03-17 11:38:40.455855308 +0100 @@ -161,6 +161,7 @@ #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED0x9000 #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED0x9001 #define NOVATELWIRELESS_PRODUCT_E362 0x9010 +#define NOVATELWIRELESS_PRODUCT_E371 0x9011 #define NOVATELWIRELESS_PRODUCT_G2 0xA010 #define NOVATELWIRELESS_PRODUCT_MC551 0xB001 @@ -992,6 +993,7 @@ /* Novatel Ovation MC551 a.k.a. Verizon USB551L */ { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E362, 0xff, 0xff, 0xff) }, + { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E371, 0xff, 0xff, 0xff) }, { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, Signed-off-by: Alexej Starschenko starsche...@gmail.com -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'
On 10-04-2014 15:14, David Laight wrote: It doesn't do any pin muxing. It switches SoC internal USB signals between USB controllers. The pins remain the same. Doesn't something like that already happen for the companion USB1 controllers for USB2 ports? Did you mean USB 1.1 and USB 2.0 controllers by USB1 and USB2? Yes. Why do you care which USB controller is driving the pins? Because the controllers the driver switches between are not companions. The multiplexing is between PCI EHCI/OHCI and Renesas USBHS (high speed device controller in this case) controllers on port 0 and between PCI EHCI/OHCI and non-PCI xHCI controller on port 2. That also doesn't sound like you are changing the PHY. I am changing one of the PHY registers that controls USB port (Renesas calls it channel) multiplexing. I'd have thought that would happen if you had a single controller that select between multiply PHY. No, it's not the case. I realised that wasn't what you were doing, but at first it did seem to be what you were doing. The PHY really does belong to the USBHS controller but that multiplexing register inside it controls routing of the ports 0 and 2; USBHS itself is on port 0. There is an interesting case, the USB3 shares a PHY with a SATA and the PCIE and SATA also share a PHY on the R8A7790. Some of those look like pcb design decisions - so there is no dynamic changing, just config time plumbing. No, there are also host/device mode DIP switches on the boards which control port 0 signals (and the port 0 connector is micro-AB, so both a host and device can be connected). The second board also has OTG chip on port 0 thru which USB ID pin can be read from the micro-AB connector. David WBR, Sergei -- 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 v9 11/11] Documentation: usb: add chipidea.txt for how to demo usb OTG HNP and SRP
From: Li Jun b47...@freescale.com This patch adds a file chipidea.txt for how to demo chipidea usb OTG HNP and SRP functions via sysfs input files, any other possible information should be documented for chipidea usb driver in future can be added into this file. Signed-off-by: Li Jun b47...@freescale.com --- Documentation/usb/chipidea.txt | 71 1 file changed, 71 insertions(+) diff --git a/Documentation/usb/chipidea.txt b/Documentation/usb/chipidea.txt new file mode 100644 index 000..4c0e2ea --- /dev/null +++ b/Documentation/usb/chipidea.txt @@ -0,0 +1,71 @@ +1. How to test OTG FSM(HNP and SRP) +--- +To show how to demo OTG HNP and SRP functions via sys input files +with 2 Freescale i.MX6Q sabre SD boards. + +1.1 How to enable OTG FSM in menuconfig +--- +Select CONFIG_USB_OTG_FSM. +If you want to check some internal variables for otg fsm, +select CONFIG_USB_CHIPIDEA_DEBUG, there are 2 files which +can show otg fsm variables and some controller registers value: +cat /sys/kernel/debug/ci_hdrc.0/otg +cat /sys/kernel/debug/ci_hdrc.0/registers + +1.2 Test operations +--- +1) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded + (e.g. g_mass_storage). + +2) Connect 2 boards with usb cable with one end is micro A plug, the other end + is micro B plug. + + The A-device(with micro A plug inserted) should enumrate B-device. + +3) Role switch + On B-device: + echo 1 /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req + + if HNP polling is not supported, also need: + On A-device: + echo 0 /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req + + B-device should take host role and enumrate A-device. + +4) A-device switch back to host. + On B-device: + echo 0 /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req + + A-device should switch back to host and enumrate B-device. + +5) Remove B-device(unplug micro B plug) and insert again in 10 seconds, + A-device should enumrate B-device again. + +6) Remove B-device(unplug micro B plug) and insert again after 10 seconds, + A-device should NOT enumrate B-device. + + if A-device wants to use bus: + On A-device: + echo 0 /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop + echo 1 /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req + + if B-device wants to use bus: + On B-device: + echo 1 /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req + +7) A-device power down the bus. + On A-device: + echo 1 /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop + + A-device should disconnect with B-device and power down the bus. + +8) B-device does data pulse for SRP. + On B-device: + echo 1 /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req + + A-device should resume usb bus and enumrate B-device. + +1.3 Reference document +-- +On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification +July 27, 2012 Revision 2.0 version 1.1a -- 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 v9 02/11] usb: chipidea: host: vbus control change for OTG HNP.
Leave vbus on/off hanlded by OTG fsm if in OTG mode. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/host.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index a8ac6c1..ffb4168 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -67,7 +67,11 @@ static int host_start(struct ci_hdrc *ci) ehci-has_tdi_phy_lpm = ci-hw_bank.lpm; ehci-imx28_write_fix = ci-imx28_write_fix; - if (ci-platdata-reg_vbus) { + /* +* vbus is always on if host is not in OTG FSM mode, +* otherwise should be controlled by OTG FSM +*/ + if (ci-platdata-reg_vbus !ci_otg_is_fsm_mode(ci)) { ret = regulator_enable(ci-platdata-reg_vbus); if (ret) { dev_err(ci-dev, @@ -89,7 +93,7 @@ static int host_start(struct ci_hdrc *ci) return ret; disable_reg: - if (ci-platdata-reg_vbus) + if (ci-platdata-reg_vbus !ci_otg_is_fsm_mode(ci)) regulator_disable(ci-platdata-reg_vbus); put_hcd: @@ -105,7 +109,7 @@ static void host_stop(struct ci_hdrc *ci) if (hcd) { usb_remove_hcd(hcd); usb_put_hcd(hcd); - if (ci-platdata-reg_vbus) + if (ci-platdata-reg_vbus !ci_otg_is_fsm_mode(ci)) regulator_disable(ci-platdata-reg_vbus); } } -- 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 v9 09/11] usb: chipidea: debug: add debug file for OTG variables
From: Li Jun b47...@freescale.com This patch adds a debug file for OTG vairables show. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/debug.c | 84 ++ 1 file changed, 84 insertions(+) diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index 5b890c1..7cccab6 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c @@ -7,6 +7,9 @@ #include linux/uaccess.h #include linux/usb/ch9.h #include linux/usb/gadget.h +#include linux/usb/phy.h +#include linux/usb/otg.h +#include linux/usb/otg-fsm.h #include ci.h #include udc.h @@ -205,6 +208,80 @@ static const struct file_operations ci_requests_fops = { .release= single_release, }; +int ci_otg_show(struct seq_file *s, void *unused) +{ + struct ci_hdrc *ci = s-private; + struct otg_fsm *fsm; + + if (!ci || !ci_otg_is_fsm_mode(ci)) + return 0; + + fsm = ci-fsm; + + /* -- State - */ + seq_printf(s, OTG state: %s\n\n, + usb_otg_state_string(ci-transceiver-state)); + + /* -- State Machine Variables - */ + seq_printf(s, a_bus_drop: %d\n, fsm-a_bus_drop); + + seq_printf(s, a_bus_req: %d\n, fsm-a_bus_req); + + seq_printf(s, a_srp_det: %d\n, fsm-a_srp_det); + + seq_printf(s, a_vbus_vld: %d\n, fsm-a_vbus_vld); + + seq_printf(s, b_conn: %d\n, fsm-b_conn); + + seq_printf(s, adp_change: %d\n, fsm-adp_change); + + seq_printf(s, power_up: %d\n, fsm-power_up); + + seq_printf(s, a_bus_resume: %d\n, fsm-a_bus_resume); + + seq_printf(s, a_bus_suspend: %d\n, fsm-a_bus_suspend); + + seq_printf(s, a_conn: %d\n, fsm-a_conn); + + seq_printf(s, b_bus_req: %d\n, fsm-b_bus_req); + + seq_printf(s, b_bus_suspend: %d\n, fsm-b_bus_suspend); + + seq_printf(s, b_se0_srp: %d\n, fsm-b_se0_srp); + + seq_printf(s, b_ssend_srp: %d\n, fsm-b_ssend_srp); + + seq_printf(s, b_sess_vld: %d\n, fsm-b_sess_vld); + + seq_printf(s, b_srp_done: %d\n, fsm-b_srp_done); + + seq_printf(s, drv_vbus: %d\n, fsm-drv_vbus); + + seq_printf(s, loc_conn: %d\n, fsm-loc_conn); + + seq_printf(s, loc_sof: %d\n, fsm-loc_sof); + + seq_printf(s, adp_prb: %d\n, fsm-adp_prb); + + seq_printf(s, id: %d\n, fsm-id); + + seq_printf(s, protocol: %d\n, fsm-protocol); + + return 0; +} + +static int ci_otg_open(struct inode *inode, struct file *file) +{ + return single_open(file, ci_otg_show, inode-i_private); +} + +static const struct file_operations ci_otg_fops = { + .open = ci_otg_open, + .read = seq_read, + .llseek = seq_lseek, + .release= single_release, +}; + static int ci_role_show(struct seq_file *s, void *data) { struct ci_hdrc *ci = s-private; @@ -332,6 +409,13 @@ int dbg_create_files(struct ci_hdrc *ci) if (!dent) goto err; + if (ci_otg_is_fsm_mode(ci)) { + dent = debugfs_create_file(otg, S_IRUGO, ci-debugfs, ci, + ci_otg_fops); + if (!dent) + goto err; + } + dent = debugfs_create_file(role, S_IRUGO | S_IWUSR, ci-debugfs, ci, ci_role_fops); if (!dent) -- 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 v9 04/11] usb: chipidea: udc: driver update for OTG HNP.
Add b_hnp_enable request handling and enable gadget-is_otg Acked-by: Peter Chen peter.c...@freescale.com Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/udc.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index f58857d..cba7fd6 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -20,6 +20,7 @@ #include linux/pm_runtime.h #include linux/usb/ch9.h #include linux/usb/gadget.h +#include linux/usb/otg-fsm.h #include linux/usb/chipidea.h #include ci.h @@ -1052,6 +1053,14 @@ __acquires(ci-lock) default: break; } + break; + case USB_DEVICE_B_HNP_ENABLE: + if (ci_otg_is_fsm_mode(ci)) { + ci-gadget.b_hnp_enable = 1; + err = isr_setup_status_phase( + ci); + } + break; default: goto delegate; } @@ -1759,7 +1768,7 @@ static int udc_start(struct ci_hdrc *ci) ci-gadget.ops = usb_gadget_ops; ci-gadget.speed= USB_SPEED_UNKNOWN; ci-gadget.max_speed= USB_SPEED_HIGH; - ci-gadget.is_otg = 0; + ci-gadget.is_otg = ci-is_otg ? 1 : 0; ci-gadget.name = ci-platdata-name; INIT_LIST_HEAD(ci-gadget.ep_list); -- 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 v9 06/11] usb: chipidea: OTG fsm timers initialization.
From: Li Jun b47...@freescale.com This patch adds OTG fsm timers initialization, which use controller's 1ms interrupt as timeout counter, also adds some local timers which are not in otg_fsm_timer list. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/bits.h|1 + drivers/usb/chipidea/otg_fsm.c | 189 drivers/usb/chipidea/otg_fsm.h | 51 +++ 3 files changed, 241 insertions(+) diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h index 44882c8..ca57e3d 100644 --- a/drivers/usb/chipidea/bits.h +++ b/drivers/usb/chipidea/bits.h @@ -81,6 +81,7 @@ /* OTGSC */ #define OTGSC_IDPU BIT(5) #define OTGSC_HADP BIT(6) +#define OTGSC_HABA BIT(7) #define OTGSC_ID BIT(8) #define OTGSC_AVVBIT(9) #define OTGSC_ASVBIT(10) diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index 5afeb59..bb64fb4 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -26,6 +26,22 @@ #include otg.h #include otg_fsm.h +static struct ci_otg_fsm_timer *otg_timer_initializer +(struct ci_hdrc *ci, void (*function)(void *, unsigned long), + unsigned long expires, unsigned long data) +{ + struct ci_otg_fsm_timer *timer; + + timer = devm_kzalloc(ci-dev, sizeof(struct ci_otg_fsm_timer), + GFP_KERNEL); + if (!timer) + return NULL; + timer-function = function; + timer-expires = expires; + timer-data = data; + return timer; +} + /* * Add timer to active timer list */ @@ -77,6 +93,163 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t) hw_write_otgsc(ci, OTGSC_1MSIE, 0); } +/* The timeout callback function to set time out bit */ +static void set_tmout(void *ptr, unsigned long indicator) +{ + *(int *)indicator = 1; +} + +static void set_tmout_and_fsm(void *ptr, unsigned long indicator) +{ + struct ci_hdrc *ci = (struct ci_hdrc *)ptr; + + set_tmout(ci, indicator); + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); +} + +static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator) +{ + struct ci_hdrc *ci = (struct ci_hdrc *)ptr; + + set_tmout(ci, indicator); + /* Disable port power */ + hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_PP, 0); + /* Clear exsiting DP irq */ + hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS); + /* Enable data pulse irq */ + hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE); + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); +} + +static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator) +{ + struct ci_hdrc *ci = (struct ci_hdrc *)ptr; + + set_tmout(ci, indicator); + if (!hw_read_otgsc(ci, OTGSC_BSV)) + ci-fsm.b_sess_vld = 0; + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); +} + +static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator) +{ + struct ci_hdrc *ci = (struct ci_hdrc *)ptr; + + set_tmout(ci, indicator); + + /* only vbus fall below B_sess_vld in b_idle state */ + if (ci-transceiver-state == OTG_STATE_B_IDLE) { + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } +} + +static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator) +{ + struct ci_hdrc *ci = (struct ci_hdrc *)ptr; + + /* Check if A detached */ + if (!(hw_read_otgsc(ci, OTGSC_BSV))) { + ci-fsm.b_sess_vld = 0; + ci_otg_add_timer(ci, B_SSEND_SRP); + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } +} + +static void b_data_pulse_end(void *ptr, unsigned long indicator) +{ + struct ci_hdrc *ci = (struct ci_hdrc *)ptr; + + ci-fsm.b_srp_done = 1; + ci-fsm.b_bus_req = 0; + if (ci-fsm.power_up) + ci-fsm.power_up = 0; + + hw_write_otgsc(ci, OTGSC_HABA, 0); + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); +} + +/* Initialize timers */ +static int ci_otg_init_timers(struct ci_hdrc *ci) +{ + struct otg_fsm *fsm = ci-fsm; + + /* FSM used timers */ + ci-fsm_timer-timer_list[A_WAIT_VRISE] = + otg_timer_initializer(ci, set_tmout_and_fsm, TA_WAIT_VRISE, + (unsigned long)fsm-a_wait_vrise_tmout); + if (ci-fsm_timer-timer_list[A_WAIT_VRISE] == NULL) + return -ENOMEM; + + ci-fsm_timer-timer_list[A_WAIT_VFALL] = + otg_timer_initializer(ci, a_wait_vfall_tmout_func, + TA_WAIT_VFALL, (unsigned long)fsm-a_wait_vfall_tmout); + if (ci-fsm_timer-timer_list[A_WAIT_VFALL] == NULL) + return -ENOMEM; + +
[PATCH v9 10/11] Documentation: ABI: usb: sysfs Description for chipidea USB OTG HNP and SRP
From: Li Jun b47...@freescale.com This patch adds sysfs interface description for chipidea USB OTG HNP and SRP. Signed-off-by: Li Jun b47...@freescale.com --- .../ABI/testing/sysfs-platform-chipidea-usb-otg| 56 1 file changed, 56 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg b/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg new file mode 100644 index 000..151c595 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg @@ -0,0 +1,56 @@ +What: /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req +Date: Feb 2014 +Contact: Li Jun b47...@freescale.com +Description: + Can be set and read. + Set a_bus_req(A-device bus request) input to be 1 if + the application running on the A-device wants to use the bus, + and to be 0 when the application no longer wants to use + the bus(or wants to work as peripheral). a_bus_req can also + be set to 1 by kernel in response to remote wakeup signaling + from the B-device, the A-device should decide to resume the bus. + + Valid values are 1 and 0. + + Reading: returns 1 if the application running on the A-device + is using the bus as host role, otherwise 0. + +What: /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop +Date: Feb 2014 +Contact: Li Jun b47...@freescale.com +Description: + Can be set and read + The a_bus_drop(A-device bus drop) input is 1 when the + application running on the A-device wants to power down + the bus, and is 0 otherwise, When a_bus_drop is 1, then + the a_bus_req shall be 0. + + Valid values are 1 and 0. + + Reading: returns 1 if the bus is off(vbus is turned off) by +A-device, otherwise 0. + +What: /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req +Date: Feb 2014 +Contact: Li Jun b47...@freescale.com +Description: + Can be set and read. + The b_bus_req(B-device bus request) input is 1 during the time + that the application running on the B-device wants to use the + bus as host, and is 0 when the application no longer wants to + work as host and decides to switch back to be peripheral. + + Valid values are 1 and 0. + + Reading: returns if the application running on the B device + is using the bus as host role, otherwise 0. + +What: /sys/bus/platform/devices/ci_hdrc.0/inputs/a_clr_err +Date: Feb 2014 +Contact: Li Jun b47...@freescale.com +Description: + Only can be set. + The a_clr_err(A-device Vbus error clear) input is used to clear + vbus error, then A-device will power down the bus. + + Valid value is 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 v9 07/11] usb: chipidea: OTG HNP and SRP fsm implementation.
From: Li Jun b47...@freescale.com USB OTG interrupt handling and fsm transitions according to USB OTG and EH 2.0. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/core.c| 23 ++-- drivers/usb/chipidea/otg.c |9 +- drivers/usb/chipidea/otg_fsm.c | 232 drivers/usb/chipidea/otg_fsm.h | 18 drivers/usb/chipidea/udc.c |9 ++ 5 files changed, 283 insertions(+), 8 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index ff38cf3..9a01e14 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -42,7 +42,6 @@ * - Not Supported: 15 16 (ISO) * * TODO List - * - OTG * - Interrupt Traffic * - GET_STATUS(device) - always reports 0 * - Gadget API (majority of optional features) @@ -74,6 +73,7 @@ #include host.h #include debug.h #include otg.h +#include otg_fsm.h /* Controller register map */ static const u8 ci_regs_nolpm[] = { @@ -412,8 +412,14 @@ static irqreturn_t ci_irq(int irq, void *data) irqreturn_t ret = IRQ_NONE; u32 otgsc = 0; - if (ci-is_otg) + if (ci-is_otg) { otgsc = hw_read_otgsc(ci, ~0); + if (ci_otg_is_fsm_mode(ci)) { + ret = ci_otg_fsm_irq(ci); + if (ret == IRQ_HANDLED) + return ret; + } + } /* * Handle id change interrupt, it indicates device/host function @@ -691,10 +697,15 @@ static int ci_hdrc_probe(struct platform_device *pdev) if (ci-role == CI_ROLE_GADGET) ci_handle_vbus_change(ci); - ret = ci_role_start(ci, ci-role); - if (ret) { - dev_err(dev, can't start %s role\n, ci_role(ci)-name); - goto stop; + if (ci_otg_is_fsm_mode(ci)) { + ci_hdrc_otg_fsm_start(ci); + } else { + ret = ci_role_start(ci, ci-role); + if (ret) { + dev_err(dev, can't start %s role\n, + ci_role(ci)-name); + goto stop; + } } platform_set_drvdata(pdev, ci); diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index d76db51..38e340c 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -11,8 +11,8 @@ */ /* - * This file mainly handles otgsc register, it may include OTG operation - * in the future. + * This file mainly handles otgsc register, OTG fsm operations for HNP and SRP + * are also included. */ #include linux/usb/otg.h @@ -91,6 +91,11 @@ static void ci_otg_work(struct work_struct *work) { struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); + if (ci_otg_is_fsm_mode(ci) !ci_otg_fsm_work(ci)) { + enable_irq(ci-irq); + return; + } + if (ci-id_event) { ci-id_event = false; ci_handle_id_switch(ci); diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index bb64fb4..3542205 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -13,6 +13,10 @@ /* * This file mainly handles OTG fsm, it includes OTG fsm operations * for HNP and SRP. + * + * TODO List + * - ADP + * - OTG test device */ #include linux/usb/otg.h @@ -93,6 +97,33 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t) hw_write_otgsc(ci, OTGSC_1MSIE, 0); } +/* + * Reduce timer count by 1, and find timeout conditions. + * Called by otg 1ms timer interrupt + */ +static inline int ci_otg_tick_timer(struct ci_hdrc *ci) +{ + struct ci_otg_fsm_timer *tmp_timer, *del_tmp; + struct list_head *active_timers = ci-fsm_timer-active_timers; + int expired = 0; + + list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) { + tmp_timer-count--; + /* check if timer expires */ + if (!tmp_timer-count) { + list_del(tmp_timer-list); + tmp_timer-function(ci, tmp_timer-data); + expired = 1; + } + } + + /* disable 1ms irq if there is no any timer active */ + if ((expired == 1) list_empty(active_timers)) + hw_write_otgsc(ci, OTGSC_1MSIE, 0); + + return expired; +} + /* The timeout callback function to set time out bit */ static void set_tmout(void *ptr, unsigned long indicator) { @@ -394,6 +425,207 @@ static struct otg_fsm_ops ci_otg_ops = { .start_gadget = ci_otg_start_gadget, }; +int ci_otg_fsm_work(struct ci_hdrc *ci) +{ + /* +* Don't do fsm transition for B device +* when there is no gadget class driver +*/ + if (ci-fsm.id !(ci-driver) + ci-transceiver-state OTG_STATE_A_IDLE) + return 0; + +
[PATCH v9 00/11] Add USB OTG HNP and SRP support on Chipidea usb driver
From: Li Jun b47...@freescale.com This patchset adds USB OTG HNP and SRP support on chipidea usb driver, existing OTG port role swtich function by ID pin status kept unchanged, based on that, if select CONFIG_USB_OTG_FSM, OTG HNP and SRP will be supported. Reference to: On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification July 27, 2012 Revision 2.0 version 1.1a Changes since v8: - fsm start cover all role start/stop, which just call to ci_otg_fsm_work(), move otg fsm start before request_irq for fsm mode, ci_role_start only for non fsm mode. - use queue work to handle further state changes in ci_otg_fsm_work(). - Let otg fsm handle all after ci-driver is set in ci_udc_start. - Enable BSV irq when power up with ID is 1. Changes since v7: - move role start special handling in ci_hdrc_otg_fsm_start() this can make start host/gadget clean. - move ci_hdrc_otg_fsm_init() into ci_hdrc_otg_init() - Remain ci_role_start() in ci_hdrc_probe because host role start need be done before request_irq. - Revert the otg-host set change since fsm init will be fixed before role start. - Remove fsm-protocol init in ci_hdrc_otg_fsm_init(). Changes since v6: - Move ci_hdrc_otg_fsm_start() into ci_hdrc_otg_fsm_init() - Call ci_hdrc_otg_fsm_init() in ci_hdrc_probe() - Add fsm-protocol init in ci_hdrc_otg_fsm_init() - Remove role check in start/stop host/gadget. - Add ci_otg_is_fsm_mode() check when start fsm in ci_udc_start(). - Add struct usb_otg *otg in ci_hdrc_otg_fsm_init() for easy read when do init, set otg-host if host role start before otg fsm init(power up with ID is 0). - set otg-host in host_start() if otg fsm init happens before host start (power up with ID is 1) in host.c - Add comments of ci_hdrc structure for added fileds(fsm and fsm_timer) in ci.h Changes since v5: - Move ci_otg_is_fsm_mode() check into caller functions. - Update comments alignment in otg_fsm.h - Revert the ci_hdrc_otg_fsm_start() change to be v4 - Revert the role check removal of start host/gadget to be v4 since ci_start_role may be called out of otg fsm. - Set controller to be device mode after stop host, to be able to generate data pulse correctly. - Update some fsm variables to align with otg state. - Update test documents for A device start new seesion in step 6): need set a_bus_drop to be 0 and set a_bus_req to be 1. - Typo fix. Changes since v4: - Fix compile warnings if USB_OTG_FSM is not enabled. - Add ci_otg_is_fsm_mode() to replace ci-is_otg for checking if ci is in OTG FSM mode. - Move ci_hdrc_otg_fsm_start() at end of ci_hdrc_otg_fsm_init(). - Fix patch splict problem(a later patch changes a previous one). - Remove unnecessary role check in start host/gadget. - Add {} in start_host.c to fix Coding style problem and declar a variable equal to ci-transceiver-otg firstly when init otg port number. - Update some driver comments of chipidea drivers if this patchset applied. Changes since v3: - Move out 2 patches from this patchset, as which are not directly related to otg fsm. - Add a new file chipidea.txt under Documentation/usb/ to show how to test OTG HNP and SRP. - Directly embed struct otg_fsm into ci_hdrc instead of pointer of otg_fsm. - Remove flag check in ci_otg_del_timer(). - Remove ADP related code and comments since ADP is not supported by chip. - Start OTG fsm before request_irq. - For B-device, do not do OTG fsm transitions when gadget driver is not registered, and start OTG fsm in register gadget driver. - Directly call ci_otg_fsm_work() in ci_hdrc_otg_fsm_start(). - Enable data pulse when a_wait_vfall timer time out. - Update a_wait_vrise time out function. - UPdate comments of OTG time macro definitions in otg_fsm.h according to OTG and EH 2.0. - Some typo and comments format changes. Changes since v2: - Add ABI document for sysfs input files description: Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg - Add a debug file for show some USB registers value. - Split host driver change to be 2 patches, one for otg_port number init; the other one for vbus control change. - Export interrupt enable and status read functions from udc driver. - Only enable AVV irq in otg fsm init. - Remove duplicated USBSTS bits definitions. - Add HowTo demo role switch with 2 Freescale i.MX6Q sabre SD boards in cover letter. - typo correction. Changes since v1: - Move out HNP polling patch from this series, which will be a seperated patchset followed this one - Change fsm timers global variables to be a structure embeded in ci_hdrc, to make multiple OTG instances can exist in one system - Change some otg fsm functions to be static - Re-split timer init patch to avoid a later patch changing a previous one in the same series - Change timer structure memory allocation to be devm_kzalloc - Update some format alignment and spelling errors Li Jun (11): usb: chipidea: usb OTG fsm initialization. usb: chipidea: host: vbus control change for OTG HNP. usb:
[PATCH v9 08/11] usb: chipidea: add sys inputs for OTG fsm input.
From: Li Jun b47...@freescale.com This patch adds sys input to control and show OTG fsm inputs by application, user can do host and preipheral role switch by change these inputs. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/otg.c |2 + drivers/usb/chipidea/otg_fsm.c | 173 drivers/usb/chipidea/otg_fsm.h |6 ++ 3 files changed, 181 insertions(+) diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 38e340c..a048b08 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -141,4 +141,6 @@ void ci_hdrc_otg_destroy(struct ci_hdrc *ci) /* Disable all OTG irq and clear status */ hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS, OTGSC_INT_STATUS_BITS); + if (ci_otg_is_fsm_mode(ci)) + ci_hdrc_otg_fsm_remove(ci); } diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index 3542205..b3207d2 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -46,6 +46,167 @@ static struct ci_otg_fsm_timer *otg_timer_initializer return timer; } +/* Add for otg: interact with user space app */ +static ssize_t +get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + t = scnprintf(next, size, %d\n, ci-fsm.a_bus_req); + size -= t; + next += t; + + return PAGE_SIZE - size; +} + +static ssize_t +set_a_bus_req(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + + mutex_lock(ci-fsm.lock); + if (buf[0] == '0') { + ci-fsm.a_bus_req = 0; + } else if (buf[0] == '1') { + /* If a_bus_drop is TRUE, a_bus_req can't be set */ + if (ci-fsm.a_bus_drop) { + mutex_unlock(ci-fsm.lock); + return count; + } + ci-fsm.a_bus_req = 1; + } + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + mutex_unlock(ci-fsm.lock); + + return count; +} +static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req); + +static ssize_t +get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + t = scnprintf(next, size, %d\n, ci-fsm.a_bus_drop); + size -= t; + next += t; + + return PAGE_SIZE - size; +} + +static ssize_t +set_a_bus_drop(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + + mutex_lock(ci-fsm.lock); + if (buf[0] == '0') { + ci-fsm.a_bus_drop = 0; + } else if (buf[0] == '1') { + ci-fsm.a_bus_drop = 1; + ci-fsm.a_bus_req = 0; + } + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + mutex_unlock(ci-fsm.lock); + + return count; +} +static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop, + set_a_bus_drop); + +static ssize_t +get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + t = scnprintf(next, size, %d\n, ci-fsm.b_bus_req); + size -= t; + next += t; + + return PAGE_SIZE - size; +} + +static ssize_t +set_b_bus_req(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + + mutex_lock(ci-fsm.lock); + if (buf[0] == '0') + ci-fsm.b_bus_req = 0; + else if (buf[0] == '1') + ci-fsm.b_bus_req = 1; + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + mutex_unlock(ci-fsm.lock); + + return count; +} +static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUSR, get_b_bus_req, set_b_bus_req); + +static ssize_t +set_a_clr_err(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return
[PATCH v9 01/11] usb: chipidea: usb OTG fsm initialization.
This patch adds OTG fsm related initialization when do otg init, add a seperate file for OTG fsm related utilities. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/Makefile |1 + drivers/usb/chipidea/ci.h | 17 +++ drivers/usb/chipidea/otg.c |4 +++ drivers/usb/chipidea/otg_fsm.c | 63 drivers/usb/chipidea/otg_fsm.h | 29 ++ 5 files changed, 114 insertions(+) diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 480bd4d..2f099c7 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -6,6 +6,7 @@ ci_hdrc-y := core.o otg.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST)+= host.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG) += debug.o +ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o # Glue/Bridge layers go here diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 7ae8cb6..bd3529f 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -17,6 +17,7 @@ #include linux/irqreturn.h #include linux/usb.h #include linux/usb/gadget.h +#include linux/usb/otg-fsm.h /** * DEFINE @@ -139,6 +140,7 @@ struct hw_bank { * @roles: array of supported roles for this controller * @role: current role * @is_otg: if the device is otg-capable + * @fsm: otg finite state machine * @work: work for role changing * @wq: workqueue thread * @qh_pool: allocation pool for queue heads @@ -174,6 +176,7 @@ struct ci_hdrc { struct ci_role_driver *roles[CI_ROLE_END]; enum ci_rolerole; boolis_otg; + struct otg_fsm fsm; struct work_struct work; struct workqueue_struct *wq; @@ -319,6 +322,20 @@ static inline u32 hw_test_and_write(struct ci_hdrc *ci, enum ci_hw_regs reg, return (val mask) __ffs(mask); } +/** + * ci_otg_is_fsm_mode: runtime check if otg controller + * is in otg fsm mode. + */ +static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci) +{ +#ifdef CONFIG_USB_OTG_FSM + return ci-is_otg ci-roles[CI_ROLE_HOST] + ci-roles[CI_ROLE_GADGET]; +#else + return false; +#endif +} + u32 hw_read_intr_enable(struct ci_hdrc *ci); u32 hw_read_intr_status(struct ci_hdrc *ci); diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index c694340..d76db51 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -22,6 +22,7 @@ #include ci.h #include bits.h #include otg.h +#include otg_fsm.h /** * hw_read_otgsc returns otgsc register bits value. @@ -116,6 +117,9 @@ int ci_hdrc_otg_init(struct ci_hdrc *ci) return -ENODEV; } + if (ci_otg_is_fsm_mode(ci)) + return ci_hdrc_otg_fsm_init(ci); + return 0; } diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c new file mode 100644 index 000..d9dfaa3 --- /dev/null +++ b/drivers/usb/chipidea/otg_fsm.c @@ -0,0 +1,63 @@ +/* + * otg_fsm.c - ChipIdea USB IP core OTG FSM driver + * + * Copyright (C) 2014 Freescale Semiconductor, Inc. + * + * Author: Jun Li + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* + * This file mainly handles OTG fsm, it includes OTG fsm operations + * for HNP and SRP. + */ + +#include linux/usb/otg.h +#include linux/usb/gadget.h +#include linux/usb/hcd.h +#include linux/usb/chipidea.h + +#include ci.h +#include bits.h +#include otg.h +#include otg_fsm.h + +int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci) +{ + struct usb_otg *otg; + + otg = devm_kzalloc(ci-dev, + sizeof(struct usb_otg), GFP_KERNEL); + if (!otg) { + dev_err(ci-dev, + Failed to allocate usb_otg structure for ci hdrc otg!\n); + return -ENOMEM; + } + + otg-phy = ci-transceiver; + otg-gadget = ci-gadget; + ci-fsm.otg = otg; + ci-transceiver-otg = ci-fsm.otg; + ci-fsm.power_up = 1; + ci-fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0; + ci-transceiver-state = OTG_STATE_UNDEFINED; + + mutex_init(ci-fsm.lock); + + /* Enable A vbus valid irq */ + hw_write_otgsc(ci, OTGSC_AVVIE, OTGSC_AVVIE); + + if (ci-fsm.id) { + ci-fsm.b_ssend_srp = + hw_read_otgsc(ci, OTGSC_BSV) ? 0 : 1; + ci-fsm.b_sess_vld = + hw_read_otgsc(ci, OTGSC_BSV) ? 1 : 0; + /* Enable BSV irq */ + hw_write_otgsc(ci, OTGSC_BSVIE, OTGSC_BSVIE); + } + + return 0; +} diff --git
[PATCH v9 05/11] usb: chipidea: add OTG fsm operation functions implemenation.
Add OTG HNP and SRP operation functions implementation: - charge vbus - drive vbus - connection signaling - drive sof - start data pulse - add fsm timer - delete fsm timer - start host - start gadget Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/bits.h|9 ++ drivers/usb/chipidea/ci.h |2 + drivers/usb/chipidea/otg_fsm.c | 197 drivers/usb/chipidea/otg_fsm.h | 25 + 4 files changed, 233 insertions(+) diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h index 83d06c1..44882c8 100644 --- a/drivers/usb/chipidea/bits.h +++ b/drivers/usb/chipidea/bits.h @@ -44,9 +44,14 @@ #define DEVICEADDR_USBADR (0x7FUL 25) /* PORTSC */ +#define PORTSC_CCSBIT(0) +#define PORTSC_CSCBIT(1) +#define PORTSC_PECBIT(3) +#define PORTSC_OCCBIT(5) #define PORTSC_FPRBIT(6) #define PORTSC_SUSP BIT(7) #define PORTSC_HSPBIT(9) +#define PORTSC_PP BIT(12) #define PORTSC_PTC(0x0FUL 16) #define PORTSC_PHCD(d) ((d) ? BIT(22) : BIT(23)) /* PTS and PTW for non lpm version only */ @@ -56,6 +61,9 @@ #define PORTSC_PTWBIT(28) #define PORTSC_STSBIT(29) +#define PORTSC_W1C_BITS\ + (PORTSC_CSC | PORTSC_PEC | PORTSC_OCC) + /* DEVLC */ #define DEVLC_PFSCBIT(23) #define DEVLC_PSPD(0x03UL 25) @@ -72,6 +80,7 @@ /* OTGSC */ #define OTGSC_IDPU BIT(5) +#define OTGSC_HADP BIT(6) #define OTGSC_ID BIT(8) #define OTGSC_AVVBIT(9) #define OTGSC_ASVBIT(10) diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index bd3529f..9563cb5 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -141,6 +141,7 @@ struct hw_bank { * @role: current role * @is_otg: if the device is otg-capable * @fsm: otg finite state machine + * @fsm_timer: pointer to timer list of otg fsm * @work: work for role changing * @wq: workqueue thread * @qh_pool: allocation pool for queue heads @@ -177,6 +178,7 @@ struct ci_hdrc { enum ci_rolerole; boolis_otg; struct otg_fsm fsm; + struct ci_otg_fsm_timer_list*fsm_timer; struct work_struct work; struct workqueue_struct *wq; diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index d9dfaa3..5afeb59 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -19,12 +19,208 @@ #include linux/usb/gadget.h #include linux/usb/hcd.h #include linux/usb/chipidea.h +#include linux/regulator/consumer.h #include ci.h #include bits.h #include otg.h #include otg_fsm.h +/* + * Add timer to active timer list + */ +static void ci_otg_add_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t) +{ + struct ci_otg_fsm_timer *tmp_timer; + struct ci_otg_fsm_timer *timer = ci-fsm_timer-timer_list[t]; + struct list_head *active_timers = ci-fsm_timer-active_timers; + + if (t = NUM_CI_OTG_FSM_TIMERS) + return; + + /* +* Check if the timer is already in the active list, +* if so update timer count +*/ + list_for_each_entry(tmp_timer, active_timers, list) + if (tmp_timer == timer) { + timer-count = timer-expires; + return; + } + + timer-count = timer-expires; + list_add_tail(timer-list, active_timers); + + /* Enable 1ms irq */ + if (!(hw_read_otgsc(ci, OTGSC_1MSIE))) + hw_write_otgsc(ci, OTGSC_1MSIE, OTGSC_1MSIE); +} + +/* + * Remove timer from active timer list + */ +static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t) +{ + struct ci_otg_fsm_timer *tmp_timer, *del_tmp; + struct ci_otg_fsm_timer *timer = ci-fsm_timer-timer_list[t]; + struct list_head *active_timers = ci-fsm_timer-active_timers; + + if (t = NUM_CI_OTG_FSM_TIMERS) + return; + + list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) + if (tmp_timer == timer) + list_del(timer-list); + + /* Disable 1ms irq if there is no any active timer */ + if (list_empty(active_timers)) + hw_write_otgsc(ci, OTGSC_1MSIE, 0); +} + +/* -*/ +/* Operations that will be called from OTG Finite State Machine */ +/* -*/ +static void ci_otg_fsm_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer t) +{ + struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm); + + if (t NUM_OTG_FSM_TIMERS) + ci_otg_add_timer(ci, t); + return; +}
[PATCH 00/13] extcon: major rework
This patchset adds many improvements to extcon class driver and extcon provider drivers. It changes extcon API to faster and safer by replaceing function taking extcon and cable names with functions working with structures representing this objects. It adds more advanced devicetree support which allows to pass specified cables to client drivers. It gives independency from cable naming conventions in individual extcon provider drivers, and allows to simply connect client drivers with providers in way that being transpatent for both of them. It adds also some minor fixes like additional checks for safety increase, and another improvements. Also added some improvements to extcon provider drivers, improved devicetree support and updated them to use faster extcon API. Patches contains also documentation for extcon, and devicetree bindings for all provider drivers. More details can be found in commit messages and Documentation. Best regards Robert Baldyga Samsung RD Institute Poland Robert Baldyga (13): Documentation: add extcon devicetree bindings Documentation: update charger-manager devicetree bindings extcon: extcon-class: remove extcon_set_cable_state() function extcon: extcon-class: match extcon device by devicetree node extcon: extcon-class: improve extcon client API extcon: extcon-class: remove unused functions extcon: extcon-class: improve get_cable_state_()/set_cable_state_() functions extcon: extcon-class: simplify extcon_updata_state() function extcon: extcon-class: move example to Documentation extcon: extcon-gpio: add devicetree support extcon: extcon-adc-jack: add devicetree support extcon: extcon-max8997: check if pdata exists extcon: extcon-max77693: check if pdata exists .../devicetree/bindings/extcon/extcon-adc-jack.txt | 60 +++ .../devicetree/bindings/extcon/extcon-arizona.txt | 47 +++ .../devicetree/bindings/extcon/extcon-bindings.txt | 36 ++ .../devicetree/bindings/extcon/extcon-gpio.txt | 63 +++ .../devicetree/bindings/extcon/extcon-max14577.txt | 49 +++ .../devicetree/bindings/extcon/extcon-max77693.txt | 56 +++ .../devicetree/bindings/extcon/extcon-max8997.txt | 49 +++ .../devicetree/bindings/extcon/extcon-palmas.txt | 37 +- .../bindings/power_supply/charger-manager.txt | 11 +- Documentation/extcon/extcon.txt| 108 + drivers/extcon/extcon-adc-jack.c | 75 drivers/extcon/extcon-arizona.c|1 + drivers/extcon/extcon-class.c | 412 +--- drivers/extcon/extcon-gpio.c | 64 ++- drivers/extcon/extcon-max14577.c | 26 +- drivers/extcon/extcon-max77693.c | 82 ++-- drivers/extcon/extcon-max8997.c| 35 +- drivers/extcon/extcon-palmas.c | 28 +- drivers/power/charger-manager.c| 36 +- drivers/usb/dwc3/dwc3-omap.c | 68 ++-- drivers/usb/phy/phy-omap-otg.c | 72 ++-- include/linux/extcon.h | 157 +++- include/linux/extcon/extcon-gpio.h |2 +- include/linux/platform_data/usb-omap1.h|2 - include/linux/power/charger-manager.h |6 +- 25 files changed, 1067 insertions(+), 515 deletions(-) create mode 100644 Documentation/devicetree/bindings/extcon/extcon-adc-jack.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-arizona.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-bindings.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-gpio.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-max14577.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-max77693.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-max8997.txt create mode 100644 Documentation/extcon/extcon.txt -- 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 02/13] Documentation: update charger-manager devicetree bindings
This patch changes charger-manager bindings to be compatible with new extcon bindings. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- .../bindings/power_supply/charger-manager.txt | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/power_supply/charger-manager.txt b/Documentation/devicetree/bindings/power_supply/charger-manager.txt index 2b33750..f987bb5 100644 --- a/Documentation/devicetree/bindings/power_supply/charger-manager.txt +++ b/Documentation/devicetree/bindings/power_supply/charger-manager.txt @@ -10,8 +10,7 @@ Required properties : - subnode regulator : - cm-regulator-name : name of charger regulator - subnode cable : - - cm-cable-name : name of charger cable - - cm-cable-extcon : name of extcon dev + - extcon-cable : specified extcon cable (optional) - cm-cable-min : minimum current of cable (optional) - cm-cable-max : maximum current of cable @@ -65,14 +64,14 @@ Example : regulator@0 { cm-regulator-name = chg-reg; cable@0 { - cm-cable-name = USB; - cm-cable-extcon = extcon-dev.0; + /* USB cable */ + extcon-cable = extcon 0; cm-cable-min = 475000; cm-cable-max = 50; }; cable@1 { - cm-cable-name = TA; - cm-cable-extcon = extcon-dev.0; + /* TA cable */ + extcon-cable = extcon 1; cm-cable-min = 65; cm-cable-max = 675000; }; -- 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 05/13] extcon: extcon-class: improve extcon client API
This patch improves extcon client API to get rid of ugly functions operating on name strings. It gives independency from naming convention in extcon provider drivers. Names given at provider registration are now used only for sysfs, debugs, and to support platforms using legacy devicetree bindings. From now individual cables are specified in devicetree, so client API has changed from extcon_dev oriented to extcon_cable oriented. Added also some minor modifications to simplify interest registration. The extcon_specific_cable_nb structure has been changed to extcon_cable_nb. Now this is the only struct which has to be supplied by client. Pointer to user_nb has been changed to extcon_notifier_fn_t to simplify interest registation process. Each single cable is represented by struct extcon_cable. Pointer to extcon_cable is returned from functions: of_extcon_get_cable() - returning cable of given index of_extcon_get_cable_by_name() - returing cable by name defined in devicetree extcon_get_cable_by_name() - similar to of_extcon_get_cable_by_name(), but it takes struct device instead of struct device_node Function extcon_register_interest() has been changed. Registration is now not based on cable name string, but on pointer to struct extcon_cable. Also extcon_get_cable_state() function has been changed. Now it takes pointer to struct extcon_cable. This patch modifies all client drivers to make it using new extcon API. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-class.c | 201 +-- drivers/power/charger-manager.c | 36 +++--- drivers/usb/dwc3/dwc3-omap.c| 68 ++- drivers/usb/phy/phy-omap-otg.c | 72 ++- include/linux/extcon.h | 92 -- include/linux/platform_data/usb-omap1.h |2 - include/linux/power/charger-manager.h |6 +- 7 files changed, 288 insertions(+), 189 deletions(-) diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 1075ce8..708b352 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -324,15 +324,14 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state_); /** * extcon_get_cable_state() - Get the status of a specific cable. - * @edev: the extcon device that has the cable. - * @cable_name:cable name. - * - * Note that this is slower than extcon_get_cable_state_. + * @cable: the cable. */ -int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name) +int extcon_get_cable_state(struct extcon_cable *cable) { - return extcon_get_cable_state_(edev, extcon_find_cable_index - (edev, cable_name)); + if (!cable) + return -ENODEV; + + return !!(cable-edev-state (1 cable-cable_index)); } EXPORT_SYMBOL_GPL(extcon_get_cable_state); @@ -376,24 +375,130 @@ out: return edev; } +/** + * of_extcon_get_cable() - Get specified extcon cable instance from devicetree + * @np:The node of extcon device + */ +struct extcon_cable *of_extcon_get_cable(struct device_node *np, int index) +{ + struct of_phandle_args extcon_spec; + struct extcon_dev *edev; + struct extcon_cable *cable; + int ret; + + if (index 0) + return ERR_PTR(-EINVAL); + + ret = of_parse_phandle_with_args(np, extcon-cables, #extcon-cells, + index, extcon_spec); + if (ret) + return ERR_PTR(ret); + + edev = of_extcon_get_extcon_dev(extcon_spec.np); + if (!edev) { + pr_devel(unable to get extcon device); + return ERR_PTR(-ENODEV); + } + + cable = edev-cables[extcon_spec.args[0]]; + + of_node_put(extcon_spec.np); + return cable; +} +EXPORT_SYMBOL_GPL(of_extcon_get_cable); + +struct extcon_cable *of_extcon_get_cable_legacy(struct device_node *np, + const char *name) +{ + struct device_node *node; + struct extcon_dev *edev; + int i; + + node = of_parse_phandle(np, extcon, 0); + if (!node) + return ERR_PTR(-EINVAL); + edev = of_extcon_get_extcon_dev(node); + if (!edev) + return ERR_PTR(-ENODEV); + + if (!edev-supported_cable) + return ERR_PTR(-EINVAL); + + for (i = 0; edev-supported_cable[i]; ++i) { + if (!strncmp(edev-supported_cable[i], name, CABLE_NAME_MAX)) + return edev-cables[i]; + } + return ERR_PTR(-ENODEV); +} + +/* + * of_extcon_get_cable_by_name() - Get extcon cable from devicetree by name + * @np - devicetree node of client device + * @name - name of the cable specified in devicetree + * + * return the instance of extcon cable + */ +struct extcon_cable *of_extcon_get_cable_by_name(struct device_node *np, +
[PATCH 03/13] extcon: extcon-class: remove extcon_set_cable_state() function
This patch removes extcon_set_cable_state() and replace all calls of this function witch extcon_set_cable_state_(), which is faster version. This is first step of changing extcon API to faster and safer. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-class.c| 17 drivers/extcon/extcon-max14577.c | 24 ++-- drivers/extcon/extcon-max77693.c | 79 +++--- drivers/extcon/extcon-max8997.c | 32 +-- drivers/extcon/extcon-palmas.c | 27 + include/linux/extcon.h |8 6 files changed, 99 insertions(+), 88 deletions(-) diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index a45c5e9..1b98c4e 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -358,23 +358,6 @@ int extcon_set_cable_state_(struct extcon_dev *edev, EXPORT_SYMBOL_GPL(extcon_set_cable_state_); /** - * extcon_set_cable_state() - Set the status of a specific cable. - * @edev: the extcon device that has the cable. - * @cable_name:cable name. - * @cable_state: the new cable status. The default semantics is - * true: attached / false: detached. - * - * Note that this is slower than extcon_set_cable_state_. - */ -int extcon_set_cable_state(struct extcon_dev *edev, - const char *cable_name, bool cable_state) -{ - return extcon_set_cable_state_(edev, extcon_find_cable_index - (edev, cable_name), cable_state); -} -EXPORT_SYMBOL_GPL(extcon_set_cable_state); - -/** * extcon_get_extcon_dev() - Get the extcon device instance from the name * @extcon_name: The extcon name provided with extcon_dev_register() */ diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c index 3846941..7a947d3 100644 --- a/drivers/extcon/extcon-max14577.c +++ b/drivers/extcon/extcon-max14577.c @@ -333,7 +333,7 @@ static int max14577_muic_get_cable_type(struct max14577_muic_info *info, static int max14577_muic_jig_handler(struct max14577_muic_info *info, int cable_type, bool attached) { - char cable_name[32]; + int cable; int ret = 0; u8 path = CTRL1_SW_OPEN; @@ -344,17 +344,17 @@ static int max14577_muic_jig_handler(struct max14577_muic_info *info, switch (cable_type) { case MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF:/* ADC_JIG_USB_OFF */ /* PATH:AP_USB */ - strcpy(cable_name, JIG-USB-OFF); + cable = EXTCON_CABLE_JIG_USB_OFF; path = CTRL1_SW_USB; break; case MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */ /* PATH:AP_USB */ - strcpy(cable_name, JIG-USB-ON); + cable = EXTCON_CABLE_JIG_USB_ON; path = CTRL1_SW_USB; break; case MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */ /* PATH:AP_UART */ - strcpy(cable_name, JIG-UART-OFF); + cable = EXTCON_CABLE_JIG_UART_OFF; path = CTRL1_SW_UART; break; default: @@ -367,7 +367,7 @@ static int max14577_muic_jig_handler(struct max14577_muic_info *info, if (ret 0) return ret; - extcon_set_cable_state(info-edev, cable_name, attached); + extcon_set_cable_state_(info-edev, cable, attached); return 0; } @@ -464,20 +464,22 @@ static int max14577_muic_chg_handler(struct max14577_muic_info *info) if (ret 0) return ret; - extcon_set_cable_state(info-edev, USB, attached); + extcon_set_cable_state_(info-edev, EXTCON_CABLE_USB, attached); break; case MAX14577_CHARGER_TYPE_DEDICATED_CHG: - extcon_set_cable_state(info-edev, TA, attached); + extcon_set_cable_state_(info-edev, EXTCON_CABLE_TA, attached); break; case MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT: - extcon_set_cable_state(info-edev, - Charge-downstream, attached); + extcon_set_cable_state_(info-edev, + EXTCON_CABLE_CHARGE_DOWNSTREAM, attached); break; case MAX14577_CHARGER_TYPE_SPECIAL_500MA: - extcon_set_cable_state(info-edev, Slow-charger, attached); + extcon_set_cable_state_(info-edev, + EXTCON_CABLE_SLOW_CHARGER, attached); break; case MAX14577_CHARGER_TYPE_SPECIAL_1A: - extcon_set_cable_state(info-edev, Fast-charger, attached); + extcon_set_cable_state_(info-edev, + EXTCON_CABLE_FAST_CHARGER, attached); break; case
[PATCH 08/13] extcon: extcon-class: simplify extcon_updata_state() function
This patch simplifies extcon_updata_state() function. There is greatly simplified kobject_uevent preparation. Also meaning of variable passed to raw_notifier_call_chain() (and in effect to _call_per_cable()) has changed. Now positions on ones in variable 'val' in _call_per_cable() indicates numbers of cables which changed their status. It allowed to simplify also _call_per_cable() function. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-class.c | 81 - include/linux/extcon.h|1 - 2 files changed, 31 insertions(+), 51 deletions(-) diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 2659805..ce76c08 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -206,59 +206,48 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) { char name_buf[120]; char state_buf[120]; - char *prop_buf; + char *tmp; char *envp[3]; int env_offset = 0; int length; unsigned long flags; + u32 change; spin_lock_irqsave(edev-lock, flags); - if (edev-state != ((edev-state ~mask) | (state mask))) { - u32 old_state = edev-state; - - if (check_mutually_exclusive(edev, (edev-state ~mask) | - (state mask))) { + change = (edev-state mask) ^ (state mask); + if (change) { + if (check_mutually_exclusive(edev, edev-state ^ change)) { spin_unlock_irqrestore(edev-lock, flags); return -EPERM; } - edev-state = ~mask; - edev-state |= state mask; - - raw_notifier_call_chain(edev-nh, old_state, edev); - /* This could be in interrupt handler */ - prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); - if (prop_buf) { - length = name_show(edev-dev, NULL, prop_buf); - if (length 0) { - if (prop_buf[length - 1] == '\n') - prop_buf[length - 1] = 0; - snprintf(name_buf, sizeof(name_buf), - NAME=%s, prop_buf); - envp[env_offset++] = name_buf; - } - length = state_show(edev-dev, NULL, prop_buf); - if (length 0) { - if (prop_buf[length - 1] == '\n') - prop_buf[length - 1] = 0; - snprintf(state_buf, sizeof(state_buf), - STATE=%s, prop_buf); - envp[env_offset++] = state_buf; - } - envp[env_offset] = NULL; - /* Unlock early before uevent */ - spin_unlock_irqrestore(edev-lock, flags); + edev-state ^= change; - kobject_uevent_env(edev-dev.kobj, KOBJ_CHANGE, envp); - free_page((unsigned long)prop_buf); - } else { - /* Unlock early before uevent */ - spin_unlock_irqrestore(edev-lock, flags); + raw_notifier_call_chain(edev-nh, change, edev); + + tmp = name_buf + sprintf(name_buf, NAME=); + length = name_show(edev-dev, NULL, tmp); + if (length 0) { + if (tmp[length - 1] == '\n') + tmp[length - 1] = 0; + envp[env_offset++] = name_buf; + } - dev_err(edev-dev, out of memory in extcon_set_state\n); - kobject_uevent(edev-dev.kobj, KOBJ_CHANGE); + tmp = state_buf + sprintf(state_buf, STATE=); + length = state_show(edev-dev, NULL, tmp); + if (length 0) { + if (tmp[length - 1] == '\n') + tmp[length - 1] = 0; + envp[env_offset++] = state_buf; } + + envp[env_offset] = NULL; + + /* Unlock early before uevent */ + spin_unlock_irqrestore(edev-lock, flags); + + kobject_uevent_env(edev-dev.kobj, KOBJ_CHANGE, envp); } else { /* No changes */ spin_unlock_irqrestore(edev-lock, flags); @@ -464,18 +453,10 @@ static int _call_per_cable(struct notifier_block *nb, unsigned long val, { struct extcon_cable_nb *obj = container_of(nb, struct extcon_cable_nb, internal_nb); - struct extcon_dev *edev = ptr; - - if ((val (1 obj-cable-cable_index)) != - (edev-state (1
[PATCH 12/13] extcon: extcon-max8997: check if pdata exists
This patch adds check if pdata is NULL, to avoid NULL pointer dereference when platform data is not available. After this changes, in described situation driver will be configured with default values. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-max8997.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index c071588..d7d12e9 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -726,7 +726,7 @@ static int max8997_muic_probe(struct platform_device *pdev) goto err_irq; } - if (pdata-muic_pdata) { + if (pdata pdata-muic_pdata) { struct max8997_muic_platform_data *muic_pdata = pdata-muic_pdata; -- 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 13/13] extcon: extcon-max77693: check if pdata exists
This patch adds check if pdata is NULL, to avoid NULL pointer dereference when platform data is not available. After this changes, in described situation driver will be configured with default values. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-max77693.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index 2cd8892..fa8534e 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -1210,7 +1210,7 @@ static int max77693_muic_probe(struct platform_device *pdev) /* Initialize MUIC register by using platform data or default data */ - if (pdata-muic_data) { + if (pdata pdata-muic_data) { init_data = pdata-muic_data-init_data; num_init_data = pdata-muic_data-num_init_data; } else { -- 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 09/13] extcon: extcon-class: move example to Documentation
This patch removes cable array example form extcon code, to avoid littering driver namespace. Now it's located in extcon documentation. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- Documentation/extcon/extcon.txt | 108 +++ drivers/extcon/extcon-class.c | 32 include/linux/extcon.h | 42 --- 3 files changed, 108 insertions(+), 74 deletions(-) create mode 100644 Documentation/extcon/extcon.txt diff --git a/Documentation/extcon/extcon.txt b/Documentation/extcon/extcon.txt new file mode 100644 index 000..6713f5f --- /dev/null +++ b/Documentation/extcon/extcon.txt @@ -0,0 +1,108 @@ +Extcon - external connector +=== + +Extcon is generic framework used for notifying client drivers +about specific cable connections and disconnections. + +Provider API + + +Providers API consists of very few functions: + +extcon_dev_register() - register new extcon provider +extcon_dev_unregister() - unregister extcon provider + +extcon_get_cable_state_() - get specific cable state +extcon_set_cable_state_() - set specific cable state + +extcon_update_state() - update entire extcon state +extcon_set_state() - set entire extcon state + +There are few fields in struct extcon_dev to be filled before passing it +to extcon_dev_register() functions: + +name - name of extcon controller +node - devicetree node of parent device +supported_cable - array of strings with cable names ended with NULL pointer + +Example of cable array definition example can be found below: + + enum extcon_cable_name { + EXTCON_USB = 0, + EXTCON_USB_HOST, + EXTCON_TA, + EXTCON_FAST_CHARGER, + EXTCON_SLOW_CHARGER, + EXTCON_CHARGE_DOWNSTREAM, + EXTCON_HDMI, + EXTCON_MHL, + EXTCON_DVI, + EXTCON_VGA, + EXTCON_DOCK, + EXTCON_LINE_IN, + EXTCON_LINE_OUT, + EXTCON_MIC_IN, + EXTCON_HEADPHONE_OUT, + EXTCON_SPDIF_IN, + EXTCON_SPDIF_OUT, + EXTCON_VIDEO_IN, + EXTCON_VIDEO_OUT, + EXTCON_MECHANICAL, + }; + + const char *extcon_cable_name[] = { + [EXTCON_USB]= USB, + [EXTCON_USB_HOST] = USB-Host, + [EXTCON_TA] = TA, + [EXTCON_FAST_CHARGER] = Fast-charger, + [EXTCON_SLOW_CHARGER] = Slow-charger, + [EXTCON_CHARGE_DOWNSTREAM] = Charge-downstream, + [EXTCON_HDMI] = HDMI, + [EXTCON_MHL]= MHL, + [EXTCON_DVI]= DVI, + [EXTCON_VGA]= VGA, + [EXTCON_DOCK] = Dock, + [EXTCON_LINE_IN]= Line-in, + [EXTCON_LINE_OUT] = Line-out, + [EXTCON_MIC_IN] = Microphone, + [EXTCON_HEADPHONE_OUT] = Headphone, + [EXTCON_SPDIF_IN] = SPDIF-in, + [EXTCON_SPDIF_OUT] = SPDIF-out, + [EXTCON_VIDEO_IN] = Video-in, + [EXTCON_VIDEO_OUT] = Video-out, + [EXTCON_MECHANICAL] = Mechanical, + }; + +Cable name strings are used for debug messages and sysfs. + +After extcon device registration you can use functions modifying extcon state. +If any extcon clients will register their interests in some cables, they will +recieve notifications about cable state changes. + +Client API +== + +Extcon client API is also pretty simple. It consists of funtions: + +of_extcon_get_cable() - returns extcon_cable at selected index +of_extcon_get_cable_by_name() - returns extcon_cable associated with + selected name +extcon_get_cable_by_name() - the same as above, but takes struct device +instead of struct device_node + +extcon_register_interest() - register interest in selected cable +extcon_unregister_interest() - unregister cable interest + +extcon_get_cable_state() - get state of given cable + +The extcon_register_interest() function takes three parameters, +struct extcon_cable, struct extcon_cable_nb and extcon_notifier_fn_t +which is pointer to callback function called when cable state changes. + +There are also two functions: + +extcon_register_notifier() - register notifier for entire extcon state +extcon_unregister_notifier() - unregister such notifier + +But they should be used only for debug, and use of them in client drivers +is not recommended. diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index ce76c08..2ea9a84 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -33,38 +33,6 @@ #include linux/sysfs.h #include linux/of.h -/* - * extcon_cable_name suggests the
[PATCH 10/13] extcon: extcon-gpio: add devicetree support
This patch modifies extcon-gpio driver to use initialization data from devicetree if platform data is not available. It allows to set controller and cable names, and another parameters from devicetree bindings. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-gpio.c | 63 ++-- include/linux/extcon/extcon-gpio.h |2 +- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index fc90b7a..2a3cfd7 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -28,6 +28,8 @@ #include linux/slab.h #include linux/workqueue.h #include linux/gpio.h +#include linux/of.h +#include linux/of_gpio.h #include linux/extcon.h #include linux/extcon/extcon-gpio.h @@ -53,7 +55,7 @@ static void gpio_extcon_work(struct work_struct *work) state = gpio_get_value(data-gpio); if (data-gpio_active_low) state = !state; - extcon_set_state(data-edev, state); + extcon_set_cable_state_(data-edev, 0, state); } static irqreturn_t gpio_irq_handler(int irq, void *dev_id) @@ -70,7 +72,7 @@ static ssize_t extcon_gpio_print_state(struct extcon_dev *edev, char *buf) struct gpio_extcon_data *extcon_data = container_of(edev, struct gpio_extcon_data, edev); const char *state; - if (extcon_get_state(edev)) + if (extcon_get_cable_state_(edev, 0)) state = extcon_data-state_on; else state = extcon_data-state_off; @@ -80,17 +82,50 @@ static ssize_t extcon_gpio_print_state(struct extcon_dev *edev, char *buf) return -EINVAL; } +static struct gpio_extcon_platform_data *get_pdata_from_dt(struct device *dev) +{ + int ret; + struct gpio_extcon_platform_data *pdata = + devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + + ret = of_property_read_string_index(dev-of_node, + gpio-controller-name, 0, pdata-name); + if (ret) + return NULL; + + ret = of_property_read_string_index(dev-of_node, + gpio-cable-name, 0, pdata-cable_name); + if (ret) + return NULL; + + ret = of_property_read_u32_array(dev-of_node, + gpio-debounce, pdata-debounce, 0); + if (ret) + pdata-debounce = 0; + + pdata-gpio = of_get_gpio(dev-of_node, 0); + if (pdata-gpio 0) + return NULL; + + pdata-gpio_active_low = of_property_read_bool(dev-of_node, + gpio-active-low); + + pdata-check_on_resume = of_property_read_bool(dev-of_node, + check-on-resume); + return pdata; +} + static int gpio_extcon_probe(struct platform_device *pdev) { struct gpio_extcon_platform_data *pdata = dev_get_platdata(pdev-dev); struct gpio_extcon_data *extcon_data; + const char *gpio_extcon_cable[2]; int ret; - if (!pdata) - return -EBUSY; - if (!pdata-irq_flags) { - dev_err(pdev-dev, IRQ flag is not specified.\n); - return -EINVAL; + if (!pdata) { + pdata = get_pdata_from_dt(pdev-dev); + if (!pdata) + return -EINVAL; } extcon_data = devm_kzalloc(pdev-dev, sizeof(struct gpio_extcon_data), @@ -98,10 +133,14 @@ static int gpio_extcon_probe(struct platform_device *pdev) if (!extcon_data) return -ENOMEM; + gpio_extcon_cable[0] = pdata-cable_name; + gpio_extcon_cable[1] = NULL; + extcon_data-edev.name = pdata-name; extcon_data-edev.dev.parent = pdev-dev; extcon_data-edev.node = pdev-dev.of_node; extcon_data-gpio = pdata-gpio; + extcon_data-edev.supported_cable = gpio_extcon_cable; extcon_data-gpio_active_low = pdata-gpio_active_low; extcon_data-state_on = pdata-state_on; extcon_data-state_off = pdata-state_off; @@ -135,8 +174,8 @@ static int gpio_extcon_probe(struct platform_device *pdev) } ret = request_any_context_irq(extcon_data-irq, gpio_irq_handler, - pdata-irq_flags, pdev-name, - extcon_data); + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, + pdev-name, extcon_data); if (ret 0) goto err; @@ -177,6 +216,11 @@ static int gpio_extcon_resume(struct device *dev) } #endif +static struct of_device_id of_gpio_match_tbl[] = { + { .compatible = extcon-gpio, }, + { /* end */ }, +}; + static SIMPLE_DEV_PM_OPS(gpio_extcon_pm_ops, NULL, gpio_extcon_resume); static struct platform_driver gpio_extcon_driver = { @@ -184,6 +228,7 @@ static struct platform_driver
[PATCH 07/13] extcon: extcon-class: improve get_cable_state_()/set_cable_state_() functions
Added check if pointer to edev is not NULL, and updated documentation of index parameter. Function extcon_find_cable_index() has been deleted and cannot be used to retrieve cable number. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-class.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 2be0ac9..2659805 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -285,10 +285,12 @@ EXPORT_SYMBOL_GPL(extcon_set_state); /** * extcon_get_cable_state_() - Get the status of a specific cable. * @edev: the extcon device that has the cable. - * @index: cable index that can be retrieved by extcon_find_cable_index(). + * @index: cable index in extcon device. */ int extcon_get_cable_state_(struct extcon_dev *edev, int index) { + if (!edev) + return -ENODEV; if (index 0 || (edev-max_supported edev-max_supported = index)) return -EINVAL; @@ -312,8 +314,7 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state); /** * extcon_set_cable_state_() - Set the status of a specific cable. * @edev: the extcon device that has the cable. - * @index: cable index that can be retrieved by - * extcon_find_cable_index(). + * @index: cable index in extcon device. * @cable_state: the new cable status. The default semantics is * true: attached / false: detached. */ @@ -322,6 +323,8 @@ int extcon_set_cable_state_(struct extcon_dev *edev, { u32 state; + if (!edev) + return -ENODEV; if (index 0 || (edev-max_supported edev-max_supported = index)) return -EINVAL; -- 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 06/13] extcon: extcon-class: remove unused functions
This patch removes two functions, extcon_find_cable_index() and extcon_get_edev_by_phandle(). They are not longer needed, since extcon client API has changed to be oriented on extcon_cable instead of extcon_dev. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-class.c | 67 - include/linux/extcon.h| 18 --- 2 files changed, 85 deletions(-) diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 708b352..2be0ac9 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -283,32 +283,6 @@ int extcon_set_state(struct extcon_dev *edev, u32 state) EXPORT_SYMBOL_GPL(extcon_set_state); /** - * extcon_find_cable_index() - Get the cable index based on the cable name. - * @edev: the extcon device that has the cable. - * @cable_name:cable name to be searched. - * - * Note that accessing a cable state based on cable_index is faster than - * cable_name because using cable_name induces a loop with strncmp(). - * Thus, when get/set_cable_state is repeatedly used, using cable_index - * is recommended. - */ -int extcon_find_cable_index(struct extcon_dev *edev, const char *cable_name) -{ - int i; - - if (edev-supported_cable) { - for (i = 0; edev-supported_cable[i]; i++) { - if (!strncmp(edev-supported_cable[i], - cable_name, CABLE_NAME_MAX)) - return i; - } - } - - return -EINVAL; -} -EXPORT_SYMBOL_GPL(extcon_find_cable_index); - -/** * extcon_get_cable_state_() - Get the status of a specific cable. * @edev: the extcon device that has the cable. * @index: cable index that can be retrieved by extcon_find_cable_index(). @@ -876,47 +850,6 @@ void extcon_dev_unregister(struct extcon_dev *edev) } EXPORT_SYMBOL_GPL(extcon_dev_unregister); -#ifdef CONFIG_OF -/* - * extcon_get_edev_by_phandle - Get the extcon device from devicetree - * @dev - instance to the given device - * @index - index into list of extcon_dev - * - * return the instance of extcon device - */ -struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) -{ - struct device_node *node; - struct extcon_dev *edev; - - if (!dev-of_node) { - dev_err(dev, device does not have a device node entry\n); - return ERR_PTR(-EINVAL); - } - - node = of_parse_phandle(dev-of_node, extcon, index); - if (!node) { - dev_err(dev, failed to get phandle in %s node\n, - dev-of_node-full_name); - return ERR_PTR(-ENODEV); - } - - edev = of_extcon_get_extcon_dev(node); - if (!edev) { - dev_err(dev, unable to get extcon device : %s\n, node-name); - return ERR_PTR(-ENODEV); - } - - return edev; -} -#else -struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) -{ - return ERR_PTR(-ENOSYS); -} -#endif /* CONFIG_OF */ -EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle); - static int __init extcon_class_init(void) { return create_extcon_class(); diff --git a/include/linux/extcon.h b/include/linux/extcon.h index a571cad..939a7b0 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h @@ -210,8 +210,6 @@ extern int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state); * They are used to access the status of each cable based on the cable_name tt or cable_index, which is retrieved by extcon_find_cable_index */ -extern int extcon_find_cable_index(struct extcon_dev *sdev, - const char *cable_name); extern int extcon_get_cable_state_(struct extcon_dev *edev, int cable_index); extern int extcon_set_cable_state_(struct extcon_dev *edev, int cable_index, bool cable_state); @@ -252,11 +250,6 @@ extern int extcon_register_notifier(struct extcon_dev *edev, extern int extcon_unregister_notifier(struct extcon_dev *edev, struct notifier_block *nb); -/* - * Following API get the extcon device from devicetree. - * This function use phandle of devicetree to get extcon device directly. - */ -extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index); #else /* CONFIG_EXTCON */ static inline int extcon_dev_register(struct extcon_dev *edev) { @@ -281,12 +274,6 @@ static inline int extcon_update_state(struct extcon_dev *edev, u32 mask, return 0; } -static inline int extcon_find_cable_index(struct extcon_dev *edev, - const char *cable_name) -{ - return 0; -} - static inline int extcon_get_cable_state_(struct extcon_dev *edev, int cable_index) { @@ -341,10 +328,5 @@ static inline int extcon_unregister_interest(struct extcon_cable_nb
[PATCH] usb: ohci-exynos: Add facility to use phy provided by the generic phy framework
Add support to consume phy provided by Generic phy framework. Keeping the support for older usb-phy intact right now, in order to prevent any functionality break in absence of relevant device tree side change for ohci-exynos. Once we move to new phy in the device nodes for ohci, we can remove the support for older phys. Signed-off-by: Vivek Gautam gautam.vi...@samsung.com Cc: Jingoo Han jg1@samsung.com Cc: Alan Stern st...@rowland.harvard.edu --- Based on 'usb-next' branch of Greg's usb tree. Tested with local dt patches, similar to ehci dt changes posted by Kamil[1]. Tested on Exynos5250 smdk. [1] [PATCH v6 4/8] dts: Add usb2phy to Exynos 5250 https://lkml.org/lkml/2014/1/29/302 .../devicetree/bindings/usb/exynos-usb.txt | 14 drivers/usb/host/ohci-exynos.c | 79 ++-- 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt b/Documentation/devicetree/bindings/usb/exynos-usb.txt index d967ba1..ef0bc09 100644 --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt @@ -38,6 +38,10 @@ Required properties: - interrupts: interrupt number to the cpu. - clocks: from common clock binding: handle to usb clock. - clock-names: from common clock binding: Shall be usbhost. + - port: if in the SoC there are OHCI phys, they should be listed here. +One phy per port. Each port should have its reg entry with a consecutive +number. Also it should contain phys and phy-names entries specifying the +phy used by the port. Example: usb@1212 { @@ -47,6 +51,16 @@ Example: clocks = clock 285; clock-names = usbhost; + + #address-cells = 1; + #size-cells = 0; + port@0 { + reg = 0; + phys = usb2phy 1; + phy-names = host; + status = disabled; + }; + }; DWC3 diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index 68588d8..52eb821 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c @@ -18,6 +18,7 @@ #include linux/module.h #include linux/of.h #include linux/platform_device.h +#include linux/phy/phy.h #include linux/usb/phy.h #include linux/usb/samsung_usb_phy.h #include linux/usb.h @@ -37,6 +38,7 @@ struct exynos_ohci_hcd { struct clk *clk; struct usb_phy *phy; struct usb_otg *otg; + struct phy *phy_g; }; static void exynos_ohci_phy_enable(struct platform_device *pdev) @@ -57,12 +59,26 @@ static void exynos_ohci_phy_disable(struct platform_device *pdev) usb_phy_shutdown(exynos_ohci-phy); } +static int exynos_ohci_phyg_on(struct phy *phy, bool on) +{ + int ret = 0; + + if (phy) { + if (on) + ret = phy_power_on(phy); + else + ret = phy_power_off(phy); + } + + return ret; +} + static int exynos_ohci_probe(struct platform_device *pdev) { struct exynos_ohci_hcd *exynos_ohci; struct usb_hcd *hcd; struct resource *res; - struct usb_phy *phy; + struct device_node *child; int irq; int err; @@ -88,16 +104,49 @@ static int exynos_ohci_probe(struct platform_device *pdev) samsung,exynos5440-ohci)) goto skip_phy; - phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2); - if (IS_ERR(phy)) { - usb_put_hcd(hcd); - dev_warn(pdev-dev, no platform data or transceiver defined\n); - return -EPROBE_DEFER; + exynos_ohci-phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2); + if (IS_ERR(exynos_ohci-phy)) { + err = PTR_ERR(exynos_ohci-phy); + if (err == -ENXIO || err == -ENODEV) { + exynos_ohci-phy = NULL; + } else if (err == -EPROBE_DEFER) { + usb_put_hcd(hcd); + return err; + } else { + dev_err(pdev-dev, no usb2 phy configured\n); + usb_put_hcd(hcd); + return err; + } } else { - exynos_ohci-phy = phy; - exynos_ohci-otg = phy-otg; + exynos_ohci-otg = exynos_ohci-phy-otg; } + /* Getting generic phy: +* We are keeping both types of phys as a part of transiting OHCI +* to generic phy framework, so that in absence of supporting dts +* changes the functionality doesn't break. +* Once we move the ohci dt nodes to use new generic phys, +* we can remove support for older PHY in this driver. +*/ + child = of_get_next_child(pdev-dev.of_node, NULL); + exynos_ohci-phy_g =
[PATCH 04/13] extcon: extcon-class: match extcon device by devicetree node
This patch modifies extcon_get_edev_by_phandle() function, to match extcon device by devicetree node. This modification needed to add field 'node' in extcon_dev structure, and fill it in probe function of each extcon provider driver. This patch replaces also extcon_get_extcon_dev() function with of_extcon_get_extcon_dev(), returning extcon device which contains given devicetree node. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-adc-jack.c |1 + drivers/extcon/extcon-arizona.c |1 + drivers/extcon/extcon-class.c| 19 +-- drivers/extcon/extcon-gpio.c |1 + drivers/extcon/extcon-max14577.c |2 ++ drivers/extcon/extcon-max77693.c |1 + drivers/extcon/extcon-max8997.c |1 + drivers/extcon/extcon-palmas.c |1 + include/linux/extcon.h |8 ++-- 9 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index e23f1c2..d65915e 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c @@ -111,6 +111,7 @@ static int adc_jack_probe(struct platform_device *pdev) } data-edev.dev.parent = pdev-dev; + data-edev.node = pdev-dev.of_node; data-edev.supported_cable = pdata-cable_names; /* Check the length of array and set num_cables */ diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 98a14f6..fc69cca 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -1153,6 +1153,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) info-edev.name = Headset Jack; info-edev.dev.parent = arizona-dev; + info-edev.node = pdev-dev.of_node; info-edev.supported_cable = arizona_cable; ret = extcon_dev_register(info-edev); diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 1b98c4e..1075ce8 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -358,24 +358,23 @@ int extcon_set_cable_state_(struct extcon_dev *edev, EXPORT_SYMBOL_GPL(extcon_set_cable_state_); /** - * extcon_get_extcon_dev() - Get the extcon device instance from the name - * @extcon_name: The extcon name provided with extcon_dev_register() + * of_extcon_get_extcon_dev() - Get the extcon device instance from the name + * @np: The node of extcon device */ -struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name) +struct extcon_dev *of_extcon_get_extcon_dev(const struct device_node *np) { - struct extcon_dev *sd; + struct extcon_dev *edev; mutex_lock(extcon_dev_list_lock); - list_for_each_entry(sd, extcon_dev_list, entry) { - if (!strcmp(sd-name, extcon_name)) + list_for_each_entry(edev, extcon_dev_list, entry) { + if (edev-node == np) goto out; } - sd = NULL; + edev = NULL; out: mutex_unlock(extcon_dev_list_lock); - return sd; + return edev; } -EXPORT_SYMBOL_GPL(extcon_get_extcon_dev); static int _call_per_cable(struct notifier_block *nb, unsigned long val, void *ptr) @@ -827,7 +826,7 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) return ERR_PTR(-ENODEV); } - edev = extcon_get_extcon_dev(node-name); + edev = of_extcon_get_extcon_dev(node); if (!edev) { dev_err(dev, unable to get extcon device : %s\n, node-name); return ERR_PTR(-ENODEV); diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 13d5222..fc90b7a 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -100,6 +100,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) extcon_data-edev.name = pdata-name; extcon_data-edev.dev.parent = pdev-dev; + extcon_data-edev.node = pdev-dev.of_node; extcon_data-gpio = pdata-gpio; extcon_data-gpio_active_low = pdata-gpio_active_low; extcon_data-state_on = pdata-state_on; diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c index 7a947d3..b017a0d 100644 --- a/drivers/extcon/extcon-max14577.c +++ b/drivers/extcon/extcon-max14577.c @@ -676,6 +676,8 @@ static int max14577_muic_probe(struct platform_device *pdev) return -ENOMEM; } info-edev-name = DEV_NAME; + info-edev-dev.parent = pdev-dev; + info-edev-node = pdev-dev.of_node; info-edev-supported_cable = max14577_extcon_cable; ret = extcon_dev_register(info-edev); if (ret) { diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index 7a014cd..2cd8892 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -1200,6 +1200,7 @@ static int max77693_muic_probe(struct
[PATCH 01/13] Documentation: add extcon devicetree bindings
This patch adds extcon devicetree bindings. Documentation describes in general client and provider bindings, and contains detailed desctiprion of bindings for each extcon provider. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- .../devicetree/bindings/extcon/extcon-adc-jack.txt | 60 +++ .../devicetree/bindings/extcon/extcon-arizona.txt | 47 +++ .../devicetree/bindings/extcon/extcon-bindings.txt | 36 +++ .../devicetree/bindings/extcon/extcon-gpio.txt | 63 .../devicetree/bindings/extcon/extcon-max14577.txt | 49 +++ .../devicetree/bindings/extcon/extcon-max77693.txt | 56 + .../devicetree/bindings/extcon/extcon-max8997.txt | 49 +++ .../devicetree/bindings/extcon/extcon-palmas.txt | 37 ++-- 8 files changed, 393 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/extcon/extcon-adc-jack.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-arizona.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-bindings.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-gpio.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-max14577.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-max77693.txt create mode 100644 Documentation/devicetree/bindings/extcon/extcon-max8997.txt diff --git a/Documentation/devicetree/bindings/extcon/extcon-adc-jack.txt b/Documentation/devicetree/bindings/extcon/extcon-adc-jack.txt new file mode 100644 index 000..6e43891 --- /dev/null +++ b/Documentation/devicetree/bindings/extcon/extcon-adc-jack.txt @@ -0,0 +1,60 @@ +* ADC JACK Extcon Controller + +ADC JACK extcon controller is responsible for cable detection. + +Required Properties: + +- compatible: should be extcon-adc-jack. + +- #extcon-cells: should be 1. + +- subnode cables: node describing list of cables. + - subnode cable: + - cable-name: name of specific cable + - adc-min: minimum specific cable ADC values range + - adc-max: maximum specific cable ADC values range + +Subnodes of node 'cables' describes specific cables with ADC value ranges +associated with this cables. When measured ADC value will be between min and +max value for specific cable, clients will be notified about connection of +this cable. Value ranges for individual cables cannot be overlaping. + +Example 1: An example of a extcon controller node is listed below. + + extcon: adc-jack { + compatible = extcon-adc-jack; + #extcon-cells = 1; + + cables { + cable@0 { + cable-name = CABLE-0; + adc-min = 120; + adc-max = 240; + } + cable@1 { + cable-name = CABLE-1; + adc-min = 250; + adc-max = 400; + } + cable@2 { + cable-name = CABLE-2; + adc-min = 500; + adc-max = 700; + }; + }; + }; + +Example 2: USB controller node that uses cable from the extcon + controller. Refer to the standard extcon bindings for + information about 'extcon-cables' and 'extcon-names' + property. + + usb@1248 { + vusb_d-supply = vusb_reg; + vusb_a-supply = vusbdac_reg; + + extcon-cables = extcon 0; + extcon-names = USB; + + status = okay; + }; diff --git a/Documentation/devicetree/bindings/extcon/extcon-arizona.txt b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt new file mode 100644 index 000..9af4422 --- /dev/null +++ b/Documentation/devicetree/bindings/extcon/extcon-arizona.txt @@ -0,0 +1,47 @@ +* Wolfson Arizona Extcon Controller + +The Wolfson Arizona Extcon Controller is responsible for cable +detection. + +Required Properties: + +- compatible: should be wlf,arizona-extcon. + +- #extcon-cells: should be 1. + +The following is the list of cables detected by the controller. Each +cable is assigned an identifier and client nodes use this identifies +to specify the cable which they are interested in. + + CableID + + + Mechanical 0 + Microphone 1 + Headphone2 + Line-out 3 + +Example 1: An example of a extcon controller node is listed below. + + extcon: arizona-extcon { + compatible = wlf,arizona-extcon; + #extcon-cells = 1; + }; + +Example 2: Audio controller node that uses cable from the extcon + controller. Refer to the standard extcon
[PATCH 11/13] extcon: extcon-adc-jack: add devicetree support
This patch modifies extcon-adc-jack driver to use initialization data from devicetree, when platform data is not available. It allows to define cable list with ADC value ranges for each of them in devicetree bindings. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-adc-jack.c | 74 ++ 1 file changed, 74 insertions(+) diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index d65915e..293871b1 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c @@ -21,6 +21,7 @@ #include linux/err.h #include linux/interrupt.h #include linux/workqueue.h +#include linux/of.h #include linux/iio/consumer.h #include linux/extcon/extcon-adc-jack.h #include linux/extcon.h @@ -92,12 +93,78 @@ static irqreturn_t adc_jack_irq_thread(int irq, void *_data) return IRQ_HANDLED; } +static struct adc_jack_pdata *get_pdata_from_dt(struct device *dev) +{ + int ret, cnt, i; + struct device_node *cables_np, *child; + struct adc_jack_pdata *pdata = + devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + + ret = of_property_read_string_index(dev-of_node, + adc-name, 0, pdata-name); + if (ret) + return NULL; + + ret = of_property_read_string_index(dev-of_node, + adc-consumer-channel, 0, pdata-consumer_channel); + if (ret) + return NULL; + + cables_np = of_find_node_by_name(dev-of_node, cables); + if (!cables_np) + return NULL; + + cnt = of_get_child_count(cables_np); + if (cnt = 0) + return NULL; + + pdata-cable_names = devm_kcalloc(dev, cnt+1, + sizeof(*pdata-cable_names), GFP_KERNEL); + if (!pdata-cable_names) + return NULL; + + pdata-adc_conditions = devm_kcalloc(dev, cnt+1, + sizeof(*pdata-adc_conditions), GFP_KERNEL); + if (!pdata-adc_conditions) + return NULL; + + i = 0; + for_each_child_of_node(cables_np, child) { + ret = of_property_read_string_index(child, + cable-name, 0, pdata-cable_names[i]); + if (ret) + return NULL; + + pdata-adc_conditions[i].state = (1i); + + ret = of_property_read_u32_array(child, adc-min, + pdata-adc_conditions[i].min_adc, 0); + if (ret) + return NULL; + + ret = of_property_read_u32_array(child, adc-max, + pdata-adc_conditions[i].max_adc, 0); + if (ret) + return NULL; + + i++; + } + + return pdata; +} + static int adc_jack_probe(struct platform_device *pdev) { struct adc_jack_data *data; struct adc_jack_pdata *pdata = dev_get_platdata(pdev-dev); int i, err = 0; + if (!pdata) { + pdata = get_pdata_from_dt(pdev-dev); + if (!pdata) + return -EINVAL; + } + data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -188,11 +255,18 @@ static int adc_jack_remove(struct platform_device *pdev) return 0; } +static struct of_device_id of_adc_jack_match_tbl[] = { + { .compatible = extcon-adc-jack, }, + { /* end */ }, +}; + + static struct platform_driver adc_jack_driver = { .probe = adc_jack_probe, .remove = adc_jack_remove, .driver = { .name = adc-jack, + .of_match_table = of_adc_jack_match_tbl, .owner = THIS_MODULE, }, }; -- 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
Darlehen Angebot
Wir bieten privaten und gewerblichen Darlehen ohne Sicherheiten (nur Identifikation) bei 3% Zinssatz, ab € 10.000 bis € 90.000.000 in 1 Jahr bis 20 Jahren Laufzeit überall in der Welt.. -- 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: MUSB/OMAP: gadget does not start when cable is plugged after the driver is started
Hi Felipe, On 08.04.2014 16:31, Felipe Balbi wrote: diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 819a7cd..d369bf1 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -316,7 +316,13 @@ static void omap_musb_mailbox_work(struct work_struct *mailbox_work) { struct omap2430_glue *glue = container_of(mailbox_work, struct omap2430_glue, omap_musb_mailbox_work); + struct musb *musb = glue_to_musb(glue); + struct device *dev = musb-controller; + + pm_runtime_get_sync(dev); omap_musb_set_mailbox(glue); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); } static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci) let me know The crash doesn't appear anymore with this patch. But the ethernet gadget is not started. This happens also with a plugged cable upon driver startup. Now I see an error in the log: [2.793121] musb-hdrc musb-hdrc.0.auto: VBUS_ERROR in b_idle (80, SessEnd), retry #0, port1 0100 that shouldn't happen... Can you add some extra debugging prints and try to figure out what's going on ? Unfortunately I can't reproduce this error. And the crash is also not happening right now. Seems to be very timing sensitive. Still with both patches applied, the ethernet gadget is only started correctly (with cable connected after driver loading) when I add some printk's. This one helps for example: static void musb_do_idle(unsigned long _musb) { struct musb *musb = (void *)_musb; unsigned long flags; u8 power; u8 devctl; #if 1 // test-only: this helps as well with gadget to connect printk(*** %s (%d): state=%d\n, __func__, __LINE__, musb-xceiv-state); // test-only #endif Without this printk the gadget is not started upon cable insertion. No MUSB interrupts occur when the USB cable is connected. There seems to be some timing dependency which I fail to solve quickly. The original locations (removed with [1]) for phy_power_on() and phy_power_off() don't suffer these timing / printk dependencies. Any ideas? Thanks, Stefan [1] 30a70b02 (usb: musb: fix obex in g_nokia.ko causing kernel panic) -- 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: problem with resume after s2ram
On Tue, Apr 01 2014, Alan Stern wrote: Should I do another git-bisect? Yes, that would be a good idea. Hi Alan, Here is the result: e583d9db9960cf40e0bc8afee4946baa9d71596e is the first bad commit commit e583d9db9960cf40e0bc8afee4946baa9d71596e Author: Alan Stern st...@rowland.harvard.edu Date: Thu Jul 11 14:58:04 2013 -0400 USB: global suspend and remote wakeup don't mix -- Peter -- 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 v2 1/2] usb: ehci-exynos: Return immediately from suspend if ehci_suspend fails
On Thu, 10 Apr 2014, Vivek Gautam wrote: Patch 'b8efdaf USB: EHCI: add check for wakeup/suspend race' adds a check for possible race between suspend and wakeup interrupt, and thereby it returns -EBUSY as error code if there's a wakeup interrupt. So the platform host controller should not proceed further with its suspend callback, rather should return immediately to avoid powering down the essential things, like phy. Signed-off-by: Vivek Gautam gautam.vi...@samsung.com Acked-by: Jingoo Han jg1@samsung.com Cc: Alan Stern st...@rowland.harvard.edu --- Changes from v1: -- Removed unnecessary change 'return 0' drivers/usb/host/ehci-exynos.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index d1d8c47..7f425ac 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -212,6 +212,8 @@ static int exynos_ehci_suspend(struct device *dev) int rc; rc = ehci_suspend(hcd, do_wakeup); + if (rc) + return rc; if (exynos_ehci-otg) exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self); Acked-by: Alan Stern st...@rowland.harvard.edu -- 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: Fwd: Isochronos audio
On Thu, 10 Apr 2014, David Laight wrote: You also definitely don't want to cancel an isoc urb. Doing so is likely to corrupt the kernel heap. If an isoc urb generates multiple TRB the code allocates a little structure 'per TRB' and links it to the urb. This seems to be done so that it can tell when all the TRB have finished so that it can complete the urb. However if a transfer is aborted they get freed individually, but they were allocated as a single item. I actually suspect the driver doesn't care about the early TRB, so shouldn't need the list at all. You've got it backward: We _do_ want to cancel isochronous URBs sometimes. If doing so will corrupt the kernel heap then the driver needs to be fixed. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/2] usb: ehci-platform: Return immediately from suspend if ehci_suspend fails
On Thu, 10 Apr 2014, Vivek Gautam wrote: Patch 'b8efdaf USB: EHCI: add check for wakeup/suspend race' adds a check for possible race between suspend and wakeup interrupt, and thereby it returns -EBUSY as error code if there's a wakeup interrupt. So the platform host controller should not proceed further with its suspend callback, rather should return immediately to avoid powering down the essential things, like phy. Signed-off-by: Vivek Gautam gautam.vi...@samsung.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Hauke Mehrtens ha...@hauke-m.de Cc: Hans de Goede hdego...@redhat.com --- Changes from v1: -- Removed unnecessary change 'return 0' drivers/usb/host/ehci-platform.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index b3a0e11..c7dd93a 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -303,6 +303,8 @@ static int ehci_platform_suspend(struct device *dev) int ret; ret = ehci_suspend(hcd, do_wakeup); + if (ret) + return ret; if (pdata-power_suspend) pdata-power_suspend(pdev); Acked-by: Alan Stern st...@rowland.harvard.edu -- 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 0/3] Fix USB deadlock caused by SCSI error handling
On Thu, 10 Apr 2014, Hannes Reinecke wrote: On 04/10/2014 12:58 PM, Andreas Reis wrote: That patch appears to work in preventing the crashes, judged on one repeated appearance of the bug. dmesg had the usual [ 215.229903] usb 4-2: usb_disable_lpm called, do nothing [ 215.336941] usb 4-2: reset SuperSpeed USB device number 3 using xhci_hcd [ 215.350296] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b829c0 [ 215.350305] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b82a08 [ 215.350621] usb 4-2: usb_enable_lpm called, do nothing repeated five times, followed by one [ 282.795801] sd 8:0:0:0: Device offlined - not ready after error recovery and then as often as something tried to read from it: [ 295.585472] sd 8:0:0:0: rejecting I/O to offline device The stick could then be properly un- and remounted (the latter if it had been physically replugged) without issue � for the bug to reoccur after one to three minutes. I tried this three times, no dmesg difference except the ep addresses varied on two of that. Was this just that patch you've tested with or the entire patch series? If the latter, Alan, is this the expected outcome? Yes, it is. The same thing should happen with the entire patch series. I would've thought the error recover should _not_ run into offlining devices here, but rather the device should be recovered eventually. The command times out, it is aborted, and the command is retried. The same thing happens, and we repeat five times. Eventually the SCSI core gives up and declares the device to be offline. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: problem with resume after s2ram
On Thu, 10 Apr 2014, Peter Münster wrote: On Tue, Apr 01 2014, Alan Stern wrote: Should I do another git-bisect? Yes, that would be a good idea. Hi Alan, Here is the result: e583d9db9960cf40e0bc8afee4946baa9d71596e is the first bad commit commit e583d9db9960cf40e0bc8afee4946baa9d71596e Author: Alan Stern st...@rowland.harvard.edu Date: Thu Jul 11 14:58:04 2013 -0400 USB: global suspend and remote wakeup don't mix I should have guessed... :-( This is surprising, because this commit partially reverses the effect of the other one. I don't see how it would make anything worse. At some point I'll send you two more diagnostic patches, one for testing with this commit applied and one for testing with this commit reverted. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: system hang
On Thu, Apr 10, 2014 at 07:59:38AM +, Narasimharao Bolisetti wrote: Hi, I have checked the same in the recent kernel versions also. Issue is still remain. What versions have you tried, and what are the logs from those versions? ::DISCLAIMER:: The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects. Oops, sorry, nope, I'm not allowed to respond to anyone with such an email footer, it's not compatible with Linux kernel development (Linux is not confidential.) Best of luck, I suggest you work with the vendor who is forcing you to stick with such an old kernel version. 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: [PATCH 0/3] Fix USB deadlock caused by SCSI error handling
On 04/10/2014 05:31 PM, Alan Stern wrote: On Thu, 10 Apr 2014, Hannes Reinecke wrote: On 04/10/2014 12:58 PM, Andreas Reis wrote: That patch appears to work in preventing the crashes, judged on one repeated appearance of the bug. dmesg had the usual [ 215.229903] usb 4-2: usb_disable_lpm called, do nothing [ 215.336941] usb 4-2: reset SuperSpeed USB device number 3 using xhci_hcd [ 215.350296] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b829c0 [ 215.350305] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b82a08 [ 215.350621] usb 4-2: usb_enable_lpm called, do nothing repeated five times, followed by one [ 282.795801] sd 8:0:0:0: Device offlined - not ready after error recovery and then as often as something tried to read from it: [ 295.585472] sd 8:0:0:0: rejecting I/O to offline device The stick could then be properly un- and remounted (the latter if it had been physically replugged) without issue � for the bug to reoccur after one to three minutes. I tried this three times, no dmesg difference except the ep addresses varied on two of that. Was this just that patch you've tested with or the entire patch series? If the latter, Alan, is this the expected outcome? Yes, it is. The same thing should happen with the entire patch series. I would've thought the error recover should _not_ run into offlining devices here, but rather the device should be recovered eventually. The command times out, it is aborted, and the command is retried. The same thing happens, and we repeat five times. Eventually the SCSI core gives up and declares the device to be offline. Hmm. Ok. If you are fine with it who am I to argue here. James, shall I resent the patch series? Cheers, Hannes -- Dr. Hannes Reinecke zSeries Storage h...@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- 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 05/13] extcon: extcon-class: improve extcon client API
Hi, On Thu, Apr 10, 2014 at 03:16:43PM +0200, Robert Baldyga wrote: +struct extcon_cable *extcon_get_cable_by_name(struct device *dev, + const char *name) +{ + return of_extcon_get_cable_by_name(dev-of_node, name); +} +EXPORT_SYMBOL_GPL(extcon_get_cable_by_name); [...] @@ -96,17 +95,13 @@ static int omap_otg_probe(struct platform_device *pdev) { const struct omap_usb_config *config = pdev-dev.platform_data; ^ [...] - ret = extcon_register_interest(otg_dev-id_dev, config-extcon, -USB-HOST, otg_dev-id_nb); + cable_id = extcon_get_cable_by_name(pdev-dev, USB-HOST); NACK. OMAP1 is not using DT, so this driver would stop working with this series. A. -- 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
libusbg and vbus detection for UDC driver
Hi all, On first sight it seems that the two things in the subject have nothing to do with each other, so I will quickly explain why they do (at least for me). So for some time already I have been working on usb_moded, which is a small daemon which handles setting up gadget drivers, so that a device can offer several different levels of functionality (for this it is also capable of setting up network and start/stop services over dbus/systemd/upstart when needed) Now I would like to add support for the new gadgetfs. And there I run into two issues. 1. It seems that libusbg from Matt Porter seems the library to use. Is that correct? I saw patches on the mailing list, but they did not seem to have made it to: https://github.com/libusbg/libusbg Is this the correct place, and should patches be sent to the mailing list here? I also pushed it through a coverity scan already and have a nice to do list. 2. I am playing around on a ATSAM5D36-EK and I tried to use that as a testing platform. Now the USB udc etc works fine. But there is no real way to detect the insertion of a cable. Most udc drivers seem to track vbus but this is not exposed. So I added a vbus attribute to the base udc, but this only works when a gadget driver is actually loaded. So as long as a gadget is active I can see the attribute change. (A possible work-around would be a gadget driver just to detect vbus, but that is a bit insane) What would be the best way to track cable insertion and expose it in some way? As in this case I cannot short-cut it by using a power_supply class type of device. And just to be sure I would like to find a way that would be acceptable upstream. Cheers, Philippe -- 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 0/3] Fix USB deadlock caused by SCSI error handling
On Thu, 2014-04-10 at 19:52 +0200, Hannes Reinecke wrote: On 04/10/2014 05:31 PM, Alan Stern wrote: On Thu, 10 Apr 2014, Hannes Reinecke wrote: On 04/10/2014 12:58 PM, Andreas Reis wrote: That patch appears to work in preventing the crashes, judged on one repeated appearance of the bug. dmesg had the usual [ 215.229903] usb 4-2: usb_disable_lpm called, do nothing [ 215.336941] usb 4-2: reset SuperSpeed USB device number 3 using xhci_hcd [ 215.350296] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b829c0 [ 215.350305] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b82a08 [ 215.350621] usb 4-2: usb_enable_lpm called, do nothing repeated five times, followed by one [ 282.795801] sd 8:0:0:0: Device offlined - not ready after error recovery and then as often as something tried to read from it: [ 295.585472] sd 8:0:0:0: rejecting I/O to offline device The stick could then be properly un- and remounted (the latter if it had been physically replugged) without issue � for the bug to reoccur after one to three minutes. I tried this three times, no dmesg difference except the ep addresses varied on two of that. Was this just that patch you've tested with or the entire patch series? If the latter, Alan, is this the expected outcome? Yes, it is. The same thing should happen with the entire patch series. I would've thought the error recover should _not_ run into offlining devices here, but rather the device should be recovered eventually. The command times out, it is aborted, and the command is retried. The same thing happens, and we repeat five times. Eventually the SCSI core gives up and declares the device to be offline. Hmm. Ok. If you are fine with it who am I to argue here. James, shall I resent the patch series? You mean the one patch? No, it's OK, I have it. It's still not complete, though, as I've said a couple of times. The problem is that we have abort memory on any eh command as well, which this doesn't fix. The scenario is abort command, set flag, abort completes, send TUR, TUR doesn't return, so we now try to abort the TUR, but scsi_abort_eh_cmnd() will skip the abort because the flag is set and move straight to reset. The fix is this, I can just add it as well. James --- diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 771c16b..7516e2c 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -920,6 +920,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses, ses-prot_op = scmd-prot_op; scmd-prot_op = SCSI_PROT_NORMAL; + scmd-eh_eflags = 0; scmd-cmnd = ses-eh_cmnd; memset(scmd-cmnd, 0, BLK_MAX_CDB); memset(scmd-sdb, 0, sizeof(scmd-sdb)); -- 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: libusbg and vbus detection for UDC driver
On Thu, Apr 10, 2014 at 11:24:49PM +0300, Philippe De Swert wrote: Hi all, On first sight it seems that the two things in the subject have nothing to do with each other, so I will quickly explain why they do (at least for me). So for some time already I have been working on usb_moded, which is a small daemon which handles setting up gadget drivers, so that a device can offer several different levels of functionality (for this it is also capable of setting up network and start/stop services over dbus/systemd/upstart when needed) Now I would like to add support for the new gadgetfs. And there I run into two issues. 1. It seems that libusbg from Matt Porter seems the library to use. Is that correct? I saw patches on the mailing list, but they did not seem to have made it to: https://github.com/libusbg/libusbg I think it's the right choice. :) As of last week, all but the latest two series that have been posted have been merged to master as I work through some backlog in my copious spare time. Is this the correct place, and should patches be sent to the mailing list here? I also pushed it through a coverity scan already and have a nice to do list. Yes, please post patches here. Bug fixes and new features are very welcome. On my TODO list is to update docs to explain submitting patches should occur on this list so we get wider code review. That's how we've been doing things so far. 2. I am playing around on a ATSAM5D36-EK and I tried to use that as a testing platform. Now the USB udc etc works fine. But there is no real way to detect the insertion of a cable. Most udc drivers seem to track vbus but this is not exposed. So I added a vbus attribute to the base udc, but this only works when a gadget driver is actually loaded. So as long as a gadget is active I can see the attribute change. (A possible work-around would be a gadget driver just to detect vbus, but that is a bit insane) What would be the best way to track cable insertion and expose it in some way? As in this case I cannot short-cut it by using a power_supply class type of device. And just to be sure I would like to find a way that would be acceptable upstream. An extcon driver would be appropriate. It's specifically meant for this use case. You can then monitor the state of your USB cable with sysfs or uevents from userspace. -Matt -- 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: problem with resume after s2ram
On Wed, Apr 02 2014, Alan Stern wrote: Below is 0aa2832dd0d9d860 back-ported to 3.9. Please try testing a 3.9 kernel with this patch installed (and also the first diagnostic patch, if it applies with no errors), with CONFIG_USB_SUSPEND _enabled_ and the mouse plugged into the rear port. If this combination works, then maybe you can do yet another git-bisect. Search between 3.9 and 0aa2832dd0d9d860, and at each step merge this patch into the kernel you are testing before you build it. No, it does not work. Please find attached the log. -- Peter [ 207.379865] PM: Syncing filesystems ... done. [ 207.446504] PM: Preparing system for mem sleep [ 207.453621] ohci_hcd :00:12.1: Dequeue: 880122086cc0 count 1 [ 207.454080] ohci_hcd :00:12.1: IRQ: count 1 intr-en 805e intr-stat 24 frame 25e6 [ 207.454119] ohci_hcd :00:12.1: Giveback: 880122086cc0 count 1 [ 207.467685] Freezing user space processes ... (elapsed 0.01 seconds) done. [ 207.479603] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done. [ 207.490595] PM: Entering mem sleep [ 207.491304] usb 4-3: usb suspend, wakeup 0 [ 207.491460] ohci_hcd :00:13.1: Dequeue: 880122086300 count 1 [ 207.491474] sd 2:0:0:0: [sdb] Synchronizing SCSI cache [ 207.491546] usb 2-3: usb suspend, wakeup 0 [ 207.491594] sd 0:0:0:0: [sda] Synchronizing SCSI cache [ 207.491799] usb usb7: usb auto-resume [ 207.491829] ohci_hcd :00:14.5: resume root hub [ 207.491879] usb usb5: usb auto-resume [ 207.491902] ohci_hcd :00:13.0: resume root hub [ 207.492043] ohci_hcd :00:13.1: IRQ: count 1 intr-en 805e intr-stat 24 frame 259e [ 207.492207] ohci_hcd :00:13.1: Giveback: 880122086300 count 1 [ 207.492439] hub 4-0:1.0: hub_suspend [ 207.492482] usb usb4: bus suspend, wakeup 0 [ 207.492507] ohci_hcd :00:12.1: suspend root hub [ 207.492603] usb usb3: usb auto-resume [ 207.492665] ohci_hcd :00:12.0: resume root hub [ 207.492754] hub 2-0:1.0: hub_suspend [ 207.492788] usb usb2: bus suspend, wakeup 0 [ 207.492810] ehci-pci :00:13.2: suspend root hub [ 207.492875] usb usb1: usb auto-resume [ 207.492967] ehci-pci :00:12.2: resume root hub [ 207.493059] usb 6-3: usb suspend, wakeup 1 [ 210.437072] r8169 :02:00.0 eth0: link up [ 212.542512] ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300) [ 212.566103] ata3.00: configured for UDMA/133 [ 212.570950] sd 2:0:0:0: [sdb] Starting disk [ 213.739414] ohci_hcd :00:12.1: Dequeue: 8800cc7ed180 count 1 [ 213.794366] ohci_hcd :00:13.1: Dequeue: 8800cfafb840 count 1 [ 213.796714] ohci_hcd :00:13.1: IRQ: count 1 intr-en 805a intr-stat 24 frame 25f0 [ 214.270943] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300) [ 214.288910] ata1.00: configured for UDMA/133 [ 214.293936] sd 0:0:0:0: [sda] Starting disk [ 223.747318] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 223.811297] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 233.754254] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 233.818228] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 243.761180] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 243.825161] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 253.768112] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 253.832091] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 263.775042] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 263.839021] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 273.781972] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 273.845952] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 283.788901] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 283.852879] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 293.795830] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 293.859810] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 303.802759] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 303.866746] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 313.809685] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 313.873665] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 323.816613] ohci_hcd :00:12.1: Timer: count 1 intr-en 805e intr-stat 20 frame 2627 [ 323.880592] ohci_hcd :00:13.1: Timer: count 1 intr-en 805e intr-stat 20 frame 25f0 [ 333.823531] ohci_hcd :00:12.1: Timer:
Re: problem with resume after s2ram
On Thu, Apr 10 2014, Alan Stern wrote: I should have guessed... :-( Next time, we can try some guesses before bisecting, right? -- Peter -- 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] cdc-acm: some enhancement on acm delayed write
Hi, Oliver, On 04/10/2014 04:02 PM, Oliver Neukum wrote: On Wed, 2014-04-09 at 22:57 +0800, Xiao Jin wrote: Thanks all for the review. We meet with the problems when developing product. I would like to explain my understanding. On 04/08/2014 11:05 AM, Xiao Jin wrote: We find two problems on acm tty write delayed mechanism. (1) When acm resume, the delayed wb will be started. But now only one write can be saved during acm suspend. More acm write may be abandoned. The scenario usually happened when user space write series AT after acm suspend. If acm accept the first AT, what's the reason for acm to refuse the second AT? If write return 0, user space will try repeatedly until resume. It looks simpler that acm accept all the data and sent out urb when resume. No. We cannot accept an arbitrary amount of data. It would let any user OOM the system. There will have to be an arbitrary limit. The simplest limit is 1 urb. And that is because we said that we are ready to accept data. We apply cdc-acm for modem AT data. I can find other usb modem driver usb_wwan_write use list to accept more data when suspend, maybe usbnet is the same. Do you have any more reason for me to understand why cdc-acm accept only one? (2) acm tty port ASYNCB_INITIALIZED flag will be cleared when close. If acm resume callback run after ASYNCB_INITIALIZED flag cleared, there will have no chance for delayed write to start. That lead to acm_wb.use can't be cleared. If user space open acm tty again and try to setd, tty will be blocked in tty_wait_until_sent for ever. We see tty write and close concurrently after acm suspend in this case. It looks no method to avoid it from tty layer. acm_tty_write and There is a delay user space can set. acm_resume call after acm_port_shutdown. It looks any action in acm_port_shutdown can't solve the problem. As acm has accepted the user space data, we can only find a way to send out urb. I feel anyway to discard the data looks like a lie to user space. In my understanding acm should accept data as much as possible, and send out urb as soon as possible. What do you think of? There's certainly no problem with sending out the data. Yet simply resuming the device in shutdown() should do the job. We see tty write and close concurrently, we have debug log to show that acm_tty_write and acm_resume is called after acm_port_shutdown, I don't understand resuming the device in shutdown() should do the job. Regards Oliver My understanding may be superficial, please correct me if anything wrong. Thanks. Br, Jin -- 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: How to put the io_ti driver in RS485 mode?
Thanks for your input. I tried the following: I created the file /etc/modprobe.d/io_ti.conf with the contents of options io_ti default_uart_mode=9 This successfully started the io_ti module with the default_uart_mode=9. I verified this by cat /sys/module/io_ti/parameters/default_uart_mode which showed that the mode was now = 9, it had been set to 0. The 0=RS232 mode. The 9=RS485 full duplex, end unit, master. This definitely had an effect on the io_ti module but unfortunately, our driver could no longer talk to our devices on the other end. -Original Message- From: Bjørn Mork [mailto:bj...@mork.no] Sent: Thursday, April 10, 2014 4:12 AM To: Greg KH Cc: Jim Bockerstette; linux-usb@vger.kernel.org Subject: Re: How to put the io_ti driver in RS485 mode? Greg KH gre...@linuxfoundation.org writes: On Wed, Apr 09, 2014 at 10:02:53PM +, Jim Bockerstette wrote: I have been using the Edgeport 8s MEI to talk RS232 to my devices with good success. However, I cannot get it to talk RS485. Does that hardware even support 485? It does, according to http://www.digi.com/products/model?mid=247 1. Does the io_ti driver support RS485? I do not think so. Maybe... Much of the infratructure seems to be in place. You have a __u8 bUartMode; /* Port type, 0: RS232, etc. */ field where I assume etc is shorthand for x: RS422, y: RS485 :-) This is populated from the default_uart_mode module parameter, which is described a Default uart_mode, 0=RS232, And the bUartMode field is further propagated to the device in change_port_settings(). So you could try to load the driver with default_uart_mode set to 2 or 1 or something. If this works, then it will change all ports on all devices handled by this driver to RS422 or RS485. So if you need more fine tuned control then some new driver API needs to be added. Please let us know how this works out. We could at least improve the module parameter docs if it is as simple as I am guessing here. 2. If yes, is there a procedure I can follow to put it in that mode? 3. Thanks. Here is my distro info: CentOS release 6.5 (Final) Linux version 2.6.32-431.5.1.el6.centos.plus.i686 (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) That's a _very_ old kernel release, based on a 2009 kernel release. That was some 260 thousand kernel changes ago :( There's not much of anything that the kernel developer community can do about that release, sorry. Yes, I am with you there... But the io_ti features haven't changed much, so I assume the module parameter thing will work equally bad/well in both 2.6.32 and 3.14. Bjørn N�r��yb�X��ǧv�^�){.n�+{��^n�r���z���h����G���h�(�階�ݢj���m��z�ޖ���f���h���~�m�
Re: [PATCH v9 07/11] usb: chipidea: OTG HNP and SRP fsm implementation.
On Thu, Apr 10, 2014 at 07:36:08PM +0800, Li Jun wrote: From: Li Jun b47...@freescale.com USB OTG interrupt handling and fsm transitions according to USB OTG and EH 2.0. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/core.c| 23 ++-- drivers/usb/chipidea/otg.c |9 +- drivers/usb/chipidea/otg_fsm.c | 232 drivers/usb/chipidea/otg_fsm.h | 18 drivers/usb/chipidea/udc.c |9 ++ 5 files changed, 283 insertions(+), 8 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index ff38cf3..9a01e14 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -42,7 +42,6 @@ * - Not Supported: 15 16 (ISO) * * TODO List - * - OTG * - Interrupt Traffic * - GET_STATUS(device) - always reports 0 * - Gadget API (majority of optional features) @@ -74,6 +73,7 @@ #include host.h #include debug.h #include otg.h +#include otg_fsm.h /* Controller register map */ static const u8 ci_regs_nolpm[] = { @@ -412,8 +412,14 @@ static irqreturn_t ci_irq(int irq, void *data) irqreturn_t ret = IRQ_NONE; u32 otgsc = 0; - if (ci-is_otg) + if (ci-is_otg) { otgsc = hw_read_otgsc(ci, ~0); + if (ci_otg_is_fsm_mode(ci)) { + ret = ci_otg_fsm_irq(ci); + if (ret == IRQ_HANDLED) + return ret; + } + } /* * Handle id change interrupt, it indicates device/host function @@ -691,10 +697,15 @@ static int ci_hdrc_probe(struct platform_device *pdev) if (ci-role == CI_ROLE_GADGET) ci_handle_vbus_change(ci); - ret = ci_role_start(ci, ci-role); - if (ret) { - dev_err(dev, can't start %s role\n, ci_role(ci)-name); - goto stop; + if (ci_otg_is_fsm_mode(ci)) { + ci_hdrc_otg_fsm_start(ci); + } else { + ret = ci_role_start(ci, ci-role); + if (ret) { + dev_err(dev, can't start %s role\n, + ci_role(ci)-name); + goto stop; + } } platform_set_drvdata(pdev, ci); diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index d76db51..38e340c 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -11,8 +11,8 @@ */ /* - * This file mainly handles otgsc register, it may include OTG operation - * in the future. + * This file mainly handles otgsc register, OTG fsm operations for HNP and SRP + * are also included. */ #include linux/usb/otg.h @@ -91,6 +91,11 @@ static void ci_otg_work(struct work_struct *work) { struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); + if (ci_otg_is_fsm_mode(ci) !ci_otg_fsm_work(ci)) { + enable_irq(ci-irq); + return; + } + if (ci-id_event) { ci-id_event = false; ci_handle_id_switch(ci); diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index bb64fb4..3542205 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -13,6 +13,10 @@ /* * This file mainly handles OTG fsm, it includes OTG fsm operations * for HNP and SRP. + * + * TODO List + * - ADP + * - OTG test device */ #include linux/usb/otg.h @@ -93,6 +97,33 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t) hw_write_otgsc(ci, OTGSC_1MSIE, 0); } +/* + * Reduce timer count by 1, and find timeout conditions. + * Called by otg 1ms timer interrupt + */ +static inline int ci_otg_tick_timer(struct ci_hdrc *ci) +{ + struct ci_otg_fsm_timer *tmp_timer, *del_tmp; + struct list_head *active_timers = ci-fsm_timer-active_timers; + int expired = 0; + + list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) { + tmp_timer-count--; + /* check if timer expires */ + if (!tmp_timer-count) { + list_del(tmp_timer-list); + tmp_timer-function(ci, tmp_timer-data); + expired = 1; + } + } + + /* disable 1ms irq if there is no any timer active */ + if ((expired == 1) list_empty(active_timers)) + hw_write_otgsc(ci, OTGSC_1MSIE, 0); + + return expired; +} + /* The timeout callback function to set time out bit */ static void set_tmout(void *ptr, unsigned long indicator) { @@ -394,6 +425,207 @@ static struct otg_fsm_ops ci_otg_ops = { .start_gadget = ci_otg_start_gadget, }; +int ci_otg_fsm_work(struct ci_hdrc *ci) +{ + /* + * Don't do fsm transition for B device + * when there is no gadget class driver + */ + if (ci-fsm.id
Re: [PATCH v9 07/11] usb: chipidea: OTG HNP and SRP fsm implementation.
On Thu, Apr 10, 2014 at 07:36:08PM +0800, Li Jun wrote: From: Li Jun b47...@freescale.com USB OTG interrupt handling and fsm transitions according to USB OTG and EH 2.0. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/core.c| 23 ++-- drivers/usb/chipidea/otg.c |9 +- drivers/usb/chipidea/otg_fsm.c | 232 drivers/usb/chipidea/otg_fsm.h | 18 drivers/usb/chipidea/udc.c |9 ++ 5 files changed, 283 insertions(+), 8 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index ff38cf3..9a01e14 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -42,7 +42,6 @@ * - Not Supported: 15 16 (ISO) * * TODO List - * - OTG * - Interrupt Traffic * - GET_STATUS(device) - always reports 0 * - Gadget API (majority of optional features) @@ -74,6 +73,7 @@ #include host.h #include debug.h #include otg.h +#include otg_fsm.h /* Controller register map */ static const u8 ci_regs_nolpm[] = { @@ -412,8 +412,14 @@ static irqreturn_t ci_irq(int irq, void *data) irqreturn_t ret = IRQ_NONE; u32 otgsc = 0; - if (ci-is_otg) + if (ci-is_otg) { otgsc = hw_read_otgsc(ci, ~0); + if (ci_otg_is_fsm_mode(ci)) { + ret = ci_otg_fsm_irq(ci); + if (ret == IRQ_HANDLED) + return ret; + } + } /* * Handle id change interrupt, it indicates device/host function @@ -691,10 +697,15 @@ static int ci_hdrc_probe(struct platform_device *pdev) if (ci-role == CI_ROLE_GADGET) ci_handle_vbus_change(ci); - ret = ci_role_start(ci, ci-role); - if (ret) { - dev_err(dev, can't start %s role\n, ci_role(ci)-name); - goto stop; + if (ci_otg_is_fsm_mode(ci)) { + ci_hdrc_otg_fsm_start(ci); + } else { + ret = ci_role_start(ci, ci-role); + if (ret) { + dev_err(dev, can't start %s role\n, + ci_role(ci)-name); + goto stop; + } } platform_set_drvdata(pdev, ci); diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index d76db51..38e340c 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -11,8 +11,8 @@ */ /* - * This file mainly handles otgsc register, it may include OTG operation - * in the future. + * This file mainly handles otgsc register, OTG fsm operations for HNP and SRP + * are also included. */ #include linux/usb/otg.h @@ -91,6 +91,11 @@ static void ci_otg_work(struct work_struct *work) { struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); + if (ci_otg_is_fsm_mode(ci) !ci_otg_fsm_work(ci)) { + enable_irq(ci-irq); + return; + } + if (ci-id_event) { ci-id_event = false; ci_handle_id_switch(ci); diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index bb64fb4..3542205 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -13,6 +13,10 @@ /* * This file mainly handles OTG fsm, it includes OTG fsm operations * for HNP and SRP. + * + * TODO List + * - ADP + * - OTG test device */ #include linux/usb/otg.h @@ -93,6 +97,33 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t) hw_write_otgsc(ci, OTGSC_1MSIE, 0); } +/* + * Reduce timer count by 1, and find timeout conditions. + * Called by otg 1ms timer interrupt + */ +static inline int ci_otg_tick_timer(struct ci_hdrc *ci) +{ + struct ci_otg_fsm_timer *tmp_timer, *del_tmp; + struct list_head *active_timers = ci-fsm_timer-active_timers; + int expired = 0; + + list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) { + tmp_timer-count--; + /* check if timer expires */ + if (!tmp_timer-count) { + list_del(tmp_timer-list); + tmp_timer-function(ci, tmp_timer-data); + expired = 1; + } + } + + /* disable 1ms irq if there is no any timer active */ + if ((expired == 1) list_empty(active_timers)) + hw_write_otgsc(ci, OTGSC_1MSIE, 0); + + return expired; +} + /* The timeout callback function to set time out bit */ static void set_tmout(void *ptr, unsigned long indicator) { @@ -394,6 +425,207 @@ static struct otg_fsm_ops ci_otg_ops = { .start_gadget = ci_otg_start_gadget, }; +int ci_otg_fsm_work(struct ci_hdrc *ci) +{ + /* + * Don't do fsm transition for B device + * when there is no gadget class driver + */ + if (ci-fsm.id
RE: [PATCHv5 4/4] usb: dwc2: Edit the Kconfig and Makefile to build dwc2_gadget driver
From: dingu...@altera.com [mailto:dingu...@altera.com] Sent: Friday, March 14, 2014 11:52 AM From: Dinh Nguyen dingu...@altera.com Modify the dwc2 Kconfig and Makefile so that it will build the dwc2_gadget driver when peripheral only mode is selected. The dwc_platform.ko and dwc2.ko will get built when dynamic linked modules are selected for Host mode. For peripheral mode only dwc2_gadget.ko will get built. NOTE: You can build both host and peripheral as a dynamically linked module, but be aware that if you insmod dwc2_gadget, then rmmod it, then insmod dwc2 and dwc2_platform for host mode, this will not work. As the step to rmmod dwc2_gadget.ko will turn off the clock to the USB IP. The dwc2 host driver currently does not look to turn on a clock yet. A patch to fix that will be coming soon. Hi Dinh, Sorry for the late response to this. The patch series looks OK to me, except I didn't quite like the Kconfig and Makefile changes, so I have redone those a little bit. Once the commit window for 3.15 opens, I will send these patches on to Greg with my and Robert's acked-bys. -- Paul -- 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: [PATCHv5 4/4] usb: dwc2: Edit the Kconfig and Makefile to build dwc2_gadget driver
On 04/10/2014 09:02 PM, Paul Zimmerman wrote: From: dingu...@altera.com [mailto:dingu...@altera.com] Sent: Friday, March 14, 2014 11:52 AM From: Dinh Nguyen dingu...@altera.com Modify the dwc2 Kconfig and Makefile so that it will build the dwc2_gadget driver when peripheral only mode is selected. The dwc_platform.ko and dwc2.ko will get built when dynamic linked modules are selected for Host mode. For peripheral mode only dwc2_gadget.ko will get built. NOTE: You can build both host and peripheral as a dynamically linked module, but be aware that if you insmod dwc2_gadget, then rmmod it, then insmod dwc2 and dwc2_platform for host mode, this will not work. As the step to rmmod dwc2_gadget.ko will turn off the clock to the USB IP. The dwc2 host driver currently does not look to turn on a clock yet. A patch to fix that will be coming soon. Hi Dinh, Sorry for the late response to this. The patch series looks OK to me, except I didn't quite like the Kconfig and Makefile changes, so I have redone those a little bit. Once the commit window for 3.15 opens, I will send these patches on to Greg with my and Robert's acked-bys. Thanks Paul! I was waiting for the 3.15 to open and resend. No longer necessary now. Dinh -- 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 v9 07/11] usb: chipidea: OTG HNP and SRP fsm implementation.
On Fri, Apr 11, 2014 at 08:10:43AM +0800, Peter Chen wrote: On Thu, Apr 10, 2014 at 07:36:08PM +0800, Li Jun wrote: From: Li Jun b47...@freescale.com USB OTG interrupt handling and fsm transitions according to USB OTG and EH 2.0. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/core.c| 23 ++-- drivers/usb/chipidea/otg.c |9 +- drivers/usb/chipidea/otg_fsm.c | 232 drivers/usb/chipidea/otg_fsm.h | 18 drivers/usb/chipidea/udc.c |9 ++ 5 files changed, 283 insertions(+), 8 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index ff38cf3..9a01e14 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -42,7 +42,6 @@ * - Not Supported: 15 16 (ISO) * * TODO List - * - OTG * - Interrupt Traffic * - GET_STATUS(device) - always reports 0 * - Gadget API (majority of optional features) @@ -74,6 +73,7 @@ #include host.h #include debug.h #include otg.h +#include otg_fsm.h /* Controller register map */ static const u8 ci_regs_nolpm[] = { @@ -412,8 +412,14 @@ static irqreturn_t ci_irq(int irq, void *data) irqreturn_t ret = IRQ_NONE; u32 otgsc = 0; - if (ci-is_otg) + if (ci-is_otg) { otgsc = hw_read_otgsc(ci, ~0); + if (ci_otg_is_fsm_mode(ci)) { + ret = ci_otg_fsm_irq(ci); + if (ret == IRQ_HANDLED) + return ret; + } + } /* * Handle id change interrupt, it indicates device/host function @@ -691,10 +697,15 @@ static int ci_hdrc_probe(struct platform_device *pdev) if (ci-role == CI_ROLE_GADGET) ci_handle_vbus_change(ci); - ret = ci_role_start(ci, ci-role); - if (ret) { - dev_err(dev, can't start %s role\n, ci_role(ci)-name); - goto stop; + if (ci_otg_is_fsm_mode(ci)) { + ci_hdrc_otg_fsm_start(ci); + } else { + ret = ci_role_start(ci, ci-role); + if (ret) { + dev_err(dev, can't start %s role\n, + ci_role(ci)-name); + goto stop; + } } platform_set_drvdata(pdev, ci); diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index d76db51..38e340c 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -11,8 +11,8 @@ */ /* - * This file mainly handles otgsc register, it may include OTG operation - * in the future. + * This file mainly handles otgsc register, OTG fsm operations for HNP and SRP + * are also included. */ #include linux/usb/otg.h @@ -91,6 +91,11 @@ static void ci_otg_work(struct work_struct *work) { struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); + if (ci_otg_is_fsm_mode(ci) !ci_otg_fsm_work(ci)) { + enable_irq(ci-irq); + return; + } + if (ci-id_event) { ci-id_event = false; ci_handle_id_switch(ci); diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index bb64fb4..3542205 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -13,6 +13,10 @@ /* * This file mainly handles OTG fsm, it includes OTG fsm operations * for HNP and SRP. + * + * TODO List + * - ADP + * - OTG test device */ #include linux/usb/otg.h @@ -93,6 +97,33 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t) hw_write_otgsc(ci, OTGSC_1MSIE, 0); } +/* + * Reduce timer count by 1, and find timeout conditions. + * Called by otg 1ms timer interrupt + */ +static inline int ci_otg_tick_timer(struct ci_hdrc *ci) +{ + struct ci_otg_fsm_timer *tmp_timer, *del_tmp; + struct list_head *active_timers = ci-fsm_timer-active_timers; + int expired = 0; + + list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) { + tmp_timer-count--; + /* check if timer expires */ + if (!tmp_timer-count) { + list_del(tmp_timer-list); + tmp_timer-function(ci, tmp_timer-data); + expired = 1; + } + } + + /* disable 1ms irq if there is no any timer active */ + if ((expired == 1) list_empty(active_timers)) + hw_write_otgsc(ci, OTGSC_1MSIE, 0); + + return expired; +} + /* The timeout callback function to set time out bit */ static void set_tmout(void *ptr, unsigned long indicator) { @@ -394,6 +425,207 @@ static struct otg_fsm_ops ci_otg_ops = { .start_gadget = ci_otg_start_gadget, }; +int ci_otg_fsm_work(struct ci_hdrc *ci) +{ + /* +* Don't do fsm
About the DRD mode implementation of DWC3 driver]
Hi Balbi, At first, thank you to help give the response in patience. Hi, On Wed, Apr 09, 2014 at 02:08:32PM +0800, Wang, Yu wrote: Glad to see the OTG mode is prepare to support in your dwc3-role-switch branch. But it is not fit for intel Merrfield/Moorfield platforms. :( that's not what I heard when I asked some friends to test that branch on different platforms. It's certainly not perfect yet and that's why the code isn't merged in mainline, but claiming that it's not fit for Merrifield/Moorfield is just a lie. Can I get your friends' email address if they are in Intel? I would like to contact them to make the branch work on my Merrifield/Moorefield board too. Currently I can't see any link change event with the branch. The reason is we implemented DRD mode instead of OTG mode. So the GCTL.PortCapDir will be set as 01 for host mode, and 10 for device mode. from a SW perspective there is *no* difference. The only reason for using PortCapDir is to cope with platforms which want to switch roles but have screwed up ID pin reporting. And since most of the platforms actually have tha problem, it's just easier to implement it that way. Ok. Just confirm with you that you think it's not a matter to use GCTL.PortCapDir or OCTL.PeriMode to switch role, right? And the most important thing is we implemented two low power states for dwc3 controller. D0i3hot and D0i3cold. what does that have to do with role switching ? Power management and role switching are two completely different problems. You can have full DRD without PM the same way you can have full PM without DRD. Agree. They can be discussed separately. If no cable connected, we will trigger D0i3cold which will power gate every clock/power used by dwc3 controller. that's not in mainline though, why should I care ? Show me code adding support for D0i3cold for dwc3 then we can talk. Until then, I'll continue assuming there's no such PM state and continue with happy hacking sessions. And entering D0i3hot with hibernation mode when acting as host mode (micro A cable connected), also during device mode(micro B cable connected to PC host). Current driver also doesn't support any runtime PM, so why should I care about your out-of-tree changes ? If you have any code which is not in mainline and I change something in mainline you have to deal to with it, not me. Get it. So we can treat this solution is working w/o PM implementation so far. And maybe we need to re-design DRD/OTG when we consider to support PM, right? I just cannot spend time imagining all twisted scenarios Vendors (including my employer, for that matter) want to support with whatever hacked up version of mainline drivers they might have. My plan is to *not* add a lot of PM support until I know all other features are functional. When I'm happy with those features and know they have been thoroughly tested on *all* users of dwc3 then we can all get together in a conference (maybe have a DWC3 mini-summit or whatever) and discuss how we're gonna implement PM *together*. Since the driver is used by many different vendors, it would be unfair for me to treat Intel (or any vendor, really) differently just because someone dropped me an email commenting about all the out-of-tree changes they have. Understand. What are the other features you mean that need thorough testing before adding PM support? For ID/VBus detection, we are using PMIC to do detect. So we will also power gate the USB PHY for D0i3cold. yeah, everybody does that. Everybody I've seen so far have moved the analog comparators for VBUS and ID out of the PHY and into the PMIC. We even have a very nice framework to cope with that (see drivers/extcon/extcon-palmas.c for an example). Thanks for pointing it out. We will use it too. When we plug in micro A/B cable, the PMIC will report the ID/VBus change event, then driver will force controller resume to D0 from D0i3cold. Due to we haven't do any backup before entering D0i3cold, so we have to re-initialize all host/device portion registers with setting GCTL.PortCapDir to 01 or 10. yeah, but this is just how *you* decided to implement this for your employer and, guess what, all of that is out-of-tree and, by all practical means wrt mainline kernel, it's all non-existent. This means I'm free to implement all of this any way I feel it's best considering the diverse user-base we have on this driver. Quite frankly, resetting the IP is only necessary iff all power rails are cut, in that case, sure, we will reset the IP and start all over, but we don't want to cut all power while we're attached to host, which means we don't need to reset the IP, a simple context restore is enough in most cases. Also, when we implement hibernation (dwc3's hibernation, that is) we won't need to reset the IP even if we go all the way down to D0i3cold because the IP keeps all context in a scratch buffer we
Re: [PATCH v9 07/11] usb: chipidea: OTG HNP and SRP fsm implementation.
On Fri, Apr 11, 2014 at 08:18:42AM +0800, Peter Chen wrote: On Thu, Apr 10, 2014 at 07:36:08PM +0800, Li Jun wrote: From: Li Jun b47...@freescale.com USB OTG interrupt handling and fsm transitions according to USB OTG and EH 2.0. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/core.c| 23 ++-- drivers/usb/chipidea/otg.c |9 +- drivers/usb/chipidea/otg_fsm.c | 232 drivers/usb/chipidea/otg_fsm.h | 18 drivers/usb/chipidea/udc.c |9 ++ 5 files changed, 283 insertions(+), 8 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index ff38cf3..9a01e14 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -42,7 +42,6 @@ * - Not Supported: 15 16 (ISO) * * TODO List - * - OTG * - Interrupt Traffic * - GET_STATUS(device) - always reports 0 * - Gadget API (majority of optional features) @@ -74,6 +73,7 @@ #include host.h #include debug.h #include otg.h +#include otg_fsm.h /* Controller register map */ static const u8 ci_regs_nolpm[] = { @@ -412,8 +412,14 @@ static irqreturn_t ci_irq(int irq, void *data) irqreturn_t ret = IRQ_NONE; u32 otgsc = 0; - if (ci-is_otg) + if (ci-is_otg) { otgsc = hw_read_otgsc(ci, ~0); + if (ci_otg_is_fsm_mode(ci)) { + ret = ci_otg_fsm_irq(ci); + if (ret == IRQ_HANDLED) + return ret; + } + } /* * Handle id change interrupt, it indicates device/host function @@ -691,10 +697,15 @@ static int ci_hdrc_probe(struct platform_device *pdev) if (ci-role == CI_ROLE_GADGET) ci_handle_vbus_change(ci); - ret = ci_role_start(ci, ci-role); - if (ret) { - dev_err(dev, can't start %s role\n, ci_role(ci)-name); - goto stop; + if (ci_otg_is_fsm_mode(ci)) { + ci_hdrc_otg_fsm_start(ci); + } else { + ret = ci_role_start(ci, ci-role); + if (ret) { + dev_err(dev, can't start %s role\n, + ci_role(ci)-name); + goto stop; + } } platform_set_drvdata(pdev, ci); diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index d76db51..38e340c 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -11,8 +11,8 @@ */ /* - * This file mainly handles otgsc register, it may include OTG operation - * in the future. + * This file mainly handles otgsc register, OTG fsm operations for HNP and SRP + * are also included. */ #include linux/usb/otg.h @@ -91,6 +91,11 @@ static void ci_otg_work(struct work_struct *work) { struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); + if (ci_otg_is_fsm_mode(ci) !ci_otg_fsm_work(ci)) { + enable_irq(ci-irq); + return; + } + if (ci-id_event) { ci-id_event = false; ci_handle_id_switch(ci); diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index bb64fb4..3542205 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -13,6 +13,10 @@ /* * This file mainly handles OTG fsm, it includes OTG fsm operations * for HNP and SRP. + * + * TODO List + * - ADP + * - OTG test device */ #include linux/usb/otg.h @@ -93,6 +97,33 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t) hw_write_otgsc(ci, OTGSC_1MSIE, 0); } +/* + * Reduce timer count by 1, and find timeout conditions. + * Called by otg 1ms timer interrupt + */ +static inline int ci_otg_tick_timer(struct ci_hdrc *ci) +{ + struct ci_otg_fsm_timer *tmp_timer, *del_tmp; + struct list_head *active_timers = ci-fsm_timer-active_timers; + int expired = 0; + + list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) { + tmp_timer-count--; + /* check if timer expires */ + if (!tmp_timer-count) { + list_del(tmp_timer-list); + tmp_timer-function(ci, tmp_timer-data); + expired = 1; + } + } + + /* disable 1ms irq if there is no any timer active */ + if ((expired == 1) list_empty(active_timers)) + hw_write_otgsc(ci, OTGSC_1MSIE, 0); + + return expired; +} + /* The timeout callback function to set time out bit */ static void set_tmout(void *ptr, unsigned long indicator) { @@ -394,6 +425,207 @@ static struct otg_fsm_ops ci_otg_ops = { .start_gadget = ci_otg_start_gadget, }; +int ci_otg_fsm_work(struct ci_hdrc *ci) +{ + /* +* Don't do fsm
Re: i.MX51 ChipIdea USB device endpoints questions
On Thu, Apr 10, 2014 at 07:08:22PM +, Ebright, Dave wrote: Hi Peter, I’m not sure what mailing list to post this to, but maybe you know… Linux usb mail list is the best place to ask linux usb questions. I am looking at the i.MX51 USB device functionality for a project I am working on and in the DCCPARAMS register (read only) there is the DEN field which defines the number of endpoints built into the device controller. For the i.MX51 when the register is read the DEN is set to 8. Valid values for this field are 0-16. My first question is do you know of any way of increasing this value? I don’t believe it can be based on the following from the i.MX51 reference manual: “The ARC USB-HS OTG High-Speed USB On-The-Go device controller hardware supports up to the USB 2.0 maximum of 32 endpoint specified numbers. Each additional endpoint beyond the required endpoint position adds additional hardware logic. The maximum number of endpoint numbers available to the DCD is configured at hardware synthesis timer. After synthesis, the DCD can enable, disable and configure endpoint type up to the maximum selected during synthesis.” Does synthesis mean when the processor chip is created or does it mean when the chip first starts up HW senses what the value should be? When the IC guys begin to integrate usb ip, the endpoint number can be changed, but once the chip has finished, this number can't be changed. Any idea if it would work to just over-ride the ci-hw_ep_map value set in hw_device_init()? Not sure what the synthesis does? The ChipIdea register set is still the same, but I assume the functionality is somehow limited in the core? Yes, this value is fixed for certain chipidea IP usb controller. If the number of endpoints cannot be increased, would it be possible to map an unused endpoint number to a higher endpoint number. For example let’s say I want my device to use endpoint 9, but endpoint 9 is not defined due to the DEN value of 8. Endpoint 7 exists and is not being used. Would it be possible to customize the chipidea drivers to map endpoint 9 to use endpoint 7 for a custom application or does the USB OTG chipidea core perform HW controlled endpoint addressing (HW looks at endpoint and sends data to the appropriate endpoint queue independent of the driver)? If endpoint number is 8, for chipidea udc driver, the ci_hw_ep[0..7] is the physical RX endpoint 0-7, , the name is ep[0..7]out, the ci_hw_ep[8..15] is the physical TX endpoint 0-7, the name is ep[0..7]in. What's the reason you want to customize endpoint number? Currently, it will allocate the smallest un-used endpoint number for application. -- 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: About a USB patch on linux kernal
On Fri, Apr 11, 2014 at 02:41:02AM +, Yanan, SUO(MBB-SZ-TCT) wrote: Hi : We have check the linux kernel patch list ,but We can’t find ours USB-PIDVID patch . What specific patch is this? And what patch list did you check? We deal with many thousands of patches every month, you are going to have to be a bit more specific, sorry. What driver was it for? What device id did it modify? The patch should have appeared in the list ,So could you give us some suggestion for this issue? ( this patch have pushed in the main branch in 12(m)-2013(y) ). In what release are you referring to? thanks, 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: [PATCH v9 07/11] usb: chipidea: OTG HNP and SRP fsm implementation.
+int ci_otg_fsm_work(struct ci_hdrc *ci) { + /* + * Don't do fsm transition for B device + * when there is no gadget class driver + */ + if (ci-fsm.id !(ci-driver) + ci-transceiver-state OTG_STATE_A_IDLE) + return 0; + + if (otg_statemachine(ci-fsm)) { + if (ci-transceiver-state == OTG_STATE_A_IDLE) { + /* + * Further state change for cases: + * A idle to B idle, or + * A idle to A wait vrise due to ID change, or At OTG A-device with HNP State Diagram, I haven't seen ID change is one of the reason for A idle to A wait vrise. Why you do this here? Peter Yes, this is out of OTG spec, but it's necessary for the case user insert a ID cable(ID is 0) and the A-device can transit to a_wait_bcon/a_host automatically, then enumeration can be started if the other end has a B- device, otherwise app need do a_bus_req additionally, I think this is making sense. Get it, add comment for that please. No more comments, you just need to fix the two tiny comments for your v10 patchset. Peter Li Jun + * A idle to A wait vrise when power up + */ + if ((ci-fsm.id) || (ci-id_event) || + (ci-fsm.power_up)) { + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } + if (ci-id_event) + ci-id_event = false; + } + } + return 0; +} + +/* + * Update fsm variables in each state if catching expected +interrupts, + * called by otg fsm isr. + */ +static void ci_otg_fsm_event(struct ci_hdrc *ci) { + u32 intr_sts, otg_bsess_vld, port_conn; + struct otg_fsm *fsm = ci-fsm; + + intr_sts = hw_read_intr_status(ci); + otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV); + port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS); + + switch (ci-transceiver-state) { + case OTG_STATE_A_WAIT_BCON: + if (port_conn) { + fsm-b_conn = 1; + fsm-a_bus_req = 1; + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } + break; + case OTG_STATE_B_IDLE: + if (otg_bsess_vld (intr_sts USBi_PCI) port_conn) { + fsm-b_sess_vld = 1; + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } + if (fsm-b_sess_vld) + fsm-power_up = 0; + break; + case OTG_STATE_B_PERIPHERAL: + if ((intr_sts USBi_SLI) port_conn otg_bsess_vld) { + fsm-a_bus_suspend = 1; + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } else if (intr_sts USBi_PCI) { + if (fsm-a_bus_suspend == 1) + fsm-a_bus_suspend = 0; + } + break; + case OTG_STATE_B_HOST: + if ((intr_sts USBi_PCI) !port_conn) { + fsm-a_conn = 0; + fsm-b_bus_req = 0; + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + ci_otg_add_timer(ci, B_SESS_VLD); + } + break; + case OTG_STATE_A_PERIPHERAL: + if (intr_sts USBi_SLI) { + fsm-b_bus_suspend = 1; + /* + * Init a timer to know how long this suspend + * will contine, if time out, indicates B no longer + * wants to be host role + */ + ci_otg_add_timer(ci, A_BIDL_ADIS); + } + + if (intr_sts USBi_URI) + ci_otg_del_timer(ci, A_BIDL_ADIS); + + if (intr_sts USBi_PCI) { + if (fsm-b_bus_suspend == 1) { + ci_otg_del_timer(ci, A_BIDL_ADIS); + fsm-b_bus_suspend = 0; + } + } + break; + case OTG_STATE_A_SUSPEND: + if ((intr_sts USBi_PCI) !port_conn) { + fsm-b_conn = 0; + + /* if gadget driver is binded */ + if (ci-driver) { + /* A device to be peripheral mode */ + ci-gadget.is_a_peripheral = 1; + } + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } + break; + case OTG_STATE_A_HOST: + if ((intr_sts USBi_PCI) !port_conn) { + fsm-b_conn = 0; + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); +
Re: libusbg and vbus detection for UDC driver
On Thu, Apr 10, 2014 at 11:24:49PM +0300, Philippe De Swert wrote: Hi all, On first sight it seems that the two things in the subject have nothing to do with each other, so I will quickly explain why they do (at least for me). So for some time already I have been working on usb_moded, which is a small daemon which handles setting up gadget drivers, so that a device can offer several different levels of functionality (for this it is also capable of setting up network and start/stop services over dbus/systemd/upstart when needed) Now I would like to add support for the new gadgetfs. And there I run into two issues. 1. It seems that libusbg from Matt Porter seems the library to use. Is that correct? I saw patches on the mailing list, but they did not seem to have made it to: https://github.com/libusbg/libusbg Is this the correct place, and should patches be sent to the mailing list here? I also pushed it through a coverity scan already and have a nice to do list. 2. I am playing around on a ATSAM5D36-EK and I tried to use that as a testing platform. Now the USB udc etc works fine. But there is no real way to detect the insertion of a cable. Most udc drivers seem to track vbus but this is not exposed. So I added a vbus attribute to the base udc, but this only works when a gadget driver is actually loaded. So as long as a gadget is active I can see the attribute change. (A possible work-around would be a gadget driver just to detect vbus, but that is a bit insane) What would be the best way to track cable insertion and expose it in some way? As in this case I cannot short-cut it by using a power_supply class type of device. And just to be sure I would like to find a way that would be acceptable upstream. The usb gadget state has already been exported (see udc-core.c), you only need to call usb_gadget_set_state(gadget, USB_STATE_ATTACHED) at your udc for cable connection. -- 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 0/3] Fix USB deadlock caused by SCSI error handling
On 04/10/2014 10:36 PM, James Bottomley wrote: On Thu, 2014-04-10 at 19:52 +0200, Hannes Reinecke wrote: On 04/10/2014 05:31 PM, Alan Stern wrote: On Thu, 10 Apr 2014, Hannes Reinecke wrote: On 04/10/2014 12:58 PM, Andreas Reis wrote: That patch appears to work in preventing the crashes, judged on one repeated appearance of the bug. dmesg had the usual [ 215.229903] usb 4-2: usb_disable_lpm called, do nothing [ 215.336941] usb 4-2: reset SuperSpeed USB device number 3 using xhci_hcd [ 215.350296] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b829c0 [ 215.350305] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 880427b82a08 [ 215.350621] usb 4-2: usb_enable_lpm called, do nothing repeated five times, followed by one [ 282.795801] sd 8:0:0:0: Device offlined - not ready after error recovery and then as often as something tried to read from it: [ 295.585472] sd 8:0:0:0: rejecting I/O to offline device The stick could then be properly un- and remounted (the latter if it had been physically replugged) without issue � for the bug to reoccur after one to three minutes. I tried this three times, no dmesg difference except the ep addresses varied on two of that. Was this just that patch you've tested with or the entire patch series? If the latter, Alan, is this the expected outcome? Yes, it is. The same thing should happen with the entire patch series. I would've thought the error recover should _not_ run into offlining devices here, but rather the device should be recovered eventually. The command times out, it is aborted, and the command is retried. The same thing happens, and we repeat five times. Eventually the SCSI core gives up and declares the device to be offline. Hmm. Ok. If you are fine with it who am I to argue here. James, shall I resent the patch series? You mean the one patch? No, it's OK, I have it. It's still not complete, though, as I've said a couple of times. The problem is that we have abort memory on any eh command as well, which this doesn't fix. The scenario is abort command, set flag, abort completes, send TUR, TUR doesn't return, so we now try to abort the TUR, but scsi_abort_eh_cmnd() will skip the abort because the flag is set and move straight to reset. The fix is this, I can just add it as well. James --- diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 771c16b..7516e2c 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -920,6 +920,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses, ses-prot_op = scmd-prot_op; scmd-prot_op = SCSI_PROT_NORMAL; + scmd-eh_eflags = 0; scmd-cmnd = ses-eh_cmnd; memset(scmd-cmnd, 0, BLK_MAX_CDB); memset(scmd-sdb, 0, sizeof(scmd-sdb)); Oh yes, that is correct. Acked-by: Hannes Reinecke h...@suse.de Cheers, Hannes -- Dr. Hannes Reinecke zSeries Storage h...@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- 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