(re)enabled USB bus scan. It takes an eternity to finish, but finally

returns. Hub found, but no mouse yet.
This commit is contained in:
Markus Fröschle
2014-09-01 06:19:45 +00:00
parent 91ee9b6274
commit db95636981
5 changed files with 147 additions and 135 deletions

View File

@@ -191,8 +191,8 @@ typedef struct /* structure of address conversion */
#define PCI_COMMAND(i) (((i) >> 16) & 0xffff)
/* register 0x08 macros */
#define PCI_CLASS_CODE(i) ((swpl((i)) & 0xff000000) >> 24)
#define PCI_SUBCLASS(i) ((swpl((i)) & 0x00ff0000) >> 16)
#define PCI_CLASS_CODE(i) ((swpl((i)) & 0xffff0000) >> 16)
#define PCI_SUBCLASS(i) ((swpl((i)) & 0xffffff00) >> 8)
#define PCI_PROG_IF(i) ((swpl((i)) & 0x0000ff00) >> 8)
#define PCI_REVISION_ID(i) ((swpl((i)) & 0x000000ff))

View File

@@ -440,7 +440,7 @@ int32_t pci_find_device(uint16_t device_id, uint16_t vendor_id, int index)
uint16_t n = 0;
int32_t handle;
for (bus = 0; bus < 2; bus++)
for (bus = 0; bus < 1; bus++)
{
for (device = 10; device < 31; device++)
{

View File

@@ -273,7 +273,7 @@ void *driver_mem_alloc(uint32_t amount)
if (amount == -1L)
{
return((void *)ffit(-1L, &pmd));
return (void *) ffit(-1L, &pmd);
}
if (amount <= 0 )
@@ -296,7 +296,7 @@ void *driver_mem_alloc(uint32_t amount)
set_ipl(level);
dbg("%s: driver_mem_alloc(%d) = 0x%08X\r\n", __FUNCTION__, amount, ret);
return(ret);
return ret;
}
static int use_count = 0;
@@ -320,7 +320,8 @@ int driver_mem_init(void)
}
use_count++;
dbg("%s: driver_mem now has a use count of %d\r\n", __FUNCTION__, use_count);
return(0);
return 0;
}
void driver_mem_release(void)

View File

@@ -55,7 +55,7 @@
#include "usb.h"
#include "video.h"
#define DEBUG_SYSINIT
// #define DEBUG_SYSINIT
#ifdef DEBUG_SYSINIT
#define dbg(format, arg...) do { xprintf("DEBUG: %s(): " format, __FUNCTION__, ##arg); } while (0)
#else
@@ -711,7 +711,7 @@ void init_usb(void)
id = pci_read_config_longword(handle, PCIIDR);
pci_class = pci_read_config_longword(handle, PCIREV);
dbg("compare class code %d to %d\r\n", PCI_CLASS_CODE(pci_class), PCI_CLASS_SERIAL_USB);
dbg("compare class code 0x%x to 0x%x\r\n", PCI_CLASS_CODE(pci_class), PCI_CLASS_SERIAL_USB);
if (PCI_CLASS_CODE(pci_class) == PCI_CLASS_SERIAL_USB)
{
xprintf("serial USB found at bus=0x%x, dev=0x%x, fnc=0x%x (0x%x)\r\n",
@@ -719,14 +719,14 @@ void init_usb(void)
PCI_DEVICE_FROM_HANDLE(handle),
PCI_FUNCTION_FROM_HANDLE(handle),
handle);
dbg("compare %d against %d\r\n", PCI_SUBCLASS(pci_class), PCI_CLASS_SERIAL_USB_EHCI);
dbg("compare subclass code 0x%x against 0x%x\r\n", PCI_SUBCLASS(pci_class), PCI_CLASS_SERIAL_USB_EHCI);
if (PCI_SUBCLASS(pci_class) == PCI_CLASS_SERIAL_USB_EHCI)
{
board = ehci_usb_pci_table;
while (board->vendor)
{
dbg("compare vendor id %d against %d\r\n", board->vendor, PCI_VENDOR_ID(id));
dbg("compare device id %d against %d\r\n", board->device, PCI_DEVICE_ID(id));
dbg("compare vendor id 0x%x against 0x%x\r\n", board->vendor, PCI_VENDOR_ID(id));
dbg("compare device id 0x%x against 0x%x\r\n", board->device, PCI_DEVICE_ID(id));
if ((board->vendor == PCI_VENDOR_ID(id)) && board->device == PCI_DEVICE_ID(id))
{
dbg("match. trying to init board\r\n");
@@ -739,15 +739,15 @@ void init_usb(void)
}
}
dbg("compare %d against %d\r\n", PCI_SUBCLASS(pci_class), PCI_CLASS_SERIAL_USB_OHCI);
dbg("compare subclass code 0x%x against 0x%x\r\n", PCI_SUBCLASS(pci_class), PCI_CLASS_SERIAL_USB_OHCI);
if (PCI_SUBCLASS(pci_class) == PCI_CLASS_SERIAL_USB_OHCI)
{
board = ohci_usb_pci_table;
while (board->vendor)
{
dbg("matched. compare vendor id %d against %d\r\n", board->vendor, PCI_VENDOR_ID(id));
dbg("compare device id %d against %d\r\n", board->device, PCI_DEVICE_ID(id));
dbg("matched. compare vendor id 0x%x against 0x%x\r\n", board->vendor, PCI_VENDOR_ID(id));
dbg("compare device id 0x%x against 0x%x\r\n", board->device, PCI_DEVICE_ID(id));
if ((board->vendor == PCI_VENDOR_ID(id)) && board->device == PCI_DEVICE_ID(id))
{
if (usb_init(handle, board) >= 0)
@@ -758,6 +758,7 @@ void init_usb(void)
}
}
}
dbg("PCI device handle = %x\r\n", handle);
} while (handle >= 0);
xprintf("finished (found %d USB controller(s))\r\n", usb_found);
@@ -1239,10 +1240,8 @@ void initialize_hardware(void)
init_pci();
video_init();
/* do not try to init USB for now on the Firebee, it hangs the machine */
//#ifndef MACHINE_FIREBEE
/* initialize USB devices */
init_usb();
//#endif
#if MACHINE_FIREBEE
init_ac97();

View File

@@ -116,22 +116,26 @@ int usb_init(int32_t handle, const struct pci_device_id *ent)
void *priv;
int res = 0;
if (bus_index >= USB_MAX_BUS)
return(-1);
return -1;
dev_index[bus_index] = 0;
asynch_allowed = 1;
if (handle && (ent != NULL))
{
if (driver_mem_init())
{
usb_started = 0;
return -1; /* out of memoy */
return -1; /* out of memory */
}
if (usb_dev == NULL)
usb_dev = (struct usb_device *) driver_mem_alloc(sizeof(struct usb_device) * USB_MAX_BUS * USB_MAX_DEVICE);
if (usb_dev == NULL)
{
usb_started = 0;
return -1; /* out of memoy */
return -1; /* out of memory */
}
}
else /* restart */
@@ -149,10 +153,12 @@ int usb_init(int32_t handle, const struct pci_device_id *ent)
}
return res;
}
usb_hub_reset(bus_index);
/* init low_level USB */
debug_printf("USB: ");
switch(ent->class)
{
case PCI_CLASS_SERIAL_USB_UHCI:
@@ -169,20 +175,25 @@ int usb_init(int32_t handle, const struct pci_device_id *ent)
break;
default: res = -1; break;
}
if (!res)
{
/* if lowlevel init is OK, scan the bus for devices
* i.e. search HUBs and configure them */
if (setup_packet == NULL)
setup_packet = (void *) driver_mem_alloc(sizeof(struct devrequest));
if (setup_packet == NULL)
{
usb_started = 0;
return -1; /* out of memoy */
}
xprintf("Scanning bus for devices... ");
controller_priv[bus_index] = (struct hci *) priv;
controller_priv[bus_index]->usbnum = bus_index;
usb_scan_devices(priv);
bus_index++;
usb_started = 1;
@@ -190,7 +201,7 @@ int usb_init(int32_t handle, const struct pci_device_id *ent)
}
else
{
debug_printf("\r\nError, couldn't init Lowlevel part\r\n");
xprintf("\r\nError, couldn't init Lowlevel part\r\n");
usb_started = 0;
return -1;
}
@@ -1076,6 +1087,7 @@ void usb_scan_devices(void *priv)
{
int i;
struct usb_device *dev;
/* first make all devices unknown */
for (i = 0; i < USB_MAX_DEVICE; i++)
{
@@ -1097,17 +1109,17 @@ void usb_scan_devices(void *priv)
xprintf("%d USB Device(s) found\r\n", dev_index[bus_index]);
}
{
#ifdef _NOT_USED_ /* not implemented yet */
/* insert "driver" if possible */
#ifdef _NOT_USED_
if (drv_usb_kbd_init() < 0)
debug_printf("No USB keyboard found\r\n");
xprintf("No USB keyboard found\r\n");
else
debug_printf("USB HID keyboard driver installed\r\n");
xprintf("USB HID keyboard driver installed\r\n");
#endif /* _NOT_USED */
if (drv_usb_mouse_init() < 0)
debug_printf("No USB mouse found\r\n");
xprintf("No USB mouse found\r\n");
else
debug_printf("USB HID mouse driver installed\r\n");
xprintf("USB HID mouse driver installed\r\n");
}
xprintf("Scan end\r\n");
}