36 #include <linux/kernel.h>
37 #include <linux/list.h>
40 #include <linux/device.h>
46 #define next_ep0_request(musb) next_in_request(&(musb)->endpoints[0])
58 static char *decode_ep0stage(
u8 stage)
75 static int service_tx_status_request(
91 result[0] |= musb->
g.b_hnp_enable
93 result[0] |= musb->
g.a_alt_hnp_support
95 result[0] |= musb->
g.a_hnp_support
139 result[0] = tmp ? 1 : 0;
172 service_in_request(
struct musb *musb,
const struct usb_ctrlrequest *ctrlrequest)
180 handled = service_tx_status_request(musb,
196 static void musb_g_ep0_giveback(
struct musb *musb,
struct usb_request *
req)
204 static inline void musb_try_b_hnp_enable(
struct musb *musb)
225 service_zero_data_request(
struct musb *musb,
258 ctrlrequest->
wIndex & 0x0f;
274 musb_ep = &ep->
ep_in;
304 request = next_request(musb_ep);
305 if (!musb_ep->
busy && request) {
324 switch (ctrlrequest->
wValue) {
331 if (ctrlrequest->
wIndex & 0xff)
334 switch (ctrlrequest->
wIndex >> 8) {
395 musb->
g.b_hnp_enable = 1;
396 musb_try_b_hnp_enable(musb);
401 musb->
g.a_hnp_support = 1;
406 musb->
g.a_alt_hnp_support = 1;
423 ctrlrequest->
wIndex & 0x0f;
424 struct musb_ep *musb_ep;
438 musb_ep = &ep->
ep_in;
485 static void ep0_rxstate(
struct musb *musb)
487 void __iomem *regs = musb->control_ep->regs;
525 musb_g_ep0_giveback(musb, req);
540 static void ep0_txstate(
struct musb *musb)
542 void __iomem *regs = musb->control_ep->regs;
562 request->
actual += fifo_count;
567 && !request->
zero)) {
580 musb_g_ep0_giveback(musb, request);
601 void __iomem *regs = musb->control_ep->regs;
618 musb_g_ep0_giveback(musb, &r->
request);
646 forward_to_driver(
struct musb *musb,
const struct usb_ctrlrequest *ctrlrequest)
653 spin_unlock(&musb->
lock);
655 spin_lock(&musb->
lock);
692 csr & ~MUSB_CSR0_P_SENTSTALL);
711 ERR(
"SetupEnd came in a wrong ep0stage %s\n",
772 musb_g_ep0_giveback(musb, &req->
request);
779 if (csr & MUSB_CSR0_RXPKTRDY)
799 if (csr & MUSB_CSR0_RXPKTRDY) {
804 ERR(
"SETUP packet len %d != 8 ?\n", len);
807 musb_read_setup(musb, &setup);
831 handled = service_zero_data_request(
853 handled = service_in_request(musb, &setup);
855 musb->
ackpend = MUSB_CSR0_TXPKTRDY
877 else if (handled > 0)
880 handled = forward_to_driver(musb, &setup);
921 static int musb_g_ep0_disable(
struct usb_ep *
e)
934 unsigned long lockflags;
942 regs = musb->control_ep->regs;
944 req = to_musb_request(r);
974 ep->
name, ep->
is_in ?
"IN/TX" :
"OUT/RX",
992 musb_g_ep0_giveback(ep->
musb, r);
1005 spin_unlock_irqrestore(&musb->
lock, lockflags);
1015 static int musb_g_ep0_halt(
struct usb_ep *e,
int value)
1020 unsigned long flags;
1030 regs = musb->control_ep->regs;
1071 spin_unlock_irqrestore(&musb->
lock, flags);
1076 .enable = musb_g_ep0_enable,
1077 .disable = musb_g_ep0_disable,
1080 .queue = musb_g_ep0_queue,
1081 .dequeue = musb_g_ep0_dequeue,
1082 .set_halt = musb_g_ep0_halt,