* Re: [PATCH v4] kcov, usbip: collect coverage from vhci_rx_loop
From: Shuah Khan @ 2020-12-17 0:01 UTC (permalink / raw)
To: Andrey Konovalov, Shuah Khan
Cc: linux-usb, linux-kernel, kasan-dev, Dmitry Vyukov,
Greg Kroah-Hartman, Alexander Potapenko, Marco Elver,
Nazime Hande Harputluoglu, Nazime Hande Harputluoglu, Shuah Khan
In-Reply-To: <f8114050f8d65aa0bc801318b1db532d9f432447.1606175386.git.andreyknvl@google.com>
On 11/23/20 4:50 PM, Andrey Konovalov wrote:
> From: Nazime Hande Harputluoglu <handeharputlu@google.com>
>
> Add kcov_remote_start()/kcov_remote_stop() annotations to the
> vhci_rx_loop() function, which is responsible for parsing USB/IP packets
> coming into USB/IP client.
>
> Since vhci_rx_loop() threads are spawned per vhci_hcd device instance, the
> common kcov handle is used for kcov_remote_start()/stop() annotations
> (see Documentation/dev-tools/kcov.rst for details). As the result kcov
> can now be used to collect coverage from vhci_rx_loop() threads.
>
> Signed-off-by: Nazime Hande Harputluoglu <handeharputlu@google.com>
> Co-developed-by: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> ---
>
> Changes in v4:
> - Add USB/IP specific wrappers around kcov functions to avoid having a lot
> of ifdef CONFIG_KCOV in the USB/IP code.
>
Looks good to me. Sorry for the delay on this. It just got lost in my Inbox.
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
^ permalink raw reply
* Re: kernel locks due to USB I/O
From: Alberto Sentieri @ 2020-12-16 22:14 UTC (permalink / raw)
To: Alan Stern; +Cc: Greg Kroah-Hartman, linux-usb
In-Reply-To: <20201214171815.GA153671@rowland.harvard.edu>
This is just a quick status update. I am just checking if it rings any
bell. I am still doing more tests.
The machine where all these problems are happening is a HP Z4 G4, as
well as the other two in production. Until this morning it had BIOS
v01.76 dated 04/22/2019. Today I update the BIOS to v02.63 dated 10/28/2020.
After updating the BIOS, the behavior definitively changed. Now both
kernels (5.4.0-53-generic and 5.9.8) reboot unexpectedly instead of
locking. After re-enabling the console, expecting to capture something,
I could not see a lock or reboot. However the serial console, after
displaying the whole boot, locked, and I cannot use it to login.
Alberto Sentieri
On 12/14/20 12:18 PM, Alan Stern wrote:
> We'll have to wait and see what the tests and debugging tools reveal.
> As for the comment about the hardware being reliable -- in fact, you
> can't be certain of this. It may be that your test is stressing the
> hardware in a way that it never experienced during the prior six
> months.
>
> Alan Stern
^ permalink raw reply
* Re: [PATCH v1 3/8] usb: chipidea: tegra: Remove MODULE_ALIAS
From: Dmitry Osipenko @ 2020-12-16 18:06 UTC (permalink / raw)
To: Thierry Reding
Cc: Jonathan Hunter, Peter Chen, Greg Kroah-Hartman, Alan Stern,
Felipe Balbi, Matt Merhar, Nicolas Chauvet, Peter Geis,
linux-tegra, linux-usb, linux-kernel
In-Reply-To: <X9pKz8O4ESRShKzh@ulmo>
16.12.2020 20:58, Thierry Reding пишет:
> On Tue, Dec 15, 2020 at 11:21:08PM +0300, Dmitry Osipenko wrote:
>> The module alias is provided by the OF core for the OF drivers, it
>> overrides the alias set by the drivers. Hence remove the unneeded macro
>> in order to keep the driver code cleaner.
>
> This is slightly misleading because that manual MODULE_ALIAS is there
> for legacy reasons and created that alias to bind against a platform
> device created from board files back in the day.
>
> Depending on how I interpret the commit message, it also sounds like
> you're suggesting that the OF core will automatically add this alias.
> However, what the OF core adds is an alias based on the OF device ID
> table, which is completely different.
>
> We don't support board files anymore and to my knowledge the aliases
> generated from the OF device ID table are enough to have the driver
> autoloaded, so this patch is correct. Perhaps make it clearer in the
> commit message why this is no longer needed. With that:
>
> Acked-by: Thierry Reding <treding@nvidia.com>
Alright, thanks.
^ permalink raw reply
* Re: [PATCH v1 3/8] usb: chipidea: tegra: Remove MODULE_ALIAS
From: Thierry Reding @ 2020-12-16 17:58 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Jonathan Hunter, Peter Chen, Greg Kroah-Hartman, Alan Stern,
Felipe Balbi, Matt Merhar, Nicolas Chauvet, Peter Geis,
linux-tegra, linux-usb, linux-kernel
In-Reply-To: <20201215202113.30394-4-digetx@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]
On Tue, Dec 15, 2020 at 11:21:08PM +0300, Dmitry Osipenko wrote:
> The module alias is provided by the OF core for the OF drivers, it
> overrides the alias set by the drivers. Hence remove the unneeded macro
> in order to keep the driver code cleaner.
This is slightly misleading because that manual MODULE_ALIAS is there
for legacy reasons and created that alias to bind against a platform
device created from board files back in the day.
Depending on how I interpret the commit message, it also sounds like
you're suggesting that the OF core will automatically add this alias.
However, what the OF core adds is an alias based on the OF device ID
table, which is completely different.
We don't support board files anymore and to my knowledge the aliases
generated from the OF device ID table are enough to have the driver
autoloaded, so this patch is correct. Perhaps make it clearer in the
commit message why this is no longer needed. With that:
Acked-by: Thierry Reding <treding@nvidia.com>
> Tested-by: Matt Merhar <mattmerhar@protonmail.com>
> Tested-by: Nicolas Chauvet <kwizart@gmail.com>
> Tested-by: Peter Geis <pgwipeout@gmail.com>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> drivers/usb/chipidea/ci_hdrc_tegra.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
> index 7455df0ede49..10eaaba2a3f0 100644
> --- a/drivers/usb/chipidea/ci_hdrc_tegra.c
> +++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
> @@ -128,5 +128,4 @@ module_platform_driver(tegra_udc_driver);
>
> MODULE_DESCRIPTION("NVIDIA Tegra USB device mode driver");
> MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
> -MODULE_ALIAS("platform:tegra-udc");
> MODULE_LICENSE("GPL v2");
> --
> 2.29.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH v1 7/8] usb: host: ehci-tegra: Remove the driver
From: Dmitry Osipenko @ 2020-12-16 17:28 UTC (permalink / raw)
To: Alan Stern
Cc: Thierry Reding, Jonathan Hunter, Peter Chen, Greg Kroah-Hartman,
Felipe Balbi, Matt Merhar, Nicolas Chauvet, Peter Geis,
linux-tegra, linux-usb, linux-kernel
In-Reply-To: <20201216172253.GC238371@rowland.harvard.edu>
16.12.2020 20:22, Alan Stern пишет:
> On Wed, Dec 16, 2020 at 08:09:51PM +0300, Dmitry Osipenko wrote:
>> 16.12.2020 19:45, Alan Stern пишет:
>>> On Tue, Dec 15, 2020 at 11:21:12PM +0300, Dmitry Osipenko wrote:
>>>> The ChipIdea driver now provides USB2 host mode support for NVIDIA Tegra
>>>> SoCs. The ehci-tegra driver is obsolete now, remove it.
>>>>
>>>> Tested-by: Matt Merhar <mattmerhar@protonmail.com>
>>>> Tested-by: Nicolas Chauvet <kwizart@gmail.com>
>>>> Tested-by: Peter Geis <pgwipeout@gmail.com>
>>>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>>>> ---
>>>> drivers/usb/host/Kconfig | 9 -
>>>> drivers/usb/host/Makefile | 1 -
>>>> drivers/usb/host/ehci-tegra.c | 604 ----------------------------------
>>>> 3 files changed, 614 deletions(-)
>>>> delete mode 100644 drivers/usb/host/ehci-tegra.c
>>>>
>>>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>>>> index 31e59309da1f..9c9e6ff9c43a 100644
>>>> --- a/drivers/usb/host/Kconfig
>>>> +++ b/drivers/usb/host/Kconfig
>>>> @@ -266,15 +266,6 @@ config USB_EHCI_HCD_AT91
>>>> Enables support for the on-chip EHCI controller on
>>>> Atmel chips.
>>>>
>>>> -config USB_EHCI_TEGRA
>>>> - tristate "NVIDIA Tegra HCD support"
>>>> - depends on ARCH_TEGRA
>>>> - select USB_EHCI_ROOT_HUB_TT
>>>> - select USB_TEGRA_PHY
>>>> - help
>>>> - This driver enables support for the internal USB Host Controllers
>>>> - found in NVIDIA Tegra SoCs. The controllers are EHCI compliant.
>>>
>>> For people upgrading from earlier kernel versions, do you think it
>>> would help to add a pointer here telling them which Kconfig option
>>> they need to enable now in order to get this functionality?
>>
>> Could you please clarify what do you mean by the "pointer"?
>
> See the entries for USB_CNS3XXX_EHCI, USB_OCTEON_EHCI,
> USB_OHCI_HCD_OMAP3, and USB_OHCI_SH in that Kconfig file for examples.
I'll point the deprecated USB_EHCI_TEGRA to the CI driver in a v2, thanks.
^ permalink raw reply
* Re: [PATCH v1 7/8] usb: host: ehci-tegra: Remove the driver
From: Alan Stern @ 2020-12-16 17:22 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Thierry Reding, Jonathan Hunter, Peter Chen, Greg Kroah-Hartman,
Felipe Balbi, Matt Merhar, Nicolas Chauvet, Peter Geis,
linux-tegra, linux-usb, linux-kernel
In-Reply-To: <33d576a4-5ace-e1a1-d829-77266025aa9b@gmail.com>
On Wed, Dec 16, 2020 at 08:09:51PM +0300, Dmitry Osipenko wrote:
> 16.12.2020 19:45, Alan Stern пишет:
> > On Tue, Dec 15, 2020 at 11:21:12PM +0300, Dmitry Osipenko wrote:
> >> The ChipIdea driver now provides USB2 host mode support for NVIDIA Tegra
> >> SoCs. The ehci-tegra driver is obsolete now, remove it.
> >>
> >> Tested-by: Matt Merhar <mattmerhar@protonmail.com>
> >> Tested-by: Nicolas Chauvet <kwizart@gmail.com>
> >> Tested-by: Peter Geis <pgwipeout@gmail.com>
> >> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> >> ---
> >> drivers/usb/host/Kconfig | 9 -
> >> drivers/usb/host/Makefile | 1 -
> >> drivers/usb/host/ehci-tegra.c | 604 ----------------------------------
> >> 3 files changed, 614 deletions(-)
> >> delete mode 100644 drivers/usb/host/ehci-tegra.c
> >>
> >> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> >> index 31e59309da1f..9c9e6ff9c43a 100644
> >> --- a/drivers/usb/host/Kconfig
> >> +++ b/drivers/usb/host/Kconfig
> >> @@ -266,15 +266,6 @@ config USB_EHCI_HCD_AT91
> >> Enables support for the on-chip EHCI controller on
> >> Atmel chips.
> >>
> >> -config USB_EHCI_TEGRA
> >> - tristate "NVIDIA Tegra HCD support"
> >> - depends on ARCH_TEGRA
> >> - select USB_EHCI_ROOT_HUB_TT
> >> - select USB_TEGRA_PHY
> >> - help
> >> - This driver enables support for the internal USB Host Controllers
> >> - found in NVIDIA Tegra SoCs. The controllers are EHCI compliant.
> >
> > For people upgrading from earlier kernel versions, do you think it
> > would help to add a pointer here telling them which Kconfig option
> > they need to enable now in order to get this functionality?
>
> Could you please clarify what do you mean by the "pointer"?
See the entries for USB_CNS3XXX_EHCI, USB_OCTEON_EHCI,
USB_OHCI_HCD_OMAP3, and USB_OHCI_SH in that Kconfig file for examples.
Alan Stern
^ permalink raw reply
* Re: [PATCH v1 7/8] usb: host: ehci-tegra: Remove the driver
From: Dmitry Osipenko @ 2020-12-16 17:09 UTC (permalink / raw)
To: Alan Stern
Cc: Thierry Reding, Jonathan Hunter, Peter Chen, Greg Kroah-Hartman,
Felipe Balbi, Matt Merhar, Nicolas Chauvet, Peter Geis,
linux-tegra, linux-usb, linux-kernel
In-Reply-To: <20201216164511.GB238371@rowland.harvard.edu>
16.12.2020 19:45, Alan Stern пишет:
> On Tue, Dec 15, 2020 at 11:21:12PM +0300, Dmitry Osipenko wrote:
>> The ChipIdea driver now provides USB2 host mode support for NVIDIA Tegra
>> SoCs. The ehci-tegra driver is obsolete now, remove it.
>>
>> Tested-by: Matt Merhar <mattmerhar@protonmail.com>
>> Tested-by: Nicolas Chauvet <kwizart@gmail.com>
>> Tested-by: Peter Geis <pgwipeout@gmail.com>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>> drivers/usb/host/Kconfig | 9 -
>> drivers/usb/host/Makefile | 1 -
>> drivers/usb/host/ehci-tegra.c | 604 ----------------------------------
>> 3 files changed, 614 deletions(-)
>> delete mode 100644 drivers/usb/host/ehci-tegra.c
>>
>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>> index 31e59309da1f..9c9e6ff9c43a 100644
>> --- a/drivers/usb/host/Kconfig
>> +++ b/drivers/usb/host/Kconfig
>> @@ -266,15 +266,6 @@ config USB_EHCI_HCD_AT91
>> Enables support for the on-chip EHCI controller on
>> Atmel chips.
>>
>> -config USB_EHCI_TEGRA
>> - tristate "NVIDIA Tegra HCD support"
>> - depends on ARCH_TEGRA
>> - select USB_EHCI_ROOT_HUB_TT
>> - select USB_TEGRA_PHY
>> - help
>> - This driver enables support for the internal USB Host Controllers
>> - found in NVIDIA Tegra SoCs. The controllers are EHCI compliant.
>
> For people upgrading from earlier kernel versions, do you think it
> would help to add a pointer here telling them which Kconfig option
> they need to enable now in order to get this functionality?
Could you please clarify what do you mean by the "pointer"?
^ permalink raw reply
* [RFC PATCH] usb: dwc2: Try usb_get_phy_by_phandle instead of usb_get_phy
From: Jules Maselbas @ 2020-12-16 16:59 UTC (permalink / raw)
To: Minas Harutyunyan
Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Jules Maselbas
On probe the dwc2 driver tries two path to get an usb phy, first calling
devm_phy_get() and secondly with devm_usb_get_phy().
However the current implementation of devm_phy_get() never return a valid
phy for usb-nop-xceiv. And the current implementation of devm_usb_get_phy
only check for phy that's has already been registered.
During boot, I see the dwc2 driver being probed before the usb-nop-xceiv
probe, this means that during the dwc2 probe the function devm_usb_get_phy
never finds the a phy (because it hasn't been registered yet) but never
cause the dwc2 probe to defer.
I tried to follow what is done by dwc3_core_get_phy(): if the current
device has an of_node then try to get the usb_phy by phandle instead of
using devm_usb_get_phy(). This way when the probe order is not good the
devm_usb_get_phy_by_phandle() function will return -EPROBE_DEFER.
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
--- 8< ---
A snippet of the device-tree source I am using:
&usb0 {
phys = <&usb_phy0>;
phy-names = "usb2-phy";
};
&usb_phy0 {
#phy-cells = <0>;
compatible = "usb-nop-xceiv";
reset-gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
};
---
drivers/usb/dwc2/platform.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index db9fd4bd1a38..b58ce996add7 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -251,7 +251,12 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
}
if (!hsotg->phy) {
- hsotg->uphy = devm_usb_get_phy(hsotg->dev, USB_PHY_TYPE_USB2);
+ if (hsotg->dev->of_node)
+ i = of_property_match_string(hsotg->dev->of_node, "phy-names", "usb2-phy");
+ if (hsotg->dev->of_node && i >= 0)
+ hsotg->uphy = devm_usb_get_phy_by_phandle(hsotg->dev, "phys", i);
+ else
+ hsotg->uphy = devm_usb_get_phy(hsotg->dev, USB_PHY_TYPE_USB2);
if (IS_ERR(hsotg->uphy)) {
ret = PTR_ERR(hsotg->uphy);
switch (ret) {
--
2.17.1
^ permalink raw reply related
* Re: [PATCH v1 7/8] usb: host: ehci-tegra: Remove the driver
From: Alan Stern @ 2020-12-16 16:45 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Thierry Reding, Jonathan Hunter, Peter Chen, Greg Kroah-Hartman,
Felipe Balbi, Matt Merhar, Nicolas Chauvet, Peter Geis,
linux-tegra, linux-usb, linux-kernel
In-Reply-To: <20201215202113.30394-8-digetx@gmail.com>
On Tue, Dec 15, 2020 at 11:21:12PM +0300, Dmitry Osipenko wrote:
> The ChipIdea driver now provides USB2 host mode support for NVIDIA Tegra
> SoCs. The ehci-tegra driver is obsolete now, remove it.
>
> Tested-by: Matt Merhar <mattmerhar@protonmail.com>
> Tested-by: Nicolas Chauvet <kwizart@gmail.com>
> Tested-by: Peter Geis <pgwipeout@gmail.com>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> drivers/usb/host/Kconfig | 9 -
> drivers/usb/host/Makefile | 1 -
> drivers/usb/host/ehci-tegra.c | 604 ----------------------------------
> 3 files changed, 614 deletions(-)
> delete mode 100644 drivers/usb/host/ehci-tegra.c
>
> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> index 31e59309da1f..9c9e6ff9c43a 100644
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -266,15 +266,6 @@ config USB_EHCI_HCD_AT91
> Enables support for the on-chip EHCI controller on
> Atmel chips.
>
> -config USB_EHCI_TEGRA
> - tristate "NVIDIA Tegra HCD support"
> - depends on ARCH_TEGRA
> - select USB_EHCI_ROOT_HUB_TT
> - select USB_TEGRA_PHY
> - help
> - This driver enables support for the internal USB Host Controllers
> - found in NVIDIA Tegra SoCs. The controllers are EHCI compliant.
For people upgrading from earlier kernel versions, do you think it
would help to add a pointer here telling them which Kconfig option
they need to enable now in order to get this functionality?
Alan Stern
^ permalink raw reply
* UBSAN: shift-out-of-bounds in mceusb_dev_printdata
From: syzbot @ 2020-12-16 16:14 UTC (permalink / raw)
To: andreyknvl, linux-kernel, linux-media, linux-usb, mchehab, sean,
syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 5e60366d Merge tag 'fallthrough-fixes-clang-5.11-rc1' of g..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
console output: https://syzkaller.appspot.com/x/log.txt?x=11b1a46b500000
kernel config: https://syzkaller.appspot.com/x/.config?x=5cea7506b7139727
dashboard link: https://syzkaller.appspot.com/bug?extid=6d31bf169a8265204b8d
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13727b7f500000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1565f123500000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6d31bf169a8265204b8d@syzkaller.appspotmail.com
================================================================================
UBSAN: shift-out-of-bounds in drivers/media/rc/mceusb.c:704:13
shift exponent 230 is too large for 32-bit type 'unsigned int'
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.10.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:79 [inline]
dump_stack+0x107/0x163 lib/dump_stack.c:120
ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
__ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:395
mceusb_dev_printdata.cold+0x19/0x1e drivers/media/rc/mceusb.c:704
mceusb_process_ir_data drivers/media/rc/mceusb.c:1275 [inline]
mceusb_dev_recv+0x3cb/0x1990 drivers/media/rc/mceusb.c:1376
__usb_hcd_giveback_urb+0x2b0/0x5c0 drivers/usb/core/hcd.c:1657
usb_hcd_giveback_urb+0x38c/0x430 drivers/usb/core/hcd.c:1728
dummy_timer+0x11f4/0x32a0 drivers/usb/gadget/udc/dummy_hcd.c:1971
call_timer_fn+0x1a5/0x690 kernel/time/timer.c:1417
expire_timers kernel/time/timer.c:1462 [inline]
__run_timers.part.0+0x692/0xa50 kernel/time/timer.c:1731
__run_timers kernel/time/timer.c:1712 [inline]
run_timer_softirq+0x80/0x120 kernel/time/timer.c:1744
__do_softirq+0x1b7/0x9c5 kernel/softirq.c:343
asm_call_irq_on_stack+0xf/0x20
</IRQ>
__run_on_irqstack arch/x86/include/asm/irq_stack.h:26 [inline]
run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:77 [inline]
do_softirq_own_stack+0x80/0xa0 arch/x86/kernel/irq_64.c:77
invoke_softirq kernel/softirq.c:226 [inline]
__irq_exit_rcu+0x119/0x1b0 kernel/softirq.c:420
irq_exit_rcu+0x5/0x10 kernel/softirq.c:432
sysvec_apic_timer_interrupt+0x43/0xa0 arch/x86/kernel/apic/apic.c:1096
asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:628
RIP: 0010:native_save_fl arch/x86/include/asm/irqflags.h:29 [inline]
RIP: 0010:arch_local_save_flags arch/x86/include/asm/irqflags.h:79 [inline]
RIP: 0010:arch_irqs_disabled arch/x86/include/asm/irqflags.h:169 [inline]
RIP: 0010:acpi_safe_halt drivers/acpi/processor_idle.c:111 [inline]
RIP: 0010:acpi_idle_do_entry+0x1c9/0x250 drivers/acpi/processor_idle.c:516
Code: 8d 61 7f fb 84 db 75 ac e8 04 5b 7f fb e8 4f 0f 85 fb e9 0c 00 00 00 e8 f5 5a 7f fb 0f 00 2d ce 86 87 00 e8 e9 5a 7f fb fb f4 <9c> 5b 81 e3 00 02 00 00 fa 31 ff 48 89 de e8 c4 62 7f fb 48 85 db
RSP: 0018:ffffffff87407d60 EFLAGS: 00000293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffffffff87431940 RSI: ffffffff85c0eb77 RDI: ffffffff85c0eb61
RBP: ffff8881037c3064 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff8145fae8 R11: 0000000000000000 R12: 0000000000000001
R13: ffff8881037c3000 R14: ffff8881037c3064 R15: ffff888105c7d804
acpi_idle_enter+0x355/0x4f0 drivers/acpi/processor_idle.c:647
cpuidle_enter_state+0x1b1/0xc80 drivers/cpuidle/cpuidle.c:237
cpuidle_enter+0x4a/0xa0 drivers/cpuidle/cpuidle.c:351
call_cpuidle kernel/sched/idle.c:158 [inline]
cpuidle_idle_call kernel/sched/idle.c:239 [inline]
do_idle+0x3df/0x580 kernel/sched/idle.c:299
cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:396
start_kernel+0x498/0x4b9 init/main.c:1061
secondary_startup_64_no_verify+0xb0/0xbb
================================================================================
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
^ permalink raw reply
* Re: [PATCH v1 5/8] usb: chipidea: tegra: Support host mode
From: Dmitry Osipenko @ 2020-12-16 15:56 UTC (permalink / raw)
To: Peter Chen
Cc: Thierry Reding, Jonathan Hunter, Greg Kroah-Hartman, Alan Stern,
Felipe Balbi, Matt Merhar, Nicolas Chauvet, Peter Geis,
linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <DBBPR04MB79794F5CC440279AF94A48448BC50@DBBPR04MB7979.eurprd04.prod.outlook.com>
16.12.2020 12:32, Peter Chen пишет:
>> ...
>>>> +static int tegra_usb_internal_port_reset(struct ehci_hcd *ehci,
>>>> + u32 __iomem *portsc_reg,
>>>> + unsigned long *flags)
>>>> +{
>>>> + u32 saved_usbintr, temp;
>>>> + unsigned int i, tries;
>>>> + int retval = 0;
>>>> +
>>>> + saved_usbintr = ehci_readl(ehci, &ehci->regs->intr_enable);
>>>> + /* disable USB interrupt */
>>>> + ehci_writel(ehci, 0, &ehci->regs->intr_enable);
>>>> + spin_unlock_irqrestore(&ehci->lock, *flags);
>>>> +
>>>> + /*
>>>> + * Here we have to do Port Reset at most twice for
>>>> + * Port Enable bit to be set.
>>>> + */
>>>> + for (i = 0; i < 2; i++) {
>>>> + temp = ehci_readl(ehci, portsc_reg);
>>>> + temp |= PORT_RESET;
>>>> + ehci_writel(ehci, temp, portsc_reg);
>>>> + mdelay(10);
>>> Needs accurate delay? How about usleep_range?
>> To be hones I don't know for sure whether hub_control() could be used from
>> interrupt context. This mdelay is borrowed from the older ehci-tegra driver.
>>
>> Are you suggesting that it should be safe to sleep here?
>>
> I see msleep is called at tegra_ehci_hub_control at ehci-tegra.c.
> .hub_control is not called at interrupt context.
>
Alright, I'll change to use msleep() in v2, thanks.
^ permalink raw reply
* Re: port power is on again after turning off by user space
From: Alan Stern @ 2020-12-16 15:51 UTC (permalink / raw)
To: Peter Chen; +Cc: Jun Li, linux-usb@vger.kernel.org
In-Reply-To: <20201216025549.GA5595@b29397-desktop>
On Wed, Dec 16, 2020 at 02:56:20AM +0000, Peter Chen wrote:
> On 20-12-15 10:55:41, Alan Stern wrote:
> > You've got the general idea.
> >
> > Normally ports are owned by the hub driver. If one of them loses power
> > for some reason (for example, the user turns it off), the hub driver
> > will turn the power back on. This is because the hub driver wants
> > ports to be powered at all times unless they are in runtime suspend.
> >
> > The way to prevent the hub driver from managing the port power is to
> > claim the port for the user, by issuing the USBDEVFS_CLAIM_PORT ioctl.
> > Also, when that is done, the kernel wno't try to manage a device
> > attached to the port -- that is, the kernel won't automatically install
> > a configuration for a new device and it won't try to probe drivers for
> > the device's interfaces if the user installs a config.
> >
>
> Alan, we have several use cases for power switchable HUB, one of the use
> cases is USB port is managed by kernel (eg, needs mass storage
> class), but needs to toggle port power, is it reasonable we add a sysfs
> entry to support it?
Can you give more information about your use cases? After all, if the
port power is turned off then the port can't possibly handle
mass-storage devices -- or anything else.
On the other hand, if the port is managed by the kernel then the kernel
(not the user) should be responsible for deciding whether or not to
turn off the port's power.
If there's some real reason for turning the port power off for an
extended period of time, the user can claim the port and turn off the
power. Then later on, the user can release the port and turn the power
back on.
Alternatively, if you only need to turn off the port power for a short
time, what you're already doing should be okay.
I can't explain it any better than this unless I understand your use
cases more fully.
Alan Stern
^ permalink raw reply
* [PATCH v1] usb: typec: intel_pmc_mux: Configure HPD first for HPD+IRQ request
From: Madhusudanarao Amara @ 2020-12-16 14:09 UTC (permalink / raw)
To: heikki.krogerus, gregkh, linux-usb, linux-kernel
Cc: heikki.krogerus, madhusudanarao.amara
Warm reboot scenarios some times type C Mux driver gets Mux configuration
request as HPD=1,IRQ=1. In that scenario typeC Mux driver need to configure
Mux as follows as per IOM requirement:
(1). Confgiure Mux HPD = 1, IRQ = 0
(2). Configure Mux with HPD = 1, IRQ = 1
IOM expects TypeC Mux configuration as follows:
(1). HPD=1, IRQ=0
(2). HPD=1, IRQ=1
if IOM gets mux config request (2) without configuring (1), it will ignore
the request. The impact of this is there is no DP_alt mode display.
Fixes: 43d596e32276 ("usb: typec: intel_pmc_mux: Check the port status before connect")
Cc: stable@vger.kernel.org
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Madhusudanarao Amara <madhusudanarao.amara@intel.com>
---
drivers/usb/typec/mux/intel_pmc_mux.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index cf37a59ce130..46a25b8db72e 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -207,10 +207,21 @@ static int
pmc_usb_mux_dp_hpd(struct pmc_usb_port *port, struct typec_displayport_data *dp)
{
u8 msg[2] = { };
+ int ret;
msg[0] = PMC_USB_DP_HPD;
msg[0] |= port->usb3_port << PMC_USB_MSG_USB3_PORT_SHIFT;
+ /* Configure HPD first if HPD,IRQ comes together */
+ if (!IOM_PORT_HPD_ASSERTED(port->iom_status) &&
+ dp->status & DP_STATUS_IRQ_HPD &&
+ dp->status & DP_STATUS_HPD_STATE) {
+ msg[1] = PMC_USB_DP_HPD_LVL;
+ ret = pmc_usb_command(port, msg, sizeof(msg));
+ if (ret)
+ return ret;
+ }
+
if (dp->status & DP_STATUS_IRQ_HPD)
msg[1] = PMC_USB_DP_HPD_IRQ;
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 2/3] usb: xhci-mtk: fix UAS issue by XHCI_BROKEN_STREAMS quirk
From: Nicolas Boichat @ 2020-12-16 12:28 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Rob Herring, Mathias Nyman, Greg Kroah-Hartman, Matthias Brugger,
linux-usb, linux-arm Mailing List,
moderated list:ARM/Mediatek SoC support, Devicetree List, lkml,
Hsin-Yi Wang, Ikjoon Jang
In-Reply-To: <20201216115125.5886-2-chunfeng.yun@mediatek.com>
On Wed, Dec 16, 2020 at 7:53 PM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:
>
> The 0.96 xHCI controller on some platforms does not support
> bulk stream even HCCPARAMS says supporting, due to MaxPSASize
> is set a non-zero default value by mistake, here use
> XHCI_BROKEN_STREAMS quirk to fix it.
>
> Fixes: 94a631d91ad3 ("usb: xhci-mtk: check hcc_params after adding primary hcd")
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> drivers/usb/host/xhci-mtk.c | 7 ++++++-
> drivers/usb/host/xhci-mtk.h | 1 +
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
> index 8f321f39ab96..08dab974d847 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -395,6 +395,9 @@ static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci)
> xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
> if (mtk->lpm_support)
> xhci->quirks |= XHCI_LPM_SUPPORT;
> +
> + if (mtk->broken_streams)
> + xhci->quirks |= XHCI_BROKEN_STREAMS;
> }
>
> /* called during probe() after chip reset completes */
> @@ -460,6 +463,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
> return ret;
>
> mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
> + mtk->broken_streams =
> + of_property_read_bool(node, "mediatek,broken_streams_quirk");
Would it be better to add a data field to struct of_device_id
mtk_xhci_of_match, and enable this quirk on mediatek,mt8173-xhci only?
(IMHO usb3-lpm-capable detection should also be done in the same way)
Thanks,
> /* optional property, ignore the error if it does not exist */
> of_property_read_u32(node, "mediatek,u3p-dis-msk",
> &mtk->u3p_dis_msk);
> @@ -546,7 +551,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
> if (ret)
> goto put_usb3_hcd;
>
> - if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> + if (!mtk->broken_streams && HCC_MAX_PSA(xhci->hcc_params) >= 4)
> xhci->shared_hcd->can_do_streams = 1;
>
> ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
> index a93cfe817904..86aa4978915e 100644
> --- a/drivers/usb/host/xhci-mtk.h
> +++ b/drivers/usb/host/xhci-mtk.h
> @@ -147,6 +147,7 @@ struct xhci_hcd_mtk {
> struct phy **phys;
> int num_phys;
> bool lpm_support;
> + bool broken_streams;
> /* usb remote wakeup */
> bool uwk_en;
> struct regmap *uwk;
> --
> 2.18.0
^ permalink raw reply
* [PATCH 3/3] arm64: dts: mt8173: add a broken streams quirk property for xHCI node
From: Chunfeng Yun @ 2020-12-16 11:51 UTC (permalink / raw)
To: Rob Herring, Mathias Nyman
Cc: Chunfeng Yun, Greg Kroah-Hartman, Matthias Brugger, linux-usb,
linux-arm-kernel, linux-mediatek, devicetree, linux-kernel,
Hsin-Yi Wang, Ikjoon Jang
In-Reply-To: <20201216115125.5886-1-chunfeng.yun@mediatek.com>
Due to 0.96 xHCI on mt8173 doesn't support bulk stream but MaxPSASize
says supporting, add a new "mediatek,broken_streams_quirk" property to
fix it.
Fixes: 94a631d91ad3 ("usb: xhci-mtk: check hcc_params after adding primary hcd")
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
arch/arm64/boot/dts/mediatek/mt8173.dtsi | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index e88bbfc1fc55..f305fb033020 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -886,6 +886,7 @@
power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
clock-names = "sys_ck", "ref_ck";
+ mediatek,broken_streams_quirk;
status = "disabled";
};
};
--
2.18.0
^ permalink raw reply related
* [PATCH 1/3] dt-bindings: usb: mtk-xhci: add a new property for broken streams
From: Chunfeng Yun @ 2020-12-16 11:51 UTC (permalink / raw)
To: Rob Herring, Mathias Nyman
Cc: Chunfeng Yun, Greg Kroah-Hartman, Matthias Brugger, linux-usb,
linux-arm-kernel, linux-mediatek, devicetree, linux-kernel,
Hsin-Yi Wang, Ikjoon Jang
The 0.96 xHCI controller on some platforms does not support
bulk stream even HCCPARAMS says supporting, due to MaxPSASize
is set a non-zero default value by mistake, so add a new
property "mediatek,broken_streams_quirk" to fix it.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
this patch depends on:
https://patchwork.kernel.org/project/linux-mediatek/list/?series=402773
[v4,09/11] dt-bindings: usb: convert mediatek, mtk-xhci.txt to YAML schema
---
Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index e5e03f902802..330f7294bf34 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -120,6 +120,11 @@ properties:
description: The mask to disable u3ports, bit0 for u3port0,
bit1 for u3port1, ... etc
+ mediatek,broken_streams_quirk:
+ description: set if the controller doesn't support bulk stream but
+ HCCPARAMS says support.
+ type: boolean
+
"#address-cells":
const: 1
--
2.18.0
^ permalink raw reply related
* [PATCH 2/3] usb: xhci-mtk: fix UAS issue by XHCI_BROKEN_STREAMS quirk
From: Chunfeng Yun @ 2020-12-16 11:51 UTC (permalink / raw)
To: Rob Herring, Mathias Nyman
Cc: Chunfeng Yun, Greg Kroah-Hartman, Matthias Brugger, linux-usb,
linux-arm-kernel, linux-mediatek, devicetree, linux-kernel,
Hsin-Yi Wang, Ikjoon Jang
In-Reply-To: <20201216115125.5886-1-chunfeng.yun@mediatek.com>
The 0.96 xHCI controller on some platforms does not support
bulk stream even HCCPARAMS says supporting, due to MaxPSASize
is set a non-zero default value by mistake, here use
XHCI_BROKEN_STREAMS quirk to fix it.
Fixes: 94a631d91ad3 ("usb: xhci-mtk: check hcc_params after adding primary hcd")
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/host/xhci-mtk.c | 7 ++++++-
drivers/usb/host/xhci-mtk.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 8f321f39ab96..08dab974d847 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -395,6 +395,9 @@ static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci)
xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
if (mtk->lpm_support)
xhci->quirks |= XHCI_LPM_SUPPORT;
+
+ if (mtk->broken_streams)
+ xhci->quirks |= XHCI_BROKEN_STREAMS;
}
/* called during probe() after chip reset completes */
@@ -460,6 +463,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
return ret;
mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
+ mtk->broken_streams =
+ of_property_read_bool(node, "mediatek,broken_streams_quirk");
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u3p-dis-msk",
&mtk->u3p_dis_msk);
@@ -546,7 +551,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto put_usb3_hcd;
- if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
+ if (!mtk->broken_streams && HCC_MAX_PSA(xhci->hcc_params) >= 4)
xhci->shared_hcd->can_do_streams = 1;
ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index a93cfe817904..86aa4978915e 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -147,6 +147,7 @@ struct xhci_hcd_mtk {
struct phy **phys;
int num_phys;
bool lpm_support;
+ bool broken_streams;
/* usb remote wakeup */
bool uwk_en;
struct regmap *uwk;
--
2.18.0
^ permalink raw reply related
* Re: [PATCH v1 5/8] usb: chipidea: tegra: Support host mode
From: Dmitry Osipenko @ 2020-12-16 9:53 UTC (permalink / raw)
To: Peter Chen
Cc: Thierry Reding, Jonathan Hunter, Greg Kroah-Hartman, Alan Stern,
Felipe Balbi, Matt Merhar, Nicolas Chauvet, Peter Geis,
linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <DBBPR04MB79794F5CC440279AF94A48448BC50@DBBPR04MB7979.eurprd04.prod.outlook.com>
16.12.2020 12:32, Peter Chen пишет:
>
>>>>
>>>> struct tegra_usb_soc_info {
>>>> unsigned long flags;
>>>> + unsigned int txfifothresh;
>>>> + enum usb_dr_mode dr_mode;
>>>> +};
>>>> +
>>>> +static const struct tegra_usb_soc_info tegra20_ehci_soc_info = {
>>>> + .flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
>>>> + CI_HDRC_OVERRIDE_PHY_CONTROL,
>>>> + .dr_mode = USB_DR_MODE_HOST,
>>>> + .txfifothresh = 10,
>>>> +};
>>>> +
>>>> +static const struct tegra_usb_soc_info tegra30_ehci_soc_info = {
>>>> + .flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
>>>> + CI_HDRC_OVERRIDE_PHY_CONTROL
>>>> + .dr_mode = USB_DR_MODE_HOST,
>>>> + .txfifothresh = 16,
>>>> };
>>>>
>>>> static const struct tegra_usb_soc_info tegra_udc_soc_info = {
>>>> - .flags = CI_HDRC_REQUIRES_ALIGNED_DMA,
>>>> + .flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
>>>> + CI_HDRC_OVERRIDE_PHY_CONTROL,
>>>> + .dr_mode = USB_DR_MODE_UNKNOWN,
>>>> };
>>>
>>> What's the usage for this dr_mode? Does these three SoCs only supports
>>> single mode, it usually sets dr_mode at board dts file to indicate USB
>>> role for this board.
>>
>> All Tegra SoCs have three USB controllers. Only one of these three controllers
>> supports peripheral / OTG modes, the other two controllers are fixed to the
>> host mode and device trees do not specify the dr_mode for the host
>> controllers.
>>
>> Hence we need to enforce the dr_mode=host for the host-mode controllers.
>>
>> For UDC the default mode is "unknown" because actual mode comes from a
>> board's device tree.
>>
>
> You could add dr_mode property at usb node of soc.dtsi to fulfill that.
This will break older DTBs, we can't do this.
...
>>>> static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool
>>>> enable) {
>>>> struct ehci_hcd *ehci = hcd_to_ehci(hcd); @@ -160,14 +166,14 @@
>>>> static int host_start(struct ci_hdrc *ci)
>>>> pinctrl_select_state(ci->platdata->pctl,
>>>> ci->platdata->pins_host);
>>>>
>>>> + ci->hcd = hcd;
>>>> +
>>>> ret = usb_add_hcd(hcd, 0, 0);
>>>> if (ret) {
>>>> goto disable_reg;
>>>> } else {
>>>> struct usb_otg *otg = &ci->otg;
>>>>
>>>> - ci->hcd = hcd;
>>>> -
>>>
>>> Why this changed?
>>
>> The ci->hcd is used by tegra_usb_notify_event() to handle reset event and the
>> reset happens once usb_add_hcd() is invoked. Hence we need to pre-assign
>> the hcd pointer, otherwise there will be a NULL dereference.
>
> Get it, please set ci->hcd as NULL at error path.
Ok, thanks.
^ permalink raw reply
* RE: [PATCH v1 5/8] usb: chipidea: tegra: Support host mode
From: Peter Chen @ 2020-12-16 9:32 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Thierry Reding, Jonathan Hunter, Greg Kroah-Hartman, Alan Stern,
Felipe Balbi, Matt Merhar, Nicolas Chauvet, Peter Geis,
linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <bb617167-e6a4-221e-5e3b-c9d7a1b50c87@gmail.com>
> >>
> >> struct tegra_usb_soc_info {
> >> unsigned long flags;
> >> + unsigned int txfifothresh;
> >> + enum usb_dr_mode dr_mode;
> >> +};
> >> +
> >> +static const struct tegra_usb_soc_info tegra20_ehci_soc_info = {
> >> + .flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
> >> + CI_HDRC_OVERRIDE_PHY_CONTROL,
> >> + .dr_mode = USB_DR_MODE_HOST,
> >> + .txfifothresh = 10,
> >> +};
> >> +
> >> +static const struct tegra_usb_soc_info tegra30_ehci_soc_info = {
> >> + .flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
> >> + CI_HDRC_OVERRIDE_PHY_CONTROL
> >> + .dr_mode = USB_DR_MODE_HOST,
> >> + .txfifothresh = 16,
> >> };
> >>
> >> static const struct tegra_usb_soc_info tegra_udc_soc_info = {
> >> - .flags = CI_HDRC_REQUIRES_ALIGNED_DMA,
> >> + .flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
> >> + CI_HDRC_OVERRIDE_PHY_CONTROL,
> >> + .dr_mode = USB_DR_MODE_UNKNOWN,
> >> };
> >
> > What's the usage for this dr_mode? Does these three SoCs only supports
> > single mode, it usually sets dr_mode at board dts file to indicate USB
> > role for this board.
>
> All Tegra SoCs have three USB controllers. Only one of these three controllers
> supports peripheral / OTG modes, the other two controllers are fixed to the
> host mode and device trees do not specify the dr_mode for the host
> controllers.
>
> Hence we need to enforce the dr_mode=host for the host-mode controllers.
>
> For UDC the default mode is "unknown" because actual mode comes from a
> board's device tree.
>
You could add dr_mode property at usb node of soc.dtsi to fulfill that.
> >> static const struct of_device_id tegra_usb_of_match[] = {
> >> {
> >> + .compatible = "nvidia,tegra20-ehci",
> >> + .data = &tegra20_ehci_soc_info,
> >> + }, {
> >> + .compatible = "nvidia,tegra30-ehci",
> >> + .data = &tegra30_ehci_soc_info,
> >> + }, {
> >> .compatible = "nvidia,tegra20-udc",
> >> .data = &tegra_udc_soc_info,
> >
> > Your compatible indicates this controller is single USB role, is it on
> > purpose?
>
> Yes, the "tegra20/30-ehci" controllers are fixed to the host-mode in hardware.
>
> ...
> >> +static int tegra_usb_internal_port_reset(struct ehci_hcd *ehci,
> >> + u32 __iomem *portsc_reg,
> >> + unsigned long *flags)
> >> +{
> >> + u32 saved_usbintr, temp;
> >> + unsigned int i, tries;
> >> + int retval = 0;
> >> +
> >> + saved_usbintr = ehci_readl(ehci, &ehci->regs->intr_enable);
> >> + /* disable USB interrupt */
> >> + ehci_writel(ehci, 0, &ehci->regs->intr_enable);
> >> + spin_unlock_irqrestore(&ehci->lock, *flags);
> >> +
> >> + /*
> >> + * Here we have to do Port Reset at most twice for
> >> + * Port Enable bit to be set.
> >> + */
> >> + for (i = 0; i < 2; i++) {
> >> + temp = ehci_readl(ehci, portsc_reg);
> >> + temp |= PORT_RESET;
> >> + ehci_writel(ehci, temp, portsc_reg);
> >> + mdelay(10);
> >
> > Needs accurate delay? How about usleep_range?
>
> To be hones I don't know for sure whether hub_control() could be used from
> interrupt context. This mdelay is borrowed from the older ehci-tegra driver.
>
> Are you suggesting that it should be safe to sleep here?
>
I see msleep is called at tegra_ehci_hub_control at ehci-tegra.c.
.hub_control is not called at interrupt context.
> ...
> >> static int tegra_usb_probe(struct platform_device *pdev) {
> >> const struct tegra_usb_soc_info *soc; @@ -83,24 +292,49 @@
> static
> >> int tegra_usb_probe(struct platform_device *pdev)
> >> return err;
> >> }
> >>
> >> + if (device_property_present(&pdev->dev, "nvidia,needs-double-reset"))
> >> + usb->needs_double_reset = true;
> >> +
> >> + err = tegra_usb_reset_controller(&pdev->dev);
> >> + if (err) {
> >> + dev_err(&pdev->dev, "failed to reset controller: %d\n", err);
> >> + goto fail_power_off;
> >> + }
> >> +
> >> + /*
> >> + * USB controller registers shan't be touched before PHY is
> >
> > %s/shan't/shouldn't
>
> ok
>
> ...
> >> static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool
> >> enable) {
> >> struct ehci_hcd *ehci = hcd_to_ehci(hcd); @@ -160,14 +166,14 @@
> >> static int host_start(struct ci_hdrc *ci)
> >> pinctrl_select_state(ci->platdata->pctl,
> >> ci->platdata->pins_host);
> >>
> >> + ci->hcd = hcd;
> >> +
> >> ret = usb_add_hcd(hcd, 0, 0);
> >> if (ret) {
> >> goto disable_reg;
> >> } else {
> >> struct usb_otg *otg = &ci->otg;
> >>
> >> - ci->hcd = hcd;
> >> -
> >
> > Why this changed?
>
> The ci->hcd is used by tegra_usb_notify_event() to handle reset event and the
> reset happens once usb_add_hcd() is invoked. Hence we need to pre-assign
> the hcd pointer, otherwise there will be a NULL dereference.
Get it, please set ci->hcd as NULL at error path.
Peter
^ permalink raw reply
* [PATCH v4 10/11] dt-bindings: usb: convert mediatek,mtu3.txt to YAML schema
From: Chunfeng Yun @ 2020-12-16 9:30 UTC (permalink / raw)
To: Rob Herring
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
David S . Miller, Jakub Kicinski, Chunfeng Yun,
Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger,
Greg Kroah-Hartman, Stanley Chu, Min Guo, dri-devel, devicetree,
linux-kernel, netdev, linux-arm-kernel, linux-mediatek, linux-usb,
Serge Semin
In-Reply-To: <20201216093012.24406-1-chunfeng.yun@mediatek.com>
Convert mediatek,mtu3.txt to YAML schema mediatek,mtu3.yaml
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v4:
1. refer to usb-drd.yaml insstead of usb/generic.txt
the following ones suggested by Rob:
2. add the number of phys supported
3. fix indentation of wakeup
4. add examples for port and connector
v3:
1. fix yamllint warning
2. remove pinctrl* properties
3. remove unnecessary '|'
4. drop unused labels in example
v2: new patch
---
.../devicetree/bindings/usb/mediatek,mtu3.txt | 108 -------
.../bindings/usb/mediatek,mtu3.yaml | 278 ++++++++++++++++++
2 files changed, 278 insertions(+), 108 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
deleted file mode 100644
index a82ca438aec1..000000000000
--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
+++ /dev/null
@@ -1,108 +0,0 @@
-The device node for Mediatek USB3.0 DRD controller
-
-Required properties:
- - compatible : should be "mediatek,<soc-model>-mtu3", "mediatek,mtu3",
- soc-model is the name of SoC, such as mt8173, mt2712 etc,
- when using "mediatek,mtu3" compatible string, you need SoC specific
- ones in addition, one of:
- - "mediatek,mt8173-mtu3"
- - reg : specifies physical base address and size of the registers
- - reg-names: should be "mac" for device IP and "ippc" for IP port control
- - interrupts : interrupt used by the device IP
- - power-domains : a phandle to USB power domain node to control USB's
- mtcmos
- - vusb33-supply : regulator of USB avdd3.3v
- - clocks : a list of phandle + clock-specifier pairs, one for each
- entry in clock-names
- - clock-names : must contain "sys_ck" for clock of controller,
- the following clocks are optional:
- "ref_ck", "mcu_ck" and "dma_ck";
- - phys : see usb-hcd.yaml in the current directory
- - dr_mode : should be one of "host", "peripheral" or "otg",
- refer to usb/generic.txt
-
-Optional properties:
- - #address-cells, #size-cells : should be '2' if the device has sub-nodes
- with 'reg' property
- - ranges : allows valid 1:1 translation between child's address space and
- parent's address space
- - extcon : external connector for vbus and idpin changes detection, needed
- when supports dual-role mode.
- it's considered valid for compatibility reasons, not allowed for
- new bindings, and use "usb-role-switch" property instead.
- - vbus-supply : reference to the VBUS regulator, needed when supports
- dual-role mode.
- it's considered valid for compatibility reasons, not allowed for
- new bindings, and put into a usb-connector node.
- see connector/usb-connector.yaml.
- - pinctrl-names : a pinctrl state named "default" is optional, and need be
- defined if auto drd switch is enabled, that means the property dr_mode
- is set as "otg", and meanwhile the property "mediatek,enable-manual-drd"
- is not set.
- - pinctrl-0 : pin control group
- See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
-
- - maximum-speed : valid arguments are "super-speed", "high-speed" and
- "full-speed"; refer to usb/generic.txt
- - usb-role-switch : use USB Role Switch to support dual-role switch, but
- not extcon; see usb/generic.txt.
- - enable-manual-drd : supports manual dual-role switch via debugfs; usually
- used when receptacle is TYPE-A and also wants to support dual-role
- mode.
- - wakeup-source: enable USB remote wakeup of host mode.
- - mediatek,syscon-wakeup : phandle to syscon used to access the register
- of the USB wakeup glue layer between SSUSB and SPM; it depends on
- "wakeup-source", and has two arguments:
- - the first one : register base address of the glue layer in syscon;
- - the second one : hardware version of the glue layer
- - 1 : used by mt8173 etc
- - 2 : used by mt2712 etc
- - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
- bit1 for u3port1, ... etc;
-
-additionally the properties from usb-hcd.yaml (in the current directory) are
-supported.
-
-Sub-nodes:
-The xhci should be added as subnode to mtu3 as shown in the following example
-if host mode is enabled. The DT binding details of xhci can be found in:
-Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
-
-The port would be added as subnode if use "usb-role-switch" property.
- see graph.txt
-
-Example:
-ssusb: usb@11271000 {
- compatible = "mediatek,mt8173-mtu3";
- reg = <0 0x11271000 0 0x3000>,
- <0 0x11280700 0 0x0100>;
- reg-names = "mac", "ippc";
- interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_LOW>;
- phys = <&phy_port0 PHY_TYPE_USB3>,
- <&phy_port1 PHY_TYPE_USB2>;
- power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
- clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>,
- <&pericfg CLK_PERI_USB0>,
- <&pericfg CLK_PERI_USB1>;
- clock-names = "sys_ck", "ref_ck";
- vusb33-supply = <&mt6397_vusb_reg>;
- vbus-supply = <&usb_p0_vbus>;
- extcon = <&extcon_usb>;
- dr_mode = "otg";
- wakeup-source;
- mediatek,syscon-wakeup = <&pericfg 0x400 1>;
- #address-cells = <2>;
- #size-cells = <2>;
- ranges;
-
- usb_host: xhci@11270000 {
- compatible = "mediatek,mt8173-xhci";
- reg = <0 0x11270000 0 0x1000>;
- reg-names = "mac";
- interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
- power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
- clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
- clock-names = "sys_ck", "ref_ck";
- vusb33-supply = <&mt6397_vusb_reg>;
- };
-};
diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
new file mode 100644
index 000000000000..e39850dff073
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
@@ -0,0 +1,278 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (c) 2020 MediaTek
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/mediatek,mtu3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek USB3 DRD Controller Device Tree Bindings
+
+maintainers:
+ - Chunfeng Yun <chunfeng.yun@mediatek.com>
+
+allOf:
+ - $ref: "usb-drd.yaml"
+
+description: |
+ The DRD controller has a glue layer IPPC (IP Port Control), and its host is
+ based on xHCI.
+
+properties:
+ compatible:
+ items:
+ - enum:
+ - mediatek,mt2712-mtu3
+ - mediatek,mt8173-mtu3
+ - mediatek,mt8183-mtu3
+ - const: mediatek,mtu3
+
+ reg:
+ items:
+ - description: the registers of device MAC
+ - description: the registers of IP Port Control
+
+ reg-names:
+ items:
+ - const: mac
+ - const: ippc
+
+ interrupts:
+ maxItems: 1
+
+ power-domains:
+ description: A phandle to USB power domain node to control USB's MTCMOS
+ maxItems: 1
+
+ clocks:
+ minItems: 1
+ maxItems: 4
+ items:
+ - description: Controller clock used by normal mode
+ - description: Reference clock used by low power mode etc
+ - description: Mcu bus clock for register access
+ - description: DMA bus clock for data transfer
+
+ clock-names:
+ minItems: 1
+ maxItems: 4
+ items:
+ - const: sys_ck # required, the following ones are optional
+ - const: ref_ck
+ - const: mcu_ck
+ - const: dma_ck
+
+ phys:
+ description: List of all the USB PHYs used
+ minItems: 0
+ maxItems: 9
+
+ vusb33-supply:
+ description: Regulator of USB AVDD3.3v
+
+ vbus-supply:
+ deprecated: true
+ description: |
+ Regulator of USB VBUS5v, needed when supports dual-role mode.
+ Particularly, if use an output GPIO to control a VBUS regulator, should
+ model it as a regulator. See bindings/regulator/fixed-regulator.yaml
+ It's considered valid for compatibility reasons, not allowed for
+ new bindings, and put into a usb-connector node.
+
+ dr_mode:
+ enum: [host, peripheral, otg]
+ default: otg
+
+ maximum-speed:
+ enum: [super-speed-plus, super-speed, high-speed, full-speed]
+
+ "#address-cells":
+ enum: [1, 2]
+
+ "#size-cells":
+ enum: [1, 2]
+
+ ranges: true
+
+ extcon:
+ deprecated: true
+ description: |
+ Phandle to the extcon device detecting the IDDIG/VBUS state, neede
+ when supports dual-role mode.
+ It's considered valid for compatibility reasons, not allowed for
+ new bindings, and use "usb-role-switch" property instead.
+
+ usb-role-switch:
+ $ref: /schemas/types.yaml#/definitions/flag
+ description: Support role switch.
+ type: boolean
+
+ connector:
+ $ref: /connector/usb-connector.yaml#
+ description:
+ Connector for dual role switch, especially for "gpio-usb-b-connector"
+ type: object
+
+ port:
+ description:
+ Any connector to the data bus of this controller should be modelled
+ using the OF graph bindings specified, if the "usb-role-switch"
+ property is used. See graph.txt
+ type: object
+
+ enable-manual-drd:
+ $ref: /schemas/types.yaml#/definitions/flag
+ description:
+ supports manual dual-role switch via debugfs; usually used when
+ receptacle is TYPE-A and also wants to support dual-role mode.
+ type: boolean
+
+ wakeup-source:
+ description: enable USB remote wakeup, see power/wakeup-source.txt
+ type: boolean
+
+ mediatek,syscon-wakeup:
+ $ref: /schemas/types.yaml#/definitions/phandle-array
+ maxItems: 1
+ description:
+ A phandle to syscon used to access the register of the USB wakeup glue
+ layer between xHCI and SPM, the field should always be 3 cells long.
+ items:
+ items:
+ - description:
+ The first cell represents a phandle to syscon
+ - description:
+ The second cell represents the register base address of the glue
+ layer in syscon
+ - description:
+ The third cell represents the hardware version of the glue layer,
+ 1 is used by mt8173 etc, 2 is used by mt2712 etc
+ enum: [1, 2]
+
+ mediatek,u3p-dis-msk:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: The mask to disable u3ports, bit0 for u3port0,
+ bit1 for u3port1, ... etc
+
+# Required child node when support dual-role
+patternProperties:
+ "^usb@[0-9a-f]+$":
+ type: object
+ $ref: /usb/mediatek,mtk-xhci.yaml#
+ description:
+ The xhci should be added as subnode to mtu3 as shown in the following
+ example if the host mode is enabled.
+
+dependencies:
+ connector: [ 'usb-role-switch' ]
+ port: [ 'usb-role-switch' ]
+ wakeup-source: [ 'mediatek,syscon-wakeup' ]
+
+required:
+ - compatible
+ - reg
+ - reg-names
+ - interrupts
+ - clocks
+ - clock-names
+
+additionalProperties: false
+
+examples:
+ # Dual role switch by extcon
+ - |
+ #include <dt-bindings/clock/mt8173-clk.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/phy/phy.h>
+ #include <dt-bindings/power/mt8173-power.h>
+
+ usb@11271000 {
+ compatible = "mediatek,mt8173-mtu3", "mediatek,mtu3";
+ reg = <0x11271000 0x3000>, <0x11280700 0x0100>;
+ reg-names = "mac", "ippc";
+ interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_LOW>;
+ phys = <&phy_port0 PHY_TYPE_USB3>, <&phy_port1 PHY_TYPE_USB2>;
+ power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
+ clocks = <&topckgen CLK_TOP_USB30_SEL>;
+ clock-names = "sys_ck";
+ vusb33-supply = <&mt6397_vusb_reg>;
+ vbus-supply = <&usb_p0_vbus>;
+ extcon = <&extcon_usb>;
+ dr_mode = "otg";
+ wakeup-source;
+ mediatek,syscon-wakeup = <&pericfg 0x400 1>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+
+ xhci: usb@11270000 {
+ compatible = "mediatek,mt8173-xhci", "mediatek,mtk-xhci";
+ reg = <0x11270000 0x1000>;
+ reg-names = "mac";
+ interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
+ power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
+ clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
+ clock-names = "sys_ck", "ref_ck";
+ vusb33-supply = <&mt6397_vusb_reg>;
+ };
+ };
+
+ # Enable/disable device by an input gpio for VBUS pin
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+ #include <dt-bindings/power/mt2712-power.h>
+
+ usb@112c1000 {
+ compatible = "mediatek,mt2712-mtu3", "mediatek,mtu3";
+ reg = <0x112c1000 0x3000>, <0x112d0700 0x0100>;
+ reg-names = "mac", "ippc";
+ interrupts = <GIC_SPI 248 IRQ_TYPE_LEVEL_LOW>;
+ phys = <&u2port2 PHY_TYPE_USB2>;
+ power-domains = <&scpsys MT2712_POWER_DOMAIN_USB2>;
+ clocks = <&topckgen CLK_TOP_USB30_SEL>;
+ clock-names = "sys_ck";
+ dr_mode = "peripheral";
+ usb-role-switch;
+
+ connector {
+ compatible = "gpio-usb-b-connector", "usb-b-connector";
+ type = "micro";
+ vbus-gpios = <&pio 13 GPIO_ACTIVE_HIGH>;
+ };
+ };
+
+ # Dual role switch with type-c
+ - |
+ usb@11201000 {
+ compatible ="mediatek,mt8183-mtu3", "mediatek,mtu3";
+ reg = <0x11201000 0x2e00>, <0x11203e00 0x0100>;
+ reg-names = "mac", "ippc";
+ interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_LOW>;
+ phys = <&u2port0 PHY_TYPE_USB2>;
+ clocks = <&clk26m>;
+ clock-names = "sys_ck";
+ mediatek,syscon-wakeup = <&pericfg 0x400 1>;
+ wakeup-source;
+ dr_mode = "otg";
+ usb-role-switch;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+
+ host: usb@11200000 {
+ compatible = "mediatek,mt8183-xhci", "mediatek,mtk-xhci";
+ reg = <0x11200000 0x1000>;
+ reg-names = "mac";
+ interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_LOW>;
+ clocks = <&clk26m>;
+ clock-names = "sys_ck";
+ };
+
+ port {
+ usb_role_sw: endpoint {
+ remote-endpoint = <&hs_ep>;
+ };
+ };
+ };
+
+...
--
2.18.0
^ permalink raw reply related
* [PATCH v4 06/11] dt-bindings: phy: convert HDMI PHY binding to YAML schema
From: Chunfeng Yun @ 2020-12-16 9:30 UTC (permalink / raw)
To: Rob Herring
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
David S . Miller, Jakub Kicinski, Chunfeng Yun,
Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger,
Greg Kroah-Hartman, Stanley Chu, Min Guo, dri-devel, devicetree,
linux-kernel, netdev, linux-arm-kernel, linux-mediatek, linux-usb,
Serge Semin
In-Reply-To: <20201216093012.24406-1-chunfeng.yun@mediatek.com>
Convert HDMI PHY binding to YAML schema mediatek,hdmi-phy.yaml
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
v4: add maintainer Philipp
v3: add Reviewed-by Rob
v2: fix binding check warning of reg in example
---
.../display/mediatek/mediatek,hdmi.txt | 18 +---
.../bindings/phy/mediatek,hdmi-phy.yaml | 92 +++++++++++++++++++
2 files changed, 93 insertions(+), 17 deletions(-)
create mode 100644 Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml
diff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.txt b/Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.txt
index 6b1c586403e4..b284ca51b913 100644
--- a/Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.txt
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.txt
@@ -53,23 +53,7 @@ Required properties:
HDMI PHY
========
-
-The HDMI PHY serializes the HDMI encoder's three channel 10-bit parallel
-output and drives the HDMI pads.
-
-Required properties:
-- compatible: "mediatek,<chip>-hdmi-phy"
-- the supported chips are mt2701, mt7623 and mt8173
-- reg: Physical base address and length of the module's registers
-- clocks: PLL reference clock
-- clock-names: must contain "pll_ref"
-- clock-output-names: must be "hdmitx_dig_cts" on mt8173
-- #phy-cells: must be <0>
-- #clock-cells: must be <0>
-
-Optional properties:
-- mediatek,ibias: TX DRV bias current for <1.65Gbps, defaults to 0xa
-- mediatek,ibias_up: TX DRV bias current for >1.65Gbps, defaults to 0x1c
+See phy/mediatek,hdmi-phy.yaml
Example:
diff --git a/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml b/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml
new file mode 100644
index 000000000000..4752517a1446
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml
@@ -0,0 +1,92 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (c) 2020 MediaTek
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/mediatek,hdmi-phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek High Definition Multimedia Interface (HDMI) PHY binding
+
+maintainers:
+ - Chun-Kuang Hu <chunkuang.hu@kernel.org>
+ - Philipp Zabel <p.zabel@pengutronix.de>
+ - Chunfeng Yun <chunfeng.yun@mediatek.com>
+
+description: |
+ The HDMI PHY serializes the HDMI encoder's three channel 10-bit parallel
+ output and drives the HDMI pads.
+
+properties:
+ $nodename:
+ pattern: "^hdmi-phy@[0-9a-f]+$"
+
+ compatible:
+ enum:
+ - mediatek,mt2701-hdmi-phy
+ - mediatek,mt7623-hdmi-phy
+ - mediatek,mt8173-hdmi-phy
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ items:
+ - description: PLL reference clock
+
+ clock-names:
+ items:
+ - const: pll_ref
+
+ clock-output-names:
+ items:
+ - const: hdmitx_dig_cts
+
+ "#phy-cells":
+ const: 0
+
+ "#clock-cells":
+ const: 0
+
+ mediatek,ibias:
+ description:
+ TX DRV bias current for < 1.65Gbps
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 0
+ maximum: 63
+ default: 0xa
+
+ mediatek,ibias_up:
+ description:
+ TX DRV bias current for >= 1.65Gbps
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 0
+ maximum: 63
+ default: 0x1c
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - clock-output-names
+ - "#phy-cells"
+ - "#clock-cells"
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/mt8173-clk.h>
+ hdmi_phy: hdmi-phy@10209100 {
+ compatible = "mediatek,mt8173-hdmi-phy";
+ reg = <0x10209100 0x24>;
+ clocks = <&apmixedsys CLK_APMIXED_HDMI_REF>;
+ clock-names = "pll_ref";
+ clock-output-names = "hdmitx_dig_cts";
+ mediatek,ibias = <0xa>;
+ mediatek,ibias_up = <0x1c>;
+ #clock-cells = <0>;
+ #phy-cells = <0>;
+ };
+
+...
--
2.18.0
^ permalink raw reply related
* [PATCH v4 01/11] dt-bindings: usb: convert usb-device.txt to YAML schema
From: Chunfeng Yun @ 2020-12-16 9:30 UTC (permalink / raw)
To: Rob Herring
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
David S . Miller, Jakub Kicinski, Chunfeng Yun,
Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger,
Greg Kroah-Hartman, Stanley Chu, Min Guo, dri-devel, devicetree,
linux-kernel, netdev, linux-arm-kernel, linux-mediatek, linux-usb,
Serge Semin
Convert usb-device.txt to YAML schema usb-device.yaml
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v4: no changes, update dependent series:
https://patchwork.kernel.org/project/linux-usb/list/?series=399561
[v6,00/19] dt-bindings: usb: Add generic USB HCD, xHCI, DWC USB3 DT schema
v3:
1. remove $nodenmae and items key word for compatilbe;
2. add additionalProperties;
The followings are suggested by Rob:
3. merge the following patch
[v2,1/4] dt-bindings: usb: convert usb-device.txt to YAML schema
[v2,2/4] dt-bindings: usb: add properties for hard wired devices
4. define the unit-address for hard-wired device in usb-hcd.yaml,
also define its 'reg' and 'compatible';
5. This series is base on Serge's series:
https://patchwork.kernel.org/project/linux-usb/cover/20201111090853.14112-1-Sergey.Semin@baikalelectronics.ru/
[v4,00/18] dt-bindings: usb: Add generic USB HCD, xHCI, DWC USB3 DT schema
v2 changes suggested by Rob:
1. modify pattern to support any USB class
2. convert usb-device.txt into usb-device.yaml
---
.../devicetree/bindings/usb/usb-device.txt | 102 --------------
.../devicetree/bindings/usb/usb-device.yaml | 125 ++++++++++++++++++
.../devicetree/bindings/usb/usb-hcd.yaml | 33 +++++
3 files changed, 158 insertions(+), 102 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/usb/usb-device.txt
create mode 100644 Documentation/devicetree/bindings/usb/usb-device.yaml
diff --git a/Documentation/devicetree/bindings/usb/usb-device.txt b/Documentation/devicetree/bindings/usb/usb-device.txt
deleted file mode 100644
index 036be172b1ae..000000000000
--- a/Documentation/devicetree/bindings/usb/usb-device.txt
+++ /dev/null
@@ -1,102 +0,0 @@
-Generic USB Device Properties
-
-Usually, we only use device tree for hard wired USB device.
-The reference binding doc is from:
-http://www.devicetree.org/open-firmware/bindings/usb/usb-1_0.ps
-
-Four types of device-tree nodes are defined: "host-controller nodes"
-representing USB host controllers, "device nodes" representing USB devices,
-"interface nodes" representing USB interfaces and "combined nodes"
-representing simple USB devices.
-
-A combined node shall be used instead of a device node and an interface node
-for devices of class 0 or 9 (hub) with a single configuration and a single
-interface.
-
-A "hub node" is a combined node or an interface node that represents a USB
-hub.
-
-
-Required properties for device nodes:
-- compatible: "usbVID,PID", where VID is the vendor id and PID the product id.
- The textual representation of VID and PID shall be in lower case hexadecimal
- with leading zeroes suppressed. The other compatible strings from the above
- standard binding could also be used, but a device adhering to this binding
- may leave out all except for "usbVID,PID".
-- reg: the number of the USB hub port or the USB host-controller port to which
- this device is attached. The range is 1-255.
-
-
-Required properties for device nodes with interface nodes:
-- #address-cells: shall be 2
-- #size-cells: shall be 0
-
-
-Required properties for interface nodes:
-- compatible: "usbifVID,PID.configCN.IN", where VID is the vendor id, PID is
- the product id, CN is the configuration value and IN is the interface
- number. The textual representation of VID, PID, CN and IN shall be in lower
- case hexadecimal with leading zeroes suppressed. The other compatible
- strings from the above standard binding could also be used, but a device
- adhering to this binding may leave out all except for
- "usbifVID,PID.configCN.IN".
-- reg: the interface number and configuration value
-
-The configuration component is not included in the textual representation of
-an interface-node unit address for configuration 1.
-
-
-Required properties for combined nodes:
-- compatible: "usbVID,PID", where VID is the vendor id and PID the product id.
- The textual representation of VID and PID shall be in lower case hexadecimal
- with leading zeroes suppressed. The other compatible strings from the above
- standard binding could also be used, but a device adhering to this binding
- may leave out all except for "usbVID,PID".
-- reg: the number of the USB hub port or the USB host-controller port to which
- this device is attached. The range is 1-255.
-
-
-Required properties for hub nodes with device nodes:
-- #address-cells: shall be 1
-- #size-cells: shall be 0
-
-
-Required properties for host-controller nodes with device nodes:
-- #address-cells: shall be 1
-- #size-cells: shall be 0
-
-
-Example:
-
-&usb1 { /* host controller */
- #address-cells = <1>;
- #size-cells = <0>;
-
- hub@1 { /* hub connected to port 1 */
- compatible = "usb5e3,608";
- reg = <1>;
- };
-
- device@2 { /* device connected to port 2 */
- compatible = "usb123,4567";
- reg = <2>;
- };
-
- device@3 { /* device connected to port 3 */
- compatible = "usb123,abcd";
- reg = <3>;
-
- #address-cells = <2>;
- #size-cells = <0>;
-
- interface@0 { /* interface 0 of configuration 1 */
- compatible = "usbif123,abcd.config1.0";
- reg = <0 1>;
- };
-
- interface@0,2 { /* interface 0 of configuration 2 */
- compatible = "usbif123,abcd.config2.0";
- reg = <0 2>;
- };
- };
-};
diff --git a/Documentation/devicetree/bindings/usb/usb-device.yaml b/Documentation/devicetree/bindings/usb/usb-device.yaml
new file mode 100644
index 000000000000..f31d8a85d3e6
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-device.yaml
@@ -0,0 +1,125 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/usb-device.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: The device tree bindings for the Generic USB Device
+
+maintainers:
+ - Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+description: |
+ Usually, we only use device tree for hard wired USB device.
+ The reference binding doc is from:
+ http://www.devicetree.org/open-firmware/bindings/usb/usb-1_0.ps
+
+ Four types of device-tree nodes are defined: "host-controller nodes"
+ representing USB host controllers, "device nodes" representing USB devices,
+ "interface nodes" representing USB interfaces and "combined nodes"
+ representing simple USB devices.
+
+ A combined node shall be used instead of a device node and an interface node
+ for devices of class 0 or 9 (hub) with a single configuration and a single
+ interface.
+
+ A "hub node" is a combined node or an interface node that represents a USB
+ hub.
+
+properties:
+ compatible:
+ pattern: "^usb[0-9a-f]+,[0-9a-f]+$"
+ description: Device nodes or combined nodes.
+ "usbVID,PID", where VID is the vendor id and PID the product id.
+ The textual representation of VID and PID shall be in lower case
+ hexadecimal with leading zeroes suppressed. The other compatible
+ strings from the above standard binding could also be used,
+ but a device adhering to this binding may leave out all except
+ for "usbVID,PID".
+
+ reg:
+ description: the number of the USB hub port or the USB host-controller
+ port to which this device is attached. The range is 1-255.
+ maxItems: 1
+
+ "#address-cells":
+ description: should be 1 for hub nodes with device nodes,
+ should be 2 for device nodes with interface nodes.
+ enum: [1, 2]
+
+ "#size-cells":
+ const: 0
+
+patternProperties:
+ "^interface@[0-9]+(,[0-9]+)$":
+ type: object
+ description: USB interface nodes.
+ The configuration component is not included in the textual
+ representation of an interface-node unit address for configuration 1.
+
+ properties:
+ compatible:
+ pattern: "^usbif[0-9a-f]+,[0-9a-f]+.config[0-9a-f]+.[0-9a-f]+$"
+ description: Interface nodes.
+ "usbifVID,PID.configCN.IN", where VID is the vendor id, PID is
+ the product id, CN is the configuration value and IN is the interface
+ number. The textual representation of VID, PID, CN and IN shall be
+ in lower case hexadecimal with leading zeroes suppressed.
+ The other compatible strings from the above standard binding could
+ also be used, but a device adhering to this binding may leave out
+ all except for "usbifVID,PID.configCN.IN".
+
+ reg:
+ description: should be 2 cells long, the first cell represents
+ the interface number and the second cell represents the
+ configuration value.
+ maxItems: 1
+
+required:
+ - compatile
+ - reg
+
+additionalProperties: true
+
+examples:
+ #hub connected to port 1
+ #device connected to port 2
+ #device connected to port 3
+ # interface 0 of configuration 1
+ # interface 0 of configuration 2
+ - |
+ usb@11270000 {
+ compatible = "generic-xhci";
+ reg = <0x11270000 0x1000>;
+ interrupts = <0x0 0x4e 0x0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ hub@1 {
+ compatible = "usb5e3,608";
+ reg = <1>;
+ };
+
+ device@2 {
+ compatible = "usb123,4567";
+ reg = <2>;
+ };
+
+ device@3 {
+ compatible = "usb123,abcd";
+ reg = <3>;
+
+ #address-cells = <2>;
+ #size-cells = <0>;
+
+ interface@0 {
+ compatible = "usbif123,abcd.config1.0";
+ reg = <0 1>;
+ };
+
+ interface@0,2 {
+ compatible = "usbif123,abcd.config2.0";
+ reg = <0 2>;
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/usb/usb-hcd.yaml b/Documentation/devicetree/bindings/usb/usb-hcd.yaml
index 9881ac10380d..5d0c6b5500d6 100755
--- a/Documentation/devicetree/bindings/usb/usb-hcd.yaml
+++ b/Documentation/devicetree/bindings/usb/usb-hcd.yaml
@@ -23,6 +23,32 @@ properties:
targeted hosts (non-PC hosts).
type: boolean
+ "#address-cells":
+ const: 1
+
+ "#size-cells":
+ const: 0
+
+patternProperties:
+ "@[0-9a-f]+$":
+ type: object
+ description: The hard wired USB devices
+
+ properties:
+ compatible:
+ pattern: "^usb[0-9a-f]+,[0-9a-f]+$"
+ $ref: /usb/usb-device.yaml
+ description: the string is 'usbVID,PID', where VID is the vendor id
+ and PID is the product id
+
+ reg:
+ $ref: /usb/usb-device.yaml
+ maxItems: 1
+
+ required:
+ - compatible
+ - reg
+
additionalProperties: true
examples:
@@ -30,4 +56,11 @@ examples:
usb {
phys = <&usb2_phy1>, <&usb3_phy1>;
phy-names = "usb";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ hub@1 {
+ compatible = "usb5e3,610";
+ reg = <1>;
+ };
};
--
2.18.0
^ permalink raw reply related
* [PATCH v4 04/11] dt-bindings: phy: convert phy-mtk-tphy.txt to YAML schema
From: Chunfeng Yun @ 2020-12-16 9:30 UTC (permalink / raw)
To: Rob Herring
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
David S . Miller, Jakub Kicinski, Chunfeng Yun,
Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger,
Greg Kroah-Hartman, Stanley Chu, Min Guo, dri-devel, devicetree,
linux-kernel, netdev, linux-arm-kernel, linux-mediatek, linux-usb,
Serge Semin
In-Reply-To: <20201216093012.24406-1-chunfeng.yun@mediatek.com>
Convert phy-mtk-tphy.txt to YAML schema mediatek,tphy.yaml
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
v4: add Reviewed-by Rob
v3:
1. fix dt_binding_check error in example after add mtu3.yaml
Changes suggested by Rob:
2. fix wrong indentation
3. remove '|' due to no formatting to preserve
4. add a space after '#'
5. drop unused labels and status in examples
6. modify file mode
v2:
1. modify description and compatible
---
.../bindings/phy/mediatek,tphy.yaml | 260 ++++++++++++++++++
.../devicetree/bindings/phy/phy-mtk-tphy.txt | 162 -----------
2 files changed, 260 insertions(+), 162 deletions(-)
create mode 100644 Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
delete mode 100644 Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt
diff --git a/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml b/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
new file mode 100644
index 000000000000..602e6ff45785
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
@@ -0,0 +1,260 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (c) 2020 MediaTek
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/mediatek,tphy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek T-PHY Controller Device Tree Bindings
+
+maintainers:
+ - Chunfeng Yun <chunfeng.yun@mediatek.com>
+
+description: |
+ The T-PHY controller supports physical layer functionality for a number of
+ controllers on MediaTek SoCs, includes USB2.0, USB3.0, PCIe and SATA.
+
+ Layout differences of banks between T-PHY V1 (mt8173/mt2701) and
+ T-PHY V2 (mt2712) when works on USB mode:
+ -----------------------------------
+ Version 1:
+ port offset bank
+ shared 0x0000 SPLLC
+ 0x0100 FMREG
+ u2 port0 0x0800 U2PHY_COM
+ u3 port0 0x0900 U3PHYD
+ 0x0a00 U3PHYD_BANK2
+ 0x0b00 U3PHYA
+ 0x0c00 U3PHYA_DA
+ u2 port1 0x1000 U2PHY_COM
+ u3 port1 0x1100 U3PHYD
+ 0x1200 U3PHYD_BANK2
+ 0x1300 U3PHYA
+ 0x1400 U3PHYA_DA
+ u2 port2 0x1800 U2PHY_COM
+ ...
+
+ Version 2:
+ port offset bank
+ u2 port0 0x0000 MISC
+ 0x0100 FMREG
+ 0x0300 U2PHY_COM
+ u3 port0 0x0700 SPLLC
+ 0x0800 CHIP
+ 0x0900 U3PHYD
+ 0x0a00 U3PHYD_BANK2
+ 0x0b00 U3PHYA
+ 0x0c00 U3PHYA_DA
+ u2 port1 0x1000 MISC
+ 0x1100 FMREG
+ 0x1300 U2PHY_COM
+ u3 port1 0x1700 SPLLC
+ 0x1800 CHIP
+ 0x1900 U3PHYD
+ 0x1a00 U3PHYD_BANK2
+ 0x1b00 U3PHYA
+ 0x1c00 U3PHYA_DA
+ u2 port2 0x2000 MISC
+ ...
+
+ SPLLC shared by u3 ports and FMREG shared by u2 ports on V1 are put back
+ into each port; a new bank MISC for u2 ports and CHIP for u3 ports are
+ added on V2.
+
+properties:
+ $nodename:
+ pattern: "^t-phy@[0-9a-f]+$"
+
+ compatible:
+ oneOf:
+ - items:
+ - enum:
+ - mediatek,mt2701-tphy
+ - mediatek,mt7623-tphy
+ - mediatek,mt7622-tphy
+ - mediatek,mt8516-tphy
+ - const: mediatek,generic-tphy-v1
+ - items:
+ - enum:
+ - mediatek,mt2712-tphy
+ - mediatek,mt7629-tphy
+ - mediatek,mt8183-tphy
+ - const: mediatek,generic-tphy-v2
+ - const: mediatek,mt2701-u3phy
+ deprecated: true
+ - const: mediatek,mt2712-u3phy
+ deprecated: true
+ - const: mediatek,mt8173-u3phy
+
+ reg:
+ description:
+ Register shared by multiple ports, exclude port's private register.
+ It is needed for T-PHY V1, such as mt2701 and mt8173, but not for
+ T-PHY V2, such as mt2712.
+ maxItems: 1
+
+ "#address-cells":
+ enum: [1, 2]
+
+ "#size-cells":
+ enum: [1, 2]
+
+ # Used with non-empty value if optional 'reg' is not provided.
+ # The format of the value is an arbitrary number of triplets of
+ # (child-bus-address, parent-bus-address, length).
+ ranges: true
+
+ mediatek,src-ref-clk-mhz:
+ description:
+ Frequency of reference clock for slew rate calibrate
+ default: 26
+
+ mediatek,src-coef:
+ description:
+ Coefficient for slew rate calibrate, depends on SoC process
+ $ref: /schemas/types.yaml#/definitions/uint32
+ default: 28
+
+# Required child node:
+patternProperties:
+ "^usb-phy@[0-9a-f]+$":
+ type: object
+ description:
+ A sub-node is required for each port the controller provides.
+ Address range information including the usual 'reg' property
+ is used inside these nodes to describe the controller's topology.
+
+ properties:
+ reg:
+ maxItems: 1
+
+ clocks:
+ minItems: 1
+ maxItems: 2
+ items:
+ - description: Reference clock, (HS is 48Mhz, SS/P is 24~27Mhz)
+ - description: Reference clock of analog phy
+ description:
+ Uses both clocks if the clock of analog and digital phys are
+ separated, otherwise uses "ref" clock only if needed.
+
+ clock-names:
+ minItems: 1
+ maxItems: 2
+ items:
+ - const: ref
+ - const: da_ref
+
+ "#phy-cells":
+ const: 1
+ description: |
+ The cells contain the following arguments.
+
+ - description: The PHY type
+ enum:
+ - PHY_TYPE_USB2
+ - PHY_TYPE_USB3
+ - PHY_TYPE_PCIE
+ - PHY_TYPE_SATA
+
+ # The following optional vendor properties are only for debug or HQA test
+ mediatek,eye-src:
+ description:
+ The value of slew rate calibrate (U2 phy)
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 1
+ maximum: 7
+
+ mediatek,eye-vrt:
+ description:
+ The selection of VRT reference voltage (U2 phy)
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 1
+ maximum: 7
+
+ mediatek,eye-term:
+ description:
+ The selection of HS_TX TERM reference voltage (U2 phy)
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 1
+ maximum: 7
+
+ mediatek,intr:
+ description:
+ The selection of internal resistor (U2 phy)
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 1
+ maximum: 31
+
+ mediatek,discth:
+ description:
+ The selection of disconnect threshold (U2 phy)
+ $ref: /schemas/types.yaml#/definitions/uint32
+ minimum: 1
+ maximum: 15
+
+ mediatek,bc12:
+ description:
+ Specify the flag to enable BC1.2 if support it
+ type: boolean
+
+ required:
+ - reg
+ - "#phy-cells"
+
+ additionalProperties: false
+
+required:
+ - compatible
+ - "#address-cells"
+ - "#size-cells"
+ - ranges
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/mt8173-clk.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/phy/phy.h>
+ usb@11271000 {
+ compatible = "mediatek,mt8173-mtu3", "mediatek,mtu3";
+ reg = <0x11271000 0x3000>, <0x11280700 0x0100>;
+ reg-names = "mac", "ippc";
+ phys = <&u2port0 PHY_TYPE_USB2>,
+ <&u3port0 PHY_TYPE_USB3>,
+ <&u2port1 PHY_TYPE_USB2>;
+ interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
+ clocks = <&topckgen CLK_TOP_USB30_SEL>;
+ clock-names = "sys_ck";
+ };
+
+ t-phy@11290000 {
+ compatible = "mediatek,mt8173-u3phy";
+ reg = <0x11290000 0x800>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+
+ u2port0: usb-phy@11290800 {
+ reg = <0x11290800 0x100>;
+ clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>, <&clk48m>;
+ clock-names = "ref", "da_ref";
+ #phy-cells = <1>;
+ };
+
+ u3port0: usb-phy@11290900 {
+ reg = <0x11290900 0x700>;
+ clocks = <&clk26m>;
+ clock-names = "ref";
+ #phy-cells = <1>;
+ };
+
+ u2port1: usb-phy@11291000 {
+ reg = <0x11291000 0x100>;
+ #phy-cells = <1>;
+ };
+ };
+
+...
diff --git a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt b/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt
deleted file mode 100644
index dd75b676b71d..000000000000
--- a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt
+++ /dev/null
@@ -1,162 +0,0 @@
-MediaTek T-PHY binding
---------------------------
-
-T-phy controller supports physical layer functionality for a number of
-controllers on MediaTek SoCs, such as, USB2.0, USB3.0, PCIe, and SATA.
-
-Required properties (controller (parent) node):
- - compatible : should be one of
- "mediatek,generic-tphy-v1"
- "mediatek,generic-tphy-v2"
- "mediatek,mt2701-u3phy" (deprecated)
- "mediatek,mt2712-u3phy" (deprecated)
- "mediatek,mt8173-u3phy";
- make use of "mediatek,generic-tphy-v1" on mt2701 instead and
- "mediatek,generic-tphy-v2" on mt2712 instead.
-
-- #address-cells: the number of cells used to represent physical
- base addresses.
-- #size-cells: the number of cells used to represent the size of an address.
-- ranges: the address mapping relationship to the parent, defined with
- - empty value: if optional 'reg' is used.
- - non-empty value: if optional 'reg' is not used. should set
- the child's base address to 0, the physical address
- within parent's address space, and the length of
- the address map.
-
-Required nodes : a sub-node is required for each port the controller
- provides. Address range information including the usual
- 'reg' property is used inside these nodes to describe
- the controller's topology.
-
-Optional properties (controller (parent) node):
- - reg : offset and length of register shared by multiple ports,
- exclude port's private register. It is needed on mt2701
- and mt8173, but not on mt2712.
- - mediatek,src-ref-clk-mhz : frequency of reference clock for slew rate
- calibrate
- - mediatek,src-coef : coefficient for slew rate calibrate, depends on
- SoC process
-
-Required properties (port (child) node):
-- reg : address and length of the register set for the port.
-- #phy-cells : should be 1 (See second example)
- cell after port phandle is phy type from:
- - PHY_TYPE_USB2
- - PHY_TYPE_USB3
- - PHY_TYPE_PCIE
- - PHY_TYPE_SATA
-
-Optional properties (PHY_TYPE_USB2 port (child) node):
-- clocks : a list of phandle + clock-specifier pairs, one for each
- entry in clock-names
-- clock-names : may contain
- "ref": 48M reference clock for HighSpeed (digital) phy; and 26M
- reference clock for SuperSpeed (digital) phy, sometimes is
- 24M, 25M or 27M, depended on platform.
- "da_ref": the reference clock of analog phy, used if the clocks
- of analog and digital phys are separated, otherwise uses
- "ref" clock only if needed.
-
-- mediatek,eye-src : u32, the value of slew rate calibrate
-- mediatek,eye-vrt : u32, the selection of VRT reference voltage
-- mediatek,eye-term : u32, the selection of HS_TX TERM reference voltage
-- mediatek,bc12 : bool, enable BC12 of u2phy if support it
-- mediatek,discth : u32, the selection of disconnect threshold
-- mediatek,intr : u32, the selection of internal R (resistance)
-
-Example:
-
-u3phy: usb-phy@11290000 {
- compatible = "mediatek,mt8173-u3phy";
- reg = <0 0x11290000 0 0x800>;
- #address-cells = <2>;
- #size-cells = <2>;
- ranges;
-
- u2port0: usb-phy@11290800 {
- reg = <0 0x11290800 0 0x100>;
- clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>;
- clock-names = "ref";
- #phy-cells = <1>;
- };
-
- u3port0: usb-phy@11290900 {
- reg = <0 0x11290800 0 0x700>;
- clocks = <&clk26m>;
- clock-names = "ref";
- #phy-cells = <1>;
- };
-
- u2port1: usb-phy@11291000 {
- reg = <0 0x11291000 0 0x100>;
- clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>;
- clock-names = "ref";
- #phy-cells = <1>;
- };
-};
-
-Specifying phy control of devices
----------------------------------
-
-Device nodes should specify the configuration required in their "phys"
-property, containing a phandle to the phy port node and a device type;
-phy-names for each port are optional.
-
-Example:
-
-#include <dt-bindings/phy/phy.h>
-
-usb30: usb@11270000 {
- ...
- phys = <&u2port0 PHY_TYPE_USB2>, <&u3port0 PHY_TYPE_USB3>;
- phy-names = "usb2-0", "usb3-0";
- ...
-};
-
-
-Layout differences of banks between mt8173/mt2701 and mt2712
--------------------------------------------------------------
-mt8173 and mt2701:
-port offset bank
-shared 0x0000 SPLLC
- 0x0100 FMREG
-u2 port0 0x0800 U2PHY_COM
-u3 port0 0x0900 U3PHYD
- 0x0a00 U3PHYD_BANK2
- 0x0b00 U3PHYA
- 0x0c00 U3PHYA_DA
-u2 port1 0x1000 U2PHY_COM
-u3 port1 0x1100 U3PHYD
- 0x1200 U3PHYD_BANK2
- 0x1300 U3PHYA
- 0x1400 U3PHYA_DA
-u2 port2 0x1800 U2PHY_COM
- ...
-
-mt2712:
-port offset bank
-u2 port0 0x0000 MISC
- 0x0100 FMREG
- 0x0300 U2PHY_COM
-u3 port0 0x0700 SPLLC
- 0x0800 CHIP
- 0x0900 U3PHYD
- 0x0a00 U3PHYD_BANK2
- 0x0b00 U3PHYA
- 0x0c00 U3PHYA_DA
-u2 port1 0x1000 MISC
- 0x1100 FMREG
- 0x1300 U2PHY_COM
-u3 port1 0x1700 SPLLC
- 0x1800 CHIP
- 0x1900 U3PHYD
- 0x1a00 U3PHYD_BANK2
- 0x1b00 U3PHYA
- 0x1c00 U3PHYA_DA
-u2 port2 0x2000 MISC
- ...
-
- SPLLC shared by u3 ports and FMREG shared by u2 ports on
-mt8173/mt2701 are put back into each port; a new bank MISC for
-u2 ports and CHIP for u3 ports are added on mt2712.
--
2.18.0
^ permalink raw reply related
* [PATCH v4 09/11] dt-bindings: usb: convert mediatek,mtk-xhci.txt to YAML schema
From: Chunfeng Yun @ 2020-12-16 9:30 UTC (permalink / raw)
To: Rob Herring
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
David S . Miller, Jakub Kicinski, Chunfeng Yun,
Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger,
Greg Kroah-Hartman, Stanley Chu, Min Guo, dri-devel, devicetree,
linux-kernel, netdev, linux-arm-kernel, linux-mediatek, linux-usb,
Serge Semin
In-Reply-To: <20201216093012.24406-1-chunfeng.yun@mediatek.com>
Convert mediatek,mtk-xhci.txt to YAML schema mediatek,mtk-xhci.yaml
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v4: update it according to Rob's suggestion
1. modify dictionary of phys
2. fix endentation in "mediatek,syscon-wakeup" items
3. remove reference to usb-hcd.yaml
v3:
1. fix yamllint warning
2. remove pinctrl* properties supported by default suggested by Rob
3. drop unused labels
4. modify description of mediatek,syscon-wakeup
5. remove type of imod-interval-ns
v2: new patch
---
.../bindings/usb/mediatek,mtk-xhci.txt | 121 -------------
.../bindings/usb/mediatek,mtk-xhci.yaml | 171 ++++++++++++++++++
2 files changed, 171 insertions(+), 121 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
deleted file mode 100644
index 42d8814f903a..000000000000
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
+++ /dev/null
@@ -1,121 +0,0 @@
-MT8173 xHCI
-
-The device node for Mediatek SOC USB3.0 host controller
-
-There are two scenarios: the first one only supports xHCI driver;
-the second one supports dual-role mode, and the host is based on xHCI
-driver. Take account of backward compatibility, we divide bindings
-into two parts.
-
-1st: only supports xHCI driver
-------------------------------------------------------------------------
-
-Required properties:
- - compatible : should be "mediatek,<soc-model>-xhci", "mediatek,mtk-xhci",
- soc-model is the name of SoC, such as mt8173, mt2712 etc, when using
- "mediatek,mtk-xhci" compatible string, you need SoC specific ones in
- addition, one of:
- - "mediatek,mt8173-xhci"
- - reg : specifies physical base address and size of the registers
- - reg-names: should be "mac" for xHCI MAC and "ippc" for IP port control
- - interrupts : interrupt used by the controller
- - power-domains : a phandle to USB power domain node to control USB's
- mtcmos
- - vusb33-supply : regulator of USB avdd3.3v
-
- - clocks : a list of phandle + clock-specifier pairs, one for each
- entry in clock-names
- - clock-names : must contain
- "sys_ck": controller clock used by normal mode,
- the following ones are optional:
- "ref_ck": reference clock used by low power mode etc,
- "mcu_ck": mcu_bus clock for register access,
- "dma_ck": dma_bus clock for data transfer by DMA,
- "xhci_ck": controller clock
-
- - phys : see usb-hcd.yaml in the current directory
-
-Optional properties:
- - wakeup-source : enable USB remote wakeup;
- - mediatek,syscon-wakeup : phandle to syscon used to access the register
- of the USB wakeup glue layer between xHCI and SPM; it depends on
- "wakeup-source", and has two arguments:
- - the first one : register base address of the glue layer in syscon;
- - the second one : hardware version of the glue layer
- - 1 : used by mt8173 etc
- - 2 : used by mt2712 etc
- - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
- bit1 for u3port1, ... etc;
- - vbus-supply : reference to the VBUS regulator;
- - usb3-lpm-capable : supports USB3.0 LPM
- - pinctrl-names : a pinctrl state named "default" must be defined
- - pinctrl-0 : pin control group
- See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
- - imod-interval-ns: default interrupt moderation interval is 5000ns
-
-additionally the properties from usb-hcd.yaml (in the current directory) are
-supported.
-
-Example:
-usb30: usb@11270000 {
- compatible = "mediatek,mt8173-xhci";
- reg = <0 0x11270000 0 0x1000>,
- <0 0x11280700 0 0x0100>;
- reg-names = "mac", "ippc";
- interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
- power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
- clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>,
- <&pericfg CLK_PERI_USB0>,
- <&pericfg CLK_PERI_USB1>;
- clock-names = "sys_ck", "ref_ck";
- phys = <&phy_port0 PHY_TYPE_USB3>,
- <&phy_port1 PHY_TYPE_USB2>;
- vusb33-supply = <&mt6397_vusb_reg>;
- vbus-supply = <&usb_p1_vbus>;
- usb3-lpm-capable;
- mediatek,syscon-wakeup = <&pericfg 0x400 1>;
- wakeup-source;
- imod-interval-ns = <10000>;
-};
-
-2nd: dual-role mode with xHCI driver
-------------------------------------------------------------------------
-
-In the case, xhci is added as subnode to mtu3. An example and the DT binding
-details of mtu3 can be found in:
-Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
-
-Required properties:
- - compatible : should be "mediatek,<soc-model>-xhci", "mediatek,mtk-xhci",
- soc-model is the name of SoC, such as mt8173, mt2712 etc, when using
- "mediatek,mtk-xhci" compatible string, you need SoC specific ones in
- addition, one of:
- - "mediatek,mt8173-xhci"
- - reg : specifies physical base address and size of the registers
- - reg-names: should be "mac" for xHCI MAC
- - interrupts : interrupt used by the host controller
- - power-domains : a phandle to USB power domain node to control USB's
- mtcmos
- - vusb33-supply : regulator of USB avdd3.3v
-
- - clocks : a list of phandle + clock-specifier pairs, one for each
- entry in clock-names
- - clock-names : must contain "sys_ck", and the following ones are optional:
- "ref_ck", "mcu_ck" and "dma_ck", "xhci_ck"
-
-Optional properties:
- - vbus-supply : reference to the VBUS regulator;
- - usb3-lpm-capable : supports USB3.0 LPM
-
-Example:
-usb30: usb@11270000 {
- compatible = "mediatek,mt8173-xhci";
- reg = <0 0x11270000 0 0x1000>;
- reg-names = "mac";
- interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
- power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
- clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
- clock-names = "sys_ck", "ref_ck";
- vusb33-supply = <&mt6397_vusb_reg>;
- usb3-lpm-capable;
-};
diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
new file mode 100644
index 000000000000..e5e03f902802
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -0,0 +1,171 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (c) 2020 MediaTek
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/mediatek,mtk-xhci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek USB3 xHCI Device Tree Bindings
+
+maintainers:
+ - Chunfeng Yun <chunfeng.yun@mediatek.com>
+
+allOf:
+ - $ref: "usb-hcd.yaml"
+
+description: |
+ There are two scenarios:
+ case 1: only supports xHCI driver;
+ case 2: supports dual-role mode, and the host is based on xHCI driver.
+
+properties:
+ # common properties for both case 1 and case 2
+ compatible:
+ items:
+ - enum:
+ - mediatek,mt2712-xhci
+ - mediatek,mt7622-xhci
+ - mediatek,mt7629-xhci
+ - mediatek,mt8173-xhci
+ - mediatek,mt8183-xhci
+ - const: mediatek,mtk-xhci
+
+ reg:
+ minItems: 1
+ maxItems: 2
+ items:
+ - description: the registers of xHCI MAC
+ - description: the registers of IP Port Control
+
+ reg-names:
+ minItems: 1
+ maxItems: 2
+ items:
+ - const: mac
+ - const: ippc # optional, only needed for case 1.
+
+ interrupts:
+ maxItems: 1
+
+ power-domains:
+ description: A phandle to USB power domain node to control USB's MTCMOS
+ maxItems: 1
+
+ clocks:
+ minItems: 1
+ maxItems: 5
+ items:
+ - description: Controller clock used by normal mode
+ - description: Reference clock used by low power mode etc
+ - description: Mcu bus clock for register access
+ - description: DMA bus clock for data transfer
+ - description: controller clock
+
+ clock-names:
+ minItems: 1
+ maxItems: 5
+ items:
+ - const: sys_ck # required, the following ones are optional
+ - const: ref_ck
+ - const: mcu_ck
+ - const: dma_ck
+ - const: xhci_ck
+
+ phys:
+ description: List of at most 5 USB2 PHYs and 4 USB3 PHYs on this HCD
+ minItems: 0
+ maxItems: 9
+
+ vusb33-supply:
+ description: Regulator of USB AVDD3.3v
+
+ vbus-supply:
+ description: Regulator of USB VBUS5v
+
+ usb3-lpm-capable:
+ description: supports USB3.0 LPM
+ type: boolean
+
+ imod-interval-ns:
+ description:
+ Interrupt moderation interval value, it is 8 times as much as that
+ defined in the xHCI spec on MTK's controller.
+ default: 5000
+
+ # the following properties are only used for case 1
+ wakeup-source:
+ description: enable USB remote wakeup, see power/wakeup-source.txt
+ type: boolean
+
+ mediatek,syscon-wakeup:
+ $ref: /schemas/types.yaml#/definitions/phandle-array
+ maxItems: 1
+ description:
+ A phandle to syscon used to access the register of the USB wakeup glue
+ layer between xHCI and SPM, the field should always be 3 cells long.
+ items:
+ items:
+ - description:
+ The first cell represents a phandle to syscon
+ - description:
+ The second cell represents the register base address of the glue
+ layer in syscon
+ - description:
+ The third cell represents the hardware version of the glue layer,
+ 1 is used by mt8173 etc, 2 is used by mt2712 etc
+ enum: [1, 2]
+
+ mediatek,u3p-dis-msk:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: The mask to disable u3ports, bit0 for u3port0,
+ bit1 for u3port1, ... etc
+
+ "#address-cells":
+ const: 1
+
+ "#size-cells":
+ const: 0
+
+patternProperties:
+ "^[a-f]+@[0-9a-f]+$":
+ type: object
+ description: The hard wired USB devices.
+
+dependencies:
+ wakeup-source: [ 'mediatek,syscon-wakeup' ]
+
+required:
+ - compatible
+ - reg
+ - reg-names
+ - interrupts
+ - clocks
+ - clock-names
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/mt8173-clk.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/phy/phy.h>
+ #include <dt-bindings/power/mt8173-power.h>
+
+ usb@11270000 {
+ compatible = "mediatek,mt8173-xhci", "mediatek,mtk-xhci";
+ reg = <0x11270000 0x1000>, <0x11280700 0x0100>;
+ reg-names = "mac", "ippc";
+ interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_LOW>;
+ power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>;
+ clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>;
+ clock-names = "sys_ck", "ref_ck";
+ phys = <&u3port0 PHY_TYPE_USB3>, <&u2port1 PHY_TYPE_USB2>;
+ vusb33-supply = <&mt6397_vusb_reg>;
+ vbus-supply = <&usb_p1_vbus>;
+ imod-interval-ns = <10000>;
+ mediatek,syscon-wakeup = <&pericfg 0x400 1>;
+ wakeup-source;
+ usb3-lpm-capable;
+ };
+...
--
2.18.0
^ permalink raw reply related
* [PATCH v4 02/11] dt-bindings: net: btusb: change reference file name
From: Chunfeng Yun @ 2020-12-16 9:30 UTC (permalink / raw)
To: Rob Herring
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
David S . Miller, Jakub Kicinski, Chunfeng Yun,
Kishon Vijay Abraham I, Vinod Koul, Matthias Brugger,
Greg Kroah-Hartman, Stanley Chu, Min Guo, dri-devel, devicetree,
linux-kernel, netdev, linux-arm-kernel, linux-mediatek, linux-usb,
Serge Semin
In-Reply-To: <20201216093012.24406-1-chunfeng.yun@mediatek.com>
Due to usb-device.txt is converted into usb-device.yaml,
so modify reference file names at the same time.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~v4: no changes
---
Documentation/devicetree/bindings/net/btusb.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/net/btusb.txt b/Documentation/devicetree/bindings/net/btusb.txt
index b1ad6ee68e90..a9c3f4277f69 100644
--- a/Documentation/devicetree/bindings/net/btusb.txt
+++ b/Documentation/devicetree/bindings/net/btusb.txt
@@ -4,7 +4,7 @@ Generic Bluetooth controller over USB (btusb driver)
Required properties:
- compatible : should comply with the format "usbVID,PID" specified in
- Documentation/devicetree/bindings/usb/usb-device.txt
+ Documentation/devicetree/bindings/usb/usb-device.yaml
At the time of writing, the only OF supported devices
(more may be added later) are:
--
2.18.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox