/* This function handles the control transfer out data phase  */
static int ctrlreq_out_data_phase(struct usb_device *dev, u32 len, void *buffer)
/* This function handles the control transfer out data phase  */
static int ctrlreq_out_data_phase(struct usb_device *dev, u32 len, void *buffer)
{
	u16 csr;
	u32 txlen = 0;
	u32 nextlen = 0;
	u8  maxpktsize = (1 << dev->maxpacketsize) * 8;
	u8  *txbuff = (u8 *)buffer;
	int result = 0;
	while (txlen < len) {
		nextlen = ((len-txlen) > maxpktsize) ? maxpktsize : (len-txlen);
		write_fifo(MUSB_CONTROL_EP, txlen, &txbuff[txlen]);
		csr = readw(&musbr->txcsr);
		writew(csr | MUSB_CSR0_H_DIS_PING | MUSB_CSR0_TXPKTRDY,
					&musbr->txcsr);
		result = wait_until_ep0_ready(dev, MUSB_CSR0_TXPKTRDY);
		if (result < 0)
			break;
		txlen += nextlen;
		dev->act_len = txlen;
	}
	return result;
}