Lines Matching refs:slot

228 static bool switch_val_changed(struct cvm_mmc_slot *slot, u64 new_val)  in switch_val_changed()  argument
233 return (slot->cached_switch & match) != (new_val & match); in switch_val_changed()
236 static void set_wdog(struct cvm_mmc_slot *slot, unsigned int ns) in set_wdog() argument
240 if (!slot->clock) in set_wdog()
244 timeout = (slot->clock * ns) / NSEC_PER_SEC; in set_wdog()
246 timeout = (slot->clock * 850ull) / 1000ull; in set_wdog()
247 writeq(timeout, slot->host->base + MIO_EMM_WDOG(slot->host)); in set_wdog()
250 static void cvm_mmc_reset_bus(struct cvm_mmc_slot *slot) in cvm_mmc_reset_bus() argument
252 struct cvm_mmc_host *host = slot->host; in cvm_mmc_reset_bus()
255 emm_switch = readq(slot->host->base + MIO_EMM_SWITCH(host)); in cvm_mmc_reset_bus()
258 set_bus_id(&emm_switch, slot->bus_id); in cvm_mmc_reset_bus()
260 wdog = readq(slot->host->base + MIO_EMM_WDOG(host)); in cvm_mmc_reset_bus()
261 do_switch(slot->host, emm_switch); in cvm_mmc_reset_bus()
263 slot->cached_switch = emm_switch; in cvm_mmc_reset_bus()
267 writeq(wdog, slot->host->base + MIO_EMM_WDOG(host)); in cvm_mmc_reset_bus()
271 static void cvm_mmc_switch_to(struct cvm_mmc_slot *slot) in cvm_mmc_switch_to() argument
273 struct cvm_mmc_host *host = slot->host; in cvm_mmc_switch_to()
277 if (slot->bus_id == host->last_slot) in cvm_mmc_switch_to()
280 if (host->last_slot >= 0 && host->slot[host->last_slot]) { in cvm_mmc_switch_to()
281 old_slot = host->slot[host->last_slot]; in cvm_mmc_switch_to()
286 writeq(slot->cached_rca, host->base + MIO_EMM_RCA(host)); in cvm_mmc_switch_to()
287 emm_switch = slot->cached_switch; in cvm_mmc_switch_to()
288 set_bus_id(&emm_switch, slot->bus_id); in cvm_mmc_switch_to()
291 emm_sample = FIELD_PREP(MIO_EMM_SAMPLE_CMD_CNT, slot->cmd_cnt) | in cvm_mmc_switch_to()
292 FIELD_PREP(MIO_EMM_SAMPLE_DAT_CNT, slot->dat_cnt); in cvm_mmc_switch_to()
295 host->last_slot = slot->bus_id; in cvm_mmc_switch_to()
627 struct cvm_mmc_slot *slot = mmc_priv(mmc); in prepare_ext_dma() local
637 set_bus_id(&emm_dma, slot->bus_id); in prepare_ext_dma()
652 struct cvm_mmc_slot *slot = mmc_priv(mmc); in cvm_mmc_dma_request() local
653 struct cvm_mmc_host *host = slot->host; in cvm_mmc_dma_request()
663 cvm_mmc_switch_to(slot); in cvm_mmc_dma_request()
669 set_wdog(slot, data->timeout_ns); in cvm_mmc_dma_request()
752 struct cvm_mmc_slot *slot = mmc_priv(mmc); in cvm_mmc_request() local
753 struct cvm_mmc_host *host = slot->host; in cvm_mmc_request()
774 cvm_mmc_switch_to(slot); in cvm_mmc_request()
788 set_wdog(slot, cmd->data->timeout_ns); in cvm_mmc_request()
790 set_wdog(slot, 0); in cvm_mmc_request()
800 set_bus_id(&emm_cmd, slot->bus_id); in cvm_mmc_request()
824 struct cvm_mmc_slot *slot = mmc_priv(mmc); in cvm_mmc_set_ios() local
825 struct cvm_mmc_host *host = slot->host; in cvm_mmc_set_ios()
830 cvm_mmc_switch_to(slot); in cvm_mmc_set_ios()
838 cvm_mmc_reset_bus(slot); in cvm_mmc_set_ios()
874 slot->clock = clock; in cvm_mmc_set_ios()
885 set_bus_id(&emm_switch, slot->bus_id); in cvm_mmc_set_ios()
887 if (!switch_val_changed(slot, emm_switch)) in cvm_mmc_set_ios()
890 set_wdog(slot, 0); in cvm_mmc_set_ios()
892 slot->cached_switch = emm_switch; in cvm_mmc_set_ios()
904 static void cvm_mmc_set_clock(struct cvm_mmc_slot *slot, unsigned int clock) in cvm_mmc_set_clock() argument
906 struct mmc_host *mmc = slot->mmc; in cvm_mmc_set_clock()
910 slot->clock = clock; in cvm_mmc_set_clock()
913 static int cvm_mmc_init_lowlevel(struct cvm_mmc_slot *slot) in cvm_mmc_init_lowlevel() argument
915 struct cvm_mmc_host *host = slot->host; in cvm_mmc_init_lowlevel()
919 host->emm_cfg |= (1ull << slot->bus_id); in cvm_mmc_init_lowlevel()
920 writeq(host->emm_cfg, slot->host->base + MIO_EMM_CFG(host)); in cvm_mmc_init_lowlevel()
924 cvm_mmc_set_clock(slot, slot->mmc->f_min); in cvm_mmc_init_lowlevel()
927 (host->sys_freq / slot->clock) / 2); in cvm_mmc_init_lowlevel()
929 (host->sys_freq / slot->clock) / 2); in cvm_mmc_init_lowlevel()
932 set_bus_id(&emm_switch, slot->bus_id); in cvm_mmc_init_lowlevel()
935 slot->cached_switch = emm_switch; in cvm_mmc_init_lowlevel()
943 set_wdog(slot, 0); in cvm_mmc_init_lowlevel()
949 static int cvm_mmc_of_parse(struct device *dev, struct cvm_mmc_slot *slot) in cvm_mmc_of_parse() argument
953 struct mmc_host *mmc = slot->mmc; in cvm_mmc_of_parse()
963 if (id >= CAVIUM_MAX_MMC || slot->host->slot[id]) { in cvm_mmc_of_parse()
1000 clock_period = 1000000000000ull / slot->host->sys_freq; in cvm_mmc_of_parse()
1003 slot->cmd_cnt = (cmd_skew + clock_period / 2) / clock_period; in cvm_mmc_of_parse()
1004 slot->dat_cnt = (dat_skew + clock_period / 2) / clock_period; in cvm_mmc_of_parse()
1011 struct cvm_mmc_slot *slot; in cvm_mmc_of_slot_probe() local
1019 slot = mmc_priv(mmc); in cvm_mmc_of_slot_probe()
1020 slot->mmc = mmc; in cvm_mmc_of_slot_probe()
1021 slot->host = host; in cvm_mmc_of_slot_probe()
1023 ret = cvm_mmc_of_parse(dev, slot); in cvm_mmc_of_slot_probe()
1055 slot->clock = mmc->f_min; in cvm_mmc_of_slot_probe()
1056 slot->bus_id = id; in cvm_mmc_of_slot_probe()
1057 slot->cached_rca = 1; in cvm_mmc_of_slot_probe()
1060 host->slot[id] = slot; in cvm_mmc_of_slot_probe()
1061 cvm_mmc_switch_to(slot); in cvm_mmc_of_slot_probe()
1062 cvm_mmc_init_lowlevel(slot); in cvm_mmc_of_slot_probe()
1068 slot->host->slot[id] = NULL; in cvm_mmc_of_slot_probe()
1074 mmc_free_host(slot->mmc); in cvm_mmc_of_slot_probe()
1078 int cvm_mmc_of_slot_remove(struct cvm_mmc_slot *slot) in cvm_mmc_of_slot_remove() argument
1080 mmc_remove_host(slot->mmc); in cvm_mmc_of_slot_remove()
1081 slot->host->slot[slot->bus_id] = NULL; in cvm_mmc_of_slot_remove()
1082 mmc_free_host(slot->mmc); in cvm_mmc_of_slot_remove()