Initialisation of SOC USB pads

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

plyatov
Posts: 4
Joined: Fri May 11, 2007 12:01 pm

Initialisation of SOC USB pads

Tue May 14, 2019 9:22 am

Hello everybody!

Can you please explain which software must configure AT91SAM9G20 SOC pads to operate as USB Host port? Is it AT91Bootstrap, U-Boot bootloader, Linux kernel or this is not required at all?

I ask, because during connection of USB disk, my board complains
usb 1-1: device descriptor read/64, error -62
usb 1-1: device descriptor read/64, error -62
usb 1-1: device descriptor read/64, error -62
usb 1-1: device descriptor read/64, error -62
usb 1-1: device not accepting address 4, error -62
usb 1-1: device not accepting address 5, error -62
usb usb1-port1: unable to enumerate USB device

Looks like there is no connectivity between USB Host module of SOC and USB device. Or am I wrong?


My setup is:
  • AT91SAM9G20 based custom board;
  • Linux kernel 4.9.36, from LINUX4SAM project;
  • USB disk connected to USB Host port 0 (HDPA, HDMA pins of SOC). 39 Ohm series resistors and 15 Kohm pull-down resistors added at these lines. Connectivity between SOC and USB device confirmed by Ohmmeter;
  • USB_VBUS voltage measured at USB connector = 4.96 VDC.
USB related kernel log:
[ 0.180000] usbcore: registered new interface driver usbfs
[ 0.180000] usbcore: registered new interface driver hub
[ 0.180000] usbcore: registered new device driver usb
[ 0.480000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.480000] ohci-atmel: OHCI Atmel driver
[ 0.480000] at91_ohci 500000.ohci: failed to find sfr node
[ 0.480000] at91_ohci 500000.ohci: USB Host Controller
[ 0.480000] at91_ohci 500000.ohci: new USB bus registered, assigned bus number 1
[ 0.480000] at91_ohci 500000.ohci: irq 37, io mem 0x00500000
[ 0.550000] usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
[ 0.550000] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.550000] usb usb1: Product: USB Host Controller
[ 0.550000] usb usb1: Manufacturer: Linux 4.9.36+ ohci_hcd
[ 0.550000] usb usb1: SerialNumber: at91
[ 0.550000] hub 1-0:1.0: USB hub found
[ 0.550000] hub 1-0:1.0: 2 ports detected
[ 0.550000] usbcore: registered new interface driver usb-storage
[ 0.620000] usbcore: registered new interface driver usbhid
[ 0.620000] usbhid: USB HID core driver
Best wishes
--
Igor Plyatov
blue_z
Location: USA
Posts: 1977
Joined: Thu Apr 19, 2007 10:15 pm

Re: Initialisation of SOC USB pads

Tue May 14, 2019 8:59 pm

plyatov wrote: Can you please explain which software must configure AT91SAM9G20 SOC pads to operate as USB Host port? Is it AT91Bootstrap, U-Boot bootloader, Linux kernel or this is not required at all?
Each boot program stage must perform its own device initialization for the device it expects to use.
AT91Bootstrap doesn't have USB capability because it is memory-space constrained.
U-Boot would have its own USB initialization, although the AT91SAM9260-EK code doesn't implement it.
Modern Linux kernels use the Device Tree to specify the pins used by each peripheral, and the pinctrl subsystem automagically performs the pin multiplexing before the device driver is executed.

Recent at91 versions of the kernel (can) enable the USB host peripheral in the Device Tree, but do not have a pinctrl definition for USB pins because they are not multiplexed.

BTW if the functionality of the hardware is in question, then Linux is the least friendly environment to check out the hardware.

Regards
plyatov
Posts: 4
Joined: Fri May 11, 2007 12:01 pm

Re: Initialisation of SOC USB pads

Wed May 22, 2019 4:33 pm

Hi all!

Update of topic.

I see USB traffic on the bus by Logical analyser.

This is definitely Linux kernel 4.9.52 issue, because USB works fine at U-Boot, when I try to load kernel image and device tree from USB disk.

Additionally, USB works fine, when same board flashed with old Linux kernel 2.6.39.

Current Linux kernel (4.9.52), has issue with USB speed on AT91SAM9G20. I see different USB speeds in U-Boot and in Linux-4.9.52. U-Boot has 12 MHz USB speed, while Linux-4.9.52 has 6 MHz USB speed.

I guess, what need to be changed to have correct USB speed?

I have try to attach resulting Device Tree source code, but looks like forum does not support this.

Best wishes.
--
Igor Plyatov
blue_z
Location: USA
Posts: 1977
Joined: Thu Apr 19, 2007 10:15 pm

Re: Initialisation of SOC USB pads

Wed May 22, 2019 8:11 pm

plyatov wrote: This is definitely Linux kernel 4.9.52 issue, because USB works fine at U-Boot ...
To be clear, the issue is probably restricted to the older AT91SAM9 SoCs that only have an OHCI controller and do not also have an EHCI controller (as found in the AT91SAM9G45 and later SoCs) in the USB Host peripheral.
It's the EHCI controller that implements USB V2.0 high-speed capability (in the AT91SAM9G45 and later SoCs).
Both the OHCI and EHCI controllers can support USB full-speed 12 Mbps USB devices.

plyatov wrote: Additionally, USB works fine, when same board flashed with old Linux kernel 2.6.39.
Then you only have a decade's worth of commits to consider.

plyatov wrote: I guess, what need to be changed to have correct USB speed?
Study section 26.4, USB Clock Controller, of the SAM9G20 datasheet.
There's mention of a divider that halves or doubles one of the clock inputs to the USB host controller.


Regards
plyatov
Posts: 4
Joined: Fri May 11, 2007 12:01 pm

Re: Initialisation of SOC USB pads

Sat Aug 17, 2019 3:05 pm

Hi all!

For those, who are interested in....

Finally I have found a time for this issue. Issue was in a bug in drivers/clk/at91/clk-pll.c.

This patch already in upstream, but I have attached it if you are interested in.

Best wishes.
--
Igor Plyatov

From 320f50baca5a275170f80ba34e2f2eddb9c200d5 Mon Sep 17 00:00:00 2001
From: plyatov <plyatov@gmail.com>
Date: Tue, 13 Aug 2019 13:29:17 +0300
Subject: [PATCH 1/2] clk-pll.c: bug-fix for wrong USB clock rate.

* Fix division by zero in PLL recalc_rate().
---
drivers/clk/at91/clk-pll.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c
index 45ad168..a17a428 100644
--- a/drivers/clk/at91/clk-pll.c
+++ b/drivers/clk/at91/clk-pll.c
@@ -132,19 +132,11 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct clk_pll *pll = to_clk_pll(hw);
- unsigned int pllr;
- u16 mul;
- u8 div;
-
- regmap_read(pll->regmap, PLL_REG(pll->id), &pllr);
-
- div = PLL_DIV(pllr);
- mul = PLL_MUL(pllr, pll->layout);

- if (!div || !mul)
+ if (!pll->div || !pll->mul)
return 0;

- return (parent_rate / div) * (mul + 1);
+ return (parent_rate / pll->div) * (pll->mul + 1);
}

static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate,
--
2.7.4

Return to “LINUX”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests