1. 12 8月, 2011 2 次提交
    • S
      usb: musb: gadget: fix error path · 6193d699
      Sebastian Andrzej Siewior 提交于
      In case one "forgot" to load the receiver i.e. doing
      |modprobe omap2430
      |modprobe musb_hdrc
      
      he ends up with:
      
      |musb-hdrc: version 6.0, ?dma?, otg (peripheral+host)
      |HS USB OTG: no transceiver configured
      |musb-hdrc musb-hdrc: musb_init_controller failed with status -19
      |(NULL device *): gadget not registered.
      |Unable to handle kernel NULL pointer dereference at virtual address 0000001c
      |Internal error: Oops: 17 [#1] SMP
      |[<c011383c>] (sysfs_find_dirent+0x4/0x60) from [<c01138c0>] (sysfs_get_dirent+0x28/0x78)
      |[<c01138c0>] (sysfs_get_dirent+0x28/0x78) from [<c0115b78>] (sysfs_unmerge_group+0x1c/0x90)
      |[<c0115b78>] (sysfs_unmerge_group+0x1c/0x90) from [<c0179ba4>] (dpm_sysfs_remove+0x14/0x3c)
      |[<c0179ba4>] (dpm_sysfs_remove+0x14/0x3c) from [<c01742f8>] (device_del+0x40/0x1b4)
      |[<c01742f8>] (device_del+0x40/0x1b4) from [<c0174478>] (device_unregister+0xc/0x18)
      |[<c0174478>] (device_unregister+0xc/0x18) from [<bf0489b4>] (musb_free+0x24/0x88 [musb_hdrc])
      |[<bf0489b4>] (musb_free+0x24/0x88 [musb_hdrc]) from [<bf057d18>] (musb_probe+0xb50/0xe3c [musb_hdrc])
      |[<bf057d18>] (musb_probe+0xb50/0xe3c [musb_hdrc]) from [<c01779c4>] (platform_drv_probe+0x1c/0x24)
      
      The problem is that musb_free() tries to figure out what was
      initializued and what wasn't and clean up only the initialized part.
      This works well for usb_del_gadget_udc() but device_unregister() can't
      deal with it. Therefore we rely on the fact the we always have a parent
      device and only then remove the device.
      I broke this in 0f91349b ("usb: gadget: convert all users to the new udc
      infrastructure")
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      6193d699
    • J
      usb: musb: fix oops on musb_gadget_pullup · 93e098a8
      John Stultz 提交于
      an 'unhandled fault' is causes when a gadget driver calls
      usb_gadget_connect() while the USB cable isn't plugged into
      the OTG port.
      
      the fault is caused by an access to MUSB's memory space
      while its clock is turned off due to pm_runtime kicking
      in.
      
      in order to fix the fault, we enclose musb_gadget_pullup()
      with pm_runtime_get_sync() ... pm_runtime_put() calls to
      be sure we will always reach that path with clock turned on.
      
      [ balbi@ti.com : simplified commit log; removed few things
      	which didn't belong there ]
      
      Cc: stable@kernel.org
      Reported-by: NZach Pfeffer <zach.pfeffer@linaro.org>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      93e098a8
  2. 02 7月, 2011 2 次提交
  3. 29 6月, 2011 1 次提交
    • S
      usb: gadget: convert all users to the new udc infrastructure · 0f91349b
      Sebastian Andrzej Siewior 提交于
      peripheral drivers are using usb_add_gadget()/usb_del_gadget() to
      register/unregister to the udc-core.
      
      The udc-core will take the first available gadget driver and attach
      function driver which is calling usb_gadget_register_driver(). This is
      the same behaviour we have right now.
      
      Only dummy_hcd was tested, the others were compiled tested.
      
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Anton Tikhomirov <av.tikhomirov@samsung.com>
      Cc: Ben Dooks <ben-linux@fluff.org>
      Cc: Dan Carpenter <error27@gmail.com>
      Cc: Darius Augulis <augulis.darius@gmail.com>
      Cc: Eric Miao <eric.y.miao@gmail.com>
      Cc: Jingoo Han <jg1.han@samsung.com>
      Cc: Kukjin Kim <kgene.kim@samsung.com>
      Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Cc: Li Yang <leoli@freescale.com>
      Cc: Michael Hennerich <michael.hennerich@analog.com>
      Acked-by: NMike Frysinger <vapier@gentoo.org>
      Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
      Cc: Pavankumar Kondeti <pkondeti@codeaurora.org>
      Cc: Roy Huang <roy.huang@analog.com>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>
      Cc: Xiaochen Shen <xiaochen.shen@intel.com>
      Cc: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
      Cc: Yuan-Hsin Chen <yhchen@faraday-tech.com>
      Cc: cxie4 <cxie4@marvell.com>
      Cc: linux-geode@lists.infradead.org
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0f91349b
  4. 09 6月, 2011 1 次提交
    • Y
      usb: musb: gadget: clear TXPKTRDY flag when set FLUSHFIFO · 4858f06e
      Yauheni Kaliuta 提交于
      Fixes mis-use of MUSB's hardware feature where it won't
      flush FIFOs when TXPKTRDY flag was set before and we are
      flushing setting both FLUSHFIFO and TXPKTRDY.
      
      In other words, we need to ensure that when we try to
      flush FIFOs, we don't accidentaly set TXPKTRDY bit too
      due to a read-back of the register.
      
      The MUSB Programming Guide says "May be set simultaneously
      with TxPktRdy to abort the packet that is currently being
      loaded into the FIFO". This is a situation where TXPKTRDY
      hasn't been set yet, but some data already loaded into the
      fifo. It looks, that if TXPKTRDY has been set before, and
      there is no loading in progress, but we set FLUSHFIFO with
      the TXPKTRDY, controller tries to use the same logic to
      abort loading and as the result just does nothing (because
      there is no packet been loaded currently)
      Signed-off-by: NYauheni Kaliuta <yauheni.kaliuta@nokia.com>
      
      [ balbi@ti.com : fixed one whitespace git complained about
      		 improved the commit log slightly ]
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      4858f06e
  5. 18 5月, 2011 1 次提交
  6. 13 5月, 2011 2 次提交
  7. 07 5月, 2011 1 次提交
  8. 02 5月, 2011 1 次提交
    • J
      usb: musb: gadget: Fix out-of-sync runtime pm calls · cdefce16
      Jarkko Nikula 提交于
      If cable is not connected to peripheral only board when initializing the
      gadget driver, then runtime pm calls are out-of-sync and the musb cannot
      idle with omap2430.c. This was noted on Nokia N900 where musb prevented the
      CPU to be able to enter deeper retention idle state.
      
      This was working in 2.6.38 before runtime pm conversions but there musb
      smart standby/idle modes were configured statically where they are now
      updated runtime depending on use and cable status.
      
      Reason for out-of-sync is that runtime pm is activated in function
      musb_gadget.c: usb_gadget_probe_driver but suspended only in OTG mode if
      cable is not connected when initializing. In peripheral only mode this leads
      to out-of-sync runtime pm since runtime pm remain active and is activated
      another time in omap2430.c: musb_otg_notifications for VBUS Connect event
      and thus cannot suspend for VBUS Disconnect event since the use count remains
      active.
      
      Fix this by moving cable status check and pm_runtime_put call in
      usb_gadget_probe_driver out of is_otg_enabled block.
      Signed-off-by: NJarkko Nikula <jhnikula@gmail.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      cdefce16
  9. 13 4月, 2011 2 次提交
  10. 24 3月, 2011 1 次提交
  11. 01 3月, 2011 2 次提交
    • H
      usb: musb: Idle path retention and offmode support for OMAP3 · 7acc6197
      Hema HK 提交于
      This patch supports the retention and offmode support in the idle path for
      musb driver using runtime pm APIs.
      
      This is restricted to support offmode and retention only when device not
      connected.When device/cable connected with gadget driver loaded,configured
      to no idle/standby which will not allow the core transition to retention
      or off.
      
      There is no context save/restore done by hardware for musb in OMAP3
      and OMAP4,driver has to take care of saving and restoring the context
      during offmode.
      
      Musb has a requirement of configuring sysconfig register to force
      idle/standby mode and set the ENFORCE bit in module STANDBY register
      for retention and offmode support.
      
      Runtime pm and hwmod frameworks will take care of configuring to force
      idle/standby when pm_runtime_put_sync is called and back to no
      idle/standby when pm_runeime_get_sync is called.
      
      Compile, boot tested and also tested the retention in the idle path on
      OMAP3630Zoom3. And tested the global suspend/resume with offmode enabled.
      Usb basic functionality tested on OMAP4430SDP.
      
      There is some problem with idle path offmode in mainline, I could not test
      with offmode. But I have tested this patch with resetting the controller
      in the idle path when wakeup from retention just to make sure that the
      context is lost, and restore path is working fine.
      
      Removed .suspend/.resume fnction pointers and functions because there
      is no need of having these functions as all required work is done
      at runtime in the driver.
      
      There is no need to call the runtime pm api with glue driver device
      as glue layer device is the parent of musb core device, when runtime apis
      are called for the child, parent device runtime functionality
      will be invoked.
      
      Design overview:
      
      pm_runtime_get_sync: When called with musb core device takes care of
      enabling the clock, calling runtime callback function of omap2430 glue
      layer, runtime call back of musb driver and configure the musb sysconfig
      to no idle/standby
      
      pm_runtime_put: Takes care of calling runtime callback function of omap2430
      glue layer, runtime call back of musb driver, Configure the musb sysconfig
      to force idle/standby and disable the clock.
      
      During musb driver load: Call pm_runtime_get_sync.
      
      End of musb driver load: Call pm_runtime_put
      
      During gadget driver load: Call pm_runtime_get_sync,
      End of gadget driver load: Call pm_runtime_put if there is no device
      or cable is connected.
      
      During unload of the gadget driver:Call pm_runtime_get_sync if cable/device
      is not connected.
      End of the gadget driver unload : pm_runtime_put
      
      During unload of musb driver : Call pm_runtime_get_sync
      End of unload: Call pm_runtime_put
      
      On connect of usb cable/device -> transceiver notification(VBUS and ID-GND):
      pm_runtime_get_sync only if the gadget driver loaded.
      
      On disconnect of the cable/device -> Disconnect Notification:
      pm_runtime_put if the gadget driver is loaded.
      Signed-off-by: NHema HK <hemahk@ti.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      7acc6197
    • F
      usb: musb: gadget: fix list_head usage · 4cbbf084
      Felipe Balbi 提交于
      commit ad1adb89
      (usb: musb: gadget: do not poke with gadget's list_head)
      fixed a bug in musb where it was corrupting the list_head
      which is supposed to be used by gadget drivers. While
      doing that, I forgot to fix the usage in musb_gadget_dequeue()
      method. Fix that.
      Reported-by: NPavol Kurina <pavol.kurina@emsys.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      4cbbf084
  12. 21 2月, 2011 1 次提交
  13. 18 2月, 2011 3 次提交
    • H
      usb: musb: OMAP4430: Fix usb device detection if connected during boot · 002eda13
      Hema HK 提交于
      OMAP4430 is embedded with UTMI PHY. This PHY does not support the
      OTG features like ID pin detection and VBUS detection. This function
      is exported to an external companion chip TWL6030. Software must retrieve
      the OTG HNP and SRP status from the TWL6030 and configure the bits inside
      the control module that drive the related USBOTGHS UTMI interface signals.
      It must also read back the UTMI signals needed to configure the TWL6030
      OTG module.
      
      Can find more details in the TRM[1].
      [1]:http://focus.ti.com/pdfs/wtbu/OMAP4430_ES2.0_Public_TRM_vJ.pdf
      
      In OMAP4430 musb driver VBUS and ID notifications are received from the
      transceiver driver. If the cable/device is connected during boot,
      notifications from transceiver driver will be missed till musb driver
      is loaded.
      Patch to configure the transceiver in the platform_enable/disable
      functions and enable the vbus in the gadget driver based on the
      last_event of the otg_transceiver.
      Signed-off-by: NHema HK <hemahk@ti.com>
      Cc: Tony Lindgren <tony@atomide.com>
      Cc: Paul Walmsley <paul@pwsan.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      002eda13
    • F
      usb: musb: gadget: do not poke with gadget's list_head · ad1adb89
      Felipe Balbi 提交于
      struct usb_request's list_head is supposed to be
      used only by gadget drivers, but musb is abusing
      that. Give struct musb_request its own list_head
      and prevent musb from poking into other driver's
      business.
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      ad1adb89
    • F
      usb: musb: gadget: beautify usb_gadget_probe_driver()/usb_gadget_unregister_driver · 63eed2b5
      Felipe Balbi 提交于
      Just a few cosmetic fixes to usb_gadget_probe_driver()
      and usb_gadget_unregister_driver().
      
      Decreased a few indentation levels with goto statements.
      
      While at that, also add the missing call to musb_stop().
      If we don't have OTG, there's no point of leaving
      MUSB prepared for operation if a gadget driver fails
      to probe. The same is valid for usb_gadget_unregister_driver(),
      since we are removing the gadget driver and we don't have
      OTG, we can completely unconfigure MUSB.
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      63eed2b5
  14. 01 2月, 2011 3 次提交
    • M
      usb: musb: introduce api for dma code to check compatibility with usb request · 5f5761cb
      Mian Yousaf Kaukab 提交于
      Gadget MUSB driver handles dma mappings in musb_gadget_queue(). Where as it is
      possible for  dma code to reject the usb request later at ->channel_program()
      called from txstate()/rxstate()
      
      For example ->channel_program in tusb6010_omap.c:
      
      static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
              u8 rndis_mode, dma_addr_t dma_addr, u32 len)
      {
      ...
      	if (unlikely(dma_addr & 0x1) || (len < 32) || (len > packet_sz))
      		return false;
      ...
      	if (dma_addr & 0x2)
      		return false;
      ...
      }
      
      In this case, usb request will be handled in PIO mode which renders dma mapping
      operations unnecessary.
      
      This patch adds an api to allow dma code to indicate incompatibility with usb
      request. Gadget musb driver call this api, if available, before dma mappings to
      avoid any unnecessary mapping operations.
      Signed-off-by: NMian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      5f5761cb
    • M
      usb: musb: maintain three states for buffer mappings instead of two · c65bfa62
      Mian Yousaf Kaukab 提交于
      If dma buffers are mapped by a higher layer, with a boolean musb_request.mapped
      it is still possible to call dma_sync_single_for_device() from
      musb_g_giveback(), even if txstate()/rxstate() has called unmap_dma_buffer()
      before falling back to pio mode.
      
      Moreover, check for musb_ep->dma is moved within map_dma_buffer() so where
      applicable checks for it are removed. And where possible, checks for
      is_dma_capable() are merged with buffer map state check.
      Signed-off-by: NMian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      c65bfa62
    • F
      usb: musb: disable double buffering when it's broken · 06624818
      Felipe Balbi 提交于
      We know that blackfin doesn't support double
      buffering feature as of today. So we add a
      flag set by musb_platform_init() to forcefully
      disable that feature.
      
      Such flag is created and marked as deprecated
      to force us to find a solution for the missing
      double buffering support on blackfin.
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      06624818
  15. 01 12月, 2010 1 次提交
  16. 22 11月, 2010 4 次提交
    • A
      usb: musb: do not use dma for control transfers · 07a8cdd2
      Anand Gadiyar 提交于
      The Inventra DMA engine used with the MUSB controller in many
      SoCs cannot use DMA for control transfers on EP0, but can use
      DMA for all other transfers.
      
      The USB core maps urbs for DMA if hcd->self.uses_dma is true.
      (hcd->self.uses_dma is true for MUSB as well).
      
      Split the uses_dma flag into two - one that says if the
      controller needs to use PIO for control transfers, and
      another which says if the controller uses DMA (for all
      other transfers).
      
      Also, populate this flag for all MUSB by default.
      
      (Tested on OMAP3 and OMAP4 boards, with EHCI and MUSB HCDs
      simultaneously in use).
      Signed-off-by: NMaulik Mankad <x0082077@ti.com>
      Signed-off-by: NSantosh Shilimkar <santosh.shilimkar@ti.com>
      Signed-off-by: NAnand Gadiyar <gadiyar@ti.com>
      Cc: Oliver Neukum <oliver@neukum.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Praveena NADAHALLY <praveen.nadahally@stericsson.com>
      Cc: Ajay Kumar Gupta <ajay.gupta@ti.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      07a8cdd2
    • A
      usb: musb: gadget: fix compilation warning · bb324b08
      Ajay Kumar Gupta 提交于
      Fixes below compilation warning when musb driver is compiled for
      PIO mode:
      
      drivers/usb/musb/musb_gadget.c: In function 'musb_g_rx':
      drivers/usb/musb/musb_gadget.c:840:
      		warning: label 'exit' defined but not used
      Signed-off-by: NAjay Kumar Gupta <ajay.gupta@ti.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      bb324b08
    • M
      usb: musb: clear RXCSR_AUTOCLEAR before PIO read · e75df371
      Ming Lei 提交于
      If RXCSR_AUTOCLEAR flag is not cleard before PIO reading, one packet
      may be recieved by musb fifo, but no chance to notify
      software, so cause packet loss, follows the detailed process:
      
      	- PIO read one packet
      	- musb fifo auto clear the MUSB_RXCSR_RXPKTRDY
      	- musb continue to recieve the next packet, and MUSB_RXCSR_RXPKTRDY
      	is set
      	- software clear the MUSB_RXCSR_RXPKTRDY, so there is no chance for
      	musb to notify software that the 2nd recieved packet.
      
      The patch does fix the g_ether issue below:
      
      	- use fifo_mode 3 to enable double buffer
      	- 'ping -s 1024 IP_OF_BEAGLE_XM'
      	- one usb packet of 512 byte is lost, so ping failed,
      	which can be observed by wireshark
      
      note:
      	Beagle xm takes musb rtl1.8 and may fallback to pio mode
      	for unaligned buffer.
      Signed-off-by: NMing Lei <tom.leiming@gmail.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      e75df371
    • H
      usb: musb: unmap dma buffer when switching to PIO · 92d2711f
      Hema Kalliguddi 提交于
      Buffer is mapped to dma when dma channel is
      allocated. If, for some reason, dma channel
      programming fails, musb code will fallback
      to PIO mode to transfer that request. In
      that case, we need to unmap the buffer
      back to CPU.
      
      MUSB RTL1.8 and above cannot handle buffers
      which are not 32bit aligned. That happens to
      every request sent by g_ether gadget
      driver. Since the buffer sent was unaligned,
      we need to fallback to PIO.
      
      Because of that, g_ether was failing due
      to missing buffer unmapping.
      
      With this patch and [1] g_ether works fine
      with all MUSB revisions.
      
      Verified with OMAP3630 board, which has
      MUSB RTL1.8 using g_ether and g_zero.
      
      [1] http://www.spinics.net/lists/linux-usb/msg38400.htmlSigned-off-by: NHema HK <hemahk@ti.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      92d2711f
  17. 08 11月, 2010 1 次提交
  18. 05 11月, 2010 3 次提交
    • M
      USB: musb: gadget: fix MUSB_TXMAXP and MUSB_RXMAXP configuration · 31c9909b
      Ming Lei 提交于
      Commit 9f445cb2[USB: musb: disable
      double buffering for older RTL versions] tries to disable double
      buffer mode by writing endpoint hw max packet size to TXMAP/RXMAP.
      
      First the approach can break full speed and cause overflow problems.
      We should always set those registers with the actual max packet size
      from endpoint descriptor.
      
      Second, the problem describe by commit 9f445cb2
      was caused by musb gadget driver; nothing to do with RTL revision as
      originaly suspected.
      
      The real fix to the problem is to always use actual max packet
      size from endpoint descriptor to config TXMAP/RXMAP registers.
      
      Cc: Cliff Cai <cliff.cai@analog.com>
      Cc: David Brownell <dbrownell@users.sourceforge.net>
      Cc: Anand Gadiyar <gadiyar@ti.com>
      Cc: Mike Frysinger <vapier@gentoo.org>
      Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
      Cc: stable@kernel.org
      Signed-off-by: NMing Lei <tom.leiming@gmail.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      31c9909b
    • R
      usb: musb: musb_gadget: fix resource leakage in error path · e2c34045
      Rahul Ruikar 提交于
      In function musb_gadget_setup() call put_device()
      when device_register() fails.
      Signed-off-by: NRahul Ruikar <rahul.ruikar@gmail.com>
      Acked-by: NMing Lei <tom.leiming@gmail.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      e2c34045
    • M
      usb: musb: gadget: fix dma mode 0 in double buffer Rx case · 9001d80d
      Ming Lei 提交于
      1, In Rx double buffer case, FIFO may have two packets, so
      rxstate should be called to unload fifo if RXPKTRDY is set
      even the current request has not been completed.
      
      2, Commit 633ba7876b96ec339ef685357e2f7c60b5a8ce85
      introduces autoclear to support double buffer in dma mode 0,
      so remove clearing RXPKTRDY manually for dma mode 0.
      
      3, Commit c7af6b29ffeffbeb28caf39e5b2ce29b11807c7d may break
      dma mode 1 for non-doublebuffer endpoint, fix it.
      
      With this patch, either usbtest #5 or g_file_storage(writing
      file to device in usb host) or g_ether have been tested OK in
      double buffer case(using fifo mode 3). Also, this patch has
      been verified that single buffer case can't be broken.
      
      Cc: David Brownell <dbrownell@users.sourceforge.net>
      Cc: Anand Gadiyar <gadiyar@ti.com>
      Cc: Mike Frysinger <vapier@gentoo.org>
      Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
      Signed-off-by: NMing Lei <tom.leiming@gmail.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      9001d80d
  19. 02 11月, 2010 1 次提交
  20. 23 10月, 2010 5 次提交
  21. 06 10月, 2010 1 次提交
  22. 25 9月, 2010 1 次提交