2022-07-18 12:43:40

by Tomer Maimon

[permalink] [raw]
Subject: [PATCH v1 0/3] usb: host: npcm7xx-ehci: add Arbel NPCM8XX support and remove reset sequence

This patch set
- Adds Arbel NPCM8XX USB EHCI host controller support to USB EHCI driver.
- Remove the USB reset sequence because it is done in the NPCM reset driver.

The NPCM USB host driver tested on the NPCM845 evaluation board.

Tomer Maimon (3):
usb: host: npcm7xx: remove USB EHCI host reset sequence
dt-bindings: usb: npcm7xx: Add npcm845 compatible
USB: host: npcm: Add NPCM8XX support

.../devicetree/bindings/usb/npcm7xx-usb.txt | 4 +-
drivers/usb/host/Kconfig | 8 ++--
drivers/usb/host/ehci-npcm7xx.c | 47 -------------------
3 files changed, 7 insertions(+), 52 deletions(-)

--
2.33.0


2022-07-18 13:00:15

by Tomer Maimon

[permalink] [raw]
Subject: [PATCH v1 1/3] usb: host: npcm7xx: remove USB EHCI host reset sequence

Remove USB EHCI host controller reset sequence from NPCM7XX USB EHCI
host probe function because it is done in the NPCM reset driver.

Due to it, NPCM7XX EHCI driver configuration is dependent on NPCM reset.

Signed-off-by: Tomer Maimon <[email protected]>
---
drivers/usb/host/Kconfig | 2 +-
drivers/usb/host/ehci-npcm7xx.c | 47 ---------------------------------
2 files changed, 1 insertion(+), 48 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 682b3d2da623..e05e2cf806f8 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -206,7 +206,7 @@ config USB_EHCI_FSL

config USB_EHCI_HCD_NPCM7XX
tristate "Support for Nuvoton NPCM7XX on-chip EHCI USB controller"
- depends on (USB_EHCI_HCD && ARCH_NPCM7XX) || COMPILE_TEST
+ depends on (USB_EHCI_HCD && ARCH_NPCM7XX && RESET_NPCM) || COMPILE_TEST
default y if (USB_EHCI_HCD && ARCH_NPCM7XX)
help
Enables support for the on-chip EHCI controller on
diff --git a/drivers/usb/host/ehci-npcm7xx.c b/drivers/usb/host/ehci-npcm7xx.c
index 6b5a7a873e01..955e7c8f3db8 100644
--- a/drivers/usb/host/ehci-npcm7xx.c
+++ b/drivers/usb/host/ehci-npcm7xx.c
@@ -28,13 +28,6 @@
#define DRIVER_DESC "EHCI npcm7xx driver"

static const char hcd_name[] = "npcm7xx-ehci";
-
-#define USB2PHYCTL_OFFSET 0x144
-
-#define IPSRST2_OFFSET 0x24
-#define IPSRST3_OFFSET 0x34
-
-
static struct hc_driver __read_mostly ehci_npcm7xx_hc_driver;

static int __maybe_unused ehci_npcm7xx_drv_suspend(struct device *dev)
@@ -60,52 +53,12 @@ static int npcm7xx_ehci_hcd_drv_probe(struct platform_device *pdev)
{
struct usb_hcd *hcd;
struct resource *res;
- struct regmap *gcr_regmap;
- struct regmap *rst_regmap;
const struct hc_driver *driver = &ehci_npcm7xx_hc_driver;
int irq;
int retval;

dev_dbg(&pdev->dev, "initializing npcm7xx ehci USB Controller\n");

- gcr_regmap = syscon_regmap_lookup_by_compatible("nuvoton,npcm750-gcr");
- if (IS_ERR(gcr_regmap)) {
- dev_err(&pdev->dev, "%s: failed to find nuvoton,npcm750-gcr\n",
- __func__);
- return PTR_ERR(gcr_regmap);
- }
-
- rst_regmap = syscon_regmap_lookup_by_compatible("nuvoton,npcm750-rst");
- if (IS_ERR(rst_regmap)) {
- dev_err(&pdev->dev, "%s: failed to find nuvoton,npcm750-rst\n",
- __func__);
- return PTR_ERR(rst_regmap);
- }
-
- /********* phy init ******/
- // reset usb host
- regmap_update_bits(rst_regmap, IPSRST2_OFFSET,
- (0x1 << 26), (0x1 << 26));
- regmap_update_bits(rst_regmap, IPSRST3_OFFSET,
- (0x1 << 25), (0x1 << 25));
- regmap_update_bits(gcr_regmap, USB2PHYCTL_OFFSET,
- (0x1 << 28), 0);
-
- udelay(1);
-
- // enable phy
- regmap_update_bits(rst_regmap, IPSRST3_OFFSET,
- (0x1 << 25), 0);
-
- udelay(50); // enable phy
-
- regmap_update_bits(gcr_regmap, USB2PHYCTL_OFFSET,
- (0x1 << 28), (0x1 << 28));
-
- // enable host
- regmap_update_bits(rst_regmap, IPSRST2_OFFSET,
- (0x1 << 26), 0);
-
if (usb_disabled())
return -ENODEV;

--
2.33.0

2022-07-18 13:01:25

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH v1 1/3] usb: host: npcm7xx: remove USB EHCI host reset sequence

On Mon, Jul 18, 2022 at 2:29 PM Tomer Maimon <[email protected]> wrote:
>
> config USB_EHCI_HCD_NPCM7XX
> tristate "Support for Nuvoton NPCM7XX on-chip EHCI USB controller"
> - depends on (USB_EHCI_HCD && ARCH_NPCM7XX) || COMPILE_TEST
> + depends on (USB_EHCI_HCD && ARCH_NPCM7XX && RESET_NPCM) || COMPILE_TEST
> default y if (USB_EHCI_HCD && ARCH_NPCM7XX)
> help
> Enables support for the on-chip EHCI controller on

I would leave out this Kconfig change, there is really no need to enforce
this specific dependency. It is expected that a device driver has dependencies
on several other subsystems (irqchip, reset, pinctrl, clock, ....) and will only
work if the required drivers are also built for the same kernel.

Also, forcing the USB driver to be a loadable module when the reset driver
is a module (rather than built-in) does not guarantee that they are initialized
in the correct order. If only the USB driver is built-in and the reset driver is
a module, or both are loadable modules and USB gets loaded first, then
the probe() function should notice this and return -EPROBE_DEFER so
it will be retried after the reset driver is successfully loaded.

Arnd

2022-07-18 13:10:04

by Tomer Maimon

[permalink] [raw]
Subject: [PATCH v1 3/3] USB: host: npcm: Add NPCM8XX support

Modify NPCM USB EHCI host controller configuration to support all NPCM
BMC SoC.

Signed-off-by: Tomer Maimon <[email protected]>
---
drivers/usb/host/Kconfig | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index e05e2cf806f8..691f60f2d0f0 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -205,12 +205,12 @@ config USB_EHCI_FSL
Variation of ARC USB block used in some Freescale chips.

config USB_EHCI_HCD_NPCM7XX
- tristate "Support for Nuvoton NPCM7XX on-chip EHCI USB controller"
- depends on (USB_EHCI_HCD && ARCH_NPCM7XX && RESET_NPCM) || COMPILE_TEST
- default y if (USB_EHCI_HCD && ARCH_NPCM7XX)
+ tristate "Support for Nuvoton NPCM on-chip EHCI USB controller"
+ depends on (USB_EHCI_HCD && ARCH_NPCM && RESET_NPCM) || COMPILE_TEST
+ default y if (USB_EHCI_HCD && ARCH_NPCM)
help
Enables support for the on-chip EHCI controller on
- Nuvoton NPCM7XX chips.
+ Nuvoton NPCM chips.

config USB_EHCI_HCD_OMAP
tristate "EHCI support for OMAP3 and later chips"
--
2.33.0

2022-07-18 13:13:14

by Tomer Maimon

[permalink] [raw]
Subject: [PATCH v1 2/3] dt-bindings: usb: npcm7xx: Add npcm845 compatible

Add a compatible string for Nuvoton BMC NPCM845 USB EHCI host controller.

Signed-off-by: Tomer Maimon <[email protected]>
---
Documentation/devicetree/bindings/usb/npcm7xx-usb.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/npcm7xx-usb.txt b/Documentation/devicetree/bindings/usb/npcm7xx-usb.txt
index 5a0f1f14fbfa..352a0a1e2f76 100644
--- a/Documentation/devicetree/bindings/usb/npcm7xx-usb.txt
+++ b/Documentation/devicetree/bindings/usb/npcm7xx-usb.txt
@@ -5,7 +5,9 @@ EHCI:
-----

Required properties:
-- compatible: "nuvoton,npcm750-ehci"
+- compatible: should be one of
+ "nuvoton,npcm750-ehci"
+ "nuvoton,npcm845-ehci"
- interrupts: Should contain the EHCI interrupt
- reg: Physical address and length of the register set for the device

--
2.33.0

2022-07-18 14:14:45

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 2/3] dt-bindings: usb: npcm7xx: Add npcm845 compatible

On 18/07/2022 14:29, Tomer Maimon wrote:
> Add a compatible string for Nuvoton BMC NPCM845 USB EHCI host controller.
>
> Signed-off-by: Tomer Maimon <[email protected]>
> ---
> Documentation/devicetree/bindings/usb/npcm7xx-usb.txt | 4 +++-


Acked-by: Krzysztof Kozlowski <[email protected]>


Best regards,
Krzysztof

2022-07-18 14:37:38

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH v1 1/3] usb: host: npcm7xx: remove USB EHCI host reset sequence

On Mon, Jul 18, 2022 at 03:29:20PM +0300, Tomer Maimon wrote:
> Remove USB EHCI host controller reset sequence from NPCM7XX USB EHCI
> host probe function because it is done in the NPCM reset driver.
>
> Due to it, NPCM7XX EHCI driver configuration is dependent on NPCM reset.
>
> Signed-off-by: Tomer Maimon <[email protected]>
> ---

Regarding the changes to ehci-npcm7xx.c:

Acked-by: Alan Stern <[email protected]>

But you probably should remove the "#include <linux/regmap.h>" line near
the start of the source file.

Alan Stern

> drivers/usb/host/Kconfig | 2 +-
> drivers/usb/host/ehci-npcm7xx.c | 47 ---------------------------------
> 2 files changed, 1 insertion(+), 48 deletions(-)
>
> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> index 682b3d2da623..e05e2cf806f8 100644
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -206,7 +206,7 @@ config USB_EHCI_FSL
>
> config USB_EHCI_HCD_NPCM7XX
> tristate "Support for Nuvoton NPCM7XX on-chip EHCI USB controller"
> - depends on (USB_EHCI_HCD && ARCH_NPCM7XX) || COMPILE_TEST
> + depends on (USB_EHCI_HCD && ARCH_NPCM7XX && RESET_NPCM) || COMPILE_TEST
> default y if (USB_EHCI_HCD && ARCH_NPCM7XX)
> help
> Enables support for the on-chip EHCI controller on
> diff --git a/drivers/usb/host/ehci-npcm7xx.c b/drivers/usb/host/ehci-npcm7xx.c
> index 6b5a7a873e01..955e7c8f3db8 100644
> --- a/drivers/usb/host/ehci-npcm7xx.c
> +++ b/drivers/usb/host/ehci-npcm7xx.c
> @@ -28,13 +28,6 @@
> #define DRIVER_DESC "EHCI npcm7xx driver"
>
> static const char hcd_name[] = "npcm7xx-ehci";
> -
> -#define USB2PHYCTL_OFFSET 0x144
> -
> -#define IPSRST2_OFFSET 0x24
> -#define IPSRST3_OFFSET 0x34
> -
> -
> static struct hc_driver __read_mostly ehci_npcm7xx_hc_driver;
>
> static int __maybe_unused ehci_npcm7xx_drv_suspend(struct device *dev)
> @@ -60,52 +53,12 @@ static int npcm7xx_ehci_hcd_drv_probe(struct platform_device *pdev)
> {
> struct usb_hcd *hcd;
> struct resource *res;
> - struct regmap *gcr_regmap;
> - struct regmap *rst_regmap;
> const struct hc_driver *driver = &ehci_npcm7xx_hc_driver;
> int irq;
> int retval;
>
> dev_dbg(&pdev->dev, "initializing npcm7xx ehci USB Controller\n");
>
> - gcr_regmap = syscon_regmap_lookup_by_compatible("nuvoton,npcm750-gcr");
> - if (IS_ERR(gcr_regmap)) {
> - dev_err(&pdev->dev, "%s: failed to find nuvoton,npcm750-gcr\n",
> - __func__);
> - return PTR_ERR(gcr_regmap);
> - }
> -
> - rst_regmap = syscon_regmap_lookup_by_compatible("nuvoton,npcm750-rst");
> - if (IS_ERR(rst_regmap)) {
> - dev_err(&pdev->dev, "%s: failed to find nuvoton,npcm750-rst\n",
> - __func__);
> - return PTR_ERR(rst_regmap);
> - }
> -
> - /********* phy init ******/
> - // reset usb host
> - regmap_update_bits(rst_regmap, IPSRST2_OFFSET,
> - (0x1 << 26), (0x1 << 26));
> - regmap_update_bits(rst_regmap, IPSRST3_OFFSET,
> - (0x1 << 25), (0x1 << 25));
> - regmap_update_bits(gcr_regmap, USB2PHYCTL_OFFSET,
> - (0x1 << 28), 0);
> -
> - udelay(1);
> -
> - // enable phy
> - regmap_update_bits(rst_regmap, IPSRST3_OFFSET,
> - (0x1 << 25), 0);
> -
> - udelay(50); // enable phy
> -
> - regmap_update_bits(gcr_regmap, USB2PHYCTL_OFFSET,
> - (0x1 << 28), (0x1 << 28));
> -
> - // enable host
> - regmap_update_bits(rst_regmap, IPSRST2_OFFSET,
> - (0x1 << 26), 0);
> -
> if (usb_disabled())
> return -ENODEV;
>
> --
> 2.33.0
>

2022-07-18 15:19:15

by Tomer Maimon

[permalink] [raw]
Subject: Re: [PATCH v1 1/3] usb: host: npcm7xx: remove USB EHCI host reset sequence

Hi Arnd,

Thanks for your detailed explanation.

I will remove this modification in the next version.

On Mon, 18 Jul 2022 at 15:38, Arnd Bergmann <[email protected]> wrote:
>
> On Mon, Jul 18, 2022 at 2:29 PM Tomer Maimon <[email protected]> wrote:
> >
> > config USB_EHCI_HCD_NPCM7XX
> > tristate "Support for Nuvoton NPCM7XX on-chip EHCI USB controller"
> > - depends on (USB_EHCI_HCD && ARCH_NPCM7XX) || COMPILE_TEST
> > + depends on (USB_EHCI_HCD && ARCH_NPCM7XX && RESET_NPCM) || COMPILE_TEST
> > default y if (USB_EHCI_HCD && ARCH_NPCM7XX)
> > help
> > Enables support for the on-chip EHCI controller on
>
> I would leave out this Kconfig change, there is really no need to enforce
> this specific dependency. It is expected that a device driver has dependencies
> on several other subsystems (irqchip, reset, pinctrl, clock, ....) and will only
> work if the required drivers are also built for the same kernel.
>
> Also, forcing the USB driver to be a loadable module when the reset driver
> is a module (rather than built-in) does not guarantee that they are initialized
> in the correct order. If only the USB driver is built-in and the reset driver is
> a module, or both are loadable modules and USB gets loaded first, then
> the probe() function should notice this and return -EPROBE_DEFER so
> it will be retried after the reset driver is successfully loaded.
>
> Arnd

Best regards,

Tomer