Hi,

On 04/04/18 10:42, Martin Lucina wrote:
> Hi,
> 
> On Thursday, 22.03.2018 at 20:47, André Przywara wrote:
>>> Ok, I just measured both ports (via a cannibalised USB cable + OTG for the
>>> micro-USB) and there's no power on either of them. Cross-checked the
>>> measurement setup against an old Thinkpad to be sure.
> 
> One more data point which I did not notice before: After ATF runs but
> before the kernel boots I get 5V (well, 4.85V but close enough) on the
> USB-A port. Once the kernel has booted the voltage drops to zero.

Ah, interesting, but would make some sense: PG9 is pulled high on the
board, so you have to actively drive it *low* to *disable* the power.
Do you have some nodes for the WiFi/BT module in the DT? The UART1 CTS
is also on PG9, and we bundle it with the RTS pin in one group. RTS is
used by the BT module, but CTS is not.
So as soon as we initialise UART1, we might accidentally pull that line
low and disable USB power.

>> OK, remote debugging!
>>
>> Can you please try to play around with GPIO PG9 from Linux? Basically:
>> # cd /sys/class/gpio
>> # echo 201 > export
>> # cd gpio201
>> # echo out > direction
>> # echo 1 > value
>>
>> And then try to measure the USB voltage again? Try 0 for "value" as
>> well. If the export complains, try to remove the DT parts I gave you
>> (switch back to the normal mainline DT). 201 is ('G'-'A') * 32 + 9.
>> Something like that should enable the voltage on the USB-A socket
>> (regardless of the DT used).
> 
> I seem to be missing some driver for the GPIOs as I have no
> /sys/class/gpio and nothing that looks suitable in /lib/modules; what do I
> need to add to the arm64 defconfig to enable this?

Ah, yes, you need CONFIG_GPIO_SYSFS in your .config. You can use any
other userland tool to manipulate GPIOs, though.
You may also try to use U-Boot's "gpio" command, though I am not sure
that works on the A64 at the moment. Possibly today's sunxi/master
U-Boot branch would fix this.

>> For the micro-B port: Can you try to add the following line to the ATF
>> source, into plat/sun50iw1p1/sunxi_power.c, somewhere in the
>> pmic_setup() function:
>>      sunxi_pmic_write(0x30, sunxi_pmic_read(0x30) | BIT(2));
>>
>> That should power the DRIVEVBUS/N_VBUSEN pin, ideally turning on the
>> power of the OTG port.
>> If that works, I can make a Linux patch to do this there as well.
> 
> When I add that line to ATF I get 5V on the micro-B port after
> initialisation and it stays powered up even after the kernel has booted.

Good, so that's some confirmation. I recently found that the BananaPi
M64 uses the very same setup for the OTG port, and there are patches on
the way to support it properly. So we can piggy back on that.
We might need that ATF patch to enable it in U-Boot as well, if we care
(fastboot?). That would be shared with the BPi-M64, then.

Cheers,
Andre.

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to