Re: Power state of USB port on computer reboot

2013-04-10 Thread Blaz Malnersic
Greg KH gregkh@... writes:

 
 On Tue, Apr 09, 2013 at 02:00:51PM +, Blaz Malnersic wrote:
   
  Is it possible to influence USB power on OS reboot? Linux and BIOS 
don't 
  interrupt the power of USB port on reboot, only Windows (all versions 
we 
  tested do). This along with different times of power lack leads me to 
  conclusion that there is no standard regarding this issue. Also we are 
  dealing with SW+HW, since we only found this issue with Lenovo 
ThinkPads.
 
 As you are having problems with Windows, not Linux, why are you asking
 this on a Linux mailing list?  Please just file a bug with Windows if
 this is a needed thing for your systems (hint, you can never rely on USB
 power being present across a reboot, that's an undefined system state,
 sorry.)
 
 good luck,
 
 greg k-h
 --
 To unsubscribe from this list: send the line unsubscribe linux-usb in
 the body of a message to majordomo@...
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 
 

Hi,


:) I am trying with Lenovo and Microsoft but there is not much happening 
from their side. 

If it is as you said concerning the undefined state of the USB power 
across a reboot, that information is very helpful for me. It means we have 
to design things differently (apart from the obvious one which is to 
replace the notebooks...). 

How come this is undefined?

Best regards,

   Blaz
 

P.S. This is why I love Linux community - open exchange of knowledge. I am 
not saying it is not happening in MS/commercial world...



--
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 00/11] usb: musb: add back support for host mode

2013-04-10 Thread Daniel Mack
On 08.04.2013 12:38, B, Ravi wrote:
 Felipe
 
 Hi,
 
 On Mon, Apr 08, 2013 at 12:25:38PM +0200, B, Ravi wrote:
 Daniel
 
 On 08.04.2013 09:57, B, Ravi wrote:
 Hi all,
 
 here are some patches to separate the HCD and gadget part
 of the
 musb
 driver so they can be deselected in Kconfig. They also make
 the
 driver
 keep track of the configured port mode that is set from DT,
 so the actual runtime configuration can be selected
 dynamically.
 
 One thing that is still broken is that once pm_suspend()
 was called
 on
 a musb device on a USB disconnect, the port won't wake up
 again
 when a
 device is plugged back in.
 
 This could be due to SESSION bit removal when root port is
 disconnected
 in otg_timer function.
 
 Not sure if we are thinking about the same details, but after
 debuging this a further, turns out that
 musb_platform_try_idle() eventually switches off the entire
 controller, which then leads to DRVBUS going
 low
 on the board. That, in turn, prevents the interrupt from being
 triggered
 on reconnect, because the host port is not powered anymore.
 
 I don't know yet how to cope with that, but for now, I simply
 disabled the call from musb_stage0_irq() to
 musb_platform_try_idle() locally.
 
 The otg_timer() gets invoked, which removes the session when no
 device connected to root controller, this is required in otg or
 dual role mode (Not for host-only mode). Because otg state is
 un-defined till user's connected a-side of b-side of cable.
 
 Embedded hosts might also want this to save some power while no
 devices are connected. I guess most of those devices would rely on
 SRP or on a polling method to enable VBUS.
 
 Yes, in case of true otg, SRP wakesup the device to enable VBUS.
 
 By 'polling' I mean that e.g. every 2
 seconds turn vbus on, if no device are enumerated in 200ms, then
 sleep for another 2 seconds.
 
 Yes, we had this workaround mechanism enabled on some earlier davinci
 platform by setting the session periodically to check any device
 connected for host or otg/dual-role controller to save VBUS power
 when no device connected.

However, this workaround doesn't seem to work anymore.

Anyway, I think we can address this issue separately from the patch set
I submitted.


Thanks,
Daniel
--
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 v4] sierra_net: keep status interrupt URB active

2013-04-10 Thread Oliver Neukum
On Tuesday 09 April 2013 18:05:51 Dan Williams wrote:
 The driver and firmware sync up through SYNC messages, and the
 firmware's affirmative reply to these SYNC messages appears to be the
 Reset indication received via the status interrupt endpoint.  Thus the
 driver needs the status interrupt endpoint always active so that the
 Reset indication can be received even if the netdev is closed, which is
 the case right after device insertion.

WHat about suspend/resume?

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 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Oliver Neukum
On Tuesday 09 April 2013 18:02:27 Dan Williams wrote:
 Some drivers (sierra_net) need the status interrupt URB
 active even when the device is closed, because they receive
 custom indications from firmware.  Add functions to refcount
 the status interrupt URB submit/kill operation so that
 sub-drivers and the generic driver don't fight over whether
 the status interrupt URB is active or not.
 
 A sub-driver can call usbnet_status_start() at any time, but
 the URB is only submitted the first time the function is
 called.  Likewise, when the sub-driver is done with the URB,
 it calls usbnet_status_stop() but the URB is only killed when
 all users have stopped it.  The URB is still killed and
 re-submitted for suspend/resume, as before, with the same
 refcount it had at suspend.
 
 Signed-off-by: Dan Williams d...@redhat.com
 ---
  drivers/net/usb/usbnet.c   | 79 
 ++
  include/linux/usb/usbnet.h |  5 +++
  2 files changed, 77 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
 index 51f3192..e8b363a 100644
 --- a/drivers/net/usb/usbnet.c
 +++ b/drivers/net/usb/usbnet.c
 @@ -42,7 +42,7 @@
  #include linux/workqueue.h
  #include linux/mii.h
  #include linux/usb.h
 -#include linux/usb/usbnet.h
 +#include usbnet.h
  #include linux/slab.h
  #include linux/kernel.h
  #include linux/pm_runtime.h
 @@ -252,6 +252,70 @@ static int init_status (struct usbnet *dev, struct 
 usb_interface *intf)
   return 0;
  }
  
 +/* Submit the interrupt URB if it hasn't been submitted yet */
 +static int __usbnet_status_start(struct usbnet *dev, gfp_t mem_flags,
 + bool force)
 +{
 + int ret = 0;
 + bool submit = false;
 +
 + if (!dev-interrupt)
 + return 0;
 +
 + mutex_lock(dev-interrupt_mutex);
 +
 + if (force) {

That design means that interrupt_count isn't accurate if force is used.
That is extremely ugly.

 + /* Only submit now if the URB was previously submitted */
 + if (dev-interrupt_count)
 + submit = true;
 + } else if (++dev-interrupt_count == 1)
 + submit = true;
 +
 + if (submit)
 + ret = usb_submit_urb(dev-interrupt, mem_flags);
 +
 + dev_dbg(dev-udev-dev, incremented interrupt URB count to %d\n,
 + dev-interrupt_count);
 + mutex_unlock(dev-interrupt_mutex);
 + return ret;
 +}
 +
 +int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
 +{
 + /* Only drivers that implement a status hook should call this */
 + BUG_ON(dev-interrupt == NULL);
 +
 + if (test_bit(EVENT_DEV_ASLEEP, dev-flags))
 + return -EINVAL;

This looks like a race condition.

 + return __usbnet_status_start(dev, mem_flags, false);
 +}
 +EXPORT_SYMBOL_GPL(usbnet_status_start);
 +
 +/* Kill the interrupt URB if all submitters want it killed */
 +static void __usbnet_status_stop(struct usbnet *dev, bool force)
 +{
 + if (dev-interrupt) {
 + mutex_lock(dev-interrupt_mutex);
 + if (!force)
 + BUG_ON(dev-interrupt_count == 0);
 +
 + if (force || --dev-interrupt_count == 0)
 + usb_kill_urb(dev-interrupt);

Why so complicated? If it may be on, kill it unconditionally.

 +
 + dev_dbg(dev-udev-dev,
 + decremented interrupt URB count to %d\n,
 + dev-interrupt_count);
 + mutex_unlock(dev-interrupt_mutex);
 + }
 +}
 +

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 v2 01/11] usb: gadget: drop unused USB_GADGET_MUSB_HDRC

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel The functionality meant to be represented by this symbol will be
 Daniel re-added later, but for now, USB_GADGET_MUSB_HDRC is in fact unused and
 Daniel can be dropped.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com

Acked-by: Peter Korsgaard jac...@sunsite.dk

 Daniel ---
 Daniel  drivers/usb/gadget/Kconfig | 8 
 Daniel  1 file changed, 8 deletions(-)

 Daniel diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
 Daniel index a61d981..0702fa0 100644
 Daniel --- a/drivers/usb/gadget/Kconfig
 Daniel +++ b/drivers/usb/gadget/Kconfig
 Daniel @@ -333,14 +333,6 @@ config USB_MV_U3D
 Daniel  # Controllers available in both integrated and discrete versions
 Daniel  #
 
 Daniel -# musb builds in ../musb along with host support
 Daniel -config USB_GADGET_MUSB_HDRC
 Daniel -  tristate Inventra HDRC USB Peripheral (TI, ADI, ...)
 Daniel -  depends on USB_MUSB_HDRC
 Daniel -  help
 Daniel -This OTG-capable silicon IP is used in dual designs including
 Daniel -the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI 
Blackfin
 Daniel -
 Daniel  config USB_M66592
 Danieltristate Renesas M66592 USB Peripheral Controller
 Danielhelp
 Daniel -- 
 Daniel 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 02/11] usb: musb: move function declarations to musb_{host,gadget}.h

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel Let the function declarations live in the header files they belong to,
 Daniel which makes it easier to stub them out later.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com

Acked-by: Peter Korsgaard jac...@sunsite.dk

 Daniel ---
 Daniel  drivers/usb/musb/musb_core.h   | 17 -
 Daniel  drivers/usb/musb/musb_gadget.h | 17 +++--
 Daniel  drivers/usb/musb/musb_host.h   |  4 +++-
 Daniel  3 files changed, 14 insertions(+), 24 deletions(-)

 Daniel diff --git a/drivers/usb/musb/musb_core.h 
b/drivers/usb/musb/musb_core.h
 Daniel index 7fb4819..04d8974 100644
 Daniel --- a/drivers/usb/musb/musb_core.h
 Daniel +++ b/drivers/usb/musb/musb_core.h
 Daniel @@ -82,23 +82,6 @@ struct musb_ep;
 Daniel  #define MUSB_CONFIG_PROC_FS
 Daniel  #endif
 
 Daniel -/** PERIPHERAL ROLE 
*/
 Daniel -
 Daniel -extern irqreturn_t musb_g_ep0_irq(struct musb *);
 Daniel -extern void musb_g_tx(struct musb *, u8);
 Daniel -extern void musb_g_rx(struct musb *, u8);
 Daniel -extern void musb_g_reset(struct musb *);
 Daniel -extern void musb_g_suspend(struct musb *);
 Daniel -extern void musb_g_resume(struct musb *);
 Daniel -extern void musb_g_wakeup(struct musb *);
 Daniel -extern void musb_g_disconnect(struct musb *);
 Daniel -
 Daniel -/** HOST ROLE 
***/
 Daniel -
 Daniel -extern irqreturn_t musb_h_ep0_irq(struct musb *);
 Daniel -extern void musb_host_tx(struct musb *, u8);
 Daniel -extern void musb_host_rx(struct musb *, u8);
 Daniel -
 Daniel  /** CONSTANTS 
/
 
 Daniel  #ifndef MUSB_C_NUM_EPS
 Daniel diff --git a/drivers/usb/musb/musb_gadget.h 
b/drivers/usb/musb/musb_gadget.h
 Daniel index 66b7c5e..75f821c 100644
 Daniel --- a/drivers/usb/musb/musb_gadget.h
 Daniel +++ b/drivers/usb/musb/musb_gadget.h
 Daniel @@ -37,6 +37,17 @@
 
 Daniel  #include linux/list.h
 
 Daniel +extern irqreturn_t musb_g_ep0_irq(struct musb *);
 Daniel +extern void musb_g_tx(struct musb *, u8);
 Daniel +extern void musb_g_rx(struct musb *, u8);
 Daniel +extern void musb_g_reset(struct musb *);
 Daniel +extern void musb_g_suspend(struct musb *);
 Daniel +extern void musb_g_resume(struct musb *);
 Daniel +extern void musb_g_wakeup(struct musb *);
 Daniel +extern void musb_g_disconnect(struct musb *);
 Daniel +extern void musb_gadget_cleanup(struct musb *);
 Daniel +extern int musb_gadget_setup(struct musb *);
 Daniel +
 Daniel  enum buffer_map_state {
 DanielUN_MAPPED = 0,
 DanielPRE_MAPPED,
 Daniel @@ -106,14 +117,8 @@ static inline struct musb_request 
*next_request(struct musb_ep *ep)
 Danielreturn container_of(queue-next, struct musb_request, list);
 Daniel  }
 
 Daniel -extern void musb_g_tx(struct musb *musb, u8 epnum);
 Daniel -extern void musb_g_rx(struct musb *musb, u8 epnum);
 Daniel -
 Daniel  extern const struct usb_ep_ops musb_g_ep0_ops;
 
 Daniel -extern int musb_gadget_setup(struct musb *);
 Daniel -extern void musb_gadget_cleanup(struct musb *);
 Daniel -
 Daniel  extern void musb_g_giveback(struct musb_ep *, struct usb_request *, 
int);
 
 Daniel  extern void musb_ep_restart(struct musb *, struct musb_request *);
 Daniel diff --git a/drivers/usb/musb/musb_host.h 
b/drivers/usb/musb/musb_host.h
 Daniel index 5a9c8fe..9670269 100644
 Daniel --- a/drivers/usb/musb/musb_host.h
 Daniel +++ b/drivers/usb/musb/musb_host.h
 Daniel @@ -84,7 +84,9 @@ static inline struct musb_qh *first_qh(struct 
list_head *q)
 Danielreturn list_entry(q-next, struct musb_qh, ring);
 Daniel  }
 
 Daniel -
 Daniel +extern irqreturn_t musb_h_ep0_irq(struct musb *);
 Daniel +extern void musb_host_tx(struct musb *, u8);
 Daniel +extern void musb_host_rx(struct musb *, u8);
 Daniel  extern void musb_root_disconnect(struct musb *musb);
 
 Daniel  struct usb_hcd;
 Daniel -- 
 Daniel 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 03/11] usb: musb: factor some host-specific functions

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel In particular, this introduces musb_host_resume_root_hub()and
 Daniel musb_host_poke_root_hub() which will be stubbed out later.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com

Acked-by: Peter Korsgaard jac...@sunsite.dk

-- 
Bye, Peter Korsgaard
--
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 04/11] usb: musb: gadget: remove hcd initialization

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel This will be done from a more appropriate location and as it doesn't
 Daniel work anyway, it can safely be removed before the other changes.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com

Acked-by: Peter Korsgaard jac...@sunsite.dk

 Daniel ---
 Daniel  drivers/usb/musb/musb_gadget.c | 10 --
 Daniel  1 file changed, 10 deletions(-)

 Daniel diff --git a/drivers/usb/musb/musb_gadget.c 
b/drivers/usb/musb/musb_gadget.c
 Daniel index ba70923..0414bc1 100644
 Daniel --- a/drivers/usb/musb/musb_gadget.c
 Daniel +++ b/drivers/usb/musb/musb_gadget.c
 Daniel @@ -1820,7 +1820,6 @@ static int musb_gadget_start(struct usb_gadget 
*g,
 Daniel  {
 Danielstruct musb *musb = gadget_to_musb(g);
 Danielstruct usb_otg  *otg = musb-xceiv-otg;
 Daniel -  struct usb_hcd  *hcd = musb_to_hcd(musb);
 Danielunsigned long   flags;
 Danielint retval = 0;
 
 Daniel @@ -1847,17 +1846,9 @@ static int musb_gadget_start(struct usb_gadget 
*g,
 Daniel * handles power budgeting ... this way also
 Daniel * ensures HdrcStart is indirectly called.
 Daniel */
 Daniel -  retval = usb_add_hcd(hcd, 0, 0);
 Daniel -  if (retval  0) {
 Daniel -  dev_dbg(musb-controller, add_hcd failed, %d\n, 
retval);
 Daniel -  goto err;
 Daniel -  }
 Daniel -
 Danielif (musb-xceiv-last_event == USB_EVENT_ID)
 Danielmusb_platform_set_vbus(musb, 1);
 
 Daniel -  hcd-self.uses_pio_for_control = 1;
 Daniel -
 Danielif (musb-xceiv-last_event == USB_EVENT_NONE)
 Danielpm_runtime_put(musb-controller);
 
 Daniel @@ -1942,7 +1933,6 @@ static int musb_gadget_stop(struct usb_gadget *g,
 Danielmusb_platform_try_idle(musb, 0);
 Danielspin_unlock_irqrestore(musb-lock, flags);
 
 Daniel -  usb_remove_hcd(musb_to_hcd(musb));
 Daniel/*
 Daniel * FIXME we need to be able to register another
 Daniel * gadget driver here and have everything work;
 Daniel -- 
 Daniel 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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-04-10 Thread victor yeo
Hi,

 Earlier, i used file=/dev/mmcblk0p1. Now i use
 file=/mnt/sd/backing_file. This backing_file is a dummy file system
 that i created. I attached two jpeg files. One show the MBR and Boot
 Sector of the backing_file. Another shows the usbmon of the Linux Host

 Why did you send jpeg files?  Plain text files are a lot easier to work
 with.  Now I can't copy and paste the lines from your files into this
 email message.  :-(

 PC. I also attached the udc log which shows the MBR and Boot Sector
 content which are read from the backing_file.

 The UDC log indicates that the MBR and boot sectors were read
 correctly.

  From the usbmon jpeg,
 that first SCSI_READ_10 command got a overflow error, the second
 SCSI_READ_10 command got a connection reset error. Is the overflow
 error occurred because the host PC cannot handle the data returned
 from the gadget device?

 The usbmon log shows that the host sent the gadget a READ(10) command
 for 8 sectors, which 4096 bytes.  It then requested a 4096-byte
 transfer on the bulk-in endpoint, expecting the gadget to reply with
 eight packets, each containing 512 bytes (because the bulk-in
 wMaxPacketSize is 512).

 But the gadget did not reply correctly.  The UDC sent a data packet
 containing only 256 bytes, instead of 512 bytes.  The overflow occurred
 when it sent a second data packet, again containing the wrong number of
 bytes.

  Call the gadget driver's -reset handler.  If the -reset pointer is
  NULL, call the -disconnect handler instead.  See the code in
  net2280.c's handle_stat1_irqs() as an example.
 
  Alan Stern
 

 i read the net2280.c code. Is it the usb_reset() function, called by
 stop_activity()? I am sorry if i understand incorrectly.

 No, it is the handle_stat1_irqs() function, as I wrote above.  In
 particular, this part of the code, which handles both disconnects and
 resets:

 if (disconnect || reset) {
 stop_activity(dev, dev-driver);
 ep0_start(dev);
 spin_unlock(dev-lock);
 if (reset  dev-driver-reset)
 (dev-driver-reset)(dev-gadget);
 else
 (dev-driver-disconnect)(dev-gadget);
 spin_lock(dev-lock);
 return;
 }


I use kernel 3.4.4, the code in handle_stat1_irqs() is as below. There
is no reset or disconnect member function in struct
usb_gadget_driver in kernel 3.4.4.

if (stat  (1  SUSPEND_REQUEST_INTERRUPT)) {
if (dev-driver-suspend)
dev-driver-suspend (dev-gadget);
if (!enable_suspend)
stat = ~(1  SUSPEND_REQUEST_INTERRUPT);
} else {
if (dev-driver-resume)
dev-driver-resume (dev-gadget);
/* at high speed, note erratum 0133 */
}


 Another usbmon trace showing 3 SCSI_READ_10 command.

This trace shows that the READ(10) commands worked correctly.  Good.
But it also shows that the gadget did not respond correctly to the 0xA1
command near the end.  The UDC was supposed to set the Halt feature
for the bulk-in endpoint and send a STALL packet, but it didn't.

In gadget driver, when do_scsi_command() receives an unknown command,
the return value is -EINVAL. Will this value be returned to UDC
driver, so that UDC driver can set the Halt feature for the bulk-in
endpoint and send a STALL packet? For now, UDC driver does not set
Halt when unknown SCSI command is received.

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 v2 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel The musb struct is currently allocated along with the hcd,
 Daniel which makes it difficult to build a driver that only acts as
 Daniel gadget device.

 Daniel Fix this by allocating musb directly, and keep the hcd around as
 Daniel a pointer in the musb struct.

 Daniel struct hc_driver musb_hc_driver can now also be static to
 Daniel musb_host.c, and the macro musb_to_hcd() is just a pointer
 Daniel dereferencer for now, and will be elminiated later.

s/elminiated/eliminated/

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com

 Daniel +++ b/drivers/usb/musb/musb_host.h
 Daniel @@ -37,15 +37,9 @@
 
 Daniel  #include linux/scatterlist.h
 
 Daniel -static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
 Daniel -{
 Daniel -  return container_of((void *) musb, struct usb_hcd, hcd_priv);
 Daniel -}
 Daniel +#define musb_to_hcd(MUSB) ((MUSB)-hcd)

I dislike the capitals, but as it's going away later:

Acked-by: Peter Korsgaard jac...@sunsite.dk

-- 
Bye, Peter Korsgaard
--
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 07/11] usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel This makes building the actual object files optional to the selected
 Daniel mode, which saves users who know which kind of USB mode support they
 Daniel need some binary size.

 Daniel Unimplemented functions are stubbed out with static inline functions.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com
 Daniel ---
 Daniel  drivers/usb/musb/Kconfig   | 29 +
 Daniel  drivers/usb/musb/Makefile  | 10 --
 Daniel  drivers/usb/musb/musb_gadget.h | 21 +
 Daniel  drivers/usb/musb/musb_host.h   | 29 +++--
 Daniel  4 files changed, 85 insertions(+), 4 deletions(-)

 Daniel diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
 Daniel index 47442d3..aab1568 100644
 Daniel --- a/drivers/usb/musb/Kconfig
 Daniel +++ b/drivers/usb/musb/Kconfig
 Daniel @@ -28,6 +28,35 @@ config USB_MUSB_HDRC
 Daniel  if USB_MUSB_HDRC
 
 Daniel  choice
 Daniel +  bool MUSB Mode Selection
 Daniel +  default USB_MUSB_DUAL_ROLE if (USB  USB_GADGET)
 Daniel +  default USB_MUSB_HOST if (USB  !USB_GADGET)
 Daniel +  default USB_MUSB_GADGET if (!USB  USB_GADGET)
 Daniel +
 Daniel +config USB_MUSB_HOST
 Daniel +  bool Host only mode
 Daniel +  depends on USB
 Daniel +  help
 Daniel +Select this when you want to use MUSB in host mode only,
 Daniel +thereby the gadget feature will be regressed.
 Daniel +
 Daniel +config USB_MUSB_GADGET
 Daniel +  bool Gadget only mode
 Daniel +  depends on USB_GADGET
 Daniel +  help
 Daniel +Select this when you want to use MUSB in gadget mode only,
 Daniel +thereby the host feature will be regressed.
 Daniel +
 Daniel +config USB_MUSB_DUAL_ROLE
 Daniel +  bool Dual Role mode
 Daniel +  depends on (USB  USB_GADGET)
 Daniel +  help
 Daniel +This is the default mode of working of MUSB controller where
 Daniel +both host and gadget features are enabled.
 Daniel +
 Daniel +endchoice
 Daniel +
 Daniel +choice
 Danielprompt Platform Glue Layer
 
 Daniel  config USB_MUSB_DAVINCI
 Daniel diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
 Daniel index 3b85871..6b13a53 100644
 Daniel --- a/drivers/usb/musb/Makefile
 Daniel +++ b/drivers/usb/musb/Makefile
 Daniel @@ -6,10 +6,16 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
 
 Daniel  musb_hdrc-y := musb_core.o
 
 Daniel -musb_hdrc-y   += musb_gadget_ep0.o 
musb_gadget.o
 Daniel -musb_hdrc-y   += musb_virthub.o 
musb_host.o
 Daniel  musb_hdrc-$(CONFIG_DEBUG_FS)  += musb_debugfs.o
 
 Daniel +ifneq ($(filter y,$(CONFIG_USB_MUSB_HOST) 
$(CONFIG_USB_MUSB_DUAL_ROLE)),)
 Daniel +  musb_hdrc-y += musb_virthub.o 
musb_host.o
 Daniel +endif
 Daniel +
 Daniel +ifneq ($(filter y,$(CONFIG_USB_MUSB_GADGET) 
$(CONFIG_USB_MUSB_DUAL_ROLE)),)
 Daniel +  musb_hdrc-y += musb_gadget_ep0.o 
musb_gadget.o
 Daniel +endif

I believe unselected option values simply expand to the empty strings,
so these can just be:

musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_virthub.o 
musb_host.o

musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += 
musb_gadget_ep0.o musb_gadget.o

Other than that, it looks good:

Acked-by: Peter Korsgaard jac...@sunsite.dk

-- 
Bye, Peter Korsgaard
--
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 08/11] usb: musb: add musb_host_setup() and musb_host_cleanup()

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel This patch re-introduces the bits that are necessary to use the musb
 Daniel controller in host mode.

Acked-by: Peter Korsgaard jac...@sunsite.dk

-- 
Bye, Peter Korsgaard
--
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 09/11] usb: musb: re-introduce musb-port_mode

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel Define MUSB_PORT_MODE_{HOST,GADGET,DUAL_ROLE} and store the
 Daniel platform-specified value in struct musb.

 Daniel Note that MUSB_PORT_MODE_HOST has to be set to 1 in order to
 Daniel match existing device tree bindings which are already
 Daniel documented but in fact unusued.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com

It would have been nice to add an explicit reference to am33xx-usb.txt /
omap-usb.txt for the bindings, but that's minor (should those files be
combined?)

Acked-by: Peter Korsgaard jac...@sunsite.dk

 Daniel ---
 Daniel  drivers/usb/musb/musb_core.c | 1 +
 Daniel  drivers/usb/musb/musb_core.h | 7 +++
 Daniel  2 files changed, 8 insertions(+)

 Daniel diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel index fbcf5cb..2640d25 100644
 Daniel --- a/drivers/usb/musb/musb_core.c
 Daniel +++ b/drivers/usb/musb/musb_core.c
 Daniel @@ -1821,6 +1821,7 @@ musb_init_controller(struct device *dev, int 
nIrq, void __iomem *ctrl)
 musb- board_set_power = plat-set_power;
 musb- min_power = plat-min_power;
 musb- ops = plat-platform_ops;
 Daniel +  musb-port_mode = plat-mode;
 
 Daniel/* The musb_platform_init() call:
 Daniel *   - adjusts musb-mregs
 Daniel diff --git a/drivers/usb/musb/musb_core.h 
b/drivers/usb/musb/musb_core.h
 Daniel index 6b65847..174c097 100644
 Daniel --- a/drivers/usb/musb/musb_core.h
 Daniel +++ b/drivers/usb/musb/musb_core.h
 Daniel @@ -77,6 +77,12 @@ struct musb_ep;
 Daniel  #define is_peripheral_active(m)   (!(m)-is_host)
 Daniel  #define is_host_active(m) ((m)-is_host)
 
 Daniel +enum {
 Daniel +  MUSB_PORT_MODE_HOST = 1,
 Daniel +  MUSB_PORT_MODE_GADGET,
 Daniel +  MUSB_PORT_MODE_DUAL_ROLE,
 Daniel +};
 Daniel +
 Daniel  #ifdef CONFIG_PROC_FS
 Daniel  #include linux/fs.h
 Daniel  #define MUSB_CONFIG_PROC_FS
 Daniel @@ -356,6 +362,7 @@ struct musb {
 
 Danielu8  min_power;  /* vbus for periph, in 
mA/2 */
 
 Daniel +  int port_mode;  /* MUSB_PORT_MODE_* */
 Danielboolis_host;
 
 Danielint a_wait_bcon;/* VBUS timeout in 
msecs */
 Daniel -- 
 Daniel 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 10/11] usb: musb: use musb-port_mode

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel Initialize the host and gagdet subsystems of the musb driver only when
 Daniel the appropriate mode is selected from platform data, or device-tree
 Daniel information, respectively.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com

Acked-by: Peter Korsgaard jac...@sunsite.dk


 Daniel ---
 Daniel  drivers/usb/musb/musb_core.c| 22 +-
 Daniel  drivers/usb/musb/musb_virthub.c |  3 ++-
 Daniel  2 files changed, 19 insertions(+), 6 deletions(-)

 Daniel diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel index 2640d25..b3b9873 100644
 Daniel --- a/drivers/usb/musb/musb_core.c
 Daniel +++ b/drivers/usb/musb/musb_core.c
 Daniel @@ -1912,11 +1912,23 @@ musb_init_controller(struct device *dev, int 
nIrq, void __iomem *ctrl)
 musb- xceiv-state = OTG_STATE_B_IDLE;
 Daniel}
 
 Daniel -  status = musb_host_setup(musb, plat-power);
 Daniel -  if (status  0)
 Daniel -  goto fail3;
 Daniel -
 Daniel -  status = musb_gadget_setup(musb);
 Daniel +  switch (musb-port_mode) {
 Daniel +  case MUSB_PORT_MODE_HOST:
 Daniel +  status = musb_host_setup(musb, plat-power);
 Daniel +  break;
 Daniel +  case MUSB_PORT_MODE_GADGET:
 Daniel +  status = musb_gadget_setup(musb);
 Daniel +  break;
 Daniel +  case MUSB_PORT_MODE_DUAL_ROLE:
 Daniel +  status = musb_host_setup(musb, plat-power);
 Daniel +  if (status  0)
 Daniel +  goto fail3;
 Daniel +  status = musb_gadget_setup(musb);
 Daniel +  break;
 Daniel +  default:
 Daniel +  dev_err(dev, unsupported port mode %d\n, 
musb-port_mode);
 Daniel +  break;
 Daniel +  }
 
 Danielif (status  0)
 Danielgoto fail3;
 Daniel diff --git a/drivers/usb/musb/musb_virthub.c 
b/drivers/usb/musb/musb_virthub.c
 Daniel index 1e17c20..8d92ba2 100644
 Daniel --- a/drivers/usb/musb/musb_virthub.c
 Daniel +++ b/drivers/usb/musb/musb_virthub.c
 Daniel @@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
 Daniel * (b) vbus present/connect IRQ, peripheral mode;
 Daniel * (c) peripheral initiates, using SRP
 Daniel */
 Daniel -  if ((devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 Daniel +  if (musb-port_mode != MUSB_PORT_MODE_HOST 
 Daniel +  (devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 musb- is_active = 1;
 Daniel} else {
 Danieldevctl |= MUSB_DEVCTL_SESSION;
 Daniel -- 
 Daniel 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 v3] staging: dwc2: toggle periodic debugging output separately

2013-04-10 Thread Matthijs Kooijman
This adds a config option USB_DWC2_DEBUG_PERIODIC that allows debugging
output be suppressed for periodic transfers. This helps when debugging
non-periodic transfers while there are also periodic transfers going on
(both to make the debug output less polluted and to prevent all CPU time
going to debug messages).

In addition, a debug message from dwc2_hcd_is_status_changed is removed
entirely, since it often floods the log regardless of periodic
transfers.

Signed-off-by: Matthijs Kooijman matth...@stdin.nl

---
v2: fix some coding style issues
v3: convert dbg_* macros to static inline functions.
introduce dbg_perio() function to remove all #ifdefs from .c files

 One question - is this meant to be applied now, or is it based on top of
 your previous patch series which you are redoing?
This is meant to be applied now, all my other patches have been
developed on top of this one.
---
 drivers/staging/dwc2/Kconfig |  10 ++
 drivers/staging/dwc2/core.c  | 266 ---
 drivers/staging/dwc2/hcd.c   |  63 ++
 drivers/staging/dwc2/hcd.h   |  27 
 drivers/staging/dwc2/hcd_intr.c  | 117 ++---
 drivers/staging/dwc2/hcd_queue.c |   6 +-
 6 files changed, 318 insertions(+), 171 deletions(-)

diff --git a/drivers/staging/dwc2/Kconfig b/drivers/staging/dwc2/Kconfig
index bc4cdfe..2f75be7 100644
--- a/drivers/staging/dwc2/Kconfig
+++ b/drivers/staging/dwc2/Kconfig
@@ -39,4 +39,14 @@ config USB_DWC2_TRACK_MISSED_SOFS
  Say Y here to enable logging of missed SOF events to the dmesg log.
  If in doubt, say N.
 
+config USB_DWC2_DEBUG_PERIODIC
+   bool Enable Debugging Messages For Periodic Transfers
+   depends on USB_DWC2_DEBUG || USB_DWC2_VERBOSE
+   default y
+   help
+ Say N here to disable (verbose) debugging messages to be
+ logged for periodic transfers. This allows better debugging of
+ non-periodic transfers, but of course the debug logs will be
+ incomplete. Note that this also disables some debug messages
+ for which the transfer type cannot be deduced.
 endif
diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index f695a9b0..549cd3d 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -717,7 +717,8 @@ static void dwc2_hc_enable_slave_ints(struct dwc2_hsotg 
*hsotg,
break;
 
case USB_ENDPOINT_XFER_INT:
-   dev_vdbg(hsotg-dev, intr\n);
+   if (dbg_perio())
+   dev_vdbg(hsotg-dev, intr\n);
hcintmsk |= HCINTMSK_XFERCOMPL;
hcintmsk |= HCINTMSK_NAK;
hcintmsk |= HCINTMSK_STALL;
@@ -738,7 +739,8 @@ static void dwc2_hc_enable_slave_ints(struct dwc2_hsotg 
*hsotg,
break;
 
case USB_ENDPOINT_XFER_ISOC:
-   dev_vdbg(hsotg-dev, isoc\n);
+   if (dbg_perio())
+   dev_vdbg(hsotg-dev, isoc\n);
hcintmsk |= HCINTMSK_XFERCOMPL;
hcintmsk |= HCINTMSK_FRMOVRUN;
hcintmsk |= HCINTMSK_ACK;
@@ -754,7 +756,8 @@ static void dwc2_hc_enable_slave_ints(struct dwc2_hsotg 
*hsotg,
}
 
writel(hcintmsk, hsotg-regs + HCINTMSK(chan-hc_num));
-   dev_vdbg(hsotg-dev, set HCINTMSK to %08x\n, hcintmsk);
+   if (dbg_hc(chan))
+   dev_vdbg(hsotg-dev, set HCINTMSK to %08x\n, hcintmsk);
 }
 
 static void dwc2_hc_enable_dma_ints(struct dwc2_hsotg *hsotg,
@@ -767,17 +770,20 @@ static void dwc2_hc_enable_dma_ints(struct dwc2_hsotg 
*hsotg,
 * Interrupt is not required.
 */
if (hsotg-core_params-dma_desc_enable = 0) {
-   dev_vdbg(hsotg-dev, desc DMA disabled\n);
+   if (dbg_hc(chan))
+   dev_vdbg(hsotg-dev, desc DMA disabled\n);
hcintmsk |= HCINTMSK_AHBERR;
} else {
-   dev_vdbg(hsotg-dev, desc DMA enabled\n);
+   if (dbg_hc(chan))
+   dev_vdbg(hsotg-dev, desc DMA enabled\n);
if (chan-ep_type == USB_ENDPOINT_XFER_ISOC)
hcintmsk |= HCINTMSK_XFERCOMPL;
}
 
if (chan-error_state  !chan-do_split 
chan-ep_type != USB_ENDPOINT_XFER_ISOC) {
-   dev_vdbg(hsotg-dev, setting ACK\n);
+   if (dbg_hc(chan))
+   dev_vdbg(hsotg-dev, setting ACK\n);
hcintmsk |= HCINTMSK_ACK;
if (chan-ep_is_in) {
hcintmsk |= HCINTMSK_DATATGLERR;
@@ -787,7 +793,8 @@ static void dwc2_hc_enable_dma_ints(struct dwc2_hsotg 
*hsotg,
}
 
writel(hcintmsk, hsotg-regs + HCINTMSK(chan-hc_num));
-   dev_vdbg(hsotg-dev, set HCINTMSK to %08x\n, hcintmsk);
+   if (dbg_hc(chan))
+   dev_vdbg(hsotg-dev, set HCINTMSK to %08x\n, hcintmsk);
 }
 
 static void dwc2_hc_enable_ints(struct dwc2_hsotg *hsotg,
@@ -796,10 +803,12 @@ 

Re: [PATCH v2 11/11] usb: musb: eliminate musb_to_hcd

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel With the hcd is now a direct member of struct musb, we can now simply
 Daniel eliminate the musb_to_hcd() macro. There aren't that many users left
 Daniel anyway, as some where already fixed up when parts were factored out to
 Daniel musb_host.c

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com

You seem to have forgotten to remove the musb_to_hcd() implementation.

With that fixed:

Acked-by: Peter Korsgaard jac...@sunsite.dk

 Daniel ---
 Daniel  drivers/usb/musb/musb_core.c| 4 ++--
 Daniel  drivers/usb/musb/musb_host.c| 8 
 Daniel  drivers/usb/musb/musb_virthub.c | 6 +++---
 Daniel  3 files changed, 9 insertions(+), 9 deletions(-)

 Daniel diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel index b3b9873..57b7a17 100644
 Daniel --- a/drivers/usb/musb/musb_core.c
 Daniel +++ b/drivers/usb/musb/musb_core.c
 Daniel @@ -389,7 +389,7 @@ static void musb_otg_timer_func(unsigned long data)
 Daniel   */
 Daniel  void musb_hnp_stop(struct musb *musb)
 Daniel  {
 Daniel -  struct usb_hcd  *hcd = musb_to_hcd(musb);
 Daniel +  struct usb_hcd  *hcd = musb-hcd;
 Danielvoid __iomem*mbase = musb-mregs;
 Danielu8  reg;
 
 Daniel @@ -686,7 +686,7 @@ static irqreturn_t musb_stage0_irq(struct musb 
*musb, u8 int_usb,
 Daniel}
 
 Danielif (int_usb  MUSB_INTR_CONNECT) {
 Daniel -  struct usb_hcd *hcd = musb_to_hcd(musb);
 Daniel +  struct usb_hcd *hcd = musb-hcd;
 
 Danielhandled = IRQ_HANDLED;
 musb- is_active = 1;
 Daniel diff --git a/drivers/usb/musb/musb_host.c 
b/drivers/usb/musb/musb_host.c
 Daniel index b6a840e..d3cbaa3 100644
 Daniel --- a/drivers/usb/musb/musb_host.c
 Daniel +++ b/drivers/usb/musb/musb_host.c
 Daniel @@ -320,9 +320,9 @@ __acquires(musb-lock)
 urb- actual_length, urb-transfer_buffer_length
 Daniel);
 
 Daniel -  usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb);
 Daniel +  usb_hcd_unlink_urb_from_ep(musb-hcd, urb);
 Danielspin_unlock(musb-lock);
 Daniel -  usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status);
 Daniel +  usb_hcd_giveback_urb(musb-hcd, urb, status);
 Danielspin_lock(musb-lock);
 Daniel  }
 
 Daniel @@ -1465,7 +1465,7 @@ done:
 Danielif (length  qh-maxpacket)
 Daniellength = qh-maxpacket;
 Daniel/* Unmap the buffer so that CPU can use it */
 Daniel -  usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb);
 Daniel +  usb_hcd_unmap_urb_for_dma(musb-hcd, urb);
 
 Daniel/*
 Daniel * We need to map sg if the transfer_buffer is
 Daniel @@ -1880,7 +1880,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
 Danielunsigned int received_len;
 
 Daniel/* Unmap the buffer so that CPU can use it */
 Daniel -  usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), 
urb);
 Daniel +  usb_hcd_unmap_urb_for_dma(musb-hcd, urb);
 
 Daniel/*
 Daniel * We need to map sg if the transfer_buffer is
 Daniel diff --git a/drivers/usb/musb/musb_virthub.c 
b/drivers/usb/musb/musb_virthub.c
 Daniel index 8d92ba2..5a101fe 100644
 Daniel --- a/drivers/usb/musb/musb_virthub.c
 Daniel +++ b/drivers/usb/musb/musb_virthub.c
 Daniel @@ -215,7 +215,7 @@ static void musb_port_reset(struct musb *musb, 
bool do_reset)
 musb- port1_status |= USB_PORT_STAT_ENABLE
 Daniel| (USB_PORT_STAT_C_RESET  16)
 Daniel| (USB_PORT_STAT_C_ENABLE  
16);
 Daniel -  usb_hcd_poll_rh_status(musb_to_hcd(musb));
 Daniel +  usb_hcd_poll_rh_status(musb-hcd);
 
 musb- vbuserr_retry = VBUSERR_RETRY_COUNT;
 Daniel}
 Daniel @@ -228,7 +228,7 @@ void musb_root_disconnect(struct musb *musb)
 musb- port1_status = USB_PORT_STAT_POWER
 Daniel| (USB_PORT_STAT_C_CONNECTION  16);
 
 Daniel -  usb_hcd_poll_rh_status(musb_to_hcd(musb));
 Daniel +  usb_hcd_poll_rh_status(musb-hcd);
 musb- is_active = 0;
 
 Danielswitch (musb-xceiv-state) {
 Daniel @@ -382,7 +382,7 @@ int musb_hub_control(
 musb- port1_status = ~(USB_PORT_STAT_SUSPEND
 Daniel| MUSB_PORT_STAT_RESUME);
 musb- port1_status |= USB_PORT_STAT_C_SUSPEND  16;
 Daniel -  usb_hcd_poll_rh_status(musb_to_hcd(musb));
 Daniel +  usb_hcd_poll_rh_status(musb-hcd);
 Daniel/* NOTE: it might really be A_WAIT_BCON ... */
 musb- xceiv-state = OTG_STATE_A_HOST;
 Daniel}
 Daniel -- 
 Daniel 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 05/11] usb: musb: move musb_start to musb_virthub.c

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel This function has its only user in musb_virthub.c, so let's move it
 Daniel there and make it static.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com

Acked-by: Peter Korsgaard jac...@sunsite.dk

 Daniel ---
 Daniel  drivers/usb/musb/musb_core.c| 45 
-
 Daniel  drivers/usb/musb/musb_core.h|  1 -
 Daniel  drivers/usb/musb/musb_virthub.c | 44 

 Daniel  3 files changed, 44 insertions(+), 46 deletions(-)

 Daniel diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel index 13341c6..adf069d 100644
 Daniel --- a/drivers/usb/musb/musb_core.c
 Daniel +++ b/drivers/usb/musb/musb_core.c
 Daniel @@ -905,51 +905,6 @@ b_host:
 
 Daniel  
/*-*/
 
 Daniel -/*
 Daniel -* Program the HDRC to start (enable interrupts, dma, etc.).
 Daniel -*/
 Daniel -void musb_start(struct musb *musb)
 Daniel -{
 Daniel -  void __iomem*regs = musb-mregs;
 Daniel -  u8  devctl = musb_readb(regs, MUSB_DEVCTL);
 Daniel -
 Daniel -  dev_dbg(musb-controller, == devctl %02x\n, devctl);
 Daniel -
 Daniel -  /*  Set INT enable registers, enable interrupts */
 Daniel -  musb-intrtxe = musb-epmask;
 Daniel -  musb_writew(regs, MUSB_INTRTXE, musb-intrtxe);
 Daniel -  musb-intrrxe = musb-epmask  0xfffe;
 Daniel -  musb_writew(regs, MUSB_INTRRXE, musb-intrrxe);
 Daniel -  musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
 Daniel -
 Daniel -  musb_writeb(regs, MUSB_TESTMODE, 0);
 Daniel -
 Daniel -  /* put into basic highspeed mode and start session */
 Daniel -  musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
 Daniel -  | MUSB_POWER_HSENAB
 Daniel -  /* ENSUSPEND wedges 
tusb */
 Daniel -  /* | 
MUSB_POWER_ENSUSPEND */
 Daniel -  );
 Daniel -
 Daniel -  musb-is_active = 0;
 Daniel -  devctl = musb_readb(regs, MUSB_DEVCTL);
 Daniel -  devctl = ~MUSB_DEVCTL_SESSION;
 Daniel -
 Daniel -  /* session started after:
 Daniel -   * (a) ID-grounded irq, host mode;
 Daniel -   * (b) vbus present/connect IRQ, peripheral mode;
 Daniel -   * (c) peripheral initiates, using SRP
 Daniel -   */
 Daniel -  if ((devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
 Daniel -  musb-is_active = 1;
 Daniel -  else
 Daniel -  devctl |= MUSB_DEVCTL_SESSION;
 Daniel -
 Daniel -  musb_platform_enable(musb);
 Daniel -  musb_writeb(regs, MUSB_DEVCTL, devctl);
 Daniel -}
 Daniel -
 Daniel -
 Daniel  static void musb_generic_disable(struct musb *musb)
 Daniel  {
 Danielvoid __iomem*mbase = musb-mregs;
 Daniel diff --git a/drivers/usb/musb/musb_core.h 
b/drivers/usb/musb/musb_core.h
 Daniel index 04d8974..87da041 100644
 Daniel --- a/drivers/usb/musb/musb_core.h
 Daniel +++ b/drivers/usb/musb/musb_core.h
 Daniel @@ -503,7 +503,6 @@ static inline void musb_configure_ep0(struct musb 
*musb)
 
 Daniel  extern const char musb_driver_name[];
 
 Daniel -extern void musb_start(struct musb *musb);
 Daniel  extern void musb_stop(struct musb *musb);
 
 Daniel  extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 
*src);
 Daniel diff --git a/drivers/usb/musb/musb_virthub.c 
b/drivers/usb/musb/musb_virthub.c
 Daniel index ef7d110..1e17c20 100644
 Daniel --- a/drivers/usb/musb/musb_virthub.c
 Daniel +++ b/drivers/usb/musb/musb_virthub.c
 Daniel @@ -44,6 +44,50 @@
 
 Daniel  #include musb_core.h
 
 Daniel +/*
 Daniel +* Program the HDRC to start (enable interrupts, dma, etc.).
 Daniel +*/
 Daniel +static void musb_start(struct musb *musb)
 Daniel +{
 Daniel +  void __iomem*regs = musb-mregs;
 Daniel +  u8  devctl = musb_readb(regs, MUSB_DEVCTL);
 Daniel +
 Daniel +  dev_dbg(musb-controller, == devctl %02x\n, devctl);
 Daniel +
 Daniel +  /*  Set INT enable registers, enable interrupts */
 Daniel +  musb-intrtxe = musb-epmask;
 Daniel +  musb_writew(regs, MUSB_INTRTXE, musb-intrtxe);
 Daniel +  musb-intrrxe = musb-epmask  0xfffe;
 Daniel +  musb_writew(regs, MUSB_INTRRXE, musb-intrrxe);
 Daniel +  musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
 Daniel +
 Daniel +  musb_writeb(regs, MUSB_TESTMODE, 0);
 Daniel +
 Daniel +  /* put into basic highspeed mode and start session */
 Daniel +  musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
 Daniel +  | MUSB_POWER_HSENAB
 Daniel +  /* ENSUSPEND wedges 
tusb */
 Daniel +  /* | 
MUSB_POWER_ENSUSPEND */
 Daniel +  );
 Daniel +
 Daniel +  musb-is_active = 0;
 

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-10 Thread Mike Turquette
Quoting Nishanth Menon (2013-04-09 13:49:00)
 On 10:43-20130409, Tony Lindgren wrote:
  * Tony Lindgren t...@atomide.com [130409 09:54]:
   * Roger Quadros rog...@ti.com [130409 03:00]:
On 04/05/2013 06:58 PM, Tony Lindgren wrote:
 
 Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get
a phandle or an index to the clock.

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
   
   Yes I understand that. But the driver/clock/omap driver can just
   remap the DT device initially so the board specific clock is
   found from the clock alias table. Basically initially a passthrough
   driver that can be enhanced to parse DT clock bindings and load
   data from /lib/firmware.
  
  Actually probably the driver/clock/omap can even do even less
  initially. There probably even no need to remap clocks there.
  
  As long as the DT clock driver understands that a board specific
  auxclk is specified in the DT it can just call clk_add_alias() so
  the driver will get the right auxclk from cclock44xx_data.c.
  
  Then other features can be added later on like to allocate a
  clock entirely based on the binding etc.
 I did try to have an implementation for cpufreq using clock nodes.
 unfortunately, device tree wont let me have arguments of strings :(
 So, I am unable to do clock = clk mpu_dpll;
 instead, I am forced to do clock = clk 249;
 

See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034

Regards,
Mike

 Here is an attempt on beagleXM - adds every clock node to the list.
 Tons of un-necessary prints added to give an idea - see log:
 http://pastebin.com/F9A2zSTr
 
 Would an cleaned up version be good enough as a step #1 of transition?
 
 From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
 From: Nishanth Menon n...@ti.com
 Date: Tue, 26 Mar 2013 10:23:27 +
 Subject: [PATCH] OMAP: add devicetree support for clock nodes.
 
 Dummy patch based on Roger's original idea
 
 Nyet-Signed-off-by: Nishanth Menon n...@ti.com
 ---
  arch/arm/boot/dts/omap3.dtsi  |5 ++
  arch/arm/boot/dts/omap34xx.dtsi   |2 +
  arch/arm/mach-omap2/cclock3xxx_data.c |3 +-
  arch/arm/mach-omap2/cclock44xx_data.c |3 +-
  arch/arm/mach-omap2/pm.c  |   11 +++-
  drivers/clk/Kconfig   |6 ++
  drivers/clk/Makefile  |2 +
  drivers/clk/ti.c  |  100 
 +
  include/linux/clk/ti.h|   30 ++
  9 files changed, 157 insertions(+), 5 deletions(-)
  create mode 100644 drivers/clk/ti.c
  create mode 100644 include/linux/clk/ti.h
 
 diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
 index 3344f05..a08990d 100644
 --- a/arch/arm/boot/dts/omap3.dtsi
 +++ b/arch/arm/boot/dts/omap3.dtsi
 @@ -73,6 +73,11 @@
 ti,hwmods = counter_32k;
 };
  
 +   clks: clocks {
 +   compatible = ti,clock;
 +   #clock-cells = 1;
 +   };
 +
 intc: interrupt-controller@4820 {
 compatible = ti,omap2-intc;
 interrupt-controller;
 diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
 index 75ed4ae..93c2621 100644
 --- a/arch/arm/boot/dts/omap34xx.dtsi
 +++ b/arch/arm/boot/dts/omap34xx.dtsi
 @@ -23,6 +23,8 @@
 60  135
 ;
 clock-latency = 30; /* From legacy driver */
 +   clocks = clks 249; /* index to cpufreq_ck */
 +   clock-names = cpu;
 };
 };
  };
 diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c 
 b/arch/arm/mach-omap2/cclock3xxx_data.c
 index 4579c3c..d5d5ef5 100644
 --- a/arch/arm/mach-omap2/cclock3xxx_data.c
 +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
 @@ -22,6 +22,7 @@
  #include linux/clk-private.h
  #include linux/list.h
  #include linux/io.h
 +#include linux/clk/ti.h
  
  #include soc.h
  #include iomap.h
 @@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
 for (c = omap3xxx_clks; c  omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
  c++)
 if (c-cpu  cpu_clkflg) {
 -   clkdev_add(c-lk);
 +   ti_clk_node_add(c-lk);
 if (!__clk_init(NULL, c-lk.clk))
 omap2_init_clk_hw_omap_clocks(c-lk.clk);
 }
 diff --git a/arch/arm/mach-omap2/cclock44xx_data.c 
 b/arch/arm/mach-omap2/cclock44xx_data.c
 index 0c6834a..338ef64 100644
 --- a/arch/arm/mach-omap2/cclock44xx_data.c
 +++ b/arch/arm/mach-omap2/cclock44xx_data.c
 @@ -27,6 +27,7 @@
  #include linux/clk-private.h
  #include linux/clkdev.h
  #include linux/io.h
 +#include linux/clk/ti.h
  
  #include soc.h
  #include iomap.h
 @@ -1697,7 

Re: [PATCH v2 00/11] usb: musb: add back support for host mode

2013-04-10 Thread Felipe Balbi
On Wed, Apr 10, 2013 at 09:10:19AM +0200, Daniel Mack wrote:
 On 08.04.2013 12:38, B, Ravi wrote:
  Felipe
  
  Hi,
  
  On Mon, Apr 08, 2013 at 12:25:38PM +0200, B, Ravi wrote:
  Daniel
  
  On 08.04.2013 09:57, B, Ravi wrote:
  Hi all,
  
  here are some patches to separate the HCD and gadget part
  of the
  musb
  driver so they can be deselected in Kconfig. They also make
  the
  driver
  keep track of the configured port mode that is set from DT,
  so the actual runtime configuration can be selected
  dynamically.
  
  One thing that is still broken is that once pm_suspend()
  was called
  on
  a musb device on a USB disconnect, the port won't wake up
  again
  when a
  device is plugged back in.
  
  This could be due to SESSION bit removal when root port is
  disconnected
  in otg_timer function.
  
  Not sure if we are thinking about the same details, but after
  debuging this a further, turns out that
  musb_platform_try_idle() eventually switches off the entire
  controller, which then leads to DRVBUS going
  low
  on the board. That, in turn, prevents the interrupt from being
  triggered
  on reconnect, because the host port is not powered anymore.
  
  I don't know yet how to cope with that, but for now, I simply
  disabled the call from musb_stage0_irq() to
  musb_platform_try_idle() locally.
  
  The otg_timer() gets invoked, which removes the session when no
  device connected to root controller, this is required in otg or
  dual role mode (Not for host-only mode). Because otg state is
  un-defined till user's connected a-side of b-side of cable.
  
  Embedded hosts might also want this to save some power while no
  devices are connected. I guess most of those devices would rely on
  SRP or on a polling method to enable VBUS.
  
  Yes, in case of true otg, SRP wakesup the device to enable VBUS.
  
  By 'polling' I mean that e.g. every 2
  seconds turn vbus on, if no device are enumerated in 200ms, then
  sleep for another 2 seconds.
  
  Yes, we had this workaround mechanism enabled on some earlier davinci
  platform by setting the session periodically to check any device
  connected for host or otg/dual-role controller to save VBUS power
  when no device connected.
 
 However, this workaround doesn't seem to work anymore.
 
 Anyway, I think we can address this issue separately from the patch set
 I submitted.

correct

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2] staging: dwc2: toggle periodic debugging output separately

2013-04-10 Thread Felipe Balbi
Hi,

On Tue, Apr 09, 2013 at 07:35:33PM +0200, Matthijs Kooijman wrote:
   This adds a config option USB_DWC2_DEBUG_PERIODIC that allows debugging
   output be suppressed for periodic transfers. This helps when debugging
   non-periodic transfers while there are also periodic transfers going on
   (both to make the debug output less polluted and to prevent all CPU time
   going to debug messages).
   [...]
   Signed-off-by: Matthijs Kooijman matth...@stdin.nl
 
  why don't you just use dynamic printk instead ?
 In some cases, this could help, but a lot of the prints modified by this
 patch are used for both periodic and non-periodic transfers. AFAIU, with
 dynamic printks you could only enable/disable them altogether, not based
 on some arbitrary condition (e.g., the urb being handled is targeted at
 a periodic endpoint or not).

you can enable prints line-by-line

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 4/9] rcar-phy: remove EHCI internal buffer setup

2013-04-10 Thread Felipe Balbi
Hi,

On Wed, Apr 10, 2013 at 02:32:30AM +0400, Sergei Shtylyov wrote:
 Now that the EHCI internal  buffer setup is done by the platform code, we  can
 remove  such code from this driver as it  never  really belonged here.  We 
 also
 no longer need the 2nd memory region now (2nd EHCI controller is simply 
 missing
 in e.g. R8A7778 SoC).
 
 The patch has been tested on the Marzen and BOCK-W boards.
 
 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
 Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 Acked-by: Simon Horman horms+rene...@verge.net.au
 
 ---
 Changes since version 2:
 - added a note about testing to the changelog;
 - added ACKs from Simon Horman and Kuninori Morimoto.
 
 Changes since the original posting:
 - split R8A7779 SoC file change to a separate patch.
 
  drivers/usb/phy/rcar-phy.c |   28 

you do realise this won't apply, right ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2] staging: dwc2: toggle periodic debugging output separately

2013-04-10 Thread Matthijs Kooijman
Hi Felipe,

  In some cases, this could help, but a lot of the prints modified by this
  patch are used for both periodic and non-periodic transfers. AFAIU, with
  dynamic printks you could only enable/disable them altogether, not based
  on some arbitrary condition (e.g., the urb being handled is targeted at
  a periodic endpoint or not).
 
 you can enable prints line-by-line
Yeah, I know that. But my point is that some prints are used for both
periodic and non-periodic transfers. So when I enable them, my log gets
flooded with the messages resulting from periodic transfers, locking up
my board. But when I disable them, I obviously don't get any useful
debugging info for the non-periodic transfers I'm looking at...

Gr.

Matthijs
--
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 00/11] usb: musb: add back support for host mode

2013-04-10 Thread Daniel Mack
On 10.04.2013 10:09, Felipe Balbi wrote:
 On Wed, Apr 10, 2013 at 09:10:19AM +0200, Daniel Mack wrote:
 On 08.04.2013 12:38, B, Ravi wrote:
 Felipe

 Hi,

 On Mon, Apr 08, 2013 at 12:25:38PM +0200, B, Ravi wrote:
 Daniel

 On 08.04.2013 09:57, B, Ravi wrote:
 Hi all,

 here are some patches to separate the HCD and gadget part
 of the
 musb
 driver so they can be deselected in Kconfig. They also make
 the
 driver
 keep track of the configured port mode that is set from DT,
 so the actual runtime configuration can be selected
 dynamically.

 One thing that is still broken is that once pm_suspend()
 was called
 on
 a musb device on a USB disconnect, the port won't wake up
 again
 when a
 device is plugged back in.

 This could be due to SESSION bit removal when root port is
 disconnected
 in otg_timer function.

 Not sure if we are thinking about the same details, but after
 debuging this a further, turns out that
 musb_platform_try_idle() eventually switches off the entire
 controller, which then leads to DRVBUS going
 low
 on the board. That, in turn, prevents the interrupt from being
 triggered
 on reconnect, because the host port is not powered anymore.

 I don't know yet how to cope with that, but for now, I simply
 disabled the call from musb_stage0_irq() to
 musb_platform_try_idle() locally.

 The otg_timer() gets invoked, which removes the session when no
 device connected to root controller, this is required in otg or
 dual role mode (Not for host-only mode). Because otg state is
 un-defined till user's connected a-side of b-side of cable.

 Embedded hosts might also want this to save some power while no
 devices are connected. I guess most of those devices would rely on
 SRP or on a polling method to enable VBUS.

 Yes, in case of true otg, SRP wakesup the device to enable VBUS.

 By 'polling' I mean that e.g. every 2
 seconds turn vbus on, if no device are enumerated in 200ms, then
 sleep for another 2 seconds.

 Yes, we had this workaround mechanism enabled on some earlier davinci
 platform by setting the session periodically to check any device
 connected for host or otg/dual-role controller to save VBUS power
 when no device connected.

 However, this workaround doesn't seem to work anymore.

 Anyway, I think we can address this issue separately from the patch set
 I submitted.
 
 correct
 

Ok, I'll amend my patches to include Peter's reports and resend? Or
should I wait for more comments from you?


Thanks,
Daniel

--
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 to SPI driver for MCP2210

2013-04-10 Thread Felipe Balbi
Hi,

On Tue, Apr 09, 2013 at 02:00:46PM -0500, Daniel Santos wrote:
 My bother  I are working on a project where we're planning on using
 these inexpensive Microchip MCP2210 USB to SPI bridge w/ GPIO
 devices.  Mathew King at Trilithic started a driver and kindly
 released it on github (https://github.com/MathewKing/mcp2210-linux),
 but he wont be using the chip or developing the driver further, so
 I'm picking it up (and with his blessings even! :)  However, rather
 than a driver written specifically for our product, I would like a
 generic or abstract MCP2210 driver that can be re-used by others. So
 how do I go about this?
 I'm not sure you can. There is no standardization wrt USB to SPI
 bridges, so your device implements a proprietary protocol (even if
 simple).
 
 I'm still pretty new to Linux device drivers  the device driver
 model, so there may be existing abstractions  libraries that I'm
 just not yet aware of.  We're not planning on changing the USB
 vendor/product ID (as I'm sure many users of this chip will opt) and
 each or our devices can have different hardware  wirings attached to
 the MCP2210.  Since SPI devices cannot be auto-configured, we plan to
 this might cause problems. If everybody has the same idVendor/idProduct
 pair but functionality is different... ugh
 Well, we don't have the $3500 for a vendor id. :(  I presume that
 others may do the same thing, hopefully mostly with DIY-type of
 projects.

heh :-)

 Your core driver would instantiate each of those children devices based
 on what's the requested state of the pin.
 
 * Finally, retrieve the (previously stored) data from the 256 bytes
 of user non-volatile EEPROM.  On this, we plan to store the device
 information that each of the GP pins configured for SPI CS lines are
 connected as well as the use for any GPIO lines.  (Pins configured
 for dedicated function need no other information.)
 is this mandatory, or something you decided to do ? If it's mandatory to
 program pin assignment like that, then you can very easily figure out
 how to use that information to instantiate proper children during your
 core driver's probe routine.
 
 Well, I guess I need to be more clear about this.  I'm talking about
 3 separate entities really:
 
 1. the MCP2210 chip its self,
 2. the hardware device that I'm creating that makes use of this chip and
 3. any hardware devices that others may create with it.
 
 So one idea of how to do this is to have generic MCP2210 driver that
 does pretty much nothing by its self (not 100% sure how this should
 work).  Then, I would have a driver for my device, that would use the
 generic MCP2210 driver to manage all of the communication with the
 MCP2210 and I would simply feed it my hardware configuration (wiring,
 SPI timings, etc.), causing it to expose SPI devices, GPIO lines,
 LEDs, etc. as you described.  Then, a 3rd party could do the same
 (hopefully, they will modify the idVendor  idProduct though. :)  I
 suppose there's room for an MCP2210 userspace driver that utilizes
 the generic one to interface with the chip and just provides an
 interface to userspace, but I'm not personally interested in such a
 thing myself.
 
 So I'm thinking that with my own driver, I would look for the
 idVendor and idProduct of the unmodified MCP2210 (because I'm a poor
 bastard) and then -ENODEV unless the product  mfg strings also

no need to look for it, just use the id_table to match your idVendor and
idProduct. Driver model will make sure to bind your device properly so
you can assume that if your probe() has been called, it's because driver
model has found idVendor/idProduct properly.

 match.  Then, I can read the EEPROM to cook up my config.  (One
 complexity is that our device can have various features  hardware
 present or not, so that's another reason for us to stick the hardware
 setup in the EEPROM.)

alright.

 Does that make sense? Also, the generic driver then becomes more of
 a library than an actual driver, huh?

I think it should still be a driver, just an MFD driver.

 If it's not mandatory, then it gets tricky to support multiple users.
 Can users write whatever they want to EEPROM or is there a specified
 format ?
 
 The MCP2210 allows you to write-protect the persistent settings
 (including the EEPROM contents) with a password or just permanently
 lock them.  You have to issue USB commands to alter the EEPROM and I
 don't plan on exposing that to userspace from the driver for my
 product.  So if anybody changes them, its their own damn fault. :)

right on ;-)

 In any case, there are ways to make it work, just some are easier to
 code then the others ;-)
 
 Well this helps a great deal, thank you!  I want to try to keep this
 simple, but I also would like it to be re-usable.  There are
 currently USB to serial, 1-wire and I think i2c in the kernel already
 and I would expect this class of device will become more prevalent in
 the future.

my suggestion would be: write it very simple, if in the 

Re: [PATCH v3 0/9] Reorganize R8A7779/Marzen USB code

2013-04-10 Thread Felipe Balbi
Hi,

On Wed, Apr 10, 2013 at 01:49:23PM +0900, Simon Horman wrote:
 On Wed, Apr 10, 2013 at 02:26:08AM +0400, Sergei Shtylyov wrote:
  Hello.
  
 Here's the set of 9 patches against the Simon Horman's 'renesas.git' 
  repo,
  'renesas-next-20130410' tag.  It was created to fix the shortcomings in the
  R8A7779/Marzen USB platform code and R8A7779 USB common PHY driver, and so
  spans both arch/arm/mach-shmobile/ and drivers/usb/ subtrees (some patches 
  have
  to touch both subtrees). The patches were conceived with the complete
  bisectability goal in mind.
  
  [1/9] ARM: shmobile: Marzen: move USB EHCI, OHCI, and PHY devices to 
  R8A7779 code
  [2/9] ehci-platform: add pre_setup() method to platform data
  [3/9] ARM: shmobile: R8A7779: setup EHCI internal buffer
  [4/9] rcar-phy: remove EHCI internal buffer setup
  [5/9] ARM: shmobile: R8A7779: remove USB PHY 2nd memory resource
  [6/9] rcar-phy: correct base address
  [7/9] rcar-phy: add platform data
  [8/9] ARM: shmobile: Marzen: pass platform data to USB PHY device
  [9/9] rcar-phy: handle platform data
  
 I'm not sure thru which tree this patchset should be merged, however it 
  turns
  out that it's too late now to push it thru Felipe Balbi's USB tree for 3.10
  (which would have been most convenient probably), and it's probably too 
  late to
  merge thru Simon's tree for 3.10 too. So it now have to be postponed to 
  3.11,
  unfortunately...
 
 Felipe, how would you prefer to handle this?
 I'm happy for you to take it or to take it myself.

please take it yourself, just keep in mind there will be conflicts, I
will go over the patches now and give my Acked-by so you can queue them
up.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 4/9] rcar-phy: remove EHCI internal buffer setup

2013-04-10 Thread Felipe Balbi
On Wed, Apr 10, 2013 at 02:32:30AM +0400, Sergei Shtylyov wrote:
 Now that the EHCI internal  buffer setup is done by the platform code, we  can
 remove  such code from this driver as it  never  really belonged here.  We 
 also
 no longer need the 2nd memory region now (2nd EHCI controller is simply 
 missing
 in e.g. R8A7778 SoC).
 
 The patch has been tested on the Marzen and BOCK-W boards.
 
 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
 Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 Acked-by: Simon Horman horms+rene...@verge.net.au

Acked-by: Felipe Balbi ba...@ti.com

Note that this will conflict with my latest phy changes since all phy
drivers got renamed.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 6/9] rcar-phy: correct base address

2013-04-10 Thread Felipe Balbi
Hi,

On Wed, Apr 10, 2013 at 02:36:50AM +0400, Sergei Shtylyov wrote:
 The memory region that is used by the driver overlaps EHCI and OHCI  register
 regions for absolutely no reason now  -- fix it  by adding offset of 0x800 to
 the base address, changing the register #define's accordingly. This has extra
 positive effect that we now can use devm_ioremap_resource()...
 
 Note that the driver and the SoC code have to be in one patch to keep the code
 bisectable...
 
 The patch has been tested on the Marzen board.
 
 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
 Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 Acked-by: Simon Horman horms+rene...@verge.net.au

Acked-by: Felipe Balbi ba...@ti.com

This will conflict with latest phy changes but it's only a rename issue.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 7/9] rcar-phy: add platform data

2013-04-10 Thread Felipe Balbi
Hi,

On Wed, Apr 10, 2013 at 02:37:49AM +0400, Sergei Shtylyov wrote:
 Currently the driver hard-codes USBPCTRL0 register to 0.  It is wrong since 
 this
 register contains board-specific USB ports configuration and so its value 
 should
 be somehow passed via the platform data.  Add linux/usb/rcar-phy.h file with
 the USBPCTRL0 bit #define's and 'struct rcar_phy_platform_data' containing the
 value to be set by the driver to that register.
 
 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
 Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 Acked-by: Simon Horman horms+rene...@verge.net.au
 
 ---
 Changes since version 2:
 - added #include linux/types.h;
 - added ACKs from Simon Horman and Kuninori Morimoto.
 
  include/linux/usb/rcar-phy.h |   40 
  1 file changed, 40 insertions(+)
 
 Index: renesas/include/linux/usb/rcar-phy.h
 ===
 --- /dev/null
 +++ renesas/include/linux/usb/rcar-phy.h
 @@ -0,0 +1,40 @@
 +/*
 + * Copyright (C) 2013 Renesas Solutions Corp.
 + * Copyright (C) 2013 Cogent Embedded, Inc.
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#ifndef __RCAR_PHY_H
 +#define __RCAR_PHY_H
 +
 +#include linux/bitops.h
 +#include linux/types.h
 +
 +/* USBPCTRL0 register bits */
 +#define USBPCTRL0_OVC2   BIT(10) /* Switches the OVC input pin for port 
 2: */
 + /* 1: USB_OVC2, 0: OVC2 */
 +#define USBPCTRL0_OVC1_VBUS1 BIT(9) /* Switches the OVC input pin for port 
 1: */
 + /* 1: USB_OVC1, 0: OVC1/VBUS1   */
 +#define USBPCTRL0_OVC0   BIT(8)  /* Switches the OVC input pin for port 
 0: */
 + /* 1: USB_OVC0 pin, 0: OVC0 */
 +#define USBPCTRL0_OVC2_ACT BIT(6) /* Host mode: OVC2 polarity:   
 */
 + /* 1: active-high, 0: active-low*/
 + /* Function mode: be sure to set to 1   */
 +#define USBPCTRL0_PENC   BIT(4)  /* Function mode: output level of PENC1 
 pin: */
 + /* 1: high, 0: low  */
 +#define USBPCTRL0_OVC0_ACT BIT(3) /* Host mode: OVC0 polarity:   
 */
 + /* 1: active-high, 0: active-low*/
 +#define USBPCTRL0_OVC1_ACT BIT(1) /* Host mode: OVC1 polarity:   
 */
 + /* 1: active-high, 0: active-low*/
 + /* Function mode: be sure to set to 1   */
 +#define USBPCTRL0_PORT1  BIT(0)  /* Selects port 1 mode: 
 */
 + /* 1: function, 0: host */
 +
 +struct rcar_phy_platform_data {
 + u32 usbpctrl0;  /* USBPCTRL0 register value */
 +};

looks really wrong to me to pass register contents via pdata. You should
pass flags which would aid the driver into figuring out how to program
that register.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 9/9] rcar-phy: handle platform data

2013-04-10 Thread Felipe Balbi
On Wed, Apr 10, 2013 at 02:39:47AM +0400, Sergei Shtylyov wrote:
 Set the USBPCTRL0 register from the passed platform data in 
 rcar_usb_phy_init();
 don't reset it to 0 in  rcar_usb_phy_shutdown()  anymore as that does not make
 sense.  Also, don't allow the driver's probe to succeed when the platform data
 are not supplied with a device.
 
 The patch has been tested on the Marzen and BOCK-W boards.
 
 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
 Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 Acked-by: Simon Horman horms+rene...@verge.net.au

NAK due to previous comments (passing register contents via pdata).

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH v4 0/2] ARM: Exynos5250: Enabling samsung usb phy

2013-04-10 Thread Kukjin Kim
Vivek Gautam wrote:
 
 Based on 'for-next' of linux-samsung tree with following patches
 from Doug on top:
 usb: Document clocks in samsung, exynos4210-ehci/ohci bindings
 ARM: dts: add usb 2.0 clock references to exynos5250 device tree
 
 Also depending upon following patch-series for Samsung-usb-phy driver:
 [PATCH v7 0/2] Adding USB 3.0 DRD-phy support for exynos5250
 
 Changes from v3:
 Added 'clocks' and 'clock-names' entry also in device nodes, aligning
 with common clock framework for Samsung's SoCs.
 
 Vivek Gautam (2):
   ARM: Exynos5250: Enabling samsung-usb2phy driver
   ARM: Exynos5250: Enabling samsung-usb3phy driver
 
  arch/arm/boot/dts/exynos5250.dtsi |   29 +
  1 files changed, 29 insertions(+), 0 deletions(-)
 
 --
 1.7.6.5

OK, applied, thanks.

- Kukjin

--
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: [Test Application PATCH 0/2] UVC gadget test application enhancements

2013-04-10 Thread Bhupesh SHARMA
Hi Laurent,

 This patchset tries to enhance the UVC gadget test application and is based
 on Laurent's git tree available here (project: uvc-gadget.git):
 git://git.ideasonboard.org/uvc-gadget.git
 
 The patch 2/2 in this patchset also adds a README file describing the UVC
 gadget test application, it's possible use-case scenarios and IO method
 support in detail.
 
 The 'linux-usb' list is also added to CC of this patchset (although this is a 
 test
 application related change), as I have received interest from a number of
 users on the list regarding availability of this patchset.
 
 Bhupesh Sharma (2):
   UVC gadget: Add support for integration with a video-capture device
 and other fixes
   UVC gadget: Add a README file describing the UVC gadget test
 application
 
  README   |  209 ++
  uvc-gadget.c | 2156
 --
  2 files changed, 2159 insertions(+), 206 deletions(-)  create mode 100644
 README
 
 --
 1.7.2.2

Can you please review this patchset and let me know if I need to change 
something here?
@ Ammar, can you please test this application patch at your end and provide 
your feedbacks?

Regards,
Bhupesh

--
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 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-10 Thread Roger Quadros
On 04/10/2013 12:54 AM, Nishanth Menon wrote:
 On 15:49-20130409, Nishanth Menon wrote:
 On 10:43-20130409, Tony Lindgren wrote:
 * Tony Lindgren t...@atomide.com [130409 09:54]:
 * Roger Quadros rog...@ti.com [130409 03:00]:
 On 04/05/2013 06:58 PM, Tony Lindgren wrote:

 Can't you just use the clock name there to get it?

 In device tree we don't pass around clock names. You can either get
 a phandle or an index to the clock.

 e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

 Yes I understand that. But the driver/clock/omap driver can just
 remap the DT device initially so the board specific clock is
 found from the clock alias table. Basically initially a passthrough
 driver that can be enhanced to parse DT clock bindings and load
 data from /lib/firmware.

 Actually probably the driver/clock/omap can even do even less
 initially. There probably even no need to remap clocks there.

 As long as the DT clock driver understands that a board specific
 auxclk is specified in the DT it can just call clk_add_alias() so
 the driver will get the right auxclk from cclock44xx_data.c.

 Then other features can be added later on like to allocate a
 clock entirely based on the binding etc.
 I did try to have an implementation for cpufreq using clock nodes.
 unfortunately, device tree wont let me have arguments of strings :(
 So, I am unable to do clock = clk mpu_dpll;
 instead, I am forced to do clock = clk 249;

 Here is an attempt on beagleXM - adds every clock node to the list.
 Tons of un-necessary prints added to give an idea - see log:
 http://pastebin.com/F9A2zSTr

 Would an cleaned up version be good enough as a step #1 of transition?

 Approach #2:
 Here is yet another revision - here I am trying to avoid the risk of
 folks messing up indexing. for example: using an older DTB with newer
 kernel, clocks being inserted into existing list etc. to prevent these,

Why do you need to worry about users using old DTB with new kernel.
That is entirely the user's fault no?

 we add an DT_ID for omap clock nodes, and use it to uniquely identify
 the clock node. We try to minimize(not avoidable with integer indexing)
 mistakes during development/productization.

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 0/4] Add USB support to R8A7778/BOCK-W

2013-04-10 Thread Sergei Shtylyov

Hello.

On 10-04-2013 2:47, Sergei Shtylyov wrote:


Here's the set of 4 patches against the Simon Horman's 'renesas.git' repo,
'renesas-next-20130410' tag.


   Sorry, forgot to mention that it is atop the previous R8A7779/Marzen USB 
patchset.


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 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Dan Williams
On Wed, 2013-04-10 at 09:23 +0200, Oliver Neukum wrote:
 On Tuesday 09 April 2013 18:02:27 Dan Williams wrote:
  Some drivers (sierra_net) need the status interrupt URB
  active even when the device is closed, because they receive
  custom indications from firmware.  Add functions to refcount
  the status interrupt URB submit/kill operation so that
  sub-drivers and the generic driver don't fight over whether
  the status interrupt URB is active or not.
  
  A sub-driver can call usbnet_status_start() at any time, but
  the URB is only submitted the first time the function is
  called.  Likewise, when the sub-driver is done with the URB,
  it calls usbnet_status_stop() but the URB is only killed when
  all users have stopped it.  The URB is still killed and
  re-submitted for suspend/resume, as before, with the same
  refcount it had at suspend.
  
  Signed-off-by: Dan Williams d...@redhat.com
  ---
   drivers/net/usb/usbnet.c   | 79 
  ++
   include/linux/usb/usbnet.h |  5 +++
   2 files changed, 77 insertions(+), 7 deletions(-)
  
  diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
  index 51f3192..e8b363a 100644
  --- a/drivers/net/usb/usbnet.c
  +++ b/drivers/net/usb/usbnet.c
  @@ -42,7 +42,7 @@
   #include linux/workqueue.h
   #include linux/mii.h
   #include linux/usb.h
  -#include linux/usb/usbnet.h
  +#include usbnet.h
   #include linux/slab.h
   #include linux/kernel.h
   #include linux/pm_runtime.h
  @@ -252,6 +252,70 @@ static int init_status (struct usbnet *dev, struct 
  usb_interface *intf)
  return 0;
   }
   
  +/* Submit the interrupt URB if it hasn't been submitted yet */
  +static int __usbnet_status_start(struct usbnet *dev, gfp_t mem_flags,
  +   bool force)
  +{
  +   int ret = 0;
  +   bool submit = false;
  +
  +   if (!dev-interrupt)
  +   return 0;
  +
  +   mutex_lock(dev-interrupt_mutex);
  +
  +   if (force) {
 
 That design means that interrupt_count isn't accurate if force is used.
 That is extremely ugly.

True; the problem here is that the URB isn't always submitted when
suspend is used.  For example, in a normal driver that doesn't need the
URB submitted all the time, interrupt_count will be 0 while !IFF_UP.
Then if the system suspends, we can't decrement interrupt_count because
it's zero.

Besides, if the system is suspended, no driver can call
usbnet_interrupt_start() or usbnet_interrupt_stop(), correct?  Suspend
is a special condition here and nothing that starts/stops the urbs will
ever run while the system is suspended.

  +   /* Only submit now if the URB was previously submitted */
  +   if (dev-interrupt_count)
  +   submit = true;
  +   } else if (++dev-interrupt_count == 1)
  +   submit = true;
  +
  +   if (submit)
  +   ret = usb_submit_urb(dev-interrupt, mem_flags);
  +
  +   dev_dbg(dev-udev-dev, incremented interrupt URB count to %d\n,
  +   dev-interrupt_count);
  +   mutex_unlock(dev-interrupt_mutex);
  +   return ret;
  +}
  +
  +int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
  +{
  +   /* Only drivers that implement a status hook should call this */
  +   BUG_ON(dev-interrupt == NULL);
  +
  +   if (test_bit(EVENT_DEV_ASLEEP, dev-flags))
  +   return -EINVAL;
 
 This looks like a race condition.

True, I'll have to fix this.  But it looks like EVENT_DEV_ASLEEP is
protected by *either* rxq.lock (rx_submit) or txq.lock
(usbnet_start_xmit, usbnet_suspend, usbnet_resume).  That doesn't seem
right, actually...  shouldn't it be protected all by one lock, not two
different ones?

  +   return __usbnet_status_start(dev, mem_flags, false);
  +}
  +EXPORT_SYMBOL_GPL(usbnet_status_start);
  +
  +/* Kill the interrupt URB if all submitters want it killed */
  +static void __usbnet_status_stop(struct usbnet *dev, bool force)
  +{
  +   if (dev-interrupt) {
  +   mutex_lock(dev-interrupt_mutex);
  +   if (!force)
  +   BUG_ON(dev-interrupt_count == 0);
  +
  +   if (force || --dev-interrupt_count == 0)
  +   usb_kill_urb(dev-interrupt);
 
 Why so complicated? If it may be on, kill it unconditionally.

This function isn't only called from suspend.  It's also called if the
sub-driver doesn't need the interrupt urb open anymore, because earlier
you indicated that we didn't want to unconditionally keep the URB open
if something didn't need it, because it's wasteful of resources.

So for example, sierra_net will call usbnet_status_start() at driver
init time, and then it could call usbnet_status_stop() when it has
received the RESTART indication about 2 seconds after driver init, all
before the interface is IFF_UP and before usbnet would ever have
submitted the URB.  However, if during that 2 seconds, somethign *does*
set the interface IFF_UP, you don't want sierra_net causing the urb to
be killed right underneath usbnet.  Hence the 

Re: [PATCH 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Oliver Neukum
On Wednesday 10 April 2013 07:49:11 Dan Williams wrote:
 On Wed, 2013-04-10 at 09:23 +0200, Oliver Neukum wrote:
  On Tuesday 09 April 2013 18:02:27 Dan Williams wrote:

   +/* Submit the interrupt URB if it hasn't been submitted yet */
   +static int __usbnet_status_start(struct usbnet *dev, gfp_t mem_flags,
   + bool force)
   +{
   + int ret = 0;
   + bool submit = false;
   +
   + if (!dev-interrupt)
   + return 0;
   +
   + mutex_lock(dev-interrupt_mutex);
   +
   + if (force) {
  
  That design means that interrupt_count isn't accurate if force is used.
  That is extremely ugly.
 
 True; the problem here is that the URB isn't always submitted when
 suspend is used.  For example, in a normal driver that doesn't need the
 URB submitted all the time, interrupt_count will be 0 while !IFF_UP.
 Then if the system suspends, we can't decrement interrupt_count because
 it's zero.

We don't need to. You ought to understand interrupt_count as
valid only while the device is not suspended.

 Besides, if the system is suspended, no driver can call
 usbnet_interrupt_start() or usbnet_interrupt_stop(), correct?  Suspend
 is a special condition here and nothing that starts/stops the urbs will
 ever run while the system is suspended.

Unfortunately there's also runtime power management.

   + /* Only submit now if the URB was previously submitted */
   + if (dev-interrupt_count)
   + submit = true;
   + } else if (++dev-interrupt_count == 1)
   + submit = true;
   +
   + if (submit)
   + ret = usb_submit_urb(dev-interrupt, mem_flags);
   +
   + dev_dbg(dev-udev-dev, incremented interrupt URB count to %d\n,
   + dev-interrupt_count);
   + mutex_unlock(dev-interrupt_mutex);
   + return ret;
   +}
   +
   +int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
   +{
   + /* Only drivers that implement a status hook should call this */
   + BUG_ON(dev-interrupt == NULL);
   +
   + if (test_bit(EVENT_DEV_ASLEEP, dev-flags))
   + return -EINVAL;
  
  This looks like a race condition.
 
 True, I'll have to fix this.  But it looks like EVENT_DEV_ASLEEP is
 protected by *either* rxq.lock (rx_submit) or txq.lock
 (usbnet_start_xmit, usbnet_suspend, usbnet_resume).  That doesn't seem
 right, actually...  shouldn't it be protected all by one lock, not two
 different ones?

Yes.

   + return __usbnet_status_start(dev, mem_flags, false);
   +}
   +EXPORT_SYMBOL_GPL(usbnet_status_start);
   +
   +/* Kill the interrupt URB if all submitters want it killed */
   +static void __usbnet_status_stop(struct usbnet *dev, bool force)
   +{
   + if (dev-interrupt) {
   + mutex_lock(dev-interrupt_mutex);
   + if (!force)
   + BUG_ON(dev-interrupt_count == 0);

BTW: please unify this in case somebody compiles out BUG_ON

   +
   + if (force || --dev-interrupt_count == 0)
   + usb_kill_urb(dev-interrupt);
  
  Why so complicated? If it may be on, kill it unconditionally.
 
 This function isn't only called from suspend.  It's also called if the
 sub-driver doesn't need the interrupt urb open anymore, because earlier
 you indicated that we didn't want to unconditionally keep the URB open
 if something didn't need it, because it's wasteful of resources.
 
 So for example, sierra_net will call usbnet_status_start() at driver
 init time, and then it could call usbnet_status_stop() when it has
 received the RESTART indication about 2 seconds after driver init, all
 before the interface is IFF_UP and before usbnet would ever have
 submitted the URB.  However, if during that 2 seconds, somethign *does*
 set the interface IFF_UP, you don't want sierra_net causing the urb to
 be killed right underneath usbnet.  Hence the refcounting scheme here.
 
 force is used only for suspend/resume specifically to ensure that the
 URB is unconditionally killed at suspend time.

It is likely to be more elegant to drop force and have an unconditional kill
in suspend.

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 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Dan Williams
On Wed, 2013-04-10 at 15:06 +0200, Oliver Neukum wrote:
 On Wednesday 10 April 2013 07:49:11 Dan Williams wrote:
  On Wed, 2013-04-10 at 09:23 +0200, Oliver Neukum wrote:
   On Tuesday 09 April 2013 18:02:27 Dan Williams wrote:
 
+/* Submit the interrupt URB if it hasn't been submitted yet */
+static int __usbnet_status_start(struct usbnet *dev, gfp_t mem_flags,
+   bool force)
+{
+   int ret = 0;
+   bool submit = false;
+
+   if (!dev-interrupt)
+   return 0;
+
+   mutex_lock(dev-interrupt_mutex);
+
+   if (force) {
   
   That design means that interrupt_count isn't accurate if force is used.
   That is extremely ugly.
  
  True; the problem here is that the URB isn't always submitted when
  suspend is used.  For example, in a normal driver that doesn't need the
  URB submitted all the time, interrupt_count will be 0 while !IFF_UP.
  Then if the system suspends, we can't decrement interrupt_count because
  it's zero.
 
 We don't need to. You ought to understand interrupt_count as
 valid only while the device is not suspended.

Ok, so at suspend we just drop the count to zero, force-kill the URB,
and then on resume it's not re-submitted again?  That seems odd, since
the usbnet driver handles submit/resubmit internally if the interface is
IFF_UP, but when the interface is !IFF_UP then sub-drivers would have to
track whether they submitted the urb or not, and then clear that on
suspend?  Having separate behavior for when the sub-driver starts the
URB and when usbnet does seems inconsistent and error-prone.

What approach would you suggest here?

  Besides, if the system is suspended, no driver can call
  usbnet_interrupt_start() or usbnet_interrupt_stop(), correct?  Suspend
  is a special condition here and nothing that starts/stops the urbs will
  ever run while the system is suspended.
 
 Unfortunately there's also runtime power management.

Hmm, right.

+   /* Only submit now if the URB was previously submitted 
*/
+   if (dev-interrupt_count)
+   submit = true;
+   } else if (++dev-interrupt_count == 1)
+   submit = true;
+
+   if (submit)
+   ret = usb_submit_urb(dev-interrupt, mem_flags);
+
+   dev_dbg(dev-udev-dev, incremented interrupt URB count to 
%d\n,
+   dev-interrupt_count);
+   mutex_unlock(dev-interrupt_mutex);
+   return ret;
+}
+
+int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
+{
+   /* Only drivers that implement a status hook should call this */
+   BUG_ON(dev-interrupt == NULL);
+
+   if (test_bit(EVENT_DEV_ASLEEP, dev-flags))
+   return -EINVAL;
   
   This looks like a race condition.
  
  True, I'll have to fix this.  But it looks like EVENT_DEV_ASLEEP is
  protected by *either* rxq.lock (rx_submit) or txq.lock
  (usbnet_start_xmit, usbnet_suspend, usbnet_resume).  That doesn't seem
  right, actually...  shouldn't it be protected all by one lock, not two
  different ones?
 
 Yes.
 
+   return __usbnet_status_start(dev, mem_flags, false);
+}
+EXPORT_SYMBOL_GPL(usbnet_status_start);
+
+/* Kill the interrupt URB if all submitters want it killed */
+static void __usbnet_status_stop(struct usbnet *dev, bool force)
+{
+   if (dev-interrupt) {
+   mutex_lock(dev-interrupt_mutex);
+   if (!force)
+   BUG_ON(dev-interrupt_count == 0);
 
 BTW: please unify this in case somebody compiles out BUG_ON

Can do.

+
+   if (force || --dev-interrupt_count == 0)
+   usb_kill_urb(dev-interrupt);
   
   Why so complicated? If it may be on, kill it unconditionally.
  
  This function isn't only called from suspend.  It's also called if the
  sub-driver doesn't need the interrupt urb open anymore, because earlier
  you indicated that we didn't want to unconditionally keep the URB open
  if something didn't need it, because it's wasteful of resources.
  
  So for example, sierra_net will call usbnet_status_start() at driver
  init time, and then it could call usbnet_status_stop() when it has
  received the RESTART indication about 2 seconds after driver init, all
  before the interface is IFF_UP and before usbnet would ever have
  submitted the URB.  However, if during that 2 seconds, somethign *does*
  set the interface IFF_UP, you don't want sierra_net causing the urb to
  be killed right underneath usbnet.  Hence the refcounting scheme here.
  
  force is used only for suspend/resume specifically to ensure that the
  URB is unconditionally killed at suspend time.
 
 It is likely to be more elegant to drop force and have an unconditional kill
 in suspend.

See my questions above.  Then we'd have to have the sub-drivers

Re: [PATCH 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Bjørn Mork
Dan Williams d...@redhat.com writes:

 +int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
 +{
 + /* Only drivers that implement a status hook should call this */
 + BUG_ON(dev-interrupt == NULL);
 
I still don't think there is any reason to BUG out. See for example
http://article.gmane.org/gmane.linux.kernel/52102

 +static void __usbnet_status_stop(struct usbnet *dev, bool force)
 +{
 + if (dev-interrupt) {
 + mutex_lock(dev-interrupt_mutex);
 + if (!force)
 + BUG_ON(dev-interrupt_count == 0);

Same here.  You can deal with this just fine.  Warn once, and go on
ignoring the problem.  Why kill the machine because of some minor driver
issue?



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: [PATCH 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Oliver Neukum
On Wednesday 10 April 2013 08:18:57 Dan Williams wrote:
 On Wed, 2013-04-10 at 15:06 +0200, Oliver Neukum wrote:
  On Wednesday 10 April 2013 07:49:11 Dan Williams wrote:
   On Wed, 2013-04-10 at 09:23 +0200, Oliver Neukum wrote:
On Tuesday 09 April 2013 18:02:27 Dan Williams wrote:
  
 +/* Submit the interrupt URB if it hasn't been submitted yet */
 +static int __usbnet_status_start(struct usbnet *dev, gfp_t mem_flags,
 + bool force)
 +{
 + int ret = 0;
 + bool submit = false;
 +
 + if (!dev-interrupt)
 + return 0;
 +
 + mutex_lock(dev-interrupt_mutex);
 +
 + if (force) {

That design means that interrupt_count isn't accurate if force is used.
That is extremely ugly.
   
   True; the problem here is that the URB isn't always submitted when
   suspend is used.  For example, in a normal driver that doesn't need the
   URB submitted all the time, interrupt_count will be 0 while !IFF_UP.
   Then if the system suspends, we can't decrement interrupt_count because
   it's zero.
  
  We don't need to. You ought to understand interrupt_count as
  valid only while the device is not suspended.
 
 Ok, so at suspend we just drop the count to zero, force-kill the URB,

No, at suspend() ignore interrupt_count. Just kill.

 and then on resume it's not re-submitted again?  That seems odd, since

On resume() evaluate interrupt_count.

 the usbnet driver handles submit/resubmit internally if the interface is
 IFF_UP, but when the interface is !IFF_UP then sub-drivers would have to
 track whether they submitted the urb or not, and then clear that on
 suspend?  Having separate behavior for when the sub-driver starts the
 URB and when usbnet does seems inconsistent and error-prone.
 
 What approach would you suggest here?

Religiously use interrupt_count. With one exception.
The start/stop helpers are good. Just don't use them at suspend().

[..]
 See my questions above.  Then we'd have to have the sub-drivers
 implement suspend/resume hooks so they'd be able to resubmit the
 interrupt URB on resume, and the whole point of this patch was to handle
 all that in usbnet.  The sub-drivers don't know what the core driver's
 suspend/resume count is, because dev-suspend_count isn't exposed to
 subdrivers, and thus they don't know whether the device is actually
 suspended or not.
 
 The core problem is this... the sub-driver submits the URB before
 IFF_UP, and then at IFF_UP time usbnet wants to submit the driver.
 Let's say later the sub-driver doesn't need its private interrupt URB
 submission anymore, but it can't kill the URB because usbnet has
 submitted it too.  Hence the refcounting.

The refcounting is very good. Just don't mess around with force

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 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Oliver Neukum
On Wednesday 10 April 2013 15:25:49 Bjørn Mork wrote:
 Dan Williams d...@redhat.com writes:
 
  +int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
  +{
  +   /* Only drivers that implement a status hook should call this */
  +   BUG_ON(dev-interrupt == NULL);
  
 I still don't think there is any reason to BUG out. See for example
 http://article.gmane.org/gmane.linux.kernel/52102

On second consideration, yes, WARN_ON() would do the job.

Regards
Oliver

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


Re: [PATCH 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Dan Williams
On Wed, 2013-04-10 at 15:29 +0200, Oliver Neukum wrote:
 On Wednesday 10 April 2013 08:18:57 Dan Williams wrote:
  On Wed, 2013-04-10 at 15:06 +0200, Oliver Neukum wrote:
   On Wednesday 10 April 2013 07:49:11 Dan Williams wrote:
On Wed, 2013-04-10 at 09:23 +0200, Oliver Neukum wrote:
 On Tuesday 09 April 2013 18:02:27 Dan Williams wrote:
   
  +/* Submit the interrupt URB if it hasn't been submitted yet */
  +static int __usbnet_status_start(struct usbnet *dev, gfp_t 
  mem_flags,
  +   bool force)
  +{
  +   int ret = 0;
  +   bool submit = false;
  +
  +   if (!dev-interrupt)
  +   return 0;
  +
  +   mutex_lock(dev-interrupt_mutex);
  +
  +   if (force) {
 
 That design means that interrupt_count isn't accurate if force is 
 used.
 That is extremely ugly.

True; the problem here is that the URB isn't always submitted when
suspend is used.  For example, in a normal driver that doesn't need the
URB submitted all the time, interrupt_count will be 0 while !IFF_UP.
Then if the system suspends, we can't decrement interrupt_count because
it's zero.
   
   We don't need to. You ought to understand interrupt_count as
   valid only while the device is not suspended.
  
  Ok, so at suspend we just drop the count to zero, force-kill the URB,
 
 No, at suspend() ignore interrupt_count. Just kill.

Isn't that what the code already does?  The suspend handler sets force
to true, which always kills the URB at suspend time.

  and then on resume it's not re-submitted again?  That seems odd, since
 
 On resume() evaluate interrupt_count.

Because suspend/resume doesn't touch interrupt_count (due to the problem
that interrupt_count may be 0 at suspend time if the URB is not yet
submitted), we need a flag to know whether or not to increment the
count, and that's what force is there to do.

  the usbnet driver handles submit/resubmit internally if the interface is
  IFF_UP, but when the interface is !IFF_UP then sub-drivers would have to
  track whether they submitted the urb or not, and then clear that on
  suspend?  Having separate behavior for when the sub-driver starts the
  URB and when usbnet does seems inconsistent and error-prone.
  
  What approach would you suggest here?
 
 Religiously use interrupt_count. With one exception.
 The start/stop helpers are good. Just don't use them at suspend().

So open-code the killing at suspend()?  That's what I had in a previous
patch, but Ming suggested I use the helpers instead to make things
cleaner.  So I did.  Should I revert to the old behavior?

 [..]
  See my questions above.  Then we'd have to have the sub-drivers
  implement suspend/resume hooks so they'd be able to resubmit the
  interrupt URB on resume, and the whole point of this patch was to handle
  all that in usbnet.  The sub-drivers don't know what the core driver's
  suspend/resume count is, because dev-suspend_count isn't exposed to
  subdrivers, and thus they don't know whether the device is actually
  suspended or not.
  
  The core problem is this... the sub-driver submits the URB before
  IFF_UP, and then at IFF_UP time usbnet wants to submit the driver.
  Let's say later the sub-driver doesn't need its private interrupt URB
  submission anymore, but it can't kill the URB because usbnet has
  submitted it too.  Hence the refcounting.
 
 The refcounting is very good. Just don't mess around with force

That's easy to do if the helpers aren't used for suspend/resume, which
is what I had previously in my v2 patches until Ming suggested that I
use the helpers there.  I can go back to that approach if you'd like, it
is a bit less complicated at the expense of sprinkling the interrupt urb
submit/kill code around more widely.

Dan

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


Re: [PATCH 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Oliver Neukum
On Wednesday 10 April 2013 08:54:43 Dan Williams wrote:
  The refcounting is very good. Just don't mess around with force
 
 That's easy to do if the helpers aren't used for suspend/resume, which
 is what I had previously in my v2 patches until Ming suggested that I
 use the helpers there.  I can go back to that approach if you'd like, it
 is a bit less complicated at the expense of sprinkling the interrupt urb
 submit/kill code around more widely.

If you introduce a third helper like forcibly_stop_interrupt or something,
I'll be perfectly happy. Just don't use flags which completely alter 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 v3 7/9] rcar-phy: add platform data

2013-04-10 Thread Sergei Shtylyov

On 10-04-2013 13:00, Felipe Balbi wrote:


Currently the driver hard-codes USBPCTRL0 register to 0.  It is wrong since this
register contains board-specific USB ports configuration and so its value should
be somehow passed via the platform data.  Add linux/usb/rcar-phy.h file with
the USBPCTRL0 bit #define's and 'struct rcar_phy_platform_data' containing the
value to be set by the driver to that register.



Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
Acked-by: Simon Horman horms+rene...@verge.net.au



---
Changes since version 2:
- added #include linux/types.h;
- added ACKs from Simon Horman and Kuninori Morimoto.



  include/linux/usb/rcar-phy.h |   40 
  1 file changed, 40 insertions(+)



Index: renesas/include/linux/usb/rcar-phy.h
===
--- /dev/null
+++ renesas/include/linux/usb/rcar-phy.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013 Cogent Embedded, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __RCAR_PHY_H
+#define __RCAR_PHY_H
+
+#include linux/bitops.h
+#include linux/types.h
+
+/* USBPCTRL0 register bits */
+#define USBPCTRL0_OVC2 BIT(10) /* Switches the OVC input pin for port 2: */
+   /* 1: USB_OVC2, 0: OVC2 */
+#define USBPCTRL0_OVC1_VBUS1 BIT(9) /* Switches the OVC input pin for port 1: 
*/
+   /* 1: USB_OVC1, 0: OVC1/VBUS1   */
+#define USBPCTRL0_OVC0 BIT(8)  /* Switches the OVC input pin for port 0: */
+   /* 1: USB_OVC0 pin, 0: OVC0 */
+#define USBPCTRL0_OVC2_ACT BIT(6) /* Host mode: OVC2 polarity: */
+   /* 1: active-high, 0: active-low*/
+   /* Function mode: be sure to set to 1   */
+#define USBPCTRL0_PENC BIT(4)  /* Function mode: output level of PENC1 pin: */
+   /* 1: high, 0: low  */
+#define USBPCTRL0_OVC0_ACT BIT(3) /* Host mode: OVC0 polarity: */
+   /* 1: active-high, 0: active-low*/
+#define USBPCTRL0_OVC1_ACT BIT(1) /* Host mode: OVC1 polarity: */
+   /* 1: active-high, 0: active-low*/
+   /* Function mode: be sure to set to 1   */
+#define USBPCTRL0_PORT1BIT(0)  /* Selects port 1 mode: 
*/
+   /* 1: function, 0: host */
+
+struct rcar_phy_platform_data {
+   u32 usbpctrl0;  /* USBPCTRL0 register value */
+};



looks really wrong to me to pass register contents via pdata. You should
pass flags which would aid the driver into figuring out how to program
that register.


   That was my first thought (and implementation) but this didn't look good 
either (and even worse with the device tree approach) as we couldn't come up 
with the clear names for the bitfields. Also, not all these bits are present 
in R8A7778 support for which I'm adding in the later patchset.
   Besides, IMO this little differs from having a flags field with the flags 
bits #define'd beforehand. Or did you mean that I should have surely used 
*bool* bitfields?


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 v3 4/9] rcar-phy: remove EHCI internal buffer setup

2013-04-10 Thread Sergei Shtylyov

Hello.

On 10-04-2013 12:27, Felipe Balbi wrote:


On Wed, Apr 10, 2013 at 02:32:30AM +0400, Sergei Shtylyov wrote:

Now that the EHCI internal  buffer setup is done by the platform code, we  can
remove  such code from this driver as it  never  really belonged here.  We also
no longer need the 2nd memory region now (2nd EHCI controller is simply missing
in e.g. R8A7778 SoC).



The patch has been tested on the Marzen and BOCK-W boards.



Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
Acked-by: Simon Horman horms+rene...@verge.net.au



---
Changes since version 2:
- added a note about testing to the changelog;
- added ACKs from Simon Horman and Kuninori Morimoto.



Changes since the original posting:
- split R8A7779 SoC file change to a separate patch.



  drivers/usb/phy/rcar-phy.c |   28 



you do realise this won't apply, right ?


   Because of the rename you've done? No, I didn't realize it until you told.
I wasn't watching changes in your tree...

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 2/2 v4] sierra_net: keep status interrupt URB active

2013-04-10 Thread Dan Williams
On Wed, 2013-04-10 at 09:15 +0200, Oliver Neukum wrote:
 On Tuesday 09 April 2013 18:05:51 Dan Williams wrote:
  The driver and firmware sync up through SYNC messages, and the
  firmware's affirmative reply to these SYNC messages appears to be the
  Reset indication received via the status interrupt endpoint.  Thus the
  driver needs the status interrupt endpoint always active so that the
  Reset indication can be received even if the netdev is closed, which is
  the case right after device insertion.
 
 WHat about suspend/resume?

usbnet should take care of that transparently from the sub-drivers
through it's own suspend/resume logic to kill/resubmit the URB if
required.  Though is there something I'm missing here?

Dan

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


Re: [PATCH 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Dan Williams
On Wed, 2013-04-10 at 15:58 +0200, Oliver Neukum wrote:
 On Wednesday 10 April 2013 08:54:43 Dan Williams wrote:
   The refcounting is very good. Just don't mess around with force
  
  That's easy to do if the helpers aren't used for suspend/resume, which
  is what I had previously in my v2 patches until Ming suggested that I
  use the helpers there.  I can go back to that approach if you'd like, it
  is a bit less complicated at the expense of sprinkling the interrupt urb
  submit/kill code around more widely.
 
 If you introduce a third helper like forcibly_stop_interrupt or something,
 I'll be perfectly happy. Just don't use flags which completely alter behavior.
 
   Regards
   Oliver

Do you mean something more like this?  If so, I'll go ahead and do the
formal submission.  Thanks!

Dan
---
 drivers/net/usb/usbnet.c   | 79 ++
 include/linux/usb/usbnet.h |  5 +++
 2 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 51f3192..f903beb 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -252,6 +252,70 @@ static int init_status (struct usbnet *dev, struct 
usb_interface *intf)
return 0;
 }
 
+/* Submit the interrupt URB if not previously submitted, increasing refcount */
+int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
+{
+   int ret = 0;
+
+   WARN_ON_ONCE(dev-interrupt == NULL);
+   if (dev-interrupt) {
+   mutex_lock(dev-interrupt_mutex);
+
+   if (++dev-interrupt_count == 1)
+   ret = usb_submit_urb(dev-interrupt, mem_flags);
+
+   dev_dbg(dev-udev-dev, incremented interrupt URB count to 
%d\n,
+   dev-interrupt_count);
+   mutex_unlock(dev-interrupt_mutex);
+   }
+   return ret;
+}
+EXPORT_SYMBOL_GPL(usbnet_status_start);
+
+/* For resume; submit interrupt URB if previously submitted */
+static int __usbnet_status_start_force(struct usbnet *dev, gfp_t mem_flags)
+{
+   int ret = 0;
+
+   mutex_lock(dev-interrupt_mutex);
+   if (dev-interrupt_count) {
+   ret = usb_submit_urb(dev-interrupt, mem_flags);
+   dev_dbg(dev-udev-dev,
+   submitted interrupt URB for resume\n);
+   }
+   mutex_unlock(dev-interrupt_mutex);
+   return ret;
+}
+
+/* Kill the interrupt URB if all submitters want it killed */
+void usbnet_status_stop(struct usbnet *dev)
+{
+   if (dev-interrupt) {
+   mutex_lock(dev-interrupt_mutex);
+   WARN_ON(dev-interrupt_count == 0);
+
+   if (dev-interrupt_count  --dev-interrupt_count == 0)
+   usb_kill_urb(dev-interrupt);
+
+   dev_dbg(dev-udev-dev,
+   decremented interrupt URB count to %d\n,
+   dev-interrupt_count);
+   mutex_unlock(dev-interrupt_mutex);
+   }
+}
+EXPORT_SYMBOL_GPL(usbnet_status_stop);
+
+/* For suspend; always kill interrupt URB */
+static void __usbnet_status_stop_force(struct usbnet *dev)
+{
+   if (dev-interrupt) {
+   mutex_lock(dev-interrupt_mutex);
+   usb_kill_urb(dev-interrupt);
+   dev_dbg(dev-udev-dev, killed interrupt URB for suspend\n);
+   mutex_unlock(dev-interrupt_mutex);
+   }
+}
+
 /* Passes this packet up the stack, updating its accounting.
  * Some link protocols batch packets, so their rx_fixup paths
  * can return clones as well as just modify the original skb.
@@ -725,7 +789,7 @@ int usbnet_stop (struct net_device *net)
if (!(info-flags  FLAG_AVOID_UNLINK_URBS))
usbnet_terminate_urbs(dev);
 
-   usb_kill_urb(dev-interrupt);
+   usbnet_status_stop(dev);
 
usbnet_purge_paused_rxq(dev);
 
@@ -787,7 +851,7 @@ int usbnet_open (struct net_device *net)
 
/* start any status interrupt transfer */
if (dev-interrupt) {
-   retval = usb_submit_urb (dev-interrupt, GFP_KERNEL);
+   retval = usbnet_status_start(dev, GFP_KERNEL);
if (retval  0) {
netif_err(dev, ifup, dev-net,
  intr submit %d\n, retval);
@@ -1430,6 +1494,8 @@ usbnet_probe (struct usb_interface *udev, const struct 
usb_device_id *prod)
dev-delay.data = (unsigned long) dev;
init_timer (dev-delay);
mutex_init (dev-phy_mutex);
+   mutex_init(dev-interrupt_mutex);
+   dev-interrupt_count = 0;
 
dev-net = net;
strcpy (net-name, usb%d);
@@ -1565,7 +1631,7 @@ int usbnet_suspend (struct usb_interface *intf, 
pm_message_t message)
 */
netif_device_detach (dev-net);
usbnet_terminate_urbs(dev);
-   usb_kill_urb(dev-interrupt);
+   __usbnet_status_stop_force(dev);
 
/*
 * reattach so runtime 

Re: [PATCH 2/2 v4] sierra_net: keep status interrupt URB active

2013-04-10 Thread Oliver Neukum
On Wednesday 10 April 2013 09:57:50 Dan Williams wrote:
 On Wed, 2013-04-10 at 09:15 +0200, Oliver Neukum wrote:
  On Tuesday 09 April 2013 18:05:51 Dan Williams wrote:
   The driver and firmware sync up through SYNC messages, and the
   firmware's affirmative reply to these SYNC messages appears to be the
   Reset indication received via the status interrupt endpoint.  Thus the
   driver needs the status interrupt endpoint always active so that the
   Reset indication can be received even if the netdev is closed, which is
   the case right after device insertion.
  
  WHat about suspend/resume?
 
 usbnet should take care of that transparently from the sub-drivers
 through it's own suspend/resume logic to kill/resubmit the URB if
 required.  Though is there something I'm missing here?

Sorry, I read mails in antichronological order.

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 v3 2/9] ehci-platform: add pre_setup() method to platform data

2013-04-10 Thread Alan Stern
On Wed, 10 Apr 2013, Sergei Shtylyov wrote:

 Sometimes there is a need  to initialize some non-standard registers mapped to
 the EHCI region before accessing the standard EHCI registers.  Add pre_setup()
 method with 'struct usb_hcd *' parameter to be called just before ehci_setup()
 to the 'ehci-platform'  driver's platform data for this purpose...
 
 While at it, add the missing incomplete declaration of 'struct 
 platform_device'
 to linux/usb/ehci_pdriver.h...
 
 The patch has been tested on the Marzen and BOCK-W boards.
 
 Suggested-by: Alan Stern st...@rowland.harvard.edu
 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
 Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 Acked-by: Simon Horman horms+rene...@verge.net.au

Acked-by: Alan Stern st...@rowland.harvard.edu

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


Re: Linux USB file storage gadget with new UDC

2013-04-10 Thread Alan Stern
On Wed, 10 Apr 2013, victor yeo wrote:

 I use kernel 3.4.4, the code in handle_stat1_irqs() is as below. There
 is no reset or disconnect member function in struct
 usb_gadget_driver in kernel 3.4.4.
 
 if (stat  (1  SUSPEND_REQUEST_INTERRUPT)) {
 if (dev-driver-suspend)
 dev-driver-suspend (dev-gadget);
 if (!enable_suspend)
 stat = ~(1  SUSPEND_REQUEST_INTERRUPT);
 } else {
 if (dev-driver-resume)
 dev-driver-resume (dev-gadget);
 /* at high speed, note erratum 0133 */
 }

Okay.  I have a hard enough time remembering how the kernel works now;
I can't afford to remember how it worked five releases ago.  :-)

In the 3.4 kernel, when either a reset or a disconnect occurs, the UDC 
driver should call the gadget driver's -disconnect handler.

  Another usbmon trace showing 3 SCSI_READ_10 command.
 
 This trace shows that the READ(10) commands worked correctly.  Good.
 But it also shows that the gadget did not respond correctly to the 0xA1
 command near the end.  The UDC was supposed to set the Halt feature
 for the bulk-in endpoint and send a STALL packet, but it didn't.
 
 In gadget driver, when do_scsi_command() receives an unknown command,
 the return value is -EINVAL.

No, the return value is 0.  Read the last line of do_scsi_command():

return 0;

  Will this value be returned to UDC
 driver, so that UDC driver can set the Halt feature for the bulk-in
 endpoint and send a STALL packet? For now, UDC driver does not set
 Halt when unknown SCSI command is received.

Look at finish_reply(), near the end of the DATA_DIR_TO_HOST case:

/*
 * For Bulk-only, mark the end of the data with a short
 * packet.  If we are allowed to stall, halt the bulk-in
 * endpoint.  (Note: This violates the Bulk-Only Transport
 * specification, which requires us to pad the data if we
 * don't halt the endpoint.  Presumably nobody will mind.)
 */
else {
bh-inreq-zero = 1;
start_transfer(fsg, fsg-bulk_in, bh-inreq,
bh-inreq_busy, bh-state);
fsg-next_buffhd_to_fill = bh-next;
if (mod_data.can_stall)
rc = halt_bulk_in_endpoint(fsg);
}

And read the fist line in halt_bulk_in_endpoint():

rc = fsg_set_halt(fsg, fsg-bulk_in);

And finally, read the last line of fsg_set_halt():

return usb_ep_set_halt(ep);

That's when your UDC is supposed to set the Halt feature -- when its 
usb_ep_set_halt() function is called.  If the controller is busy at 
this time because the bulk-in buffer is full, and it is unable to set 
the Halt feature, then usb_ep_set_halt() should return -EAGAIN -- see 
the documentation for usb_ep_set_halt in include/linux/usb/gadget.h.

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: Power state of USB port on computer reboot

2013-04-10 Thread Greg KH
On Wed, Apr 10, 2013 at 06:27:14AM +, Blaz Malnersic wrote:
 If it is as you said concerning the undefined state of the USB power 
 across a reboot, that information is very helpful for me. It means we have 
 to design things differently (apart from the obvious one which is to 
 replace the notebooks...). 
 
 How come this is undefined?

Because it is not defined in the USB host controller spec, or in the USB
spec, and because different machines do different things on soft vs.
hard reboots, as do different BIOSes, and even different BIOS version
numbers, not to mention all of the machines that don't even have a BIOS
at all (the large majority of computers in the world.)

Sorry,

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 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Bjørn Mork
Dan Williams d...@redhat.com writes:
 On Wed, 2013-04-10 at 15:25 +0200, Bjørn Mork wrote:
 Dan Williams d...@redhat.com writes:
 
  +int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
  +{
  +  /* Only drivers that implement a status hook should call this */
  +  BUG_ON(dev-interrupt == NULL);
  
 I still don't think there is any reason to BUG out. See for example
 http://article.gmane.org/gmane.linux.kernel/52102
 
  +static void __usbnet_status_stop(struct usbnet *dev, bool force)
  +{
  +  if (dev-interrupt) {
  +  mutex_lock(dev-interrupt_mutex);
  +  if (!force)
  +  BUG_ON(dev-interrupt_count == 0);
 
 Same here.  You can deal with this just fine.  Warn once, and go on
 ignoring the problem.  Why kill the machine because of some minor driver
 issue?

 Actually in the stop case, no, we can't deal with it, because then (due
 to the buggy sub-driver) we'd go on to decrement 0 into UINT_MAX.  It
 really is a bug if, *not* at suspend time, we're told to stop the
 interrupt URB when it's not yet submitted. 

Sure it is a bug.  All I'm saying is that you can deal with it.  Warn
about the bug and give up.  Or continue.  But don't roll over and die.
Let the user unload the buggy driver and email the author instead.

 I'm happy to add another
 if() here though, which would end up looking like this:

 if (dev-interrupt_count  --dev-interrupt_count == 0)
 usb_kill_urb(dev-interrupt);

 which seems odd, but fine.

Yes, there are too many decision factors, so it does look odd.  You
could also decide early that the bogus dev-interrupt_count means that
nothing needs to be done, because no interrupt URB was subitted.  Like

static void __usbnet_status_stop(struct usbnet *dev, bool force)
{
if (dev-interrupt) {
mutex_lock(dev-interrupt_mutex);
if (!force  dev-interrupt_count == 0) {
 print loud warning blaming the minidriver author;
 goto out;
}
if (force || --dev-interrupt_count == 0)
usb_kill_urb(dev-interrupt);

dev_dbg(dev-udev-dev,
decremented interrupt URB count to %d\n,
dev-interrupt_count);
out:
mutex_unlock(dev-interrupt_mutex);
}
}


But it is pretty much the same.  force makes a mess of it.

In any case, I believe any of those solutions are a lot nicer to any
unsuspecting user, who may not agree with you that a failing 3G modem is
important enough to kill the machine.


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


USB-Wishbone bridge adapter

2013-04-10 Thread Wesley W. Terpstra
As discussed earlier on this list, we are building a few devices which
provide two serial interfaces via a USB port. Since we last spoke, we
now have a valid VID+PID pair (thank you OpenMoko!) and the interface
seems to work out.

Dan, you said you needed to add this device to a no probe list so that
it didn't get queried with ATx commands. I've attached the output of
lsusb -v, which hopefully provides you with enough information to
exclude it. However, the cdc-acm already recognizes that it is not a
modem, so is this still necessary?

Greg, I've attached a small Linux driver which recognizes and the
USB-Wishbone functionality of the device. It just adds two vendor
messages to signal to the FPGA that the device has been opened. Please
let me know what needs to be improved before it could be considered for
inclusion in the kernel proper.

The hardware interface solution I opted for was:
1- user-interactive console follows the CDC-ACM standard and appears
as /dev/ttyACMx without any driver needed
2- the proprietary USB-Wishbone bridge uses an interface id of 0xFF and
uses a custom driver to handle the extra signalling it needs

When attached, I see:
usb 1-3: new high-speed USB device number 46 using ehci_hcd
usb 1-3: New USB device found, idVendor=1d50, idProduct=6062
usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-3: Product: USB-{Serial,Wishbone} adapter
usb 1-3: Manufacturer: GSI Helmholtzzentrum
cdc_acm 1-3:1.0: This device cannot do calls on its own. It is not a
modem.
cdc_acm 1-3:1.0: ttyACM0: USB ACM device
usb_wb 1-3:1.2: usb_wb converter detected
usb 1-3: usb_wb converter now attached to ttyUSB0

Bus 001 Device 046: ID 1d50:6062 OpenMoko, Inc. 
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass2 Communications
  bDeviceSubClass 0 
  bDeviceProtocol 0 
  bMaxPacketSize064
  idVendor   0x1d50 OpenMoko, Inc.
  idProduct  0x6062 
  bcdDevice1.00
  iManufacturer   1 GSI Helmholtzzentrum
  iProduct2 USB-{Serial,Wishbone} adapter
  iSerial 0 
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   90
bNumInterfaces  3
bConfigurationValue 1
iConfiguration  0 
bmAttributes 0xa0
  (Bus Powered)
  Remote Wakeup
MaxPower   60mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   1
  bInterfaceClass 2 Communications
  bInterfaceSubClass  2 Abstract (modem)
  bInterfaceProtocol  0 None
  iInterface  3 White Rabbit Console (Comm)
  CDC Header:
bcdCDC   1.10
  CDC Call Management:
bmCapabilities   0x00
bDataInterface  1
  CDC ACM:
bmCapabilities   0x01
  get/set/clear comm features
  CDC Union:
bMasterInterface0
bSlaveInterface 1 
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81  EP 1 IN
bmAttributes3
  Transfer TypeInterrupt
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0040  1x 64 bytes
bInterval   2
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber1
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass10 CDC Data
  bInterfaceSubClass  0 Unused
  bInterfaceProtocol  0 
  iInterface  4 White Rabbit Console (Data)
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x88  EP 8 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04  EP 4 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber2
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass   255 Vendor Specific Class
  bInterfaceSubClass255 Vendor Specific Subclass
  

Re: USB-Wishbone bridge adapter

2013-04-10 Thread Greg KH
On Wed, Apr 10, 2013 at 07:01:40PM +0200, Wesley W. Terpstra wrote:
 Greg, I've attached a small Linux driver which recognizes and the
 USB-Wishbone functionality of the device. It just adds two vendor
 messages to signal to the FPGA that the device has been opened. Please
 let me know what needs to be improved before it could be considered for
 inclusion in the kernel proper.

You need to send it in a format that I can use to apply it (hint, read
the file, Documentation/SubmittingPatches.)  If you do that, I will be
glad to review it, and if all is good, apply it to the kernel tree.

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 v3 7/9] rcar-phy: add platform data

2013-04-10 Thread Felipe Balbi
Hi,

On Wed, Apr 10, 2013 at 06:03:49PM +0400, Sergei Shtylyov wrote:
 On 10-04-2013 13:00, Felipe Balbi wrote:
 
 Currently the driver hard-codes USBPCTRL0 register to 0.  It is wrong since 
 this
 register contains board-specific USB ports configuration and so its value 
 should
 be somehow passed via the platform data.  Add linux/usb/rcar-phy.h file 
 with
 the USBPCTRL0 bit #define's and 'struct rcar_phy_platform_data' containing 
 the
 value to be set by the driver to that register.
 
 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
 Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 Acked-by: Simon Horman horms+rene...@verge.net.au
 
 ---
 Changes since version 2:
 - added #include linux/types.h;
 - added ACKs from Simon Horman and Kuninori Morimoto.
 
   include/linux/usb/rcar-phy.h |   40 
  
   1 file changed, 40 insertions(+)
 
 Index: renesas/include/linux/usb/rcar-phy.h
 ===
 --- /dev/null
 +++ renesas/include/linux/usb/rcar-phy.h
 @@ -0,0 +1,40 @@
 +/*
 + * Copyright (C) 2013 Renesas Solutions Corp.
 + * Copyright (C) 2013 Cogent Embedded, Inc.
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#ifndef __RCAR_PHY_H
 +#define __RCAR_PHY_H
 +
 +#include linux/bitops.h
 +#include linux/types.h
 +
 +/* USBPCTRL0 register bits */
 +#define USBPCTRL0_OVC2 BIT(10) /* Switches the OVC input pin for port 
 2: */
 +   /* 1: USB_OVC2, 0: OVC2 */
 +#define USBPCTRL0_OVC1_VBUS1 BIT(9) /* Switches the OVC input pin for port 
 1: */
 +   /* 1: USB_OVC1, 0: OVC1/VBUS1   */
 +#define USBPCTRL0_OVC0 BIT(8)  /* Switches the OVC input pin for port 
 0: */
 +   /* 1: USB_OVC0 pin, 0: OVC0 */
 +#define USBPCTRL0_OVC2_ACT BIT(6) /* Host mode: OVC2 polarity: 
 */
 +   /* 1: active-high, 0: active-low*/
 +   /* Function mode: be sure to set to 1   */
 +#define USBPCTRL0_PENC BIT(4)  /* Function mode: output level of PENC1 
 pin: */
 +   /* 1: high, 0: low  */
 +#define USBPCTRL0_OVC0_ACT BIT(3) /* Host mode: OVC0 polarity: 
 */
 +   /* 1: active-high, 0: active-low*/
 +#define USBPCTRL0_OVC1_ACT BIT(1) /* Host mode: OVC1 polarity: 
 */
 +   /* 1: active-high, 0: active-low*/
 +   /* Function mode: be sure to set to 1   */
 +#define USBPCTRL0_PORT1BIT(0)  /* Selects port 1 mode: 
 */
 +   /* 1: function, 0: host */
 +
 +struct rcar_phy_platform_data {
 +   u32 usbpctrl0;  /* USBPCTRL0 register value */
 +};
 
 looks really wrong to me to pass register contents via pdata. You should
 pass flags which would aid the driver into figuring out how to program
 that register.
 
That was my first thought (and implementation) but this didn't
 look good either (and even worse with the device tree approach) as we
 couldn't come up with the clear names for the bitfields. Also, not
 all these bits are present in R8A7778 support for which I'm adding in
 the later patchset.
Besides, IMO this little differs from having a flags field with
 the flags bits #define'd beforehand. Or did you mean that I should
 have surely used *bool* bitfields?

How about:

rcar {
compatible ...
reg...

/* switch OVC for all three ports */
renesas,rcar-ovc-port-config = 2 high,
1  low,
0  high ;
renesas,rcar-port1-mode = host; /* could also be peripheral */;
};

Or something similar (not sure if the syntax is entirely correct). PENC
apparently doesn't anything if it always needs to be set to 1. Would
this work for you ?

-- 
balbi


signature.asc
Description: Digital signature


Re: USB-Wishbone bridge adapter

2013-04-10 Thread Wesley W. Terpstra
On Wed, 2013-04-10 at 19:01 +0200, Wesley W. Terpstra wrote:
 I've attached the output of lsusb -v
... and of course attached the output of an older version of the device.

The capabilities should read:
  CDC ACM:
bmCapabilities   0x02
  line coding and serial state
... otherwise it is the same.

I am not 100% certain if the CDC Call Management record should be
present in a non-modem device. This record may disappear once I've
clarified this detail of standard.


--
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-Wishbone bridge adapter

2013-04-10 Thread Wesley W. Terpstra
On Wed, 2013-04-10 at 10:08 -0700, Greg KH wrote:
 On Wed, Apr 10, 2013 at 07:01:40PM +0200, Wesley W. Terpstra wrote:
  Greg, I've attached a small Linux driver which recognizes and the
  USB-Wishbone functionality of the device. It just adds two vendor
  messages to signal to the FPGA that the device has been opened. Please
  let me know what needs to be improved before it could be considered for
  inclusion in the kernel proper.
 
 You need to send it in a format that I can use to apply it (hint, read
 the file, Documentation/SubmittingPatches.)  If you do that, I will be
 glad to review it, and if all is good, apply it to the kernel tree.

Alrighty. I will prepare a patch version of it tomorrow.

Thanks.


--
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 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-10 Thread Nishanth Menon
On 13:55-20130410, Roger Quadros wrote:
 On 04/10/2013 11:06 AM, Mike Turquette wrote:
  Quoting Nishanth Menon (2013-04-09 13:49:00)
  On 10:43-20130409, Tony Lindgren wrote:
  * Tony Lindgren t...@atomide.com [130409 09:54]:
  * Roger Quadros rog...@ti.com [130409 03:00]:
  On 04/05/2013 06:58 PM, Tony Lindgren wrote:
 
  Can't you just use the clock name there to get it?
 
  In device tree we don't pass around clock names. You can either get
  a phandle or an index to the clock.
 
  e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
 
  Yes I understand that. But the driver/clock/omap driver can just
  remap the DT device initially so the board specific clock is
  found from the clock alias table. Basically initially a passthrough
  driver that can be enhanced to parse DT clock bindings and load
  data from /lib/firmware.
 
  Actually probably the driver/clock/omap can even do even less
  initially. There probably even no need to remap clocks there.
 
  As long as the DT clock driver understands that a board specific
  auxclk is specified in the DT it can just call clk_add_alias() so
  the driver will get the right auxclk from cclock44xx_data.c.
 
  Then other features can be added later on like to allocate a
  clock entirely based on the binding etc.
  I did try to have an implementation for cpufreq using clock nodes.
  unfortunately, device tree wont let me have arguments of strings :(
  So, I am unable to do clock = clk mpu_dpll;
  instead, I am forced to do clock = clk 249;
 
  
  See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
  
 
 Awesome. Thanks for pointing this out Mike.
 
 Now all we need to do is create a named define for each clock index in the
 header file.
Approach #3: Thanks to Tony for collaborating on this:
Works for cpufreq-cpu0 - additional patches:
http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
beagleXM)
Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
this.
Details in the patch below (Tony, I have added you as collaborator for
helping in getting this working-clk_add_alias was'nt needed in the
internal patch discussion we had - I have taken a bit of freedom in
adding your contributions to the patch below)

Folks, this does seem to be the best compromise we can achieve at this
point in time. feedback on this approach is much appreciated - if folks
are ok, I can post this as an formal patch series.

From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
From: Nishanth Menon n...@ti.com
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
 data

OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
However, this presents an obstacle for using these clock nodes in
Device Tree definitions. There are many possible approaches to this
problem as discussed in the following thread:
http://marc.info/?t=13637032569r=1w=2
Highlights of the options:
a) device specific clk_add_alias:
cons: driver handling required
b) using an generic clk node and indexing to reach the clock required.
   This is similar in approach taken by tegra and few other platforms.
   example clock = clk 5;
   cons: potential to have mismatches in indexed table and associated
   dtb data. In addition, managing continued documentation in bindings
   as clock indexing increases. Even though readability angle could be
   improved by using preprocessing of DT using macros, indexed approach
   is inherently risky from cases like the following:
   clk indexes in kernel:
   1 - mpu_dpll
   2 - aux_clk1
   3 - core_clk
   DT entry for peripheral x uses clk 2, kernel updates to:
   1 - mpu_dpll
   2 - per_dpll
   3 - aux_clk1
   4 - core_clk
   using the old dtb(or dts missing an update), on new kernel which has
   updated indices will result in per_dpll now controlled for peripheral
   X without warning or any potential error detection and warning.

   Even though we can claim this is user error, such errors are hard to
   track down and fix.

An alternate approach introduced here is to introduce device tree bindings
corresponding to the clock nodes required in DT definition for SoC which
automatically maps back to the definitions in cclockXYZ_data.c.

The driver introduced here to do this mapping will eventually be the
place where the clock handling will migrate to. We need to consider this
angle as well so that the solution will be an valid transition point for
moving the clock data out of kernel image (into device tree or firmware load
etc..).

Overall strategy introduced here is simple: an clock node described in
device tree blob is used to identify the exact clock provided in the SoC
specific data. This is then linked back using of_clk_add_provider to the
device node to be accessible by of_clk_get.

Based on discussion contributions from Roger Quadros, Grygorii Strashko
and others.

[t...@atomide.com: co-developed]
Signed-off-by: Tony Lindgren t

Re: [PATCH v3 7/9] rcar-phy: add platform data

2013-04-10 Thread Sergei Shtylyov

Hello.

On 04/10/2013 09:16 PM, Felipe Balbi wrote:


Currently the driver hard-codes USBPCTRL0 register to 0.  It is wrong since this
register contains board-specific USB ports configuration and so its value should
be somehow passed via the platform data.  Add linux/usb/rcar-phy.h file with
the USBPCTRL0 bit #define's and 'struct rcar_phy_platform_data' containing the
value to be set by the driver to that register.
Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
Acked-by: Simon Horman horms+rene...@verge.net.au
---
Changes since version 2:
- added #include linux/types.h;
- added ACKs from Simon Horman and Kuninori Morimoto.
  include/linux/usb/rcar-phy.h |   40 
  1 file changed, 40 insertions(+)
Index: renesas/include/linux/usb/rcar-phy.h
===
--- /dev/null
+++ renesas/include/linux/usb/rcar-phy.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013 Cogent Embedded, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __RCAR_PHY_H
+#define __RCAR_PHY_H
+
+#include linux/bitops.h
+#include linux/types.h
+
+/* USBPCTRL0 register bits */
+#define USBPCTRL0_OVC2 BIT(10) /* Switches the OVC input pin for port 2: */
+   /* 1: USB_OVC2, 0: OVC2 */
+#define USBPCTRL0_OVC1_VBUS1 BIT(9) /* Switches the OVC input pin for port 1: 
*/
+   /* 1: USB_OVC1, 0: OVC1/VBUS1   */
+#define USBPCTRL0_OVC0 BIT(8)  /* Switches the OVC input pin for port 0: */
+   /* 1: USB_OVC0 pin, 0: OVC0 */
+#define USBPCTRL0_OVC2_ACT BIT(6) /* Host mode: OVC2 polarity: */
+   /* 1: active-high, 0: active-low*/
+   /* Function mode: be sure to set to 1   */
+#define USBPCTRL0_PENC BIT(4)  /* Function mode: output level of PENC1 pin: */
+   /* 1: high, 0: low  */
+#define USBPCTRL0_OVC0_ACT BIT(3) /* Host mode: OVC0 polarity: */
+   /* 1: active-high, 0: active-low*/
+#define USBPCTRL0_OVC1_ACT BIT(1) /* Host mode: OVC1 polarity: */
+   /* 1: active-high, 0: active-low*/
+   /* Function mode: be sure to set to 1   */
+#define USBPCTRL0_PORT1BIT(0)  /* Selects port 1 mode: 
*/
+   /* 1: function, 0: host */
+
+struct rcar_phy_platform_data {
+   u32 usbpctrl0;  /* USBPCTRL0 register value */
+};

looks really wrong to me to pass register contents via pdata. You should
pass flags which would aid the driver into figuring out how to program
that register.

That was my first thought (and implementation) but this didn't
look good either (and even worse with the device tree approach) as we
couldn't come up with the clear names for the bitfields. Also, not
all these bits are present in R8A7778 support for which I'm adding in
the later patchset.
Besides, IMO this little differs from having a flags field with
the flags bits #define'd beforehand. Or did you mean that I should
have surely used *bool* bitfields?

How about:


Er, I was asking you about the platform data only, not the DT 
representation yet. :-)




rcar {
compatible ...
reg...

/* switch OVC for all three ports */
renesas,rcar-ovc-port-config = 2 high,
1  low,
0  high ;


Hm, 'dtc' allows mixed type properties now?
Also, we need to describe the multiplexing of the OVCn pins (5V or 
3.3V input),

not only the active level.


renesas,rcar-port1-mode = host; /* could also be peripheral */;


You see, all this involves string type (and so more complex to deal 
with) props.
We were hoping to use only boolean props, more or less corresponding to 
the register bits...



};

Or something similar (not sure if the syntax is entirely correct).


   I'm not sure too.


PENC
apparently doesn't anything if it always needs to be set to 1.


   You've mixed it with some other pin -- it can be 0 or 1 in function 
mode.



Would this work for you ?


I should try... All this surely looks more complex than we would 
hope...


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 1/2 v4] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Oliver Neukum
On Wednesday 10 April 2013 10:01:20 Dan Williams wrote:
 On Wed, 2013-04-10 at 15:58 +0200, Oliver Neukum wrote:
  On Wednesday 10 April 2013 08:54:43 Dan Williams wrote:
The refcounting is very good. Just don't mess around with force
   
   That's easy to do if the helpers aren't used for suspend/resume, which
   is what I had previously in my v2 patches until Ming suggested that I
   use the helpers there.  I can go back to that approach if you'd like, it
   is a bit less complicated at the expense of sprinkling the interrupt urb
   submit/kill code around more widely.
  
  If you introduce a third helper like forcibly_stop_interrupt or something,
  I'll be perfectly happy. Just don't use flags which completely alter 
  behavior.
  
  Regards
  Oliver
 
 Do you mean something more like this?  If so, I'll go ahead and do the
 formal submission.  Thanks!

That looks good and ready.

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


[PATCH v3 00/11] usb: musb: add back support for host mode

2013-04-10 Thread Daniel Mack
Hi all,

here are some patches to separate the HCD and gadget part of the musb
driver so they can be deselected in Kconfig. They also make the driver
keep track of the configured port mode that is set from DT, so the
actual runtime configuration can be selected dynamically.

One thing that is still broken is that once pm_suspend() was called on
a musb device on a USB disconnect, the port won't wake up again when a
device is plugged back in. I doubt this is related to my patches, but I
might be wrong. If that effect rings a bell to anyone, please let me
know.

Thanks,
Daniel


Changes from v2:
* simplified Makefile rework
* really remove musb_to_hcd
* fixed some types
(all reported by Peter Korsgaard, thanks!)

Changes from v1:
* fixed some typos in commit logs
* factor out musb_host_resume_root_hub and
  musb_host_poke_root_hub()
* split some changes into separate patches
* some minor cosmetics fixed

Daniel Mack (11):
  usb: gadget: drop unused USB_GADGET_MUSB_HDRC
  usb: musb: move function declarations to musb_{host,gadget}.h
  usb: musb: factor some host-specific functions
  usb: musb: gadget: remove hcd initialization
  usb: musb: move musb_start to musb_virthub.c
  usb: musb: factor out hcd initalization
  usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes
  usb: musb: add musb_host_setup() and musb_host_cleanup()
  usb: musb: re-introduce musb-port_mode
  usb: musb: use musb-port_mode
  usb: musb: eliminate musb_to_hcd

 drivers/usb/gadget/Kconfig  |   8 ---
 drivers/usb/musb/Kconfig|  29 +
 drivers/usb/musb/Makefile   |   4 +-
 drivers/usb/musb/musb_core.c| 127 +++-
 drivers/usb/musb/musb_core.h|  26 +++-
 drivers/usb/musb/musb_gadget.c  |  10 
 drivers/usb/musb/musb_gadget.h  |  38 ++--
 drivers/usb/musb/musb_host.c|  90 +---
 drivers/usb/musb/musb_host.h|  57 ++
 drivers/usb/musb/musb_virthub.c |  51 +++-
 drivers/usb/musb/omap2430.c |   2 +-
 11 files changed, 294 insertions(+), 148 deletions(-)

-- 
1.8.1.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 v3 01/11] usb: gadget: drop unused USB_GADGET_MUSB_HDRC

2013-04-10 Thread Daniel Mack
The functionality meant to be represented by this symbol will be
re-added later, but for now, USB_GADGET_MUSB_HDRC is in fact unused and
can be dropped.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/gadget/Kconfig | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a61d981..0702fa0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -333,14 +333,6 @@ config USB_MV_U3D
 # Controllers available in both integrated and discrete versions
 #
 
-# musb builds in ../musb along with host support
-config USB_GADGET_MUSB_HDRC
-   tristate Inventra HDRC USB Peripheral (TI, ADI, ...)
-   depends on USB_MUSB_HDRC
-   help
- This OTG-capable silicon IP is used in dual designs including
- the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI Blackfin
-
 config USB_M66592
tristate Renesas M66592 USB Peripheral Controller
help
-- 
1.8.1.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 v3 02/11] usb: musb: move function declarations to musb_{host,gadget}.h

2013-04-10 Thread Daniel Mack
Let the function declarations live in the header files they belong to,
which makes it easier to stub them out later.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.h   | 17 -
 drivers/usb/musb/musb_gadget.h | 17 +++--
 drivers/usb/musb/musb_host.h   |  4 +++-
 3 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 7fb4819..04d8974 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -82,23 +82,6 @@ struct musb_ep;
 #define MUSB_CONFIG_PROC_FS
 #endif
 
-/** PERIPHERAL ROLE */
-
-extern irqreturn_t musb_g_ep0_irq(struct musb *);
-extern void musb_g_tx(struct musb *, u8);
-extern void musb_g_rx(struct musb *, u8);
-extern void musb_g_reset(struct musb *);
-extern void musb_g_suspend(struct musb *);
-extern void musb_g_resume(struct musb *);
-extern void musb_g_wakeup(struct musb *);
-extern void musb_g_disconnect(struct musb *);
-
-/** HOST ROLE ***/
-
-extern irqreturn_t musb_h_ep0_irq(struct musb *);
-extern void musb_host_tx(struct musb *, u8);
-extern void musb_host_rx(struct musb *, u8);
-
 /** CONSTANTS /
 
 #ifndef MUSB_C_NUM_EPS
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 66b7c5e..75f821c 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -37,6 +37,17 @@
 
 #include linux/list.h
 
+extern irqreturn_t musb_g_ep0_irq(struct musb *);
+extern void musb_g_tx(struct musb *, u8);
+extern void musb_g_rx(struct musb *, u8);
+extern void musb_g_reset(struct musb *);
+extern void musb_g_suspend(struct musb *);
+extern void musb_g_resume(struct musb *);
+extern void musb_g_wakeup(struct musb *);
+extern void musb_g_disconnect(struct musb *);
+extern void musb_gadget_cleanup(struct musb *);
+extern int musb_gadget_setup(struct musb *);
+
 enum buffer_map_state {
UN_MAPPED = 0,
PRE_MAPPED,
@@ -106,14 +117,8 @@ static inline struct musb_request *next_request(struct 
musb_ep *ep)
return container_of(queue-next, struct musb_request, list);
 }
 
-extern void musb_g_tx(struct musb *musb, u8 epnum);
-extern void musb_g_rx(struct musb *musb, u8 epnum);
-
 extern const struct usb_ep_ops musb_g_ep0_ops;
 
-extern int musb_gadget_setup(struct musb *);
-extern void musb_gadget_cleanup(struct musb *);
-
 extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
 
 extern void musb_ep_restart(struct musb *, struct musb_request *);
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 5a9c8fe..9670269 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -84,7 +84,9 @@ static inline struct musb_qh *first_qh(struct list_head *q)
return list_entry(q-next, struct musb_qh, ring);
 }
 
-
+extern irqreturn_t musb_h_ep0_irq(struct musb *);
+extern void musb_host_tx(struct musb *, u8);
+extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
 
 struct usb_hcd;
-- 
1.8.1.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 v3 05/11] usb: musb: move musb_start to musb_virthub.c

2013-04-10 Thread Daniel Mack
This function has its only user in musb_virthub.c, so let's move it
there and make it static.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c| 45 -
 drivers/usb/musb/musb_core.h|  1 -
 drivers/usb/musb/musb_virthub.c | 44 
 3 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 13341c6..adf069d 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -905,51 +905,6 @@ b_host:
 
 /*-*/
 
-/*
-* Program the HDRC to start (enable interrupts, dma, etc.).
-*/
-void musb_start(struct musb *musb)
-{
-   void __iomem*regs = musb-mregs;
-   u8  devctl = musb_readb(regs, MUSB_DEVCTL);
-
-   dev_dbg(musb-controller, == devctl %02x\n, devctl);
-
-   /*  Set INT enable registers, enable interrupts */
-   musb-intrtxe = musb-epmask;
-   musb_writew(regs, MUSB_INTRTXE, musb-intrtxe);
-   musb-intrrxe = musb-epmask  0xfffe;
-   musb_writew(regs, MUSB_INTRRXE, musb-intrrxe);
-   musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
-
-   musb_writeb(regs, MUSB_TESTMODE, 0);
-
-   /* put into basic highspeed mode and start session */
-   musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
-   | MUSB_POWER_HSENAB
-   /* ENSUSPEND wedges tusb */
-   /* | MUSB_POWER_ENSUSPEND */
-   );
-
-   musb-is_active = 0;
-   devctl = musb_readb(regs, MUSB_DEVCTL);
-   devctl = ~MUSB_DEVCTL_SESSION;
-
-   /* session started after:
-* (a) ID-grounded irq, host mode;
-* (b) vbus present/connect IRQ, peripheral mode;
-* (c) peripheral initiates, using SRP
-*/
-   if ((devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
-   musb-is_active = 1;
-   else
-   devctl |= MUSB_DEVCTL_SESSION;
-
-   musb_platform_enable(musb);
-   musb_writeb(regs, MUSB_DEVCTL, devctl);
-}
-
-
 static void musb_generic_disable(struct musb *musb)
 {
void __iomem*mbase = musb-mregs;
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 04d8974..87da041 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -503,7 +503,6 @@ static inline void musb_configure_ep0(struct musb *musb)
 
 extern const char musb_driver_name[];
 
-extern void musb_start(struct musb *musb);
 extern void musb_stop(struct musb *musb);
 
 extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index ef7d110..1e17c20 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -44,6 +44,50 @@
 
 #include musb_core.h
 
+/*
+* Program the HDRC to start (enable interrupts, dma, etc.).
+*/
+static void musb_start(struct musb *musb)
+{
+   void __iomem*regs = musb-mregs;
+   u8  devctl = musb_readb(regs, MUSB_DEVCTL);
+
+   dev_dbg(musb-controller, == devctl %02x\n, devctl);
+
+   /*  Set INT enable registers, enable interrupts */
+   musb-intrtxe = musb-epmask;
+   musb_writew(regs, MUSB_INTRTXE, musb-intrtxe);
+   musb-intrrxe = musb-epmask  0xfffe;
+   musb_writew(regs, MUSB_INTRRXE, musb-intrrxe);
+   musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
+
+   musb_writeb(regs, MUSB_TESTMODE, 0);
+
+   /* put into basic highspeed mode and start session */
+   musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
+   | MUSB_POWER_HSENAB
+   /* ENSUSPEND wedges tusb */
+   /* | MUSB_POWER_ENSUSPEND */
+   );
+
+   musb-is_active = 0;
+   devctl = musb_readb(regs, MUSB_DEVCTL);
+   devctl = ~MUSB_DEVCTL_SESSION;
+
+   /* session started after:
+* (a) ID-grounded irq, host mode;
+* (b) vbus present/connect IRQ, peripheral mode;
+* (c) peripheral initiates, using SRP
+*/
+   if ((devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
+   musb-is_active = 1;
+   } else {
+   devctl |= MUSB_DEVCTL_SESSION;
+   }
+
+   musb_platform_enable(musb);
+   musb_writeb(regs, MUSB_DEVCTL, devctl);
+}
 
 static void musb_port_suspend(struct musb *musb, bool do_suspend)
 {
-- 
1.8.1.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 v3 04/11] usb: musb: gadget: remove hcd initialization

2013-04-10 Thread Daniel Mack
This will be done from a more appropriate location and as it doesn't
work anyway, it can safely be removed before the other changes.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_gadget.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index ba70923..0414bc1 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1820,7 +1820,6 @@ static int musb_gadget_start(struct usb_gadget *g,
 {
struct musb *musb = gadget_to_musb(g);
struct usb_otg  *otg = musb-xceiv-otg;
-   struct usb_hcd  *hcd = musb_to_hcd(musb);
unsigned long   flags;
int retval = 0;
 
@@ -1847,17 +1846,9 @@ static int musb_gadget_start(struct usb_gadget *g,
 * handles power budgeting ... this way also
 * ensures HdrcStart is indirectly called.
 */
-   retval = usb_add_hcd(hcd, 0, 0);
-   if (retval  0) {
-   dev_dbg(musb-controller, add_hcd failed, %d\n, retval);
-   goto err;
-   }
-
if (musb-xceiv-last_event == USB_EVENT_ID)
musb_platform_set_vbus(musb, 1);
 
-   hcd-self.uses_pio_for_control = 1;
-
if (musb-xceiv-last_event == USB_EVENT_NONE)
pm_runtime_put(musb-controller);
 
@@ -1942,7 +1933,6 @@ static int musb_gadget_stop(struct usb_gadget *g,
musb_platform_try_idle(musb, 0);
spin_unlock_irqrestore(musb-lock, flags);
 
-   usb_remove_hcd(musb_to_hcd(musb));
/*
 * FIXME we need to be able to register another
 * gadget driver here and have everything work;
-- 
1.8.1.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 v3 07/11] usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes

2013-04-10 Thread Daniel Mack
This makes building the actual object files optional to the selected
mode, which saves users who know which kind of USB mode support they
need some binary size.

Unimplemented functions are stubbed out with static inline functions.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/Kconfig   | 29 +
 drivers/usb/musb/Makefile  |  4 ++--
 drivers/usb/musb/musb_gadget.h | 21 +
 drivers/usb/musb/musb_host.h   | 29 +++--
 4 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 47442d3..aab1568 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -28,6 +28,35 @@ config USB_MUSB_HDRC
 if USB_MUSB_HDRC
 
 choice
+   bool MUSB Mode Selection
+   default USB_MUSB_DUAL_ROLE if (USB  USB_GADGET)
+   default USB_MUSB_HOST if (USB  !USB_GADGET)
+   default USB_MUSB_GADGET if (!USB  USB_GADGET)
+
+config USB_MUSB_HOST
+   bool Host only mode
+   depends on USB
+   help
+ Select this when you want to use MUSB in host mode only,
+ thereby the gadget feature will be regressed.
+
+config USB_MUSB_GADGET
+   bool Gadget only mode
+   depends on USB_GADGET
+   help
+ Select this when you want to use MUSB in gadget mode only,
+ thereby the host feature will be regressed.
+
+config USB_MUSB_DUAL_ROLE
+   bool Dual Role mode
+   depends on (USB  USB_GADGET)
+   help
+ This is the default mode of working of MUSB controller where
+ both host and gadget features are enabled.
+
+endchoice
+
+choice
prompt Platform Glue Layer
 
 config USB_MUSB_DAVINCI
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index 3b85871..2b82ed7 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -6,8 +6,8 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
 
 musb_hdrc-y := musb_core.o
 
-musb_hdrc-y+= musb_gadget_ep0.o 
musb_gadget.o
-musb_hdrc-y+= musb_virthub.o musb_host.o
+musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += 
musb_virthub.o musb_host.o
+musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += 
musb_gadget_ep0.o musb_gadget.o
 musb_hdrc-$(CONFIG_DEBUG_FS)   += musb_debugfs.o
 
 # Hardware Glue Layer
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 75f821c..0314dfc 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -37,6 +37,7 @@
 
 #include linux/list.h
 
+#if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
 extern irqreturn_t musb_g_ep0_irq(struct musb *);
 extern void musb_g_tx(struct musb *, u8);
 extern void musb_g_rx(struct musb *, u8);
@@ -48,6 +49,26 @@ extern void musb_g_disconnect(struct musb *);
 extern void musb_gadget_cleanup(struct musb *);
 extern int musb_gadget_setup(struct musb *);
 
+#else
+static inline irqreturn_t musb_g_ep0_irq(struct musb *musb)
+{
+   return 0;
+}
+
+static inline void musb_g_tx(struct musb *musb, u8 epnum)  {}
+static inline void musb_g_rx(struct musb *musb, u8 epnum)  {}
+static inline void musb_g_reset(struct musb *musb) {}
+static inline void musb_g_suspend(struct musb *musb)   {}
+static inline void musb_g_resume(struct musb *musb){}
+static inline void musb_g_wakeup(struct musb *musb){}
+static inline void musb_g_disconnect(struct musb *musb){}
+static inline void musb_gadget_cleanup(struct musb *musb)  {}
+static inline int musb_gadget_setup(struct musb *musb)
+{
+   return 0;
+}
+#endif
+
 enum buffer_map_state {
UN_MAPPED = 0,
PRE_MAPPED,
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index e47035e..1ce6e4e 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -39,8 +39,6 @@
 
 #define musb_to_hcd(MUSB) ((MUSB)-hcd)
 
-extern struct musb *hcd_to_musb(struct usb_hcd *);
-
 /* stored in usb_host_endpoint.hcpriv for scheduled endpoints */
 struct musb_qh {
struct usb_host_endpoint *hep;  /* usbcore info */
@@ -78,6 +76,9 @@ static inline struct musb_qh *first_qh(struct list_head *q)
return list_entry(q-next, struct musb_qh, ring);
 }
 
+
+#if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
+extern struct musb *hcd_to_musb(struct usb_hcd *);
 extern irqreturn_t musb_h_ep0_irq(struct musb *);
 extern int musb_host_alloc(struct musb *);
 extern void musb_host_tx(struct musb *, u8);
@@ -90,6 +91,30 @@ extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
 extern void musb_host_resume_root_hub(struct musb *musb);
 extern void musb_host_poke_root_hub(struct musb *musb);
+#else
+static inline 

[PATCH v3 08/11] usb: musb: add musb_host_setup() and musb_host_cleanup()

2013-04-10 Thread Daniel Mack
This patch re-introduces the bits that are necessary to use the musb
controller in host mode.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c |  5 +
 drivers/usb/musb/musb_host.c | 21 +
 drivers/usb/musb/musb_host.h |  8 
 3 files changed, 34 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index f3519d3..fbcf5cb 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -961,6 +961,7 @@ static void musb_shutdown(struct platform_device *pdev)
 
pm_runtime_get_sync(musb-controller);
 
+   musb_host_cleanup(musb);
musb_gadget_cleanup(musb);
 
spin_lock_irqsave(musb-lock, flags);
@@ -1910,6 +1911,10 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-xceiv-state = OTG_STATE_B_IDLE;
}
 
+   status = musb_host_setup(musb, plat-power);
+   if (status  0)
+   goto fail3;
+
status = musb_gadget_setup(musb);
 
if (status  0)
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 38834b2..b6a840e 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2648,6 +2648,27 @@ void musb_host_free(struct musb *musb)
usb_put_hcd(musb-hcd);
 }
 
+int musb_host_setup(struct musb *musb, int power_budget)
+{
+   int ret;
+   struct usb_hcd *hcd = musb-hcd;
+
+   MUSB_HST_MODE(musb);
+   musb-xceiv-otg-default_a = 1;
+   musb-xceiv-state = OTG_STATE_A_IDLE;
+
+   otg_set_host(musb-xceiv-otg, hcd-self);
+   hcd-self.otg_port = 1;
+   musb-xceiv-otg-host = hcd-self;
+   hcd-power_budget = 2 * (power_budget ? : 250);
+
+   ret = usb_add_hcd(hcd, 0, 0);
+   if (ret  0)
+   return ret;
+
+   return 0;
+}
+
 void musb_host_resume_root_hub(struct musb *musb)
 {
usb_hcd_resume_root_hub(musb-hcd);
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 1ce6e4e..48a4bdd 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -81,6 +81,8 @@ static inline struct musb_qh *first_qh(struct list_head *q)
 extern struct musb *hcd_to_musb(struct usb_hcd *);
 extern irqreturn_t musb_h_ep0_irq(struct musb *);
 extern int musb_host_alloc(struct musb *);
+extern int musb_host_setup(struct musb *, int);
+extern void musb_host_cleanup(struct musb *);
 extern void musb_host_tx(struct musb *, u8);
 extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
@@ -107,6 +109,12 @@ static inline int musb_host_alloc(struct musb *musb)
return 0;
 }
 
+static inline int musb_host_setup(struct musb *musb, int power_budget)
+{
+   return 0;
+}
+
+static inline void musb_host_cleanup(struct musb *musb){}
 static inline void musb_host_free(struct musb *musb)   {}
 static inline void musb_host_tx(struct musb *musb, u8 epnum)   {}
 static inline void musb_host_rx(struct musb *musb, u8 epnum)   {}
-- 
1.8.1.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 v3 09/11] usb: musb: re-introduce musb-port_mode

2013-04-10 Thread Daniel Mack
Define MUSB_PORT_MODE_{HOST,GADGET,DUAL_ROLE} and store the
platform-specified value in struct musb.

Note that MUSB_PORT_MODE_HOST has to be set to 1 in order to match
existing device tree bindings which are already documented but in fact
unusued. For information on the bindings, please refer to

  Documentation/devicetree/bindings/usb/omap-usb.txt
  Documentation/devicetree/bindings/usb/am33xx-usb.txt

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c | 1 +
 drivers/usb/musb/musb_core.h | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index fbcf5cb..2640d25 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1821,6 +1821,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-board_set_power = plat-set_power;
musb-min_power = plat-min_power;
musb-ops = plat-platform_ops;
+   musb-port_mode = plat-mode;
 
/* The musb_platform_init() call:
 *   - adjusts musb-mregs
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 6b65847..174c097 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -77,6 +77,12 @@ struct musb_ep;
 #define is_peripheral_active(m)(!(m)-is_host)
 #define is_host_active(m)  ((m)-is_host)
 
+enum {
+   MUSB_PORT_MODE_HOST = 1,
+   MUSB_PORT_MODE_GADGET,
+   MUSB_PORT_MODE_DUAL_ROLE,
+};
+
 #ifdef CONFIG_PROC_FS
 #include linux/fs.h
 #define MUSB_CONFIG_PROC_FS
@@ -356,6 +362,7 @@ struct musb {
 
u8  min_power;  /* vbus for periph, in mA/2 */
 
+   int port_mode;  /* MUSB_PORT_MODE_* */
boolis_host;
 
int a_wait_bcon;/* VBUS timeout in msecs */
-- 
1.8.1.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 v3 10/11] usb: musb: use musb-port_mode

2013-04-10 Thread Daniel Mack
Initialize the host and gagdet subsystems of the musb driver only when
the appropriate mode is selected from platform data, or device-tree
information, respectively.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c| 22 +-
 drivers/usb/musb/musb_virthub.c |  3 ++-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2640d25..b3b9873 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1912,11 +1912,23 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-xceiv-state = OTG_STATE_B_IDLE;
}
 
-   status = musb_host_setup(musb, plat-power);
-   if (status  0)
-   goto fail3;
-
-   status = musb_gadget_setup(musb);
+   switch (musb-port_mode) {
+   case MUSB_PORT_MODE_HOST:
+   status = musb_host_setup(musb, plat-power);
+   break;
+   case MUSB_PORT_MODE_GADGET:
+   status = musb_gadget_setup(musb);
+   break;
+   case MUSB_PORT_MODE_DUAL_ROLE:
+   status = musb_host_setup(musb, plat-power);
+   if (status  0)
+   goto fail3;
+   status = musb_gadget_setup(musb);
+   break;
+   default:
+   dev_err(dev, unsupported port mode %d\n, musb-port_mode);
+   break;
+   }
 
if (status  0)
goto fail3;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 1e17c20..8d92ba2 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
 * (b) vbus present/connect IRQ, peripheral mode;
 * (c) peripheral initiates, using SRP
 */
-   if ((devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
+   if (musb-port_mode != MUSB_PORT_MODE_HOST 
+   (devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
musb-is_active = 1;
} else {
devctl |= MUSB_DEVCTL_SESSION;
-- 
1.8.1.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 v3 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Daniel Mack
The musb struct is currently allocated along with the hcd, which makes
it difficult to build a driver that only acts as gadget device.

Fix this by allocating musb directly, and keep the hcd around as
a pointer in the musb struct.

struct hc_driver musb_hc_driver can now also be static to musb_host.c,
and the macro musb_to_hcd() is just a pointer dereferencer for now, and
will be eliminated later.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c | 40 
 drivers/usb/musb/musb_core.h |  1 +
 drivers/usb/musb/musb_host.c | 54 ++--
 drivers/usb/musb/musb_host.h | 19 +++-
 4 files changed, 75 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index adf069d..f3519d3 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -404,7 +404,8 @@ void musb_hnp_stop(struct musb *musb)
break;
case OTG_STATE_B_HOST:
dev_dbg(musb-controller, HNP: Disabling HR\n);
-   hcd-self.is_b_host = 0;
+   if (hcd)
+   hcd-self.is_b_host = 0;
musb-xceiv-state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
reg = musb_readb(mbase, MUSB_POWER);
@@ -726,7 +727,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
dev_dbg(musb-controller, HNP: CONNECT, now b_host\n);
 b_host:
musb-xceiv-state = OTG_STATE_B_HOST;
-   hcd-self.is_b_host = 1;
+   if (hcd)
+   hcd-self.is_b_host = 1;
musb-ignore_disconnect = 0;
del_timer(musb-otg_timer);
break;
@@ -768,7 +770,8 @@ b_host:
 * in hnp_stop() is currently not used...
 */
musb_root_disconnect(musb);
-   musb_to_hcd(musb)-self.is_b_host = 0;
+   if (musb-hcd)
+   musb-hcd-self.is_b_host = 0;
musb-xceiv-state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
musb_g_disconnect(musb);
@@ -1714,24 +1717,18 @@ static struct musb *allocate_instance(struct device 
*dev,
struct musb *musb;
struct musb_hw_ep   *ep;
int epnum;
-   struct usb_hcd  *hcd;
+   int ret;
 
-   hcd = usb_create_hcd(musb_hc_driver, dev, dev_name(dev));
-   if (!hcd)
+   musb = devm_kzalloc(dev, sizeof(*musb), GFP_KERNEL);
+   if (!musb)
return NULL;
-   /* usbcore sets dev-driver_data to hcd, and sometimes uses that... */
 
-   musb = hcd_to_musb(hcd);
INIT_LIST_HEAD(musb-control);
INIT_LIST_HEAD(musb-in_bulk);
INIT_LIST_HEAD(musb-out_bulk);
 
-   hcd-uses_new_polling = 1;
-   hcd-has_tt = 1;
-
musb-vbuserr_retry = VBUSERR_RETRY_COUNT;
musb-a_wait_bcon = OTG_TIME_A_WAIT_BCON;
-   dev_set_drvdata(dev, musb);
musb-mregs = mbase;
musb-ctrl_base = mbase;
musb-nIrq = -ENODEV;
@@ -1746,7 +1743,16 @@ static struct musb *allocate_instance(struct device *dev,
 
musb-controller = dev;
 
+   ret = musb_host_alloc(musb);
+   if (ret  0)
+   goto err_free;
+
+   dev_set_drvdata(dev, musb);
+
return musb;
+
+err_free:
+   return NULL;
 }
 
 static void musb_free(struct musb *musb)
@@ -1772,7 +1778,7 @@ static void musb_free(struct musb *musb)
dma_controller_destroy(c);
}
 
-   usb_put_hcd(musb_to_hcd(musb));
+   musb_host_free(musb);
 }
 
 /*
@@ -1789,7 +1795,6 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
int status;
struct musb *musb;
struct musb_hdrc_platform_data *plat = dev-platform_data;
-   struct usb_hcd  *hcd;
 
/* The driver might handle more features than the board; OK.
 * Fail when the board needs a feature that's not enabled.
@@ -1890,13 +1895,6 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-irq_wake = 0;
}
 
-   /* host side needs more setup */
-   hcd = musb_to_hcd(musb);
-   otg_set_host(musb-xceiv-otg, hcd-self);
-   hcd-self.otg_port = 1;
-   musb-xceiv-otg-host = hcd-self;
-   hcd-power_budget = 2 * (plat-power ? : 250);
-
/* program PHY to use external vBus if required */
if (plat-extvbus) {
u8 busctl = musb_read_ulpi_buscontrol(musb-mregs);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 87da041..6b65847 100644
--- 

[PATCH v3 11/11] usb: musb: eliminate musb_to_hcd

2013-04-10 Thread Daniel Mack
With the hcd is now a direct member of struct musb, we can now simply
eliminate the musb_to_hcd() macro. There aren't that many users left
anyway, as some where already fixed up when parts were factored out to
musb_host.c

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c| 4 ++--
 drivers/usb/musb/musb_host.c| 8 
 drivers/usb/musb/musb_host.h| 2 --
 drivers/usb/musb/musb_virthub.c | 6 +++---
 drivers/usb/musb/omap2430.c | 2 +-
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b3b9873..57b7a17 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -389,7 +389,7 @@ static void musb_otg_timer_func(unsigned long data)
  */
 void musb_hnp_stop(struct musb *musb)
 {
-   struct usb_hcd  *hcd = musb_to_hcd(musb);
+   struct usb_hcd  *hcd = musb-hcd;
void __iomem*mbase = musb-mregs;
u8  reg;
 
@@ -686,7 +686,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
}
 
if (int_usb  MUSB_INTR_CONNECT) {
-   struct usb_hcd *hcd = musb_to_hcd(musb);
+   struct usb_hcd *hcd = musb-hcd;
 
handled = IRQ_HANDLED;
musb-is_active = 1;
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index b6a840e..d3cbaa3 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -320,9 +320,9 @@ __acquires(musb-lock)
urb-actual_length, urb-transfer_buffer_length
);
 
-   usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb);
+   usb_hcd_unlink_urb_from_ep(musb-hcd, urb);
spin_unlock(musb-lock);
-   usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status);
+   usb_hcd_giveback_urb(musb-hcd, urb, status);
spin_lock(musb-lock);
 }
 
@@ -1465,7 +1465,7 @@ done:
if (length  qh-maxpacket)
length = qh-maxpacket;
/* Unmap the buffer so that CPU can use it */
-   usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb);
+   usb_hcd_unmap_urb_for_dma(musb-hcd, urb);
 
/*
 * We need to map sg if the transfer_buffer is
@@ -1880,7 +1880,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
unsigned int received_len;
 
/* Unmap the buffer so that CPU can use it */
-   usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb);
+   usb_hcd_unmap_urb_for_dma(musb-hcd, urb);
 
/*
 * We need to map sg if the transfer_buffer is
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 48a4bdd..c202d5b 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -37,8 +37,6 @@
 
 #include linux/scatterlist.h
 
-#define musb_to_hcd(MUSB) ((MUSB)-hcd)
-
 /* stored in usb_host_endpoint.hcpriv for scheduled endpoints */
 struct musb_qh {
struct usb_host_endpoint *hep;  /* usbcore info */
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 8d92ba2..5a101fe 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -215,7 +215,7 @@ static void musb_port_reset(struct musb *musb, bool 
do_reset)
musb-port1_status |= USB_PORT_STAT_ENABLE
| (USB_PORT_STAT_C_RESET  16)
| (USB_PORT_STAT_C_ENABLE  16);
-   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   usb_hcd_poll_rh_status(musb-hcd);
 
musb-vbuserr_retry = VBUSERR_RETRY_COUNT;
}
@@ -228,7 +228,7 @@ void musb_root_disconnect(struct musb *musb)
musb-port1_status = USB_PORT_STAT_POWER
| (USB_PORT_STAT_C_CONNECTION  16);
 
-   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   usb_hcd_poll_rh_status(musb-hcd);
musb-is_active = 0;
 
switch (musb-xceiv-state) {
@@ -382,7 +382,7 @@ int musb_hub_control(
musb-port1_status = ~(USB_PORT_STAT_SUSPEND
| MUSB_PORT_STAT_RESUME);
musb-port1_status |= USB_PORT_STAT_C_SUSPEND  16;
-   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   usb_hcd_poll_rh_status(musb-hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
musb-xceiv-state = OTG_STATE_A_HOST;
}
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3551f1a..1bafcd5 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -87,7 +87,7 @@ static void musb_do_idle(unsigned long _musb)
musb-port1_status = ~(USB_PORT_STAT_SUSPEND

[PATCH v3 03/11] usb: musb: factor some host-specific functions

2013-04-10 Thread Daniel Mack
In particular, this introduces musb_host_resume_root_hub()and
musb_host_poke_root_hub() which will be stubbed out later.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c | 18 +++---
 drivers/usb/musb/musb_host.c | 15 ++-
 drivers/usb/musb/musb_host.h |  3 +++
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 37a261a..13341c6 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -484,7 +484,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
 
musb-xceiv-state = OTG_STATE_A_HOST;
musb-is_active = 1;
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
musb-xceiv-state = OTG_STATE_B_PERIPHERAL;
@@ -501,7 +501,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
case OTG_STATE_A_SUSPEND:
/* possibly DISCONNECT is upcoming */
musb-xceiv-state = OTG_STATE_A_HOST;
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_PERIPHERAL:
@@ -643,7 +643,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
 * undesired detour through A_WAIT_BCON.
 */
musb_hnp_stop(musb);
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
musb_root_disconnect(musb);
musb_platform_try_idle(musb, jiffies
+ msecs_to_jiffies(musb-a_wait_bcon
@@ -734,17 +734,13 @@ b_host:
if ((devctl  MUSB_DEVCTL_VBUS)
== (3  MUSB_DEVCTL_VBUS_SHIFT)) {
musb-xceiv-state = OTG_STATE_A_HOST;
-   hcd-self.is_b_host = 0;
+   if (hcd)
+   hcd-self.is_b_host = 0;
}
break;
}
 
-   /* poke the root hub */
-   MUSB_HST_MODE(musb);
-   if (hcd-status_urb)
-   usb_hcd_poll_rh_status(hcd);
-   else
-   usb_hcd_resume_root_hub(hcd);
+   musb_host_poke_root_hub(musb);
 
dev_dbg(musb-controller, CONNECT (%s) devctl %02x\n,
usb_otg_state_string(musb-xceiv-state), 
devctl);
@@ -759,7 +755,7 @@ b_host:
switch (musb-xceiv-state) {
case OTG_STATE_A_HOST:
case OTG_STATE_A_SUSPEND:
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
musb_root_disconnect(musb);
if (musb-a_wait_bcon != 0)
musb_platform_try_idle(musb, jiffies
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 8914dec..8b977d2 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -46,7 +46,6 @@
 #include musb_core.h
 #include musb_host.h
 
-
 /* MUSB HOST status 22-mar-2006
  *
  * - There's still lots of partial code duplication for fault paths, so
@@ -2608,3 +2607,17 @@ const struct hc_driver musb_hc_driver = {
/* .start_port_reset= NULL, */
/* .hub_irq_enable  = NULL, */
 };
+
+void musb_host_resume_root_hub(struct musb *musb)
+{
+   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+}
+
+void musb_host_poke_root_hub(struct musb *musb)
+{
+   MUSB_HST_MODE(musb);
+   if (musb_to_hcd(musb)-status_urb)
+   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   else
+   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+}
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 9670269..c63e585 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -89,6 +89,9 @@ extern void musb_host_tx(struct musb *, u8);
 extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
 
+extern void musb_host_resume_root_hub(struct musb *musb);
+extern void musb_host_poke_root_hub(struct musb *musb);
+
 struct usb_hcd;
 
 extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
-- 
1.8.1.4

--
To 

Re: [PATCH v3 7/9] rcar-phy: add platform data

2013-04-10 Thread Felipe Balbi
Hi,

On Wed, Apr 10, 2013 at 09:44:33PM +0400, Sergei Shtylyov wrote:
 Currently the driver hard-codes USBPCTRL0 register to 0.  It is wrong 
 since this
 register contains board-specific USB ports configuration and so its value 
 should
 be somehow passed via the platform data.  Add linux/usb/rcar-phy.h file 
 with
 the USBPCTRL0 bit #define's and 'struct rcar_phy_platform_data' 
 containing the
 value to be set by the driver to that register.
 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
 Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 Acked-by: Simon Horman horms+rene...@verge.net.au
 ---
 Changes since version 2:
 - added #include linux/types.h;
 - added ACKs from Simon Horman and Kuninori Morimoto.
   include/linux/usb/rcar-phy.h |   40 
  
   1 file changed, 40 insertions(+)
 Index: renesas/include/linux/usb/rcar-phy.h
 ===
 --- /dev/null
 +++ renesas/include/linux/usb/rcar-phy.h
 @@ -0,0 +1,40 @@
 +/*
 + * Copyright (C) 2013 Renesas Solutions Corp.
 + * Copyright (C) 2013 Cogent Embedded, Inc.
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#ifndef __RCAR_PHY_H
 +#define __RCAR_PHY_H
 +
 +#include linux/bitops.h
 +#include linux/types.h
 +
 +/* USBPCTRL0 register bits */
 +#define USBPCTRL0_OVC2   BIT(10) /* Switches the OVC input pin for port 
 2: */
 + /* 1: USB_OVC2, 0: OVC2 */
 +#define USBPCTRL0_OVC1_VBUS1 BIT(9) /* Switches the OVC input pin for 
 port 1: */
 + /* 1: USB_OVC1, 0: OVC1/VBUS1   */
 +#define USBPCTRL0_OVC0   BIT(8)  /* Switches the OVC input pin for port 
 0: */
 + /* 1: USB_OVC0 pin, 0: OVC0 */
 +#define USBPCTRL0_OVC2_ACT BIT(6) /* Host mode: OVC2 polarity:   
 */
 + /* 1: active-high, 0: active-low*/
 + /* Function mode: be sure to set to 1   */
 +#define USBPCTRL0_PENC   BIT(4)  /* Function mode: output level of PENC1 
 pin: */
 + /* 1: high, 0: low  */
 +#define USBPCTRL0_OVC0_ACT BIT(3) /* Host mode: OVC0 polarity:   
 */
 + /* 1: active-high, 0: active-low*/
 +#define USBPCTRL0_OVC1_ACT BIT(1) /* Host mode: OVC1 polarity:   
 */
 + /* 1: active-high, 0: active-low*/
 + /* Function mode: be sure to set to 1   */
 +#define USBPCTRL0_PORT1  BIT(0)  /* Selects port 1 mode: 
 */
 + /* 1: function, 0: host */
 +
 +struct rcar_phy_platform_data {
 + u32 usbpctrl0;  /* USBPCTRL0 register value */
 +};
 looks really wrong to me to pass register contents via pdata. You should
 pass flags which would aid the driver into figuring out how to program
 that register.
 That was my first thought (and implementation) but this didn't
 look good either (and even worse with the device tree approach) as we
 couldn't come up with the clear names for the bitfields. Also, not
 all these bits are present in R8A7778 support for which I'm adding in
 the later patchset.
 Besides, IMO this little differs from having a flags field with
 the flags bits #define'd beforehand. Or did you mean that I should
 have surely used *bool* bitfields?
 How about:
 
 Er, I was asking you about the platform data only, not the DT
 representation yet. :-)

easy(-ish) to translate, just needs more fields in your structure.

 rcar {
  compatible ...
  reg...
 
  /* switch OVC for all three ports */
  renesas,rcar-ovc-port-config = 2 high,
  1  low,
  0  high ;
 
 Hm, 'dtc' allows mixed type properties now?
 Also, we need to describe the multiplexing of the OVCn pins (5V
 or 3.3V input),
 not only the active level.

fair enough, it can now be pre-processed so you can have defines, then
you can:

#define PORT_HIGH   1
#define PORT_LOW0

#define MUX_ABC foo
#define MUX_XYZ bar
#define MUX_MNO baz

...-port-config = 2 PORT_HIGH MUX_ABC,
   1 PORT_LOW MUX_XYZ,
   0 PORT_HIGH MUX_MNO;

  renesas,rcar-port1-mode = host; /* could also be peripheral */;
 
 You see, all this involves string type (and so more complex to
 deal with) props.
 We were hoping to use only boolean props, more or less corresponding
 to the register bits...

see above.

 PENC
 apparently doesn't anything if it always needs to be set to 1.
 
You've mixed it with some other pin -- it can be 0 or 1 in
 function mode.
 
 Would this work for you ?
 
 I should try... All this surely looks more complex 

Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-10 Thread Tony Lindgren
* Nishanth Menon n...@ti.com [130410 10:44]:
 Details in the patch below (Tony, I have added you as collaborator for
 helping in getting this working-clk_add_alias was'nt needed in the
 internal patch discussion we had - I have taken a bit of freedom in
 adding your contributions to the patch below)

OK thanks. Noticed few minor things, see below.
 
 Folks, this does seem to be the best compromise we can achieve at this
 point in time. feedback on this approach is much appreciated - if folks
 are ok, I can post this as an formal patch series.
 
 From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
 From: Nishanth Menon n...@ti.com
 Date: Tue, 9 Apr 2013 19:26:40 -0500
 Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
  data
 
 OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
 However, this presents an obstacle for using these clock nodes in
 Device Tree definitions. There are many possible approaches to this
 problem as discussed in the following thread:
 http://marc.info/?t=13637032569r=1w=2

It might be worth clarifying that this is especially for the board
specific clocks initially. The fixed clocks are currently found via
the clock aliases table.

 Highlights of the options:
 a) device specific clk_add_alias:
   cons: driver handling required
 b) using an generic clk node and indexing to reach the clock required.
This is similar in approach taken by tegra and few other platforms.
example clock = clk 5;
cons: potential to have mismatches in indexed table and associated
dtb data. In addition, managing continued documentation in bindings
as clock indexing increases. Even though readability angle could be
improved by using preprocessing of DT using macros, indexed approach
is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses clk 2, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has
updated indices will result in per_dpll now controlled for peripheral
X without warning or any potential error detection and warning.
 
Even though we can claim this is user error, such errors are hard to
track down and fix.
 
 An alternate approach introduced here is to introduce device tree bindings
 corresponding to the clock nodes required in DT definition for SoC which
 automatically maps back to the definitions in cclockXYZ_data.c.
 
 The driver introduced here to do this mapping will eventually be the
 place where the clock handling will migrate to. We need to consider this
 angle as well so that the solution will be an valid transition point for
 moving the clock data out of kernel image (into device tree or firmware load
 etc..).
 
 Overall strategy introduced here is simple: an clock node described in
 device tree blob is used to identify the exact clock provided in the SoC
 specific data. This is then linked back using of_clk_add_provider to the
 device node to be accessible by of_clk_get.
 
 Based on discussion contributions from Roger Quadros, Grygorii Strashko
 and others.
 
 [t...@atomide.com: co-developed]
 Signed-off-by: Tony Lindgren t...@atomide.com
 Signed-off-by: Nishanth Menon n...@ti.com
 ---
  .../devicetree/bindings/clock/omap-clock.txt   |   40 +
  drivers/clk/Makefile   |1 +
  drivers/clk/omap/Makefile  |1 +
  drivers/clk/omap/clk.c |   94 
 
  4 files changed, 136 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
  create mode 100644 drivers/clk/omap/Makefile
  create mode 100644 drivers/clk/omap/clk.c
 
 diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt 
 b/Documentation/devicetree/bindings/clock/omap-clock.txt
 new file mode 100644
 index 000..07e3ff8
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
 @@ -0,0 +1,40 @@
 +Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
 +
 +This binding is a work-in-progress, and meant to be stage #1 of transitioning
 +OMAP clock data out of kernel image.

As it's using the common clock binding, this will be supported in the
long run too. So maybe replace work-in-progress with initial minimal
binding that can be enhanced later on.

 +This binding uses the common clock binding[1].
 +
 +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
 +
 +Required properties:
 +- compatible : shall be ti,omap-clock
 +- #clock-cells : from common clock binding; shall be set to 0.
 +NOTE:
 +node name should map to clock database in 
 arch/arm/mach-omap2/cclockSoC_data.c
 +Since all clocks are described with _ck, the node name is optimized to drop 
 the
 +usage of _ck. For example, a clock called dpll1_ck will 

Re: [PATCH v3 10/11] usb: musb: use musb-port_mode

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel Initialize the host and gagdet subsystems of the musb driver
 Daniel only when

Sorry, I missed this before - s/gagdet/gadget/


 Daniel the appropriate mode is selected from platform data, or device-tree
 Daniel information, respectively.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com
 Daniel Acked-by: Peter Korsgaard jac...@sunsite.dk
 Daniel ---
 Daniel  drivers/usb/musb/musb_core.c| 22 +-
 Daniel  drivers/usb/musb/musb_virthub.c |  3 ++-
 Daniel  2 files changed, 19 insertions(+), 6 deletions(-)

 Daniel diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel index 2640d25..b3b9873 100644
 Daniel --- a/drivers/usb/musb/musb_core.c
 Daniel +++ b/drivers/usb/musb/musb_core.c
 Daniel @@ -1912,11 +1912,23 @@ musb_init_controller(struct device *dev, int 
nIrq, void __iomem *ctrl)
 musb- xceiv-state = OTG_STATE_B_IDLE;
 Daniel}
 
 Daniel -  status = musb_host_setup(musb, plat-power);
 Daniel -  if (status  0)
 Daniel -  goto fail3;
 Daniel -
 Daniel -  status = musb_gadget_setup(musb);
 Daniel +  switch (musb-port_mode) {
 Daniel +  case MUSB_PORT_MODE_HOST:
 Daniel +  status = musb_host_setup(musb, plat-power);
 Daniel +  break;
 Daniel +  case MUSB_PORT_MODE_GADGET:
 Daniel +  status = musb_gadget_setup(musb);
 Daniel +  break;
 Daniel +  case MUSB_PORT_MODE_DUAL_ROLE:
 Daniel +  status = musb_host_setup(musb, plat-power);
 Daniel +  if (status  0)
 Daniel +  goto fail3;
 Daniel +  status = musb_gadget_setup(musb);
 Daniel +  break;
 Daniel +  default:
 Daniel +  dev_err(dev, unsupported port mode %d\n, 
musb-port_mode);
 Daniel +  break;
 Daniel +  }
 
 Danielif (status  0)
 Danielgoto fail3;
 Daniel diff --git a/drivers/usb/musb/musb_virthub.c 
b/drivers/usb/musb/musb_virthub.c
 Daniel index 1e17c20..8d92ba2 100644
 Daniel --- a/drivers/usb/musb/musb_virthub.c
 Daniel +++ b/drivers/usb/musb/musb_virthub.c
 Daniel @@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
 Daniel * (b) vbus present/connect IRQ, peripheral mode;
 Daniel * (c) peripheral initiates, using SRP
 Daniel */
 Daniel -  if ((devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 Daniel +  if (musb-port_mode != MUSB_PORT_MODE_HOST 
 Daniel +  (devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 musb- is_active = 1;
 Daniel} else {
 Danieldevctl |= MUSB_DEVCTL_SESSION;
 Daniel -- 
 Daniel 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 v3 7/9] rcar-phy: add platform data

2013-04-10 Thread Sergei Shtylyov

On 04/10/2013 10:40 PM, Felipe Balbi wrote:




Currently the driver hard-codes USBPCTRL0 register to 0.  It is wrong since this
register contains board-specific USB ports configuration and so its value should
be somehow passed via the platform data.  Add linux/usb/rcar-phy.h file with
the USBPCTRL0 bit #define's and 'struct rcar_phy_platform_data' containing the
value to be set by the driver to that register.
Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
Acked-by: Simon Horman horms+rene...@verge.net.au
---
Changes since version 2:
- added #include linux/types.h;
- added ACKs from Simon Horman and Kuninori Morimoto.
  include/linux/usb/rcar-phy.h |   40 
  1 file changed, 40 insertions(+)
Index: renesas/include/linux/usb/rcar-phy.h
===
--- /dev/null
+++ renesas/include/linux/usb/rcar-phy.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013 Cogent Embedded, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __RCAR_PHY_H
+#define __RCAR_PHY_H
+
+#include linux/bitops.h
+#include linux/types.h
+
+/* USBPCTRL0 register bits */
+#define USBPCTRL0_OVC2 BIT(10) /* Switches the OVC input pin for port 2: */
+   /* 1: USB_OVC2, 0: OVC2 */
+#define USBPCTRL0_OVC1_VBUS1 BIT(9) /* Switches the OVC input pin for port 1: 
*/
+   /* 1: USB_OVC1, 0: OVC1/VBUS1   */
+#define USBPCTRL0_OVC0 BIT(8)  /* Switches the OVC input pin for port 0: */
+   /* 1: USB_OVC0 pin, 0: OVC0 */
+#define USBPCTRL0_OVC2_ACT BIT(6) /* Host mode: OVC2 polarity: */
+   /* 1: active-high, 0: active-low*/
+   /* Function mode: be sure to set to 1   */
+#define USBPCTRL0_PENC BIT(4)  /* Function mode: output level of PENC1 pin: */
+   /* 1: high, 0: low  */
+#define USBPCTRL0_OVC0_ACT BIT(3) /* Host mode: OVC0 polarity: */
+   /* 1: active-high, 0: active-low*/
+#define USBPCTRL0_OVC1_ACT BIT(1) /* Host mode: OVC1 polarity: */
+   /* 1: active-high, 0: active-low*/
+   /* Function mode: be sure to set to 1   */
+#define USBPCTRL0_PORT1BIT(0)  /* Selects port 1 mode: 
*/
+   /* 1: function, 0: host */
+
+struct rcar_phy_platform_data {
+   u32 usbpctrl0;  /* USBPCTRL0 register value */
+};

looks really wrong to me to pass register contents via pdata. You should
pass flags which would aid the driver into figuring out how to program
that register.

That was my first thought (and implementation) but this didn't
look good either (and even worse with the device tree approach) as we
couldn't come up with the clear names for the bitfields. Also, not
all these bits are present in R8A7778 support for which I'm adding in
the later patchset.
Besides, IMO this little differs from having a flags field with
the flags bits #define'd beforehand. Or did you mean that I should
have surely used *bool* bitfields?

How about:

 Er, I was asking you about the platform data only, not the DT
representation yet. :-)

easy(-ish) to translate, just needs more fields in your structure.


   That's clear , about more fields. :-)




rcar {
compatible ...
reg...

/* switch OVC for all three ports */
renesas,rcar-ovc-port-config = 2 high,
1  low,
0  high ;

 Hm, 'dtc' allows mixed type properties now?
 Also, we need to describe the multiplexing of the OVCn pins (5V
or 3.3V input),
not only the active level.

fair enough, it can now be pre-processed so you can have defines, then
you can:

#define PORT_HIGH   1
#define PORT_LOW0

#define MUX_ABC foo
#define MUX_XYZ bar
#define MUX_MNO baz

...-port-config = 2 PORT_HIGH MUX_ABC,
   1 PORT_LOW MUX_XYZ,
   0 PORT_HIGH MUX_MNO;


   Ah, didn't know about that (although have seen some named entities
like these in the device tree excerpts. OK, it's getting clearer now...


Would this work for you ?

 I should try... All this surely looks more complex than we would
hope...

passing register contents will hurt you in the future if some other
device comes up with more bits


   It's already there: R8A7779 vs R8A7778. An it will hurt anyway, as 
I'll have to

add the new fields for the new bits...


or a slightly different layout


Re: [PATCH v3 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

 Daniel The musb struct is currently allocated along with the hcd, which makes
 Daniel it difficult to build a driver that only acts as gadget device.

 Daniel Fix this by allocating musb directly, and keep the hcd around as
 Daniel a pointer in the musb struct.

 Daniel struct hc_driver musb_hc_driver can now also be static to musb_host.c,
 Daniel and the macro musb_to_hcd() is just a pointer dereferencer for now, and
 Daniel will be eliminated later.

 Daniel Signed-off-by: Daniel Mack zon...@gmail.com
 Daniel Acked-by: Peter Korsgaard jac...@sunsite.dk
 Daniel ---
 Daniel  drivers/usb/musb/musb_core.c | 40 
 Daniel  drivers/usb/musb/musb_core.h |  1 +
 Daniel  drivers/usb/musb/musb_host.c | 54 
++--
 Daniel  drivers/usb/musb/musb_host.h | 19 +++-
 Daniel  4 files changed, 75 insertions(+), 39 deletions(-)

 
 Daniel +struct musb_hcd_link {
 Daniel +  struct musb *musb;
 Daniel +};
 Daniel +
 Daniel +struct musb *hcd_to_musb(struct usb_hcd *hcd)
 Daniel +{
 Daniel +  struct musb_hcd_link *link = (struct musb_hcd_link *) 
hcd-hcd_priv;
 Daniel +  return link-musb;
 Daniel +}
 Daniel +

Sorry, I missed this first time around - But why the indirection with
musb_hcd_link? Why not simply directly store a pointer to struct musb in
hcd_priv?

-- 
Bye, Peter Korsgaard
--
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 v3 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Daniel Mack
On 10.04.2013 20:54, Peter Korsgaard wrote:
 Daniel == Daniel Mack zon...@gmail.com writes:
 
  Daniel The musb struct is currently allocated along with the hcd, which 
 makes
  Daniel it difficult to build a driver that only acts as gadget device.
 
  Daniel Fix this by allocating musb directly, and keep the hcd around as
  Daniel a pointer in the musb struct.
 
  Daniel struct hc_driver musb_hc_driver can now also be static to 
 musb_host.c,
  Daniel and the macro musb_to_hcd() is just a pointer dereferencer for now, 
 and
  Daniel will be eliminated later.
 
  Daniel Signed-off-by: Daniel Mack zon...@gmail.com
  Daniel Acked-by: Peter Korsgaard jac...@sunsite.dk
  Daniel ---
  Daniel  drivers/usb/musb/musb_core.c | 40 
  Daniel  drivers/usb/musb/musb_core.h |  1 +
  Daniel  drivers/usb/musb/musb_host.c | 54 
 ++--
  Daniel  drivers/usb/musb/musb_host.h | 19 +++-
  Daniel  4 files changed, 75 insertions(+), 39 deletions(-)
 
  
  Daniel +struct musb_hcd_link {
  Daniel +struct musb *musb;
  Daniel +};
  Daniel +
  Daniel +struct musb *hcd_to_musb(struct usb_hcd *hcd)
  Daniel +{
  Daniel +struct musb_hcd_link *link = (struct musb_hcd_link *) 
 hcd-hcd_priv;
  Daniel +return link-musb;
  Daniel +}
  Daniel +
 
 Sorry, I missed this first time around - But why the indirection with
 musb_hcd_link? Why not simply directly store a pointer to struct musb in
 hcd_priv?

Well, that's also possible. I just thought it's nicer (more readable)
that way. But I can as well rework it so the struct isn't needed. It
won't safe us any binary size or anything though. So I'm not sure.

Any particular reason why you don't like the struct? :)


Daniel

--
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 v3 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

Hi,

 Daniel +struct musb_hcd_link {
 Daniel +  struct musb *musb;
 Daniel +};
 Daniel +
 Daniel +struct musb *hcd_to_musb(struct usb_hcd *hcd)
 Daniel +{
 Daniel +  struct musb_hcd_link *link = (struct musb_hcd_link *) 
hcd-hcd_priv;
 Daniel +  return link-musb;
 Daniel +}
 Daniel +
  
  Sorry, I missed this first time around - But why the indirection with
  musb_hcd_link? Why not simply directly store a pointer to struct musb in
  hcd_priv?

 Daniel Well, that's also possible. I just thought it's nicer (more readable)
 Daniel that way. But I can as well rework it so the struct isn't needed. It
 Daniel won't safe us any binary size or anything though. So I'm not sure.

Well, it will save one level of indirection (hcd_priv-link-musb vs
hcd_priv-musb).

 Daniel Any particular reason why you don't like the struct? :)

Just that it's an unneeded extra level of indirection.

-- 
Bye, Peter Korsgaard
--
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 v4 00/11] usb: musb: add back support for host mode

2013-04-10 Thread Daniel Mack
Hi all,

here are some patches to separate the HCD and gadget part of the musb
driver so they can be deselected in Kconfig. They also make the driver
keep track of the configured port mode that is set from DT, so the
actual runtime configuration can be selected dynamically.

One thing that is still broken is that once pm_suspend() was called on
a musb device on a USB disconnect, the port won't wake up again when a
device is plugged back in. I doubt this is related to my patches, but I
might be wrong. If that effect rings a bell to anyone, please let me
know.

Thanks,
Daniel


Changes from v3:
* removed unnecessary indirection level via struct musb_hdc_link
* fixed a typo in commit log of patch 10/11
(all reported by Peter Korsgaard, thanks!)

Changes from v2:
* simplified Makefile rework
* really remove musb_to_hcd
* fixed some types
(all reported by Peter Korsgaard, thanks!)

Changes from v1:
* fixed some typos in commit logs
* factor out musb_host_resume_root_hub and
  musb_host_poke_root_hub()
* split some changes into separate patches
* some minor cosmetics fixed

Daniel Mack (11):
  usb: gadget: drop unused USB_GADGET_MUSB_HDRC
  usb: musb: move function declarations to musb_{host,gadget}.h
  usb: musb: factor some host-specific functions
  usb: musb: gadget: remove hcd initialization
  usb: musb: move musb_start to musb_virthub.c
  usb: musb: factor out hcd initalization
  usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes
  usb: musb: add musb_host_setup() and musb_host_cleanup()
  usb: musb: re-introduce musb-port_mode
  usb: musb: use musb-port_mode
  usb: musb: eliminate musb_to_hcd

 drivers/usb/gadget/Kconfig  |   8 ---
 drivers/usb/musb/Kconfig|  29 +
 drivers/usb/musb/Makefile   |   4 +-
 drivers/usb/musb/musb_core.c| 127 +++-
 drivers/usb/musb/musb_core.h|  26 +++-
 drivers/usb/musb/musb_gadget.c  |  10 
 drivers/usb/musb/musb_gadget.h  |  38 ++--
 drivers/usb/musb/musb_host.c|  82 +++---
 drivers/usb/musb/musb_host.h|  57 ++
 drivers/usb/musb/musb_virthub.c |  51 +++-
 drivers/usb/musb/omap2430.c |   2 +-
 11 files changed, 286 insertions(+), 148 deletions(-)

-- 
1.8.1.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 v4 01/11] usb: gadget: drop unused USB_GADGET_MUSB_HDRC

2013-04-10 Thread Daniel Mack
The functionality meant to be represented by this symbol will be
re-added later, but for now, USB_GADGET_MUSB_HDRC is in fact unused and
can be dropped.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/gadget/Kconfig | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a61d981..0702fa0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -333,14 +333,6 @@ config USB_MV_U3D
 # Controllers available in both integrated and discrete versions
 #
 
-# musb builds in ../musb along with host support
-config USB_GADGET_MUSB_HDRC
-   tristate Inventra HDRC USB Peripheral (TI, ADI, ...)
-   depends on USB_MUSB_HDRC
-   help
- This OTG-capable silicon IP is used in dual designs including
- the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI Blackfin
-
 config USB_M66592
tristate Renesas M66592 USB Peripheral Controller
help
-- 
1.8.1.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 v4 05/11] usb: musb: move musb_start to musb_virthub.c

2013-04-10 Thread Daniel Mack
This function has its only user in musb_virthub.c, so let's move it
there and make it static.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c| 45 -
 drivers/usb/musb/musb_core.h|  1 -
 drivers/usb/musb/musb_virthub.c | 44 
 3 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 13341c6..adf069d 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -905,51 +905,6 @@ b_host:
 
 /*-*/
 
-/*
-* Program the HDRC to start (enable interrupts, dma, etc.).
-*/
-void musb_start(struct musb *musb)
-{
-   void __iomem*regs = musb-mregs;
-   u8  devctl = musb_readb(regs, MUSB_DEVCTL);
-
-   dev_dbg(musb-controller, == devctl %02x\n, devctl);
-
-   /*  Set INT enable registers, enable interrupts */
-   musb-intrtxe = musb-epmask;
-   musb_writew(regs, MUSB_INTRTXE, musb-intrtxe);
-   musb-intrrxe = musb-epmask  0xfffe;
-   musb_writew(regs, MUSB_INTRRXE, musb-intrrxe);
-   musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
-
-   musb_writeb(regs, MUSB_TESTMODE, 0);
-
-   /* put into basic highspeed mode and start session */
-   musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
-   | MUSB_POWER_HSENAB
-   /* ENSUSPEND wedges tusb */
-   /* | MUSB_POWER_ENSUSPEND */
-   );
-
-   musb-is_active = 0;
-   devctl = musb_readb(regs, MUSB_DEVCTL);
-   devctl = ~MUSB_DEVCTL_SESSION;
-
-   /* session started after:
-* (a) ID-grounded irq, host mode;
-* (b) vbus present/connect IRQ, peripheral mode;
-* (c) peripheral initiates, using SRP
-*/
-   if ((devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
-   musb-is_active = 1;
-   else
-   devctl |= MUSB_DEVCTL_SESSION;
-
-   musb_platform_enable(musb);
-   musb_writeb(regs, MUSB_DEVCTL, devctl);
-}
-
-
 static void musb_generic_disable(struct musb *musb)
 {
void __iomem*mbase = musb-mregs;
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 04d8974..87da041 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -503,7 +503,6 @@ static inline void musb_configure_ep0(struct musb *musb)
 
 extern const char musb_driver_name[];
 
-extern void musb_start(struct musb *musb);
 extern void musb_stop(struct musb *musb);
 
 extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index ef7d110..1e17c20 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -44,6 +44,50 @@
 
 #include musb_core.h
 
+/*
+* Program the HDRC to start (enable interrupts, dma, etc.).
+*/
+static void musb_start(struct musb *musb)
+{
+   void __iomem*regs = musb-mregs;
+   u8  devctl = musb_readb(regs, MUSB_DEVCTL);
+
+   dev_dbg(musb-controller, == devctl %02x\n, devctl);
+
+   /*  Set INT enable registers, enable interrupts */
+   musb-intrtxe = musb-epmask;
+   musb_writew(regs, MUSB_INTRTXE, musb-intrtxe);
+   musb-intrrxe = musb-epmask  0xfffe;
+   musb_writew(regs, MUSB_INTRRXE, musb-intrrxe);
+   musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
+
+   musb_writeb(regs, MUSB_TESTMODE, 0);
+
+   /* put into basic highspeed mode and start session */
+   musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
+   | MUSB_POWER_HSENAB
+   /* ENSUSPEND wedges tusb */
+   /* | MUSB_POWER_ENSUSPEND */
+   );
+
+   musb-is_active = 0;
+   devctl = musb_readb(regs, MUSB_DEVCTL);
+   devctl = ~MUSB_DEVCTL_SESSION;
+
+   /* session started after:
+* (a) ID-grounded irq, host mode;
+* (b) vbus present/connect IRQ, peripheral mode;
+* (c) peripheral initiates, using SRP
+*/
+   if ((devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
+   musb-is_active = 1;
+   } else {
+   devctl |= MUSB_DEVCTL_SESSION;
+   }
+
+   musb_platform_enable(musb);
+   musb_writeb(regs, MUSB_DEVCTL, devctl);
+}
 
 static void musb_port_suspend(struct musb *musb, bool do_suspend)
 {
-- 
1.8.1.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 v4 04/11] usb: musb: gadget: remove hcd initialization

2013-04-10 Thread Daniel Mack
This will be done from a more appropriate location and as it doesn't
work anyway, it can safely be removed before the other changes.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_gadget.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index ba70923..0414bc1 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1820,7 +1820,6 @@ static int musb_gadget_start(struct usb_gadget *g,
 {
struct musb *musb = gadget_to_musb(g);
struct usb_otg  *otg = musb-xceiv-otg;
-   struct usb_hcd  *hcd = musb_to_hcd(musb);
unsigned long   flags;
int retval = 0;
 
@@ -1847,17 +1846,9 @@ static int musb_gadget_start(struct usb_gadget *g,
 * handles power budgeting ... this way also
 * ensures HdrcStart is indirectly called.
 */
-   retval = usb_add_hcd(hcd, 0, 0);
-   if (retval  0) {
-   dev_dbg(musb-controller, add_hcd failed, %d\n, retval);
-   goto err;
-   }
-
if (musb-xceiv-last_event == USB_EVENT_ID)
musb_platform_set_vbus(musb, 1);
 
-   hcd-self.uses_pio_for_control = 1;
-
if (musb-xceiv-last_event == USB_EVENT_NONE)
pm_runtime_put(musb-controller);
 
@@ -1942,7 +1933,6 @@ static int musb_gadget_stop(struct usb_gadget *g,
musb_platform_try_idle(musb, 0);
spin_unlock_irqrestore(musb-lock, flags);
 
-   usb_remove_hcd(musb_to_hcd(musb));
/*
 * FIXME we need to be able to register another
 * gadget driver here and have everything work;
-- 
1.8.1.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 v4 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Daniel Mack
The musb struct is currently allocated along with the hcd, which makes
it difficult to build a driver that only acts as gadget device.

Fix this by allocating musb directly, and keep the hcd around as
a pointer in the musb struct.

struct hc_driver musb_hc_driver can now also be static to musb_host.c,
and the macro musb_to_hcd() is just a pointer dereferencer for now, and
will be eliminated later.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c | 40 ++
 drivers/usb/musb/musb_core.h |  1 +
 drivers/usb/musb/musb_host.c | 46 +---
 drivers/usb/musb/musb_host.h | 19 --
 4 files changed, 67 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index adf069d..f3519d3 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -404,7 +404,8 @@ void musb_hnp_stop(struct musb *musb)
break;
case OTG_STATE_B_HOST:
dev_dbg(musb-controller, HNP: Disabling HR\n);
-   hcd-self.is_b_host = 0;
+   if (hcd)
+   hcd-self.is_b_host = 0;
musb-xceiv-state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
reg = musb_readb(mbase, MUSB_POWER);
@@ -726,7 +727,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
dev_dbg(musb-controller, HNP: CONNECT, now b_host\n);
 b_host:
musb-xceiv-state = OTG_STATE_B_HOST;
-   hcd-self.is_b_host = 1;
+   if (hcd)
+   hcd-self.is_b_host = 1;
musb-ignore_disconnect = 0;
del_timer(musb-otg_timer);
break;
@@ -768,7 +770,8 @@ b_host:
 * in hnp_stop() is currently not used...
 */
musb_root_disconnect(musb);
-   musb_to_hcd(musb)-self.is_b_host = 0;
+   if (musb-hcd)
+   musb-hcd-self.is_b_host = 0;
musb-xceiv-state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
musb_g_disconnect(musb);
@@ -1714,24 +1717,18 @@ static struct musb *allocate_instance(struct device 
*dev,
struct musb *musb;
struct musb_hw_ep   *ep;
int epnum;
-   struct usb_hcd  *hcd;
+   int ret;
 
-   hcd = usb_create_hcd(musb_hc_driver, dev, dev_name(dev));
-   if (!hcd)
+   musb = devm_kzalloc(dev, sizeof(*musb), GFP_KERNEL);
+   if (!musb)
return NULL;
-   /* usbcore sets dev-driver_data to hcd, and sometimes uses that... */
 
-   musb = hcd_to_musb(hcd);
INIT_LIST_HEAD(musb-control);
INIT_LIST_HEAD(musb-in_bulk);
INIT_LIST_HEAD(musb-out_bulk);
 
-   hcd-uses_new_polling = 1;
-   hcd-has_tt = 1;
-
musb-vbuserr_retry = VBUSERR_RETRY_COUNT;
musb-a_wait_bcon = OTG_TIME_A_WAIT_BCON;
-   dev_set_drvdata(dev, musb);
musb-mregs = mbase;
musb-ctrl_base = mbase;
musb-nIrq = -ENODEV;
@@ -1746,7 +1743,16 @@ static struct musb *allocate_instance(struct device *dev,
 
musb-controller = dev;
 
+   ret = musb_host_alloc(musb);
+   if (ret  0)
+   goto err_free;
+
+   dev_set_drvdata(dev, musb);
+
return musb;
+
+err_free:
+   return NULL;
 }
 
 static void musb_free(struct musb *musb)
@@ -1772,7 +1778,7 @@ static void musb_free(struct musb *musb)
dma_controller_destroy(c);
}
 
-   usb_put_hcd(musb_to_hcd(musb));
+   musb_host_free(musb);
 }
 
 /*
@@ -1789,7 +1795,6 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
int status;
struct musb *musb;
struct musb_hdrc_platform_data *plat = dev-platform_data;
-   struct usb_hcd  *hcd;
 
/* The driver might handle more features than the board; OK.
 * Fail when the board needs a feature that's not enabled.
@@ -1890,13 +1895,6 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-irq_wake = 0;
}
 
-   /* host side needs more setup */
-   hcd = musb_to_hcd(musb);
-   otg_set_host(musb-xceiv-otg, hcd-self);
-   hcd-self.otg_port = 1;
-   musb-xceiv-otg-host = hcd-self;
-   hcd-power_budget = 2 * (plat-power ? : 250);
-
/* program PHY to use external vBus if required */
if (plat-extvbus) {
u8 busctl = musb_read_ulpi_buscontrol(musb-mregs);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 87da041..6b65847 100644
--- 

[PATCH v4 09/11] usb: musb: re-introduce musb-port_mode

2013-04-10 Thread Daniel Mack
Define MUSB_PORT_MODE_{HOST,GADGET,DUAL_ROLE} and store the
platform-specified value in struct musb.

Note that MUSB_PORT_MODE_HOST has to be set to 1 in order to match
existing device tree bindings which are already documented but in fact
unusued. For information on the bindings, please refer to

  Documentation/devicetree/bindings/usb/omap-usb.txt
  Documentation/devicetree/bindings/usb/am33xx-usb.txt

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c | 1 +
 drivers/usb/musb/musb_core.h | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index fbcf5cb..2640d25 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1821,6 +1821,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-board_set_power = plat-set_power;
musb-min_power = plat-min_power;
musb-ops = plat-platform_ops;
+   musb-port_mode = plat-mode;
 
/* The musb_platform_init() call:
 *   - adjusts musb-mregs
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 6b65847..174c097 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -77,6 +77,12 @@ struct musb_ep;
 #define is_peripheral_active(m)(!(m)-is_host)
 #define is_host_active(m)  ((m)-is_host)
 
+enum {
+   MUSB_PORT_MODE_HOST = 1,
+   MUSB_PORT_MODE_GADGET,
+   MUSB_PORT_MODE_DUAL_ROLE,
+};
+
 #ifdef CONFIG_PROC_FS
 #include linux/fs.h
 #define MUSB_CONFIG_PROC_FS
@@ -356,6 +362,7 @@ struct musb {
 
u8  min_power;  /* vbus for periph, in mA/2 */
 
+   int port_mode;  /* MUSB_PORT_MODE_* */
boolis_host;
 
int a_wait_bcon;/* VBUS timeout in msecs */
-- 
1.8.1.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 v4 11/11] usb: musb: eliminate musb_to_hcd

2013-04-10 Thread Daniel Mack
With the hcd is now a direct member of struct musb, we can now simply
eliminate the musb_to_hcd() macro. There aren't that many users left
anyway, as some where already fixed up when parts were factored out to
musb_host.c

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c| 4 ++--
 drivers/usb/musb/musb_host.c| 8 
 drivers/usb/musb/musb_host.h| 2 --
 drivers/usb/musb/musb_virthub.c | 6 +++---
 drivers/usb/musb/omap2430.c | 2 +-
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b3b9873..57b7a17 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -389,7 +389,7 @@ static void musb_otg_timer_func(unsigned long data)
  */
 void musb_hnp_stop(struct musb *musb)
 {
-   struct usb_hcd  *hcd = musb_to_hcd(musb);
+   struct usb_hcd  *hcd = musb-hcd;
void __iomem*mbase = musb-mregs;
u8  reg;
 
@@ -686,7 +686,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
}
 
if (int_usb  MUSB_INTR_CONNECT) {
-   struct usb_hcd *hcd = musb_to_hcd(musb);
+   struct usb_hcd *hcd = musb-hcd;
 
handled = IRQ_HANDLED;
musb-is_active = 1;
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 6057c23..f15d114 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -315,9 +315,9 @@ __acquires(musb-lock)
urb-actual_length, urb-transfer_buffer_length
);
 
-   usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb);
+   usb_hcd_unlink_urb_from_ep(musb-hcd, urb);
spin_unlock(musb-lock);
-   usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status);
+   usb_hcd_giveback_urb(musb-hcd, urb, status);
spin_lock(musb-lock);
 }
 
@@ -1460,7 +1460,7 @@ done:
if (length  qh-maxpacket)
length = qh-maxpacket;
/* Unmap the buffer so that CPU can use it */
-   usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb);
+   usb_hcd_unmap_urb_for_dma(musb-hcd, urb);
 
/*
 * We need to map sg if the transfer_buffer is
@@ -1875,7 +1875,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
unsigned int received_len;
 
/* Unmap the buffer so that CPU can use it */
-   usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb);
+   usb_hcd_unmap_urb_for_dma(musb-hcd, urb);
 
/*
 * We need to map sg if the transfer_buffer is
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 48a4bdd..c202d5b 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -37,8 +37,6 @@
 
 #include linux/scatterlist.h
 
-#define musb_to_hcd(MUSB) ((MUSB)-hcd)
-
 /* stored in usb_host_endpoint.hcpriv for scheduled endpoints */
 struct musb_qh {
struct usb_host_endpoint *hep;  /* usbcore info */
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 8d92ba2..5a101fe 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -215,7 +215,7 @@ static void musb_port_reset(struct musb *musb, bool 
do_reset)
musb-port1_status |= USB_PORT_STAT_ENABLE
| (USB_PORT_STAT_C_RESET  16)
| (USB_PORT_STAT_C_ENABLE  16);
-   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   usb_hcd_poll_rh_status(musb-hcd);
 
musb-vbuserr_retry = VBUSERR_RETRY_COUNT;
}
@@ -228,7 +228,7 @@ void musb_root_disconnect(struct musb *musb)
musb-port1_status = USB_PORT_STAT_POWER
| (USB_PORT_STAT_C_CONNECTION  16);
 
-   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   usb_hcd_poll_rh_status(musb-hcd);
musb-is_active = 0;
 
switch (musb-xceiv-state) {
@@ -382,7 +382,7 @@ int musb_hub_control(
musb-port1_status = ~(USB_PORT_STAT_SUSPEND
| MUSB_PORT_STAT_RESUME);
musb-port1_status |= USB_PORT_STAT_C_SUSPEND  16;
-   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   usb_hcd_poll_rh_status(musb-hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
musb-xceiv-state = OTG_STATE_A_HOST;
}
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3551f1a..1bafcd5 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -87,7 +87,7 @@ static void musb_do_idle(unsigned long _musb)
musb-port1_status = ~(USB_PORT_STAT_SUSPEND

[PATCH v4 08/11] usb: musb: add musb_host_setup() and musb_host_cleanup()

2013-04-10 Thread Daniel Mack
This patch re-introduces the bits that are necessary to use the musb
controller in host mode.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c |  5 +
 drivers/usb/musb/musb_host.c | 21 +
 drivers/usb/musb/musb_host.h |  8 
 3 files changed, 34 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index f3519d3..fbcf5cb 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -961,6 +961,7 @@ static void musb_shutdown(struct platform_device *pdev)
 
pm_runtime_get_sync(musb-controller);
 
+   musb_host_cleanup(musb);
musb_gadget_cleanup(musb);
 
spin_lock_irqsave(musb-lock, flags);
@@ -1910,6 +1911,10 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-xceiv-state = OTG_STATE_B_IDLE;
}
 
+   status = musb_host_setup(musb, plat-power);
+   if (status  0)
+   goto fail3;
+
status = musb_gadget_setup(musb);
 
if (status  0)
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index e6ece8a..6057c23 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2640,6 +2640,27 @@ void musb_host_free(struct musb *musb)
usb_put_hcd(musb-hcd);
 }
 
+int musb_host_setup(struct musb *musb, int power_budget)
+{
+   int ret;
+   struct usb_hcd *hcd = musb-hcd;
+
+   MUSB_HST_MODE(musb);
+   musb-xceiv-otg-default_a = 1;
+   musb-xceiv-state = OTG_STATE_A_IDLE;
+
+   otg_set_host(musb-xceiv-otg, hcd-self);
+   hcd-self.otg_port = 1;
+   musb-xceiv-otg-host = hcd-self;
+   hcd-power_budget = 2 * (power_budget ? : 250);
+
+   ret = usb_add_hcd(hcd, 0, 0);
+   if (ret  0)
+   return ret;
+
+   return 0;
+}
+
 void musb_host_resume_root_hub(struct musb *musb)
 {
usb_hcd_resume_root_hub(musb-hcd);
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 1ce6e4e..48a4bdd 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -81,6 +81,8 @@ static inline struct musb_qh *first_qh(struct list_head *q)
 extern struct musb *hcd_to_musb(struct usb_hcd *);
 extern irqreturn_t musb_h_ep0_irq(struct musb *);
 extern int musb_host_alloc(struct musb *);
+extern int musb_host_setup(struct musb *, int);
+extern void musb_host_cleanup(struct musb *);
 extern void musb_host_tx(struct musb *, u8);
 extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
@@ -107,6 +109,12 @@ static inline int musb_host_alloc(struct musb *musb)
return 0;
 }
 
+static inline int musb_host_setup(struct musb *musb, int power_budget)
+{
+   return 0;
+}
+
+static inline void musb_host_cleanup(struct musb *musb){}
 static inline void musb_host_free(struct musb *musb)   {}
 static inline void musb_host_tx(struct musb *musb, u8 epnum)   {}
 static inline void musb_host_rx(struct musb *musb, u8 epnum)   {}
-- 
1.8.1.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 v4 10/11] usb: musb: use musb-port_mode

2013-04-10 Thread Daniel Mack
Initialize the host and gadget subsystems of the musb driver only when
the appropriate mode is selected from platform data, or device-tree
information, respectively.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c| 22 +-
 drivers/usb/musb/musb_virthub.c |  3 ++-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2640d25..b3b9873 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1912,11 +1912,23 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-xceiv-state = OTG_STATE_B_IDLE;
}
 
-   status = musb_host_setup(musb, plat-power);
-   if (status  0)
-   goto fail3;
-
-   status = musb_gadget_setup(musb);
+   switch (musb-port_mode) {
+   case MUSB_PORT_MODE_HOST:
+   status = musb_host_setup(musb, plat-power);
+   break;
+   case MUSB_PORT_MODE_GADGET:
+   status = musb_gadget_setup(musb);
+   break;
+   case MUSB_PORT_MODE_DUAL_ROLE:
+   status = musb_host_setup(musb, plat-power);
+   if (status  0)
+   goto fail3;
+   status = musb_gadget_setup(musb);
+   break;
+   default:
+   dev_err(dev, unsupported port mode %d\n, musb-port_mode);
+   break;
+   }
 
if (status  0)
goto fail3;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 1e17c20..8d92ba2 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
 * (b) vbus present/connect IRQ, peripheral mode;
 * (c) peripheral initiates, using SRP
 */
-   if ((devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
+   if (musb-port_mode != MUSB_PORT_MODE_HOST 
+   (devctl  MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
musb-is_active = 1;
} else {
devctl |= MUSB_DEVCTL_SESSION;
-- 
1.8.1.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 v4 03/11] usb: musb: factor some host-specific functions

2013-04-10 Thread Daniel Mack
In particular, this introduces musb_host_resume_root_hub()and
musb_host_poke_root_hub() which will be stubbed out later.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.c | 18 +++---
 drivers/usb/musb/musb_host.c | 15 ++-
 drivers/usb/musb/musb_host.h |  3 +++
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 37a261a..13341c6 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -484,7 +484,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
 
musb-xceiv-state = OTG_STATE_A_HOST;
musb-is_active = 1;
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
musb-xceiv-state = OTG_STATE_B_PERIPHERAL;
@@ -501,7 +501,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
case OTG_STATE_A_SUSPEND:
/* possibly DISCONNECT is upcoming */
musb-xceiv-state = OTG_STATE_A_HOST;
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_PERIPHERAL:
@@ -643,7 +643,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
 * undesired detour through A_WAIT_BCON.
 */
musb_hnp_stop(musb);
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
musb_root_disconnect(musb);
musb_platform_try_idle(musb, jiffies
+ msecs_to_jiffies(musb-a_wait_bcon
@@ -734,17 +734,13 @@ b_host:
if ((devctl  MUSB_DEVCTL_VBUS)
== (3  MUSB_DEVCTL_VBUS_SHIFT)) {
musb-xceiv-state = OTG_STATE_A_HOST;
-   hcd-self.is_b_host = 0;
+   if (hcd)
+   hcd-self.is_b_host = 0;
}
break;
}
 
-   /* poke the root hub */
-   MUSB_HST_MODE(musb);
-   if (hcd-status_urb)
-   usb_hcd_poll_rh_status(hcd);
-   else
-   usb_hcd_resume_root_hub(hcd);
+   musb_host_poke_root_hub(musb);
 
dev_dbg(musb-controller, CONNECT (%s) devctl %02x\n,
usb_otg_state_string(musb-xceiv-state), 
devctl);
@@ -759,7 +755,7 @@ b_host:
switch (musb-xceiv-state) {
case OTG_STATE_A_HOST:
case OTG_STATE_A_SUSPEND:
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
musb_root_disconnect(musb);
if (musb-a_wait_bcon != 0)
musb_platform_try_idle(musb, jiffies
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 8914dec..8b977d2 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -46,7 +46,6 @@
 #include musb_core.h
 #include musb_host.h
 
-
 /* MUSB HOST status 22-mar-2006
  *
  * - There's still lots of partial code duplication for fault paths, so
@@ -2608,3 +2607,17 @@ const struct hc_driver musb_hc_driver = {
/* .start_port_reset= NULL, */
/* .hub_irq_enable  = NULL, */
 };
+
+void musb_host_resume_root_hub(struct musb *musb)
+{
+   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+}
+
+void musb_host_poke_root_hub(struct musb *musb)
+{
+   MUSB_HST_MODE(musb);
+   if (musb_to_hcd(musb)-status_urb)
+   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   else
+   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+}
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 9670269..c63e585 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -89,6 +89,9 @@ extern void musb_host_tx(struct musb *, u8);
 extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
 
+extern void musb_host_resume_root_hub(struct musb *musb);
+extern void musb_host_poke_root_hub(struct musb *musb);
+
 struct usb_hcd;
 
 extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
-- 
1.8.1.4

--
To 

[PATCH v4 07/11] usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes

2013-04-10 Thread Daniel Mack
This makes building the actual object files optional to the selected
mode, which saves users who know which kind of USB mode support they
need some binary size.

Unimplemented functions are stubbed out with static inline functions.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/Kconfig   | 29 +
 drivers/usb/musb/Makefile  |  4 ++--
 drivers/usb/musb/musb_gadget.h | 21 +
 drivers/usb/musb/musb_host.h   | 29 +++--
 4 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 47442d3..aab1568 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -28,6 +28,35 @@ config USB_MUSB_HDRC
 if USB_MUSB_HDRC
 
 choice
+   bool MUSB Mode Selection
+   default USB_MUSB_DUAL_ROLE if (USB  USB_GADGET)
+   default USB_MUSB_HOST if (USB  !USB_GADGET)
+   default USB_MUSB_GADGET if (!USB  USB_GADGET)
+
+config USB_MUSB_HOST
+   bool Host only mode
+   depends on USB
+   help
+ Select this when you want to use MUSB in host mode only,
+ thereby the gadget feature will be regressed.
+
+config USB_MUSB_GADGET
+   bool Gadget only mode
+   depends on USB_GADGET
+   help
+ Select this when you want to use MUSB in gadget mode only,
+ thereby the host feature will be regressed.
+
+config USB_MUSB_DUAL_ROLE
+   bool Dual Role mode
+   depends on (USB  USB_GADGET)
+   help
+ This is the default mode of working of MUSB controller where
+ both host and gadget features are enabled.
+
+endchoice
+
+choice
prompt Platform Glue Layer
 
 config USB_MUSB_DAVINCI
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index 3b85871..2b82ed7 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -6,8 +6,8 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
 
 musb_hdrc-y := musb_core.o
 
-musb_hdrc-y+= musb_gadget_ep0.o 
musb_gadget.o
-musb_hdrc-y+= musb_virthub.o musb_host.o
+musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += 
musb_virthub.o musb_host.o
+musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += 
musb_gadget_ep0.o musb_gadget.o
 musb_hdrc-$(CONFIG_DEBUG_FS)   += musb_debugfs.o
 
 # Hardware Glue Layer
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 75f821c..0314dfc 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -37,6 +37,7 @@
 
 #include linux/list.h
 
+#if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
 extern irqreturn_t musb_g_ep0_irq(struct musb *);
 extern void musb_g_tx(struct musb *, u8);
 extern void musb_g_rx(struct musb *, u8);
@@ -48,6 +49,26 @@ extern void musb_g_disconnect(struct musb *);
 extern void musb_gadget_cleanup(struct musb *);
 extern int musb_gadget_setup(struct musb *);
 
+#else
+static inline irqreturn_t musb_g_ep0_irq(struct musb *musb)
+{
+   return 0;
+}
+
+static inline void musb_g_tx(struct musb *musb, u8 epnum)  {}
+static inline void musb_g_rx(struct musb *musb, u8 epnum)  {}
+static inline void musb_g_reset(struct musb *musb) {}
+static inline void musb_g_suspend(struct musb *musb)   {}
+static inline void musb_g_resume(struct musb *musb){}
+static inline void musb_g_wakeup(struct musb *musb){}
+static inline void musb_g_disconnect(struct musb *musb){}
+static inline void musb_gadget_cleanup(struct musb *musb)  {}
+static inline int musb_gadget_setup(struct musb *musb)
+{
+   return 0;
+}
+#endif
+
 enum buffer_map_state {
UN_MAPPED = 0,
PRE_MAPPED,
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index e47035e..1ce6e4e 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -39,8 +39,6 @@
 
 #define musb_to_hcd(MUSB) ((MUSB)-hcd)
 
-extern struct musb *hcd_to_musb(struct usb_hcd *);
-
 /* stored in usb_host_endpoint.hcpriv for scheduled endpoints */
 struct musb_qh {
struct usb_host_endpoint *hep;  /* usbcore info */
@@ -78,6 +76,9 @@ static inline struct musb_qh *first_qh(struct list_head *q)
return list_entry(q-next, struct musb_qh, ring);
 }
 
+
+#if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
+extern struct musb *hcd_to_musb(struct usb_hcd *);
 extern irqreturn_t musb_h_ep0_irq(struct musb *);
 extern int musb_host_alloc(struct musb *);
 extern void musb_host_tx(struct musb *, u8);
@@ -90,6 +91,30 @@ extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
 extern void musb_host_resume_root_hub(struct musb *musb);
 extern void musb_host_poke_root_hub(struct musb *musb);
+#else
+static inline 

[PATCH v4 02/11] usb: musb: move function declarations to musb_{host,gadget}.h

2013-04-10 Thread Daniel Mack
Let the function declarations live in the header files they belong to,
which makes it easier to stub them out later.

Signed-off-by: Daniel Mack zon...@gmail.com
Acked-by: Peter Korsgaard jac...@sunsite.dk
---
 drivers/usb/musb/musb_core.h   | 17 -
 drivers/usb/musb/musb_gadget.h | 17 +++--
 drivers/usb/musb/musb_host.h   |  4 +++-
 3 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 7fb4819..04d8974 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -82,23 +82,6 @@ struct musb_ep;
 #define MUSB_CONFIG_PROC_FS
 #endif
 
-/** PERIPHERAL ROLE */
-
-extern irqreturn_t musb_g_ep0_irq(struct musb *);
-extern void musb_g_tx(struct musb *, u8);
-extern void musb_g_rx(struct musb *, u8);
-extern void musb_g_reset(struct musb *);
-extern void musb_g_suspend(struct musb *);
-extern void musb_g_resume(struct musb *);
-extern void musb_g_wakeup(struct musb *);
-extern void musb_g_disconnect(struct musb *);
-
-/** HOST ROLE ***/
-
-extern irqreturn_t musb_h_ep0_irq(struct musb *);
-extern void musb_host_tx(struct musb *, u8);
-extern void musb_host_rx(struct musb *, u8);
-
 /** CONSTANTS /
 
 #ifndef MUSB_C_NUM_EPS
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 66b7c5e..75f821c 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -37,6 +37,17 @@
 
 #include linux/list.h
 
+extern irqreturn_t musb_g_ep0_irq(struct musb *);
+extern void musb_g_tx(struct musb *, u8);
+extern void musb_g_rx(struct musb *, u8);
+extern void musb_g_reset(struct musb *);
+extern void musb_g_suspend(struct musb *);
+extern void musb_g_resume(struct musb *);
+extern void musb_g_wakeup(struct musb *);
+extern void musb_g_disconnect(struct musb *);
+extern void musb_gadget_cleanup(struct musb *);
+extern int musb_gadget_setup(struct musb *);
+
 enum buffer_map_state {
UN_MAPPED = 0,
PRE_MAPPED,
@@ -106,14 +117,8 @@ static inline struct musb_request *next_request(struct 
musb_ep *ep)
return container_of(queue-next, struct musb_request, list);
 }
 
-extern void musb_g_tx(struct musb *musb, u8 epnum);
-extern void musb_g_rx(struct musb *musb, u8 epnum);
-
 extern const struct usb_ep_ops musb_g_ep0_ops;
 
-extern int musb_gadget_setup(struct musb *);
-extern void musb_gadget_cleanup(struct musb *);
-
 extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
 
 extern void musb_ep_restart(struct musb *, struct musb_request *);
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 5a9c8fe..9670269 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -84,7 +84,9 @@ static inline struct musb_qh *first_qh(struct list_head *q)
return list_entry(q-next, struct musb_qh, ring);
 }
 
-
+extern irqreturn_t musb_h_ep0_irq(struct musb *);
+extern void musb_host_tx(struct musb *, u8);
+extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
 
 struct usb_hcd;
-- 
1.8.1.4

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


Re: [PATCH v3 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Daniel Mack
On 10.04.2013 21:15, Peter Korsgaard wrote:
 Daniel == Daniel Mack zon...@gmail.com writes:
 
 Hi,
 
  Daniel +struct musb_hcd_link {
  Daniel +struct musb *musb;
  Daniel +};
  Daniel +
  Daniel +struct musb *hcd_to_musb(struct usb_hcd *hcd)
  Daniel +{
  Daniel +struct musb_hcd_link *link = (struct musb_hcd_link *) 
 hcd-hcd_priv;
  Daniel +return link-musb;
  Daniel +}
  Daniel +
   
   Sorry, I missed this first time around - But why the indirection with
   musb_hcd_link? Why not simply directly store a pointer to struct musb in
   hcd_priv?
 
  Daniel Well, that's also possible. I just thought it's nicer (more readable)
  Daniel that way. But I can as well rework it so the struct isn't needed. It
  Daniel won't safe us any binary size or anything though. So I'm not sure.
 
 Well, it will save one level of indirection (hcd_priv-link-musb vs
 hcd_priv-musb).
 
  Daniel Any particular reason why you don't like the struct? :)
 
 Just that it's an unneeded extra level of indirection.
 

Ok, alright. Sent v4 right now.

Thanks for your feedback! Much appreciated. Btw - did you try that on
your board yet? Does it work for you as well?


Daniel

--
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 v3 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Peter Korsgaard
 Daniel == Daniel Mack zon...@gmail.com writes:

Hi,

  Just that it's an unneeded extra level of indirection.

 Daniel Ok, alright. Sent v4 right now.

Thanks!

 Daniel Thanks for your feedback! Much appreciated. Btw - did you try
 Daniel that on your board yet? Does it work for you as well?

Sorry, not yet. I'm temporarily working on a dm8168 based board (which
unfortunately doesn't have mainline support), and I'm afraid I won't be
able to test it on our am335x based board until a few weeks.

I will need USB host support though, so I am interested in getting it
fixed. Thanks for doing this work!

-- 
Bye, Peter Korsgaard
--
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 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-10 Thread Tony Lindgren
* Nishanth Menon n...@ti.com [130410 12:23]:
 On Wed, Apr 10, 2013 at 1:49 PM, Tony Lindgren t...@atomide.com wrote:
 
  We can avoid the concern of storing the struct clk * and do the
  look up lazily on consumer driver probe by setting a dummy struct
  clk * here. Then replace of_clk_src_simple_get() with a custom
  omap_clk_src_get() that does the lookup and replaces the struct
  clk * with the real one.
 Hmm.. this is interesting. will give it a try. Thanks on the suggestion.

Setting the struct clk * to NULL initially might work too, but that
needs to be checked.

Regards,

Tony
--
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 v5] usbnet: allow status interrupt URB to always be active

2013-04-10 Thread Dan Williams
Some drivers (sierra_net) need the status interrupt URB
active even when the device is closed, because they receive
custom indications from firmware.  Add functions to refcount
the status interrupt URB submit/kill operation so that
sub-drivers and the generic driver don't fight over whether
the status interrupt URB is active or not.

A sub-driver can call usbnet_status_start() at any time, but
the URB is only submitted the first time the function is
called.  Likewise, when the sub-driver is done with the URB,
it calls usbnet_status_stop() but the URB is only killed when
all users have stopped it.  The URB is still killed and
re-submitted for suspend/resume, as before, with the same
refcount it had at suspend.

Signed-off-by: Dan Williams d...@redhat.com
---
 drivers/net/usb/usbnet.c   | 79 ++
 include/linux/usb/usbnet.h |  5 +++
 2 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 51f3192..b71ce36 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -252,6 +252,70 @@ static int init_status (struct usbnet *dev, struct 
usb_interface *intf)
return 0;
 }
 
+/* Submit the interrupt URB if not previously submitted, increasing refcount */
+int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
+{
+   int ret = 0;
+
+   WARN_ON_ONCE(dev-interrupt == NULL);
+   if (dev-interrupt) {
+   mutex_lock(dev-interrupt_mutex);
+
+   if (++dev-interrupt_count == 1)
+   ret = usb_submit_urb(dev-interrupt, mem_flags);
+
+   dev_dbg(dev-udev-dev, incremented interrupt URB count to 
%d\n,
+   dev-interrupt_count);
+   mutex_unlock(dev-interrupt_mutex);
+   }
+   return ret;
+}
+EXPORT_SYMBOL_GPL(usbnet_status_start);
+
+/* For resume; submit interrupt URB if previously submitted */
+static int __usbnet_status_start_force(struct usbnet *dev, gfp_t mem_flags)
+{
+   int ret = 0;
+
+   mutex_lock(dev-interrupt_mutex);
+   if (dev-interrupt_count) {
+   ret = usb_submit_urb(dev-interrupt, mem_flags);
+   dev_dbg(dev-udev-dev,
+   submitted interrupt URB for resume\n);
+   }
+   mutex_unlock(dev-interrupt_mutex);
+   return ret;
+}
+
+/* Kill the interrupt URB if all submitters want it killed */
+void usbnet_status_stop(struct usbnet *dev)
+{
+   if (dev-interrupt) {
+   mutex_lock(dev-interrupt_mutex);
+   WARN_ON(dev-interrupt_count == 0);
+
+   if (dev-interrupt_count  --dev-interrupt_count == 0)
+   usb_kill_urb(dev-interrupt);
+
+   dev_dbg(dev-udev-dev,
+   decremented interrupt URB count to %d\n,
+   dev-interrupt_count);
+   mutex_unlock(dev-interrupt_mutex);
+   }
+}
+EXPORT_SYMBOL_GPL(usbnet_status_stop);
+
+/* For suspend; always kill interrupt URB */
+static void __usbnet_status_stop_force(struct usbnet *dev)
+{
+   if (dev-interrupt) {
+   mutex_lock(dev-interrupt_mutex);
+   usb_kill_urb(dev-interrupt);
+   dev_dbg(dev-udev-dev, killed interrupt URB for suspend\n);
+   mutex_unlock(dev-interrupt_mutex);
+   }
+}
+
 /* Passes this packet up the stack, updating its accounting.
  * Some link protocols batch packets, so their rx_fixup paths
  * can return clones as well as just modify the original skb.
@@ -725,7 +789,7 @@ int usbnet_stop (struct net_device *net)
if (!(info-flags  FLAG_AVOID_UNLINK_URBS))
usbnet_terminate_urbs(dev);
 
-   usb_kill_urb(dev-interrupt);
+   usbnet_status_stop(dev);
 
usbnet_purge_paused_rxq(dev);
 
@@ -787,7 +851,7 @@ int usbnet_open (struct net_device *net)
 
/* start any status interrupt transfer */
if (dev-interrupt) {
-   retval = usb_submit_urb (dev-interrupt, GFP_KERNEL);
+   retval = usbnet_status_start(dev, GFP_KERNEL);
if (retval  0) {
netif_err(dev, ifup, dev-net,
  intr submit %d\n, retval);
@@ -1430,6 +1494,8 @@ usbnet_probe (struct usb_interface *udev, const struct 
usb_device_id *prod)
dev-delay.data = (unsigned long) dev;
init_timer (dev-delay);
mutex_init (dev-phy_mutex);
+   mutex_init(dev-interrupt_mutex);
+   dev-interrupt_count = 0;
 
dev-net = net;
strcpy (net-name, usb%d);
@@ -1565,7 +1631,7 @@ int usbnet_suspend (struct usb_interface *intf, 
pm_message_t message)
 */
netif_device_detach (dev-net);
usbnet_terminate_urbs(dev);
-   usb_kill_urb(dev-interrupt);
+   __usbnet_status_stop_force(dev);
 
/*
 * reattach so runtime management can use and
@@ -1585,9 +1651,8 @@ int 

[PATCH 2/2 v5] sierra_net: keep status interrupt URB active

2013-04-10 Thread Dan Williams
The driver and firmware sync up through SYNC messages, and the
firmware's affirmative reply to these SYNC messages appears to be the
Reset indication received via the status interrupt endpoint.  Thus the
driver needs the status interrupt endpoint always active so that the
Reset indication can be received even if the netdev is closed, which is
the case right after device insertion.

Signed-off-by: Dan Williams d...@redhat.com
---
 drivers/net/usb/sierra_net.c | 40 
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 79ab243..d0fa5c18 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -427,6 +427,13 @@ static void sierra_net_dosync(struct usbnet *dev)
 
dev_dbg(dev-udev-dev, %s, __func__);
 
+   /* The SIERRA_NET_HIP_MSYNC_ID command appears to request that the
+* firmware restart itself.  After restarting, the modem will respond
+* with the SIERRA_NET_HIP_RESTART_ID indication.  The driver continues
+* sending MSYNC commands every few seconds until it receives the
+* RESTART event from the firmware
+*/
+
/* tell modem we are ready */
status = sierra_net_send_sync(dev);
if (status  0)
@@ -705,6 +712,9 @@ static int sierra_net_bind(struct usbnet *dev, struct 
usb_interface *intf)
/* set context index initially to 0 - prepares tx hdr template */
sierra_net_set_ctx_index(priv, 0);
 
+   /* prepare sync message template */
+   memcpy(priv-sync_msg, sync_tmplate, sizeof(priv-sync_msg));
+
/* decrease the rx_urb_size and max_tx_size to 4k on USB 1.1 */
dev-rx_urb_size  = SIERRA_NET_RX_URB_SIZE;
if (dev-udev-speed != USB_SPEED_HIGH)
@@ -740,11 +750,6 @@ static int sierra_net_bind(struct usbnet *dev, struct 
usb_interface *intf)
kfree(priv);
return -ENODEV;
}
-   /* prepare sync message from template */
-   memcpy(priv-sync_msg, sync_tmplate, sizeof(priv-sync_msg));
-
-   /* initiate the sync sequence */
-   sierra_net_dosync(dev);
 
return 0;
 }
@@ -767,8 +772,9 @@ static void sierra_net_unbind(struct usbnet *dev, struct 
usb_interface *intf)
netdev_err(dev-net,
usb_control_msg failed, status %d\n, status);
 
-   sierra_net_set_private(dev, NULL);
+   usbnet_status_stop(dev);
 
+   sierra_net_set_private(dev, NULL);
kfree(priv);
 }
 
@@ -909,6 +915,24 @@ static const struct driver_info sierra_net_info_direct_ip 
= {
.tx_fixup = sierra_net_tx_fixup,
 };
 
+static int
+sierra_net_probe(struct usb_interface *udev, const struct usb_device_id *prod)
+{
+   int ret;
+
+   ret = usbnet_probe(udev, prod);
+   if (ret == 0) {
+   struct usbnet *dev = usb_get_intfdata(udev);
+
+   ret = usbnet_status_start(dev, GFP_KERNEL);
+   if (ret == 0) {
+   /* Interrupt URB now set up; initiate sync sequence */
+   sierra_net_dosync(dev);
+   }
+   }
+   return ret;
+}
+
 #define DIRECT_IP_DEVICE(vend, prod) \
{USB_DEVICE_INTERFACE_NUMBER(vend, prod, 7), \
.driver_info = (unsigned long)sierra_net_info_direct_ip}, \
@@ -931,7 +955,7 @@ MODULE_DEVICE_TABLE(usb, products);
 static struct usb_driver sierra_net_driver = {
.name = sierra_net,
.id_table = products,
-   .probe = usbnet_probe,
+   .probe = sierra_net_probe,
.disconnect = usbnet_disconnect,
.suspend = usbnet_suspend,
.resume = usbnet_resume,
-- 
1.8.1.4


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


RE: [PATCH v3] staging: dwc2: toggle periodic debugging output separately

2013-04-10 Thread Paul Zimmerman
 From: Matthijs Kooijman [mailto:matth...@stdin.nl]
 Sent: Wednesday, April 10, 2013 12:56 AM
 
 This adds a config option USB_DWC2_DEBUG_PERIODIC that allows debugging
 output be suppressed for periodic transfers. This helps when debugging
 non-periodic transfers while there are also periodic transfers going on
 (both to make the debug output less polluted and to prevent all CPU time
 going to debug messages).
 
 In addition, a debug message from dwc2_hcd_is_status_changed is removed
 entirely, since it often floods the log regardless of periodic
 transfers.
 
 Signed-off-by: Matthijs Kooijman matth...@stdin.nl

Applied.

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


[PATCH] drivers: usb: chipidea: convert to devm_ioremap_resource()

2013-04-10 Thread Silviu-Mihai Popescu
Convert  use 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: Silviu-Mihai Popescu silviupopescu1...@gmail.com
---
 drivers/usb/chipidea/core.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 57cae1f..7f3a9e1 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -410,11 +410,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   base = devm_request_and_ioremap(dev, res);
-   if (!base) {
-   dev_err(dev, can't request and ioremap resource\n);
-   return -ENOMEM;
-   }
+   base = devm_ioremap_resource(dev, res);
+   if (IS_ERR(base))
+   return PTR_ERR(base);
 
ci = devm_kzalloc(dev, sizeof(*ci), GFP_KERNEL);
if (!ci) {
-- 
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 v3] staging: dwc2: toggle periodic debugging output separately

2013-04-10 Thread Greg KH
On Wed, Apr 10, 2013 at 08:44:59PM +, Paul Zimmerman wrote:
  From: Matthijs Kooijman [mailto:matth...@stdin.nl]
  Sent: Wednesday, April 10, 2013 12:56 AM
  
  This adds a config option USB_DWC2_DEBUG_PERIODIC that allows debugging
  output be suppressed for periodic transfers. This helps when debugging
  non-periodic transfers while there are also periodic transfers going on
  (both to make the debug output less polluted and to prevent all CPU time
  going to debug messages).
  
  In addition, a debug message from dwc2_hcd_is_status_changed is removed
  entirely, since it often floods the log regardless of periodic
  transfers.
  
  Signed-off-by: Matthijs Kooijman matth...@stdin.nl
 
 Applied.

To what?  Want me to just apply it to my tree so it gets to Linus for
3.10?

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 v3] staging: dwc2: toggle periodic debugging output separately

2013-04-10 Thread Paul Zimmerman
 From: Greg KH [mailto:g...@kroah.com]
 Sent: Wednesday, April 10, 2013 3:53 PM
 
 On Wed, Apr 10, 2013 at 08:44:59PM +, Paul Zimmerman wrote:
   From: Matthijs Kooijman [mailto:matth...@stdin.nl]
   Sent: Wednesday, April 10, 2013 12:56 AM
  
   This adds a config option USB_DWC2_DEBUG_PERIODIC that allows debugging
   output be suppressed for periodic transfers. This helps when debugging
   non-periodic transfers while there are also periodic transfers going on
   (both to make the debug output less polluted and to prevent all CPU time
   going to debug messages).
  
   In addition, a debug message from dwc2_hcd_is_status_changed is removed
   entirely, since it often floods the log regardless of periodic
   transfers.
  
   Signed-off-by: Matthijs Kooijman matth...@stdin.nl
 
  Applied.
 
 To what?  Want me to just apply it to my tree so it gets to Linus for
 3.10?

To my local tree. But sure, if you apply it directly to your tree, that's
good too. Might as well get it into 3.10. Thanks.

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


[PATCH 00/30] ARM: exynos multiplatform support

2013-04-10 Thread Arnd Bergmann
Hi everyone,

I have updated my series for multiplatform support of the ARM exynos
platform, based on what is currently queued up in arm-soc.

It would be really nice to still get this merged for 3.10. A lot of
the patches are really trivial, but there are some complex ones
as well.

To all subsystem maintainers: feel free to directly apply the patches
for your subsystem, there should be no dependencies between any of them,
aside from the last patch requiring all of the earlier ones to be applied
first. Getting an Ack is also fine so we can put the patches into arm-soc.

Arnd

Arnd Bergmann (30):
  ARM: exynos: introduce EXYNOS_ATAGS symbol
  ARM: exynos: prepare for sparse IRQ
  ARM: exynos: move debug-macro.S to include/debug/
  ARM: samsung: move mfc device definition to s5p-dev-mfc.c
  tty: serial/samsung: prepare for common clock API
  tty: serial/samsung: make register definitions global
  tty: serial/samsung: fix modular build
  i2c: s3c2410: make header file local
  mmc: sdhci-s3c: remove platform dependencies
  usb: exynos: do not include plat/usb-phy.h
  [media] exynos: remove unnecessary header inclusions
  video/exynos: remove unnecessary header inclusions
  video/s3c: move platform_data out of arch/arm
  thermal/exynos: remove unnecessary header inclusions
  mtd: onenand/samsung: make regs-onenand.h file local
  rtc: s3c: make header file local
  pwm: samsung: repair the worst MMIO abuses
  ASoC: samsung: move plat/ headers to local directory
  ASoC: samsung: use irq resource for idma
  ASoC: samsung: convert to dmaengine API
  ASoC: samsung/i2s: fix module_device_table
  ASoC: samsung/idma: export idma_reg_addr_init
  clk: exynos: prepare for multiplatform
  clocksource: exynos_mct: remove platform header dependency
  irqchip: exynos: pass max combiner number to combiner_init
  irqchip: exynos: allocate combiner_data dynamically
  irqchip: exynos: localize irq lookup for ATAGS
  irqchip: exynos: pass irq_base from platform
  spi: s3c64xx: move to generic dmaengine API
  ARM: exynos: enable multiplatform support

 arch/arm/Kconfig   |  10 +-
 arch/arm/Kconfig.debug |   8 +
 arch/arm/configs/exynos4_defconfig |   2 +-
 .../mach/debug-macro.S = include/debug/exynos.S}  |  12 +-
 .../plat/debug-macro.S = include/debug/samsung.S} |   2 +-
 arch/arm/mach-exynos/Kconfig   |  40 ++-
 arch/arm/mach-exynos/Makefile  |   5 +-
 arch/arm/mach-exynos/common.c  |  26 +-
 arch/arm/mach-exynos/common.h  |   7 +-
 arch/arm/mach-exynos/dev-uart.c|   1 +
 arch/arm/mach-exynos/include/mach/irqs.h   |   5 +-
 arch/arm/mach-exynos/mach-armlex4210.c |   2 +
 arch/arm/mach-exynos/mach-exynos4-dt.c |   3 +
 arch/arm/mach-exynos/mach-exynos5-dt.c |   2 +
 arch/arm/mach-exynos/mach-nuri.c   |   2 +
 arch/arm/mach-exynos/mach-origen.c |   2 +
 arch/arm/mach-exynos/mach-smdk4x12.c   |   2 +
 arch/arm/mach-exynos/mach-smdkv310.c   |   3 +
 arch/arm/mach-exynos/setup-sdhci-gpio.c|   2 +-
 arch/arm/mach-exynos/setup-usb-phy.c   |   8 +-
 arch/arm/mach-s3c24xx/clock-s3c2440.c  |   5 +
 arch/arm/mach-s3c24xx/common.c |   5 +
 arch/arm/mach-s3c24xx/dma-s3c2410.c|   2 -
 arch/arm/mach-s3c24xx/dma-s3c2412.c|   2 -
 arch/arm/mach-s3c24xx/dma-s3c2440.c|   2 -
 arch/arm/mach-s3c24xx/dma-s3c2443.c|   2 -
 arch/arm/mach-s3c24xx/include/mach/debug-macro.S   |   2 +-
 arch/arm/mach-s3c24xx/mach-rx1950.c|   1 -
 arch/arm/mach-s3c64xx/include/mach/debug-macro.S   |   2 +-
 arch/arm/mach-s3c64xx/setup-usb-phy.c  |   4 +-
 arch/arm/mach-s5p64x0/include/mach/debug-macro.S   |   2 +-
 arch/arm/mach-s5pc100/include/mach/debug-macro.S   |   2 +-
 arch/arm/mach-s5pc100/setup-sdhci-gpio.c   |   1 -
 arch/arm/mach-s5pv210/include/mach/debug-macro.S   |   2 +-
 arch/arm/mach-s5pv210/setup-sdhci-gpio.c   |   1 -
 arch/arm/mach-s5pv210/setup-usb-phy.c  |   4 +-
 arch/arm/plat-samsung/Kconfig  |   7 +-
 arch/arm/plat-samsung/Makefile |   8 +-
 arch/arm/plat-samsung/devs.c   |  62 ++---
 arch/arm/plat-samsung/include/plat/fb.h|  50 +---
 arch/arm/plat-samsung/include/plat/pm.h|   5 +
 arch/arm/plat-samsung/include/plat/regs-serial.h   | 282 +
 arch/arm/plat-samsung/include/plat/sdhci.h |  56 +---
 arch/arm/plat-samsung/include/plat/usb-phy.h   |   5 +-
 arch/arm/plat-samsung/irq-vic-timer.c  |   1 +
 arch/arm/plat-samsung/pm.c |   1 +
 arch/arm/plat-samsung/s5p-dev-mfc.c|  42 ++-
 arch/arm/plat-samsung/s5p-irq.c|   

[PATCH 10/30] usb: exynos: do not include plat/usb-phy.h

2013-04-10 Thread Arnd Bergmann
The definitions have moved to include/linux/usb/samsung-usb-phy.h,
and plat/usb-phy.h is unavailable from drivers in a multiplatform
configuration.

Also fix up the plat/usb-phy.h header file to use the definitions
from the new header instead of providing a separate copy.

Signed-off-by: Arnd Bergmann a...@arndb.de
Cc: linux-usb@vger.kernel.org
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Alan Stern st...@rowland.harvard.edu
---
 arch/arm/mach-exynos/setup-usb-phy.c | 8 
 arch/arm/mach-s3c64xx/setup-usb-phy.c| 4 ++--
 arch/arm/mach-s5pv210/setup-usb-phy.c| 4 ++--
 arch/arm/plat-samsung/include/plat/usb-phy.h | 5 +
 drivers/usb/host/ehci-s5p.c  | 1 -
 drivers/usb/host/ohci-exynos.c   | 1 -
 6 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index b81cc56..6af4066 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -204,9 +204,9 @@ static int exynos4210_usb_phy1_exit(struct platform_device 
*pdev)
 
 int s5p_usb_phy_init(struct platform_device *pdev, int type)
 {
-   if (type == S5P_USB_PHY_DEVICE)
+   if (type == USB_PHY_TYPE_DEVICE)
return exynos4210_usb_phy0_init(pdev);
-   else if (type == S5P_USB_PHY_HOST)
+   else if (type == USB_PHY_TYPE_HOST)
return exynos4210_usb_phy1_init(pdev);
 
return -EINVAL;
@@ -214,9 +214,9 @@ int s5p_usb_phy_init(struct platform_device *pdev, int type)
 
 int s5p_usb_phy_exit(struct platform_device *pdev, int type)
 {
-   if (type == S5P_USB_PHY_DEVICE)
+   if (type == USB_PHY_TYPE_DEVICE)
return exynos4210_usb_phy0_exit(pdev);
-   else if (type == S5P_USB_PHY_HOST)
+   else if (type == USB_PHY_TYPE_HOST)
return exynos4210_usb_phy1_exit(pdev);
 
return -EINVAL;
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index c8174d9..ca960bd 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -76,7 +76,7 @@ static int s3c_usb_otgphy_exit(struct platform_device *pdev)
 
 int s5p_usb_phy_init(struct platform_device *pdev, int type)
 {
-   if (type == S5P_USB_PHY_DEVICE)
+   if (type == USB_PHY_TYPE_DEVICE)
return s3c_usb_otgphy_init(pdev);
 
return -EINVAL;
@@ -84,7 +84,7 @@ int s5p_usb_phy_init(struct platform_device *pdev, int type)
 
 int s5p_usb_phy_exit(struct platform_device *pdev, int type)
 {
-   if (type == S5P_USB_PHY_DEVICE)
+   if (type == USB_PHY_TYPE_DEVICE)
return s3c_usb_otgphy_exit(pdev);
 
return -EINVAL;
diff --git a/arch/arm/mach-s5pv210/setup-usb-phy.c 
b/arch/arm/mach-s5pv210/setup-usb-phy.c
index 356a090..b2ee533 100644
--- a/arch/arm/mach-s5pv210/setup-usb-phy.c
+++ b/arch/arm/mach-s5pv210/setup-usb-phy.c
@@ -80,7 +80,7 @@ static int s5pv210_usb_otgphy_exit(struct platform_device 
*pdev)
 
 int s5p_usb_phy_init(struct platform_device *pdev, int type)
 {
-   if (type == S5P_USB_PHY_DEVICE)
+   if (type == USB_PHY_TYPE_DEVICE)
return s5pv210_usb_otgphy_init(pdev);
 
return -EINVAL;
@@ -88,7 +88,7 @@ int s5p_usb_phy_init(struct platform_device *pdev, int type)
 
 int s5p_usb_phy_exit(struct platform_device *pdev, int type)
 {
-   if (type == S5P_USB_PHY_DEVICE)
+   if (type == USB_PHY_TYPE_DEVICE)
return s5pv210_usb_otgphy_exit(pdev);
 
return -EINVAL;
diff --git a/arch/arm/plat-samsung/include/plat/usb-phy.h 
b/arch/arm/plat-samsung/include/plat/usb-phy.h
index 959bcdb..ab34dfa 100644
--- a/arch/arm/plat-samsung/include/plat/usb-phy.h
+++ b/arch/arm/plat-samsung/include/plat/usb-phy.h
@@ -11,10 +11,7 @@
 #ifndef __PLAT_SAMSUNG_USB_PHY_H
 #define __PLAT_SAMSUNG_USB_PHY_H __FILE__
 
-enum s5p_usb_phy_type {
-   S5P_USB_PHY_DEVICE,
-   S5P_USB_PHY_HOST,
-};
+#include linux/usb/samsung_usb_phy.h
 
 extern int s5p_usb_phy_init(struct platform_device *pdev, int type);
 extern int s5p_usb_phy_exit(struct platform_device *pdev, int type);
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 20ebf6a..7dc9c15 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -19,7 +19,6 @@
 #include linux/platform_data/usb-ehci-s5p.h
 #include linux/usb/phy.h
 #include linux/usb/samsung_usb_phy.h
-#include plat/usb-phy.h
 
 #define EHCI_INSNREG00(base)   (base + 0x90)
 #define EHCI_INSNREG00_ENA_INCR16  (0x1  25)
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 0bd6f47..0792bfd 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -18,7 +18,6 @@
 #include linux/usb/phy.h
 #include linux/usb/samsung_usb_phy.h
 
-#include plat/usb-phy.h
 
 struct exynos_ohci_hcd {
struct device *dev;
-- 
1.8.1.2

--
To 

  1   2   >