Re: [linux-usb-devel] [PATCH] USB/gadget: PXA27x USB device support

2007-03-04 Thread Richard Purdie
On Fri, 2007-03-02 at 18:47 +0100, Rodolfo Giometti wrote:
 Hello,
 
 here my new proposal for PXA27x USB device support. In this version I
 fixed the power management support (suspend/resume).
 
 As already mentioned in my previous, I know this driver is quite far
 from perfection but, in my opinion, it could be a good starting point
 to add this support into the kernel.
 
 I use the driver from my platform specific file into
 arch/arm/mach-pxa/ by using the following code:

There is some code which might be useful in:

http://www.rpsys.net/openzaurus/patches/usb_add_epalloc-r3.patch
http://www.rpsys.net/openzaurus/patches/usb_pxa27x_udc-r3.patch

In the past I've tried to merge other peoples changes into these to make
one more useful driver but there are known issues with try to merge
either of these into mainline (particularly RNDIS support).

Cheers,

Richard


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] usb: generic calibration support

2006-11-17 Thread Richard Purdie
On Fri, 2006-11-17 at 15:53 +0100, Holger Schurig wrote:
  I believe tslib handles this.
 
 The special X server KDrive supports tslib, this is used in 
 many embedded projects, e.g. by images created via 
 http://www.openembedded.org. But mainline X.org server, e.g. 
 what is in Debian unstable (7.1.0), doesn't support tslib.

Someone should add tslib support to the main xorg server then ;-). All
tslib supported devices will then just work...

 Also I don't know if X/tslib allows re-calibration on-the-fly, 
 but I guess it does. 

It does.

 However, tslib usually does not work via 
 the input subsystem (/dev/input/eventX is just one of them), 
 most devices use proprietary kernel interfaces.

tslib does work via the input subsystem for almost every 2.6 kernel
based device I can think of in OpenEmbedded and we made an active effort
to get into that position. The only proprietary interfaces are old 2.4
kernels.

 Qt/Embedded for Qt 2 and Qt 3 doesn't handle tslib 
 out-of-the-box, (heck, the don't even know 
 about /dev/input/eventX), but patches exist.

Qt/E 2/3 have a ton of other input issues beside this (e.e keymap
problems) so the lack of merged tslib support is only a minor one and as
you say, patches exist.

IMO, calibration in the kernel would be a backwards step (especially
when tslib can do more besides like filtering and hopefully in the
future rescaling).

Regards,

Richard


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] limit power budget on spitz

2006-06-08 Thread Richard Purdie
On Thu, 2006-06-08 at 10:34 +0200, Pavel Machek wrote:
 diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
 index acde886..1d8b58c 100644
 --- a/drivers/usb/host/ohci-pxa27x.c
 +++ b/drivers/usb/host/ohci-pxa27x.c
 @@ -185,6 +185,13 @@ int usb_hcd_pxa27x_probe (const struct h
   /* Select Power Management Mode */
   pxa27x_ohci_select_pmm(inf-port_mode);
  
 + if (machine_is_spitz()) {
 + /* Warning, not coming from any official docs. But
 +  * spitz is unable to properly power wireless card
 +  * claiming 500mA -- usb interface work but wireless
 +  * does not. */
 + hcd-power_budget = 250;
 + }
   ohci_hcd_init(hcd_to_ohci(hcd));
  
   retval = usb_add_hcd(hcd, pdev-resource[1].start, SA_INTERRUPT);

Should this value not be specified by the platform in the platform data
rather than a set of machine_is_xxx statements in the driver itself? I
already put most of the infrastructure for that into place.

I also strongly suspect the power supply on the device is limited to
150mA.

Richard



___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] limit power budget on spitz

2006-06-08 Thread Richard Purdie
Hi,

On Thu, 2006-06-08 at 11:02 +0200, Pavel Machek wrote:
   + if (machine_is_spitz()) {
   + /* Warning, not coming from any official docs. But
   +  * spitz is unable to properly power wireless card
   +  * claiming 500mA -- usb interface work but wireless
   +  * does not. */
   + hcd-power_budget = 250;
   + }
 
  
  Should this value not be specified by the platform in the platform data
  rather than a set of machine_is_xxx statements in the driver itself? I
  already put most of the infrastructure for that into place.
 
 Well, it has quite few users now, and this is how it works in
 ohci-omap. Yes, if we get more of such hooks, it probably needs to be
 moved to platform data...

Just because the omap does it that way, doesn't mean it can't be done
better ;-). I've also just realised the above doesn't account for akita
or borzoi. Since the hardware is identical in this area, the same
changes should be applied for those machines. If we use the platform
device/data approach, we don't have this problem as they all use the
same platform device :)

I can't create a patch at the moment but I can have a look at this
later...

Cheers,

Richard



___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] limit power budget on spitz

2006-06-08 Thread Richard Purdie
On Thu, 2006-06-08 at 11:26 -0700, David Brownell wrote:
 On Thu, Jun 08, 2006 at 10:22:50AM +0100, Richard Purdie wrote:
  Just because the omap does it that way, doesn't mean it can't be done
  better ;-).
 
 Agreed that platform_data is a better approach overall for holding that
 power budget.  OMAP and AT91 should do so too.

 Sounds like someone should update the patch to (a) use a 150 mA budget,
 and (b) test for those other machines.  As a near term patch, anyway.
 
 Unless there's a patch to provide and use platform_data ... but that'd
 be much more involved, since ISTR the PXA platforms don't yet have a
 mechanism to provide board-specific platform_data.  (I'll suggest the
 AT91 code as a model there; it's simpler hardware than OMAP, so the
 code is more straightforward.)

The PXA platform does have an existing mechanism to pass platform data
(I added it a while back). I've added
http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=3547/1
into the patch system replacing Pavel's version.

Cheers,

Richard



___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] limit power budget on spitz

2006-06-08 Thread Richard Purdie
On Thu, 2006-06-08 at 13:38 -0700, David Brownell wrote: 
  http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=3547/1
 
 OK, I see now.  Simple enough, better than the original.  Go for it.
 
 There was a PXA issue I was alluding to that's still open, though.
 It's the way there's no selectivity about what platform devices are
 registered ... even kernels running on boards where OHCI isn't hooked
 up to anything will be registering an OHCI controller, as one of many
 examples.  Won't affect this particular case, but in general that'd
 be nice to see fixed.

As I understood the code, if you don't have platform_data set, it will
abort in the probe function so it depends what you mean by register. An
OHCI controller never gets created without platform_data.

You're right that the PXA platform device is always registered. FWIW,
there is no platform in mainline that doesn't have OHCI present so this
isn't a major problem at the moment.

The easiest solution might be to move the ohci device registration into
pxa_set_ohci_info (in pxa27x.c). I gave in and appended a patch (compile
tested only so far).

Cheers,

Richard


Only register the PXA OHCI platform device on platforms which provide
the platform data.

Signed-off-by: Richard Purdie [EMAIL PROTECTED]

Index: git/arch/arm/mach-pxa/pxa27x.c
===
--- git.orig/arch/arm/mach-pxa/pxa27x.c 2006-06-08 20:50:15.0 +0100
+++ git/arch/arm/mach-pxa/pxa27x.c  2006-06-08 22:08:49.0 +0100
@@ -200,15 +200,5 @@
 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
 {
ohci_device.dev.platform_data = info;
+   platform_device_register(ohci_device);
 }
-
-static struct platform_device *devices[] __initdata = {
-   ohci_device,
-};
-
-static int __init pxa27x_init(void)
-{
-   return platform_add_devices(devices, ARRAY_SIZE(devices));
-}
-
-subsys_initcall(pxa27x_init);




___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] [PATCH] limit power budget on spitz

2006-06-08 Thread Richard Purdie
On Thu, 2006-06-08 at 14:40 -0700, David Brownell wrote:
 Right.  OHCI was just an example though ... there are lots of other
 platform drivers for PXA.  I'm not sure they all check for platform_data
 before succeeding in their probe() methods.

The implementations in mainline generally use all the bits or they'd
have been fixed by now so its not really a problem. I'm sure Russell
would take patches :)

  The easiest solution might be to move the ohci device registration into
  pxa_set_ohci_info (in pxa27x.c). I gave in and appended a patch (compile
  tested only so far).
 
 Looked OK to me.
 
 That's the kind of approach now used with OMAP and AT91, and which IMO
 would be appropriate to use for most platform devices ... that is, don't
 register devices that the board doesn't have.  One additional nuance:  if
 the kernel doesn't have that driver configured, that's another reason not
 to bother registering its device.

This is where you start to add ugly ifdefs and generally start making
the code look horrible. The device model separated the drivers and the
devices to deal with this issue as I see it. Generally I'd say its
cleaner just to let the device register, then if a module comes along at
some later point, the device is there for it.

Cheers,

Richard



___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


[linux-usb-devel] Progress on the pxa27x UDC Driver + RNDIS problem

2006-01-02 Thread Richard Purdie
I've done some work on the pxa27x UDC driver which may be of interest to
others. I have CDC-Ethernet running but can't get RNDIS to work (fresh
pairs of eyes would be welcome).

The patches:

http://projects.o-hand.com/hx2750/patches/usb_add_epalloc-r1.patch

provides usb_ep_autoconfig() with more information about the
configuration, interface and altinterface combinations any particular
endpoint might take. This is unfortunately necessary to correctly setup
the pxa27x (see below). 

usb_ep_autoconfig can then optionally call a driver provided
configuration function (ops-ep_alloc) instead of using its
autoconfigure logic. This shouldn't change any existing behaviour and
reading the comments in that function, it looks like such a function was
already envisaged? Comments would be welcome on any better way of doing
this.

http://projects.o-hand.com/hx2750/patches/usb_pxa27x_udc-r0.patch

is the pxa27x driver itself. I've taken the one from handhelds.org and
made changes to get full CDC-Ethernet running with it instead of
CDC-Subset by handling the pxa27x specific configuration issues
properly. I've also started the process of cleaning up the style a bit
although there's still a way to go. This patch is now being used in the
Zaurus kernel tree and there are a couple of Zaurus specific lines of
code in there which can easily be abstracted to the platform data.

The tricky problem with the pxa27x is that it has 24 endpoints, each of
one of which can only be active for one configuration, interface and
altinterface combination. The driver therefore maps multiple pxa
endpoints to one linux usb_ep structure and this is why the above
interface details are required. Once pxa27x controller is enabled, you
can't change these numbers...

g_zero is known to work with this driver and tests with usbtest.c only
fail on test 11 (count  1 on double stalls). g_serial and g_filestore
haven't been tested yet.

RNDIS Issues

As mentioned above, CDC-Ether works fine. If an RNDIS connection is
attempted, the controller receives an RNDIS request and queues an RNDIS
RESPONSE_AVAILABLE message via the status (interrupt) endpoint. The
host never appears to actually transfer this message across the wire
though as the controller never informs the transfer was completed.
Whether the host knows the message is waiting on the status ep is
unknown and I lack the hardware to check this.

Having tried many different things to try and provoke this transfer, I'm
at a loss as to why it doesn't work. Perhaps a fresh pair of eyes
looking at it might spot something.

I was slightly concerned that the data endpoints on interface 1 get
activated whilst interface=0 and data gets queued against them
prematurely as this could have been upsetting the controller. I changed
this locally to match the CDC-ether method of waiting for the
SET_INTERFACE command and it made no difference to the above problem
though (something like
http://projects.o-hand.com/hx2750/patches/usb_rndis_tweaks-r0.patch ). 

Any collaboration on improving this code would be welcome. I'd also be
interested in a rough indication as to what needs doing to the driver
itself before it can be merged into mainline linux. At a minimum I
suspect it needs:

1. Coding style changes to be completed / code cleanup (removal of
pxa25x related comments)
2. Proper abstraction of device specifics (mainly UP2OCR handling)
3. Proper pull up handling (again UP20CR handling)
4. Perhaps some kind of interfacing with the pxa27x ohci_hcd (is there
some similar code for the omap udc?)

Anything else?

Regards,

Richard




---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637alloc_id=16865op=click
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


[linux-usb-devel] [patch] OHCI lh7a404 platform device conversion fixup

2005-11-14 Thread Richard Purdie
Fix an error in the OHCI lh7a404 driver after the platform device
conversion.

Signed-off-by: Richard Purdie [EMAIL PROTECTED]

Index: linux-2.6.15-rc1/drivers/usb/host/ohci-lh7a404.c
===
--- linux-2.6.15-rc1.orig/drivers/usb/host/ohci-lh7a404.c   2005-11-12 
01:43:36.0 +
+++ linux-2.6.15-rc1/drivers/usb/host/ohci-lh7a404.c2005-11-14 
17:41:14.0 +
@@ -219,7 +219,7 @@
 
 static int ohci_hcd_lh7a404_drv_remove(struct platform_device *pdev)
 {
-   struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct usb_hcd *hcd = platform_get_drvdata(pdev);
 
usb_hcd_lh7a404_remove(hcd, pdev);
return 0;




---
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42 plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


[linux-usb-devel] [patch] dummy_hcd platform device conversion fixup

2005-11-12 Thread Richard Purdie
Fix an error in dummy_hcd after the platform device conversion.

Signed-off-by: Richard Purdie [EMAIL PROTECTED]

Index: linux-2.6.14/drivers/usb/gadget/dummy_hcd.c
===
--- linux-2.6.14.orig/drivers/usb/gadget/dummy_hcd.c2005-11-12 
10:55:38.0 +
+++ linux-2.6.14/drivers/usb/gadget/dummy_hcd.c 2005-11-12 12:14:25.0 
+
@@ -944,7 +944,7 @@
set_link_state (dum);
spin_unlock_irq (dum-lock);
 
-   dev-power.power_state = state;
+   dev-dev.power.power_state = state;
usb_hcd_poll_rh_status (dummy_to_hcd (dum));
return 0;
 }
@@ -1904,7 +1904,7 @@
struct usb_hcd  *hcd;
int retval;
 
-   dev_info (dev, %s, driver  DRIVER_VERSION \n, driver_desc);
+   dev_info (dev-dev, %s, driver  DRIVER_VERSION \n, driver_desc);
 
hcd = usb_create_hcd (dummy_hcd, dev-dev, dev-dev.bus_id);
if (!hcd)



---
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42 plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


[linux-usb-devel] [PATCH 0/1] pxa27x ohci updates

2005-10-30 Thread Richard Purdie
Two patches follow which update the pxa27x OHCI host controller driver.
The first has been seen before and approved by various people but never
made it to Greg. I've rediffed it against latest git after the recent
merging.

The second adds PM functions to the driver. Todd originally submitted a
patch to do this but after the recent usb changes, it needed totally
rewriting which I've done, basing it on the omap ohci code. Dave: If you
could sanity check this and ack it, I'd appreciate it.

Both have been tested on the Zaurus SL-C3000 (Spitz) and make the driver
much more usable.

I have a patch for platform support for OHCI on the C3000 (similar to
the mainstone code) but I'll pass this through Russell King once these
are applied as there are several other patches for spitz.c floating
around the system.

Cheers,

Richard



---
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


[linux-usb-devel] [PATCH 2/2] Add pxa27x OHCI PM functions

2005-10-30 Thread Richard Purdie
Add power management functions for the pxa27x USB OHCI host controller.
This is a totally rewritten version of the patch by Nicolas Pitre and
Todd Poynor which accounts for recent USB changes.

Signed-off-by: Richard Purdie

Index: git/drivers/usb/host/ohci-pxa27x.c
===
--- git.orig/drivers/usb/host/ohci-pxa27x.c 2005-10-30 11:26:52.0 
+
+++ git/drivers/usb/host/ohci-pxa27x.c  2005-10-30 12:11:18.0 +
@@ -310,23 +310,40 @@
return 0;
 }
 
+#ifdef CONFIG_PM
 static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state)
 {
-// struct platform_device *pdev = to_platform_device(dev);
-// struct usb_hcd *hcd = dev_get_drvdata(dev);
-   printk(%s: not implemented yet\n, __FUNCTION__);
+   struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev));
+
+   if (time_before(jiffies, ohci-next_statechange))
+   msleep(5);
+   ohci-next_statechange = jiffies;
+
+   pxa27x_stop_hc(dev);
+   ohci_to_hcd(ohci)-state = HC_STATE_SUSPENDED;
+   dev-power.power_state = PMSG_SUSPEND;
 
return 0;
 }
 
 static int ohci_hcd_pxa27x_drv_resume(struct device *dev)
 {
-// struct platform_device *pdev = to_platform_device(dev);
-// struct usb_hcd *hcd = dev_get_drvdata(dev);
-   printk(%s: not implemented yet\n, __FUNCTION__);
+   struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev));
+   int status;
+
+   if (time_before(jiffies, ohci-next_statechange))
+   msleep(5);
+   ohci-next_statechange = jiffies;
+
+   if ((status = pxa27x_start_hc(dev))  0)
+   return status;
+
+   dev-power.power_state = PMSG_ON;
+   usb_hcd_resume_root_hub(dev_get_drvdata(dev));
 
return 0;
 }
+#endif
 
 
 static struct device_driver ohci_hcd_pxa27x_driver = {
@@ -334,8 +351,10 @@
.bus= platform_bus_type,
.probe  = ohci_hcd_pxa27x_drv_probe,
.remove = ohci_hcd_pxa27x_drv_remove,
+#ifdef CONFIG_PM
.suspend= ohci_hcd_pxa27x_drv_suspend, 
.resume = ohci_hcd_pxa27x_drv_resume, 
+#endif
 };
 
 static int __init ohci_hcd_pxa27x_init (void)




---
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


[linux-usb-devel] [PATCH 1/2] pxa27x OHCI - Separate platform code from main driver

2005-10-30 Thread Richard Purdie
To allow multiple platforms to use the PXA27x OHCI driver, the platform
code needs to be moved into the board specific files in
arch/arm/mach-pxa. This patch does this for mainstone and adds
preliminary hooks to allow other boards to use the driver.

This has been compile tested for mainstone and successfully run on Spitz
(Sharp Zaurus SL-C3000) with the addition of an appropriate board
support file.

Signed-off-by: Richard Purdie [EMAIL PROTECTED]
Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]
Acked-by: David Brownell [EMAIL PROTECTED]

Index: git/drivers/usb/host/ohci-pxa27x.c
===
--- git.orig/drivers/usb/host/ohci-pxa27x.c 2005-10-30 10:57:02.0 
+
+++ git/drivers/usb/host/ohci-pxa27x.c  2005-10-30 11:08:11.0 +
@@ -23,18 +23,12 @@
 #include asm/mach-types.h
 #include asm/hardware.h
 #include asm/arch/pxa-regs.h
-
-
-#define PMM_NPS_MODE   1
-#define PMM_GLOBAL_MODE2
-#define PMM_PERPORT_MODE   3
+#include asm/arch/ohci.h
 
 #define PXA_UHC_MAX_PORTNUM3
 
 #define UHCRHPS(x)  __REG2( 0x4C50, (x)2 )
 
-static int pxa27x_ohci_pmm_state;
-
 /*
   PMM_NPS_MODE -- PMM Non-power switching mode
   Ports are powered continuously.
@@ -47,8 +41,6 @@
  */
 static int pxa27x_ohci_select_pmm( int mode )
 {
-   pxa27x_ohci_pmm_state = mode;
-
switch ( mode ) {
case PMM_NPS_MODE:
UHCRHDA |= RH_A_NPS;
@@ -68,7 +60,6 @@
Invalid mode %d, set to non-power switch mode.\n, 
mode );
 
-   pxa27x_ohci_pmm_state = PMM_NPS_MODE;
UHCRHDA |= RH_A_NPS;
}
 
@@ -79,8 +70,13 @@
 
 /*-*/
 
-static void pxa27x_start_hc(struct platform_device *dev)
+static int pxa27x_start_hc(struct device *dev)
 {
+   int retval = 0;
+   struct pxaohci_platform_data *inf;
+
+   inf = dev-platform_data;
+
pxa_set_cken(CKEN10_USBHOST, 1);
 
UHCHR |= UHCHR_FHR;
@@ -91,21 +87,11 @@
while (UHCHR  UHCHR_FSBIR)
cpu_relax();
 
-   /* This could be properly abstracted away through the
-  device data the day more machines are supported and
-  their differences can be figured out correctly. */
-   if (machine_is_mainstone()) {
-   /* setup Port1 GPIO pin. */
-   pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN);  /* USBHPWR1 */
-   pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */
-
-   /* Set the Power Control Polarity Low and Power Sense
-  Polarity Low to active low. Supply power to USB ports. */
-   UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) 
-   ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
+   if (inf-init)
+   retval = inf-init(dev);
 
-   pxa27x_ohci_pmm_state = PMM_PERPORT_MODE;
-   }
+   if (retval  0)
+   return retval;
 
UHCHR = ~UHCHR_SSE;
 
@@ -114,10 +100,19 @@
/* Clear any OTG Pin Hold */
if (PSSR  PSSR_OTGPH)
PSSR |= PSSR_OTGPH;
+
+   return 0;
 }
 
-static void pxa27x_stop_hc(struct platform_device *dev)
+static void pxa27x_stop_hc(struct device *dev)
 {
+   struct pxaohci_platform_data *inf;
+
+   inf = dev-platform_data;
+
+   if (inf-exit)
+   inf-exit(dev);
+
UHCHR |= UHCHR_FHR;
udelay(11);
UHCHR = ~UHCHR_FHR;
@@ -144,22 +139,28 @@
  * through the hotplug entry's driver_data.
  *
  */
-int usb_hcd_pxa27x_probe (const struct hc_driver *driver,
- struct platform_device *dev)
+int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct device *dev)
 {
int retval;
struct usb_hcd *hcd;
+   struct pxaohci_platform_data *inf;
+   struct platform_device *pdev = to_platform_device(dev);
+
+   inf = dev-platform_data;
+
+   if (!inf)
+   return -ENODEV;
 
-   if (dev-resource[1].flags != IORESOURCE_IRQ) {
+   if (pdev-resource[1].flags != IORESOURCE_IRQ) {
pr_debug (resource[1] is not IORESOURCE_IRQ);
return -ENOMEM;
}
 
-   hcd = usb_create_hcd (driver, dev-dev, pxa27x);
+   hcd = usb_create_hcd (driver, dev, pxa27x);
if (!hcd)
return -ENOMEM;
-   hcd-rsrc_start = dev-resource[0].start;
-   hcd-rsrc_len = dev-resource[0].end - dev-resource[0].start + 1;
+   hcd-rsrc_start = pdev-resource[0].start;
+   hcd-rsrc_len = pdev-resource[0].end - pdev-resource[0].start + 1;
 
if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
pr_debug(request_mem_region failed);
@@ -174,18 +175,22 @@
goto err2;
}
 
-   pxa27x_start_hc(dev);
+   if ((retval = pxa27x_start_hc(dev))  0) {
+   pr_debug

[linux-usb-devel] [patch] fix pxa2xx_udc compile warnings

2005-09-14 Thread Richard Purdie
I saw this when compiling the pxa25x_udc driver in the lastest linus git
kernel. I've included a patch below as one way of cleaning this up.

  CC  drivers/usb/gadget/pxa2xx_udc.o
drivers/usb/gadget/pxa2xx_udc.c: In function `write_ep0_fifo':
drivers/usb/gadget/pxa2xx_udc.c:532: warning: passing arg 1 of `write_packet' 
from incompatible pointer type
drivers/usb/gadget/pxa2xx_udc.c: At top level:
drivers/usb/gadget/pxa2xx_udc.c:2175: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2176: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2190: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2191: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2204: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2205: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2206: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2220: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2221: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2234: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2235: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2236: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2249: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2250: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2264: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2265: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2278: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2279: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2280: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2293: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2294: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2307: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2308: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2309: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2322: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2323: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2337: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2338: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2351: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2352: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2353: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2366: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2367: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2380: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2381: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2382: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2395: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2396: warning: initialization from incompatible 
pointer type
drivers/usb/gadget/pxa2xx_udc.c:2639: warning: initialization from incompatible 
pointer type
  LD  drivers/usb/gadget/built-in.o


This patch fixes several types in the PXA25x udc driver and hence fixes
several compiler warnings.

Signed-Off-By: Richard Purdie [EMAIL PROTECTED]

Index: git/drivers/usb/gadget/pxa2xx_udc.c
===
--- git.orig/drivers/usb/gadget/pxa2xx_udc.c2005-09-14 10:08:27.0 
+0100
+++ git/drivers/usb/gadget/pxa2xx_udc.c 2005-09-14 15:44:47.0 +0100
@@ -422,7 +422,7 @@
 }
 
 static int
-write_packet(volatile u32 *uddr, struct pxa2xx_request *req, unsigned max)
+write_packet(volatile unsigned long *uddr, struct pxa2xx_request *req, 
unsigned max)
 {
u8  *buf;
unsignedlength, count;
@@ -2602,7 +2602,7 @@
  * VBUS IRQs should probably be ignored so that the PXA device just acts
  * dead to USB hosts until system resume.
  */
-static int pxa2xx_udc_suspend(struct device *dev

[linux-usb-devel] [rediffed patch] USB PXA-27x OHCI Separate platform code from main driver

2005-09-13 Thread Richard Purdie
To allow multiple platforms to use the PXA27x OHCI driver, the platform
code needs to be moved into the board specific files in
arch/arm/mach-pxa. This patch does this for mainstone and adds
preliminary hooks to allow other boards to use the driver.

This has been compile tested for mainstone and successfully run on Spitz
(Sharp Zaurus SL-C3000) with the addition of an appropriate board
support file.

Signed-Off-By: Richard Purdie [EMAIL PROTECTED]
Signed-off-by: Nicolas Pitre [EMAIL PROTECTED]

Index: linux-2.6.13/drivers/usb/host/ohci-pxa27x.c
===
--- linux-2.6.13.orig/drivers/usb/host/ohci-pxa27x.c2005-09-13 
16:38:45.0 +0100
+++ linux-2.6.13/drivers/usb/host/ohci-pxa27x.c 2005-09-13 16:39:13.0 
+0100
@@ -23,18 +23,12 @@
 #include asm/mach-types.h
 #include asm/hardware.h
 #include asm/arch/pxa-regs.h
-
-
-#define PMM_NPS_MODE   1
-#define PMM_GLOBAL_MODE2
-#define PMM_PERPORT_MODE   3
+#include asm/arch/ohci.h
 
 #define PXA_UHC_MAX_PORTNUM3
 
 #define UHCRHPS(x)  __REG2( 0x4C50, (x)2 )
 
-static int pxa27x_ohci_pmm_state;
-
 /*
   PMM_NPS_MODE -- PMM Non-power switching mode
   Ports are powered continuously.
@@ -47,8 +41,6 @@
  */
 static int pxa27x_ohci_select_pmm( int mode )
 {
-   pxa27x_ohci_pmm_state = mode;
-
switch ( mode ) {
case PMM_NPS_MODE:
UHCRHDA |= RH_A_NPS;
@@ -68,7 +60,6 @@
Invalid mode %d, set to non-power switch mode.\n, 
mode );
 
-   pxa27x_ohci_pmm_state = PMM_NPS_MODE;
UHCRHDA |= RH_A_NPS;
}
 
@@ -79,8 +70,13 @@
 
 /*-*/
 
-static void pxa27x_start_hc(struct platform_device *dev)
+static int pxa27x_start_hc(struct device *dev)
 {
+   int retval = 0;
+   struct pxaohci_platform_data *inf;
+
+   inf = dev-platform_data;
+
pxa_set_cken(CKEN10_USBHOST, 1);
 
UHCHR |= UHCHR_FHR;
@@ -91,21 +87,11 @@
while (UHCHR  UHCHR_FSBIR)
cpu_relax();
 
-   /* This could be properly abstracted away through the
-  device data the day more machines are supported and
-  their differences can be figured out correctly. */
-   if (machine_is_mainstone()) {
-   /* setup Port1 GPIO pin. */
-   pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN);  /* USBHPWR1 */
-   pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */
-
-   /* Set the Power Control Polarity Low and Power Sense
-  Polarity Low to active low. Supply power to USB ports. */
-   UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) 
-   ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
+   if (inf-init)
+   retval = inf-init(dev);
 
-   pxa27x_ohci_pmm_state = PMM_PERPORT_MODE;
-   }
+   if (retval  0)
+   return retval;
 
UHCHR = ~UHCHR_SSE;
 
@@ -114,10 +100,19 @@
/* Clear any OTG Pin Hold */
if (PSSR  PSSR_OTGPH)
PSSR |= PSSR_OTGPH;
+
+   return 0;
 }
 
-static void pxa27x_stop_hc(struct platform_device *dev)
+static void pxa27x_stop_hc(struct device *dev)
 {
+   struct pxaohci_platform_data *inf;
+
+   inf = dev-platform_data;
+
+   if (inf-exit)
+   inf-exit(dev);
+
UHCHR |= UHCHR_FHR;
udelay(11);
UHCHR = ~UHCHR_FHR;
@@ -144,22 +139,28 @@
  * through the hotplug entry's driver_data.
  *
  */
-int usb_hcd_pxa27x_probe (const struct hc_driver *driver,
- struct platform_device *dev)
+int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct device *dev)
 {
int retval;
struct usb_hcd *hcd;
+   struct pxaohci_platform_data *inf;
+   struct platform_device *pdev = to_platform_device(dev);
+
+   inf = dev-platform_data;
+
+   if (!inf)
+   return -ENODEV;
 
-   if (dev-resource[1].flags != IORESOURCE_IRQ) {
+   if (pdev-resource[1].flags != IORESOURCE_IRQ) {
pr_debug (resource[1] is not IORESOURCE_IRQ);
return -ENOMEM;
}
 
-   hcd = usb_create_hcd (driver, dev-dev, pxa27x);
+   hcd = usb_create_hcd (driver, dev, pxa27x);
if (!hcd)
return -ENOMEM;
-   hcd-rsrc_start = dev-resource[0].start;
-   hcd-rsrc_len = dev-resource[0].end - dev-resource[0].start + 1;
+   hcd-rsrc_start = pdev-resource[0].start;
+   hcd-rsrc_len = pdev-resource[0].end - pdev-resource[0].start + 1;
 
if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
pr_debug(request_mem_region failed);
@@ -174,18 +175,22 @@
goto err2;
}
 
-   pxa27x_start_hc(dev);
+   if ((retval = pxa27x_start_hc(dev))  0) {
+   pr_debug(pxa27x_start_hc

[linux-usb-devel] Re: [rediffed patch] USB PXA-27x OHCI Separate platform code from main driver

2005-09-13 Thread Richard Purdie
On Tue, 2005-09-13 at 12:15 -0700, David Brownell wrote:
 Looks OK to me ... except for one minor point, that I'd prefer not
 to see platform devices registered on boards that don't support them.
 In such cases they're just a waste of memory.  Wasting a KByte here
 and there does start to add up.
 
 For one reason or another, that's not the convention that seems to
 be used on the PXA hardware.

Personally I totally agree but that really needs to be discussed on
linux-arm-kernel with the other PXA developers. I know several people
with several different problems all related to the way the pxa device
structures are defined and registered.

I will be trying to address those issues in due course, probably by
replacing the pxa_set_ohci_info() function (and similar for the pxafb
etc.) with a call returning the struct device which the board can do
with as it pleases. This needs to be done in a different patch though.

Can we apply this patch on that basis?

Richard



---
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42 plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


Re: [linux-usb-devel] PXA27x OHCI Driver RFC

2005-08-25 Thread Richard Purdie
On Wed, 2005-08-24 at 14:42 -0700, David Brownell wrote:
 What I'd like to do is have NDP used only in ohci_hub_status()
 (e.g. the workaround for those early AMD-756 chips) and have the
 rest of the driver reference some field in struct ohci_hcd which
 is initialized by OHCI core code -- iff it starts as zero.
 
 That way chip (and board) specific logic could initialize that
 field to address quirks like this one.  (Another example would
 be the AT91rm9200.  PQFP packages have fewer pins than the BGA
 ones, and one sacrifice was pins for the second OHCI port.)
 
 That'd get rid of the ugly #ifdef CONFIG_PXA27x in the core
 code, which will break for folk doing marginally perverse stuff
 like tacking a PCI bridge on the external bus to get EHCI and
 maybe other things.
 
 Feel like spinning a patch that looks like that?

This email will be followed by a patch along these lines. The one thing
I'm unsure of is the point at which you can read the NDP value. I've
done this in ohci_init and found it didn't seem to be required in
ohci_hub_status. See what you think...

 Not sure ...  there's no guarantee the board designer has
 wired up the relevant USBHPEN (power enable) bits.  Though
 if they do, you ought to be right about not needing special
 case logic there.  Most embedded OHCI chips seem to expect
 those issues to be handled by GPIO pins; PXA 27x is a bit
 atypical in dedicating such bits.

They are GPIO pins but on the pxa27x, gpios have alternate functions and
the USBHPEN/USBPWR pins fall into that category. As long as the pin is
set to be a normal GPIO instead of an alternate function, it doesn't
matter what state its set to by the ohci controller as it will have no
effect on external circuitry. As an example, those pins on spitz have
completely different uses which are not USB related. Mainstone uses the
pins so it calls pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN) to set then to
their alternate functions.

With this in mind, I see no reason for the power control code in the
driver. The second patch attached starts to tidy it up. Its incorrect
anyway.

 It'd be the USB hub driver that drives power switching, in
 whatever mode the chip supports.   Sometimes that maps to
 a direct hardware request -- usual on PCs, and in this case
 the PXA 27x supports it -- but on embedded hardware that
 seems to be more typically handled with GPIOs instead of
 the root hub port power bits.

On spitz, we have one power gpio (not connected into the ohci logic or
the dedicated alternate functions) controlling power to port 2 which is
the only one used. Sharp's 2.4 code just sets the power gpio before
loading the ohci driver.

Is there a way we can have platform code load the ohci driver and power
up the port when it detects a device and shutdown otherwise? Reading the
link you gave me, it mentions switching the initialisation model for
ohci so I'll have to look at that.

 Ideally that would be recorded in the dev-platform_data field; yes,
 that stuff should be board-specific.

 Again, overcurrent support (or lack thereof) is board specific.
 (Maybe the board doesn't have pins to spare for such a signal
 going to the CPU...)

I'm also sending a patch to move the existing mainstone code into the
platform file (arch/arm/mach-pxa/mainstone.c) and add hooks other
platforms such as spitz can use. I've tested this series of patches on
spitz and they work. I've only compiled mainstone.

  There is logic to go into the board support file to control switching
  between host and udc mode. I think my hardware might support detection
  of the mode but I'm not sure how it will be possible to switch between
  the two drivers...
 
 You think it might?  That'd surprise me.  But one way to test is to
 see whether both Mini-A and Mini-B connectors will fit (separately) into
 the socket on that device ... without forcing anything!  If that works,
 it's likely you have the other hardware needed too.  (Last I heard,
 the pxa27x_udc driver wasn't quite usable yet.)

I know the hardware can do it as the device came with both leads! I just
wasn't sure how clever its detection is. Your hint about the ID pin
answers my question though - I suspect this goes straight to a gpio. I
did a bit of digging and discovered that whilst there is space left on
the PCB for an OTG transceiver, they didn't include one. It'll be
interesting to see how clever we can be with just what the pxa270
provides...

The link to the OTG USB information is interesting and I'll have to see
what I can do with it in due course. My priority for now is to get the
UDC driver running. I think the hh.org code works but fails over a
suspend/resume although I have yet to try it. Once that's done and the
rest of the spitz drivers ready for mainline, I'll worry about OTG :)

Cheers,

Richard



---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices

[linux-usb-devel] [patch] USB OHCI Consolidate NDP register handling

2005-08-25 Thread Richard Purdie
A number of platforms have differences in the way the NDP register (in
roothub_a) reports the number of ports present. This patch allows the
platform specific code to optionally supply the number of ports. The
driver just reads the value at init (if not supplied) instead of reading
it every time its needed.

It also sets the value correctly for the ARM pxa27x architecture.

Signed-Off-By: Richard Purdie [EMAIL PROTECTED]

Index: linux-2.6.12/drivers/usb/host/ohci-dbg.c
===
--- linux-2.6.12.orig/drivers/usb/host/ohci-dbg.c   2005-08-25 
15:53:19.0 +0100
+++ linux-2.6.12/drivers/usb/host/ohci-dbg.c2005-08-25 15:55:38.0 
+0100
@@ -228,23 +228,22 @@
char **next,
unsigned *size)
 {
-   u32 temp, ndp, i;
+   u32 temp, i;
 
temp = roothub_a (controller);
if (temp == ~(u32)0)
return;
-   ndp = (temp  RH_A_NDP);
 
if (verbose) {
ohci_dbg_sw (controller, next, size,
-   roothub.a %08x POTPGT=%d%s%s%s%s%s NDP=%d\n, temp,
+   roothub.a %08x POTPGT=%d%s%s%s%s%s NDP=%d(%d)\n, temp,
((temp  RH_A_POTPGT)  24)  0xff,
(temp  RH_A_NOCP) ?  NOCP : ,
(temp  RH_A_OCPM) ?  OCPM : ,
(temp  RH_A_DT) ?  DT : ,
(temp  RH_A_NPS) ?  NPS : ,
(temp  RH_A_PSM) ?  PSM : ,
-   ndp
+   (temp  RH_A_NDP), controller-num_ports
);
temp = roothub_b (controller);
ohci_dbg_sw (controller, next, size,
@@ -266,7 +265,7 @@
);
}
 
-   for (i = 0; i  ndp; i++) {
+   for (i = 0; i  controller-num_ports; i++) {
temp = roothub_portstatus (controller, i);
dbg_port_sw (controller, i, temp, next, size);
}
Index: linux-2.6.12/drivers/usb/host/ohci-hcd.c
===
--- linux-2.6.12.orig/drivers/usb/host/ohci-hcd.c   2005-08-25 
15:53:19.0 +0100
+++ linux-2.6.12/drivers/usb/host/ohci-hcd.c2005-08-25 15:55:38.0 
+0100
@@ -485,6 +485,10 @@
// flush the writes
(void) ohci_readl (ohci, ohci-regs-control);
 
+   /* Read the number of ports unless overridden */
+   if (ohci-num_ports == 0)
+   ohci-num_ports = roothub_a(ohci)  RH_A_NDP;
+
if (ohci-hcca)
return 0;
 
@@ -561,10 +565,8 @@
msleep(temp);
temp = roothub_a (ohci);
if (!(temp  RH_A_NPS)) {
-   unsigned ports = temp  RH_A_NDP; 
-
/* power down each port */
-   for (temp = 0; temp  ports; temp++)
+   for (temp = 0; temp  ohci-num_ports; temp++)
ohci_writel (ohci, RH_PS_LSDA,
ohci-regs-roothub.portstatus [temp]);
}
@@ -861,7 +863,7 @@
 * and that if we try to turn them back on the root hub
 * will respond to CSC processing.
 */
-   i = roothub_a (ohci)  RH_A_NDP;
+   i = ohci-num_ports;
while (i--)
ohci_writel (ohci, RH_PS_PSS,
ohci-regs-roothub.portstatus [temp]);
Index: linux-2.6.12/drivers/usb/host/ohci-hub.c
===
--- linux-2.6.12.orig/drivers/usb/host/ohci-hub.c   2005-08-25 
15:53:19.0 +0100
+++ linux-2.6.12/drivers/usb/host/ohci-hub.c2005-08-25 15:55:38.0 
+0100
@@ -184,7 +184,7 @@
if (status != -EINPROGRESS)
return status;
 
-   temp = roothub_a (ohci)  RH_A_NDP;
+   temp = ohci-num_ports;
enables = 0;
while (temp--) {
u32 stat = ohci_readl (ohci,
@@ -304,7 +304,7 @@
 ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
 {
struct ohci_hcd *ohci = hcd_to_ohci (hcd);
-   int ports, i, changed = 0, length = 1;
+   int i, changed = 0, length = 1;
int can_suspend = hcd-can_wakeup;
unsigned long   flags;
 
@@ -319,26 +319,18 @@
goto done;
}
 
-   ports = roothub_a (ohci)  RH_A_NDP; 
-   if (ports  MAX_ROOT_PORTS) {
-   ohci_err (ohci, bogus NDP=%d, rereads as NDP=%d\n, ports,
- ohci_readl (ohci, ohci-regs-roothub.a)  RH_A_NDP);
-   /* retry later; should not happen */
-   goto done;
-   }
-
/* init status */
if (roothub_status (ohci)  (RH_HS_LPSC | RH_HS_OCIC))
buf [0] = changed = 1;
else
buf [0] = 0;
-   if (ports  7) {
+   if (ohci-num_ports  7

[linux-usb-devel] [patch 1/2] USB PXA-27x OHCI Driver Cleanup

2005-08-25 Thread Richard Purdie
There is no need to set usb power during init with the modern ohci
driver. The power control functions are also incorrect. They should
therefore be removed. (This leads into the removal of platform specific
code.)

Add a check to clear the OTG pin hold bit until such times OTG is
properly implemented.

Allow the platform to select the port power mode

Signed-Off-By: Richard Purdie [EMAIL PROTECTED]

Index: linux-2.6.12/drivers/usb/host/ohci-pxa27x.c
===
--- linux-2.6.12.orig/drivers/usb/host/ohci-pxa27x.c2005-08-25 
16:22:16.0 +0100
+++ linux-2.6.12/drivers/usb/host/ohci-pxa27x.c 2005-08-25 16:36:39.0 
+0100
@@ -75,33 +75,6 @@
return 0;
 }
 
-/*
-  If you select PMM_PERPORT_MODE, you should set the port power
- */
-static int pxa27x_ohci_set_port_power( int port )
-{
-   if ( (pxa27x_ohci_pmm_state==PMM_PERPORT_MODE)
- (port0)  (portPXA_UHC_MAX_PORTNUM) ) {
-   UHCRHPS(port) |= 0x100;
-   return 0;
-   }
-   return -1;
-}
-
-/*
-  If you select PMM_PERPORT_MODE, you should set the port power
- */
-static int pxa27x_ohci_clear_port_power( int port )
-{
-   if ( (pxa27x_ohci_pmm_state==PMM_PERPORT_MODE) 
- (port0)  (portPXA_UHC_MAX_PORTNUM) ) {
-   UHCRHPS(port) |= 0x200;
-   return 0;
-   }
-
-   return -1;
-}
-
 extern int usb_disabled(void);
 
 /*-*/
@@ -130,11 +103,17 @@
   Polarity Low to active low. Supply power to USB ports. */
UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) 
~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
+
+   pxa27x_ohci_pmm_state=PMM_PERPORT_MODE;
}
 
UHCHR = ~UHCHR_SSE;
 
UHCHIE = (UHCHIE_UPRIE | UHCHIE_RWIE);
+
+   /* Clear any OTG Pin Hold */
+   if (PSSR  PSSR_OTGPH)
+   PSSR |= PSSR_OTGPH;
 }
 
 static void pxa27x_stop_hc(struct platform_device *dev)
@@ -198,17 +177,7 @@
pxa27x_start_hc(dev);
 
/* Select Power Management Mode */
-   pxa27x_ohci_select_pmm( PMM_PERPORT_MODE );
-
-   /* If choosing PMM_PERPORT_MODE, we should set the port power before we 
use it. */
-   if (pxa27x_ohci_set_port_power(1)  0)
-   printk(KERN_ERR Setting port 1 power failed.\n);
-
-   if (pxa27x_ohci_clear_port_power(2)  0)
-   printk(KERN_ERR Setting port 2 power failed.\n);
-
-   if (pxa27x_ohci_clear_port_power(3)  0)
-   printk(KERN_ERR Setting port 3 power failed.\n);
+   pxa27x_ohci_select_pmm(pxa27x_ohci_pmm_state);
 
ohci_hcd_init(hcd_to_ohci(hcd));
 




---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile  Plan-Driven Development * Managing Projects  Teams * Testing  QA
Security * Process Improvement  Measurement * http://www.sqe.com/bsce5sf
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel


[linux-usb-devel] [patch 2/2] USB PXA-27x OHCI Separate platform code from main driver

2005-08-25 Thread Richard Purdie
To allow multiple platforms to use the PXA27x OHCI driver, the platform
code needs to be moved into the board specific files in
arch/arm/mach-pxa. This patch does this for mainstone and adds
preliminary hooks to allow other boards to use the driver.

This has been compile tested for mainstone and successfully run on Spitz
(Sharp Zaurus SL-C3000) with the addition of an appropriate board
support file.

Signed-Off-By: Richard Purdie [EMAIL PROTECTED]

Index: linux-2.6.12/drivers/usb/host/ohci-pxa27x.c
===
--- linux-2.6.12.orig/drivers/usb/host/ohci-pxa27x.c2005-08-26 
00:08:18.0 +0100
+++ linux-2.6.12/drivers/usb/host/ohci-pxa27x.c 2005-08-26 00:08:20.0 
+0100
@@ -23,18 +23,12 @@
 #include asm/mach-types.h
 #include asm/hardware.h
 #include asm/arch/pxa-regs.h
-
-
-#define PMM_NPS_MODE   1
-#define PMM_GLOBAL_MODE2
-#define PMM_PERPORT_MODE   3
+#include asm/arch/ohci.h
 
 #define PXA_UHC_MAX_PORTNUM3
 
 #define UHCRHPS(x)  __REG2( 0x4C50, (x)2 )
 
-static int pxa27x_ohci_pmm_state;
-
 /*
   PMM_NPS_MODE -- PMM Non-power switching mode
   Ports are powered continuously.
@@ -47,8 +41,6 @@
  */
 static int pxa27x_ohci_select_pmm( int mode )
 {
-   pxa27x_ohci_pmm_state = mode;
-
switch ( mode ) {
case PMM_NPS_MODE:
UHCRHDA |= RH_A_NPS;
@@ -68,7 +60,6 @@
Invalid mode %d, set to non-power switch mode.\n, 
mode );
 
-   pxa27x_ohci_pmm_state = PMM_NPS_MODE;
UHCRHDA |= RH_A_NPS;
}
 
@@ -79,8 +70,13 @@
 
 /*-*/
 
-static void pxa27x_start_hc(struct platform_device *dev)
+static int pxa27x_start_hc(struct device *dev)
 {
+   int retval = 0;
+   struct pxaohci_platform_data *inf;
+
+   inf = dev-platform_data;
+
pxa_set_cken(CKEN10_USBHOST, 1);
 
UHCHR |= UHCHR_FHR;
@@ -91,21 +87,11 @@
while (UHCHR  UHCHR_FSBIR)
cpu_relax();
 
-   /* This could be properly abstracted away through the
-  device data the day more machines are supported and
-  their differences can be figured out correctly. */
-   if (machine_is_mainstone()) {
-   /* setup Port1 GPIO pin. */
-   pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN);  /* USBHPWR1 */
-   pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */
-
-   /* Set the Power Control Polarity Low and Power Sense
-  Polarity Low to active low. Supply power to USB ports. */
-   UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) 
-   ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
+   if (inf-init)
+   retval = inf-init(dev);
 
-   pxa27x_ohci_pmm_state=PMM_PERPORT_MODE;
-   }
+   if (retval  0)
+   return retval;
 
UHCHR = ~UHCHR_SSE;
 
@@ -114,10 +100,19 @@
/* Clear any OTG Pin Hold */
if (PSSR  PSSR_OTGPH)
PSSR |= PSSR_OTGPH;
+
+   return 0;
 }
 
-static void pxa27x_stop_hc(struct platform_device *dev)
+static void pxa27x_stop_hc(struct device *dev)
 {
+   struct pxaohci_platform_data *inf;
+
+   inf = dev-platform_data;
+
+   if (inf-exit)
+   inf-exit(dev);
+
UHCHR |= UHCHR_FHR;
udelay(11);
UHCHR = ~UHCHR_FHR;
@@ -144,22 +139,28 @@
  * through the hotplug entry's driver_data.
  *
  */
-int usb_hcd_pxa27x_probe (const struct hc_driver *driver,
- struct platform_device *dev)
+int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct device *dev)
 {
int retval;
struct usb_hcd *hcd;
+   struct pxaohci_platform_data *inf;
+   struct platform_device *pdev = to_platform_device(dev);
+
+   inf = dev-platform_data;
+
+   if (!inf)
+   return -ENODEV;
 
-   if (dev-resource[1].flags != IORESOURCE_IRQ) {
+   if (pdev-resource[1].flags != IORESOURCE_IRQ) {
pr_debug (resource[1] is not IORESOURCE_IRQ);
return -ENOMEM;
}
 
-   hcd = usb_create_hcd (driver, dev-dev, pxa27x);
+   hcd = usb_create_hcd (driver, dev, pxa27x);
if (!hcd)
return -ENOMEM;
-   hcd-rsrc_start = dev-resource[0].start;
-   hcd-rsrc_len = dev-resource[0].end - dev-resource[0].start + 1;
+   hcd-rsrc_start = pdev-resource[0].start;
+   hcd-rsrc_len = pdev-resource[0].end - pdev-resource[0].start + 1;
 
if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
pr_debug(request_mem_region failed);
@@ -174,18 +175,22 @@
goto err2;
}
 
-   pxa27x_start_hc(dev);
+   if ((retval = pxa27x_start_hc(dev))  0) {
+   pr_debug(pxa27x_start_hc failed);
+   goto err3

Re: [linux-usb-devel] PXA27x OHCI Driver RFC

2005-08-23 Thread Richard Purdie
On Tue, 2005-08-23 at 12:43 +0200, Bernd Petrovitsch wrote:
 Just C-specific ones - God knows what people will pass as argument:
 
  +#ifdef CONFIG_PXA27x
  +#define OHCI_GETPORTNUM(x) ((x  RH_A_NDP) + 1)
 +#define OHCI_GETPORTNUM(x)   (((x)  RH_A_NDP) + 1)
  +#else
  +#define OHCI_GETPORTNUM(x) (x  RH_A_NDP)
 +#define OHCI_GETPORTNUM(x) ((x)  RH_A_NDP)
  +#endif

Thanks. I also noticed:

 -   ndp = (temp  RH_A_NDP);
 +   ndp = OHCI_GETPORTNUM(temp  RH_A_NDP);

which should have been:

+   ndp = OHCI_GETPORTNUM(temp);

Richard



---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile  Plan-Driven Development * Managing Projects  Teams * Testing  QA
Security * Process Improvement  Measurement * http://www.sqe.com/bsce5sf
___
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel