[Letux-kernel] [PATCH 0/3] MIPS: CI20: USB EHCI/OHCI
H. Nikolaus Schaller
hns at goldelico.com
Sat Sep 26 16:23:08 CEST 2020
> Am 26.09.2020 um 11:51 schrieb H. Nikolaus Schaller <hns at goldelico.com>:
>
>
>> Am 26.09.2020 um 11:26 schrieb H. Nikolaus Schaller <hns at goldelico.com>:
>>
>>
>> Some more info from studying the old 3.18 code:
>>
>> ohci-jz4740.c did there call jz4780_cgu_set_usb_suspend() for jz4780:
>>
>> drivers/usb/host/ohci-jz4740.c:
>>
>> + if (of_machine_is_compatible("ingenic,jz4780-ohci")) {
>> + ret = jz4780_cgu_set_usb_suspend(USB_PORT_HOST, false);
>> + if (ret) {
>> + dev_err(&pdev->dev, "failed to unsuspend port\n");
>> + goto err_disable;
>> + }
>> + }
>> +
>>
>> drivers/clk/jz47xx/jz4780-cgu.c:
>> +int jz4780_cgu_set_usb_suspend(enum jz4780_usb_port port, bool suspend)
>> +{
>> + unsigned long flags;
>> + u32 opcr, bit;
>> +
>> + switch (port) {
>> + case USB_PORT_OTG:
>> + bit = OPCR_SPENDN0;
>> + break;
>> +
>> + case USB_PORT_HOST:
>> + bit = OPCR_SPENDN1;
>> + break;
>> +
>> + default:
>> + return -EINVAL;
>> + }
>> +
>> + spin_lock_irqsave(&cgu->power_lock, flags);
>> +
>> + opcr = readl(cgu->base + CGU_REG_OPCR);
>> + if (suspend)
>> + opcr &= ~bit;
>> + else
>> + opcr |= bit;
>> + writel(opcr, cgu->base + CGU_REG_OPCR);
>> +
>> + spin_unlock_irqrestore(&cgu->power_lock, flags);
>> + return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(jz4780_cgu_set_usb_suspend);
>>
>> And EHCI does some calls like:
>> + jz4780_cgu_start_ehci();
>> +
>>
>> + /* Set utmi data bus width of controller to 16bit */
>> + temp = readl((volatile int *)EHCI_REG_UTMI_BUS);
>> + writel(temp | UTMIBUS_WIDTH, (volatile int *)EHCI_REG_UTMI_BUS);
>>
>>
>> So this means that the ohci-generic driver doesn't really work because
>> it can't handle writing some very special bits for the jz4780 cgu.
>>
>> Now we can try to
>> a) can hack that into the clock handling
>
> Yippee ki-yay!
>
> root at letux:~# lsusb
> Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 001 Device 004: ID 0eef:0005 D-WAV Scientific Co., Ltd WS170120
> Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> root at letux:~#
> root at letux:~# evtest /dev/input/touchscreen
> Input driver version is 1.0.1
> Input device ID: bus 0x3 vendor 0xeef product 0x5 version 0x110
> Input device name: "WaveShare WS170120"
> Supported events:
> Event type 0 (EV_SYN)
> Event type 1 (EV_KEY)
> Event code 330 (BTN_TOUCH)
> Event type 3 (EV_ABS)
> Event code 0 (ABS_X)
> Value 0
> Min 0
> Max 1024
> Event code 1 (ABS_Y)
> Value 0
> Min 0
> Max 600
> Event code 24 (ABS_PRESSURE)
> Value 0
> Min 0
> Max 255
> Event code 40 (ABS_MISC)
> Value 0
> Min 0
> Max 255
> Event type 4 (EV_MSC)
> Event code 4 (MSC_SCAN)
> Properties:
> Testing ... (interrupt to exit)
> Event: time 1601113558.596184, type 4 (EV_MSC), code 4 (MSC_SCAN), value d0042
> Event: time 1601113558.596184, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
> Event: time 1601113558.596184, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 5
> Event: time 1601113558.596184, type 3 (EV_ABS), code 0 (ABS_X), value 302
> Event: time 1601113558.596184, type 3 (EV_ABS), code 1 (ABS_Y), value 305
> Event: time 1601113558.596184, -------------- SYN_REPORT ------------
> Event: time 1601113558.750194, type 4 (EV_MSC), code 4 (MSC_SCAN), value d0042
> Event: time 1601113558.750194, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
> Event: time 1601113558.750194, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 0
> Event: time 1601113558.750194, -------------- SYN_REPORT ------------
> ^Croot at letux:~#
>
> Attached is my hack for drivers/clk/jz47xx/jz4780-cgu.c
> which simply assumes that we want to enable the OTG *and* the HOST port...
>
> What I think we must do is write a custom clock handler for
> [JZ4780_CLK_UHC] that enables/disables OPCR_SPENDN1.
>
> But for the moment it is enough to get the USB HOST port working in addition
> to the OTG port. I think I can merge it into letux-5.9-rc7 and then we can
> improve...
Yes. I have cleaned it up a little and will include it in letux-5.9-rc7 next Monday.
Observations:
* EHCI doesn't seem to work - falls back to USB 1.1 speed
* using my panel on either port and a memory stick on the other leads to
dwc2 13500000.usb: Overcurrent change detected
* it seems as if I have to remove the Mini-OTG jumper for a moment to make the OTG port detect something
* my attempt to do the enable/disable by [JZ4780_CLK_UHC] leads to a kernel panic - so I have it disabled
Your observations and fixes will be welcome.
BR,
Nikolaus
More information about the Letux-kernel
mailing list