@@ -49,7 +49,7 @@ static void sdhci_finish_data(struct sdhci_host *);
4949
5050static void sdhci_send_command (struct sdhci_host * , struct mmc_command * );
5151static void sdhci_finish_command (struct sdhci_host * );
52- static int sdhci_execute_tuning (struct mmc_host * mmc );
52+ static int sdhci_execute_tuning (struct mmc_host * mmc , u32 opcode );
5353static void sdhci_tuning_timer (unsigned long data );
5454
5555#ifdef CONFIG_PM_RUNTIME
@@ -1014,7 +1014,8 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
10141014 flags |= SDHCI_CMD_INDEX ;
10151015
10161016 /* CMD19 is special in that the Data Present Select should be set */
1017- if (cmd -> data || (cmd -> opcode == MMC_SEND_TUNING_BLOCK ))
1017+ if (cmd -> data || cmd -> opcode == MMC_SEND_TUNING_BLOCK ||
1018+ cmd -> opcode == MMC_SEND_TUNING_BLOCK_HS200 )
10181019 flags |= SDHCI_CMD_DATA ;
10191020
10201021 sdhci_writew (host , SDHCI_MAKE_CMD (cmd -> opcode , flags ), SDHCI_COMMAND );
@@ -1287,7 +1288,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
12871288 if ((host -> flags & SDHCI_NEEDS_RETUNING ) &&
12881289 !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ ))) {
12891290 spin_unlock_irqrestore (& host -> lock , flags );
1290- sdhci_execute_tuning (mmc );
1291+ sdhci_execute_tuning (mmc , mrq -> cmd -> opcode );
12911292 spin_lock_irqsave (& host -> lock , flags );
12921293
12931294 /* Restore original mmc_request structure */
@@ -1382,7 +1383,8 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
13821383 unsigned int clock ;
13831384
13841385 /* In case of UHS-I modes, set High Speed Enable */
1385- if ((ios -> timing == MMC_TIMING_UHS_SDR50 ) ||
1386+ if ((ios -> timing == MMC_TIMING_MMC_HS200 ) ||
1387+ (ios -> timing == MMC_TIMING_UHS_SDR50 ) ||
13861388 (ios -> timing == MMC_TIMING_UHS_SDR104 ) ||
13871389 (ios -> timing == MMC_TIMING_UHS_DDR50 ) ||
13881390 (ios -> timing == MMC_TIMING_UHS_SDR25 ))
@@ -1435,7 +1437,9 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
14351437 ctrl_2 = sdhci_readw (host , SDHCI_HOST_CONTROL2 );
14361438 /* Select Bus Speed Mode for host */
14371439 ctrl_2 &= ~SDHCI_CTRL_UHS_MASK ;
1438- if (ios -> timing == MMC_TIMING_UHS_SDR12 )
1440+ if (ios -> timing == MMC_TIMING_MMC_HS200 )
1441+ ctrl_2 |= SDHCI_CTRL_HS_SDR200 ;
1442+ else if (ios -> timing == MMC_TIMING_UHS_SDR12 )
14391443 ctrl_2 |= SDHCI_CTRL_UHS_SDR12 ;
14401444 else if (ios -> timing == MMC_TIMING_UHS_SDR25 )
14411445 ctrl_2 |= SDHCI_CTRL_UHS_SDR25 ;
@@ -1682,14 +1686,15 @@ static int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
16821686 return err ;
16831687}
16841688
1685- static int sdhci_execute_tuning (struct mmc_host * mmc )
1689+ static int sdhci_execute_tuning (struct mmc_host * mmc , u32 opcode )
16861690{
16871691 struct sdhci_host * host ;
16881692 u16 ctrl ;
16891693 u32 ier ;
16901694 int tuning_loop_counter = MAX_TUNING_LOOP ;
16911695 unsigned long timeout ;
16921696 int err = 0 ;
1697+ bool requires_tuning_nonuhs = false;
16931698
16941699 host = mmc_priv (mmc );
16951700
@@ -1700,13 +1705,19 @@ static int sdhci_execute_tuning(struct mmc_host *mmc)
17001705 ctrl = sdhci_readw (host , SDHCI_HOST_CONTROL2 );
17011706
17021707 /*
1703- * Host Controller needs tuning only in case of SDR104 mode
1704- * and for SDR50 mode when Use Tuning for SDR50 is set in
1708+ * The Host Controller needs tuning only in case of SDR104 mode
1709+ * and for SDR50 mode when Use Tuning for SDR50 is set in the
17051710 * Capabilities register.
1711+ * If the Host Controller supports the HS200 mode then the
1712+ * tuning function has to be executed.
17061713 */
1714+ if (((ctrl & SDHCI_CTRL_UHS_MASK ) == SDHCI_CTRL_UHS_SDR50 ) &&
1715+ (host -> flags & SDHCI_SDR50_NEEDS_TUNING ||
1716+ host -> flags & SDHCI_HS200_NEEDS_TUNING ))
1717+ requires_tuning_nonuhs = true;
1718+
17071719 if (((ctrl & SDHCI_CTRL_UHS_MASK ) == SDHCI_CTRL_UHS_SDR104 ) ||
1708- (((ctrl & SDHCI_CTRL_UHS_MASK ) == SDHCI_CTRL_UHS_SDR50 ) &&
1709- (host -> flags & SDHCI_SDR50_NEEDS_TUNING )))
1720+ requires_tuning_nonuhs )
17101721 ctrl |= SDHCI_CTRL_EXEC_TUNING ;
17111722 else {
17121723 spin_unlock (& host -> lock );
@@ -1742,7 +1753,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc)
17421753 if (!tuning_loop_counter && !timeout )
17431754 break ;
17441755
1745- cmd .opcode = MMC_SEND_TUNING_BLOCK ;
1756+ cmd .opcode = opcode ;
17461757 cmd .arg = 0 ;
17471758 cmd .flags = MMC_RSP_R1 | MMC_CMD_ADTC ;
17481759 cmd .retries = 0 ;
@@ -1757,7 +1768,17 @@ static int sdhci_execute_tuning(struct mmc_host *mmc)
17571768 * block to the Host Controller. So we set the block size
17581769 * to 64 here.
17591770 */
1760- sdhci_writew (host , SDHCI_MAKE_BLKSZ (7 , 64 ), SDHCI_BLOCK_SIZE );
1771+ if (cmd .opcode == MMC_SEND_TUNING_BLOCK_HS200 ) {
1772+ if (mmc -> ios .bus_width == MMC_BUS_WIDTH_8 )
1773+ sdhci_writew (host , SDHCI_MAKE_BLKSZ (7 , 128 ),
1774+ SDHCI_BLOCK_SIZE );
1775+ else if (mmc -> ios .bus_width == MMC_BUS_WIDTH_4 )
1776+ sdhci_writew (host , SDHCI_MAKE_BLKSZ (7 , 64 ),
1777+ SDHCI_BLOCK_SIZE );
1778+ } else {
1779+ sdhci_writew (host , SDHCI_MAKE_BLKSZ (7 , 64 ),
1780+ SDHCI_BLOCK_SIZE );
1781+ }
17611782
17621783 /*
17631784 * The tuning block is sent by the card to the host controller.
@@ -2140,12 +2161,14 @@ static void sdhci_show_adma_error(struct sdhci_host *host) { }
21402161
21412162static void sdhci_data_irq (struct sdhci_host * host , u32 intmask )
21422163{
2164+ u32 command ;
21432165 BUG_ON (intmask == 0 );
21442166
21452167 /* CMD19 generates _only_ Buffer Read Ready interrupt */
21462168 if (intmask & SDHCI_INT_DATA_AVAIL ) {
2147- if (SDHCI_GET_CMD (sdhci_readw (host , SDHCI_COMMAND )) ==
2148- MMC_SEND_TUNING_BLOCK ) {
2169+ command = SDHCI_GET_CMD (sdhci_readw (host , SDHCI_COMMAND ));
2170+ if (command == MMC_SEND_TUNING_BLOCK ||
2171+ command == MMC_SEND_TUNING_BLOCK_HS200 ) {
21492172 host -> tuning_done = 1 ;
21502173 wake_up (& host -> buf_ready_int );
21512174 return ;
@@ -2747,10 +2770,14 @@ int sdhci_add_host(struct sdhci_host *host)
27472770 if (caps [1 ] & SDHCI_SUPPORT_DDR50 )
27482771 mmc -> caps |= MMC_CAP_UHS_DDR50 ;
27492772
2750- /* Does the host needs tuning for SDR50? */
2773+ /* Does the host need tuning for SDR50? */
27512774 if (caps [1 ] & SDHCI_USE_SDR50_TUNING )
27522775 host -> flags |= SDHCI_SDR50_NEEDS_TUNING ;
27532776
2777+ /* Does the host need tuning for HS200? */
2778+ if (mmc -> caps2 & MMC_CAP2_HS200 )
2779+ host -> flags |= SDHCI_HS200_NEEDS_TUNING ;
2780+
27542781 /* Driver Type(s) (A, C, D) supported by the host */
27552782 if (caps [1 ] & SDHCI_DRIVER_TYPE_A )
27562783 mmc -> caps |= MMC_CAP_DRIVER_TYPE_A ;
0 commit comments