Lines Matching defs:host

42 static inline struct device *ms_dev(struct rtsx_usb_ms *host)
44 return &(host->pdev->dev);
47 static inline void ms_clear_error(struct rtsx_usb_ms *host)
49 struct rtsx_ucr *ucr = host->ucr;
60 static void ms_print_debug_regs(struct rtsx_usb_ms *host)
62 struct rtsx_ucr *ucr = host->ucr;
66 /* Print MS host internal registers */
92 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
94 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
96 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
98 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_DATA_SOURCE, *(ptr++));
99 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_SELECT, *(ptr++));
100 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_CLK_EN, *(ptr++));
101 dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_PWR_CTL, *(ptr++));
106 static void ms_print_debug_regs(struct rtsx_usb_ms *host)
168 static int ms_power_on(struct rtsx_usb_ms *host)
170 struct rtsx_ucr *ucr = host->ucr;
173 dev_dbg(ms_dev(host), "%s\n", __func__);
208 static int ms_power_off(struct rtsx_usb_ms *host)
210 struct rtsx_ucr *ucr = host->ucr;
213 dev_dbg(ms_dev(host), "%s\n", __func__);
230 static int ms_transfer_data(struct rtsx_usb_ms *host, unsigned char data_dir,
233 struct rtsx_ucr *ucr = host->ucr;
239 struct memstick_dev *card = host->msh->card;
241 dev_dbg(ms_dev(host), "%s: tpc = 0x%02x, data_dir = %s, length = %d\n",
312 ms_clear_error(host);
316 static int ms_write_bytes(struct rtsx_usb_ms *host, u8 tpc,
319 struct rtsx_ucr *ucr = host->ucr;
322 dev_dbg(ms_dev(host), "%s: tpc = 0x%02x\n", __func__, tpc);
355 dev_dbg(ms_dev(host), "MS_TRANS_CFG: 0x%02x\n", val);
360 ms_print_debug_regs(host);
362 ms_clear_error(host);
383 static int ms_read_bytes(struct rtsx_usb_ms *host, u8 tpc,
386 struct rtsx_ucr *ucr = host->ucr;
390 dev_dbg(ms_dev(host), "%s: tpc = 0x%02x\n", __func__, tpc);
423 dev_dbg(ms_dev(host), "MS_TRANS_CFG: 0x%02x\n", val);
425 if (int_reg && (host->ifmode != MEMSTICK_SERIAL))
428 ms_print_debug_regs(host);
430 ms_clear_error(host);
450 if (int_reg && (host->ifmode != MEMSTICK_SERIAL))
456 static int rtsx_usb_ms_issue_cmd(struct rtsx_usb_ms *host)
458 struct memstick_request *req = host->req;
462 dev_dbg(ms_dev(host), "%s\n", __func__);
465 if (host->ifmode != MEMSTICK_SERIAL)
470 err = ms_transfer_data(host, req->data_dir,
474 err = ms_read_bytes(host, req->tpc, cfg,
477 err = ms_write_bytes(host, req->tpc, cfg,
484 if (host->ifmode == MEMSTICK_SERIAL) {
485 err = ms_read_bytes(host, MS_TPC_GET_INT,
500 dev_dbg(ms_dev(host), "int_reg: 0x%02x\n", req->int_reg);
508 struct rtsx_usb_ms *host = container_of(work,
510 struct rtsx_ucr *ucr = host->ucr;
511 struct memstick_host *msh = host->msh;
514 if (!host->req) {
515 pm_runtime_get_sync(ms_dev(host));
517 rc = memstick_next_req(msh, &host->req);
518 dev_dbg(ms_dev(host), "next req %d\n", rc);
525 host->req->error = -EIO;
527 host->req->error =
528 rtsx_usb_ms_issue_cmd(host);
532 dev_dbg(ms_dev(host), "req result %d\n",
533 host->req->error);
536 pm_runtime_put_sync(ms_dev(host));
543 struct rtsx_usb_ms *host = memstick_priv(msh);
545 dev_dbg(ms_dev(host), "--> %s\n", __func__);
547 if (!host->eject)
548 schedule_work(&host->handle_req);
554 struct rtsx_usb_ms *host = memstick_priv(msh);
555 struct rtsx_ucr *ucr = host->ucr;
560 dev_dbg(ms_dev(host), "%s: param = %d, value = %d\n",
563 pm_runtime_get_sync(ms_dev(host));
572 if (value == host->power_mode)
576 pm_runtime_get_noresume(ms_dev(host));
577 err = ms_power_on(host);
579 pm_runtime_put_noidle(ms_dev(host));
581 err = ms_power_off(host);
583 pm_runtime_put_noidle(ms_dev(host));
587 host->power_mode = value;
615 dev_dbg(ms_dev(host), "switch clock failed\n");
619 host->ssc_depth = ssc_depth;
620 host->clock = clock;
621 host->ifmode = value;
629 pm_runtime_put_sync(ms_dev(host));
635 if (!host->eject)
636 schedule_delayed_work(&host->poll_card, 100);
639 dev_dbg(ms_dev(host), "%s: return = %d\n", __func__, err);
646 struct rtsx_usb_ms *host = dev_get_drvdata(dev);
647 struct memstick_host *msh = host->msh;
664 host->system_suspending = true;
672 struct rtsx_usb_ms *host = dev_get_drvdata(dev);
673 struct memstick_host *msh = host->msh;
676 host->system_suspending = false;
685 struct rtsx_usb_ms *host = dev_get_drvdata(dev);
687 if (host->system_suspending)
690 if (host->msh->card || host->power_mode != MEMSTICK_POWER_OFF)
698 struct rtsx_usb_ms *host = dev_get_drvdata(dev);
701 if (host->system_suspending)
704 memstick_detect_change(host->msh);
718 struct rtsx_usb_ms *host = container_of(work, struct rtsx_usb_ms,
720 struct rtsx_ucr *ucr = host->ucr;
724 if (host->eject || host->power_mode != MEMSTICK_POWER_ON)
727 pm_runtime_get_sync(ms_dev(host));
745 dev_dbg(ms_dev(host), "MS slot change detected\n");
746 memstick_detect_change(host->msh);
750 pm_runtime_put_sync(ms_dev(host));
752 if (!host->eject && host->power_mode == MEMSTICK_POWER_ON)
753 schedule_delayed_work(&host->poll_card, 100);
759 struct rtsx_usb_ms *host;
770 msh = memstick_alloc_host(sizeof(*host), &pdev->dev);
774 host = memstick_priv(msh);
775 host->ucr = ucr;
776 host->msh = msh;
777 host->pdev = pdev;
778 host->power_mode = MEMSTICK_POWER_OFF;
779 platform_set_drvdata(pdev, host);
781 mutex_init(&host->host_mutex);
782 INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req);
784 INIT_DELAYED_WORK(&host->poll_card, rtsx_usb_ms_poll_card);
790 pm_runtime_get_noresume(ms_dev(host));
791 pm_runtime_set_active(ms_dev(host));
792 pm_runtime_enable(ms_dev(host));
798 pm_runtime_put(ms_dev(host));
802 pm_runtime_disable(ms_dev(host));
803 pm_runtime_put_noidle(ms_dev(host));
810 struct rtsx_usb_ms *host = platform_get_drvdata(pdev);
811 struct memstick_host *msh = host->msh;
814 host->eject = true;
815 cancel_work_sync(&host->handle_req);
817 mutex_lock(&host->host_mutex);
818 if (host->req) {
819 dev_dbg(ms_dev(host),
822 host->req->error = -ENOMEDIUM;
824 err = memstick_next_req(msh, &host->req);
826 host->req->error = -ENOMEDIUM;
829 mutex_unlock(&host->host_mutex);
834 if (pm_runtime_active(ms_dev(host)))
835 pm_runtime_put(ms_dev(host));
837 pm_runtime_disable(ms_dev(host));
839 dev_dbg(ms_dev(host),