Subject: Re: Allwinner wip
From: Artturi Alm <[email-masked]>
To: [email-masked]
Date: Wed, 31 Jul 2013 03:19:25 +0300
List-Id: <tech.openbsd.org>

New version attached, intr.c is now back in line with beagle/ for
easier A20-support 'integration'.

Added initial version of AHCI driver based on imxahci.c from bitrig,
atm. doesn't detect the SSD i have tried with it, have not verified
that the drive is sufficiently powered and working on any other OS
either, however.
Could also be that PLL6 factors need to be adjusted, yup, i've been
lazy, and i guess dma might need some setting up also :D
Also began working on 'Security System'-peripheral driver, doesn't
do more than
add_true_randomness() from PRNG atm. not sure yet if rest of the
peripheral is even usable for crypto(9), next time when i'm bored.

So pluggable interrupt controller, minimal non-intrusive diff for com,
few incomplete drivers, proper driver for clock control module and
possibly everything necessary to make release included in attachments.
i have not tried to build userland with the newly copypasted files.
last time i did the copy-paste from beagle it did work, but it took
between 20-26hrs to build the userland on cubie, i forgot to time it...

-Artturi
? distrib/allwinner
? distrib/sets/lists/base/md.allwinner
? distrib/sets/lists/comp/md.allwinner
? distrib/sets/lists/etc/md.allwinner
? distrib/sets/lists/game/md.allwinner
? distrib/sets/lists/man/md.allwinner
? etc/etc.allwinner
? share/man/man4/man4.allwinner
? share/man/man8/man8.allwinner
? sys/arch/allwinner
Index: Makefile.cross
===================================================================
RCS file: /cvs/src/Makefile.cross,v
retrieving revision 1.66
diff -u -p -r1.66 Makefile.cross
--- Makefile.cross	6 Jul 2013 17:52:57 -0000	1.66
+++ Makefile.cross	30 Jul 2013 17:53:06 -0000
@@ -6,8 +6,8 @@ cross-distrib:	cross-tools cross-bin cro
 
 # Have to compute TARGET_ARCH directly in the Makefile, for .if tests involving
 # this variable to work.
-.if	(${TARGET} == "armish" || ${TARGET} == "beagle" || \
-	 ${TARGET} == "zaurus")
+.if	(${TARGET} == "allwinner" || ${TARGET} == "armish" || \
+	 ${TARGET} == "beagle" || ${TARGET} == "zaurus")
 TARGET_ARCH=	arm
 .elif	(${TARGET} == "hp300" || ${TARGET} == "mvme68k")
 TARGET_ARCH=	m68k
Index: distrib/Makefile
===================================================================
RCS file: /cvs/src/distrib/Makefile,v
retrieving revision 1.42
diff -u -p -r1.42 Makefile
--- distrib/Makefile	26 Mar 2013 18:06:00 -0000	1.42
+++ distrib/Makefile	30 Jul 2013 17:53:07 -0000
@@ -3,7 +3,8 @@
 SUBDIR=	special notes
 
 .if	make(obj)
-SUBDIR+=alpha amd64 armish beagle hp300 hppa i386 landisk loongson luna88k \
+SUBDIR+=allwinner \
+	alpha amd64 armish beagle hp300 hppa i386 landisk loongson luna88k \
 	macppc mvme68k mvme88k octeon sgi socppc sparc sparc64 vax zaurus
 .elif exists(${MACHINE})
 SUBDIR+=${MACHINE}
Index: etc/Makefile
===================================================================
RCS file: /cvs/src/etc/Makefile,v
retrieving revision 1.333
diff -u -p -r1.333 Makefile
--- etc/Makefile	10 Jul 2013 05:12:15 -0000	1.333
+++ etc/Makefile	30 Jul 2013 17:53:07 -0000
@@ -349,6 +349,7 @@ moduli.8192:
 	bootblocks ${ALL_KERNELS}

+SUBDIR+= etc.allwinner
 SUBDIR+= etc.alpha etc.amd64 etc.armish etc.aviion etc.beagle etc.hp300
 SUBDIR+= etc.hppa etc.hppa64 etc.i386 etc.landisk etc.loongson etc.luna88k
 SUBDIR+= etc.macppc etc.mvme68k etc.mvme88k etc.octeon
Index: share/man/man8/Makefile
===================================================================
RCS file: /cvs/src/share/man/man8/Makefile,v
retrieving revision 1.84
diff -u -p -r1.84 Makefile
--- share/man/man8/Makefile	26 Mar 2013 18:06:00 -0000	1.84
+++ share/man/man8/Makefile	30 Jul 2013 17:53:16 -0000
@@ -13,7 +13,8 @@ MLINKS+=daily.8 weekly.8 daily.8 monthly
 MLINKS+=rc.8 rc.firsttime.8 rc.8 rc.local.8 rc.8 rc.securelevel.8
 MLINKS+=rc.conf.8 rc.conf.local.8
 
-SUBDIR=	man8.alpha man8.amd64 man8.armish man8.aviion man8.beagle \
+SUBDIR=	man8.allwinner \
+	man8.alpha man8.amd64 man8.armish man8.aviion man8.beagle \
 	man8.hp300 man8.hppa man8.hppa64 man8.i386 man8.landisk \
 	man8.loongson man8.luna88k man8.macppc man8.mvme68k man8.mvme88k \
 	man8.octeon man8.sgi man8.socppc man8.sparc man8.sparc64 man8.vax \
Index: sys/Makefile
===================================================================
RCS file: /cvs/src/sys/Makefile,v
retrieving revision 1.39
diff -u -p -r1.39 Makefile
--- sys/Makefile	26 Mar 2013 19:20:57 -0000	1.39
+++ sys/Makefile	30 Jul 2013 17:53:17 -0000
@@ -1,7 +1,7 @@
 #	$OpenBSD: Makefile,v 1.39 2013/03/26 19:20:57 jasper Exp $
 #	$NetBSD: Makefile,v 1.5 1995/09/15 21:05:21 pk Exp $
 
-SUBDIR=	dev/microcode \
+SUBDIR=	dev/microcode arch/allwinner \
 	arch/alpha arch/amd64 arch/armish arch/aviion arch/beagle \
 	arch/hp300 arch/hppa arch/hppa64 arch/i386 arch/landisk \
 	arch/loongson arch/luna88k arch/m68k arch/macppc \
Index: sys/dev/ic/com.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/com.c,v
retrieving revision 1.154
diff -u -p -r1.154 com.c
--- sys/dev/ic/com.c	14 Feb 2013 22:22:48 -0000	1.154
+++ sys/dev/ic/com.c	30 Jul 2013 17:53:19 -0000
@@ -1219,7 +1219,14 @@ comintr(void *arg)
 	if (!sc->sc_tty)
 		return (0);		/* Can't do squat. */
 
-	if (ISSET(bus_space_read_1(iot, ioh, com_iir), IIR_NOPEND))
+	u_char iir = bus_space_read_1(iot, ioh, com_iir);
+#if defined(__allwinner__)
+	if ((iir & IIR_IMASK) == IIR_BUSY) {
+		(void)bus_space_read_1(iot, ioh, com_usr);
+		return (0);
+	}
+#endif
+	if (ISSET(iir, IIR_NOPEND))
 		return (0);
 
 	tp = sc->sc_tty;
Index: sys/dev/ic/comreg.h
===================================================================
RCS file: /cvs/src/sys/dev/ic/comreg.h,v
retrieving revision 1.16
diff -u -p -r1.16 comreg.h
--- sys/dev/ic/comreg.h	8 Jun 2008 13:55:06 -0000	1.16
+++ sys/dev/ic/comreg.h	30 Jul 2013 17:53:19 -0000
@@ -76,6 +76,7 @@
 /* interrupt identification register */
 #define	IIR_IMASK	0xf
 #define	IIR_RXTOUT	0xc
+#define	IIR_BUSY	0x7	/* Busy, read usr to clear */
 #define	IIR_RLS		0x6	/* Line status change */
 #define	IIR_RXRDY	0x4	/* Receiver ready */
 #define	IIR_TXRDY	0x2	/* Transmitter ready */
@@ -179,6 +180,13 @@
 #define ISR_XMODE	0x04	/* 1.6us transmit pulse width */
 #define ISR_TXPL	0x08	/* negative transmit data polarity */
 #define ISR_RXPL	0x10	/* negative receive data polarity */
+
+/* uart status register */
+#define	USR_RFF		0x10	/* Rx FIFO Full */
+#define	USR_RFNE	0x08	/* Rx FIFO Not Empty */
+#define	USR_TFE		0x04	/* Tx FIFO Empty */
+#define	USR_TFNF	0x02	/* Tx FIFO Not Full */
+#define	USR_BUSY	0x01	/* Busy, dont write to lcr */
 
 #ifdef COM_PXA2X0
 #define	COM_NPORTS	9
Index: sys/dev/ic/ns16550reg.h
===================================================================
RCS file: /cvs/src/sys/dev/ic/ns16550reg.h,v
retrieving revision 1.5
diff -u -p -r1.5 ns16550reg.h
--- sys/dev/ic/ns16550reg.h	2 Jun 2003 23:28:02 -0000	1.5
+++ sys/dev/ic/ns16550reg.h	30 Jul 2013 17:53:19 -0000
@@ -36,6 +36,7 @@
  * NS16550 (and above) UART registers
  */
 
+#if !defined(__allwinner__)
 #define	com_data	0	/* data register (R/W) */
 #define	com_dlbl	0	/* divisor latch low (W) */
 #define	com_dlbh	1	/* divisor latch high (W) */
@@ -50,3 +51,23 @@
 #define	com_lsr		5	/* line status register (R/W) */
 #define	com_msr		6	/* modem status register (R/W) */
 #define com_scratch	7	/* scratch register (R/W) */
+#else
+#define	com_data	0x00	/* data register (R/W) */
+#define	com_dlbl	0x00	/* divisor latch low (W) */
+#define	com_dlbh	0x04	/* divisor latch high (W) */
+#define	com_ier		0x04	/* interrupt enable (W) */
+#define	com_iir		0x08	/* interrupt identification (R) */
+#define	com_fifo	0x08	/* FIFO control (W) */
+#define	com_fctl	0x08	/* extended FIFO control (W) */
+#define	com_efr		0x08	/* extended features register (W) */
+#define	com_lctl	0x0c	/* line control register (R/W) */
+#define	com_cfcr	com_lctl
+#define	com_mcr		0x10	/* modem control register (R/W) */
+#define	com_lsr		0x14	/* line status register (R/W) */
+#define	com_msr		0x18	/* modem status register (R/W) */
+#define	com_scratch	0x1c	/* scratch register (R/W) */
+#define	com_usr		0x7c	/* uart status register (R) */
+#define	com_tfl		0x80	/* tx fifo level register (R) */
+#define	com_rfl		0x84	/* rx fifo level register (R) */
+#define	com_halt	0xa4	/* uart halt tx register (R/W) */
+#endif