All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] usb: Introduce CONFIG_SPL_DM_USB
@ 2018-11-15  8:20 Sven Schwermer
  2018-11-15 14:27 ` Marek Vasut
  0 siblings, 1 reply; 60+ messages in thread
From: Sven Schwermer @ 2018-11-15  8:20 UTC (permalink / raw)
  To: u-boot

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 at 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);

-- 
2.17.1

^ permalink raw reply related	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2018-11-21 14:08 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-15  8:20 [U-Boot] [PATCH] usb: Introduce CONFIG_SPL_DM_USB Sven Schwermer
2018-11-15 14:27 ` Marek Vasut
2018-11-15 15:09   ` Sven Schwermer
2018-11-15 15:16     ` Marek Vasut
2018-11-16 12:46       ` Sven Schwermer
2018-11-16 12:46         ` Marek Vasut
2018-11-17 12:20           ` [U-Boot] [PATCH v2 0/4] " Sven Schwermer
2018-11-15  7:50             ` [U-Boot] [PATCH v2 2/4] usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ Sven Schwermer
2018-11-18  3:32               ` Marek Vasut
2018-11-16 11:04             ` [U-Boot] [PATCH v2 4/4] usb: am335x_evm: Disable CONFIG_SPL_DM_USB Sven Schwermer
2018-11-18  3:33               ` Marek Vasut
2018-11-18 14:15                 ` Tom Rini
2018-11-18 19:05                   ` Sven Schwermer
2018-11-18 19:17                     ` Marek Vasut
2018-11-18 20:46                     ` Tom Rini
2018-11-20  9:09                       ` Jean-Jacques Hiblot
2018-11-20  9:19                         ` Jean-Jacques Hiblot
2018-11-17 11:14             ` [U-Boot] [PATCH v2 3/4] usb: storage: s/CONFIG_BLK/CONFIG_IS_ENABLED(BLK)/ Sven Schwermer
2018-11-18  3:32               ` Marek Vasut
2018-11-17 11:37             ` [U-Boot] [PATCH v2 1/4] usb: Introduce CONFIG_SPL_DM_USB Sven Schwermer
2018-11-18  3:31               ` Marek Vasut
2018-11-18 19:08                 ` Sven Schwermer
2018-11-18 19:19                   ` Marek Vasut
2018-11-19 20:33             ` [U-Boot] [PATCH v3 0/5] " Sven Schwermer
2018-11-15  7:50               ` [U-Boot] [PATCH v3 4/5] usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ Sven Schwermer
2018-11-16 11:04               ` [U-Boot] [PATCH v3 2/5] usb: am335x_evm: Disable CONFIG_SPL_DM_USB Sven Schwermer
2018-11-19 21:18                 ` Marek Vasut
2018-11-20  7:28                   ` Sven Schwermer
2018-11-20 12:43                     ` Marek Vasut
2018-11-20 13:22                       ` Sven Schwermer
2018-11-20 13:31                         ` Marek Vasut
2018-11-20 14:10                           ` Sven Schwermer
2018-11-20 14:14                             ` Marek Vasut
2018-11-20 15:21                               ` Sven Schwermer
2018-11-20 15:47                                 ` Marek Vasut
2018-11-20 17:42                                   ` Sven Schwermer
2018-11-20 17:59                                     ` Marek Vasut
2018-11-20 20:01                                       ` Sven Schwermer
2018-11-20 20:11                                         ` Marek Vasut
2018-11-17 11:14               ` [U-Boot] [PATCH v3 5/5] usb: storage: s/CONFIG_BLK/CONFIG_IS_ENABLED(BLK)/ Sven Schwermer
2018-11-17 11:37               ` [U-Boot] [PATCH v3 1/5] usb: Introduce CONFIG_SPL_DM_USB Sven Schwermer
2018-11-19 21:18                 ` Marek Vasut
2018-11-20  7:25                   ` Sven Schwermer
2018-11-20 12:49                     ` Marek Vasut
2018-11-20 13:27                       ` Sven Schwermer
2018-11-20 13:32                         ` Marek Vasut
2018-11-20 15:30                           ` Sven Schwermer
2018-11-20 15:48                             ` Marek Vasut
2018-11-20 17:31                               ` Sven Schwermer
2018-11-20 17:38                                 ` Marek Vasut
2018-11-20 19:28                                   ` Sven Schwermer
2018-11-20 19:34                                     ` Marek Vasut
2018-11-21  7:43                                       ` [U-Boot] [PATCH v3 RESEND 0/5] " Sven Schwermer
2018-11-21  7:43                                         ` [U-Boot] [PATCH v3 RESEND 1/5] " Sven Schwermer
2018-11-21  7:43                                         ` [U-Boot] [PATCH v3 RESEND 2/5] usb: am335x_evm: Disable CONFIG_SPL_DM_USB Sven Schwermer
2018-11-21  7:43                                         ` [U-Boot] [PATCH v3 RESEND 3/5] usb: Remove CMD_USB dependency for common code Sven Schwermer
2018-11-21  7:43                                         ` [U-Boot] [PATCH v3 RESEND 4/5] usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/ Sven Schwermer
2018-11-21  7:43                                         ` [U-Boot] [PATCH v3 RESEND 5/5] usb: storage: s/CONFIG_BLK/CONFIG_IS_ENABLED(BLK)/ Sven Schwermer
2018-11-21 14:08                                         ` [U-Boot] [PATCH v3 RESEND 0/5] usb: Introduce CONFIG_SPL_DM_USB Marek Vasut
2018-11-19  8:11               ` [U-Boot] [PATCH v3 3/5] usb: Remove CMD_USB dependency for common code Sven Schwermer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.