All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 43/80] dm: usb: Bind generic USB devices when there is no driver
Date: Wed, 25 Mar 2015 12:22:31 -0600	[thread overview]
Message-ID: <1427307788-7496-44-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1427307788-7496-1-git-send-email-sjg@chromium.org>

At present USB devices with no driver model driver cannot be seen in the
device list, and we fail to set them up correctly. This means they cannot
be used.

While having real drivers that support driver model for all USB devices
is the eventual goal, we are not there yet.

As a stop-gap, add a generic USB driver which is bound when we do not have
a real driver. This allows the device to be set up and shown on the bus.
It also allows ad-hoc code (such as usb_ether) to find these devices and
set them up.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 drivers/usb/host/usb-uclass.c | 18 +++++++++++++++++-
 include/dm/uclass-id.h        |  1 +
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index a86e905..fa5f14e 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -384,7 +384,13 @@ static int usb_find_and_bind_driver(struct udevice *parent,
 		}
 	}
 
-	ret = -ENOENT;
+	/* Bind a generic driver so that the device can be used */
+	snprintf(name, sizeof(name), "generic_bus_%x_dev_%x", bus_seq, devnum);
+	str = strdup(name);
+	if (!str)
+		return -ENOMEM;
+	ret = device_bind_driver(parent, "usb_dev_generic_drv", str, devp);
+
 error:
 	debug("%s: No match found: %d\n", __func__, ret);
 	return ret;
@@ -592,3 +598,13 @@ UCLASS_DRIVER(usb) = {
 	.child_pre_probe = usb_child_pre_probe,
 	.per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata),
 };
+
+UCLASS_DRIVER(usb_dev_generic) = {
+	.id		= UCLASS_USB_DEV_GENERIC,
+	.name		= "usb_dev_generic",
+};
+
+U_BOOT_DRIVER(usb_dev_generic_drv) = {
+	.id		= UCLASS_USB_DEV_GENERIC,
+	.name		= "usb_dev_generic_drv",
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index acec938..42a6f1f 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -41,6 +41,7 @@ enum uclass_id {
 	UCLASS_ETH,		/* Ethernet device */
 	UCLASS_USB,		/* USB bus */
 	UCLASS_USB_HUB,		/* USB hub */
+	UCLASS_USB_DEV_GENERIC,	/* USB generic device */
 
 	UCLASS_COUNT,
 	UCLASS_INVALID = -1,
-- 
2.2.0.rc0.207.ga3a616c

  parent reply	other threads:[~2015-03-25 18:22 UTC|newest]

Thread overview: 178+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-25 18:21 [U-Boot] [PATCH v2 0/80] dm: Add USB support Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 01/80] linker_lists: Add a function to access a linker list entry Simon Glass
2015-04-07 18:39   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 02/80] sandbox: Fix comment for os_open() Simon Glass
2015-04-07 18:39   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 03/80] dm: test: bus: Use a local variable to simplify code Simon Glass
2015-04-07 18:39   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 04/80] dm: exynos: snow: Move the keyboard to I2C Simon Glass
2015-04-07 18:39   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 05/80] dm: core: Support allocating driver-private data for DMA Simon Glass
2015-04-07 18:39   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 06/80] dm: core: Convert driver_bind() to use const Simon Glass
2015-04-07 18:39   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 07/80] dm: core: Rename driver data function to dev_get_driver_data() Simon Glass
2015-04-07 18:40   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 08/80] dm: core: Mark device as active before calling uclass probe() methods Simon Glass
2015-04-07 18:40   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 09/80] dm: core: Add device children and sibling functions Simon Glass
2015-04-07 18:40   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 10/80] dm: gpio: Add an implementation for gpio_get_number() Simon Glass
2015-04-07 18:40   ` Simon Glass
2015-03-25 18:21 ` [U-Boot] [PATCH v2 11/80] dm: usb: Add a uclass for USB controllers Simon Glass
2015-04-07 18:40   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 12/80] dm: usb: Adjust usb command to prepare for driver model Simon Glass
2015-04-07 18:40   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 13/80] dm: usb: Adjust usb_alloc_new_device() to return an error Simon Glass
2015-04-07 18:40   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 14/80] dm: usb: Convert 'usb' command to support driver model Simon Glass
2015-04-07 18:40   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 15/80] dm: usb: Drop the legacy USB init sequence Simon Glass
2015-03-26 18:22   ` Marek Vasut
2015-04-07 18:41     ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 16/80] dm: usb: Refactor port resets Simon Glass
2015-04-07 18:41   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 17/80] dm: usb: Move descriptor setup code into its own function Simon Glass
2015-04-07 18:41   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 18/80] dm: usb: Split out more code from usb_new_device() Simon Glass
2015-04-07 18:41   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 19/80] dm: usb: Complete the splitting up of usb_new_device() Simon Glass
2015-04-07 18:41   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 20/80] dm: usb: Convert core usb.c file to support driver model Simon Glass
2015-04-07 18:41   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 21/80] dm: usb: Split hub detection into its own function Simon Glass
2015-04-07 18:41   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 22/80] dm: usb: Add driver model support for hubs Simon Glass
2015-04-07 18:41   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 23/80] dm: usb: Move USB storage definitions to usb_defs.h Simon Glass
2015-04-07 18:42   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 24/80] dm: usb: Fix type problems in usb_stor_get_info() Simon Glass
2015-04-07 18:42   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 25/80] dm: usb: Simply device finding code in usb_storage Simon Glass
2015-04-07 18:42   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 26/80] dm: usb: Adjust usb_storage to work with sandbox Simon Glass
2015-04-07 18:42   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 27/80] dm: usb: Move storage device scanning into its own function Simon Glass
2015-04-07 18:43   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 28/80] dm: usb: Convert usb_storage to driver model Simon Glass
2015-04-07 18:43   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 29/80] dm: usb: Move all the EHCI weak functions together and declare them Simon Glass
2015-04-07 18:43   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 30/80] dm: usb: Pass EHCI controller pointer to ehci_get_port_speed() Simon Glass
2015-04-07 18:43   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 31/80] dm: usb: Allow ECHI to hold private data for the controller Simon Glass
2015-04-07 18:43   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 32/80] dm: usb: tegra: Store the controller type explicitly Simon Glass
2015-04-07 18:43   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 33/80] dm: usb: Pass EHCI controller pointer to ehci_powerup_fixup() Simon Glass
2015-04-07 18:43   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 34/80] dm: usb: tegra: Drop use of global controller variable Simon Glass
2015-04-07 18:44   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 35/80] dm: usb: Pass EHCI controller pointer to ehci_set_usbmode() Simon Glass
2015-04-07 18:44   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 36/80] dm: usb: Pass EHCI controller pointer to ehci_get_portsc_register() Simon Glass
2015-04-07 18:44   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 37/80] dm: usb: ehci: Use a function to find the controller from struct udevice Simon Glass
2015-04-07 18:44   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 38/80] dm: usb: Refactor EHCI init Simon Glass
2015-04-07 18:44   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 39/80] dm: usb: Drop the EHCI weak functions Simon Glass
2015-04-07 18:44   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 40/80] dm: usb: Change ehci_reset() to use a pointer Simon Glass
2015-04-07 18:44   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 41/80] dm: usb: Add driver model support to EHCI Simon Glass
2015-04-07 18:44   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 42/80] dm: usb: Allow USB drivers to be declared and auto-probed Simon Glass
2015-04-07 18:45   ` Simon Glass
2015-03-25 18:22 ` Simon Glass [this message]
2015-04-07 18:45   ` [U-Boot] [PATCH v2 43/80] dm: usb: Bind generic USB devices when there is no driver Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 44/80] dm: usb: Allow setting up a USB controller as a device/gadget Simon Glass
2015-04-07 18:45   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 45/80] dm: usb: Split out the keyboard probe into its own function Simon Glass
2015-04-07 18:45   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 46/80] dm: usb: Support driver model with USB keyboards Simon Glass
2015-04-07 18:45   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 47/80] dm: usb: tegra: Add vbus GPIOs for nyan Simon Glass
2015-04-07 19:09   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 48/80] dm: usb: Move struct usb_string to a common place Simon Glass
2015-04-07 19:09   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 49/80] dm: usb: sandbox: Add a uclass for USB device emulation Simon Glass
2015-04-07 19:09   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 50/80] dm: usb: sandbox: Reset emulation devices in usb stop() Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 51/80] dm: usb: sandbox: Add an emulator for USB flash devices Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 52/80] dm: usb: sandbox: Add an emulator for USB hub emulation Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 53/80] dm: usb: sandbox: Add a driver for sandbox Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 54/80] dm: usb: dts: sandbox: Add some sample USB devices to sandbox Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 55/80] dm: usb: Add support for USB ethernet devices with driver model Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 56/80] dm: usb: exynos: Add driver model support to exynos EHCI Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 57/80] dm: usb: tegra: Remove the port_addr_clear_csc variable Simon Glass
2015-03-26  3:38   ` Jim Lin
2015-03-26  9:01     ` Jim Lin
2015-04-07 19:10       ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 58/80] dm: usb: tegra: Tidy up error handling and a static function Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 59/80] dm: usb: tegra: Move most of init/uninit into a function Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 60/80] dm: usb: tegra: Add driver model support to tegra EHCI Simon Glass
2015-04-07 19:10   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 61/80] dm: usb: xhci: Use a function to get xhci_ctrl Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 62/80] dm: usb: xhci: Use explicit parameters for xhci_alloc_virt_device() Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 63/80] dm: usb: xhci: Use explicit parameters for xhci_setup_addressable_virt_dev() Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 64/80] dm: usb: xhci: Factor out common init/uninit Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 65/80] dm: usb: Support driver model in XHCI Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 66/80] dm: usb: Rename the XHCI HCD to U-Boot Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 67/80] dm: usb: exynos: Adjust XHCI driver to support driver model Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 68/80] dm: usb: exynos: Use driver model for USB Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 69/80] dm: usb: exynos: Enable both USB ports on snow Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 70/80] dm: usb: exynos: Enable both EHCI and XHCI " Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:22 ` [U-Boot] [PATCH v2 71/80] dm: usb: tegra: Move to driver model for USB Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:23 ` [U-Boot] [PATCH v2 72/80] dm: usb: Add a generic descriptor struct Simon Glass
2015-04-07 19:11   ` Simon Glass
2015-03-25 18:23 ` [U-Boot] [PATCH v2 73/80] dm: usb: Tidy up pipe value decoding Simon Glass
2015-04-07 19:12   ` Simon Glass
2015-03-25 18:23 ` [U-Boot] [PATCH v2 74/80] dm: usb: sandbox: Enable USB Simon Glass
2015-04-07 19:12   ` Simon Glass
2015-03-25 18:23 ` [U-Boot] [PATCH v2 75/80] dm: test: Correct printf() output nit in 'dm uclass' Simon Glass
2015-04-07 19:12   ` Simon Glass
2015-03-25 18:23 ` [U-Boot] [PATCH v2 76/80] dm: test: Allow 'dm test' to select a particular test to run Simon Glass
2015-04-07 19:12   ` Simon Glass
2015-03-25 18:23 ` [U-Boot] [PATCH v2 77/80] dm: usb: Add tests for the USB uclass Simon Glass
2015-04-07 19:12   ` Simon Glass
2015-04-21  5:24   ` Joe Hershberger
2015-04-21 13:14     ` Simon Glass
2015-04-21 16:05       ` Joe Hershberger
2015-04-21 16:19         ` Simon Glass
2015-04-21 16:57           ` Joe Hershberger
2015-04-21 17:00             ` Simon Glass
2015-04-21 20:10               ` Joe Hershberger
2015-04-21 20:14                 ` Simon Glass
2015-03-25 18:23 ` [U-Boot] [PATCH v2 78/80] dm: usb: tegra: Drop legacy USB code Simon Glass
2015-06-11 20:19   ` Simon Glass
2015-03-25 18:23 ` [U-Boot] [PATCH v2 79/80] dm: usb: exynos: " Simon Glass
2015-05-06 21:44   ` Simon Glass
2015-03-25 18:23 ` [U-Boot] [PATCH v2 80/80] dm: usb: Add a README for driver model Simon Glass
2015-04-07  3:24   ` Jim Lin
2015-04-08  1:40     ` Simon Glass
2015-03-26 19:40 ` [U-Boot] [PATCH v2 0/80] dm: Add USB support Marek Vasut
2015-04-05 23:38   ` Simon Glass
2015-04-06 13:13     ` Marek Vasut
2015-04-06 22:38       ` Simon Glass
2015-04-07 13:52         ` Marek Vasut

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1427307788-7496-44-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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.