Lines Matching refs:host

54 static inline struct device *ms_dev(struct rtsx_usb_ms *host)  in ms_dev()  argument
56 return &(host->pdev->dev); in ms_dev()
59 static inline void ms_clear_error(struct rtsx_usb_ms *host) in ms_clear_error() argument
61 struct rtsx_ucr *ucr = host->ucr; in ms_clear_error()
72 static void ms_print_debug_regs(struct rtsx_usb_ms *host) in ms_print_debug_regs() argument
74 struct rtsx_ucr *ucr = host->ucr; in ms_print_debug_regs()
104 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++)); in ms_print_debug_regs()
106 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++)); in ms_print_debug_regs()
108 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++)); in ms_print_debug_regs()
110 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_DATA_SOURCE, *(ptr++)); in ms_print_debug_regs()
111 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_SELECT, *(ptr++)); in ms_print_debug_regs()
112 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_CLK_EN, *(ptr++)); in ms_print_debug_regs()
113 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_PWR_CTL, *(ptr++)); in ms_print_debug_regs()
118 static void ms_print_debug_regs(struct rtsx_usb_ms *host) in ms_print_debug_regs() argument
180 static int ms_power_on(struct rtsx_usb_ms *host) in ms_power_on() argument
182 struct rtsx_ucr *ucr = host->ucr; in ms_power_on()
185 dev_dbg(ms_dev(host), "%s\n", __func__); in ms_power_on()
220 static int ms_power_off(struct rtsx_usb_ms *host) in ms_power_off() argument
222 struct rtsx_ucr *ucr = host->ucr; in ms_power_off()
225 dev_dbg(ms_dev(host), "%s\n", __func__); in ms_power_off()
242 static int ms_transfer_data(struct rtsx_usb_ms *host, unsigned char data_dir, in ms_transfer_data() argument
245 struct rtsx_ucr *ucr = host->ucr; in ms_transfer_data()
251 struct memstick_dev *card = host->msh->card; in ms_transfer_data()
253 dev_dbg(ms_dev(host), "%s: tpc = 0x%02x, data_dir = %s, length = %d\n", in ms_transfer_data()
324 ms_clear_error(host); in ms_transfer_data()
328 static int ms_write_bytes(struct rtsx_usb_ms *host, u8 tpc, in ms_write_bytes() argument
331 struct rtsx_ucr *ucr = host->ucr; in ms_write_bytes()
334 dev_dbg(ms_dev(host), "%s: tpc = 0x%02x\n", __func__, tpc); in ms_write_bytes()
367 dev_dbg(ms_dev(host), "MS_TRANS_CFG: 0x%02x\n", val); in ms_write_bytes()
372 ms_print_debug_regs(host); in ms_write_bytes()
374 ms_clear_error(host); in ms_write_bytes()
395 static int ms_read_bytes(struct rtsx_usb_ms *host, u8 tpc, in ms_read_bytes() argument
398 struct rtsx_ucr *ucr = host->ucr; in ms_read_bytes()
402 dev_dbg(ms_dev(host), "%s: tpc = 0x%02x\n", __func__, tpc); in ms_read_bytes()
435 dev_dbg(ms_dev(host), "MS_TRANS_CFG: 0x%02x\n", val); in ms_read_bytes()
437 if (int_reg && (host->ifmode != MEMSTICK_SERIAL)) in ms_read_bytes()
440 ms_print_debug_regs(host); in ms_read_bytes()
442 ms_clear_error(host); in ms_read_bytes()
462 if (int_reg && (host->ifmode != MEMSTICK_SERIAL)) in ms_read_bytes()
468 static int rtsx_usb_ms_issue_cmd(struct rtsx_usb_ms *host) in rtsx_usb_ms_issue_cmd() argument
470 struct memstick_request *req = host->req; in rtsx_usb_ms_issue_cmd()
474 dev_dbg(ms_dev(host), "%s\n", __func__); in rtsx_usb_ms_issue_cmd()
477 if (host->ifmode != MEMSTICK_SERIAL) in rtsx_usb_ms_issue_cmd()
482 err = ms_transfer_data(host, req->data_dir, in rtsx_usb_ms_issue_cmd()
486 err = ms_read_bytes(host, req->tpc, cfg, in rtsx_usb_ms_issue_cmd()
489 err = ms_write_bytes(host, req->tpc, cfg, in rtsx_usb_ms_issue_cmd()
496 if (host->ifmode == MEMSTICK_SERIAL) { in rtsx_usb_ms_issue_cmd()
497 err = ms_read_bytes(host, MS_TPC_GET_INT, in rtsx_usb_ms_issue_cmd()
512 dev_dbg(ms_dev(host), "int_reg: 0x%02x\n", req->int_reg); in rtsx_usb_ms_issue_cmd()
520 struct rtsx_usb_ms *host = container_of(work, in rtsx_usb_ms_handle_req() local
522 struct rtsx_ucr *ucr = host->ucr; in rtsx_usb_ms_handle_req()
523 struct memstick_host *msh = host->msh; in rtsx_usb_ms_handle_req()
526 if (!host->req) { in rtsx_usb_ms_handle_req()
528 rc = memstick_next_req(msh, &host->req); in rtsx_usb_ms_handle_req()
529 dev_dbg(ms_dev(host), "next req %d\n", rc); in rtsx_usb_ms_handle_req()
536 host->req->error = -EIO; in rtsx_usb_ms_handle_req()
538 host->req->error = in rtsx_usb_ms_handle_req()
539 rtsx_usb_ms_issue_cmd(host); in rtsx_usb_ms_handle_req()
543 dev_dbg(ms_dev(host), "req result %d\n", in rtsx_usb_ms_handle_req()
544 host->req->error); in rtsx_usb_ms_handle_req()
553 struct rtsx_usb_ms *host = memstick_priv(msh); in rtsx_usb_ms_request() local
555 dev_dbg(ms_dev(host), "--> %s\n", __func__); in rtsx_usb_ms_request()
557 if (!host->eject) in rtsx_usb_ms_request()
558 schedule_work(&host->handle_req); in rtsx_usb_ms_request()
564 struct rtsx_usb_ms *host = memstick_priv(msh); in rtsx_usb_ms_set_param() local
565 struct rtsx_ucr *ucr = host->ucr; in rtsx_usb_ms_set_param()
570 dev_dbg(ms_dev(host), "%s: param = %d, value = %d\n", in rtsx_usb_ms_set_param()
581 if (value == host->power_mode) in rtsx_usb_ms_set_param()
585 pm_runtime_get_sync(ms_dev(host)); in rtsx_usb_ms_set_param()
586 err = ms_power_on(host); in rtsx_usb_ms_set_param()
588 err = ms_power_off(host); in rtsx_usb_ms_set_param()
589 if (host->msh->card) in rtsx_usb_ms_set_param()
590 pm_runtime_put_noidle(ms_dev(host)); in rtsx_usb_ms_set_param()
592 pm_runtime_put(ms_dev(host)); in rtsx_usb_ms_set_param()
596 host->power_mode = value; in rtsx_usb_ms_set_param()
624 dev_dbg(ms_dev(host), "switch clock failed\n"); in rtsx_usb_ms_set_param()
628 host->ssc_depth = ssc_depth; in rtsx_usb_ms_set_param()
629 host->clock = clock; in rtsx_usb_ms_set_param()
630 host->ifmode = value; in rtsx_usb_ms_set_param()
643 dev_dbg(ms_dev(host), "%s: return = %d\n", __func__, err); in rtsx_usb_ms_set_param()
650 struct rtsx_usb_ms *host = dev_get_drvdata(dev); in rtsx_usb_ms_suspend() local
651 struct memstick_host *msh = host->msh; in rtsx_usb_ms_suspend()
653 dev_dbg(ms_dev(host), "--> %s\n", __func__); in rtsx_usb_ms_suspend()
661 struct rtsx_usb_ms *host = dev_get_drvdata(dev); in rtsx_usb_ms_resume() local
662 struct memstick_host *msh = host->msh; in rtsx_usb_ms_resume()
664 dev_dbg(ms_dev(host), "--> %s\n", __func__); in rtsx_usb_ms_resume()
678 struct rtsx_usb_ms *host = (struct rtsx_usb_ms *)__host; in rtsx_usb_detect_ms_card() local
679 struct rtsx_ucr *ucr = host->ucr; in rtsx_usb_detect_ms_card()
701 dev_dbg(ms_dev(host), "MS slot change detected\n"); in rtsx_usb_detect_ms_card()
702 memstick_detect_change(host->msh); in rtsx_usb_detect_ms_card()
706 if (host->eject) in rtsx_usb_detect_ms_card()
712 complete(&host->detect_ms_exit); in rtsx_usb_detect_ms_card()
719 struct rtsx_usb_ms *host; in rtsx_usb_ms_drv_probe() local
730 msh = memstick_alloc_host(sizeof(*host), &pdev->dev); in rtsx_usb_ms_drv_probe()
734 host = memstick_priv(msh); in rtsx_usb_ms_drv_probe()
735 host->ucr = ucr; in rtsx_usb_ms_drv_probe()
736 host->msh = msh; in rtsx_usb_ms_drv_probe()
737 host->pdev = pdev; in rtsx_usb_ms_drv_probe()
738 host->power_mode = MEMSTICK_POWER_OFF; in rtsx_usb_ms_drv_probe()
739 platform_set_drvdata(pdev, host); in rtsx_usb_ms_drv_probe()
741 mutex_init(&host->host_mutex); in rtsx_usb_ms_drv_probe()
742 INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req); in rtsx_usb_ms_drv_probe()
744 init_completion(&host->detect_ms_exit); in rtsx_usb_ms_drv_probe()
745 host->detect_ms = kthread_create(rtsx_usb_detect_ms_card, host, in rtsx_usb_ms_drv_probe()
747 if (IS_ERR(host->detect_ms)) { in rtsx_usb_ms_drv_probe()
750 err = PTR_ERR(host->detect_ms); in rtsx_usb_ms_drv_probe()
763 wake_up_process(host->detect_ms); in rtsx_usb_ms_drv_probe()
772 struct rtsx_usb_ms *host = platform_get_drvdata(pdev); in rtsx_usb_ms_drv_remove() local
776 msh = host->msh; in rtsx_usb_ms_drv_remove()
777 host->eject = true; in rtsx_usb_ms_drv_remove()
778 cancel_work_sync(&host->handle_req); in rtsx_usb_ms_drv_remove()
780 mutex_lock(&host->host_mutex); in rtsx_usb_ms_drv_remove()
781 if (host->req) { in rtsx_usb_ms_drv_remove()
785 host->req->error = -ENOMEDIUM; in rtsx_usb_ms_drv_remove()
787 err = memstick_next_req(msh, &host->req); in rtsx_usb_ms_drv_remove()
789 host->req->error = -ENOMEDIUM; in rtsx_usb_ms_drv_remove()
792 mutex_unlock(&host->host_mutex); in rtsx_usb_ms_drv_remove()
794 wait_for_completion(&host->detect_ms_exit); in rtsx_usb_ms_drv_remove()
801 if (pm_runtime_active(ms_dev(host))) in rtsx_usb_ms_drv_remove()
802 pm_runtime_put(ms_dev(host)); in rtsx_usb_ms_drv_remove()