public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Lokesh Vutla <lokeshvutla@ti.com>, Tom Rini <trini@konsulko.com>,
	Simon Glass <sjg@chromium.org>
Cc: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>,
	Merlijn Wajer <merlijn@wizzup.org>,
	maemo-leste@lists.dyne.org, u-boot@lists.denx.de,
	Pavel Machek <pavel@ucw.cz>
Subject: [PATCH 1/2] DM_USB: allow building without OF_CONTROL
Date: Fri, 18 Jun 2021 16:57:23 +0200	[thread overview]
Message-ID: <20210618145724.2558-1-pali@kernel.org> (raw)

From: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>

Currently DM_USB requires OF_CONTROL to be enabled, otherwise link errors
occur. On the other hand OF_CONTROL requires board code to be migrated to
DT, which is not always possible or required.

Fix that by conditionally compiling OF_CONTROL specific sections in USB
related drivers code in the same way like it is done in the other drivers.
Also, auto select OF_LIBFDT if DM_USB is selected but OF_CONTROL is not.
Introduce a new Kconfig option OF_NODE used to compile of_node.c in case
OF_CONTROL is not enabled. Fix deprecation warning condition as well.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Tested-by: Pali Rohár <pali@kernel.org>
---
 Makefile                      | 3 +--
 common/usb_hub.c              | 2 ++
 drivers/core/Makefile         | 7 ++++++-
 drivers/usb/Kconfig           | 6 ++++++
 drivers/usb/host/usb-uclass.c | 5 ++++-
 5 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index a73481d18c14..e1cf0200b72c 100644
--- a/Makefile
+++ b/Makefile
@@ -1114,8 +1114,7 @@ ifneq ($(CONFIG_DM),y)
 	@echo >&2 "See doc/driver-model/migration.rst for more info."
 	@echo >&2 "===================================================="
 endif
-	$(call deprecated,CONFIG_DM_USB CONFIG_OF_CONTROL CONFIG_BLK,\
-		USB,v2019.07,$(CONFIG_USB))
+	$(call deprecated,CONFIG_DM_USB CONFIG_BLK,USB,v2019.07,$(CONFIG_USB))
 	$(call deprecated,CONFIG_DM_PCI,PCI,v2019.07,$(CONFIG_PCI))
 	$(call deprecated,CONFIG_DM_VIDEO,video,v2019.07,\
 		$(CONFIG_LCD)$(CONFIG_VIDEO))
diff --git a/common/usb_hub.c b/common/usb_hub.c
index ba11a188ca64..c6b042a68440 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -956,7 +956,9 @@ U_BOOT_DRIVER(usb_generic_hub) = {
 UCLASS_DRIVER(usb_hub) = {
 	.id		= UCLASS_USB_HUB,
 	.name		= "usb_hub",
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 	.post_bind	= dm_scan_fdt_dev,
+#endif
 	.post_probe	= usb_hub_post_probe,
 	.child_pre_probe	= usb_child_pre_probe,
 	.per_child_auto	= sizeof(struct usb_device),
diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index 5edd4e413576..2cf5873a3278 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -15,6 +15,11 @@ obj-$(CONFIG_$(SPL_)OF_LIVE) += of_access.o of_addr.o
 ifndef CONFIG_DM_DEV_READ_INLINE
 obj-$(CONFIG_OF_CONTROL) += read.o
 endif
-obj-$(CONFIG_OF_CONTROL) += of_extra.o ofnode.o read_extra.o
+obj-$(CONFIG_OF_CONTROL) += of_extra.o read_extra.o
+ifdef CONFIG_OF_NODE
+obj-y += ofnode.o
+else
+obj-$(CONFIG_OF_CONTROL) += ofnode.o
+endif
 
 ccflags-$(CONFIG_DM_DEBUG) += -DDEBUG
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index f6975730bf8d..cb0593a724f0 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -33,9 +33,15 @@ menuconfig USB
 
 if USB
 
+config OF_NODE
+	bool
+	default n
+
 config DM_USB
 	bool "Enable driver model for USB"
 	depends on USB && DM
+	select OF_LIBFDT if !OF_CONTROL
+	select OF_NODE if !OF_CONTROL
 	help
 	  Enable driver model for USB. The USB interface is then implemented
 	  by the USB uclass. Multiple USB controllers of different types
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index e3b616c3266a..71dc578550f5 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -770,6 +770,7 @@ int usb_detect_change(void)
 
 static int usb_child_post_bind(struct udevice *dev)
 {
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct usb_dev_plat *plat = dev_get_parent_plat(dev);
 	int val;
 
@@ -787,7 +788,7 @@ static int usb_child_post_bind(struct udevice *dev)
 		plat->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS;
 		plat->id.bInterfaceClass = val;
 	}
-
+#endif
 	return 0;
 }
 
@@ -848,7 +849,9 @@ UCLASS_DRIVER(usb) = {
 	.id		= UCLASS_USB,
 	.name		= "usb",
 	.flags		= DM_UC_FLAG_SEQ_ALIAS,
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 	.post_bind	= dm_scan_fdt_dev,
+#endif
 	.priv_auto	= sizeof(struct usb_uclass_priv),
 	.per_child_auto	= sizeof(struct usb_device),
 	.per_device_auto	= sizeof(struct usb_bus_priv),
-- 
2.20.1


             reply	other threads:[~2021-06-18 14:57 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18 14:57 Pali Rohár [this message]
2021-06-18 14:57 ` [PATCH 2/2] Nokia RX-51: Enable CONFIG_DM_USB to remove deprecation warning Pali Rohár
2021-06-26 18:31   ` Simon Glass
2021-06-18 16:38 ` [PATCH 1/2] DM_USB: allow building without OF_CONTROL Tom Rini
2021-06-19  2:23   ` Marek Vasut
2021-06-19  6:14     ` Ivaylo Dimitrov
2021-06-19 18:17       ` Marek Vasut
2021-06-19 19:33         ` Ivaylo Dimitrov
2021-06-19 19:38           ` Marek Vasut
2021-06-19 20:15             ` Ivaylo Dimitrov
2021-06-19 20:51               ` Tom Rini
2021-06-20  3:52                 ` Marek Vasut
2021-06-20 15:54                   ` Tom Rini
2021-06-20 19:43                     ` Marek Vasut
2021-06-25 12:38                       ` Tom Rini
2021-06-25 13:07                         ` Pali Rohár
2021-06-25 16:04                           ` Simon Glass
2021-06-25 16:16                             ` Pali Rohár
2021-06-25 16:43                               ` Simon Glass
2021-06-25 16:58                                 ` Pali Rohár
2021-06-27 19:06                                   ` Simon Glass
2021-06-28 13:39                                     ` Tom Rini
2021-06-28 14:20                                       ` Simon Glass
2021-06-28 14:43                                         ` Tom Rini
2021-06-25 21:31                             ` Ivaylo Dimitrov
2021-06-25 21:37                               ` Tom Rini
2021-06-25 21:51                                 ` Pali Rohár
2021-06-25 21:59                                   ` Tom Rini
2021-06-26 10:59                                     ` Merlijn Wajer
2021-06-26 14:58                                       ` Tom Rini
2021-06-30  7:12                                         ` Ivaylo Dimitrov
2021-06-30  7:30                                         ` Ivaylo Dimitrov
2021-06-30 13:33                                           ` Tom Rini
2021-06-30 14:31                                             ` Ivaylo Dimitrov
2021-06-30 15:48                                               ` Tom Rini
2021-06-30 16:02                                                 ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210618145724.2558-1-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=lokeshvutla@ti.com \
    --cc=maemo-leste@lists.dyne.org \
    --cc=merlijn@wizzup.org \
    --cc=pavel@ucw.cz \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox