static void
uhci_dump (hci_t *controller)
{
- printf ("dump:\nUSBCMD: %x\n", uhci_reg_read16 (controller, USBCMD));
- printf ("USBSTS: %x\n", uhci_reg_read16 (controller, USBSTS));
- printf ("USBINTR: %x\n", uhci_reg_read16 (controller, USBINTR));
- printf ("FRNUM: %x\n", uhci_reg_read16 (controller, FRNUM));
- printf ("FLBASEADD: %x\n", uhci_reg_read32 (controller, FLBASEADD));
- printf ("SOFMOD: %x\n", uhci_reg_read8 (controller, SOFMOD));
- printf ("PORTSC1: %x\n", uhci_reg_read16 (controller, PORTSC1));
- printf ("PORTSC2: %x\n", uhci_reg_read16 (controller, PORTSC2));
+ debug ("dump:\nUSBCMD: %x\n", uhci_reg_read16 (controller, USBCMD));
+ debug ("USBSTS: %x\n", uhci_reg_read16 (controller, USBSTS));
+ debug ("USBINTR: %x\n", uhci_reg_read16 (controller, USBINTR));
+ debug ("FRNUM: %x\n", uhci_reg_read16 (controller, FRNUM));
+ debug ("FLBASEADD: %x\n", uhci_reg_read32 (controller, FLBASEADD));
+ debug ("SOFMOD: %x\n", uhci_reg_read8 (controller, SOFMOD));
+ debug ("PORTSC1: %x\n", uhci_reg_read16 (controller, PORTSC1));
+ debug ("PORTSC2: %x\n", uhci_reg_read16 (controller, PORTSC2));
}
#endif
sprintf(td_value, "%x", td->pid);
td_type=td_value;
}
- printf ("%s packet (at %lx) to %x.%x failed\n", td_type,
+ debug ("%s packet (at %lx) to %x.%x failed\n", td_type,
virt_to_phys (td), td->dev_addr, td->endp);
- printf ("td (counter at %x) returns: ", td->counter);
- printf (" bitstuff err: %x, ", td->status_bitstuff_err);
- printf (" CRC err: %x, ", td->status_crc_err);
- printf (" NAK rcvd: %x, ", td->status_nakrcvd);
- printf (" Babble: %x, ", td->status_babble);
- printf (" Data Buffer err: %x, ", td->status_databuf_err);
- printf (" Stalled: %x, ", td->status_stalled);
- printf (" Active: %x\n", td->status_active);
+ debug ("td (counter at %x) returns: ", td->counter);
+ debug (" bitstuff err: %x, ", td->status_bitstuff_err);
+ debug (" CRC err: %x, ", td->status_crc_err);
+ debug (" NAK rcvd: %x, ", td->status_nakrcvd);
+ debug (" Babble: %x, ", td->status_babble);
+ debug (" Data Buffer err: %x, ", td->status_databuf_err);
+ debug (" Stalled: %x, ", td->status_stalled);
+ debug (" Active: %x\n", td->status_active);
if (td->status_babble)
- printf (" Babble because of %s\n",
+ debug (" Babble because of %s\n",
td->status_bitstuff_err ? "host" : "device");
if (td->status_active)
- printf (" still active - timeout?\n");
+ debug (" still active - timeout?\n");
}
static void
uhci_reg_write32 (controller, FLBASEADD,
(u32) virt_to_phys (UHCI_INST (controller)->
framelistptr));
- //printf ("framelist at %p\n",UHCI_INST(controller)->framelistptr);
+ //debug ("framelist at %p\n",UHCI_INST(controller)->framelistptr);
/* disable irqs */
uhci_reg_write16 (controller, USBINTR, 0);
/* reset framelist index */
uhci_reg_write16 (controller, FRNUM, 0);
- uhci_reg_mask16 (controller, USBCMD, ~0, 0xc0); // max packets, configure flag
+ uhci_reg_write16(controller, USBCMD,
+ uhci_reg_read16(controller, USBCMD) | 0xc0); // max packets, configure flag
uhci_start (controller);
}
hci_t *controller = new_controller ();
if (!controller)
- usb_fatal("Could not create USB controller instance.\n");
+ fatal("Could not create USB controller instance.\n");
controller->instance = malloc (sizeof (uhci_t));
if(!controller->instance)
- usb_fatal("Not enough memory creating USB controller instance.\n");
+ fatal("Not enough memory creating USB controller instance.\n");
controller->start = uhci_start;
controller->stop = uhci_stop;
UHCI_INST (controller)->framelistptr = memalign (0x1000, 1024 * sizeof (flistp_t *)); /* 4kb aligned to 4kb */
if (! UHCI_INST (controller)->framelistptr)
- usb_fatal("Not enough memory for USB frame list pointer.\n");
+ fatal("Not enough memory for USB frame list pointer.\n");
memset (UHCI_INST (controller)->framelistptr, 0,
1024 * sizeof (flistp_t));
*/
td_t *antiberserk = memalign(16, sizeof(td_t));
if (!antiberserk)
- usb_fatal("Not enough memory for chipset workaround.\n");
+ fatal("Not enough memory for chipset workaround.\n");
memset(antiberserk, 0, sizeof(td_t));
UHCI_INST (controller)->qh_prei = memalign (16, sizeof (qh_t));
! UHCI_INST (controller)->qh_intr ||
! UHCI_INST (controller)->qh_data ||
! UHCI_INST (controller)->qh_last)
- usb_fatal ("Not enough memory for USB controller queues.\n");
+ fatal("Not enough memory for USB controller queues.\n");
UHCI_INST (controller)->qh_prei->headlinkptr.ptr =
virt_to_phys (UHCI_INST (controller)->qh_intr);
detach_controller (controller);
UHCI_INST (controller)->roothub->destroy (UHCI_INST (controller)->
roothub);
- uhci_reg_mask16 (controller, USBCMD, 0, 0); // stop work
+ uhci_reg_write16(controller, USBCMD,
+ uhci_reg_read16(controller, USBCMD) & 0); // stop work
free (UHCI_INST (controller)->framelistptr);
free (UHCI_INST (controller)->qh_prei);
free (UHCI_INST (controller)->qh_intr);
static void
uhci_start (hci_t *controller)
{
- uhci_reg_mask16 (controller, USBCMD, ~0, 1); // start work on schedule
+ uhci_reg_write16(controller, USBCMD,
+ uhci_reg_read16(controller, USBCMD) | 1); // start work on schedule
}
static void
uhci_stop (hci_t *controller)
{
- uhci_reg_mask16 (controller, USBCMD, ~1, 0); // stop work on schedule
+ uhci_reg_write16(controller, USBCMD,
+ uhci_reg_read16(controller, USBCMD) & ~1); // stop work on schedule
}
#define GET_TD(x) ((void*)(((unsigned int)(x))&~0xf))
current = GET_TD (qh->elementlinkptr.ptr);
timeout = 1000000;
}
- uhci_reg_mask16 (controller, USBSTS, ~0, 0); // clear resettable registers
+ uhci_reg_write16(controller, USBSTS,
+ uhci_reg_read16(controller, USBSTS) | 0); // clear resettable registers
udelay (30);
}
return (GET_TD (qh->elementlinkptr.ptr) ==
if (td == 0) {
result = 0;
} else {
- printf ("control packet, req %x\n", req);
+ debug ("control packet, req %x\n", req);
td_dump (td);
result = 1;
}
{
int maxpsize = ep->maxpacketsize;
if (maxpsize == 0)
- usb_fatal ("MaxPacketSize == 0!!!");
+ fatal("MaxPacketSize == 0!!!");
int numpackets = (size + maxpsize - 1 + finalize) / maxpsize;
if (numpackets == 0)
return 0;
qh_t *qh = memalign(16, sizeof(qh_t));
if (!data || !tds || !qh)
- usb_fatal ("Not enough memory to create USB intr queue prerequisites.\n");
+ fatal("Not enough memory to create USB intr queue prerequisites.\n");
qh->elementlinkptr.ptr = virt_to_phys(tds);
qh->elementlinkptr.queue_head = 0;
intr_q *q = malloc(sizeof(intr_q));
if (!q)
- usb_fatal ("Not enough memory to create USB intr queue.\n");
+ fatal("Not enough memory to create USB intr queue.\n");
q->qh = qh;
q->tds = tds;
q->data = data;
{
return inb (ctrl->reg_base + reg);
}
-
-void
-uhci_reg_mask32 (hci_t *ctrl, usbreg reg, u32 andmask, u32 ormask)
-{
- uhci_reg_write32 (ctrl, reg,
- (uhci_reg_read32 (ctrl, reg) & andmask) | ormask);
-}
-
-void
-uhci_reg_mask16 (hci_t *ctrl, usbreg reg, u16 andmask, u16 ormask)
-{
- uhci_reg_write16 (ctrl, reg,
- (uhci_reg_read16 (ctrl, reg) & andmask) | ormask);
-}
-
-void
-uhci_reg_mask8 (hci_t *ctrl, usbreg reg, u8 andmask, u8 ormask)
-{
- uhci_reg_write8 (ctrl, reg,
- (uhci_reg_read8 (ctrl, reg) & andmask) | ormask);
-}