shithub: riscv

Download patch

ref: 811b80cae120168762e5825784a135ee4a5558e2
parent: dfea95b3c29ef4a6de2713a946453d3a022ae0b4
author: cinap_lenrek <[email protected]>
date: Thu Jul 25 04:58:58 EDT 2019

bcm, bcm64: make irq.$O optional and add intrdisable(), use intrenable()

the raspberry pi 4 has a new interrupt controller and
pci support, so get rid of intrenable() macro and
properly make intrenable function with tbdf argument.

--- a/sys/src/9/bcm/clock.c
+++ b/sys/src/9/bcm/clock.c
@@ -128,7 +128,7 @@
 			*(ulong*)(ARMLOCAL + Prescaler) = (((uvlong)SystimerFreq<<31)/19200000)&~1UL;
 		} else {
 			cpwrsc(0, CpTIMER, CpTIMERphys, CpTIMERphysctl, Enable);
-			intrenable(IRQcntpns, localclockintr, nil, 0, "clock");
+			intrenable(IRQcntpns, localclockintr, nil, BUSUNKNOWN, "clock");
 		}
 	}
 
@@ -148,7 +148,7 @@
 
 	if(m->machno == 0){
 		tn->c3 = tn->clo - 1;
-		intrenable(IRQtimer3, clockintr, nil, 0, "clock");
+		intrenable(IRQtimer3, clockintr, nil, BUSUNKNOWN, "clock");
 
 		tm = (Armtimer*)ARMTIMER;
 		tm->load = 0;
--- a/sys/src/9/bcm/devgpio.c
+++ b/sys/src/9/bcm/devgpio.c
@@ -336,7 +336,7 @@
 	gpiomeminit();
 	boardrev = getboardrev() & 0xff;
 	pinscheme = Qboard;
-	intrenable(49, interrupt, nil, 0, "gpio1");
+	intrenable(49, interrupt, nil, BUSUNKNOWN, "gpio1");
 }
 
 static void
--- a/sys/src/9/bcm/emmc.c
+++ b/sys/src/9/bcm/emmc.c
@@ -236,7 +236,7 @@
 	if(i == 1000)
 		print("SD clock won't initialise!\n");
 	WR(Irptmask, ~(Dtoerr|Cardintr));
-	intrenable(IRQmmc, mmcinterrupt, nil, 0, "mmc");
+	intrenable(IRQmmc, mmcinterrupt, nil, BUSUNKNOWN, "mmc");
 }
 
 static int
@@ -398,8 +398,6 @@
 	}
 	if(i)
 		WR(Interrupt, i);
-	if(!write)
-		cachedinvse(buf, len);
 	poperror();
 	okay(0);
 }
--- a/sys/src/9/bcm/fns.h
+++ b/sys/src/9/bcm/fns.h
@@ -61,8 +61,8 @@
 extern void gpiomeminit(void);
 extern u32int ifsrget(void);
 extern void intrcpushutdown(void);
-extern void irqenable(int, void (*)(Ureg*, void*), void*);
-#define intrenable(i, f, a, b, n) irqenable((i), (f), (a))
+extern void intrenable(int, void (*)(Ureg*, void*), void*, int, char*);
+extern void intrdisable(int, void (*)(Ureg*, void*), void*, int, char*);
 extern void intrsoff(void);
 extern int isaconfig(char*, int, ISAConf*);
 extern void l2cacheuwbinv(void);
--- a/sys/src/9/bcm/irq.c
+++ b/sys/src/9/bcm/irq.c
@@ -114,7 +114,7 @@
 }
 
 void
-irqenable(int irq, void (*f)(Ureg*, void*), void* a)
+intrenable(int irq, void (*f)(Ureg*, void*), void* a, int, char*)
 {
 	Vctl *v;
 	Intregs *ip;
@@ -164,4 +164,9 @@
 			*enable = v->mask;
 	}
 	unlock(&vctllock);
+}
+
+void
+intrdisable(int, void (*)(Ureg*, void*), void*, int, char*)
+{
 }
--- a/sys/src/9/bcm/mem.h
+++ b/sys/src/9/bcm/mem.h
@@ -10,9 +10,7 @@
  */
 #define	BY2PG		(4*KiB)			/* bytes per page */
 #define	PGSHIFT		12			/* log(BY2PG) */
-#define	HOWMANY(x,y)	(((x)+((y)-1))/(y))
-#define	ROUNDUP(x,y)	(HOWMANY((x),(y))*(y))
-#define	PGROUND(s)	ROUNDUP(s, BY2PG)
+#define	PGROUND(s)	ROUND(s, BY2PG)
 #define	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
 
 #define	MAXMACH		4			/* max # cpus system can run */
@@ -51,8 +49,8 @@
 #define	FIQSTKTOP	(KZERO+0x4000)		/* FIQ stack */
 #define	L1		(KZERO+0x4000)		/* tt ptes: 16KiB aligned */
 #define	KTZERO		(KZERO+0x8000)		/* kernel text start */
-#define VIRTIO		0x7E000000		/* i/o registers */
-#define	ARMLOCAL	(VIRTIO+IOSIZE)		/* armv7 only */
+#define VIRTIO		(0x7E000000)		/* i/o registers */
+#define	ARMLOCAL	(0x7F000000)		/* armv7 only */
 #define	VGPIO		(ARMLOCAL+MiB)		/* virtual gpio for pi3 ACT LED */
 #define	FRAMEBUFFER	0xC0000000		/* video framebuffer */
 
@@ -95,7 +93,6 @@
  *	BUS  addresses as seen from the videocore gpu.
  */
 #define	PHYSDRAM	0
-#define	IOSIZE		(16*MiB)
 
 #define MIN(a, b)	((a) < (b)? (a): (b))
 #define MAX(a, b)	((a) > (b)? (a): (b))
--- a/sys/src/9/bcm/mkfile
+++ b/sys/src/9/bcm/mkfile
@@ -50,7 +50,6 @@
 	fpi.$O\
 	fpiarm.$O\
 	fpimem.$O\
-	irq.$O\
 	main.$O\
 	mmu.$O\
 	random.$O\
--- a/sys/src/9/bcm/pi
+++ b/sys/src/9/bcm/pi
@@ -43,6 +43,7 @@
 	dma
 	vcore
 	vfp3	coproc
+	irq
 
 port
 	int cpuserver = 0;
--- a/sys/src/9/bcm/pi2
+++ b/sys/src/9/bcm/pi2
@@ -43,6 +43,7 @@
 	dma
 	vcore
 	vfp3	coproc
+	irq
 
 port
 	int cpuserver = 0;
--- a/sys/src/9/bcm/uartmini.c
+++ b/sys/src/9/bcm/uartmini.c
@@ -100,7 +100,7 @@
 	ap[MuCntl] = TxEn|RxEn;
 	baud(uart, uart->baud);
 	if(ie){
-		intrenable(IRQaux, interrupt, uart, 0, uart->name);
+		intrenable(IRQaux, interrupt, uart, BUSUNKNOWN, uart->name);
 		ap[MuIer] = RxIen|TxIen;
 	}else
 		ap[MuIer] = 0;
--- a/sys/src/9/bcm/uartpl011.c
+++ b/sys/src/9/bcm/uartpl011.c
@@ -148,7 +148,7 @@
 
 	disable(uart);
 	if(ie){
-		intrenable(IRQuart, interrupt, uart, 0, uart->name);
+		intrenable(IRQuart, interrupt, uart, BUSUNKNOWN, uart->name);
 		reg[IMSC] = TXIM|RXIM;
 	}
 	uarton(uart);
--- a/sys/src/9/bcm/usbdwc.c
+++ b/sys/src/9/bcm/usbdwc.c
@@ -85,6 +85,8 @@
 static void dumphchan(Ctlr *ctlr, Hostchan *hc);
 static void dump(Hci *hp);
 
+#define	HOWMANY(x, y)	(((x)+((y)-1))/(y))
+
 static void
 filock(Lock *l)
 {
@@ -1051,7 +1053,7 @@
 		return -1;
 	dprint("usbdwc: rev %d.%3.3x\n", (id>>12)&0xF, id&0xFFF);
 
-	intrenable(IRQtimerArm, irqintr, ctlr, 0, "dwc");
+	intrenable(IRQtimerArm, irqintr, ctlr, BUSUNKNOWN, "dwc");
 
 	hp->aux = ctlr;
 	hp->port = 0;
@@ -1075,7 +1077,7 @@
 	hp->debug = setdebug;
 	hp->type = "dwcotg";
 
-	intrenable(hp->irq, hp->interrupt, hp, UNKNOWN, "usbdwcotg");
+	intrenable(hp->irq, hp->interrupt, hp, BUSUNKNOWN, "usbdwcotg");
 
 	return 0;
 }
--- a/sys/src/9/bcm64/clock.c
+++ b/sys/src/9/bcm64/clock.c
@@ -131,7 +131,7 @@
 		*(u32int*)(ARMLOCAL + Prescaler) = (((uvlong)SystimerFreq<<31)/19200000)&~1UL;
 	} else {
 		syswr(CNTP_CTL_EL0, Enable);
-		intrenable(IRQcntpns, localclockintr, nil, 0, "clock");
+		intrenable(IRQcntpns, localclockintr, nil, BUSUNKNOWN, "clock");
 	}
 
 	tn = (Systimers*)SYSTIMERS;
@@ -151,7 +151,7 @@
 	if(m->machno == 0){
 		tn->cs = 1<<3;
 		tn->c3 = tn->clo - 1;
-		intrenable(IRQtimer3, clockintr, nil, 0, "clock");
+		intrenable(IRQtimer3, clockintr, nil, BUSUNKNOWN, "clock");
 
 		tm = (Armtimer*)ARMTIMER;
 		tm->load = 0;
--- a/sys/src/9/bcm64/fns.h
+++ b/sys/src/9/bcm64/fns.h
@@ -110,8 +110,8 @@
 /* irq */
 extern void intrcpushutdown(void);
 extern void intrsoff(void);
-#define intrenable(i, f, a, b, n)	irqenable((i), (f), (a))
-extern void irqenable(int, void (*)(Ureg*, void*), void*);
+extern void intrenable(int, void (*)(Ureg*, void*), void*, int, char*);
+extern void intrdisable(int, void (*)(Ureg*, void*), void*, int, char*);
 extern int irq(Ureg*);
 extern void fiq(Ureg*);
 
--- a/sys/src/9/bcm64/mkfile
+++ b/sys/src/9/bcm64/mkfile
@@ -44,7 +44,6 @@
 	bootargs.$O\
 	clock.$O\
 	fpu.$O\
-	irq.$O\
 	main.$O\
 	mmu.$O\
 	sysreg.$O\
--- a/sys/src/9/bcm64/pi3
+++ b/sys/src/9/bcm64/pi3
@@ -43,6 +43,7 @@
 	sdmmc	emmc
 	dma
 	vcore
+	irq
 
 	dtracysys
 	dtracytimer