[U-Boot] [PATCH] usb: Introduce CONFIG_SPL_DM_USB

This allows building the SPL without driver model for USB. So far, support has only been added to the iMX6/7 host driver. Other boards will keep their existing behaviour.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- This solves the dependency problem I described in [1].
[1]: http://u-boot.10912.n7.nabble.com/-td347224.html
common/usb_storage.c | 34 +++++++++++++++++----------------- drivers/usb/Kconfig | 5 +++++ drivers/usb/gadget/ci_udc.c | 2 +- drivers/usb/host/Makefile | 3 ++- drivers/usb/host/ehci-hcd.c | 12 ++++++------ drivers/usb/host/ehci-mx6.c | 2 +- include/usb.h | 12 ++++++------ 7 files changed, 38 insertions(+), 32 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c index d92ebb6eb1..ff881aa0c9 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -66,7 +66,7 @@ static __u32 CBWTag;
static int usb_max_devs; /* number of highest available usb device */
-#ifndef CONFIG_BLK +#if !CONFIG_IS_ENABLED(BLK) static struct blk_desc usb_dev_desc[USB_MAX_STOR_DEV]; #endif
@@ -99,7 +99,7 @@ struct us_data { unsigned short max_xfer_blk; /* maximum transfer blocks */ };
-#ifndef CONFIG_BLK +#if !CONFIG_IS_ENABLED(BLK) static struct us_data usb_stor[USB_MAX_STOR_DEV]; #endif
@@ -111,7 +111,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *us, struct blk_desc *dev_desc); int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, struct us_data *ss); -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer); static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr, @@ -136,7 +136,7 @@ static void usb_show_progress(void) int usb_stor_info(void) { int count = 0; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct udevice *dev;
for (blk_first_device(IF_TYPE_USB, &dev); @@ -186,7 +186,7 @@ static int usb_stor_probe_device(struct usb_device *udev) { int lun, max_lun;
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct us_data *data; int ret; #else @@ -197,7 +197,7 @@ static int usb_stor_probe_device(struct usb_device *udev) #endif
debug("\n\nProbing for storage\n"); -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) /* * We store the us_data in the mass storage device's platdata. It * is shared by all LUNs (block devices) attached to this mass storage @@ -301,7 +301,7 @@ int usb_stor_scan(int mode) if (mode == 1) printf(" scanning usb for storage devices... ");
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) unsigned char i;
usb_disable_asynch(1); /* asynch transfer not allowed */ @@ -944,7 +944,7 @@ static void usb_stor_set_max_xfer_blk(struct usb_device *udev, size_t __maybe_unused size; int __maybe_unused ret;
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) #ifdef CONFIG_USB_EHCI_HCD /* * The U-Boot EHCI driver can handle any transfer length as long as @@ -1121,7 +1121,7 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor, } #endif /* CONFIG_USB_BIN_FIXUP */
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) #else @@ -1136,14 +1136,14 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr, struct us_data *ss; int retry; struct scsi_cmd *srb = &usb_ccb; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct blk_desc *block_dev; #endif
if (blkcnt == 0) return 0; /* Setup device */ -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) block_dev = dev_get_uclass_platdata(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); @@ -1202,7 +1202,7 @@ retry_it: return blkcnt; }
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) #else @@ -1217,7 +1217,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, struct us_data *ss; int retry; struct scsi_cmd *srb = &usb_ccb; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct blk_desc *block_dev; #endif
@@ -1225,7 +1225,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, return 0;
/* Setup device */ -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) block_dev = dev_get_uclass_platdata(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); @@ -1497,7 +1497,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, return 1; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int usb_mass_storage_probe(struct udevice *dev) { @@ -1521,7 +1521,7 @@ U_BOOT_DRIVER(usb_mass_storage) = { .id = UCLASS_MASS_STORAGE, .of_match = usb_mass_storage_ids, .probe = usb_mass_storage_probe, -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) .platdata_auto_alloc_size = sizeof(struct us_data), #endif }; @@ -1542,7 +1542,7 @@ static const struct usb_device_id mass_storage_id_table[] = { U_BOOT_USB_DEVICE(usb_mass_storage, mass_storage_id_table); #endif
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static const struct blk_ops usb_storage_ops = { .read = usb_stor_read, .write = usb_stor_write, diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 4fbe172e05..03746dd12f 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -47,6 +47,11 @@ config DM_USB declared with the U_BOOT_USB_DEVICE() macro and will be automatically probed when found on the bus.
+config SPL_DM_USB + bool "Enable driver model for USB in SPL" + depends on DM_USB + default y + source "drivers/usb/host/Kconfig"
source "drivers/usb/dwc3/Kconfig" diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index 0a84f6850d..bd596ce977 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -1015,7 +1015,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) if (driver->speed != USB_SPEED_FULL && driver->speed != USB_SPEED_HIGH) return -EINVAL;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) ret = usb_setup_ehci_gadget(&controller.ctrl); #else ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl); diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index cb8c315a15..94839ffd97 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -3,8 +3,9 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+obj-$(CONFIG_$(SPL_)DM_USB) += usb-uclass.o + ifdef CONFIG_DM_USB -obj-$(CONFIG_CMD_USB) += usb-uclass.o obj-$(CONFIG_SANDBOX) += usb-sandbox.o endif
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index d1d8f08d98..4b28db70a5 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -30,7 +30,7 @@ */ #define HCHALT_TIMEOUT (8 * 1000)
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct ehci_ctrl ehcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; #endif
@@ -111,7 +111,7 @@ static struct descriptor {
static struct ehci_ctrl *ehci_get_ctrl(struct usb_device *udev) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) return dev_get_priv(usb_get_bus(udev->dev)); #else return udev->controller; @@ -973,7 +973,7 @@ static void ehci_setup_ops(struct ehci_ctrl *ctrl, const struct ehci_ops *ops) } }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) void ehci_set_controller_priv(int index, void *priv, const struct ehci_ops *ops) { struct ehci_ctrl *ctrl = &ehcic[index]; @@ -1097,7 +1097,7 @@ static int ehci_common_init(struct ehci_ctrl *ctrl, uint tweaks) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_lowlevel_stop(int index) { ehci_shutdown(&ehcic[index]); @@ -1518,7 +1518,7 @@ static int _ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe, return result; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int length) { @@ -1556,7 +1556,7 @@ int destroy_int_queue(struct usb_device *dev, struct int_queue *queue) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index be010b1adb..1acf08dfb7 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -335,7 +335,7 @@ int ehci_mx6_common_init(struct usb_ehci *ehci, int index) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { diff --git a/include/usb.h b/include/usb.h index b6b48a8c60..420a30e49f 100644 --- a/include/usb.h +++ b/include/usb.h @@ -140,7 +140,7 @@ struct usb_device { int act_len; /* transferred bytes */ int maxchild; /* Number of ports if hub */ int portnr; /* Port number, 1=first */ -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* parent hub, or NULL if this is the root hub */ struct usb_device *parent; struct usb_device *children[USB_MAXCHILDREN]; @@ -148,7 +148,7 @@ struct usb_device { #endif /* slot_id - for xHCI enabled devices */ unsigned int slot_id; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; /* Pointer to associated device */ struct udevice *controller_dev; /* Pointer to associated controller */ #endif @@ -173,7 +173,7 @@ enum usb_init_type { int usb_lowlevel_init(int index, enum usb_init_type init, void **controller); int usb_lowlevel_stop(int index);
-#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_DM_USB) +#if defined(CONFIG_USB_MUSB_HOST) || CONFIG_IS_ENABLED(DM_USB) int usb_reset_root_port(struct usb_device *dev); #else #define usb_reset_root_port(dev) @@ -187,7 +187,7 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
#if defined CONFIG_USB_EHCI_HCD || defined CONFIG_USB_MUSB_HOST \ - || defined(CONFIG_DM_USB) + || CONFIG_IS_ENABLED(DM_USB) struct int_queue *create_int_queue(struct usb_device *dev, unsigned long pipe, int queuesize, int elementsize, void *buffer, int interval); int destroy_int_queue(struct usb_device *dev, struct int_queue *queue); @@ -588,7 +588,7 @@ struct usb_hub_device { struct usb_tt tt; /* Transaction Translator */ };
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /** * struct usb_platdata - Platform data about a USB controller * @@ -912,7 +912,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp); */ void usb_stor_reset(void);
-#else /* !CONFIG_DM_USB */ +#else /* !CONFIG_IS_ENABLED(DM_USB) */
struct usb_device *usb_get_dev_index(int index);

On 11/15/2018 09:20 AM, Sven Schwermer wrote:
This allows building the SPL without driver model for USB. So far, support has only been added to the iMX6/7 host driver. Other boards will keep their existing behaviour.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
Sweet! Is this s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ or is there some other stuff in the patch too ? If the later is the case, it'd be nice to do the s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ in a separate patch, to make the later easier to review.
Otherwise looks good.

Sweet! Is this s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ or is there some other stuff in the patch too ?
There is also a bunch of CONFIG_BLK replacements.
If the later is the case, it'd be nice to do the s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ in a separate patch, to make the later easier to review.
I was careful changing stuff that I couldn’t easily test. How should we take it from here?
Sven

On 11/15/2018 04:09 PM, Sven Schwermer wrote:
Sweet! Is this s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ or is there some other stuff in the patch too ?
There is also a bunch of CONFIG_BLK replacements.
If the later is the case, it'd be nice to do the s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ in a separate patch, to make the later easier to review.
I was careful changing stuff that I couldn’t easily test. How should we take it from here?
Split it in two patches, I'll pick it and see what happens :)
Did you have a chance to run it through travis CI to see if it builds on all and every platform ?

Hi again,
Did you have a chance to run it through travis CI to see if it builds on all and every platform ?
This was a really good tip. I discovered a bunch of problems and will basically replace CONFIG_DM_USB in the entire driver/usb directory. I’ll prepare split patches.
Sven

On 11/16/2018 01:46 PM, Sven Schwermer wrote:
Hi again,
Did you have a chance to run it through travis CI to see if it builds on all and every platform ?
This was a really good tip. I discovered a bunch of problems and will basically replace CONFIG_DM_USB in the entire driver/usb directory. I’ll prepare split patches.
Thanks!

This solves the dependency problem I described in [1].
[1]: http://u-boot.10912.n7.nabble.com/-td347224.html
Version 2: * Globally replace CONFIG_DM_USB * Split the CONFIG_DM_USB replacement into separate patch * Fix am335x_evm build
Sven Schwermer (4): usb: Introduce CONFIG_SPL_DM_USB usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ usb: storage: s/CONFIG_BLK/CONFIG_IS_ENABLED(BLK)/ usb: am335x_evm: Disable CONFIG_SPL_DM_USB
common/Makefile | 2 +- common/usb.c | 14 ++++++------- common/usb_hub.c | 16 +++++++-------- common/usb_kbd.c | 4 ++-- common/usb_storage.c | 34 +++++++++++++++---------------- configs/am335x_evm_defconfig | 3 ++- drivers/usb/Kconfig | 5 +++++ drivers/usb/common/Makefile | 2 +- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 2 +- drivers/usb/eth/usb_ether.c | 2 +- drivers/usb/gadget/ci_udc.c | 2 +- drivers/usb/gadget/ether.c | 8 ++++---- drivers/usb/host/Makefile | 5 +++-- drivers/usb/host/dwc2.c | 12 +++++------ drivers/usb/host/ehci-atmel.c | 2 +- drivers/usb/host/ehci-fsl.c | 12 +++++------ drivers/usb/host/ehci-hcd.c | 12 +++++------ drivers/usb/host/ehci-marvell.c | 4 ++-- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/ehci-pci.c | 8 ++++---- drivers/usb/host/ehci-vf.c | 2 +- drivers/usb/host/ohci-hcd.c | 10 ++++----- drivers/usb/host/ohci.h | 4 ++-- drivers/usb/host/xhci-dwc3.c | 2 +- drivers/usb/host/xhci-fsl.c | 4 ++-- drivers/usb/host/xhci-mem.c | 6 +++--- drivers/usb/host/xhci.c | 12 +++++------ drivers/usb/host/xhci.h | 2 +- drivers/usb/musb-new/musb_uboot.c | 12 +++++------ drivers/usb/musb-new/omap2430.c | 4 ++-- drivers/usb/musb-new/ti-musb.c | 4 ++-- drivers/usb/musb-new/usb-compat.h | 2 +- include/usb.h | 12 +++++------ 34 files changed, 118 insertions(+), 111 deletions(-)

Signed-off-by: Sven Schwermer sven@svenschwermer.de --- common/usb.c | 14 +++++++------- common/usb_hub.c | 16 ++++++++-------- common/usb_kbd.c | 4 ++-- common/usb_storage.c | 6 +++--- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 2 +- drivers/usb/eth/usb_ether.c | 2 +- drivers/usb/gadget/ci_udc.c | 2 +- drivers/usb/gadget/ether.c | 8 ++++---- drivers/usb/host/dwc2.c | 12 ++++++------ drivers/usb/host/ehci-atmel.c | 2 +- drivers/usb/host/ehci-fsl.c | 12 ++++++------ drivers/usb/host/ehci-hcd.c | 12 ++++++------ drivers/usb/host/ehci-marvell.c | 4 ++-- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/ehci-pci.c | 8 ++++---- drivers/usb/host/ehci-vf.c | 2 +- drivers/usb/host/ohci-hcd.c | 10 +++++----- drivers/usb/host/ohci.h | 4 ++-- drivers/usb/host/xhci-dwc3.c | 2 +- drivers/usb/host/xhci-fsl.c | 4 ++-- drivers/usb/host/xhci-mem.c | 6 +++--- drivers/usb/host/xhci.c | 12 ++++++------ drivers/usb/host/xhci.h | 2 +- drivers/usb/musb-new/musb_uboot.c | 12 ++++++------ drivers/usb/musb-new/omap2430.c | 4 ++-- drivers/usb/musb-new/ti-musb.c | 4 ++-- drivers/usb/musb-new/usb-compat.h | 2 +- include/usb.h | 12 ++++++------ 29 files changed, 92 insertions(+), 92 deletions(-)
diff --git a/common/usb.c b/common/usb.c index 78178c54c8..b70f614d24 100644 --- a/common/usb.c +++ b/common/usb.c @@ -42,7 +42,7 @@ static int asynch_allowed; char usb_started; /* flag for the started/stopped USB status */
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct usb_device usb_dev[USB_MAX_DEVICE]; static int dev_index;
@@ -183,7 +183,7 @@ int usb_disable_asynch(int disable) asynch_allowed = !disable; return old_value; } -#endif /* !CONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
/*------------------------------------------------------------------- @@ -849,7 +849,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) * the USB device are static allocated [USB_MAX_DEVICE]. */
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB)
/* returns a pointer to the device with the index [index]. * if the device is not assigned (dev->devnum==-1) returns NULL @@ -906,7 +906,7 @@ __weak int usb_alloc_device(struct usb_device *udev) { return 0; } -#endif /* !CONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
static int usb_hub_port_reset(struct usb_device *dev, struct usb_device *hub) { @@ -1166,7 +1166,7 @@ int usb_setup_device(struct usb_device *dev, bool do_read, return ret; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* * By the time we get here, the device has gotten a new device ID * and is in the default state. We need to identify the thing and @@ -1215,14 +1215,14 @@ int board_usb_cleanup(int index, enum usb_init_type init)
bool usb_device_has_child_on_port(struct usb_device *parent, int port) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) return false; #else return parent->children[port] != NULL; #endif }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) void usb_find_usb2_hub_address_port(struct usb_device *udev, uint8_t *hub_address, uint8_t *hub_port) { diff --git a/common/usb_hub.c b/common/usb_hub.c index e1d93b8333..33aaeb8e44 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -64,7 +64,7 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev) return hdev->descriptor.bDeviceProtocol == 3; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) bool usb_hub_is_root_hub(struct udevice *hub) { if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB) @@ -125,7 +125,7 @@ int usb_get_port_status(struct usb_device *dev, int port, void *data) USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port, data, sizeof(struct usb_port_status), USB_CNTL_TIMEOUT);
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) if (ret < 0) return ret;
@@ -209,7 +209,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub) max(100, (int)pgood_delay) + 1000); }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct usb_hub_device hub_dev[USB_MAX_HUB]; static int usb_hub_index;
@@ -273,7 +273,7 @@ static int usb_hub_port_reset(struct usb_device *dev, int port, unsigned short portstatus, portchange; int delay = HUB_SHORT_RESET_TIME; /* start with short reset delay */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) debug("%s: resetting '%s' port %d...\n", __func__, dev->dev->name, port + 1); #else @@ -394,7 +394,7 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port) break; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *child;
ret = usb_scan_device(dev->dev, port + 1, speed, &child); @@ -604,7 +604,7 @@ static struct usb_hub_device *usb_get_hub_device(struct usb_device *dev) { struct usb_hub_device *hub;
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* "allocate" Hub device */ hub = usb_hub_allocate(); #else @@ -788,7 +788,7 @@ static int usb_hub_configure(struct usb_device *dev) (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? \ "" : "no ");
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* * Update USB host controller's internal representation of this hub * after the hub descriptor is fetched. @@ -930,7 +930,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum) return ret; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) int usb_hub_scan(struct udevice *hub) { struct usb_device *udev = dev_get_parent_priv(hub); diff --git a/common/usb_kbd.c b/common/usb_kbd.c index fdeb2aed24..020f0d4117 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -539,7 +539,7 @@ static int probe_usb_keyboard(struct usb_device *dev) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* Search for keyboard and register it if found. */ int drv_usb_kbd_init(void) { @@ -602,7 +602,7 @@ int usb_kbd_deregister(int force)
#endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int usb_kbd_probe(struct udevice *dev) { diff --git a/common/usb_storage.c b/common/usb_storage.c index 560d60538b..c9a99b1ca2 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -299,7 +299,7 @@ int usb_stor_scan(int mode) if (mode == 1) printf(" scanning usb for storage devices... ");
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) unsigned char i;
usb_disable_asynch(1); /* asynch transfer not allowed */ @@ -942,7 +942,7 @@ static void usb_stor_set_max_xfer_blk(struct usb_device *udev, size_t __maybe_unused size; int __maybe_unused ret;
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) #ifdef CONFIG_USB_EHCI_HCD /* * The U-Boot EHCI driver can handle any transfer length as long as @@ -1495,7 +1495,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, return 1; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int usb_mass_storage_probe(struct udevice *dev) { diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 1ab5cee609..f1ca6191ce 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -789,7 +789,7 @@ MODULE_AUTHOR("Felipe Balbi balbi@ti.com"); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
int dwc3_init(struct dwc3 *dwc) { diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 58fe91dc51..cfe29884e7 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -712,7 +712,7 @@ struct dwc3 { /* device lock */ spinlock_t lock;
-#if defined(__UBOOT__) && defined(CONFIG_DM_USB) +#if defined(__UBOOT__) && CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; #else struct device *dev; diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c index 1ce3361b45..3aca9ac265 100644 --- a/drivers/usb/eth/usb_ether.c +++ b/drivers/usb/eth/usb_ether.c @@ -271,7 +271,7 @@ int usb_host_eth_scan(int mode) }
usb_max_eth_dev = 0; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* * TODO: We should add U_BOOT_USB_DEVICE() declarations to each USB * Ethernet driver and then most of this file can be removed. diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index 0a84f6850d..bd596ce977 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -1015,7 +1015,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) if (driver->speed != USB_SPEED_FULL && driver->speed != USB_SPEED_HIGH) return -EINVAL;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) ret = usb_setup_ehci_gadget(&controller.ctrl); #else ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl); diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 90ef1f055f..193583b437 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -100,7 +100,7 @@ struct eth_dev { struct usb_gadget *gadget; struct usb_request *req; /* for control responses */ struct usb_request *stat_req; /* for cdc & rndis status */ -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *usb_udev; #endif
@@ -2337,7 +2337,7 @@ fail:
/*-------------------------------------------------------------------------*/
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) int dm_usb_init(struct eth_dev *e_dev) { struct udevice *dev = NULL; @@ -2362,7 +2362,7 @@ static int _usb_eth_init(struct ether_priv *priv) unsigned long ts; unsigned long timeout = USB_CONNECT_TIMEOUT;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) if (dm_usb_init(dev)) { pr_err("USB ether not found\n"); return -ENODEV; @@ -2541,7 +2541,7 @@ void _usb_eth_halt(struct ether_priv *priv) }
usb_gadget_unregister_driver(&priv->eth_driver); -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) board_usb_cleanup(0, USB_INIT_DEVICE); #endif } diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index b6f008a400..a62a2f8a95 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -29,7 +29,7 @@ #define MAX_ENDPOINT 16
struct dwc2_priv { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) uint8_t aligned_buffer[DWC2_DATA_BUF_SIZE] __aligned(ARCH_DMA_MINALIGN); uint8_t status_buffer[DWC2_STATUS_BUF_SIZE] __aligned(ARCH_DMA_MINALIGN); #ifdef CONFIG_DM_REGULATOR @@ -54,7 +54,7 @@ struct dwc2_priv { struct reset_ctl_bulk resets; };
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* We need cacheline-aligned buffers for DMA transfers and dcache support */ DEFINE_ALIGN_BUFFER(uint8_t, aligned_buffer_addr, DWC2_DATA_BUF_SIZE, ARCH_DMA_MINALIGN); @@ -168,7 +168,7 @@ static void dwc_otg_core_reset(struct dwc2_core_regs *regs) mdelay(100); }
-#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR) +#if CONFIG_IS_ENABLED(DM_USB) && defined(CONFIG_DM_REGULATOR) static int dwc_vbus_supply_init(struct udevice *dev) { struct dwc2_priv *priv = dev_get_priv(dev); @@ -211,7 +211,7 @@ static int dwc_vbus_supply_init(struct udevice *dev) return 0; }
-#if defined(CONFIG_DM_USB) +#if CONFIG_IS_ENABLED(DM_USB) static int dwc_vbus_supply_exit(struct udevice *dev) { return 0; @@ -1222,7 +1222,7 @@ static void dwc2_uninit_common(struct dwc2_core_regs *regs) DWC2_HPRT0_PRTRST); }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int len, struct devrequest *setup) { @@ -1267,7 +1267,7 @@ int usb_lowlevel_stop(int index) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int dwc2_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 66dc63da08..6900848df1 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c @@ -14,7 +14,7 @@
#include "ehci.h"
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB)
int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index a8fb2b8ac3..23e7e7125f 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR; #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct ehci_fsl_priv { struct ehci_ctrl ehci; fdt_addr_t hcd_base; @@ -34,7 +34,7 @@ struct ehci_fsl_priv { #endif
static void set_txfifothresh(struct usb_ehci *, u32); -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci, struct ehci_hccr *hccr, struct ehci_hcor *hcor); #else @@ -54,7 +54,7 @@ static int usb_phy_clk_valid(struct usb_ehci *ehci) } }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_fsl_ofdata_to_platdata(struct udevice *dev) { struct ehci_fsl_priv *priv = dev_get_priv(dev); @@ -183,7 +183,7 @@ int ehci_hcd_stop(int index) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci, struct ehci_hccr *hccr, struct ehci_hcor *hcor) #else @@ -192,7 +192,7 @@ static int ehci_fsl_init(int index, struct usb_ehci *ehci, #endif { const char *phy_type = NULL; -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) size_t len; char current_usb_controller[5]; #endif @@ -218,7 +218,7 @@ static int ehci_fsl_init(int index, struct usb_ehci *ehci, out_be32(&ehci->snoop2, 0x80000000 | SNOOP_SIZE_2GB);
/* Init phy */ -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) if (priv->phy_type) phy_type = priv->phy_type; #else diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index d1d8f08d98..4b28db70a5 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -30,7 +30,7 @@ */ #define HCHALT_TIMEOUT (8 * 1000)
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct ehci_ctrl ehcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; #endif
@@ -111,7 +111,7 @@ static struct descriptor {
static struct ehci_ctrl *ehci_get_ctrl(struct usb_device *udev) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) return dev_get_priv(usb_get_bus(udev->dev)); #else return udev->controller; @@ -973,7 +973,7 @@ static void ehci_setup_ops(struct ehci_ctrl *ctrl, const struct ehci_ops *ops) } }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) void ehci_set_controller_priv(int index, void *priv, const struct ehci_ops *ops) { struct ehci_ctrl *ctrl = &ehcic[index]; @@ -1097,7 +1097,7 @@ static int ehci_common_init(struct ehci_ctrl *ctrl, uint tweaks) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_lowlevel_stop(int index) { ehci_shutdown(&ehcic[index]); @@ -1518,7 +1518,7 @@ static int _ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe, return result; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int length) { @@ -1556,7 +1556,7 @@ int destroy_int_queue(struct usb_device *dev, struct int_queue *queue) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c index 73432f2acd..8efe6b63b9 100644 --- a/drivers/usb/host/ehci-marvell.c +++ b/drivers/usb/host/ehci-marvell.c @@ -38,7 +38,7 @@ DECLARE_GLOBAL_DATA_PTR; /* * USB 2.0 Bridge Address Decoding registers setup */ -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
struct ehci_mvebu_priv { struct ehci_ctrl ehci; @@ -228,4 +228,4 @@ int ehci_hcd_stop(int index) return 0; }
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index be010b1adb..1acf08dfb7 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -335,7 +335,7 @@ int ehci_mx6_common_init(struct usb_ehci *ehci, int index) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 6150f3d888..04e7c5e37f 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -19,7 +19,7 @@ struct ehci_pci_priv { struct phy phy; };
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr, struct ehci_hcor **ret_hcor) { @@ -121,9 +121,9 @@ int ehci_hcd_stop(int index) { return 0; } -#endif /* nCONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_pci_probe(struct udevice *dev) { struct ehci_hccr *hccr; @@ -173,4 +173,4 @@ static struct pci_device_id ehci_pci_supported[] = {
U_BOOT_PCI_DEVICE(ehci_pci, ehci_pci_supported);
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c index 22e5afad6e..a16cf135e3 100644 --- a/drivers/usb/host/ehci-vf.c +++ b/drivers/usb/host/ehci-vf.c @@ -153,7 +153,7 @@ int ehci_vf_common_init(struct usb_ehci *ehci, int index) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 6ea9f105a6..3b6f889f7b 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -120,7 +120,7 @@ static struct pci_device_id ehci_pci_ids[] = { #define invalidate_dcache_iso_td(addr) invalidate_dcache_buffer(addr, 32) #define invalidate_dcache_hcca(addr) invalidate_dcache_buffer(addr, 256)
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* * The various ohci_mdelay(1) calls in the code seem unnecessary. We keep * them around when building for older boards not yet converted to the dm @@ -131,7 +131,7 @@ static struct pci_device_id ehci_pci_ids[] = { #define ohci_mdelay(x) mdelay(x) #endif
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* global ohci_t */ static ohci_t gohci; /* this must be aligned to a 256 byte boundary */ @@ -1691,7 +1691,7 @@ static int _ohci_destroy_int_queue(ohci_t *ohci, struct usb_device *dev, return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* submit routines called from usb.c */ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len) @@ -1980,7 +1980,7 @@ static int hc_interrupt(ohci_t *ohci)
/*-------------------------------------------------------------------------*/
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB)
/*-------------------------------------------------------------------------*/
@@ -2130,7 +2130,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ohci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index fba78dcf7a..f9f02cb09c 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h @@ -27,7 +27,7 @@ #define ED_ALIGNMENT 16 #endif
-#if defined CONFIG_DM_USB && ARCH_DMA_MINALIGN > 32 +#if CONFIG_IS_ENABLED(DM_USB) && ARCH_DMA_MINALIGN > 32 #define TD_ALIGNMENT ARCH_DMA_MINALIGN #else #define TD_ALIGNMENT 32 @@ -406,7 +406,7 @@ typedef struct ohci { const char *slot_name; } ohci_t;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) extern struct dm_usb_ops ohci_usb_ops;
int ohci_register(struct udevice *dev, struct ohci_regs *regs); diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c index 80754d76d0..dd0d156027 100644 --- a/drivers/usb/host/xhci-dwc3.c +++ b/drivers/usb/host/xhci-dwc3.c @@ -109,7 +109,7 @@ void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val) GFLADJ_30MHZ(val)); }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int xhci_dwc3_setup_phy(struct udevice *dev) { struct xhci_dwc3_platdata *plat = dev_get_platdata(dev); diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c index 047a8dfdef..c0b98a8ec7 100644 --- a/drivers/usb/host/xhci-fsl.c +++ b/drivers/usb/host/xhci-fsl.c @@ -19,7 +19,7 @@ #include <dm.h>
/* Declare global data pointer */ -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct fsl_xhci fsl_xhci; unsigned long ctr_addr[] = FSL_USB_XHCI_ADDR; #else @@ -107,7 +107,7 @@ static int fsl_xhci_core_exit(struct fsl_xhci *fsl_xhci) return 0; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int xhci_fsl_probe(struct udevice *dev) { struct xhci_fsl_priv *priv = dev_get_priv(dev); diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index da5dbd94ed..04ab540695 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -723,7 +723,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, int slot_id = udev->slot_id; int speed = udev->speed; int route = 0; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct usb_device *dev = udev; struct usb_hub_device *hub; #endif @@ -739,7 +739,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, /* Only the control endpoint is valid - one endpoint context */ slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1));
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* Calculate the route string for this device */ port_num = dev->portnr; while (!usb_hub_is_root_hub(dev->dev)) { @@ -782,7 +782,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, BUG(); }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* Set up TT fields to support FS/LS devices */ if (speed == USB_SPEED_LOW || speed == USB_SPEED_FULL) { struct udevice *parent = udev->dev; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 9ded14cc3c..44c5f2d264 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -108,13 +108,13 @@ static struct descriptor { }, };
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct xhci_ctrl xhcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; #endif
struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev;
/* Find the USB controller */ @@ -741,7 +741,7 @@ static int _xhci_alloc_device(struct usb_device *udev) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_alloc_device(struct usb_device *udev) { return _xhci_alloc_device(udev); @@ -1256,7 +1256,7 @@ static int xhci_lowlevel_stop(struct xhci_ctrl *ctrl) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) { @@ -1340,9 +1340,9 @@ int usb_lowlevel_stop(int index)
return 0; } -#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int xhci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index a7555b2fa8..6017504488 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1211,7 +1211,7 @@ void xhci_hcd_stop(int index); #define XHCI_STS_CNR (1 << 11)
struct xhci_ctrl { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; #endif struct xhci_hccr *hccr; /* R/O registers, not need for volatile */ diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 2bf918eab4..d40772b1aa 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -19,7 +19,7 @@ struct int_queue { struct urb urb; };
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) struct musb_host_data musb_host; #endif
@@ -243,7 +243,7 @@ int musb_lowlevel_init(struct musb_host_data *host) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_lowlevel_stop(int index) { if (!musb_host.host) { @@ -300,9 +300,9 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) { return musb_lowlevel_init(&musb_host); } -#endif /* !CONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int musb_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) @@ -364,7 +364,7 @@ struct dm_usb_ops musb_usb_ops = { .destroy_int_queue = musb_destroy_int_queue, .reset_root_port = musb_reset_root_port, }; -#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ #endif /* CONFIG_USB_MUSB_HOST */
#ifdef CONFIG_USB_MUSB_GADGET @@ -425,7 +425,7 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata, struct musb **musbp;
switch (plat->mode) { -#if defined(CONFIG_USB_MUSB_HOST) && !defined(CONFIG_DM_USB) +#if defined(CONFIG_USB_MUSB_HOST) && !CONFIG_IS_ENABLED(DM_USB) case MUSB_HOST: musbp = &musb_host.host; break; diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index 342d76bd6f..58aed72b7d 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -135,7 +135,7 @@ const struct musb_platform_ops omap2430_ops = { .disable = omap2430_musb_disable, };
-#if defined(CONFIG_DM_USB) +#if CONFIG_IS_ENABLED(DM_USB)
struct omap2430_musb_platdata { void *base; @@ -276,4 +276,4 @@ U_BOOT_DRIVER(omap2430_musb) = { .priv_auto_alloc_size = sizeof(struct musb_host_data), };
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index 9fbe2d6861..ee0960704a 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -19,7 +19,7 @@
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
/* USB 2.0 PHY Control */ #define CM_PHY_PWRDN (1 << 0) @@ -251,4 +251,4 @@ U_BOOT_DRIVER(ti_musb_wrapper) = { .bind = ti_musb_wrapper_bind, };
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/musb-new/usb-compat.h b/drivers/usb/musb-new/usb-compat.h index 760bd787bc..f2c18ad3a2 100644 --- a/drivers/usb/musb-new/usb-compat.h +++ b/drivers/usb/musb-new/usb-compat.h @@ -67,7 +67,7 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, return 0; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev) { struct udevice *parent = udev->dev->parent; diff --git a/include/usb.h b/include/usb.h index b6b48a8c60..420a30e49f 100644 --- a/include/usb.h +++ b/include/usb.h @@ -140,7 +140,7 @@ struct usb_device { int act_len; /* transferred bytes */ int maxchild; /* Number of ports if hub */ int portnr; /* Port number, 1=first */ -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* parent hub, or NULL if this is the root hub */ struct usb_device *parent; struct usb_device *children[USB_MAXCHILDREN]; @@ -148,7 +148,7 @@ struct usb_device { #endif /* slot_id - for xHCI enabled devices */ unsigned int slot_id; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; /* Pointer to associated device */ struct udevice *controller_dev; /* Pointer to associated controller */ #endif @@ -173,7 +173,7 @@ enum usb_init_type { int usb_lowlevel_init(int index, enum usb_init_type init, void **controller); int usb_lowlevel_stop(int index);
-#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_DM_USB) +#if defined(CONFIG_USB_MUSB_HOST) || CONFIG_IS_ENABLED(DM_USB) int usb_reset_root_port(struct usb_device *dev); #else #define usb_reset_root_port(dev) @@ -187,7 +187,7 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
#if defined CONFIG_USB_EHCI_HCD || defined CONFIG_USB_MUSB_HOST \ - || defined(CONFIG_DM_USB) + || CONFIG_IS_ENABLED(DM_USB) struct int_queue *create_int_queue(struct usb_device *dev, unsigned long pipe, int queuesize, int elementsize, void *buffer, int interval); int destroy_int_queue(struct usb_device *dev, struct int_queue *queue); @@ -588,7 +588,7 @@ struct usb_hub_device { struct usb_tt tt; /* Transaction Translator */ };
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /** * struct usb_platdata - Platform data about a USB controller * @@ -912,7 +912,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp); */ void usb_stor_reset(void);
-#else /* !CONFIG_DM_USB */ +#else /* !CONFIG_IS_ENABLED(DM_USB) */
struct usb_device *usb_get_dev_index(int index);

On 11/15/2018 08:50 AM, Sven Schwermer wrote:
Commit message is missing, please fix.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
common/usb.c | 14 +++++++------- common/usb_hub.c | 16 ++++++++-------- common/usb_kbd.c | 4 ++--
[...]

This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- configs/am335x_evm_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index b6cd49a469..6cc170ad40 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -40,15 +40,16 @@ CONFIG_NAND=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y -CONFIG_DRIVER_TI_CPSW=y CONFIG_PHY_GIGE=y CONFIG_MII=y +CONFIG_DRIVER_TI_CPSW=y CONFIG_SPI=y CONFIG_OMAP3_SPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y CONFIG_DM_USB=y +# CONFIG_SPL_DM_USB is not set CONFIG_USB_MUSB_HOST=y CONFIG_USB_MUSB_GADGET=y CONFIG_USB_MUSB_TI=y

On 11/16/2018 12:04 PM, Sven Schwermer wrote:
This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
How many other boards will need such a patch ?
configs/am335x_evm_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index b6cd49a469..6cc170ad40 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -40,15 +40,16 @@ CONFIG_NAND=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y -CONFIG_DRIVER_TI_CPSW=y CONFIG_PHY_GIGE=y CONFIG_MII=y +CONFIG_DRIVER_TI_CPSW=y CONFIG_SPI=y CONFIG_OMAP3_SPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y CONFIG_DM_USB=y +# CONFIG_SPL_DM_USB is not set CONFIG_USB_MUSB_HOST=y CONFIG_USB_MUSB_GADGET=y CONFIG_USB_MUSB_TI=y

On Sun, Nov 18, 2018 at 04:33:34AM +0100, Marek Vasut wrote:
On 11/16/2018 12:04 PM, Sven Schwermer wrote:
This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
How many other boards will need such a patch ?
In this case, "all" am335x boards should as only am43xx and later offer ROM loads SPL from a USB mass storage device (rather than showing up as a CDC ethernet device).

This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
How many other boards will need such a patch ?
In this case, "all" am335x boards should as only am43xx and later offer ROM loads SPL from a USB mass storage device (rather than showing up as a CDC ethernet device).
I actually tested this patch series on Travis CI and this was the only “offender”. See https://travis-ci.org/svenschwermer/u-boot/builds/456335517 https://travis-ci.org/svenschwermer/u-boot/builds/456335517 Are the other boards not checked in Travis? If so, I’d go through them manually.
Sven

On 11/18/2018 08:05 PM, Sven Schwermer wrote:
This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer <sven@svenschwermer.de mailto:sven@svenschwermer.de>
How many other boards will need such a patch ?
In this case, "all" am335x boards should as only am43xx and later offer ROM loads SPL from a USB mass storage device (rather than showing up as a CDC ethernet device).
I actually tested this patch series on Travis CI and this was the only “offender”. See https://travis-ci.org/svenschwermer/u-boot/builds/456335517 Are the other boards not checked in Travis? If so, I’d go through them manually.
Well, this patch disables DM_USB in SPL for am335x, but SPL_DM_USB is default y, so I wonder on how many boards SPL_DM_USB got enabled automatically and incorrectly.

On Sun, Nov 18, 2018 at 08:05:11PM +0100, Sven Schwermer wrote:
This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
How many other boards will need such a patch ?
In this case, "all" am335x boards should as only am43xx and later offer ROM loads SPL from a USB mass storage device (rather than showing up as a CDC ethernet device).
I actually tested this patch series on Travis CI and this was the only “offender”. See https://travis-ci.org/svenschwermer/u-boot/builds/456335517 https://travis-ci.org/svenschwermer/u-boot/builds/456335517 Are the other boards not checked in Travis? If so, I’d go through them manually.
I mean functionally. But if you can confirm that it's not being enabled on other platforms, that would be good, thanks!

Hi Sven,
On 18/11/2018 21:46, Tom Rini wrote:
On Sun, Nov 18, 2018 at 08:05:11PM +0100, Sven Schwermer wrote:
This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
How many other boards will need such a patch ?
In this case, "all" am335x boards should as only am43xx and later offer ROM loads SPL from a USB mass storage device (rather than showing up as a CDC ethernet device).
I actually tested this patch series on Travis CI and this was the only “offender”. See https://travis-ci.org/svenschwermer/u-boot/builds/456335517 https://travis-ci.org/svenschwermer/u-boot/builds/456335517 Are the other boards not checked in Travis? If so, I’d go through them manually.
I mean functionally. But if you can confirm that it's not being enabled on other platforms, that would be good, thanks!
FYI I posted a series a few weeks ago that adds a tool to automate this kind of job. check out "[RFC PATCH v3 0/3] python tools to inspect configs"
Command lines would be:
"tools/configs2csv.py --rebuild -" to build the database
and then
"tools/configs2csv.py CONFIG_SPL_DM_USB CONFIG_DM_USB > dm_usb_usage.csv"
JJ
U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot

On 20/11/2018 10:09, Jean-Jacques Hiblot wrote:
Hi Sven,
On 18/11/2018 21:46, Tom Rini wrote:
On Sun, Nov 18, 2018 at 08:05:11PM +0100, Sven Schwermer wrote:
This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
How many other boards will need such a patch ?
In this case, "all" am335x boards should as only am43xx and later offer ROM loads SPL from a USB mass storage device (rather than showing up as a CDC ethernet device).
I actually tested this patch series on Travis CI and this was the only “offender”. See https://travis-ci.org/svenschwermer/u-boot/builds/456335517 https://travis-ci.org/svenschwermer/u-boot/builds/456335517 Are the other boards not checked in Travis? If so, I’d go through them manually.
I mean functionally. But if you can confirm that it's not being enabled on other platforms, that would be good, thanks!
FYI I posted a series a few weeks ago that adds a tool to automate this kind of job. check out "[RFC PATCH v3 0/3] python tools to inspect configs"
Command lines would be:
"tools/configs2csv.py --rebuild -" to build the database
and then
"tools/configs2csv.py CONFIG_SPL_DM_USB CONFIG_DM_USB > dm_usb_usage.csv"
more accurate (because some board don't use the same config for u-boot, spl and tpl) and more readable (since we are interested only in the boards that activate the options) would be:
"tools/configs2csv.py CONFIG_SPL_DM_USB CONFIG_DM_USB --u-boot --spl --tpl --discard-empty > dm_usb_usage.csv"
JJ
U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot

Signed-off-by: Sven Schwermer sven@svenschwermer.de --- common/usb_storage.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c index c9a99b1ca2..8c889bb1a6 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -66,7 +66,7 @@ static __u32 CBWTag;
static int usb_max_devs; /* number of highest available usb device */
-#ifndef CONFIG_BLK +#if !CONFIG_IS_ENABLED(BLK) static struct blk_desc usb_dev_desc[USB_MAX_STOR_DEV]; #endif
@@ -99,7 +99,7 @@ struct us_data { unsigned short max_xfer_blk; /* maximum transfer blocks */ };
-#ifndef CONFIG_BLK +#if !CONFIG_IS_ENABLED(BLK) static struct us_data usb_stor[USB_MAX_STOR_DEV]; #endif
@@ -111,7 +111,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *us, struct blk_desc *dev_desc); int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, struct us_data *ss); -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer); static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr, @@ -136,7 +136,7 @@ static void usb_show_progress(void) int usb_stor_info(void) { int count = 0; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct udevice *dev;
for (blk_first_device(IF_TYPE_USB, &dev); @@ -186,7 +186,7 @@ static int usb_stor_probe_device(struct usb_device *udev) { int lun, max_lun;
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct us_data *data; int ret; #else @@ -197,7 +197,7 @@ static int usb_stor_probe_device(struct usb_device *udev) #endif
debug("\n\nProbing for storage\n"); -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) /* * We store the us_data in the mass storage device's platdata. It * is shared by all LUNs (block devices) attached to this mass storage @@ -1119,7 +1119,7 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor, } #endif /* CONFIG_USB_BIN_FIXUP */
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) #else @@ -1134,14 +1134,14 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr, struct us_data *ss; int retry; struct scsi_cmd *srb = &usb_ccb; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct blk_desc *block_dev; #endif
if (blkcnt == 0) return 0; /* Setup device */ -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) block_dev = dev_get_uclass_platdata(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); @@ -1200,7 +1200,7 @@ retry_it: return blkcnt; }
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) #else @@ -1215,7 +1215,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, struct us_data *ss; int retry; struct scsi_cmd *srb = &usb_ccb; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct blk_desc *block_dev; #endif
@@ -1223,7 +1223,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, return 0;
/* Setup device */ -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) block_dev = dev_get_uclass_platdata(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); @@ -1519,7 +1519,7 @@ U_BOOT_DRIVER(usb_mass_storage) = { .id = UCLASS_MASS_STORAGE, .of_match = usb_mass_storage_ids, .probe = usb_mass_storage_probe, -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) .platdata_auto_alloc_size = sizeof(struct us_data), #endif }; @@ -1540,7 +1540,7 @@ static const struct usb_device_id mass_storage_id_table[] = { U_BOOT_USB_DEVICE(usb_mass_storage, mass_storage_id_table); #endif
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static const struct blk_ops usb_storage_ops = { .read = usb_stor_read, .write = usb_stor_write,

On 11/17/2018 12:14 PM, Sven Schwermer wrote:
Commit message is missing.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
[...]

This allows building the SPL without driver model for USB.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- common/Makefile | 2 +- drivers/usb/Kconfig | 5 +++++ drivers/usb/common/Makefile | 2 +- drivers/usb/host/Makefile | 5 +++-- 4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/common/Makefile b/common/Makefile index a2388364d9..7d88077930 100644 --- a/common/Makefile +++ b/common/Makefile @@ -33,7 +33,7 @@ obj-$(CONFIG_MII) += miiphyutil.o obj-$(CONFIG_CMD_MII) += miiphyutil.o obj-$(CONFIG_PHYLIB) += miiphyutil.o
-ifdef CONFIG_CMD_USB +ifdef CONFIG_USB obj-y += usb.o usb_hub.o obj-$(CONFIG_USB_STORAGE) += usb_storage.o endif diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 4fbe172e05..03746dd12f 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -47,6 +47,11 @@ config DM_USB declared with the U_BOOT_USB_DEVICE() macro and will be automatically probed when found on the bus.
+config SPL_DM_USB + bool "Enable driver model for USB in SPL" + depends on DM_USB + default y + source "drivers/usb/host/Kconfig"
source "drivers/usb/dwc3/Kconfig" diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile index 55e0547b16..3bedbf213f 100644 --- a/drivers/usb/common/Makefile +++ b/drivers/usb/common/Makefile @@ -3,6 +3,6 @@ # (C) Copyright 2016 Freescale Semiconductor, Inc. #
-obj-$(CONFIG_DM_USB) += common.o +obj-$(CONFIG_$(SPL_)DM_USB) += common.o obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index cb8c315a15..2a3eec1eee 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -3,8 +3,9 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-ifdef CONFIG_DM_USB -obj-$(CONFIG_CMD_USB) += usb-uclass.o +obj-$(CONFIG_$(SPL_)DM_USB) += usb-uclass.o + +ifdef CONFIG_$(SPL_)DM_USB obj-$(CONFIG_SANDBOX) += usb-sandbox.o endif

On 11/17/2018 12:37 PM, Sven Schwermer wrote:
This allows building the SPL without driver model for USB.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
common/Makefile | 2 +- drivers/usb/Kconfig | 5 +++++ drivers/usb/common/Makefile | 2 +- drivers/usb/host/Makefile | 5 +++-- 4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/common/Makefile b/common/Makefile index a2388364d9..7d88077930 100644 --- a/common/Makefile +++ b/common/Makefile @@ -33,7 +33,7 @@ obj-$(CONFIG_MII) += miiphyutil.o obj-$(CONFIG_CMD_MII) += miiphyutil.o obj-$(CONFIG_PHYLIB) += miiphyutil.o
-ifdef CONFIG_CMD_USB +ifdef CONFIG_USB
Shouldn't this be a separate change ?
obj-y += usb.o usb_hub.o obj-$(CONFIG_USB_STORAGE) += usb_storage.o endif diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 4fbe172e05..03746dd12f 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -47,6 +47,11 @@ config DM_USB declared with the U_BOOT_USB_DEVICE() macro and will be automatically probed when found on the bus.
+config SPL_DM_USB
I think this should be introduced last, after all the core changes, since this patch won't compile cleanly on it's own, will it ?
- bool "Enable driver model for USB in SPL"
- depends on DM_USB
- default y
source "drivers/usb/host/Kconfig"
source "drivers/usb/dwc3/Kconfig" diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile index 55e0547b16..3bedbf213f 100644 --- a/drivers/usb/common/Makefile +++ b/drivers/usb/common/Makefile @@ -3,6 +3,6 @@ # (C) Copyright 2016 Freescale Semiconductor, Inc. #
-obj-$(CONFIG_DM_USB) += common.o +obj-$(CONFIG_$(SPL_)DM_USB) += common.o obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index cb8c315a15..2a3eec1eee 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -3,8 +3,9 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-ifdef CONFIG_DM_USB -obj-$(CONFIG_CMD_USB) += usb-uclass.o +obj-$(CONFIG_$(SPL_)DM_USB) += usb-uclass.o
+ifdef CONFIG_$(SPL_)DM_USB obj-$(CONFIG_SANDBOX) += usb-sandbox.o endif

Hi!
-ifdef CONFIG_CMD_USB +ifdef CONFIG_USB
Shouldn't this be a separate change ?
Do you mean a separate patch set or its own patch? I was actually not 100% sure about this one but ran into link problems with the status quo. It seemed odd that this code would depend on the USB command. Maybe you can elaborate a little?
obj-y += usb.o usb_hub.o obj-$(CONFIG_USB_STORAGE) += usb_storage.o endif diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 4fbe172e05..03746dd12f 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -47,6 +47,11 @@ config DM_USB declared with the U_BOOT_USB_DEVICE() macro and will be automatically probed when found on the bus.
+config SPL_DM_USB
I think this should be introduced last, after all the core changes, since this patch won't compile cleanly on it's own, will it ?
Not sure, I understand. Just introducing a new Kconfig variable won’t change the “compilibility” of existing code?!
Best, Sven

On 11/18/2018 08:08 PM, Sven Schwermer wrote:
Hi!
-ifdef CONFIG_CMD_USB +ifdef CONFIG_USB
Shouldn't this be a separate change ?
Do you mean a separate patch set or its own patch? I was actually not 100% sure about this one but ran into link problems with the status quo. It seemed odd that this code would depend on the USB command. Maybe you can elaborate a little?
I think this particular change should be in a separate patch . The code should not depend on CMD_USB I think.
obj-y += usb.o usb_hub.o obj-$(CONFIG_USB_STORAGE) += usb_storage.o endif diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 4fbe172e05..03746dd12f 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -47,6 +47,11 @@ config DM_USB declared with the U_BOOT_USB_DEVICE() macro and will be automatically probed when found on the bus.
+config SPL_DM_USB
I think this should be introduced last, after all the core changes, since this patch won't compile cleanly on it's own, will it ?
Not sure, I understand. Just introducing a new Kconfig variable won’t change the “compilibility” of existing code?!
No, but you're not "just introducing" new Kconfig option, you are also using it. And the general rule of thumb is, do preparatory changes first and introduce new features afterward.

This solves the dependency problem I described in [1].
[1]: http://u-boot.10912.n7.nabble.com/-td347224.html
Version 3: * Reordered patches. * Split out CMD_USB dependency patch. * Verified that no patch breaks the Travis CI build. * Added missing commit comments. * Verified that all AM33xx boards still build.
Version 2: * Globally replace CONFIG_DM_USB * Split the CONFIG_DM_USB replacement into separate patch * Fix am335x_evm build
Sven Schwermer (5): usb: Introduce CONFIG_SPL_DM_USB usb: am335x_evm: Disable CONFIG_SPL_DM_USB usb: Remove CMD_USB dependency for common code usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ usb: storage: s/CONFIG_BLK/CONFIG_IS_ENABLED(BLK)/
common/Makefile | 2 +- common/usb.c | 14 ++++++------- common/usb_hub.c | 16 +++++++-------- common/usb_kbd.c | 4 ++-- common/usb_storage.c | 34 +++++++++++++++---------------- configs/am335x_evm_defconfig | 3 ++- drivers/usb/Kconfig | 5 +++++ drivers/usb/common/Makefile | 2 +- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 2 +- drivers/usb/eth/usb_ether.c | 2 +- drivers/usb/gadget/ci_udc.c | 2 +- drivers/usb/gadget/ether.c | 8 ++++---- drivers/usb/host/Makefile | 4 ++-- drivers/usb/host/dwc2.c | 12 +++++------ drivers/usb/host/ehci-atmel.c | 2 +- drivers/usb/host/ehci-fsl.c | 12 +++++------ drivers/usb/host/ehci-hcd.c | 12 +++++------ drivers/usb/host/ehci-marvell.c | 4 ++-- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/ehci-pci.c | 8 ++++---- drivers/usb/host/ehci-vf.c | 2 +- drivers/usb/host/ohci-hcd.c | 10 ++++----- drivers/usb/host/ohci.h | 4 ++-- drivers/usb/host/xhci-dwc3.c | 2 +- drivers/usb/host/xhci-fsl.c | 4 ++-- drivers/usb/host/xhci-mem.c | 6 +++--- drivers/usb/host/xhci.c | 12 +++++------ drivers/usb/host/xhci.h | 2 +- drivers/usb/musb-new/musb_uboot.c | 12 +++++------ drivers/usb/musb-new/omap2430.c | 4 ++-- drivers/usb/musb-new/ti-musb.c | 4 ++-- drivers/usb/musb-new/usb-compat.h | 2 +- include/usb.h | 12 +++++------ 34 files changed, 117 insertions(+), 111 deletions(-)

This allows to disable the USB driver model in SPL because it checks the CONFIG_SPL_DM_USB variable for SPL builds. Nothing changes for regular non-SPL builds.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- common/usb.c | 14 +++++++------- common/usb_hub.c | 16 ++++++++-------- common/usb_kbd.c | 4 ++-- common/usb_storage.c | 6 +++--- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 2 +- drivers/usb/eth/usb_ether.c | 2 +- drivers/usb/gadget/ci_udc.c | 2 +- drivers/usb/gadget/ether.c | 8 ++++---- drivers/usb/host/dwc2.c | 12 ++++++------ drivers/usb/host/ehci-atmel.c | 2 +- drivers/usb/host/ehci-fsl.c | 12 ++++++------ drivers/usb/host/ehci-hcd.c | 12 ++++++------ drivers/usb/host/ehci-marvell.c | 4 ++-- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/ehci-pci.c | 8 ++++---- drivers/usb/host/ehci-vf.c | 2 +- drivers/usb/host/ohci-hcd.c | 10 +++++----- drivers/usb/host/ohci.h | 4 ++-- drivers/usb/host/xhci-dwc3.c | 2 +- drivers/usb/host/xhci-fsl.c | 4 ++-- drivers/usb/host/xhci-mem.c | 6 +++--- drivers/usb/host/xhci.c | 12 ++++++------ drivers/usb/host/xhci.h | 2 +- drivers/usb/musb-new/musb_uboot.c | 12 ++++++------ drivers/usb/musb-new/omap2430.c | 4 ++-- drivers/usb/musb-new/ti-musb.c | 4 ++-- drivers/usb/musb-new/usb-compat.h | 2 +- include/usb.h | 12 ++++++------ 29 files changed, 92 insertions(+), 92 deletions(-)
diff --git a/common/usb.c b/common/usb.c index 78178c54c8..b70f614d24 100644 --- a/common/usb.c +++ b/common/usb.c @@ -42,7 +42,7 @@ static int asynch_allowed; char usb_started; /* flag for the started/stopped USB status */
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct usb_device usb_dev[USB_MAX_DEVICE]; static int dev_index;
@@ -183,7 +183,7 @@ int usb_disable_asynch(int disable) asynch_allowed = !disable; return old_value; } -#endif /* !CONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
/*------------------------------------------------------------------- @@ -849,7 +849,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) * the USB device are static allocated [USB_MAX_DEVICE]. */
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB)
/* returns a pointer to the device with the index [index]. * if the device is not assigned (dev->devnum==-1) returns NULL @@ -906,7 +906,7 @@ __weak int usb_alloc_device(struct usb_device *udev) { return 0; } -#endif /* !CONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
static int usb_hub_port_reset(struct usb_device *dev, struct usb_device *hub) { @@ -1166,7 +1166,7 @@ int usb_setup_device(struct usb_device *dev, bool do_read, return ret; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* * By the time we get here, the device has gotten a new device ID * and is in the default state. We need to identify the thing and @@ -1215,14 +1215,14 @@ int board_usb_cleanup(int index, enum usb_init_type init)
bool usb_device_has_child_on_port(struct usb_device *parent, int port) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) return false; #else return parent->children[port] != NULL; #endif }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) void usb_find_usb2_hub_address_port(struct usb_device *udev, uint8_t *hub_address, uint8_t *hub_port) { diff --git a/common/usb_hub.c b/common/usb_hub.c index e1d93b8333..33aaeb8e44 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -64,7 +64,7 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev) return hdev->descriptor.bDeviceProtocol == 3; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) bool usb_hub_is_root_hub(struct udevice *hub) { if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB) @@ -125,7 +125,7 @@ int usb_get_port_status(struct usb_device *dev, int port, void *data) USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port, data, sizeof(struct usb_port_status), USB_CNTL_TIMEOUT);
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) if (ret < 0) return ret;
@@ -209,7 +209,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub) max(100, (int)pgood_delay) + 1000); }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct usb_hub_device hub_dev[USB_MAX_HUB]; static int usb_hub_index;
@@ -273,7 +273,7 @@ static int usb_hub_port_reset(struct usb_device *dev, int port, unsigned short portstatus, portchange; int delay = HUB_SHORT_RESET_TIME; /* start with short reset delay */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) debug("%s: resetting '%s' port %d...\n", __func__, dev->dev->name, port + 1); #else @@ -394,7 +394,7 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port) break; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *child;
ret = usb_scan_device(dev->dev, port + 1, speed, &child); @@ -604,7 +604,7 @@ static struct usb_hub_device *usb_get_hub_device(struct usb_device *dev) { struct usb_hub_device *hub;
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* "allocate" Hub device */ hub = usb_hub_allocate(); #else @@ -788,7 +788,7 @@ static int usb_hub_configure(struct usb_device *dev) (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? \ "" : "no ");
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* * Update USB host controller's internal representation of this hub * after the hub descriptor is fetched. @@ -930,7 +930,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum) return ret; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) int usb_hub_scan(struct udevice *hub) { struct usb_device *udev = dev_get_parent_priv(hub); diff --git a/common/usb_kbd.c b/common/usb_kbd.c index fdeb2aed24..020f0d4117 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -539,7 +539,7 @@ static int probe_usb_keyboard(struct usb_device *dev) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* Search for keyboard and register it if found. */ int drv_usb_kbd_init(void) { @@ -602,7 +602,7 @@ int usb_kbd_deregister(int force)
#endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int usb_kbd_probe(struct udevice *dev) { diff --git a/common/usb_storage.c b/common/usb_storage.c index 560d60538b..c9a99b1ca2 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -299,7 +299,7 @@ int usb_stor_scan(int mode) if (mode == 1) printf(" scanning usb for storage devices... ");
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) unsigned char i;
usb_disable_asynch(1); /* asynch transfer not allowed */ @@ -942,7 +942,7 @@ static void usb_stor_set_max_xfer_blk(struct usb_device *udev, size_t __maybe_unused size; int __maybe_unused ret;
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) #ifdef CONFIG_USB_EHCI_HCD /* * The U-Boot EHCI driver can handle any transfer length as long as @@ -1495,7 +1495,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, return 1; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int usb_mass_storage_probe(struct udevice *dev) { diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 1ab5cee609..f1ca6191ce 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -789,7 +789,7 @@ MODULE_AUTHOR("Felipe Balbi balbi@ti.com"); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
int dwc3_init(struct dwc3 *dwc) { diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 58fe91dc51..cfe29884e7 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -712,7 +712,7 @@ struct dwc3 { /* device lock */ spinlock_t lock;
-#if defined(__UBOOT__) && defined(CONFIG_DM_USB) +#if defined(__UBOOT__) && CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; #else struct device *dev; diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c index 1ce3361b45..3aca9ac265 100644 --- a/drivers/usb/eth/usb_ether.c +++ b/drivers/usb/eth/usb_ether.c @@ -271,7 +271,7 @@ int usb_host_eth_scan(int mode) }
usb_max_eth_dev = 0; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* * TODO: We should add U_BOOT_USB_DEVICE() declarations to each USB * Ethernet driver and then most of this file can be removed. diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index 0a84f6850d..bd596ce977 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -1015,7 +1015,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) if (driver->speed != USB_SPEED_FULL && driver->speed != USB_SPEED_HIGH) return -EINVAL;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) ret = usb_setup_ehci_gadget(&controller.ctrl); #else ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl); diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 90ef1f055f..193583b437 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -100,7 +100,7 @@ struct eth_dev { struct usb_gadget *gadget; struct usb_request *req; /* for control responses */ struct usb_request *stat_req; /* for cdc & rndis status */ -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *usb_udev; #endif
@@ -2337,7 +2337,7 @@ fail:
/*-------------------------------------------------------------------------*/
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) int dm_usb_init(struct eth_dev *e_dev) { struct udevice *dev = NULL; @@ -2362,7 +2362,7 @@ static int _usb_eth_init(struct ether_priv *priv) unsigned long ts; unsigned long timeout = USB_CONNECT_TIMEOUT;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) if (dm_usb_init(dev)) { pr_err("USB ether not found\n"); return -ENODEV; @@ -2541,7 +2541,7 @@ void _usb_eth_halt(struct ether_priv *priv) }
usb_gadget_unregister_driver(&priv->eth_driver); -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) board_usb_cleanup(0, USB_INIT_DEVICE); #endif } diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index b6f008a400..a62a2f8a95 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -29,7 +29,7 @@ #define MAX_ENDPOINT 16
struct dwc2_priv { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) uint8_t aligned_buffer[DWC2_DATA_BUF_SIZE] __aligned(ARCH_DMA_MINALIGN); uint8_t status_buffer[DWC2_STATUS_BUF_SIZE] __aligned(ARCH_DMA_MINALIGN); #ifdef CONFIG_DM_REGULATOR @@ -54,7 +54,7 @@ struct dwc2_priv { struct reset_ctl_bulk resets; };
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* We need cacheline-aligned buffers for DMA transfers and dcache support */ DEFINE_ALIGN_BUFFER(uint8_t, aligned_buffer_addr, DWC2_DATA_BUF_SIZE, ARCH_DMA_MINALIGN); @@ -168,7 +168,7 @@ static void dwc_otg_core_reset(struct dwc2_core_regs *regs) mdelay(100); }
-#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR) +#if CONFIG_IS_ENABLED(DM_USB) && defined(CONFIG_DM_REGULATOR) static int dwc_vbus_supply_init(struct udevice *dev) { struct dwc2_priv *priv = dev_get_priv(dev); @@ -211,7 +211,7 @@ static int dwc_vbus_supply_init(struct udevice *dev) return 0; }
-#if defined(CONFIG_DM_USB) +#if CONFIG_IS_ENABLED(DM_USB) static int dwc_vbus_supply_exit(struct udevice *dev) { return 0; @@ -1222,7 +1222,7 @@ static void dwc2_uninit_common(struct dwc2_core_regs *regs) DWC2_HPRT0_PRTRST); }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int len, struct devrequest *setup) { @@ -1267,7 +1267,7 @@ int usb_lowlevel_stop(int index) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int dwc2_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 66dc63da08..6900848df1 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c @@ -14,7 +14,7 @@
#include "ehci.h"
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB)
int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index a8fb2b8ac3..23e7e7125f 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR; #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct ehci_fsl_priv { struct ehci_ctrl ehci; fdt_addr_t hcd_base; @@ -34,7 +34,7 @@ struct ehci_fsl_priv { #endif
static void set_txfifothresh(struct usb_ehci *, u32); -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci, struct ehci_hccr *hccr, struct ehci_hcor *hcor); #else @@ -54,7 +54,7 @@ static int usb_phy_clk_valid(struct usb_ehci *ehci) } }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_fsl_ofdata_to_platdata(struct udevice *dev) { struct ehci_fsl_priv *priv = dev_get_priv(dev); @@ -183,7 +183,7 @@ int ehci_hcd_stop(int index) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci, struct ehci_hccr *hccr, struct ehci_hcor *hcor) #else @@ -192,7 +192,7 @@ static int ehci_fsl_init(int index, struct usb_ehci *ehci, #endif { const char *phy_type = NULL; -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) size_t len; char current_usb_controller[5]; #endif @@ -218,7 +218,7 @@ static int ehci_fsl_init(int index, struct usb_ehci *ehci, out_be32(&ehci->snoop2, 0x80000000 | SNOOP_SIZE_2GB);
/* Init phy */ -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) if (priv->phy_type) phy_type = priv->phy_type; #else diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index d1d8f08d98..4b28db70a5 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -30,7 +30,7 @@ */ #define HCHALT_TIMEOUT (8 * 1000)
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct ehci_ctrl ehcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; #endif
@@ -111,7 +111,7 @@ static struct descriptor {
static struct ehci_ctrl *ehci_get_ctrl(struct usb_device *udev) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) return dev_get_priv(usb_get_bus(udev->dev)); #else return udev->controller; @@ -973,7 +973,7 @@ static void ehci_setup_ops(struct ehci_ctrl *ctrl, const struct ehci_ops *ops) } }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) void ehci_set_controller_priv(int index, void *priv, const struct ehci_ops *ops) { struct ehci_ctrl *ctrl = &ehcic[index]; @@ -1097,7 +1097,7 @@ static int ehci_common_init(struct ehci_ctrl *ctrl, uint tweaks) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_lowlevel_stop(int index) { ehci_shutdown(&ehcic[index]); @@ -1518,7 +1518,7 @@ static int _ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe, return result; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int length) { @@ -1556,7 +1556,7 @@ int destroy_int_queue(struct usb_device *dev, struct int_queue *queue) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c index 73432f2acd..8efe6b63b9 100644 --- a/drivers/usb/host/ehci-marvell.c +++ b/drivers/usb/host/ehci-marvell.c @@ -38,7 +38,7 @@ DECLARE_GLOBAL_DATA_PTR; /* * USB 2.0 Bridge Address Decoding registers setup */ -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
struct ehci_mvebu_priv { struct ehci_ctrl ehci; @@ -228,4 +228,4 @@ int ehci_hcd_stop(int index) return 0; }
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index be010b1adb..1acf08dfb7 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -335,7 +335,7 @@ int ehci_mx6_common_init(struct usb_ehci *ehci, int index) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 6150f3d888..04e7c5e37f 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -19,7 +19,7 @@ struct ehci_pci_priv { struct phy phy; };
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr, struct ehci_hcor **ret_hcor) { @@ -121,9 +121,9 @@ int ehci_hcd_stop(int index) { return 0; } -#endif /* nCONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_pci_probe(struct udevice *dev) { struct ehci_hccr *hccr; @@ -173,4 +173,4 @@ static struct pci_device_id ehci_pci_supported[] = {
U_BOOT_PCI_DEVICE(ehci_pci, ehci_pci_supported);
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c index 22e5afad6e..a16cf135e3 100644 --- a/drivers/usb/host/ehci-vf.c +++ b/drivers/usb/host/ehci-vf.c @@ -153,7 +153,7 @@ int ehci_vf_common_init(struct usb_ehci *ehci, int index) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 6ea9f105a6..3b6f889f7b 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -120,7 +120,7 @@ static struct pci_device_id ehci_pci_ids[] = { #define invalidate_dcache_iso_td(addr) invalidate_dcache_buffer(addr, 32) #define invalidate_dcache_hcca(addr) invalidate_dcache_buffer(addr, 256)
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* * The various ohci_mdelay(1) calls in the code seem unnecessary. We keep * them around when building for older boards not yet converted to the dm @@ -131,7 +131,7 @@ static struct pci_device_id ehci_pci_ids[] = { #define ohci_mdelay(x) mdelay(x) #endif
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* global ohci_t */ static ohci_t gohci; /* this must be aligned to a 256 byte boundary */ @@ -1691,7 +1691,7 @@ static int _ohci_destroy_int_queue(ohci_t *ohci, struct usb_device *dev, return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* submit routines called from usb.c */ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len) @@ -1980,7 +1980,7 @@ static int hc_interrupt(ohci_t *ohci)
/*-------------------------------------------------------------------------*/
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB)
/*-------------------------------------------------------------------------*/
@@ -2130,7 +2130,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ohci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index fba78dcf7a..f9f02cb09c 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h @@ -27,7 +27,7 @@ #define ED_ALIGNMENT 16 #endif
-#if defined CONFIG_DM_USB && ARCH_DMA_MINALIGN > 32 +#if CONFIG_IS_ENABLED(DM_USB) && ARCH_DMA_MINALIGN > 32 #define TD_ALIGNMENT ARCH_DMA_MINALIGN #else #define TD_ALIGNMENT 32 @@ -406,7 +406,7 @@ typedef struct ohci { const char *slot_name; } ohci_t;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) extern struct dm_usb_ops ohci_usb_ops;
int ohci_register(struct udevice *dev, struct ohci_regs *regs); diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c index 80754d76d0..dd0d156027 100644 --- a/drivers/usb/host/xhci-dwc3.c +++ b/drivers/usb/host/xhci-dwc3.c @@ -109,7 +109,7 @@ void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val) GFLADJ_30MHZ(val)); }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int xhci_dwc3_setup_phy(struct udevice *dev) { struct xhci_dwc3_platdata *plat = dev_get_platdata(dev); diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c index 047a8dfdef..c0b98a8ec7 100644 --- a/drivers/usb/host/xhci-fsl.c +++ b/drivers/usb/host/xhci-fsl.c @@ -19,7 +19,7 @@ #include <dm.h>
/* Declare global data pointer */ -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct fsl_xhci fsl_xhci; unsigned long ctr_addr[] = FSL_USB_XHCI_ADDR; #else @@ -107,7 +107,7 @@ static int fsl_xhci_core_exit(struct fsl_xhci *fsl_xhci) return 0; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int xhci_fsl_probe(struct udevice *dev) { struct xhci_fsl_priv *priv = dev_get_priv(dev); diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index da5dbd94ed..04ab540695 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -723,7 +723,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, int slot_id = udev->slot_id; int speed = udev->speed; int route = 0; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct usb_device *dev = udev; struct usb_hub_device *hub; #endif @@ -739,7 +739,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, /* Only the control endpoint is valid - one endpoint context */ slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1));
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* Calculate the route string for this device */ port_num = dev->portnr; while (!usb_hub_is_root_hub(dev->dev)) { @@ -782,7 +782,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, BUG(); }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* Set up TT fields to support FS/LS devices */ if (speed == USB_SPEED_LOW || speed == USB_SPEED_FULL) { struct udevice *parent = udev->dev; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 9ded14cc3c..44c5f2d264 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -108,13 +108,13 @@ static struct descriptor { }, };
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct xhci_ctrl xhcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; #endif
struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev;
/* Find the USB controller */ @@ -741,7 +741,7 @@ static int _xhci_alloc_device(struct usb_device *udev) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_alloc_device(struct usb_device *udev) { return _xhci_alloc_device(udev); @@ -1256,7 +1256,7 @@ static int xhci_lowlevel_stop(struct xhci_ctrl *ctrl) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) { @@ -1340,9 +1340,9 @@ int usb_lowlevel_stop(int index)
return 0; } -#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int xhci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index a7555b2fa8..6017504488 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1211,7 +1211,7 @@ void xhci_hcd_stop(int index); #define XHCI_STS_CNR (1 << 11)
struct xhci_ctrl { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; #endif struct xhci_hccr *hccr; /* R/O registers, not need for volatile */ diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 2bf918eab4..d40772b1aa 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -19,7 +19,7 @@ struct int_queue { struct urb urb; };
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) struct musb_host_data musb_host; #endif
@@ -243,7 +243,7 @@ int musb_lowlevel_init(struct musb_host_data *host) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_lowlevel_stop(int index) { if (!musb_host.host) { @@ -300,9 +300,9 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) { return musb_lowlevel_init(&musb_host); } -#endif /* !CONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int musb_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) @@ -364,7 +364,7 @@ struct dm_usb_ops musb_usb_ops = { .destroy_int_queue = musb_destroy_int_queue, .reset_root_port = musb_reset_root_port, }; -#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ #endif /* CONFIG_USB_MUSB_HOST */
#ifdef CONFIG_USB_MUSB_GADGET @@ -425,7 +425,7 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata, struct musb **musbp;
switch (plat->mode) { -#if defined(CONFIG_USB_MUSB_HOST) && !defined(CONFIG_DM_USB) +#if defined(CONFIG_USB_MUSB_HOST) && !CONFIG_IS_ENABLED(DM_USB) case MUSB_HOST: musbp = &musb_host.host; break; diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index 342d76bd6f..58aed72b7d 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -135,7 +135,7 @@ const struct musb_platform_ops omap2430_ops = { .disable = omap2430_musb_disable, };
-#if defined(CONFIG_DM_USB) +#if CONFIG_IS_ENABLED(DM_USB)
struct omap2430_musb_platdata { void *base; @@ -276,4 +276,4 @@ U_BOOT_DRIVER(omap2430_musb) = { .priv_auto_alloc_size = sizeof(struct musb_host_data), };
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index 9fbe2d6861..ee0960704a 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -19,7 +19,7 @@
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
/* USB 2.0 PHY Control */ #define CM_PHY_PWRDN (1 << 0) @@ -251,4 +251,4 @@ U_BOOT_DRIVER(ti_musb_wrapper) = { .bind = ti_musb_wrapper_bind, };
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/musb-new/usb-compat.h b/drivers/usb/musb-new/usb-compat.h index 760bd787bc..f2c18ad3a2 100644 --- a/drivers/usb/musb-new/usb-compat.h +++ b/drivers/usb/musb-new/usb-compat.h @@ -67,7 +67,7 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, return 0; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev) { struct udevice *parent = udev->dev->parent; diff --git a/include/usb.h b/include/usb.h index b6b48a8c60..420a30e49f 100644 --- a/include/usb.h +++ b/include/usb.h @@ -140,7 +140,7 @@ struct usb_device { int act_len; /* transferred bytes */ int maxchild; /* Number of ports if hub */ int portnr; /* Port number, 1=first */ -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* parent hub, or NULL if this is the root hub */ struct usb_device *parent; struct usb_device *children[USB_MAXCHILDREN]; @@ -148,7 +148,7 @@ struct usb_device { #endif /* slot_id - for xHCI enabled devices */ unsigned int slot_id; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; /* Pointer to associated device */ struct udevice *controller_dev; /* Pointer to associated controller */ #endif @@ -173,7 +173,7 @@ enum usb_init_type { int usb_lowlevel_init(int index, enum usb_init_type init, void **controller); int usb_lowlevel_stop(int index);
-#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_DM_USB) +#if defined(CONFIG_USB_MUSB_HOST) || CONFIG_IS_ENABLED(DM_USB) int usb_reset_root_port(struct usb_device *dev); #else #define usb_reset_root_port(dev) @@ -187,7 +187,7 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
#if defined CONFIG_USB_EHCI_HCD || defined CONFIG_USB_MUSB_HOST \ - || defined(CONFIG_DM_USB) + || CONFIG_IS_ENABLED(DM_USB) struct int_queue *create_int_queue(struct usb_device *dev, unsigned long pipe, int queuesize, int elementsize, void *buffer, int interval); int destroy_int_queue(struct usb_device *dev, struct int_queue *queue); @@ -588,7 +588,7 @@ struct usb_hub_device { struct usb_tt tt; /* Transaction Translator */ };
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /** * struct usb_platdata - Platform data about a USB controller * @@ -912,7 +912,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp); */ void usb_stor_reset(void);
-#else /* !CONFIG_DM_USB */ +#else /* !CONFIG_IS_ENABLED(DM_USB) */
struct usb_device *usb_get_dev_index(int index);

This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- configs/am335x_evm_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index b6cd49a469..6cc170ad40 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -40,15 +40,16 @@ CONFIG_NAND=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y -CONFIG_DRIVER_TI_CPSW=y CONFIG_PHY_GIGE=y CONFIG_MII=y +CONFIG_DRIVER_TI_CPSW=y CONFIG_SPI=y CONFIG_OMAP3_SPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y CONFIG_DM_USB=y +# CONFIG_SPL_DM_USB is not set CONFIG_USB_MUSB_HOST=y CONFIG_USB_MUSB_GADGET=y CONFIG_USB_MUSB_TI=y

On 11/16/2018 12:04 PM, Sven Schwermer wrote:
This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
Is this also needed on other boards ?

This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
Is this also needed on other boards ?
As per the cover letter, I have successfully run the Travis CI build for this patch series. Furthermore, I have manually verified that all AM33xx builds still succeed. So I don’t think, we need to change anything on other boards. If you want me to do more testing, let me know.
Best regards, Sven

On 11/20/2018 08:28 AM, Sven Schwermer wrote:
This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
Is this also needed on other boards ?
As per the cover letter, I have successfully run the Travis CI build for this patch series. Furthermore, I have manually verified that all AM33xx builds still succeed. So I don’t think, we need to change anything on other boards. If you want me to do more testing, let me know.
I just want to know whether some boards now get CONFIG_SPL_DM_USB even though they didn't have it before, since the Kconfig option is default=y
btw I don't think SPL_DM_USB should depend on DM_USB , one is for SPL and the other for U-Boot.

This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
Is this also needed on other boards ?
As per the cover letter, I have successfully run the Travis CI build for this patch series. Furthermore, I have manually verified that all AM33xx builds still succeed. So I don’t think, we need to change anything on other boards. If you want me to do more testing, let me know.
I just want to know whether some boards now get CONFIG_SPL_DM_USB even though they didn't have it before, since the Kconfig option is default=y
Well, since CONFIG_SPL_DM_USB depends on SPL_DM_USB, I don’t think that’s the case.
btw I don't think SPL_DM_USB should depend on DM_USB , one is for SPL and the other for U-Boot.
Aha! There are two reasons I did this: 1) I used CONFIG_SPL_DM_MMC as the inspiration for my changes. That one depends on CONFIG_DM_MMC. 2) In order to not break a lot of configs, see above.
If this is unacceptable for you, I guess, I’ll have to revisit this. That’d make this series a lot bigger I think. Tell me your preference.
Sven

On 11/20/2018 02:22 PM, Sven Schwermer wrote:
This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
Is this also needed on other boards ?
As per the cover letter, I have successfully run the Travis CI build for this patch series. Furthermore, I have manually verified that all AM33xx builds still succeed. So I don’t think, we need to change anything on other boards. If you want me to do more testing, let me know.
I just want to know whether some boards now get CONFIG_SPL_DM_USB even though they didn't have it before, since the Kconfig option is default=y
Well, since CONFIG_SPL_DM_USB depends on SPL_DM_USB, I don’t think that’s the case.
Are you _sure_ ? Sorry if I'm being hard, but this affects a lot of users, so I have to be cautious.
btw I don't think SPL_DM_USB should depend on DM_USB , one is for SPL and the other for U-Boot.
Aha! There are two reasons I did this:
- I used CONFIG_SPL_DM_MMC as the inspiration for my changes. That one depends on CONFIG_DM_MMC.
I don't think that's right. SPL and U-Boot are separate things.
- In order to not break a lot of configs, see above.
If this is unacceptable for you, I guess, I’ll have to revisit this. That’d make this series a lot bigger I think. Tell me your preference.
I don't mind bigger and better series, but let's just answer the question first.

Well, since CONFIG_SPL_DM_USB depends on SPL_DM_USB, I don’t think that’s the case.
Are you _sure_ ? Sorry if I'm being hard, but this affects a lot of users, so I have to be cautious.
I am _not_ sure. That’s why I used the verb “think” ;-) I’m sorry, but I don’t think I can provide the guarantees you need. How can we investigate this systematically?
btw I don't think SPL_DM_USB should depend on DM_USB , one is for SPL and the other for U-Boot.
Aha! There are two reasons I did this:
- I used CONFIG_SPL_DM_MMC as the inspiration for my changes. That one depends on CONFIG_DM_MMC.
I don't think that's right. SPL and U-Boot are separate things.
Agreed.
- In order to not break a lot of configs, see above.
If this is unacceptable for you, I guess, I’ll have to revisit this. That’d make this series a lot bigger I think. Tell me your preference.
I don't mind bigger and better series, but let's just answer the question first.
I’m just afraid, that this is more likely to break existing boards.
Sven

On 11/20/2018 03:10 PM, Sven Schwermer wrote:
Well, since CONFIG_SPL_DM_USB depends on SPL_DM_USB, I don’t think that’s the case.
Are you _sure_ ? Sorry if I'm being hard, but this affects a lot of users, so I have to be cautious.
I am _not_ sure. That’s why I used the verb “think” ;-) I’m sorry, but I don’t think I can provide the guarantees you need. How can we investigate this systematically?
I think you can just run make $board_defconfig for all boards (I don't think you need toolchain to do that) and verify that the option didn't get enabled in the resulting .config .
btw I don't think SPL_DM_USB should depend on DM_USB , one is for SPL and the other for U-Boot.
Aha! There are two reasons I did this:
- I used CONFIG_SPL_DM_MMC as the inspiration for my changes. That one depends on CONFIG_DM_MMC.
I don't think that's right. SPL and U-Boot are separate things.
Agreed.
- In order to not break a lot of configs, see above.
If this is unacceptable for you, I guess, I’ll have to revisit this. That’d make this series a lot bigger I think. Tell me your preference.
I don't mind bigger and better series, but let's just answer the question first.
I’m just afraid, that this is more likely to break existing boards.
Let's see :)

Hi again,
On 20 Nov 2018, at 15:14, Marek Vasut marex@denx.de wrote:
On 11/20/2018 03:10 PM, Sven Schwermer wrote:
Well, since CONFIG_SPL_DM_USB depends on SPL_DM_USB, I don’t think that’s the case.
Are you _sure_ ? Sorry if I'm being hard, but this affects a lot of users, so I have to be cautious.
I am _not_ sure. That’s why I used the verb “think” ;-) I’m sorry, but I don’t think I can provide the guarantees you need. How can we investigate this systematically?
I think you can just run make $board_defconfig for all boards (I don't think you need toolchain to do that) and verify that the option didn't get enabled in the resulting .config .
I can confirm that after applying this series, no board has CONFIG_SPL_DM_USB=y that does not have CONFIG_DM_USB=y. Why is it necessary to check this? Do we not trust the Kconfig dependencies? Or did I misunderstand you and that’s what you wanted me to check?
Sven

On 11/20/2018 04:21 PM, Sven Schwermer wrote:
Hi again,
On 20 Nov 2018, at 15:14, Marek Vasut <marex@denx.de mailto:marex@denx.de> wrote:
On 11/20/2018 03:10 PM, Sven Schwermer wrote:
Well, since CONFIG_SPL_DM_USB depends on SPL_DM_USB, I don’t think that’s the case.
Are you _sure_ ? Sorry if I'm being hard, but this affects a lot of users, so I have to be cautious.
I am _not_ sure. That’s why I used the verb “think” ;-) I’m sorry, but I don’t think I can provide the guarantees you need. How can we investigate this systematically?
I think you can just run make $board_defconfig for all boards (I don't think you need toolchain to do that) and verify that the option didn't get enabled in the resulting .config .
I can confirm that after applying this series, no board has CONFIG_SPL_DM_USB=y that does not have CONFIG_DM_USB=y. Why is it necessary to check this? Do we not trust the Kconfig dependencies? Or did I misunderstand you and that’s what you wanted me to check?
But DM_USB is DM and USB in U-Boot proper and it doesn't imply that SPL should have DM or USB support. I want to be sure that some boards don't suddenly grow DM or USB support in SPL if it wasn't there before.

Hi,
On 20 Nov 2018, at 16:47, Marek Vasut marex@denx.de wrote:
On 11/20/2018 04:21 PM, Sven Schwermer wrote:
Hi again,
On 20 Nov 2018, at 15:14, Marek Vasut <marex@denx.de mailto:marex@denx.de> wrote:
On 11/20/2018 03:10 PM, Sven Schwermer wrote:
Well, since CONFIG_SPL_DM_USB depends on SPL_DM_USB, I don’t think that’s the case.
Are you _sure_ ? Sorry if I'm being hard, but this affects a lot of users, so I have to be cautious.
I am _not_ sure. That’s why I used the verb “think” ;-) I’m sorry, but I don’t think I can provide the guarantees you need. How can we investigate this systematically?
I think you can just run make $board_defconfig for all boards (I don't think you need toolchain to do that) and verify that the option didn't get enabled in the resulting .config .
I can confirm that after applying this series, no board has CONFIG_SPL_DM_USB=y that does not have CONFIG_DM_USB=y. Why is it necessary to check this? Do we not trust the Kconfig dependencies? Or did I misunderstand you and that’s what you wanted me to check?
But DM_USB is DM and USB in U-Boot proper and it doesn't imply that SPL should have DM or USB support. I want to be sure that some boards don't suddenly grow DM or USB support in SPL if it wasn't there before.
If anything, this patch series takes away DM_USB from SPL where it was previously active. Since SPL_DM_USB depends on DM_USB, it won’t be enabled where it wasn’t enabled already. Before this series, DM_USB was enabled also in the SPL when enabled in proper.
Sorry, I guess I’m missing something fundamental here. I fail to see the possibility of code being included in the SPL that wasn’t included before.
Sven

On 11/20/2018 06:42 PM, Sven Schwermer wrote:
Hi,
On 20 Nov 2018, at 16:47, Marek Vasut marex@denx.de wrote:
On 11/20/2018 04:21 PM, Sven Schwermer wrote:
Hi again,
On 20 Nov 2018, at 15:14, Marek Vasut <marex@denx.de mailto:marex@denx.de> wrote:
On 11/20/2018 03:10 PM, Sven Schwermer wrote:
> Well, since CONFIG_SPL_DM_USB depends on SPL_DM_USB, I don’t think > that’s the case.
Are you _sure_ ? Sorry if I'm being hard, but this affects a lot of users, so I have to be cautious.
I am _not_ sure. That’s why I used the verb “think” ;-) I’m sorry, but I don’t think I can provide the guarantees you need. How can we investigate this systematically?
I think you can just run make $board_defconfig for all boards (I don't think you need toolchain to do that) and verify that the option didn't get enabled in the resulting .config .
I can confirm that after applying this series, no board has CONFIG_SPL_DM_USB=y that does not have CONFIG_DM_USB=y. Why is it necessary to check this? Do we not trust the Kconfig dependencies? Or did I misunderstand you and that’s what you wanted me to check?
But DM_USB is DM and USB in U-Boot proper and it doesn't imply that SPL should have DM or USB support. I want to be sure that some boards don't suddenly grow DM or USB support in SPL if it wasn't there before.
If anything, this patch series takes away DM_USB from SPL where it was previously active. Since SPL_DM_USB depends on DM_USB, it won’t be enabled where it wasn’t enabled already. Before this series, DM_USB was enabled also in the SPL when enabled in proper.
Sorry, I guess I’m missing something fundamental here. I fail to see the possibility of code being included in the SPL that wasn’t included before.
Well, the easiest test might be to run this through buildman, since it reports if there was any size increase for any board.

Well, the easiest test might be to run this through buildman, since it reports if there was any size increase for any board.
Isn’t that run during the Travis CI builds? If so, I’ve done it: https://travis-ci.org/svenschwermer/u-boot/builds/456862718
Sven

On 11/20/2018 09:01 PM, Sven Schwermer wrote:
Well, the easiest test might be to run this through buildman, since it reports if there was any size increase for any board.
Isn’t that run during the Travis CI builds? If so, I’ve done it: https://travis-ci.org/svenschwermer/u-boot/builds/456862718
Is it ? I wasn't aware of that, I don't think so.

This fixes link issues when building the SPL without USB driver model but with USB storage support. CONFIG_BLK can be enabled and disabled independently for SPL and non-SPL builds. We leverage that existing functionality here.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- common/usb_storage.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c index c9a99b1ca2..8c889bb1a6 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -66,7 +66,7 @@ static __u32 CBWTag;
static int usb_max_devs; /* number of highest available usb device */
-#ifndef CONFIG_BLK +#if !CONFIG_IS_ENABLED(BLK) static struct blk_desc usb_dev_desc[USB_MAX_STOR_DEV]; #endif
@@ -99,7 +99,7 @@ struct us_data { unsigned short max_xfer_blk; /* maximum transfer blocks */ };
-#ifndef CONFIG_BLK +#if !CONFIG_IS_ENABLED(BLK) static struct us_data usb_stor[USB_MAX_STOR_DEV]; #endif
@@ -111,7 +111,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *us, struct blk_desc *dev_desc); int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, struct us_data *ss); -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer); static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr, @@ -136,7 +136,7 @@ static void usb_show_progress(void) int usb_stor_info(void) { int count = 0; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct udevice *dev;
for (blk_first_device(IF_TYPE_USB, &dev); @@ -186,7 +186,7 @@ static int usb_stor_probe_device(struct usb_device *udev) { int lun, max_lun;
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct us_data *data; int ret; #else @@ -197,7 +197,7 @@ static int usb_stor_probe_device(struct usb_device *udev) #endif
debug("\n\nProbing for storage\n"); -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) /* * We store the us_data in the mass storage device's platdata. It * is shared by all LUNs (block devices) attached to this mass storage @@ -1119,7 +1119,7 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor, } #endif /* CONFIG_USB_BIN_FIXUP */
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) #else @@ -1134,14 +1134,14 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr, struct us_data *ss; int retry; struct scsi_cmd *srb = &usb_ccb; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct blk_desc *block_dev; #endif
if (blkcnt == 0) return 0; /* Setup device */ -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) block_dev = dev_get_uclass_platdata(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); @@ -1200,7 +1200,7 @@ retry_it: return blkcnt; }
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) #else @@ -1215,7 +1215,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, struct us_data *ss; int retry; struct scsi_cmd *srb = &usb_ccb; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct blk_desc *block_dev; #endif
@@ -1223,7 +1223,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, return 0;
/* Setup device */ -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) block_dev = dev_get_uclass_platdata(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); @@ -1519,7 +1519,7 @@ U_BOOT_DRIVER(usb_mass_storage) = { .id = UCLASS_MASS_STORAGE, .of_match = usb_mass_storage_ids, .probe = usb_mass_storage_probe, -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) .platdata_auto_alloc_size = sizeof(struct us_data), #endif }; @@ -1540,7 +1540,7 @@ static const struct usb_device_id mass_storage_id_table[] = { U_BOOT_USB_DEVICE(usb_mass_storage, mass_storage_id_table); #endif
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static const struct blk_ops usb_storage_ops = { .read = usb_stor_read, .write = usb_stor_write,

This allows building the SPL without driver model for USB. Since CONFIG_SPL_DM_USB is enabled if and only if CONFIG_DM_USB was enabled before, this patch does not change the build behaviour.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- drivers/usb/Kconfig | 5 +++++ drivers/usb/common/Makefile | 2 +- drivers/usb/host/Makefile | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 4fbe172e05..03746dd12f 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -47,6 +47,11 @@ config DM_USB declared with the U_BOOT_USB_DEVICE() macro and will be automatically probed when found on the bus.
+config SPL_DM_USB + bool "Enable driver model for USB in SPL" + depends on DM_USB + default y + source "drivers/usb/host/Kconfig"
source "drivers/usb/dwc3/Kconfig" diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile index 55e0547b16..3bedbf213f 100644 --- a/drivers/usb/common/Makefile +++ b/drivers/usb/common/Makefile @@ -3,6 +3,6 @@ # (C) Copyright 2016 Freescale Semiconductor, Inc. #
-obj-$(CONFIG_DM_USB) += common.o +obj-$(CONFIG_$(SPL_)DM_USB) += common.o obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index cb8c315a15..bfa565c4c3 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -3,7 +3,7 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-ifdef CONFIG_DM_USB +ifdef CONFIG_$(SPL_)DM_USB obj-$(CONFIG_CMD_USB) += usb-uclass.o obj-$(CONFIG_SANDBOX) += usb-sandbox.o endif

On 11/17/2018 12:37 PM, Sven Schwermer wrote:
This allows building the SPL without driver model for USB. Since CONFIG_SPL_DM_USB is enabled if and only if CONFIG_DM_USB was enabled before, this patch does not change the build behaviour.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
I asked before, but shouldn't this be 5/5 ?

Hi Marek,
This allows building the SPL without driver model for USB. Since CONFIG_SPL_DM_USB is enabled if and only if CONFIG_DM_USB was enabled before, this patch does not change the build behaviour.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
I asked before, but shouldn't this be 5/5 ?
Here are the reasons why I don’t think so: 1) This particular order doesn’t break any builds. I triggered Travis CI runs for every patch in order and they have all succeeded. 2) Before this patch series, DM was enabled for both SPL and proper when setting CONFIG_DM_USB=y. If I had done the s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ step before this patch, the DM would have suddenly been disabled for _all_ boards in their SPL builds. That would have definitively changed the existing behaviour. By doing it this way (CONFIG_SPL_DM_USB depends on CONFIG_DM_USB and the default for the former is “y”), IMHO nothing changes.
I have difficulties seeing any advantages doing this patch last.
Best regards, Sven

On 11/20/2018 08:25 AM, Sven Schwermer wrote:
Hi Marek,
This allows building the SPL without driver model for USB. Since CONFIG_SPL_DM_USB is enabled if and only if CONFIG_DM_USB was enabled before, this patch does not change the build behaviour.
Signed-off-by: Sven Schwermer sven@svenschwermer.de
I asked before, but shouldn't this be 5/5 ?
Here are the reasons why I don’t think so:
- This particular order doesn’t break any builds. I triggered Travis CI runs for every patch in order and they have all succeeded.
- Before this patch series, DM was enabled for both SPL and proper when setting CONFIG_DM_USB=y.
Are you sure about this ? I recall boards which built SPL without DM and U-Boot with DM USB.
If I had done the s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ step before this patch, the DM would have suddenly been disabled for _all_ boards in their SPL builds. That would have definitively changed the existing behaviour. By doing it this way (CONFIG_SPL_DM_USB depends on CONFIG_DM_USB and the default for the former is “y”), IMHO nothing changes.
I have difficulties seeing any advantages doing this patch last.
If you're sure this doesn't enable SPL_DM_USB on boards where it was previously disabled, fine by me.

Here are the reasons why I don’t think so:
- This particular order doesn’t break any builds. I triggered Travis CI runs for every patch in order and they have all succeeded.
- Before this patch series, DM was enabled for both SPL and proper when setting CONFIG_DM_USB=y.
Are you sure about this ? I recall boards which built SPL without DM and U-Boot with DM USB.
Well I’m not very experienced contributing to u-boot, this is a first, so I’m not certain. However, that was my train of thought. If you have a concrete defconfig I should check, I can do so.
Sven

On 11/20/2018 02:27 PM, Sven Schwermer wrote:
Here are the reasons why I don’t think so:
- This particular order doesn’t break any builds. I triggered Travis CI runs for every patch in order and they have all succeeded.
- Before this patch series, DM was enabled for both SPL and proper when setting CONFIG_DM_USB=y.
Are you sure about this ? I recall boards which built SPL without DM and U-Boot with DM USB.
Well I’m not very experienced contributing to u-boot, this is a first, so I’m not certain.
You sure picked an awesome topic for your first contribution :-) This is certainly not an easy change.
However, that was my train of thought. If you have a concrete defconfig I should check, I can do so.
dh_imx6 for example.

Hi,
On 20 Nov 2018, at 14:32, Marek Vasut marex@denx.de wrote:
On 11/20/2018 02:27 PM, Sven Schwermer wrote:
Here are the reasons why I don’t think so:
- This particular order doesn’t break any builds. I triggered Travis CI runs for every patch in order and they have all succeeded.
- Before this patch series, DM was enabled for both SPL and proper when setting CONFIG_DM_USB=y.
Are you sure about this ? I recall boards which built SPL without DM and U-Boot with DM USB.
Well I’m not very experienced contributing to u-boot, this is a first, so I’m not certain.
You sure picked an awesome topic for your first contribution :-) This is certainly not an easy change.
So it seems.
However, that was my train of thought. If you have a concrete defconfig I should check, I can do so.
dh_imx6 for example.
The generated .config is identical before and after the patch series for this board. It also compiles fine after the patch series.
Sven

On 11/20/2018 04:30 PM, Sven Schwermer wrote:
Hi,
On 20 Nov 2018, at 14:32, Marek Vasut marex@denx.de wrote:
On 11/20/2018 02:27 PM, Sven Schwermer wrote:
Here are the reasons why I don’t think so:
- This particular order doesn’t break any builds. I triggered Travis CI runs for every patch in order and they have all succeeded.
- Before this patch series, DM was enabled for both SPL and proper when setting CONFIG_DM_USB=y.
Are you sure about this ? I recall boards which built SPL without DM and U-Boot with DM USB.
Well I’m not very experienced contributing to u-boot, this is a first, so I’m not certain.
You sure picked an awesome topic for your first contribution :-) This is certainly not an easy change.
So it seems.
However, that was my train of thought. If you have a concrete defconfig I should check, I can do so.
dh_imx6 for example.
The generated .config is identical before and after the patch series for this board. It also compiles fine after the patch series.
Good, so no USB support in SPL ?

Hi again,
However, that was my train of thought. If you have a concrete defconfig I should check, I can do so.
dh_imx6 for example.
The generated .config is identical before and after the patch series for this board. It also compiles fine after the patch series.
Good, so no USB support in SPL ?
No.
Sven

On 11/20/2018 06:31 PM, Sven Schwermer wrote:
Hi again,
However, that was my train of thought. If you have a concrete defconfig I should check, I can do so.
dh_imx6 for example.
The generated .config is identical before and after the patch series for this board. It also compiles fine after the patch series.
Good, so no USB support in SPL ?
No.
OK, can you resend the series one more time ? The patches somehow disintegrated and I'm not having 3/5. Did you use git send-email ?

Hi,
OK, can you resend the series one more time ? The patches somehow disintegrated and I'm not having 3/5. Did you use git send-email ?
See https://patchwork.ozlabs.org/patch/1000076 for part 3.
I used imap-send, I think my mailer might have slaughtered the threading. Let me know if I should still resend. Should I mark it v4 even though, it contains the same patches?
Sven

On 11/20/2018 08:28 PM, Sven Schwermer wrote:
Hi,
OK, can you resend the series one more time ? The patches somehow disintegrated and I'm not having 3/5. Did you use git send-email ?
See https://patchwork.ozlabs.org/patch/1000076 for part 3.
I used imap-send, I think my mailer might have slaughtered the threading. Let me know if I should still resend. Should I mark it v4 even though, it contains the same patches?
Yes please, the threading was completely broken. Feel free to mark it v3 RESEND.

This solves the dependency problem I described in [1].
[1]: http://u-boot.10912.n7.nabble.com/-td347224.html
Version 3: * Reordered patches. * Split out CMD_USB dependency patch. * Verified that no patch breaks the Travis CI build. * Added missing commit comments. * Verified that all AM33xx boards still build.
Version 2: * Globally replace CONFIG_DM_USB * Split the CONFIG_DM_USB replacement into separate patch * Fix am335x_evm build
Sven Schwermer (5): usb: Introduce CONFIG_SPL_DM_USB usb: am335x_evm: Disable CONFIG_SPL_DM_USB usb: Remove CMD_USB dependency for common code usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ usb: storage: s/CONFIG_BLK/CONFIG_IS_ENABLED(BLK)/
common/Makefile | 2 +- common/usb.c | 14 ++++++------- common/usb_hub.c | 16 +++++++-------- common/usb_kbd.c | 4 ++-- common/usb_storage.c | 34 +++++++++++++++---------------- configs/am335x_evm_defconfig | 3 ++- drivers/usb/Kconfig | 5 +++++ drivers/usb/common/Makefile | 2 +- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 2 +- drivers/usb/eth/usb_ether.c | 2 +- drivers/usb/gadget/ci_udc.c | 2 +- drivers/usb/gadget/ether.c | 8 ++++---- drivers/usb/host/Makefile | 4 ++-- drivers/usb/host/dwc2.c | 12 +++++------ drivers/usb/host/ehci-atmel.c | 2 +- drivers/usb/host/ehci-fsl.c | 12 +++++------ drivers/usb/host/ehci-hcd.c | 12 +++++------ drivers/usb/host/ehci-marvell.c | 4 ++-- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/ehci-pci.c | 8 ++++---- drivers/usb/host/ehci-vf.c | 2 +- drivers/usb/host/ohci-hcd.c | 10 ++++----- drivers/usb/host/ohci.h | 4 ++-- drivers/usb/host/xhci-dwc3.c | 2 +- drivers/usb/host/xhci-fsl.c | 4 ++-- drivers/usb/host/xhci-mem.c | 6 +++--- drivers/usb/host/xhci.c | 12 +++++------ drivers/usb/host/xhci.h | 2 +- drivers/usb/musb-new/musb_uboot.c | 12 +++++------ drivers/usb/musb-new/omap2430.c | 4 ++-- drivers/usb/musb-new/ti-musb.c | 4 ++-- drivers/usb/musb-new/usb-compat.h | 2 +- include/usb.h | 12 +++++------ 34 files changed, 117 insertions(+), 111 deletions(-)

This allows building the SPL without driver model for USB. Since CONFIG_SPL_DM_USB is enabled if and only if CONFIG_DM_USB was enabled before, this patch does not change the build behaviour.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- drivers/usb/Kconfig | 5 +++++ drivers/usb/common/Makefile | 2 +- drivers/usb/host/Makefile | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 4fbe172e05..03746dd12f 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -47,6 +47,11 @@ config DM_USB declared with the U_BOOT_USB_DEVICE() macro and will be automatically probed when found on the bus.
+config SPL_DM_USB + bool "Enable driver model for USB in SPL" + depends on DM_USB + default y + source "drivers/usb/host/Kconfig"
source "drivers/usb/dwc3/Kconfig" diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile index 55e0547b16..3bedbf213f 100644 --- a/drivers/usb/common/Makefile +++ b/drivers/usb/common/Makefile @@ -3,6 +3,6 @@ # (C) Copyright 2016 Freescale Semiconductor, Inc. #
-obj-$(CONFIG_DM_USB) += common.o +obj-$(CONFIG_$(SPL_)DM_USB) += common.o obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index cb8c315a15..bfa565c4c3 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -3,7 +3,7 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-ifdef CONFIG_DM_USB +ifdef CONFIG_$(SPL_)DM_USB obj-$(CONFIG_CMD_USB) += usb-uclass.o obj-$(CONFIG_SANDBOX) += usb-sandbox.o endif

This configuration doesn't use USB in the SPL, so we need to disable driver model for USB in the SPL.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- configs/am335x_evm_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index b6cd49a469..6cc170ad40 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -40,15 +40,16 @@ CONFIG_NAND=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y -CONFIG_DRIVER_TI_CPSW=y CONFIG_PHY_GIGE=y CONFIG_MII=y +CONFIG_DRIVER_TI_CPSW=y CONFIG_SPI=y CONFIG_OMAP3_SPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y CONFIG_DM_USB=y +# CONFIG_SPL_DM_USB is not set CONFIG_USB_MUSB_HOST=y CONFIG_USB_MUSB_GADGET=y CONFIG_USB_MUSB_TI=y

Common USB code is built whenever USB is enabled (in non-SPL builds). The USB uclass is built whenever (SPL_)DM_USB is enabled. Both need to be independent from CMD_USB.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- common/Makefile | 2 +- drivers/usb/host/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/Makefile b/common/Makefile index a2388364d9..7d88077930 100644 --- a/common/Makefile +++ b/common/Makefile @@ -33,7 +33,7 @@ obj-$(CONFIG_MII) += miiphyutil.o obj-$(CONFIG_CMD_MII) += miiphyutil.o obj-$(CONFIG_PHYLIB) += miiphyutil.o
-ifdef CONFIG_CMD_USB +ifdef CONFIG_USB obj-y += usb.o usb_hub.o obj-$(CONFIG_USB_STORAGE) += usb_storage.o endif diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index bfa565c4c3..285c20ae86 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -4,7 +4,7 @@ # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
ifdef CONFIG_$(SPL_)DM_USB -obj-$(CONFIG_CMD_USB) += usb-uclass.o +obj-y += usb-uclass.o obj-$(CONFIG_SANDBOX) += usb-sandbox.o endif

This allows to disable the USB driver model in SPL because it checks the CONFIG_SPL_DM_USB variable for SPL builds. Nothing changes for regular non-SPL builds.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- common/usb.c | 14 +++++++------- common/usb_hub.c | 16 ++++++++-------- common/usb_kbd.c | 4 ++-- common/usb_storage.c | 6 +++--- drivers/usb/dwc3/core.c | 2 +- drivers/usb/dwc3/core.h | 2 +- drivers/usb/eth/usb_ether.c | 2 +- drivers/usb/gadget/ci_udc.c | 2 +- drivers/usb/gadget/ether.c | 8 ++++---- drivers/usb/host/dwc2.c | 12 ++++++------ drivers/usb/host/ehci-atmel.c | 2 +- drivers/usb/host/ehci-fsl.c | 12 ++++++------ drivers/usb/host/ehci-hcd.c | 12 ++++++------ drivers/usb/host/ehci-marvell.c | 4 ++-- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/ehci-pci.c | 8 ++++---- drivers/usb/host/ehci-vf.c | 2 +- drivers/usb/host/ohci-hcd.c | 10 +++++----- drivers/usb/host/ohci.h | 4 ++-- drivers/usb/host/xhci-dwc3.c | 2 +- drivers/usb/host/xhci-fsl.c | 4 ++-- drivers/usb/host/xhci-mem.c | 6 +++--- drivers/usb/host/xhci.c | 12 ++++++------ drivers/usb/host/xhci.h | 2 +- drivers/usb/musb-new/musb_uboot.c | 12 ++++++------ drivers/usb/musb-new/omap2430.c | 4 ++-- drivers/usb/musb-new/ti-musb.c | 4 ++-- drivers/usb/musb-new/usb-compat.h | 2 +- include/usb.h | 12 ++++++------ 29 files changed, 92 insertions(+), 92 deletions(-)
diff --git a/common/usb.c b/common/usb.c index 78178c54c8..b70f614d24 100644 --- a/common/usb.c +++ b/common/usb.c @@ -42,7 +42,7 @@ static int asynch_allowed; char usb_started; /* flag for the started/stopped USB status */
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct usb_device usb_dev[USB_MAX_DEVICE]; static int dev_index;
@@ -183,7 +183,7 @@ int usb_disable_asynch(int disable) asynch_allowed = !disable; return old_value; } -#endif /* !CONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
/*------------------------------------------------------------------- @@ -849,7 +849,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) * the USB device are static allocated [USB_MAX_DEVICE]. */
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB)
/* returns a pointer to the device with the index [index]. * if the device is not assigned (dev->devnum==-1) returns NULL @@ -906,7 +906,7 @@ __weak int usb_alloc_device(struct usb_device *udev) { return 0; } -#endif /* !CONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
static int usb_hub_port_reset(struct usb_device *dev, struct usb_device *hub) { @@ -1166,7 +1166,7 @@ int usb_setup_device(struct usb_device *dev, bool do_read, return ret; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* * By the time we get here, the device has gotten a new device ID * and is in the default state. We need to identify the thing and @@ -1215,14 +1215,14 @@ int board_usb_cleanup(int index, enum usb_init_type init)
bool usb_device_has_child_on_port(struct usb_device *parent, int port) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) return false; #else return parent->children[port] != NULL; #endif }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) void usb_find_usb2_hub_address_port(struct usb_device *udev, uint8_t *hub_address, uint8_t *hub_port) { diff --git a/common/usb_hub.c b/common/usb_hub.c index e1d93b8333..33aaeb8e44 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -64,7 +64,7 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev) return hdev->descriptor.bDeviceProtocol == 3; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) bool usb_hub_is_root_hub(struct udevice *hub) { if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB) @@ -125,7 +125,7 @@ int usb_get_port_status(struct usb_device *dev, int port, void *data) USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port, data, sizeof(struct usb_port_status), USB_CNTL_TIMEOUT);
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) if (ret < 0) return ret;
@@ -209,7 +209,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub) max(100, (int)pgood_delay) + 1000); }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct usb_hub_device hub_dev[USB_MAX_HUB]; static int usb_hub_index;
@@ -273,7 +273,7 @@ static int usb_hub_port_reset(struct usb_device *dev, int port, unsigned short portstatus, portchange; int delay = HUB_SHORT_RESET_TIME; /* start with short reset delay */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) debug("%s: resetting '%s' port %d...\n", __func__, dev->dev->name, port + 1); #else @@ -394,7 +394,7 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port) break; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *child;
ret = usb_scan_device(dev->dev, port + 1, speed, &child); @@ -604,7 +604,7 @@ static struct usb_hub_device *usb_get_hub_device(struct usb_device *dev) { struct usb_hub_device *hub;
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* "allocate" Hub device */ hub = usb_hub_allocate(); #else @@ -788,7 +788,7 @@ static int usb_hub_configure(struct usb_device *dev) (le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? \ "" : "no ");
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* * Update USB host controller's internal representation of this hub * after the hub descriptor is fetched. @@ -930,7 +930,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum) return ret; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) int usb_hub_scan(struct udevice *hub) { struct usb_device *udev = dev_get_parent_priv(hub); diff --git a/common/usb_kbd.c b/common/usb_kbd.c index fdeb2aed24..020f0d4117 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -539,7 +539,7 @@ static int probe_usb_keyboard(struct usb_device *dev) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* Search for keyboard and register it if found. */ int drv_usb_kbd_init(void) { @@ -602,7 +602,7 @@ int usb_kbd_deregister(int force)
#endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int usb_kbd_probe(struct udevice *dev) { diff --git a/common/usb_storage.c b/common/usb_storage.c index 560d60538b..c9a99b1ca2 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -299,7 +299,7 @@ int usb_stor_scan(int mode) if (mode == 1) printf(" scanning usb for storage devices... ");
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) unsigned char i;
usb_disable_asynch(1); /* asynch transfer not allowed */ @@ -942,7 +942,7 @@ static void usb_stor_set_max_xfer_blk(struct usb_device *udev, size_t __maybe_unused size; int __maybe_unused ret;
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) #ifdef CONFIG_USB_EHCI_HCD /* * The U-Boot EHCI driver can handle any transfer length as long as @@ -1495,7 +1495,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss, return 1; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int usb_mass_storage_probe(struct udevice *dev) { diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 1ab5cee609..f1ca6191ce 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -789,7 +789,7 @@ MODULE_AUTHOR("Felipe Balbi balbi@ti.com"); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
int dwc3_init(struct dwc3 *dwc) { diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 58fe91dc51..cfe29884e7 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -712,7 +712,7 @@ struct dwc3 { /* device lock */ spinlock_t lock;
-#if defined(__UBOOT__) && defined(CONFIG_DM_USB) +#if defined(__UBOOT__) && CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; #else struct device *dev; diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c index 1ce3361b45..3aca9ac265 100644 --- a/drivers/usb/eth/usb_ether.c +++ b/drivers/usb/eth/usb_ether.c @@ -271,7 +271,7 @@ int usb_host_eth_scan(int mode) }
usb_max_eth_dev = 0; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* * TODO: We should add U_BOOT_USB_DEVICE() declarations to each USB * Ethernet driver and then most of this file can be removed. diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index 0a84f6850d..bd596ce977 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -1015,7 +1015,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) if (driver->speed != USB_SPEED_FULL && driver->speed != USB_SPEED_HIGH) return -EINVAL;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) ret = usb_setup_ehci_gadget(&controller.ctrl); #else ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl); diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 90ef1f055f..193583b437 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -100,7 +100,7 @@ struct eth_dev { struct usb_gadget *gadget; struct usb_request *req; /* for control responses */ struct usb_request *stat_req; /* for cdc & rndis status */ -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *usb_udev; #endif
@@ -2337,7 +2337,7 @@ fail:
/*-------------------------------------------------------------------------*/
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) int dm_usb_init(struct eth_dev *e_dev) { struct udevice *dev = NULL; @@ -2362,7 +2362,7 @@ static int _usb_eth_init(struct ether_priv *priv) unsigned long ts; unsigned long timeout = USB_CONNECT_TIMEOUT;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) if (dm_usb_init(dev)) { pr_err("USB ether not found\n"); return -ENODEV; @@ -2541,7 +2541,7 @@ void _usb_eth_halt(struct ether_priv *priv) }
usb_gadget_unregister_driver(&priv->eth_driver); -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) board_usb_cleanup(0, USB_INIT_DEVICE); #endif } diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index b6f008a400..a62a2f8a95 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -29,7 +29,7 @@ #define MAX_ENDPOINT 16
struct dwc2_priv { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) uint8_t aligned_buffer[DWC2_DATA_BUF_SIZE] __aligned(ARCH_DMA_MINALIGN); uint8_t status_buffer[DWC2_STATUS_BUF_SIZE] __aligned(ARCH_DMA_MINALIGN); #ifdef CONFIG_DM_REGULATOR @@ -54,7 +54,7 @@ struct dwc2_priv { struct reset_ctl_bulk resets; };
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* We need cacheline-aligned buffers for DMA transfers and dcache support */ DEFINE_ALIGN_BUFFER(uint8_t, aligned_buffer_addr, DWC2_DATA_BUF_SIZE, ARCH_DMA_MINALIGN); @@ -168,7 +168,7 @@ static void dwc_otg_core_reset(struct dwc2_core_regs *regs) mdelay(100); }
-#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR) +#if CONFIG_IS_ENABLED(DM_USB) && defined(CONFIG_DM_REGULATOR) static int dwc_vbus_supply_init(struct udevice *dev) { struct dwc2_priv *priv = dev_get_priv(dev); @@ -211,7 +211,7 @@ static int dwc_vbus_supply_init(struct udevice *dev) return 0; }
-#if defined(CONFIG_DM_USB) +#if CONFIG_IS_ENABLED(DM_USB) static int dwc_vbus_supply_exit(struct udevice *dev) { return 0; @@ -1222,7 +1222,7 @@ static void dwc2_uninit_common(struct dwc2_core_regs *regs) DWC2_HPRT0_PRTRST); }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int len, struct devrequest *setup) { @@ -1267,7 +1267,7 @@ int usb_lowlevel_stop(int index) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int dwc2_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 66dc63da08..6900848df1 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c @@ -14,7 +14,7 @@
#include "ehci.h"
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB)
int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index a8fb2b8ac3..23e7e7125f 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR; #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct ehci_fsl_priv { struct ehci_ctrl ehci; fdt_addr_t hcd_base; @@ -34,7 +34,7 @@ struct ehci_fsl_priv { #endif
static void set_txfifothresh(struct usb_ehci *, u32); -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci, struct ehci_hccr *hccr, struct ehci_hcor *hcor); #else @@ -54,7 +54,7 @@ static int usb_phy_clk_valid(struct usb_ehci *ehci) } }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_fsl_ofdata_to_platdata(struct udevice *dev) { struct ehci_fsl_priv *priv = dev_get_priv(dev); @@ -183,7 +183,7 @@ int ehci_hcd_stop(int index) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci, struct ehci_hccr *hccr, struct ehci_hcor *hcor) #else @@ -192,7 +192,7 @@ static int ehci_fsl_init(int index, struct usb_ehci *ehci, #endif { const char *phy_type = NULL; -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) size_t len; char current_usb_controller[5]; #endif @@ -218,7 +218,7 @@ static int ehci_fsl_init(int index, struct usb_ehci *ehci, out_be32(&ehci->snoop2, 0x80000000 | SNOOP_SIZE_2GB);
/* Init phy */ -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) if (priv->phy_type) phy_type = priv->phy_type; #else diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index d1d8f08d98..4b28db70a5 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -30,7 +30,7 @@ */ #define HCHALT_TIMEOUT (8 * 1000)
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct ehci_ctrl ehcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; #endif
@@ -111,7 +111,7 @@ static struct descriptor {
static struct ehci_ctrl *ehci_get_ctrl(struct usb_device *udev) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) return dev_get_priv(usb_get_bus(udev->dev)); #else return udev->controller; @@ -973,7 +973,7 @@ static void ehci_setup_ops(struct ehci_ctrl *ctrl, const struct ehci_ops *ops) } }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) void ehci_set_controller_priv(int index, void *priv, const struct ehci_ops *ops) { struct ehci_ctrl *ctrl = &ehcic[index]; @@ -1097,7 +1097,7 @@ static int ehci_common_init(struct ehci_ctrl *ctrl, uint tweaks) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_lowlevel_stop(int index) { ehci_shutdown(&ehcic[index]); @@ -1518,7 +1518,7 @@ static int _ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe, return result; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int length) { @@ -1556,7 +1556,7 @@ int destroy_int_queue(struct usb_device *dev, struct int_queue *queue) } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c index 73432f2acd..8efe6b63b9 100644 --- a/drivers/usb/host/ehci-marvell.c +++ b/drivers/usb/host/ehci-marvell.c @@ -38,7 +38,7 @@ DECLARE_GLOBAL_DATA_PTR; /* * USB 2.0 Bridge Address Decoding registers setup */ -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
struct ehci_mvebu_priv { struct ehci_ctrl ehci; @@ -228,4 +228,4 @@ int ehci_hcd_stop(int index) return 0; }
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index be010b1adb..1acf08dfb7 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -335,7 +335,7 @@ int ehci_mx6_common_init(struct usb_ehci *ehci, int index) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 6150f3d888..04e7c5e37f 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -19,7 +19,7 @@ struct ehci_pci_priv { struct phy phy; };
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr, struct ehci_hcor **ret_hcor) { @@ -121,9 +121,9 @@ int ehci_hcd_stop(int index) { return 0; } -#endif /* nCONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ehci_pci_probe(struct udevice *dev) { struct ehci_hccr *hccr; @@ -173,4 +173,4 @@ static struct pci_device_id ehci_pci_supported[] = {
U_BOOT_PCI_DEVICE(ehci_pci, ehci_pci_supported);
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c index 22e5afad6e..a16cf135e3 100644 --- a/drivers/usb/host/ehci-vf.c +++ b/drivers/usb/host/ehci-vf.c @@ -153,7 +153,7 @@ int ehci_vf_common_init(struct usb_ehci *ehci, int index) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 6ea9f105a6..3b6f889f7b 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -120,7 +120,7 @@ static struct pci_device_id ehci_pci_ids[] = { #define invalidate_dcache_iso_td(addr) invalidate_dcache_buffer(addr, 32) #define invalidate_dcache_hcca(addr) invalidate_dcache_buffer(addr, 256)
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* * The various ohci_mdelay(1) calls in the code seem unnecessary. We keep * them around when building for older boards not yet converted to the dm @@ -131,7 +131,7 @@ static struct pci_device_id ehci_pci_ids[] = { #define ohci_mdelay(x) mdelay(x) #endif
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* global ohci_t */ static ohci_t gohci; /* this must be aligned to a 256 byte boundary */ @@ -1691,7 +1691,7 @@ static int _ohci_destroy_int_queue(ohci_t *ohci, struct usb_device *dev, return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* submit routines called from usb.c */ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len) @@ -1980,7 +1980,7 @@ static int hc_interrupt(ohci_t *ohci)
/*-------------------------------------------------------------------------*/
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB)
/*-------------------------------------------------------------------------*/
@@ -2130,7 +2130,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, } #endif
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int ohci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index fba78dcf7a..f9f02cb09c 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h @@ -27,7 +27,7 @@ #define ED_ALIGNMENT 16 #endif
-#if defined CONFIG_DM_USB && ARCH_DMA_MINALIGN > 32 +#if CONFIG_IS_ENABLED(DM_USB) && ARCH_DMA_MINALIGN > 32 #define TD_ALIGNMENT ARCH_DMA_MINALIGN #else #define TD_ALIGNMENT 32 @@ -406,7 +406,7 @@ typedef struct ohci { const char *slot_name; } ohci_t;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) extern struct dm_usb_ops ohci_usb_ops;
int ohci_register(struct udevice *dev, struct ohci_regs *regs); diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c index 80754d76d0..dd0d156027 100644 --- a/drivers/usb/host/xhci-dwc3.c +++ b/drivers/usb/host/xhci-dwc3.c @@ -109,7 +109,7 @@ void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val) GFLADJ_30MHZ(val)); }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int xhci_dwc3_setup_phy(struct udevice *dev) { struct xhci_dwc3_platdata *plat = dev_get_platdata(dev); diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c index 047a8dfdef..c0b98a8ec7 100644 --- a/drivers/usb/host/xhci-fsl.c +++ b/drivers/usb/host/xhci-fsl.c @@ -19,7 +19,7 @@ #include <dm.h>
/* Declare global data pointer */ -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct fsl_xhci fsl_xhci; unsigned long ctr_addr[] = FSL_USB_XHCI_ADDR; #else @@ -107,7 +107,7 @@ static int fsl_xhci_core_exit(struct fsl_xhci *fsl_xhci) return 0; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int xhci_fsl_probe(struct udevice *dev) { struct xhci_fsl_priv *priv = dev_get_priv(dev); diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index da5dbd94ed..04ab540695 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -723,7 +723,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, int slot_id = udev->slot_id; int speed = udev->speed; int route = 0; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct usb_device *dev = udev; struct usb_hub_device *hub; #endif @@ -739,7 +739,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, /* Only the control endpoint is valid - one endpoint context */ slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1));
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* Calculate the route string for this device */ port_num = dev->portnr; while (!usb_hub_is_root_hub(dev->dev)) { @@ -782,7 +782,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, BUG(); }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /* Set up TT fields to support FS/LS devices */ if (speed == USB_SPEED_LOW || speed == USB_SPEED_FULL) { struct udevice *parent = udev->dev; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 9ded14cc3c..44c5f2d264 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -108,13 +108,13 @@ static struct descriptor { }, };
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) static struct xhci_ctrl xhcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; #endif
struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev) { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev;
/* Find the USB controller */ @@ -741,7 +741,7 @@ static int _xhci_alloc_device(struct usb_device *udev) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_alloc_device(struct usb_device *udev) { return _xhci_alloc_device(udev); @@ -1256,7 +1256,7 @@ static int xhci_lowlevel_stop(struct xhci_ctrl *ctrl) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) { @@ -1340,9 +1340,9 @@ int usb_lowlevel_stop(int index)
return 0; } -#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
static int xhci_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index a7555b2fa8..6017504488 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1211,7 +1211,7 @@ void xhci_hcd_stop(int index); #define XHCI_STS_CNR (1 << 11)
struct xhci_ctrl { -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; #endif struct xhci_hccr *hccr; /* R/O registers, not need for volatile */ diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 2bf918eab4..d40772b1aa 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -19,7 +19,7 @@ struct int_queue { struct urb urb; };
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) struct musb_host_data musb_host; #endif
@@ -243,7 +243,7 @@ int musb_lowlevel_init(struct musb_host_data *host) return 0; }
-#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) int usb_lowlevel_stop(int index) { if (!musb_host.host) { @@ -300,9 +300,9 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) { return musb_lowlevel_init(&musb_host); } -#endif /* !CONFIG_DM_USB */ +#endif /* !CONFIG_IS_ENABLED(DM_USB) */
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static int musb_submit_control_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, struct devrequest *setup) @@ -364,7 +364,7 @@ struct dm_usb_ops musb_usb_ops = { .destroy_int_queue = musb_destroy_int_queue, .reset_root_port = musb_reset_root_port, }; -#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ #endif /* CONFIG_USB_MUSB_HOST */
#ifdef CONFIG_USB_MUSB_GADGET @@ -425,7 +425,7 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata, struct musb **musbp;
switch (plat->mode) { -#if defined(CONFIG_USB_MUSB_HOST) && !defined(CONFIG_DM_USB) +#if defined(CONFIG_USB_MUSB_HOST) && !CONFIG_IS_ENABLED(DM_USB) case MUSB_HOST: musbp = &musb_host.host; break; diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index 342d76bd6f..58aed72b7d 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -135,7 +135,7 @@ const struct musb_platform_ops omap2430_ops = { .disable = omap2430_musb_disable, };
-#if defined(CONFIG_DM_USB) +#if CONFIG_IS_ENABLED(DM_USB)
struct omap2430_musb_platdata { void *base; @@ -276,4 +276,4 @@ U_BOOT_DRIVER(omap2430_musb) = { .priv_auto_alloc_size = sizeof(struct musb_host_data), };
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index 9fbe2d6861..ee0960704a 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -19,7 +19,7 @@
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB)
/* USB 2.0 PHY Control */ #define CM_PHY_PWRDN (1 << 0) @@ -251,4 +251,4 @@ U_BOOT_DRIVER(ti_musb_wrapper) = { .bind = ti_musb_wrapper_bind, };
-#endif /* CONFIG_DM_USB */ +#endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/musb-new/usb-compat.h b/drivers/usb/musb-new/usb-compat.h index 760bd787bc..f2c18ad3a2 100644 --- a/drivers/usb/musb-new/usb-compat.h +++ b/drivers/usb/musb-new/usb-compat.h @@ -67,7 +67,7 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, return 0; }
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev) { struct udevice *parent = udev->dev->parent; diff --git a/include/usb.h b/include/usb.h index b6b48a8c60..420a30e49f 100644 --- a/include/usb.h +++ b/include/usb.h @@ -140,7 +140,7 @@ struct usb_device { int act_len; /* transferred bytes */ int maxchild; /* Number of ports if hub */ int portnr; /* Port number, 1=first */ -#ifndef CONFIG_DM_USB +#if !CONFIG_IS_ENABLED(DM_USB) /* parent hub, or NULL if this is the root hub */ struct usb_device *parent; struct usb_device *children[USB_MAXCHILDREN]; @@ -148,7 +148,7 @@ struct usb_device { #endif /* slot_id - for xHCI enabled devices */ unsigned int slot_id; -#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) struct udevice *dev; /* Pointer to associated device */ struct udevice *controller_dev; /* Pointer to associated controller */ #endif @@ -173,7 +173,7 @@ enum usb_init_type { int usb_lowlevel_init(int index, enum usb_init_type init, void **controller); int usb_lowlevel_stop(int index);
-#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_DM_USB) +#if defined(CONFIG_USB_MUSB_HOST) || CONFIG_IS_ENABLED(DM_USB) int usb_reset_root_port(struct usb_device *dev); #else #define usb_reset_root_port(dev) @@ -187,7 +187,7 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
#if defined CONFIG_USB_EHCI_HCD || defined CONFIG_USB_MUSB_HOST \ - || defined(CONFIG_DM_USB) + || CONFIG_IS_ENABLED(DM_USB) struct int_queue *create_int_queue(struct usb_device *dev, unsigned long pipe, int queuesize, int elementsize, void *buffer, int interval); int destroy_int_queue(struct usb_device *dev, struct int_queue *queue); @@ -588,7 +588,7 @@ struct usb_hub_device { struct usb_tt tt; /* Transaction Translator */ };
-#ifdef CONFIG_DM_USB +#if CONFIG_IS_ENABLED(DM_USB) /** * struct usb_platdata - Platform data about a USB controller * @@ -912,7 +912,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp); */ void usb_stor_reset(void);
-#else /* !CONFIG_DM_USB */ +#else /* !CONFIG_IS_ENABLED(DM_USB) */
struct usb_device *usb_get_dev_index(int index);

This fixes link issues when building the SPL without USB driver model but with USB storage support. CONFIG_BLK can be enabled and disabled independently for SPL and non-SPL builds. We leverage that existing functionality here.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- common/usb_storage.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c index c9a99b1ca2..8c889bb1a6 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -66,7 +66,7 @@ static __u32 CBWTag;
static int usb_max_devs; /* number of highest available usb device */
-#ifndef CONFIG_BLK +#if !CONFIG_IS_ENABLED(BLK) static struct blk_desc usb_dev_desc[USB_MAX_STOR_DEV]; #endif
@@ -99,7 +99,7 @@ struct us_data { unsigned short max_xfer_blk; /* maximum transfer blocks */ };
-#ifndef CONFIG_BLK +#if !CONFIG_IS_ENABLED(BLK) static struct us_data usb_stor[USB_MAX_STOR_DEV]; #endif
@@ -111,7 +111,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *us, struct blk_desc *dev_desc); int usb_storage_probe(struct usb_device *dev, unsigned int ifnum, struct us_data *ss); -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer); static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr, @@ -136,7 +136,7 @@ static void usb_show_progress(void) int usb_stor_info(void) { int count = 0; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct udevice *dev;
for (blk_first_device(IF_TYPE_USB, &dev); @@ -186,7 +186,7 @@ static int usb_stor_probe_device(struct usb_device *udev) { int lun, max_lun;
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct us_data *data; int ret; #else @@ -197,7 +197,7 @@ static int usb_stor_probe_device(struct usb_device *udev) #endif
debug("\n\nProbing for storage\n"); -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) /* * We store the us_data in the mass storage device's platdata. It * is shared by all LUNs (block devices) attached to this mass storage @@ -1119,7 +1119,7 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor, } #endif /* CONFIG_USB_BIN_FIXUP */
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) #else @@ -1134,14 +1134,14 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr, struct us_data *ss; int retry; struct scsi_cmd *srb = &usb_ccb; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct blk_desc *block_dev; #endif
if (blkcnt == 0) return 0; /* Setup device */ -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) block_dev = dev_get_uclass_platdata(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); @@ -1200,7 +1200,7 @@ retry_it: return blkcnt; }
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) #else @@ -1215,7 +1215,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, struct us_data *ss; int retry; struct scsi_cmd *srb = &usb_ccb; -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) struct blk_desc *block_dev; #endif
@@ -1223,7 +1223,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, return 0;
/* Setup device */ -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) block_dev = dev_get_uclass_platdata(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); @@ -1519,7 +1519,7 @@ U_BOOT_DRIVER(usb_mass_storage) = { .id = UCLASS_MASS_STORAGE, .of_match = usb_mass_storage_ids, .probe = usb_mass_storage_probe, -#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) .platdata_auto_alloc_size = sizeof(struct us_data), #endif }; @@ -1540,7 +1540,7 @@ static const struct usb_device_id mass_storage_id_table[] = { U_BOOT_USB_DEVICE(usb_mass_storage, mass_storage_id_table); #endif
-#ifdef CONFIG_BLK +#if CONFIG_IS_ENABLED(BLK) static const struct blk_ops usb_storage_ops = { .read = usb_stor_read, .write = usb_stor_write,

Common USB code is built whenever USB is enabled (in non-SPL builds). The USB uclass is built whenever (SPL_)DM_USB is enabled. Both need to be independent from CMD_USB.
Signed-off-by: Sven Schwermer sven@svenschwermer.de --- common/Makefile | 2 +- drivers/usb/host/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/Makefile b/common/Makefile index a2388364d9..7d88077930 100644 --- a/common/Makefile +++ b/common/Makefile @@ -33,7 +33,7 @@ obj-$(CONFIG_MII) += miiphyutil.o obj-$(CONFIG_CMD_MII) += miiphyutil.o obj-$(CONFIG_PHYLIB) += miiphyutil.o
-ifdef CONFIG_CMD_USB +ifdef CONFIG_USB obj-y += usb.o usb_hub.o obj-$(CONFIG_USB_STORAGE) += usb_storage.o endif diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index bfa565c4c3..285c20ae86 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -4,7 +4,7 @@ # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
ifdef CONFIG_$(SPL_)DM_USB -obj-$(CONFIG_CMD_USB) += usb-uclass.o +obj-y += usb-uclass.o obj-$(CONFIG_SANDBOX) += usb-sandbox.o endif
participants (4)
-
Jean-Jacques Hiblot
-
Marek Vasut
-
Sven Schwermer
-
Tom Rini