diff options
Diffstat (limited to 'hw/usb-musb.c')
-rw-r--r-- | hw/usb-musb.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/hw/usb-musb.c b/hw/usb-musb.c index 9efe7a6344..782cfa2282 100644 --- a/hw/usb-musb.c +++ b/hw/usb-musb.c @@ -259,7 +259,13 @@ #endif -static void musb_attach(USBPort *port, USBDevice *dev); +static void musb_attach(USBPort *port); +static void musb_detach(USBPort *port); + +static USBPortOps musb_port_ops = { + .attach = musb_attach, + .detach = musb_detach, +}; typedef struct { uint16_t faddr[2]; @@ -343,7 +349,9 @@ struct MUSBState { } usb_bus_new(&s->bus, NULL /* FIXME */); - usb_register_port(&s->bus, &s->port, s, 0, NULL, musb_attach); + usb_register_port(&s->bus, &s->port, s, 0, &musb_port_ops, + USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); + usb_port_location(&s->port, NULL, 1); return s; } @@ -460,34 +468,20 @@ static void musb_session_update(MUSBState *s, int prev_dev, int prev_sess) } /* Attach or detach a device on our only port. */ -static void musb_attach(USBPort *port, USBDevice *dev) +static void musb_attach(USBPort *port) { MUSBState *s = (MUSBState *) port->opaque; - USBDevice *curr; - - port = &s->port; - curr = port->dev; - - if (dev) { - if (curr) { - usb_attach(port, NULL); - /* TODO: signal some interrupts */ - } - - musb_intr_set(s, musb_irq_vbus_request, 1); - /* Send the attach message to device */ - usb_send_msg(dev, USB_MSG_ATTACH); - } else if (curr) { - /* Send the detach message */ - usb_send_msg(curr, USB_MSG_DETACH); - - musb_intr_set(s, musb_irq_disconnect, 1); - } + musb_intr_set(s, musb_irq_vbus_request, 1); + musb_session_update(s, 0, s->session); +} - port->dev = dev; +static void musb_detach(USBPort *port) +{ + MUSBState *s = (MUSBState *) port->opaque; - musb_session_update(s, !!curr, s->session); + musb_intr_set(s, musb_irq_disconnect, 1); + musb_session_update(s, 1, s->session); } static inline void musb_cb_tick0(void *opaque) |