Lines Matching defs:slot
23 #include <linux/mmc/slot-gpio.h>
207 * Modes setting only taken from slot 0. Work around that hardware
208 * issue by first switching to slot 0.
228 static bool switch_val_changed(struct cvm_mmc_slot *slot, u64 new_val)
233 return (slot->cached_switch & match) != (new_val & match);
236 static void set_wdog(struct cvm_mmc_slot *slot, unsigned int ns)
240 if (!slot->clock)
244 timeout = (slot->clock * ns) / NSEC_PER_SEC;
246 timeout = (slot->clock * 850ull) / 1000ull;
247 writeq(timeout, slot->host->base + MIO_EMM_WDOG(slot->host));
250 static void cvm_mmc_reset_bus(struct cvm_mmc_slot *slot)
252 struct cvm_mmc_host *host = slot->host;
255 emm_switch = readq(slot->host->base + MIO_EMM_SWITCH(host));
258 set_bus_id(&emm_switch, slot->bus_id);
260 wdog = readq(slot->host->base + MIO_EMM_WDOG(host));
261 do_switch(slot->host, emm_switch);
263 slot->cached_switch = emm_switch;
267 writeq(wdog, slot->host->base + MIO_EMM_WDOG(host));
270 /* Switch to another slot if needed */
271 static void cvm_mmc_switch_to(struct cvm_mmc_slot *slot)
273 struct cvm_mmc_host *host = slot->host;
277 if (slot->bus_id == host->last_slot)
280 if (host->last_slot >= 0 && host->slot[host->last_slot]) {
281 old_slot = host->slot[host->last_slot];
286 writeq(slot->cached_rca, host->base + MIO_EMM_RCA(host));
287 emm_switch = slot->cached_switch;
288 set_bus_id(&emm_switch, slot->bus_id);
291 emm_sample = FIELD_PREP(MIO_EMM_SAMPLE_CMD_CNT, slot->cmd_cnt) |
292 FIELD_PREP(MIO_EMM_SAMPLE_DAT_CNT, slot->dat_cnt);
295 host->last_slot = slot->bus_id;
627 struct cvm_mmc_slot *slot = mmc_priv(mmc);
637 set_bus_id(&emm_dma, slot->bus_id);
652 struct cvm_mmc_slot *slot = mmc_priv(mmc);
653 struct cvm_mmc_host *host = slot->host;
663 cvm_mmc_switch_to(slot);
669 set_wdog(slot, data->timeout_ns);
689 * If we have a valid SD card in the slot, we set the response
752 struct cvm_mmc_slot *slot = mmc_priv(mmc);
753 struct cvm_mmc_host *host = slot->host;
774 cvm_mmc_switch_to(slot);
788 set_wdog(slot, cmd->data->timeout_ns);
790 set_wdog(slot, 0);
800 set_bus_id(&emm_cmd, slot->bus_id);
824 struct cvm_mmc_slot *slot = mmc_priv(mmc);
825 struct cvm_mmc_host *host = slot->host;
830 cvm_mmc_switch_to(slot);
838 cvm_mmc_reset_bus(slot);
874 slot->clock = clock;
885 set_bus_id(&emm_switch, slot->bus_id);
887 if (!switch_val_changed(slot, emm_switch))
890 set_wdog(slot, 0);
892 slot->cached_switch = emm_switch;
904 static void cvm_mmc_set_clock(struct cvm_mmc_slot *slot, unsigned int clock)
906 struct mmc_host *mmc = slot->mmc;
910 slot->clock = clock;
913 static int cvm_mmc_init_lowlevel(struct cvm_mmc_slot *slot)
915 struct cvm_mmc_host *host = slot->host;
918 /* Enable this bus slot. */
919 host->emm_cfg |= (1ull << slot->bus_id);
920 writeq(host->emm_cfg, slot->host->base + MIO_EMM_CFG(host));
924 cvm_mmc_set_clock(slot, slot->mmc->f_min);
927 (host->sys_freq / slot->clock) / 2);
929 (host->sys_freq / slot->clock) / 2);
931 /* Make the changes take effect on this bus slot. */
932 set_bus_id(&emm_switch, slot->bus_id);
935 slot->cached_switch = emm_switch;
943 set_wdog(slot, 0);
949 static int cvm_mmc_of_parse(struct device *dev, struct cvm_mmc_slot *slot)
953 struct mmc_host *mmc = slot->mmc;
963 if (id >= CAVIUM_MAX_MMC || slot->host->slot[id]) {
1000 clock_period = 1000000000000ull / slot->host->sys_freq;
1003 slot->cmd_cnt = (cmd_skew + clock_period / 2) / clock_period;
1004 slot->dat_cnt = (dat_skew + clock_period / 2) / clock_period;
1011 struct cvm_mmc_slot *slot;
1019 slot = mmc_priv(mmc);
1020 slot->mmc = mmc;
1021 slot->host = host;
1023 ret = cvm_mmc_of_parse(dev, slot);
1055 slot->clock = mmc->f_min;
1056 slot->bus_id = id;
1057 slot->cached_rca = 1;
1060 host->slot[id] = slot;
1061 cvm_mmc_switch_to(slot);
1062 cvm_mmc_init_lowlevel(slot);
1068 slot->host->slot[id] = NULL;
1074 mmc_free_host(slot->mmc);
1078 int cvm_mmc_of_slot_remove(struct cvm_mmc_slot *slot)
1080 mmc_remove_host(slot->mmc);
1081 slot->host->slot[slot->bus_id] = NULL;
1082 mmc_free_host(slot->mmc);