shithub: riscv

Download patch

ref: c0a7fbea1f61b1d77a09d612b85c74fd6c673b7c
parent: 901a176a030ca15db5cf2a1ec71f7d8ec8e97d64
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 5 13:52:50 EST 2023

bcm, bcm64: handle disk activity led from sdmmc

We don't want to blink the disk activity led for wifi,
so handle the disk activity LED from sdmmc when it
is actually used as a disk.

--- a/sys/src/9/bcm/emmc.c
+++ b/sys/src/9/bcm/emmc.c
@@ -409,11 +409,6 @@
 	int i;
 
 	assert((len&3) == 0);
-	okay(1);
-	if(waserror()){
-		okay(0);
-		nexterror();
-	}
 	if(write)
 		dmastart(DmaChanEmmc, DmaDevEmmc, DmaM2D,
 			buf, &r[Data], len);
@@ -439,8 +434,6 @@
 	}
 	if(i)
 		WR(Interrupt, i);
-	poperror();
-	okay(0);
 }
 
 static void
@@ -457,6 +450,11 @@
 	WR(Irpten, r[Irpten] & ~i);
 }
 
+static void
+emmcled(SDio*, int on)
+{
+	okay(on);
+}
 
 static SDio sdio = {
 	"emmc",
@@ -467,6 +465,7 @@
 	emmciosetup,
 	emmcio,
 	emmcbus,
+	emmcled,
 	emmccardintr,
 };
 
--- a/sys/src/9/bcm64/sdhc.c
+++ b/sys/src/9/bcm64/sdhc.c
@@ -452,7 +452,6 @@
 	else
 		cachedwbinvse(buf, len);
 	WR(Dmadesc, sdhc.busdram + (PADDR(sdhc.dma) - PHYSDRAM));
-	okay(1);
 }
 
 static void
@@ -461,10 +460,6 @@
 	u32int *r = (u32int*)SDHCREGS;
 	int i;
 
-	if(waserror()){
-		okay(0);
-		nexterror();
-	}
 	WR(Irpten, r[Irpten] | Datadone|Err);
 	tsleep(&sdhc.r, datadone, 0, 3000);
 	WR(Irpten, r[Irpten] & ~(Datadone|Err));
@@ -478,8 +473,6 @@
 	WR(Interrupt, i);
 	if(!write)
 		cachedinvse(buf, len);
-	poperror();
-	okay(0);
 }
 
 static void
@@ -494,6 +487,12 @@
 	WR(Irpten, r[Irpten] & ~i);
 }
 
+static void
+sdhcled(SDio*, int on)
+{
+	okay(on);
+}
+
 void
 sdhclink(void)
 {
@@ -506,6 +505,7 @@
 		sdhciosetup,
 		sdhcio,
 		sdhcbus,
+		sdhcled,
 	};
 	addmmcio(&io);
 }
--- a/sys/src/9/bcm64/sdhost.c
+++ b/sys/src/9/bcm64/sdhost.c
@@ -240,6 +240,12 @@
 		sdhosterror(i);
 }
 
+static void
+sdhostled(SDio*, int on)
+{
+	okay(on);
+}
+
 void
 sdhostlink(void)
 {
@@ -252,6 +258,7 @@
 		sdhostiosetup,
 		sdhostio,
 		sdhostbus,
+		sdhostled,
 	};
 	addmmcio(&io);
 }
--- a/sys/src/9/port/sd.h
+++ b/sys/src/9/port/sd.h
@@ -197,6 +197,7 @@
 	void	(*iosetup)(SDio*, int, void*, int, int);
 	void	(*io)(SDio*, int, uchar*, int);
 	void	(*bus)(SDio*, int, int);
+	void	(*led)(SDio*, int);
 	int	(*cardintr)(SDio*, int);
 	char	nomultiwrite;	/* quirk for usdhc */
 	void	*aux;
--- a/sys/src/9/port/sdmmc.c
+++ b/sys/src/9/port/sdmmc.c
@@ -675,9 +675,13 @@
 
 	eqlock(card);
 	if(waserror()){
+		if(io->led != nil)
+			(*io->led)(io, 0);
 		qunlock(card);
 		nexterror();
 	}
+	if(io->led != nil)
+		(*io->led)(io, 1);
 
 	if(card->ismmc && unit->subno != (card->ext_csd[179]&7)){
 		b = (card->ext_csd[179] & ~7) | unit->subno;
@@ -714,7 +718,8 @@
 			buf += len;
 		}
 	}
-
+	if(io->led != nil)
+		(*io->led)(io, 0);
 	qunlock(card);
 	poperror();