Re: [RFC v2] usb/gadget: the start of the configfs interface

2012-12-04 Thread Sebastian Andrzej Siewior

On 12/03/2012 07:23 PM, Michal Nazarewicz wrote:

On 11/30/2012 07:39 PM, Michal Nazarewicz wrote:

Yeah, but what Felipe just made me realise is that if that's the case,
than it makes no sense to have the functions directory outside of the
gadget.  Instead we should have something like:


On Mon, Dec 03 2012, Sebastian Andrzej Siewior wrote:

Yes. Except if we want to move functions from one udc to another.
Doesn't this look useful? Are sure we won't to disallow this?


But there is no need for functions to be outside of gadget for that.
After all, one does not move a single function between UDCs, one moves
the whole gadgets.


Hmm. Okay then. Lets the move the functions as you proposed and add a
configs folder

Sebastian
--
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] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Marc Kleine-Budde
On 12/03/2012 09:42 PM, krumbo...@universalnet.at wrote:
> Hi Marc!
> 
> 
>>> +/* Send open command to device */
>>> +static int usb_8dev_cmd_open(struct usb_8dev *dev)
>>> +{
>>> +struct can_bittiming *bt = &dev->can.bittiming;
>>> +struct usb_8dev_cmd_msg outmsg;
>>> +struct usb_8dev_cmd_msg inmsg;
>>> +u32 flags = 0;
>>> +u32 beflags;
>>> +u16 bebrp;
>>> +u32 ctrlmode = dev->can.ctrlmode;
>>> +
>>> +if (ctrlmode & CAN_CTRLMODE_LOOPBACK)
>>> +flags |= USB_8DEV_LOOPBACK;
>>> +if (ctrlmode & CAN_CTRLMODE_LISTENONLY)
>>> +flags |= USB_8DEV_SILENT;
>>> +if (ctrlmode & CAN_CTRLMODE_ONE_SHOT)
>>> +flags |= USB_8DEV_DISABLE_AUTO_RESTRANS;
>>> +
>>> +flags |= USB_8DEV_STATUS_FRAME;
>>> +
>>> +memset(&outmsg, 0, sizeof(struct usb_8dev_cmd_msg));
>>> +outmsg.command = USB_8DEV_OPEN;
>>> +outmsg.opt1 = USB_8DEV_BAUD_MANUAL;
>>> +outmsg.data[0] = (bt->prop_seg + bt->phase_seg1);
>>> +outmsg.data[1] = bt->phase_seg2;
>>> +outmsg.data[2] = bt->sjw;
>>
>> But you should not use usb_bulk_msg() to send data which is on the
>> stack, please use you already allocated memory in priv or kmalloc
>> something here.
> 
> The function usb_8dev_send_cmd copies the data to dev->cmd_msg_buffer
> (allocated with kzalloc, GFP_KERNEL).

Okay, then you might want to set outmsg via C99 initializers.

>>> +
>>> +/* BRP */
>>> +bebrp = cpu_to_be16((u16) bt->brp);
>>> +memcpy(&outmsg.data[3], &bebrp, sizeof(bebrp));
>>
>> Are you sure about the endianess? Some data types are BE some are LE?
> 
> Where is LE used?

Opps, yeah right. only BE.


Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v2] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Marc Kleine-Budde
On 12/03/2012 09:15 PM, Wolfgang Grandegger wrote:
> On 12/03/2012 09:32 PM, krumbo...@universalnet.at wrote:
>> Hi Wolfgang!
>>
>>>
>>> And please also drop the remaining sysfs files for firmware and
>>> hardware. I thinks it's enough that the versions are printed when the
>>> device is probed.
>>
>> Systemadministrators often use versions for configuration scripts.
>> If you insist I will remove.
> 
> Marc?

Are these values exported via lsusb -v (e.g. iSerial)?

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v2 13/22] mfd: omap-usb-host: override number of ports from platform data

2012-12-04 Thread Sergei Shtylyov

Hello.

On 03-12-2012 19:58, Roger Quadros wrote:


On 28-11-2012 18:49, Roger Quadros wrote:



Both OMAP4 and 5 exhibit the same revision ID in the REVISION register
but they have different number of ports i.e. 2 and 3 respectively.
So we can't rely on REVISION register for number of ports on OMAP5
and depend on platform data (or device tree) instead.



Signed-off-by: Roger Quadros 

[...]



diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 87b574b..fda235a 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -495,19 +495,27 @@ static int __devinit usbhs_omap_probe(struct
platform_device *pdev)
*/
   pm_runtime_put_sync(dev);

-switch (omap->usbhs_rev) {
-case OMAP_USBHS_REV1:
-omap->nports = 3;
-break;
-case OMAP_USBHS_REV2:
-omap->nports = 2;
-break;
-default:
-omap->nports = OMAP3_HS_USB_PORTS;
-dev_dbg(dev,
-  "USB HOST Rev : 0x%d not recognized, assuming %d ports\n",
-   omap->usbhs_rev, omap->nports);
-break;
+/*
+ * If platform data contains nports then use that
+ * else make out number of ports from USBHS revision
+ */
+if (pdata->nports) {
+omap->nports = pdata->nports;



Overindented line?



Sorry, I didn't get it. Did you mean extra tab/space?


   Extra tab, yes.

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 v2] gadget/mass_storage: remove >= 0 check for unsigned type

2012-12-04 Thread Sergei Shtylyov

Hello.

On 03-12-2012 18:32, Sebastian Andrzej Siewior wrote:


| In file included from drivers/usb/gadget/acm_ms.c:43:
| f_mass_storage.c:2199:18: warning: comparison of unsigned expression >= 0 is 
always true  [-Wtautological-compare]
| if (common->lun >= 0 && common->lun < common->nluns)
| ~~~ ^  ~



common->lun is defined as "unsigned int" so its value is always >= 0.
It is assigned via cbw->Lun which is defined as u8 so it is also not
abused as -1.



[min...@mina86.com: make lun unsigned int and use %u in DBG() macro for it]
Acked-by: Michal Nazarewicz 


   Michal, shouldn't you rather sign off on the patch if it includes a chunk 
from you anyway?



Signed-off-by: Sebastian Andrzej Siewior 
---
v1..v2: add Michal's chunk which converts lun to unsigned int


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 v2] gadget/mass_storage: remove >= 0 check for unsigned type

2012-12-04 Thread Michal Nazarewicz
> On 03-12-2012 18:32, Sebastian Andrzej Siewior wrote:
>> | In file included from drivers/usb/gadget/acm_ms.c:43:
>> | f_mass_storage.c:2199:18: warning: comparison of unsigned expression >= 0 
>> is always true  [-Wtautological-compare]
>> | if (common->lun >= 0 && common->lun < common->nluns)
>> | ~~~ ^  ~
>
>> common->lun is defined as "unsigned int" so its value is always >= 0.
>> It is assigned via cbw->Lun which is defined as u8 so it is also not
>> abused as -1.
>
>> [min...@mina86.com: make lun unsigned int and use %u in DBG() macro for it]
>> Acked-by: Michal Nazarewicz 

On Tue, Dec 04 2012, Sergei Shtylyov  wrote:
> Michal, shouldn't you rather sign off on the patch if it includes a chunk 
> from you anyway?

Makes sense I guess, I'm fine either way:

Signed-off-by: Michal Nazarewicz 

>> Signed-off-by: Sebastian Andrzej Siewior 

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpkQCFCAIkJN.pgp
Description: PGP signature


[PATCH 1/2] USB: fsl-mph-dr-of: fix regression on mpc5121e

2012-12-04 Thread Anatolij Gustschin
fsl-ehci probing fails on mpc5121e:
...
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
fsl-ehci fsl-ehci.0: Freescale On-Chip EHCI Host Controller
fsl-ehci fsl-ehci.0: new USB bus registered, assigned bus number 1
fsl-ehci fsl-ehci.0: Could not get controller version
fsl-ehci fsl-ehci.0: can't setup
fsl-ehci fsl-ehci.0: USB bus 1 deregistered
fsl-ehci fsl-ehci.0: init fsl-ehci.0 fail, -22
fsl-ehci: probe of fsl-ehci.0 failed with error -22

Fix it by returning appropriate version info for mpc5121, too.

Signed-off-by: Anatolij Gustschin 
---
 drivers/usb/host/fsl-mph-dr-of.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 1e77129..4450d12 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -142,6 +142,9 @@ static int usb_get_ver_info(struct device_node *np)
return ver;
}
 
+   if (of_device_is_compatible(np, "fsl,mpc5121-usb2-dr"))
+   return FSL_USB_VER_OLD;
+
if (of_device_is_compatible(np, "fsl-usb2-mph")) {
if (of_device_is_compatible(np, "fsl-usb2-mph-v1.6"))
ver = FSL_USB_VER_1_6;
-- 
1.7.7.6

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


[PATCH 2/2] USB: ehci-fsl: fix regression on mpc5121e

2012-12-04 Thread Anatolij Gustschin
mpc5121e doesn't have system interface registers, accessing this
register address space cause the machine check exception and a
kernel crash:

...
Machine check in kernel mode.
Caused by (from SRR1=49030): Transfer error ack signal
Oops: Machine check, sig: 7 [#1]
MPC5121 ADS
Modules linked in:
NIP: c025fd60 LR: c0265bb4 CTR: 
REGS: df82dac0 TRAP: 0200   Not tainted
(3.7.0-rc7-00641-g81e6c91)
MSR: 00049030   CR: 42002024  XER: 2000
TASK = df824b70[1] 'swapper' THREAD: df82c000
GPR00:  df82db70 df824b70 df3ed0f0 0003   
GPR08: 0020 3200 c03550ec 2000 22002028  c0003f5c 
GPR16:       c0423898 c045
GPR24: 0077 0002 e5086180 1c000c00 e5086000 df33ec00 0003 df34e000
NIP [c025fd60] ehci_fsl_setup_phy+0xd0/0x354
LR [c0265bb4] ehci_fsl_setup+0x220/0x284
...

Fix it by checking 'have_sysif_regs' flag before register access.

Signed-off-by: Anatolij Gustschin 
---
 drivers/usb/host/ehci-fsl.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 0d2f35c..16ed5d6 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -230,7 +230,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
 
switch (phy_mode) {
case FSL_USB2_PHY_ULPI:
-   if (pdata->controller_ver) {
+   if (pdata->have_sysif_regs && pdata->controller_ver) {
/* controller version 1.6 or above */
setbits32(non_ehci + FSL_SOC_USB_CTRL,
ULPI_PHY_CLK_SEL);
@@ -251,7 +251,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
portsc |= PORT_PTS_PTW;
/* fall through */
case FSL_USB2_PHY_UTMI:
-   if (pdata->controller_ver) {
+   if (pdata->have_sysif_regs && pdata->controller_ver) {
/* controller version 1.6 or above */
setbits32(non_ehci + FSL_SOC_USB_CTRL, UTMI_PHY_EN);
mdelay(FSL_UTMI_PHY_DLY);  /* Delay for UTMI PHY CLK to
@@ -267,7 +267,8 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
break;
}
 
-   if (pdata->controller_ver && (phy_mode == FSL_USB2_PHY_ULPI)) {
+   if (pdata->have_sysif_regs && pdata->controller_ver &&
+   (phy_mode == FSL_USB2_PHY_ULPI)) {
/* check PHY_CLK_VALID to get phy clk valid */
if (!spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) &
PHY_CLK_VALID, FSL_USB_PHY_CLK_TIMEOUT, 0)) {
@@ -278,7 +279,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
 
ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]);
 
-   if (phy_mode != FSL_USB2_PHY_ULPI)
+   if (phy_mode != FSL_USB2_PHY_ULPI && pdata->have_sysif_regs)
setbits32(non_ehci + FSL_SOC_USB_CTRL, USB_CTRL_USB_EN);
 
return 0;
-- 
1.7.7.6

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


[PATCH] USB: fix fsl_otg config dependency

2012-12-04 Thread Anatolij Gustschin
USB_GADGET_FSL_USB2 has been changed to USB_FSL_USB2 by commit
193ab2a6070039e7ee2b9b9bebea754a7c52fd1b (usb: gadget: allow
multiple gadgets to be built). But old USB_GADGET_FSL_USB2 is
still listed as dependency for fsl_otg driver, so the driver
cannot be selected in the configuration currently. Fix it.

Signed-off-by: Anatolij Gustschin 
---
 drivers/usb/otg/Kconfig |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 6223062..37962c9 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -110,7 +110,7 @@ config AB8500_USB
 
 config FSL_USB2_OTG
bool "Freescale USB OTG Transceiver Driver"
-   depends on USB_EHCI_FSL && USB_GADGET_FSL_USB2 && USB_SUSPEND
+   depends on USB_EHCI_FSL && USB_FSL_USB2 && USB_SUSPEND
select USB_OTG
select USB_OTG_UTILS
help
-- 
1.7.7.6

--
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/23] mfd: omap-usb-tll: Avoid creating copy of platform data

2012-12-04 Thread Roger Quadros
Just a pointer to the platform data should suffice.

Signed-off-by: Roger Quadros 
Acked-by: Felipe Balbi 
---
 drivers/mfd/omap-usb-tll.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 0db0dfa..18fefdb 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -98,7 +98,7 @@
 struct usbtll_omap {
struct clk  *usbtll_p1_fck;
struct clk  *usbtll_p2_fck;
-   struct usbtll_omap_platform_dataplatdata;
+   struct usbtll_omap_platform_data*pdata;
/* secure the register updates */
spinlock_t  lock;
 };
@@ -223,8 +223,7 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
 
spin_lock_init(&tll->lock);
 
-   for (i = 0; i < OMAP3_HS_USB_PORTS; i++)
-   tll->platdata.port_mode[i] = pdata->port_mode[i];
+   tll->pdata = pdata;
 
tll->usbtll_p1_fck = clk_get(dev, "usb_tll_hs_usb_ch0_clk");
if (IS_ERR(tll->usbtll_p1_fck)) {
@@ -362,7 +361,7 @@ static int __devexit usbtll_omap_remove(struct 
platform_device *pdev)
 static int usbtll_runtime_resume(struct device *dev)
 {
struct usbtll_omap  *tll = dev_get_drvdata(dev);
-   struct usbtll_omap_platform_data*pdata = &tll->platdata;
+   struct usbtll_omap_platform_data*pdata = tll->pdata;
unsigned long   flags;
 
dev_dbg(dev, "usbtll_runtime_resume\n");
@@ -388,7 +387,7 @@ static int usbtll_runtime_resume(struct device *dev)
 static int usbtll_runtime_suspend(struct device *dev)
 {
struct usbtll_omap  *tll = dev_get_drvdata(dev);
-   struct usbtll_omap_platform_data*pdata = &tll->platdata;
+   struct usbtll_omap_platform_data*pdata = tll->pdata;
unsigned long   flags;
 
dev_dbg(dev, "usbtll_runtime_suspend\n");
-- 
1.7.4.1

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


[PATCH v3 00/23] OMAP USB Host cleanup

2012-12-04 Thread Roger Quadros
Hi,

This patchset addresses the following

- Avoid addressing clocks one by one by name and use a for loop + bunch
  of cleanups.
- Get number of channels/ports dynamically either from revision register
  or from platform data. Avoids getting clocks that are not present.
- Add OMAP5 and HSIC mode (Not tested)

changes in v3:
- Rebased on arm-soc/for-next commit f979306c4d38d213c6977aaf3b1115e8ded71e3a
- Rearranged patch that get rids of cpu_is_omap..() macros
- Coding style fixes

changes in v2:
- Clocks are allocated dynamically based on number of ports available
on the platform
- Reduced console spam if non critical clocks are not found on the platform.
- Get rid of cpu_is_.. macros from USB host driver.

cheers,
-roger

--
Roger Quadros (23):
  mfd: omap-usb-host: get rid of cpu_is_omap..() macros
  mfd: omap-usb-tll: Avoid creating copy of platform data
  mfd: omap-usb-tll: Fix channel count detection
  mfd: omap-usb-tll: Use devm_kzalloc/ioremap and clean up error path
  mfd: omap-usb-tll: Clean up clock handling
  mfd: omap-usb-tll: introduce and use mode_needs_tll()
  mfd: omap-usb-tll: Check for missing platform data in probe
  mfd: omap-usb-tll: Fix error message
  mfd: omap-usb-tll: serialize access to TLL device
  mfd: omap-usb-tll: Add OMAP5 revision and HSIC support
  mfd: omap_usb_host: Avoid creating copy of platform_data
  mfd: omap-usb-host: Use devm_kzalloc() and devm_request_and_ioremap()
  mfd: omap-usb-host: know about number of ports from revision register
  mfd: omap-usb-host: override number of ports from platform data
  mfd: omap-usb-host: cleanup clock management code
  ARM: OMAP2+: clock data: Merge utmi_px_gfclk into
usb_host_hs_utmi_px_clk
  mfd: omap-usb-host: Manage HSIC clocks for HSIC mode
  mfd: omap-usb-host: Get rid of unnecessary spinlock
  mfd: omap-usb-host: clean up omap_usbhs_init()
  USB: ehci-omap: Don't free gpios that we didn't request
  ARM: OMAP3: clock data: get rid of unused USB host clock aliases and
dummies
  ARM: OMAP4: clock data: get rid of unused USB host clock aliases
  mfd: omap-usb-host: Don't spam console on clk_set_parent failure

 arch/arm/mach-omap2/cclock3xxx_data.c  |   13 -
 arch/arm/mach-omap2/cclock44xx_data.c  |   55 +++--
 arch/arm/mach-omap2/usb-host.c |5 +
 arch/arm/mach-omap2/usb.h  |1 +
 drivers/mfd/omap-usb-host.c|  474 ++--
 drivers/mfd/omap-usb-tll.c |  244 +
 drivers/usb/host/ehci-omap.c   |8 -
 include/linux/platform_data/usb-omap.h |4 +
 8 files changed, 451 insertions(+), 353 deletions(-)

-- 
1.7.4.1

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


[PATCH v3 01/23] mfd: omap-usb-host: get rid of cpu_is_omap..() macros

2012-12-04 Thread Roger Quadros
Instead of using cpu_is_omap..() macros in the device driver we
rely on information provided in the platform data.

The only information we need is whether the USB Host module has
a single ULPI bypass control bit for all ports or individual bypass
control bits for each port. OMAP3 REV2.1 and earlier have the former.

Signed-off-by: Roger Quadros 
CC: Tony Lindgren 
---
 arch/arm/mach-omap2/usb-host.c |4 
 drivers/mfd/omap-usb-host.c|2 +-
 include/linux/platform_data/usb-omap.h |3 +++
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c
index d1dbe12..2e44e8a 100644
--- a/arch/arm/mach-omap2/usb-host.c
+++ b/arch/arm/mach-omap2/usb-host.c
@@ -508,6 +508,10 @@ void __init usbhs_init(const struct usbhs_omap_board_data 
*pdata)
if (cpu_is_omap34xx()) {
setup_ehci_io_mux(pdata->port_mode);
setup_ohci_io_mux(pdata->port_mode);
+
+   if (omap_rev() <= OMAP3430_REV_ES2_1)
+   usbhs_data.single_ulpi_bypass = true;
+
} else if (cpu_is_omap44xx()) {
setup_4430ehci_io_mux(pdata->port_mode);
setup_4430ohci_io_mux(pdata->port_mode);
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index cebfe0a..fe7906b 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -384,7 +384,7 @@ static void omap_usbhs_init(struct device *dev)
reg &= ~OMAP_UHH_HOSTCONFIG_P3_CONNECT_STATUS;
 
/* Bypass the TLL module for PHY mode operation */
-   if (cpu_is_omap3430() && (omap_rev() <= OMAP3430_REV_ES2_1)) {
+   if (pdata->single_ulpi_bypass) {
dev_dbg(dev, "OMAP3 ES version <= ES2.1\n");
if (is_ehci_phy_mode(pdata->port_mode[0]) ||
is_ehci_phy_mode(pdata->port_mode[1]) ||
diff --git a/include/linux/platform_data/usb-omap.h 
b/include/linux/platform_data/usb-omap.h
index 8570bcf..ef65b67 100644
--- a/include/linux/platform_data/usb-omap.h
+++ b/include/linux/platform_data/usb-omap.h
@@ -59,6 +59,9 @@ struct usbhs_omap_platform_data {
 
struct ehci_hcd_omap_platform_data  *ehci_data;
struct ohci_hcd_omap_platform_data  *ohci_data;
+
+   /* OMAP3 <= ES2.1 have a single ulpi bypass control bit */
+   unsignedsingle_ulpi_bypass:1;
 };
 
 /*-*/
-- 
1.7.4.1

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


[PATCH v3 03/23] mfd: omap-usb-tll: Fix channel count detection

2012-12-04 Thread Roger Quadros
Fix channel count detecion for REV2. Also, don't give up
if we don't recognize the IP Revision. We assume the default
number of channels (i.e. 3) for unrecognized IPs.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 18fefdb..e67cafc 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -98,6 +98,7 @@
 struct usbtll_omap {
struct clk  *usbtll_p1_fck;
struct clk  *usbtll_p2_fck;
+   int nch;/* num. of channels */
struct usbtll_omap_platform_data*pdata;
/* secure the register updates */
spinlock_t  lock;
@@ -210,7 +211,7 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
unsignedreg;
unsigned long   flags;
int ret = 0;
-   int i, ver, count;
+   int i, ver;
 
dev_dbg(dev, "starting TI HSUSB TLL Controller\n");
 
@@ -262,16 +263,18 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
ver =  usbtll_read(base, OMAP_USBTLL_REVISION);
switch (ver) {
case OMAP_USBTLL_REV1:
-   case OMAP_USBTLL_REV2:
-   count = OMAP_TLL_CHANNEL_COUNT;
+   tll->nch = OMAP_TLL_CHANNEL_COUNT;
break;
+   case OMAP_USBTLL_REV2:
case OMAP_USBTLL_REV3:
-   count = OMAP_REV2_TLL_CHANNEL_COUNT;
+   tll->nch = OMAP_REV2_TLL_CHANNEL_COUNT;
break;
default:
-   dev_err(dev, "TLL version failed\n");
-   ret = -ENODEV;
-   goto err_ioremap;
+   tll->nch = OMAP_TLL_CHANNEL_COUNT;
+   dev_dbg(dev,
+"USB TLL Rev : 0x%x not recognized, assuming %d channels\n",
+   ver, tll->nch);
+   break;
}
 
if (is_ehci_tll_mode(pdata->port_mode[0]) ||
@@ -291,7 +294,7 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
usbtll_write(base, OMAP_TLL_SHARED_CONF, reg);
 
/* Enable channels now */
-   for (i = 0; i < count; i++) {
+   for (i = 0; i < tll->nch; i++) {
reg = usbtll_read(base, OMAP_TLL_CHANNEL_CONF(i));
 
if (is_ohci_port(pdata->port_mode[i])) {
@@ -319,7 +322,6 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
}
}
 
-err_ioremap:
spin_unlock_irqrestore(&tll->lock, flags);
iounmap(base);
pm_runtime_put_sync(dev);
-- 
1.7.4.1

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


[PATCH v3 05/23] mfd: omap-usb-tll: Clean up clock handling

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

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

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   93 +++-
 1 files changed, 57 insertions(+), 36 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 828207f..7d0f6cf 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -96,10 +96,9 @@
 #define is_ehci_tll_mode(x)(x == OMAP_EHCI_PORT_MODE_TLL)
 
 struct usbtll_omap {
-   struct clk  *usbtll_p1_fck;
-   struct clk  *usbtll_p2_fck;
int nch;/* num. of channels */
struct usbtll_omap_platform_data*pdata;
+   struct clk  **ch_clk;
/* secure the register updates */
spinlock_t  lock;
 };
@@ -225,26 +224,10 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
 
tll->pdata = pdata;
 
-   tll->usbtll_p1_fck = clk_get(dev, "usb_tll_hs_usb_ch0_clk");
-   if (IS_ERR(tll->usbtll_p1_fck)) {
-   ret = PTR_ERR(tll->usbtll_p1_fck);
-   dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret);
-   return ret;
-   }
-
-   tll->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk");
-   if (IS_ERR(tll->usbtll_p2_fck)) {
-   ret = PTR_ERR(tll->usbtll_p2_fck);
-   dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret);
-   goto err_p2_fck;
-   }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_request_and_ioremap(dev, res);
-   if (!base) {
-   ret = -EADDRNOTAVAIL;
-   goto err_res;
-   }
+   if (!base)
+   return -EADDRNOTAVAIL;
 
platform_set_drvdata(pdev, tll);
pm_runtime_enable(dev);
@@ -269,6 +252,32 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
break;
}
 
+   spin_unlock_irqrestore(&tll->lock, flags);
+
+   tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll->nch]),
+   GFP_KERNEL);
+   if (!tll->ch_clk) {
+   ret = -ENOMEM;
+   dev_err(dev, "Couldn't allocate memory for channel clocks\n");
+   goto err_clk_alloc;
+   }
+
+   spin_lock_irqsave(&tll->lock, flags);
+
+   for (i = 0; i < tll->nch; i++) {
+   char clkname[] = "usb_tll_hs_usb_chx_clk";
+   struct clk *fck;
+
+   snprintf(clkname, sizeof(clkname),
+   "usb_tll_hs_usb_ch%d_clk", i);
+   fck = clk_get(dev, clkname);
+
+   if (IS_ERR(fck))
+   dev_dbg(dev, "can't get clock : %s\n", clkname);
+   else
+   tll->ch_clk[i] = fck;
+   }
+
if (is_ehci_tll_mode(pdata->port_mode[0]) ||
is_ehci_tll_mode(pdata->port_mode[1]) ||
is_ehci_tll_mode(pdata->port_mode[2]) ||
@@ -320,11 +329,9 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
 
return 0;
 
-err_res:
-   clk_put(tll->usbtll_p2_fck);
-
-err_p2_fck:
-   clk_put(tll->usbtll_p1_fck);
+err_clk_alloc:
+   pm_runtime_put_sync(dev);
+   pm_runtime_disable(dev);
 
return ret;
 }
@@ -338,9 +345,11 @@ err_p2_fck:
 static int __devexit usbtll_omap_remove(struct platform_device *pdev)
 {
struct usbtll_omap *tll = platform_get_drvdata(pdev);
+   int i;
+
+   for (i = 0; i < tll->nch; i++)
+   clk_put(tll->ch_clk[i]);
 
-   clk_put(tll->usbtll_p2_fck);
-   clk_put(tll->usbtll_p1_fck);
pm_runtime_disable(&pdev->dev);
return 0;
 }
@@ -350,6 +359,7 @@ static int usbtll_runtime_resume(struct device *dev)
struct usbtll_omap  *tll = dev_get_drvdata(dev);
struct usbtll_omap_platform_data*pdata = tll->pdata;
unsigned long   flags;
+   int i;
 
dev_dbg(dev, "usbtll_runtime_resume\n");
 
@@ -360,11 +370,20 @@ static int usbtll_runtime_resume(struct device *dev)
 
spin_lock_irqsave(&tll->lock, flags);
 
-   if (is_ehci_tll_mode(pdata->port_mode[0]))
-   clk_enable(tll->usbtll_p1_fck);
+   for (i = 0; i < tll->nch; i++) {
+   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   int r;
 
-   if (is_ehci_tll_mode(pdata->port_mode[1]))
-   clk_enable(tll->usbtll_p2_fck);
+   if (!tll->ch_clk[i])
+   continue;
+
+   r = clk_enable(tll->ch_clk

[PATCH v3 04/23] mfd: omap-usb-tll: Use devm_kzalloc/ioremap and clean up error path

2012-12-04 Thread Roger Quadros
Use devm_ variants of kzalloc() and ioremap(). Simplify the error path.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   37 +++--
 1 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index e67cafc..828207f 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -215,11 +215,10 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
 
dev_dbg(dev, "starting TI HSUSB TLL Controller\n");
 
-   tll = kzalloc(sizeof(struct usbtll_omap), GFP_KERNEL);
+   tll = devm_kzalloc(dev, sizeof(struct usbtll_omap), GFP_KERNEL);
if (!tll) {
dev_err(dev, "Memory allocation failed\n");
-   ret = -ENOMEM;
-   goto end;
+   return -ENOMEM;
}
 
spin_lock_init(&tll->lock);
@@ -230,28 +229,21 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
if (IS_ERR(tll->usbtll_p1_fck)) {
ret = PTR_ERR(tll->usbtll_p1_fck);
dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret);
-   goto err_tll;
+   return ret;
}
 
tll->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk");
if (IS_ERR(tll->usbtll_p2_fck)) {
ret = PTR_ERR(tll->usbtll_p2_fck);
dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret);
-   goto err_usbtll_p1_fck;
+   goto err_p2_fck;
}
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(dev, "usb tll get resource failed\n");
-   ret = -ENODEV;
-   goto err_usbtll_p2_fck;
-   }
-
-   base = ioremap(res->start, resource_size(res));
+   base = devm_request_and_ioremap(dev, res);
if (!base) {
-   dev_err(dev, "TLL ioremap failed\n");
-   ret = -ENOMEM;
-   goto err_usbtll_p2_fck;
+   ret = -EADDRNOTAVAIL;
+   goto err_res;
}
 
platform_set_drvdata(pdev, tll);
@@ -323,23 +315,17 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
}
 
spin_unlock_irqrestore(&tll->lock, flags);
-   iounmap(base);
pm_runtime_put_sync(dev);
tll_pdev = pdev;
-   if (!ret)
-   goto end;
-   pm_runtime_disable(dev);
 
-err_usbtll_p2_fck:
+   return 0;
+
+err_res:
clk_put(tll->usbtll_p2_fck);
 
-err_usbtll_p1_fck:
+err_p2_fck:
clk_put(tll->usbtll_p1_fck);
 
-err_tll:
-   kfree(tll);
-
-end:
return ret;
 }
 
@@ -356,7 +342,6 @@ static int __devexit usbtll_omap_remove(struct 
platform_device *pdev)
clk_put(tll->usbtll_p2_fck);
clk_put(tll->usbtll_p1_fck);
pm_runtime_disable(&pdev->dev);
-   kfree(tll);
return 0;
 }
 
-- 
1.7.4.1

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


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

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

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   20 
 1 files changed, 12 insertions(+), 8 deletions(-)

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

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


[PATCH v3 08/23] mfd: omap-usb-tll: Fix error message

2012-12-04 Thread Roger Quadros
omap_enable/disable_tll() can fail if TLL device is not
initialized. It could be due to multiple reasons and not only
due to missing platform data.

Also make local variables static and use 'struct device *'
instead of 'struct platform_device *' for global reference.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   21 -
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 8b596e0..38d0532 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -109,8 +109,8 @@ struct usbtll_omap {
 
 /*-*/
 
-const char usbtll_driver_name[] = USBTLL_DRIVER_NAME;
-struct platform_device *tll_pdev;
+static const char usbtll_driver_name[] = USBTLL_DRIVER_NAME;
+static struct device   *tll_dev;
 
 /*-*/
 
@@ -334,7 +334,8 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
 
spin_unlock_irqrestore(&tll->lock, flags);
pm_runtime_put_sync(dev);
-   tll_pdev = pdev;
+   /* only after this can omap_tll_enable/disable work */
+   tll_dev = dev;
 
return 0;
 
@@ -356,6 +357,8 @@ static int __devexit usbtll_omap_remove(struct 
platform_device *pdev)
struct usbtll_omap *tll = platform_get_drvdata(pdev);
int i;
 
+   tll_dev = NULL;
+
for (i = 0; i < tll->nch; i++)
clk_put(tll->ch_clk[i]);
 
@@ -435,21 +438,21 @@ static struct platform_driver usbtll_omap_driver = {
 
 int omap_tll_enable(void)
 {
-   if (!tll_pdev) {
-   pr_err("missing omap usbhs tll platform_data\n");
+   if (!tll_dev) {
+   pr_err("%s: OMAP USB TLL not initialized\n", __func__);
return  -ENODEV;
}
-   return pm_runtime_get_sync(&tll_pdev->dev);
+   return pm_runtime_get_sync(tll_dev);
 }
 EXPORT_SYMBOL_GPL(omap_tll_enable);
 
 int omap_tll_disable(void)
 {
-   if (!tll_pdev) {
-   pr_err("missing omap usbhs tll platform_data\n");
+   if (!tll_dev) {
+   pr_err("%s: OMAP USB TLL not initialized\n", __func__);
return  -ENODEV;
}
-   return pm_runtime_put_sync(&tll_pdev->dev);
+   return pm_runtime_put_sync(tll_dev);
 }
 EXPORT_SYMBOL_GPL(omap_tll_disable);
 
-- 
1.7.4.1

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


[PATCH v3 11/23] mfd: omap_usb_host: Avoid creating copy of platform_data

2012-12-04 Thread Roger Quadros
We can just hold the pointer to the platform data instead
of creating a copy of it.

Also get rid of the unnecessary missing platform data checks
in runtime_suspend/resume. We are already checking for missing
platform data in probe.

Signed-off-by: Roger Quadros 
Acked-by: Felipe Balbi 
---
 drivers/mfd/omap-usb-host.c |   30 --
 1 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index fe7906b..8b8f1da 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -103,7 +103,7 @@ struct usbhs_hcd_omap {
 
void __iomem*uhh_base;
 
-   struct usbhs_omap_platform_data platdata;
+   struct usbhs_omap_platform_data *pdata;
 
u32 usbhs_rev;
spinlock_t  lock;
@@ -195,8 +195,8 @@ static int omap_usbhs_alloc_children(struct platform_device 
*pdev)
int ret;
 
omap = platform_get_drvdata(pdev);
-   ehci_data = omap->platdata.ehci_data;
-   ohci_data = omap->platdata.ohci_data;
+   ehci_data = omap->pdata->ehci_data;
+   ohci_data = omap->pdata->ohci_data;
 
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ehci");
if (!res) {
@@ -279,16 +279,11 @@ static bool is_ohci_port(enum usbhs_omap_port_mode pmode)
 static int usbhs_runtime_resume(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
-   struct usbhs_omap_platform_data *pdata = &omap->platdata;
unsigned long   flags;
+   struct usbhs_omap_platform_data *pdata = omap->pdata;
 
dev_dbg(dev, "usbhs_runtime_resume\n");
 
-   if (!pdata) {
-   dev_dbg(dev, "missing platform_data\n");
-   return  -ENODEV;
-   }
-
omap_tll_enable();
spin_lock_irqsave(&omap->lock, flags);
 
@@ -311,16 +306,11 @@ static int usbhs_runtime_resume(struct device *dev)
 static int usbhs_runtime_suspend(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
-   struct usbhs_omap_platform_data *pdata = &omap->platdata;
unsigned long   flags;
+   struct usbhs_omap_platform_data *pdata = omap->pdata;
 
dev_dbg(dev, "usbhs_runtime_suspend\n");
 
-   if (!pdata) {
-   dev_dbg(dev, "missing platform_data\n");
-   return  -ENODEV;
-   }
-
spin_lock_irqsave(&omap->lock, flags);
 
if (is_ehci_tll_mode(pdata->port_mode[0]))
@@ -343,7 +333,7 @@ static int usbhs_runtime_suspend(struct device *dev)
 static void omap_usbhs_init(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
-   struct usbhs_omap_platform_data *pdata = &omap->platdata;
+   struct usbhs_omap_platform_data *pdata = omap->pdata;
unsigned long   flags;
unsignedreg;
 
@@ -450,7 +440,7 @@ static void omap_usbhs_init(struct device *dev)
 static void omap_usbhs_deinit(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
-   struct usbhs_omap_platform_data *pdata = &omap->platdata;
+   struct usbhs_omap_platform_data *pdata = omap->pdata;
 
if (pdata->ehci_data->phy_reset) {
if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
@@ -491,11 +481,7 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
 
spin_lock_init(&omap->lock);
 
-   for (i = 0; i < OMAP3_HS_USB_PORTS; i++)
-   omap->platdata.port_mode[i] = pdata->port_mode[i];
-
-   omap->platdata.ehci_data = pdata->ehci_data;
-   omap->platdata.ohci_data = pdata->ohci_data;
+   omap->pdata = pdata;
 
pm_runtime_enable(dev);
 
-- 
1.7.4.1

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


[PATCH v3 10/23] mfd: omap-usb-tll: Add OMAP5 revision and HSIC support

2012-12-04 Thread Roger Quadros
The TLL module on OMAP5 has 3 channels.
HSIC mode requires the TLL channel to be in Transparent UTMI mode.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 7b4afd0..ecc6a62 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -54,10 +54,13 @@
 
 #defineOMAP_TLL_CHANNEL_CONF(num)  (0x040 + 0x004 
* num)
 #define OMAP_TLL_CHANNEL_CONF_FSLSMODE_SHIFT   24
+#define OMAP_TLL_CHANNEL_CONF_DRVVBUS  (1 << 16)
+#define OMAP_TLL_CHANNEL_CONF_CHRGVBUS (1 << 15)
 #defineOMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF(1 << 11)
 #defineOMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10)
 #defineOMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE  (1 << 9)
 #defineOMAP_TLL_CHANNEL_CONF_ULPIDDRMODE   (1 << 8)
+#define OMAP_TLL_CHANNEL_CONF_MODE_TRANSPARENT_UTMI(2 << 1)
 #define OMAP_TLL_CHANNEL_CONF_CHANMODE_FSLS(1 << 1)
 #defineOMAP_TLL_CHANNEL_CONF_CHANEN(1 << 0)
 
@@ -92,6 +95,7 @@
 #define OMAP_USBTLL_REV1   0x0015  /* OMAP3 */
 #define OMAP_USBTLL_REV2   0x0018  /* OMAP 3630 */
 #define OMAP_USBTLL_REV3   0x0004  /* OMAP4 */
+#define OMAP_USBTLL_REV4   0x0006  /* OMAP5 */
 
 #define is_ehci_tll_mode(x)(x == OMAP_EHCI_PORT_MODE_TLL)
 
@@ -242,6 +246,7 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
ver =  usbtll_read(base, OMAP_USBTLL_REVISION);
switch (ver) {
case OMAP_USBTLL_REV1:
+   case OMAP_USBTLL_REV4:
tll->nch = OMAP_TLL_CHANNEL_COUNT;
break;
case OMAP_USBTLL_REV2:
@@ -310,6 +315,15 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
reg &= ~(OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE
| OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF
| OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE);
+   } else if (pdata->port_mode[i] ==
+   OMAP_EHCI_PORT_MODE_HSIC) {
+   /*
+* HSIC Mode requires UTMI port configurations
+*/
+   reg |= OMAP_TLL_CHANNEL_CONF_DRVVBUS
+| OMAP_TLL_CHANNEL_CONF_CHRGVBUS
+| OMAP_TLL_CHANNEL_CONF_MODE_TRANSPARENT_UTMI
+| OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF;
} else {
continue;
}
-- 
1.7.4.1

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


[PATCH v3 12/23] mfd: omap-usb-host: Use devm_kzalloc() and devm_request_and_ioremap()

2012-12-04 Thread Roger Quadros
Use devm_ variants of kzalloc and ioremap. Also clean up error path.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-host.c |   36 +---
 1 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 8b8f1da..13a3e8c 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -468,17 +468,20 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
 
if (!pdata) {
dev_err(dev, "Missing platform data\n");
-   ret = -ENOMEM;
-   goto end_probe;
+   return -ENODEV;
}
 
-   omap = kzalloc(sizeof(*omap), GFP_KERNEL);
+   omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL);
if (!omap) {
dev_err(dev, "Memory allocation failed\n");
-   ret = -ENOMEM;
-   goto end_probe;
+   return -ENOMEM;
}
 
+   res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh");
+   omap->uhh_base = devm_request_and_ioremap(dev, res);
+   if (!omap->uhh_base)
+   return -EADDRNOTAVAIL;
+
spin_lock_init(&omap->lock);
 
omap->pdata = pdata;
@@ -576,20 +579,6 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
"failed error:%d\n", ret);
}
 
-   res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh");
-   if (!res) {
-   dev_err(dev, "UHH EHCI get resource failed\n");
-   ret = -ENODEV;
-   goto err_init_60m_fclk;
-   }
-
-   omap->uhh_base = ioremap(res->start, resource_size(res));
-   if (!omap->uhh_base) {
-   dev_err(dev, "UHH ioremap failed\n");
-   ret = -ENOMEM;
-   goto err_init_60m_fclk;
-   }
-
platform_set_drvdata(pdev, omap);
 
omap_usbhs_init(dev);
@@ -599,13 +588,10 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
goto err_alloc;
}
 
-   goto end_probe;
+   return 0;
 
 err_alloc:
omap_usbhs_deinit(&pdev->dev);
-   iounmap(omap->uhh_base);
-
-err_init_60m_fclk:
clk_put(omap->init_60m_fclk);
 
 err_usbhost_p2_fck:
@@ -629,9 +615,7 @@ err_utmi_p1_fck:
 err_end:
clk_put(omap->ehci_logic_fck);
pm_runtime_disable(dev);
-   kfree(omap);
 
-end_probe:
return ret;
 }
 
@@ -646,7 +630,6 @@ static int __devexit usbhs_omap_remove(struct 
platform_device *pdev)
struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
 
omap_usbhs_deinit(&pdev->dev);
-   iounmap(omap->uhh_base);
clk_put(omap->init_60m_fclk);
clk_put(omap->usbhost_p2_fck);
clk_put(omap->usbhost_p1_fck);
@@ -656,7 +639,6 @@ static int __devexit usbhs_omap_remove(struct 
platform_device *pdev)
clk_put(omap->utmi_p1_fck);
clk_put(omap->ehci_logic_fck);
pm_runtime_disable(&pdev->dev);
-   kfree(omap);
 
return 0;
 }
-- 
1.7.4.1

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


[PATCH v3 13/23] mfd: omap-usb-host: know about number of ports from revision register

2012-12-04 Thread Roger Quadros
The revision register should tell us how many ports are present.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-host.c |   32 +++-
 1 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 13a3e8c..9c23a08 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -92,6 +92,8 @@
 
 
 struct usbhs_hcd_omap {
+   int nports;
+
struct clk  *xclk60mhsp1_ck;
struct clk  *xclk60mhsp2_ck;
struct clk  *utmi_p1_fck;
@@ -354,8 +356,6 @@ static void omap_usbhs_init(struct device *dev)
 
pm_runtime_get_sync(dev);
spin_lock_irqsave(&omap->lock, flags);
-   omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
-   dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
 
reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG);
/* setup ULPI bypass and burst configurations */
@@ -488,8 +488,32 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
 
pm_runtime_enable(dev);
 
+   platform_set_drvdata(pdev, omap);
+   pm_runtime_get_sync(dev);
 
-   for (i = 0; i < OMAP3_HS_USB_PORTS; i++)
+   omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
+
+   /* we need to call runtime suspend before we update omap->nports
+* to prevent unbalanced clk_disable()
+*/
+   pm_runtime_put_sync(dev);
+
+   switch (omap->usbhs_rev) {
+   case OMAP_USBHS_REV1:
+   omap->nports = 3;
+   break;
+   case OMAP_USBHS_REV2:
+   omap->nports = 2;
+   break;
+   default:
+   omap->nports = OMAP3_HS_USB_PORTS;
+   dev_dbg(dev,
+ "USB HOST Rev : 0x%d not recognized, assuming %d ports\n",
+  omap->usbhs_rev, omap->nports);
+   break;
+   }
+
+   for (i = 0; i < omap->nports; i++)
if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) ||
is_ehci_hsic_mode(i)) {
omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck");
@@ -579,8 +603,6 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
"failed error:%d\n", ret);
}
 
-   platform_set_drvdata(pdev, omap);
-
omap_usbhs_init(dev);
ret = omap_usbhs_alloc_children(pdev);
if (ret) {
-- 
1.7.4.1

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


[PATCH v3 14/23] mfd: omap-usb-host: override number of ports from platform data

2012-12-04 Thread Roger Quadros
Both OMAP4 and 5 exhibit the same revision ID in the REVISION register
but they have different number of ports i.e. 2 and 3 respectively.
So we can't rely on REVISION register for number of ports on OMAP5
and depend on platform data (or device tree) instead.

Signed-off-by: Roger Quadros 
---
 arch/arm/mach-omap2/usb-host.c |1 +
 arch/arm/mach-omap2/usb.h  |1 +
 drivers/mfd/omap-usb-host.c|   34 +++
 include/linux/platform_data/usb-omap.h |1 +
 4 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c
index 2e44e8a..ee8c473 100644
--- a/arch/arm/mach-omap2/usb-host.c
+++ b/arch/arm/mach-omap2/usb-host.c
@@ -504,6 +504,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data 
*pdata)
ohci_data.es2_compatibility = pdata->es2_compatibility;
usbhs_data.ehci_data = &ehci_data;
usbhs_data.ohci_data = &ohci_data;
+   usbhs_data.nports = pdata->nports;
 
if (cpu_is_omap34xx()) {
setup_ehci_io_mux(pdata->port_mode);
diff --git a/arch/arm/mach-omap2/usb.h b/arch/arm/mach-omap2/usb.h
index 9b986ea..7dc0f04 100644
--- a/arch/arm/mach-omap2/usb.h
+++ b/arch/arm/mach-omap2/usb.h
@@ -54,6 +54,7 @@
 #define USBPHY_DATA_POLARITY   (1 << 23)
 
 struct usbhs_omap_board_data {
+   int nports;
enum usbhs_omap_port_mode   port_mode[OMAP3_HS_USB_PORTS];
 
/* have to be valid if phy_reset is true and portx is in phy mode */
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 9c23a08..714b2f1 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -498,19 +498,27 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
 */
pm_runtime_put_sync(dev);
 
-   switch (omap->usbhs_rev) {
-   case OMAP_USBHS_REV1:
-   omap->nports = 3;
-   break;
-   case OMAP_USBHS_REV2:
-   omap->nports = 2;
-   break;
-   default:
-   omap->nports = OMAP3_HS_USB_PORTS;
-   dev_dbg(dev,
- "USB HOST Rev : 0x%d not recognized, assuming %d ports\n",
-  omap->usbhs_rev, omap->nports);
-   break;
+   /*
+* If platform data contains nports then use that
+* else make out number of ports from USBHS revision
+*/
+   if (pdata->nports) {
+   omap->nports = pdata->nports;
+   } else {
+   switch (omap->usbhs_rev) {
+   case OMAP_USBHS_REV1:
+   omap->nports = 3;
+   break;
+   case OMAP_USBHS_REV2:
+   omap->nports = 2;
+   break;
+   default:
+   omap->nports = OMAP3_HS_USB_PORTS;
+   dev_dbg(dev,
+   "USB HOST Rev:0x%d not recognized, assuming %d ports\n",
+   omap->usbhs_rev, omap->nports);
+   break;
+   }
}
 
for (i = 0; i < omap->nports; i++)
diff --git a/include/linux/platform_data/usb-omap.h 
b/include/linux/platform_data/usb-omap.h
index ef65b67..57707c7 100644
--- a/include/linux/platform_data/usb-omap.h
+++ b/include/linux/platform_data/usb-omap.h
@@ -55,6 +55,7 @@ struct ohci_hcd_omap_platform_data {
 };
 
 struct usbhs_omap_platform_data {
+   int nports;
enum usbhs_omap_port_mode   port_mode[OMAP3_HS_USB_PORTS];
 
struct ehci_hcd_omap_platform_data  *ehci_data;
-- 
1.7.4.1

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


[PATCH v3 15/23] mfd: omap-usb-host: cleanup clock management code

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

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

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-host.c |  159 ++-
 1 files changed, 80 insertions(+), 79 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 714b2f1..6294f13 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -93,13 +93,10 @@
 
 struct usbhs_hcd_omap {
int nports;
+   struct clk  **utmi_clk;
 
struct clk  *xclk60mhsp1_ck;
struct clk  *xclk60mhsp2_ck;
-   struct clk  *utmi_p1_fck;
-   struct clk  *usbhost_p1_fck;
-   struct clk  *utmi_p2_fck;
-   struct clk  *usbhost_p2_fck;
struct clk  *init_60m_fclk;
struct clk  *ehci_logic_fck;
 
@@ -283,6 +280,7 @@ static int usbhs_runtime_resume(struct device *dev)
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
unsigned long   flags;
struct usbhs_omap_platform_data *pdata = omap->pdata;
+   int i, r;
 
dev_dbg(dev, "usbhs_runtime_resume\n");
 
@@ -292,13 +290,18 @@ static int usbhs_runtime_resume(struct device *dev)
if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck))
clk_enable(omap->ehci_logic_fck);
 
-   if (is_ehci_tll_mode(pdata->port_mode[0]))
-   clk_enable(omap->usbhost_p1_fck);
-   if (is_ehci_tll_mode(pdata->port_mode[1]))
-   clk_enable(omap->usbhost_p2_fck);
-
-   clk_enable(omap->utmi_p1_fck);
-   clk_enable(omap->utmi_p2_fck);
+   for (i = 0; i < omap->nports; i++) {
+   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   if (omap->utmi_clk[i]) {
+   r = clk_enable(omap->utmi_clk[i]);
+   if (r) {
+   dev_err(dev,
+"Can't enable port %d clk : %d\n",
+i, r);
+   }
+   }
+   }
+   }
 
spin_unlock_irqrestore(&omap->lock, flags);
 
@@ -310,18 +313,18 @@ static int usbhs_runtime_suspend(struct device *dev)
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
unsigned long   flags;
struct usbhs_omap_platform_data *pdata = omap->pdata;
+   int i;
 
dev_dbg(dev, "usbhs_runtime_suspend\n");
 
spin_lock_irqsave(&omap->lock, flags);
 
-   if (is_ehci_tll_mode(pdata->port_mode[0]))
-   clk_disable(omap->usbhost_p1_fck);
-   if (is_ehci_tll_mode(pdata->port_mode[1]))
-   clk_disable(omap->usbhost_p2_fck);
-
-   clk_disable(omap->utmi_p2_fck);
-   clk_disable(omap->utmi_p1_fck);
+   for (i = 0; i < omap->nports; i++) {
+   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   if (omap->utmi_clk[i])
+   clk_disable(omap->utmi_clk[i]);
+   }
+   }
 
if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck))
clk_disable(omap->ehci_logic_fck);
@@ -465,6 +468,7 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
struct resource *res;
int ret = 0;
int i;
+   boolneed_logic_fck;
 
if (!pdata) {
dev_err(dev, "Missing platform data\n");
@@ -521,76 +525,79 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
}
}
 
-   for (i = 0; i < omap->nports; i++)
+   i = sizeof(struct clk *) * omap->nports;
+   omap->utmi_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+   if (!omap->utmi_clk) {
+   dev_err(dev, "Memory allocation failed\n");
+   ret = -ENOMEM;
+   goto err_mem;
+   }
+
+   need_logic_fck = false;
+   for (i = 0; i < omap->nports; i++) {
if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) ||
-   is_ehci_hsic_mode(i)) {
-   omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck");
-   if (IS_ERR(omap->ehci_logic_fck)) {
-   ret = PTR_ERR(omap->ehci_logic_fck);
-   dev_warn(dev, "ehci_logic_fck failed:%d\n",
-ret);
-   }
-   break;
-   }
+   is_ehci_hsic_

[PATCH v3 09/23] mfd: omap-usb-tll: serialize access to TLL device

2012-12-04 Thread Roger Quadros
Get rid of the unnecessary spin_lock_irqsave/restore() as there is
no interrupt handler for this driver. Instead we serialize access
to tll_dev using a global spinlock.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   53 ++-
 1 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 38d0532..7b4afd0 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -103,14 +103,13 @@ struct usbtll_omap {
int nch;/* num. of channels */
struct usbtll_omap_platform_data*pdata;
struct clk  **ch_clk;
-   /* secure the register updates */
-   spinlock_t  lock;
 };
 
 /*-*/
 
 static const char usbtll_driver_name[] = USBTLL_DRIVER_NAME;
 static struct device   *tll_dev;
+static DEFINE_SPINLOCK(tll_lock);  /* serialize access to tll_dev */
 
 /*-*/
 
@@ -212,7 +211,6 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
struct resource *res;
struct usbtll_omap  *tll;
unsignedreg;
-   unsigned long   flags;
int ret = 0;
int i, ver;
bool needs_tll;
@@ -230,8 +228,6 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
return -ENODEV;
}
 
-   spin_lock_init(&tll->lock);
-
tll->pdata = pdata;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -243,8 +239,6 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
 
-   spin_lock_irqsave(&tll->lock, flags);
-
ver =  usbtll_read(base, OMAP_USBTLL_REVISION);
switch (ver) {
case OMAP_USBTLL_REV1:
@@ -262,8 +256,6 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
break;
}
 
-   spin_unlock_irqrestore(&tll->lock, flags);
-
tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll->nch]),
GFP_KERNEL);
if (!tll->ch_clk) {
@@ -272,8 +264,6 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
goto err_clk_alloc;
}
 
-   spin_lock_irqsave(&tll->lock, flags);
-
for (i = 0; i < tll->nch; i++) {
char clkname[] = "usb_tll_hs_usb_chx_clk";
struct clk *fck;
@@ -332,10 +322,11 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
}
}
 
-   spin_unlock_irqrestore(&tll->lock, flags);
pm_runtime_put_sync(dev);
/* only after this can omap_tll_enable/disable work */
+   spin_lock(&tll_lock);
tll_dev = dev;
+   spin_unlock(&tll_lock);
 
return 0;
 
@@ -357,7 +348,9 @@ static int __devexit usbtll_omap_remove(struct 
platform_device *pdev)
struct usbtll_omap *tll = platform_get_drvdata(pdev);
int i;
 
+   spin_lock(&tll_lock);
tll_dev = NULL;
+   spin_unlock(&tll_lock);
 
for (i = 0; i < tll->nch; i++)
clk_put(tll->ch_clk[i]);
@@ -370,13 +363,10 @@ static int usbtll_runtime_resume(struct device *dev)
 {
struct usbtll_omap  *tll = dev_get_drvdata(dev);
struct usbtll_omap_platform_data*pdata = tll->pdata;
-   unsigned long   flags;
int i;
 
dev_dbg(dev, "usbtll_runtime_resume\n");
 
-   spin_lock_irqsave(&tll->lock, flags);
-
for (i = 0; i < tll->nch; i++) {
if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
int r;
@@ -392,8 +382,6 @@ static int usbtll_runtime_resume(struct device *dev)
}
}
 
-   spin_unlock_irqrestore(&tll->lock, flags);
-
return 0;
 }
 
@@ -401,13 +389,10 @@ static int usbtll_runtime_suspend(struct device *dev)
 {
struct usbtll_omap  *tll = dev_get_drvdata(dev);
struct usbtll_omap_platform_data*pdata = tll->pdata;
-   unsigned long   flags;
int i;
 
dev_dbg(dev, "usbtll_runtime_suspend\n");
 
-   spin_lock_irqsave(&tll->lock, flags);
-
for (i = 0; i < tll->nch; i++) {
if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
if (tll->ch_clk[i])
@@ -415,8 +400,6 @@ static int usbtll_runtime_suspend(struct device *dev)
}
}
 
-   spin_unlock_irqrestore(&tll->lock, flags);
-

[PATCH v3 07/23] mfd: omap-usb-tll: Check for missing platform data in probe

2012-12-04 Thread Roger Quadros
No need to check for missing platform data in runtime_suspend/resume
as it makes more sense to do it in the probe function.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   15 +--
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 07370a3..8b596e0 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -225,6 +225,11 @@ static int __devinit usbtll_omap_probe(struct 
platform_device *pdev)
return -ENOMEM;
}
 
+   if (!pdata) {
+   dev_err(dev, "Platform data missing\n");
+   return -ENODEV;
+   }
+
spin_lock_init(&tll->lock);
 
tll->pdata = pdata;
@@ -367,11 +372,6 @@ static int usbtll_runtime_resume(struct device *dev)
 
dev_dbg(dev, "usbtll_runtime_resume\n");
 
-   if (!pdata) {
-   dev_dbg(dev, "missing platform_data\n");
-   return  -ENODEV;
-   }
-
spin_lock_irqsave(&tll->lock, flags);
 
for (i = 0; i < tll->nch; i++) {
@@ -403,11 +403,6 @@ static int usbtll_runtime_suspend(struct device *dev)
 
dev_dbg(dev, "usbtll_runtime_suspend\n");
 
-   if (!pdata) {
-   dev_dbg(dev, "missing platform_data\n");
-   return  -ENODEV;
-   }
-
spin_lock_irqsave(&tll->lock, flags);
 
for (i = 0; i < tll->nch; i++) {
-- 
1.7.4.1

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


[PATCH v3 16/23] ARM: OMAP2+: clock data: Merge utmi_px_gfclk into usb_host_hs_utmi_px_clk

2012-12-04 Thread Roger Quadros
There is no such clock as utmi_p1_gfclk. It is only a clock selector
bit to select th the parent of usb_host_hs_utmi_p1_clk.
So we get rid of utmi_p1_gfclk and utmi_p2_gfclk by merging them into
usb_host_hs_utmi_p1_clk and usb_host_hs_utmi_p2_clk respectively.

CC: Paul Walmsley 
CC: Rajendra Nayak 
CC: Benoit Cousson 

Signed-off-by: Roger Quadros 
---
 arch/arm/mach-omap2/cclock3xxx_data.c |2 -
 arch/arm/mach-omap2/cclock44xx_data.c |   47 +++--
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c 
b/arch/arm/mach-omap2/cclock3xxx_data.c
index bdf3948..5655414 100644
--- a/arch/arm/mach-omap2/cclock3xxx_data.c
+++ b/arch/arm/mach-omap2/cclock3xxx_data.c
@@ -3392,8 +3392,6 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL,   "usbhost_48m_fck", &usbhost_48m_fck, CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "usbhost_ick",  &usbhost_ick,   CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK("usbhs_omap",   "usbhost_ick",  &usbhost_ick,   CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
-   CLK(NULL,   "utmi_p1_gfclk",&dummy_ck,  CK_3XXX),
-   CLK(NULL,   "utmi_p2_gfclk",&dummy_ck,  CK_3XXX),
CLK(NULL,   "xclk60mhsp1_ck",   &dummy_ck,  CK_3XXX),
CLK(NULL,   "xclk60mhsp2_ck",   &dummy_ck,  CK_3XXX),
CLK(NULL,   "usb_host_hs_utmi_p1_clk",  &dummy_ck,  
CK_3XXX),
diff --git a/arch/arm/mach-omap2/cclock44xx_data.c 
b/arch/arm/mach-omap2/cclock44xx_data.c
index aa56c3e..74535fe 100644
--- a/arch/arm/mach-omap2/cclock44xx_data.c
+++ b/arch/arm/mach-omap2/cclock44xx_data.c
@@ -1366,31 +1366,52 @@ static struct clk_hw_omap usb_host_fs_fck_hw = {
 DEFINE_STRUCT_CLK(usb_host_fs_fck, usb_host_fs_fck_parent_names,
  usb_host_fs_fck_ops);
 
+static const struct clk_ops utmi_clk_ops = {
+   .enable = &omap2_dflt_clk_enable,
+   .disable= &omap2_dflt_clk_disable,
+   .is_enabled = &omap2_dflt_clk_is_enabled,
+   .recalc_rate= &omap2_clksel_recalc,
+   .get_parent = &omap2_clksel_find_parent_index,
+   .set_parent = &omap2_clksel_set_parent,
+};
+
 static const char *utmi_p1_gfclk_parents[] = {
"init_60m_fclk", "xclk60mhsp1_ck",
 };
 
-DEFINE_CLK_MUX(utmi_p1_gfclk, utmi_p1_gfclk_parents, NULL, 0x0,
-  OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
-  OMAP4430_CLKSEL_UTMI_P1_SHIFT, OMAP4430_CLKSEL_UTMI_P1_WIDTH,
-  0x0, NULL);
+static const struct clksel utmi_p1_clk_mux_sel[] = {
+   { .parent = &init_60m_fclk, .rates = div_1_0_rates },
+   { .parent = &xclk60mhsp1_ck, .rates = div_1_1_rates },
+   { .parent = NULL },
+};
 
-DEFINE_CLK_GATE(usb_host_hs_utmi_p1_clk, "utmi_p1_gfclk", &utmi_p1_gfclk, 0x0,
+/* Merged utmi_p1_gfclk into usb_host_hs_utmi_p1_clk */
+DEFINE_CLK_OMAP_MUX_GATE(usb_host_hs_utmi_p1_clk, "l3_init_clkdm",
+   utmi_p1_clk_mux_sel,
+   OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
+   OMAP4430_CLKSEL_UTMI_P1_MASK,
OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
-   OMAP4430_OPTFCLKEN_UTMI_P1_CLK_SHIFT, 0x0, NULL);
+   OMAP4430_OPTFCLKEN_UTMI_P1_CLK_SHIFT, NULL,
+   utmi_p1_gfclk_parents, utmi_clk_ops);
 
 static const char *utmi_p2_gfclk_parents[] = {
"init_60m_fclk", "xclk60mhsp2_ck",
 };
 
-DEFINE_CLK_MUX(utmi_p2_gfclk, utmi_p2_gfclk_parents, NULL, 0x0,
-  OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
-  OMAP4430_CLKSEL_UTMI_P2_SHIFT, OMAP4430_CLKSEL_UTMI_P2_WIDTH,
-  0x0, NULL);
+static const struct clksel utmi_p2_clk_mux_sel[] = {
+   { .parent = &init_60m_fclk, .rates = div_1_0_rates },
+   { .parent = &xclk60mhsp2_ck, .rates = div_1_1_rates },
+   { .parent = NULL },
+};
 
-DEFINE_CLK_GATE(usb_host_hs_utmi_p2_clk, "utmi_p2_gfclk", &utmi_p2_gfclk, 0x0,
+/* Merged utmi_p2_gfclk into usb_host_hs_utmi_p2_clk */
+DEFINE_CLK_OMAP_MUX_GATE(usb_host_hs_utmi_p2_clk, "l3_init_clkdm",
+   utmi_p2_clk_mux_sel,
+   OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
+   OMAP4430_CLKSEL_UTMI_P2_MASK,
OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
-   OMAP4430_OPTFCLKEN_UTMI_P2_CLK_SHIFT, 0x0, NULL);
+   OMAP4430_OPTFCLKEN_UTMI_P2_CLK_SHIFT, NULL,
+   utmi_p2_gfclk_parents, utmi_clk_ops);
 
 DEFINE_CLK_GATE(usb_host_hs_utmi_p3_clk, "init_60m_fclk", &init_60m_fclk, 0x0,
OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
@@ -1838,9 +1859,7 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "uart4_fck",&uart4_fck, 
CK_443X),
CLK(NULL,   "usb_host_fs_fck",  &usb_host_fs_fck,   
CK_443X),
CLK("usbhs_omap",   "fs_fck",   &usb_host_fs_fck,   
CK_443X),
-   CLK(NULL,   "utmi_p1_gfclk",&utmi_p1_gfclk, 

[PATCH v3 17/23] mfd: omap-usb-host: Manage HSIC clocks for HSIC mode

2012-12-04 Thread Roger Quadros
Enable the optional HSIC clocks (60MHz and 480MHz) for the ports
that are configured in HSIC mode.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-host.c |   77 +++---
 1 files changed, 71 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 6294f13..90dbd17 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -94,6 +94,8 @@
 struct usbhs_hcd_omap {
int nports;
struct clk  **utmi_clk;
+   struct clk  **hsic60m_clk;
+   struct clk  **hsic480m_clk;
 
struct clk  *xclk60mhsp1_ck;
struct clk  *xclk60mhsp2_ck;
@@ -291,7 +293,28 @@ static int usbhs_runtime_resume(struct device *dev)
clk_enable(omap->ehci_logic_fck);
 
for (i = 0; i < omap->nports; i++) {
-   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   switch (pdata->port_mode[i]) {
+   case OMAP_EHCI_PORT_MODE_HSIC:
+   if (omap->hsic60m_clk[i]) {
+   r = clk_enable(omap->hsic60m_clk[i]);
+   if (r) {
+   dev_err(dev,
+"Can't enable port %d hsic60m 
clk:%d\n",
+i, r);
+   }
+   }
+
+   if (omap->hsic480m_clk[i]) {
+   r = clk_enable(omap->hsic480m_clk[i]);
+   if (r) {
+   dev_err(dev,
+"Can't enable port %d hsic480m 
clk:%d\n",
+i, r);
+   }
+   }
+   /* Fall through as HSIC mode needs utmi_clk */
+
+   case OMAP_EHCI_PORT_MODE_TLL:
if (omap->utmi_clk[i]) {
r = clk_enable(omap->utmi_clk[i]);
if (r) {
@@ -300,6 +323,9 @@ static int usbhs_runtime_resume(struct device *dev)
 i, r);
}
}
+   break;
+   default:
+   break;
}
}
 
@@ -320,9 +346,21 @@ static int usbhs_runtime_suspend(struct device *dev)
spin_lock_irqsave(&omap->lock, flags);
 
for (i = 0; i < omap->nports; i++) {
-   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   switch (pdata->port_mode[i]) {
+   case OMAP_EHCI_PORT_MODE_HSIC:
+   if (omap->hsic60m_clk[i])
+   clk_disable(omap->hsic60m_clk[i]);
+
+   if (omap->hsic480m_clk[i])
+   clk_disable(omap->hsic480m_clk[i]);
+   /* Fall through as utmi_clks were used in HSIC mode */
+
+   case OMAP_EHCI_PORT_MODE_TLL:
if (omap->utmi_clk[i])
clk_disable(omap->utmi_clk[i]);
+   break;
+   default:
+   break;
}
}
 
@@ -527,7 +565,10 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
 
i = sizeof(struct clk *) * omap->nports;
omap->utmi_clk = devm_kzalloc(dev, i, GFP_KERNEL);
-   if (!omap->utmi_clk) {
+   omap->hsic480m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+   omap->hsic60m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+
+   if (!omap->utmi_clk || !omap->hsic480m_clk || !omap->hsic60m_clk) {
dev_err(dev, "Memory allocation failed\n");
ret = -ENOMEM;
goto err_mem;
@@ -571,7 +612,7 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
 
for (i = 0; i < omap->nports; i++) {
struct clk *pclk;
-   char clkname[] = "usb_host_hs_utmi_px_clk";
+   char clkname[] = "usb_host_hs_hsic480m_px_clk";
 
/* clock names are indexed from 1*/
snprintf(clkname, sizeof(clkname),
@@ -587,6 +628,24 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
clkname, PTR_ERR(pclk));
else
omap->utmi_clk[i] = pclk;
+
+   snprintf(clkname, sizeof(clkname),
+   "usb_host_hs_hsic480m_p%d_clk", i + 1);
+   pclk = clk_get(dev, clkname);
+   if (IS_ERR(pclk))
+   dev_dbg(dev, "Failed to get clock : %s : %ld\n",
+   clkname, PTR_ERR(pclk));
+   else
+   omap->hsic480m_clk[i] = pc

[PATCH v3 20/23] USB: ehci-omap: Don't free gpios that we didn't request

2012-12-04 Thread Roger Quadros
This driver does not request any gpios so don't free them.
Fixes L3 bus error on multiple modprobe/rmmod of ehci_hcd
with ehci-omap in use.

Signed-off-by: Roger Quadros 
---
 drivers/usb/host/ehci-omap.c |8 
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 0d5ac36..9f7441b 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -291,7 +291,6 @@ static int ehci_hcd_omap_remove(struct platform_device 
*pdev)
 {
struct device *dev  = &pdev->dev;
struct usb_hcd *hcd = dev_get_drvdata(dev);
-   struct ehci_hcd_omap_platform_data *pdata   = dev->platform_data;
 
usb_remove_hcd(hcd);
disable_put_regulator(dev->platform_data);
@@ -301,13 +300,6 @@ static int ehci_hcd_omap_remove(struct platform_device 
*pdev)
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
 
-   if (pdata->phy_reset) {
-   if (gpio_is_valid(pdata->reset_gpio_port[0]))
-   gpio_free(pdata->reset_gpio_port[0]);
-
-   if (gpio_is_valid(pdata->reset_gpio_port[1]))
-   gpio_free(pdata->reset_gpio_port[1]);
-   }
return 0;
 }
 
-- 
1.7.4.1

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


[PATCH v3 21/23] ARM: OMAP3: clock data: get rid of unused USB host clock aliases and dummies

2012-12-04 Thread Roger Quadros
We don't need multiple aliases for the OMAP USB host clocks and neither
the dummy clocks so remove them.

CC: Paul Walmsley 
CC: Rajendra Nayak 
CC: Benoit Cousson 

Signed-off-by: Roger Quadros 
---
 arch/arm/mach-omap2/cclock3xxx_data.c |   11 ---
 1 files changed, 0 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c 
b/arch/arm/mach-omap2/cclock3xxx_data.c
index 5655414..8b9d109 100644
--- a/arch/arm/mach-omap2/cclock3xxx_data.c
+++ b/arch/arm/mach-omap2/cclock3xxx_data.c
@@ -3289,8 +3289,6 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL,   "cpefuse_fck",  &cpefuse_fck,   CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "ts_fck",   &ts_fck,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "usbtll_fck",   &usbtll_fck,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
-   CLK("usbhs_omap",   "usbtll_fck",   &usbtll_fck,CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
-   CLK("usbhs_tll","usbtll_fck",   &usbtll_fck,CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
CLK(NULL,   "core_96m_fck", &core_96m_fck,  CK_3XXX),
CLK(NULL,   "mmchs3_fck",   &mmchs3_fck,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "mmchs2_fck",   &mmchs2_fck,CK_3XXX),
@@ -3327,8 +3325,6 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL,   "pka_ick",  &pka_ick,   CK_34XX | CK_36XX),
CLK(NULL,   "core_l4_ick",  &core_l4_ick,   CK_3XXX),
CLK(NULL,   "usbtll_ick",   &usbtll_ick,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
-   CLK("usbhs_omap",   "usbtll_ick",   &usbtll_ick,CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
-   CLK("usbhs_tll","usbtll_ick",   &usbtll_ick,CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
CLK("omap_hsmmc.2", "ick",  &mmchs3_ick,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "mmchs3_ick",   &mmchs3_ick,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "icr_ick",  &icr_ick,   CK_34XX | CK_36XX),
@@ -3391,15 +3387,8 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL,   "usbhost_120m_fck", &usbhost_120m_fck, CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "usbhost_48m_fck", &usbhost_48m_fck, CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "usbhost_ick",  &usbhost_ick,   CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
-   CLK("usbhs_omap",   "usbhost_ick",  &usbhost_ick,   CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
CLK(NULL,   "xclk60mhsp1_ck",   &dummy_ck,  CK_3XXX),
CLK(NULL,   "xclk60mhsp2_ck",   &dummy_ck,  CK_3XXX),
-   CLK(NULL,   "usb_host_hs_utmi_p1_clk",  &dummy_ck,  
CK_3XXX),
-   CLK(NULL,   "usb_host_hs_utmi_p2_clk",  &dummy_ck,  
CK_3XXX),
-   CLK("usbhs_omap",   "usb_tll_hs_usb_ch0_clk",   &dummy_ck,  
CK_3XXX),
-   CLK("usbhs_omap",   "usb_tll_hs_usb_ch1_clk",   &dummy_ck,  
CK_3XXX),
-   CLK("usbhs_tll","usb_tll_hs_usb_ch0_clk",   &dummy_ck,  
CK_3XXX),
-   CLK("usbhs_tll","usb_tll_hs_usb_ch1_clk",   &dummy_ck,  
CK_3XXX),
CLK(NULL,   "init_60m_fclk",&dummy_ck,  CK_3XXX),
CLK(NULL,   "usim_fck", &usim_fck,  CK_3430ES2PLUS | 
CK_36XX),
CLK(NULL,   "gpt1_fck", &gpt1_fck,  CK_3XXX),
-- 
1.7.4.1

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


[PATCH v3 23/23] mfd: omap-usb-host: Don't spam console on clk_set_parent failure

2012-12-04 Thread Roger Quadros
clk_set_parent is expected to fail on OMAP3 platforms. We don't
consider that as fatal so don't spam console.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-host.c |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 0bb54393..e5257dc 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -657,32 +657,32 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
}
 
if (is_ehci_phy_mode(pdata->port_mode[0])) {
-   /* for OMAP3 , the clk set paretn fails */
+   /* for OMAP3, clk_set_parent fails */
ret = clk_set_parent(omap->utmi_clk[0],
omap->xclk60mhsp1_ck);
if (ret != 0)
-   dev_err(dev, "xclk60mhsp1_ck set parent"
-   "failed error:%d\n", ret);
+   dev_dbg(dev, "xclk60mhsp1_ck set parent failed : %d\n",
+   ret);
} else if (is_ehci_tll_mode(pdata->port_mode[0])) {
ret = clk_set_parent(omap->utmi_clk[0],
omap->init_60m_fclk);
if (ret != 0)
-   dev_err(dev, "init_60m_fclk set parent"
-   "failed error:%d\n", ret);
+   dev_dbg(dev, "P0 init_60m_fclk set parent failed: %d\n",
+   ret);
}
 
if (is_ehci_phy_mode(pdata->port_mode[1])) {
ret = clk_set_parent(omap->utmi_clk[1],
omap->xclk60mhsp2_ck);
if (ret != 0)
-   dev_err(dev, "xclk60mhsp2_ck set parent"
-   "failed error:%d\n", ret);
+   dev_dbg(dev, "xclk60mhsp2_ck set parent failed : %d\n",
+   ret);
} else if (is_ehci_tll_mode(pdata->port_mode[1])) {
ret = clk_set_parent(omap->utmi_clk[1],
omap->init_60m_fclk);
if (ret != 0)
-   dev_err(dev, "init_60m_fclk set parent"
-   "failed error:%d\n", ret);
+   dev_dbg(dev, "P1 init_60m_fclk set parent failed: %d\n",
+   ret);
}
 
omap_usbhs_init(dev);
-- 
1.7.4.1

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


[PATCH v3 22/23] ARM: OMAP4: clock data: get rid of unused USB host clock aliases

2012-12-04 Thread Roger Quadros
We don't need multiple aliases for the OMAP USB host clocks so remove them.

CC: Paul Walmsley 
CC: Rajendra Nayak 
CC: Benoit Cousson 

Signed-off-by: Roger Quadros 
---
 arch/arm/mach-omap2/cclock44xx_data.c |8 +---
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/cclock44xx_data.c 
b/arch/arm/mach-omap2/cclock44xx_data.c
index 74535fe..5a27244 100644
--- a/arch/arm/mach-omap2/cclock44xx_data.c
+++ b/arch/arm/mach-omap2/cclock44xx_data.c
@@ -1858,7 +1858,6 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "uart3_fck",&uart3_fck, 
CK_443X),
CLK(NULL,   "uart4_fck",&uart4_fck, 
CK_443X),
CLK(NULL,   "usb_host_fs_fck",  &usb_host_fs_fck,   
CK_443X),
-   CLK("usbhs_omap",   "fs_fck",   &usb_host_fs_fck,   
CK_443X),
CLK(NULL,   "usb_host_hs_utmi_p1_clk",  
&usb_host_hs_utmi_p1_clk,   CK_443X),
CLK(NULL,   "usb_host_hs_utmi_p2_clk",  
&usb_host_hs_utmi_p2_clk,   CK_443X),
CLK(NULL,   "usb_host_hs_utmi_p3_clk",  
&usb_host_hs_utmi_p3_clk,   CK_443X),
@@ -1868,7 +1867,6 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "usb_host_hs_hsic480m_p2_clk",  
&usb_host_hs_hsic480m_p2_clk,   CK_443X),
CLK(NULL,   "usb_host_hs_func48mclk",   
&usb_host_hs_func48mclk,CK_443X),
CLK(NULL,   "usb_host_hs_fck",  &usb_host_hs_fck,   
CK_443X),
-   CLK("usbhs_omap",   "hs_fck",   &usb_host_hs_fck,   
CK_443X),
CLK(NULL,   "otg_60m_gfclk",&otg_60m_gfclk, 
CK_443X),
CLK(NULL,   "usb_otg_hs_xclk",  &usb_otg_hs_xclk,   
CK_443X),
CLK(NULL,   "usb_otg_hs_ick",   &usb_otg_hs_ick,
CK_443X),
@@ -1878,8 +1876,6 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "usb_tll_hs_usb_ch0_clk",   
&usb_tll_hs_usb_ch0_clk,CK_443X),
CLK(NULL,   "usb_tll_hs_usb_ch1_clk",   
&usb_tll_hs_usb_ch1_clk,CK_443X),
CLK(NULL,   "usb_tll_hs_ick",   &usb_tll_hs_ick,
CK_443X),
-   CLK("usbhs_omap",   "usbtll_ick",   &usb_tll_hs_ick,
CK_443X),
-   CLK("usbhs_tll","usbtll_ick",   &usb_tll_hs_ick,
CK_443X),
CLK(NULL,   "usim_ck",  &usim_ck,   
CK_443X),
CLK(NULL,   "usim_fclk",&usim_fclk, 
CK_443X),
CLK(NULL,   "usim_fck", &usim_fck,  
CK_443X),
@@ -1930,9 +1926,7 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "uart2_ick",&dummy_ck,  
CK_443X),
CLK(NULL,   "uart3_ick",&dummy_ck,  
CK_443X),
CLK(NULL,   "uart4_ick",&dummy_ck,  
CK_443X),
-   CLK("usbhs_omap",   "usbhost_ick",  &dummy_ck,  
CK_443X),
-   CLK("usbhs_omap",   "usbtll_fck",   &dummy_ck,  
CK_443X),
-   CLK("usbhs_tll","usbtll_fck",   &dummy_ck,  
CK_443X),
+   CLK(NULL,   "usbhost_ick",  &dummy_ck,  
CK_443X),
CLK("omap_wdt", "ick",  &dummy_ck,  
CK_443X),
CLK(NULL,   "timer_32k_ck", &sys_32k_ck,CK_443X),
/* TODO: Remove "omap_timer.X" aliases once DT migration is complete */
-- 
1.7.4.1

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


[PATCH v3 18/23] mfd: omap-usb-host: Get rid of unnecessary spinlock

2012-12-04 Thread Roger Quadros
The driver does not have an interrupt handler and
we don't really need a spinlock, so get rid of it.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-host.c |   16 
 1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 90dbd17..289b356 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -23,7 +23,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -107,7 +106,6 @@ struct usbhs_hcd_omap {
struct usbhs_omap_platform_data *pdata;
 
u32 usbhs_rev;
-   spinlock_t  lock;
 };
 /*-*/
 
@@ -280,14 +278,12 @@ static bool is_ohci_port(enum usbhs_omap_port_mode pmode)
 static int usbhs_runtime_resume(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
-   unsigned long   flags;
struct usbhs_omap_platform_data *pdata = omap->pdata;
int i, r;
 
dev_dbg(dev, "usbhs_runtime_resume\n");
 
omap_tll_enable();
-   spin_lock_irqsave(&omap->lock, flags);
 
if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck))
clk_enable(omap->ehci_logic_fck);
@@ -329,22 +325,17 @@ static int usbhs_runtime_resume(struct device *dev)
}
}
 
-   spin_unlock_irqrestore(&omap->lock, flags);
-
return 0;
 }
 
 static int usbhs_runtime_suspend(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
-   unsigned long   flags;
struct usbhs_omap_platform_data *pdata = omap->pdata;
int i;
 
dev_dbg(dev, "usbhs_runtime_suspend\n");
 
-   spin_lock_irqsave(&omap->lock, flags);
-
for (i = 0; i < omap->nports; i++) {
switch (pdata->port_mode[i]) {
case OMAP_EHCI_PORT_MODE_HSIC:
@@ -367,7 +358,6 @@ static int usbhs_runtime_suspend(struct device *dev)
if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck))
clk_disable(omap->ehci_logic_fck);
 
-   spin_unlock_irqrestore(&omap->lock, flags);
omap_tll_disable();
 
return 0;
@@ -377,7 +367,6 @@ static void omap_usbhs_init(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = omap->pdata;
-   unsigned long   flags;
unsignedreg;
 
dev_dbg(dev, "starting TI HSUSB Controller\n");
@@ -396,7 +385,6 @@ static void omap_usbhs_init(struct device *dev)
}
 
pm_runtime_get_sync(dev);
-   spin_lock_irqsave(&omap->lock, flags);
 
reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG);
/* setup ULPI bypass and burst configurations */
@@ -459,8 +447,6 @@ static void omap_usbhs_init(struct device *dev)
usbhs_write(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg);
dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg);
 
-   spin_unlock_irqrestore(&omap->lock, flags);
-
pm_runtime_put_sync(dev);
if (pdata->ehci_data->phy_reset) {
/* Hold the PHY in RESET for enough time till
@@ -524,8 +510,6 @@ static int __devinit usbhs_omap_probe(struct 
platform_device *pdev)
if (!omap->uhh_base)
return -EADDRNOTAVAIL;
 
-   spin_lock_init(&omap->lock);
-
omap->pdata = pdata;
 
pm_runtime_enable(dev);
-- 
1.7.4.1

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


[PATCH v3 19/23] mfd: omap-usb-host: clean up omap_usbhs_init()

2012-12-04 Thread Roger Quadros
We split initializing revision 1 and revision 2 into different
functions. Initialization is now done dynamically so that only
the number of ports available on the system are initialized.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-host.c |  122 +-
 1 files changed, 73 insertions(+), 49 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 289b356..0bb54393 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -363,6 +363,75 @@ static int usbhs_runtime_suspend(struct device *dev)
return 0;
 }
 
+static unsigned omap_usbhs_rev1_hostconfig(struct usbhs_hcd_omap *omap,
+   unsigned reg)
+{
+   struct usbhs_omap_platform_data *pdata = omap->pdata;
+   int i;
+
+   for (i = 0; i < omap->nports; i++) {
+   switch (pdata->port_mode[i]) {
+   case OMAP_USBHS_PORT_MODE_UNUSED:
+   reg &= ~(OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS << i);
+   break;
+   case OMAP_EHCI_PORT_MODE_PHY:
+   if (pdata->single_ulpi_bypass)
+   break;
+
+   if (i == 0)
+   reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
+   else
+   reg &= ~(OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS
+   << (i-1));
+   break;
+   default:
+   if (pdata->single_ulpi_bypass)
+   break;
+
+   if (i == 0)
+   reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
+   else
+   reg |= OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS
+   << (i-1);
+   break;
+   }
+   }
+
+   if (pdata->single_ulpi_bypass) {
+   /* bypass ULPI only if none of the ports use PHY mode */
+   reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
+
+   for (i = 0; i < omap->nports; i++) {
+   if (is_ehci_phy_mode(pdata->port_mode[i])) {
+   reg &= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
+   break;
+   }
+   }
+   }
+
+   return reg;
+}
+
+static unsigned omap_usbhs_rev2_hostconfig(struct usbhs_hcd_omap *omap,
+   unsigned reg)
+{
+   struct usbhs_omap_platform_data *pdata = omap->pdata;
+   int i;
+
+   for (i = 0; i < omap->nports; i++) {
+   /* Clear port mode fields for PHY mode */
+   reg &= ~(OMAP4_P1_MODE_CLEAR << 2 * i);
+
+   if (is_ehci_tll_mode(pdata->port_mode[i]) ||
+   (is_ohci_port(pdata->port_mode[i])))
+   reg |= OMAP4_P1_MODE_TLL << 2 * i;
+   else if (is_ehci_hsic_mode(pdata->port_mode[i]))
+   reg |= OMAP4_P1_MODE_HSIC << 2 * i;
+   }
+
+   return reg;
+}
+
 static void omap_usbhs_init(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
@@ -394,55 +463,10 @@ static void omap_usbhs_init(struct device *dev)
reg |= OMAP4_UHH_HOSTCONFIG_APP_START_CLK;
reg &= ~OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN;
 
-   if (is_omap_usbhs_rev1(omap)) {
-   if (pdata->port_mode[0] == OMAP_USBHS_PORT_MODE_UNUSED)
-   reg &= ~OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS;
-   if (pdata->port_mode[1] == OMAP_USBHS_PORT_MODE_UNUSED)
-   reg &= ~OMAP_UHH_HOSTCONFIG_P2_CONNECT_STATUS;
-   if (pdata->port_mode[2] == OMAP_USBHS_PORT_MODE_UNUSED)
-   reg &= ~OMAP_UHH_HOSTCONFIG_P3_CONNECT_STATUS;
-
-   /* Bypass the TLL module for PHY mode operation */
-   if (pdata->single_ulpi_bypass) {
-   dev_dbg(dev, "OMAP3 ES version <= ES2.1\n");
-   if (is_ehci_phy_mode(pdata->port_mode[0]) ||
-   is_ehci_phy_mode(pdata->port_mode[1]) ||
-   is_ehci_phy_mode(pdata->port_mode[2]))
-   reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
-   else
-   reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
-   } else {
-   dev_dbg(dev, "OMAP3 ES version > ES2.1\n");
-   if (is_ehci_phy_mode(pdata->port_mode[0]))
-   reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
-   else
-   reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
-   if (is_ehci_phy_mode(pdata->port_mode[1]))
-

Re: [PATCH 00/16] OMAP USB Host cleanup

2012-12-04 Thread Grazvydas Ignotas
On Tue, Nov 27, 2012 at 6:30 PM, Felipe Balbi  wrote:
> On Tue, Nov 27, 2012 at 04:42:47PM +0200, Roger Quadros wrote:
>> Kevin,
>>
>> I gave a quick look at the issue. It seems that the High Speed USB Host
>> module is kept in Software forced wakeup mode as a quick fix workaround
>> to a bunch of silicon erratas. And we do nothing on USB global suspend.
>> That's why CORE does not hit retention.
>>
>> If we runtime_suspend the USB host module on USB global suspend then it
>> will be put in Force Idle mode. This will allow CORE to hit retention
>> but then we will no longer be able to detect USB device connect events.
>>
>> So, till we have a better solution I will suggest to keep EHCI_HCD as a
>> module in omap2plus_defconfig.
>
> I guess that "better solution" would be I/O pads wakeup interrupts ? But
> I don't think that's already in mainline, is it ?

I believe there was attempt to mainline that but it was rejected by Tony:
http://marc.info/?l=linux-omap&m=134727428329745&w=2

Hopefully someone can come up with a suitable solution, not being able
to suspend and broken power saving with EHCI sucks :(

-- 
Gražvydas
--
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


lsusb no output problem

2012-12-04 Thread Deniz Eren
Hello;

After upgrading my machine from kernel 2.6.18 to kernel 3.5.3 `lsusb`
started to not giving output.

With hwdata-0.213.26-1.el5 package installed:
$ lsusb
Protocol spec without prior Class and Subclass spec at line 4297

Gave this error and nothing more.


After downgrading hwdata to hwdata-0.213.16-1.el5.noarch.rpm:

$ lsusb

Started to give no output.

I am using usbutils-0.71-2.1. Can you offer a solution?

Thanks in advance.

--
Deniz Eren
--
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] USB: ehci-fsl: fix regression on mpc5121e

2012-12-04 Thread Alan Stern
On Tue, 4 Dec 2012, Anatolij Gustschin wrote:

> mpc5121e doesn't have system interface registers, accessing this
> register address space cause the machine check exception and a
> kernel crash:
> 
> ...
> Machine check in kernel mode.
> Caused by (from SRR1=49030): Transfer error ack signal
> Oops: Machine check, sig: 7 [#1]
> MPC5121 ADS
> Modules linked in:
> NIP: c025fd60 LR: c0265bb4 CTR: 
> REGS: df82dac0 TRAP: 0200   Not tainted
> (3.7.0-rc7-00641-g81e6c91)
> MSR: 00049030   CR: 42002024  XER: 2000
> TASK = df824b70[1] 'swapper' THREAD: df82c000
> GPR00:  df82db70 df824b70 df3ed0f0 0003   
> GPR08: 0020 3200 c03550ec 2000 22002028  c0003f5c 
> GPR16:       c0423898 c045
> GPR24: 0077 0002 e5086180 1c000c00 e5086000 df33ec00 0003 df34e000
> NIP [c025fd60] ehci_fsl_setup_phy+0xd0/0x354
> LR [c0265bb4] ehci_fsl_setup+0x220/0x284
> ...
> 
> Fix it by checking 'have_sysif_regs' flag before register access.
> 
> Signed-off-by: Anatolij Gustschin 

Acked-by: 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: lsusb no output problem

2012-12-04 Thread Deniz Eren
My strace output is like below. `lsusb` looks for /dev/bus/usb and
since it does not exist gives error. So I created symlink to
/sys/bus/usb but it did not give any output too.

execve("/sbin/lsusb", ["lsusb"], [/* 22 vars */]) = 0
brk(0)  = 0x888e000
access("/etc/ld.so.preload", R_OK)  = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)  = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=24248, ...}) = 0
mmap2(NULL, 24248, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb77ee000
close(3)= 0
open("/usr/lib/libusb-0.1.so.4", O_RDONLY) = 3
read(3, 
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240\21\0\0004\0\0\0"...,
512) = 512
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb77ed000
fstat64(3, {st_mode=S_IFREG|0755, st_size=31468, ...}) = 0
mmap2(NULL, 30204, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0xb77e5000
mmap2(0xb77eb000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6) = 0xb77eb000
close(3)= 0
open("/usr/lib/libz.so.1", O_RDONLY)= 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\300uL\0004\0\0\0"...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=75028, ...}) = 0
mmap2(0x4c6000, 76400, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0x4c6000
mmap2(0x4d8000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x11) = 0x4d8000
close(3)= 0
open("/lib/libc.so.6", O_RDONLY)= 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340?3\0004\0\0\0"...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1693812, ...}) = 0
mmap2(0x31e000, 1410500, PROT_READ|PROT_EXEC,
MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x31e000
mmap2(0x471000, 12288, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x153) = 0x471000
mmap2(0x474000, 9668, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x474000
close(3)= 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb77e4000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb77e46c0,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0x471000, 8192, PROT_READ) = 0
mprotect(0x315000, 4096, PROT_READ) = 0
munmap(0xb77ee000, 24248)   = 0
brk(0)  = 0x888e000
brk(0x88af000)  = 0x88af000
open("/usr/share/usb.ids", O_RDONLY)= 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=367327, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb77f3000
read(3, "#\n#\tList of USB ID's\n#\n#\tMaintai"..., 16384) = 16384
_llseek(3, 0, [16384], SEEK_CUR)= 0
read(3, "2  Matrix Orbital MX4 or MX5\n\tfa"..., 4096) = 4096
read(3, "4  Digital Camera\n\t05a5  Digital"..., 4096) = 4096
read(3, "edia\n\t5521  Keyboard\n\t6481  16-b"..., 4096) = 4096
read(3, " AVALON Parent\n\t0104  ADL Re-Fla"..., 4096) = 4096
read(3, "  Z12 Color Jetprinter\n\t0017  Z3"..., 4096) = 4096
read(3, "t Module\n044f  ThrustMaster, Inc"..., 4096) = 4096
read(3, "5d  Nortel Networks, Ltd\n045e  M"..., 4096) = 4096
read(3, "8  Windows Powered Pocket PC 200"..., 4096) = 4096
read(3, " Colorado 600u Scanner\n\t0345  Vi"..., 4096) = 4096
read(3, "kCam for Notebooks\n\t092b  Labtec"..., 4096) = 4096
read(3, "dless Desktop S510\n\tc50d  Cordle"..., 4096) = 4096
read(3, "C5 Digital Media Camera (PC cont"..., 4096) = 4096
read(3, "ader\n\t0503  SmartMedia Card Read"..., 4096) = 4096
read(3, "\t6200  MP3 Player\n\t7500  Hi-Spee"..., 4096) = 4096
read(3, "noScan 9950F\n\t221b  CanoScan 420"..., 4096) = 4096
brk(0x88d)  = 0x88d
read(3, "220\n\t30be  CP-330\n\t30bf  Digital"..., 4096) = 4096
read(3, "30  MyIRC Remote Receiver\n\t0306 "..., 4096) = 4096
read(3, "3  iKey Token\n\t1204  iKey Token\n"..., 4096) = 4096
read(3, "12f  FinePix Digital Camera 0307"..., 4096) = 4096
read(3, "one\n\t91a3  922SH Internet Machin"..., 4096) = 4096
read(3, "0\n\t5003  YP-700\n\t5004  YP-30\n\t50"..., 4096) = 4096
read(3, "100C\n\t0110  MFC4800 Scanner\n\t011"..., 4096) = 4096
read(3, "e1  n10 Handheld Sync\n\t16e2  n20"..., 4096) = 4096
read(3, "le Storage Gadget\n\ta4a6  Linux-U"..., 4096) = 4096
read(3, "Drive\n\t002d  MSAC-US1 MemoryStic"..., 4096) = 4096
read(3, "0 I/F A/D Converter\n0557  ATEN I"..., 4096) = 4096
read(3, "\t5003  UC-SGT\n\t5004  UC-SGT\n\tabc"..., 4096) = 4096
read(3, " IP\n\t5601  AVM FRITZ!WLAN Stick\n"..., 4096) = 4096
read(3, "492  Hub\n\t6232  Hi-Speed 16-in-1"..., 4096) = 4096
read(3, "Storage Adapter V2\n\t5901  Smart "..., 4096) = 4096
read(3, "lio RR30 / Medion MD 6126 Camera"..., 4096) = 4096
read(3, "200  JumpDrive 2.0 Pro\n\t0300  Ju"..., 4096) = 4096
read(3, "s Co., Ltd\n\t0101  DA-Port DAC\n05"..., 4096) = 4096
read(3, "ng Kai Industrial Co., Ltd\n063e "...,

Re: lsusb no output problem

2012-12-04 Thread Greg KH
On Tue, Dec 04, 2012 at 05:10:45PM +0200, Deniz Eren wrote:
> Hello;
> 
> After upgrading my machine from kernel 2.6.18 to kernel 3.5.3 `lsusb`
> started to not giving output.
> 
> With hwdata-0.213.26-1.el5 package installed:
> $ lsusb
> Protocol spec without prior Class and Subclass spec at line 4297
> 
> Gave this error and nothing more.
> 
> 
> After downgrading hwdata to hwdata-0.213.16-1.el5.noarch.rpm:
> 
> $ lsusb
> 
> Started to give no output.
> 
> I am using usbutils-0.71-2.1. Can you offer a solution?

Yes, please upgrade your very old version of usbutils and things should
start working again.  The hwdata package isn't the problem here at all.

Please let us know if that doesn't work,

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: USB issue with kernel 3.6

2012-12-04 Thread Alan Stern
On Mon, 3 Dec 2012, Piergiorgio Sartor wrote:

> Hi Alan,
> 
> I updated the bug report with dmesg dump.
> 
> I hope this time it is correct...

Yes, it is.  It shows a couple of strange things; I need more 
information.

Below is a new test patch; try running the test with this patch in 
place of the previous one.  I don't need to see the usbmon trace, just 
the dmesg log.  And not even all of that; just the part from "alan 
start" to "alan end" -- this will be near the end of the log.

Also, what output do you get from "lspci -v -s b.1"?

Alan Stern



Index: usb-3.7/drivers/usb/host/ehci-hcd.c
===
--- usb-3.7.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.7/drivers/usb/host/ehci-hcd.c
@@ -825,8 +825,10 @@ dead:
bh = 0;
}
 
-   if (bh)
+   if (bh) {
+   ehci->last_scan_time = jiffies;
ehci_work (ehci);
+   }
spin_unlock (&ehci->lock);
if (pcd_status)
usb_hcd_poll_rh_status(hcd);
@@ -884,6 +886,53 @@ static int ehci_urb_enqueue (
}
 }
 
+static void alan_debug(struct ehci_hcd *ehci, struct urb *urb, struct ehci_qh 
*qh)
+{
+   static int done;
+   struct ehci_qh *qh2;
+   struct ehci_qtd *td;
+   char label[24];
+
+   if (done)
+   return;
+   if (urb->transfer_buffer_length != 31) {
+   ehci_dbg(ehci, "unlink urb len %d\n", 
urb->transfer_buffer_length);
+   return;
+   }
+
+   ehci->alan_urb = urb;
+   done = 1;
+   ehci_dbg(ehci, "alan start  cur time %lu last scan %lu\n",
+   jiffies, ehci->last_scan_time);
+   ehci_dbg(ehci, "command %x cmd reg %x io watchdog %d async count %d\n",
+   ehci->command, ehci_readl(ehci, &ehci->regs->command),
+   ehci->need_io_watchdog, ehci->async_count);
+
+   ehci_dbg(ehci, "async list:\n");
+   qh2 = ehci->async;
+   while (qh2) {
+   ehci_dbg(ehci, " qh %p hw %p dma %x next %p hw_next %x\n",
+   qh2, qh2->hw, (u32) qh2->qh_dma, qh2->qh_next.qh,
+   hc32_to_cpu(ehci, qh2->hw->hw_next));
+   qh2 = qh2->qh_next.qh;
+   }
+
+   ehci_dbg(ehci, "This qh link time %lu enqueue time %lu td token %x ov 
token %x\n",
+   qh->link_time, qh->enqueue_time,
+   hc32_to_cpu(ehci, qh->tdtoken),
+   hc32_to_cpu(ehci, qh->ovtoken));
+   dbg_qh(" ", ehci, qh);
+
+   list_for_each_entry(td, &qh->qtd_list, qtd_list) {
+   sprintf(label, "  dma %x", (u32) td->qtd_dma);
+   dbg_qtd(label, ehci, td);
+   }
+
+   sprintf(label, "  dummy %x", (u32) qh->dummy->qtd_dma);
+   dbg_qtd(label, ehci, qh->dummy);
+}
+
+
 /* remove from hardware lists
  * completions normally happen asynchronously
  */
@@ -907,6 +956,10 @@ static int ehci_urb_dequeue(struct usb_h
qh = (struct ehci_qh *) urb->hcpriv;
if (!qh)
break;
+
+   if (usb_pipetype(urb->pipe) == PIPE_BULK)
+   alan_debug(ehci, urb, qh);
+
switch (qh->qh_state) {
case QH_STATE_LINKED:
case QH_STATE_COMPLETING:
Index: usb-3.7/drivers/usb/host/ehci.h
===
--- usb-3.7.orig/drivers/usb/host/ehci.h
+++ usb-3.7/drivers/usb/host/ehci.h
@@ -221,6 +221,10 @@ struct ehci_hcd {  /* one per controlle
 #ifdef DEBUG
struct dentry   *debug_dir;
 #endif
+
+   struct urb  *alan_urb;
+   unsigned long   last_scan_time;
+
 };
 
 /* convert between an HCD pointer and the corresponding EHCI_HCD */
@@ -400,6 +404,9 @@ struct ehci_qh {
struct usb_device   *dev;   /* access to TT */
unsignedis_out:1;   /* bulk or intr OUT */
unsignedclearing_tt:1;  /* Clear-TT-Buf in progress */
+
+   unsigned long   link_time, enqueue_time;
+   __hc32  tdtoken, ovtoken;
 };
 
 /*-*/
Index: usb-3.7/drivers/usb/host/ehci-q.c
===
--- usb-3.7.orig/drivers/usb/host/ehci-q.c
+++ usb-3.7/drivers/usb/host/ehci-q.c
@@ -291,6 +291,11 @@ __acquires(ehci->lock)
/* complete() can reenter this HCD */
usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb);
spin_unlock (&ehci->lock);
+   if (urb == ehci->alan_urb) {
+   ehci->alan_urb = NULL;
+   ehci_dbg(ehci, "giveback urb %p actual %d\n", urb, 
urb->actual_length);
+   ehci_dbg(ehci, "alan end\n");
+   }
usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status);
spin_lock (&ehci->lock);
 }
@@ -1002,6 +1007,7 @@ static void qh_link_async (struct ehci_

Re: [RFC PATCH 4/5] arm: omap2: support port power on lan95xx devices

2012-12-04 Thread Alan Stern
[CC: list trimmed; the people who were on it should be subscribed to at 
least one of the lists anyway.]

On Tue, 4 Dec 2012, Andy Green wrote:

> I think associating ULPI PHY reset and SMSC power and reset with the hub 
> port power state is good.  Then, you could have the driver in a device 
> with multiple onboard USB devices, and individually control whether 
> they're eating power or not.  In the asset case, you'd associate mux 
> assets with ehci-omap.0.
> 
> Yesterday I studied the hub port code and have a couple of patches, one 
> normalizes the hub port device to have a stub driver.
> 
> The other then puts hub port power state signalling into runtime_pm 
> handlers in the hub port device.  Until now, actually there's no code in 
> hub.c to switch off a port.

In fact that's not quite true.  You simply weren't aware of the new
code; you can find a series of patches starting here:

http://marc.info/?l=linux-usb&m=135314427413307&w=2

The parts of interest to us begin in patch 7/10.

> Assuming that's not insane, what should the user interface to disable a 
> port power look like, something in sysfs?  Until now it doesn't seem to 
> exist.

It will be implemented through PM QOS.

> > (On the other hand, since the LAN95xx is the only thing
> > connected to the root hub, it could be powered off and on by
> > unbinding the ehci-omap.0 device from its driver and rebinding
> > it.)
> 
> We shouldn't get to tied up with Panda case, this will be there for all 
> cases like PCs etc.  It should work well if there are multiple ports 
> with onboard assets.

Okay, I'm fine with tying this to the port.

> >   2. If we do choose the port, do we want to identify it by matching
> > against a device name string or by matching a sequence of port
> > numbers (in this case, a length-1 sequence)?  The port numbers
> > are fixed by the board design, whereas the device name strings
> > might  get changed in the future.  On the other hand, the port
> > numbers apply only to USB whereas device names can be used by
> > any subsystem.
> 
> USB device names contain the port information.  The matching scheme I 
> have currently just uses the right-hand side of the path information and 
> nothing that is not defined by the USB subsystem.  It uses a 
> platform_device ancestor to restrict matches to descendants of the right 
> host controller.  So unlike try#1 the names are as stable as the 
> subsystem code alone, however stable that is, it's not exposed to 
> changes from anywhere else.  As you mention it's then workable on any 
> dynamically probed bus.
> 
> >   3. Should the matching mechanism go into the device core or into
> > the USB port code?  (This is related to the previous question.)
> 
> Currently I am experimenting with having the asset pointer in struct 
> device, but migrating the events into runtime_resume and 
> runtime_suspend.  If it works out that has advantages that assets follow 
> not just the logical device existence but the pm state of the device 
> closely.
> 
> It also allows leveraging assets directly to the hub port runtime_pm 
> state, so they follow enable state of the port without any additional code.

If we use a PM domain then there won't be any need to hook the runtime
PM events.  The domain will automatically be notified about power
changes.

> >   4. Should this be implemented simply as a regulator (or a pair of
> > regulators)?  Or should it be generalized to some sort of PM
> > domain thing?  The generic_pm_domain structure defined in
> > include/linux/pm_domain.h seems like overkill, but maybe it's
> > the most appropriate thing to use.
> 
> They should be regulators for that I think.  But it's only part the 
> problem since clocks and mux are also going to be commonly associated 
> with device power state, and indeed are in Panda case.
> 
> I realize restricting the scope is desirable to get something done, but 
> I'm not sure supporting regulators only is enough of the job.

Then why not use a PM domain?  It will allow us to do whatever we want 
in the callbacks.


On Tue, 4 Dec 2012, Ming Lei wrote:

> Alos, the same ehci-omap driver and same LAN95xx chip is used in
> beagle board and panda board with different power control
> approach, does port driver can distinguish these two cases?
> Port device is a general device(not platform device), how does
> port driver get platform/board dependent info?

This is the part that Andy has been working on.  The board-dependent 
info will be registered by the board file, and it will take effect 
either when the port is registered or when it is bound to a driver.

The details of this aren't clear yet.  For instance, should the device 
core try to match the port with the asset info, or should this be done 
by the USB code when the port is created?

> Not only regulators involved, clock or other things might be involved too.
> Also the same power domain might be shared wi

Re: [RFC PATCH 4/5] arm: omap2: support port power on lan95xx devices

2012-12-04 Thread Sarah Sharp
On Tue, Dec 04, 2012 at 11:40:05AM +0800, Andy Green wrote:
> On 04/12/12 01:09, the mail apparently from Alan Stern included:
> >On Mon, 3 Dec 2012, Andy Green wrote:
> >
> >>Unless someone NAKs it for sure already (if you're already sure you're
> >>going to, please do so to avoid wasting time), I'll issue a try#2 of my
> >>code later which demonstrates what I mean.  At least I guess it's useful
> >>for comparative purposes.
> >
> >Before you go writing a whole lot more code, we should discuss the
> >basics a bit more clearly.  There are several unsettled issues here:
> 
> >  1. Should the LAN95xx stuff be associated with the ehci-omap.0's
> > driver or with the hub port?  The port would be more flexible,
> > offering the ability to turn the power off and on while the
> > system is running without affecting anything else.  But the
> > port code is currently in flux, which could cause this new
> > addition to be delayed.
> 
> I think associating ULPI PHY reset and SMSC power and reset with the
> hub port power state is good.  Then, you could have the driver in a
> device with multiple onboard USB devices, and individually control
> whether they're eating power or not.  In the asset case, you'd
> associate mux assets with ehci-omap.0.
> 
> Yesterday I studied the hub port code and have a couple of patches,
> one normalizes the hub port device to have a stub driver.
> 
> The other then puts hub port power state signalling into runtime_pm
> handlers in the hub port device.  Until now, actually there's no
> code in hub.c to switch off a port.

Did you take a look at the most recent patches from Tianyu to add
support to power off a port if a device is suspended?

Start of the series:
http://marc.info/?l=linux-usb&m=135314427413307&w=2
Patch that adds power off on device suspend:
http://marc.info/?l=linux-usb&m=135314431913321&w=2

Tianyu also added some code to the xHCI host controller driver to call
into the ACPI methods to power off a port when the USB hub driver clears
the port power feature.

Sarah Sharp
--
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] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread krumbo...@universalnet.at

Add device driver for USB2CAN interface from "8 devices" 
(http://www.8devices.com).

Signed-off-by: Bernd Krumboeck 
---
 drivers/net/can/usb/Kconfig|6 +
 drivers/net/can/usb/Makefile   |1 +
 drivers/net/can/usb/usb_8dev.c | 1093 
 3 files changed, 1100 insertions(+)
 create mode 100644 drivers/net/can/usb/usb_8dev.c

diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
index a4e4bee..2162233 100644
--- a/drivers/net/can/usb/Kconfig
+++ b/drivers/net/can/usb/Kconfig
@@ -48,4 +48,10 @@ config CAN_PEAK_USB
  This driver supports the PCAN-USB and PCAN-USB Pro adapters
  from PEAK-System Technik (http://www.peak-system.com).
 +config CAN_8DEV_USB
+   tristate "8 devices USB2CAN interface"
+   ---help---
+ This driver supports the USB2CAN interface
+ from 8 devices (http://www.8devices.com).
+
 endmenu
diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile
index 80a2ee4..becef46 100644
--- a/drivers/net/can/usb/Makefile
+++ b/drivers/net/can/usb/Makefile
@@ -6,5 +6,6 @@ obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
 obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
 obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
 obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/
+obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
  ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c
new file mode 100644
index 000..9202a12
--- /dev/null
+++ b/drivers/net/can/usb/usb_8dev.c
@@ -0,0 +1,1093 @@
+/*
+ * CAN driver for "8 devices" USB2CAN converter
+ *
+ * Copyright (C) 2012 Bernd Krumboeck (krumbo...@universalnet.at)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * This driver is inspired by the 3.2.0 version of 
drivers/net/can/usb/ems_usb.c
+ * and drivers/net/can/usb/esd_usb2.c
+ *
+ * Many thanks to Gerhard Bertelsmann (i...@gerhard-bertelsmann.de)
+ * for testing and fixing this driver. Also many thanks to "8 devices",
+ * who were very cooperative and answered my questions.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/* driver constants */
+#define MAX_RX_URBS10
+#define MAX_TX_URBS10
+#define RX_BUFFER_SIZE 64
+
+/* vendor and product id */
+#define USB_8DEV_VENDOR_ID 0x0483
+#define USB_8DEV_PRODUCT_ID0x1234
+
+/* endpoints */
+enum usb_8dev_endpoint {
+   USB_8DEV_ENDP_DATA_RX = 1,
+   USB_8DEV_ENDP_DATA_TX,
+   USB_8DEV_ENDP_CMD_RX,
+   USB_8DEV_ENDP_CMD_TX
+};
+
+/* bittiming constants */
+#define USB_8DEV_ABP_CLOCK 3200
+#define USB_8DEV_BAUD_MANUAL   0x09
+#define USB_8DEV_TSEG1_MIN 1
+#define USB_8DEV_TSEG1_MAX 16
+#define USB_8DEV_TSEG2_MIN 1
+#define USB_8DEV_TSEG2_MAX 8
+#define USB_8DEV_SJW_MAX   4
+#define USB_8DEV_BRP_MIN   1
+#define USB_8DEV_BRP_MAX   1024
+#define USB_8DEV_BRP_INC   1
+
+/* setup flags */
+#define USB_8DEV_SILENT0x01
+#define USB_8DEV_LOOPBACK  0x02
+#define USB_8DEV_DISABLE_AUTO_RESTRANS 0x04
+#define USB_8DEV_STATUS_FRAME  0x08
+
+/* commands */
+enum usb_8dev_cmd {
+   USB_8DEV_RESET = 1,
+   USB_8DEV_OPEN,
+   USB_8DEV_CLOSE,
+   USB_8DEV_SET_SPEED,
+   USB_8DEV_SET_MASK_FILTER,
+   USB_8DEV_GET_STATUS,
+   USB_8DEV_GET_STATISTICS,
+   USB_8DEV_GET_SERIAL,
+   USB_8DEV_GET_SOFTW_VER,
+   USB_8DEV_GET_HARDW_VER,
+   USB_8DEV_RESET_TIMESTAMP,
+   USB_8DEV_GET_SOFTW_HARDW_VER
+};
+
+#define USB_8DEV_CMD_START 0x11
+#define USB_8DEV_CMD_END   0x22
+
+#define USB_8DEV_CMD_SUCCESS   0
+#define USB_8DEV_CMD_ERROR 255
+
+#define USB_8DEV_CMD_TIMEOUT   1000
+
+/* frames */
+#define USB_8DEV_DATA_START0x55
+#define USB_8DEV_DATA_END  0xAA
+
+#define USB_8DEV_TYPE_CAN_FRAME0
+#define USB_8DEV_TYPE_ERROR_FRAME  3
+
+#define USB_8DEV_EXTID 0x01
+#define USB_8DEV_RTR   0x02
+#define USB_8DEV_ERR_FLAG  0x04
+
+/* status */
+#define USB_8DEV_STATUSMSG_OK  0x00  /* Normal condition. */
+#define USB

Re: [PATCH v3] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Wolfgang Grandegger
On 12/04/2012 09:44 PM, krumbo...@universalnet.at wrote:
> Add device driver for USB2CAN interface from "8 devices"
> (http://www.8devices.com).
> 
> Signed-off-by: Bernd Krumboeck 
> ---
>  drivers/net/can/usb/Kconfig|6 +
>  drivers/net/can/usb/Makefile   |1 +
>  drivers/net/can/usb/usb_8dev.c | 1093
> 
>  3 files changed, 1100 insertions(+)
>  create mode 100644 drivers/net/can/usb/usb_8dev.c
> 
> diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
> index a4e4bee..2162233 100644
> --- a/drivers/net/can/usb/Kconfig
> +++ b/drivers/net/can/usb/Kconfig
> @@ -48,4 +48,10 @@ config CAN_PEAK_USB
>This driver supports the PCAN-USB and PCAN-USB Pro adapters
>from PEAK-System Technik (http://www.peak-system.com).
>  +config CAN_8DEV_USB
> +tristate "8 devices USB2CAN interface"
> +---help---
> +  This driver supports the USB2CAN interface
> +  from 8 devices (http://www.8devices.com).
> +
>  endmenu
> diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile
> index 80a2ee4..becef46 100644
> --- a/drivers/net/can/usb/Makefile
> +++ b/drivers/net/can/usb/Makefile
> @@ -6,5 +6,6 @@ obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
>  obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
>  obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
>  obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/
> +obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
>   ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG

The patch looks white-space mangled.

> diff --git a/drivers/net/can/usb/usb_8dev.c
> b/drivers/net/can/usb/usb_8dev.c
> new file mode 100644
> index 000..9202a12
> --- /dev/null
> +++ b/drivers/net/can/usb/usb_8dev.c
> @@ -0,0 +1,1093 @@
> +/*
> + * CAN driver for "8 devices" USB2CAN converter
> + *
> + * Copyright (C) 2012 Bernd Krumboeck (krumbo...@universalnet.at)
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published
> + * by the Free Software Foundation; version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + *
> + * This driver is inspired by the 3.2.0 version of
> drivers/net/can/usb/ems_usb.c
> + * and drivers/net/can/usb/esd_usb2.c
> + *
> + * Many thanks to Gerhard Bertelsmann (i...@gerhard-bertelsmann.de)
> + * for testing and fixing this driver. Also many thanks to "8 devices",
> + * who were very cooperative and answered my questions.
> + */
> +
...
> +
> +/* Read data and status frames */
> +static void usb_8dev_rx_can_msg(struct usb_8dev *dev,
> +struct usb_8dev_rx_msg *msg)
> +{
> +struct can_frame *cf;
> +struct sk_buff *skb;
> +struct net_device_stats *stats = &dev->netdev->stats;
> +
> +if (msg->type == USB_8DEV_TYPE_CAN_FRAME) {
> +skb = alloc_can_skb(dev->netdev, &cf);
> +if (!skb)
> +return;
> +
> +cf->can_id = be32_to_cpu(msg->id);
> +cf->can_dlc = get_can_dlc(msg->dlc & 0xF);
> +
> +if (msg->flags & USB_8DEV_EXTID)
> +cf->can_id |= CAN_EFF_FLAG;
> +
> +if (msg->flags & USB_8DEV_RTR)
> +cf->can_id |= CAN_RTR_FLAG;
> +else
> +memcpy(cf->data, msg->data, cf->can_dlc);
> +} else if (msg->type == USB_8DEV_TYPE_ERROR_FRAME &&
> +   msg->flags == USB_8DEV_ERR_FLAG) {
> +
> +/*
> + * Error message:
> + * byte 0: Status
> + * byte 1: bit   7: Receive Passive
> + * byte 1: bit 0-6: Receive Error Counter
> + * byte 2: Transmit Error Counter
> + * byte 3: Always 0 (maybe reserved for future use)
> + */
> +
> +u8 state = msg->data[0];
> +u8 rxerr = msg->data[1] & USB_8DEV_RP_MASK;
> +u8 txerr = msg->data[2];
> +int rx_errors = 0;
> +int tx_errors = 0;
> +
> +skb = alloc_can_err_skb(dev->netdev, &cf);
> +if (!skb)
> +return;
> +
> +dev->can.can_stats.bus_error++;

As we have seen, the device does either report bus-errors or state
changes. ALso obvious because a switch is used. Please don't increment
"bus_error" for state change messages.

> +
> +switch (state) {
> +case USB_8DEV_STATUSMSG_OK:
> +dev->can.state = CAN_STATE_ERROR_ACTIVE;
> +cf->can_id |= CAN_ERR_PROT;
> +cf->data[2] = CAN_ERR_PROT_ACTIVE;
> +break;
> +case USB_8DEV_STATUSMSG_BUSOFF:
> +dev->can.state = CAN_STATE_BUS_OFF;
> +cf->can_id |= CAN_ERR_B

Correlating SOF with host system time

2012-12-04 Thread Stefan Tauner
Hi!

My broad goal is to transmit the current system time somewhat
accurately to devices (namely fullspeed microcontrollers).

I'd like to be able correlate some instant of a USB frame (i.e. a point
in time with a known offset to the SOF) with the host's system time. 
The host PC can then create a snapshot containing the frame number, a
timestamp (corrected by the offset to the frame's SOF if applicable)
and send this in a normal data packet to the device(s). On the devices
I can use SOF interrupts to take note of a local clock and compare that
to the measurements of the host to derive real time.

These are the notes of my research in respect of standards:
- UHCI does not define any interrupts that are related to the SOF/frame
  borders.
- OHCI defines a SOF interrupt (7.1.4 HcInterruptStatus Register).
- EHCI does only define a Frame List Rollover Interrupt (2.3.2 USBSTS),
  but that should suffice too for my purpose.
- USB 3.0 is not my main concern, but there are some interesting bits:
  * MFINDEX Wrap Events seem to be similar to the rollover interrupts.
  * there exist Isochronous Timestamp Packets (8.7) to compensate for
the missing SOF packets.
  * a special field in the hub descriptors (wHubDelay) allows to take
delays due to different hierarchies into account of synchronization
schemes.
  * "Set Isochronous Delay" requests informs devices about transmission
delays.
  see also 
http://www.usb.org/developers/presentations/SuperSpeed_USB_DevCon_Isochronous_Froelich.pdf

Regarding existing code i have seen a few references to the features above.
EHCI code seems to just ignore/mask away the rollover interrupt
STS_FLR (apart from debug prints).
OHCI code uses the SOF interrupt (OHCI_INTR_SF) just for quirks and
queue management(?).
I have not really looked at XHCI code.
(TBH i have looked at 3.2 code only yet, please flame me, if there have
been any major related changes since ;)

>From a user's perspective there is AFAIK only
usb_get_current_frame_number() which is not very useful for my use case
due to its polling nature. libusb does not even expose that:
http://marc.info/?t=12847763202&r=1&w=4

What do you think would be a reasonable approach to make userspace
aware of SOF-related events/timestamps and/or achieve my goal? Do you
think this might be useful/generic enough to be merged upstream? Do
think i should instead just implement something vaguely similar to
NTP/PTP on top of normal USB pipes? I am a complete linux kernel newbie
(apart from applying existing patches, staring a bit at foreign code and
compiling it), but I have always wanted to start hacking it... :)
-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
--
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] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Bernd Krumboeck

Hi Wolfgang!


Am 2012-12-04 21:44, schrieb Wolfgang Grandegger:

On 12/04/2012 09:44 PM, krumbo...@universalnet.at wrote:

Add device driver for USB2CAN interface from "8 devices"
(http://www.8devices.com).

Signed-off-by: Bernd Krumboeck 
---
  drivers/net/can/usb/Kconfig|6 +
  drivers/net/can/usb/Makefile   |1 +
  drivers/net/can/usb/usb_8dev.c | 1093

  3 files changed, 1100 insertions(+)
  create mode 100644 drivers/net/can/usb/usb_8dev.c

diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
index a4e4bee..2162233 100644
--- a/drivers/net/can/usb/Kconfig
+++ b/drivers/net/can/usb/Kconfig
@@ -48,4 +48,10 @@ config CAN_PEAK_USB
This driver supports the PCAN-USB and PCAN-USB Pro adapters
from PEAK-System Technik (http://www.peak-system.com).
  +config CAN_8DEV_USB
+tristate "8 devices USB2CAN interface"
+---help---
+  This driver supports the USB2CAN interface
+  from 8 devices (http://www.8devices.com).
+
  endmenu
diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile
index 80a2ee4..becef46 100644
--- a/drivers/net/can/usb/Makefile
+++ b/drivers/net/can/usb/Makefile
@@ -6,5 +6,6 @@ obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
  obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
  obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
  obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/
+obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
   ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG


The patch looks white-space mangled.


The patch is correct, only thunderbird hates me.
Sorry, I will try it again.


+switch (state) {
+case USB_8DEV_STATUSMSG_ACK:
+cf->can_id |= CAN_ERR_ACK;
+tx_errors = 1;
+break;
+case USB_8DEV_STATUSMSG_CRC:
+cf->data[2] |= CAN_ERR_PROT_BIT;
+rx_errors = 1;
+break;
+case USB_8DEV_STATUSMSG_BIT0:
+cf->data[2] |= CAN_ERR_PROT_BIT0;
+tx_errors = 1;
+break;
+case USB_8DEV_STATUSMSG_BIT1:
+cf->data[2] |= CAN_ERR_PROT_BIT1;
+tx_errors = 1;
+break;
+case USB_8DEV_STATUSMSG_FORM:
+cf->data[2] |= CAN_ERR_PROT_FORM;
+rx_errors = 1;
+break;
+case USB_8DEV_STATUSMSG_STUFF:
+cf->data[2] |= CAN_ERR_PROT_STUFF;
+rx_errors = 1;
+break;
+case USB_8DEV_STATUSMSG_OVERRUN:
+cf->data[1] = (txerr > rxerr) ?
+CAN_ERR_CRTL_TX_OVERFLOW :
+CAN_ERR_CRTL_RX_OVERFLOW;
+cf->data[2] |= CAN_ERR_PROT_OVERLOAD;
+stats->rx_over_errors++;
+break;
+case USB_8DEV_STATUSMSG_BUSLIGHT:
+cf->data[1] = (txerr > rxerr) ?
+CAN_ERR_CRTL_TX_WARNING :
+CAN_ERR_CRTL_RX_WARNING;
+dev->can.can_stats.error_warning++;
+break;
+case USB_8DEV_STATUSMSG_BUSHEAVY:
+cf->data[1] = (txerr > rxerr) ?
+CAN_ERR_CRTL_TX_PASSIVE :
+CAN_ERR_CRTL_RX_PASSIVE;
+dev->can.can_stats.error_passive++;
+break;
+default:
+cf->data[2] |= CAN_ERR_PROT_UNSPEC;


Did you see this happen?


No. I'll remove default case.


regards,
Bernd

--
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 issue with kernel 3.6

2012-12-04 Thread Piergiorgio Sartor
Hi Alan,

thanks for the patch.

One question, which kernel version should I use
for this patch?

It's the latest from git?

Thanks,

bye,

pg

On Tue, Dec 04, 2012 at 11:45:14AM -0500, Alan Stern wrote:
> On Mon, 3 Dec 2012, Piergiorgio Sartor wrote:
> 
> > Hi Alan,
> > 
> > I updated the bug report with dmesg dump.
> > 
> > I hope this time it is correct...
> 
> Yes, it is.  It shows a couple of strange things; I need more 
> information.
> 
> Below is a new test patch; try running the test with this patch in 
> place of the previous one.  I don't need to see the usbmon trace, just 
> the dmesg log.  And not even all of that; just the part from "alan 
> start" to "alan end" -- this will be near the end of the log.
> 
> Also, what output do you get from "lspci -v -s b.1"?
> 
> Alan Stern
> 
> 
> 
> Index: usb-3.7/drivers/usb/host/ehci-hcd.c
> ===
> --- usb-3.7.orig/drivers/usb/host/ehci-hcd.c
> +++ usb-3.7/drivers/usb/host/ehci-hcd.c
> @@ -825,8 +825,10 @@ dead:
>   bh = 0;
>   }
>  
> - if (bh)
> + if (bh) {
> + ehci->last_scan_time = jiffies;
>   ehci_work (ehci);
> + }
>   spin_unlock (&ehci->lock);
>   if (pcd_status)
>   usb_hcd_poll_rh_status(hcd);
> @@ -884,6 +886,53 @@ static int ehci_urb_enqueue (
>   }
>  }
>  
> +static void alan_debug(struct ehci_hcd *ehci, struct urb *urb, struct 
> ehci_qh *qh)
> +{
> + static int done;
> + struct ehci_qh *qh2;
> + struct ehci_qtd *td;
> + char label[24];
> +
> + if (done)
> + return;
> + if (urb->transfer_buffer_length != 31) {
> + ehci_dbg(ehci, "unlink urb len %d\n", 
> urb->transfer_buffer_length);
> + return;
> + }
> +
> + ehci->alan_urb = urb;
> + done = 1;
> + ehci_dbg(ehci, "alan start  cur time %lu last scan %lu\n",
> + jiffies, ehci->last_scan_time);
> + ehci_dbg(ehci, "command %x cmd reg %x io watchdog %d async count %d\n",
> + ehci->command, ehci_readl(ehci, &ehci->regs->command),
> + ehci->need_io_watchdog, ehci->async_count);
> +
> + ehci_dbg(ehci, "async list:\n");
> + qh2 = ehci->async;
> + while (qh2) {
> + ehci_dbg(ehci, " qh %p hw %p dma %x next %p hw_next %x\n",
> + qh2, qh2->hw, (u32) qh2->qh_dma, qh2->qh_next.qh,
> + hc32_to_cpu(ehci, qh2->hw->hw_next));
> + qh2 = qh2->qh_next.qh;
> + }
> +
> + ehci_dbg(ehci, "This qh link time %lu enqueue time %lu td token %x ov 
> token %x\n",
> + qh->link_time, qh->enqueue_time,
> + hc32_to_cpu(ehci, qh->tdtoken),
> + hc32_to_cpu(ehci, qh->ovtoken));
> + dbg_qh(" ", ehci, qh);
> +
> + list_for_each_entry(td, &qh->qtd_list, qtd_list) {
> + sprintf(label, "  dma %x", (u32) td->qtd_dma);
> + dbg_qtd(label, ehci, td);
> + }
> +
> + sprintf(label, "  dummy %x", (u32) qh->dummy->qtd_dma);
> + dbg_qtd(label, ehci, qh->dummy);
> +}
> +
> +
>  /* remove from hardware lists
>   * completions normally happen asynchronously
>   */
> @@ -907,6 +956,10 @@ static int ehci_urb_dequeue(struct usb_h
>   qh = (struct ehci_qh *) urb->hcpriv;
>   if (!qh)
>   break;
> +
> + if (usb_pipetype(urb->pipe) == PIPE_BULK)
> + alan_debug(ehci, urb, qh);
> +
>   switch (qh->qh_state) {
>   case QH_STATE_LINKED:
>   case QH_STATE_COMPLETING:
> Index: usb-3.7/drivers/usb/host/ehci.h
> ===
> --- usb-3.7.orig/drivers/usb/host/ehci.h
> +++ usb-3.7/drivers/usb/host/ehci.h
> @@ -221,6 +221,10 @@ struct ehci_hcd {/* one per 
> controlle
>  #ifdef DEBUG
>   struct dentry   *debug_dir;
>  #endif
> +
> + struct urb  *alan_urb;
> + unsigned long   last_scan_time;
> +
>  };
>  
>  /* convert between an HCD pointer and the corresponding EHCI_HCD */
> @@ -400,6 +404,9 @@ struct ehci_qh {
>   struct usb_device   *dev;   /* access to TT */
>   unsignedis_out:1;   /* bulk or intr OUT */
>   unsignedclearing_tt:1;  /* Clear-TT-Buf in progress */
> +
> + unsigned long   link_time, enqueue_time;
> + __hc32  tdtoken, ovtoken;
>  };
>  
>  /*-*/
> Index: usb-3.7/drivers/usb/host/ehci-q.c
> ===
> --- usb-3.7.orig/drivers/usb/host/ehci-q.c
> +++ usb-3.7/drivers/usb/host/ehci-q.c
> @@ -291,6 +291,11 @@ __acquires(ehci->lock)
>   /* complete() can reenter this HCD */
>   usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb);
>   spin_unlock (&ehci->lock);
> + if (urb == eh

Re: Correlating SOF with host system time

2012-12-04 Thread Alan Stern
On Tue, 4 Dec 2012, Stefan Tauner wrote:

> Hi!
> 
> My broad goal is to transmit the current system time somewhat
> accurately to devices (namely fullspeed microcontrollers).
> 
> I'd like to be able correlate some instant of a USB frame (i.e. a point
> in time with a known offset to the SOF) with the host's system time. 
> The host PC can then create a snapshot containing the frame number, a
> timestamp (corrected by the offset to the frame's SOF if applicable)
> and send this in a normal data packet to the device(s). On the devices
> I can use SOF interrupts to take note of a local clock and compare that
> to the measurements of the host to derive real time.
> 
> These are the notes of my research in respect of standards:
> - UHCI does not define any interrupts that are related to the SOF/frame
>   borders.
> - OHCI defines a SOF interrupt (7.1.4 HcInterruptStatus Register).
> - EHCI does only define a Frame List Rollover Interrupt (2.3.2 USBSTS),
>   but that should suffice too for my purpose.
> - USB 3.0 is not my main concern, but there are some interesting bits:
>   * MFINDEX Wrap Events seem to be similar to the rollover interrupts.
>   * there exist Isochronous Timestamp Packets (8.7) to compensate for
> the missing SOF packets.
>   * a special field in the hub descriptors (wHubDelay) allows to take
> delays due to different hierarchies into account of synchronization
> schemes.
>   * "Set Isochronous Delay" requests informs devices about transmission
> delays.
>   see also 
> http://www.usb.org/developers/presentations/SuperSpeed_USB_DevCon_Isochronous_Froelich.pdf
> 
> Regarding existing code i have seen a few references to the features above.
> EHCI code seems to just ignore/mask away the rollover interrupt
> STS_FLR (apart from debug prints).
> OHCI code uses the SOF interrupt (OHCI_INTR_SF) just for quirks and
> queue management(?).
> I have not really looked at XHCI code.
> (TBH i have looked at 3.2 code only yet, please flame me, if there have
> been any major related changes since ;)
> 
> From a user's perspective there is AFAIK only
> usb_get_current_frame_number() which is not very useful for my use case
> due to its polling nature. libusb does not even expose that:
> http://marc.info/?t=12847763202&r=1&w=4
> 
> What do you think would be a reasonable approach to make userspace
> aware of SOF-related events/timestamps and/or achieve my goal? Do you
> think this might be useful/generic enough to be merged upstream? Do
> think i should instead just implement something vaguely similar to
> NTP/PTP on top of normal USB pipes? I am a complete linux kernel newbie
> (apart from applying existing patches, staring a bit at foreign code and
> compiling it), but I have always wanted to start hacking it... :)

I don't think referencing times to SOF packets is the best approach, 
although it probably is the approach that would yield the most 
precision.  How precise do you want your synchronization to be?

Running NTP over a USB-based network link would certainly be the 
easiest solution, if your device can support it.  Over the long run, it 
might even be more accurate on average than using SOF packets.

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


[PATCH v4] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Bernd Krumboeck

Add device driver for USB2CAN interface from "8 devices" 
(http://www.8devices.com).

Signed-off-by: Bernd Krumboeck 
---
 drivers/net/can/usb/Kconfig|6 +
 drivers/net/can/usb/Makefile   |1 +
 drivers/net/can/usb/usb_8dev.c | 1089 
 3 files changed, 1096 insertions(+)
 create mode 100644 drivers/net/can/usb/usb_8dev.c

diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
index a4e4bee..2162233 100644
--- a/drivers/net/can/usb/Kconfig
+++ b/drivers/net/can/usb/Kconfig
@@ -48,4 +48,10 @@ config CAN_PEAK_USB
  This driver supports the PCAN-USB and PCAN-USB Pro adapters
  from PEAK-System Technik (http://www.peak-system.com).

+config CAN_8DEV_USB
+   tristate "8 devices USB2CAN interface"
+   ---help---
+ This driver supports the USB2CAN interface
+ from 8 devices (http://www.8devices.com).
+
 endmenu
diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile
index 80a2ee4..becef46 100644
--- a/drivers/net/can/usb/Makefile
+++ b/drivers/net/can/usb/Makefile
@@ -6,5 +6,6 @@ obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
 obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
 obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
 obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/
+obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o

 ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c
new file mode 100644
index 000..b3a7eee
--- /dev/null
+++ b/drivers/net/can/usb/usb_8dev.c
@@ -0,0 +1,1089 @@
+/*
+ * CAN driver for "8 devices" USB2CAN converter
+ *
+ * Copyright (C) 2012 Bernd Krumboeck (krumbo...@universalnet.at)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * This driver is inspired by the 3.2.0 version of 
drivers/net/can/usb/ems_usb.c
+ * and drivers/net/can/usb/esd_usb2.c
+ *
+ * Many thanks to Gerhard Bertelsmann (i...@gerhard-bertelsmann.de)
+ * for testing and fixing this driver. Also many thanks to "8 devices",
+ * who were very cooperative and answered my questions.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/* driver constants */
+#define MAX_RX_URBS10
+#define MAX_TX_URBS10
+#define RX_BUFFER_SIZE 64
+
+/* vendor and product id */
+#define USB_8DEV_VENDOR_ID 0x0483
+#define USB_8DEV_PRODUCT_ID0x1234
+
+/* endpoints */
+enum usb_8dev_endpoint {
+   USB_8DEV_ENDP_DATA_RX = 1,
+   USB_8DEV_ENDP_DATA_TX,
+   USB_8DEV_ENDP_CMD_RX,
+   USB_8DEV_ENDP_CMD_TX
+};
+
+/* bittiming constants */
+#define USB_8DEV_ABP_CLOCK 3200
+#define USB_8DEV_BAUD_MANUAL   0x09
+#define USB_8DEV_TSEG1_MIN 1
+#define USB_8DEV_TSEG1_MAX 16
+#define USB_8DEV_TSEG2_MIN 1
+#define USB_8DEV_TSEG2_MAX 8
+#define USB_8DEV_SJW_MAX   4
+#define USB_8DEV_BRP_MIN   1
+#define USB_8DEV_BRP_MAX   1024
+#define USB_8DEV_BRP_INC   1
+
+/* setup flags */
+#define USB_8DEV_SILENT0x01
+#define USB_8DEV_LOOPBACK  0x02
+#define USB_8DEV_DISABLE_AUTO_RESTRANS 0x04
+#define USB_8DEV_STATUS_FRAME  0x08
+
+/* commands */
+enum usb_8dev_cmd {
+   USB_8DEV_RESET = 1,
+   USB_8DEV_OPEN,
+   USB_8DEV_CLOSE,
+   USB_8DEV_SET_SPEED,
+   USB_8DEV_SET_MASK_FILTER,
+   USB_8DEV_GET_STATUS,
+   USB_8DEV_GET_STATISTICS,
+   USB_8DEV_GET_SERIAL,
+   USB_8DEV_GET_SOFTW_VER,
+   USB_8DEV_GET_HARDW_VER,
+   USB_8DEV_RESET_TIMESTAMP,
+   USB_8DEV_GET_SOFTW_HARDW_VER
+};
+
+#define USB_8DEV_CMD_START 0x11
+#define USB_8DEV_CMD_END   0x22
+
+#define USB_8DEV_CMD_SUCCESS   0
+#define USB_8DEV_CMD_ERROR 255
+
+#define USB_8DEV_CMD_TIMEOUT   1000
+
+/* frames */
+#define USB_8DEV_DATA_START0x55
+#define USB_8DEV_DATA_END  0xAA
+
+#define USB_8DEV_TYPE_CAN_FRAME0
+#define USB_8DEV_TYPE_ERROR_FRAME  3
+
+#define USB_8DEV_EXTID 0x01
+#define USB_8DEV_RTR   0x02
+#define USB_8DEV_ERR_FLAG  0x04
+
+/* status */
+#define USB_8DEV_STATUSMSG_OK  0x00  /* Normal condition. */
+#define USB

Re: [PATCH v3] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Marc Kleine-Budde
On 12/04/2012 09:44 PM, krumbo...@universalnet.at wrote:
> Add device driver for USB2CAN interface from "8 devices"
> (http://www.8devices.com).

Please use git send-email to send patches, your mailer does strange things.

> 
> Signed-off-by: Bernd Krumboeck 
> ---
>  drivers/net/can/usb/Kconfig|6 +
>  drivers/net/can/usb/Makefile   |1 +
>  drivers/net/can/usb/usb_8dev.c | 1093
> 
>  3 files changed, 1100 insertions(+)
>  create mode 100644 drivers/net/can/usb/usb_8dev.c
> 
> diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
> index a4e4bee..2162233 100644
> --- a/drivers/net/can/usb/Kconfig
> +++ b/drivers/net/can/usb/Kconfig
> @@ -48,4 +48,10 @@ config CAN_PEAK_USB
>This driver supports the PCAN-USB and PCAN-USB Pro adapters
>from PEAK-System Technik (http://www.peak-system.com).
>  +config CAN_8DEV_USB
> +tristate "8 devices USB2CAN interface"
> +---help---
> +  This driver supports the USB2CAN interface
> +  from 8 devices (http://www.8devices.com).
> +
>  endmenu
> diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile
> index 80a2ee4..becef46 100644
> --- a/drivers/net/can/usb/Makefile
> +++ b/drivers/net/can/usb/Makefile
> @@ -6,5 +6,6 @@ obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
>  obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
>  obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
>  obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/
> +obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
>   ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
> diff --git a/drivers/net/can/usb/usb_8dev.c
> b/drivers/net/can/usb/usb_8dev.c
> new file mode 100644
> index 000..9202a12
> --- /dev/null
> +++ b/drivers/net/can/usb/usb_8dev.c
> @@ -0,0 +1,1093 @@
> +/*
> + * CAN driver for "8 devices" USB2CAN converter
> + *
> + * Copyright (C) 2012 Bernd Krumboeck (krumbo...@universalnet.at)
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published
> + * by the Free Software Foundation; version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + *
> + * This driver is inspired by the 3.2.0 version of
> drivers/net/can/usb/ems_usb.c
> + * and drivers/net/can/usb/esd_usb2.c
> + *
> + * Many thanks to Gerhard Bertelsmann (i...@gerhard-bertelsmann.de)
> + * for testing and fixing this driver. Also many thanks to "8 devices",
> + * who were very cooperative and answered my questions.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +/* driver constants */
> +#define MAX_RX_URBS10
> +#define MAX_TX_URBS10
> +#define RX_BUFFER_SIZE64
> +
> +/* vendor and product id */
> +#define USB_8DEV_VENDOR_ID0x0483
> +#define USB_8DEV_PRODUCT_ID0x1234
> +
> +/* endpoints */
> +enum usb_8dev_endpoint {
> +USB_8DEV_ENDP_DATA_RX = 1,
> +USB_8DEV_ENDP_DATA_TX,
> +USB_8DEV_ENDP_CMD_RX,
> +USB_8DEV_ENDP_CMD_TX
> +};
> +
> +/* bittiming constants */
> +#define USB_8DEV_ABP_CLOCK3200
> +#define USB_8DEV_BAUD_MANUAL0x09
> +#define USB_8DEV_TSEG1_MIN1
> +#define USB_8DEV_TSEG1_MAX16
> +#define USB_8DEV_TSEG2_MIN1
> +#define USB_8DEV_TSEG2_MAX8
> +#define USB_8DEV_SJW_MAX4
> +#define USB_8DEV_BRP_MIN1
> +#define USB_8DEV_BRP_MAX1024
> +#define USB_8DEV_BRP_INC1
> +
> +/* setup flags */
> +#define USB_8DEV_SILENT0x01
> +#define USB_8DEV_LOOPBACK0x02
> +#define USB_8DEV_DISABLE_AUTO_RESTRANS0x04
> +#define USB_8DEV_STATUS_FRAME0x08
> +
> +/* commands */
> +enum usb_8dev_cmd {
> +USB_8DEV_RESET = 1,
> +USB_8DEV_OPEN,
> +USB_8DEV_CLOSE,
> +USB_8DEV_SET_SPEED,
> +USB_8DEV_SET_MASK_FILTER,
> +USB_8DEV_GET_STATUS,
> +USB_8DEV_GET_STATISTICS,
> +USB_8DEV_GET_SERIAL,
> +USB_8DEV_GET_SOFTW_VER,
> +USB_8DEV_GET_HARDW_VER,
> +USB_8DEV_RESET_TIMESTAMP,
> +USB_8DEV_GET_SOFTW_HARDW_VER
> +};
> +
> +#define USB_8DEV_CMD_START0x11
> +#define USB_8DEV_CMD_END0x22
> +
> +#define USB_8DEV_CMD_SUCCESS0
> +#define USB_8DEV_CMD_ERROR255
> +
> +#define USB_8DEV_CMD_TIMEOUT1000
> +
> +/* frames */
> +#define USB_8DEV_DATA_START0x55
> +#define USB_8DEV_DATA_END0xAA
> +
> +#define USB_8DEV_TYPE_CAN_FRAME0
> +#define USB_8DEV_TYPE_ERROR_FRAME3
> +
> +#define USB_8DEV

Re: USB issue with kernel 3.6

2012-12-04 Thread Alan Stern
On Tue, 4 Dec 2012, Piergiorgio Sartor wrote:

> Hi Alan,
> 
> thanks for the patch.
> 
> One question, which kernel version should I use
> for this patch?
> 
> It's the latest from git?

I think it should work with any fairly recent kernel.  The patch was 
written against linux-next from about six weeks ago.  I don't think 
much has changed in this area for a while.

Alan Stern

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


Re: [PATCH v4] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Marc Kleine-Budde
On 12/04/2012 11:43 PM, Bernd Krumboeck wrote:
> Add device driver for USB2CAN interface from "8 devices"
> (http://www.8devices.com).
> 
> Signed-off-by: Bernd Krumboeck 

Please use git send-email.

A changelog would be nice, in the form of:

changes since v4:
- done this, deleted that

If you post v5, changes since v4 are sufficient.

> ---
>  drivers/net/can/usb/Kconfig|6 +
>  drivers/net/can/usb/Makefile   |1 +
>  drivers/net/can/usb/usb_8dev.c | 1089
> 
>  3 files changed, 1096 insertions(+)
>  create mode 100644 drivers/net/can/usb/usb_8dev.c
> 
> diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
> index a4e4bee..2162233 100644
> --- a/drivers/net/can/usb/Kconfig
> +++ b/drivers/net/can/usb/Kconfig
> @@ -48,4 +48,10 @@ config CAN_PEAK_USB
>This driver supports the PCAN-USB and PCAN-USB Pro adapters
>from PEAK-System Technik (http://www.peak-system.com).
> 
> +config CAN_8DEV_USB
> +tristate "8 devices USB2CAN interface"
> +---help---
> +  This driver supports the USB2CAN interface
> +  from 8 devices (http://www.8devices.com).
> +
>  endmenu
> diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile
> index 80a2ee4..becef46 100644
> --- a/drivers/net/can/usb/Makefile
> +++ b/drivers/net/can/usb/Makefile
> @@ -6,5 +6,6 @@ obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
>  obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
>  obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
>  obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/
> +obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
> 
>  ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
> diff --git a/drivers/net/can/usb/usb_8dev.c
> b/drivers/net/can/usb/usb_8dev.c
> new file mode 100644
> index 000..b3a7eee
> --- /dev/null
> +++ b/drivers/net/can/usb/usb_8dev.c
> @@ -0,0 +1,1089 @@
> +/*
> + * CAN driver for "8 devices" USB2CAN converter
> + *
> + * Copyright (C) 2012 Bernd Krumboeck (krumbo...@universalnet.at)
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published
> + * by the Free Software Foundation; version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

you can remove the address here.

> + *
> + * This driver is inspired by the 3.2.0 version of
> drivers/net/can/usb/ems_usb.c
> + * and drivers/net/can/usb/esd_usb2.c
> + *
> + * Many thanks to Gerhard Bertelsmann (i...@gerhard-bertelsmann.de)
> + * for testing and fixing this driver. Also many thanks to "8 devices",
> + * who were very cooperative and answered my questions.
> + */

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v4] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Marc Kleine-Budde
On 12/04/2012 11:11 PM, Marc Kleine-Budde wrote:
> On 12/04/2012 11:43 PM, Bernd Krumboeck wrote:


btw: your clock is wrong by about 1h :)

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH] mv-otg: use to_delayed_work instead of cast

2012-12-04 Thread Cesar Eduardo Barros
Directly casting a work_struct pointer to a delayed_work is risky if the
work member of struct delayed_work is ever moved from being the first
member.

Instead, use the inline function to_delayed_work(), which does the same
cast in a safer way (using container_of).

Signed-off-by: Cesar Eduardo Barros 
---
 drivers/usb/otg/mv_otg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index 3f124e8..156e1d9 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -420,7 +420,7 @@ static void mv_otg_work(struct work_struct *work)
struct usb_otg *otg;
int old_state;
 
-   mvotg = container_of((struct delayed_work *)work, struct mv_otg, work);
+   mvotg = container_of(to_delayed_work(work), struct mv_otg, work);
 
 run:
/* work queue is single thread, or we need spin_lock to protect */
-- 
1.7.11.7

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


Re: [PATCH V2 2/3] Remove VLAIS usage from gadget code

2012-12-04 Thread Sebastian Andrzej Siewior
On Mon, Dec 03, 2012 at 07:57:33PM +0100, Behan Webster wrote:
> However, in order to approximate what gcc is doing in code, obviously
> some math is required. The thought was that macros would hide the
> worst of it, trying not to obfuscate what was actually being done.

Why hide? The thing that is done here is setting up pointers and keep this
struct as a container. It is never used again, just freed. Therefore I would
suggest to remove and do something different.

> One of the project members came up with this alternative. How about
> something like this? Less math, though more string pasting. When
> compiled, the unused variables get optimized away. Otherwise the
> memory packing is identical to using VLAIS in gcc.
> 
> #define vla_struct(structname) size_t structname##__##next = 0
> #define vla_struct_size(structname) structname##__##next
> 
> #define vla_item(structname, type, name, n) \
> type * structname##_##name; \
> size_t structname##_##name##__##pad = \
> (structname##__##next & (__alignof__(type)-1)); \
> size_t structname##_##name##__##offset = \
> structname##__##next + structname##_##name##__##pad; \
> size_t structname##_##name##__##sz = n * sizeof(type); \
> structname##__##next = structname##__##next + \
> structname##_##name##__##pad +
> structname##_##name##__##sz;
> 
> #define vla_ptr(ptr,structname,name) structname##_##name = \
> (typeof(structname##_##name))&ptr[structname##_##name##__##offset]
> 
> 
> Then you can do something like this that looks vaguely struct-like:
> 
> vla_struct(foo);
> vla_item(foo, char,  vara, 1);
> vla_item(foo, short, varb, 10);
> vla_item(foo, int,   varc, 5);
> vla_item(foo, long,  vard, 3);
> size_t total = vla_struct_size(foo);
> char buffer[total];
> 
> vla_ptr(buffer, foo, varc);
> foo_varc = 1;

I prefer to try to rewritte the code in the gadget in a different manner
before using macro magic. I guess most people around here think that extensive
usage of macros equals giving a gun to a chimpanzee. It may work for a while
and may even look cute in the eye of the gun sponsor. However once it fires…

> I've been profiling some sample code around this implementation
> comparing it between compilers, and it approximates the code size and
> speed of using VLAIS in gcc (especially with -O2). It actually
> performs better than the previously proposed macros.

I'm not concerned about speed here. This is an one time setup.

> But certainly if anyone has a solution which works for everyone, then
> I'm more than happy to adopt it. The LLVM community has made quite a
> few changes in order to help get Linux working with clang. However,

That is nice to hear. Besides gcc there is the icc.

> VLAIS is not something they are willing to accept (for various
> reasons). There are other patches to LLVM that are still working
Is this not described in C99 6.7.2.1p16?

> their way upstream that are required to be able to compile Linux as
> well.

I hope the other are "simple" to get in :)

> 
> Behan
> 

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


Re: problem with USB DVD drive, can't find root fs on some drives

2012-12-04 Thread Matthew Dharm
If I had to guess, I'd say it was a timing issue.  The CD-ROM that
doesn't work is taking slightly longer to discover and maybe longer to
get ready.

Most "LiveCD" type distros I've seen load an initrd which has a
wait-loop in it to wait for the real root device to appear before
mount/chroot.

Matt

On Tue, Dec 4, 2012 at 2:13 PM, Chris Friesen  wrote:
>
> Hi,
>
> I hope this is the right place to send this, if not please let me know where
> would be more appropriate.
>
> We distribute a 2.6.27-based software load on bootable DVD.  It's intended
> to boot on a system that has no internal DVD drive, so we use USB DVD drives.
>
> With most drives we have no problems, but I've received a complaint from
> someone that has a drive that won't boot our software and I can't figure
> out why.  The same drive will boot a RHEL install disc.
>
> Any suggestions you might have would be great.
>
>
> The non-working drive is a Sony, and the relevant boot logs look like this:
>
> usb 1-1.6.1: new high speed USB device using ehci_hcd and address 5
> scsi9 : usb-storage 1-1.6.1:1.0
> scsi 9:0:0:0: Direct-Access Generic  Ultra HS-COMBO   2.01 PQ: 0 ANSI: 0
> sd 9:0:0:0: Attached scsi generic sg2 type 0
> sd 9:0:0:0: [sdc] Attached SCSI removable disk
> scsi 9:0:0:1: Direct-Access Generic  Ultra HS-SD/MMC2 2.01 PQ: 0 ANSI: 0
> sd 9:0:0:1: Attached scsi generic sg3 type 0
> sd 9:0:0:1: [sdd] Attached SCSI removable disk
> scsi 8:0:0:0: CD-ROMSONY DVD RW DRU-840A  SS01 PQ: 0 ANSI: 0
> sr0: scsi3-mmc drive: 12x/40x writer dvd-ram cd/rw xa/form2 cdda tray
> Uniform CD-ROM driver Revision: 3.20
> sr 8:0:0:0: Attached scsi generic sg4 type 5
> md: Waiting for all devices to be available before autodetect
> md: If you don't use raid, use raid=noautodetect
> md: Autodetecting RAID arrays.
> md: Scanned 0 and added 0 devices.
> md: autorun ...
> md: ... autorun DONE.
> VFS: Cannot open root device "sr0" or unknown-block(11,0)
> Please append a correct "root=" boot option; here are the available 
> partitions:
> 0810   879087384 sdb driver: sd
> 0800   879087384 sda driver: sd
> 0b00 1048575 sr0 driver: sr
> VFS: Unable to mount root fs on unknown-block(11,0)
> User configuration error - no valid root filesystem found
>
>
> I'm confused why it can't open sr0 when it clearly lists sr0 as one of the
> available partitions.
>
>
> On a working Lite-On drive plugged into the same system with the same install
> media, the equivalent logs are:
>
> usb 1-1.6.1: new high speed USB device using ehci_hcd and address 5
> scsi9 : usb-storage 1-1.6.1:1.0
> scsi 8:0:0:0: CD-ROMSlimtype eSAU208   2  ML05 PQ: 0 ANSI: 0
> sr0: scsi3-mmc drive: 62x/62x writer dvd-ram cd/rw xa/form2 cdda pop-up
> Uniform CD-ROM driver Revision: 3.20
> sr 8:0:0:0: Attached scsi generic sg2 type 5
> scsi 9:0:0:0: Direct-Access Generic  Ultra HS-COMBO   2.01 PQ: 0 ANSI: 0
> sd 9:0:0:0: Attached scsi generic sg3 type 0
> sd 9:0:0:0: [sdc] Attached SCSI removable disk
> scsi 9:0:0:1: Direct-Access Generic  Ultra HS-SD/MMC2 2.01 PQ: 0 ANSI: 0
> sd 9:0:0:1: Attached scsi generic sg4 type 0
> sd 9:0:0:1: [sdd] Attached SCSI removable disk
> md: Waiting for all devices to be available before autodetect
> md: If you don't use raid, use raid=noautodetect
> md: Autodetecting RAID arrays.
> md: Scanned 0 and added 0 devices.
> md: autorun ...
> md: ... autorun DONE.
> VFS: Mounted root (iso9660 filesystem) readonly on device 11:0.
> devtmpfs: mounted
> Freeing unused kernel memory: 656k freed
>
> =
> Transferring basename: typhoon-unit0
> Sourcing 
> isolinux/tftpboot/cnp/x86_ng/7.0.0/targets/sb_rms/common//etc/sysconfig/pivotroot
> Setting up rootfs...
>
>
> Chris



-- 
Matthew Dharm
Maintainer, USB Mass Storage driver for Linux
--
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


problem with USB DVD drive, can't find root fs on some drives

2012-12-04 Thread Chris Friesen

Hi,

I hope this is the right place to send this, if not please let me know where
would be more appropriate.

We distribute a 2.6.27-based software load on bootable DVD.  It's intended
to boot on a system that has no internal DVD drive, so we use USB DVD drives.

With most drives we have no problems, but I've received a complaint from
someone that has a drive that won't boot our software and I can't figure
out why.  The same drive will boot a RHEL install disc.

Any suggestions you might have would be great.


The non-working drive is a Sony, and the relevant boot logs look like this:

usb 1-1.6.1: new high speed USB device using ehci_hcd and address 5
scsi9 : usb-storage 1-1.6.1:1.0
scsi 9:0:0:0: Direct-Access Generic  Ultra HS-COMBO   2.01 PQ: 0 ANSI: 0
sd 9:0:0:0: Attached scsi generic sg2 type 0
sd 9:0:0:0: [sdc] Attached SCSI removable disk
scsi 9:0:0:1: Direct-Access Generic  Ultra HS-SD/MMC2 2.01 PQ: 0 ANSI: 0
sd 9:0:0:1: Attached scsi generic sg3 type 0
sd 9:0:0:1: [sdd] Attached SCSI removable disk
scsi 8:0:0:0: CD-ROMSONY DVD RW DRU-840A  SS01 PQ: 0 ANSI: 0
sr0: scsi3-mmc drive: 12x/40x writer dvd-ram cd/rw xa/form2 cdda tray
Uniform CD-ROM driver Revision: 3.20
sr 8:0:0:0: Attached scsi generic sg4 type 5
md: Waiting for all devices to be available before autodetect
md: If you don't use raid, use raid=noautodetect
md: Autodetecting RAID arrays.
md: Scanned 0 and added 0 devices.
md: autorun ...
md: ... autorun DONE.
VFS: Cannot open root device "sr0" or unknown-block(11,0)
Please append a correct "root=" boot option; here are the available partitions:
0810   879087384 sdb driver: sd
0800   879087384 sda driver: sd
0b00 1048575 sr0 driver: sr
VFS: Unable to mount root fs on unknown-block(11,0)
User configuration error - no valid root filesystem found


I'm confused why it can't open sr0 when it clearly lists sr0 as one of the
available partitions.


On a working Lite-On drive plugged into the same system with the same install
media, the equivalent logs are:

usb 1-1.6.1: new high speed USB device using ehci_hcd and address 5
scsi9 : usb-storage 1-1.6.1:1.0
scsi 8:0:0:0: CD-ROMSlimtype eSAU208   2  ML05 PQ: 0 ANSI: 0
sr0: scsi3-mmc drive: 62x/62x writer dvd-ram cd/rw xa/form2 cdda pop-up
Uniform CD-ROM driver Revision: 3.20
sr 8:0:0:0: Attached scsi generic sg2 type 5
scsi 9:0:0:0: Direct-Access Generic  Ultra HS-COMBO   2.01 PQ: 0 ANSI: 0
sd 9:0:0:0: Attached scsi generic sg3 type 0
sd 9:0:0:0: [sdc] Attached SCSI removable disk
scsi 9:0:0:1: Direct-Access Generic  Ultra HS-SD/MMC2 2.01 PQ: 0 ANSI: 0
sd 9:0:0:1: Attached scsi generic sg4 type 0
sd 9:0:0:1: [sdd] Attached SCSI removable disk
md: Waiting for all devices to be available before autodetect
md: If you don't use raid, use raid=noautodetect
md: Autodetecting RAID arrays.
md: Scanned 0 and added 0 devices.
md: autorun ...
md: ... autorun DONE.
VFS: Mounted root (iso9660 filesystem) readonly on device 11:0.
devtmpfs: mounted
Freeing unused kernel memory: 656k freed

=
Transferring basename: typhoon-unit0
Sourcing 
isolinux/tftpboot/cnp/x86_ng/7.0.0/targets/sb_rms/common//etc/sysconfig/pivotroot
Setting up rootfs...


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


Re: [PATCH V2 2/3] Remove VLAIS usage from gadget code

2012-12-04 Thread Behan Webster

On 12-12-04 11:24 PM, Sebastian Andrzej Siewior wrote:

On Mon, Dec 03, 2012 at 07:57:33PM +0100, Behan Webster wrote:

However, in order to approximate what gcc is doing in code, obviously
some math is required. The thought was that macros would hide the
worst of it, trying not to obfuscate what was actually being done.

Why hide? The thing that is done here is setting up pointers and keep this
struct as a container. It is never used again, just freed. Therefore I would
suggest to remove and do something different.

Fair enough. That works too.


I've been profiling some sample code around this implementation
comparing it between compilers, and it approximates the code size and
speed of using VLAIS in gcc (especially with -O2). It actually
performs better than the previously proposed macros.

I'm not concerned about speed here. This is an one time setup.

Which is all good in the case of the gadget code.

However VLAIS is used in other places too where code size and speed are 
very important. The proposal was for something which might be used for 
more than just the gadget code. VLAIS is used in only a handful of 
places in the kernel. They just happen to be in important parts of the 
kernel which was why the approach was to change as little as necessary.



But certainly if anyone has a solution which works for everyone, then
I'm more than happy to adopt it. The LLVM community has made quite a
few changes in order to help get Linux working with clang. However,

That is nice to hear. Besides gcc there is the icc.
Lots of people have brought up icc. Although in the same breath most 
also say nobody is using it anymore. However, I have no idea whether 
that is true. The difference is that clang is widely available in most 
distros; icc is not.



VLAIS is not something they are willing to accept (for various
reasons). There are other patches to LLVM that are still working

Is this not described in C99 6.7.2.1p16?
You're thinking of "Flexible Array Members". Essentially the last 
element in a structure can be the equivalent of a zero length array; 
something which both gcc and clang support today.


From C99 6.7.2.1p16:
16 As a special case, the last element of a structure with more than 
one named member may
have an incomplete array type; this is called a flexible array member. 
In most situations,
the flexible array member is ignored. In particular, the size of the 
structure is as if the
flexible array member were omitted except that it may have more 
trailing padding than
the omission would imply. Howev er, when a . (or ->) operator has a 
left operand that is
(a pointer to) a structure with a flexible array member and the right 
operand names that
member, it behaves as if that member were replaced with the longest 
array (with the same
element type) that would not make the structure larger than the object 
being accessed; the
offset of the array shall remain that of the flexible array member, 
even if this would differ
from that of the replacement array. If this array would have no 
elements, it behaves as if
it had one element but the behavior is undefined if any attempt is made 
to access that

element or to generate a pointer one past it.


However if we're considering the C99 standard, it also explicitly 
disallows the use of VLAs in structs (VLAIS).


From C99 6.7.2.1 p2:
2 A structure or union shall not contain a member with incomplete or 
function type (hence,
a structure shall not contain an instance of itself, but may contain a 
pointer to an instance
of itself), except that the last member of a structure with more than 
one named member
may have incomplete array type; such a structure (and any union 
containing, possibly
recursively, a member that is such a structure) shall not be a member 
of a structure or an

element of an array.

From C99 6.7.5.2 p4:

4 If the size is not present, the array type is an incomplete type. 
Essentially all arrays in a structure must not be variable length except 
the last member of the array which can be a zero length array (which can 
be used to approximate a VLA at the end). It also says that a struct 
which uses a flexible array member can't be used inside another struct.



their way upstream that are required to be able to compile Linux as
well.

I hope the other are "simple" to get in :)
I hope so too. But like the Linux kernel community, the LLVM community 
have standards and procedures for getting code accepted which take time.


Thanks,

Behan

--
Behan Webster
beh...@converseincode.com

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


[RFC v2 00/11] USB core reset changes

2012-12-04 Thread Sarah Sharp
Hi Alan,

I reworked the warm reset patches, could you take a look at them?

Changelog:

 - Added xHCI roothub port polling when a change bit is set.

 - Removed patch to unconditionally clear all change bits on USB 2.0
   port disable, since the port polling should now take care of that.

 - Reworked the second patch description to make it more clear why it's
   necessary to ignore errors for the xHCI Reset Device command.

 - Changed the patch to ignore port state until the reset is complete to
   do that for all speeds of hubs.

 - Broke the final patch "USB: Fix connected device switch to Inactive
   state." into the last four patches.  Hopefully this is more readable.


Unchanged patches:
  USB: Handle auto-transition from hot to warm reset.
  USB: Ignore xHCI Reset Device status.
  USB: Allow USB 3.0 ports to be disabled.
  USB: Increase reset timeout.
  USB: Handle warm reset failure on empty port.

Thanks,
Sarah Sharp


The following changes since commit fb37ef98015f864d22be223a0e0d93547cd1d4ef:

  USB: mark uas driver as BROKEN (2012-11-28 13:28:54 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git warm-reset-next-2

for you to fetch changes up to d648bb68116e2c30aa6c272e2f824eb3afecb46d:

  USB: Fix connected device switch to Inactive state. (2012-12-04 16:24:01 
-0800)


Sarah Sharp (11):
  USB: Handle auto-transition from hot to warm reset.
  USB: Ignore xHCI Reset Device status.
  USB: Allow USB 3.0 ports to be disabled.
  USB: Increase reset timeout.
  USB: Ignore port state until reset completes.
  USB: Handle warm reset failure on empty port.
  xhci: Avoid "dead ports", add roothub port polling.
  USB: Don't use EHCI port sempahore for USB 3.0 hubs.
  USB: Prepare for refactoring by adding extra udev checks.
  USB: Rip out recursive call on warm port reset.
  USB: Fix connected device switch to Inactive state.

 drivers/usb/core/hub.c   |  271 +++---
 drivers/usb/host/xhci-hub.c  |   36 ++-
 drivers/usb/host/xhci-ring.c |7 +
 drivers/usb/host/xhci.c  |   10 ++
 4 files changed, 227 insertions(+), 97 deletions(-)
--
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


[RFC v2 01/11] USB: Handle auto-transition from hot to warm reset.

2012-12-04 Thread Sarah Sharp
USB 3.0 hubs and roothubs will automatically transition a failed hot
reset to a warm (BH) reset.  In that case, the warm reset change bit
will be set, and the link state change bit may also be set.  Change
hub_port_finish_reset to unconditionally clear those change bits for USB
3.0 hubs.  If these bits are not cleared, we may lose port change events
from the roothub.

This commit should be backported to kernels as old as 3.2, that contain
the commit 75d7cf72ab9fa01dc70877aa5c68e8ef477229dc "usbcore: refine
warm reset logic".

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 drivers/usb/core/hub.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a815fd2..7f8f10e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2580,16 +2580,16 @@ static void hub_port_finish_reset(struct usb_hub *hub, 
int port1,
clear_port_feature(hub->hdev,
port1, USB_PORT_FEAT_C_RESET);
/* FIXME need disconnect() for NOTATTACHED device */
-   if (warm) {
+   if (hub_is_superspeed(hub->hdev)) {
clear_port_feature(hub->hdev, port1,
USB_PORT_FEAT_C_BH_PORT_RESET);
clear_port_feature(hub->hdev, port1,
USB_PORT_FEAT_C_PORT_LINK_STATE);
-   } else {
+   }
+   if (!warm)
usb_set_device_state(udev, *status
? USB_STATE_NOTATTACHED
: USB_STATE_DEFAULT);
-   }
break;
}
 }
-- 
1.7.9

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


[RFC v2 02/11] USB: Ignore xHCI Reset Device status.

2012-12-04 Thread Sarah Sharp
When the USB core finishes reseting a USB device, the xHCI driver sends
a Reset Device command to the host.  The xHC then updates its internal
representation of the USB device to the 'Default' device state.  If the
device was already in the Default state, the xHC will complete the
command with an error status.

If a device needs to be reset several times during enumeration, the
second reset will always fail because of the xHCI Reset Device command.
This can cause issues during enumeration.

For example, usb_reset_and_verify_device calls into hub_port_init in a
loop.  Say that on the first call into hub_port_init, the device is
successfully reset, but doesn't respond to several set address control
transfers.  Then the port will be disabled, but the udev will remain in
tact.  usb_reset_and_verify_device will call into hub_port_init again.

On the second call into hub_port_init, the device will be reset, and the
xHCI driver will issue a Reset Device command.  This command will fail
(because the device is already in the Default state), and
usb_reset_and_verify_device will fail.  The port will be disabled, and
the device won't be able to enumerate.

Fix this by ignoring the return value of the HCD reset_device callback.

This commit should be backported to kernels as old as 3.2, that contain
the commit 75d7cf72ab9fa01dc70877aa5c68e8ef477229dc "usbcore: refine
warm reset logic".

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 drivers/usb/core/hub.c |   13 +
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 7f8f10e..3bc50fc 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2565,14 +2565,11 @@ static void hub_port_finish_reset(struct usb_hub *hub, 
int port1,
msleep(10 + 40);
update_devnum(udev, 0);
hcd = bus_to_hcd(udev->bus);
-   if (hcd->driver->reset_device) {
-   *status = hcd->driver->reset_device(hcd, udev);
-   if (*status < 0) {
-   dev_err(&udev->dev, "Cannot reset "
-   "HCD device state\n");
-   break;
-   }
-   }
+   /* The xHC may think the device is already reset,
+* so ignore the status.
+*/
+   if (hcd->driver->reset_device)
+   hcd->driver->reset_device(hcd, udev);
}
/* FALL THROUGH */
case -ENOTCONN:
-- 
1.7.9

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


[RFC v2 03/11] USB: Allow USB 3.0 ports to be disabled.

2012-12-04 Thread Sarah Sharp
If hot and warm reset fails, or a port remains in the Compliance Mode,
the USB core needs to be able to disable a USB 3.0 port.  Unlike USB 2.0
ports, once the port is placed into the Disabled link state, it will not
report any new device connects.  To get device connect notifications, we
need to put the link into the Disabled state, and then the RxDetect
state.

The xHCI driver needs to atomically clear all change bits on USB 3.0
port disable, so that we get Port Status Change Events for future port
changes.

(We could technically do this in the USB core instead of in the xHCI
roothub code, since the port state machine can't advance out of the
disabled state until we set the link state to RxDetect.  However,
external USB 3.0 hubs don't need this code.  They are level-triggered,
not edge-triggered like xHCI, so they will continue to send interrupt
events when any change bit is set.  Therefore it doesn't make sense to
put this code in the USB core.)

This patch is part of a series to fix several reports of infinite loops
on device enumeration failure.  This includes John, when he boots with
a USB 3.0 device (Roseweil eusb3 enclosure) attached to his NEC 0.96
host controller.  The fix requires warm reset support, so it does not
make sense to backport this patch to stable kernels without warm reset
support.

This patch should be backported to kernels as old as 3.2, contain the
commit ID 75d7cf72ab9fa01dc70877aa5c68e8ef477229dc "usbcore: refine warm
reset logic"

Signed-off-by: Sarah Sharp 
Reported-by: John Covici 
Cc: sta...@vger.kernel.org
---
 drivers/usb/core/hub.c  |   63 +-
 drivers/usb/host/xhci-hub.c |   29 +++-
 2 files changed, 89 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 3bc50fc..968ec37 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -877,6 +877,60 @@ static int hub_hub_status(struct usb_hub *hub,
return ret;
 }
 
+static int hub_set_port_link_state(struct usb_hub *hub, int port1,
+   unsigned int link_status)
+{
+   return set_port_feature(hub->hdev,
+   port1 | (link_status << 3),
+   USB_PORT_FEAT_LINK_STATE);
+}
+
+/*
+ * If USB 3.0 ports are placed into the Disabled state, they will no longer
+ * detect any device connects or disconnects.  This is generally not what the
+ * USB core wants, since it expects a disabled port to produce a port status
+ * change event when a new device connects.
+ *
+ * Instead, set the link state to Disabled, wait for the link to settle into
+ * that state, clear any change bits, and then put the port into the RxDetect
+ * state.
+ */
+static int hub_usb3_port_disable(struct usb_hub *hub, int port1)
+{
+   int ret;
+   int total_time;
+   u16 portchange, portstatus;
+
+   if (!hub_is_superspeed(hub->hdev))
+   return -EINVAL;
+
+   ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED);
+   if (ret) {
+   dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
+   port1, ret);
+   return ret;
+   }
+
+   /* Wait for the link to enter the disabled state. */
+   for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) {
+   ret = hub_port_status(hub, port1, &portstatus, &portchange);
+   if (ret < 0)
+   return ret;
+
+   if ((portstatus & USB_PORT_STAT_LINK_STATE) ==
+   USB_SS_PORT_LS_SS_DISABLED)
+   break;
+   if (total_time >= HUB_DEBOUNCE_TIMEOUT)
+   break;
+   msleep(HUB_DEBOUNCE_STEP);
+   }
+   if (total_time >= HUB_DEBOUNCE_TIMEOUT)
+   dev_warn(hub->intfdev, "Could not disable port %d after %d 
ms\n",
+   port1, total_time);
+
+   return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT);
+}
+
 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
 {
struct usb_device *hdev = hub->hdev;
@@ -885,8 +939,13 @@ static int hub_port_disable(struct usb_hub *hub, int 
port1, int set_state)
if (hub->ports[port1 - 1]->child && set_state)
usb_set_device_state(hub->ports[port1 - 1]->child,
USB_STATE_NOTATTACHED);
-   if (!hub->error && !hub_is_superspeed(hub->hdev))
-   ret = clear_port_feature(hdev, port1, USB_PORT_FEAT_ENABLE);
+   if (!hub->error) {
+   if (hub_is_superspeed(hub->hdev))
+   ret = hub_usb3_port_disable(hub, port1);
+   else
+   ret = clear_port_feature(hdev, port1,
+   USB_PORT_FEAT_ENABLE);
+   }
if (ret)
dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",

[RFC v2 04/11] USB: Increase reset timeout.

2012-12-04 Thread Sarah Sharp
John's NEC 0.96 xHCI host controller needs a longer timeout for a warm
reset to complete.  The logs show it takes 650ms to complete the warm
reset, so extend the hub reset timeout to 800ms to be on the safe side.

This commit should be backported to kernels as old as 3.2, that contain
the commit 75d7cf72ab9fa01dc70877aa5c68e8ef477229dc "usbcore: refine
warm reset logic".

Signed-off-by: Sarah Sharp 
Reported-by: John Covici 
Cc: sta...@vger.kernel.org
---
 drivers/usb/core/hub.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 968ec37..b9ce5e8 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2499,7 +2499,7 @@ static unsigned hub_is_wusb(struct usb_hub *hub)
 #define HUB_SHORT_RESET_TIME   10
 #define HUB_BH_RESET_TIME  50
 #define HUB_LONG_RESET_TIME200
-#define HUB_RESET_TIMEOUT  500
+#define HUB_RESET_TIMEOUT  800
 
 static int hub_port_reset(struct usb_hub *hub, int port1,
struct usb_device *udev, unsigned int delay, bool warm);
-- 
1.7.9

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


[RFC v2 05/11] USB: Ignore port state until reset completes.

2012-12-04 Thread Sarah Sharp
The port reset code bails out early if the current connect status is
cleared (device disconnected).  If we're issuing a hot reset, it may
also look at the link state before the reset is finished.

Section 10.14.2.6 of the USB 3.0 spec says that when a port enters the
Error state or Resetting state, the port connection bit retains the
value from the previous state.  Therefore we can't trust it until the
reset finishes.  Also, the xHCI spec section 4.19.1.2.5 says software
shall ignore the link state while the port is resetting, as it can be in
an unknown state.

The port state during reset is also unknown for USB 2.0 hubs.  The hub
sends a reset signal by driving the bus into an SE0 state.  This
overwhelms the "connect" signal from the device, so the port can't tell
whether anything is connected or not.

Fix the port reset code to ignore the port link state and current
connect bit until the reset finishes.

This patch should be backported to all stable kernels.

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 drivers/usb/core/hub.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b9ce5e8..b7b055f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2534,6 +2534,10 @@ static int hub_port_wait_reset(struct usb_hub *hub, int 
port1,
if (ret < 0)
return ret;
 
+   /* The port state is unknown until the reset completes. */
+   if ((portstatus & USB_PORT_STAT_RESET))
+   goto delay;
+
/*
 * Some buggy devices require a warm reset to be issued even
 * when the port appears not to be connected.
@@ -2601,6 +2605,7 @@ static int hub_port_wait_reset(struct usb_hub *hub, int 
port1,
return 0;
}
 
+delay:
/* switch to the long delay after two short delay failures */
if (delay_time >= 2 * HUB_SHORT_RESET_TIME)
delay = HUB_LONG_RESET_TIME;
-- 
1.7.9

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


[RFC v2 11/11] USB: Fix connected device switch to Inactive state.

2012-12-04 Thread Sarah Sharp
A USB 3.0 device can transition to the Inactive state if a U1 or U2 exit
transition fails.  The current code in hub_events simply issues a warm
reset, but does not call any pre-reset or post-reset driver methods (or
unbind/rebind drivers without them).  Therefore the drivers won't know
their device has just been reset.

hub_events should instead call usb_reset_device.  This means
hub_port_reset now needs to figure out whether it should issue a warm
reset or a hot reset.

Remove the FIXME note about needing disconnect() for a NOTATTACHED
device.  This patch fixes that.

Signed-off-by: Sarah Sharp 
---
 drivers/usb/core/hub.c |   29 -
 1 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a502857..9341302 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2609,7 +2609,6 @@ static void hub_port_finish_reset(struct usb_hub *hub, 
int port1,
case -ENODEV:
clear_port_feature(hub->hdev,
port1, USB_PORT_FEAT_C_RESET);
-   /* FIXME need disconnect() for NOTATTACHED device */
if (hub_is_superspeed(hub->hdev)) {
clear_port_feature(hub->hdev, port1,
USB_PORT_FEAT_C_BH_PORT_RESET);
@@ -2643,6 +2642,18 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
 * Some companion controllers don't like it when they mix.
 */
down_read(&ehci_cf_port_reset_rwsem);
+   } else if (!warm) {
+   /*
+* If the caller hasn't explicitly requested a warm reset,
+* double check and see if one is needed.
+*/
+   status = hub_port_status(hub, port1,
+   &portstatus, &portchange);
+   if (status < 0)
+   goto done;
+
+   if (hub_port_warm_reset_required(hub, portstatus))
+   warm = true;
}
 
/* Reset the port */
@@ -4694,12 +4705,20 @@ static void hub_events(void)
 */
if (hub_port_warm_reset_required(hub, portstatus)) {
int status;
+   struct usb_device *udev = hdev->children[i-1];
 
dev_dbg(hub_dev, "warm reset port %d\n", i);
-   status = hub_port_reset(hub, i, NULL,
-   HUB_BH_RESET_TIME, true);
-   if (status < 0)
-   hub_port_disable(hub, i, 1);
+   if (!udev) {
+   status = hub_port_reset(hub, i,
+   NULL, HUB_BH_RESET_TIME,
+   true);
+   if (status < 0)
+   hub_port_disable(hub, i, 1);
+   } else {
+   usb_lock_device(udev);
+   status = usb_reset_device(udev);
+   usb_unlock_device(udev);
+   }
connect_change = 0;
}
 
-- 
1.7.9

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


[RFC v2 10/11] USB: Rip out recursive call on warm port reset.

2012-12-04 Thread Sarah Sharp
When a hot reset fails on a USB 3.0 port, the current port reset code
recursively calls hub_port_reset inside hub_port_wait_reset.  This isn't
ideal, since we should avoid recursive calls in the kernel, and it also
doesn't allow us to issue multiple warm resets on reset failures.

Rip out the recursive call.  Instead, add code to hub_port_reset to
issue a warm reset if the hot reset fails, and try multiple warm resets
before giving up on the port.

In hub_port_wait_reset, remove the recursive call and re-indent.  The
code is basically the same, except:

1. It bails out early if the port has transitioned to Inactive or
Compliance Mode after the reset completed.

2. It doesn't consider a connect status change to be a failed reset.  If
multiple warm resets needed to be issued, the connect status may have
changed, so we need to ignore that and look at the port link state
instead.  hub_port_reset will now do that.

3. It unconditionally sets udev->speed on all types of successful
resets.  The old recursive code would set the port speed when the second
hub_port_reset returned.

With the new code in hub_port_reset, the 'warm' variable may change on a
transition from a hot reset to a warm reset.  So hub_port_finish_reset
could be called with 'warm' set to true when a connected USB device has
been reset.  Fix the code by unconditionally updating the device number,
informing the host that the device has been reset, and setting the
device state to default.

In hub_port_finish_reset, unconditionally clear the connect status
change (CSC) bit for USB 3.0 hubs when the port reset is done.  If we
had to issue multiple warm resets for a device, that bit may have been
set if the device went into SS.Inactive and then was successfully warm
reset.

Signed-off-by: Sarah Sharp 
---
 drivers/usb/core/hub.c |  159 +--
 1 files changed, 71 insertions(+), 88 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index d8de712..a502857 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2538,80 +2538,39 @@ static int hub_port_wait_reset(struct usb_hub *hub, int 
port1,
if ((portstatus & USB_PORT_STAT_RESET))
goto delay;
 
-   /*
-* Some buggy devices require a warm reset to be issued even
-* when the port appears not to be connected.
-*/
-   if (!warm) {
-   /*
-* Some buggy devices can cause an NEC host controller
-* to transition to the "Error" state after a hot port
-* reset.  This will show up as the port state in
-* "Inactive", and the port may also report a
-* disconnect.  Forcing a warm port reset seems to make
-* the device work.
-*
-* See https://bugzilla.kernel.org/show_bug.cgi?id=41752
-*/
-   if (hub_port_warm_reset_required(hub, portstatus)) {
-   int ret;
-
-   if ((portchange & USB_PORT_STAT_C_CONNECTION))
-   clear_port_feature(hub->hdev, port1,
-   
USB_PORT_FEAT_C_CONNECTION);
-   if (portchange & USB_PORT_STAT_C_LINK_STATE)
-   clear_port_feature(hub->hdev, port1,
-   
USB_PORT_FEAT_C_PORT_LINK_STATE);
-   if (portchange & USB_PORT_STAT_C_RESET)
-   clear_port_feature(hub->hdev, port1,
-   USB_PORT_FEAT_C_RESET);
-   dev_dbg(hub->intfdev, "hot reset failed, warm 
reset port %d\n",
-   port1);
-   ret = hub_port_reset(hub, port1,
-   udev, HUB_BH_RESET_TIME,
-   true);
-   if ((portchange & USB_PORT_STAT_C_CONNECTION))
-   clear_port_feature(hub->hdev, port1,
-   
USB_PORT_FEAT_C_CONNECTION);
-   return ret;
-   }
-   /* Device went away? */
-   if (!(portstatus & USB_PORT_STAT_CONNECTION))
-   return -ENOTCONN;
+   if (hub_port_warm_reset_required(hub, portstatus))
+   return -ENOTCONN;
 
-   /* bomb out completely if the connection bounced */
-   if ((portchange & USB_PORT_STAT_C_CONNECTION))
- 

[RFC v2 08/11] USB: Don't use EHCI port sempahore for USB 3.0 hubs.

2012-12-04 Thread Sarah Sharp
The EHCI host controller needs to prevent EHCI initialization when the
UHCI or OHCI companion controller is in the middle of a port reset.  It
uses ehci_cf_port_reset_rwsem to do this.  USB 3.0 hubs can't be under
an EHCI host controller, so it makes no sense to down the semaphore for
USB 3.0 hubs.  It also makes the warm port reset code more complex.

Don't down ehci_cf_port_reset_rwsem for USB 3.0 hubs.

Signed-off-by: Sarah Sharp 
---
 drivers/usb/core/hub.c |   15 +++
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 85977de..c8d32b4 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2668,17 +2668,16 @@ static int hub_port_reset(struct usb_hub *hub, int 
port1,
 {
int i, status;
 
-   if (!warm) {
-   /* Block EHCI CF initialization during the port reset.
-* Some companion controllers don't like it when they mix.
-*/
-   down_read(&ehci_cf_port_reset_rwsem);
-   } else {
-   if (!hub_is_superspeed(hub->hdev)) {
+   if (!hub_is_superspeed(hub->hdev)) {
+   if (warm) {
dev_err(hub->intfdev, "only USB3 hub support "
"warm reset\n");
return -EINVAL;
}
+   /* Block EHCI CF initialization during the port reset.
+* Some companion controllers don't like it when they mix.
+*/
+   down_read(&ehci_cf_port_reset_rwsem);
}
 
/* Reset the port */
@@ -2716,7 +2715,7 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
port1);
 
 done:
-   if (!warm)
+   if (!hub_is_superspeed(hub->hdev))
up_read(&ehci_cf_port_reset_rwsem);
 
return status;
-- 
1.7.9

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


[RFC v2 07/11] xhci: Avoid "dead ports", add roothub port polling.

2012-12-04 Thread Sarah Sharp
The USB core hub thread (khubd) is designed with external USB hubs in
mind.  It expects that if a port status change bit is set, the hub will
continue to send a notification through the hub status data transfer.
Basically, it expects hub notifications to be level-triggered.

The xHCI host controller is designed to be edge-triggered.  When all
port status change bits are clear, and a new change bit is set, the xHC
will generate a Port Status Change Event.  If another change bit is set
in the same port status register before the first bit is cleared, it
will not send another event.

This means that the hub code may lose port status changes because of
race conditions between clearing change bits.  The user sees this as a
"dead port" that doesn't react to device connects.

The fix is to turn on port polling whenever a new change bit is set.
Once the USB core issues a hub status request that shows that no change
bits are set in any USB ports, turn off port polling.

We can't allow the USB core to poll the roothub for port events during
host suspend because if the PCI host is in D3cold, the port registers
will be all f's.  Instead, stop the port polling timer, and
unconditionally restart it when the host resumes.  If there are no port
change bits set after the resume, the first call to hub_status_data will
disable polling.

This patch should be backported to stable kernels with the first xHCI
support, 2.6.31 and newer, that include the commit
0f2a79300a1471cf92ab43af165ea13555c8b0a5 "USB: xhci: Root hub support."
There will be merge conflicts because the check for HC_STATE_SUSPENDED
was moved into xhci_suspend in 3.8.

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 drivers/usb/host/xhci-hub.c  |7 +++
 drivers/usb/host/xhci-ring.c |7 +++
 drivers/usb/host/xhci.c  |   10 ++
 3 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 4c0cdd0..e873ee6 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -984,6 +984,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
int max_ports;
__le32 __iomem **port_array;
struct xhci_bus_state *bus_state;
+   bool reset_change = false;
 
max_ports = xhci_get_ports(hcd, &port_array);
bus_state = &xhci->bus_state[hcd_index(hcd)];
@@ -1015,6 +1016,12 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
buf[(i + 1) / 8] |= 1 << (i + 1) % 8;
status = 1;
}
+   if ((temp & PORT_RC))
+   reset_change = true;
+   }
+   if (!status && !reset_change) {
+   xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
+   clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
}
spin_unlock_irqrestore(&xhci->lock, flags);
return status ? retval : 0;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index cbb44b7..ebb6358 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1725,6 +1725,13 @@ cleanup:
if (bogus_port_status)
return;
 
+   /*
+* xHCI portsc bits are level-triggered. An event is sent on the first
+* change bit, but won't be sent if another change bit is still set.
+* Poll to avoid losing change bits.
+*/
+   xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
+   set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
spin_unlock(&xhci->lock);
/* Pass this up to the core */
usb_hcd_poll_rh_status(hcd);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 5c72c43..f1f01a8 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -884,6 +884,11 @@ int xhci_suspend(struct xhci_hcd *xhci)
xhci->shared_hcd->state != HC_STATE_SUSPENDED)
return -EINVAL;
 
+   /* Don't poll the roothubs on bus suspend. */
+   xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
+   clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+   del_timer_sync(&hcd->rh_timer);
+
spin_lock_irq(&xhci->lock);
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags);
@@ -1069,6 +1074,11 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
if (xhci->quirks & XHCI_COMP_MODE_QUIRK)
compliance_mode_recovery_timer_init(xhci);
 
+   /* Re-enable port polling. */
+   xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
+   set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+   usb_hcd_poll_rh_status(hcd);
+
return retval;
 }
 #endif /* CONFIG_PM */
-- 
1.7.9

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


[RFC v2 06/11] USB: Handle warm reset failure on empty port.

2012-12-04 Thread Sarah Sharp
An empty port can transition to either Inactive or Compliance Mode if a
newly connected USB 3.0 device fails to link train.  In that case, we
issue a warm reset.  Some devices, such as John's Roseweil eusb3
enclosure, slip back into Compliance Mode after the warm reset.

The current warm reset code does not check for device connect status on
warm reset completion, and it incorrectly reports the warm reset
succeeded.  This causes the USB core to attempt to send a Set Address
control transfer to a port in Compliance Mode, which will always fail.

Make hub_port_wait_reset check the current connect status and link state
after the warm reset completes.  Return a failure status if the device
is disconnected or the link state is Compliance Mode or SS.Inactive.

Make hub_events disable the port if warm reset fails.  This will disable
the port, and then bring it back into the RxDetect state.  Make the USB
core ignore the connect change until the device reconnects.

Note that this patch does NOT handle connected devices slipping into the
Inactive state very well.  This is a concern, because devices can go
into the Inactive state on U1/U2 exit failure.  However, the fix for
that case is too large for stable, so it will be submitted in a separate
patch.

This patch should be backported to kernels as old as 3.2, contain the
commit ID 75d7cf72ab9fa01dc70877aa5c68e8ef477229dc "usbcore: refine warm
reset logic"

Signed-off-by: Sarah Sharp 
Reported-by: John Covici 
Cc: sta...@vger.kernel.org
---
 drivers/usb/core/hub.c |   18 +++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b7b055f..85977de 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2601,8 +2601,15 @@ static int hub_port_wait_reset(struct usb_hub *hub, int 
port1,
return 0;
}
} else {
-   if (portchange & USB_PORT_STAT_C_BH_RESET)
-   return 0;
+   if (!(portchange & USB_PORT_STAT_C_BH_RESET))
+   goto delay;
+
+   if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
+   hub_port_warm_reset_required(hub,
+   portstatus))
+   return -ENOTCONN;
+
+   return 0;
}
 
 delay:
@@ -4699,9 +4706,14 @@ static void hub_events(void)
 * SS.Inactive state.
 */
if (hub_port_warm_reset_required(hub, portstatus)) {
+   int status;
+
dev_dbg(hub_dev, "warm reset port %d\n", i);
-   hub_port_reset(hub, i, NULL,
+   status = hub_port_reset(hub, i, NULL,
HUB_BH_RESET_TIME, true);
+   if (status < 0)
+   hub_port_disable(hub, i, 1);
+   connect_change = 0;
}
 
if (connect_change)
-- 
1.7.9

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


[RFC v2 09/11] USB: Prepare for refactoring by adding extra udev checks.

2012-12-04 Thread Sarah Sharp
The next patch will refactor the hub port code to rip out the recursive
call to hub_port_reset on a failed hot reset.  In preparation for that,
make sure all code paths can deal with being called with a NULL udev.
The usb_device will not be valid if warm reset was issued because a port
transitioned to the Inactive or Compliance Mode on a device connect.

This patch should have no effect on current behavior.

Signed-off-by: Sarah Sharp 
---
 drivers/usb/core/hub.c |   21 +
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index c8d32b4..d8de712 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2588,6 +2588,9 @@ static int hub_port_wait_reset(struct usb_hub *hub, int 
port1,
 */
if (!(portstatus & USB_PORT_STAT_RESET) &&
(portstatus & USB_PORT_STAT_ENABLE)) {
+   if (!udev)
+   return 0;
+
if (hub_is_wusb(hub))
udev->speed = USB_SPEED_WIRELESS;
else if (hub_is_superspeed(hub->hdev))
@@ -2634,13 +2637,15 @@ static void hub_port_finish_reset(struct usb_hub *hub, 
int port1,
struct usb_hcd *hcd;
/* TRSTRCY = 10 ms; plus some extra */
msleep(10 + 40);
-   update_devnum(udev, 0);
-   hcd = bus_to_hcd(udev->bus);
-   /* The xHC may think the device is already reset,
-* so ignore the status.
-*/
-   if (hcd->driver->reset_device)
-   hcd->driver->reset_device(hcd, udev);
+   if (udev) {
+   update_devnum(udev, 0);
+   hcd = bus_to_hcd(udev->bus);
+   /* The xHC may think the device is already
+* reset, so ignore the status.
+*/
+   if (hcd->driver->reset_device)
+   hcd->driver->reset_device(hcd, udev);
+   }
}
/* FALL THROUGH */
case -ENOTCONN:
@@ -2654,7 +2659,7 @@ static void hub_port_finish_reset(struct usb_hub *hub, 
int port1,
clear_port_feature(hub->hdev, port1,
USB_PORT_FEAT_C_PORT_LINK_STATE);
}
-   if (!warm)
+   if (!warm && udev)
usb_set_device_state(udev, *status
? USB_STATE_NOTATTACHED
: USB_STATE_DEFAULT);
-- 
1.7.9

--
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: Correlating SOF with host system time

2012-12-04 Thread Stefan Tauner
On Tue, 4 Dec 2012 16:27:00 -0500 (EST)
Alan Stern  wrote:

> I don't think referencing times to SOF packets is the best approach, 
> although it probably is the approach that would yield the most 
> precision.  How precise do you want your synchronization to be?

It should be below 1ms accuracy, but being more precise does never hurt of
course :)
BTW anyone interested in really accurate USB synchronization should
read the paper "Sub-nanosecond Distributed Synchronisation via the
Universal Serial Bus"; they use custom hardware though.

> Running NTP over a USB-based network link would certainly be the 
> easiest solution, if your device can support it.  Over the long run, it 
> might even be more accurate on average than using SOF packets.

We are talking about microcontrollers with a few kB RAM at most, so
just cross-compiling any (S)NTP client wont cut it probably :)
So the SOF approach seems to be way more elegant and easy to implement
to me... in theory.

Another nice property is that SOF packets are sent for every frame in
any case (but errors) and they are broadcasted, which is both
advantageous regarding bandwidth usage and independent of the number of
devices attached.

Regarding long-term stability/precision i am not sure i can agree with
you. If i throw the same amount of statistics/algorithm complexity at
the SOF scheme and a software-exclusive approach i dont see how the
latter could be better :)

-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
--
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 01/10] USB: Set usb port's DeviceRemovable according acpi information in EHCI

2012-12-04 Thread Lan Tianyu
On 2012年11月29日 08:08, Alan Stern wrote:
> On Wed, 28 Nov 2012, Sarah Sharp wrote:
> 
 The shared code to overwrite the bits should probably print a warning if
 the host and ACPI bits differ.
>>>
>>> I'm not so sure about that.  For one thing, who wants warnings to be 
>>> logged every time they run "lsusb -v"?
>>
>> Yeah, that's probably not a great idea.
>>
>>> Also, this sort of thing might be more common than you might expect.  
>>> I'd guess that if the ACPI information contains anything useful at all, 
>>> it will be different from the [Ex]HCI information.
>>>
>>> Tianyu's patches log such warnings for xHCI but not for EHCI.  That 
>>> inconsistency is another reason to rework them.
>>
>> Tianyu did that because I asked him to for xHCI.  I didn't think about
>> the lsusb implications.  You're right that it will probably be annoying
>> to the user, so he should just drop the warning in the shared code.
> 
> It could be changed to a dev_dbg.  That wouldn't bother people and it 
> might be useful.
> 
> Alan Stern
> 
Hi Alan:
how about following patch?

Index: usb/drivers/usb/core/hub.c
===
--- usb.orig/drivers/usb/core/hub.c
+++ usb/drivers/usb/core/hub.c
@@ -1441,6 +1441,8 @@ static int hub_configure(struct usb_hub
dev_err(hub->intfdev,
"couldn't create port%d device.\n", i + 1);

+   usb_hub_adjust_DeviceRemovable(hdev, hub->descriptor);
+
hub_activate(hub, HUB_INIT);
return 0;

@@ -5086,8 +5088,56 @@ usb_get_hub_port_connect_type(struct usb
 {
struct usb_hub *hub = hdev_to_hub(hdev);

+   if (!hub)
+   return USB_PORT_CONNECT_TYPE_UNKNOWN;
+
return hub->ports[port1 - 1]->connect_type;
 }
+EXPORT_SYMBOL_GPL(usb_get_hub_port_connect_type);
+
+void usb_hub_adjust_DeviceRemovable(struct usb_device *hdev,
+   struct usb_hub_descriptor *desc)
+{
+   enum usb_port_connect_type connect_type;
+   int i;
+
+   if (!hub_is_superspeed(hdev)) {
+   for (i = 1; i <= hdev->maxchild; i++) {
+   connect_type =
+   usb_get_hub_port_connect_type(hdev, i);
+
+   if (connect_type ==
USB_PORT_CONNECT_TYPE_HARD_WIRED) {
+   u8 mask = 1 << (i%8);
+
+   if (!(desc->u.hs.DeviceRemovable[i/8] &
mask))
+   dev_dbg(&hdev->dev, "usb2.0
port%d's DeviceRemovable is changed to 1 according platform
information.\n", i);
+
+   desc->u.hs.DeviceRemovable[i/8]
+   |= mask;
+   }
+   }
+   } else {
+   u16 port_removable =
+   le16_to_cpu(desc->u.ss.DeviceRemovable);
+
+   for (i = 1; i <= hdev->maxchild; i++) {
+   connect_type =
+   usb_get_hub_port_connect_type(hdev, i);
+
+   if (connect_type ==
USB_PORT_CONNECT_TYPE_HARD_WIRED) {
+   u16 mask = 1 << i;
+
+   if (!(port_removable & mask))
+   dev_dbg(&hdev->dev, "usb3.0
port%d's DeviceRemovable is changed to 1 according platform
information.\n", i);
+
+   port_removable |= mask;
+   }
+   }
+
+   desc->u.ss.DeviceRemovable =
+   cpu_to_le16(port_removable);
+   }
+}

 #ifdef CONFIG_ACPI
 /**
Index: usb/drivers/usb/core/usb.h
===
--- usb.orig/drivers/usb/core/usb.h
+++ usb/drivers/usb/core/usb.h
@@ -1,5 +1,6 @@
 #include 
 #include 
+#include 

 struct dev_state;

@@ -169,10 +170,13 @@ extern void usb_notify_add_device(struct
 extern void usb_notify_remove_device(struct usb_device *udev);
 extern void usb_notify_add_bus(struct usb_bus *ubus);
 extern void usb_notify_remove_bus(struct usb_bus *ubus);
+
 extern enum usb_port_connect_type
usb_get_hub_port_connect_type(struct usb_device *hdev, int port1);
 extern void usb_set_hub_port_connect_type(struct usb_device *hdev, int
port1,
enum usb_port_connect_type type);
+extern void usb_hub_adjust_DeviceRemovable(struct usb_device *hdev,
+   struct usb_hub_descriptor *desc);

 #ifdef CONFIG_ACPI
 extern int usb_acpi_register(void);
Index: usb/drivers/usb/core/hcd.c
===
--- usb.orig/drivers/usb/core/hcd.c
+++ usb/drivers/usb/core/hcd.c
@@ -619,6 +619,10 @@ nongeneric:
status = hcd->driver->hub_control (hcd,
typeReq, wValue, wIndex,
tbuf, wLength);
+
+   if (typeReq == GetHubDescriptor)
+   usb_hub_adjust_DeviceRemovable(h

Re: [PATCH v3 16/23] ARM: OMAP2+: clock data: Merge utmi_px_gfclk into usb_host_hs_utmi_px_clk

2012-12-04 Thread Paul Walmsley
+ Benoît, Mike

Hi Roger,

On Tue, 4 Dec 2012, Roger Quadros wrote:

> There is no such clock as utmi_p1_gfclk. It is only a clock selector
> bit to select th the parent of usb_host_hs_utmi_p1_clk.
> So we get rid of utmi_p1_gfclk and utmi_p2_gfclk by merging them into
> usb_host_hs_utmi_p1_clk and usb_host_hs_utmi_p2_clk respectively.
> 
> CC: Paul Walmsley 
> CC: Rajendra Nayak 
> CC: Benoit Cousson 
> 
> Signed-off-by: Roger Quadros 

This one needs careful review from Benoît; these were originally 
autogenerated, and it would be nice to return to an autogenerated clock 
tree for OMAP4...


- Paul

Re: [PATCH v4] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Bernd Krumböck
> On 12/04/2012 11:11 PM, Marc Kleine-Budde wrote:
>> On 12/04/2012 11:43 PM, Bernd Krumboeck wrote:
> 
>
> btw: your clock is wrong by about 1h :)

Corrected. I like UTC system clock, but Windows doesn't.

Bernd

--
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: lsusb no output problem

2012-12-04 Thread Deniz Eren
Thanks, I installed usbutils-006 package and it worked.

On Tue, Dec 4, 2012 at 6:11 PM, Greg KH  wrote:
> On Tue, Dec 04, 2012 at 05:10:45PM +0200, Deniz Eren wrote:
>> Hello;
>>
>> After upgrading my machine from kernel 2.6.18 to kernel 3.5.3 `lsusb`
>> started to not giving output.
>>
>> With hwdata-0.213.26-1.el5 package installed:
>> $ lsusb
>> Protocol spec without prior Class and Subclass spec at line 4297
>>
>> Gave this error and nothing more.
>>
>>
>> After downgrading hwdata to hwdata-0.213.16-1.el5.noarch.rpm:
>>
>> $ lsusb
>>
>> Started to give no output.
>>
>> I am using usbutils-0.71-2.1. Can you offer a solution?
>
> Yes, please upgrade your very old version of usbutils and things should
> start working again.  The hwdata package isn't the problem here at all.
>
> Please let us know if that doesn't work,
>
> greg k-h



-- 
Deniz Eren
--
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] usb_8dev: Add support for USB2CAN interface from 8 devices

2012-12-04 Thread Wolfgang Grandegger
On 12/04/2012 11:20 PM, Bernd Krumboeck wrote:
> Hi Wolfgang!
> 
> 
> Am 2012-12-04 21:44, schrieb Wolfgang Grandegger:
>> On 12/04/2012 09:44 PM, krumbo...@universalnet.at wrote:
>>> Add device driver for USB2CAN interface from "8 devices"
>>> (http://www.8devices.com).
>>>
>>> Signed-off-by: Bernd Krumboeck 
>>> ---
>>>   drivers/net/can/usb/Kconfig|6 +
>>>   drivers/net/can/usb/Makefile   |1 +
>>>   drivers/net/can/usb/usb_8dev.c | 1093
>>> 
>>>   3 files changed, 1100 insertions(+)
>>>   create mode 100644 drivers/net/can/usb/usb_8dev.c
>>>
>>> diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
>>> index a4e4bee..2162233 100644
>>> --- a/drivers/net/can/usb/Kconfig
>>> +++ b/drivers/net/can/usb/Kconfig
>>> @@ -48,4 +48,10 @@ config CAN_PEAK_USB
>>> This driver supports the PCAN-USB and PCAN-USB Pro adapters
>>> from PEAK-System Technik (http://www.peak-system.com).
>>>   +config CAN_8DEV_USB
>>> +tristate "8 devices USB2CAN interface"
>>> +---help---
>>> +  This driver supports the USB2CAN interface
>>> +  from 8 devices (http://www.8devices.com).
>>> +
>>>   endmenu
>>> diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile
>>> index 80a2ee4..becef46 100644
>>> --- a/drivers/net/can/usb/Makefile
>>> +++ b/drivers/net/can/usb/Makefile
>>> @@ -6,5 +6,6 @@ obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
>>>   obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
>>>   obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
>>>   obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/
>>> +obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
>>>ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
>>
>> The patch looks white-space mangled.
> 
> The patch is correct, only thunderbird hates me.
> Sorry, I will try it again.

I use the add-on "Toggle Word Wrap". Anyway, git send-email is better.

>>> +switch (state) {
>>> +case USB_8DEV_STATUSMSG_ACK:
>>> +cf->can_id |= CAN_ERR_ACK;
>>> +tx_errors = 1;
>>> +break;
>>> +case USB_8DEV_STATUSMSG_CRC:
>>> +cf->data[2] |= CAN_ERR_PROT_BIT;
>>> +rx_errors = 1;
>>> +break;
>>> +case USB_8DEV_STATUSMSG_BIT0:
>>> +cf->data[2] |= CAN_ERR_PROT_BIT0;
>>> +tx_errors = 1;
>>> +break;
>>> +case USB_8DEV_STATUSMSG_BIT1:
>>> +cf->data[2] |= CAN_ERR_PROT_BIT1;
>>> +tx_errors = 1;
>>> +break;
>>> +case USB_8DEV_STATUSMSG_FORM:
>>> +cf->data[2] |= CAN_ERR_PROT_FORM;
>>> +rx_errors = 1;
>>> +break;
>>> +case USB_8DEV_STATUSMSG_STUFF:
>>> +cf->data[2] |= CAN_ERR_PROT_STUFF;
>>> +rx_errors = 1;
>>> +break;
>>> +case USB_8DEV_STATUSMSG_OVERRUN:
>>> +cf->data[1] = (txerr > rxerr) ?
>>> +CAN_ERR_CRTL_TX_OVERFLOW :
>>> +CAN_ERR_CRTL_RX_OVERFLOW;
>>> +cf->data[2] |= CAN_ERR_PROT_OVERLOAD;
>>> +stats->rx_over_errors++;
>>> +break;
>>> +case USB_8DEV_STATUSMSG_BUSLIGHT:
>>> +cf->data[1] = (txerr > rxerr) ?
>>> +CAN_ERR_CRTL_TX_WARNING :
>>> +CAN_ERR_CRTL_RX_WARNING;
>>> +dev->can.can_stats.error_warning++;
>>> +break;
>>> +case USB_8DEV_STATUSMSG_BUSHEAVY:
>>> +cf->data[1] = (txerr > rxerr) ?
>>> +CAN_ERR_CRTL_TX_PASSIVE :
>>> +CAN_ERR_CRTL_RX_PASSIVE;
>>> +dev->can.can_stats.error_passive++;
>>> +break;
>>> +default:
>>> +cf->data[2] |= CAN_ERR_PROT_UNSPEC;
>>
>> Did you see this happen?
> 
> No. I'll remove default case.

I would prefer adding a netdev_warn message here. Sending an empty bus
error message upstream is ok as we konw that is an error.

Wolfgang.

--
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 4/5] arm: omap2: support port power on lan95xx devices

2012-12-04 Thread Andy Green

On 05/12/12 01:10, the mail apparently from Alan Stern included:

[CC: list trimmed; the people who were on it should be subscribed to at
least one of the lists anyway.]

On Tue, 4 Dec 2012, Andy Green wrote:


I think associating ULPI PHY reset and SMSC power and reset with the hub
port power state is good.  Then, you could have the driver in a device
with multiple onboard USB devices, and individually control whether
they're eating power or not.  In the asset case, you'd associate mux
assets with ehci-omap.0.

Yesterday I studied the hub port code and have a couple of patches, one
normalizes the hub port device to have a stub driver.

The other then puts hub port power state signalling into runtime_pm
handlers in the hub port device.  Until now, actually there's no code in
hub.c to switch off a port.


In fact that's not quite true.  You simply weren't aware of the new
code; you can find a series of patches starting here:

http://marc.info/?l=linux-usb&m=135314427413307&w=2

The parts of interest to us begin in patch 7/10.


Yes I have been looking in usb-next.


Assuming that's not insane, what should the user interface to disable a
port power look like, something in sysfs?  Until now it doesn't seem to
exist.


It will be implemented through PM QOS.


OK.  I saw "[PATCH 09/10] usb: expose usb port's pm qos flags to user 
space" now.



(On the other hand, since the LAN95xx is the only thing
connected to the root hub, it could be powered off and on by
unbinding the ehci-omap.0 device from its driver and rebinding
it.)


We shouldn't get to tied up with Panda case, this will be there for all
cases like PCs etc.  It should work well if there are multiple ports
with onboard assets.


Okay, I'm fine with tying this to the port.


OK.


   2. If we do choose the port, do we want to identify it by matching
against a device name string or by matching a sequence of port
numbers (in this case, a length-1 sequence)?  The port numbers
are fixed by the board design, whereas the device name strings
might  get changed in the future.  On the other hand, the port
numbers apply only to USB whereas device names can be used by
any subsystem.


USB device names contain the port information.  The matching scheme I
have currently just uses the right-hand side of the path information and
nothing that is not defined by the USB subsystem.  It uses a
platform_device ancestor to restrict matches to descendants of the right
host controller.  So unlike try#1 the names are as stable as the
subsystem code alone, however stable that is, it's not exposed to
changes from anywhere else.  As you mention it's then workable on any
dynamically probed bus.


   3. Should the matching mechanism go into the device core or into
the USB port code?  (This is related to the previous question.)


Currently I am experimenting with having the asset pointer in struct
device, but migrating the events into runtime_resume and
runtime_suspend.  If it works out that has advantages that assets follow
not just the logical device existence but the pm state of the device
closely.

It also allows leveraging assets directly to the hub port runtime_pm
state, so they follow enable state of the port without any additional code.


If we use a PM domain then there won't be any need to hook the runtime
PM events.  The domain will automatically be notified about power
changes.


OK.


   4. Should this be implemented simply as a regulator (or a pair of
regulators)?  Or should it be generalized to some sort of PM
domain thing?  The generic_pm_domain structure defined in
include/linux/pm_domain.h seems like overkill, but maybe it's
the most appropriate thing to use.


They should be regulators for that I think.  But it's only part the
problem since clocks and mux are also going to be commonly associated
with device power state, and indeed are in Panda case.

I realize restricting the scope is desirable to get something done, but
I'm not sure supporting regulators only is enough of the job.


Then why not use a PM domain?  It will allow us to do whatever we want
in the callbacks.


I see, I never met them before now is the reason ^^.  You're right it's 
already in struct device too, and it's much more plumbed into the future 
apis than what I have been doing.  I'll study how to change what I have 
to fit this and do so.



On Tue, 4 Dec 2012, Ming Lei wrote:


Alos, the same ehci-omap driver and same LAN95xx chip is used in
beagle board and panda board with different power control
approach, does port driver can distinguish these two cases?
Port device is a general device(not platform device), how does
port driver get platform/board dependent info?


This is the part that Andy has been working on.  The board-dependent
info will be registered by the board file, and it will take effect
either when the port is registered or when it is bou

Re: [RFC PATCH 4/5] arm: omap2: support port power on lan95xx devices

2012-12-04 Thread Andy Green

On 05/12/12 02:14, the mail apparently from Sarah Sharp included:

On Tue, Dec 04, 2012 at 11:40:05AM +0800, Andy Green wrote:

On 04/12/12 01:09, the mail apparently from Alan Stern included:

On Mon, 3 Dec 2012, Andy Green wrote:


Unless someone NAKs it for sure already (if you're already sure you're
going to, please do so to avoid wasting time), I'll issue a try#2 of my
code later which demonstrates what I mean.  At least I guess it's useful
for comparative purposes.


Before you go writing a whole lot more code, we should discuss the
basics a bit more clearly.  There are several unsettled issues here:



  1. Should the LAN95xx stuff be associated with the ehci-omap.0's
driver or with the hub port?  The port would be more flexible,
offering the ability to turn the power off and on while the
system is running without affecting anything else.  But the
port code is currently in flux, which could cause this new
addition to be delayed.


I think associating ULPI PHY reset and SMSC power and reset with the
hub port power state is good.  Then, you could have the driver in a
device with multiple onboard USB devices, and individually control
whether they're eating power or not.  In the asset case, you'd
associate mux assets with ehci-omap.0.

Yesterday I studied the hub port code and have a couple of patches,
one normalizes the hub port device to have a stub driver.

The other then puts hub port power state signalling into runtime_pm
handlers in the hub port device.  Until now, actually there's no
code in hub.c to switch off a port.


Did you take a look at the most recent patches from Tianyu to add
support to power off a port if a device is suspended?

Start of the series:
http://marc.info/?l=linux-usb&m=135314427413307&w=2
Patch that adds power off on device suspend:
http://marc.info/?l=linux-usb&m=135314431913321&w=2

Tianyu also added some code to the xHCI host controller driver to call
into the ACPI methods to power off a port when the USB hub driver clears
the port power feature.


No I didn't know about it, I will study these along with pm_domain stuff 
thanks.


-Andy

--
Andy Green | TI Landing Team Leader
Linaro.org │ Open source software for ARM SoCs | Follow Linaro
http://facebook.com/pages/Linaro/155974581091106  - 
http://twitter.com/#!/linaroorg - http://linaro.org/linaro-blog

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