ubuntu: 3.8 kernel: Fix MUSB power

Pantelis / Robert
Here is a fix for musb (attached), causing some devices not to enumerate at all.
Tested with a wifi usb device.

regards

0001-usb-musb-fix-power-variable-data-size.patch (1.07 KB)

Just for me to to understand: With the comment I would expect for
500mA a value of 250 which fits in 8bits. Is the comment wrong or is
there something else going wrong?

Andreas

Interesting find..

In most cases with musb:
u8 power;
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/musb/omap2430.c#n62

For the Bone's hardware glue, it's wrapped to 32bit here:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/musb/musb_dsps.c#n569

Regards,

Pantelis / Robert
Here is a fix for musb (attached), causing some devices not to enumerate at all.
Tested with a wifi usb device.

regards

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Just for me to to understand: With the comment I would expect for
500mA a value of 250 which fits in 8bits. Is the comment wrong or is
there something else going wrong?

As pointed by Robert [1]

Device tree blob provides a value of 500mAmp via :
+&usb_otg_hs {
+ interface_type = <1>;
+ power = <500>; <--------------- 500mAmp
+ status = "okay";
+};

Its the sw that does the divide by 2 to get value of 250.

Problem happens when you try to read DT and truncate the 500 decimal
to 244 decimal here [1]

regards

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/musb/musb_dsps.c#n569

Some more oddness:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/usb/omap-usb.txt#n19

According to the binding doc's it's actually suppost to be the value *2.

So we should be using 250 to get 500mA..

Regards,

While editing a patch i noticed:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/am33xx.dtsi#n338

So yeah, these should be 250, so it's just hacking off the top bits
and using the lower 8 bits..

Regards,

Robert

This is the place where the power value from DT gets multiplied by two:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/musb/musb_core.c#n1992

So what is wrong on your Ubuntu 3.8 kernel is this patch:
patches/usb/0009-MUSB-Hack-around-to-make-host-port-to-work.patch

diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi
b/arch/arm/boot/dts/am335x-bone-common.dtsi
index 23a8b01..bf34fc1 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -373,3 +373,9 @@
&aes {
        status = "okay";
};

So in other words, the fix is still valid, since 1000mAmp is a valid
use case for host to supply that much current.
So DT can provide <500> as a valid value and SW should not make that
into 244 !!!