aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb
diff options
context:
space:
mode:
authorNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2013-07-24 14:26:33 +0530
committerNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2013-07-24 14:46:22 +0530
commita4e14d308fb321de4bbd7e30458b3b128db3c4db (patch)
tree90f49cabb0363192bbd501e6f39e09e92dab7792 /lib/libusb
parent7ef84987993d1327bde0aa78f666b47da2ea5898 (diff)
downloadSLOF-a4e14d308fb321de4bbd7e30458b3b128db3c4db.zip
SLOF-a4e14d308fb321de4bbd7e30458b3b128db3c4db.tar.gz
SLOF-a4e14d308fb321de4bbd7e30458b3b128db3c4db.tar.bz2
usb-core: hcd registration and query routines
* usb-core: hcd registration query hcd operations structure hcd controller init routines * usb-ohci: stub ochi controller init Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Acked-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Diffstat (limited to 'lib/libusb')
-rw-r--r--lib/libusb/usb-core.c45
-rw-r--r--lib/libusb/usb-core.h14
-rw-r--r--lib/libusb/usb-ohci.c13
-rw-r--r--lib/libusb/usb.code10
-rw-r--r--lib/libusb/usb.h5
-rw-r--r--lib/libusb/usb.in1
6 files changed, 84 insertions, 4 deletions
diff --git a/lib/libusb/usb-core.c b/lib/libusb/usb-core.c
index 7aa918a..0419710 100644
--- a/lib/libusb/usb-core.c
+++ b/lib/libusb/usb-core.c
@@ -12,9 +12,52 @@
#include "usb-core.h"
+#undef DEBUG
+//#define DEBUG
+#ifdef DEBUG
+#define dprintf(_x ...) printf(_x)
+#else
+#define dprintf(_x ...)
+#endif
+
+struct usb_hcd_ops *head;
+
void usb_hcd_register(struct usb_hcd_ops *ops)
{
+ struct usb_hcd_ops *list;
+
if (!ops)
printf("Error");
- printf("Registering %s\n", ops->name);
+ dprintf("Registering %s %d\n", ops->name, ops->usb_type);
+
+ if (head) {
+ list = head;
+ while (list->next)
+ list = list->next;
+ list->next = ops;
+ } else
+ head = ops;
+}
+
+void usb_hcd_init(void *hcidev)
+{
+ struct usb_hcd_dev *dev = hcidev;
+ struct usb_hcd_ops *list = head;
+
+ if (!dev) {
+ printf("Device Error");
+ return;
+ }
+
+ while (list) {
+ if (list->usb_type == dev->type) {
+ dprintf("usb_ops(%p) for the controller found\n", list);
+ dev->ops = list;
+ dev->ops->init(dev);
+ return;
+ }
+ list = list->next;
+ }
+
+ dprintf("usb_ops for the controller not found\n");
}
diff --git a/lib/libusb/usb-core.h b/lib/libusb/usb-core.h
index 649cb95..1a4e3ec 100644
--- a/lib/libusb/usb-core.h
+++ b/lib/libusb/usb-core.h
@@ -14,6 +14,7 @@
#define __USB_CORE_H
#include <stdio.h>
+#include "usb.h"
enum usb_hcd_type {
USB_OHCI = 1,
@@ -21,15 +22,26 @@ enum usb_hcd_type {
USB_XHCI = 3,
};
+struct usb_hcd_dev;
+
struct usb_hcd_ops {
const char *name;
- void (*init)(void);
+ void (*init)(struct usb_hcd_dev *);
void (*detect)(void);
void (*disconnect)(void);
struct usb_hcd_ops *next;
unsigned int usb_type;
};
+struct usb_hcd_dev {
+ void *base;
+ long type;
+ long num;
+ struct usb_hcd_ops *ops;
+ void *priv; /* hcd owned structure */
+ long nextaddr; /* address for devices */
+};
+
extern void usb_hcd_register(struct usb_hcd_ops *ops);
#endif
diff --git a/lib/libusb/usb-ohci.c b/lib/libusb/usb-ohci.c
index 7f65b71..5fb1356 100644
--- a/lib/libusb/usb-ohci.c
+++ b/lib/libusb/usb-ohci.c
@@ -10,12 +10,21 @@
* IBM Corporation - initial implementation
*****************************************************************************/
+#include <string.h>
#include "usb.h"
#include "usb-core.h"
-static void ohci_init(void)
-{
+#undef DEBUG
+//#define DEBUG
+#ifdef DEBUG
+#define dprintf(_x ...) printf(_x)
+#else
+#define dprintf(_x ...)
+#endif
+static void ohci_init(struct usb_hcd_dev *hcidev)
+{
+ dprintf("In ohci_init: start resetting and configuring the device %p\n", hcidev->base);
}
static void ohci_detect(void)
diff --git a/lib/libusb/usb.code b/lib/libusb/usb.code
index 73b77cb..b906aea 100644
--- a/lib/libusb/usb.code
+++ b/lib/libusb/usb.code
@@ -24,3 +24,13 @@
PRIM(USB_X2d_OHCI_X2d_REGISTER)
usb_ohci_register();
MIRP
+
+/************************************************/
+/* Initialize hcidev with the usb-core */
+/* SLOF: USB-HCD-INIT ( hcidev -- ) */
+/* LIBNEWUSB: usb_hcd_init(hcidev) */
+/************************************************/
+PRIM(USB_X2d_HCD_X2d_INIT)
+ void *hcidev = TOS.a; POP;
+ usb_hcd_init(hcidev);
+MIRP
diff --git a/lib/libusb/usb.h b/lib/libusb/usb.h
index ef944ad..8acc9b8 100644
--- a/lib/libusb/usb.h
+++ b/lib/libusb/usb.h
@@ -1,3 +1,4 @@
+
/******************************************************************************
* Copyright (c) 2006, 2012, 2013 IBM Corporation
* All rights reserved.
@@ -20,6 +21,10 @@
/* SLOF: USB-OHCI-REGISTER */
/*******************************************/
extern void usb_ohci_register(void);
+/*******************************************/
+/* SLOF: USB-HCD-INIT */
+/*******************************************/
+extern void usb_hcd_init(void *hcidev);
#endif
diff --git a/lib/libusb/usb.in b/lib/libusb/usb.in
index ad2dad1..4d6d163 100644
--- a/lib/libusb/usb.in
+++ b/lib/libusb/usb.in
@@ -14,3 +14,4 @@
*/
cod(USB-OHCI-REGISTER)
+cod(USB-HCD-INIT)