Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2013-01-21 Thread Felipe Balbi
Hi,

On Sun, Jan 20, 2013 at 11:17:31AM +0100, Pali Rohár wrote:
 On Sunday 20 January 2013 10:25:37 Felipe Balbi wrote:
  On Sun, Jan 20, 2013 at 03:58:13AM +0100, Pali Rohár wrote:
   Signed-off-by: Pali Rohár pali.ro...@gmail.com
  
  NAK for two reasons:
  
  a) the original Nokia kernel used a separate g_file_storage
  gadget to use Mass Storage mode, use that
  
  b) there is no commit log
 
 Reason why add mass storage mode to g_nokia is to avoid switching 
 between g_{file,mass}_storage and g_nokia and to have one gadget 
 driver for Nokia N900. It is better to have usb network and mass 
 storage mode in one driver (and not to unload  load another).
 
 I tested this patch with 3.8-rc3 kernel on Nokia N900 and usb 
 network with mass storage mode working without problems.

Doesn't matter, in this case this is something which nokia wrote to
carry on their Maemo/MeeGo devices so unless someone from Nokia says
this is how they want to use nokia.c from now on, I can't simply risk
breaking all other users for your own convenience.

On top of all that, we're working to remove all gadget drivers from
kernel and keep only function drivers.

-- 
balbi


signature.asc
Description: Digital signature


Re: Linux USB file storage gadget with new UDC

2013-01-21 Thread Felipe Balbi
Hi,

On Mon, Jan 21, 2013 at 01:32:09PM +0800, victor yeo wrote:
   This log looks oddly incomplete.  A lot of debugging messages are
   missing.
  
   g_file_storage gadget: ep0-setup, length 8:
   : 80 06 00 01 00 00 40 00
   g_file_storage gadget: get device descriptor
  
   For example, right here we should see the device descriptor data that
   was sent back to the host.
 
  I checked the log again, the dmesg log did not contain that info. May
  i know which part of the gadget code will print out the device
  descriptor data that was sent back to the host?
 
  ep0_complete(), where it calls dump_msg().
 
 My Usb gadget hardware was broken for 2 weeks, i am sorry for the late
 reply. Today i check the ep0_complete() function, it is not called
 during Usb mass storage gadget enumeration with host PC. I am not sure
 which part of file_storage.c called ep0_complete(). Please kindly
 point out to me. Thanks.

ep0_complete() should be called by your UDC driver. Seriously dude, read
the documentation and read other drivers to figure out how things should
be called. A quick look in the storage drivers would have shown you that
ep0_complete() is passed in as req-complete() through the usb_request
structure. That structure (well, a pointer to it) is passed to the UDC
driver through usb_ep_queue(). All you had to figure out is when it
req-complete called. ANY UDC driver would have given you the answer.

Likely your UDC driver is still buggy, if you don't call -complete(),
you're starving your usb_request queue.

-- 
balbi


signature.asc
Description: Digital signature


USB subsystem stops working

2013-01-21 Thread Norbert Preining
Hi everyone,
(please Cc)

I am currently running 3.8.0-rc4 and see the following behaviour:
When I plug/eject my kindle a few times, suddenly the kernel does
not see any USB activity any more. Nothing. PLugging in the kindle -
no reaction, plugging in a usb kbd - no reaction, plugging in a 
usb  mouse - no reaction. All dead.

I turned on udev debug mode, no messages at all.

I restarted udev - no changes.

Unfortunately I have build the kernel with USB fix built in,
so I cannot unload the module.

While everything connected, a simple
lsusb
didn't show up any devices but what was there from the beginning.

Bu then, I did a 
lsusb -v
and whoops everything was back there ...

Is there a different way to achieve this?
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 007: ID 05ac:1006 Apple, Inc. Hub in Aluminum Keyboard
Bus 002 Device 003: ID 17ef:4815 Lenovo Integrated Webcam [R5U877]
Bus 001 Device 010: ID 1949:0004 Lab126 Amazon Kindle 3/4
Bus 001 Device 008: ID 05ac:0220 Apple, Inc. Aluminum Keyboard (ANSI)
Bus 001 Device 009: ID 05ac:0304 Apple, Inc. Optical USB Mouse [Mitsumi]

(now everything is connected via the kbd which serves as a hub, but
it was the same during direct connection of the kindle to the laptop).

Lenovo ThinkPad Edge.

Thanks a lot and all the best
(please Cc)

Norbert

--
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: Linux USB file storage gadget with new UDC

2013-01-21 Thread Felipe Balbi
Hi,

On Mon, Jan 21, 2013 at 04:15:32PM +0800, victor yeo wrote:
 Hi,
 
g_file_storage gadget: ep0-setup, length 8:
: 80 06 00 01 00 00 40 00
g_file_storage gadget: get device descriptor
   
For example, right here we should see the device descriptor data that
was sent back to the host.
  
   I checked the log again, the dmesg log did not contain that info. May
   i know which part of the gadget code will print out the device
   descriptor data that was sent back to the host?
  
   ep0_complete(), where it calls dump_msg().
 
  My Usb gadget hardware was broken for 2 weeks, i am sorry for the late
  reply. Today i check the ep0_complete() function, it is not called
  during Usb mass storage gadget enumeration with host PC. I am not sure
  which part of file_storage.c called ep0_complete(). Please kindly
  point out to me. Thanks.
 
  ep0_complete() should be called by your UDC driver. Seriously dude, read
  the documentation and read other drivers to figure out how things should
  be called. A quick look in the storage drivers would have shown you that
  ep0_complete() is passed in as req-complete() through the usb_request
  structure. That structure (well, a pointer to it) is passed to the UDC
  driver through usb_ep_queue(). All you had to figure out is when it
  req-complete called. ANY UDC driver would have given you the answer.
 
  Likely your UDC driver is still buggy, if you don't call -complete(),
  you're starving your usb_request queue.
 
 
 Yes, ep0_complete() is called in UDC driver queue function, i just
 added it in and ep0_complete() is called now. The dmesg output is
 below.

not in queue function, you should call it when completing.

 handle setup GET_DESCRIPTOR, 80, 6 index 0 value 100 len 40
 g_file_storage gadget: ep0-setup, length 8:
 : 80 06 00 01 00 00 40 00
 g_file_storage gadget: get device descriptor
 g_file_storage gadget: ep0_complete -- 0, 0/18
 
 the req-actual is 0, so dump_msg() in ep0_complete() is not called.

you need to increment req-actual by the amount of transferred bytes
reported by your HW

 My UDC driver is still buggy.

yes

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/2] CDC_NCM: adding support FLAG_NOARP for Infineon modem platform

2013-01-21 Thread Wei Shuai
Thank you David. yes in the core driver, FLAG_NOARP will be translated
to IFF_NOARP

2013/1/21, David Miller da...@davemloft.net:
 From: Wei Shuai cpuw...@gmail.com
 Date: Mon, 21 Jan 2013 10:20:22 +0800

 The main problem is that these devices don't support ethernet.

 He's saying your comment is referring to the wrong thing,
 rather than saying anything against what your change is
 doing.

 Read his feedback carefully:

 +/* Same as wwan_info, but with IFF_NOARP  */

 FLAG_NOARP, you mean?

 He's saying your commnet is talking about FLAG_NOARP rather
 than what the core code does with this flag, which is
 translate into setting IFF_NOARP on the net device.


--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB subsystem stops working

2013-01-21 Thread Felipe Balbi
Hi,

On Mon, Jan 21, 2013 at 04:51:28PM +0900, Norbert Preining wrote:
 Hi everyone,
 (please Cc)
 
 I am currently running 3.8.0-rc4 and see the following behaviour:
 When I plug/eject my kindle a few times, suddenly the kernel does
 not see any USB activity any more. Nothing. PLugging in the kindle -
 no reaction, plugging in a usb kbd - no reaction, plugging in a 
 usb  mouse - no reaction. All dead.
 
 I turned on udev debug mode, no messages at all.
 
 I restarted udev - no changes.
 
 Unfortunately I have build the kernel with USB fix built in,
 so I cannot unload the module.
 
 While everything connected, a simple
   lsusb
 didn't show up any devices but what was there from the beginning.
 
 Bu then, I did a 
   lsusb -v
 and whoops everything was back there ...
 
 Is there a different way to achieve this?
 Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
 Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 001 Device 007: ID 05ac:1006 Apple, Inc. Hub in Aluminum Keyboard
 Bus 002 Device 003: ID 17ef:4815 Lenovo Integrated Webcam [R5U877]
 Bus 001 Device 010: ID 1949:0004 Lab126 Amazon Kindle 3/4
 Bus 001 Device 008: ID 05ac:0220 Apple, Inc. Aluminum Keyboard (ANSI)
 Bus 001 Device 009: ID 05ac:0304 Apple, Inc. Optical USB Mouse [Mitsumi]
 
 (now everything is connected via the kbd which serves as a hub, but
 it was the same during direct connection of the kindle to the laptop).
 
 Lenovo ThinkPad Edge.

Can you try rebuilding your kernel with CONFIG_USB_DEBUG=y and run your
test again ? Maybe it gives us more information of what's going on.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 0/2] Adding USB 3.0 DRD-phy support for exynos5250

2013-01-21 Thread Felipe Balbi
Hi,

On Mon, Jan 21, 2013 at 12:15:10PM +0530, Vivek Gautam wrote:
 Hi Felipe,
 
 
 On Mon, Jan 14, 2013 at 6:29 PM, Vivek Gautam gautam.vi...@samsung.com 
 wrote:
  Changes from v2:
   - Renaming 'samsung-usbphy.c' driver to 'samsung-usb2.c' indicating
 usb 2.0 phy controller's driver for Samsung's SoCs.
   - Moving the register definitions and strcuture definitions to
 common header file 'samsung-usbphy.h' to be used across
 usb 2.0 and usb 3.0 phy.
   - Keeping common exported function definitions in samsung-usbphy.c
 which can be used across usb 2.0 and usb 3.0 phy.
   - Writting separate driver file for Samsung's USB 3.0 phy controller.
 and making it dependent on USB_DWC3.
 
 
 Is the re-organization being done here fine as per requirements for
 separate drivers for usb 2.0 type PHY and usb 3.0 type PHY ?

should be fine ;-) If there is *truly generic* pieces, it makes sense to
re-use - unless those generic parts are common driver churn
(platform_driver definition, module_init(), module_exit(), etc).

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH net] net: cdc_ncm: workaround for missing CDC Union

2013-01-21 Thread Bjørn Mork
Alexey Orishko alexey.oris...@gmail.com writes:
 On Fri, Jan 18, 2013 at 10:17 PM, Bjørn Mork bj...@mork.no wrote:

 Some Sierra Wireless firmwares support CDC MBIM but have no CDC
 Union funtional descriptor. This violates the MBIM specification,

 I don't believe Sierra Wireless violates MBIM specification.
 See in the specification: there are two ways to group interfaces: the
 WHCM Union functional descriptor and IAD.

I disagree.  This is not about the WHCM Union descriptor, it's about the
CDC Union descriptor.  WHCM is of course not mandatory.

Quoting that whole section from the MBIM specification:

quote
  6.1 OVERVIEW
  
  A USB MBIM function is implemented as a USB CDC function with two
  interfaces.  Functions shall provide a CDC Union functional descriptor
  to group these two interfaces.  See [USBWMC11].
  
  A Communication Class interface, with class 02h and subclass 0Eh, and
  a Data Class interface combine to form a single functional unit
  representing the USB MBIM device.  The Communication Class interface
  includes a single endpoint for event notification; it also uses the
  device’s default pipe for control messages.  The Data Class interface
  includes two bulk endpoints for data traffic.
  
  There are two ways to group interfaces: the WHCM Union Functional
  Descriptor (see [USBWMC11]) and the IAD.  Devices may also provide an
  IAD.  If an IAD is provided, the information in the IAD for MBIM
  functions shall be consistent with the information in the CDC Union
  descriptor and Communication Class interface descriptor.
/quote


The Functions shall provide a CDC Union functional descriptor to group
these two interfaces. is pretty clear IMHO.  You also have table 6‐2
listing the HEADER, UNION and MBIM functional descriptors as Required.

There is absolutely not way to make this anything but a firmware bug.

But I am all for working around it, of course.  There also seems to be a
couple more oddities with the MBIM mode of this device compared to the
other I've seen, but those are more likely revealing driver bugs.  I
intend to fix them as well.



Bjørn
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [balbi-usb:gadget 19/61] drivers/usb/gadget/mv_udc_core.c:1124:16: error: 'struct mv_usb_platform_data' has no member named 'phy_init'

2013-01-21 Thread Fengguang Wu
On Mon, Jan 21, 2013 at 10:13:43AM +0200, Felipe Balbi wrote:
 On Sun, Jan 20, 2013 at 05:24:05PM -0800, Chao Xie wrote:
[snip]
  I am formatting and re-test the patches. I will send out today.
  Thanks.
 
 
 great, please make sure to compile test on x86 and ARM with
 allyesconfig, allnoconfig and allmodconfig.

Note that allyesconfig, allnoconfig and allmodconfig builds are broken
in ARM. The ARM configs that are expected to be build tested can be
found in arch/arm/configs/. Just pick some of them for doing build tests.

Thanks,
Fengguang
--
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: Linux USB file storage gadget with new UDC

2013-01-21 Thread victor yeo
Hi,

  ep0_complete() should be called by your UDC driver. Seriously dude, read
  the documentation and read other drivers to figure out how things should
  be called. A quick look in the storage drivers would have shown you that
  ep0_complete() is passed in as req-complete() through the usb_request
  structure. That structure (well, a pointer to it) is passed to the UDC
  driver through usb_ep_queue(). All you had to figure out is when it
  req-complete called. ANY UDC driver would have given you the answer.
 
  Likely your UDC driver is still buggy, if you don't call -complete(),
  you're starving your usb_request queue.
 

 Yes, ep0_complete() is called in UDC driver queue function, i just
 added it in and ep0_complete() is called now. The dmesg output is
 below.

 not in queue function, you should call it when completing.


Is there any mistake in my understanding of ep0 setup data processing?

1. usb gadget HW IRQ is triggered if ep0 receives data
2. fsg_setup() is called
3. ep0_queue() is called
4. UDC driver queue function is called
5. UDC driver sends data to ep0 HW buffer
6. UDC driver increments req-actual by the amount of transferred bytes
7. UDC driver call ep0_complete()

thanks.
victor
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [balbi-usb:gadget 19/61] drivers/usb/gadget/mv_udc_core.c:1124:16: error: 'struct mv_usb_platform_data' has no member named 'phy_init'

2013-01-21 Thread Felipe Balbi
Hi,

On Mon, Jan 21, 2013 at 04:38:32PM +0800, Fengguang Wu wrote:
 On Mon, Jan 21, 2013 at 10:13:43AM +0200, Felipe Balbi wrote:
  On Sun, Jan 20, 2013 at 05:24:05PM -0800, Chao Xie wrote:
 [snip]
   I am formatting and re-test the patches. I will send out today.
   Thanks.
  
  
  great, please make sure to compile test on x86 and ARM with
  allyesconfig, allnoconfig and allmodconfig.
 
 Note that allyesconfig, allnoconfig and allmodconfig builds are broken
 in ARM. The ARM configs that are expected to be build tested can be
 found in arch/arm/configs/. Just pick some of them for doing build tests.

right, the multiarch support for ARM is broken in so many places...

-- 
balbi


signature.asc
Description: Digital signature


Re: Linux USB file storage gadget with new UDC

2013-01-21 Thread Felipe Balbi
On Mon, Jan 21, 2013 at 04:45:03PM +0800, victor yeo wrote:
 Hi,
 
   ep0_complete() should be called by your UDC driver. Seriously dude, read
   the documentation and read other drivers to figure out how things should
   be called. A quick look in the storage drivers would have shown you that
   ep0_complete() is passed in as req-complete() through the usb_request
   structure. That structure (well, a pointer to it) is passed to the UDC
   driver through usb_ep_queue(). All you had to figure out is when it
   req-complete called. ANY UDC driver would have given you the answer.
  
   Likely your UDC driver is still buggy, if you don't call -complete(),
   you're starving your usb_request queue.
  
 
  Yes, ep0_complete() is called in UDC driver queue function, i just
  added it in and ep0_complete() is called now. The dmesg output is
  below.
 
  not in queue function, you should call it when completing.
 
 
 Is there any mistake in my understanding of ep0 setup data processing?
 
 1. usb gadget HW IRQ is triggered if ep0 receives data
 2. fsg_setup() is called
 3. ep0_queue() is called
 4. UDC driver queue function is called
 5. UDC driver sends data to ep0 HW buffer
 6. UDC driver increments req-actual by the amount of transferred bytes
 7. UDC driver call ep0_complete()

looks correct

-- 
balbi


signature.asc
Description: Digital signature


[PATCH] usb: musb: fix context save over suspend.

2013-01-21 Thread NeilBrown


The standard suspend sequence involves runtime_resuming
devices before suspending the system.
So just saving context in runtime_suspend and restoring it
in runtime resume isn't enough.  We  must also save in suspend
and restore in resume.

Without this patch, and OMAP3 system with off_mode enabled will find
the musb port non-functional after suspend/resume.  With the patch it
works perfectly.

Signed-off-by: NeilBrown ne...@suse.de

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index fd34867..b6ccc02 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2225,6 +2225,7 @@ static int musb_suspend(struct device *dev)
}
 
spin_unlock_irqrestore(musb-lock, flags);
+   musb_save_context(musb);
return 0;
 }
 
@@ -2234,6 +2235,8 @@ static int musb_resume_noirq(struct device *dev)
 * unless for some reason the whole soc powered down or the USB
 * module got reset through the PSC (vs just being disabled).
 */
+   struct musb *musb = dev_to_musb(dev);
+   musb_restore_context(musb);
return 0;
 }
 


signature.asc
Description: PGP signature


Re: [PATCH v8 19/22] ARM: OMAP3: clock data: get rid of unused USB host clock aliases and dummies

2013-01-21 Thread Roger Quadros
On 01/18/2013 10:27 PM, Paul Walmsley wrote:
 Hi Roger,
 
 On Fri, 18 Jan 2013, Roger Quadros wrote:
 
 We don't need multiple aliases for the OMAP USB host clocks and neither
 the dummy clocks so remove them.

 CC: Paul Walmsley p...@pwsan.com
 CC: Rajendra Nayak rna...@ti.com
 CC: Benoit Cousson b-cous...@ti.com
 CC: Mike Turquette mturque...@linaro.com

 Signed-off-by: Roger Quadros rog...@ti.com
 Reviewed-by: Felipe Balbi ba...@ti.com
 Acked-by: Paul Walmsley p...@pwsan.com
 
 Per Tony's earlier request, you can drop this patch and patch 20 from your 
 series now.  I've got them queued for 3.10 or late 3.9 merge window.
 

Should have mentioned it earlier, but just this patch without the rest
of the cleanup patches will break USB Host on OMAP3, as the old driver
bails out if optional clock nodes are missing.

Including patch 20 doesn't seem to cause a problem with OMAP4 though.

regards,
-roger
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 2/4] usb: phy: samsung: Add host phy support to samsung-phy driver

2013-01-21 Thread Vivek Gautam
Hi Kukjin,


On Fri, Jan 18, 2013 at 8:37 PM, Felipe Balbi ba...@ti.com wrote:
 On Fri, Jan 18, 2013 at 07:59:52PM +0530, Vivek Gautam wrote:
 HI Balbi,


 On Fri, Jan 18, 2013 at 7:52 PM, Felipe Balbi ba...@ti.com wrote:
  On Fri, Jan 18, 2013 at 07:51:08PM +0530, Vivek Gautam wrote:
  Hi Felipe,
 
 
  On Fri, Jan 18, 2013 at 6:46 PM, Felipe Balbi ba...@ti.com wrote:
   Hi,
  
   On Mon, Jan 14, 2013 at 05:52:15PM +0530, Vivek Gautam wrote:
   This patch adds host phy support to samsung-usbphy driver and
   further adds support for samsung's exynos5250 usb-phy.
  
   Signed-off-by: Praveen Paneri p.pan...@samsung.com
   Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
  
   Missing Kukjim's Acked-by here
  
 
  Hope you are fine with the changes happened after discussion in thread:
  [PATCH v5 2/4] usb: phy: samsung: Add host phy support to samsung-phy 
  driver
 
  Is it something you want me to modify in this patch ?
 
  please send the final patch and we shall see. After quickly browsing
  that thread, I didn't see anything scary, but I'd like to see your final
  version before giving my final answer ;-)
 

 this series of patch is the final version from my side unless Doug or
 you have any further comments
 on the thread :
 https://lkml.org/lkml/2013/1/14/481

 Seems like Doug wanted to know your opinion in this regard. ;-)

 only Kukjim's Acked-by missing ;-)


Any comments on this patch-series please ?


-- 
Thanks  Regards
Vivek
--
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


[V4 PATCH 00/26] mv-usb fix and enhancement patches

2013-01-21 Thread Chao Xie
The patches are divied into 4 parts
1. bug fixes
  usb: gadget: mv_udc: use udc_start and udc_stop functions
  usb: gadget: mv_udc: use devm_xxx for probe
  usb: gadget: mv_udc: fix the warning of mv_udc_remove
  usb: otg: mv_otg: use devm_xxx for probe
  usb: host: ehci-mv: remove unused variable
  usb: gadget: mv_udc: fix the value of tranceiver
  usb: gadget: mv_udc: make mv_udc depends on ARCH_MMP or ARCH_PXA
Above patches are bug fixes.

2. PHY driver
To remove the callbacks in the platform data, a usb PHY driver
for marvell udc/otg/ehci is written.
For device tree support, it is not good to pass the callback
pointers by platform data. The PHY driver also removes the
block.

  usb: phy: mv_usb2: add PHY driver for marvell usb2 controller
  usb: gadget: mv_udc: use PHY driver for udc
  usb: ehci: ehci-mv: use PHY driver for ehci
  usb: otg: mv_otg: use PHY driver for otg
Above patches are marvell usb PHY driver support.

  arm: mmp2: change the defintion of usb devices
  arm: pxa910: change the defintion of usb devices
  arm: brownstone: add usb support for the board
  arm: ttc_dkb: add usb support
  arm: mmp: remove the usb phy setting
  arm: mmp: remove usb devices from pxa168
Above patches are for SOC/board support for marvell usb PHY
driver.

3. external chip support
The marvell usb controller can detect the vbus/idpin, but it
need PHY and usb clocks to be enabled.
Based on measurement it will import 15mA current, and increase
the power when the usb is not used.
Using a external chip to detect vbus/idpin changes will save
the power.
In fact the marvell PMIC 88pm860x and 88pm80x can do it. The
drivers are located at drivers/mfd.
So add a middle layer in the marvell usb PHY driver.
PMIC call the APIs in middle driver to registers the callback
for vbus/idpin detection/query
udc/otg/ehci driver will call the APIs to get vbus/idpin changes
and query the states of the vbus/idpin.
  usb: phy: mv_usb2_phy: add externel chip support
  usb: gadget: mv_udc: add extern chip support
  usb: ehci: ehci-mv: add extern chip support
  usb: otg: mv_otg: add extern chip support
Above patches are the middle layer suppor for udc/otg/ehci

  arm: mmp: add extern chip support for brownstone
  arm: mmp: add extern chip support for ttc_dkb
Above patches are corresponding board file changes

4. device tree support
After removing the callbacks in platform data, and the not
constant variables in platform data. All the information needed
by udc/otg/ehci driver are constant.

  usb: gadget: mv_udc: add device tree support
  usb: otg: mv_otg: add device tree support
  usb: ehci: ehci-mv: add device tree support
Above patches are device tree support for udc/otg/ehci driver.

V2-V1:
  Change the Signed-off-by to be right email address

v3-v2
  re-format the patches to new code base

v4-v3
  1. make mv udc gadget driver depend on ARCH_PXA and ARCH_MMP
  2. remove __devinit and __devexit
  3. make the driver compiled successful if CONFIG_MV_USB2_PHY is not defined.
  The modified patches are
  usb: gadget: mv_udc: make mv_udc depends on ARCH_MMP or ARCH_PXA
  usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

Chao Xie (26):
  usb: gadget: mv_udc: use udc_start and udc_stop functions
  usb: gadget: mv_udc: use devm_xxx for probe
  usb: gadget: mv_udc: fix the warning of mv_udc_remove
  usb: otg: mv_otg: use devm_xxx for probe
  usb: host: ehci-mv: remove unused variable
  usb: gadget: mv_udc: fix the value of tranceiver
  usb: gadget: mv_udc: make mv_udc depends on ARCH_MMP or ARCH_PXA
  usb: phy: mv_usb2: add PHY driver for marvell usb2 controller
  usb: gadget: mv_udc: use PHY driver for udc
  usb: ehci: ehci-mv: use PHY driver for ehci
  usb: otg: mv_otg: use PHY driver for otg
  arm: mmp2: change the defintion of usb devices
  arm: pxa910: change the defintion of usb devices
  arm: brownstone: add usb support for the board
  arm: ttc_dkb: add usb support
  arm: mmp: remove the usb phy setting
  arm: mmp: remove usb devices from pxa168
  usb: phy: mv_usb2_phy: add externel chip support
  usb: gadget: mv_udc: add extern chip support
  usb: ehci: ehci-mv: add extern chip support
  usb: otg: mv_otg: add extern chip support
  arm: mmp: add extern chip support for brownstone
  arm: mmp: add extern chip support for ttc_dkb
  usb: gadget: mv_udc: add device tree support
  usb: otg: mv_otg: add device tree support
  usb: ehci: ehci-mv: add device tree support

 arch/arm/mach-mmp/brownstone.c|   45 +++
 arch/arm/mach-mmp/devices.c   |  278 
 arch/arm/mach-mmp/include/mach/mmp2.h |4 +
 arch/arm/mach-mmp/include/mach/pxa910.h   |7 +-
 arch/arm/mach-mmp/include/mach/regs-usb.h |  253 --
 arch/arm/mach-mmp/mmp2.c  |4 +
 arch/arm/mach-mmp/pxa168.c|   42 ---
 arch/arm/mach-mmp/pxa910.c|4 +
 arch/arm/mach-mmp/ttc_dkb.c   |   32 +-
 drivers/usb/gadget/mv_udc.h   |   10 +-
 

[V4 PATCH 01/26] usb: gadget: mv_udc: use udc_start and udc_stop functions

2013-01-21 Thread Chao Xie
This patches converts the driver into the new style start/stop
interface. As a result the driver no longer uses the static
global the_conroller variable.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/gadget/mv_udc_core.c |   79 +-
 1 files changed, 35 insertions(+), 44 deletions(-)

diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index 6e8b127..32a9972 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -61,9 +61,6 @@ static DECLARE_COMPLETION(release_done);
 static const char driver_name[] = mv_udc;
 static const char driver_desc[] = DRIVER_DESC;
 
-/* controller device global variable */
-static struct mv_udc   *the_controller;
-
 static void nuke(struct mv_ep *ep, int status);
 static void stop_activity(struct mv_udc *udc, struct usb_gadget_driver 
*driver);
 
@@ -1268,9 +1265,8 @@ static int mv_udc_pullup(struct usb_gadget *gadget, int 
is_on)
return retval;
 }
 
-static int mv_udc_start(struct usb_gadget_driver *driver,
-   int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
-static int mv_udc_stop(struct usb_gadget_driver *driver);
+static int mv_udc_start(struct usb_gadget *, struct usb_gadget_driver *);
+static int mv_udc_stop(struct usb_gadget *, struct usb_gadget_driver *);
 /* device controller usb_gadget_ops structure */
 static const struct usb_gadget_ops mv_ops = {
 
@@ -1285,8 +1281,8 @@ static const struct usb_gadget_ops mv_ops = {
 
/* D+ pullup, software-controlled connect/disconnect to USB host */
.pullup = mv_udc_pullup,
-   .start  = mv_udc_start,
-   .stop   = mv_udc_stop,
+   .udc_start  = mv_udc_start,
+   .udc_stop   = mv_udc_stop,
 };
 
 static int eps_init(struct mv_udc *udc)
@@ -1373,15 +1369,14 @@ static void stop_activity(struct mv_udc *udc, struct 
usb_gadget_driver *driver)
}
 }
 
-static int mv_udc_start(struct usb_gadget_driver *driver,
-   int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
+static int mv_udc_start(struct usb_gadget *gadget,
+   struct usb_gadget_driver *driver)
 {
-   struct mv_udc *udc = the_controller;
+   struct mv_udc *udc;
int retval = 0;
unsigned long flags;
 
-   if (!udc)
-   return -ENODEV;
+   udc = container_of(gadget, struct mv_udc, gadget);
 
if (udc-driver)
return -EBUSY;
@@ -1399,26 +1394,14 @@ static int mv_udc_start(struct usb_gadget_driver 
*driver,
 
spin_unlock_irqrestore(udc-lock, flags);
 
-   retval = bind(udc-gadget, driver);
-   if (retval) {
-   dev_err(udc-dev-dev, bind to driver %s -- %d\n,
-   driver-driver.name, retval);
-   udc-driver = NULL;
-   udc-gadget.dev.driver = NULL;
-   return retval;
-   }
-
if (!IS_ERR_OR_NULL(udc-transceiver)) {
retval = otg_set_peripheral(udc-transceiver-otg,
udc-gadget);
if (retval) {
dev_err(udc-dev-dev,
unable to register peripheral to otg\n);
-   if (driver-unbind) {
-   driver-unbind(udc-gadget);
-   udc-gadget.dev.driver = NULL;
-   udc-driver = NULL;
-   }
+   udc-driver = NULL;
+   udc-gadget.dev.driver = NULL;
return retval;
}
}
@@ -1433,13 +1416,13 @@ static int mv_udc_start(struct usb_gadget_driver 
*driver,
return 0;
 }
 
-static int mv_udc_stop(struct usb_gadget_driver *driver)
+static int mv_udc_stop(struct usb_gadget *gadget,
+   struct usb_gadget_driver *driver)
 {
-   struct mv_udc *udc = the_controller;
+   struct mv_udc *udc;
unsigned long flags;
 
-   if (!udc)
-   return -ENODEV;
+   udc = container_of(gadget, struct mv_udc, gadget);
 
spin_lock_irqsave(udc-lock, flags);
 
@@ -1454,7 +1437,6 @@ static int mv_udc_stop(struct usb_gadget_driver *driver)
spin_unlock_irqrestore(udc-lock, flags);
 
/* unbind gadget driver */
-   driver-unbind(udc-gadget);
udc-gadget.dev.driver = NULL;
udc-driver = NULL;
 
@@ -1472,10 +1454,13 @@ static void mv_set_ptc(struct mv_udc *udc, u32 mode)
 
 static void prime_status_complete(struct usb_ep *ep, struct usb_request *_req)
 {
-   struct mv_udc *udc = the_controller;
+   struct mv_ep *mvep = container_of(ep, struct mv_ep, ep);
struct mv_req *req = container_of(_req, struct mv_req, req);
+   struct mv_udc *udc;
unsigned long flags;
 
+   udc = mvep-udc;
+
dev_info(udc-dev-dev, switch to test mode %d\n, req-test_mode);
 

[V4 PATCH 02/26] usb: gadget: mv_udc: use devm_xxx for probe

2013-01-21 Thread Chao Xie
use devm_xxx for udc driver probe. So we do need care about
the resources release in driver remove or failure handling
in driver probe.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/gadget/mv_udc_core.c |  156 ++
 1 files changed, 56 insertions(+), 100 deletions(-)

diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index 32a9972..e2fdc8e 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -2115,12 +2115,11 @@ static void gadget_release(struct device *_dev)
complete(udc-done);
 }
 
-static int mv_udc_remove(struct platform_device *dev)
+static int mv_udc_remove(struct platform_device *pdev)
 {
struct mv_udc *udc;
-   int clk_i;
 
-   udc = platform_get_drvdata(dev);
+   udc = platform_get_drvdata(pdev);
 
usb_del_gadget_udc(udc-gadget);
 
@@ -2129,55 +2128,27 @@ static int mv_udc_remove(struct platform_device *dev)
destroy_workqueue(udc-qwork);
}
 
-   /*
-* If we have transceiver inited,
-* then vbus irq will not be requested in udc driver.
-*/
-   if (udc-pdata  udc-pdata-vbus
-udc-clock_gating  IS_ERR_OR_NULL(udc-transceiver))
-   free_irq(udc-pdata-vbus-irq, dev-dev);
-
/* free memory allocated in probe */
if (udc-dtd_pool)
dma_pool_destroy(udc-dtd_pool);
 
if (udc-ep_dqh)
-   dma_free_coherent(dev-dev, udc-ep_dqh_size,
+   dma_free_coherent(pdev-dev, udc-ep_dqh_size,
udc-ep_dqh, udc-ep_dqh_dma);
 
-   kfree(udc-eps);
-
-   if (udc-irq)
-   free_irq(udc-irq, dev-dev);
-
mv_udc_disable(udc);
 
-   if (udc-cap_regs)
-   iounmap(udc-cap_regs);
-
-   if (udc-phy_regs)
-   iounmap(udc-phy_regs);
-
-   if (udc-status_req) {
-   kfree(udc-status_req-req.buf);
-   kfree(udc-status_req);
-   }
-
-   for (clk_i = 0; clk_i = udc-clknum; clk_i++)
-   clk_put(udc-clk[clk_i]);
-
device_unregister(udc-gadget.dev);
 
/* free dev, wait for the release() finished */
wait_for_completion(udc-done);
-   kfree(udc);
 
return 0;
 }
 
-static int mv_udc_probe(struct platform_device *dev)
+static int mv_udc_probe(struct platform_device *pdev)
 {
-   struct mv_usb_platform_data *pdata = dev-dev.platform_data;
+   struct mv_usb_platform_data *pdata = pdev-dev.platform_data;
struct mv_udc *udc;
int retval = 0;
int clk_i = 0;
@@ -2185,70 +2156,68 @@ static int mv_udc_probe(struct platform_device *dev)
size_t size;
 
if (pdata == NULL) {
-   dev_err(dev-dev, missing platform_data\n);
+   dev_err(pdev-dev, missing platform_data\n);
return -ENODEV;
}
 
size = sizeof(*udc) + sizeof(struct clk *) * pdata-clknum;
-   udc = kzalloc(size, GFP_KERNEL);
+   udc = devm_kzalloc(pdev-dev, size, GFP_KERNEL);
if (udc == NULL) {
-   dev_err(dev-dev, failed to allocate memory for udc\n);
+   dev_err(pdev-dev, failed to allocate memory for udc\n);
return -ENOMEM;
}
 
udc-done = release_done;
-   udc-pdata = dev-dev.platform_data;
+   udc-pdata = pdev-dev.platform_data;
spin_lock_init(udc-lock);
 
-   udc-dev = dev;
+   udc-dev = pdev;
 
 #ifdef CONFIG_USB_OTG_UTILS
if (pdata-mode == MV_USB_MODE_OTG)
-   udc-transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+   udc-transceiver = devm_usb_get_phy(pdev-dev,
+   USB_PHY_TYPE_USB2);
 #endif
 
udc-clknum = pdata-clknum;
for (clk_i = 0; clk_i  udc-clknum; clk_i++) {
-   udc-clk[clk_i] = clk_get(dev-dev, pdata-clkname[clk_i]);
+   udc-clk[clk_i] = devm_clk_get(pdev-dev,
+   pdata-clkname[clk_i]);
if (IS_ERR(udc-clk[clk_i])) {
retval = PTR_ERR(udc-clk[clk_i]);
-   goto err_put_clk;
+   return retval;
}
}
 
r = platform_get_resource_byname(udc-dev, IORESOURCE_MEM, capregs);
if (r == NULL) {
-   dev_err(dev-dev, no I/O memory resource defined\n);
-   retval = -ENODEV;
-   goto err_put_clk;
+   dev_err(pdev-dev, no I/O memory resource defined\n);
+   return -ENODEV;
}
 
udc-cap_regs = (struct mv_cap_regs __iomem *)
-   ioremap(r-start, resource_size(r));
+   devm_ioremap(pdev-dev, r-start, resource_size(r));
if (udc-cap_regs == NULL) {
-   dev_err(dev-dev, failed to map I/O memory\n);
-   retval = -EBUSY;
-   goto err_put_clk;
+   

[V4 PATCH 05/26] usb: host: ehci-mv: remove unused variable

2013-01-21 Thread Chao Xie
Signed-off-by: Chao Xie chao@marvell.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-mv.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 6c56297..3065809 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -302,7 +302,6 @@ static int mv_ehci_remove(struct platform_device *pdev)
 {
struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
struct usb_hcd *hcd = ehci_mv-hcd;
-   int clk_i;
 
if (hcd-rh_registered)
usb_remove_hcd(hcd);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 06/26] usb: gadget: mv_udc: fix the value of tranceiver

2013-01-21 Thread Chao Xie
usally we will use udc-tranceiver == NULL or
udc-tranceiver != NULL.
So when failed to get the udc-tranceiver by usb_get_phy(), we
directly set udc-tranceiver to be NULL.
Then the source code will not need macro IS_ERR_OR_NULL() for
udc-tranceiver judgement. It can reduce the line size and make
the judgement simple.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/gadget/mv_udc_core.c |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index 910c4b5..c8cf959 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -1394,7 +1394,7 @@ static int mv_udc_start(struct usb_gadget *gadget,
 
spin_unlock_irqrestore(udc-lock, flags);
 
-   if (!IS_ERR_OR_NULL(udc-transceiver)) {
+   if (udc-transceiver) {
retval = otg_set_peripheral(udc-transceiver-otg,
udc-gadget);
if (retval) {
@@ -2174,9 +2174,14 @@ static int mv_udc_probe(struct platform_device *pdev)
udc-dev = pdev;
 
 #ifdef CONFIG_USB_OTG_UTILS
-   if (pdata-mode == MV_USB_MODE_OTG)
+   if (pdata-mode == MV_USB_MODE_OTG) {
udc-transceiver = devm_usb_get_phy(pdev-dev,
USB_PHY_TYPE_USB2);
+   if (IS_ERR_OR_NULL(udc-transceiver)) {
+   udc-transceiver = NULL;
+   return -ENODEV;
+   }
+   }
 #endif
 
udc-clknum = pdata-clknum;
@@ -2319,7 +2324,7 @@ static int mv_udc_probe(struct platform_device *pdev)
eps_init(udc);
 
/* VBUS detect: we can disable/enable clock on demand.*/
-   if (!IS_ERR_OR_NULL(udc-transceiver))
+   if (udc-transceiver)
udc-clock_gating = 1;
else if (pdata-vbus) {
udc-clock_gating = 1;
@@ -2386,7 +2391,7 @@ static int mv_udc_suspend(struct device *dev)
udc = dev_get_drvdata(dev);
 
/* if OTG is enabled, the following will be done in OTG driver*/
-   if (!IS_ERR_OR_NULL(udc-transceiver))
+   if (udc-transceiver)
return 0;
 
if (udc-pdata-vbus  udc-pdata-vbus-poll)
@@ -2421,7 +2426,7 @@ static int mv_udc_resume(struct device *dev)
udc = dev_get_drvdata(dev);
 
/* if OTG is enabled, the following will be done in OTG driver*/
-   if (!IS_ERR_OR_NULL(udc-transceiver))
+   if (udc-transceiver)
return 0;
 
if (!udc-clock_gating) {
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 03/26] usb: gadget: mv_udc: fix the warning of mv_udc_remove

2013-01-21 Thread Chao Xie
The __exit_p() will be NULL if MODULE is no defined.
It will cause the warning. Removing __exit_p to remove
the warning.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/gadget/mv_udc_core.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index e2fdc8e..910c4b5 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -2461,7 +2461,7 @@ static void mv_udc_shutdown(struct platform_device *pdev)
 
 static struct platform_driver udc_driver = {
.probe  = mv_udc_probe,
-   .remove = __exit_p(mv_udc_remove),
+   .remove = mv_udc_remove,
.shutdown   = mv_udc_shutdown,
.driver = {
.owner  = THIS_MODULE,
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 07/26] usb: gadget: mv_udc: make mv_udc depends on ARCH_MMP or ARCH_PXA

2013-01-21 Thread Chao Xie
Only ARCH_PXA and ARCH_MMP will use mv_udc.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/gadget/Kconfig |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 14625fd..53943f7 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -319,6 +319,7 @@ config USB_S3C_HSUDC
 
 config USB_MV_UDC
tristate Marvell USB2.0 Device Controller
+   depends on ARCH_PXA || ARCH_MMP
help
  Marvell Socs (including PXA and MMP series) include a high speed
  USB2.0 OTG controller, which can be configured as high speed or
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 09/26] usb: gadget: mv_udc: use PHY driver for udc

2013-01-21 Thread Chao Xie
Originaly, udc driver will call the callbacks in platform data
for PHY initialization and shut down.
With PHY driver, it will call the APIs provided by PHY driver
for PHY initialization and shut down. It removes the callbacks
in platform data, and at same time it removes one block in the
way of enabling device tree for udc driver.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/gadget/mv_udc.h  |2 +-
 drivers/usb/gadget/mv_udc_core.c |   23 ---
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/mv_udc.h b/drivers/usb/gadget/mv_udc.h
index 9073436..4851b2b 100644
--- a/drivers/usb/gadget/mv_udc.h
+++ b/drivers/usb/gadget/mv_udc.h
@@ -180,7 +180,6 @@ struct mv_udc {
 
struct mv_cap_regs __iomem  *cap_regs;
struct mv_op_regs __iomem   *op_regs;
-   void __iomem*phy_regs;
unsigned intmax_eps;
struct mv_dqh   *ep_dqh;
size_t  ep_dqh_size;
@@ -217,6 +216,7 @@ struct mv_udc {
struct work_struct  vbus_work;
struct workqueue_struct *qwork;
 
+   struct mv_usb2_phy  *phy;
struct usb_phy  *transceiver;
 
struct mv_usb_platform_data *pdata;
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index c8cf959..76fcfc7 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -35,6 +35,7 @@
 #include linux/platform_device.h
 #include linux/clk.h
 #include linux/platform_data/mv_usb.h
+#include linux/usb/mv_usb2.h
 #include asm/unaligned.h
 
 #include mv_udc.h
@@ -1121,8 +1122,8 @@ static int mv_udc_enable_internal(struct mv_udc *udc)
 
dev_dbg(udc-dev-dev, enable udc\n);
udc_clock_enable(udc);
-   if (udc-pdata-phy_init) {
-   retval = udc-pdata-phy_init(udc-phy_regs);
+   if (udc-phy-init) {
+   retval = udc-phy-init(udc-phy);
if (retval) {
dev_err(udc-dev-dev,
init phy error %d\n, retval);
@@ -1147,8 +1148,8 @@ static void mv_udc_disable_internal(struct mv_udc *udc)
 {
if (udc-active) {
dev_dbg(udc-dev-dev, disable udc\n);
-   if (udc-pdata-phy_deinit)
-   udc-pdata-phy_deinit(udc-phy_regs);
+   if (udc-phy-shutdown)
+   udc-phy-shutdown(udc-phy);
udc_clock_disable(udc);
udc-active = 0;
}
@@ -2194,7 +2195,7 @@ static int mv_udc_probe(struct platform_device *pdev)
}
}
 
-   r = platform_get_resource_byname(udc-dev, IORESOURCE_MEM, capregs);
+   r = platform_get_resource(udc-dev, IORESOURCE_MEM, 0);
if (r == NULL) {
dev_err(pdev-dev, no I/O memory resource defined\n);
return -ENODEV;
@@ -2207,17 +2208,9 @@ static int mv_udc_probe(struct platform_device *pdev)
return -EBUSY;
}
 
-   r = platform_get_resource_byname(udc-dev, IORESOURCE_MEM, phyregs);
-   if (r == NULL) {
-   dev_err(pdev-dev, no phy I/O memory resource defined\n);
+   udc-phy = mv_usb2_get_phy();
+   if (udc-phy == NULL)
return -ENODEV;
-   }
-
-   udc-phy_regs = ioremap(r-start, resource_size(r));
-   if (udc-phy_regs == NULL) {
-   dev_err(pdev-dev, failed to map phy I/O memory\n);
-   return -EBUSY;
-   }
 
/* we will acces controller register, so enable the clk */
retval = mv_udc_enable_internal(udc);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 08/26] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-01-21 Thread Chao Xie
The PHY is seperated from usb controller.
The usb controller used in marvell pxa168/pxa910/mmp2 are same,
but PHY initialization may be different.
the usb controller can support udc/otg/ehci, and for each of
the mode, it need PHY to initialized before use the controller.
Direclty writing the phy driver will make the usb controller
driver to be simple and portable.
The PHY driver will be used by marvell udc/otg/ehci.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/phy/Kconfig  |7 +
 drivers/usb/phy/Makefile |1 +
 drivers/usb/phy/mv_usb2_phy.c|  454 ++
 include/linux/platform_data/mv_usb.h |9 +-
 include/linux/usb/mv_usb2.h  |   43 
 5 files changed, 511 insertions(+), 3 deletions(-)
 create mode 100644 drivers/usb/phy/mv_usb2_phy.c
 create mode 100644 include/linux/usb/mv_usb2.h

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 5de6e7f..7bfce04 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -45,3 +45,10 @@ config USB_RCAR_PHY
 
  To compile this driver as a module, choose M here: the
  module will be called rcar-phy.
+
+config MV_USB2_PHY
+   tristate Marvell USB 2.0 PHY Driver
+   depends on ARCH_PXA || ARCH_MMP
+   help
+ Enable this to support Marvell USB 2.0 phy driver for Marvell
+ SoC.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 1a579a8..e33e09c 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_USB_ISP1301)   += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
 obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
+obj-$(CONFIG_MV_USB2_PHY)  += mv_usb2_phy.o
diff --git a/drivers/usb/phy/mv_usb2_phy.c b/drivers/usb/phy/mv_usb2_phy.c
new file mode 100644
index 000..c2bccae
--- /dev/null
+++ b/drivers/usb/phy/mv_usb2_phy.c
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * Author:
+ * Chao Xie xiechao.m...@gmail.com
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include linux/resource.h
+#include linux/delay.h
+#include linux/slab.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/io.h
+#include linux/err.h
+#include linux/clk.h
+#include linux/export.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/platform_data/mv_usb.h
+#include linux/usb/mv_usb2.h
+
+/* phy regs */
+#define UTMI_REVISION  0x0
+#define UTMI_CTRL  0x4
+#define UTMI_PLL   0x8
+#define UTMI_TX0xc
+#define UTMI_RX0x10
+#define UTMI_IVREF 0x14
+#define UTMI_T00x18
+#define UTMI_T10x1c
+#define UTMI_T20x20
+#define UTMI_T30x24
+#define UTMI_T40x28
+#define UTMI_T50x2c
+#define UTMI_RESERVE   0x30
+#define UTMI_USB_INT   0x34
+#define UTMI_DBG_CTL   0x38
+#define UTMI_OTG_ADDON 0x3c
+
+/* For UTMICTRL Register */
+#define UTMI_CTRL_USB_CLK_EN(1  31)
+/* pxa168 */
+#define UTMI_CTRL_SUSPEND_SET1  (1  30)
+#define UTMI_CTRL_SUSPEND_SET2  (1  29)
+#define UTMI_CTRL_RXBUF_PDWN(1  24)
+#define UTMI_CTRL_TXBUF_PDWN(1  11)
+
+#define UTMI_CTRL_INPKT_DELAY_SHIFT 30
+#define UTMI_CTRL_INPKT_DELAY_SOF_SHIFT28
+#define UTMI_CTRL_PU_REF_SHIFT 20
+#define UTMI_CTRL_ARC_PULLDN_SHIFT  12
+#define UTMI_CTRL_PLL_PWR_UP_SHIFT  1
+#define UTMI_CTRL_PWR_UP_SHIFT  0
+
+/* For UTMI_PLL Register */
+#define UTMI_PLL_PLLCALI12_SHIFT   29
+#define UTMI_PLL_PLLCALI12_MASK(0x3  29)
+
+#define UTMI_PLL_PLLVDD18_SHIFT27
+#define UTMI_PLL_PLLVDD18_MASK (0x3  27)
+
+#define UTMI_PLL_PLLVDD12_SHIFT25
+#define UTMI_PLL_PLLVDD12_MASK (0x3  25)
+
+#define UTMI_PLL_CLK_BLK_EN_SHIFT   24
+#define CLK_BLK_EN  (0x1  24)
+#define PLL_READY   (0x1  23)
+#define KVCO_EXT(0x1  22)
+#define VCOCAL_START(0x1  21)
+
+#define UTMI_PLL_KVCO_SHIFT15

[V4 PATCH 04/26] usb: otg: mv_otg: use devm_xxx for probe

2013-01-21 Thread Chao Xie
use devm_xxx for otg driver probe. So we do need care about
the resources release in driver remove or failure handling
in driver probe.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/otg/mv_otg.c |   82 -
 1 files changed, 22 insertions(+), 60 deletions(-)

diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index eace975..da2d60c 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -662,18 +662,9 @@ static struct attribute_group inputs_attr_group = {
 int mv_otg_remove(struct platform_device *pdev)
 {
struct mv_otg *mvotg = platform_get_drvdata(pdev);
-   int clk_i;
 
sysfs_remove_group(mvotg-pdev-dev.kobj, inputs_attr_group);
 
-   if (mvotg-irq)
-   free_irq(mvotg-irq, mvotg);
-
-   if (mvotg-pdata-vbus)
-   free_irq(mvotg-pdata-vbus-irq, mvotg);
-   if (mvotg-pdata-id)
-   free_irq(mvotg-pdata-id-irq, mvotg);
-
if (mvotg-qwork) {
flush_workqueue(mvotg-qwork);
destroy_workqueue(mvotg-qwork);
@@ -681,21 +672,9 @@ int mv_otg_remove(struct platform_device *pdev)
 
mv_otg_disable(mvotg);
 
-   if (mvotg-cap_regs)
-   iounmap(mvotg-cap_regs);
-
-   if (mvotg-phy_regs)
-   iounmap(mvotg-phy_regs);
-
-   for (clk_i = 0; clk_i = mvotg-clknum; clk_i++)
-   clk_put(mvotg-clk[clk_i]);
-
usb_remove_phy(mvotg-phy);
platform_set_drvdata(pdev, NULL);
 
-   kfree(mvotg-phy.otg);
-   kfree(mvotg);
-
return 0;
 }
 
@@ -714,17 +693,15 @@ static int mv_otg_probe(struct platform_device *pdev)
}
 
size = sizeof(*mvotg) + sizeof(struct clk *) * pdata-clknum;
-   mvotg = kzalloc(size, GFP_KERNEL);
+   mvotg = devm_kzalloc(pdev-dev, size, GFP_KERNEL);
if (!mvotg) {
dev_err(pdev-dev, failed to allocate memory!\n);
return -ENOMEM;
}
 
-   otg = kzalloc(sizeof *otg, GFP_KERNEL);
-   if (!otg) {
-   kfree(mvotg);
+   otg = devm_kzalloc(pdev-dev, sizeof(*otg), GFP_KERNEL);
+   if (!otg)
return -ENOMEM;
-   }
 
platform_set_drvdata(pdev, mvotg);
 
@@ -733,18 +710,18 @@ static int mv_otg_probe(struct platform_device *pdev)
 
mvotg-clknum = pdata-clknum;
for (clk_i = 0; clk_i  mvotg-clknum; clk_i++) {
-   mvotg-clk[clk_i] = clk_get(pdev-dev, pdata-clkname[clk_i]);
+   mvotg-clk[clk_i] = devm_clk_get(pdev-dev,
+   pdata-clkname[clk_i]);
if (IS_ERR(mvotg-clk[clk_i])) {
retval = PTR_ERR(mvotg-clk[clk_i]);
-   goto err_put_clk;
+   return retval;
}
}
 
mvotg-qwork = create_singlethread_workqueue(mv_otg_queue);
if (!mvotg-qwork) {
dev_dbg(pdev-dev, cannot create workqueue for OTG\n);
-   retval = -ENOMEM;
-   goto err_put_clk;
+   return -ENOMEM;
}
 
INIT_DELAYED_WORK(mvotg-work, mv_otg_work);
@@ -772,7 +749,7 @@ static int mv_otg_probe(struct platform_device *pdev)
goto err_destroy_workqueue;
}
 
-   mvotg-phy_regs = ioremap(r-start, resource_size(r));
+   mvotg-phy_regs = devm_ioremap(pdev-dev, r-start, resource_size(r));
if (mvotg-phy_regs == NULL) {
dev_err(pdev-dev, failed to map phy I/O memory\n);
retval = -EFAULT;
@@ -784,21 +761,21 @@ static int mv_otg_probe(struct platform_device *pdev)
if (r == NULL) {
dev_err(pdev-dev, no I/O memory resource defined\n);
retval = -ENODEV;
-   goto err_unmap_phyreg;
+   goto err_destroy_workqueue;
}
 
-   mvotg-cap_regs = ioremap(r-start, resource_size(r));
+   mvotg-cap_regs = devm_ioremap(pdev-dev, r-start, resource_size(r));
if (mvotg-cap_regs == NULL) {
dev_err(pdev-dev, failed to map I/O memory\n);
retval = -EFAULT;
-   goto err_unmap_phyreg;
+   goto err_destroy_workqueue;
}
 
/* we will acces controller register, so enable the udc controller */
retval = mv_otg_enable_internal(mvotg);
if (retval) {
dev_err(pdev-dev, mv otg enable error %d\n, retval);
-   goto err_unmap_capreg;
+   goto err_destroy_workqueue;
}
 
mvotg-op_regs =
@@ -806,9 +783,9 @@ static int mv_otg_probe(struct platform_device *pdev)
+ (readl(mvotg-cap_regs)  CAPLENGTH_MASK));
 
if (pdata-id) {
-   retval = request_threaded_irq(pdata-id-irq, NULL,
- mv_otg_inputs_irq,
- IRQF_ONESHOT, id, mvotg);
+   retval = 

[V4 PATCH 10/26] usb: ehci: ehci-mv: use PHY driver for ehci

2013-01-21 Thread Chao Xie
Originaly, ehci driver will call the callbacks in platform data
for PHY initialization and shut down.
With PHY driver, it will call the APIs provided by PHY driver
for PHY initialization and shut down. It removes the callbacks
in platform data, and at same time it removes one block in the
way of enabling device tree for ehci driver.

Signed-off-by: Chao Xie chao@marvell.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-mv.c |   37 +
 1 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 3065809..be504fd 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -15,17 +15,18 @@
 #include linux/clk.h
 #include linux/err.h
 #include linux/usb/otg.h
+#include linux/usb/mv_usb2.h
 #include linux/platform_data/mv_usb.h
 
 #define CAPLENGTH_MASK (0xff)
 
 struct ehci_hcd_mv {
struct usb_hcd *hcd;
+   struct mv_usb2_phy *mvphy;
 
/* Which mode does this ehci running OTG/Host ? */
int mode;
 
-   void __iomem *phy_regs;
void __iomem *cap_regs;
void __iomem *op_regs;
 
@@ -59,8 +60,8 @@ static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv)
int retval;
 
ehci_clock_enable(ehci_mv);
-   if (ehci_mv-pdata-phy_init) {
-   retval = ehci_mv-pdata-phy_init(ehci_mv-phy_regs);
+   if (ehci_mv-mvphy-init) {
+   retval = ehci_mv-mvphy-init(ehci_mv-mvphy);
if (retval)
return retval;
}
@@ -70,8 +71,8 @@ static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv)
 
 static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv)
 {
-   if (ehci_mv-pdata-phy_deinit)
-   ehci_mv-pdata-phy_deinit(ehci_mv-phy_regs);
+   if (ehci_mv-mvphy-shutdown)
+   ehci_mv-mvphy-shutdown(ehci_mv-mvphy);
ehci_clock_disable(ehci_mv);
 }
 
@@ -184,22 +185,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
}
}
 
-   r = platform_get_resource_byname(pdev, IORESOURCE_MEM, phyregs);
-   if (r == NULL) {
-   dev_err(pdev-dev, no phy I/O memory resource defined\n);
-   retval = -ENODEV;
-   goto err_clear_drvdata;
-   }
-
-   ehci_mv-phy_regs = devm_ioremap(pdev-dev, r-start,
-resource_size(r));
-   if (ehci_mv-phy_regs == 0) {
-   dev_err(pdev-dev, failed to map phy I/O memory\n);
-   retval = -EFAULT;
-   goto err_clear_drvdata;
-   }
-
-   r = platform_get_resource_byname(pdev, IORESOURCE_MEM, capregs);
+   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) {
dev_err(pdev-dev, no I/O memory resource defined\n);
retval = -ENODEV;
@@ -214,6 +200,12 @@ static int mv_ehci_probe(struct platform_device *pdev)
goto err_clear_drvdata;
}
 
+   ehci_mv-mvphy = mv_usb2_get_phy();
+   if (ehci_mv-mvphy == NULL) {
+   retval = -ENODEV;
+   goto err_clear_drvdata;
+   }
+
retval = mv_ehci_enable(ehci_mv);
if (retval) {
dev_err(pdev-dev, init phy error %d\n, retval);
@@ -275,9 +267,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
}
}
 
-   if (pdata-private_init)
-   pdata-private_init(ehci_mv-op_regs, ehci_mv-phy_regs);
-
dev_info(pdev-dev,
 successful find EHCI device with regs 0x%p irq %d
  working in %s mode\n, hcd-regs, hcd-irq,
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 11/26] usb: otg: mv_otg: use PHY driver for otg

2013-01-21 Thread Chao Xie
Originaly, otg driver will call the callbacks in platform data
for PHY initialization and shut down.
With PHY driver, it will call the APIs provided by PHY driver
for PHY initialization and shut down. It removes the callbacks
in platform data, and at same time it removes one block in the
way of enabling device tree for otg driver.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/otg/mv_otg.c |   33 -
 drivers/usb/otg/mv_otg.h |2 +-
 2 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index da2d60c..cc45ef2 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -25,6 +25,7 @@
 #include linux/usb/otg.h
 #include linux/usb/gadget.h
 #include linux/usb/hcd.h
+#include linux/usb/mv_usb2.h
 #include linux/platform_data/mv_usb.h
 
 #include mv_otg.h
@@ -261,8 +262,8 @@ static int mv_otg_enable_internal(struct mv_otg *mvotg)
dev_dbg(mvotg-pdev-dev, otg enabled\n);
 
otg_clock_enable(mvotg);
-   if (mvotg-pdata-phy_init) {
-   retval = mvotg-pdata-phy_init(mvotg-phy_regs);
+   if (mvotg-mvphy-init) {
+   retval = mvotg-mvphy-init(mvotg-mvphy);
if (retval) {
dev_err(mvotg-pdev-dev,
init phy error %d\n, retval);
@@ -288,8 +289,8 @@ static void mv_otg_disable_internal(struct mv_otg *mvotg)
 {
if (mvotg-active) {
dev_dbg(mvotg-pdev-dev, otg disabled\n);
-   if (mvotg-pdata-phy_deinit)
-   mvotg-pdata-phy_deinit(mvotg-phy_regs);
+   if (mvotg-mvphy-shutdown)
+   mvotg-mvphy-shutdown(mvotg-mvphy);
otg_clock_disable(mvotg);
mvotg-active = 0;
}
@@ -741,23 +742,8 @@ static int mv_otg_probe(struct platform_device *pdev)
for (i = 0; i  OTG_TIMER_NUM; i++)
init_timer(mvotg-otg_ctrl.timer[i]);
 
-   r = platform_get_resource_byname(mvotg-pdev,
-IORESOURCE_MEM, phyregs);
-   if (r == NULL) {
-   dev_err(pdev-dev, no phy I/O memory resource defined\n);
-   retval = -ENODEV;
-   goto err_destroy_workqueue;
-   }
-
-   mvotg-phy_regs = devm_ioremap(pdev-dev, r-start, resource_size(r));
-   if (mvotg-phy_regs == NULL) {
-   dev_err(pdev-dev, failed to map phy I/O memory\n);
-   retval = -EFAULT;
-   goto err_destroy_workqueue;
-   }
-
-   r = platform_get_resource_byname(mvotg-pdev,
-IORESOURCE_MEM, capregs);
+   r = platform_get_resource(mvotg-pdev,
+IORESOURCE_MEM, 0);
if (r == NULL) {
dev_err(pdev-dev, no I/O memory resource defined\n);
retval = -ENODEV;
@@ -770,6 +756,11 @@ static int mv_otg_probe(struct platform_device *pdev)
retval = -EFAULT;
goto err_destroy_workqueue;
}
+   mvotg-mvphy = mv_usb2_get_phy();
+   if (mvotg-mvphy == NULL) {
+   retval = -ENODEV;
+   goto err_destroy_workqueue;
+   }
 
/* we will acces controller register, so enable the udc controller */
retval = mv_otg_enable_internal(mvotg);
diff --git a/drivers/usb/otg/mv_otg.h b/drivers/usb/otg/mv_otg.h
index 8a9e351..7b9629a 100644
--- a/drivers/usb/otg/mv_otg.h
+++ b/drivers/usb/otg/mv_otg.h
@@ -137,10 +137,10 @@ struct mv_otg_regs {
 
 struct mv_otg {
struct usb_phy phy;
+   struct mv_usb2_phy *mvphy;
struct mv_otg_ctrl otg_ctrl;
 
/* base address */
-   void __iomem *phy_regs;
void __iomem *cap_regs;
struct mv_otg_regs __iomem *op_regs;
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 14/26] arm: brownstone: add usb support for the board

2013-01-21 Thread Chao Xie
for brownstone board, add the udc/otg/ehci support

Signed-off-by: Chao Xie chao@marvell.com
---
 arch/arm/mach-mmp/brownstone.c |   47 
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index 5cb769c..90c0340 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -18,6 +18,7 @@
 #include linux/regulator/max8649.h
 #include linux/regulator/fixed.h
 #include linux/mfd/max8925.h
+#include linux/platform_data/mv_usb.h
 
 #include asm/mach-types.h
 #include asm/mach/arch.h
@@ -195,6 +196,31 @@ static struct sram_platdata mmp2_isram_platdata = {
.granularity= SRAM_GRANULARITY,
 };
 
+#ifdef CONFIG_USB_SUPPORT
+
+static char *mmp2_usb_clock_name[] = {
+   [0] = usb_clk,
+};
+
+static struct mv_usb_phy_platform_data brownstone_usb_phy_pdata = {
+   .clknum = 1,
+   .clkname= mmp2_usb_clock_name,
+};
+
+#if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV_U2O)
+
+static struct mv_usb_platform_data brownstone_usb_pdata = {
+   .clknum = 1,
+   .clkname= mmp2_usb_clock_name,
+   .vbus   = NULL,
+   .mode   = MV_USB_MODE_OTG,
+   .otg_force_a_bus_req = 1,
+   .set_vbus   = NULL,
+};
+#endif
+#endif
+
+
 static void __init brownstone_init(void)
 {
mfp_config(ARRAY_AND_SIZE(brownstone_pin_config));
@@ -211,6 +237,27 @@ static void __init brownstone_init(void)
 
/* enable 5v regulator */
platform_device_register(brownstone_v_5vp_device);
+
+#ifdef CONFIG_USB_SUPPORT
+   pxa_register_device(mmp2_device_u2ophy, brownstone_usb_phy_pdata,
+   sizeof(brownstone_usb_phy_pdata));
+#endif
+
+#ifdef CONFIG_USB_MV_UDC
+   pxa_register_device(mmp2_device_u2o, brownstone_usb_pdata,
+   sizeof(brownstone_usb_pdata));
+#endif
+
+#ifdef CONFIG_USB_EHCI_MV_U2O
+   pxa_register_device(mmp2_device_u2oehci, brownstone_usb_pdata,
+   sizeof(brownstone_usb_pdata));
+#endif
+
+#ifdef CONFIG_USB_MV_OTG
+   pxa_register_device(mmp2_device_u2ootg, brownstone_usb_pdata,
+   sizeof(brownstone_usb_pdata));
+#endif
+
 }
 
 MACHINE_START(BROWNSTONE, Brownstone Development Platform)
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 16/26] arm: mmp: remove the usb phy setting

2013-01-21 Thread Chao Xie
phy setting are formatted into a phy driver at drivers/usb/phy,
we do not need do the setting in SOC files.

Signed-off-by: Chao Xie chao@marvell.com
---
 arch/arm/mach-mmp/devices.c   |  278 -
 arch/arm/mach-mmp/include/mach/regs-usb.h |  253 --
 2 files changed, 0 insertions(+), 531 deletions(-)
 delete mode 100644 arch/arm/mach-mmp/include/mach/regs-usb.h

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index dd2d8b1..af341e5 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -15,7 +15,6 @@
 #include mach/irqs.h
 #include mach/devices.h
 #include mach/cputype.h
-#include mach/regs-usb.h
 
 int __init pxa_register_device(struct pxa_device_desc *desc,
void *data, size_t size)
@@ -72,280 +71,3 @@ int __init pxa_register_device(struct pxa_device_desc *desc,
return platform_device_add(pdev);
 }
 
-#if defined(CONFIG_USB) || defined(CONFIG_USB_GADGET)
-
-/*
- * The registers read/write routines
- */
-
-static unsigned int u2o_get(void __iomem *base, unsigned int offset)
-{
-   return readl_relaxed(base + offset);
-}
-
-static void u2o_set(void __iomem *base, unsigned int offset,
-   unsigned int value)
-{
-   u32 reg;
-
-   reg = readl_relaxed(base + offset);
-   reg |= value;
-   writel_relaxed(reg, base + offset);
-   readl_relaxed(base + offset);
-}
-
-static void u2o_clear(void __iomem *base, unsigned int offset,
-   unsigned int value)
-{
-   u32 reg;
-
-   reg = readl_relaxed(base + offset);
-   reg = ~value;
-   writel_relaxed(reg, base + offset);
-   readl_relaxed(base + offset);
-}
-
-static void u2o_write(void __iomem *base, unsigned int offset,
-   unsigned int value)
-{
-   writel_relaxed(value, base + offset);
-   readl_relaxed(base + offset);
-}
-
-#if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV)
-
-#if defined(CONFIG_CPU_PXA910) || defined(CONFIG_CPU_PXA168)
-
-static DEFINE_MUTEX(phy_lock);
-static int phy_init_cnt;
-
-static int usb_phy_init_internal(void __iomem *base)
-{
-   int loops;
-
-   pr_info(Init usb phy!!!\n);
-
-   /* Initialize the USB PHY power */
-   if (cpu_is_pxa910()) {
-   u2o_set(base, UTMI_CTRL, (1UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
-   | (1UTMI_CTRL_PU_REF_SHIFT));
-   }
-
-   u2o_set(base, UTMI_CTRL, 1UTMI_CTRL_PLL_PWR_UP_SHIFT);
-   u2o_set(base, UTMI_CTRL, 1UTMI_CTRL_PWR_UP_SHIFT);
-
-   /* UTMI_PLL settings */
-   u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
-   | UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
-   | UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
-   | UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
-
-   u2o_set(base, UTMI_PLL, 0xeeUTMI_PLL_FBDIV_SHIFT
-   | 0xbUTMI_PLL_REFDIV_SHIFT | 3UTMI_PLL_PLLVDD18_SHIFT
-   | 3UTMI_PLL_PLLVDD12_SHIFT | 3UTMI_PLL_PLLCALI12_SHIFT
-   | 1UTMI_PLL_ICP_SHIFT | 3UTMI_PLL_KVCO_SHIFT);
-
-   /* UTMI_TX */
-   u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
-   | UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
-   | UTMI_TX_IMPCAL_VTH_MASK | UTMI_TX_REG_EXT_FS_RCAL_MASK
-   | UTMI_TX_AMP_MASK);
-   u2o_set(base, UTMI_TX, 3UTMI_TX_TXVDD12_SHIFT
-   | 4UTMI_TX_CK60_PHSEL_SHIFT | 4UTMI_TX_IMPCAL_VTH_SHIFT
-   | 8UTMI_TX_REG_EXT_FS_RCAL_SHIFT | 3UTMI_TX_AMP_SHIFT);
-
-   /* UTMI_RX */
-   u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
-   | UTMI_REG_SQ_LENGTH_MASK);
-   u2o_set(base, UTMI_RX, 7UTMI_RX_SQ_THRESH_SHIFT
-   | 2UTMI_REG_SQ_LENGTH_SHIFT);
-
-   /* UTMI_IVREF */
-   if (cpu_is_pxa168())
-   /* fixing Microsoft Altair board interface with NEC hub issue -
-* Set UTMI_IVREF from 0x4a3 to 0x4bf */
-   u2o_write(base, UTMI_IVREF, 0x4bf);
-
-   /* toggle VCOCAL_START bit of UTMI_PLL */
-   udelay(200);
-   u2o_set(base, UTMI_PLL, VCOCAL_START);
-   udelay(40);
-   u2o_clear(base, UTMI_PLL, VCOCAL_START);
-
-   /* toggle REG_RCAL_START bit of UTMI_TX */
-   udelay(400);
-   u2o_set(base, UTMI_TX, REG_RCAL_START);
-   udelay(40);
-   u2o_clear(base, UTMI_TX, REG_RCAL_START);
-   udelay(400);
-
-   /* Make sure PHY PLL is ready */
-   loops = 0;
-   while ((u2o_get(base, UTMI_PLL)  PLL_READY) == 0) {
-   mdelay(1);
-   loops++;
-   if (loops  100) {
-   printk(KERN_WARNING calibrate timeout, UTMI_PLL %x\n,
-   u2o_get(base, UTMI_PLL));
-   break;
-   }
- 

[V4 PATCH 17/26] arm: mmp: remove usb devices from pxa168

2013-01-21 Thread Chao Xie
Signed-off-by: Chao Xie chao@marvell.com
---
 arch/arm/mach-mmp/pxa168.c |   42 --
 1 files changed, 0 insertions(+), 42 deletions(-)

diff --git a/arch/arm/mach-mmp/pxa168.c b/arch/arm/mach-mmp/pxa168.c
index b7f074f..dd3a68b 100644
--- a/arch/arm/mach-mmp/pxa168.c
+++ b/arch/arm/mach-mmp/pxa168.c
@@ -28,7 +28,6 @@
 #include mach/mfp.h
 #include linux/dma-mapping.h
 #include mach/pxa168.h
-#include mach/regs-usb.h
 
 #include common.h
 #include clock.h
@@ -135,47 +134,6 @@ struct platform_device pxa168_device_gpio = {
.resource   = pxa168_resource_gpio,
 };
 
-struct resource pxa168_usb_host_resources[] = {
-   /* USB Host conroller register base */
-   [0] = {
-   .start  = PXA168_U2H_REGBASE + U2x_CAPREGS_OFFSET,
-   .end= PXA168_U2H_REGBASE + USB_REG_RANGE,
-   .flags  = IORESOURCE_MEM,
-   .name   = capregs,
-   },
-   /* USB PHY register base */
-   [1] = {
-   .start  = PXA168_U2H_PHYBASE,
-   .end= PXA168_U2H_PHYBASE + USB_PHY_RANGE,
-   .flags  = IORESOURCE_MEM,
-   .name   = phyregs,
-   },
-   [2] = {
-   .start  = IRQ_PXA168_USB2,
-   .end= IRQ_PXA168_USB2,
-   .flags  = IORESOURCE_IRQ,
-   },
-};
-
-static u64 pxa168_usb_host_dmamask = DMA_BIT_MASK(32);
-struct platform_device pxa168_device_usb_host = {
-   .name = pxa-sph,
-   .id   = -1,
-   .dev  = {
-   .dma_mask = pxa168_usb_host_dmamask,
-   .coherent_dma_mask = DMA_BIT_MASK(32),
-   },
-
-   .num_resources = ARRAY_SIZE(pxa168_usb_host_resources),
-   .resource  = pxa168_usb_host_resources,
-};
-
-int __init pxa168_add_usb_host(struct mv_usb_platform_data *pdata)
-{
-   pxa168_device_usb_host.dev.platform_data = pdata;
-   return platform_device_register(pxa168_device_usb_host);
-}
-
 void pxa168_restart(char mode, const char *cmd)
 {
soft_restart(0x);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 18/26] usb: phy: mv_usb2_phy: add externel chip support

2013-01-21 Thread Chao Xie
For the vbus and idpin detection. It may be completed by some
external chip, for example the pmic chip 88pm860x in driver/mfd
can do it.
Although the usb controller can detect the vbus and id pin, but
it need clock on and PHY enabled to detect the
vbus/idpin. It will increase the power.
Using the external chip to detect vbus/idpin can save the power.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/phy/mv_usb2_phy.c|   54 +
 include/linux/platform_data/mv_usb.h |   15 ++
 include/linux/usb/mv_usb2.h  |   85 ++
 3 files changed, 144 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/phy/mv_usb2_phy.c b/drivers/usb/phy/mv_usb2_phy.c
index c2bccae..0bea901 100644
--- a/drivers/usb/phy/mv_usb2_phy.c
+++ b/drivers/usb/phy/mv_usb2_phy.c
@@ -136,6 +136,53 @@ struct mv_usb2_phy *mv_usb2_get_phy(void)
 }
 EXPORT_SYMBOL(mv_usb2_get_phy);
 
+int mv_usb2_register_notifier(struct mv_usb2_phy *phy,
+   struct notifier_block *nb)
+{
+   int ret;
+
+   if (!phy)
+   return -ENODEV;
+
+   ret = atomic_notifier_chain_register(phy-extern_chip.head, nb);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+EXPORT_SYMBOL(mv_usb2_register_notifier);
+
+int mv_usb2_unregister_notifier(struct mv_usb2_phy *phy,
+   struct notifier_block *nb)
+{
+   int ret;
+
+   if (!phy)
+   return -ENODEV;
+
+   ret = atomic_notifier_chain_unregister(phy-extern_chip.head, nb);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+EXPORT_SYMBOL(mv_usb2_unregister_notifier);
+
+int mv_usb2_notify(struct mv_usb2_phy *phy, unsigned long val, void *v)
+{
+   int ret;
+
+   if (!phy)
+   return -ENODEV;
+
+   ret = atomic_notifier_call_chain(phy-extern_chip.head, val, v);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+EXPORT_SYMBOL(mv_usb2_notify);
+
 static unsigned int u2o_get(void __iomem *base, unsigned int offset)
 {
return readl(base + offset);
@@ -414,6 +461,13 @@ static int usb_phy_probe(struct platform_device *pdev)
mv_phy-init = usb_phy_init;
mv_phy-shutdown = usb_phy_shutdown;
 
+   mv_phy-extern_chip.head = devm_kzalloc(pdev-dev,
+   sizeof(*mv_phy-extern_chip.head),
+   GFP_KERNEL);
+   if (mv_phy-extern_chip.head == NULL)
+   return -ENOMEM;
+   ATOMIC_INIT_NOTIFIER_HEAD(mv_phy-extern_chip.head);
+
platform_set_drvdata(pdev, mv_phy);
 
the_phy = mv_phy;
diff --git a/include/linux/platform_data/mv_usb.h 
b/include/linux/platform_data/mv_usb.h
index fd3d1b4..dc25d60 100644
--- a/include/linux/platform_data/mv_usb.h
+++ b/include/linux/platform_data/mv_usb.h
@@ -28,16 +28,13 @@ enum {
VBUS_HIGH   = 1  0,
 };
 
-struct mv_usb_addon_irq {
-   unsigned intirq;
-   int (*poll)(void);
-};
-
+#define MV_USB_HAS_VBUS_DETECTION  (1  0)
+#define MV_USB_HAS_IDPIN_DETECTION (1  1)
 struct mv_usb_platform_data {
unsigned intclknum;
char**clkname;
-   struct mv_usb_addon_irq *id;/* Only valid for OTG. ID pin change*/
-   struct mv_usb_addon_irq *vbus;  /* valid for OTG/UDC. VBUS change*/
+
+   unsigned intextern_attr;
 
/* only valid for HCD. OTG or Host only*/
unsigned intmode;
@@ -45,9 +42,7 @@ struct mv_usb_platform_data {
/* This flag is used for that needs id pin checked by otg */
unsigned intdisable_otg_clock_gating:1;
/* Force a_bus_req to be asserted */
-unsigned intotg_force_a_bus_req:1;
-
-   int (*set_vbus)(unsigned int vbus);
+   unsigned intotg_force_a_bus_req:1;
 };
 
 struct mv_usb_phy_platform_data {
diff --git a/include/linux/usb/mv_usb2.h b/include/linux/usb/mv_usb2.h
index 9744a97..e0246d9 100644
--- a/include/linux/usb/mv_usb2.h
+++ b/include/linux/usb/mv_usb2.h
@@ -17,6 +17,33 @@
 
 #include linux/clk.h
 
+enum {
+   EVENT_VBUS,
+   EVENT_ID,
+};
+
+struct pxa_usb_vbus_ops {
+   int (*get_vbus)(unsigned int *level);
+   int (*set_vbus)(unsigned int level);
+   int (*init)(void);
+};
+
+struct pxa_usb_idpin_ops {
+   int (*get_idpin)(unsigned int *level);
+   int (*init)(void);
+};
+
+struct pxa_usb_extern_ops {
+   struct pxa_usb_vbus_ops vbus;
+   struct pxa_usb_idpin_opsidpin;
+};
+
+struct mv_usb2_extern_chip {
+   unsigned int id;
+   struct pxa_usb_extern_ops ops;
+   struct atomic_notifier_head *head;
+};
+
 struct mv_usb2_phy {
struct platform_device  *pdev;
struct mutexphy_lock;
@@ -26,6 +53,8 @@ struct mv_usb2_phy {
struct clk  **clks;
unsigned intclks_num;
 
+   struct mv_usb2_extern_chip extern_chip;
+
int

[V4 PATCH 20/26] usb: ehci: ehci-mv: add extern chip support

2013-01-21 Thread Chao Xie
It does the similar things as what we do for udc driver.

Signed-off-by: Chao Xie chao@marvell.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-mv.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index be504fd..171e145 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -256,8 +256,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
goto err_disable_clk;
 #endif
} else {
-   if (pdata-set_vbus)
-   pdata-set_vbus(1);
+   if (mv_usb2_has_extern_call(ehci_mv-mvphy, vbus, set_vbus))
+   mv_usb2_extern_call(ehci_mv-mvphy, vbus, set_vbus, 1);
 
retval = usb_add_hcd(hcd, hcd-irq, IRQF_SHARED);
if (retval) {
@@ -275,8 +275,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
return 0;
 
 err_set_vbus:
-   if (pdata-set_vbus)
-   pdata-set_vbus(0);
+   if (mv_usb2_has_extern_call(ehci_mv-mvphy, vbus, set_vbus))
+   mv_usb2_extern_call(ehci_mv-mvphy, vbus, set_vbus, 0);
 err_disable_clk:
mv_ehci_disable(ehci_mv);
 err_clear_drvdata:
@@ -299,8 +299,8 @@ static int mv_ehci_remove(struct platform_device *pdev)
otg_set_host(ehci_mv-otg-otg, NULL);
 
if (ehci_mv-mode == MV_USB_MODE_HOST) {
-   if (ehci_mv-pdata-set_vbus)
-   ehci_mv-pdata-set_vbus(0);
+   if (mv_usb2_has_extern_call(ehci_mv-mvphy, vbus, set_vbus))
+   mv_usb2_extern_call(ehci_mv-mvphy, vbus, set_vbus, 1);
 
mv_ehci_disable(ehci_mv);
}
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 21/26] usb: otg: mv_otg: add extern chip support

2013-01-21 Thread Chao Xie
It does the similar things as what we do for udc driver.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/otg/mv_otg.c |   63 -
 drivers/usb/otg/mv_otg.h |3 ++
 2 files changed, 31 insertions(+), 35 deletions(-)

diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index cc45ef2..379df92 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -59,10 +59,10 @@ static char *state_string[] = {
 static int mv_otg_set_vbus(struct usb_otg *otg, bool on)
 {
struct mv_otg *mvotg = container_of(otg-phy, struct mv_otg, phy);
-   if (mvotg-pdata-set_vbus == NULL)
+   if (!mv_usb2_has_extern_call(mvotg-mvphy, vbus, set_vbus))
return -ENODEV;
 
-   return mvotg-pdata-set_vbus(on);
+   return mv_usb2_extern_call(mvotg-mvphy, vbus, set_vbus, on);
 }
 
 static int mv_otg_set_host(struct usb_otg *otg,
@@ -184,14 +184,14 @@ static void mv_otg_init_irq(struct mv_otg *mvotg)
mvotg-irq_status = OTGSC_INTSTS_A_SESSION_VALID
| OTGSC_INTSTS_A_VBUS_VALID;
 
-   if (mvotg-pdata-vbus == NULL) {
+   if (!(mvotg-extern_attr  MV_USB_HAS_VBUS_DETECTION)) {
mvotg-irq_en |= OTGSC_INTR_B_SESSION_VALID
| OTGSC_INTR_B_SESSION_END;
mvotg-irq_status |= OTGSC_INTSTS_B_SESSION_VALID
| OTGSC_INTSTS_B_SESSION_END;
}
 
-   if (mvotg-pdata-id == NULL) {
+   if (!(mvotg-extern_attr  MV_USB_HAS_IDPIN_DETECTION)) {
mvotg-irq_en |= OTGSC_INTR_USB_ID;
mvotg-irq_status |= OTGSC_INTSTS_USB_ID;
}
@@ -306,11 +306,14 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg)
 {
struct mv_otg_ctrl *otg_ctrl = mvotg-otg_ctrl;
u32 otgsc;
+   unsigned int vbus, idpin;
 
otgsc = readl(mvotg-op_regs-otgsc);
 
-   if (mvotg-pdata-vbus) {
-   if (mvotg-pdata-vbus-poll() == VBUS_HIGH) {
+   if (mvotg-extern_attr  MV_USB_HAS_VBUS_DETECTION) {
+   if (mv_usb2_extern_call(mvotg-mvphy, vbus, get_vbus, vbus))
+   return;
+   if (vbus == VBUS_HIGH) {
otg_ctrl-b_sess_vld = 1;
otg_ctrl-b_sess_end = 0;
} else {
@@ -322,8 +325,11 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg)
otg_ctrl-b_sess_end = !!(otgsc  OTGSC_STS_B_SESSION_END);
}
 
-   if (mvotg-pdata-id)
-   otg_ctrl-id = !!mvotg-pdata-id-poll();
+   if (mvotg-extern_attr  MV_USB_HAS_IDPIN_DETECTION) {
+   if (mv_usb2_extern_call(mvotg-mvphy, idpin, get_idpin, idpin))
+   return;
+   otg_ctrl-id = !!idpin;
+   }
else
otg_ctrl-id = !!(otgsc  OTGSC_STS_USB_ID);
 
@@ -505,7 +511,7 @@ static irqreturn_t mv_otg_irq(int irq, void *dev)
 * if we have vbus, then the vbus detection for B-device
 * will be done by mv_otg_inputs_irq().
 */
-   if (mvotg-pdata-vbus)
+   if (mvotg-extern_attr  MV_USB_HAS_VBUS_DETECTION)
if ((otgsc  OTGSC_STS_USB_ID) 
!(otgsc  OTGSC_INTSTS_USB_ID))
return IRQ_NONE;
@@ -518,9 +524,10 @@ static irqreturn_t mv_otg_irq(int irq, void *dev)
return IRQ_HANDLED;
 }
 
-static irqreturn_t mv_otg_inputs_irq(int irq, void *dev)
+static int mv_otg_notifier_call(struct notifier_block *nb,
+   unsigned long val, void *v)
 {
-   struct mv_otg *mvotg = dev;
+   struct mv_otg *mvotg = container_of(nb, struct mv_otg, notifier);
 
/* The clock may disabled at this time */
if (!mvotg-active) {
@@ -530,7 +537,7 @@ static irqreturn_t mv_otg_inputs_irq(int irq, void *dev)
 
mv_otg_run_state_machine(mvotg, 0);
 
-   return IRQ_HANDLED;
+   return 0;
 }
 
 static ssize_t
@@ -666,6 +673,10 @@ int mv_otg_remove(struct platform_device *pdev)
 
sysfs_remove_group(mvotg-pdev-dev.kobj, inputs_attr_group);
 
+   if ((mvotg-extern_attr  MV_USB_HAS_VBUS_DETECTION) ||
+   (mvotg-extern_attr  MV_USB_HAS_IDPIN_DETECTION))
+   mv_usb2_unregister_notifier(mvotg-mvphy, mvotg-notifier);
+
if (mvotg-qwork) {
flush_workqueue(mvotg-qwork);
destroy_workqueue(mvotg-qwork);
@@ -707,6 +718,7 @@ static int mv_otg_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mvotg);
 
mvotg-pdev = pdev;
+   mvotg-extern_attr = pdata-extern_attr;
mvotg-pdata = pdata;
 
mvotg-clknum = pdata-clknum;
@@ -773,29 +785,10 @@ static int mv_otg_probe(struct platform_device *pdev)
(struct mv_otg_regs __iomem *) ((unsigned long) mvotg-cap_regs
+ (readl(mvotg-cap_regs)  CAPLENGTH_MASK));
 
-   if (pdata-id) {
-   retval = devm_request_threaded_irq(pdev-dev, pdata-id-irq,
-

[V4 PATCH 22/26] arm: mmp: add extern chip support for brownstone

2013-01-21 Thread Chao Xie
Change the board support for usb as extern chip is supported
in marvell usb PHY driver

Signed-off-by: Chao Xie chao@marvell.com
---
 arch/arm/mach-mmp/brownstone.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index 90c0340..3dcf38f 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -212,10 +212,8 @@ static struct mv_usb_phy_platform_data 
brownstone_usb_phy_pdata = {
 static struct mv_usb_platform_data brownstone_usb_pdata = {
.clknum = 1,
.clkname= mmp2_usb_clock_name,
-   .vbus   = NULL,
.mode   = MV_USB_MODE_OTG,
.otg_force_a_bus_req = 1,
-   .set_vbus   = NULL,
 };
 #endif
 #endif
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 23/26] arm: mmp: add extern chip support for ttc_dkb

2013-01-21 Thread Chao Xie
Change the board support for usb as extern chip is supported
in marvell usb PHY driver.

Signed-off-by: Chao Xie chao@marvell.com
---
 arch/arm/mach-mmp/ttc_dkb.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index 0962791..eb34608 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -172,10 +172,8 @@ static struct mv_usb_phy_platform_data ttc_usb_phy_pdata = 
{
 static struct mv_usb_platform_data ttc_usb_pdata = {
.clknum = 1,
.clkname= pxa910_usb_clock_name,
-   .vbus   = NULL,
.mode   = MV_USB_MODE_OTG,
.otg_force_a_bus_req = 1,
-   .set_vbus   = NULL,
 };
 #endif
 #endif
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V4 PATCH 25/26] usb: otg: mv_otg: add device tree support

2013-01-21 Thread Chao Xie
All blocks are removed. Add the device tree support for otg.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/otg/mv_otg.c |  128 +
 drivers/usb/otg/mv_otg.h |6 +-
 2 files changed, 108 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index 379df92..3aa7fdc 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -17,6 +17,7 @@
 #include linux/device.h
 #include linux/proc_fs.h
 #include linux/clk.h
+#include linux/of.h
 #include linux/workqueue.h
 #include linux/platform_device.h
 
@@ -333,7 +334,7 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg)
else
otg_ctrl-id = !!(otgsc  OTGSC_STS_USB_ID);
 
-   if (mvotg-pdata-otg_force_a_bus_req  !otg_ctrl-id)
+   if (mvotg-otg_force_a_bus_req  !otg_ctrl-id)
otg_ctrl-a_bus_req = 1;
 
otg_ctrl-a_sess_vld = !!(otgsc  OTGSC_STS_A_SESSION_VALID);
@@ -690,21 +691,69 @@ int mv_otg_remove(struct platform_device *pdev)
return 0;
 }
 
+static int mv_otg_parse_dt(struct platform_device *pdev,
+   struct mv_otg *mvotg)
+{
+   struct device_node *np = pdev-dev.of_node;
+   unsigned int clks_num;
+   unsigned int val;
+   int i, ret;
+   const char *clk_name;
+
+   if (!np)
+   return 1;
+
+   clks_num = of_property_count_strings(np, clocks);
+   if (clks_num  0)
+   return clks_num;
+
+   mvotg-clk = devm_kzalloc(pdev-dev,
+   sizeof(struct clk *) * clks_num, GFP_KERNEL);
+   if (mvotg-clk == NULL)
+   return -ENOMEM;
+
+   for (i = 0; i  clks_num; i++) {
+   ret = of_property_read_string_index(np, clocks, i,
+   clk_name);
+   if (ret)
+   return ret;
+   mvotg-clk[i] = devm_clk_get(pdev-dev, clk_name);
+   if (IS_ERR(mvotg-clk[i]))
+   return PTR_ERR(mvotg-clk[i]);
+   }
+
+   mvotg-clknum = clks_num;
+
+   ret = of_property_read_u32(np, extern_attr, mvotg-extern_attr);
+   if (ret)
+   return ret;
+
+   ret = of_property_read_u32(np, mode, mvotg-mode);
+   if (ret)
+   return ret;
+
+   ret = of_property_read_u32(np, force_a_bus_req, val);
+   if (ret)
+   return ret;
+   mvotg-otg_force_a_bus_req = !!val;
+
+   ret = of_property_read_u32(np, disable_clock_gating, val);
+   if (ret)
+   return ret;
+   mvotg-clock_gating = !val;
+
+   return 0;
+}
+
 static int mv_otg_probe(struct platform_device *pdev)
 {
-   struct mv_usb_platform_data *pdata = pdev-dev.platform_data;
struct mv_otg *mvotg;
struct usb_otg *otg;
struct resource *r;
-   int retval = 0, clk_i, i;
+   int retval = 0, i;
size_t size;
 
-   if (pdata == NULL) {
-   dev_err(pdev-dev, failed to get platform data\n);
-   return -ENODEV;
-   }
-
-   size = sizeof(*mvotg) + sizeof(struct clk *) * pdata-clknum;
+   size = sizeof(*mvotg);
mvotg = devm_kzalloc(pdev-dev, size, GFP_KERNEL);
if (!mvotg) {
dev_err(pdev-dev, failed to allocate memory!\n);
@@ -718,17 +767,45 @@ static int mv_otg_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mvotg);
 
mvotg-pdev = pdev;
-   mvotg-extern_attr = pdata-extern_attr;
-   mvotg-pdata = pdata;
 
-   mvotg-clknum = pdata-clknum;
-   for (clk_i = 0; clk_i  mvotg-clknum; clk_i++) {
-   mvotg-clk[clk_i] = devm_clk_get(pdev-dev,
+   retval = mv_otg_parse_dt(pdev, mvotg);
+   if (retval  0) {
+   struct mv_usb_platform_data *pdata = pdev-dev.platform_data;
+   /* no CONFIG_OF */
+   int clk_i = 0;
+
+   if (pdata == NULL) {
+   dev_err(pdev-dev, missing platform_data\n);
+   return -ENODEV;
+   }
+   mvotg-extern_attr = pdata-extern_attr;
+   mvotg-mode = pdata-mode;
+   mvotg-clknum = pdata-clknum;
+   mvotg-otg_force_a_bus_req = pdata-otg_force_a_bus_req;
+   if (pdata-disable_otg_clock_gating)
+   mvotg-clock_gating = 0;
+
+   size = sizeof(struct clk *) * mvotg-clknum;
+   mvotg-clk = devm_kzalloc(pdev-dev, size, GFP_KERNEL);
+   if (mvotg-clk == NULL) {
+   dev_err(pdev-dev,
+   failed to allocate memory for clk\n);
+   return -ENOMEM;
+   }
+
+   for (clk_i = 0; clk_i  mvotg-clknum; clk_i++) {
+   mvotg-clk[clk_i] = devm_clk_get(pdev-dev,
pdata-clkname[clk_i]);
-   if (IS_ERR(mvotg-clk[clk_i])) {
- 

[V4 PATCH 24/26] usb: gadget: mv_udc: add device tree support

2013-01-21 Thread Chao Xie
In original driver, we have callbacks in platform data, and some
dynamically allocations variables in platform data.
Now, these blocks are removed, the device tree support is easier
now.

Signed-off-by: Chao Xie chao@marvell.com
---
 drivers/usb/gadget/mv_udc.h  |5 +-
 drivers/usb/gadget/mv_udc_core.c |  106 ++
 2 files changed, 86 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/gadget/mv_udc.h b/drivers/usb/gadget/mv_udc.h
index 50ae7c7..de84722 100644
--- a/drivers/usb/gadget/mv_udc.h
+++ b/drivers/usb/gadget/mv_udc.h
@@ -179,6 +179,7 @@ struct mv_udc {
int irq;
 
unsigned intextern_attr;
+   unsigned intmode;
struct notifier_block   notifier;
 
struct mv_cap_regs __iomem  *cap_regs;
@@ -222,11 +223,9 @@ struct mv_udc {
struct mv_usb2_phy  *phy;
struct usb_phy  *transceiver;
 
-   struct mv_usb_platform_data *pdata;
-
/* some SOC has mutiple clock sources for USB*/
unsigned intclknum;
-   struct clk  *clk[0];
+   struct clk  **clk;
 };
 
 /* endpoint data structure */
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index 4b50334..42eba77 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -34,6 +34,7 @@
 #include linux/irq.h
 #include linux/platform_device.h
 #include linux/clk.h
+#include linux/of.h
 #include linux/platform_data/mv_usb.h
 #include linux/usb/mv_usb2.h
 #include asm/unaligned.h
@@ -2153,21 +2154,57 @@ static int mv_udc_remove(struct platform_device *pdev)
return 0;
 }
 
+static int mv_udc_parse_dt(struct platform_device *pdev,
+   struct mv_udc *udc)
+{
+   struct device_node *np = pdev-dev.of_node;
+   unsigned int clks_num;
+   int i, ret;
+   const char *clk_name;
+
+   if (!np)
+   return 1;
+
+   clks_num = of_property_count_strings(np, clocks);
+   if (clks_num  0)
+   return clks_num;
+
+   udc-clk = devm_kzalloc(pdev-dev,
+   sizeof(struct clk *) * clks_num, GFP_KERNEL);
+   if (udc-clk == NULL)
+   return -ENOMEM;
+
+   for (i = 0; i  clks_num; i++) {
+   ret = of_property_read_string_index(np, clocks, i,
+   clk_name);
+   if (ret)
+   return ret;
+   udc-clk[i] = devm_clk_get(pdev-dev, clk_name);
+   if (IS_ERR(udc-clk[i]))
+   return PTR_ERR(udc-clk[i]);
+   }
+
+   udc-clknum = clks_num;
+
+   ret = of_property_read_u32(np, extern_attr, udc-extern_attr);
+   if (ret)
+   return ret;
+
+   ret = of_property_read_u32(np, mode, udc-mode);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
 static int mv_udc_probe(struct platform_device *pdev)
 {
-   struct mv_usb_platform_data *pdata = pdev-dev.platform_data;
struct mv_udc *udc;
int retval = 0;
-   int clk_i = 0;
struct resource *r;
size_t size;
 
-   if (pdata == NULL) {
-   dev_err(pdev-dev, missing platform_data\n);
-   return -ENODEV;
-   }
-
-   size = sizeof(*udc) + sizeof(struct clk *) * pdata-clknum;
+   size = sizeof(*udc);
udc = devm_kzalloc(pdev-dev, size, GFP_KERNEL);
if (udc == NULL) {
dev_err(pdev-dev, failed to allocate memory for udc\n);
@@ -2175,14 +2212,43 @@ static int mv_udc_probe(struct platform_device *pdev)
}
 
udc-done = release_done;
-   udc-extern_attr = pdata-extern_attr;
-   udc-pdata = pdev-dev.platform_data;
spin_lock_init(udc-lock);
 
udc-dev = pdev;
 
+   retval = mv_udc_parse_dt(pdev, udc);
+   if (retval  0) {
+   /* no CONFIG_OF */
+   struct mv_usb_platform_data *pdata = pdev-dev.platform_data;
+   int clk_i = 0;
+
+   if (pdata == NULL) {
+   dev_err(pdev-dev, missing platform_data\n);
+   return -ENODEV;
+   }
+   udc-extern_attr = pdata-extern_attr;
+   udc-mode = pdata-mode;
+   udc-clknum = pdata-clknum;
+
+   size = sizeof(struct clk *) * udc-clknum;
+   udc-clk = devm_kzalloc(pdev-dev, size, GFP_KERNEL);
+   if (udc-clk == NULL)
+   return -ENOMEM;
+   for (clk_i = 0; clk_i  udc-clknum; clk_i++) {
+   udc-clk[clk_i] = devm_clk_get(pdev-dev,
+   pdata-clkname[clk_i]);
+   if (IS_ERR(udc-clk[clk_i])) {
+   retval = PTR_ERR(udc-clk[clk_i]);
+   return retval;
+   }
+   }
+  

[V4 PATCH 26/26] usb: ehci: ehci-mv: add device tree support

2013-01-21 Thread Chao Xie
All blocks are removed. Add the device tree support for ehci.

Signed-off-by: Chao Xie chao@marvell.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-mv.c |  105 +--
 1 files changed, 80 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 171e145..79eca0c 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -13,6 +13,7 @@
 #include linux/module.h
 #include linux/platform_device.h
 #include linux/clk.h
+#include linux/of.h
 #include linux/err.h
 #include linux/usb/otg.h
 #include linux/usb/mv_usb2.h
@@ -32,11 +33,9 @@ struct ehci_hcd_mv {
 
struct usb_phy *otg;
 
-   struct mv_usb_platform_data *pdata;
-
/* clock source and total clock number */
unsigned int clknum;
-   struct clk *clk[0];
+   struct clk **clk;
 };
 
 static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv)
@@ -138,22 +137,55 @@ static const struct hc_driver mv_ehci_hc_driver = {
.bus_resume = ehci_bus_resume,
 };
 
+static int mv_ehci_parse_dt(struct platform_device *pdev,
+   struct ehci_hcd_mv *ehci_mv)
+{
+   struct device_node *np = pdev-dev.of_node;
+   unsigned int clks_num;
+   int i, ret;
+   const char *clk_name;
+
+   if (!np)
+   return 1;
+
+   clks_num = of_property_count_strings(np, clocks);
+   if (clks_num  0)
+   return clks_num;
+
+   ehci_mv-clk = devm_kzalloc(pdev-dev,
+   sizeof(struct clk *) * clks_num, GFP_KERNEL);
+   if (ehci_mv-clk == NULL)
+   return -ENOMEM;
+
+   for (i = 0; i  clks_num; i++) {
+   ret = of_property_read_string_index(np, clocks, i,
+   clk_name);
+   if (ret)
+   return ret;
+   ehci_mv-clk[i] = clk_get(NULL, clk_name);
+   if (IS_ERR(ehci_mv-clk[i]))
+   return PTR_ERR(ehci_mv-clk[i]);
+   }
+
+   ehci_mv-clknum = clks_num;
+
+   ret = of_property_read_u32(np, mode, ehci_mv-mode);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
 static int mv_ehci_probe(struct platform_device *pdev)
 {
-   struct mv_usb_platform_data *pdata = pdev-dev.platform_data;
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
struct ehci_hcd_mv *ehci_mv;
struct resource *r;
-   int clk_i, retval = -ENODEV;
+   int retval = -ENODEV;
u32 offset;
size_t size;
 
-   if (!pdata) {
-   dev_err(pdev-dev, missing platform_data\n);
-   return -ENODEV;
-   }
-
if (usb_disabled())
return -ENODEV;
 
@@ -161,7 +193,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
if (!hcd)
return -ENOMEM;
 
-   size = sizeof(*ehci_mv) + sizeof(struct clk *) * pdata-clknum;
+   size = sizeof(*ehci_mv);
ehci_mv = devm_kzalloc(pdev-dev, size, GFP_KERNEL);
if (ehci_mv == NULL) {
dev_err(pdev-dev, cannot allocate ehci_hcd_mv\n);
@@ -170,19 +202,36 @@ static int mv_ehci_probe(struct platform_device *pdev)
}
 
platform_set_drvdata(pdev, ehci_mv);
-   ehci_mv-pdata = pdata;
ehci_mv-hcd = hcd;
 
-   ehci_mv-clknum = pdata-clknum;
-   for (clk_i = 0; clk_i  ehci_mv-clknum; clk_i++) {
-   ehci_mv-clk[clk_i] =
-   devm_clk_get(pdev-dev, pdata-clkname[clk_i]);
-   if (IS_ERR(ehci_mv-clk[clk_i])) {
-   dev_err(pdev-dev, error get clck \%s\\n,
-   pdata-clkname[clk_i]);
-   retval = PTR_ERR(ehci_mv-clk[clk_i]);
-   goto err_clear_drvdata;
+   retval = mv_ehci_parse_dt(pdev, ehci_mv);
+   if (retval  0) {
+   struct mv_usb_platform_data *pdata = pdev-dev.platform_data;
+   int clk_i = 0;
+
+   /* no CONFIG_OF */
+   if (pdata == NULL) {
+   dev_err(pdev-dev, missing platform_data\n);
+   return -ENODEV;
+   }
+   ehci_mv-mode = pdata-mode;
+   ehci_mv-clknum = pdata-clknum;
+
+   size = sizeof(struct clk *) * ehci_mv-clknum;
+   ehci_mv-clk = devm_kzalloc(pdev-dev, size, GFP_KERNEL);
+   if (ehci_mv-clk == NULL)
+   return -ENOMEM;
+   for (clk_i = 0; clk_i  ehci_mv-clknum; clk_i++) {
+   ehci_mv-clk[clk_i] = devm_clk_get(pdev-dev,
+   pdata-clkname[clk_i]);
+   if (IS_ERR(ehci_mv-clk[clk_i])) {
+   retval = PTR_ERR(ehci_mv-clk[clk_i]);
+   return retval;
+   }
}
+   } else if (retval  0) {
+  

[V4 PATCH 15/26] arm: ttc_dkb: add usb support

2013-01-21 Thread Chao Xie
for ttc_dkb board, add udc/otg/ehci support

Signed-off-by: Chao Xie chao@marvell.com
---
 arch/arm/mach-mmp/ttc_dkb.c |   30 +++---
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index ce55fd8..0962791 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -27,7 +27,6 @@
 #include mach/mfp-pxa910.h
 #include mach/pxa910.h
 #include mach/irqs.h
-#include mach/regs-usb.h
 
 #include common.h
 
@@ -158,20 +157,24 @@ static struct i2c_board_info ttc_dkb_i2c_info[] = {
 };
 
 #ifdef CONFIG_USB_SUPPORT
-#if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV_U2O)
 
 static char *pxa910_usb_clock_name[] = {
-   [0] = U2OCLK,
+   [0] = usb_clk,
+};
+
+static struct mv_usb_phy_platform_data ttc_usb_phy_pdata = {
+   .clknum = 1,
+   .clkname= pxa910_usb_clock_name,
 };
 
+#if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV_U2O)
+
 static struct mv_usb_platform_data ttc_usb_pdata = {
.clknum = 1,
.clkname= pxa910_usb_clock_name,
.vbus   = NULL,
.mode   = MV_USB_MODE_OTG,
.otg_force_a_bus_req = 1,
-   .phy_init   = pxa_usb_phy_init,
-   .phy_deinit = pxa_usb_phy_deinit,
.set_vbus   = NULL,
 };
 #endif
@@ -198,19 +201,24 @@ static void __init ttc_dkb_init(void)
pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info));
platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
 
+#ifdef CONFIG_USB_SUPPORT
+   pxa_register_device(pxa910_device_u2ophy, ttc_usb_phy_pdata,
+   sizeof(ttc_usb_phy_pdata));
+#endif
+
 #ifdef CONFIG_USB_MV_UDC
-   pxa168_device_u2o.dev.platform_data = ttc_usb_pdata;
-   platform_device_register(pxa168_device_u2o);
+   pxa_register_device(pxa910_device_u2o, ttc_usb_pdata,
+   sizeof(ttc_usb_pdata));
 #endif
 
 #ifdef CONFIG_USB_EHCI_MV_U2O
-   pxa168_device_u2oehci.dev.platform_data = ttc_usb_pdata;
-   platform_device_register(pxa168_device_u2oehci);
+   pxa_register_device(pxa910_device_u2oehci, ttc_usb_pdata,
+   sizeof(ttc_usb_pdata));
 #endif
 
 #ifdef CONFIG_USB_MV_OTG
-   pxa168_device_u2ootg.dev.platform_data = ttc_usb_pdata;
-   platform_device_register(pxa168_device_u2ootg);
+   pxa_register_device(pxa910_device_u2ootg, ttc_usb_pdata,
+   sizeof(ttc_usb_pdata));
 #endif
 }
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 29/33] usb: Convert to devm_ioremap_resource()

2013-01-21 Thread Thierry Reding
Convert all uses of devm_request_and_ioremap() to the newly introduced
devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit
error messages can be removed from the failure code paths.

Signed-off-by: Thierry Reding thierry.red...@avionic-design.de
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Alan Stern st...@rowland.harvard.edu
Cc: Felipe Balbi ba...@ti.com
Cc: linux-usb@vger.kernel.org
---
 drivers/usb/chipidea/usbmisc_imx6q.c |  6 +++---
 drivers/usb/gadget/bcm63xx_udc.c | 13 +++--
 drivers/usb/gadget/s3c-hsotg.c   |  7 +++
 drivers/usb/gadget/s3c-hsudc.c   |  7 +++
 drivers/usb/host/ehci-atmel.c|  7 +++
 drivers/usb/host/ehci-grlib.c|  9 -
 drivers/usb/host/ehci-mxc.c  |  7 +++
 drivers/usb/host/ehci-platform.c |  7 ---
 drivers/usb/host/ehci-ppc-of.c   |  8 
 drivers/usb/host/ehci-sead3.c|  8 
 drivers/usb/host/ehci-sh.c   |  7 +++
 drivers/usb/host/ehci-vt8500.c   |  8 
 drivers/usb/host/ehci-xilinx-of.c|  8 
 drivers/usb/host/ohci-nxp.c  |  7 +++
 drivers/usb/host/ohci-platform.c |  7 ---
 drivers/usb/host/ohci-s3c2410.c  |  7 +++
 drivers/usb/musb/musb_dsps.c |  7 +++
 drivers/usb/musb/omap2430.c  |  4 +---
 drivers/usb/otg/mxs-phy.c|  6 +++---
 drivers/usb/phy/mv_u3d_phy.c |  8 +++-
 drivers/usb/phy/omap-usb2.c  |  8 +++-
 drivers/usb/renesas_usbhs/common.c   |  9 -
 22 files changed, 76 insertions(+), 89 deletions(-)

diff --git a/drivers/usb/chipidea/usbmisc_imx6q.c 
b/drivers/usb/chipidea/usbmisc_imx6q.c
index 845efe2..a1bce39 100644
--- a/drivers/usb/chipidea/usbmisc_imx6q.c
+++ b/drivers/usb/chipidea/usbmisc_imx6q.c
@@ -98,9 +98,9 @@ static int usbmisc_imx6q_probe(struct platform_device *pdev)
spin_lock_init(data-lock);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   data-base = devm_request_and_ioremap(pdev-dev, res);
-   if (!data-base)
-   return -EADDRNOTAVAIL;
+   data-base = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(data-base))
+   return PTR_ERR(data-base);
 
data-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(data-clk)) {
diff --git a/drivers/usb/gadget/bcm63xx_udc.c b/drivers/usb/gadget/bcm63xx_udc.c
index 47a4993..8cc8253 100644
--- a/drivers/usb/gadget/bcm63xx_udc.c
+++ b/drivers/usb/gadget/bcm63xx_udc.c
@@ -2351,19 +2351,20 @@ static int bcm63xx_udc_probe(struct platform_device 
*pdev)
dev_err(dev, error finding USBD resource\n);
return -ENXIO;
}
-   udc-usbd_regs = devm_request_and_ioremap(dev, res);
+
+   udc-usbd_regs = devm_ioremap_resource(dev, res);
+   if (IS_ERR(udc-usbd_regs))
+   return PTR_ERR(udc-usbd_regs);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
dev_err(dev, error finding IUDMA resource\n);
return -ENXIO;
}
-   udc-iudma_regs = devm_request_and_ioremap(dev, res);
 
-   if (!udc-usbd_regs || !udc-iudma_regs) {
-   dev_err(dev, error requesting resources\n);
-   return -ENXIO;
-   }
+   udc-iudma_regs = devm_ioremap_resource(dev, res);
+   if (IS_ERR(udc-iudma_regs))
+   return PTR_ERR(udc-iudma_regs);
 
spin_lock_init(udc-lock);
INIT_WORK(udc-ep0_wq, bcm63xx_ep0_process);
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 439c3f9..de80fa6 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3525,10 +3525,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-   hsotg-regs = devm_request_and_ioremap(pdev-dev, res);
-   if (!hsotg-regs) {
-   dev_err(dev, cannot map registers\n);
-   ret = -ENXIO;
+   hsotg-regs = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(hsotg-regs)) {
+   ret = PTR_ERR(hsotg-regs);
goto err_clk;
}
 
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
index 52379b1..94ca33b 100644
--- a/drivers/usb/gadget/s3c-hsudc.c
+++ b/drivers/usb/gadget/s3c-hsudc.c
@@ -1295,10 +1295,9 @@ static int s3c_hsudc_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-   hsudc-regs = devm_request_and_ioremap(pdev-dev, res);
-   if (!hsudc-regs) {
-   dev_err(dev, error mapping device register area\n);
-   ret = -EBUSY;
+   hsudc-regs = devm_ioremap_resource(pdev-dev, res);
+   if (IS_ERR(hsudc-regs)) {
+   ret = PTR_ERR(hsudc-regs);
goto err_res;
}
 
diff --git 

[PATCH v9 05/22] mfd: omap-usb-tll: Clean up clock handling

2013-01-21 Thread Roger Quadros
Every channel has a functional clock that is similarly named.
It makes sense to use a for loop to manage these clocks as OMAPs
can come with up to 3 channels.

Dynamically allocate and get channel clocks depending on the
number of clocks avaiable on the platform.

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   87 +++-
 1 files changed, 54 insertions(+), 33 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 9a19cc7..bf7355e 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -96,10 +96,9 @@
 #define is_ehci_tll_mode(x)(x == OMAP_EHCI_PORT_MODE_TLL)
 
 struct usbtll_omap {
-   struct clk  *usbtll_p1_fck;
-   struct clk  *usbtll_p2_fck;
int nch;/* num. of channels */
struct usbhs_omap_platform_data *pdata;
+   struct clk  **ch_clk;
/* secure the register updates */
spinlock_t  lock;
 };
@@ -225,26 +224,12 @@ static int usbtll_omap_probe(struct platform_device *pdev)
 
tll-pdata = pdata;
 
-   tll-usbtll_p1_fck = clk_get(dev, usb_tll_hs_usb_ch0_clk);
-   if (IS_ERR(tll-usbtll_p1_fck)) {
-   ret = PTR_ERR(tll-usbtll_p1_fck);
-   dev_err(dev, usbtll_p1_fck failed error:%d\n, ret);
-   return ret;
-   }
-
-   tll-usbtll_p2_fck = clk_get(dev, usb_tll_hs_usb_ch1_clk);
-   if (IS_ERR(tll-usbtll_p2_fck)) {
-   ret = PTR_ERR(tll-usbtll_p2_fck);
-   dev_err(dev, usbtll_p2_fck failed error:%d\n, ret);
-   goto err_p2_fck;
-   }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_request_and_ioremap(dev, res);
if (!base) {
ret = -EADDRNOTAVAIL;
dev_err(dev, Resource request/ioremap failed:%d\n, ret);
-   goto err_res;
+   return ret;
}
 
platform_set_drvdata(pdev, tll);
@@ -270,6 +255,29 @@ static int usbtll_omap_probe(struct platform_device *pdev)
break;
}
 
+   spin_unlock_irqrestore(tll-lock, flags);
+
+   tll-ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll-nch]),
+   GFP_KERNEL);
+   if (!tll-ch_clk) {
+   ret = -ENOMEM;
+   dev_err(dev, Couldn't allocate memory for channel clocks\n);
+   goto err_clk_alloc;
+   }
+
+   for (i = 0; i  tll-nch; i++) {
+   char clkname[] = usb_tll_hs_usb_chx_clk;
+
+   snprintf(clkname, sizeof(clkname),
+   usb_tll_hs_usb_ch%d_clk, i);
+   tll-ch_clk[i] = clk_get(dev, clkname);
+
+   if (IS_ERR(tll-ch_clk[i]))
+   dev_dbg(dev, can't get clock : %s\n, clkname);
+   }
+
+   spin_lock_irqsave(tll-lock, flags);
+
if (is_ehci_tll_mode(pdata-port_mode[0]) ||
is_ehci_tll_mode(pdata-port_mode[1]) ||
is_ehci_tll_mode(pdata-port_mode[2]) ||
@@ -321,11 +329,9 @@ static int usbtll_omap_probe(struct platform_device *pdev)
 
return 0;
 
-err_res:
-   clk_put(tll-usbtll_p2_fck);
-
-err_p2_fck:
-   clk_put(tll-usbtll_p1_fck);
+err_clk_alloc:
+   pm_runtime_put_sync(dev);
+   pm_runtime_disable(dev);
 
return ret;
 }
@@ -339,9 +345,12 @@ err_p2_fck:
 static int usbtll_omap_remove(struct platform_device *pdev)
 {
struct usbtll_omap *tll = platform_get_drvdata(pdev);
+   int i;
+
+   for (i = 0; i  tll-nch; i++)
+   if (!IS_ERR(tll-ch_clk[i]))
+   clk_put(tll-ch_clk[i]);
 
-   clk_put(tll-usbtll_p2_fck);
-   clk_put(tll-usbtll_p1_fck);
pm_runtime_disable(pdev-dev);
return 0;
 }
@@ -351,6 +360,7 @@ static int usbtll_runtime_resume(struct device *dev)
struct usbtll_omap  *tll = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = tll-pdata;
unsigned long   flags;
+   int i;
 
dev_dbg(dev, usbtll_runtime_resume\n);
 
@@ -361,11 +371,20 @@ static int usbtll_runtime_resume(struct device *dev)
 
spin_lock_irqsave(tll-lock, flags);
 
-   if (is_ehci_tll_mode(pdata-port_mode[0]))
-   clk_enable(tll-usbtll_p1_fck);
+   for (i = 0; i  tll-nch; i++) {
+   if (is_ehci_tll_mode(pdata-port_mode[i])) {
+   int r;
 
-   if (is_ehci_tll_mode(pdata-port_mode[1]))
-   clk_enable(tll-usbtll_p2_fck);
+   if (IS_ERR(tll-ch_clk[i]))
+   continue;
+
+   r = clk_enable(tll-ch_clk[i]);
+   if (r) {
+   

[PATCH v9 06/22] mfd: omap-usb-tll: introduce and use mode_needs_tll()

2013-01-21 Thread Roger Quadros
This is a handy macro to check if the port requires the
USB TLL module or not. Use it to Enable the TLL module and manage
the clocks.

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   20 
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index bf7355e..af67b96 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -95,6 +95,10 @@
 
 #define is_ehci_tll_mode(x)(x == OMAP_EHCI_PORT_MODE_TLL)
 
+/* only PHY and UNUSED modes don't need TLL */
+#define omap_usb_mode_needs_tll(x) ((x) != OMAP_USBHS_PORT_MODE_UNUSED \
+(x) != OMAP_EHCI_PORT_MODE_PHY)
+
 struct usbtll_omap {
int nch;/* num. of channels */
struct usbhs_omap_platform_data *pdata;
@@ -211,6 +215,7 @@ static int usbtll_omap_probe(struct platform_device *pdev)
unsigned long   flags;
int ret = 0;
int i, ver;
+   bool needs_tll;
 
dev_dbg(dev, starting TI HSUSB TLL Controller\n);
 
@@ -278,12 +283,11 @@ static int usbtll_omap_probe(struct platform_device *pdev)
 
spin_lock_irqsave(tll-lock, flags);
 
-   if (is_ehci_tll_mode(pdata-port_mode[0]) ||
-   is_ehci_tll_mode(pdata-port_mode[1]) ||
-   is_ehci_tll_mode(pdata-port_mode[2]) ||
-   is_ohci_port(pdata-port_mode[0]) ||
-   is_ohci_port(pdata-port_mode[1]) ||
-   is_ohci_port(pdata-port_mode[2])) {
+   needs_tll = false;
+   for (i = 0; i  tll-nch; i++)
+   needs_tll |= omap_usb_mode_needs_tll(pdata-port_mode[i]);
+
+   if (needs_tll) {
 
/* Program Common TLL register */
reg = usbtll_read(base, OMAP_TLL_SHARED_CONF);
@@ -372,7 +376,7 @@ static int usbtll_runtime_resume(struct device *dev)
spin_lock_irqsave(tll-lock, flags);
 
for (i = 0; i  tll-nch; i++) {
-   if (is_ehci_tll_mode(pdata-port_mode[i])) {
+   if (omap_usb_mode_needs_tll(pdata-port_mode[i])) {
int r;
 
if (IS_ERR(tll-ch_clk[i]))
@@ -408,7 +412,7 @@ static int usbtll_runtime_suspend(struct device *dev)
spin_lock_irqsave(tll-lock, flags);
 
for (i = 0; i  tll-nch; i++) {
-   if (is_ehci_tll_mode(pdata-port_mode[i])) {
+   if (omap_usb_mode_needs_tll(pdata-port_mode[i])) {
if (!IS_ERR(tll-ch_clk[i]))
clk_disable(tll-ch_clk[i]);
}
-- 
1.7.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v9 15/22] mfd: omap-usb-host: cleanup clock management code

2013-01-21 Thread Roger Quadros
All ports have similarly named port clocks so we can
bunch them into a port data structure and use for loop
to enable/disable the clocks.

Dynamically allocate and get clocks based on number of ports
available on the platform

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-host.c |  186 --
 1 files changed, 106 insertions(+), 80 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 779588b..9fa0215 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -92,13 +92,12 @@
 
 struct usbhs_hcd_omap {
int nports;
+   struct clk  **utmi_clk;
 
struct clk  *xclk60mhsp1_ck;
struct clk  *xclk60mhsp2_ck;
-   struct clk  *utmi_p1_fck;
-   struct clk  *usbhost_p1_fck;
-   struct clk  *utmi_p2_fck;
-   struct clk  *usbhost_p2_fck;
+   struct clk  *utmi_p1_gfclk;
+   struct clk  *utmi_p2_gfclk;
struct clk  *init_60m_fclk;
struct clk  *ehci_logic_fck;
 
@@ -276,22 +275,25 @@ static int usbhs_runtime_resume(struct device *dev)
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = omap-pdata;
unsigned long   flags;
+   int i, r;
 
dev_dbg(dev, usbhs_runtime_resume\n);
 
omap_tll_enable();
spin_lock_irqsave(omap-lock, flags);
 
-   if (omap-ehci_logic_fck  !IS_ERR(omap-ehci_logic_fck))
+   if (!IS_ERR(omap-ehci_logic_fck))
clk_enable(omap-ehci_logic_fck);
 
-   if (is_ehci_tll_mode(pdata-port_mode[0]))
-   clk_enable(omap-usbhost_p1_fck);
-   if (is_ehci_tll_mode(pdata-port_mode[1]))
-   clk_enable(omap-usbhost_p2_fck);
+   for (i = 0; i  omap-nports; i++) {
+   if (!is_ehci_tll_mode(pdata-port_mode[i]) ||
+   IS_ERR(omap-utmi_clk[i]))
+   continue;
 
-   clk_enable(omap-utmi_p1_fck);
-   clk_enable(omap-utmi_p2_fck);
+   r = clk_enable(omap-utmi_clk[i]);
+   if (r)
+   dev_err(dev, Can't enable port %d clk : %d\n, i, r);
+   }
 
spin_unlock_irqrestore(omap-lock, flags);
 
@@ -303,20 +305,19 @@ static int usbhs_runtime_suspend(struct device *dev)
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = omap-pdata;
unsigned long   flags;
+   int i;
 
dev_dbg(dev, usbhs_runtime_suspend\n);
 
spin_lock_irqsave(omap-lock, flags);
 
-   if (is_ehci_tll_mode(pdata-port_mode[0]))
-   clk_disable(omap-usbhost_p1_fck);
-   if (is_ehci_tll_mode(pdata-port_mode[1]))
-   clk_disable(omap-usbhost_p2_fck);
-
-   clk_disable(omap-utmi_p2_fck);
-   clk_disable(omap-utmi_p1_fck);
+   for (i = 0; i  omap-nports; i++) {
+   if (is_ehci_tll_mode(pdata-port_mode[i]) 
+   !IS_ERR(omap-utmi_clk[i]))
+   clk_disable(omap-utmi_clk[i]);
+   }
 
-   if (omap-ehci_logic_fck  !IS_ERR(omap-ehci_logic_fck))
+   if (!IS_ERR(omap-ehci_logic_fck))
clk_disable(omap-ehci_logic_fck);
 
spin_unlock_irqrestore(omap-lock, flags);
@@ -458,6 +459,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
struct resource *res;
int ret = 0;
int i;
+   boolneed_logic_fck;
 
if (!pdata) {
dev_err(dev, Missing platform data\n);
@@ -516,76 +518,91 @@ static int usbhs_omap_probe(struct platform_device *pdev)
}
}
 
-   for (i = 0; i  omap-nports; i++)
+   i = sizeof(struct clk *) * omap-nports;
+   omap-utmi_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+   if (!omap-utmi_clk) {
+   dev_err(dev, Memory allocation failed\n);
+   ret = -ENOMEM;
+   goto err_mem;
+   }
+
+   need_logic_fck = false;
+   for (i = 0; i  omap-nports; i++) {
if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) ||
-   is_ehci_hsic_mode(i)) {
-   omap-ehci_logic_fck = clk_get(dev, ehci_logic_fck);
-   if (IS_ERR(omap-ehci_logic_fck)) {
-   ret = PTR_ERR(omap-ehci_logic_fck);
-   dev_warn(dev, ehci_logic_fck failed:%d\n,
-ret);
-   }
-   break;
+

[PATCH v9 16/22] mfd: omap-usb-host: Manage HSIC clocks for HSIC mode

2013-01-21 Thread Roger Quadros
Enable the optional HSIC clocks (60MHz and 480MHz) for the ports
that are configured in HSIC mode.

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-host.c |   97 --
 1 files changed, 83 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 9fa0215..bdfc8b7 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -93,6 +93,8 @@
 struct usbhs_hcd_omap {
int nports;
struct clk  **utmi_clk;
+   struct clk  **hsic60m_clk;
+   struct clk  **hsic480m_clk;
 
struct clk  *xclk60mhsp1_ck;
struct clk  *xclk60mhsp2_ck;
@@ -286,13 +288,40 @@ static int usbhs_runtime_resume(struct device *dev)
clk_enable(omap-ehci_logic_fck);
 
for (i = 0; i  omap-nports; i++) {
-   if (!is_ehci_tll_mode(pdata-port_mode[i]) ||
-   IS_ERR(omap-utmi_clk[i]))
-   continue;
-
-   r = clk_enable(omap-utmi_clk[i]);
-   if (r)
-   dev_err(dev, Can't enable port %d clk : %d\n, i, r);
+   switch (pdata-port_mode[i]) {
+   case OMAP_EHCI_PORT_MODE_HSIC:
+   if (!IS_ERR(omap-hsic60m_clk[i])) {
+   r = clk_enable(omap-hsic60m_clk[i]);
+   if (r) {
+   dev_err(dev,
+Can't enable port %d hsic60m 
clk:%d\n,
+i, r);
+   }
+   }
+
+   if (!IS_ERR(omap-hsic480m_clk[i])) {
+   r = clk_enable(omap-hsic480m_clk[i]);
+   if (r) {
+   dev_err(dev,
+Can't enable port %d hsic480m 
clk:%d\n,
+i, r);
+   }
+   }
+   /* Fall through as HSIC mode needs utmi_clk */
+
+   case OMAP_EHCI_PORT_MODE_TLL:
+   if (!IS_ERR(omap-utmi_clk[i])) {
+   r = clk_enable(omap-utmi_clk[i]);
+   if (r) {
+   dev_err(dev,
+Can't enable port %d clk : %d\n,
+i, r);
+   }
+   }
+   break;
+   default:
+   break;
+   }
}
 
spin_unlock_irqrestore(omap-lock, flags);
@@ -312,9 +341,22 @@ static int usbhs_runtime_suspend(struct device *dev)
spin_lock_irqsave(omap-lock, flags);
 
for (i = 0; i  omap-nports; i++) {
-   if (is_ehci_tll_mode(pdata-port_mode[i]) 
-   !IS_ERR(omap-utmi_clk[i]))
-   clk_disable(omap-utmi_clk[i]);
+   switch (pdata-port_mode[i]) {
+   case OMAP_EHCI_PORT_MODE_HSIC:
+   if (!IS_ERR(omap-hsic60m_clk[i]))
+   clk_disable(omap-hsic60m_clk[i]);
+
+   if (!IS_ERR(omap-hsic480m_clk[i]))
+   clk_disable(omap-hsic480m_clk[i]);
+   /* Fall through as utmi_clks were used in HSIC mode */
+
+   case OMAP_EHCI_PORT_MODE_TLL:
+   if (!IS_ERR(omap-utmi_clk[i]))
+   clk_disable(omap-utmi_clk[i]);
+   break;
+   default:
+   break;
+   }
}
 
if (!IS_ERR(omap-ehci_logic_fck))
@@ -520,7 +562,10 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 
i = sizeof(struct clk *) * omap-nports;
omap-utmi_clk = devm_kzalloc(dev, i, GFP_KERNEL);
-   if (!omap-utmi_clk) {
+   omap-hsic480m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+   omap-hsic60m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+
+   if (!omap-utmi_clk || !omap-hsic480m_clk || !omap-hsic60m_clk) {
dev_err(dev, Memory allocation failed\n);
ret = -ENOMEM;
goto err_mem;
@@ -578,7 +623,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
}
 
for (i = 0; i  omap-nports; i++) {
-   char clkname[] = usb_host_hs_utmi_px_clk;
+   char clkname[30];
 
/* clock names are indexed from 1*/
snprintf(clkname, sizeof(clkname),
@@ -592,6 +637,20 @@ static int usbhs_omap_probe(struct platform_device *pdev)
if (IS_ERR(omap-utmi_clk[i]))

Re: Linux USB file storage gadget with new UDC

2013-01-21 Thread victor yeo
Hi,

  Yes, ep0_complete() is called in UDC driver queue function, i just
  added it in and ep0_complete() is called now. The dmesg output is
  below.
 
  not in queue function, you should call it when completing.
 

 Is there any mistake in my understanding of ep0 setup data processing?

 1. usb gadget HW IRQ is triggered if ep0 receives data
 2. fsg_setup() is called
 3. ep0_queue() is called
 4. UDC driver queue function is called
 5. UDC driver sends data to ep0 HW buffer
 6. UDC driver increments req-actual by the amount of transferred bytes
 7. UDC driver call ep0_complete()

 looks correct


Some progress, now i am able to see the dump_msg from ep0_complete().
It looks like the enumeration is ok, but the SCSI Inquiry command is
not received by the UDC driver. The do_scsi_command() in
fsg_main_thread() is not called. Is this another bug in my UDC driver?

below is the debug message from file storage gadget

g_file_storage gadget: ep0-setup, length 8:
: 80 06 00 01 00 00 40 00
g_file_storage gadget: get device descriptor
g_file_storage gadget: ep0-in, length 18:
: 12 01 00 02 00 00 00 40 25 05 a5 a4 33 03 01 02
0010: 00 01
g_file_storage gadget: ep0-setup, length 8:
: 80 06 00 01 00 00 12 00
g_file_storage gadget: get device descriptor
g_file_storage gadget: ep0-in, length 18:
: 12 01 00 02 00 00 00 40 25 05 a5 a4 33 03 01 02
0010: 00 01
g_file_storage gadget: ep0-setup, length 8:
: 80 06 00 02 00 00 ff 00
g_file_storage gadget: get configuration descriptor
g_file_storage gadget: ep0-in, length 32:
: 09 02 20 00 01 01 04 c0 01 09 04 00 00 02 08 06
0010: 50 05 07 05 81 02 00 02 00 07 05 01 02 00 02 01
g_file_storage gadget: ep0-setup, length 8:
: 80 06 00 03 00 00 ff 00
g_file_storage gadget: ep0-in, length 4:
: 04 03 09 04
g_file_storage gadget: ep0-setup, length 8:
: 80 06 02 03 09 04 ff 00
g_file_storage gadget: get string descriptor
g_file_storage gadget: ep0-in, length 54:
: 36 03 46 00 69 00 6c 00 65 00 2d 00 62 00 61 00
0010: 63 00 6b 00 65 00 64 00 20 00 53 00 74 00 6f 00
0020: 72 00 61 00 67 00 65 00 20 00 47 00 61 00 64 00
0030: 67 00 65 00 74 00
g_file_storage gadget: ep0-setup, length 8:
: 80 06 00 01 00 00 12 00
g_file_storage gadget: get device descriptor
g_file_storage gadget: ep0-in, length 18:
: 12 01 00 02 00 00 00 40 25 05 a5 a4 33 03 01 02
0010: 00 01
g_file_storage gadget: ep0-setup, length 8:
: 80 06 00 02 00 00 09 00
g_file_storage gadget: get configuration descriptor
g_file_storage gadget: ep0-in, length 9:
: 09 02 20 00 01 01 04 c0 01
g_file_storage gadget: ep0-setup, length 8:
: 80 06 00 02 00 00 20 00
g_file_storage gadget: get configuration descriptor
g_file_storage gadget: ep0-in, length 32:
: 09 02 20 00 01 01 04 c0 01 09 04 00 00 02 08 06
0010: 50 05 07 05 81 02 00 02 00 07 05 01 02 00 02 01
g_file_storage gadget: ep0-setup, length 8:
: 00 09 01 00 00 00 00 00
g_file_storage gadget: set configuration
g_file_storage gadget: set interface 0
g_file_storage gadget: high-speed config #1
g_file_storage gadget: ep0-setup, length 8:
: a1 fe 00 00 00 00 01 00
g_file_storage gadget: ep0-in, length 1:
: 00
g_file_storage gadget: ep0-setup, length 8:
: 80 06 01 03 09 04 ff 00
g_file_storage gadget: get string descriptor
g_file_storage gadget: ep0-in, length 58:
: 3a 03 4c 00 69 00 6e 00 75 00 78 00 20 00 33 00
0010: 2e 00 34 00 2e 00 34 00 2b 00 20 00 77 00 69 00
0020: 74 00 68 00 20 00 6b 00 61 00 67 00 65 00 6e 00
0030: 32 00 5f 00 75 00 73 00 62 00
g_file_storage gadget: ep0-setup, length 8:
: 80 06 04 03 09 04 ff 00
g_file_storage gadget: get string descriptor
g_file_storage gadget: ep0-in, length 26:
: 1a 03 53 00 65 00 6c 00 66 00 2d 00 70 00 6f 00
0010: 77 00 65 00 72 00 65 00 64 00
g_file_storage gadget: ep0-setup, length 8:
: 80 06 05 03 09 04 ff 00
g_file_storage gadget: get string descriptor
g_file_storage gadget: ep0-in, length 26:
: 1a 03 4d 00 61 00 73 00 73 00 20 00 53 00 74 00
0010: 6f 00 72 00 61 00 67 00 65 00

thanks,
victor
--
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 2/2] CDC_NCM: adding support FLAG_NOARP for Infineon modem platform

2013-01-21 Thread Sergei Shtylyov

Hello.

On 21-01-2013 6:20, Wei Shuai wrote:


The main problem is that these devices don't support ethernet.  They
support IP (v4 and _maybe_ v6) with an ethernet header.  Many of them
will do ARP (and IPv6 ND) as well to complete the picture, but some of
them don't and that's what these drivers try to deal with.

Note that most of the devices will run a DHCP server, so there is some
sort of IP broadcast support.  Whether that qualifies as proper ethernet
broadcast support is another question...

These devices are attempting to bridge an IP-only point-to-point
interface and an ethernet over USB interface, with the intention to make
the point-to-point interface look like ethernet to applications and
users. This is of course always going to be imperfect.  But I believe
that we should aim to help the firmware achive this goal when writing
drivers instead of working against it.  Setting IFF_NOARP and not
IFF_POINTTOPOINT is one way to do that.  by  Bjorn Mork bj...@mork.no


   Why are you replying with this long story to my simple patch comments? :-)


2013/1/21, Sergei Shtylyov sshtyl...@mvista.com:

Hello.



On 20-01-2013 10:12, Wei Shuai wrote:



Infineon(now Intel) HSPA Modem platform NCM cannot support ARP. we can
define a new common structure wwan_noarp_info.



 Wrap your lines at 76-80 columns maximum please.



Then more similiar NO ARP devices can be handled easily


   s/NO/no/.


Signed-off-by: Wei Shuai cpuw...@gmail.com
---
   drivers/net/usb/cdc_ncm.c |   21 +
   1 files changed, 21 insertions(+), 0 deletions(-)



diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 71b6e92..2d699b6 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1155,6 +1155,20 @@ static const struct driver_info wwan_info = {
.tx_fixup = cdc_ncm_tx_fixup,
   };

+/* Same as wwan_info, but with IFF_NOARP  */



 FLAG_NOARP, you mean?



+static const struct driver_info wwan_noarp_info = {
+   .description = Mobile Broadband Network Device (NO ARP),
+   .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
+   | FLAG_WWAN | FLAG_NOARP,


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] drivers/usb/gadget: using strlcpy instead of strncpy

2013-01-21 Thread Chen Gang

  for NUL terminated string, better notice '\0' in the end.

Signed-off-by: Chen Gang gang.c...@asianux.com
---
 drivers/usb/gadget/uvc_v4l2.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c
index 2ca9386..a9934c7 100644
--- a/drivers/usb/gadget/uvc_v4l2.c
+++ b/drivers/usb/gadget/uvc_v4l2.c
@@ -178,9 +178,9 @@ uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void 
*arg)
struct v4l2_capability *cap = arg;
 
memset(cap, 0, sizeof *cap);
-   strncpy(cap-driver, g_uvc, sizeof(cap-driver));
-   strncpy(cap-card, cdev-gadget-name, sizeof(cap-card));
-   strncpy(cap-bus_info, dev_name(cdev-gadget-dev),
+   strlcpy(cap-driver, g_uvc, sizeof(cap-driver));
+   strlcpy(cap-card, cdev-gadget-name, sizeof(cap-card));
+   strlcpy(cap-bus_info, dev_name(cdev-gadget-dev),
sizeof cap-bus_info);
cap-version = DRIVER_VERSION_NUMBER;
cap-capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
-- 
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: Linux USB file storage gadget with new UDC

2013-01-21 Thread Felipe Balbi
Hi,

On Mon, Jan 21, 2013 at 07:13:03PM +0800, victor yeo wrote:
   Yes, ep0_complete() is called in UDC driver queue function, i just
   added it in and ep0_complete() is called now. The dmesg output is
   below.
  
   not in queue function, you should call it when completing.
  
 
  Is there any mistake in my understanding of ep0 setup data processing?
 
  1. usb gadget HW IRQ is triggered if ep0 receives data
  2. fsg_setup() is called
  3. ep0_queue() is called
  4. UDC driver queue function is called
  5. UDC driver sends data to ep0 HW buffer
  6. UDC driver increments req-actual by the amount of transferred bytes
  7. UDC driver call ep0_complete()
 
  looks correct
 
 
 Some progress, now i am able to see the dump_msg from ep0_complete().
 It looks like the enumeration is ok, but the SCSI Inquiry command is
 not received by the UDC driver. The do_scsi_command() in
 fsg_main_thread() is not called. Is this another bug in my UDC driver?

I would believe so since so many other controllers work just fine.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH 2/15] drivers/usb/chipidea/core.c: adjust duplicate test

2013-01-21 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Delete successive tests to the same location.  In this case res has already
been tested for being NULL, and calling devm_request_and_ioremap will not
make it NULL.  On the other hand, devm_request_and_ioremap can return NULL
on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@s exists@
local idexpression y;
expression x,e;
@@

*if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
 { ... when forall
   return ...; }
... when != \(y = e\|y += e\|y -= e\|y |= e\|y = e\|y++\|y--\|y\)
when != \(XT_GETPAGE(...,y)\|WMI_CMD_BUF(...)\)
*if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
 { ... when forall
   return ...; }
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
This code could be improved in other ways.  The previous NULL test on res
is not needed, and the dev_err in the error-handling code for the call to
devm_request_and_ioremap is redundant with respect to the logging already
done by devm_request_and_ioremap.  But these should probably be done
separately.

 drivers/usb/chipidea/core.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index aebf695..57cae1f 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -411,7 +411,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
}
 
base = devm_request_and_ioremap(dev, res);
-   if (!res) {
+   if (!base) {
dev_err(dev, can't request and ioremap resource\n);
return -ENOMEM;
}

--
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 13/15] drivers/usb/musb/omap2430.c: adjust duplicate test

2013-01-21 Thread Felipe Balbi
Hi,

On Mon, Jan 21, 2013 at 02:02:57PM +0100, Julia Lawall wrote:
 From: Julia Lawall julia.law...@lip6.fr
 
 Delete successive tests to the same location.  Data is the just previously
 allocated and tested value.  Test the result of the allocation made here
 instead.
 
 A simplified version of the semantic match that finds this problem is as
 follows: (http://coccinelle.lip6.fr/)
 
 // smpl
 @s exists@
 local idexpression y;
 expression x,e;
 @@
 
 *if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
  { ... when forall
return ...; }
 ... when != \(y = e\|y += e\|y -= e\|y |= e\|y = e\|y++\|y--\|y\)
 when != \(XT_GETPAGE(...,y)\|WMI_CMD_BUF(...)\)
 *if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
  { ... when forall
return ...; }
 // /smpl
 
 Signed-off-by: Julia Lawall julia.law...@lip6.fr

Already in my tree ;-)

commit b37457d80bc3e2a6bb86a6036c572574614a7631
Author: Sergei Shtylyov sshtyl...@ru.mvista.com
Date:   Tue Jan 8 22:11:14 2013 +0300

usb: musb: omap2430: fix wrong devm_kzalloc() result check

Commit 00a0b1d58af873d842580dcac55f3b156c3a4077 (usb: musb: omap: Add device
tree support for omap musb glue) assigns result of devm_kzalloc() call to
the 'config' variable but then checks for NULL the 'data' variable (already
checked after previous call). Thus we risk a kernel oops further when data
pointed by 'config' is written to by subsequent of_property_read_u32() calls
iff the allocation happens to fail...

Signed-off-by: Sergei Shtylyov sshtyl...@ru.mvista.com
Signed-off-by: Felipe Balbi ba...@ti.com

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index b15bb05..bb48796 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -543,7 +543,7 @@ static int omap2430_probe(struct platform_device *pdev)
}
 
config = devm_kzalloc(pdev-dev, sizeof(*config), GFP_KERNEL);
-   if (!data) {
+   if (!config) {
dev_err(pdev-dev,
failed to allocate musb hdrc config\n);
goto err2;

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH V3 0/5] UVC webcam gadget related changes

2013-01-21 Thread Laurent Pinchart
Hi Felipe,

On Friday 18 January 2013 20:46:59 Felipe Balbi wrote:
 On Thu, Jan 17, 2013 at 04:23:48PM +0530, Bhupesh Sharma wrote:
  This patchset tries to enhance the UVC webcam gadget driver and
  is based on Laurent's git tree available here (head uvc-gadget):
  git://linuxtv.org/pinchartl/uvcvideo.git
  
  Note that to ease review and integration of these patches, I have
  rebased them on Laurent's repo and all the relevant patches after
  review can be pushed in Felipe's repo in one go.
  
  The patches 3/5 and 4/5 in this patchset try to handle all the review
  comments received on the following UVC gadget related patches:
  
  [PATCH V2 1/2] usb: gadget/uvc: Port UVC webcam gadget to use videobuf2
  framework [PATCH V2 2/2] usb: gadget/uvc: Add support for
  'USB_GADGET_DELAYED_STATUS' response for a set_intf(alt-set 1) command
  
  which can be viewed here:
  [1] http://www.spinics.net/lists/linux-usb/msg68297.html
  [2] http://www.spinics.net/lists/linux-usb/msg68298.html
  
  I have tested this patchset on a super-speed compliant USB device
  controller (DWC3), with the VIVI capture device acting as a dummy source
  of video data and I also have modified the 'uvc-gadget' application
  written by Laurent (original application available here:
  http://git.ideasonboard.org/uvc-gadget.git) for testing the
  complete flow from V4L2 to UVC domain and vice versa.
 
 Laurent, do you wanna queue this yourself or should I take it ?

I was away last week, please give me a couple of days to review the patches. 
I'll take them in my tree with the other UVC gadget patches I have and I'll 
send you a pull request.

-- 
Regards,

Laurent Pinchart


signature.asc
Description: This is a digitally signed message part.


Re: [RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot

2013-01-21 Thread Roger Quadros
On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:
 The OMAP glue has been modified to get PHY by phandle for dt boot.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/usb/musb/omap2430.c |7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index 3628a50..08709cf 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -346,7 +346,12 @@ static int omap2430_musb_init(struct musb *musb)
* up through ULPI.  TWL4030-family PMICs include one,
* which needs a driver, drivers aren't always needed.
*/
 - musb-xceiv = devm_usb_get_phy(dev, 0);
 + if (dev-parent-of_node)
 + musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
 + usb_phy, 0);

Why dev-parent and not just dev?

 + else
 + musb-xceiv = devm_usb_get_phy(dev, 0);
 +
   if (IS_ERR_OR_NULL(musb-xceiv)) {
   pr_err(HS USB OTG: no transceiver configured\n);
   return -ENODEV;
 

--
cheers,
-roger
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 5/6] usb: otg: add device tree support to otg library

2013-01-21 Thread Roger Quadros
On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:
 Added an API devm_usb_get_phy_by_phandle(), to get usb phy by passing a
 device node phandle value. This function will return a pointer to
 the phy on success, -EPROBE_DEFER if there is a device_node for the phandle,
 but the phy has not been added, or a ERR_PTR() otherwise.
 
 Cc: Marc Kleine-Budde m...@pengutronix.de
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/usb/otg/otg.c   |   77 
 +++
  include/linux/usb/phy.h |8 +
  2 files changed, 85 insertions(+)
 
 diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
 index dbf2043..e9799bb 100644
 --- a/drivers/usb/otg/otg.c
 +++ b/drivers/usb/otg/otg.c
 @@ -13,7 +13,9 @@
  #include linux/export.h
  #include linux/err.h
  #include linux/device.h
 +#include linux/module.h
  #include linux/slab.h
 +#include linux/of.h
  
  #include linux/usb/otg.h
  
 @@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct device *dev, 
 u8 index)
   return ERR_PTR(-ENODEV);
  }
  
 +static struct usb_phy *__of_usb_find_phy(struct device_node *node)
 +{
 + struct usb_phy  *phy;
 +
 + list_for_each_entry(phy, phy_list, head) {
 + if (node != phy-dev-of_node)
 + continue;
 +
 + return phy;
 + }
 +
 + return ERR_PTR(-ENODEV);
 +}
 +
  static void devm_usb_phy_release(struct device *dev, void *res)
  {
   struct usb_phy *phy = *(struct usb_phy **)res;
 @@ -109,6 +125,67 @@ err0:
  }
  EXPORT_SYMBOL(usb_get_phy);
  
 + /**
 + * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
 + * @dev - device that requests this phy
 + * @phandle - name of the property holding the phy phandle value
 + * @index - the index of the phy
 + *
 + * Returns the phy driver associated with the given phandle value,
 + * after getting a refcount to it, -ENODEV if there is no such phy or
 + * -EPROBE_DEFER if there is a phandle to the phy, but the device is
 + * not yet loaded. While at that, it also associates the device with
 + * the phy using devres. On driver detach, release function is invoked
 + * on the devres data, then, devres data is freed.
 + *
 + * For use by USB host and peripheral drivers.
 + */
 +struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
 + const char *phandle, u8 index)
 +{
 + struct usb_phy  *phy = NULL, **ptr;
 + unsigned long   flags;
 + struct device_node *node;
 +
 + if (!dev-of_node) {
 + dev_dbg(dev, device does not have a device node entry\n);
 + return ERR_PTR(-EINVAL);
 + }
 +
 + node = of_parse_phandle(dev-of_node, phandle, index);
 + if (!node) {
 + dev_dbg(dev, failed to get %s phandle in %s node\n, phandle,
 + dev-of_node-full_name);
 + return ERR_PTR(-ENODEV);
 + }
 +
 + ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
 + if (!ptr) {
 + dev_dbg(dev, failed to allocate memory for devres\n);
 + return ERR_PTR(-ENOMEM);
 + }

I fail to understand why you need ptr at all and why do devres_alloc()
for it.

 +
 + spin_lock_irqsave(phy_lock, flags);
 +
 + phy = __of_usb_find_phy(node);
 + if (IS_ERR(phy) || !try_module_get(phy-dev-driver-owner)) {
 + phy = ERR_PTR(-EPROBE_DEFER);
 + devres_free(ptr);
 + goto err0;
 + }
 +
 + *ptr = phy;
 + devres_add(dev, ptr);
 +
 + get_device(phy-dev);
 +
 +err0:
 + spin_unlock_irqrestore(phy_lock, flags);
 +
 + return phy;
 +}
 +EXPORT_SYMBOL(devm_usb_get_phy_by_phandle);
 +

--
cheers,
-roger

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 5/6] usb: otg: add device tree support to otg library

2013-01-21 Thread kishon

On Monday 21 January 2013 06:51 PM, Roger Quadros wrote:

On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:

Added an API devm_usb_get_phy_by_phandle(), to get usb phy by passing a
device node phandle value. This function will return a pointer to
the phy on success, -EPROBE_DEFER if there is a device_node for the phandle,
but the phy has not been added, or a ERR_PTR() otherwise.

Cc: Marc Kleine-Budde m...@pengutronix.de
Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
  drivers/usb/otg/otg.c   |   77 +++
  include/linux/usb/phy.h |8 +
  2 files changed, 85 insertions(+)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index dbf2043..e9799bb 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -13,7 +13,9 @@
  #include linux/export.h
  #include linux/err.h
  #include linux/device.h
+#include linux/module.h
  #include linux/slab.h
+#include linux/of.h

  #include linux/usb/otg.h

@@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct device *dev, u8 
index)
return ERR_PTR(-ENODEV);
  }

+static struct usb_phy *__of_usb_find_phy(struct device_node *node)
+{
+   struct usb_phy  *phy;
+
+   list_for_each_entry(phy, phy_list, head) {
+   if (node != phy-dev-of_node)
+   continue;
+
+   return phy;
+   }
+
+   return ERR_PTR(-ENODEV);
+}
+
  static void devm_usb_phy_release(struct device *dev, void *res)
  {
struct usb_phy *phy = *(struct usb_phy **)res;
@@ -109,6 +125,67 @@ err0:
  }
  EXPORT_SYMBOL(usb_get_phy);

+ /**
+ * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
+ * @dev - device that requests this phy
+ * @phandle - name of the property holding the phy phandle value
+ * @index - the index of the phy
+ *
+ * Returns the phy driver associated with the given phandle value,
+ * after getting a refcount to it, -ENODEV if there is no such phy or
+ * -EPROBE_DEFER if there is a phandle to the phy, but the device is
+ * not yet loaded. While at that, it also associates the device with
+ * the phy using devres. On driver detach, release function is invoked
+ * on the devres data, then, devres data is freed.
+ *
+ * For use by USB host and peripheral drivers.
+ */
+struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
+   const char *phandle, u8 index)
+{
+   struct usb_phy  *phy = NULL, **ptr;
+   unsigned long   flags;
+   struct device_node *node;
+
+   if (!dev-of_node) {
+   dev_dbg(dev, device does not have a device node entry\n);
+   return ERR_PTR(-EINVAL);
+   }
+
+   node = of_parse_phandle(dev-of_node, phandle, index);
+   if (!node) {
+   dev_dbg(dev, failed to get %s phandle in %s node\n, phandle,
+   dev-of_node-full_name);
+   return ERR_PTR(-ENODEV);
+   }
+
+   ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr) {
+   dev_dbg(dev, failed to allocate memory for devres\n);
+   return ERR_PTR(-ENOMEM);
+   }


I fail to understand why you need ptr at all and why do devres_alloc()
for it.


Thats how we create a managed device resource. You can have a look at 
Documentation/driver-model/devres.txt and drivers/base/devres.c.


I'm not sure if that is what you are looking for :-P

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


USB gadget lockup on MX53 udc

2013-01-21 Thread Michael McTernan
Hi,

I think I've found a debug in fsl_udc_core.c and hope for some review of the 
fix.  It's pretty complex so apologies in advance if my explanation misses 
anything.

The background is that I started with the 3.0.59 stable branch (which shows the 
problem), then merged down the specific changes around fsl_usb2_udc from 
/balbi/usb.git.  The problem can be demonstrated on the Freescale START-R board 
(iMX53 running at 1GHz) acting as a USB gadget with g_ether (EEM) loaded and 
connected to a Linux PC, though I normally work on a derivative board.

The problem I see is that if I hammer data over the USB Ethernet towards the 
iMX53, the USB Ethernet 'jams' after a random amount of time between 10 seconds 
and a couple of minutes.  I currently use iperf to generate lots of packets - a 
bit more than the link can really carry e.g. iperf -c 10.10.10.10 -u -b 150M -i 
1 -t 6000.  When 'jammed' endpoint 0 still runs but endpoint 1 no longer 
transfers data.  /proc/interrupts show that no interrupts are being created for 
ep1 (ep0 will increase the count).

I beefed up /proc/driver/fsl_usb2_udc a bit, and it appears the queue on ep1out 
has gone wrong:

Endpoint Setup Status Reg: SETUP on ep 0x00

EP Ctrl Reg [0x00] =[0x00800080]
EP Ctrl Reg [0x01] =[0x00880088]
EP Ctrl Reg [0x02] =[0x00080008]
EP Ctrl Reg [0x03] =[0x00080008]
EP Ctrl Reg [0x04] =[0x00080008]
EP Ctrl Reg [0x05] =[0x00080008]
EP Ctrl Reg [0x06] =[0x00080008]
EP Ctrl Reg [0x07] =[0x00080008]
EP Prime Reg  = [0x]
EP Complete Reg   = [0x]
EP Status = [0x]

For ep0 Maxpkt is 0x0040 index is 0x
its req queue is empty

Gadget endpoints

For ep1out Maxpkt is 0x0200 index is 0x0001
curr_dtd_ptr 0x8f017080
next_dtd_ptr 0x1
size_ioc_int_sts 0x128000
req df9a9c80 actual 0x0600 length 0x0600  buf dfb47802 no_interrupt 0 
status -115
  td_dma=0x8f0170c0 size_ioc_sts=0x06008080 next_td_ptr=0x8f017100
req df9a9f80 actual 0x0600 length 0x0600  buf df05c802 no_interrupt 0 
status -115
  td_dma=0x8f017100 size_ioc_sts=0x06008080 next_td_ptr=0x8f017140
req df9a9600 actual 0x0600 length 0x0600  buf df05d802 no_interrupt 0 
status -115
  td_dma=0x8f017140 size_ioc_sts=0x06008080 next_td_ptr=0x8f017180
req df9a9980 actual 0x0600 length 0x0600  buf df05e802 no_interrupt 0 
status -115
  td_dma=0x8f017180 size_ioc_sts=0x06008080 next_td_ptr=0x8f0171c0
req df9a9e80 actual 0x0600 length 0x0600  buf df05f802 no_interrupt 0 
status -115
  td_dma=0x8f0171c0 size_ioc_sts=0x06008080 next_td_ptr=0x8f017200
req df9a9e00 actual 0x0600 length 0x0600  buf df0bc802 no_interrupt 0 
status -115
  td_dma=0x8f017200 size_ioc_sts=0x06008080 next_td_ptr=0x8f017240
req df9a9b80 actual 0x0600 length 0x0600  buf df0bd802 no_interrupt 0 
status -115
  td_dma=0x8f017240 size_ioc_sts=0x06008080 next_td_ptr=0x8f017000
req df9a9580 actual 0x0600 length 0x0600  buf df0be802 no_interrupt 0 
status -115
  td_dma=0x8f017000 size_ioc_sts=0x06008080 next_td_ptr=0x8f017040
req df9a9f00 actual 0x0600 length 0x0600  buf df0bf802 no_interrupt 0 
status -115
  td_dma=0x8f017040 size_ioc_sts=0x06008080 next_td_ptr=0x8f017080
req df9a9b00 actual 0x0600 length 0x0600  buf df0cc802 no_interrupt 0 
status -115
  td_dma=0x8f017080 size_ioc_sts=0x00128000 next_td_ptr=0x0001

For ep1in Maxpkt is 0x0200 index is 0x0001
curr_dtd_ptr 0x8f017300
next_dtd_ptr 0x1
size_ioc_int_sts 0x8000
its req queue is empty

This output shows that hardware arrived on the last queue entry for ep1out but 
somehow skipped the other items in the list (size_ioc_sts  0x8 still shows 
0x8=active for them).  I believe this is due to an incorrect re-priming of the 
hardware, so I added some debug to fsl_queue_td().  I found that the error 
occurs when the request list is not empty, tmp_stat is not set after the ATDTW 
procedure, AND the queue head next_dtd_ptr != 1 (i.e. not terminate but a dTD 
pointer).  This last condition is unchecked in the software (checking the 
next_dtd_prr is not mentioned in the iMX53 Reference Manual), but from 
observation the next_dtd_ptr is normally always 1 when we have to re-prime and 
conversely when next_dtd_ptr contains a dTD address we see the jamming.  This 
observation is not however the primary cause, but explains how we end up with 
the broken queue and jam I see.

Working back, I found that jamming problem appears after the following 
[abbreviated] call sequence occurs:

fsl_udc_irq()
- dtd_complete_irq() 
  - done() 
- dma_pool_free(udc-td_pool, ...) 
- req-req.complete()
   
  - fsl_ep_queue()
- fsl_req_to_dtd()
  - fsl_build_dtd()
- dma_pool_alloc(udc-td_pool, ...)
- fsl_queue_td()


Specifically when there is a problem, the DMA free and subsequent alloc use the 
same dTD address i.e. the pool element is reused straight away.  This should 
not be a 

Re: [RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot

2013-01-21 Thread kishon

Hi,

On Monday 21 January 2013 06:48 PM, Roger Quadros wrote:

On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:

The OMAP glue has been modified to get PHY by phandle for dt boot.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
  drivers/usb/musb/omap2430.c |7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3628a50..08709cf 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -346,7 +346,12 @@ static int omap2430_musb_init(struct musb *musb)
 * up through ULPI.  TWL4030-family PMICs include one,
 * which needs a driver, drivers aren't always needed.
 */
-   musb-xceiv = devm_usb_get_phy(dev, 0);
+   if (dev-parent-of_node)
+   musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
+   usb_phy, 0);


Why dev-parent and not just dev?


Right now MUSB core is not converted to dt and hence we don't have 
separate dt node for MUSB core.

So the PHY information is added to the glue dt data.

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


[PATCH] usb: phy: samsung: Remove __devinit, __devexit_p and __exit annotations

2013-01-21 Thread Vivek Gautam
Dropping __devinit, __devexit_p, __exit annotations since they are
nop and no longer supported.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---
 drivers/usb/phy/samsung-usbphy.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
index 30aebb5..6b30809 100644
--- a/drivers/usb/phy/samsung-usbphy.c
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -343,7 +343,7 @@ static inline const struct samsung_usbphy_drvdata
platform_get_device_id(pdev)-driver_data;
 }
 
-static int __devinit samsung_usbphy_probe(struct platform_device *pdev)
+static int samsung_usbphy_probe(struct platform_device *pdev)
 {
struct samsung_usbphy *sphy;
struct samsung_usbphy_data *pdata = pdev-dev.platform_data;
@@ -405,7 +405,7 @@ static int __devinit samsung_usbphy_probe(struct 
platform_device *pdev)
return usb_add_phy(sphy-phy, USB_PHY_TYPE_USB2);
 }
 
-static int __exit samsung_usbphy_remove(struct platform_device *pdev)
+static int samsung_usbphy_remove(struct platform_device *pdev)
 {
struct samsung_usbphy *sphy = platform_get_drvdata(pdev);
 
@@ -456,7 +456,7 @@ MODULE_DEVICE_TABLE(platform, samsung_usbphy_driver_ids);
 
 static struct platform_driver samsung_usbphy_driver = {
.probe  = samsung_usbphy_probe,
-   .remove = __devexit_p(samsung_usbphy_remove),
+   .remove = samsung_usbphy_remove,
.id_table   = samsung_usbphy_driver_ids,
.driver = {
.name   = samsung-usbphy,
-- 
1.7.6.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net] net: cdc_ncm: workaround for missing CDC Union

2013-01-21 Thread Bjørn Mork
Hello Alexey,

I have another issue with the Sierra firmware which I hope you can help
me with: The MC7710 device requires at ZLP even if we send
dwNtbOutMaxSize sized NTBs. This is a problem because the current code
explicitly prevents this.

The following code in the v3.8 cdc-ncm was written to keep existing
behaviour from the pre-v3.8 driver:

if (((skb_out-len % le16_to_cpu(ctx-out_ep-desc.wMaxPacketSize)) == 
0) 
(skb_out-len  le32_to_cpu(ctx-ncm_parm.dwNtbOutMaxSize))  
skb_tailroom(skb_out))
*skb_put(skb_out, 1) = 0;   /* force short packet */



The previous implementaion looked like this:

6c60408e (Alexey Orishko 2011-05-06 03:01:30 +  832)if 
(((last_offset  ctx-tx_max)  ((last_offset %
6c60408e (Alexey Orishko 2011-05-06 03:01:30 +  833)
le16_to_cpu(ctx-out_ep-desc.wMaxPacketSize)) == 0)) ||
6c60408e (Alexey Orishko 2011-05-06 03:01:30 +  834)
(((last_offset == ctx-tx_max)  ((ctx-tx_max %
6c60408e (Alexey Orishko 2011-05-06 03:01:30 +  835)
le16_to_cpu(ctx-out_ep-desc.wMaxPacketSize)) == 0)) 
6c60408e (Alexey Orishko 2011-05-06 03:01:30 +  836)
(ctx-tx_max  le32_to_cpu(ctx-ncm_parm.dwNtbOutMaxSize {
900d495a (Alexey Orishko 2010-11-29 23:23:28 +  837)/* 
force short packet */
900d495a (Alexey Orishko 2010-11-29 23:23:28 +  838)*(((u8 
*)skb_out-data) + last_offset) = 0;
900d495a (Alexey Orishko 2010-11-29 23:23:28 +  839)
last_offset++;
900d495a (Alexey Orishko 2010-11-29 23:23:28 +  840)}


The effect is the same: We add a 0 byte if the NTB length is a multiplum
of wMaxPacketSize *except* if the length is equal to dwNtbOutMaxSize.
This exception will happen very often because of the way we pad NTBs.

Now, I have tried to find what the above code was based on, and my guess
is that it is this note in table 3-1 in the CDC NCM spec:

   If wBlockLength = 0x, the block is terminated by a
   short packet. In this case, the USB transfer must still
   be shorter than dwNtbInMaxSize or dwNtbOutMax-
   Size. If exactly dwNtbInMaxSize or dwNtbOutMaxSize
   bytes are sent, and the size is a multiple of wMax-
   PacketSize for the given pipe, then no ZLP shall be
   sent.

Is that correct?  I cannot find any special ZLP handling mentioned
anywhere else in the standard.

If so, then I believe it is a misinterpretation.  The above text deals
only with the exceptional case of wBlockLength = 0x, which we do not
do.  As long as wBlockLength  0 then I believe the device is in its
full right to expect a ZLP if wBlockLength % wMaxPacketSize is 0.

Would you feel comfortable dropping the additional condition and going
with

if (((skb_out-len % le16_to_cpu(ctx-out_ep-desc.wMaxPacketSize)) == 
0) 
skb_tailroom(skb_out))
*skb_put(skb_out, 1) = 0;   /* force short packet */


? I have verified that this is sufficient to make the Sierra device
work.  I will of course test it with the other NCM and MBIM devices I've
got, but that is a very limited set...

The other option I see is making a device specific quirk for this.  But
I suspect that Sierra is using the current Qualcomm MBIM implemetation
here, and if so then we are likely to see a large number of similar
devices in the near future.  I'd really like to avoid having device
specific quirks for all of them if at all possible.



Bjørn
--
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 3/4] ARM: OMAP2: MUSB: Specify omap4 has mailbox

2013-01-21 Thread Kishon Vijay Abraham I
Added has_mailbox to the musb platform data to specify that omap uses
an external mailbox (in control module) to communicate with the musb
core during device connect and disconnect.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-omap2/usb-musb.c |3 +++
 include/linux/usb/musb.h   |2 ++
 2 files changed, 5 insertions(+)

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 7b33b37..9d27e3f 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -85,6 +85,9 @@ void __init usb_musb_init(struct omap_musb_board_data 
*musb_board_data)
musb_plat.mode = board_data-mode;
musb_plat.extvbus = board_data-extvbus;
 
+   if (cpu_is_omap44xx())
+   musb_plat.has_mailbox = true;
+
if (soc_is_am35xx()) {
oh_name = am35x_otg_hs;
name = musb-am35x;
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
index eb50525..053c268 100644
--- a/include/linux/usb/musb.h
+++ b/include/linux/usb/musb.h
@@ -99,6 +99,8 @@ struct musb_hdrc_platform_data {
/* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
u8  mode;
 
+   u8  has_mailbox:1;
+
/* for clk_get() */
const char  *clock;
 
-- 
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 v2 2/4] ARM: OMAP: devices: create device for usb part of control module

2013-01-21 Thread Kishon Vijay Abraham I
A seperate driver has been added to handle the usb part of control
module. A device for the above driver is created here, using the register
address information to be used by the driver for powering on the PHY and
for writing to the mailbox.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-omap2/devices.c |   45 +
 1 file changed, 45 insertions(+)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 5e304d0..edc5ec2 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -20,6 +20,7 @@
 #include linux/pinctrl/machine.h
 #include linux/platform_data/omap4-keypad.h
 #include linux/platform_data/omap_ocp2scp.h
+#include linux/usb/omap_control_usb.h
 
 #include asm/mach-types.h
 #include asm/mach/map.h
@@ -254,6 +255,49 @@ static inline void omap_init_camera(void)
 #endif
 }
 
+#if IS_ENABLED(CONFIG_OMAP_CONTROL_USB)
+static struct omap_control_usb_platform_data omap4_control_usb_pdata = {
+   .has_mailbox = true,
+};
+
+struct resource omap4_control_usb_res[] = {
+   {
+   .name   = control_dev_conf,
+   .start  = 0x4a002300,
+   .end= 0x4a002303,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .name   = otghs_control,
+   .start  = 0x4a00233c,
+   .end= 0x4a00233f,
+   .flags  = IORESOURCE_MEM,
+   },
+};
+
+static struct platform_device omap4_control_usb = {
+   .name   = omap-control-usb,
+   .id = -1,
+   .dev = {
+   .platform_data = omap4_control_usb_pdata,
+   },
+   .num_resources = 2,
+   .resource = omap4_control_usb_res,
+};
+
+static inline void __init omap_init_control_usb(void)
+{
+   if (!cpu_is_omap44xx())
+   return;
+
+   if (platform_device_register(omap4_control_usb))
+   pr_err(Error registering omap_control_usb device\n);
+}
+
+#else
+static inline void omap_init_control_usb(void) { }
+#endif /* CONFIG_OMAP_CONTROL_USB */
+
 int __init omap4_keyboard_init(struct omap4_keypad_platform_data
*sdp4430_keypad_data, struct omap_board_data *bdata)
 {
@@ -721,6 +765,7 @@ static int __init omap2_init_devices(void)
omap_init_mbox();
/* If dtb is there, the devices will be created dynamically */
if (!of_have_populated_dt()) {
+   omap_init_control_usb();
omap_init_dmic();
omap_init_mcpdm();
omap_init_mcspi();
-- 
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 v2 4/4] drivers: usb: start using the control module driver

2013-01-21 Thread Kishon Vijay Abraham I
Start using the control module driver for powering on the PHY and for
writing to the mailbox instead of writing to the control module
registers on their own.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |4 ++
 Documentation/devicetree/bindings/usb/usb-phy.txt  |7 +--
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   13 
 drivers/usb/musb/Kconfig   |1 +
 drivers/usb/musb/omap2430.c|   64 +++-
 drivers/usb/musb/omap2430.h|9 ---
 drivers/usb/phy/Kconfig|1 +
 drivers/usb/phy/omap-usb2.c|   38 +++-
 include/linux/usb/omap_usb.h   |4 +-
 9 files changed, 40 insertions(+), 101 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index ead6ba9..8bedbba 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -3,6 +3,9 @@ OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS
 OMAP MUSB GLUE
  - compatible : Should be ti,omap4-musb or ti,omap3-musb
  - ti,hwmods : must be usb_otg_hs
+ - ti,has_mailbox : to specify that omap uses an external mailbox
+   (in control module) to communicate with the musb core during device connect
+   and disconnect.
  - multipoint : Should be 1 indicating the musb controller supports
multipoint. This is a MUSB configuration-specific setting.
  - num_eps : Specifies the number of endpoints. This is also a
@@ -24,6 +27,7 @@ SOC specific device node entry
 usb_otg_hs: usb_otg_hs@4a0ab000 {
compatible = ti,omap4-musb;
ti,hwmods = usb_otg_hs;
+   ti,has_mailbox;
multipoint = 1;
num_eps = 16;
ram_bits = 12;
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 2466b6f..48761a2 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -4,9 +4,7 @@ OMAP USB2 PHY
 
 Required properties:
  - compatible: Should be ti,omap-usb2
- - reg : Address and length of the register set for the device. Also
-add the address of control module dev conf register until a driver for
-control module is added
+ - reg : Address and length of the register set for the device.
 
 Optional properties:
  - ctrl_module : phandle of the control module used by PHY driver to power on
@@ -16,7 +14,6 @@ This is usually a subnode of ocp2scp to which it is connected.
 
 usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
-   reg = 0x4a0ad080 0x58,
- 0x4a002300 0x4;
+   reg = 0x4a0ad080 0x58;
ctrl_module = omap_control_usb;
 };
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 129d508..103f4ba 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -2698,13 +2698,6 @@ static struct resource omap44xx_usb_phy_and_pll_addrs[] 
= {
.end= 0x4a0ae000,
.flags  = IORESOURCE_MEM,
},
-   {
-   /* XXX: Remove this once control module driver is in place */
-   .name   = ctrl_dev,
-   .start  = 0x4a002300,
-   .end= 0x4a002303,
-   .flags  = IORESOURCE_MEM,
-   },
{ }
 };
 
@@ -6152,12 +6145,6 @@ static struct omap_hwmod_addr_space 
omap44xx_usb_otg_hs_addrs[] = {
.pa_end = 0x4a0ab7ff,
.flags  = ADDR_TYPE_RT
},
-   {
-   /* XXX: Remove this once control module driver is in place */
-   .pa_start   = 0x4a00233c,
-   .pa_end = 0x4a00233f,
-   .flags  = ADDR_TYPE_RT
-   },
{ }
 };
 
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 23a0b7f..de6e5ce 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -11,6 +11,7 @@ config USB_MUSB_HDRC
select NOP_USB_XCEIV if (SOC_TI81XX || SOC_AM33XX)
select TWL4030_USB if MACH_OMAP_3430SDP
select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
+   select OMAP_CONTROL_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
select USB_OTG_UTILS
help
  Say Y here if your system has a dual role high speed USB
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index da00af4..bf6cfe0 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -37,6 +37,7 @@
 #include linux/err.h
 #include linux/delay.h
 #include linux/usb/musb-omap.h
+#include linux/usb/omap_control_usb.h
 
 #include musb_core.h
 #include omap2430.h
@@ -46,7 +47,7 @@ struct omap2430_glue {
struct 

[PATCH v2 1/4] drivers: usb: phy: add a new driver for usb part of control module

2013-01-21 Thread Kishon Vijay Abraham I
Added a new driver for the usb part of control module. This has an API
to power on the USB2 phy and an API to write to the mailbox depending on
whether MUSB has to act in host mode or in device mode.

Writing to control module registers for doing the above task which was
previously done in omap glue and in omap-usb2 phy will be removed.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |   26 ++-
 Documentation/devicetree/bindings/usb/usb-phy.txt  |5 +
 drivers/usb/phy/Kconfig|9 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/omap-control-usb.c |  238 
 include/linux/usb/omap_control_usb.h   |   71 ++
 6 files changed, 349 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/phy/omap-control-usb.c
 create mode 100644 include/linux/usb/omap_control_usb.h

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 29a043e..ead6ba9 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -1,4 +1,4 @@
-OMAP GLUE
+OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS
 
 OMAP MUSB GLUE
  - compatible : Should be ti,omap4-musb or ti,omap3-musb
@@ -16,6 +16,10 @@ OMAP MUSB GLUE
  - power : Should be 50. This signifies the controller can supply upto
100mA when operating in host mode.
 
+Optional properties:
+ - ctrl_module : phandle of the control module this glue uses to write to
+   mailbox
+
 SOC specific device node entry
 usb_otg_hs: usb_otg_hs@4a0ab000 {
compatible = ti,omap4-musb;
@@ -23,6 +27,7 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
multipoint = 1;
num_eps = 16;
ram_bits = 12;
+   ctrl_module = omap_control_usb;
 };
 
 Board specific device node entry
@@ -31,3 +36,22 @@ Board specific device node entry
mode = 3;
power = 50;
 };
+
+OMAP CONTROL USB
+
+Required properties:
+ - compatible: Should be ti,omap-control-usb
+ - reg : Address and length of the register set for the device. It contains
+   the address of control_dev_conf and otghs_control.
+ - reg-names: The names of the register addresses corresponding to the 
registers
+   filled in reg.
+ - ti,has_mailbox: This is used to specify if the platform has mailbox in
+   control module.
+
+omap_control_usb: omap-control-usb@4a002300 {
+   compatible = ti,omap-control-usb;
+   reg = 0x4a002300 0x4,
+ 0x4a00233c 0x4;
+   reg-names = control_dev_conf, otghs_control;
+   ti,has_mailbox;
+};
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 80d4148..2466b6f 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -8,10 +8,15 @@ Required properties:
 add the address of control module dev conf register until a driver for
 control module is added
 
+Optional properties:
+ - ctrl_module : phandle of the control module used by PHY driver to power on
+   the PHY.
+
 This is usually a subnode of ocp2scp to which it is connected.
 
 usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58,
  0x4a002300 0x4;
+   ctrl_module = omap_control_usb;
 };
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 36a85b6..20479e8 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -14,6 +14,15 @@ config OMAP_USB2
  The USB OTG controller communicates with the comparator using this
  driver.
 
+config OMAP_CONTROL_USB
+   tristate OMAP CONTROL USB Driver
+   depends on ARCH_OMAP2PLUS
+   help
+ Enable this to add support for the USB part present in the control
+ module. This driver has API to power on the PHY and to write to the
+ mailbox. The mailbox is present only in omap4 and the register to
+ power on the PHY is present in omap4 and omap5.
+
 config USB_ISP1301
tristate NXP ISP1301 USB transceiver support
depends on USB || USB_GADGET
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index ec304f6..ee97767 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,6 +5,7 @@
 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_OMAP_USB2)+= omap-usb2.o
+obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
diff --git a/drivers/usb/phy/omap-control-usb.c 
b/drivers/usb/phy/omap-control-usb.c
new file mode 100644
index 000..e8fd85c
--- /dev/null
+++ b/drivers/usb/phy/omap-control-usb.c
@@ -0,0 +1,238 @@
+/*
+ * omap-control-usb.c - The USB part of control module.
+ *
+ * Copyright (C) 2013 

[PATCH V6 0/8] usb: usb port power off mechanism and expose usb port connect type

2013-01-21 Thread Lan Tianyu
Change since v1:
   optimize the export connect type patch and adjust the DeviceRemovalbe 
flag
in the rh_call_control() after GetHubDescriptor request being processed.
   move all debounce operation to usb port's runtime resume callback(). Add
did_runtime_put in the struct usb_port to call pm_runtime_get/put(portdev) 
paired.
   using pm_runtime_get/put(portdev) to allow or prohibit device to be power
off inside of pm qos request in the kernel side. 

Change since v2:
   Correct some link breaks. 
   Add did_runtime_put in the usb_disconnect() before calling 
pm_runtime_put(portdev).
   Provide two seperate functions usb_device_allow_power_off() and 
usb_device_prevent_power_off()
instead of just one.

Change since v3:
Set did_runtime_put to false in usb_disconnect() when its value is true
Add comment about not enable port runtime pm if fail to expose port's 
pm qos. and call
pm_runtime_set_active(portdev) unconditionally.
rename usb_device_allow_prevent_power_off with 
usb_device_control_power_off
Modify be power off to be powered off
Expose dev_pm_qos_flags() symbol in order to ensure usb core can 
compile as module. 

Resend v4:
make patch PM/Qos: Expose dev_pm_qos_flags symbol as first patch to 
avoid compilation error during git bisect
correct some comments.

Change since v4:
use EXPORT_SYMBOL_GPL to export dev_pm_qos_flags().
correct some unnecessary link breaks.   
Add CONFIG_USB_SUSPEND check around usb_port_runtime_resume() and 
usb_port_runtime_suspend()

Change since v5:
predefine struct usb_hub_descriptor in the /driver/usb/core/usb.h 
instead of including linux/usb/ch11.h
move patch PM/Qos: Expose dev_pm_qos_flags symbol before patch usb: 
add runtime pm support for usb port device
 where dev_pm_qos_flags() fistly is called.


This patchset is based on usb-next tree commit f4cc1834 USB: storage: avoid 
scanning other targets for single target device

This patchset is to add usb port power off mechanism and
merge with patchset usb: expose DeviceRemovable to user space via sysfs 
attribute.

Patchset usb: expose DeviceRemovable to user space via sysfs attribute.
http://marc.info/?l=linux-usbm=135279430410171w=2 with some link break 
corrects

The main discussion about usb port power off mechanism is in the following link:
http://marc.info/?l=linux-usbm=134818340017208w=2


USB: Set usb port's DeviceRemovable according acpi information
usb: Register usb port's acpi power resources
PM/Qos: Expose dev_pm_qos_flags symbol
usb: add runtime pm support for usb port device
usb: add usb port auto power off mechanism
usb: expose usb port's pm qos flags to user space
usb: add usb_device_allow_power_off() and usb_device_prevent_power_off() 
function.
usb: enable usb port device's async suspend.
--
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 v6 1/8] USB: Set usb port's DeviceRemovable according acpi information

2013-01-21 Thread Lan Tianyu
ACPI provide _PLD and _UPC aml methods to describe usb port
visibility and connectability. This patch is to add 
usb_hub_adjust_DeviceRemovable()
to adjust usb hub port's DeviceRemovable according ACPI information and invoke 
it in
the rh_call_control(). When hub descriptor request is issued at first time,
usb port device isn't created and usb port is not bound with acpi. So first
hub descriptor request is not changed based on ACPI information. After usb
port devices being created, call usb_hub_adjust_DeviceRemovable in the 
hub_configure()
and then set hub port's DeviceRemovable according ACPI information and this 
also works
for non-root hub.

Acked-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Lan Tianyu tianyu@intel.com
---
 drivers/usb/core/hcd.c |4 
 drivers/usb/core/hub.c |   43 +++
 drivers/usb/core/usb.h |3 +++
 3 files changed, 50 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 5f6da8b..2459896 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -619,6 +619,10 @@ nongeneric:
status = hcd-driver-hub_control (hcd,
typeReq, wValue, wIndex,
tbuf, wLength);
+
+   if (typeReq == GetHubDescriptor)
+   usb_hub_adjust_deviceremovable(hcd-self.root_hub,
+   (struct usb_hub_descriptor *)tbuf);
break;
 error:
/* protocol stall on error */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index cfdd4ee..29ca6ed 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1513,6 +1513,8 @@ static int hub_configure(struct usb_hub *hub,
dev_err(hub-intfdev,
couldn't create port%d device.\n, i + 1);
 
+   usb_hub_adjust_deviceremovable(hdev, hub-descriptor);
+
hub_activate(hub, HUB_INIT);
return 0;
 
@@ -5219,6 +5221,47 @@ usb_get_hub_port_connect_type(struct usb_device *hdev, 
int port1)
return hub-ports[port1 - 1]-connect_type;
 }
 
+void usb_hub_adjust_deviceremovable(struct usb_device *hdev,
+   struct usb_hub_descriptor *desc)
+{
+   enum usb_port_connect_type connect_type;
+   int i;
+
+   if (!hub_is_superspeed(hdev)) {
+   for (i = 1; i = hdev-maxchild; i++) {
+   connect_type = usb_get_hub_port_connect_type(hdev, i);
+
+   if (connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
+   u8 mask = 1  (i%8);
+
+   if (!(desc-u.hs.DeviceRemovable[i/8]  mask)) {
+   dev_dbg(hdev-dev, usb port%d's 
DeviceRemovable is changed to 1 according to platform information.\n,
+   i);
+   desc-u.hs.DeviceRemovable[i/8] |= mask;
+   }
+   }
+   }
+   } else {
+   u16 port_removable = le16_to_cpu(desc-u.ss.DeviceRemovable);
+
+   for (i = 1; i = hdev-maxchild; i++) {
+   connect_type = usb_get_hub_port_connect_type(hdev, i);
+
+   if (connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
+   u16 mask = 1  i;
+
+   if (!(port_removable  mask)) {
+   dev_dbg(hdev-dev, usb port%d's 
DeviceRemovable is changed to 1 according to platform information.\n,
+   i);
+   port_removable |= mask;
+   }
+   }
+   }
+
+   desc-u.ss.DeviceRemovable = cpu_to_le16(port_removable);
+   }
+}
+
 #ifdef CONFIG_ACPI
 /**
  * usb_get_hub_port_acpi_handle - Get the usb port's acpi handle
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index fb7d8fc..a7f20bd 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -1,6 +1,7 @@
 #include linux/pm.h
 #include linux/acpi.h
 
+struct usb_hub_descriptor;
 struct dev_state;
 
 /* Functions local to drivers/usb/core/ */
@@ -182,6 +183,8 @@ extern enum usb_port_connect_type
usb_get_hub_port_connect_type(struct usb_device *hdev, int port1);
 extern void usb_set_hub_port_connect_type(struct usb_device *hdev, int port1,
enum usb_port_connect_type type);
+extern void usb_hub_adjust_deviceremovable(struct usb_device *hdev,
+   struct usb_hub_descriptor *desc);
 
 #ifdef CONFIG_ACPI
 extern int usb_acpi_register(void);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 2/8] usb: Register usb port's acpi power resources

2013-01-21 Thread Lan Tianyu
This patch is to register usb port's acpi power resources. Create
link between usb port device and its acpi power resource.

Acked-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Lan Tianyu tianyu@intel.com
---
 drivers/usb/core/port.c |3 +++
 drivers/usb/core/usb-acpi.c |   20 
 drivers/usb/core/usb.h  |6 ++
 3 files changed, 29 insertions(+)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index fe5959f..4dfa254 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -66,6 +66,7 @@ static void usb_port_device_release(struct device *dev)
 {
struct usb_port *port_dev = to_usb_port(dev);
 
+   usb_acpi_unregister_power_resources(dev);
kfree(port_dev);
 }
 
@@ -95,6 +96,8 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
if (retval)
goto error_register;
 
+   usb_acpi_register_power_resources(port_dev-dev);
+
return 0;
 
 error_register:
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index cef4252..558ab01 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -216,6 +216,26 @@ static struct acpi_bus_type usb_acpi_bus = {
.find_device = usb_acpi_find_device,
 };
 
+int usb_acpi_register_power_resources(struct device *dev)
+{
+   acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev);
+
+   if (!port_handle)
+   return -ENODEV;
+
+   if (acpi_power_resource_register_device(dev, port_handle)  0)
+   return -ENODEV;
+   return 0;
+}
+
+void usb_acpi_unregister_power_resources(struct device *dev)
+{
+   acpi_handle port_handle = DEVICE_ACPI_HANDLE(dev);
+
+   if (port_handle)
+   acpi_power_resource_unregister_device(dev, port_handle);
+}
+
 int usb_acpi_register(void)
 {
return register_acpi_bus_type(usb_acpi_bus);
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index a7f20bd..601b044 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -191,7 +191,13 @@ extern int usb_acpi_register(void);
 extern void usb_acpi_unregister(void);
 extern acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev,
int port1);
+extern int usb_acpi_register_power_resources(struct device *dev);
+extern void usb_acpi_unregister_power_resources(struct device *dev);
 #else
 static inline int usb_acpi_register(void) { return 0; };
 static inline void usb_acpi_unregister(void) { };
+static inline int usb_acpi_register_power_resources(struct device *dev)
+   { return 0; };
+static inline void usb_acpi_unregister_power_resources(struct device *dev)
+   { };
 #endif
-- 
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 v6 3/8] PM/Qos: Expose dev_pm_qos_flags symbol

2013-01-21 Thread Lan Tianyu
The dev_pm_qos_flags() will be used in the usb core which could be
compiled as a module. This patch is to export it.

Acked-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Lan Tianyu tianyu@intel.com
---
 drivers/base/power/qos.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index d213495..3d4d1f8 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -91,6 +91,7 @@ enum pm_qos_flags_status dev_pm_qos_flags(struct device *dev, 
s32 mask)
 
return ret;
 }
+EXPORT_SYMBOL_GPL(dev_pm_qos_flags);
 
 /**
  * __dev_pm_qos_read_value - Get PM QoS constraint for a given device.
-- 
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 v6 4/8] usb: add runtime pm support for usb port device

2013-01-21 Thread Lan Tianyu
This patch is to add runtime pm callback for usb port device.
Set/clear PORT_POWER feature in the resume/suspend callbak.
Add portnum for struct usb_port to record port number. Do
pm_rumtime_get_sync/put(portdev) when a device is plugged/unplugged
to prevent it from being powered off when it is active.

Acked-by: Alan Stern st...@rowland.harvard.edu
Acked-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
Signed-off-by: Lan Tianyu tianyu@intel.com
---
 drivers/usb/core/hub.c  |   18 ++
 drivers/usb/core/hub.h  |4 
 drivers/usb/core/port.c |   45 +
 3 files changed, 67 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 29ca6ed..8c1f9a5 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -714,6 +714,18 @@ static void hub_tt_work(struct work_struct *work)
spin_unlock_irqrestore (hub-tt.lock, flags);
 }
 
+int usb_hub_set_port_power(struct usb_device *hdev, int port1,
+   bool set)
+{
+   int ret;
+
+   if (set)
+   ret = set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
+   else
+   ret = clear_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
+   return ret;
+}
+
 /**
  * usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub
  * @urb: an URB associated with the failed or incomplete split transaction
@@ -1569,6 +1581,7 @@ static void hub_disconnect(struct usb_interface *intf)
kfree(hub-status);
kfree(hub-buffer);
 
+   pm_suspend_ignore_children(intf-dev, false);
kref_put(hub-kref, hub_release);
 }
 
@@ -1671,6 +1684,7 @@ descriptor_error:
 
usb_set_intfdata (intf, hub);
intf-needs_remote_wakeup = 1;
+   pm_suspend_ignore_children(intf-dev, true);
 
if (hdev-speed == USB_SPEED_HIGH)
highspeed_hubs++;
@@ -1997,6 +2011,8 @@ void usb_disconnect(struct usb_device **pdev)
 
sysfs_remove_link(udev-dev.kobj, port);
sysfs_remove_link(port_dev-dev.kobj, device);
+
+   pm_runtime_put(port_dev-dev);
}
 
usb_remove_ep_devs(udev-ep0);
@@ -2307,6 +2323,8 @@ int usb_new_device(struct usb_device *udev)
sysfs_remove_link(udev-dev.kobj, port);
goto fail;
}
+
+   pm_runtime_get_sync(port_dev-dev);
}
 
(void) usb_create_ep_devs(udev-dev, udev-ep0, udev);
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index d16a7c9..8ea6bc8 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -79,12 +79,14 @@ struct usb_hub {
  * @dev: generic device interface
  * @port_owner: port's owner
  * @connect_type: port's connect type
+ * @portnum: port index num based one
  */
 struct usb_port {
struct usb_device *child;
struct device dev;
struct dev_state *port_owner;
enum usb_port_connect_type connect_type;
+   u8 portnum;
 };
 
 #define to_usb_port(_dev) \
@@ -94,4 +96,6 @@ extern int usb_hub_create_port_device(struct usb_hub *hub,
int port1);
 extern void usb_hub_remove_port_device(struct usb_hub *hub,
int port1);
+extern int usb_hub_set_port_power(struct usb_device *hdev,
+   int port1, bool set);
 
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 4dfa254..bd08f7e 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -17,6 +17,7 @@
  */
 
 #include linux/slab.h
+#include linux/pm_qos.h
 
 #include hub.h
 
@@ -70,9 +71,50 @@ static void usb_port_device_release(struct device *dev)
kfree(port_dev);
 }
 
+#ifdef CONFIG_USB_SUSPEND
+static int usb_port_runtime_resume(struct device *dev)
+{
+   struct usb_port *port_dev = to_usb_port(dev);
+   struct usb_device *hdev = to_usb_device(dev-parent-parent);
+   struct usb_interface *intf = to_usb_interface(dev-parent);
+   int retval;
+
+   usb_autopm_get_interface(intf);
+   retval = usb_hub_set_port_power(hdev, port_dev-portnum, true);
+   usb_autopm_put_interface(intf);
+   return retval;
+}
+
+static int usb_port_runtime_suspend(struct device *dev)
+{
+   struct usb_port *port_dev = to_usb_port(dev);
+   struct usb_device *hdev = to_usb_device(dev-parent-parent);
+   struct usb_interface *intf = to_usb_interface(dev-parent);
+   int retval;
+
+   if (dev_pm_qos_flags(port_dev-dev, PM_QOS_FLAG_NO_POWER_OFF)
+   == PM_QOS_FLAGS_ALL)
+   return -EAGAIN;
+
+   usb_autopm_get_interface(intf);
+   retval = usb_hub_set_port_power(hdev, port_dev-portnum, false);
+   usb_autopm_put_interface(intf);
+   return retval;
+}
+#endif
+
+static const struct dev_pm_ops usb_port_pm_ops = {
+#ifdef CONFIG_USB_SUSPEND
+   .runtime_suspend =  usb_port_runtime_suspend,
+   .runtime_resume =   usb_port_runtime_resume,
+   .runtime_idle = 

[PATCH v6 6/8] usb: expose usb port's pm qos flags to user space

2013-01-21 Thread Lan Tianyu
This patch is to expose usb port's pm qos flags(pm_qos_no_power_off,
pm_qos_remote_wakeup) to user space. User can set pm_qos_no_power_off
flag to prohibit the port from being powered off.

Acked-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Lan Tianyu tianyu@intel.com
---
 drivers/usb/core/port.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index dc1aaec..0c51d24 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -67,6 +67,7 @@ static void usb_port_device_release(struct device *dev)
 {
struct usb_port *port_dev = to_usb_port(dev);
 
+   dev_pm_qos_hide_flags(dev);
usb_acpi_unregister_power_resources(dev);
kfree(port_dev);
 }
@@ -176,7 +177,15 @@ int usb_hub_create_port_device(struct usb_hub *hub, int 
port1)
goto error_register;
 
pm_runtime_set_active(port_dev-dev);
-   pm_runtime_enable(port_dev-dev);
+
+   /* It would be dangerous if user space couldn't
+* prevent usb device from being powered off. So don't
+* enable port runtime pm if failed to expose port's pm qos.
+*/
+   if (!dev_pm_qos_expose_flags(port_dev-dev,
+   PM_QOS_FLAG_NO_POWER_OFF))
+   pm_runtime_enable(port_dev-dev);
+
usb_acpi_register_power_resources(port_dev-dev);
 
return 0;
-- 
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 v6 8/8] usb: enable usb port device's async suspend.

2013-01-21 Thread Lan Tianyu
Signed-off-by: Lan Tianyu tianyu@intel.com
---
 drivers/usb/core/port.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 0334d91..50b646e 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -215,7 +215,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int 
port1)
pm_runtime_enable(port_dev-dev);
 
usb_acpi_register_power_resources(port_dev-dev);
-
+   device_enable_async_suspend(port_dev-dev);
return 0;
 
 error_register:
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH v9 0/2] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2013-01-21 Thread Tomasz Figa
On Friday 18 of January 2013 14:30:21 Praveen Paneri wrote:
 Changes from v8:
 Resending this patch series after rebasing to the latest usb-next
 branch. Rewording inline comments for better readability.
 Removed IS_ENABLED(CONFIG_OF) as pdev-dev.of_node is enough to check
 for dt support. Using of_match_ptr to add of_match_table to
 platform_driver structure. Removed unnecessary variables.
 
 Changes from v7:
 Rebased to the latest usb-next branch.
 Separating arch patches from these driver patches.
 
 Changes from v6:
 Modified register definitions according to the existing ones.
 Changed default PHY clk selection for SoCs.
 Improved binding text and rebased to the latest usb-next.
 
 Changes from v5:
 Moved clk_get() to driver's probe function. Now reference clock
 frequency selection value is stored in samsung_usbphy structure for
 later use. Used IS_ENABLED() instead of #ifdef in
 samsung_usbphy_get_driver_data().
 
 Changes from v4:
 Moved header file contents to driver's source file
 Removed unnecessary print message from driver's probe function
 Dropped the Free Software Foundation address from the header
 
 Changes from v3:
 Replaced susbsys_initcall()/module_exit() by module_platform_driver().
 Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
 is registered
 Removed unnecessary devm_usb_put_phy() call from the hsotg driver
 remove.
 
 Changes from v2:
 Changed the driver filenames to samsung-usbphy
 Rectified coding style related errors
 
 Changes from v1:
 Rebased patches to latest usb-next branch
 Changed the name 'sec_usbphy' to 'samsung_usbphy'
 
 This patch set introduces a phy driver for samsung SoCs. It uses the
 existing transceiver infrastructure to provide phy control functions.
 Use of this driver can be extended for usb host phy as well. Over the
 period of time all the phy related code for most of the samsung SoCs
 can be integrated here. Removing the existing phy code from
 mach-s3c64xx. Same can be done for other SoCs when they start
 supporting this phy driver.
 This driver is tested with smdk6410 and Exynos4210(with DT).
 
 Praveen Paneri (2):
   usb: phy: samsung: Introducing usb phy driver for hsotg
   usb: s3c-hsotg: Adding phy driver support
 
  .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
  drivers/usb/gadget/s3c-hsotg.c |   37 ++-
  drivers/usb/phy/Kconfig|8 +
  drivers/usb/phy/Makefile   |1 +
  drivers/usb/phy/samsung-usbphy.c   |  354
  include/linux/platform_data/samsung-usbphy.h  
 |   27 ++
  6 files changed, 428 insertions(+), 10 deletions(-)
  create mode 100644
 Documentation/devicetree/bindings/usb/samsung-usbphy.txt create mode
 100644 drivers/usb/phy/samsung-usbphy.c
  create mode 100644 include/linux/platform_data/samsung-usbphy.h
 
 --
 To unsubscribe from this list: send the line unsubscribe
 linux-samsung-soc in the body of a message to
 majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Tested on Exynos4210-Trats.

Tested-by: Tomasz Figa t.f...@samsung.com

I also have patches for Exynos 4x12, which I will send once this series 
and generic PMU isolation setting patches get merged.

Best regards,
-- 
Tomasz Figa
Samsung Poland RD Center
SW Solution Development, Linux Platform

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 5/6] usb: otg: add device tree support to otg library

2013-01-21 Thread Roger Quadros
On 01/21/2013 03:34 PM, kishon wrote:
 On Monday 21 January 2013 06:51 PM, Roger Quadros wrote:
 On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:
 Added an API devm_usb_get_phy_by_phandle(), to get usb phy by passing a
 device node phandle value. This function will return a pointer to
 the phy on success, -EPROBE_DEFER if there is a device_node for the
 phandle,
 but the phy has not been added, or a ERR_PTR() otherwise.

 Cc: Marc Kleine-Budde m...@pengutronix.de
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
   drivers/usb/otg/otg.c   |   77
 +++
   include/linux/usb/phy.h |8 +
   2 files changed, 85 insertions(+)

 diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
 index dbf2043..e9799bb 100644
 --- a/drivers/usb/otg/otg.c
 +++ b/drivers/usb/otg/otg.c
 @@ -13,7 +13,9 @@
   #include linux/export.h
   #include linux/err.h
   #include linux/device.h
 +#include linux/module.h
   #include linux/slab.h
 +#include linux/of.h

   #include linux/usb/otg.h

 @@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct
 device *dev, u8 index)
   return ERR_PTR(-ENODEV);
   }

 +static struct usb_phy *__of_usb_find_phy(struct device_node *node)
 +{
 +struct usb_phy  *phy;
 +
 +list_for_each_entry(phy, phy_list, head) {
 +if (node != phy-dev-of_node)
 +continue;
 +
 +return phy;
 +}
 +
 +return ERR_PTR(-ENODEV);
 +}
 +
   static void devm_usb_phy_release(struct device *dev, void *res)
   {
   struct usb_phy *phy = *(struct usb_phy **)res;
 @@ -109,6 +125,67 @@ err0:
   }
   EXPORT_SYMBOL(usb_get_phy);

 + /**
 + * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
 + * @dev - device that requests this phy
 + * @phandle - name of the property holding the phy phandle value
 + * @index - the index of the phy
 + *
 + * Returns the phy driver associated with the given phandle value,
 + * after getting a refcount to it, -ENODEV if there is no such phy or
 + * -EPROBE_DEFER if there is a phandle to the phy, but the device is
 + * not yet loaded. While at that, it also associates the device with
 + * the phy using devres. On driver detach, release function is invoked
 + * on the devres data, then, devres data is freed.
 + *
 + * For use by USB host and peripheral drivers.
 + */
 +struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
 +const char *phandle, u8 index)
 +{
 +struct usb_phy*phy = NULL, **ptr;
 +unsigned longflags;
 +struct device_node *node;
 +
 +if (!dev-of_node) {
 +dev_dbg(dev, device does not have a device node entry\n);
 +return ERR_PTR(-EINVAL);
 +}
 +
 +node = of_parse_phandle(dev-of_node, phandle, index);
 +if (!node) {
 +dev_dbg(dev, failed to get %s phandle in %s node\n, phandle,
 +dev-of_node-full_name);
 +return ERR_PTR(-ENODEV);
 +}
 +
 +ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
 +if (!ptr) {
 +dev_dbg(dev, failed to allocate memory for devres\n);
 +return ERR_PTR(-ENOMEM);
 +}

 I fail to understand why you need ptr at all and why do devres_alloc()
 for it.
 
 Thats how we create a managed device resource. You can have a look at
 Documentation/driver-model/devres.txt and drivers/base/devres.c.

OK, I get it now. You might want to update the text file too since you
are adding a automagically managed interface.

regards,
-roger
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot

2013-01-21 Thread Roger Quadros
On 01/21/2013 03:41 PM, kishon wrote:
 Hi,
 
 On Monday 21 January 2013 06:48 PM, Roger Quadros wrote:
 On 01/16/2013 05:01 PM, Kishon Vijay Abraham I wrote:
 The OMAP glue has been modified to get PHY by phandle for dt boot.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
   drivers/usb/musb/omap2430.c |7 ++-
   1 file changed, 6 insertions(+), 1 deletion(-)

 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index 3628a50..08709cf 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -346,7 +346,12 @@ static int omap2430_musb_init(struct musb *musb)
* up through ULPI.  TWL4030-family PMICs include one,
* which needs a driver, drivers aren't always needed.
*/
 -musb-xceiv = devm_usb_get_phy(dev, 0);
 +if (dev-parent-of_node)
 +musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
 +usb_phy, 0);

 Why dev-parent and not just dev?
 
 Right now MUSB core is not converted to dt and hence we don't have
 separate dt node for MUSB core.
 So the PHY information is added to the glue dt data.
 

OK. Got it :).

--
cheers,
-roger


--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net] net: cdc_ncm: workaround for missing CDC Union

2013-01-21 Thread Bjørn Mork
Bjørn Mork bj...@mork.no writes:

 I have another issue with the Sierra firmware which I hope you can help
 me with: The MC7710 device requires at ZLP even if we send
 dwNtbOutMaxSize sized NTBs. This is a problem because the current code
 explicitly prevents this.

If anyone found this more than normally confused, then that is
correct...

What the NCM code does is that it sends a *short* packet whenever the
usbnet would normally have done so, except if the NTP length =
dwNtbOutMaxSize.

The problem is that we do not set 

urb-transfer_flags |= URB_ZERO_PACKET;

either in this special case, resulting in neither a short nor a zero
length packet being sent.  I believe this is what the Sierra firmware
chokes at. This seems to fix the issue, and is IMHO correct:

diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index 42f51c7..3a5673a 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -366,7 +366,7 @@ err:
 
 static const struct driver_info cdc_mbim_info = {
.description = CDC MBIM,
-   .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN,
+   .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN | FLAG_SEND_ZLP,
.bind = cdc_mbim_bind,
.unbind = cdc_mbim_unbind,
.manage_power = cdc_mbim_manage_power,



But I wonder if this isn't really a generic problem in usbnet.  The
FLAG_MULTI_PACKET test here seems completely bogus:

if (length % dev-maxpacket == 0) {
if (!(info-flags  FLAG_SEND_ZLP)) {
if (!(info-flags  FLAG_MULTI_PACKET)) {
urb-transfer_buffer_length++;
if (skb_tailroom(skb)) {
skb-data[skb-len] = 0;
__skb_put(skb, 1);
}
}
} else
urb-transfer_flags |= URB_ZERO_PACKET;
}

Either the FLAG_MULTI_PACKET minidriver will have already padded the
buffer so that we do not hit (length % dev-maxpacket == 0), or we
should choose one of the alternatives: ZLP or padding.

Minidrivers not wanting the short packets (like cdc_ncm) must set
FLAG_SEND_ZLP.


Bjørn
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: musb: core: Add missing newline character

2013-01-21 Thread Kishon Vijay Abraham I
No functional change. Just added a missing newline character.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 drivers/usb/musb/musb_core.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index f1c6c54..c534131 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2301,7 +2301,7 @@ static int __init musb_init(void)
pr_info(%s: version  MUSB_VERSION , 
?dma?
, 
-   otg (peripheral+host),
+   otg (peripheral+host)\n,
musb_driver_name);
return platform_driver_register(musb_driver);
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net] net: cdc_ncm: workaround for missing CDC Union

2013-01-21 Thread Oliver Neukum
On Monday 21 January 2013 15:47:13 Bjørn Mork wrote:
 But I wonder if this isn't really a generic problem in usbnet.  The
 FLAG_MULTI_PACKET test here seems completely bogus:
 
 if (length % dev-maxpacket == 0) {
 if (!(info-flags  FLAG_SEND_ZLP)) {
 if (!(info-flags  FLAG_MULTI_PACKET)) {
 urb-transfer_buffer_length++;
 if (skb_tailroom(skb)) {
 skb-data[skb-len] = 0;
 __skb_put(skb, 1);
 }
 }
 } else
 urb-transfer_flags |= URB_ZERO_PACKET;
 }
 
 Either the FLAG_MULTI_PACKET minidriver will have already padded the
 buffer so that we do not hit (length % dev-maxpacket == 0), or we
 should choose one of the alternatives: ZLP or padding.

But we cannot simply call __skb_put for a complicated data frame.
Besides you may want the current behavior.

Regards
Oliver

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 19/22] ARM: OMAP3: clock data: get rid of unused USB host clock aliases and dummies

2013-01-21 Thread Paul Walmsley
Hi

On Mon, 21 Jan 2013, Roger Quadros wrote:

 On 01/18/2013 10:27 PM, Paul Walmsley wrote:
  On Fri, 18 Jan 2013, Roger Quadros wrote:
  
  We don't need multiple aliases for the OMAP USB host clocks and neither
  the dummy clocks so remove them.
 
  CC: Paul Walmsley p...@pwsan.com
  CC: Rajendra Nayak rna...@ti.com
  CC: Benoit Cousson b-cous...@ti.com
  CC: Mike Turquette mturque...@linaro.com
 
  Signed-off-by: Roger Quadros rog...@ti.com
  Reviewed-by: Felipe Balbi ba...@ti.com
  Acked-by: Paul Walmsley p...@pwsan.com
  
  Per Tony's earlier request, you can drop this patch and patch 20 from your 
  series now.  I've got them queued for 3.10 or late 3.9 merge window.
  
 
 Should have mentioned it earlier, but just this patch without the rest
 of the cleanup patches will break USB Host on OMAP3, as the old driver
 bails out if optional clock nodes are missing.
 
 Including patch 20 doesn't seem to cause a problem with OMAP4 though.

I've got these two patches queued for merging after your other patches go 
upstream -- e.g., probably 3.10.  Do you foresee any problems with that?

- 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: Linux USB file storage gadget with new UDC

2013-01-21 Thread victor yeo
Hi,

   Yes, ep0_complete() is called in UDC driver queue function, i just
   added it in and ep0_complete() is called now. The dmesg output is
   below.
  
   not in queue function, you should call it when completing.
  
 
  Is there any mistake in my understanding of ep0 setup data processing?
 
  1. usb gadget HW IRQ is triggered if ep0 receives data
  2. fsg_setup() is called
  3. ep0_queue() is called
  4. UDC driver queue function is called
  5. UDC driver sends data to ep0 HW buffer
  6. UDC driver increments req-actual by the amount of transferred bytes
  7. UDC driver call ep0_complete()
 
  looks correct
 

 Some progress, now i am able to see the dump_msg from ep0_complete().
 It looks like the enumeration is ok, but the SCSI Inquiry command is
 not received by the UDC driver. The do_scsi_command() in
 fsg_main_thread() is not called. Is this another bug in my UDC driver?

 I would believe so since so many other controllers work just fine.

Is there any way to to further debug into why do_scsi_command() is not called?

thanks,
victor
--
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 net] net: cdc_ncm: workaround for missing CDC Union

2013-01-21 Thread Bjørn Mork
Oliver Neukum oneu...@suse.de writes:
 On Monday 21 January 2013 15:47:13 Bjørn Mork wrote:
 But I wonder if this isn't really a generic problem in usbnet.  The
 FLAG_MULTI_PACKET test here seems completely bogus:
 
 if (length % dev-maxpacket == 0) {
 if (!(info-flags  FLAG_SEND_ZLP)) {
 if (!(info-flags  FLAG_MULTI_PACKET)) {
 urb-transfer_buffer_length++;
 if (skb_tailroom(skb)) {
 skb-data[skb-len] = 0;
 __skb_put(skb, 1);
 }
 }
 } else
 urb-transfer_flags |= URB_ZERO_PACKET;
 }
 
 Either the FLAG_MULTI_PACKET minidriver will have already padded the
 buffer so that we do not hit (length % dev-maxpacket == 0), or we
 should choose one of the alternatives: ZLP or padding.

 But we cannot simply call __skb_put for a complicated data frame.

Agreed.  But I believe the condition should be 

 if (!(info-flags  FLAG_SEND_ZLP)  !(info-flags  FLAG_MULTI_PACKET)) {
 ..
 } else {
 urb-transfer_flags |= URB_ZERO_PACKET;
 }

to ensure that we send the ZLP in this case.

 Besides you may want the current behavior.

Why? Does it ever make sense to prevent both the short packet and the
ZLP?


Bjørn
--
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: Linux USB file storage gadget with new UDC

2013-01-21 Thread Felipe Balbi
On Mon, Jan 21, 2013 at 11:14:19PM +0800, victor yeo wrote:
 Hi,
 
Yes, ep0_complete() is called in UDC driver queue function, i just
added it in and ep0_complete() is called now. The dmesg output is
below.
   
not in queue function, you should call it when completing.
   
  
   Is there any mistake in my understanding of ep0 setup data processing?
  
   1. usb gadget HW IRQ is triggered if ep0 receives data
   2. fsg_setup() is called
   3. ep0_queue() is called
   4. UDC driver queue function is called
   5. UDC driver sends data to ep0 HW buffer
   6. UDC driver increments req-actual by the amount of transferred bytes
   7. UDC driver call ep0_complete()
  
   looks correct
  
 
  Some progress, now i am able to see the dump_msg from ep0_complete().
  It looks like the enumeration is ok, but the SCSI Inquiry command is
  not received by the UDC driver. The do_scsi_command() in
  fsg_main_thread() is not called. Is this another bug in my UDC driver?
 
  I would believe so since so many other controllers work just fine.
 
 Is there any way to to further debug into why do_scsi_command() is not called?

usbmon, printk(), trace_printk(), kernel function tracer, there are many
ways choose one and spend some time debugging, I'm sure you'll find the
bug.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH net 1/3] net: cdc_ncm: workaround for missing CDC Union

2013-01-21 Thread Bjørn Mork
Adding support for the MBIM mode in some Sierra Wireless devices.

Some Sierra Wireless firmwares support CDC MBIM but have no CDC
Union funtional descriptor. This violates the MBIM specification,
but we can easily work around the bug by looking at the Interface
Association Descriptor instead.  This is most likely what
Windows uses too, which explains how the firmware bug has gone
unnoticed until now.

This change will not affect any currently supported device
conforming to the NCM or MBIM specifications, as they must have
the CDC Union descriptor.

Cc: Greg Suarez gsua...@smithmicro.com
Cc: Alexey Orishko alexey.oris...@stericsson.com
Signed-off-by: Bjørn Mork bj...@mork.no
---
 drivers/net/usb/cdc_ncm.c |   27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 71b6e92..4041159 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -344,6 +344,23 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = {
.nway_reset = usbnet_nway_reset,
 };
 
+/* return first slave interface if an IAD matches the given master */
+static struct usb_interface *get_iad_slave(struct usb_device *udev,
+  struct usb_interface *master) {
+   int i;
+   struct usb_interface_assoc_descriptor *iad;
+   u8 mnum = master-cur_altsetting-desc.bInterfaceNumber;
+
+   for (i = 0; i  USB_MAXIADS; i++) {
+   iad = udev-actconfig-intf_assoc[i];
+   if (!iad)
+   break;
+   if (iad-bFirstInterface == mnum  iad-bInterfaceCount == 2)
+   return usb_ifnum_to_if(udev, mnum + 1);
+   }
+   return NULL;
+}
+
 int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 
data_altsetting)
 {
struct cdc_ncm_ctx *ctx;
@@ -435,6 +452,16 @@ advance:
len -= temp;
}
 
+   /* some buggy devices have an IAD but no CDC Union */
+   if (!ctx-union_desc) {
+   dev_dbg(intf-dev, missing CDC Union descriptor\n);
+   ctx-data = get_iad_slave(dev-udev, intf);
+   if (ctx-data) {
+   ctx-control = intf;
+   dev_dbg(intf-dev, got slave from IAD\n);
+   }
+   }
+
/* check if we got everything */
if ((ctx-control == NULL) || (ctx-data == NULL) ||
((!ctx-mbim_desc)  ((ctx-ether_desc == NULL) || (ctx-control 
!= intf
-- 
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


[PATCH net 0/3] cdc_ncm and cdc_mbim fixes for 3.8

2013-01-21 Thread Bjørn Mork
The 2 first patches in this series are required to make the Sierra
Wireless MC7710 card work in MBIM mode.  They may also be
required for other Qualcomm firmware based MBIM devices.

Patch #1 was previously posted as a standalone patch.  This version
is a replacement, removing a theoretical NULL pointer exception. 

Patch #3 fixes a bug I introduced in v3.7

Bjørn Mork (3):
  net: cdc_ncm: workaround for missing CDC Union
  net: cdc_mbim: send ZLP after max sized NTBs
  net: cdc_ncm: fix error path for single interface probing

 drivers/net/usb/cdc_mbim.c |2 +-
 drivers/net/usb/cdc_ncm.c  |   30 +-
 2 files changed, 30 insertions(+), 2 deletions(-)

-- 
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


[PATCH net 3/3] net: cdc_ncm: fix error path for single interface probing

2013-01-21 Thread Bjørn Mork
commit bbc8d92 (net: cdc_ncm: add Huawei devices) implemented
support for devices with a single combined control and data
interface. Fix up the error path so that we do not double
release such interfaces in case of probing failures.

Signed-off-by: Bjørn Mork bj...@mork.no
---
 drivers/net/usb/cdc_ncm.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 4041159..2c4b41f 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -524,7 +524,8 @@ advance:
 error2:
usb_set_intfdata(ctx-control, NULL);
usb_set_intfdata(ctx-data, NULL);
-   usb_driver_release_interface(driver, ctx-data);
+   if (ctx-data != ctx-control)
+   usb_driver_release_interface(driver, ctx-data);
 error:
cdc_ncm_free((struct cdc_ncm_ctx *)dev-data[0]);
dev-data[0] = 0;
-- 
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


[PATCH net 2/3] net: cdc_mbim: send ZLP after max sized NTBs

2013-01-21 Thread Bjørn Mork
We normally avoid sending ZLPs by padding NTBs with a zero byte
if the NTB is shorter than dwNtbOutMaxSize, resulting in a short
USB packet instead of a ZLP.  But in the case where the NTB length
is exactly dwNtbOutMaxSize and this is an exact multiplum of
wMaxPacketSize, then we must send a ZLP.

This fixes an issue seen on a Sierra Wireless MC7710 device
where the transmission would fail whenever we ended up padding
the NTBs to max size.

Signed-off-by: Bjørn Mork bj...@mork.no
---
 drivers/net/usb/cdc_mbim.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index 42f51c7..3a5673a 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -366,7 +366,7 @@ err:
 
 static const struct driver_info cdc_mbim_info = {
.description = CDC MBIM,
-   .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN,
+   .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN | FLAG_SEND_ZLP,
.bind = cdc_mbim_bind,
.unbind = cdc_mbim_unbind,
.manage_power = cdc_mbim_manage_power,
-- 
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: [V4 PATCH 18/26] usb: phy: mv_usb2_phy: add externel chip support

2013-01-21 Thread Russell King - ARM Linux
On Mon, Jan 21, 2013 at 05:07:36AM -0500, Chao Xie wrote:
 + mv_phy-extern_chip.head = devm_kzalloc(pdev-dev,
 + sizeof(*mv_phy-extern_chip.head),
 + GFP_KERNEL);
 + if (mv_phy-extern_chip.head == NULL)
 + return -ENOMEM;
 + ATOMIC_INIT_NOTIFIER_HEAD(mv_phy-extern_chip.head);

Why do you need to allocate an atomic notifier list head as an entirely
separate data structure?
--
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 1/2] usbnet: add new flag FLAG_NOARP for usb net devices

2013-01-21 Thread Wei Shuai
We do have some USB net devices, which cannot do ARP. 
so we can introduce a new flag FLAG_NOARP, then client drivers 
can easily handle this kind of devices


Signed-off-by: Wei Shuai cpuw...@gmail.com
---
 drivers/net/usb/usbnet.c   |4 
 include/linux/usb/usbnet.h |1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 3d4bf01..f34b2eb 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1448,6 +1448,10 @@ usbnet_probe (struct usb_interface *udev, const struct 
usb_device_id *prod)
if ((dev-driver_info-flags  FLAG_WWAN) != 0)
strcpy(net-name, wwan%d);
 
+   /* devices that cannot do ARP */
+   if ((dev-driver_info-flags  FLAG_NOARP) != 0)
+   net-flags |= IFF_NOARP;
+
/* maybe the remote can't receive an Ethernet MTU */
if (net-mtu  (dev-hard_mtu - net-hard_header_len))
net-mtu = dev-hard_mtu - net-hard_header_len;
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index bd45eb7..5de7a22 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -100,6 +100,7 @@ struct driver_info {
 #define FLAG_LINK_INTR 0x0800  /* updates link (carrier) status */
 
 #define FLAG_POINTTOPOINT 0x1000   /* possibly use usb%d names */
+#define FLAG_NOARP 0x2000  /* device can't do ARP */
 
 /*
  * Indicates to usbnet, that USB driver accumulates multiple IP packets.
-- 
1.7.6.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 05/22] mfd: omap-usb-tll: Clean up clock handling

2013-01-21 Thread Russell King - ARM Linux
On Mon, Jan 21, 2013 at 01:04:46PM +0200, Roger Quadros wrote:
 Every channel has a functional clock that is similarly named.
 It makes sense to use a for loop to manage these clocks as OMAPs
 can come with up to 3 channels.
 
 Dynamically allocate and get channel clocks depending on the
 number of clocks avaiable on the platform.
 
 Signed-off-by: Roger Quadros rog...@ti.com
 Reviewed-by: Felipe Balbi ba...@ti.com

Much better from the clk API usage, thanks.

Acked-by: Russell King rmk+ker...@arm.linux.org.uk
--
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 2/2] cdc_ncm: add support FLAG_NOARP for Infineon modem platform

2013-01-21 Thread Wei Shuai
Infineon(now Intel) HSPA Modem platform NCM cannot support ARP.
we can define a new common structure wwan_noarp_info.
Then more similiar NO ARP devices can be handled easily


Signed-off-by: Wei Shuai cpuw...@gmail.com
---
 drivers/net/usb/cdc_ncm.c |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 71b6e92..2d699b6 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1155,6 +1155,20 @@ static const struct driver_info wwan_info = {
.tx_fixup = cdc_ncm_tx_fixup,
 };
 
+/* Same as wwan_info, but with FLAG_NOARP  */
+static const struct driver_info wwan_noarp_info = {
+   .description = Mobile Broadband Network Device (NO ARP),
+   .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
+   | FLAG_WWAN | FLAG_NOARP,
+   .bind = cdc_ncm_bind,
+   .unbind = cdc_ncm_unbind,
+   .check_connect = cdc_ncm_check_connect,
+   .manage_power = usbnet_manage_power,
+   .status = cdc_ncm_status,
+   .rx_fixup = cdc_ncm_rx_fixup,
+   .tx_fixup = cdc_ncm_tx_fixup,
+};
+
 static const struct usb_device_id cdc_devs[] = {
/* Ericsson MBM devices like F5521gw */
{ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
@@ -1194,6 +1208,13 @@ static const struct usb_device_id cdc_devs[] = {
  .driver_info = (unsigned long)wwan_info,
},
 
+   /* Infineon(now Intel) HSPA Modem platform */
+   { USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443,
+   USB_CLASS_COMM,
+   USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
+ .driver_info = (unsigned long)wwan_noarp_info,
+   },
+
/* Generic CDC-NCM devices */
{ USB_INTERFACE_INFO(USB_CLASS_COMM,
USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
-- 
1.7.6.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] drivers/usb/host/uhci-* : check buffer length to avoid memory overflow

2013-01-21 Thread Alan Stern
On Fri, 18 Jan 2013, Greg KH wrote:

 On Sat, Jan 12, 2013 at 11:18:03PM +0800, Chen Gang wrote:
  
for function uhci_sprint_schedule:
  the buffer len is MAX_OUTPUT: 64 * 1024, which may not be enough:
may loop UHCI_NUMFRAMES times (UHCI_NUMFRAMES is 1024)
each time of loop may get more than 64 bytes
  so need check the buffer length to avoid memory overflow
  
this patch fix it like this:
  at first, make enough room for buffering the exceeding contents
  judge the contents which written whether bigger than buffer length
  if bigger (the exceeding contents will be in the exceeding buffer)
break current work flow, and return.
  
also let the const string contents not seperated in second line.
  
  
  
  Signed-off-by: Chen Gang gang.c...@asianux.com
  ---
   drivers/usb/host/uhci-debug.c |  178 
  +++--
   drivers/usb/host/uhci-hcd.c   |   31 ---
   drivers/usb/host/uhci-q.c |2 +-
   3 files changed, 136 insertions(+), 75 deletions(-)
 
 Alan, any objections to me taking this patch?

Gang:

This needs to be broken up into two distinct patches:

One to fix the buffer-overflow problem;

One to get rid of the line breaks in string constants.

Two totally separate goals like these should not be combined into a 
single patch.  Also, why did you change the comment in 
uhci_debug_lseek?

Apart from that, it looks fine.

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] usb: musb: core: Add missing newline character

2013-01-21 Thread Sergei Shtylyov
Hello.

On 01/21/2013 05:52 PM, Kishon Vijay Abraham I wrote:

 No functional change. Just added a missing newline character.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  drivers/usb/musb/musb_core.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
 index f1c6c54..c534131 100644
 --- a/drivers/usb/musb/musb_core.c
 +++ b/drivers/usb/musb/musb_core.c
 @@ -2301,7 +2301,7 @@ static int __init musb_init(void)
   pr_info(%s: version  MUSB_VERSION , 
   ?dma?
   , 
 - otg (peripheral+host),
 + otg (peripheral+host)\n,
   musb_driver_name);
   return platform_driver_register(musb_driver);
  }

   Refresh your tree, alike patch is already upstream. :-)

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


RE: [PATCH net 2/3] net: cdc_mbim: send ZLP after max sized NTBs

2013-01-21 Thread Alexey ORISHKO
 -Original Message-
 From: Bjørn Mork [mailto:bj...@mork.no]
 
 We normally avoid sending ZLPs by padding NTBs with a zero byte if the
 NTB is shorter than dwNtbOutMaxSize, resulting in a short USB packet
 instead of a ZLP.  But in the case where the NTB length is exactly
 dwNtbOutMaxSize and this is an exact multiplum of wMaxPacketSize, then
 we must send a ZLP.
 
 This fixes an issue seen on a Sierra Wireless MC7710 device where the
 transmission would fail whenever we ended up padding the NTBs to max
 size.

If you add ZLP for NTBs of dwNtbOutMaxSize, you are heavily affecting CPU
load, increasing interrupt load by factor of 2 in high load traffic
scenario and possibly decreasing throughput for all other devices
which behaves correctly. 

Why should others pay for Sierra Wireless fault?

At least, do check VID/PID in usbnet and send ZLP only for malfunctioning 
devices.

Regards,
Alexey


Re: [PATCH net 2/3] net: cdc_mbim: send ZLP after max sized NTBs

2013-01-21 Thread Yauheni Kaliuta

Hi, Bjørn!

 BM == Bjørn Mork writes:

  We normally avoid sending ZLPs by padding NTBs with a zero byte
  if the NTB is shorter than dwNtbOutMaxSize, resulting in a short
  USB packet instead of a ZLP.  But in the case where the NTB length
  is exactly dwNtbOutMaxSize and this is an exact multiplum of
  wMaxPacketSize, then we must send a ZLP.

The idea of NCM was to avoid extra ZLPs. If your transfer is exactly
dwNtbOutMaxSize, it's known, you can submit such request on the receiver
side and you do not need any EOT indicatation, so the frametime can be
used for useful data.

I didn't check MBIM specs, but I guess, it wasn't changed. But better get
Alexey's answer for sure.

  This fixes an issue seen on a Sierra Wireless MC7710 device
  where the transmission would fail whenever we ended up padding
  the NTBs to max size.

Is it buggy?

  Signed-off-by: Bjørn Mork bj...@mork.no
  ---
   drivers/net/usb/cdc_mbim.c |2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

  diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
  index 42f51c7..3a5673a 100644
  --- a/drivers/net/usb/cdc_mbim.c
  +++ b/drivers/net/usb/cdc_mbim.c
  @@ -366,7 +366,7 @@ err:
   
   static const struct driver_info cdc_mbim_info = {
   .description = CDC MBIM,
  -.flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN,
  +.flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN | 
  FLAG_SEND_ZLP,
   .bind = cdc_mbim_bind,
   .unbind = cdc_mbim_unbind,
   .manage_power = cdc_mbim_manage_power,
  -- 
  1.7.10.4



-- 
WBR, Yauheni Kaliuta
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

2013-01-21 Thread Greg KH
On Mon, Jan 21, 2013 at 03:37:15AM +, Fangxiaozhi (Franko) wrote:
 Dear Greg:
   
  I get the following errors:
  
  drivers/usb/storage/unusual_devs.h:1530:1: error: implicit declaration of
  function ‘UNUSUAL_VENDOR_INTF’ [-Werror=implicit-function-declaration]
  drivers/usb/storage/unusual_devs.h:1534:3: warning: missing braces around
  initializer [-Wmissing-braces]
  drivers/usb/storage/unusual_devs.h:1534:3: warning: (near initialization for
  ‘us_unusual_dev_list[186]’) [-Wmissing-braces]
  drivers/usb/storage/unusual_devs.h:1534:3: error: initializer element is not
  constant
  drivers/usb/storage/unusual_devs.h:1534:3: error: (near initialization for
  ‘us_unusual_dev_list[186].vendorName’)
  drivers/usb/storage/unusual_devs.h:1537:1: warning: braces around scalar
  initializer [enabled by default]
  
  And it goes on and on...
 --The macro define, please see another patch: 
   [PATCH 1/1]linux-usb:Define a new macro for USB storage match rules
   http://www.spinics.net/lists/linux-usb/msg76629.html

Please resend it, I do not have this patch anymore in my queue.
Remember, I asked you to resend everything that was needed, with the
proper ordering.

Please resend all patches, properly fixed up, that you wish to see
applied.

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: Linux USB file storage gadget with new UDC

2013-01-21 Thread Alan Stern
On Mon, 21 Jan 2013, Felipe Balbi wrote:

 On Mon, Jan 21, 2013 at 11:14:19PM +0800, victor yeo wrote:
  Hi,
  
 Yes, ep0_complete() is called in UDC driver queue function, i just
 added it in and ep0_complete() is called now. The dmesg output is
 below.

 not in queue function, you should call it when completing.

   
Is there any mistake in my understanding of ep0 setup data processing?
   
1. usb gadget HW IRQ is triggered if ep0 receives data
2. fsg_setup() is called
3. ep0_queue() is called
4. UDC driver queue function is called
5. UDC driver sends data to ep0 HW buffer
6. UDC driver increments req-actual by the amount of transferred 
bytes
7. UDC driver call ep0_complete()
   
looks correct
   
  
   Some progress, now i am able to see the dump_msg from ep0_complete().
   It looks like the enumeration is ok, but the SCSI Inquiry command is
   not received by the UDC driver. The do_scsi_command() in
   fsg_main_thread() is not called. Is this another bug in my UDC driver?
  
   I would believe so since so many other controllers work just fine.
  
  Is there any way to to further debug into why do_scsi_command() is not 
  called?
 
 usbmon, printk(), trace_printk(), kernel function tracer, there are many
 ways choose one and spend some time debugging, I'm sure you'll find the
 bug.

It sounds like the UDC driver now works okay for control transfers but 
not for bulk transfers.

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: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

2013-01-21 Thread Greg KH
On Mon, Jan 21, 2013 at 03:41:20AM +, Fangxiaozhi (Franko) wrote:
 Dear Greg:
 
  -Original Message-
  From: Greg KH [mailto:gre...@linuxfoundation.org]
  Sent: Saturday, January 19, 2013 7:42 AM
  To: Fangxiaozhi (Franko)
  Cc: linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org; Xueguiying 
  (Zihan);
  Linlei (Lei Lin); Yili (Neil); Wangyuhua (Roger, Credit); Huqiao (C); 
  ba...@ti.com;
  mdharm-...@one-eyed-alien.net; sebast...@breakpoint.cc
  Subject: Re: USB: storage: optimize the matching rules and support new 
  switch
  command for Huawei USB storage devices
  
  On Mon, Jan 14, 2013 at 10:55:48AM +0800, fangxiaozhi 00110321 wrote:
  
   From: fangxiaozhi huana...@huawei.com
  
   1. Optimize the matching rules with new macro for Huawei USB storage
  devices, to avoid to load USB storage driver for the modem interface
  with Huawei devices.
   2. Add to support new switch command for new Huawei USB dongles.
  
   Signed-off-by: fangxiaozhi huana...@huawei.com
  
  Next time, please always use the scripts/checkpatch.pl tool to find any
  problems you might have made in your patch (you had trailing whitespace in
  this one, which I have fixed.)
  
 -Yes, I have checked my patch with scripts/checkpatch.pl tool before 
 submitting.

Then where did the trailing whitespace come from?

 -For this trailing whitespace error, I think that it is better
 readable to leave whitespace in our patch code. Isn't it?

Not at the end of lines for no reason, right?

Please fix up and resend.

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 29/33] usb: Convert to devm_ioremap_resource()

2013-01-21 Thread Alan Stern
On Mon, 21 Jan 2013, Thierry Reding wrote:

 Convert all uses of devm_request_and_ioremap() to the newly introduced
 devm_ioremap_resource() which provides more consistent error handling.
 
 devm_ioremap_resource() provides its own error messages so all explicit
 error messages can be removed from the failure code paths.
 
 Signed-off-by: Thierry Reding thierry.red...@avionic-design.de
 Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
 Cc: Alan Stern st...@rowland.harvard.edu
 Cc: Felipe Balbi ba...@ti.com
 Cc: linux-usb@vger.kernel.org

For the EHCI and OHCI changes:

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


[PATCH 13/15] USB: ehci: make orion and mxc bus glues coexist

2013-01-21 Thread Arnd Bergmann
In linux-3.8-rc1 it became possible to build the imx and
mvebu platforms together in a single kernel, which clashes
in the ehci driver.

Manjunath Goudar is already working on a patch to convert
both the imx and the mvebu glue drivers (along with all
the other ARM specific ones) to the new probing method,
but that will be too late to fix v3.8. This patch instead
adds yet another hack like the existing ones to allow
the ehci driver to load both back-ends.

Without this patch, building allyesconfig results in:

drivers/usb/host/ehci-hcd.c:1285:0: error: PLATFORM_DRIVER redefined
drivers/usb/host/ehci-hcd.c:1255:0: note: this is the location of the previous 
definition
In file included from drivers/usb/host/ehci-hcd.c:1254:0:
drivers/usb/host/ehci-mxc.c:280:31: warning: 'ehci_mxc_driver' defined but not 
used

Signed-off-by: Arnd Bergmann a...@arndb.de
Cc: Alan Stern st...@rowland.harvard.edu
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: linux-usb@vger.kernel.org
Cc: Manjunath Goudar manjunath.gou...@linaro.org
Cc: Shawn Guo shawn@linaro.org
Cc: Sascha Hauer s.ha...@pengutronix.de
Cc: Jason Cooper ja...@lakedaemon.net
Cc: Andrew Lunn and...@lunn.ch
Cc: Gregory Clement gregory.clem...@free-electrons.com
---
 drivers/usb/host/ehci-hcd.c |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c97503b..92e7180 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1282,7 +1282,7 @@ MODULE_LICENSE (GPL);
 
 #ifdef CONFIG_PLAT_ORION
 #include ehci-orion.c
-#definePLATFORM_DRIVER ehci_orion_driver
+#defineORION_PLATFORM_DRIVER   ehci_orion_driver
 #endif
 
 #ifdef CONFIG_USB_W90X900_EHCI
@@ -1353,6 +1353,7 @@ MODULE_LICENSE (GPL);
 #if !IS_ENABLED(CONFIG_USB_EHCI_PCI)  \
!IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM)  \
!defined(CONFIG_USB_CHIPIDEA_HOST)  \
+   !defined(ORION_PLATFORM_DRIVER)  \
!defined(PLATFORM_DRIVER)  \
!defined(PS3_SYSTEM_BUS_DRIVER)  \
!defined(OF_PLATFORM_DRIVER)  \
@@ -1393,6 +1394,12 @@ static int __init ehci_hcd_init(void)
goto clean0;
 #endif
 
+#ifdef ORION_PLATFORM_DRIVER
+   retval = platform_driver_register(ORION_PLATFORM_DRIVER);
+   if (retval  0)
+   goto clean1;
+#endif
+
 #ifdef PS3_SYSTEM_BUS_DRIVER
retval = ps3_ehci_driver_register(PS3_SYSTEM_BUS_DRIVER);
if (retval  0)
@@ -1424,6 +1431,10 @@ clean3:
ps3_ehci_driver_unregister(PS3_SYSTEM_BUS_DRIVER);
 clean2:
 #endif
+#ifdef ORION_PLATFORM_DRIVER
+   platform_driver_unregister(ORION_PLATFORM_DRIVER);
+clean1:
+#endif
 #ifdef PLATFORM_DRIVER
platform_driver_unregister(PLATFORM_DRIVER);
 clean0:
@@ -1446,6 +1457,9 @@ static void __exit ehci_hcd_cleanup(void)
 #ifdef OF_PLATFORM_DRIVER
platform_driver_unregister(OF_PLATFORM_DRIVER);
 #endif
+#ifdef ORION_PLATFORM_DRIVER
+   platform_driver_unregister(ORION_PLATFORM_DRIVER);
+#endif
 #ifdef PLATFORM_DRIVER
platform_driver_unregister(PLATFORM_DRIVER);
 #endif
-- 
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


[PATCH 00/15] ARM build regressions in v3.8

2013-01-21 Thread Arnd Bergmann
I know this comes late, but we have a number of broken
configurations in ARM in v3.8 that were still building
in v3.7, and I'd like to get them all fixed in the
final 3.8 release.

It would be nice if the respective maintainers could
have a look at these patches and apply them directly
when they are happy with them.

The first patch in the series is strictly speaking
not a build error but just a warning, but it is a
particularly annoying one that came in through the
latest binutils release rather than a kernel change.

The same binutils update also broke the samsung
and w90x900 platforms.

A few of the other changes are the result of the
imx multiplatform conversion. I'm not really fixing
those here, just picking up the pieces. It would
be much nicer if we could actually get those drivers
to work again with CONFIG_MULTIPLATFORM enabled
rather than just disabling them, but it may be
much too late for that. At least the drivers don't
seem to be too essential, as they are only built
in allyesconfig but not in any of the defconfigs.

Arnd

Arnd Bergmann (15):
  ARM: compressed/head.S: work around new binutils warning
  ARM: mvebu: build coherency_ll.S for arch=armv7-a
  ARM: samsung: fix assembly syntax for new gas
  ARM: w90x900: fix legacy assembly syntax
  ASoC: fsl: fiq and dma cannot both be modules
  clk: export __clk_get_name
  drm/exynos: don't include plat/gpio-cfg.h
  drm/exynos: fimd and ipp are broken on multiplatform
  media: coda: don't build on multiplatform
  mfd/vexpress: export vexpress_config_func_{put,get}
  mtd: davinci_nand: fix OF support
  USB: gadget/freescale: disable non-multiplatform drivers
  USB: ehci: make orion and mxc bus glues coexist
  samples/seccomp: be less stupid about cross compiling
  staging/omapdrm: don't build on multiplatform

 arch/arm/boot/compressed/Makefile|2 +-
 arch/arm/boot/compressed/head.S  |   12 
 arch/arm/mach-mvebu/coherency_ll.S   |1 +
 arch/arm/mach-s3c24xx/include/mach/debug-macro.S |   12 ++--
 arch/arm/mach-s3c24xx/include/mach/entry-macro.S |4 ++--
 arch/arm/mach-s3c24xx/pm-h1940.S |2 +-
 arch/arm/mach-s3c24xx/sleep-s3c2410.S|   12 ++--
 arch/arm/mach-s3c24xx/sleep-s3c2412.S|   12 ++--
 arch/arm/mach-w90x900/include/mach/entry-macro.S |4 ++--
 arch/arm/plat-samsung/include/plat/debug-macro.S |   18 +-
 drivers/clk/clk.c|1 +
 drivers/gpu/drm/exynos/Kconfig   |4 ++--
 drivers/gpu/drm/exynos/exynos_hdmi.c |1 -
 drivers/media/platform/Kconfig   |2 +-
 drivers/mfd/vexpress-config.c|3 ++-
 drivers/mtd/nand/davinci_nand.c  |2 +-
 drivers/staging/omapdrm/Kconfig  |2 +-
 drivers/usb/gadget/Kconfig   |3 ++-
 drivers/usb/host/ehci-hcd.c  |   16 +++-
 samples/seccomp/Makefile |2 ++
 sound/soc/fsl/Kconfig|3 +++
 21 files changed, 76 insertions(+), 42 deletions(-)

-- 
1.7.10.4
Cc: Artem Bityutskiy artem.bityuts...@linux.intel.com
Cc: Ben Dooks ben-li...@fluff.org
Cc: David Airlie airl...@linux.ie
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: James Morris james.l.mor...@oracle.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Mauro Carvalho Chehab mche...@redhat.com
Cc: Mike Turquette mturque...@linaro.org
Cc: Rob Clark r...@ti.com
Cc: Russell King rmk+ker...@arm.linux.org.uk
Cc: Shawn Guo shawn@linaro.org
Cc: alsa-de...@alsa-project.org
Cc: dri-de...@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
--
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 net] net: cdc_ncm: workaround for missing CDC Union

2013-01-21 Thread Alexey ORISHKO
 -Original Message-
 From: Oliver Neukum [mailto:oneu...@suse.de]
 On Monday 21 January 2013 15:47:13 Bjørn Mork wrote:
  But I wonder if this isn't really a generic problem in usbnet.  The
  FLAG_MULTI_PACKET test here seems completely bogus:
 
  if (length % dev-maxpacket == 0) {
  if (!(info-flags  FLAG_SEND_ZLP)) {
  if (!(info-flags  FLAG_MULTI_PACKET)) {
  urb-transfer_buffer_length++;
  if (skb_tailroom(skb)) {
  skb-data[skb-len] = 0;
  __skb_put(skb, 1);
  }
  }
  } else
  urb-transfer_flags |= URB_ZERO_PACKET;
  }
 
  Either the FLAG_MULTI_PACKET minidriver will have already padded the
  buffer so that we do not hit (length % dev-maxpacket == 0), or we
  should choose one of the alternatives: ZLP or padding.
 
 But we cannot simply call __skb_put for a complicated data frame.
 Besides you may want the current behavior.
 

Specification says: 
NCM/MBIM shall not send ZLP if buffer size is dwNtbOutMaxSize.

The problem is: 
dwNtbOutMaxSize value is negotiated between host and device NCM/MBIM
entities and usbnet has no knowledge about it.

Adding one byte to make buffer looking like a short packet was most
simple approach instead of inventing a way to communicate 
dwNtbOutMaxSize to usbnet.

You could drop short packet approach if dwNtbOutMaxSize is provided
to usbnet and decision is made accordingly to NCM/MBIM spec (with
exception to faulty devices).

Regards,
Alexey
--
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: xHCI immediately wakes up Asus P8Z68-V LX in S5

2013-01-21 Thread Ben Hutchings
On Mon, Jan 21, 2013 at 09:33:15AM -0800, Sarah Sharp wrote:
 On Mon, Jan 21, 2013 at 12:00:14AM +, Ben Hutchings wrote:
  I finally got enough email out of the way to get back to this:
  
  On Wed, 2012-12-19 at 16:23 -0800, Sarah Sharp wrote:
   On Wed, Dec 19, 2012 at 03:15:09AM +, Ben Hutchings wrote:
  [...]
   The symptoms are pretty bizarre, and I honestly don't know what could be
   the root cause.  I would suggest you try the BIOS update and see if it
   fixes the issue.
  
  Now that I've worked out how to do the update (Asus's Windows utilities
  fail to install, but there turns out to be a flash update program inside
  the setup program) it does seem to be fixed in the current BIOS version
  (version 4003 dated 2012-08-22).  I can't tell for sure whether that's
  because of a code change or a configuration change, because *of course*
  the flash update program has to erase the configuration sector too. :-/
 
 Ok, thanks for letting me know the BIOS update fixed it.
 
Thanks for taking the time to look at this.

Ben.

-- 
Ben Hutchings
We get into the habit of living before acquiring the habit of thinking.
  - Albert Camus
--
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 13/15] USB: ehci: make orion and mxc bus glues coexist

2013-01-21 Thread Felipe Balbi
On Mon, Jan 21, 2013 at 05:16:06PM +, Arnd Bergmann wrote:
 In linux-3.8-rc1 it became possible to build the imx and
 mvebu platforms together in a single kernel, which clashes
 in the ehci driver.
 
 Manjunath Goudar is already working on a patch to convert
 both the imx and the mvebu glue drivers (along with all
 the other ARM specific ones) to the new probing method,
 but that will be too late to fix v3.8. This patch instead
 adds yet another hack like the existing ones to allow
 the ehci driver to load both back-ends.
 
 Without this patch, building allyesconfig results in:
 
 drivers/usb/host/ehci-hcd.c:1285:0: error: PLATFORM_DRIVER redefined
 drivers/usb/host/ehci-hcd.c:1255:0: note: this is the location of the 
 previous definition
 In file included from drivers/usb/host/ehci-hcd.c:1254:0:
 drivers/usb/host/ehci-mxc.c:280:31: warning: 'ehci_mxc_driver' defined but 
 not used
 
 Signed-off-by: Arnd Bergmann a...@arndb.de
 Cc: Alan Stern st...@rowland.harvard.edu
 Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
 Cc: linux-usb@vger.kernel.org
 Cc: Manjunath Goudar manjunath.gou...@linaro.org
 Cc: Shawn Guo shawn@linaro.org
 Cc: Sascha Hauer s.ha...@pengutronix.de
 Cc: Jason Cooper ja...@lakedaemon.net
 Cc: Andrew Lunn and...@lunn.ch
 Cc: Gregory Clement gregory.clem...@free-electrons.com

NAK, should be converted to the new usage of ehci library driver. Alan
Stern already implemented for a few drivers, help is very welcome.

-- 
balbi


signature.asc
Description: Digital signature


  1   2   >