aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/mmci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/host/mmci.c')
-rw-r--r--drivers/mmc/host/mmci.c168
1 files changed, 140 insertions, 28 deletions
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 7ad463e9741c..e4d470704150 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -52,34 +52,53 @@ static unsigned int fmax = 515633;
52 * struct variant_data - MMCI variant-specific quirks 52 * struct variant_data - MMCI variant-specific quirks
53 * @clkreg: default value for MCICLOCK register 53 * @clkreg: default value for MCICLOCK register
54 * @clkreg_enable: enable value for MMCICLOCK register 54 * @clkreg_enable: enable value for MMCICLOCK register
55 * @clkreg_8bit_bus_enable: enable value for 8 bit bus
56 * @clkreg_neg_edge_enable: enable value for inverted data/cmd output
55 * @datalength_bits: number of bits in the MMCIDATALENGTH register 57 * @datalength_bits: number of bits in the MMCIDATALENGTH register
56 * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY 58 * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY
57 * is asserted (likewise for RX) 59 * is asserted (likewise for RX)
58 * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY 60 * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY
59 * is asserted (likewise for RX) 61 * is asserted (likewise for RX)
62 * @data_cmd_enable: enable value for data commands.
60 * @sdio: variant supports SDIO 63 * @sdio: variant supports SDIO
61 * @st_clkdiv: true if using a ST-specific clock divider algorithm 64 * @st_clkdiv: true if using a ST-specific clock divider algorithm
65 * @datactrl_mask_ddrmode: ddr mode mask in datactrl register.
62 * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register 66 * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register
67 * @blksz_datactrl4: true if Block size is at b4..b16 position in datactrl
68 * register
63 * @pwrreg_powerup: power up value for MMCIPOWER register 69 * @pwrreg_powerup: power up value for MMCIPOWER register
70 * @f_max: maximum clk frequency supported by the controller.
64 * @signal_direction: input/out direction of bus signals can be indicated 71 * @signal_direction: input/out direction of bus signals can be indicated
65 * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock 72 * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock
66 * @busy_detect: true if busy detection on dat0 is supported 73 * @busy_detect: true if busy detection on dat0 is supported
67 * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply 74 * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply
75 * @explicit_mclk_control: enable explicit mclk control in driver.
76 * @qcom_fifo: enables qcom specific fifo pio read logic.
77 * @reversed_irq_handling: handle data irq before cmd irq.
68 */ 78 */
69struct variant_data { 79struct variant_data {
70 unsigned int clkreg; 80 unsigned int clkreg;
71 unsigned int clkreg_enable; 81 unsigned int clkreg_enable;
82 unsigned int clkreg_8bit_bus_enable;
83 unsigned int clkreg_neg_edge_enable;
72 unsigned int datalength_bits; 84 unsigned int datalength_bits;
73 unsigned int fifosize; 85 unsigned int fifosize;
74 unsigned int fifohalfsize; 86 unsigned int fifohalfsize;
87 unsigned int data_cmd_enable;
88 unsigned int datactrl_mask_ddrmode;
75 bool sdio; 89 bool sdio;
76 bool st_clkdiv; 90 bool st_clkdiv;
77 bool blksz_datactrl16; 91 bool blksz_datactrl16;
92 bool blksz_datactrl4;
78 u32 pwrreg_powerup; 93 u32 pwrreg_powerup;
94 u32 f_max;
79 bool signal_direction; 95 bool signal_direction;
80 bool pwrreg_clkgate; 96 bool pwrreg_clkgate;
81 bool busy_detect; 97 bool busy_detect;
82 bool pwrreg_nopower; 98 bool pwrreg_nopower;
99 bool explicit_mclk_control;
100 bool qcom_fifo;
101 bool reversed_irq_handling;
83}; 102};
84 103
85static struct variant_data variant_arm = { 104static struct variant_data variant_arm = {
@@ -87,6 +106,8 @@ static struct variant_data variant_arm = {
87 .fifohalfsize = 8 * 4, 106 .fifohalfsize = 8 * 4,
88 .datalength_bits = 16, 107 .datalength_bits = 16,
89 .pwrreg_powerup = MCI_PWR_UP, 108 .pwrreg_powerup = MCI_PWR_UP,
109 .f_max = 100000000,
110 .reversed_irq_handling = true,
90}; 111};
91 112
92static struct variant_data variant_arm_extended_fifo = { 113static struct variant_data variant_arm_extended_fifo = {
@@ -94,6 +115,7 @@ static struct variant_data variant_arm_extended_fifo = {
94 .fifohalfsize = 64 * 4, 115 .fifohalfsize = 64 * 4,
95 .datalength_bits = 16, 116 .datalength_bits = 16,
96 .pwrreg_powerup = MCI_PWR_UP, 117 .pwrreg_powerup = MCI_PWR_UP,
118 .f_max = 100000000,
97}; 119};
98 120
99static struct variant_data variant_arm_extended_fifo_hwfc = { 121static struct variant_data variant_arm_extended_fifo_hwfc = {
@@ -102,15 +124,18 @@ static struct variant_data variant_arm_extended_fifo_hwfc = {
102 .clkreg_enable = MCI_ARM_HWFCEN, 124 .clkreg_enable = MCI_ARM_HWFCEN,
103 .datalength_bits = 16, 125 .datalength_bits = 16,
104 .pwrreg_powerup = MCI_PWR_UP, 126 .pwrreg_powerup = MCI_PWR_UP,
127 .f_max = 100000000,
105}; 128};
106 129
107static struct variant_data variant_u300 = { 130static struct variant_data variant_u300 = {
108 .fifosize = 16 * 4, 131 .fifosize = 16 * 4,
109 .fifohalfsize = 8 * 4, 132 .fifohalfsize = 8 * 4,
110 .clkreg_enable = MCI_ST_U300_HWFCEN, 133 .clkreg_enable = MCI_ST_U300_HWFCEN,
134 .clkreg_8bit_bus_enable = MCI_ST_8BIT_BUS,
111 .datalength_bits = 16, 135 .datalength_bits = 16,
112 .sdio = true, 136 .sdio = true,
113 .pwrreg_powerup = MCI_PWR_ON, 137 .pwrreg_powerup = MCI_PWR_ON,
138 .f_max = 100000000,
114 .signal_direction = true, 139 .signal_direction = true,
115 .pwrreg_clkgate = true, 140 .pwrreg_clkgate = true,
116 .pwrreg_nopower = true, 141 .pwrreg_nopower = true,
@@ -124,6 +149,7 @@ static struct variant_data variant_nomadik = {
124 .sdio = true, 149 .sdio = true,
125 .st_clkdiv = true, 150 .st_clkdiv = true,
126 .pwrreg_powerup = MCI_PWR_ON, 151 .pwrreg_powerup = MCI_PWR_ON,
152 .f_max = 100000000,
127 .signal_direction = true, 153 .signal_direction = true,
128 .pwrreg_clkgate = true, 154 .pwrreg_clkgate = true,
129 .pwrreg_nopower = true, 155 .pwrreg_nopower = true,
@@ -134,10 +160,13 @@ static struct variant_data variant_ux500 = {
134 .fifohalfsize = 8 * 4, 160 .fifohalfsize = 8 * 4,
135 .clkreg = MCI_CLK_ENABLE, 161 .clkreg = MCI_CLK_ENABLE,
136 .clkreg_enable = MCI_ST_UX500_HWFCEN, 162 .clkreg_enable = MCI_ST_UX500_HWFCEN,
163 .clkreg_8bit_bus_enable = MCI_ST_8BIT_BUS,
164 .clkreg_neg_edge_enable = MCI_ST_UX500_NEG_EDGE,
137 .datalength_bits = 24, 165 .datalength_bits = 24,
138 .sdio = true, 166 .sdio = true,
139 .st_clkdiv = true, 167 .st_clkdiv = true,
140 .pwrreg_powerup = MCI_PWR_ON, 168 .pwrreg_powerup = MCI_PWR_ON,
169 .f_max = 100000000,
141 .signal_direction = true, 170 .signal_direction = true,
142 .pwrreg_clkgate = true, 171 .pwrreg_clkgate = true,
143 .busy_detect = true, 172 .busy_detect = true,
@@ -149,17 +178,38 @@ static struct variant_data variant_ux500v2 = {
149 .fifohalfsize = 8 * 4, 178 .fifohalfsize = 8 * 4,
150 .clkreg = MCI_CLK_ENABLE, 179 .clkreg = MCI_CLK_ENABLE,
151 .clkreg_enable = MCI_ST_UX500_HWFCEN, 180 .clkreg_enable = MCI_ST_UX500_HWFCEN,
181 .clkreg_8bit_bus_enable = MCI_ST_8BIT_BUS,
182 .clkreg_neg_edge_enable = MCI_ST_UX500_NEG_EDGE,
183 .datactrl_mask_ddrmode = MCI_ST_DPSM_DDRMODE,
152 .datalength_bits = 24, 184 .datalength_bits = 24,
153 .sdio = true, 185 .sdio = true,
154 .st_clkdiv = true, 186 .st_clkdiv = true,
155 .blksz_datactrl16 = true, 187 .blksz_datactrl16 = true,
156 .pwrreg_powerup = MCI_PWR_ON, 188 .pwrreg_powerup = MCI_PWR_ON,
189 .f_max = 100000000,
157 .signal_direction = true, 190 .signal_direction = true,
158 .pwrreg_clkgate = true, 191 .pwrreg_clkgate = true,
159 .busy_detect = true, 192 .busy_detect = true,
160 .pwrreg_nopower = true, 193 .pwrreg_nopower = true,
161}; 194};
162 195
196static struct variant_data variant_qcom = {
197 .fifosize = 16 * 4,
198 .fifohalfsize = 8 * 4,
199 .clkreg = MCI_CLK_ENABLE,
200 .clkreg_enable = MCI_QCOM_CLK_FLOWENA |
201 MCI_QCOM_CLK_SELECT_IN_FBCLK,
202 .clkreg_8bit_bus_enable = MCI_QCOM_CLK_WIDEBUS_8,
203 .datactrl_mask_ddrmode = MCI_QCOM_CLK_SELECT_IN_DDR_MODE,
204 .data_cmd_enable = MCI_QCOM_CSPM_DATCMD,
205 .blksz_datactrl4 = true,
206 .datalength_bits = 24,
207 .pwrreg_powerup = MCI_PWR_UP,
208 .f_max = 208000000,
209 .explicit_mclk_control = true,
210 .qcom_fifo = true,
211};
212
163static int mmci_card_busy(struct mmc_host *mmc) 213static int mmci_card_busy(struct mmc_host *mmc)
164{ 214{
165 struct mmci_host *host = mmc_priv(mmc); 215 struct mmci_host *host = mmc_priv(mmc);
@@ -260,7 +310,9 @@ static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired)
260 host->cclk = 0; 310 host->cclk = 0;
261 311
262 if (desired) { 312 if (desired) {
263 if (desired >= host->mclk) { 313 if (variant->explicit_mclk_control) {
314 host->cclk = host->mclk;
315 } else if (desired >= host->mclk) {
264 clk = MCI_CLK_BYPASS; 316 clk = MCI_CLK_BYPASS;
265 if (variant->st_clkdiv) 317 if (variant->st_clkdiv)
266 clk |= MCI_ST_UX500_NEG_EDGE; 318 clk |= MCI_ST_UX500_NEG_EDGE;
@@ -299,11 +351,11 @@ static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired)
299 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4) 351 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4)
300 clk |= MCI_4BIT_BUS; 352 clk |= MCI_4BIT_BUS;
301 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8) 353 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8)
302 clk |= MCI_ST_8BIT_BUS; 354 clk |= variant->clkreg_8bit_bus_enable;
303 355
304 if (host->mmc->ios.timing == MMC_TIMING_UHS_DDR50 || 356 if (host->mmc->ios.timing == MMC_TIMING_UHS_DDR50 ||
305 host->mmc->ios.timing == MMC_TIMING_MMC_DDR52) 357 host->mmc->ios.timing == MMC_TIMING_MMC_DDR52)
306 clk |= MCI_ST_UX500_NEG_EDGE; 358 clk |= variant->clkreg_neg_edge_enable;
307 359
308 mmci_write_clkreg(host, clk); 360 mmci_write_clkreg(host, clk);
309} 361}
@@ -719,7 +771,7 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
719 data->bytes_xfered = 0; 771 data->bytes_xfered = 0;
720 772
721 clks = (unsigned long long)data->timeout_ns * host->cclk; 773 clks = (unsigned long long)data->timeout_ns * host->cclk;
722 do_div(clks, 1000000000UL); 774 do_div(clks, NSEC_PER_SEC);
723 775
724 timeout = data->timeout_clks + (unsigned int)clks; 776 timeout = data->timeout_clks + (unsigned int)clks;
725 777
@@ -732,6 +784,8 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
732 784
733 if (variant->blksz_datactrl16) 785 if (variant->blksz_datactrl16)
734 datactrl = MCI_DPSM_ENABLE | (data->blksz << 16); 786 datactrl = MCI_DPSM_ENABLE | (data->blksz << 16);
787 else if (variant->blksz_datactrl4)
788 datactrl = MCI_DPSM_ENABLE | (data->blksz << 4);
735 else 789 else
736 datactrl = MCI_DPSM_ENABLE | blksz_bits << 4; 790 datactrl = MCI_DPSM_ENABLE | blksz_bits << 4;
737 791
@@ -767,7 +821,7 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
767 821
768 if (host->mmc->ios.timing == MMC_TIMING_UHS_DDR50 || 822 if (host->mmc->ios.timing == MMC_TIMING_UHS_DDR50 ||
769 host->mmc->ios.timing == MMC_TIMING_MMC_DDR52) 823 host->mmc->ios.timing == MMC_TIMING_MMC_DDR52)
770 datactrl |= MCI_ST_DPSM_DDRMODE; 824 datactrl |= variant->datactrl_mask_ddrmode;
771 825
772 /* 826 /*
773 * Attempt to use DMA operation mode, if this 827 * Attempt to use DMA operation mode, if this
@@ -812,7 +866,7 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
812 866
813 if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) { 867 if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) {
814 writel(0, base + MMCICOMMAND); 868 writel(0, base + MMCICOMMAND);
815 udelay(1); 869 mmci_reg_delay(host);
816 } 870 }
817 871
818 c |= cmd->opcode | MCI_CPSM_ENABLE; 872 c |= cmd->opcode | MCI_CPSM_ENABLE;
@@ -824,6 +878,9 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
824 if (/*interrupt*/0) 878 if (/*interrupt*/0)
825 c |= MCI_CPSM_INTERRUPT; 879 c |= MCI_CPSM_INTERRUPT;
826 880
881 if (mmc_cmd_type(cmd) == MMC_CMD_ADTC)
882 c |= host->variant->data_cmd_enable;
883
827 host->cmd = cmd; 884 host->cmd = cmd;
828 885
829 writel(cmd->arg, base + MMCIARGUMENT); 886 writel(cmd->arg, base + MMCIARGUMENT);
@@ -834,6 +891,10 @@ static void
834mmci_data_irq(struct mmci_host *host, struct mmc_data *data, 891mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
835 unsigned int status) 892 unsigned int status)
836{ 893{
894 /* Make sure we have data to handle */
895 if (!data)
896 return;
897
837 /* First check for errors */ 898 /* First check for errors */
838 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR| 899 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR|
839 MCI_TXUNDERRUN|MCI_RXOVERRUN)) { 900 MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
@@ -902,9 +963,17 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
902 unsigned int status) 963 unsigned int status)
903{ 964{
904 void __iomem *base = host->base; 965 void __iomem *base = host->base;
905 bool sbc = (cmd == host->mrq->sbc); 966 bool sbc, busy_resp;
906 bool busy_resp = host->variant->busy_detect && 967
907 (cmd->flags & MMC_RSP_BUSY); 968 if (!cmd)
969 return;
970
971 sbc = (cmd == host->mrq->sbc);
972 busy_resp = host->variant->busy_detect && (cmd->flags & MMC_RSP_BUSY);
973
974 if (!((status|host->busy_status) & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT|
975 MCI_CMDSENT|MCI_CMDRESPEND)))
976 return;
908 977
909 /* Check if we need to wait for busy completion. */ 978 /* Check if we need to wait for busy completion. */
910 if (host->busy_status && (status & MCI_ST_CARDBUSY)) 979 if (host->busy_status && (status & MCI_ST_CARDBUSY))
@@ -957,15 +1026,34 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
957 } 1026 }
958} 1027}
959 1028
1029static int mmci_get_rx_fifocnt(struct mmci_host *host, u32 status, int remain)
1030{
1031 return remain - (readl(host->base + MMCIFIFOCNT) << 2);
1032}
1033
1034static int mmci_qcom_get_rx_fifocnt(struct mmci_host *host, u32 status, int r)
1035{
1036 /*
1037 * on qcom SDCC4 only 8 words are used in each burst so only 8 addresses
1038 * from the fifo range should be used
1039 */
1040 if (status & MCI_RXFIFOHALFFULL)
1041 return host->variant->fifohalfsize;
1042 else if (status & MCI_RXDATAAVLBL)
1043 return 4;
1044
1045 return 0;
1046}
1047
960static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int remain) 1048static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int remain)
961{ 1049{
962 void __iomem *base = host->base; 1050 void __iomem *base = host->base;
963 char *ptr = buffer; 1051 char *ptr = buffer;
964 u32 status; 1052 u32 status = readl(host->base + MMCISTATUS);
965 int host_remain = host->size; 1053 int host_remain = host->size;
966 1054
967 do { 1055 do {
968 int count = host_remain - (readl(base + MMCIFIFOCNT) << 2); 1056 int count = host->get_rx_fifocnt(host, status, host_remain);
969 1057
970 if (count > remain) 1058 if (count > remain)
971 count = remain; 1059 count = remain;
@@ -1132,9 +1220,6 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
1132 spin_lock(&host->lock); 1220 spin_lock(&host->lock);
1133 1221
1134 do { 1222 do {
1135 struct mmc_command *cmd;
1136 struct mmc_data *data;
1137
1138 status = readl(host->base + MMCISTATUS); 1223 status = readl(host->base + MMCISTATUS);
1139 1224
1140 if (host->singleirq) { 1225 if (host->singleirq) {
@@ -1154,16 +1239,13 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
1154 1239
1155 dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status); 1240 dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status);
1156 1241
1157 cmd = host->cmd; 1242 if (host->variant->reversed_irq_handling) {
1158 if ((status|host->busy_status) & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT| 1243 mmci_data_irq(host, host->data, status);
1159 MCI_CMDSENT|MCI_CMDRESPEND) && cmd) 1244 mmci_cmd_irq(host, host->cmd, status);
1160 mmci_cmd_irq(host, cmd, status); 1245 } else {
1161 1246 mmci_cmd_irq(host, host->cmd, status);
1162 data = host->data; 1247 mmci_data_irq(host, host->data, status);
1163 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR| 1248 }
1164 MCI_TXUNDERRUN|MCI_RXOVERRUN|MCI_DATAEND|
1165 MCI_DATABLOCKEND) && data)
1166 mmci_data_irq(host, data, status);
1167 1249
1168 /* Don't poll for busy completion in irq context. */ 1250 /* Don't poll for busy completion in irq context. */
1169 if (host->busy_status) 1251 if (host->busy_status)
@@ -1296,6 +1378,17 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1296 if (!ios->clock && variant->pwrreg_clkgate) 1378 if (!ios->clock && variant->pwrreg_clkgate)
1297 pwr &= ~MCI_PWR_ON; 1379 pwr &= ~MCI_PWR_ON;
1298 1380
1381 if (host->variant->explicit_mclk_control &&
1382 ios->clock != host->clock_cache) {
1383 ret = clk_set_rate(host->clk, ios->clock);
1384 if (ret < 0)
1385 dev_err(mmc_dev(host->mmc),
1386 "Error setting clock rate (%d)\n", ret);
1387 else
1388 host->mclk = clk_get_rate(host->clk);
1389 }
1390 host->clock_cache = ios->clock;
1391
1299 spin_lock_irqsave(&host->lock, flags); 1392 spin_lock_irqsave(&host->lock, flags);
1300 1393
1301 mmci_set_clkreg(host, ios->clock); 1394 mmci_set_clkreg(host, ios->clock);
@@ -1443,6 +1536,11 @@ static int mmci_probe(struct amba_device *dev,
1443 if (ret) 1536 if (ret)
1444 goto host_free; 1537 goto host_free;
1445 1538
1539 if (variant->qcom_fifo)
1540 host->get_rx_fifocnt = mmci_qcom_get_rx_fifocnt;
1541 else
1542 host->get_rx_fifocnt = mmci_get_rx_fifocnt;
1543
1446 host->plat = plat; 1544 host->plat = plat;
1447 host->variant = variant; 1545 host->variant = variant;
1448 host->mclk = clk_get_rate(host->clk); 1546 host->mclk = clk_get_rate(host->clk);
@@ -1451,8 +1549,8 @@ static int mmci_probe(struct amba_device *dev,
1451 * so we try to adjust the clock down to this, 1549 * so we try to adjust the clock down to this,
1452 * (if possible). 1550 * (if possible).
1453 */ 1551 */
1454 if (host->mclk > 100000000) { 1552 if (host->mclk > variant->f_max) {
1455 ret = clk_set_rate(host->clk, 100000000); 1553 ret = clk_set_rate(host->clk, variant->f_max);
1456 if (ret < 0) 1554 if (ret < 0)
1457 goto clk_disable; 1555 goto clk_disable;
1458 host->mclk = clk_get_rate(host->clk); 1556 host->mclk = clk_get_rate(host->clk);
@@ -1471,9 +1569,12 @@ static int mmci_probe(struct amba_device *dev,
1471 * The ARM and ST versions of the block have slightly different 1569 * The ARM and ST versions of the block have slightly different
1472 * clock divider equations which means that the minimum divider 1570 * clock divider equations which means that the minimum divider
1473 * differs too. 1571 * differs too.
1572 * on Qualcomm like controllers get the nearest minimum clock to 100Khz
1474 */ 1573 */
1475 if (variant->st_clkdiv) 1574 if (variant->st_clkdiv)
1476 mmc->f_min = DIV_ROUND_UP(host->mclk, 257); 1575 mmc->f_min = DIV_ROUND_UP(host->mclk, 257);
1576 else if (variant->explicit_mclk_control)
1577 mmc->f_min = clk_round_rate(host->clk, 100000);
1477 else 1578 else
1478 mmc->f_min = DIV_ROUND_UP(host->mclk, 512); 1579 mmc->f_min = DIV_ROUND_UP(host->mclk, 512);
1479 /* 1580 /*
@@ -1483,9 +1584,14 @@ static int mmci_probe(struct amba_device *dev,
1483 * the block, of course. 1584 * the block, of course.
1484 */ 1585 */
1485 if (mmc->f_max) 1586 if (mmc->f_max)
1486 mmc->f_max = min(host->mclk, mmc->f_max); 1587 mmc->f_max = variant->explicit_mclk_control ?
1588 min(variant->f_max, mmc->f_max) :
1589 min(host->mclk, mmc->f_max);
1487 else 1590 else
1488 mmc->f_max = min(host->mclk, fmax); 1591 mmc->f_max = variant->explicit_mclk_control ?
1592 fmax : min(host->mclk, fmax);
1593
1594
1489 dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max); 1595 dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max);
1490 1596
1491 /* Get regulators and the supported OCR mask */ 1597 /* Get regulators and the supported OCR mask */
@@ -1752,6 +1858,12 @@ static struct amba_id mmci_ids[] = {
1752 .mask = 0xf0ffffff, 1858 .mask = 0xf0ffffff,
1753 .data = &variant_ux500v2, 1859 .data = &variant_ux500v2,
1754 }, 1860 },
1861 /* Qualcomm variants */
1862 {
1863 .id = 0x00051180,
1864 .mask = 0x000fffff,
1865 .data = &variant_qcom,
1866 },
1755 { 0, 0 }, 1867 { 0, 0 },
1756}; 1868};
1757 1869