Lines Matching refs:host
401 static void msdc_reset_hw(struct msdc_host *host) in msdc_reset_hw() argument
405 setbits_le32(&host->base->msdc_cfg, MSDC_CFG_RST); in msdc_reset_hw()
407 readl_poll_timeout(&host->base->msdc_cfg, reg, in msdc_reset_hw()
411 static void msdc_fifo_clr(struct msdc_host *host) in msdc_fifo_clr() argument
415 setbits_le32(&host->base->msdc_fifocs, MSDC_FIFOCS_CLR); in msdc_fifo_clr()
417 readl_poll_timeout(&host->base->msdc_fifocs, reg, in msdc_fifo_clr()
421 static u32 msdc_fifo_rx_bytes(struct msdc_host *host) in msdc_fifo_rx_bytes() argument
423 return (readl(&host->base->msdc_fifocs) & in msdc_fifo_rx_bytes()
427 static u32 msdc_fifo_tx_bytes(struct msdc_host *host) in msdc_fifo_tx_bytes() argument
429 return (readl(&host->base->msdc_fifocs) & in msdc_fifo_tx_bytes()
433 static u32 msdc_cmd_find_resp(struct msdc_host *host, struct mmc_cmd *cmd) in msdc_cmd_find_resp() argument
460 static u32 msdc_cmd_prepare_raw_cmd(struct msdc_host *host, in msdc_cmd_prepare_raw_cmd() argument
465 u32 resp_type = msdc_cmd_find_resp(host, cmd); in msdc_cmd_prepare_raw_cmd()
510 static int msdc_cmd_done(struct msdc_host *host, int events, in msdc_cmd_done() argument
518 rsp[0] = readl(&host->base->sdc_resp[3]); in msdc_cmd_done()
519 rsp[1] = readl(&host->base->sdc_resp[2]); in msdc_cmd_done()
520 rsp[2] = readl(&host->base->sdc_resp[1]); in msdc_cmd_done()
521 rsp[3] = readl(&host->base->sdc_resp[0]); in msdc_cmd_done()
523 rsp[0] = readl(&host->base->sdc_resp[0]); in msdc_cmd_done()
534 msdc_reset_hw(host); in msdc_cmd_done()
545 static bool msdc_cmd_is_ready(struct msdc_host *host) in msdc_cmd_is_ready() argument
551 ret = readl_poll_timeout(&host->base->sdc_sts, reg, in msdc_cmd_is_ready()
556 msdc_reset_hw(host); in msdc_cmd_is_ready()
560 if (host->last_resp_type == MMC_RSP_R1b && host->last_data_write) { in msdc_cmd_is_ready()
561 ret = readl_poll_timeout(&host->base->msdc_ps, reg, in msdc_cmd_is_ready()
566 msdc_reset_hw(host); in msdc_cmd_is_ready()
574 static int msdc_start_command(struct msdc_host *host, struct mmc_cmd *cmd, in msdc_start_command() argument
582 if (!msdc_cmd_is_ready(host)) in msdc_start_command()
585 if ((readl(&host->base->msdc_fifocs) & in msdc_start_command()
587 (readl(&host->base->msdc_fifocs) & in msdc_start_command()
590 msdc_reset_hw(host); in msdc_start_command()
593 msdc_fifo_clr(host); in msdc_start_command()
595 host->last_resp_type = cmd->resp_type; in msdc_start_command()
596 host->last_data_write = 0; in msdc_start_command()
598 rawcmd = msdc_cmd_prepare_raw_cmd(host, cmd, data); in msdc_start_command()
603 writel(CMD_INTS_MASK, &host->base->msdc_int); in msdc_start_command()
604 writel(DATA_INTS_MASK, &host->base->msdc_int); in msdc_start_command()
605 writel(blocks, &host->base->sdc_blk_num); in msdc_start_command()
606 writel(cmd->cmdarg, &host->base->sdc_arg); in msdc_start_command()
607 writel(rawcmd, &host->base->sdc_cmd); in msdc_start_command()
609 ret = readl_poll_timeout(&host->base->msdc_int, status, in msdc_start_command()
615 return msdc_cmd_done(host, status, cmd); in msdc_start_command()
618 static void msdc_fifo_read(struct msdc_host *host, u8 *buf, u32 size) in msdc_fifo_read() argument
623 *buf++ = readb(&host->base->msdc_rxdata); in msdc_fifo_read()
629 *wbuf++ = readl(&host->base->msdc_rxdata); in msdc_fifo_read()
635 *buf++ = readb(&host->base->msdc_rxdata); in msdc_fifo_read()
640 static void msdc_fifo_write(struct msdc_host *host, const u8 *buf, u32 size) in msdc_fifo_write() argument
645 writeb(*buf++, &host->base->msdc_txdata); in msdc_fifo_write()
651 writel(*wbuf++, &host->base->msdc_txdata); in msdc_fifo_write()
657 writeb(*buf++, &host->base->msdc_txdata); in msdc_fifo_write()
662 static int msdc_pio_read(struct msdc_host *host, u8 *ptr, u32 size) in msdc_pio_read() argument
669 status = readl(&host->base->msdc_int); in msdc_pio_read()
670 writel(status, &host->base->msdc_int); in msdc_pio_read()
685 if (msdc_fifo_rx_bytes(host) >= chksz) { in msdc_pio_read()
686 msdc_fifo_read(host, ptr, chksz); in msdc_pio_read()
704 static int msdc_pio_write(struct msdc_host *host, const u8 *ptr, u32 size) in msdc_pio_write() argument
711 status = readl(&host->base->msdc_int); in msdc_pio_write()
712 writel(status, &host->base->msdc_int); in msdc_pio_write()
736 if (MSDC_FIFO_SIZE - msdc_fifo_tx_bytes(host) >= chksz) { in msdc_pio_write()
737 msdc_fifo_write(host, ptr, chksz); in msdc_pio_write()
746 static int msdc_start_data(struct msdc_host *host, struct mmc_data *data) in msdc_start_data() argument
752 host->last_data_write = 1; in msdc_start_data()
757 ret = msdc_pio_write(host, (const u8 *)data->src, size); in msdc_start_data()
759 ret = msdc_pio_read(host, (u8 *)data->dest, size); in msdc_start_data()
762 msdc_reset_hw(host); in msdc_start_data()
763 msdc_fifo_clr(host); in msdc_start_data()
772 struct msdc_host *host = dev_get_priv(dev); in msdc_ops_send_cmd() local
775 cmd_ret = msdc_start_command(host, cmd, data); in msdc_ops_send_cmd()
783 data_ret = msdc_start_data(host, data); in msdc_ops_send_cmd()
793 static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks) in msdc_set_timeout() argument
798 host->timeout_ns = ns; in msdc_set_timeout()
799 host->timeout_clks = clks; in msdc_set_timeout()
801 if (host->sclk == 0) { in msdc_set_timeout()
804 clk_ns = 1000000000UL / host->sclk; in msdc_set_timeout()
808 if (host->dev_comp->clk_div_bits == 8) in msdc_set_timeout()
809 mode = (readl(&host->base->msdc_cfg) & in msdc_set_timeout()
812 mode = (readl(&host->base->msdc_cfg) & in msdc_set_timeout()
820 clrsetbits_le32(&host->base->sdc_cfg, SDC_CFG_DTOC_M, in msdc_set_timeout()
824 static void msdc_set_buswidth(struct msdc_host *host, u32 width) in msdc_set_buswidth() argument
826 u32 val = readl(&host->base->sdc_cfg); in msdc_set_buswidth()
843 writel(val, &host->base->sdc_cfg); in msdc_set_buswidth()
847 struct msdc_host *host, enum bus_mode timing, u32 hz) in msdc_set_mclk() argument
855 host->mclk = 0; in msdc_set_mclk()
856 clrbits_le32(&host->base->msdc_cfg, MSDC_CFG_CKPDN); in msdc_set_mclk()
860 if (host->dev_comp->clk_div_bits == 8) in msdc_set_mclk()
861 clrbits_le32(&host->base->msdc_cfg, MSDC_CFG_HS400_CK_MODE); in msdc_set_mclk()
863 clrbits_le32(&host->base->msdc_cfg, in msdc_set_mclk()
873 if (hz >= (host->src_clk_freq >> 2)) { in msdc_set_mclk()
875 sclk = host->src_clk_freq >> 2; /* sclk = clk / 4 */ in msdc_set_mclk()
877 div = (host->src_clk_freq + ((hz << 2) - 1)) / in msdc_set_mclk()
879 sclk = (host->src_clk_freq >> 2) / div; in msdc_set_mclk()
883 if (timing == MMC_HS_400 && hz >= (host->src_clk_freq >> 1)) { in msdc_set_mclk()
884 if (host->dev_comp->clk_div_bits == 8) in msdc_set_mclk()
885 setbits_le32(&host->base->msdc_cfg, in msdc_set_mclk()
888 setbits_le32(&host->base->msdc_cfg, in msdc_set_mclk()
891 sclk = host->src_clk_freq >> 1; in msdc_set_mclk()
894 } else if (hz >= host->src_clk_freq) { in msdc_set_mclk()
897 sclk = host->src_clk_freq; in msdc_set_mclk()
900 if (hz >= (host->src_clk_freq >> 1)) { in msdc_set_mclk()
902 sclk = host->src_clk_freq >> 1; /* sclk = clk / 2 */ in msdc_set_mclk()
904 div = (host->src_clk_freq + ((hz << 2) - 1)) / in msdc_set_mclk()
906 sclk = (host->src_clk_freq >> 2) / div; in msdc_set_mclk()
910 clrbits_le32(&host->base->msdc_cfg, MSDC_CFG_CKPDN); in msdc_set_mclk()
912 if (host->dev_comp->clk_div_bits == 8) { in msdc_set_mclk()
914 clrsetbits_le32(&host->base->msdc_cfg, in msdc_set_mclk()
921 clrsetbits_le32(&host->base->msdc_cfg, in msdc_set_mclk()
927 readl_poll_timeout(&host->base->msdc_cfg, reg, in msdc_set_mclk()
930 setbits_le32(&host->base->msdc_cfg, MSDC_CFG_CKPDN); in msdc_set_mclk()
931 host->sclk = sclk; in msdc_set_mclk()
932 host->mclk = hz; in msdc_set_mclk()
933 host->timing = timing; in msdc_set_mclk()
936 msdc_set_timeout(host, host->timeout_ns, host->timeout_clks); in msdc_set_mclk()
942 if (host->sclk <= 52000000) { in msdc_set_mclk()
943 writel(host->def_tune_para.iocon, &host->base->msdc_iocon); in msdc_set_mclk()
944 writel(host->def_tune_para.pad_tune, in msdc_set_mclk()
945 &host->base->pad_tune); in msdc_set_mclk()
947 writel(host->saved_tune_para.iocon, &host->base->msdc_iocon); in msdc_set_mclk()
948 writel(host->saved_tune_para.pad_tune, in msdc_set_mclk()
949 &host->base->pad_tune); in msdc_set_mclk()
952 dev_dbg(dev, "sclk: %d, timing: %d\n", host->sclk, timing); in msdc_set_mclk()
958 struct msdc_host *host = dev_get_priv(dev); in msdc_ops_set_ios() local
962 msdc_set_buswidth(host, mmc->bus_width); in msdc_ops_set_ios()
969 if (host->mclk != clock || host->timing != mmc->selected_mode) in msdc_ops_set_ios()
970 msdc_set_mclk(dev, host, mmc->selected_mode, clock); in msdc_ops_set_ios()
977 struct msdc_host *host = dev_get_priv(dev); in msdc_ops_get_cd() local
980 if (host->builtin_cd) { in msdc_ops_get_cd()
981 val = readl(&host->base->msdc_ps); in msdc_ops_get_cd()
984 return !val ^ host->cd_active_high; in msdc_ops_get_cd()
988 if (!host->gpio_cd.dev) in msdc_ops_get_cd()
991 return dm_gpio_get_value(&host->gpio_cd); in msdc_ops_get_cd()
1000 struct msdc_host *host = dev_get_priv(dev); in msdc_ops_get_wp() local
1002 if (!host->gpio_wp.dev) in msdc_ops_get_wp()
1005 return !dm_gpio_get_value(&host->gpio_wp); in msdc_ops_get_wp()
1031 struct msdc_host *host, u32 delay) in get_best_delay() argument
1071 static inline void msdc_set_cmd_delay(struct msdc_host *host, u32 value) in msdc_set_cmd_delay() argument
1073 void __iomem *tune_reg = &host->base->pad_tune; in msdc_set_cmd_delay()
1075 if (host->dev_comp->pad_tune0) in msdc_set_cmd_delay()
1076 tune_reg = &host->base->pad_tune0; in msdc_set_cmd_delay()
1078 if (host->top_base) in msdc_set_cmd_delay()
1079 clrsetbits_le32(&host->top_base->emmc_top_cmd, PAD_CMD_RXDLY, in msdc_set_cmd_delay()
1086 static inline void msdc_set_data_delay(struct msdc_host *host, u32 value) in msdc_set_data_delay() argument
1088 void __iomem *tune_reg = &host->base->pad_tune; in msdc_set_data_delay()
1090 if (host->dev_comp->pad_tune0) in msdc_set_data_delay()
1091 tune_reg = &host->base->pad_tune0; in msdc_set_data_delay()
1093 if (host->top_base) in msdc_set_data_delay()
1094 clrsetbits_le32(&host->top_base->emmc_top_control, in msdc_set_data_delay()
1104 struct msdc_host *host = dev_get_priv(dev); in hs400_tune_response() local
1109 void __iomem *tune_reg = &host->base->pad_cmd_tune; in hs400_tune_response()
1113 setbits_le32(&host->base->pad_cmd_tune, BIT(0)); in hs400_tune_response()
1118 host->hs200_cmd_int_delay << in hs400_tune_response()
1121 if (host->r_smpl) in hs400_tune_response()
1122 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL); in hs400_tune_response()
1124 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL); in hs400_tune_response()
1141 final_cmd_delay = get_best_delay(dev, host, cmd_delay); in hs400_tune_response()
1154 struct msdc_host *host = dev_get_priv(dev); in msdc_tune_response() local
1161 void __iomem *tune_reg = &host->base->pad_tune; in msdc_tune_response()
1165 if (host->dev_comp->pad_tune0) in msdc_tune_response()
1166 tune_reg = &host->base->pad_tune0; in msdc_tune_response()
1171 host->hs200_cmd_int_delay << in msdc_tune_response()
1174 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL); in msdc_tune_response()
1191 final_rise_delay = get_best_delay(dev, host, rise_delay); in msdc_tune_response()
1197 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL); in msdc_tune_response()
1213 final_fall_delay = get_best_delay(dev, host, fall_delay); in msdc_tune_response()
1218 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL); in msdc_tune_response()
1224 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL); in msdc_tune_response()
1231 if (host->dev_comp->async_fifo || host->hs200_cmd_int_delay) in msdc_tune_response()
1245 internal_delay_phase = get_best_delay(dev, host, internal_delay); in msdc_tune_response()
1258 struct msdc_host *host = dev_get_priv(dev); in msdc_tune_data() local
1263 void __iomem *tune_reg = &host->base->pad_tune; in msdc_tune_data()
1267 if (host->dev_comp->pad_tune0) in msdc_tune_data()
1268 tune_reg = &host->base->pad_tune0; in msdc_tune_data()
1270 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_DSPL); in msdc_tune_data()
1271 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_W_DSPL); in msdc_tune_data()
1288 final_rise_delay = get_best_delay(dev, host, rise_delay); in msdc_tune_data()
1293 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_DSPL); in msdc_tune_data()
1294 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_W_DSPL); in msdc_tune_data()
1311 final_fall_delay = get_best_delay(dev, host, fall_delay); in msdc_tune_data()
1316 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_DSPL); in msdc_tune_data()
1317 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_W_DSPL); in msdc_tune_data()
1323 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_DSPL); in msdc_tune_data()
1324 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_W_DSPL); in msdc_tune_data()
1334 host->hs200_write_int_delay << in msdc_tune_data()
1349 struct msdc_host *host = dev_get_priv(dev); in msdc_tune_together() local
1356 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_DSPL); in msdc_tune_together()
1357 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_W_DSPL); in msdc_tune_together()
1360 msdc_set_cmd_delay(host, i); in msdc_tune_together()
1361 msdc_set_data_delay(host, i); in msdc_tune_together()
1367 final_rise_delay = get_best_delay(dev, host, rise_delay); in msdc_tune_together()
1372 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_DSPL); in msdc_tune_together()
1373 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_W_DSPL); in msdc_tune_together()
1376 msdc_set_cmd_delay(host, i); in msdc_tune_together()
1377 msdc_set_data_delay(host, i); in msdc_tune_together()
1383 final_fall_delay = get_best_delay(dev, host, fall_delay); in msdc_tune_together()
1388 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_DSPL); in msdc_tune_together()
1389 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_W_DSPL); in msdc_tune_together()
1392 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_DSPL); in msdc_tune_together()
1393 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_W_DSPL); in msdc_tune_together()
1397 msdc_set_cmd_delay(host, final_delay); in msdc_tune_together()
1398 msdc_set_data_delay(host, final_delay); in msdc_tune_together()
1407 struct msdc_host *host = dev_get_priv(dev); in msdc_execute_tuning() local
1411 if (host->dev_comp->data_tune && host->dev_comp->async_fifo) { in msdc_execute_tuning()
1419 clrbits_le32(&host->base->msdc_iocon, in msdc_execute_tuning()
1421 clrsetbits_le32(&host->base->pad_tune, in msdc_execute_tuning()
1424 writel(host->hs400_ds_delay, &host->base->pad_ds_tune); in msdc_execute_tuning()
1426 clrbits_le32(&host->base->patch_bit2, in msdc_execute_tuning()
1428 host->hs400_mode = true; in msdc_execute_tuning()
1451 host->saved_tune_para.iocon = readl(&host->base->msdc_iocon); in msdc_execute_tuning()
1452 host->saved_tune_para.pad_tune = readl(&host->base->pad_tune); in msdc_execute_tuning()
1453 host->saved_tune_para.pad_cmd_tune = readl(&host->base->pad_cmd_tune); in msdc_execute_tuning()
1459 static void msdc_init_hw(struct msdc_host *host) in msdc_init_hw() argument
1462 void __iomem *tune_reg = &host->base->pad_tune; in msdc_init_hw()
1463 void __iomem *rd_dly0_reg = &host->base->pad_tune0; in msdc_init_hw()
1464 void __iomem *rd_dly1_reg = &host->base->pad_tune1; in msdc_init_hw()
1466 if (host->dev_comp->pad_tune0) { in msdc_init_hw()
1467 tune_reg = &host->base->pad_tune0; in msdc_init_hw()
1468 rd_dly0_reg = &host->base->dat_rd_dly[0]; in msdc_init_hw()
1469 rd_dly1_reg = &host->base->dat_rd_dly[1]; in msdc_init_hw()
1473 setbits_le32(&host->base->msdc_cfg, MSDC_CFG_MODE); in msdc_init_hw()
1476 setbits_le32(&host->base->msdc_cfg, MSDC_CFG_PIO); in msdc_init_hw()
1479 msdc_reset_hw(host); in msdc_init_hw()
1482 if (host->builtin_cd) in msdc_init_hw()
1483 clrsetbits_le32(&host->base->msdc_ps, in msdc_init_hw()
1488 clrbits_le32(&host->base->msdc_ps, MSDC_PS_CDEN); in msdc_init_hw()
1491 val = readl(&host->base->msdc_int); in msdc_init_hw()
1492 writel(val, &host->base->msdc_int); in msdc_init_hw()
1495 writel(DATA_INTS_MASK | CMD_INTS_MASK, &host->base->msdc_inten); in msdc_init_hw()
1498 writel(0, &host->base->msdc_iocon); in msdc_init_hw()
1500 if (host->r_smpl) in msdc_init_hw()
1501 setbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL); in msdc_init_hw()
1503 clrbits_le32(&host->base->msdc_iocon, MSDC_IOCON_RSPL); in msdc_init_hw()
1505 writel(0x403c0046, &host->base->patch_bit0); in msdc_init_hw()
1506 writel(0xffff4089, &host->base->patch_bit1); in msdc_init_hw()
1508 if (host->dev_comp->stop_clk_fix) in msdc_init_hw()
1509 clrsetbits_le32(&host->base->patch_bit1, MSDC_PB1_STOP_DLY_M, in msdc_init_hw()
1512 if (host->dev_comp->busy_check) in msdc_init_hw()
1513 clrbits_le32(&host->base->patch_bit1, (1 << 7)); in msdc_init_hw()
1515 setbits_le32(&host->base->emmc50_cfg0, EMMC50_CFG_CFCSTS_SEL); in msdc_init_hw()
1517 if (host->dev_comp->async_fifo) { in msdc_init_hw()
1518 clrsetbits_le32(&host->base->patch_bit2, MSDC_PB2_RESPWAIT_M, in msdc_init_hw()
1521 if (host->dev_comp->enhance_rx) { in msdc_init_hw()
1522 if (host->top_base) in msdc_init_hw()
1523 setbits_le32(&host->top_base->emmc_top_control, in msdc_init_hw()
1526 setbits_le32(&host->base->sdc_adv_cfg0, in msdc_init_hw()
1529 clrsetbits_le32(&host->base->patch_bit2, in msdc_init_hw()
1532 clrsetbits_le32(&host->base->patch_bit2, in msdc_init_hw()
1538 clrbits_le32(&host->base->patch_bit2, in msdc_init_hw()
1540 clrbits_le32(&host->base->patch_bit2, in msdc_init_hw()
1544 if (host->dev_comp->data_tune) { in msdc_init_hw()
1547 clrsetbits_le32(&host->base->patch_bit0, in msdc_init_hw()
1549 host->latch_ck << in msdc_init_hw()
1556 if (host->dev_comp->builtin_pad_ctrl) { in msdc_init_hw()
1560 (4 << MSDC_PAD_CTRL0_CLKDRVP_S), &host->base->pad_ctrl0); in msdc_init_hw()
1563 (4 << MSDC_PAD_CTRL1_CMDDRVP_S), &host->base->pad_ctrl1); in msdc_init_hw()
1566 (4 << MSDC_PAD_CTRL2_DATDRVP_S), &host->base->pad_ctrl2); in msdc_init_hw()
1569 if (host->dev_comp->default_pad_dly) { in msdc_init_hw()
1596 setbits_le32(&host->base->sdc_cfg, SDC_CFG_SDIO); in msdc_init_hw()
1599 clrbits_le32(&host->base->sdc_cfg, SDC_CFG_SDIOIDE); in msdc_init_hw()
1602 clrsetbits_le32(&host->base->sdc_cfg, SDC_CFG_DTOC_M, in msdc_init_hw()
1605 if (host->dev_comp->stop_clk_fix) { in msdc_init_hw()
1606 clrbits_le32(&host->base->sdc_fifo_cfg, in msdc_init_hw()
1608 clrbits_le32(&host->base->sdc_fifo_cfg, in msdc_init_hw()
1612 host->def_tune_para.iocon = readl(&host->base->msdc_iocon); in msdc_init_hw()
1613 host->def_tune_para.pad_tune = readl(&host->base->pad_tune); in msdc_init_hw()
1616 static void msdc_ungate_clock(struct msdc_host *host) in msdc_ungate_clock() argument
1618 clk_enable(&host->src_clk); in msdc_ungate_clock()
1619 clk_enable(&host->h_clk); in msdc_ungate_clock()
1620 if (host->src_clk_cg.dev) in msdc_ungate_clock()
1621 clk_enable(&host->src_clk_cg); in msdc_ungate_clock()
1628 struct msdc_host *host = dev_get_priv(dev); in msdc_drv_probe() local
1633 host->dev_comp = (struct msdc_compatible *)dev_get_driver_data(dev); in msdc_drv_probe()
1635 host->src_clk_freq = clk_get_rate(&host->src_clk); in msdc_drv_probe()
1637 if (host->dev_comp->clk_div_bits == 8) in msdc_drv_probe()
1638 cfg->f_min = host->src_clk_freq / (4 * 255); in msdc_drv_probe()
1640 cfg->f_min = host->src_clk_freq / (4 * 4095); in msdc_drv_probe()
1642 if (cfg->f_max < cfg->f_min || cfg->f_max > host->src_clk_freq) in msdc_drv_probe()
1643 cfg->f_max = host->src_clk_freq; in msdc_drv_probe()
1648 host->mmc = &plat->mmc; in msdc_drv_probe()
1649 host->timeout_ns = 100000000; in msdc_drv_probe()
1650 host->timeout_clks = 3 * (1 << SCLK_CYCLES_SHIFT); in msdc_drv_probe()
1656 msdc_ungate_clock(host); in msdc_drv_probe()
1657 msdc_init_hw(host); in msdc_drv_probe()
1667 struct msdc_host *host = dev_get_priv(dev); in msdc_of_to_plat() local
1675 host->base = map_sysmem(base, 0); in msdc_of_to_plat()
1679 host->top_base = NULL; in msdc_of_to_plat()
1681 host->top_base = map_sysmem(top_base, 0); in msdc_of_to_plat()
1687 ret = clk_get_by_name(dev, "source", &host->src_clk); in msdc_of_to_plat()
1691 ret = clk_get_by_name(dev, "hclk", &host->h_clk); in msdc_of_to_plat()
1695 clk_get_by_name(dev, "source_cg", &host->src_clk_cg); /* optional */ in msdc_of_to_plat()
1698 gpio_request_by_name(dev, "wp-gpios", 0, &host->gpio_wp, GPIOD_IS_IN); in msdc_of_to_plat()
1699 gpio_request_by_name(dev, "cd-gpios", 0, &host->gpio_cd, GPIOD_IS_IN); in msdc_of_to_plat()
1702 host->hs400_ds_delay = dev_read_u32_default(dev, "hs400-ds-delay", 0); in msdc_of_to_plat()
1703 host->hs200_cmd_int_delay = in msdc_of_to_plat()
1705 host->hs200_write_int_delay = in msdc_of_to_plat()
1707 host->latch_ck = dev_read_u32_default(dev, "latch-ck", 0); in msdc_of_to_plat()
1708 host->r_smpl = dev_read_u32_default(dev, "r_smpl", 0); in msdc_of_to_plat()
1709 host->builtin_cd = dev_read_u32_default(dev, "builtin-cd", 0); in msdc_of_to_plat()
1710 host->cd_active_high = dev_read_bool(dev, "cd-active-high"); in msdc_of_to_plat()