shithub: plan9front

Download patch

ref: e760ded4943d802d7012514d56e18a8ddb54cc56
parent: 524f8c2d5374e34bbb665e7a52484859ae9e3e59
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Jun 18 09:19:55 EDT 2022

imx8/usdhc: implement highspeed mode (50Mhz)

--- a/sys/src/9/imx8/usdhc.c	Sat Jun 18 08:49:29 2022
+++ b/sys/src/9/imx8/usdhc.c	Sat Jun 18 09:19:55 2022
@@ -10,6 +10,7 @@
 enum {
 	Initfreq	= 400000,	/* initialisation frequency for MMC */
 	SDfreq		= 25*Mhz,	/* standard SD frequency */
+	SDfreqhs	= 50*Mhz,	/* highspeed frequency */
 	DTO		= 14,		/* data timeout exponent (guesswork) */
 
 	GoIdle		= 0,		/* mmc/sdio go idle state */
@@ -446,6 +447,15 @@
 				WR(Control0, (RR(Control0) & ~DwidthMask) | Dwidth4);
 				break;
 			}
+		} else {
+			/*
+			 * If card switched into high speed mode, increase clock speed
+			 */
+			if((arg&0x8000000F) == 0x80000001){
+				delay(1);
+				usdhcclk(SDfreqhs);
+				delay(1);
+			}
 		}
 	}else if(cmd == IORWdirect && (arg & ~0xFF) == (1<<31|0<<28|7<<9)){
 		switch(arg & 0x3){
@@ -518,4 +528,5 @@
 	usdhccmd,
 	usdhciosetup,
 	usdhcio,
+	.highspeed = 1,
 };