
Adding support for driver model and necessary callbacks in ohci/ehci/xhci.
Signed-off-by: Vivek Gautam gautam.vivek@samsung.com --- drivers/usb/host/ehci-hcd.c | 36 ++++++++++++++++++++++++++++-------- drivers/usb/host/ohci-hcd.c | 35 ++++++++++++++++++++++++++++------- drivers/usb/host/xhci.c | 34 +++++++++++++++++++++++++++------- 3 files changed, 83 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index f1fb190..6320b98 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -930,13 +930,13 @@ unknown: return -1; }
-int usb_lowlevel_stop(int index) +int ehci_lowlevel_stop(int index) { ehci_shutdown(&ehcic[index]); return ehci_hcd_stop(index); }
-int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) +int ehci_lowlevel_init(int index, enum usb_init_type init, void **controller) { uint32_t reg; uint32_t cmd; @@ -1065,8 +1065,8 @@ done: }
int -submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - int length) +ehci_submit_bulk_msg(struct usb_device *dev, unsigned long pipe, + void *buffer, int length) {
if (usb_pipetype(pipe) != PIPE_BULK) { @@ -1077,8 +1077,8 @@ submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, }
int -submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - int length, struct devrequest *setup) +ehci_submit_control_msg(struct usb_device *dev, unsigned long pipe, + void *buffer, int length, struct devrequest *setup) { struct ehci_ctrl *ctrl = dev->controller;
@@ -1387,8 +1387,8 @@ out: }
int -submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - int length, int interval) +ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe, + void *buffer, int length, int interval) { void *backbuffer; struct int_queue *queue; @@ -1423,3 +1423,23 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, /* everything worked out fine */ return result; } + +static const struct udevice_id ehci_hcd_id[] = { + { "ehci-hcd", 0 }, + { }, +}; + +static const struct usb_ops ehci_ops = { + .lowlevel_init = ehci_lowlevel_init, + .lowlevel_stop = ehci_lowlevel_stop, + .submit_ctrl_msg = ehci_submit_control_msg, + .submit_bulk_msg = ehci_submit_bulk_msg, + .submit_int_msg = ehci_submit_int_msg, +}; + +U_BOOT_DRIVER(ehci_hcd_drv) = { + .name = "ehci_hcd_drv", + .of_match = ehci_hcd_id, + .id = UCLASS_USB, + .ops = &ehci_ops, +}; diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 97a7ede..3bfc295 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1465,15 +1465,15 @@ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer, }
/* submit routines called from usb.c */ -int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - int transfer_len) +int ohci_submit_bulk_msg(struct usb_device *dev, unsigned long pipe, + void *buffer, int transfer_len) { info("submit_bulk_msg"); return submit_common_msg(dev, pipe, buffer, transfer_len, NULL, 0); }
-int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - int transfer_len, struct devrequest *setup) +int ohci_submit_control_msg(struct usb_device *dev, unsigned long pipe, + void *buffer, int transfer_len, struct devrequest *setup) { int maxsize = usb_maxpacket(dev, pipe);
@@ -1499,7 +1499,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, return submit_common_msg(dev, pipe, buffer, transfer_len, setup, 0); }
-int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, +int ohci_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval) { info("submit_int_msg"); @@ -1748,7 +1748,8 @@ static void hc_release_ohci(ohci_t *ohci) */ static char ohci_inited = 0;
-int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) +int ohci_lowlevel_init(int index, enum usb_init_type init, + void **controller) { #ifdef CONFIG_PCI_OHCI pci_dev_t pdev; @@ -1854,7 +1855,7 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) return 0; }
-int usb_lowlevel_stop(int index) +int ohci_lowlevel_stop(int index) { /* this gets called really early - before the controller has */ /* even been initialized! */ @@ -1880,3 +1881,23 @@ int usb_lowlevel_stop(int index) ohci_inited = 0; return 0; } + +static const struct udevice_id ohci_hcd_id[] = { + { "ohci-hcd", 0 }, + { }, +}; + +static const struct usb_ops ohci_ops = { + .lowlevel_init = ohci_lowlevel_init + .lowlevel_stop = ohci_lowlevel_stop + .submit_ctrl_msg = ohci_submit_control_msg + .submit_bulk_msg = ohci_submit_bulk_msg + .submit_int_msg = ohci_submit_int_msg +}; + +U_BOOT_DRIVER(ohci_hcd_drv) = { + .name = "ohci_hcd_drv", + .of_match = ohci_hcd_id, + .id = UCLASS_USB, + .ops = &ohci_ops, +}; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 87f2972..b3c3aab 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -859,7 +859,7 @@ unknown: * @return 0 */ int -submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, +xhci_submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, int length, int interval) { /* @@ -879,8 +879,8 @@ submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, * @return returns 0 if successful else -1 on failure */ int -submit_bulk_msg(struct usb_device *udev, unsigned long pipe, void *buffer, - int length) +xhci_submit_bulk_msg(struct usb_device *udev, unsigned long pipe, + void *buffer, int length) { if (usb_pipetype(pipe) != PIPE_BULK) { printf("non-bulk pipe (type=%lu)", usb_pipetype(pipe)); @@ -901,8 +901,8 @@ submit_bulk_msg(struct usb_device *udev, unsigned long pipe, void *buffer, * @return returns 0 if successful else -1 on failure */ int -submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, - int length, struct devrequest *setup) +xhci_submit_control_msg(struct usb_device *udev, unsigned long pipe, + void *buffer, int length, struct devrequest *setup) { struct xhci_ctrl *ctrl = udev->controller; int ret = 0; @@ -936,7 +936,7 @@ submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, * @param index index to the host controller data structure * @return pointer to the intialised controller */ -int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) +int xhci_lowlevel_init(int index, enum usb_init_type init, void **controller) { uint32_t val; uint32_t val2; @@ -1009,7 +1009,7 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) * @param index index to the host controller data structure * @return none */ -int usb_lowlevel_stop(int index) +int xhci_lowlevel_stop(int index) { struct xhci_ctrl *ctrl = (xhcic + index); u32 temp; @@ -1028,3 +1028,23 @@ int usb_lowlevel_stop(int index)
return 0; } + +static const struct udevice_id xhci_hcd_id[] = { + { "xhci-hcd", 0 }, + { }, +}; + +static const struct usb_ops xhci_ops = { + .lowlevel_init = xhci_lowlevel_init, + .lowlevel_stop = xhci_lowlevel_stop, + .submit_ctrl_msg = xhci_submit_control_msg, + .submit_bulk_msg = xhci_submit_bulk_msg, + .submit_int_msg = xhci_submit_int_msg, +}; + +U_BOOT_DRIVER(xhci_hcd_drv) = { + .name = "xhci_hcd_drv", + .of_match = xhci_hcd_id, + .id = UCLASS_USB, + .ops = &xhci_ops, +};