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;
628 struct cvm_mmc_slot *slot = mmc_priv(mmc);
638 set_bus_id(&emm_dma, slot->bus_id);
653 struct cvm_mmc_slot *slot = mmc_priv(mmc);
654 struct cvm_mmc_host *host = slot->host;
665 cvm_mmc_switch_to(slot);
671 set_wdog(slot, data->timeout_ns);
691 * If we have a valid SD card in the slot, we set the response
754 struct cvm_mmc_slot *slot = mmc_priv(mmc);
755 struct cvm_mmc_host *host = slot->host;
776 cvm_mmc_switch_to(slot);
790 set_wdog(slot, cmd->data->timeout_ns);
792 set_wdog(slot, 0);
802 set_bus_id(&emm_cmd, slot->bus_id);
826 struct cvm_mmc_slot *slot = mmc_priv(mmc);
827 struct cvm_mmc_host *host = slot->host;
832 cvm_mmc_switch_to(slot);
840 cvm_mmc_reset_bus(slot);
876 slot->clock = clock;
887 set_bus_id(&emm_switch, slot->bus_id);
889 if (!switch_val_changed(slot, emm_switch))
892 set_wdog(slot, 0);
894 slot->cached_switch = emm_switch;
906 static void cvm_mmc_set_clock(struct cvm_mmc_slot *slot, unsigned int clock)
908 struct mmc_host *mmc = slot->mmc;
912 slot->clock = clock;
915 static int cvm_mmc_init_lowlevel(struct cvm_mmc_slot *slot)
917 struct cvm_mmc_host *host = slot->host;
920 /* Enable this bus slot. */
921 host->emm_cfg |= (1ull << slot->bus_id);
922 writeq(host->emm_cfg, slot->host->base + MIO_EMM_CFG(host));
926 cvm_mmc_set_clock(slot, slot->mmc->f_min);
929 (host->sys_freq / slot->clock) / 2);
931 (host->sys_freq / slot->clock) / 2);
933 /* Make the changes take effect on this bus slot. */
934 set_bus_id(&emm_switch, slot->bus_id);
937 slot->cached_switch = emm_switch;
945 set_wdog(slot, 0);
951 static int cvm_mmc_of_parse(struct device *dev, struct cvm_mmc_slot *slot)
955 struct mmc_host *mmc = slot->mmc;
965 if (id >= CAVIUM_MAX_MMC || slot->host->slot[id]) {
1002 clock_period = 1000000000000ull / slot->host->sys_freq;
1005 slot->cmd_cnt = (cmd_skew + clock_period / 2) / clock_period;
1006 slot->dat_cnt = (dat_skew + clock_period / 2) / clock_period;
1013 struct cvm_mmc_slot *slot;
1021 slot = mmc_priv(mmc);
1022 slot->mmc = mmc;
1023 slot->host = host;
1025 ret = cvm_mmc_of_parse(dev, slot);
1057 slot->clock = mmc->f_min;
1058 slot->bus_id = id;
1059 slot->cached_rca = 1;
1062 host->slot[id] = slot;
1063 cvm_mmc_switch_to(slot);
1064 cvm_mmc_init_lowlevel(slot);
1070 slot->host->slot[id] = NULL;
1076 mmc_free_host(slot->mmc);
1080 int cvm_mmc_of_slot_remove(struct cvm_mmc_slot *slot)
1082 mmc_remove_host(slot->mmc);
1083 slot->host->slot[slot->bus_id] = NULL;
1084 mmc_free_host(slot->mmc);