+Marek

On Fri, Jun 18, 2021 at 04:57:23PM +0200, Pali Rohár wrote:

> From: Ivaylo Dimitrov <ivo.g.dimitrov...@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...@gmail.com>
> Tested-by: Pali Rohár <p...@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
> 

-- 
Tom

Attachment: signature.asc
Description: PGP signature

Reply via email to