Lines Matching refs:hsotg

211 static void s3c_hsotg_dump(struct s3c_hsotg *hsotg);
232 static inline bool using_dma(struct s3c_hsotg *hsotg) in using_dma() argument
242 static void s3c_hsotg_en_gsint(struct s3c_hsotg *hsotg, u32 ints) in s3c_hsotg_en_gsint() argument
244 u32 gsintmsk = readl(hsotg->regs + S3C_GINTMSK); in s3c_hsotg_en_gsint()
250 dev_dbg(hsotg->dev, "gsintmsk now 0x%08x\n", new_gsintmsk); in s3c_hsotg_en_gsint()
251 writel(new_gsintmsk, hsotg->regs + S3C_GINTMSK); in s3c_hsotg_en_gsint()
260 static void s3c_hsotg_disable_gsint(struct s3c_hsotg *hsotg, u32 ints) in s3c_hsotg_disable_gsint() argument
262 u32 gsintmsk = readl(hsotg->regs + S3C_GINTMSK); in s3c_hsotg_disable_gsint()
268 writel(new_gsintmsk, hsotg->regs + S3C_GINTMSK); in s3c_hsotg_disable_gsint()
281 static void s3c_hsotg_ctrl_epint(struct s3c_hsotg *hsotg, in s3c_hsotg_ctrl_epint() argument
293 daint = readl(hsotg->regs + S3C_DAINTMSK); in s3c_hsotg_ctrl_epint()
298 writel(daint, hsotg->regs + S3C_DAINTMSK); in s3c_hsotg_ctrl_epint()
306 static void s3c_hsotg_init_fifo(struct s3c_hsotg *hsotg) in s3c_hsotg_init_fifo() argument
323 writel(2048, hsotg->regs + S3C_GRXFSIZ); in s3c_hsotg_init_fifo()
326 hsotg->regs + S3C_GNPTXFSIZ); in s3c_hsotg_init_fifo()
345 writel(val, hsotg->regs + S3C_DPTXFSIZn(ep)); in s3c_hsotg_init_fifo()
352 S3C_GRSTCTL_RxFFlsh, hsotg->regs + S3C_GRSTCTL); in s3c_hsotg_init_fifo()
357 val = readl(hsotg->regs + S3C_GRSTCTL); in s3c_hsotg_init_fifo()
363 dev_err(hsotg->dev, in s3c_hsotg_init_fifo()
371 dev_dbg(hsotg->dev, "FIFOs reset, timeout at %d\n", timeout); in s3c_hsotg_init_fifo()
416 static void s3c_hsotg_unmap_dma(struct s3c_hsotg *hsotg, in s3c_hsotg_unmap_dma() argument
432 dma_unmap_single(hsotg->dev, req->dma, req->length, dir); in s3c_hsotg_unmap_dma()
437 dma_sync_single_for_cpu(hsotg->dev, req->dma, req->length, dir); in s3c_hsotg_unmap_dma()
457 static int s3c_hsotg_write_fifo(struct s3c_hsotg *hsotg, in s3c_hsotg_write_fifo() argument
462 u32 gnptxsts = readl(hsotg->regs + S3C_GNPTXSTS); in s3c_hsotg_write_fifo()
475 if (periodic && !hsotg->dedicated_fifos) { in s3c_hsotg_write_fifo()
476 u32 epsize = readl(hsotg->regs + S3C_DIEPTSIZ(hs_ep->index)); in s3c_hsotg_write_fifo()
489 s3c_hsotg_en_gsint(hsotg, S3C_GINTSTS_PTxFEmp); in s3c_hsotg_write_fifo()
493 dev_dbg(hsotg->dev, "%s: left=%d, load=%d, fifo=%d, size %d\n", in s3c_hsotg_write_fifo()
502 dev_dbg(hsotg->dev, "%s: => can_write1=%d\n", in s3c_hsotg_write_fifo()
506 dev_dbg(hsotg->dev, "%s: => can_write2=%d\n", in s3c_hsotg_write_fifo()
510 s3c_hsotg_en_gsint(hsotg, S3C_GINTSTS_PTxFEmp); in s3c_hsotg_write_fifo()
513 } else if (hsotg->dedicated_fifos && hs_ep->index != 0) { in s3c_hsotg_write_fifo()
514 can_write = readl(hsotg->regs + S3C_DTXFSTS(hs_ep->index)); in s3c_hsotg_write_fifo()
520 dev_dbg(hsotg->dev, in s3c_hsotg_write_fifo()
524 s3c_hsotg_en_gsint(hsotg, S3C_GINTSTS_NPTxFEmp); in s3c_hsotg_write_fifo()
532 dev_dbg(hsotg->dev, "%s: GNPTXSTS=%08x, can=%d, to=%d, mps %d\n", in s3c_hsotg_write_fifo()
548 s3c_hsotg_en_gsint(hsotg, in s3c_hsotg_write_fifo()
573 s3c_hsotg_en_gsint(hsotg, in s3c_hsotg_write_fifo()
578 dev_dbg(hsotg->dev, "write %d/%d, can_write %d, done %d\n", in s3c_hsotg_write_fifo()
593 writesl(hsotg->regs + S3C_EPFIFO(hs_ep->index), data, to_write); in s3c_hsotg_write_fifo()
646 static void s3c_hsotg_start_req(struct s3c_hsotg *hsotg, in s3c_hsotg_start_req() argument
664 dev_err(hsotg->dev, "%s: active request\n", __func__); in s3c_hsotg_start_req()
668 dev_err(hsotg->dev, in s3c_hsotg_start_req()
678 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x, ep %d, dir %s\n", in s3c_hsotg_start_req()
679 __func__, readl(hsotg->regs + epctrl_reg), index, in s3c_hsotg_start_req()
685 dev_dbg(hsotg->dev, in s3c_hsotg_start_req()
694 dev_dbg(hsotg->dev, "%s: length %d, max-req %d, r %d\n", in s3c_hsotg_start_req()
725 dev_dbg(hsotg->dev, "%s: %d@%d/%d, 0x%08x => 0x%08x\n", in s3c_hsotg_start_req()
732 writel(epsize, hsotg->regs + epsize_reg); in s3c_hsotg_start_req()
734 ctrl = readl(hsotg->regs + epctrl_reg); in s3c_hsotg_start_req()
737 dev_warn(hsotg->dev, "%s: ep%d is stalled\n", __func__, index); in s3c_hsotg_start_req()
746 if (using_dma(hsotg)) { in s3c_hsotg_start_req()
753 writel(ureq->dma, hsotg->regs + dma_reg); in s3c_hsotg_start_req()
755 dev_dbg(hsotg->dev, "%s: 0x%08x => 0x%08x\n", in s3c_hsotg_start_req()
763 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x\n", __func__, ctrl); in s3c_hsotg_start_req()
764 writel(ctrl, hsotg->regs + epctrl_reg); in s3c_hsotg_start_req()
772 if (dir_in && !using_dma(hsotg)) { in s3c_hsotg_start_req()
776 s3c_hsotg_write_fifo(hsotg, hs_ep, hs_req); in s3c_hsotg_start_req()
783 hsotg->regs + S3C_DIEPINT(index)); in s3c_hsotg_start_req()
789 if (!(readl(hsotg->regs + epctrl_reg) & S3C_DxEPCTL_EPEna)) in s3c_hsotg_start_req()
790 dev_warn(hsotg->dev, in s3c_hsotg_start_req()
792 index, readl(hsotg->regs + epctrl_reg)); in s3c_hsotg_start_req()
794 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x\n", in s3c_hsotg_start_req()
795 __func__, readl(hsotg->regs + epctrl_reg)); in s3c_hsotg_start_req()
810 static int s3c_hsotg_map_dma(struct s3c_hsotg *hsotg, in s3c_hsotg_map_dma() argument
826 dma = dma_map_single(hsotg->dev, req->buf, req->length, dir); in s3c_hsotg_map_dma()
828 if (unlikely(dma_mapping_error(hsotg->dev, dma))) in s3c_hsotg_map_dma()
832 dev_err(hsotg->dev, "%s: unaligned dma buffer\n", in s3c_hsotg_map_dma()
835 dma_unmap_single(hsotg->dev, dma, req->length, dir); in s3c_hsotg_map_dma()
842 dma_sync_single_for_cpu(hsotg->dev, req->dma, req->length, dir); in s3c_hsotg_map_dma()
849 dev_err(hsotg->dev, "%s: failed to map buffer %p, %d bytes\n", in s3c_hsotg_map_dma()
913 struct s3c_hsotg *hsotg = hs_ep->parent; in s3c_hsotg_complete_oursetup() local
915 dev_dbg(hsotg->dev, "%s: ep %p, req %p\n", __func__, ep, req); in s3c_hsotg_complete_oursetup()
928 static struct s3c_hsotg_ep *ep_from_windex(struct s3c_hsotg *hsotg, in ep_from_windex() argument
931 struct s3c_hsotg_ep *ep = &hsotg->eps[windex & 0x7F]; in ep_from_windex()
957 static int s3c_hsotg_send_reply(struct s3c_hsotg *hsotg, in s3c_hsotg_send_reply() argument
965 dev_dbg(hsotg->dev, "%s: buff %p, len %d\n", __func__, buff, length); in s3c_hsotg_send_reply()
968 hsotg->ep0_reply = req; in s3c_hsotg_send_reply()
970 dev_warn(hsotg->dev, "%s: cannot alloc req\n", __func__); in s3c_hsotg_send_reply()
974 req->buf = hsotg->ep0_buff; in s3c_hsotg_send_reply()
986 dev_warn(hsotg->dev, "%s: cannot queue req\n", __func__); in s3c_hsotg_send_reply()
998 static int s3c_hsotg_process_req_status(struct s3c_hsotg *hsotg, in s3c_hsotg_process_req_status() argument
1001 struct s3c_hsotg_ep *ep0 = &hsotg->eps[0]; in s3c_hsotg_process_req_status()
1006 dev_dbg(hsotg->dev, "%s: USB_REQ_GET_STATUS\n", __func__); in s3c_hsotg_process_req_status()
1009 dev_warn(hsotg->dev, "%s: direction out?\n", __func__); in s3c_hsotg_process_req_status()
1025 ep = ep_from_windex(hsotg, le16_to_cpu(ctrl->wIndex)); in s3c_hsotg_process_req_status()
1039 ret = s3c_hsotg_send_reply(hsotg, ep0, &reply, 2); in s3c_hsotg_process_req_status()
1041 dev_err(hsotg->dev, "%s: failed to send reply\n", __func__); in s3c_hsotg_process_req_status()
1055 static int s3c_hsotg_process_req_feature(struct s3c_hsotg *hsotg, in s3c_hsotg_process_req_feature() argument
1061 dev_dbg(hsotg->dev, "%s: %s_FEATURE\n", in s3c_hsotg_process_req_feature()
1065 ep = ep_from_windex(hsotg, le16_to_cpu(ctrl->wIndex)); in s3c_hsotg_process_req_feature()
1067 dev_dbg(hsotg->dev, "%s: no endpoint for 0x%04x\n", in s3c_hsotg_process_req_feature()
1095 static void s3c_hsotg_process_control(struct s3c_hsotg *hsotg, in s3c_hsotg_process_control() argument
1098 struct s3c_hsotg_ep *ep0 = &hsotg->eps[0]; in s3c_hsotg_process_control()
1104 dev_dbg(hsotg->dev, "ctrl Req=%02x, Type=%02x, V=%04x, L=%04x\n", in s3c_hsotg_process_control()
1112 dev_dbg(hsotg->dev, "ctrl: dir_in=%d\n", ep0->dir_in); in s3c_hsotg_process_control()
1122 dcfg = readl(hsotg->regs + S3C_DCFG); in s3c_hsotg_process_control()
1125 writel(dcfg, hsotg->regs + S3C_DCFG); in s3c_hsotg_process_control()
1127 dev_info(hsotg->dev, "new address %d\n", ctrl->wValue); in s3c_hsotg_process_control()
1129 ret = s3c_hsotg_send_reply(hsotg, ep0, NULL, 0); in s3c_hsotg_process_control()
1133 ret = s3c_hsotg_process_req_status(hsotg, ctrl); in s3c_hsotg_process_control()
1138 ret = s3c_hsotg_process_req_feature(hsotg, ctrl); in s3c_hsotg_process_control()
1145 if (ret == 0 && hsotg->driver) { in s3c_hsotg_process_control()
1146 ret = hsotg->driver->setup(&hsotg->gadget, ctrl); in s3c_hsotg_process_control()
1148 dev_dbg(hsotg->dev, "driver->setup() ret %d\n", ret); in s3c_hsotg_process_control()
1155 ret = s3c_hsotg_send_reply(hsotg, ep0, NULL, 0); in s3c_hsotg_process_control()
1167 dev_dbg(hsotg->dev, "ep0 stall (dir=%d)\n", ep0->dir_in); in s3c_hsotg_process_control()
1173 ctrl = readl(hsotg->regs + reg); in s3c_hsotg_process_control()
1176 writel(ctrl, hsotg->regs + reg); in s3c_hsotg_process_control()
1178 dev_dbg(hsotg->dev, in s3c_hsotg_process_control()
1180 ctrl, reg, readl(hsotg->regs + reg)); in s3c_hsotg_process_control()
1187 static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg);
1201 struct s3c_hsotg *hsotg = hs_ep->parent; in s3c_hsotg_complete_setup() local
1204 dev_dbg(hsotg->dev, "%s: failed %d\n", __func__, req->status); in s3c_hsotg_complete_setup()
1209 s3c_hsotg_enqueue_setup(hsotg); in s3c_hsotg_complete_setup()
1211 s3c_hsotg_process_control(hsotg, req->buf); in s3c_hsotg_complete_setup()
1221 static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg) in s3c_hsotg_enqueue_setup() argument
1223 struct usb_request *req = hsotg->ctrl_req; in s3c_hsotg_enqueue_setup()
1227 dev_dbg(hsotg->dev, "%s: queueing setup request\n", __func__); in s3c_hsotg_enqueue_setup()
1231 req->buf = hsotg->ctrl_buff; in s3c_hsotg_enqueue_setup()
1235 dev_dbg(hsotg->dev, "%s already queued???\n", __func__); in s3c_hsotg_enqueue_setup()
1239 hsotg->eps[0].dir_in = 0; in s3c_hsotg_enqueue_setup()
1241 ret = s3c_hsotg_ep_queue(&hsotg->eps[0].ep, req, GFP_ATOMIC); in s3c_hsotg_enqueue_setup()
1243 dev_err(hsotg->dev, "%s: failed queue (%d)\n", __func__, ret); in s3c_hsotg_enqueue_setup()
1276 static void s3c_hsotg_complete_request(struct s3c_hsotg *hsotg, in s3c_hsotg_complete_request() argument
1284 dev_dbg(hsotg->dev, "%s: nothing to complete?\n", __func__); in s3c_hsotg_complete_request()
1288 dev_dbg(hsotg->dev, "complete: ep %p %s, req %p, %d => %p\n", in s3c_hsotg_complete_request()
1300 if (using_dma(hsotg)) in s3c_hsotg_complete_request()
1301 s3c_hsotg_unmap_dma(hsotg, hs_ep, hs_req); in s3c_hsotg_complete_request()
1320 s3c_hsotg_start_req(hsotg, hs_ep, hs_req, false); in s3c_hsotg_complete_request()
1335 static void s3c_hsotg_complete_request_lock(struct s3c_hsotg *hsotg, in s3c_hsotg_complete_request_lock() argument
1343 s3c_hsotg_complete_request(hsotg, hs_ep, hs_req, result); in s3c_hsotg_complete_request_lock()
1357 static void s3c_hsotg_rx_data(struct s3c_hsotg *hsotg, int ep_idx, int size) in s3c_hsotg_rx_data() argument
1359 struct s3c_hsotg_ep *hs_ep = &hsotg->eps[ep_idx]; in s3c_hsotg_rx_data()
1361 void __iomem *fifo = hsotg->regs + S3C_EPFIFO(ep_idx); in s3c_hsotg_rx_data()
1367 u32 epctl = readl(hsotg->regs + S3C_DOEPCTL(ep_idx)); in s3c_hsotg_rx_data()
1370 dev_warn(hsotg->dev, in s3c_hsotg_rx_data()
1387 dev_dbg(hsotg->dev, "%s: read %d/%d, done %d/%d\n", in s3c_hsotg_rx_data()
1422 static void s3c_hsotg_send_zlp(struct s3c_hsotg *hsotg, in s3c_hsotg_send_zlp() argument
1428 dev_warn(hsotg->dev, "%s: no request?\n", __func__); in s3c_hsotg_send_zlp()
1433 hsotg->eps[0].sent_zlp = 1; in s3c_hsotg_send_zlp()
1434 s3c_hsotg_enqueue_setup(hsotg); in s3c_hsotg_send_zlp()
1438 hsotg->eps[0].dir_in = 1; in s3c_hsotg_send_zlp()
1439 hsotg->eps[0].sent_zlp = 1; in s3c_hsotg_send_zlp()
1441 dev_dbg(hsotg->dev, "sending zero-length packet\n"); in s3c_hsotg_send_zlp()
1445 S3C_DxEPTSIZ_XferSize(0), hsotg->regs + S3C_DIEPTSIZ(0)); in s3c_hsotg_send_zlp()
1447 ctrl = readl(hsotg->regs + S3C_DIEPCTL0); in s3c_hsotg_send_zlp()
1451 writel(ctrl, hsotg->regs + S3C_DIEPCTL0); in s3c_hsotg_send_zlp()
1464 static void s3c_hsotg_handle_outdone(struct s3c_hsotg *hsotg, in s3c_hsotg_handle_outdone() argument
1467 u32 epsize = readl(hsotg->regs + S3C_DOEPTSIZ(epnum)); in s3c_hsotg_handle_outdone()
1468 struct s3c_hsotg_ep *hs_ep = &hsotg->eps[epnum]; in s3c_hsotg_handle_outdone()
1475 dev_dbg(hsotg->dev, "%s: no request active\n", __func__); in s3c_hsotg_handle_outdone()
1479 if (using_dma(hsotg)) { in s3c_hsotg_handle_outdone()
1498 s3c_hsotg_start_req(hsotg, hs_ep, hs_req, true); in s3c_hsotg_handle_outdone()
1503 dev_dbg(hsotg->dev, "%s: got %d/%d (short not ok) => error\n", in s3c_hsotg_handle_outdone()
1512 s3c_hsotg_send_zlp(hsotg, hs_req); in s3c_hsotg_handle_outdone()
1515 s3c_hsotg_complete_request_lock(hsotg, hs_ep, hs_req, result); in s3c_hsotg_handle_outdone()
1524 static u32 s3c_hsotg_read_frameno(struct s3c_hsotg *hsotg) in s3c_hsotg_read_frameno() argument
1528 dsts = readl(hsotg->regs + S3C_DSTS); in s3c_hsotg_read_frameno()
1551 static void s3c_hsotg_handle_rx(struct s3c_hsotg *hsotg) in s3c_hsotg_handle_rx() argument
1553 u32 grxstsr = readl(hsotg->regs + S3C_GRXSTSP); in s3c_hsotg_handle_rx()
1556 WARN_ON(using_dma(hsotg)); in s3c_hsotg_handle_rx()
1565 dev_dbg(hsotg->dev, "%s: GRXSTSP=0x%08x (%d@%d)\n", in s3c_hsotg_handle_rx()
1572 dev_dbg(hsotg->dev, "GlobalOutNAK\n"); in s3c_hsotg_handle_rx()
1576 dev_dbg(hsotg->dev, "OutDone (Frame=0x%08x)\n", in s3c_hsotg_handle_rx()
1577 s3c_hsotg_read_frameno(hsotg)); in s3c_hsotg_handle_rx()
1579 if (!using_dma(hsotg)) in s3c_hsotg_handle_rx()
1580 s3c_hsotg_handle_outdone(hsotg, epnum, false); in s3c_hsotg_handle_rx()
1584 dev_dbg(hsotg->dev, in s3c_hsotg_handle_rx()
1586 s3c_hsotg_read_frameno(hsotg), in s3c_hsotg_handle_rx()
1587 readl(hsotg->regs + S3C_DOEPCTL(0))); in s3c_hsotg_handle_rx()
1589 s3c_hsotg_handle_outdone(hsotg, epnum, true); in s3c_hsotg_handle_rx()
1593 s3c_hsotg_rx_data(hsotg, epnum, size); in s3c_hsotg_handle_rx()
1597 dev_dbg(hsotg->dev, in s3c_hsotg_handle_rx()
1599 s3c_hsotg_read_frameno(hsotg), in s3c_hsotg_handle_rx()
1600 readl(hsotg->regs + S3C_DOEPCTL(0))); in s3c_hsotg_handle_rx()
1602 s3c_hsotg_rx_data(hsotg, epnum, size); in s3c_hsotg_handle_rx()
1606 dev_warn(hsotg->dev, "%s: unknown status %08x\n", in s3c_hsotg_handle_rx()
1609 s3c_hsotg_dump(hsotg); in s3c_hsotg_handle_rx()
1645 static void s3c_hsotg_set_ep_maxpacket(struct s3c_hsotg *hsotg, in s3c_hsotg_set_ep_maxpacket() argument
1648 struct s3c_hsotg_ep *hs_ep = &hsotg->eps[ep]; in s3c_hsotg_set_ep_maxpacket()
1649 void __iomem *regs = hsotg->regs; in s3c_hsotg_set_ep_maxpacket()
1683 dev_err(hsotg->dev, "ep%d: bad mps of %d\n", ep, mps); in s3c_hsotg_set_ep_maxpacket()
1695 static int s3c_hsotg_trytx(struct s3c_hsotg *hsotg, in s3c_hsotg_trytx() argument
1704 dev_dbg(hsotg->dev, "trying to write more for ep%d\n", in s3c_hsotg_trytx()
1706 return s3c_hsotg_write_fifo(hsotg, hs_ep, hs_req); in s3c_hsotg_trytx()
1720 static void s3c_hsotg_complete_in(struct s3c_hsotg *hsotg, in s3c_hsotg_complete_in() argument
1724 u32 epsize = readl(hsotg->regs + S3C_DIEPTSIZ(hs_ep->index)); in s3c_hsotg_complete_in()
1728 dev_dbg(hsotg->dev, "XferCompl but no req\n"); in s3c_hsotg_complete_in()
1747 dev_dbg(hsotg->dev, "%s: adjusting size done %d => %d\n", in s3c_hsotg_complete_in()
1756 dev_dbg(hsotg->dev, "%s trying more for req...\n", __func__); in s3c_hsotg_complete_in()
1757 s3c_hsotg_start_req(hsotg, hs_ep, hs_req, true); in s3c_hsotg_complete_in()
1759 s3c_hsotg_complete_request_lock(hsotg, hs_ep, hs_req, 0); in s3c_hsotg_complete_in()
1770 static void s3c_hsotg_epint(struct s3c_hsotg *hsotg, unsigned int idx, in s3c_hsotg_epint() argument
1773 struct s3c_hsotg_ep *hs_ep = &hsotg->eps[idx]; in s3c_hsotg_epint()
1780 ints = readl(hsotg->regs + epint_reg); in s3c_hsotg_epint()
1782 dev_dbg(hsotg->dev, "%s: ep%d(%s) DxEPINT=0x%08x\n", in s3c_hsotg_epint()
1786 dev_dbg(hsotg->dev, in s3c_hsotg_epint()
1788 __func__, readl(hsotg->regs + epctl_reg), in s3c_hsotg_epint()
1789 readl(hsotg->regs + epsiz_reg)); in s3c_hsotg_epint()
1794 s3c_hsotg_complete_in(hsotg, hs_ep); in s3c_hsotg_epint()
1797 s3c_hsotg_enqueue_setup(hsotg); in s3c_hsotg_epint()
1798 } else if (using_dma(hsotg)) { in s3c_hsotg_epint()
1802 s3c_hsotg_handle_outdone(hsotg, idx, false); in s3c_hsotg_epint()
1809 dev_dbg(hsotg->dev, "%s: EPDisbld\n", __func__); in s3c_hsotg_epint()
1814 dev_dbg(hsotg->dev, "%s: AHBErr\n", __func__); in s3c_hsotg_epint()
1819 dev_dbg(hsotg->dev, "%s: Setup/Timeout\n", __func__); in s3c_hsotg_epint()
1821 if (using_dma(hsotg) && idx == 0) { in s3c_hsotg_epint()
1830 s3c_hsotg_handle_outdone(hsotg, 0, true); in s3c_hsotg_epint()
1837 dev_dbg(hsotg->dev, "%s: B2BSetup/INEPNakEff\n", __func__); in s3c_hsotg_epint()
1845 dev_dbg(hsotg->dev, "%s: ep%d: INTknTXFEmpMsk\n", in s3c_hsotg_epint()
1852 dev_warn(hsotg->dev, "%s: ep%d: INTknEP\n", in s3c_hsotg_epint()
1858 if (hsotg->dedicated_fifos && in s3c_hsotg_epint()
1860 dev_dbg(hsotg->dev, "%s: ep%d: TxFIFOEmpty\n", in s3c_hsotg_epint()
1862 s3c_hsotg_trytx(hsotg, hs_ep); in s3c_hsotg_epint()
1867 writel(clear, hsotg->regs + epint_reg); in s3c_hsotg_epint()
1877 static void s3c_hsotg_irq_enumdone(struct s3c_hsotg *hsotg) in s3c_hsotg_irq_enumdone() argument
1879 u32 dsts = readl(hsotg->regs + S3C_DSTS); in s3c_hsotg_irq_enumdone()
1886 dev_dbg(hsotg->dev, "EnumDone (DSTS=0x%08x)\n", dsts); in s3c_hsotg_irq_enumdone()
1896 hsotg->gadget.speed = USB_SPEED_FULL; in s3c_hsotg_irq_enumdone()
1897 dev_info(hsotg->dev, "new device is full-speed\n"); in s3c_hsotg_irq_enumdone()
1904 dev_info(hsotg->dev, "new device is high-speed\n"); in s3c_hsotg_irq_enumdone()
1905 hsotg->gadget.speed = USB_SPEED_HIGH; in s3c_hsotg_irq_enumdone()
1912 hsotg->gadget.speed = USB_SPEED_LOW; in s3c_hsotg_irq_enumdone()
1913 dev_info(hsotg->dev, "new device is low-speed\n"); in s3c_hsotg_irq_enumdone()
1927 s3c_hsotg_set_ep_maxpacket(hsotg, 0, ep0_mps); in s3c_hsotg_irq_enumdone()
1929 s3c_hsotg_set_ep_maxpacket(hsotg, i, ep_mps); in s3c_hsotg_irq_enumdone()
1934 s3c_hsotg_enqueue_setup(hsotg); in s3c_hsotg_irq_enumdone()
1936 dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", in s3c_hsotg_irq_enumdone()
1937 readl(hsotg->regs + S3C_DIEPCTL0), in s3c_hsotg_irq_enumdone()
1938 readl(hsotg->regs + S3C_DOEPCTL0)); in s3c_hsotg_irq_enumdone()
1951 static void kill_all_requests(struct s3c_hsotg *hsotg, in kill_all_requests() argument
1967 s3c_hsotg_complete_request(hsotg, ep, req, in kill_all_requests()
1987 static void s3c_hsotg_disconnect_irq(struct s3c_hsotg *hsotg) in s3c_hsotg_disconnect_irq() argument
1992 kill_all_requests(hsotg, &hsotg->eps[ep], -ESHUTDOWN, true); in s3c_hsotg_disconnect_irq()
1994 call_gadget(hsotg, disconnect); in s3c_hsotg_disconnect_irq()
2002 static void s3c_hsotg_irq_fifoempty(struct s3c_hsotg *hsotg, bool periodic) in s3c_hsotg_irq_fifoempty() argument
2010 ep = &hsotg->eps[epno]; in s3c_hsotg_irq_fifoempty()
2019 ret = s3c_hsotg_trytx(hsotg, ep); in s3c_hsotg_irq_fifoempty()
2039 struct s3c_hsotg *hsotg = pw; in s3c_hsotg_irq() local
2045 gintsts = readl(hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2046 gintmsk = readl(hsotg->regs + S3C_GINTMSK); in s3c_hsotg_irq()
2048 dev_dbg(hsotg->dev, "%s: %08x %08x (%08x) retry %d\n", in s3c_hsotg_irq()
2054 u32 otgint = readl(hsotg->regs + S3C_GOTGINT); in s3c_hsotg_irq()
2056 dev_info(hsotg->dev, "OTGInt: %08x\n", otgint); in s3c_hsotg_irq()
2058 writel(otgint, hsotg->regs + S3C_GOTGINT); in s3c_hsotg_irq()
2059 writel(S3C_GINTSTS_OTGInt, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2063 dev_dbg(hsotg->dev, "%s: DisconnInt\n", __func__); in s3c_hsotg_irq()
2064 writel(S3C_GINTSTS_DisconnInt, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2066 s3c_hsotg_disconnect_irq(hsotg); in s3c_hsotg_irq()
2070 dev_dbg(hsotg->dev, "%s: SessReqInt\n", __func__); in s3c_hsotg_irq()
2071 writel(S3C_GINTSTS_SessReqInt, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2075 s3c_hsotg_irq_enumdone(hsotg); in s3c_hsotg_irq()
2076 writel(S3C_GINTSTS_EnumDone, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2080 dev_dbg(hsotg->dev, "ConIDStsChg (DSTS=0x%08x, GOTCTL=%08x)\n", in s3c_hsotg_irq()
2081 readl(hsotg->regs + S3C_DSTS), in s3c_hsotg_irq()
2082 readl(hsotg->regs + S3C_GOTGCTL)); in s3c_hsotg_irq()
2084 writel(S3C_GINTSTS_ConIDStsChng, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2088 u32 daint = readl(hsotg->regs + S3C_DAINT); in s3c_hsotg_irq()
2093 dev_dbg(hsotg->dev, "%s: daint=%08x\n", __func__, daint); in s3c_hsotg_irq()
2097 s3c_hsotg_epint(hsotg, ep, 0); in s3c_hsotg_irq()
2102 s3c_hsotg_epint(hsotg, ep, 1); in s3c_hsotg_irq()
2105 writel(daint, hsotg->regs + S3C_DAINT); in s3c_hsotg_irq()
2107 hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2111 dev_info(hsotg->dev, "%s: USBRst\n", __func__); in s3c_hsotg_irq()
2112 dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n", in s3c_hsotg_irq()
2113 readl(hsotg->regs + S3C_GNPTXSTS)); in s3c_hsotg_irq()
2115 kill_all_requests(hsotg, &hsotg->eps[0], -ECONNRESET, true); in s3c_hsotg_irq()
2123 s3c_hsotg_init_fifo(hsotg); in s3c_hsotg_irq()
2125 s3c_hsotg_enqueue_setup(hsotg); in s3c_hsotg_irq()
2127 writel(S3C_GINTSTS_USBRst, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2133 dev_dbg(hsotg->dev, "NPTxFEmp\n"); in s3c_hsotg_irq()
2139 s3c_hsotg_disable_gsint(hsotg, S3C_GINTSTS_NPTxFEmp); in s3c_hsotg_irq()
2140 s3c_hsotg_irq_fifoempty(hsotg, false); in s3c_hsotg_irq()
2142 writel(S3C_GINTSTS_NPTxFEmp, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2146 dev_dbg(hsotg->dev, "PTxFEmp\n"); in s3c_hsotg_irq()
2150 s3c_hsotg_disable_gsint(hsotg, S3C_GINTSTS_PTxFEmp); in s3c_hsotg_irq()
2151 s3c_hsotg_irq_fifoempty(hsotg, true); in s3c_hsotg_irq()
2153 writel(S3C_GINTSTS_PTxFEmp, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2161 s3c_hsotg_handle_rx(hsotg); in s3c_hsotg_irq()
2162 writel(S3C_GINTSTS_RxFLvl, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2166 dev_warn(hsotg->dev, "warning, mode mismatch triggered\n"); in s3c_hsotg_irq()
2167 writel(S3C_GINTSTS_ModeMis, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2171 dev_info(hsotg->dev, "S3C_GINTSTS_USBSusp\n"); in s3c_hsotg_irq()
2172 writel(S3C_GINTSTS_USBSusp, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2174 call_gadget(hsotg, suspend); in s3c_hsotg_irq()
2178 dev_info(hsotg->dev, "S3C_GINTSTS_WkUpIn\n"); in s3c_hsotg_irq()
2179 writel(S3C_GINTSTS_WkUpInt, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2181 call_gadget(hsotg, resume); in s3c_hsotg_irq()
2185 dev_dbg(hsotg->dev, "S3C_GINTSTS_ErlySusp\n"); in s3c_hsotg_irq()
2186 writel(S3C_GINTSTS_ErlySusp, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2194 dev_info(hsotg->dev, "GOUTNakEff triggered\n"); in s3c_hsotg_irq()
2196 s3c_hsotg_dump(hsotg); in s3c_hsotg_irq()
2198 writel(S3C_DCTL_CGOUTNak, hsotg->regs + S3C_DCTL); in s3c_hsotg_irq()
2199 writel(S3C_GINTSTS_GOUTNakEff, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2203 dev_info(hsotg->dev, "GINNakEff triggered\n"); in s3c_hsotg_irq()
2205 s3c_hsotg_dump(hsotg); in s3c_hsotg_irq()
2207 writel(S3C_DCTL_CGNPInNAK, hsotg->regs + S3C_DCTL); in s3c_hsotg_irq()
2208 writel(S3C_GINTSTS_GINNakEff, hsotg->regs + S3C_GINTSTS); in s3c_hsotg_irq()
2231 struct s3c_hsotg *hsotg = hs_ep->parent; in s3c_hsotg_ep_enable() local
2240 dev_dbg(hsotg->dev, in s3c_hsotg_ep_enable()
2250 dev_err(hsotg->dev, "%s: direction mismatch!\n", __func__); in s3c_hsotg_ep_enable()
2259 epctrl = readl(hsotg->regs + epctrl_reg); in s3c_hsotg_ep_enable()
2261 dev_dbg(hsotg->dev, "%s: read DxEPCTL=0x%08x from 0x%08x\n", in s3c_hsotg_ep_enable()
2289 dev_err(hsotg->dev, "no current ISOC support\n"); in s3c_hsotg_ep_enable()
2319 if (dir_in && hsotg->dedicated_fifos) in s3c_hsotg_ep_enable()
2326 dev_dbg(hsotg->dev, "%s: write DxEPCTL=0x%08x\n", in s3c_hsotg_ep_enable()
2329 writel(epctrl, hsotg->regs + epctrl_reg); in s3c_hsotg_ep_enable()
2330 dev_dbg(hsotg->dev, "%s: read DxEPCTL=0x%08x\n", in s3c_hsotg_ep_enable()
2331 __func__, readl(hsotg->regs + epctrl_reg)); in s3c_hsotg_ep_enable()
2334 s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); in s3c_hsotg_ep_enable()
2344 struct s3c_hsotg *hsotg = hs_ep->parent; in s3c_hsotg_ep_disable() local
2351 dev_info(hsotg->dev, "%s(ep %p)\n", __func__, ep); in s3c_hsotg_ep_disable()
2353 if (ep == &hsotg->eps[0].ep) { in s3c_hsotg_ep_disable()
2354 dev_err(hsotg->dev, "%s: called for ep0\n", __func__); in s3c_hsotg_ep_disable()
2361 kill_all_requests(hsotg, hs_ep, -ESHUTDOWN, false); in s3c_hsotg_ep_disable()
2365 ctrl = readl(hsotg->regs + epctrl_reg); in s3c_hsotg_ep_disable()
2370 dev_dbg(hsotg->dev, "%s: DxEPCTL=0x%08x\n", __func__, ctrl); in s3c_hsotg_ep_disable()
2371 writel(ctrl, hsotg->regs + epctrl_reg); in s3c_hsotg_ep_disable()
2374 s3c_hsotg_ctrl_epint(hsotg, hs_ep->index, hs_ep->dir_in, 0); in s3c_hsotg_ep_disable()
2481 static int s3c_hsotg_corereset(struct s3c_hsotg *hsotg) in s3c_hsotg_corereset() argument
2486 dev_dbg(hsotg->dev, "resetting core\n"); in s3c_hsotg_corereset()
2489 writel(S3C_GRSTCTL_CSftRst, hsotg->regs + S3C_GRSTCTL); in s3c_hsotg_corereset()
2493 grstctl = readl(hsotg->regs + S3C_GRSTCTL); in s3c_hsotg_corereset()
2497 dev_err(hsotg->dev, "Failed to get CSftRst asserted\n"); in s3c_hsotg_corereset()
2504 u32 grstctl = readl(hsotg->regs + S3C_GRSTCTL); in s3c_hsotg_corereset()
2507 dev_info(hsotg->dev, in s3c_hsotg_corereset()
2522 dev_dbg(hsotg->dev, "reset successful\n"); in s3c_hsotg_corereset()
2529 struct s3c_hsotg *hsotg = our_hsotg; in usb_gadget_probe_driver() local
2532 if (!hsotg) { in usb_gadget_probe_driver()
2538 dev_err(hsotg->dev, "%s: no driver\n", __func__); in usb_gadget_probe_driver()
2544 dev_err(hsotg->dev, "%s: bad speed\n", __func__); in usb_gadget_probe_driver()
2548 dev_err(hsotg->dev, "%s: missing entry points\n", __func__); in usb_gadget_probe_driver()
2552 WARN_ON(hsotg->driver); in usb_gadget_probe_driver()
2555 hsotg->driver = driver; in usb_gadget_probe_driver()
2556 hsotg->gadget.dev.driver = &driver->driver; in usb_gadget_probe_driver()
2557 hsotg->gadget.dev.dma_mask = hsotg->dev->dma_mask; in usb_gadget_probe_driver()
2558 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in usb_gadget_probe_driver()
2560 ret = device_add(&hsotg->gadget.dev); in usb_gadget_probe_driver()
2562 dev_err(hsotg->dev, "failed to register gadget device\n"); in usb_gadget_probe_driver()
2566 ret = bind(&hsotg->gadget); in usb_gadget_probe_driver()
2568 dev_err(hsotg->dev, "failed bind %s\n", driver->driver.name); in usb_gadget_probe_driver()
2570 hsotg->gadget.dev.driver = NULL; in usb_gadget_probe_driver()
2571 hsotg->driver = NULL; in usb_gadget_probe_driver()
2578 s3c_hsotg_corereset(hsotg); in usb_gadget_probe_driver()
2582 (0x5 << 10), hsotg->regs + S3C_GUSBCFG); in usb_gadget_probe_driver()
2585 s3c_hsotg_init_fifo(hsotg); in usb_gadget_probe_driver()
2587 __orr32(hsotg->regs + S3C_DCTL, S3C_DCTL_SftDiscon); in usb_gadget_probe_driver()
2589 writel(1 << 18 | S3C_DCFG_DevSpd_HS, hsotg->regs + S3C_DCFG); in usb_gadget_probe_driver()
2597 hsotg->regs + S3C_GINTMSK); in usb_gadget_probe_driver()
2599 if (using_dma(hsotg)) in usb_gadget_probe_driver()
2602 hsotg->regs + S3C_GAHBCFG); in usb_gadget_probe_driver()
2604 writel(S3C_GAHBCFG_GlblIntrEn, hsotg->regs + S3C_GAHBCFG); in usb_gadget_probe_driver()
2613 ((hsotg->dedicated_fifos) ? S3C_DIEPMSK_TxFIFOEmpty : 0), in usb_gadget_probe_driver()
2614 hsotg->regs + S3C_DIEPMSK); in usb_gadget_probe_driver()
2620 (using_dma(hsotg) ? (S3C_DIEPMSK_XferComplMsk | in usb_gadget_probe_driver()
2622 hsotg->regs + S3C_DOEPMSK); in usb_gadget_probe_driver()
2624 writel(0, hsotg->regs + S3C_DAINTMSK); in usb_gadget_probe_driver()
2626 dev_info(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", in usb_gadget_probe_driver()
2627 readl(hsotg->regs + S3C_DIEPCTL0), in usb_gadget_probe_driver()
2628 readl(hsotg->regs + S3C_DOEPCTL0)); in usb_gadget_probe_driver()
2631 s3c_hsotg_en_gsint(hsotg, S3C_GINTSTS_OEPInt | S3C_GINTSTS_IEPInt); in usb_gadget_probe_driver()
2636 if (!using_dma(hsotg)) in usb_gadget_probe_driver()
2637 s3c_hsotg_en_gsint(hsotg, S3C_GINTSTS_RxFLvl); in usb_gadget_probe_driver()
2640 s3c_hsotg_ctrl_epint(hsotg, 0, 0, 1); in usb_gadget_probe_driver()
2641 s3c_hsotg_ctrl_epint(hsotg, 0, 1, 1); in usb_gadget_probe_driver()
2643 __orr32(hsotg->regs + S3C_DCTL, S3C_DCTL_PWROnPrgDone); in usb_gadget_probe_driver()
2645 __bic32(hsotg->regs + S3C_DCTL, S3C_DCTL_PWROnPrgDone); in usb_gadget_probe_driver()
2647 dev_info(hsotg->dev, "DCTL=0x%08x\n", readl(hsotg->regs + S3C_DCTL)); in usb_gadget_probe_driver()
2654 S3C_DxEPTSIZ_XferSize(8), hsotg->regs + DOEPTSIZ0); in usb_gadget_probe_driver()
2656 writel(s3c_hsotg_ep0_mps(hsotg->eps[0].ep.maxpacket) | in usb_gadget_probe_driver()
2659 hsotg->regs + S3C_DOEPCTL0); in usb_gadget_probe_driver()
2662 writel(s3c_hsotg_ep0_mps(hsotg->eps[0].ep.maxpacket) | in usb_gadget_probe_driver()
2663 S3C_DxEPCTL_USBActEp, hsotg->regs + S3C_DIEPCTL0); in usb_gadget_probe_driver()
2665 s3c_hsotg_enqueue_setup(hsotg); in usb_gadget_probe_driver()
2667 dev_info(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", in usb_gadget_probe_driver()
2668 readl(hsotg->regs + S3C_DIEPCTL0), in usb_gadget_probe_driver()
2669 readl(hsotg->regs + S3C_DOEPCTL0)); in usb_gadget_probe_driver()
2673 hsotg->regs + S3C_DCTL); in usb_gadget_probe_driver()
2679 __bic32(hsotg->regs + S3C_DCTL, S3C_DCTL_SftDiscon); in usb_gadget_probe_driver()
2683 dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name); in usb_gadget_probe_driver()
2687 hsotg->driver = NULL; in usb_gadget_probe_driver()
2688 hsotg->gadget.dev.driver = NULL; in usb_gadget_probe_driver()
2695 struct s3c_hsotg *hsotg = our_hsotg; in usb_gadget_unregister_driver() local
2698 if (!hsotg) in usb_gadget_unregister_driver()
2701 if (!driver || driver != hsotg->driver || !driver->unbind) in usb_gadget_unregister_driver()
2706 s3c_hsotg_ep_disable(&hsotg->eps[ep].ep); in usb_gadget_unregister_driver()
2708 call_gadget(hsotg, disconnect); in usb_gadget_unregister_driver()
2710 driver->unbind(&hsotg->gadget); in usb_gadget_unregister_driver()
2711 hsotg->driver = NULL; in usb_gadget_unregister_driver()
2712 hsotg->gadget.speed = USB_SPEED_UNKNOWN; in usb_gadget_unregister_driver()
2714 device_del(&hsotg->gadget.dev); in usb_gadget_unregister_driver()
2716 dev_info(hsotg->dev, "unregistered gadget driver '%s'\n", in usb_gadget_unregister_driver()
2742 static void __devinit s3c_hsotg_initep(struct s3c_hsotg *hsotg, in s3c_hsotg_initep() argument
2769 list_add_tail(&hs_ep->ep.ep_list, &hsotg->gadget.ep_list); in s3c_hsotg_initep()
2771 hs_ep->parent = hsotg; in s3c_hsotg_initep()
2781 ptxfifo = readl(hsotg->regs + S3C_DPTXFSIZn(epnum)); in s3c_hsotg_initep()
2788 if (using_dma(hsotg)) { in s3c_hsotg_initep()
2790 writel(next, hsotg->regs + S3C_DIEPCTL(epnum)); in s3c_hsotg_initep()
2791 writel(next, hsotg->regs + S3C_DOEPCTL(epnum)); in s3c_hsotg_initep()
2801 static void s3c_hsotg_otgreset(struct s3c_hsotg *hsotg) in s3c_hsotg_otgreset() argument
2811 osc = hsotg->plat->is_osc ? S3C_PHYCLK_EXT_OSC : 0; in s3c_hsotg_otgreset()
2813 xusbxti = clk_get(hsotg->dev, "xusbxti"); in s3c_hsotg_otgreset()
2840 static void s3c_hsotg_init(struct s3c_hsotg *hsotg) in s3c_hsotg_init() argument
2848 hsotg->regs + S3C_DIEPMSK); in s3c_hsotg_init()
2852 hsotg->regs + S3C_DOEPMSK); in s3c_hsotg_init()
2854 writel(0, hsotg->regs + S3C_DAINTMSK); in s3c_hsotg_init()
2857 __orr32(hsotg->regs + S3C_DCTL, S3C_DCTL_SftDiscon); in s3c_hsotg_init()
2862 hsotg->regs + S3C_DCTL); in s3c_hsotg_init()
2867 dev_info(hsotg->dev, "GRXFSIZ=0x%08x, GNPTXFSIZ=0x%08x\n", in s3c_hsotg_init()
2868 readl(hsotg->regs + S3C_GRXFSIZ), in s3c_hsotg_init()
2869 readl(hsotg->regs + S3C_GNPTXFSIZ)); in s3c_hsotg_init()
2871 s3c_hsotg_init_fifo(hsotg); in s3c_hsotg_init()
2875 hsotg->regs + S3C_GUSBCFG); in s3c_hsotg_init()
2877 writel(using_dma(hsotg) ? S3C_GAHBCFG_DMAEn : 0x0, in s3c_hsotg_init()
2878 hsotg->regs + S3C_GAHBCFG); in s3c_hsotg_init()
2882 cfg4 = readl(hsotg->regs + 0x50); in s3c_hsotg_init()
2883 hsotg->dedicated_fifos = (cfg4 >> 25) & 1; in s3c_hsotg_init()
2885 dev_info(hsotg->dev, "%s fifos\n", in s3c_hsotg_init()
2886 hsotg->dedicated_fifos ? "dedicated" : "shared"); in s3c_hsotg_init()
2889 static void s3c_hsotg_dump(struct s3c_hsotg *hsotg) in s3c_hsotg_dump() argument
2891 struct device *dev = hsotg->dev; in s3c_hsotg_dump()
2892 void __iomem *regs = hsotg->regs; in s3c_hsotg_dump()
2947 struct s3c_hsotg *hsotg = seq->private; in state_show() local
2948 void __iomem *regs = hsotg->regs; in state_show()
3017 struct s3c_hsotg *hsotg = seq->private; in fifo_show() local
3018 void __iomem *regs = hsotg->regs; in fifo_show()
3073 struct s3c_hsotg *hsotg = ep->parent; in ep_show() local
3075 void __iomem *regs = hsotg->regs; in ep_show()
3150 static void __devinit s3c_hsotg_create_debug(struct s3c_hsotg *hsotg) in s3c_hsotg_create_debug() argument
3155 root = debugfs_create_dir(dev_name(hsotg->dev), NULL); in s3c_hsotg_create_debug()
3156 hsotg->debug_root = root; in s3c_hsotg_create_debug()
3158 dev_err(hsotg->dev, "cannot create debug root\n"); in s3c_hsotg_create_debug()
3164 hsotg->debug_file = debugfs_create_file("state", 0444, root, in s3c_hsotg_create_debug()
3165 hsotg, &state_fops); in s3c_hsotg_create_debug()
3167 if (IS_ERR(hsotg->debug_file)) in s3c_hsotg_create_debug()
3168 dev_err(hsotg->dev, "%s: failed to create state\n", __func__); in s3c_hsotg_create_debug()
3170 hsotg->debug_fifo = debugfs_create_file("fifo", 0444, root, in s3c_hsotg_create_debug()
3171 hsotg, &fifo_fops); in s3c_hsotg_create_debug()
3173 if (IS_ERR(hsotg->debug_fifo)) in s3c_hsotg_create_debug()
3174 dev_err(hsotg->dev, "%s: failed to create fifo\n", __func__); in s3c_hsotg_create_debug()
3179 struct s3c_hsotg_ep *ep = &hsotg->eps[epidx]; in s3c_hsotg_create_debug()
3185 dev_err(hsotg->dev, "failed to create %s debug file\n", in s3c_hsotg_create_debug()
3196 static void __devexit s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) in s3c_hsotg_delete_debug() argument
3201 struct s3c_hsotg_ep *ep = &hsotg->eps[epidx]; in s3c_hsotg_delete_debug()
3205 debugfs_remove(hsotg->debug_file); in s3c_hsotg_delete_debug()
3206 debugfs_remove(hsotg->debug_fifo); in s3c_hsotg_delete_debug()
3207 debugfs_remove(hsotg->debug_root); in s3c_hsotg_delete_debug()
3242 struct s3c_hsotg *hsotg; in s3c_hsotg_probe() local
3250 hsotg = kzalloc(sizeof(struct s3c_hsotg) + in s3c_hsotg_probe()
3253 if (!hsotg) { in s3c_hsotg_probe()
3258 hsotg->dev = dev; in s3c_hsotg_probe()
3259 hsotg->plat = plat; in s3c_hsotg_probe()
3261 hsotg->clk = clk_get(&pdev->dev, "otg"); in s3c_hsotg_probe()
3262 if (IS_ERR(hsotg->clk)) { in s3c_hsotg_probe()
3268 platform_set_drvdata(pdev, hsotg); in s3c_hsotg_probe()
3277 hsotg->regs_res = request_mem_region(res->start, resource_size(res), in s3c_hsotg_probe()
3279 if (!hsotg->regs_res) { in s3c_hsotg_probe()
3285 hsotg->regs = ioremap(res->start, resource_size(res)); in s3c_hsotg_probe()
3286 if (!hsotg->regs) { in s3c_hsotg_probe()
3298 hsotg->irq = ret; in s3c_hsotg_probe()
3300 ret = request_irq(ret, s3c_hsotg_irq, 0, dev_name(dev), hsotg); in s3c_hsotg_probe()
3306 dev_info(dev, "regs %p, irq %d\n", hsotg->regs, hsotg->irq); in s3c_hsotg_probe()
3308 device_initialize(&hsotg->gadget.dev); in s3c_hsotg_probe()
3310 dev_set_name(&hsotg->gadget.dev, "gadget"); in s3c_hsotg_probe()
3312 hsotg->gadget.is_dualspeed = 1; in s3c_hsotg_probe()
3313 hsotg->gadget.ops = &s3c_hsotg_gadget_ops; in s3c_hsotg_probe()
3314 hsotg->gadget.name = dev_name(dev); in s3c_hsotg_probe()
3316 hsotg->gadget.dev.parent = dev; in s3c_hsotg_probe()
3317 hsotg->gadget.dev.dma_mask = dev->dma_mask; in s3c_hsotg_probe()
3321 INIT_LIST_HEAD(&hsotg->gadget.ep_list); in s3c_hsotg_probe()
3322 hsotg->gadget.ep0 = &hsotg->eps[0].ep; in s3c_hsotg_probe()
3326 hsotg->ctrl_req = s3c_hsotg_ep_alloc_request(&hsotg->eps[0].ep, in s3c_hsotg_probe()
3328 if (!hsotg->ctrl_req) { in s3c_hsotg_probe()
3335 clk_enable(hsotg->clk); in s3c_hsotg_probe()
3339 s3c_hsotg_otgreset(hsotg); in s3c_hsotg_probe()
3340 s3c_hsotg_corereset(hsotg); in s3c_hsotg_probe()
3341 s3c_hsotg_init(hsotg); in s3c_hsotg_probe()
3345 s3c_hsotg_initep(hsotg, &hsotg->eps[epnum], epnum); in s3c_hsotg_probe()
3347 s3c_hsotg_create_debug(hsotg); in s3c_hsotg_probe()
3349 s3c_hsotg_dump(hsotg); in s3c_hsotg_probe()
3351 our_hsotg = hsotg; in s3c_hsotg_probe()
3355 iounmap(hsotg->regs); in s3c_hsotg_probe()
3358 release_resource(hsotg->regs_res); in s3c_hsotg_probe()
3359 kfree(hsotg->regs_res); in s3c_hsotg_probe()
3361 clk_put(hsotg->clk); in s3c_hsotg_probe()
3363 kfree(hsotg); in s3c_hsotg_probe()
3369 struct s3c_hsotg *hsotg = platform_get_drvdata(pdev); in s3c_hsotg_remove() local
3371 s3c_hsotg_delete_debug(hsotg); in s3c_hsotg_remove()
3373 usb_gadget_unregister_driver(hsotg->driver); in s3c_hsotg_remove()
3375 free_irq(hsotg->irq, hsotg); in s3c_hsotg_remove()
3376 iounmap(hsotg->regs); in s3c_hsotg_remove()
3378 release_resource(hsotg->regs_res); in s3c_hsotg_remove()
3379 kfree(hsotg->regs_res); in s3c_hsotg_remove()
3383 clk_disable(hsotg->clk); in s3c_hsotg_remove()
3384 clk_put(hsotg->clk); in s3c_hsotg_remove()
3386 kfree(hsotg); in s3c_hsotg_remove()