CVS commit: src/sys/arch/arm/allwinner

2018-02-12 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Feb 12 16:58:01 UTC 2018

Modified Files:
src/sys/arch/arm/allwinner: awin_eth.c

Log Message:
NULL-check after M_DONTWAIT.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/allwinner/awin_eth.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_eth.c
diff -u src/sys/arch/arm/allwinner/awin_eth.c:1.11 src/sys/arch/arm/allwinner/awin_eth.c:1.12
--- src/sys/arch/arm/allwinner/awin_eth.c:1.11	Fri Jun 10 13:27:10 2016
+++ src/sys/arch/arm/allwinner/awin_eth.c	Mon Feb 12 16:58:01 2018
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_eth.c,v 1.11 2016/06/10 13:27:10 ozaki-r Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_eth.c,v 1.12 2018/02/12 16:58:01 maxv Exp $");
 
 #include 
 #include 
@@ -401,6 +401,9 @@ awin_eth_mgethdr(struct awin_eth_softc *
 {
 	struct mbuf *m = m_gethdr(M_DONTWAIT, MT_DATA);
 
+	if (m == NULL) {
+		return NULL;
+	}
 	if (rxlen + 2 > MHLEN) {
 		MCLGET(m, M_DONTWAIT);
 		if ((m->m_flags & M_EXT) == 0) {



CVS commit: src/sys/arch/arm/allwinner

2017-07-02 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jul  2 15:09:53 UTC 2017

Modified Files:
src/sys/arch/arm/allwinner: awin_can.c

Log Message:
In the RX IRQ handler, release the receive buffer in the error paths.
Fix a hang I've been seeing under high traffic.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/allwinner/awin_can.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_can.c
diff -u src/sys/arch/arm/allwinner/awin_can.c:1.2 src/sys/arch/arm/allwinner/awin_can.c:1.3
--- src/sys/arch/arm/allwinner/awin_can.c:1.2	Sat May 27 21:02:55 2017
+++ src/sys/arch/arm/allwinner/awin_can.c	Sun Jul  2 15:09:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_can.c,v 1.2 2017/05/27 21:02:55 bouyer Exp $	*/
+/*	$NetBSD: awin_can.c,v 1.3 2017/07/02 15:09:53 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_can.c,v 1.2 2017/05/27 21:02:55 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_can.c,v 1.3 2017/07/02 15:09:53 bouyer Exp $");
 
 #include 
 #include 
@@ -239,12 +239,14 @@ awin_can_rx_intr(struct awin_can_softc *
 
 	if (dlc > CAN_MAX_DLC) {
 		ifp->if_ierrors++;
+		awin_can_write(sc, AWIN_CAN_CMD_REG, AWIN_CAN_CMD_REL_RX_BUF);
 		return;
 	}
 		
 	m = m_gethdr(M_NOWAIT, MT_HEADER);
 	if (m == NULL) {
 		ifp->if_ierrors++;
+		awin_can_write(sc, AWIN_CAN_CMD_REG, AWIN_CAN_CMD_REL_RX_BUF);
 		return;
 	}
 	cf = mtod(m, struct can_frame *);



CVS commit: src/sys/arch/arm/allwinner

2016-12-26 Thread Robert Swindells
Module Name:src
Committed By:   rjs
Date:   Mon Dec 26 16:20:17 UTC 2016

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
Remove more trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.89 src/sys/arch/arm/allwinner/awin_reg.h:1.90
--- src/sys/arch/arm/allwinner/awin_reg.h:1.89	Wed May 11 18:33:40 2016
+++ src/sys/arch/arm/allwinner/awin_reg.h	Mon Dec 26 16:20:17 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.89 2016/05/11 18:33:40 bouyer Exp $ */
+/* $NetBSD: awin_reg.h,v 1.90 2016/12/26 16:20:17 rjs Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -1296,8 +1296,8 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_PIO_INT_SIZE		0x0028
 
 #define AWIN_PIO_CFG_PINMASK(pin)	(7 << (4*((pin) & 7)))
-#define AWIN_PIO_DRV_MASK(pin)		((x) << (2*((pin) & 15))) 
-#define AWIN_PIO_PULn(v, pin)		((v) << (2*((pin) & 15))) 
+#define AWIN_PIO_DRV_MASK(pin)		((x) << (2*((pin) & 15)))
+#define AWIN_PIO_PULn(v, pin)		((v) << (2*((pin) & 15)))
 
 #define AWIN_PIO_FUNC_INPUT		0x0
 #define AWIN_PIO_FUNC_OUTPUT		0x1



CVS commit: src/sys/arch/arm/allwinner

2016-06-06 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Jun  6 12:25:37 UTC 2016

Modified Files:
src/sys/arch/arm/allwinner: awin_otgreg.h

Log Message:
Correct MUSB2_REG_RXNAKLIMIT offset on Allwinner.

This register is actually the RXINTERVAL register...


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/allwinner/awin_otgreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_otgreg.h
diff -u src/sys/arch/arm/allwinner/awin_otgreg.h:1.4 src/sys/arch/arm/allwinner/awin_otgreg.h:1.5
--- src/sys/arch/arm/allwinner/awin_otgreg.h:1.4	Mon Oct 20 21:18:00 2014
+++ src/sys/arch/arm/allwinner/awin_otgreg.h	Mon Jun  6 12:25:37 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_otgreg.h,v 1.4 2014/10/20 21:18:00 jmcneill Exp $ */
+/* $NetBSD: awin_otgreg.h,v 1.5 2016/06/06 12:25:37 jakllsch Exp $ */
 /* FreeBSD: head/sys/dev/usb/controller/musb_otg.h 267122 2014-06-05 18:23:51Z hselasky */
 /*-
  * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
@@ -187,7 +187,7 @@
 #define	MUSB2_MASK_TI_EP_NUM 0x0F
 
 #define	MUSB2_REG_TXNAKLIMIT (0x000D /* EPN=0 */ + MUSB2_REG_INDEXED_CSR)
-#define	MUSB2_REG_RXNAKLIMIT (0x000D /* EPN=0 */ + MUSB2_REG_INDEXED_CSR)
+#define	MUSB2_REG_RXNAKLIMIT (0x000F /* EPN=0 */ + MUSB2_REG_INDEXED_CSR)
 #define	MUSB2_MASK_NAKLIMIT 0xFF
 
 #define MUSB2_REG_FSIZE (0x0010 + MUSB2_REG_INDEXED_CSR)



CVS commit: src/sys/arch/arm/allwinner

2016-05-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May 26 07:45:51 UTC 2016

Modified Files:
src/sys/arch/arm/allwinner: awin_gpio.c

Log Message:
Remove a KASSERT() which is A20-specific, as well as the local variable
used here.
Fix "error: unused variable 'grp'" for non-DIAGNOSTIC kernels,
reported by Rin Okuyama.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/allwinner/awin_gpio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_gpio.c
diff -u src/sys/arch/arm/allwinner/awin_gpio.c:1.21 src/sys/arch/arm/allwinner/awin_gpio.c:1.22
--- src/sys/arch/arm/allwinner/awin_gpio.c:1.21	Wed May 11 18:33:40 2016
+++ src/sys/arch/arm/allwinner/awin_gpio.c	Thu May 26 07:45:51 2016
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.21 2016/05/11 18:33:40 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.22 2016/05/26 07:45:51 bouyer Exp $");
 
 #include 
 #include 
@@ -934,11 +934,9 @@ awin_gpio_pin_ctl(void *cookie, int pin,
 static void
 awin_gpio_pin_irqen(void *cookie, int pin, bool enable)
 {
-	struct awin_gpio_pin_group * const grp = cookie;
 	uint32_t enabled;
 	struct awin_gpio_softc *sc = _gpio_sc;
 
-	KASSERT(grp->grp_index == 7);
 	mutex_enter(>sc_intr_lock);
 	enabled = bus_space_read_4(sc->sc_bst, sc->sc_eint_bsh,
 	INT_OFFSET(AWIN_PIO_INT_CTL_REG));



CVS commit: src/sys/arch/arm/allwinner

2016-04-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Apr 12 10:54:30 UTC 2016

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
Alternate UART3 pins a PG6-7, not PG8-9


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.86 src/sys/arch/arm/allwinner/awin_reg.h:1.87
--- src/sys/arch/arm/allwinner/awin_reg.h:1.86	Mon Jan 11 17:09:25 2016
+++ src/sys/arch/arm/allwinner/awin_reg.h	Tue Apr 12 10:54:29 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.86 2016/01/11 17:09:25 macallan Exp $ */
+/* $NetBSD: awin_reg.h,v 1.87 2016/04/12 10:54:29 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -1410,7 +1410,7 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_PIO_PG_CSI1_FUNC		3
 #define AWIN_PIO_PG_UART4_PINS		0x0c00 /* PG pins 11-10 */
 #define AWIN_PIO_PG_UART4_FUNC		4
-#define AWIN_PIO_PG_UART3_PINS		0x0300 /* PG pins 9-8 */
+#define AWIN_PIO_PG_UART3_PINS		0x00c0 /* PG pins 6-7 */
 #define AWIN_PIO_PG_UART3_FUNC		4
 #define AWIN_PIO_PG_SDC1_PINS		0x003f /* PG pins 5-0 */
 #define AWIN_PIO_PG_SDC1_FUNC		4



CVS commit: src/sys/arch/arm/allwinner

2016-01-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan 13 13:29:51 UTC 2016

Modified Files:
src/sys/arch/arm/allwinner: awin_tcon.c

Log Message:
add OUTPUT_VGA in order to shut down the right output(s) when blanking etc.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/allwinner/awin_tcon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_tcon.c
diff -u src/sys/arch/arm/allwinner/awin_tcon.c:1.11 src/sys/arch/arm/allwinner/awin_tcon.c:1.12
--- src/sys/arch/arm/allwinner/awin_tcon.c:1.11	Fri Nov 20 18:32:13 2015
+++ src/sys/arch/arm/allwinner/awin_tcon.c	Wed Jan 13 13:29:51 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_tcon.c,v 1.11 2015/11/20 18:32:13 bouyer Exp $ */
+/* $NetBSD: awin_tcon.c,v 1.12 2016/01/13 13:29:51 macallan Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #include "opt_allwinner.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.11 2015/11/20 18:32:13 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.12 2016/01/13 13:29:51 macallan Exp $");
 
 #include 
 #include 
@@ -67,6 +67,7 @@ struct awin_tcon_softc {
 	unsigned int sc_output_type;
 #define OUTPUT_HDMI 0
 #define OUTPUT_LVDS 1
+#define OUTPUT_VGA 2
 	const char *sc_lcdpwr_pin_name;
 	struct awin_gpio_pindata sc_lcdpwr_pin;
 	const char *sc_lcdblk_pin_name;
@@ -159,6 +160,8 @@ awin_tcon_attach(device_t parent, device
 			sc->sc_output_type = OUTPUT_HDMI;
 		} else if (strcmp(output, "lvds") == 0) {
 			sc->sc_output_type = OUTPUT_LVDS;
+		} else if (strcmp(output, "vga") == 0) {
+			sc->sc_output_type = OUTPUT_VGA;
 		} else {
 			panic("tcon: wrong mode %s", output);
 		}
@@ -254,7 +257,8 @@ awin_tcon_set_pll(struct awin_tcon_softc
 	switch(sc->sc_clk_pll) {
 	case 3:
 		awin_pll3_set_rate(n * 300);
-		if (sc->sc_output_type == OUTPUT_HDMI) {
+		if ((sc->sc_output_type == OUTPUT_HDMI) ||
+		(sc->sc_output_type == OUTPUT_VGA)) {
 			awin_reg_set_clear(sc->sc_bst, sc->sc_ch1clk_bsh, 0,
 			AWIN_CLK_OUT_ENABLE |
 			AWIN_LCDx_CH1_SCLK1_GATING |
@@ -286,7 +290,8 @@ awin_tcon_set_pll(struct awin_tcon_softc
 		break;
 	case 7:
 		awin_pll7_set_rate(n * 300);
-		if (sc->sc_output_type == OUTPUT_HDMI) {
+		if ((sc->sc_output_type == OUTPUT_HDMI) || 
+		(sc->sc_output_type == OUTPUT_VGA)) {
 			awin_reg_set_clear(sc->sc_bst, sc->sc_ch1clk_bsh, 0,
 			AWIN_CLK_OUT_ENABLE |
 			AWIN_LCDx_CH1_SCLK1_GATING |
@@ -593,7 +598,8 @@ awin_tcon1_enable(int unit, bool enable)
 		return;
 	}
 	sc = device_private(dev);
-	KASSERT(sc->sc_output_type == OUTPUT_HDMI);
+	KASSERT((sc->sc_output_type == OUTPUT_HDMI) || 
+		(sc->sc_output_type == OUTPUT_VGA));
 
 	awin_debe_enable(device_unit(sc->sc_dev), enable);
 	delay(2);
@@ -604,7 +610,10 @@ awin_tcon1_enable(int unit, bool enable)
 		val = TCON_READ(sc, AWIN_TCON1_CTL_REG);
 		val |= AWIN_TCONx_CTL_EN;
 		TCON_WRITE(sc, AWIN_TCON1_CTL_REG, val);
-		TCON_WRITE(sc, AWIN_TCON1_IO_TRI_REG, 0);
+		if (sc->sc_output_type == OUTPUT_VGA) {
+			TCON_WRITE(sc, AWIN_TCON1_IO_TRI_REG, 0x0cff);
+		} else
+			TCON_WRITE(sc, AWIN_TCON1_IO_TRI_REG, 0);
 	} else {
 		TCON_WRITE(sc, AWIN_TCON1_IO_TRI_REG, 0x);
 		val = TCON_READ(sc, AWIN_TCON1_CTL_REG);
@@ -618,7 +627,7 @@ awin_tcon1_enable(int unit, bool enable)
 	KASSERT(tcon_mux_inited);
 	val = bus_space_read_4(sc->sc_bst, tcon_mux_bsh, 0);
 #ifdef AWIN_TCON_DEBUG
-	printf("awin_tcon1_enable(%d) val 0x%x", unit, val);
+	printf("awin_tcon1_enable(%d) %d val 0x%x", unit, enable, val);
 #endif
 	val &= ~ AWIN_TCON_MUX_CTL_HDMI_OUTPUT_SRC;
 	if (unit == 0) {
@@ -652,7 +661,8 @@ awin_tcon1_set_videomode(int unit, const
 		return;
 	}
 	sc = device_private(dev);
-	KASSERT(sc->sc_output_type == OUTPUT_HDMI);
+	KASSERT((sc->sc_output_type == OUTPUT_HDMI) || 
+		(sc->sc_output_type == OUTPUT_VGA));
 
 	awin_debe_set_videomode(device_unit(sc->sc_dev), mode);
 	if (mode) {
@@ -660,9 +670,9 @@ awin_tcon1_set_videomode(int unit, const
 		const u_int phsync_p = !!(mode->flags & VID_PHSYNC);
 		const u_int pvsync_p = !!(mode->flags & VID_PVSYNC);
 		const u_int hspw = mode->hsync_end - mode->hsync_start;
-		const u_int hbp = mode->htotal - mode->hsync_start;
+		const u_int hbp = mode->htotal - mode->hsync_end;
 		const u_int vspw = mode->vsync_end - mode->vsync_start;
-		const u_int vbp = mode->vtotal - mode->vsync_start;
+		const u_int vbp = mode->vtotal - mode->vsync_end;
 		const u_int vblank_len =
 		((mode->vtotal << interlace_p) >> 1) - mode->vdisplay - 2;
 		const u_int start_delay =
@@ -801,9 +811,15 @@ awin_tcon_setvideo(int unit, bool enable
 	}
 	sc = device_private(dev);
 
-	if (sc->sc_output_type == OUTPUT_HDMI)  {
-		awin_hdmi_poweron(enable);
-	} else {
-		awin_tcon0_enable(sc, enable);
+	switch (sc->sc_output_type) {
+		case OUTPUT_HDMI:
+			awin_hdmi_poweron(enable);
+			

CVS commit: src/sys/arch/arm/allwinner

2016-01-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan 13 17:07:52 UTC 2016

Modified Files:
src/sys/arch/arm/allwinner: awin_tcon.c

Log Message:
revert accidentially committed changes in awin_tcon1_set_videomode()


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/allwinner/awin_tcon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_tcon.c
diff -u src/sys/arch/arm/allwinner/awin_tcon.c:1.12 src/sys/arch/arm/allwinner/awin_tcon.c:1.13
--- src/sys/arch/arm/allwinner/awin_tcon.c:1.12	Wed Jan 13 13:29:51 2016
+++ src/sys/arch/arm/allwinner/awin_tcon.c	Wed Jan 13 17:07:51 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_tcon.c,v 1.12 2016/01/13 13:29:51 macallan Exp $ */
+/* $NetBSD: awin_tcon.c,v 1.13 2016/01/13 17:07:51 macallan Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #include "opt_allwinner.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.12 2016/01/13 13:29:51 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.13 2016/01/13 17:07:51 macallan Exp $");
 
 #include 
 #include 
@@ -670,9 +670,9 @@ awin_tcon1_set_videomode(int unit, const
 		const u_int phsync_p = !!(mode->flags & VID_PHSYNC);
 		const u_int pvsync_p = !!(mode->flags & VID_PVSYNC);
 		const u_int hspw = mode->hsync_end - mode->hsync_start;
-		const u_int hbp = mode->htotal - mode->hsync_end;
+		const u_int hbp = mode->htotal - mode->hsync_start;
 		const u_int vspw = mode->vsync_end - mode->vsync_start;
-		const u_int vbp = mode->vtotal - mode->vsync_end;
+		const u_int vbp = mode->vtotal - mode->vsync_start;
 		const u_int vblank_len =
 		((mode->vtotal << interlace_p) >> 1) - mode->vdisplay - 2;
 		const u_int start_delay =



CVS commit: src/sys/arch/arm/allwinner

2016-01-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Jan 11 17:09:25 UTC 2016

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
moar register bits


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.85 src/sys/arch/arm/allwinner/awin_reg.h:1.86
--- src/sys/arch/arm/allwinner/awin_reg.h:1.85	Sat Dec 26 16:48:54 2015
+++ src/sys/arch/arm/allwinner/awin_reg.h	Mon Jan 11 17:09:25 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.85 2015/12/26 16:48:54 macallan Exp $ */
+/* $NetBSD: awin_reg.h,v 1.86 2016/01/11 17:09:25 macallan Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -2343,7 +2343,9 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_TVE_CONFIG_2		0x0138
 #define AWIN_TVE_CONFIG_3		0x013C
 
-
+/* AWIN_TVE_ENABLE */
+#define AWIN_TVE_CLOCK_GATE_DISABLE	__BIT(31)
+#define AWIN_TVE_EN			__BIT(0)
 
 /*
  * A31 registers



CVS commit: src/sys/arch/arm/allwinner

2015-12-26 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Dec 26 16:48:54 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
add registers for TV encoder / VGA output


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.84 src/sys/arch/arm/allwinner/awin_reg.h:1.85
--- src/sys/arch/arm/allwinner/awin_reg.h:1.84	Sun Nov 15 21:28:54 2015
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sat Dec 26 16:48:54 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.84 2015/11/15 21:28:54 bouyer Exp $ */
+/* $NetBSD: awin_reg.h,v 1.85 2015/12/26 16:48:54 macallan Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -2305,6 +2305,47 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_MP_CMDQUESTS_FINISHIRQ_FLAG	__BIT(8)
 
 /*
+ * TVE registers
+ */
+
+#define AWIN_TVE_ENABLE			0x
+#define AWIN_TVE_CONFIG			0x0004
+#define AWIN_TVE_DAC_1			0x0008
+#define AWIN_TVE_NOTCH			0x000c
+#define AWIN_TVE_CHROMA			0x0010
+#define AWIN_TVE_PORCH			0x0014
+#define AWIN_TVE_VSYNC			0x0018
+#define AWIN_TVE_LINENUMBER		0x001C
+#define AWIN_TVE_LEVEL			0x0020
+#define AWIN_TVE_DAC_2			0x0024
+#define AWIN_TVE_AUTODETECT_E		0x0030
+#define AWIN_TVE_AUTODETECT_INTR	0x0034
+#define AWIN_TVE_AUTODETECT_STATUS	0x0038
+#define AWIN_TVE_AUTODETECT_DEBOUNCE	0x003C
+#define AWIN_TVE_CSC_1			0x0040
+#define AWIN_TVE_CSC_2			0x0044
+#define AWIN_TVE_CSC_3			0x0048
+#define AWIN_TVE_CSC_4			0x004C
+#define AWIN_TVE_COLOR_BURST		0x0100
+#define AWIN_TVE_VSYNC_NUMBER		0x0104
+#define AWIN_TVE_NOTCH_FREQ		0x0108
+#define AWIN_TVE_CBCR			0x010C
+#define AWIN_TVE_TINT			0x0110
+#define AWIN_TVE_BURST_WIDTH		0x0114
+#define AWIN_TVE_CBCR_GAIN		0x0118
+#define AWIN_TVE_SYNC_VBI		0x011C
+#define AWIN_TVE_WHITE_LEVEL		0x0120
+#define AWIN_TVE_ACTIVE_LINE		0x0124
+#define AWIN_TVE_CHROMA_COMPGAIN	0x0128
+#define AWIN_TVE_TVENC			0x012C
+#define AWIN_TVE_RESYNC			0x0130
+#define AWIN_TVE_SLAVE_PARAM		0x0134
+#define AWIN_TVE_CONFIG_2		0x0138
+#define AWIN_TVE_CONFIG_3		0x013C
+
+
+
+/*
  * A31 registers
  */
 #define AWIN_A31_USB0_OFFSET		0x00019000	/* OTG */



CVS commit: src/sys/arch/arm/allwinner

2015-12-26 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Dec 26 16:56:41 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_io.c files.awin
Added Files:
src/sys/arch/arm/allwinner: awin_tve.c

Log Message:
driver for cubietruck's VGA port. Not quite finished but enough to be useful


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/allwinner/awin_io.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/allwinner/awin_tve.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_io.c
diff -u src/sys/arch/arm/allwinner/awin_io.c:1.43 src/sys/arch/arm/allwinner/awin_io.c:1.44
--- src/sys/arch/arm/allwinner/awin_io.c:1.43	Mon Apr 20 01:33:22 2015
+++ src/sys/arch/arm/allwinner/awin_io.c	Sat Dec 26 16:56:41 2015
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_io.c,v 1.43 2015/04/20 01:33:22 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_io.c,v 1.44 2015/12/26 16:56:41 macallan Exp $");
 
 #include 
 #include 
@@ -168,6 +168,7 @@ static const struct awin_locators awin_l
 	{ "awiniic", OFFANDSIZE(A80_TWI2), 2, AWIN_A80_IRQ_TWI2, A80 },
 	{ "awiniic", OFFANDSIZE(A80_TWI3), 3, AWIN_A80_IRQ_TWI3, A80 },
 	{ "awiniic", OFFANDSIZE(A80_TWI4), 4, AWIN_A80_IRQ_TWI4, A80 },
+	{ "awintve", OFFANDSIZE(TVE0), 0, AWIN_IRQ_TVE, A20 },
 	{ "awinp2wi", OFFANDSIZE(A31_P2WI), NOPORT, AWIN_A31_IRQ_P2WI, A31 },
 	{ "awinp2wi", OFFANDSIZE(A80_RSB), NOPORT, AWIN_A80_IRQ_R_RSB, A80 },
 	{ "spi", OFFANDSIZE(SPI0), 0, AWIN_IRQ_SPI0, AANY },

Index: src/sys/arch/arm/allwinner/files.awin
diff -u src/sys/arch/arm/allwinner/files.awin:1.33 src/sys/arch/arm/allwinner/files.awin:1.34
--- src/sys/arch/arm/allwinner/files.awin:1.33	Sun Nov 22 17:50:48 2015
+++ src/sys/arch/arm/allwinner/files.awin	Sat Dec 26 16:56:41 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: files.awin,v 1.33 2015/11/22 17:50:48 aymeric Exp $
+#	$NetBSD: files.awin,v 1.34 2015/12/26 16:56:41 macallan Exp $
 #
 # Configuration info for Allwinner ARM Peripherals
 #
@@ -144,6 +144,11 @@ device	awinhdmi: edid, videomode
 attach	awinhdmi at awinio with awin_hdmi
 file	arch/arm/allwinner/awin_hdmi.c		awin_hdmi
 
+# A20 TV Encoder / VGA output
+device	awintve: edid, videomode
+attach	awintve at awinio with awin_tve
+file	arch/arm/allwinner/awin_tve.c		awin_tve
+
 # A20/A31 HDMI audio (HDMIAUDIO)
 device	awinhdmiaudio: audiobus, auconv, mulaw, aurateconv, auvolconv
 attach	awinhdmiaudio at awinio with awin_hdmiaudio

Added files:

Index: src/sys/arch/arm/allwinner/awin_tve.c
diff -u /dev/null src/sys/arch/arm/allwinner/awin_tve.c:1.1
--- /dev/null	Sat Dec 26 16:56:41 2015
+++ src/sys/arch/arm/allwinner/awin_tve.c	Sat Dec 26 16:56:41 2015
@@ -0,0 +1,297 @@
+/* $NetBSD: awin_tve.c,v 1.1 2015/12/26 16:56:41 macallan Exp $ */
+
+/*-
+ * Copyright (c) 2015 Michael Lorenz
+ *   2014 Jared D. McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* based on jmcneill's awin_hdmi.c */
+
+#include "opt_ddb.h"
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: awin_tve.c,v 1.1 2015/12/26 16:56:41 macallan Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "opt_allwinner.h"
+
+#define AWIN_TVE_DEBUG
+
+struct awin_tve_softc {
+	device_t sc_dev;
+	bus_space_tag_t sc_bst;
+	bus_space_handle_t sc_bsh;
+	void *sc_ih;
+
+	struct i2c_controller *sc_i2c;
+
+	bool sc_connected;
+	char sc_display_vendor[16];
+	char sc_display_product[16];
+	
+	int   

CVS commit: src/sys/arch/arm/allwinner

2015-12-26 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Dec 26 16:54:41 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_twi.c awin_var.h

Log Message:
add access function to get the i2c_controller, awiniic2 is the VGA output's
DDC2 port on cubietruck


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/allwinner/awin_twi.c
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/arm/allwinner/awin_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_twi.c
diff -u src/sys/arch/arm/allwinner/awin_twi.c:1.6 src/sys/arch/arm/allwinner/awin_twi.c:1.7
--- src/sys/arch/arm/allwinner/awin_twi.c:1.6	Fri Dec  5 15:25:27 2014
+++ src/sys/arch/arm/allwinner/awin_twi.c	Sat Dec 26 16:54:41 2015
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_twi.c,v 1.6 2014/12/05 15:25:27 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_twi.c,v 1.7 2015/12/26 16:54:41 macallan Exp $");
 
 #include 
 #include 
@@ -208,3 +208,14 @@ awin_twi_attach(device_t parent, device_
 	 */
 	gttwsi_config_children(self);
 }
+
+struct i2c_controller *
+awin_twi_get_controller(device_t dev)
+{
+	if (!device_is_a(dev, "awiniic"))
+		return NULL;
+
+	struct awin_twi_softc * const sc = device_private(dev);
+
+	return >asc_sc.sc_i2c;
+}

Index: src/sys/arch/arm/allwinner/awin_var.h
diff -u src/sys/arch/arm/allwinner/awin_var.h:1.39 src/sys/arch/arm/allwinner/awin_var.h:1.40
--- src/sys/arch/arm/allwinner/awin_var.h:1.39	Thu Nov 19 18:48:22 2015
+++ src/sys/arch/arm/allwinner/awin_var.h	Sat Dec 26 16:54:41 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_var.h,v 1.39 2015/11/19 18:48:22 bouyer Exp $ */
+/* $NetBSD: awin_var.h,v 1.40 2015/12/26 16:54:41 macallan Exp $ */
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -189,4 +189,6 @@ awin_reg_set_clear(bus_space_tag_t bst, 
 	}
 }
 
+struct i2c_controller *awin_twi_get_controller(device_t);
+
 #endif /* _ARM_ALLWINNER_AWIN_VAR_H_ */



CVS commit: src/sys/arch/arm/allwinner

2015-11-22 Thread Aymeric Vincent
Module Name:src
Committed By:   aymeric
Date:   Sun Nov 22 17:50:48 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c files.awin

Log Message:
do not fail if no awintcon is present so that ALLWINNER_A80 compiles again


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/allwinner/awin_debe.c
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.19 src/sys/arch/arm/allwinner/awin_debe.c:1.20
--- src/sys/arch/arm/allwinner/awin_debe.c:1.19	Thu Nov 19 18:48:22 2015
+++ src/sys/arch/arm/allwinner/awin_debe.c	Sun Nov 22 17:50:48 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $ */
+/* $NetBSD: awin_debe.c,v 1.20 2015/11/22 17:50:48 aymeric Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -29,6 +29,7 @@
 #include "opt_allwinner.h"
 #include "genfb.h"
 #include "awin_mp.h"
+#include "awin_tcon.h"
 
 #ifndef AWIN_DEBE_VIDEOMEM
 #define AWIN_DEBE_VIDEOMEM	(16 * 1024 * 1024)
@@ -37,7 +38,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.20 2015/11/22 17:50:48 aymeric Exp $");
 
 #include 
 #include 
@@ -602,8 +603,10 @@ awin_debe_ioctl(device_t self, u_long cm
 			val &= ~AWIN_DEBE_MODCTL_HWC_EN;
 		}
 		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
+#if NAWIN_TCON > 0
 		/* debe0 always connected to tcon0, debe1 to tcon1*/
 		awin_tcon_setvideo(device_unit(sc->sc_dev), enable);
+#endif
 		return 0;
 	case WSDISPLAYIO_GVIDEO:
 		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);

Index: src/sys/arch/arm/allwinner/files.awin
diff -u src/sys/arch/arm/allwinner/files.awin:1.32 src/sys/arch/arm/allwinner/files.awin:1.33
--- src/sys/arch/arm/allwinner/files.awin:1.32	Sat Jul 25 15:19:54 2015
+++ src/sys/arch/arm/allwinner/files.awin	Sun Nov 22 17:50:48 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: files.awin,v 1.32 2015/07/25 15:19:54 jmcneill Exp $
+#	$NetBSD: files.awin,v 1.33 2015/11/22 17:50:48 aymeric Exp $
 #
 # Configuration info for Allwinner ARM Peripherals
 #
@@ -152,7 +152,7 @@ file	arch/arm/allwinner/awin_hdmiaudio.c
 # A10/A20/A31 LCD/TV timing controller (TCON)
 device	awintcon
 attach	awintcon at awinio with awin_tcon
-file	arch/arm/allwinner/awin_tcon.c		awin_tcon | awin_hdmi
+file	arch/arm/allwinner/awin_tcon.c		awin_tcon | awin_hdmi	needs-flag
 
 # A10/A20/A31 Display engine backend (DE-BE)
 device	awindebe { }



CVS commit: src/sys/arch/arm/allwinner

2015-11-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Nov 20 18:32:13 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_tcon.c

Log Message:
Turn off more bits when turning off the display. Saves about 50ma on the
5V supply.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/allwinner/awin_tcon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_tcon.c
diff -u src/sys/arch/arm/allwinner/awin_tcon.c:1.10 src/sys/arch/arm/allwinner/awin_tcon.c:1.11
--- src/sys/arch/arm/allwinner/awin_tcon.c:1.10	Thu Nov 19 18:48:22 2015
+++ src/sys/arch/arm/allwinner/awin_tcon.c	Fri Nov 20 18:32:13 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_tcon.c,v 1.10 2015/11/19 18:48:22 bouyer Exp $ */
+/* $NetBSD: awin_tcon.c,v 1.11 2015/11/20 18:32:13 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #include "opt_allwinner.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.10 2015/11/19 18:48:22 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.11 2015/11/20 18:32:13 bouyer Exp $");
 
 #include 
 #include 
@@ -555,13 +555,29 @@ awin_tcon0_enable(struct awin_tcon_softc
 
 	awin_debe_enable(device_unit(sc->sc_dev), enable);
 	delay(2);
-	val = TCON_READ(sc, AWIN_TCON_GCTL_REG);
 	if (enable) {
+		val = TCON_READ(sc, AWIN_TCON_GCTL_REG);
 		val |= AWIN_TCON_GCTL_EN;
+		TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val);
+		val = TCON_READ(sc, AWIN_TCON0_CTL_REG);
+		val |= AWIN_TCONx_CTL_EN;
+		TCON_WRITE(sc, AWIN_TCON0_CTL_REG, val);
+		val = TCON_READ(sc, AWIN_TCON0_LVDS_IF_REG);
+		val |= AWIN_TCON0_LVDS_IF_EN;
+		TCON_WRITE(sc, AWIN_TCON0_LVDS_IF_REG, val);
+		TCON_WRITE(sc, AWIN_TCON0_IO_TRI_REG, 0);
 	} else {
+		TCON_WRITE(sc, AWIN_TCON0_IO_TRI_REG, 0x);
+		val = TCON_READ(sc, AWIN_TCON0_LVDS_IF_REG);
+		val &= ~AWIN_TCON0_LVDS_IF_EN;
+		TCON_WRITE(sc, AWIN_TCON0_LVDS_IF_REG, val);
+		val = TCON_READ(sc, AWIN_TCON0_CTL_REG);
+		val &= ~AWIN_TCONx_CTL_EN;
+		TCON_WRITE(sc, AWIN_TCON0_CTL_REG, val);
+		val = TCON_READ(sc, AWIN_TCON_GCTL_REG);
 		val &= ~AWIN_TCON_GCTL_EN;
+		TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val);
 	}
-	TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val);
 }
 
 void
@@ -581,15 +597,23 @@ awin_tcon1_enable(int unit, bool enable)
 
 	awin_debe_enable(device_unit(sc->sc_dev), enable);
 	delay(2);
-	val = TCON_READ(sc, AWIN_TCON_GCTL_REG);
 	if (enable) {
+		val = TCON_READ(sc, AWIN_TCON_GCTL_REG);
 		val |= AWIN_TCON_GCTL_EN;
+		TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val);
+		val = TCON_READ(sc, AWIN_TCON1_CTL_REG);
+		val |= AWIN_TCONx_CTL_EN;
+		TCON_WRITE(sc, AWIN_TCON1_CTL_REG, val);
+		TCON_WRITE(sc, AWIN_TCON1_IO_TRI_REG, 0);
 	} else {
+		TCON_WRITE(sc, AWIN_TCON1_IO_TRI_REG, 0x);
+		val = TCON_READ(sc, AWIN_TCON1_CTL_REG);
+		val &= ~AWIN_TCONx_CTL_EN;
+		TCON_WRITE(sc, AWIN_TCON1_CTL_REG, val);
+		val = TCON_READ(sc, AWIN_TCON_GCTL_REG);
 		val &= ~AWIN_TCON_GCTL_EN;
+		TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val);
 	}
-	TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val);
-
-	TCON_WRITE(sc, AWIN_TCON1_IO_TRI_REG, 0);
 
 	KASSERT(tcon_mux_inited);
 	val = bus_space_read_4(sc->sc_bst, tcon_mux_bsh, 0);



CVS commit: src/sys/arch/arm/allwinner

2015-11-19 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Nov 19 18:48:22 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c awin_hdmi.c awin_hdmiaudio.c
awin_tcon.c awin_var.h

Log Message:
Turn off video output on WSDISPLAYIO_SVIDEO.
For LCD/LVDS, just stop the tcon0.
For HDMI, turn off tcon and hdmi (so that the monitor goes to sleeo)
if the audio output is inactive.
For this, add a lock-protected refcount in awin_hdmi, incremented when
audio and/or video is active.
Tested with an audio-enabled HDMI display.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/allwinner/awin_debe.c \
src/sys/arch/arm/allwinner/awin_hdmi.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/allwinner/awin_hdmiaudio.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/allwinner/awin_tcon.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/arm/allwinner/awin_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.18 src/sys/arch/arm/allwinner/awin_debe.c:1.19
--- src/sys/arch/arm/allwinner/awin_debe.c:1.18	Tue Nov  3 18:38:03 2015
+++ src/sys/arch/arm/allwinner/awin_debe.c	Thu Nov 19 18:48:22 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.18 2015/11/03 18:38:03 bouyer Exp $ */
+/* $NetBSD: awin_debe.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -37,7 +37,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.18 2015/11/03 18:38:03 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $");
 
 #include 
 #include 
@@ -583,6 +583,10 @@ awin_debe_ioctl(device_t self, u_long cm
 		enable = *(int *)data;
 		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
 		if (enable) {
+			if (val & AWIN_DEBE_MODCTL_LAY0_EN) {
+/* already enabled */
+return 0;
+			}
 			val |= AWIN_DEBE_MODCTL_LAY0_EN;
 			if (sc->sc_cursor_enable) {
 val |= AWIN_DEBE_MODCTL_HWC_EN;
@@ -590,10 +594,16 @@ awin_debe_ioctl(device_t self, u_long cm
 val &= ~AWIN_DEBE_MODCTL_HWC_EN;
 			}
 		} else {
+			if ((val & AWIN_DEBE_MODCTL_LAY0_EN) == 0) {
+/* already disabled */
+return 0;
+			}
 			val &= ~AWIN_DEBE_MODCTL_LAY0_EN;
 			val &= ~AWIN_DEBE_MODCTL_HWC_EN;
 		}
 		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
+		/* debe0 always connected to tcon0, debe1 to tcon1*/
+		awin_tcon_setvideo(device_unit(sc->sc_dev), enable);
 		return 0;
 	case WSDISPLAYIO_GVIDEO:
 		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.18 src/sys/arch/arm/allwinner/awin_hdmi.c:1.19
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.18	Sun Nov 15 21:28:54 2015
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Thu Nov 19 18:48:22 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.18 2015/11/15 21:28:54 bouyer Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -30,7 +30,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_hdmi.c,v 1.18 2015/11/15 21:28:54 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_hdmi.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $");
 
 #include 
 #include 
@@ -74,6 +74,9 @@ struct awin_hdmi_softc {
 	int   sc_tcon_unit;
 	unsigned int sc_tcon_pll;
 
+	kmutex_t sc_pwr_lock;
+	int	sc_pwr_refcount; /* reference who needs HDMI */
+
 	uint32_t sc_ver;
 	unsigned int sc_i2c_blklen;
 };
@@ -219,6 +222,9 @@ awin_hdmi_attach(device_t parent, device
 	aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr);
 #endif
 
+	mutex_init(>sc_pwr_lock, MUTEX_DEFAULT, IPL_NONE);
+	sc->sc_pwr_refcount = 1; /* we start with video powered on */
+
 	awin_hdmi_i2c_init(sc);
 
 	awin_hdmi_enable(sc);
@@ -990,6 +996,36 @@ awin_hdmi_get_info(struct awin_hdmi_info
 	}
 }
 
+void
+awin_hdmi_poweron(bool enable)
+{
+	struct awin_hdmi_softc *sc;
+	device_t dev;
+
+	dev = device_find_by_driver_unit("awinhdmi", 0);
+	if (dev == NULL) {
+		return;
+	}
+	sc = device_private(dev);
+	mutex_enter(>sc_pwr_lock);
+	if (enable) {
+		KASSERT(sc->sc_pwr_refcount >= 0);
+		if (sc->sc_pwr_refcount == 0) {
+			awin_tcon1_enable(sc->sc_tcon_unit, true);
+			awin_hdmi_video_enable(sc, true);
+		}
+		sc->sc_pwr_refcount++;
+	} else {
+		sc->sc_pwr_refcount--;
+		KASSERT(sc->sc_pwr_refcount >= 0);
+		if (sc->sc_pwr_refcount == 0) {
+			awin_hdmi_video_enable(sc, false);
+			awin_tcon1_enable(sc->sc_tcon_unit, false);
+		}
+	}
+	mutex_exit(>sc_pwr_lock);
+}
+
 #if defined(DDB)
 void
 awin_hdmi_dump_regs(void)

Index: src/sys/arch/arm/allwinner/awin_hdmiaudio.c
diff -u src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.5 src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.6
--- src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.5	Tue Nov 18 01:53:53 

CVS commit: src/sys/arch/arm/allwinner

2015-11-14 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 14 10:32:40 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_mmc.c

Log Message:
Wait 20ms for the PLL to stabilize after enabling it.
Fixes occasional bogus size report for my SD card.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/allwinner/awin_mmc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_mmc.c
diff -u src/sys/arch/arm/allwinner/awin_mmc.c:1.22 src/sys/arch/arm/allwinner/awin_mmc.c:1.23
--- src/sys/arch/arm/allwinner/awin_mmc.c:1.22	Fri Oct 16 14:22:25 2015
+++ src/sys/arch/arm/allwinner/awin_mmc.c	Sat Nov 14 10:32:40 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_mmc.c,v 1.22 2015/10/16 14:22:25 bouyer Exp $ */
+/* $NetBSD: awin_mmc.c,v 1.23 2015/11/14 10:32:40 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #include "locators.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_mmc.c,v 1.22 2015/10/16 14:22:25 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_mmc.c,v 1.23 2015/11/14 10:32:40 bouyer Exp $");
 
 #include 
 #include 
@@ -380,6 +380,7 @@ awin_mmc_set_clock(struct awin_mmc_softc
 	clk |= __SHIFTIN(sdly, AWIN_SD_CLK_PHASE_CTR);
 	clk |= AWIN_PLL_CFG_ENABLE;
 	bus_space_write_4(sc->sc_bst, sc->sc_clk_bsh, 0, clk);
+	delay(2);
 
 	return 0;
 }



CVS commit: src/sys/arch/arm/allwinner

2015-11-09 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Nov  9 10:10:39 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
Fix typo, pointed out by jmcneill@ (thanks !)


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.82 src/sys/arch/arm/allwinner/awin_reg.h:1.83
--- src/sys/arch/arm/allwinner/awin_reg.h:1.82	Tue Nov  3 18:38:03 2015
+++ src/sys/arch/arm/allwinner/awin_reg.h	Mon Nov  9 10:10:39 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.82 2015/11/03 18:38:03 bouyer Exp $ */
+/* $NetBSD: awin_reg.h,v 1.83 2015/11/09 10:10:39 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -1702,7 +1702,7 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_DEBE_MODCTL_ITLMOD_EN	__BIT(28)
 #define AWIN_DEBE_MODCTL_OUT_SEL	__BITS(22,20)
 #define AWIN_DEBE_MODCTL_OUT_SEL_LCD0	0
-#define AWIN_DEBE_MODCTL_OUT_SEL_LCD1	0
+#define AWIN_DEBE_MODCTL_OUT_SEL_LCD1	1
 #define AWIN_DEBE_MODCTL_OUT_SEL_FE0	6
 #define AWIN_DEBE_MODCTL_OUT_SEL_FE1	7
 #define AWIN_DEBE_MODCTL_OSCA_EN	__BIT(17)



CVS commit: src/sys/arch/arm/allwinner

2015-11-03 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Nov  3 19:28:28 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_tcon.c

Log Message:
remove unused variable


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/allwinner/awin_tcon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_tcon.c
diff -u src/sys/arch/arm/allwinner/awin_tcon.c:1.7 src/sys/arch/arm/allwinner/awin_tcon.c:1.8
--- src/sys/arch/arm/allwinner/awin_tcon.c:1.7	Tue Nov  3 18:38:03 2015
+++ src/sys/arch/arm/allwinner/awin_tcon.c	Tue Nov  3 19:28:28 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_tcon.c,v 1.7 2015/11/03 18:38:03 bouyer Exp $ */
+/* $NetBSD: awin_tcon.c,v 1.8 2015/11/03 19:28:28 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #include "opt_allwinner.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.7 2015/11/03 18:38:03 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.8 2015/11/03 19:28:28 bouyer Exp $");
 
 #include 
 #include 
@@ -112,7 +112,6 @@ awin_tcon_attach(device_t parent, device
 	struct awin_tcon_softc *sc = device_private(self);
 	struct awinio_attach_args * const aio = aux;
 	const struct awin_locators * const loc = >aio_loc;
-	prop_dictionary_t cfg = device_properties(self);
 
 	sc->sc_dev = self;
 	sc->sc_bst = aio->aio_core_bst;



CVS commit: src/sys/arch/arm/allwinner

2015-10-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Oct 17 15:00:45 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_board.c

Log Message:
Factor out reading/writing CCM registers in macros


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/arm/allwinner/awin_board.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_board.c
diff -u src/sys/arch/arm/allwinner/awin_board.c:1.36 src/sys/arch/arm/allwinner/awin_board.c:1.37
--- src/sys/arch/arm/allwinner/awin_board.c:1.36	Sat Oct 17 14:46:01 2015
+++ src/sys/arch/arm/allwinner/awin_board.c	Sat Oct 17 15:00:45 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_board.c,v 1.36 2015/10/17 14:46:01 bouyer Exp $	*/
+/*	$NetBSD: awin_board.c,v 1.37 2015/10/17 15:00:45 bouyer Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.36 2015/10/17 14:46:01 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.37 2015/10/17 15:00:45 bouyer Exp $");
 
 #include 
 #include 
@@ -86,6 +86,11 @@ struct arm32_bus_dma_tag awin_coherent_d
 	_BUS_DMATAG_FUNCS,
 };
 
+#define CCM_READ4(reg) bus_space_read_4(_generic_bs_tag, \
+awin_core_bsh, AWIN_CCM_OFFSET + (reg))
+#define CCM_WRITE4(reg, v) bus_space_write_4(_generic_bs_tag, \
+awin_core_bsh, AWIN_CCM_OFFSET + (reg), (v))
+
 #ifdef AWIN_CONSOLE_EARLY
 #include 
 #include 
@@ -128,9 +133,9 @@ static void
 awin_cpu_clk(void)
 {
 	struct cpu_info * const ci = curcpu();
-	bus_space_tag_t bst = _generic_bs_tag;
 
 #if defined(ALLWINNER_A80)
+	bus_space_tag_t bst = _generic_bs_tag;
 	const uint32_t c0cpux = bus_space_read_4(bst, awin_core_bsh,
 	AWIN_A80_CCU_OFFSET + AWIN_A80_CCU_PLL_C0CPUX_CTRL_REG);
 	const u_int p = (c0cpux & AWIN_A80_CCU_PLL_CxCPUX_OUT_EXT_DIVP) ? 4 : 1;
@@ -141,8 +146,8 @@ awin_cpu_clk(void)
 	u_int reg = awin_chip_id() == AWIN_CHIP_ID_A31 ?
   AWIN_A31_CPU_AXI_CFG_REG :
   AWIN_CPU_AHB_APB0_CFG_REG;
-	const uint32_t cpu0_cfg = bus_space_read_4(bst, awin_core_bsh,
-	AWIN_CCM_OFFSET + reg);
+	const uint32_t cpu0_cfg = CCM_READ4(reg);
+
 	switch (__SHIFTOUT(cpu0_cfg, AWIN_CPU_CLK_SRC_SEL)) {
 	case AWIN_CPU_CLK_SRC_SEL_LOSC:
 		ci->ci_data.cpu_cc_freq = 32768;
@@ -151,8 +156,7 @@ awin_cpu_clk(void)
 		ci->ci_data.cpu_cc_freq = AWIN_REF_FREQ;
 		break;
 	case AWIN_CPU_CLK_SRC_SEL_PLL1: {
-		const uint32_t pll1_cfg = bus_space_read_4(bst,
-		awin_core_bsh, AWIN_CCM_OFFSET + AWIN_PLL1_CFG_REG);
+		const uint32_t pll1_cfg = CCM_READ4(AWIN_PLL1_CFG_REG);
 		u_int p, n, k, m;
 		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 			p = 0;
@@ -350,16 +354,12 @@ awin_chip_name(void)
 void
 awin_pll6_enable(void)
 {
-	bus_space_tag_t bst = _generic_bs_tag;
-	bus_space_handle_t bsh = awin_core_bsh;
-
 	KASSERT(awin_chip_id() != AWIN_CHIP_ID_A80);
 
 	/*
 	 * SATA needs PLL6 to be a 100MHz clock.
 	 */
-	const uint32_t ocfg = bus_space_read_4(bst, bsh,
-	AWIN_CCM_OFFSET + AWIN_PLL6_CFG_REG);
+	const uint32_t ocfg = CCM_READ4(AWIN_PLL6_CFG_REG);
 
 	/*
 	 * Output freq is 24MHz * n * k / m / 6.
@@ -380,13 +380,11 @@ awin_pll6_enable(void)
 	}
 	ncfg |= AWIN_PLL_CFG_ENABLE;
 	if (ncfg != ocfg) {
-		bus_space_write_4(bst, bsh,
-		AWIN_CCM_OFFSET + AWIN_PLL6_CFG_REG, ncfg);
+		CCM_WRITE4(AWIN_PLL6_CFG_REG, ncfg);
 
 		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 			do {
-ncfg = bus_space_read_4(bst, bsh,
-AWIN_CCM_OFFSET + AWIN_PLL6_CFG_REG);
+ncfg = CCM_READ4(AWIN_PLL6_CFG_REG);
 			} while ((ncfg & AWIN_A31_PLL6_CFG_LOCK) == 0);
 		}
 	}
@@ -402,14 +400,10 @@ awin_pll6_enable(void)
 void
 awin_pll2_enable(void)
 {
-	bus_space_tag_t bst = _generic_bs_tag;
-	bus_space_handle_t bsh = awin_core_bsh;
-
 	/*
   	 * AC (at 48kHz) needs PLL2 to be 24576000 Hz
   	 */
-	const uint32_t ocfg = bus_space_read_4(bst, bsh,
-	AWIN_CCM_OFFSET + AWIN_PLL2_CFG_REG);
+	const uint32_t ocfg = CCM_READ4(AWIN_PLL2_CFG_REG);
 
 	uint32_t ncfg = ocfg;
 
@@ -432,13 +426,11 @@ awin_pll2_enable(void)
 	}
 
 	if (ncfg != ocfg) {
-		bus_space_write_4(bst, bsh,
-		AWIN_CCM_OFFSET + AWIN_PLL2_CFG_REG, ncfg);
+		CCM_WRITE4(AWIN_PLL2_CFG_REG, ncfg);
 
 		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 			do {
-ncfg = bus_space_read_4(bst, bsh,
-AWIN_CCM_OFFSET + AWIN_PLL2_CFG_REG);
+ncfg = CCM_READ4(AWIN_PLL2_CFG_REG);
 			} while ((ncfg & AWIN_A31_PLL2_CFG_LOCK) == 0);
 		}
 	}
@@ -447,14 +439,10 @@ awin_pll2_enable(void)
 void
 awin_pll3_enable(void)
 {
-	bus_space_tag_t bst = _generic_bs_tag;
-	bus_space_handle_t bsh = awin_core_bsh;
-
 	/*
 	 * HDMI needs PLL3 to be 2970 Hz
 	 */
-	const uint32_t ocfg = bus_space_read_4(bst, bsh,
-	AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG);
+	const uint32_t ocfg = CCM_READ4(AWIN_PLL3_CFG_REG);
 
 	uint32_t ncfg = ocfg;
 
@@ -470,13 +458,11 @@ awin_pll3_enable(void)
 	}
 
 	

CVS commit: src/sys/arch/arm/allwinner

2015-10-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Oct 17 14:46:01 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_board.c

Log Message:
awin_cpu_clk(): Fix reading of CPU_CLK_SRC_CEL bits: doing a shiftin followed
by a shiftout ends up reading bits(0,1) instead of AWIN_CPU_CLK_SRC_SEL.
It happens that these bits (AWIN_AXI_CLK_DIV_RATIO) are 2 (divide by 3) at boot
(at last on cubieboard2 and olimex lime2), which matches
AWIN_CPU_CLK_SRC_SEL_PLL1, so this has gone  unnoticed.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/arm/allwinner/awin_board.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_board.c
diff -u src/sys/arch/arm/allwinner/awin_board.c:1.35 src/sys/arch/arm/allwinner/awin_board.c:1.36
--- src/sys/arch/arm/allwinner/awin_board.c:1.35	Mon Apr 20 01:33:22 2015
+++ src/sys/arch/arm/allwinner/awin_board.c	Sat Oct 17 14:46:01 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_board.c,v 1.35 2015/04/20 01:33:22 matt Exp $	*/
+/*	$NetBSD: awin_board.c,v 1.36 2015/10/17 14:46:01 bouyer Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.35 2015/04/20 01:33:22 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.36 2015/10/17 14:46:01 bouyer Exp $");
 
 #include 
 #include 
@@ -143,8 +143,7 @@ awin_cpu_clk(void)
   AWIN_CPU_AHB_APB0_CFG_REG;
 	const uint32_t cpu0_cfg = bus_space_read_4(bst, awin_core_bsh,
 	AWIN_CCM_OFFSET + reg);
-	const u_int cpu_clk_sel = __SHIFTIN(cpu0_cfg, AWIN_CPU_CLK_SRC_SEL);
-	switch (__SHIFTOUT(cpu_clk_sel, AWIN_CPU_CLK_SRC_SEL)) {
+	switch (__SHIFTOUT(cpu0_cfg, AWIN_CPU_CLK_SRC_SEL)) {
 	case AWIN_CPU_CLK_SRC_SEL_LOSC:
 		ci->ci_data.cpu_cc_freq = 32768;
 		break;



CVS commit: src/sys/arch/arm/allwinner

2015-10-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Oct 17 15:02:55 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_board.c

Log Message:
The A20 manual says that the pll6 output is (AWIN_REF_FREQ * n * k) / 2,
not (AWIN_REF_FREQ * n * k) / m (m is only used for the SATA clock).
On the boards I tested, m happens to be 2 so the correct value was returned
anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/arm/allwinner/awin_board.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_board.c
diff -u src/sys/arch/arm/allwinner/awin_board.c:1.37 src/sys/arch/arm/allwinner/awin_board.c:1.38
--- src/sys/arch/arm/allwinner/awin_board.c:1.37	Sat Oct 17 15:00:45 2015
+++ src/sys/arch/arm/allwinner/awin_board.c	Sat Oct 17 15:02:55 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_board.c,v 1.37 2015/10/17 15:00:45 bouyer Exp $	*/
+/*	$NetBSD: awin_board.c,v 1.38 2015/10/17 15:02:55 bouyer Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.37 2015/10/17 15:00:45 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.38 2015/10/17 15:02:55 bouyer Exp $");
 
 #include 
 #include 
@@ -570,7 +570,7 @@ awin_pll6_get_rate(void)
 	} else {
 		n = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_N);
 		k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K) + 1;
-		m = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_M) + 1;
+		m = 2;
 	}
 
 	return (AWIN_REF_FREQ * n * k) / m;



CVS commit: src/sys/arch/arm/allwinner

2015-10-16 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Oct 16 14:22:25 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_mmc.c

Log Message:
Avoid a divide by 0 when unplugging a sd card.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/allwinner/awin_mmc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_mmc.c
diff -u src/sys/arch/arm/allwinner/awin_mmc.c:1.21 src/sys/arch/arm/allwinner/awin_mmc.c:1.22
--- src/sys/arch/arm/allwinner/awin_mmc.c:1.21	Sat Aug  8 17:21:19 2015
+++ src/sys/arch/arm/allwinner/awin_mmc.c	Fri Oct 16 14:22:25 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_mmc.c,v 1.21 2015/08/08 17:21:19 jmcneill Exp $ */
+/* $NetBSD: awin_mmc.c,v 1.22 2015/10/16 14:22:25 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -29,7 +29,7 @@
 #include "locators.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_mmc.c,v 1.21 2015/08/08 17:21:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_mmc.c,v 1.22 2015/10/16 14:22:25 bouyer Exp $");
 
 #include 
 #include 
@@ -346,7 +346,10 @@ awin_mmc_set_clock(struct awin_mmc_softc
 		sdly = 0;
 		clksrc = AWIN_SD_CLK_SRC_SEL_OSC24M;
 		n = 2;
-		m = ((osc24m_freq / (1 << n)) / freq) - 1;
+		if (freq > 0)
+			m = ((osc24m_freq / (1 << n)) / freq) - 1;
+		else
+			m = 15;
 	} else if (freq <= 25000) {
 		odly = 0;
 		sdly = 5;



CVS commit: src/sys/arch/arm/allwinner

2015-10-09 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Oct  9 07:23:33 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c

Log Message:
revert previous (turn off tcon when disabling video output).
I found it's better to do it in the hdmi driver, but the hdmi audio issue
needs to be fixed as well.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/allwinner/awin_debe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.15 src/sys/arch/arm/allwinner/awin_debe.c:1.16
--- src/sys/arch/arm/allwinner/awin_debe.c:1.15	Mon Oct  5 14:42:19 2015
+++ src/sys/arch/arm/allwinner/awin_debe.c	Fri Oct  9 07:23:33 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.15 2015/10/05 14:42:19 bouyer Exp $ */
+/* $NetBSD: awin_debe.c,v 1.16 2015/10/09 07:23:33 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -37,7 +37,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.15 2015/10/05 14:42:19 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.16 2015/10/09 07:23:33 bouyer Exp $");
 
 #include 
 #include 
@@ -582,7 +582,6 @@ awin_debe_ioctl(device_t self, u_long cm
 			val &= ~AWIN_DEBE_MODCTL_HWC_EN;
 		}
 		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
-		awin_tcon_enable(enable);
 		return 0;
 	case WSDISPLAYIO_GVIDEO:
 		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);



CVS commit: src/sys/arch/arm/allwinner

2015-10-05 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Oct  5 14:42:19 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c

Log Message:
When disabling video ouput also turn off the tcon. This will cause the
HDMI output to stop too, and the monitor will go to sleep.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/allwinner/awin_debe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.14 src/sys/arch/arm/allwinner/awin_debe.c:1.15
--- src/sys/arch/arm/allwinner/awin_debe.c:1.14	Sun Dec 21 18:36:05 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Mon Oct  5 14:42:19 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.14 2014/12/21 18:36:05 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.15 2015/10/05 14:42:19 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill 
@@ -37,7 +37,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.14 2014/12/21 18:36:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.15 2015/10/05 14:42:19 bouyer Exp $");
 
 #include 
 #include 
@@ -582,6 +582,7 @@ awin_debe_ioctl(device_t self, u_long cm
 			val &= ~AWIN_DEBE_MODCTL_HWC_EN;
 		}
 		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
+		awin_tcon_enable(enable);
 		return 0;
 	case WSDISPLAYIO_GVIDEO:
 		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);



CVS commit: src/sys/arch/arm/allwinner

2015-10-02 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Oct  2 14:06:02 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_gpio.c

Log Message:
Print the port name when gpio(4) attaches, makes it much easier to find
what port is connected to what gpio instance:
gpio0 at awingpio0: 18 pins
gpio0: port B
gpio1 at awingpio0: 25 pins
gpio1: port C
gpio2 at awingpio0: 28 pins
gpio2: port D
gpio3 at awingpio0: 12 pins
gpio3: port E
gpio4 at awingpio0: 12 pins
gpio4: port G
gpio5 at awingpio0: 28 pins
gpio5: port H
gpio6 at awingpio0: 22 pins
gpio6: port I


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/allwinner/awin_gpio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_gpio.c
diff -u src/sys/arch/arm/allwinner/awin_gpio.c:1.18 src/sys/arch/arm/allwinner/awin_gpio.c:1.19
--- src/sys/arch/arm/allwinner/awin_gpio.c:1.18	Mon Apr 20 01:33:22 2015
+++ src/sys/arch/arm/allwinner/awin_gpio.c	Fri Oct  2 14:06:02 2015
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.18 2015/04/20 01:33:22 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.19 2015/10/02 14:06:02 bouyer Exp $");
 
 #include 
 #include 
@@ -298,6 +298,7 @@ awin_gpio_config_pins(device_t self)
 	for (u_int i = 0; i < __arraycount(pin_groups); i++) {
 		struct awin_gpio_pin_group * const grp = _groups[i];
 		uint32_t mask = grp->grp_pin_mask & ~grp->grp_pin_inuse_mask;
+		device_t gpio;
 
 		/* 
 		 * If this group has no bits to provide, skip it.
@@ -323,7 +324,8 @@ awin_gpio_config_pins(device_t self)
 		}
 
 		gba.gba_npins = pin - gba.gba_pins;
-		config_found_ia(self, "gpiobus", , gpiobus_print);
+		gpio = config_found_ia(self, "gpiobus", , gpiobus_print);
+		aprint_normal_dev(gpio, "port %c\n", 'A' + i);
 	}
 }
 #endif /* NGPIO > 0 */



CVS commit: src/sys/arch/arm/allwinner

2015-10-02 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Oct  2 16:04:40 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_gpio.c

Log Message:
Based on suggestion from jared, redo previous using a specific print callback
to avoid the extra line. Now output looks like:
gpio0 at awingpio0 port B: 18 pins
gpio1 at awingpio0 port C: 25 pins
gpio2 at awingpio0 port D: 28 pins
gpio3 at awingpio0 port E: 12 pins
gpio4 at awingpio0 port G: 12 pins
gpio5 at awingpio0 port H: 28 pins
gpio6 at awingpio0 port I: 22 pins


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/allwinner/awin_gpio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_gpio.c
diff -u src/sys/arch/arm/allwinner/awin_gpio.c:1.19 src/sys/arch/arm/allwinner/awin_gpio.c:1.20
--- src/sys/arch/arm/allwinner/awin_gpio.c:1.19	Fri Oct  2 14:06:02 2015
+++ src/sys/arch/arm/allwinner/awin_gpio.c	Fri Oct  2 16:04:40 2015
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.19 2015/10/02 14:06:02 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.20 2015/10/02 16:04:40 bouyer Exp $");
 
 #include 
 #include 
@@ -81,6 +81,7 @@ static struct awin_gpio_pin_group {
 	bus_space_handle_t grp_bsh;
 	struct awin_gpio_pin_cfg grp_cfg;
 	struct gpio_chipset_tag grp_gc_tag;
+	const int grp_index;
 	const char grp_nc_name[6];
 } pin_groups[] = {
 	[0] = {
@@ -92,6 +93,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_write = awin_gpio_pin_write,
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
+		.grp_index = 0,
 		.grp_nc_name = "nc-pa",
 	},
 	[1] = {
@@ -103,6 +105,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_write = awin_gpio_pin_write,
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
+		.grp_index = 1,
 		.grp_nc_name = "nc-pb",
 	},
 	[2] = {
@@ -114,6 +117,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_write = awin_gpio_pin_write,
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
+		.grp_index = 2,
 		.grp_nc_name = "nc-pc",
 	},
 	[3] = {
@@ -125,6 +129,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_write = awin_gpio_pin_write,
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
+		.grp_index = 3,
 		.grp_nc_name = "nc-pd",
 	},
 	[4] = {
@@ -136,6 +141,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_write = awin_gpio_pin_write,
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
+		.grp_index = 4,
 		.grp_nc_name = "nc-pe",
 	},
 	[5] = {
@@ -147,6 +153,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_write = awin_gpio_pin_write,
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
+		.grp_index = 5,
 		.grp_nc_name = "nc-pf",
 	},
 	[6] = {
@@ -158,6 +165,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_write = awin_gpio_pin_write,
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
+		.grp_index = 6,
 		.grp_nc_name = "nc-pg",
 	},
 	[7] = {
@@ -169,6 +177,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_write = awin_gpio_pin_write,
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
+		.grp_index = 7,
 		.grp_nc_name = "nc-ph",
 	},
 	[8] = {
@@ -180,6 +189,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_write = awin_gpio_pin_write,
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
+		.grp_index = 8,
 		.grp_nc_name = "nc-pi",
 	},
 	[9] = {
@@ -191,6 +201,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
 		.grp_pin_mask = 0,
+		.grp_index = 9,
 		.grp_nc_name = "nc-pj",
 	},
 	[10] = {
@@ -202,6 +213,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
 		.grp_pin_mask = 0,
+		.grp_index = 10,
 		.grp_nc_name = "nc-pk",
 	},
 	[11] = {
@@ -213,6 +225,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
 		.grp_pin_mask = 0,
+		.grp_index = 11,
 		.grp_nc_name = "nc-pl",
 	},
 	[12] = {
@@ -224,6 +237,7 @@ static struct awin_gpio_pin_group {
 			.gp_pin_ctl = awin_gpio_pin_ctl,
 		},
 		.grp_pin_mask = 0,
+		.grp_index = 12,
 		.grp_nc_name = "nc-pm",
 	},
 	[13] = {
@@ -268,6 +282,20 @@ awin_gpio_match(device_t parent, cfdata_
 }
 
 #if NGPIO > 0
+static int
+awin_gpio_cfprint(void *priv, const char *pnp)
+{
+	struct gpiobus_attach_args *gba = priv;
+	struct awin_gpio_pin_group *grp = gba->gba_gc->gp_cookie;
+
+	if (pnp)
+		aprint_normal("gpiobus at %s", pnp);
+
+	aprint_normal(" port %c", 'A' + grp->grp_index);
+
+	return UNCONF;
+}
+
 static void
 awin_gpio_config_pins(device_t self)
 {
@@ -298,7 +326,6 @@ awin_gpio_config_pins(device_t self)
 	for (u_int i = 0; i < __arraycount(pin_groups); i++) {
 		struct awin_gpio_pin_group * const grp = _groups[i];
 		uint32_t mask = grp->grp_pin_mask & ~grp->grp_pin_inuse_mask;
-		device_t gpio;
 
 		/* 
 		 * If this group has no bits to provide, skip it.
@@ -324,8 +351,7 @@ awin_gpio_config_pins(device_t self)
 		}
 
 		gba.gba_npins = pin - gba.gba_pins;
-		gpio = config_found_ia(self, "gpiobus", , gpiobus_print);
-		aprint_normal_dev(gpio, 

CVS commit: src/sys/arch/arm/allwinner

2015-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  8 17:21:19 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_mmc.c

Log Message:
don't need a full reset to recover from errors, only DMA and FIFO resets


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/allwinner/awin_mmc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_mmc.c
diff -u src/sys/arch/arm/allwinner/awin_mmc.c:1.20 src/sys/arch/arm/allwinner/awin_mmc.c:1.21
--- src/sys/arch/arm/allwinner/awin_mmc.c:1.20	Sun Dec  7 20:10:59 2014
+++ src/sys/arch/arm/allwinner/awin_mmc.c	Sat Aug  8 17:21:19 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_mmc.c,v 1.20 2014/12/07 20:10:59 jmcneill Exp $ */
+/* $NetBSD: awin_mmc.c,v 1.21 2015/08/08 17:21:19 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.20 2014/12/07 20:10:59 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.21 2015/08/08 17:21:19 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -976,7 +976,14 @@ done:
 #ifdef AWIN_MMC_DEBUG
 		aprint_error_dev(sc-sc_dev, i/o error %d\n, cmd-c_error);
 #endif
-		awin_mmc_host_reset(sc);
+		MMC_WRITE(sc, AWIN_MMC_GCTRL,
+		MMC_READ(sc, AWIN_MMC_GCTRL) |
+		  AWIN_MMC_GCTRL_DMARESET | AWIN_MMC_GCTRL_FIFORESET);
+		for (int retry = 0; retry  1000; retry++) {
+			if (!(MMC_READ(sc, AWIN_MMC_GCTRL)  AWIN_MMC_GCTRL_RESET))
+break;
+			delay(10);
+		}
 		awin_mmc_update_clock(sc);
 	}
 



CVS commit: src/sys/arch/arm/allwinner

2015-08-08 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Aug  8 23:30:16 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_com.c awin_reg.h

Log Message:
fix attachment of non-console UARTs and ensure the UART clock is running


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/allwinner/awin_com.c
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_com.c
diff -u src/sys/arch/arm/allwinner/awin_com.c:1.9 src/sys/arch/arm/allwinner/awin_com.c:1.10
--- src/sys/arch/arm/allwinner/awin_com.c:1.9	Sun Dec  7 12:44:24 2014
+++ src/sys/arch/arm/allwinner/awin_com.c	Sat Aug  8 23:30:16 2015
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_com.c,v 1.9 2014/12/07 12:44:24 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_com.c,v 1.10 2015/08/08 23:30:16 tnn Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -130,7 +130,28 @@ awin_com_match(device_t parent, cfdata_t
 	awin_gpio_pinset_acquire(pinset);
 
 	bus_space_subregion(iot, aio-aio_core_bsh,
-	loc-loc_offset, loc-loc_size, bsh);
+	loc-loc_offset / 4, loc-loc_size, bsh);
+
+	/*
+	 * Clock gating, soft reset
+	 */
+	if (awin_chip_id() == AWIN_CHIP_ID_A80) {
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_REG,
+		AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_UART0  loc-loc_port, 0);
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_REG,
+		AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_UART0  loc-loc_port, 0);
+	} else {
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		   AWIN_APB1_GATING_REG,
+		   AWIN_APB_GATING1_UART0  loc-loc_port, 0);
+		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+			awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+			AWIN_A31_APB2_RESET_REG,
+			AWIN_A31_APB2_RESET_UART0_RST  loc-loc_port, 0);
+		}
+	}
 
 	const int rv = comprobe1(iot, bsh);
 

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.78 src/sys/arch/arm/allwinner/awin_reg.h:1.79
--- src/sys/arch/arm/allwinner/awin_reg.h:1.78	Wed Jun  3 12:22:41 2015
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sat Aug  8 23:30:16 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.78 2015/06/03 12:22:41 skrll Exp $ */
+/* $NetBSD: awin_reg.h,v 1.79 2015/08/08 23:30:16 tnn Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -2416,6 +2416,13 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_A31_APB1_RESET_DIGITAL_MIC_RST	__BIT(4)
 #define AWIN_A31_APB1_RESET_CODEC_RST		__BIT(0)
 
+#define AWIN_A31_APB2_RESET_UART5_RST		__BIT(21)
+#define AWIN_A31_APB2_RESET_UART4_RST		__BIT(20)
+#define AWIN_A31_APB2_RESET_UART3_RST		__BIT(19)
+#define AWIN_A31_APB2_RESET_UART2_RST		__BIT(18)
+#define AWIN_A31_APB2_RESET_UART1_RST		__BIT(17)
+#define AWIN_A31_APB2_RESET_UART0_RST		__BIT(16)
+
 #define AWIN_A31_APB2_RESET_TWI3_RST		__BIT(3)
 #define AWIN_A31_APB2_RESET_TWI2_RST		__BIT(2)
 #define AWIN_A31_APB2_RESET_TWI1_RST		__BIT(1)
@@ -2786,6 +2793,13 @@ struct awin_a31_dma_desc {
 #define AWIN_A80_CCU_SCLK_BUS_CLK_GATING1_GMAC	__BIT(17)
 #define AWIN_A80_CCU_SCLK_BUS_CLK_GATING1_USB_HOST __BIT(1)
 
+#define AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_UART5	__BIT(21)
+#define AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_UART4	__BIT(20)
+#define AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_UART3	__BIT(19)
+#define AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_UART2	__BIT(18)
+#define AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_UART1	__BIT(17)
+#define AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_UART0	__BIT(16)
+
 #define AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_TWI4	__BIT(4)
 #define AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_TWI2	__BIT(3)
 #define AWIN_A80_CCU_SCLK_BUS_CLK_GATING4_TWI3	__BIT(2)
@@ -2798,6 +2812,13 @@ struct awin_a31_dma_desc {
 #define AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_GMAC	__BIT(17)
 #define AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_USB_DRD	__BIT(1)
 
+#define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_UART5	__BIT(21)
+#define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_UART4	__BIT(20)
+#define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_UART3	__BIT(19)
+#define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_UART2	__BIT(18)
+#define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_UART1	__BIT(17)
+#define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_UART0	__BIT(16)
+
 #define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_TWI4	__BIT(4)
 #define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_TWI3	__BIT(3)
 #define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_TWI2	__BIT(2)



CVS commit: src/sys/arch/arm/allwinner

2015-07-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jul 25 15:19:54 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmi.c files.awin

Log Message:
For DDC, we don't have a real I2C bus, but instead read an EDID block at
a time. Read the blocks ourselves instead of pulling in ddc_read_edid.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/allwinner/awin_hdmi.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.15 src/sys/arch/arm/allwinner/awin_hdmi.c:1.16
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.15	Mon Nov 17 10:00:14 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Sat Jul 25 15:19:54 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.15 2014/11/17 10:00:14 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.16 2015/07/25 15:19:54 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -32,7 +32,7 @@
 #define AWIN_HDMI_PLL	3	/* PLL7 or PLL3 */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.15 2014/11/17 10:00:14 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.16 2015/07/25 15:19:54 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -99,6 +99,8 @@ static int	awin_hdmi_i2c_reset(struct aw
 
 static void	awin_hdmi_enable(struct awin_hdmi_softc *);
 static void	awin_hdmi_read_edid(struct awin_hdmi_softc *);
+static int	awin_hdmi_read_edid_block(struct awin_hdmi_softc *, uint8_t *,
+	  uint8_t);
 static u_int	awin_hdmi_get_display_mode(struct awin_hdmi_softc *,
 	   const struct edid_info *);
 static void	awin_hdmi_video_enable(struct awin_hdmi_softc *, bool);
@@ -486,6 +488,29 @@ awin_hdmi_enable(struct awin_hdmi_softc 
 	delay(1000);
 }
 
+static int
+awin_hdmi_read_edid_block(struct awin_hdmi_softc *sc, uint8_t *data,
+uint8_t block)
+{
+	i2c_tag_t tag = sc-sc_ic;
+	uint8_t wbuf[2];
+	int error;
+
+	if ((error = iic_acquire_bus(tag, I2C_F_POLL)) != 0)
+		return error;
+
+	wbuf[0] = block;	/* start address */
+
+	if ((error = iic_exec(tag, I2C_OP_READ_WITH_STOP, DDC_ADDR, wbuf, 1,
+	data, 128, I2C_F_POLL)) != 0) {
+		iic_release_bus(tag, I2C_F_POLL);
+		return error;
+	}
+	iic_release_bus(tag, I2C_F_POLL);
+
+	return 0;
+}
+
 static void
 awin_hdmi_read_edid(struct awin_hdmi_softc *sc)
 {
@@ -499,7 +524,7 @@ awin_hdmi_read_edid(struct awin_hdmi_sof
 	memset(ei, 0, sizeof(ei));
 
 	while (--retry  0) {
-		if (!ddc_read_edid_block(sc-sc_ic, edid, sizeof(edid), 0))
+		if (!awin_hdmi_read_edid_block(sc, edid, 0))
 			break;
 	}
 	if (retry == 0) {
@@ -566,7 +591,7 @@ awin_hdmi_get_display_mode(struct awin_h
 	 * found in that, assume HDMI mode.
 	 */
 	for (n = 1; n = MIN(ei-edid_ext_block_count, 4); n++) {
-		if (ddc_read_edid_block(sc-sc_ic, edid, sizeof(edid), n)) {
+		if (awin_hdmi_read_edid_block(sc, edid, n)) {
 #ifdef AWIN_HDMI_DEBUG
 			device_printf(sc-sc_dev,
 			Failed to read EDID block %d\n, n);

Index: src/sys/arch/arm/allwinner/files.awin
diff -u src/sys/arch/arm/allwinner/files.awin:1.31 src/sys/arch/arm/allwinner/files.awin:1.32
--- src/sys/arch/arm/allwinner/files.awin:1.31	Mon Apr 20 01:33:22 2015
+++ src/sys/arch/arm/allwinner/files.awin	Sat Jul 25 15:19:54 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: files.awin,v 1.31 2015/04/20 01:33:22 matt Exp $
+#	$NetBSD: files.awin,v 1.32 2015/07/25 15:19:54 jmcneill Exp $
 #
 # Configuration info for Allwinner ARM Peripherals
 #
@@ -140,7 +140,7 @@ attach	awinac at awinio with awin_ac
 file	arch/arm/allwinner/awin_ac.c		awin_ac
 
 # A20/A31 HDMI
-device	awinhdmi: edid, ddc_read_edid, videomode
+device	awinhdmi: edid, videomode
 attach	awinhdmi at awinio with awin_hdmi
 file	arch/arm/allwinner/awin_hdmi.c		awin_hdmi
 



CVS commit: src/sys/arch/arm/allwinner

2015-06-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun 14 08:32:02 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_wdt.c

Log Message:
Add disarm support


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/allwinner/awin_wdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_wdt.c
diff -u src/sys/arch/arm/allwinner/awin_wdt.c:1.8 src/sys/arch/arm/allwinner/awin_wdt.c:1.9
--- src/sys/arch/arm/allwinner/awin_wdt.c:1.8	Tue Jun  9 12:46:37 2015
+++ src/sys/arch/arm/allwinner/awin_wdt.c	Sun Jun 14 08:32:02 2015
@@ -33,7 +33,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_wdt.c,v 1.8 2015/06/09 12:46:37 martin Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_wdt.c,v 1.9 2015/06/14 08:32:02 martin Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -145,10 +145,12 @@ awin_wdt_setmode(struct sysmon_wdog *smw
 	}
 
 	if ((smw-smw_mode  WDOG_MODE_MASK) == WDOG_MODE_DISARMED) {
-		/*
-		 * We can't disarm the watchdog.
-		 */
-		return sc-sc_wdog_armed ? EBUSY : 0;
+		if (sc-sc_wdog_armed)
+			/* can not disarm pre-armed kernel mode wdog */
+			return EBUSY;
+
+		bus_space_write_4(sc-sc_bst, sc-sc_bsh, sc-sc_mode_reg, 0);
+		return 0;
 	}
 
 	if (sc-sc_wdog_armed  smw-smw_period == sc-sc_wdog_period) {



CVS commit: src/sys/arch/arm/allwinner

2015-06-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jun  9 12:46:38 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_wdt.c

Log Message:
Fix period handling


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/allwinner/awin_wdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_wdt.c
diff -u src/sys/arch/arm/allwinner/awin_wdt.c:1.7 src/sys/arch/arm/allwinner/awin_wdt.c:1.8
--- src/sys/arch/arm/allwinner/awin_wdt.c:1.7	Mon Apr 20 01:33:22 2015
+++ src/sys/arch/arm/allwinner/awin_wdt.c	Tue Jun  9 12:46:37 2015
@@ -33,7 +33,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_wdt.c,v 1.7 2015/04/20 01:33:22 matt Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_wdt.c,v 1.8 2015/06/09 12:46:37 martin Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -164,12 +164,14 @@ awin_wdt_setmode(struct sysmon_wdog *smw
 		awin_wdt_tickle(smw);
 		return 0;
 	}
-	if (smw-smw_period  mapsize) {
-		return EINVAL;
-	}
 	if (smw-smw_period == WDOG_PERIOD_DEFAULT) {
 		smw-smw_period = AWIN_WDT_PERIOD_DEFAULT;
 		sc-sc_wdog_period = AWIN_WDT_PERIOD_DEFAULT;
+	} else {
+		if (smw-smw_period  mapsize) {
+			return EINVAL;
+		}
+		sc-sc_wdog_period = smw-smw_period;
 	}
 	sc-sc_wdog_mode = AWIN_WDOG_MODE_EN | map[sc-sc_wdog_period];
 	if (awin_chip_id() == AWIN_CHIP_ID_A20 ||



CVS commit: src/sys/arch/arm/allwinner

2015-06-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jun  3 11:38:33 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
AWIN_SDRAM_PBASE is actually 0x2000


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.76 src/sys/arch/arm/allwinner/awin_reg.h:1.77
--- src/sys/arch/arm/allwinner/awin_reg.h:1.76	Mon Dec 22 00:07:24 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Wed Jun  3 11:38:33 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.76 2014/12/22 00:07:24 jmcneill Exp $ */
+/* $NetBSD: awin_reg.h,v 1.77 2015/06/03 11:38:33 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -164,7 +164,7 @@
 #define AWIN_DE_BE0_OFFSET		0x0026
 #define AWIN_MP_OFFSET			0x0028
 #define AWIN_AVG_OFFSET			0x002A
-#define AWIN_SDRAM_PBASE		0x4000
+#define AWIN_SDRAM_PBASE		0x2000
 
 /* A10/A20 SRAM Controller */
 #define AWIN_SRAM_CTL0_REG		0x



CVS commit: src/sys/arch/arm/allwinner

2015-06-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jun  3 12:22:41 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
Oops fix PBASE for non-A80


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.77 src/sys/arch/arm/allwinner/awin_reg.h:1.78
--- src/sys/arch/arm/allwinner/awin_reg.h:1.77	Wed Jun  3 11:38:33 2015
+++ src/sys/arch/arm/allwinner/awin_reg.h	Wed Jun  3 12:22:41 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.77 2015/06/03 11:38:33 skrll Exp $ */
+/* $NetBSD: awin_reg.h,v 1.78 2015/06/03 12:22:41 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -164,7 +164,11 @@
 #define AWIN_DE_BE0_OFFSET		0x0026
 #define AWIN_MP_OFFSET			0x0028
 #define AWIN_AVG_OFFSET			0x002A
+#if defined(ALLWINNER_A80)
 #define AWIN_SDRAM_PBASE		0x2000
+#else
+#define AWIN_SDRAM_PBASE		0x4000
+#endif
 
 /* A10/A20 SRAM Controller */
 #define AWIN_SRAM_CTL0_REG		0x



CVS commit: src/sys/arch/arm/allwinner

2015-04-19 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Apr 19 21:25:19 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: files.awin

Log Message:
Let the ALLWINNER_Axx define the CPU they use


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/files.awin
diff -u src/sys/arch/arm/allwinner/files.awin:1.29 src/sys/arch/arm/allwinner/files.awin:1.30
--- src/sys/arch/arm/allwinner/files.awin:1.29	Sun Dec 21 17:40:59 2014
+++ src/sys/arch/arm/allwinner/files.awin	Sun Apr 19 21:25:19 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: files.awin,v 1.29 2014/12/21 17:40:59 jmcneill Exp $
+#	$NetBSD: files.awin,v 1.30 2015/04/19 21:25:19 matt Exp $
 #
 # Configuration info for Allwinner ARM Peripherals
 #
@@ -23,10 +23,10 @@ defparam opt_allwinner.h			MEMSIZE
 defparam opt_allwinner.h			AWIN_WDT_DEFAULT_PERIOD
 defflag opt_allwinner.hAWIN_CONSOLE_EARLY
 defflag opt_allwinner.hAWINETH_COUNTERS
-defflag opt_allwinner.hALLWINNER_A10
-defflag opt_allwinner.hALLWINNER_A20
-defflag opt_allwinner.hALLWINNER_A31
-defflag opt_allwinner.hALLWINNER_A80
+defflag opt_allwinner.hALLWINNER_A10: CPU_CORTEXA8
+defflag opt_allwinner.hALLWINNER_A20: CPU_CORTEXA7
+defflag opt_allwinner.hALLWINNER_A31: CPU_CORTEXA7
+defflag opt_allwinner.hALLWINNER_A80: CPU_CORTEXA7
 defflag opt_allwinner.hAWIN_GPIO_IGNORE_FW
 defflag opt_allwinner.hAWIN_HDMI_DEBUG
 defflag opt_allwinner.hAWIN_TCON_DEBUG



CVS commit: src/sys/arch/arm/allwinner

2015-04-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr  1 07:44:18 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_cnt.c

Log Message:
Change tc_quality so that gtmr can be used for MULTIPROCESSOR now that
gtmr has been fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/allwinner/awin_cnt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_cnt.c
diff -u src/sys/arch/arm/allwinner/awin_cnt.c:1.2 src/sys/arch/arm/allwinner/awin_cnt.c:1.3
--- src/sys/arch/arm/allwinner/awin_cnt.c:1.2	Mon Nov 17 08:48:59 2014
+++ src/sys/arch/arm/allwinner/awin_cnt.c	Wed Apr  1 07:44:18 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_cnt.c,v 1.2 2014/11/17 08:48:59 skrll Exp $ */
+/* $NetBSD: awin_cnt.c,v 1.3 2015/04/01 07:44:18 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_cnt.c,v 1.2 2014/11/17 08:48:59 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_cnt.c,v 1.3 2015/04/01 07:44:18 skrll Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -102,11 +102,7 @@ awin_cnt_attach(device_t parent, device_
 	sc-sc_tc.tc_frequency = AWIN_REF_FREQ;
 	sc-sc_tc.tc_name = CNT64;
 	sc-sc_tc.tc_priv = sc;
-#ifdef MULTIPROCESSOR
-	sc-sc_tc.tc_quality = 900;
-#else
 	sc-sc_tc.tc_quality = 200;
-#endif
 
 	tc_init(sc-sc_tc);
 }



CVS commit: src/sys/arch/arm/allwinner

2015-03-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Mar 15 13:15:26 UTC 2015

Modified Files:
src/sys/arch/arm/allwinner: awin_eth.c awin_gige.c awin_gpio.c
awin_usb.c

Log Message:
sprinkle __diagused to fix no options DIAGNOSTIC build


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/allwinner/awin_eth.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/allwinner/awin_gige.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/allwinner/awin_gpio.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/allwinner/awin_usb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_eth.c
diff -u src/sys/arch/arm/allwinner/awin_eth.c:1.7 src/sys/arch/arm/allwinner/awin_eth.c:1.8
--- src/sys/arch/arm/allwinner/awin_eth.c:1.7	Sat Sep  6 19:00:50 2014
+++ src/sys/arch/arm/allwinner/awin_eth.c	Sun Mar 15 13:15:26 2015
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_eth.c,v 1.7 2014/09/06 19:00:50 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_eth.c,v 1.8 2015/03/15 13:15:26 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -141,10 +141,8 @@ awin_eth_clear_set(struct awin_eth_softc
 static int
 awin_eth_match(device_t parent, cfdata_t cf, void *aux)
 {
-	struct awinio_attach_args * const aio = aux;
-#ifdef DIAGNOSTIC
-	const struct awin_locators * const loc = aio-aio_loc;
-#endif
+	struct awinio_attach_args * const aio __diagused = aux;
+	const struct awin_locators * const loc __diagused = aio-aio_loc;
 	const struct awin_gpio_pinset * const pinset =
 	awin_eth_pinsets[cf-cf_flags  1];
 

Index: src/sys/arch/arm/allwinner/awin_gige.c
diff -u src/sys/arch/arm/allwinner/awin_gige.c:1.21 src/sys/arch/arm/allwinner/awin_gige.c:1.22
--- src/sys/arch/arm/allwinner/awin_gige.c:1.21	Sun Dec  7 00:37:52 2014
+++ src/sys/arch/arm/allwinner/awin_gige.c	Sun Mar 15 13:15:26 2015
@@ -34,7 +34,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_gige.c,v 1.21 2014/12/07 00:37:52 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_gige.c,v 1.22 2015/03/15 13:15:26 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -90,13 +90,11 @@ CFATTACH_DECL_NEW(awin_gige, sizeof(stru
 static int
 awin_gige_match(device_t parent, cfdata_t cf, void *aux)
 {
-	struct awinio_attach_args * const aio = aux;
 	const struct awin_gpio_pinset *pinset =
 	awin_chip_id() == AWIN_CHIP_ID_A31 ?
 	awin_gige_gpio_pinset_a31 : awin_gige_gpio_pinset;
-#ifdef DIAGNOSTIC
-	const struct awin_locators * const loc = aio-aio_loc;
-#endif
+	struct awinio_attach_args * const aio __diagused = aux;
+	const struct awin_locators * const loc __diagused = aio-aio_loc;
 	if (cf-cf_flags  1)
 		return 0;
 

Index: src/sys/arch/arm/allwinner/awin_gpio.c
diff -u src/sys/arch/arm/allwinner/awin_gpio.c:1.16 src/sys/arch/arm/allwinner/awin_gpio.c:1.17
--- src/sys/arch/arm/allwinner/awin_gpio.c:1.16	Sun Dec  7 18:32:13 2014
+++ src/sys/arch/arm/allwinner/awin_gpio.c	Sun Mar 15 13:15:26 2015
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_gpio.c,v 1.16 2014/12/07 18:32:13 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_gpio.c,v 1.17 2015/03/15 13:15:26 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -254,8 +254,8 @@ CFATTACH_DECL_NEW(awin_gpio, sizeof(stru
 static int
 awin_gpio_match(device_t parent, cfdata_t cf, void *aux)
 {
-	struct awinio_attach_args * const aio = aux;
-	const struct awin_locators * const loc = aio-aio_loc;
+	struct awinio_attach_args * const aio __diagused = aux;
+	const struct awin_locators * const loc __diagused = aio-aio_loc;
 
 	KASSERT(!strcmp(cf-cf_name, loc-loc_name));
 	KASSERT(loc-loc_port == AWINIOCF_PORT_DEFAULT);

Index: src/sys/arch/arm/allwinner/awin_usb.c
diff -u src/sys/arch/arm/allwinner/awin_usb.c:1.19 src/sys/arch/arm/allwinner/awin_usb.c:1.20
--- src/sys/arch/arm/allwinner/awin_usb.c:1.19	Sun Dec  7 16:20:33 2014
+++ src/sys/arch/arm/allwinner/awin_usb.c	Sun Mar 15 13:15:26 2015
@@ -34,7 +34,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_usb.c,v 1.19 2014/12/07 16:20:33 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_usb.c,v 1.20 2015/03/15 13:15:26 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -403,8 +403,8 @@ static const uint32_t awinusb_usb_pcr_a8
 int
 awinusb_match(device_t parent, cfdata_t cf, void *aux)
 {
-	struct awinio_attach_args * const aio = aux;
-	const struct awin_locators * const loc = aio-aio_loc;
+	struct awinio_attach_args * const aio __diagused = aux;
+	const struct awin_locators * const loc __diagused = aio-aio_loc;
 
 	KASSERT(loc-loc_port != AWINIOCF_PORT_DEFAULT);
 	KASSERT(!strcmp(cf-cf_name, loc-loc_name));



CVS commit: src/sys/arch/arm/allwinner

2014-12-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 23 13:34:40 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_io.c

Log Message:
get rid of extra newline at startup


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/arm/allwinner/awin_io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_io.c
diff -u src/sys/arch/arm/allwinner/awin_io.c:1.41 src/sys/arch/arm/allwinner/awin_io.c:1.42
--- src/sys/arch/arm/allwinner/awin_io.c:1.41	Mon Dec 22 00:07:24 2014
+++ src/sys/arch/arm/allwinner/awin_io.c	Tue Dec 23 13:34:40 2014
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_io.c,v 1.41 2014/12/22 00:07:24 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_io.c,v 1.42 2014/12/23 13:34:40 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -243,11 +243,7 @@ awinio_attach(device_t parent, device_t 
 	}
 
 	aprint_naive(\n);
-	aprint_normal(: %s, chip_name);
-	if ((chip_id  0xff00) != 0xff00) {
-		aprint_normal( (0x%04x)\n, chip_id);
-	}
-	aprint_normal(\n);
+	aprint_normal(: %s (0x%04x)\n, chip_name, chip_id);
 
 	const struct awin_locators * const eloc =
 	awin_locators + __arraycount(awin_locators);



CVS commit: src/sys/arch/arm/allwinner

2014-12-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec 21 17:37:40 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
add some A80 daudio and display regs


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.74 src/sys/arch/arm/allwinner/awin_reg.h:1.75
--- src/sys/arch/arm/allwinner/awin_reg.h:1.74	Sat Dec 20 16:22:17 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sun Dec 21 17:37:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.74 2014/12/20 16:22:17 skrll Exp $ */
+/* $NetBSD: awin_reg.h,v 1.75 2014/12/21 17:37:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -2674,6 +2674,11 @@ struct awin_a31_dma_desc {
  * These offsets are relative to AWIN_CORE_PBASE
  */
 #define AWIN_A80_SDMMC_COMM_OFFSET	0x00013000
+#define AWIN_A80_DE_BE0_OFFSET		0x0160
+#define AWIN_A80_DE_BE1_OFFSET		0x0164
+#define AWIN_A80_DE_BE2_OFFSET		0x0168
+#define AWIN_A80_LCD0_OFFSET		0x0200
+#define AWIN_A80_HDMI_OFFSET		0x0210
 #define AWIN_A80_CCU_OFFSET		0x0440
 #define AWIN_A80_CCU_SCLK_OFFSET	0x04400400
 #define AWIN_A80_PIO_OFFSET		0x04400800
@@ -2716,6 +2721,7 @@ struct awin_a31_dma_desc {
 #define AWIN_A80_CIR_OFFSET		0x2000
 #define AWIN_A80_RPIO_OFFSET		0x2c00
 #define AWIN_A80_RSB_OFFSET		0x3400
+#define AWIN_A80_DAUDIO1_OFFSET		0x6000
 
 #define AWIN_A80_SDMMC_COMM_SDC_RESET_SW	__BIT(18)
 #define AWIN_A80_SDMMC_COMM_SDC_CLOCK_SW	__BIT(16)
@@ -2739,6 +2745,13 @@ struct awin_a31_dma_desc {
 #define AWIN_A80_CCU_PLL_CxCPUX_FACTOR_N	__BITS(15,8)
 #define AWIN_A80_CCU_PLL_CxCPUX_POSTDIV_M	__BITS(1,0)
 
+#define AWIN_A80_CCU_PLL_AUDIO_ENABLE		__BIT(31)
+#define AWIN_A80_CCU_PLL_AUDIO_SDM_ENABLE	__BIT(24)
+#define AWIN_A80_CCU_PLL_AUDIO_OUTPUT_DIV	__BIT(18)
+#define AWIN_A80_CCU_PLL_AUDIO_INPUT_DIV	__BIT(16)
+#define AWIN_A80_CCU_PLL_AUDIO_FACTOR_N		__BITS(15,8)
+#define AWIN_A80_CCU_PLL_AUDIO_POSTDIV_P	__BITS(5,0)
+
 #define AWIN_A80_CCU_PLL_PERIPH0_ENABLE		__BIT(31)
 #define AWIN_A80_CCU_PLL_PERIPH0_SDM_ENABLE	__BIT(24)
 #define AWIN_A80_CCU_PLL_PERIPH0_OUTPUT_DIV	__BIT(18)
@@ -2795,6 +2808,8 @@ struct awin_a31_dma_desc {
 #define AWIN_A80_CCU_SCLK_SDMMC_OUTPUT_CLK_PHASE_CTR __BITS(10,8)
 #define AWIN_A80_CCU_SCLK_SDMMC_CLK_DIV_RATIO_M	__BITS(3,0)
 
+#define AWIN_A80_CCU_SCLK_DAUDIO_SCLK_GATING	__BIT(31)
+
 #define AWIN_A80_USBPHY_HCI_SCR_REG		0x
 #define AWIN_A80_USBPHY_HCI_PCR_REG		0x0004
 
@@ -2822,6 +2837,8 @@ struct awin_a31_dma_desc {
 
 #define AWIN_A80_RPRCM_APB0_GATING_REG		0x0028
 #define AWIN_A80_RPRCM_CIR_CLK_REG		0x0054
+#define AWIN_A80_RPRCM_DAUDIO0_CLK_REG		0x0058
+#define AWIN_A80_RPRCM_DAUDIO1_CLK_REG		0x005c
 #define AWIN_A80_RPRCM_APB0_RST_REG		0x00b0
 
 #define AWIN_A80_RPRCM_CLUSTER0_RST_REG		0x0004
@@ -2839,7 +2856,11 @@ struct awin_a31_dma_desc {
 #define AWIN_A80_RPRCM_PRIVATE_REG		0x0164
 
 #define AWIN_A80_RPRCM_APB0_GATING_CIR		__BIT(1)
+#define AWIN_A80_RPRCM_APB0_GATING_DAUDIO1	__BIT(18)
+#define AWIN_A80_RPRCM_APB0_GATING_DAUDIO0	__BIT(17)
 #define AWIN_A80_RPRCM_APB0_RST_CIR		__BIT(1)
+#define AWIN_A80_RPRCM_APB0_RST_DAUDIO1		__BIT(18)
+#define AWIN_A80_RPRCM_APB0_RST_DAUDIO0		__BIT(17)
 
 #define AWIN_A80_RCPUCFG_CLUSTER0_RST_REG	0x0080
 #define AWIN_A80_RCPUCFG_CLUSTER1_RST_REG	0x0084
@@ -2900,6 +2921,8 @@ struct awin_a31_dma_desc {
 #define AWIN_A80_PIO_PL_CIR_PINS	0x0040 /* PL pin 6 */
 
 #define AWIN_A80_PIO_PM_PINS		16
+#define AWIN_A80_PIO_PM_DAUDIO1_FUNC	3
+#define AWIN_A80_PIO_PM_DAUDIO1_PINS	0x7cf0 /* PM pins 14-10,7-4 */
 
 #define AWIN_A80_PIO_PN_PINS		2
 



CVS commit: src/sys/arch/arm/allwinner

2014-12-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec 21 17:38:47 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_intr.h

Log Message:
add A80 R_DAUDIO irq


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/allwinner/awin_intr.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_intr.h
diff -u src/sys/arch/arm/allwinner/awin_intr.h:1.14 src/sys/arch/arm/allwinner/awin_intr.h:1.15
--- src/sys/arch/arm/allwinner/awin_intr.h:1.14	Sun Dec  7 18:32:13 2014
+++ src/sys/arch/arm/allwinner/awin_intr.h	Sun Dec 21 17:38:47 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_intr.h,v 1.14 2014/12/07 18:32:13 jmcneill Exp $ */
+/* $NetBSD: awin_intr.h,v 1.15 2014/12/21 17:38:47 jmcneill Exp $ */
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -200,6 +200,7 @@
 #define AWIN_A80_IRQ_NMI	64
 #define AWIN_A80_IRQ_R_CIR	69
 #define AWIN_A80_IRQ_R_RSB	71
+#define AWIN_A80_IRQ_R_DAUDIO	74
 #define AWIN_A80_IRQ_DMA	82
 #define AWIN_A80_IRQ_HSTIMER0	83
 #define AWIN_A80_IRQ_HSTIMER1	84



CVS commit: src/sys/arch/arm/allwinner

2014-12-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec 21 17:40:17 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_io.c

Log Message:
add A80 debe, tcon, hdmi, daudio


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/arm/allwinner/awin_io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_io.c
diff -u src/sys/arch/arm/allwinner/awin_io.c:1.39 src/sys/arch/arm/allwinner/awin_io.c:1.40
--- src/sys/arch/arm/allwinner/awin_io.c:1.39	Sun Dec  7 18:32:13 2014
+++ src/sys/arch/arm/allwinner/awin_io.c	Sun Dec 21 17:40:17 2014
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_io.c,v 1.39 2014/12/07 18:32:13 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_io.c,v 1.40 2014/12/21 17:40:17 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -118,10 +118,15 @@ static const struct awin_locators awin_l
 	{ awinmp, OFFANDSIZE(MP), NOPORT, AWIN_A31_IRQ_MP, A31 },
 	{ awindebe, AWIN_DE_BE0_OFFSET, 0x1000, 0, NOINTR, A20|A31 },
 	{ awindebe, AWIN_DE_BE1_OFFSET, 0x1000, 1, NOINTR, A20|A31 },
+	{ awindebe, AWIN_A80_DE_BE0_OFFSET, 0x1000, 0, NOINTR, A80 },
+	{ awindebe, AWIN_A80_DE_BE1_OFFSET, 0x1000, 1, NOINTR, A80 },
+	{ awindebe, AWIN_A80_DE_BE2_OFFSET, 0x1000, 2, NOINTR, A80 },
 	{ awintcon, OFFANDSIZE(LCD0), 0, NOINTR, A20|A31 },
 	{ awintcon, OFFANDSIZE(LCD1), 1, NOINTR, A20|A31 },
+	{ awintcon, OFFANDSIZE(A80_LCD0), 0, NOINTR, A80 },
 	{ awinhdmi, OFFANDSIZE(HDMI), NOPORT, AWIN_IRQ_HDMI0, A20 },
 	{ awinhdmi, OFFANDSIZE(HDMI), NOPORT, AWIN_A31_IRQ_HDMI, A31 },
+	{ awinhdmi, OFFANDSIZE(A80_HDMI), NOPORT, AWIN_A80_IRQ_HDMI, A80 },
 	{ awinwdt, OFFANDSIZE(TMR), NOPORT, NOINTR, A10|A20|A31 },
 	{ awinwdt, OFFANDSIZE(A80_TIMER), NOPORT, NOINTR, A80 },
 	{ awinrtc, OFFANDSIZE(TMR), NOPORT, NOINTR, A10|A20 },
@@ -176,6 +181,7 @@ static const struct awin_locators awin_l
 	{ awincrypto, OFFANDSIZE(SS), NOPORT, AWIN_IRQ_SS, AANY },
 	{ awinac, OFFANDSIZE(AC), NOPORT, AWIN_IRQ_AC, A10|A20 },
 	{ awinac, OFFANDSIZE(AC), NOPORT, AWIN_A31_IRQ_AC, A31 },
+	{ awindaudio, OFFANDSIZE(A80_DAUDIO1), 1, AWIN_A80_IRQ_R_DAUDIO, A80 },
 	{ awinhdmiaudio, OFFANDSIZE(HDMI), NOPORT, NOINTR, A20 },
 	{ awinhdmiaudio, OFFANDSIZE(HDMI), NOPORT, NOINTR, A31 },
 	{ awinnand, OFFANDSIZE(NFC), NOPORT, AWIN_IRQ_NAND, A10|A20 },



CVS commit: src/sys/arch/arm/allwinner

2014-12-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec 21 17:40:59 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c files.awin

Log Message:
add support for re-using a display mode setup by the bootloader


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/allwinner/awin_debe.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.12 src/sys/arch/arm/allwinner/awin_debe.c:1.13
--- src/sys/arch/arm/allwinner/awin_debe.c:1.12	Mon Dec  8 10:48:22 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Sun Dec 21 17:40:59 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.12 2014/12/08 10:48:22 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.13 2014/12/21 17:40:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -37,7 +37,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.12 2014/12/08 10:48:22 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.13 2014/12/21 17:40:59 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -118,6 +118,9 @@ awin_debe_attach(device_t parent, device
 #if NAWIN_MP  0
 	device_t mpdev;
 #endif
+#ifdef AWIN_DEBE_FWINIT
+	struct videomode mode;
+#endif
 	int error;
 
 	sc-sc_dev = self;
@@ -139,7 +142,7 @@ awin_debe_attach(device_t parent, device
 		AWIN_A31_AHB_RESET1_REG,
 		AWIN_A31_AHB_RESET1_BE0_RST  loc-loc_port,
 		0);
-	} else {
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A20) {
 		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
 		AWIN_BE0_SCLK_CFG_REG + (loc-loc_port * 4),
 		AWIN_BEx_CLK_RST,
@@ -160,7 +163,7 @@ awin_debe_attach(device_t parent, device
 			  AWIN_A31_BEx_CLK_SRC_SEL) |
 		__SHIFTIN(clk_div - 1, AWIN_BEx_CLK_DIV_RATIO_M),
 		AWIN_A31_BEx_CLK_SRC_SEL | AWIN_BEx_CLK_DIV_RATIO_M);
-	} else {
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A20) {
 		uint32_t pll5x_freq = awin_pll5x_get_rate();
 		unsigned int clk_div = (pll5x_freq + 2) / 3;
 
@@ -176,23 +179,55 @@ awin_debe_attach(device_t parent, device
 		AWIN_BEx_CLK_SRC_SEL | AWIN_BEx_CLK_DIV_RATIO_M);
 	}
 
-	awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
-	AWIN_AHB_GATING1_REG, AWIN_AHB_GATING1_DE_BE0  loc-loc_port, 0);
+	if (awin_chip_id() == AWIN_CHIP_ID_A20 ||
+	awin_chip_id() == AWIN_CHIP_ID_A31) {
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_AHB_GATING1_REG,
+		AWIN_AHB_GATING1_DE_BE0  loc-loc_port, 0);
+
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_DRAM_CLK_REG,
+		AWIN_DRAM_CLK_BE0_DCLK_ENABLE  loc-loc_port, 0);
+
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_BE0_SCLK_CFG_REG + (loc-loc_port * 4),
+		AWIN_CLK_ENABLE, 0);
+	}
 
-	awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
-	AWIN_DRAM_CLK_REG,
-	AWIN_DRAM_CLK_BE0_DCLK_ENABLE  loc-loc_port, 0);
-
-	awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
-	AWIN_BE0_SCLK_CFG_REG + (loc-loc_port * 4),
-	AWIN_CLK_ENABLE, 0);
+#ifdef AWIN_DEBE_FWINIT
+	const uint32_t modctl = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
+	const uint32_t dissize = DEBE_READ(sc, AWIN_DEBE_DISSIZE_REG);
+	if ((modctl  AWIN_DEBE_MODCTL_EN) == 0) {
+		aprint_error_dev(sc-sc_dev, disabled\n);
+		return;
+	}
+	if ((modctl  AWIN_DEBE_MODCTL_START_CTL) == 0) {
+		aprint_error_dev(sc-sc_dev, stopped\n);
+		return;
+	}
+	memset(mode, 0, sizeof(mode));
+	mode.hdisplay = (dissize  0x) + 1;
 
+	if (mode.hdisplay == 1 || mode.vdisplay == 1) {
+		aprint_error_dev(sc-sc_dev,
+		couldn't determine video mode\n);
+		return;
+	}
+
+	aprint_verbose_dev(sc-sc_dev, using %dx%d mode from firmware\n,
+	mode.hdisplay, mode.vdisplay);
+
+	sc-sc_dmasize = mode.hdisplay * mode.vdisplay * 4;
+#else
 	for (unsigned int reg = 0x800; reg  0x1000; reg += 4) {
 		DEBE_WRITE(sc, reg, 0);
 	}
 
 	DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, AWIN_DEBE_MODCTL_EN);
 
+	sc-sc_dmasize = AWIN_DEBE_VIDEOMEM;
+#endif
+
 	DEBE_WRITE(sc, AWIN_DEBE_HWC_PALETTE_TABLE, 0);
 
 	error = awin_debe_alloc_videomem(sc);
@@ -211,6 +246,11 @@ awin_debe_attach(device_t parent, device
 		awin_mp_setbase(mpdev, pa, sc-sc_dmasize);
 	}
 #endif
+
+#ifdef AWIN_DEBE_FWINIT
+	awin_debe_set_videomode(mode);
+	awin_debe_enable(true);
+#endif
 }
 
 static int
@@ -218,9 +258,8 @@ awin_debe_alloc_videomem(struct awin_deb
 {
 	int error, nsegs;
 
-	sc-sc_dmasize = AWIN_DEBE_VIDEOMEM;
-	error = bus_dmamem_alloc(sc-sc_dmat, sc-sc_dmasize, 0,
-	sc-sc_dmasize, sc-sc_dmasegs, 1, nsegs, BUS_DMA_WAITOK);
+	error = bus_dmamem_alloc(sc-sc_dmat, sc-sc_dmasize, 0x1000, 0,
+	sc-sc_dmasegs, 1, nsegs, BUS_DMA_WAITOK);
 	if (error)
 		return error;
 	error = bus_dmamem_map(sc-sc_dmat, 

CVS commit: src/sys/arch/arm/allwinner

2014-12-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec 21 18:36:05 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c

Log Message:
actually initialize mode.vdisplay


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/allwinner/awin_debe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.13 src/sys/arch/arm/allwinner/awin_debe.c:1.14
--- src/sys/arch/arm/allwinner/awin_debe.c:1.13	Sun Dec 21 17:40:59 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Sun Dec 21 18:36:05 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.13 2014/12/21 17:40:59 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.14 2014/12/21 18:36:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -37,7 +37,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.13 2014/12/21 17:40:59 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.14 2014/12/21 18:36:05 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -207,6 +207,7 @@ awin_debe_attach(device_t parent, device
 	}
 	memset(mode, 0, sizeof(mode));
 	mode.hdisplay = (dissize  0x) + 1;
+	mode.vdisplay = ((dissize  16)  0x) + 1;
 
 	if (mode.hdisplay == 1 || mode.vdisplay == 1) {
 		aprint_error_dev(sc-sc_dev,



CVS commit: src/sys/arch/arm/allwinner

2014-12-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 20 16:22:17 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
RCSID police


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.73 src/sys/arch/arm/allwinner/awin_reg.h:1.74
--- src/sys/arch/arm/allwinner/awin_reg.h:1.73	Thu Dec 11 23:35:11 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sat Dec 20 16:22:17 2014
@@ -1,4 +1,5 @@
-/* $NetBSD */
+/* $NetBSD: awin_reg.h,v 1.74 2014/12/20 16:22:17 skrll Exp $ */
+
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
  * All rights reserved.



CVS commit: src/sys/arch/arm/allwinner

2014-12-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Dec  8 10:48:23 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c awin_reg.h

Log Message:
Set BGRA pixel sequence if __ARMEB__ is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/allwinner/awin_debe.c
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.11 src/sys/arch/arm/allwinner/awin_debe.c:1.12
--- src/sys/arch/arm/allwinner/awin_debe.c:1.11	Thu Dec  4 11:16:38 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Mon Dec  8 10:48:22 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.11 2014/12/04 11:16:38 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.12 2014/12/08 10:48:22 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -37,7 +37,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.11 2014/12/04 11:16:38 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.12 2014/12/08 10:48:22 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -487,6 +487,13 @@ awin_debe_set_videomode(const struct vid
  AWIN_DEBE_ATTCTL1_LAY_FBFMT);
 		val = ~AWIN_DEBE_ATTCTL1_LAY_BRSWAPEN;
 		val = ~AWIN_DEBE_ATTCTL1_LAY_FBPS;
+#if __ARMEB__
+		val |= __SHIFTIN(AWIN_DEBE_ATTCTL1_LAY_FBPS_32BPP_BGRA,
+ AWIN_DEBE_ATTCTL1_LAY_FBPS);
+#else
+		val |= __SHIFTIN(AWIN_DEBE_ATTCTL1_LAY_FBPS_32BPP_ARGB,
+ AWIN_DEBE_ATTCTL1_LAY_FBPS);
+#endif
 		DEBE_WRITE(sc, AWIN_DEBE_ATTCTL1_REG, val);
 
 		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.71 src/sys/arch/arm/allwinner/awin_reg.h:1.72
--- src/sys/arch/arm/allwinner/awin_reg.h:1.71	Sun Dec  7 18:32:13 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Mon Dec  8 10:48:22 2014
@@ -1727,6 +1727,8 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_DEBE_ATTCTL1_LAY_FBFMT_RGBA	13
 #define AWIN_DEBE_ATTCTL1_LAY_BRSWAPEN	__BIT(2)
 #define AWIN_DEBE_ATTCTL1_LAY_FBPS	__BITS(1,0)
+#define AWIN_DEBE_ATTCTL1_LAY_FBPS_32BPP_ARGB	0
+#define AWIN_DEBE_ATTCTL1_LAY_FBPS_32BPP_BGRA	2
 
 #define AWIN_DEBE_REGBUFFCTL_REGAUTOLOAD_DIS __BIT(1)
 #define AWIN_DEBE_REGBUFFCTL_REGLOADCTL	__BIT(0)



CVS commit: src/sys/arch/arm/allwinner

2014-12-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 12:44:24 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_com.c awin_reg.h

Log Message:
A80 UART0 pinsets


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/allwinner/awin_com.c
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_com.c
diff -u src/sys/arch/arm/allwinner/awin_com.c:1.8 src/sys/arch/arm/allwinner/awin_com.c:1.9
--- src/sys/arch/arm/allwinner/awin_com.c:1.8	Fri Dec  5 01:13:11 2014
+++ src/sys/arch/arm/allwinner/awin_com.c	Sun Dec  7 12:44:24 2014
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_com.c,v 1.8 2014/12/05 01:13:11 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_com.c,v 1.9 2014/12/07 12:44:24 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -81,6 +81,10 @@ static const struct awin_gpio_pinset awi
 	{ 'H', AWIN_A31_PIO_PH_UART0_FUNC, AWIN_A31_PIO_PH_UART0_PINS },
 };
 
+static const struct awin_gpio_pinset awin_com_pinsets_a80[] = {
+	{ 'H', AWIN_A80_PIO_PH_UART0_FUNC, AWIN_A80_PIO_PH_UART0_PINS },
+};
+
 CFATTACH_DECL_NEW(awin_com, sizeof(struct awin_com_softc),
 	awin_com_match, awin_com_attach, NULL, NULL);
 
@@ -97,6 +101,8 @@ awin_com_match(device_t parent, cfdata_t
 
 	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 		pinset = awin_com_pinsets_a31;
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A80) {
+		pinset = awin_com_pinsets_a80;
 	} else {
 		pinset = loc-loc_port + ((cf-cf_flags  1) ?
 		awin_com_alt_pinsets : awin_com_pinsets);
@@ -148,6 +154,8 @@ awin_com_attach(device_t parent, device_
 
 	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 		pinset = awin_com_pinsets_a31;
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A80) {
+		pinset = awin_com_pinsets_a80;
 	} else {
 		pinset = loc-loc_port + ((cf-cf_flags  1) ?
 		awin_com_alt_pinsets : awin_com_pinsets);

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.68 src/sys/arch/arm/allwinner/awin_reg.h:1.69
--- src/sys/arch/arm/allwinner/awin_reg.h:1.68	Sun Dec  7 02:01:51 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sun Dec  7 12:44:24 2014
@@ -2861,5 +2861,7 @@ struct awin_a31_dma_desc {
 #define AWIN_A80_PIO_PH_TWI1_PINS	0x000c /* PH pins 3-2 */
 #define AWIN_A80_PIO_PH_TWI2_FUNC	2
 #define AWIN_A80_PIO_PH_TWI2_PINS	0x0030 /* PH pins 5-4 */
+#define AWIN_A80_PIO_PH_UART0_FUNC	2
+#define AWIN_A80_PIO_PH_UART0_PINS	0x3000 /* PH pins 13-12 */
 
 #endif /* _ARM_ALLWINNER_AWIN_REG_H_ */



CVS commit: src/sys/arch/arm/allwinner

2014-12-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 13:06:39 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_p2wi.c

Log Message:
Only need to SRTA if the device address is changing. Add AC100 device address.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/allwinner/awin_p2wi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_p2wi.c
diff -u src/sys/arch/arm/allwinner/awin_p2wi.c:1.2 src/sys/arch/arm/allwinner/awin_p2wi.c:1.3
--- src/sys/arch/arm/allwinner/awin_p2wi.c:1.2	Sun Dec  7 00:36:26 2014
+++ src/sys/arch/arm/allwinner/awin_p2wi.c	Sun Dec  7 13:06:39 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_p2wi.c,v 1.2 2014/12/07 00:36:26 jmcneill Exp $ */
+/* $NetBSD: awin_p2wi.c,v 1.3 2014/12/07 13:06:39 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_p2wi.c,v 1.2 2014/12/07 00:36:26 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_p2wi.c,v 1.3 2014/12/07 13:06:39 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -45,9 +45,11 @@ __KERNEL_RCSID(0, $NetBSD: awin_p2wi.c,
 
 #define AWIN_RSB_ADDR_AXP809	0x3a3
 #define AWIN_RSB_ADDR_AXP806	0x745
+#define AWIN_RSB_ADDR_AC100	0xe89
 
 #define AWIN_RSB_RTA_AXP809	0x2d
 #define AWIN_RSB_RTA_AXP806	0x3a
+#define AWIN_RSB_RTA_AC100	0x4e
 
 struct awin_p2wi_softc {
 	device_t sc_dev;
@@ -61,6 +63,7 @@ struct awin_p2wi_softc {
 	uint32_t sc_stat;
 
 	bool sc_rsb_p;
+	uint16_t sc_rsb_last_da;
 };
 
 #define P2WI_READ(sc, reg) \
@@ -283,7 +286,7 @@ awin_p2wi_exec(void *priv, i2c_op_t op, 
 	if (cmdlen != 1 || len != 1)
 		return EINVAL;
 
-	if (sc-sc_rsb_p) {
+	if (sc-sc_rsb_p  sc-sc_rsb_last_da != addr) {
 		switch (addr) {
 		case AWIN_RSB_ADDR_AXP809:
 			rta = AWIN_RSB_RTA_AXP809;
@@ -291,6 +294,9 @@ awin_p2wi_exec(void *priv, i2c_op_t op, 
 		case AWIN_RSB_ADDR_AXP806:
 			rta = AWIN_RSB_RTA_AXP806;
 			break;
+		case AWIN_RSB_ADDR_AC100:
+			rta = AWIN_RSB_RTA_AC100;
+			break;
 		default:
 			return ENXIO;
 		}
@@ -299,8 +305,11 @@ awin_p2wi_exec(void *priv, i2c_op_t op, 
 			device_printf(sc-sc_dev,
 			SRTA failed, flags = %x, error = %d\n,
 			flags, error);
+			sc-sc_rsb_last_da = 0;
 			return error;
 		}
+
+		sc-sc_rsb_last_da = addr;
 	}
 
 	/* Data byte register */



CVS commit: src/sys/arch/arm/allwinner

2014-12-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 14:22:08 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_p2wi.c

Log Message:
Add support for 2- and 4- byte transfers


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/allwinner/awin_p2wi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_p2wi.c
diff -u src/sys/arch/arm/allwinner/awin_p2wi.c:1.3 src/sys/arch/arm/allwinner/awin_p2wi.c:1.4
--- src/sys/arch/arm/allwinner/awin_p2wi.c:1.3	Sun Dec  7 13:06:39 2014
+++ src/sys/arch/arm/allwinner/awin_p2wi.c	Sun Dec  7 14:22:08 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_p2wi.c,v 1.3 2014/12/07 13:06:39 jmcneill Exp $ */
+/* $NetBSD: awin_p2wi.c,v 1.4 2014/12/07 14:22:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_p2wi.c,v 1.3 2014/12/07 13:06:39 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_p2wi.c,v 1.4 2014/12/07 14:22:08 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -283,7 +283,7 @@ awin_p2wi_exec(void *priv, i2c_op_t op, 
 
 	KASSERT(mutex_owned(sc-sc_lock));
 
-	if (cmdlen != 1 || len != 1)
+	if (cmdlen != 1 || (len != 1  len != 2  len != 4))
 		return EINVAL;
 
 	if (sc-sc_rsb_p  sc-sc_rsb_last_da != addr) {
@@ -316,13 +316,45 @@ awin_p2wi_exec(void *priv, i2c_op_t op, 
 	P2WI_WRITE(sc, AWIN_A31_P2WI_DADDR0_REG, *(const uint8_t *)cmdbuf);
 
 	if (I2C_OP_WRITE_P(op)) {
-		/* Write data byte */
-		P2WI_WRITE(sc, AWIN_A31_P2WI_DATA0_REG, *(uint8_t *)buf);
+		uint8_t *pbuf = buf;
+		uint32_t data;
+		/* Write data */
+		switch (len) {
+		case 1:
+			data = pbuf[0];
+			break;
+		case 2:
+			data = pbuf[0] | (pbuf[1]  8);
+			break;
+		case 4:
+			data = pbuf[0] | (pbuf[1]  8) |
+			(pbuf[2]  16) | (pbuf[3]  24);
+			break;
+		default:
+			return EINVAL;
+		}
+		device_printf(sc-sc_dev, writing 0x%x to 0x%x\n,
+		data, *(const uint8_t *)cmdbuf);
+		P2WI_WRITE(sc, AWIN_A31_P2WI_DATA0_REG, data);
 	}
 
 	if (sc-sc_rsb_p) {
-		uint8_t cmd = I2C_OP_WRITE_P(op) ? AWIN_A80_RSB_CMD_IDX_WR8 :
-		   AWIN_A80_RSB_CMD_IDX_RD8;
+		uint8_t cmd;
+		if (I2C_OP_WRITE_P(op)) {
+			switch (len) {
+			case 1:	cmd = AWIN_A80_RSB_CMD_IDX_WR8; break;
+			case 2: cmd = AWIN_A80_RSB_CMD_IDX_WR16; break;
+			case 4: cmd = AWIN_A80_RSB_CMD_IDX_WR32; break;
+			default: return EINVAL;
+			}
+		} else {
+			switch (len) {
+			case 1:	cmd = AWIN_A80_RSB_CMD_IDX_RD8; break;
+			case 2: cmd = AWIN_A80_RSB_CMD_IDX_RD16; break;
+			case 4: cmd = AWIN_A80_RSB_CMD_IDX_RD32; break;
+			default: return EINVAL;
+			}
+		}
 		P2WI_WRITE(sc, AWIN_A80_RSB_CMD_REG, cmd);
 	}
 
@@ -350,7 +382,20 @@ awin_p2wi_exec(void *priv, i2c_op_t op, 
 	}
 
 	if (I2C_OP_READ_P(op)) {
-		*(uint8_t *)buf = P2WI_READ(sc, AWIN_A31_P2WI_DATA0_REG)  0xff;
+		uint32_t data = P2WI_READ(sc, AWIN_A31_P2WI_DATA0_REG);
+		switch (len) {
+		case 4:
+			*(uint32_t *)buf = data;
+			break;
+		case 2:
+			*(uint16_t *)buf = data  0x;
+			break;
+		case 1:
+			*(uint8_t *)buf = data  0xff;
+			break;
+		default:
+			return EINVAL;
+		}
 	}
 
 	return 0;



CVS commit: src/sys/arch/arm/allwinner

2014-12-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 14:22:33 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_p2wi.c

Log Message:
remove debug printf


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/allwinner/awin_p2wi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_p2wi.c
diff -u src/sys/arch/arm/allwinner/awin_p2wi.c:1.4 src/sys/arch/arm/allwinner/awin_p2wi.c:1.5
--- src/sys/arch/arm/allwinner/awin_p2wi.c:1.4	Sun Dec  7 14:22:08 2014
+++ src/sys/arch/arm/allwinner/awin_p2wi.c	Sun Dec  7 14:22:32 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_p2wi.c,v 1.4 2014/12/07 14:22:08 jmcneill Exp $ */
+/* $NetBSD: awin_p2wi.c,v 1.5 2014/12/07 14:22:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_p2wi.c,v 1.4 2014/12/07 14:22:08 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_p2wi.c,v 1.5 2014/12/07 14:22:32 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -333,8 +333,6 @@ awin_p2wi_exec(void *priv, i2c_op_t op, 
 		default:
 			return EINVAL;
 		}
-		device_printf(sc-sc_dev, writing 0x%x to 0x%x\n,
-		data, *(const uint8_t *)cmdbuf);
 		P2WI_WRITE(sc, AWIN_A31_P2WI_DATA0_REG, data);
 	}
 



CVS commit: src/sys/arch/arm/allwinner

2014-12-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 15:00:37 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_board.c

Log Message:
only access A20 regs if running on A20


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/allwinner/awin_board.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_board.c
diff -u src/sys/arch/arm/allwinner/awin_board.c:1.31 src/sys/arch/arm/allwinner/awin_board.c:1.32
--- src/sys/arch/arm/allwinner/awin_board.c:1.31	Fri Dec  5 14:36:44 2014
+++ src/sys/arch/arm/allwinner/awin_board.c	Sun Dec  7 15:00:37 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_board.c,v 1.31 2014/12/05 14:36:44 jmcneill Exp $	*/
+/*	$NetBSD: awin_board.c,v 1.32 2014/12/07 15:00:37 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_board.c,v 1.31 2014/12/05 14:36:44 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_board.c,v 1.32 2014/12/07 15:00:37 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -217,7 +217,7 @@ awin_bootstrap(vaddr_t iobase, vaddr_t u
 		}
 		printf(%s: cpu status: 0=%#x 1=%#x 2=%#x 3=%#x\n, __func__,
 		s[0], s[1], s[2], s[3]);
-	} else {
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A20) {
 		uint32_t s0 = bus_space_read_4(awin_bs_tag, awin_core_bsh,
 		AWIN_CPUCFG_OFFSET + AWIN_CPUCFG_CPU0_STATUS_REG);
 		uint32_t s1 = bus_space_read_4(awin_bs_tag, awin_core_bsh,



CVS commit: src/sys/arch/arm/allwinner

2014-12-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 16:20:33 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h awin_usb.c

Log Message:
CCU SCLK soft reset 1 bit 1 is for USB DRD, not host controller


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/allwinner/awin_usb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.69 src/sys/arch/arm/allwinner/awin_reg.h:1.70
--- src/sys/arch/arm/allwinner/awin_reg.h:1.69	Sun Dec  7 12:44:24 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sun Dec  7 16:20:33 2014
@@ -2771,7 +2771,7 @@ struct awin_a31_dma_desc {
 
 #define AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_DMA	__BIT(24)
 #define AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_GMAC	__BIT(17)
-#define AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_USB_HOST __BIT(1)
+#define AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_USB_DRD	__BIT(1)
 
 #define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_TWI4	__BIT(4)
 #define AWIN_A80_CCU_SCLK_BUS_SOFT_RST4_TWI3	__BIT(3)

Index: src/sys/arch/arm/allwinner/awin_usb.c
diff -u src/sys/arch/arm/allwinner/awin_usb.c:1.18 src/sys/arch/arm/allwinner/awin_usb.c:1.19
--- src/sys/arch/arm/allwinner/awin_usb.c:1.18	Fri Dec  5 17:32:08 2014
+++ src/sys/arch/arm/allwinner/awin_usb.c	Sun Dec  7 16:20:33 2014
@@ -34,7 +34,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_usb.c,v 1.18 2014/12/05 17:32:08 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_usb.c,v 1.19 2014/12/07 16:20:33 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -473,10 +473,6 @@ awinusb_attach(device_t parent, device_t
 		awin_reg_set_clear(usbsc-usbsc_bst, aio-aio_ccm_bsh,
 		AWIN_A80_CCU_SCLK_BUS_CLK_GATING1_REG,
 		AWIN_A80_CCU_SCLK_BUS_CLK_GATING1_USB_HOST, 0);
-		/* Soft reset */
-		awin_reg_set_clear(usbsc-usbsc_bst, aio-aio_ccm_bsh,
-		AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_REG,
-		AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_USB_HOST, 0);
 
 		/* Enable USB PHY */
 		awin_reg_set_clear(usbsc-usbsc_bst, usb_bsh,



CVS commit: src/sys/arch/arm/allwinner

2014-12-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 18:34:24 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_ir.c

Log Message:
turn off AWIN_IR_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/allwinner/awin_ir.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_ir.c
diff -u src/sys/arch/arm/allwinner/awin_ir.c:1.5 src/sys/arch/arm/allwinner/awin_ir.c:1.6
--- src/sys/arch/arm/allwinner/awin_ir.c:1.5	Sun Dec  7 18:32:13 2014
+++ src/sys/arch/arm/allwinner/awin_ir.c	Sun Dec  7 18:34:24 2014
@@ -1,6 +1,4 @@
-/* $NetBSD: awin_ir.c,v 1.5 2014/12/07 18:32:13 jmcneill Exp $ */
-
-#define AWIN_IR_DEBUG
+/* $NetBSD: awin_ir.c,v 1.6 2014/12/07 18:34:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -31,7 +29,7 @@
 #include opt_ddb.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_ir.c,v 1.5 2014/12/07 18:32:13 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_ir.c,v 1.6 2014/12/07 18:34:24 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h



CVS commit: src/sys/arch/arm/allwinner

2014-12-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 20:09:35 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_mmc.c

Log Message:
Initialize AWIN_MMC_TIMEOUT reg, return ETIMEDOUT on cmd timeout, fix 
SCF_RSP_BSY handling, specify pullup and drv level on A80 pinsets, report 
MMC_OCR_HSC


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/allwinner/awin_mmc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_mmc.c
diff -u src/sys/arch/arm/allwinner/awin_mmc.c:1.18 src/sys/arch/arm/allwinner/awin_mmc.c:1.19
--- src/sys/arch/arm/allwinner/awin_mmc.c:1.18	Fri Dec  5 23:22:40 2014
+++ src/sys/arch/arm/allwinner/awin_mmc.c	Sun Dec  7 20:09:35 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_mmc.c,v 1.18 2014/12/05 23:22:40 jmcneill Exp $ */
+/* $NetBSD: awin_mmc.c,v 1.19 2014/12/07 20:09:35 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.18 2014/12/05 23:22:40 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.19 2014/12/07 20:09:35 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -50,9 +50,12 @@ __KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v
 #define AWIN_MMC_DMA_FTRGLEVEL_A80	0x200f0010
 
 static const struct awin_gpio_pinset awin_mmc_pinsets_a80[4] = {
-	[0] = { 'F', AWIN_A80_PIO_PF_SDMMC0_FUNC, AWIN_A80_PIO_PF_SDMMC0_PINS },
-	[1] = { 'G', AWIN_A80_PIO_PG_SDMMC1_FUNC, AWIN_A80_PIO_PG_SDMMC1_PINS },
-	[2] = { 'C', AWIN_A80_PIO_PC_SDMMC2_FUNC, AWIN_A80_PIO_PC_SDMMC2_PINS },
+	[0] = { 'F', AWIN_A80_PIO_PF_SDMMC0_FUNC, AWIN_A80_PIO_PF_SDMMC0_PINS,
+		GPIO_PIN_PULLUP, 2 },
+	[1] = { 'G', AWIN_A80_PIO_PG_SDMMC1_FUNC, AWIN_A80_PIO_PG_SDMMC1_PINS,
+		GPIO_PIN_PULLUP, 2 },
+	[2] = { 'C', AWIN_A80_PIO_PC_SDMMC2_FUNC, AWIN_A80_PIO_PC_SDMMC2_PINS,
+		GPIO_PIN_PULLUP, 2 },
 };
 
 static int	awin_mmc_match(device_t, cfdata_t, void *);
@@ -517,6 +520,8 @@ awin_mmc_host_reset(sdmmc_chipset_handle
 		delay(100);
 	}
 
+	MMC_WRITE(sc, AWIN_MMC_TIMEOUT, 0x);
+
 	MMC_WRITE(sc, AWIN_MMC_IMASK,
 	AWIN_MMC_INT_CMD_DONE | AWIN_MMC_INT_ERROR |
 	AWIN_MMC_INT_DATA_OVER | AWIN_MMC_INT_AUTO_CMD_DONE);
@@ -531,7 +536,7 @@ awin_mmc_host_reset(sdmmc_chipset_handle
 static uint32_t
 awin_mmc_host_ocr(sdmmc_chipset_handle_t sch)
 {
-	return MMC_OCR_3_2V_3_3V | MMC_OCR_3_3V_3_4V;
+	return MMC_OCR_3_2V_3_3V | MMC_OCR_3_3V_3_4V | MMC_OCR_HSC;
 }
 
 static int
@@ -907,8 +912,13 @@ awin_mmc_exec_command(sdmmc_chipset_hand
 
 	cmd-c_error = awin_mmc_wait_rint(sc,
 	AWIN_MMC_INT_ERROR|AWIN_MMC_INT_CMD_DONE, hz * 10);
-	if (cmd-c_error == 0  (sc-sc_intr_rint  AWIN_MMC_INT_ERROR))
-		cmd-c_error = EIO;
+	if (cmd-c_error == 0  (sc-sc_intr_rint  AWIN_MMC_INT_ERROR)) {
+		if (sc-sc_intr_rint  AWIN_MMC_INT_RESP_TIMEOUT) {
+			cmd-c_error = ETIMEDOUT;
+		} else {
+			cmd-c_error = EIO;
+		}
+	}
 	if (cmd-c_error) {
 #ifdef AWIN_MMC_DEBUG
 		aprint_error_dev(sc-sc_dev,
@@ -936,22 +946,6 @@ awin_mmc_exec_command(sdmmc_chipset_hand
 			cmd-c_error = ETIMEDOUT;
 			goto done;
 		}
-	} else if (cmd-c_flags  SCF_RSP_BSY) {
-		uint32_t status;
-		int retry = 0xf;
-		while (--retry  0) {
-			status = MMC_READ(sc, AWIN_MMC_STATUS);
-			if (status  AWIN_MMC_STATUS_CARD_DATA_BUSY)
-break;
-		}
-		if (retry == 0) {
-#ifdef AWIN_MMC_DEBUG
-			aprint_error_dev(sc-sc_dev,
-			BSY timeout, status = %08x\n, status);
-#endif
-			cmd-c_error = ETIMEDOUT;
-			goto done;
-		}
 	}
 
 	if (cmd-c_flags  SCF_RSP_PRESENT) {



CVS commit: src/sys/arch/arm/allwinner

2014-12-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 20:10:59 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_mmc.c

Log Message:
fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/allwinner/awin_mmc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_mmc.c
diff -u src/sys/arch/arm/allwinner/awin_mmc.c:1.19 src/sys/arch/arm/allwinner/awin_mmc.c:1.20
--- src/sys/arch/arm/allwinner/awin_mmc.c:1.19	Sun Dec  7 20:09:35 2014
+++ src/sys/arch/arm/allwinner/awin_mmc.c	Sun Dec  7 20:10:59 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_mmc.c,v 1.19 2014/12/07 20:09:35 jmcneill Exp $ */
+/* $NetBSD: awin_mmc.c,v 1.20 2014/12/07 20:10:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.19 2014/12/07 20:09:35 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.20 2014/12/07 20:10:59 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -536,7 +536,7 @@ awin_mmc_host_reset(sdmmc_chipset_handle
 static uint32_t
 awin_mmc_host_ocr(sdmmc_chipset_handle_t sch)
 {
-	return MMC_OCR_3_2V_3_3V | MMC_OCR_3_3V_3_4V | MMC_OCR_HSC;
+	return MMC_OCR_3_2V_3_3V | MMC_OCR_3_3V_3_4V | MMC_OCR_HCS;
 }
 
 static int



CVS commit: src/sys/arch/arm/allwinner

2014-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  7 02:01:51 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
fix core2, usb, rcpus sizes


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.67 src/sys/arch/arm/allwinner/awin_reg.h:1.68
--- src/sys/arch/arm/allwinner/awin_reg.h:1.67	Sun Dec  7 00:36:26 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sun Dec  7 02:01:51 2014
@@ -55,11 +55,11 @@
 #if defined(ALLWINNER_A80)
 #define AWIN_CORE_SIZE			0x0640	/* XXX */
 #define AWIN_A80_CORE2_PBASE		0x0080
-#define AWIN_A80_CORE2_SIZE		0x5000
+#define AWIN_A80_CORE2_SIZE		0x0010
 #define AWIN_A80_USB_PBASE		0x00a0
-#define AWIN_A80_USB_SIZE		0x0001
+#define AWIN_A80_USB_SIZE		0x0010
 #define AWIN_A80_RCPUS_PBASE		0x0800
-#define AWIN_A80_RCPUS_SIZE		0x0001
+#define AWIN_A80_RCPUS_SIZE		0x0010
 #else
 #define AWIN_CORE_SIZE			0x0040
 #endif



CVS commit: src/sys/arch/arm/allwinner

2014-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Dec  5 11:53:22 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_intr.h

Log Message:
Add missing A80 intr defs


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/allwinner/awin_intr.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_intr.h
diff -u src/sys/arch/arm/allwinner/awin_intr.h:1.11 src/sys/arch/arm/allwinner/awin_intr.h:1.12
--- src/sys/arch/arm/allwinner/awin_intr.h:1.11	Fri Dec  5 01:13:11 2014
+++ src/sys/arch/arm/allwinner/awin_intr.h	Fri Dec  5 11:53:22 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_intr.h,v 1.11 2014/12/05 01:13:11 jmcneill Exp $ */
+/* $NetBSD: awin_intr.h,v 1.12 2014/12/05 11:53:22 jmcneill Exp $ */
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -185,5 +185,70 @@
 #define AWIN_A80_IRQ_TWI2	40
 #define AWIN_A80_IRQ_TWI3	41
 #define AWIN_A80_IRQ_TWI4	42
+#define AWIN_A80_IRQ_PA_EINT	43
+#define AWIN_A80_IRQ_PB_EINT	47
+#define AWIN_A80_IRQ_PE_EINT	48
+#define AWIN_A80_IRQ_PG_EINT	49
+#define AWIN_A80_IRQ_TIMER0	50
+#define AWIN_A80_IRQ_TIMER1	51
+#define AWIN_A80_IRQ_TIMER2	52
+#define AWIN_A80_IRQ_TIMER3	53
+#define AWIN_A80_IRQ_TIMER4	54
+#define AWIN_A80_IRQ_TIMER5	55
+#define AWIN_A80_IRQ_WATCHDOG	56
+#define AWIN_A80_IRQ_KEYADC	62
+#define AWIN_A80_IRQ_NMI	64
+#define AWIN_A80_IRQ_DMA	82
+#define AWIN_A80_IRQ_HSTIMER0	83
+#define AWIN_A80_IRQ_HSTIMER1	84
+#define AWIN_A80_IRQ_HSTIMER2	85
+#define AWIN_A80_IRQ_HSTIMER3	86
+#define AWIN_A80_IRQ_HSTIMER4	87
+#define AWIN_A80_IRQ_SMC	88
+#define AWIN_A80_IRQ_VE		90
+#define AWIN_A80_IRQ_SDMMC0	92
+#define AWIN_A80_IRQ_SDMMC1	93
+#define AWIN_A80_IRQ_SDMMC2	94
+#define AWIN_A80_IRQ_SDMMC3	95
+#define AWIN_A80_IRQ_SPI0	97
+#define AWIN_A80_IRQ_SPI1	98
+#define AWIN_A80_IRQ_SPI2	99
+#define AWIN_A80_IRQ_SPI3	100
+#define AWIN_A80_IRQ_NAND0	102
+#define AWIN_A80_IRQ_USB_DRD	103
+#define AWIN_A80_IRQ_USB_EHCI0	104
+#define AWIN_A80_IRQ_USB_OHCI0	105
+#define AWIN_A80_IRQ_USB_EHCI1	106
+#define AWIN_A80_IRQ_USB_EHCI2	108
+#define AWIN_A80_IRQ_USB_OHCI2	109
+#define AWIN_A80_IRQ_SS		112
+#define AWIN_A80_IRQ_TS		113
+#define AWIN_A80_IRQ_EMAC	114
+#define AWIN_A80_IRQ_MP		115
+#define AWIN_A80_IRQ_CSI0	116
+#define AWIN_A80_IRQ_CSI1	117
+#define AWIN_A80_IRQ_LCD0	118
+#define AWIN_A80_IRQ_LCD1	119
+#define AWIN_A80_IRQ_HDMI	120
+#define AWIN_A80_IRQ_MIPI_DSI	121
+#define AWIN_A80_IRQ_MIPI_CSI	122
+#define AWIN_A80_IRQ_DRC01	123
+#define AWIN_A80_IRQ_DEU01	124
+#define AWIN_A80_IRQ_DE_FE0	125
+#define AWIN_A80_IRQ_DE_FE1	126
+#define AWIN_A80_IRQ_DE_BE0	127
+#define AWIN_A80_IRQ_DE_BE1	128
+#define AWIN_A80_IRQ_GPU	129
+#define AWIN_A80_IRQ_GPU_PWR	130
+#define AWIN_A80_IRQ_FD		140
+#define AWIN_A80_IRQ_GPADC	141
+#define AWIN_A80_IRQ_THS	147
+#define AWIN_A80_IRQ_DE_BE2	148
+#define AWIN_A80_IRQ_DE_FE2	149
+#define AWIN_A80_IRQ_EDP	150
+#define AWIN_A80_IRQ_PH_EINT	152
+#define AWIN_A80_IRQ_CSI0_CCI	154
+#define AWIN_A80_IRQ_CSI1_CCI	155
+#define AWIN_A80_IRQ_CCI_400	156
 
 #endif /* _ARM_ALLWINNER_AWIN_INTR_H_ */



CVS commit: src/sys/arch/arm/allwinner

2014-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Dec  5 11:53:43 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_gpio.c awin_io.c awin_reg.h awin_wdt.c

Log Message:
A80 gpio and watchdog support


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/allwinner/awin_gpio.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/allwinner/awin_io.c
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/allwinner/awin_wdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_gpio.c
diff -u src/sys/arch/arm/allwinner/awin_gpio.c:1.14 src/sys/arch/arm/allwinner/awin_gpio.c:1.15
--- src/sys/arch/arm/allwinner/awin_gpio.c:1.14	Sun Nov 23 23:04:58 2014
+++ src/sys/arch/arm/allwinner/awin_gpio.c	Fri Dec  5 11:53:43 2014
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_gpio.c,v 1.14 2014/11/23 23:04:58 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_gpio.c,v 1.15 2014/12/05 11:53:43 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -448,6 +448,41 @@ awin_gpio_init(void)
 		pin_groups[12].grp_offset = AWIN_A31_CPUPIO_OFFSET +
 	1 * AWIN_PIO_GRP_SIZE;
 		pin_groups[12].grp_pin_mask = __BIT(AWIN_A31_PIO_PM_PINS) - 1;
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A80) {
+		pin_groups[0].grp_pin_mask = __BIT(AWIN_A80_PIO_PA_PINS) - 1;
+		pin_groups[0].grp_offset = AWIN_A80_PIO_OFFSET + 
+	   0 * AWIN_PIO_GRP_SIZE;
+		pin_groups[1].grp_pin_mask = __BIT(AWIN_A80_PIO_PB_PINS) - 1;
+		pin_groups[1].grp_offset = AWIN_A80_PIO_OFFSET + 
+	   1 * AWIN_PIO_GRP_SIZE;
+		pin_groups[2].grp_pin_mask = __BIT(AWIN_A80_PIO_PC_PINS) - 1;
+		pin_groups[2].grp_offset = AWIN_A80_PIO_OFFSET + 
+	   2 * AWIN_PIO_GRP_SIZE;
+		pin_groups[3].grp_pin_mask = __BIT(AWIN_A80_PIO_PD_PINS) - 1;
+		pin_groups[3].grp_offset = AWIN_A80_PIO_OFFSET + 
+	   3 * AWIN_PIO_GRP_SIZE;
+		pin_groups[4].grp_pin_mask = __BIT(AWIN_A80_PIO_PE_PINS) - 1;
+		pin_groups[4].grp_offset = AWIN_A80_PIO_OFFSET + 
+	   4 * AWIN_PIO_GRP_SIZE;
+		pin_groups[5].grp_pin_mask = __BIT(AWIN_A80_PIO_PF_PINS) - 1;
+		pin_groups[5].grp_offset = AWIN_A80_PIO_OFFSET + 
+	   5 * AWIN_PIO_GRP_SIZE;
+		pin_groups[6].grp_pin_mask = __BIT(AWIN_A80_PIO_PG_PINS) - 1;
+		pin_groups[6].grp_offset = AWIN_A80_PIO_OFFSET + 
+	   6 * AWIN_PIO_GRP_SIZE;
+		pin_groups[7].grp_pin_mask = __BIT(AWIN_A80_PIO_PH_PINS) - 1;
+		pin_groups[7].grp_offset = AWIN_A80_PIO_OFFSET + 
+	   7 * AWIN_PIO_GRP_SIZE;
+		pin_groups[8].grp_offset = 0;		/* PI */
+		pin_groups[8].grp_pin_mask = 0;		/* PI */
+		pin_groups[9].grp_offset = 0;		/* PJ */
+		pin_groups[9].grp_pin_mask = 0;		/* PJ */
+		pin_groups[10].grp_offset = 0;		/* PK */
+		pin_groups[10].grp_pin_mask = 0;	/* PK */
+		pin_groups[11].grp_offset = 0;		/* PL */
+		pin_groups[11].grp_pin_mask = 0;	/* PL */
+		pin_groups[12].grp_offset = 0;		/* PM */
+		pin_groups[12].grp_pin_mask = 0;	/* PM */
 	}
 
 	for (u_int i = 0; i  __arraycount(pin_groups); i++) {

Index: src/sys/arch/arm/allwinner/awin_io.c
diff -u src/sys/arch/arm/allwinner/awin_io.c:1.30 src/sys/arch/arm/allwinner/awin_io.c:1.31
--- src/sys/arch/arm/allwinner/awin_io.c:1.30	Fri Dec  5 01:13:11 2014
+++ src/sys/arch/arm/allwinner/awin_io.c	Fri Dec  5 11:53:43 2014
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_io.c,v 1.30 2014/12/05 01:13:11 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_io.c,v 1.31 2014/12/05 11:53:43 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -94,7 +94,8 @@ awinio_print(void *aux, const char *pnp)
 
 static const struct awin_locators awin_locators[] = {
 	{ awinicu, OFFANDSIZE(INTC), NOPORT, NOINTR, A10|REQ },
-	{ awingpio, OFFANDSIZE(PIO), NOPORT, NOINTR, AANY|REQ },
+	{ awingpio, OFFANDSIZE(PIO), NOPORT, NOINTR, A10|A20|A31|REQ },
+	{ awingpio, OFFANDSIZE(A80_PIO), NOPORT, NOINTR, A80|REQ },
 	{ awindma, OFFANDSIZE(DMA), NOPORT, AWIN_IRQ_DMA, A10|A20 },
 	{ awindma, OFFANDSIZE(DMA), NOPORT, AWIN_A31_IRQ_DMA, A31 },
 	{ awintmr, OFFANDSIZE(TMR), NOPORT, AWIN_IRQ_TMR0, A10 },
@@ -118,6 +119,7 @@ static const struct awin_locators awin_l
 	{ awinhdmi, OFFANDSIZE(HDMI), NOPORT, AWIN_IRQ_HDMI0, A20 },
 	{ awinhdmi, OFFANDSIZE(HDMI), NOPORT, AWIN_A31_IRQ_HDMI, A31 },
 	{ awinwdt, OFFANDSIZE(TMR), NOPORT, NOINTR, A10|A20|A31 },
+	{ awinwdt, OFFANDSIZE(A80_TIMER), NOPORT, NOINTR, A80 },
 	{ awinrtc, OFFANDSIZE(TMR), NOPORT, NOINTR, A10|A20 },
 	{ awinrtc, OFFANDSIZE(A31_RTC), NOPORT, NOINTR, A31 },
 	{ awinusb, OFFANDSIZE(USB1), 0, NOINTR, A10|A20 },
@@ -135,6 +137,10 @@ static const struct awin_locators awin_l
 	{ awinmmc, OFFANDSIZE(SDMMC1), 1, AWIN_A31_IRQ_SDMMC1, A31 },
 	{ awinmmc, OFFANDSIZE(SDMMC2), 2, AWIN_A31_IRQ_SDMMC2, A31 },
 	{ awinmmc, OFFANDSIZE(SDMMC3), 3, AWIN_A31_IRQ_SDMMC3, A31 },
+	{ awinmmc, OFFANDSIZE(SDMMC0), 0, 

CVS commit: src/sys/arch/arm/allwinner

2014-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Dec  5 18:41:41 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_gige.c awin_io.c awin_reg.h awin_var.h

Log Message:
Partial A80 GMAC support. Needs help from PMU to power it up still.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/allwinner/awin_gige.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/arm/allwinner/awin_io.c
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/allwinner/awin_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_gige.c
diff -u src/sys/arch/arm/allwinner/awin_gige.c:1.19 src/sys/arch/arm/allwinner/awin_gige.c:1.20
--- src/sys/arch/arm/allwinner/awin_gige.c:1.19	Sun Nov 23 23:05:19 2014
+++ src/sys/arch/arm/allwinner/awin_gige.c	Fri Dec  5 18:41:41 2014
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_gige.c,v 1.19 2014/11/23 23:05:19 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_gige.c,v 1.20 2014/12/05 18:41:41 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -69,6 +69,9 @@ static const struct awin_gpio_pinset awi
 	'A', AWIN_A31_PIO_PA_GMAC_FUNC, AWIN_A31_PIO_PA_GMAC_PINS, 0, 3
 };
 
+static const struct awin_gpio_pinset awin_gige_gpio_pinset_a80 = {
+	'A', AWIN_A80_PIO_PA_GMAC_FUNC, AWIN_A80_PIO_PA_GMAC_PINS, 0, 3
+};
 
 CFATTACH_DECL_NEW(awin_gige, sizeof(struct awin_gige_softc),
 	awin_gige_match, awin_gige_attach, NULL, NULL);
@@ -102,12 +105,26 @@ awin_gige_attach(device_t parent, device
 	struct awin_gige_softc * const sc = device_private(self);
 	struct awinio_attach_args * const aio = aux;
 	const struct awin_locators * const loc = aio-aio_loc;
-	struct awin_gpio_pinset pinset =
-	awin_chip_id() == AWIN_CHIP_ID_A31 ?
-	awin_gige_gpio_pinset_a31 : awin_gige_gpio_pinset;
+	struct awin_gpio_pinset pinset;
 	prop_dictionary_t cfg = device_properties(self);
 	uint32_t clkreg;
 	const char *phy_type, *pin_name;
+	bus_space_handle_t bsh;
+
+	switch (awin_chip_id()) {
+	case AWIN_CHIP_ID_A80:
+		bsh = aio-aio_a80_core2_bsh;
+		pinset = awin_gige_gpio_pinset_a80;
+		break;
+	case AWIN_CHIP_ID_A31:
+		bsh = aio-aio_core_bsh;
+		pinset = awin_gige_gpio_pinset_a31;
+		break;
+	default:
+		bsh = aio-aio_core_bsh;
+		pinset = awin_gige_gpio_pinset;
+		break;
+	}
 
 	sc-sc_core.sc_dev = self;
 
@@ -116,7 +133,7 @@ awin_gige_attach(device_t parent, device
 
 	sc-sc_core.sc_bst = aio-aio_core_bst;
 	sc-sc_core.sc_dmat = aio-aio_dmat;
-	bus_space_subregion(sc-sc_core.sc_bst, aio-aio_core_bsh,
+	bus_space_subregion(sc-sc_core.sc_bst, bsh,
 	loc-loc_offset, loc-loc_size, sc-sc_core.sc_bsh);
 
 	aprint_naive(\n);
@@ -147,10 +164,14 @@ awin_gige_attach(device_t parent, device
 	/*
 	 * Enable GMAC clock
 	 */
-	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+	if (awin_chip_id() == AWIN_CHIP_ID_A80) {
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_A80_CCU_SCLK_BUS_CLK_GATING1_REG,
+		AWIN_A80_CCU_SCLK_BUS_CLK_GATING1_GMAC, 0);
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
 		AWIN_AHB_GATING0_REG, AWIN_A31_AHB_GATING0_GMAC, 0);
-	} else {
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A20) {
 		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
 		AWIN_AHB_GATING1_REG, AWIN_AHB_GATING1_GMAC, 0);
 	}
@@ -158,9 +179,14 @@ awin_gige_attach(device_t parent, device
 	/*
 	 * Soft reset
 	 */
-	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+	if (awin_chip_id() == AWIN_CHIP_ID_A80) {
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_REG,
+		AWIN_A80_CCU_SCLK_BUS_SOFT_RST1_GMAC, 0);
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
-		AWIN_A31_AHB_RESET0_REG, AWIN_A31_AHB_RESET0_GMAC_RST, 0);
+		AWIN_A31_AHB_RESET0_REG,
+		AWIN_A31_AHB_RESET0_GMAC_RST, 0);
 	}
 
 	/*
@@ -184,7 +210,11 @@ awin_gige_attach(device_t parent, device
 	} else {
 		panic(unknown phy type '%s', phy_type);
 	}
-	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+	if (awin_chip_id() == AWIN_CHIP_ID_A80) {
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_a80_core2_bsh,
+		AWIN_A80_SYS_CTRL_OFFSET + AWIN_A80_SYS_CTRL_EMAC_CLK_REG,
+		clkreg, AWIN_GMAC_CLK_PIT|AWIN_GMAC_CLK_TCS);
+	} else if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
 		AWIN_A31_GMAC_CLK_REG, clkreg,
 		AWIN_GMAC_CLK_PIT|AWIN_GMAC_CLK_TCS);

Index: src/sys/arch/arm/allwinner/awin_io.c
diff -u src/sys/arch/arm/allwinner/awin_io.c:1.34 src/sys/arch/arm/allwinner/awin_io.c:1.35
--- src/sys/arch/arm/allwinner/awin_io.c:1.34	Fri Dec  5 17:32:08 2014
+++ src/sys/arch/arm/allwinner/awin_io.c	Fri Dec  5 18:41:41 2014
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 

CVS commit: src/sys/arch/arm/allwinner

2014-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Dec  5 19:06:41 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_io.c

Log Message:
fix non-A80 builds


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/arm/allwinner/awin_io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_io.c
diff -u src/sys/arch/arm/allwinner/awin_io.c:1.36 src/sys/arch/arm/allwinner/awin_io.c:1.37
--- src/sys/arch/arm/allwinner/awin_io.c:1.36	Fri Dec  5 18:54:35 2014
+++ src/sys/arch/arm/allwinner/awin_io.c	Fri Dec  5 19:06:41 2014
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_io.c,v 1.36 2014/12/05 18:54:35 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_io.c,v 1.37 2014/12/05 19:06:41 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -217,6 +217,7 @@ awinio_attach(device_t parent, device_t 
 	sc-sc_coherent_dmat = awin_coherent_dma_tag;
 
 	switch (awin_chip_id()) {
+#ifdef ALLWINNER_A80
 	case AWIN_CHIP_ID_A80:
 		bus_space_subregion(sc-sc_bst, sc-sc_bsh,
 		AWIN_A80_CCU_SCLK_OFFSET, 0x1000, sc-sc_ccm_bsh);
@@ -225,6 +226,7 @@ awinio_attach(device_t parent, device_t 
 		bus_space_map(sc-sc_bst, AWIN_A80_CORE2_PBASE,
 		AWIN_A80_CORE2_SIZE, 0, sc-sc_a80_core2_bsh);
 		break;
+#endif
 	default:
 		bus_space_subregion(sc-sc_bst, sc-sc_bsh, AWIN_CCM_OFFSET,
 		0x1000, sc-sc_ccm_bsh);



CVS commit: src/sys/arch/arm/allwinner

2014-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Dec  5 23:22:40 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_mmc.c

Log Message:
ensure module clk is initialized before attaching


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/allwinner/awin_mmc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_mmc.c
diff -u src/sys/arch/arm/allwinner/awin_mmc.c:1.17 src/sys/arch/arm/allwinner/awin_mmc.c:1.18
--- src/sys/arch/arm/allwinner/awin_mmc.c:1.17	Fri Dec  5 14:36:44 2014
+++ src/sys/arch/arm/allwinner/awin_mmc.c	Fri Dec  5 23:22:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_mmc.c,v 1.17 2014/12/05 14:36:44 jmcneill Exp $ */
+/* $NetBSD: awin_mmc.c,v 1.18 2014/12/05 23:22:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.17 2014/12/05 14:36:44 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.18 2014/12/05 23:22:40 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -95,7 +95,6 @@ struct awin_mmc_softc {
 	bus_space_tag_t sc_bst;
 	bus_space_handle_t sc_bsh;
 	bus_space_handle_t sc_clk_bsh;
-	bus_space_handle_t sc_comm_bsh;
 	bus_dma_tag_t sc_dmat;
 
 	bool sc_use_dma;
@@ -227,7 +226,6 @@ awin_mmc_attach(device_t parent, device_
 	aprint_normal(: SD3.0 (%s)\n, sc-sc_use_dma ? DMA : PIO);
 
 	if (awin_chip_id() == AWIN_CHIP_ID_A80) {
-
 		if (awin_mmc_pinsets_a80[loc-loc_port].pinset_group) {
 			awin_gpio_pinset_acquire(
 			awin_mmc_pinsets_a80[loc-loc_port]);
@@ -236,22 +234,16 @@ awin_mmc_attach(device_t parent, device_
 		bus_space_subregion(sc-sc_bst, aio-aio_ccm_bsh,
 		AWIN_A80_CCU_SCLK_SDMMC0_CLK_REG + (loc-loc_port * 4), 4,
 		sc-sc_clk_bsh);
-		bus_space_subregion(sc-sc_bst, aio-aio_core_bsh,
-		AWIN_A80_SDMMC_COMM_OFFSET + (loc-loc_port * 4), 4,
-		sc-sc_comm_bsh);
 		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
 		AWIN_A80_CCU_SCLK_BUS_CLK_GATING0_REG,
 		AWIN_A80_CCU_SCLK_BUS_CLK_GATING0_SD, 0);
 		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
 		AWIN_A80_CCU_SCLK_BUS_SOFT_RST0_REG,
 		AWIN_A80_CCU_SCLK_BUS_SOFT_RST0_SD, 0);
-
-		const uint32_t comm = bus_space_read_4(sc-sc_bst,
-		sc-sc_comm_bsh, 0);
-		bus_space_write_4(sc-sc_bst, sc-sc_comm_bsh, 0,
-		comm |
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_core_bsh,
+		AWIN_A80_SDMMC_COMM_OFFSET + (loc-loc_port * 4),
 		AWIN_A80_SDMMC_COMM_SDC_RESET_SW |
-		AWIN_A80_SDMMC_COMM_SDC_CLOCK_SW);
+		AWIN_A80_SDMMC_COMM_SDC_CLOCK_SW, 0);
 		delay(1000);
 	} else {
 		bus_space_subregion(sc-sc_bst, aio-aio_ccm_bsh,
@@ -328,6 +320,64 @@ awin_mmc_attach(device_t parent, device_
 	config_interrupts(self, awin_mmc_attach_i);
 }
 
+static int
+awin_mmc_set_clock(struct awin_mmc_softc *sc, u_int freq)
+{
+	uint32_t odly, sdly, clksrc, n, m, clk;
+	u_int osc24m_freq = AWIN_REF_FREQ / 1000;
+	u_int pll_freq;
+
+	if (awin_chip_id() == AWIN_CHIP_ID_A80) {
+		pll_freq = awin_periph0_get_rate() / 1000;
+	} else {
+		pll_freq = awin_pll6_get_rate() / 1000;
+	}
+
+#ifdef AWIN_MMC_DEBUG
+	aprint_normal_dev(sc-sc_dev, freq = %d, pll_freq = %d\n,
+	freq, pll_freq);
+#endif
+
+	if (freq = 400) {
+		odly = 0;
+		sdly = 0;
+		clksrc = AWIN_SD_CLK_SRC_SEL_OSC24M;
+		n = 2;
+		m = ((osc24m_freq / (1  n)) / freq) - 1;
+	} else if (freq = 25000) {
+		odly = 0;
+		sdly = 5;
+		clksrc = AWIN_SD_CLK_SRC_SEL_PLL6;
+		n = awin_chip_id() == AWIN_CHIP_ID_A80 ? 2 : 0;
+		m = ((pll_freq / freq) / (1  n)) - 1;
+	} else if (freq = 5) {
+		odly = awin_chip_id() == AWIN_CHIP_ID_A80 ? 5 : 3;
+		sdly = awin_chip_id() == AWIN_CHIP_ID_A80 ? 4 : 5;
+		clksrc = AWIN_SD_CLK_SRC_SEL_PLL6;
+		n = awin_chip_id() == AWIN_CHIP_ID_A80 ? 2 : 0;
+		m = ((pll_freq / freq) / (1  n)) - 1;
+	} else {
+		/* UHS speeds not implemented yet */
+		return EIO;
+	}
+
+	clk = bus_space_read_4(sc-sc_bst, sc-sc_clk_bsh, 0);
+	clk = ~AWIN_SD_CLK_SRC_SEL;
+	clk |= __SHIFTIN(clksrc, AWIN_SD_CLK_SRC_SEL);
+	clk = ~AWIN_SD_CLK_DIV_RATIO_N;
+	clk |= __SHIFTIN(n, AWIN_SD_CLK_DIV_RATIO_N);
+	clk = ~AWIN_SD_CLK_DIV_RATIO_M;
+	clk |= __SHIFTIN(m, AWIN_SD_CLK_DIV_RATIO_M);
+	clk = ~AWIN_SD_CLK_OUTPUT_PHASE_CTR;
+	clk |= __SHIFTIN(odly, AWIN_SD_CLK_OUTPUT_PHASE_CTR);
+	clk = ~AWIN_SD_CLK_PHASE_CTR;
+	clk |= __SHIFTIN(sdly, AWIN_SD_CLK_PHASE_CTR);
+	clk |= AWIN_PLL_CFG_ENABLE;
+	bus_space_write_4(sc-sc_bst, sc-sc_clk_bsh, 0, clk);
+
+	return 0;
+}
+
 static void
 awin_mmc_attach_i(device_t self)
 {
@@ -336,7 +386,7 @@ awin_mmc_attach_i(device_t self)
 
 	awin_mmc_host_reset(sc);
 	awin_mmc_bus_width(sc, 1);
-	awin_mmc_bus_clock(sc, 400);
+	awin_mmc_set_clock(sc, 400);
 
 	memset(saa, 0, sizeof(saa));
 	saa.saa_busname = sdmmc;
@@ -580,43 +630,7 @@ static int
 awin_mmc_bus_clock(sdmmc_chipset_handle_t 

CVS commit: src/sys/arch/arm/allwinner

2014-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Dec  5 23:23:23 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
bump AWIN_CORE_SIZE to include gmac


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.64 src/sys/arch/arm/allwinner/awin_reg.h:1.65
--- src/sys/arch/arm/allwinner/awin_reg.h:1.64	Fri Dec  5 18:54:35 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Fri Dec  5 23:23:23 2014
@@ -53,7 +53,7 @@
 
 #define AWIN_CORE_PBASE			0x01C0
 #if defined(ALLWINNER_A80)
-#define AWIN_CORE_SIZE			0x0640	/* XXX */
+#define AWIN_CORE_SIZE			0x0740	/* XXX */
 #define AWIN_A80_CORE2_PBASE		0x0080
 #define AWIN_A80_CORE2_SIZE		0x5000
 #define AWIN_A80_USB_PBASE		0x00a0



CVS commit: src/sys/arch/arm/allwinner

2014-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Dec  5 23:25:17 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
oops, back out previous AWIN_CORE_SIZE change, i misread gmac offset


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.65 src/sys/arch/arm/allwinner/awin_reg.h:1.66
--- src/sys/arch/arm/allwinner/awin_reg.h:1.65	Fri Dec  5 23:23:23 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Fri Dec  5 23:25:17 2014
@@ -53,7 +53,7 @@
 
 #define AWIN_CORE_PBASE			0x01C0
 #if defined(ALLWINNER_A80)
-#define AWIN_CORE_SIZE			0x0740	/* XXX */
+#define AWIN_CORE_SIZE			0x0640	/* XXX */
 #define AWIN_A80_CORE2_PBASE		0x0080
 #define AWIN_A80_CORE2_SIZE		0x5000
 #define AWIN_A80_USB_PBASE		0x00a0



CVS commit: src/sys/arch/arm/allwinner

2014-12-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Dec  4 11:16:38 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c awin_fb.c awin_intr.h awin_io.c
awin_var.h files.awin

Log Message:
Add awinmp(4) glue.

It won't compile (uses nonexistent ioctls) but adding this for posterity.
In my testing, 2D accel for solid fill and copy is considerably slower than
with software rendering, so no sense in turning this on.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/allwinner/awin_debe.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/allwinner/awin_fb.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/allwinner/awin_intr.h
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/allwinner/awin_io.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/allwinner/awin_var.h \
src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.10 src/sys/arch/arm/allwinner/awin_debe.c:1.11
--- src/sys/arch/arm/allwinner/awin_debe.c:1.10	Sun Nov 30 20:04:57 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Thu Dec  4 11:16:38 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.10 2014/11/30 20:04:57 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.11 2014/12/04 11:16:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -28,6 +28,7 @@
 
 #include opt_allwinner.h
 #include genfb.h
+#include awin_mp.h
 
 #ifndef AWIN_DEBE_VIDEOMEM
 #define AWIN_DEBE_VIDEOMEM	(16 * 1024 * 1024)
@@ -36,7 +37,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.10 2014/11/30 20:04:57 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.11 2014/12/04 11:16:38 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -114,6 +115,9 @@ awin_debe_attach(device_t parent, device
 	struct awinio_attach_args * const aio = aux;
 	const struct awin_locators * const loc = aio-aio_loc;
 	prop_dictionary_t cfg = device_properties(self);
+#if NAWIN_MP  0
+	device_t mpdev;
+#endif
 	int error;
 
 	sc-sc_dev = self;
@@ -197,6 +201,16 @@ awin_debe_attach(device_t parent, device
 		couldn't allocate video memory, error = %d\n, error);
 		return;
 	}
+
+#if NAWIN_MP  0
+	mpdev = device_find_by_driver_unit(awinmp, 0);
+	if (mpdev) {
+		paddr_t pa = sc-sc_dmamap-dm_segs[0].ds_addr;
+		if (pa = AWIN_SDRAM_PBASE)
+			pa -= AWIN_SDRAM_PBASE;
+		awin_mp_setbase(mpdev, pa, sc-sc_dmasize);
+	}
+#endif
 }
 
 static int

Index: src/sys/arch/arm/allwinner/awin_fb.c
diff -u src/sys/arch/arm/allwinner/awin_fb.c:1.8 src/sys/arch/arm/allwinner/awin_fb.c:1.9
--- src/sys/arch/arm/allwinner/awin_fb.c:1.8	Sun Nov 30 20:25:54 2014
+++ src/sys/arch/arm/allwinner/awin_fb.c	Thu Dec  4 11:16:38 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_fb.c,v 1.8 2014/11/30 20:25:54 jmcneill Exp $ */
+/* $NetBSD: awin_fb.c,v 1.9 2014/12/04 11:16:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -26,8 +26,10 @@
  * SUCH DAMAGE.
  */
 
+#include awin_mp.h
+
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.8 2014/11/30 20:25:54 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.9 2014/12/04 11:16:38 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -47,6 +49,7 @@ __KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 
 struct awin_fb_softc {
 	struct genfb_softc sc_gen;
 	device_t sc_debedev;
+	device_t sc_mpdev;
 
 	bus_dma_tag_t sc_dmat;
 	bus_dma_segment_t *sc_dmasegs;
@@ -87,6 +90,7 @@ awin_fb_attach(device_t parent, device_t
 	sc-sc_dmat = afb-afb_dmat;
 	sc-sc_dmasegs = afb-afb_dmasegs;
 	sc-sc_ndmasegs = afb-afb_ndmasegs;
+	sc-sc_mpdev = device_find_by_driver_unit(awinmp, 0);
 
 	prop_dictionary_set_uint32(cfg, width, afb-afb_width);
 	prop_dictionary_set_uint32(cfg, height, afb-afb_height);
@@ -146,6 +150,10 @@ awin_fb_ioctl(void *v, void *vs, u_long 
 		if (error == 0) {
 			fbi-fbi_flags |= WSFB_VRAM_IS_RAM;
 			fbi-fbi_fbsize = sc-sc_dmasegs[0].ds_len;
+#if NAWIN_MP  0
+			if (sc-sc_mpdev)
+fbi-fbi_flags |= WSFB_ACCEL;
+#endif
 		}
 		return error;
 	case WSDISPLAYIO_SVIDEO:
@@ -155,6 +163,14 @@ awin_fb_ioctl(void *v, void *vs, u_long 
 	case WSDISPLAYIO_GCURMAX:
 	case WSDISPLAYIO_SCURSOR:
 		return awin_debe_ioctl(sc-sc_debedev, cmd, data);
+#if NAWIN_MP  0
+	case WSDISPLAYIO_FILL:
+	case WSDISPLAYIO_COPY:
+	case WSDISPLAYIO_SYNC:
+		if (sc-sc_mpdev == NULL)
+			return EPASSTHROUGH;
+		return awin_mp_ioctl(sc-sc_mpdev, cmd, data);
+#endif
 	default:
 		return EPASSTHROUGH;
 	}

Index: src/sys/arch/arm/allwinner/awin_intr.h
diff -u src/sys/arch/arm/allwinner/awin_intr.h:1.9 src/sys/arch/arm/allwinner/awin_intr.h:1.10
--- src/sys/arch/arm/allwinner/awin_intr.h:1.9	Sun Nov  2 23:55:06 2014
+++ src/sys/arch/arm/allwinner/awin_intr.h	Thu Dec  4 11:16:38 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: 

CVS commit: src/sys/arch/arm/allwinner

2014-12-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Dec  4 02:11:03 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
fix some mixer processor definitions, add A31 PLL6 cfg lock bit and some extra 
SD CLK bits


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.56 src/sys/arch/arm/allwinner/awin_reg.h:1.57
--- src/sys/arch/arm/allwinner/awin_reg.h:1.56	Sun Nov 30 19:15:53 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Thu Dec  4 02:11:03 2014
@@ -1076,6 +1076,10 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_CLK_SRC_SEL_DE_PLL5	2
 #define AWIN_CLK_SRC_SEL_CIR_LOSC	0
 #define AWIN_CLK_SRC_SEL_CIR_HOSC	1
+#define AWIN_CLK_SRC_SEL_MP_PLL3	0
+#define AWIN_CLK_SRC_SEL_MP_PLL7	1
+#define AWIN_CLK_SRC_SEL_MP_PLL9	2
+#define AWIN_CLK_SRC_SEL_MP_PLL10	3
 #define AWIN_CLK_DIV_RATIO_N		__BITS(17,16)
 #define AWIN_CLK_DIV_RATIO_M		__BITS(3,0)
 
@@ -1141,8 +1145,13 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_HDMI_CLK_SRC_SEL_PLL7_2X	3
 #define AWIN_HDMI_CLK_DIV_RATIO_M	__BITS(3,0)
 
+#define AWIN_SD_CLK_SRC_SEL		__BITS(25,24)
+#define AWIN_SD_CLK_SRC_SEL_OSC24M	0
+#define AWIN_SD_CLK_SRC_SEL_PLL6	1
 #define AWIN_SD_CLK_PHASE_CTR		__BITS(22,20)
+#define AWIN_SD_CLK_DIV_RATIO_N		__BITS(17,16)
 #define AWIN_SD_CLK_OUTPUT_PHASE_CTR	__BITS(10,8)
+#define AWIN_SD_CLK_DIV_RATIO_M		__BITS(3,0)
 
 #define AWIN_CLK_OUT_ENABLE		__BIT(31)
 #define AWIN_CLK_OUT_SRC_SEL		__BITS(25,24)
@@ -2024,7 +2033,7 @@ struct awin_mmc_idma_descriptor {
 /* Mixer processor */
 #define AWIN_MP_CTL_REG0x
 #define AWIN_MP_STS_REG0x0004
-#define AWIN_MP_IDMAGBLCTL_REG			0x0008
+#define AWIN_MP_IDMAGLBCTL_REG			0x0008
 #define AWIN_MP_IDMA_H4ADD_REG			0x000C
 #define AWIN_MP_IDMA_L32ADD_REG(n)		(0x0010 + ((n) * 4))
 #define AWIN_MP_IDMALINEWIDTH_REG(n)		(0x0020 + ((n) * 4))
@@ -2111,9 +2120,9 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_MP_IDMASET_IDMA_FCMODEN		__BIT(16)
 #define AWIN_MP_IDMASET_IDMA_PS			__BITS(15,12)
 #define AWIN_MP_IDMASET_IDMA_FMT		__BITS(11,8)
-#define AWIN_MP_IDMASET_IDMA_FMT_ARGB888	0
-#define AWIN_MP_IDMASET_IDMA_FMT_ARGB444	1
-#define AWIN_MP_IDMASET_IDMA_FMT_ARGB155	2
+#define AWIN_MP_IDMASET_IDMA_FMT_ARGB	0
+#define AWIN_MP_IDMASET_IDMA_FMT_ARGB	1
+#define AWIN_MP_IDMASET_IDMA_FMT_ARGB1555	2
 #define AWIN_MP_IDMASET_IDMA_FMT_RGB565		3
 #define AWIN_MP_IDMASET_IDMA_FMT_IYUV422	4
 #define AWIN_MP_IDMASET_IDMA_FMT_UV88		5
@@ -2297,6 +2306,8 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_A31_PLL3_CFG_FACTOR_N	__BITS(14,8)
 #define AWIN_A31_PLL3_CFG_PREDIV_M	__BITS(3,0)
 
+#define AWIN_A31_PLL6_CFG_LOCK		__BIT(28)
+
 #define AWIN_A31_PLL7_CFG_MODE		__BIT(30)
 #define AWIN_A31_PLL7_CFG_LOCK		__BIT(28)
 #define AWIN_A31_PLL7_CFG_FRAC_CLK_OUT	__BIT(25)



CVS commit: src/sys/arch/arm/allwinner

2014-12-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Dec  4 02:12:07 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_board.c

Log Message:
for A31, when enabling pll, wait for pll to become stable before returning


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/allwinner/awin_board.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_board.c
diff -u src/sys/arch/arm/allwinner/awin_board.c:1.28 src/sys/arch/arm/allwinner/awin_board.c:1.29
--- src/sys/arch/arm/allwinner/awin_board.c:1.28	Wed Nov 12 21:27:48 2014
+++ src/sys/arch/arm/allwinner/awin_board.c	Thu Dec  4 02:12:07 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_board.c,v 1.28 2014/11/12 21:27:48 jmcneill Exp $	*/
+/*	$NetBSD: awin_board.c,v 1.29 2014/12/04 02:12:07 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_board.c,v 1.28 2014/11/12 21:27:48 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_board.c,v 1.29 2014/12/04 02:12:07 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -345,6 +345,13 @@ awin_pll6_enable(void)
 	if (ncfg != ocfg) {
 		bus_space_write_4(bst, bsh,
 		AWIN_CCM_OFFSET + AWIN_PLL6_CFG_REG, ncfg);
+
+		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+			do {
+ncfg = bus_space_read_4(bst, bsh,
+AWIN_CCM_OFFSET + AWIN_PLL6_CFG_REG);
+			} while ((ncfg  AWIN_A31_PLL6_CFG_LOCK) == 0);
+		}
 	}
 #if 0
 	printf( [pll6=%#x-%#x:n=%ju k=%ju m=%ju] ,
@@ -390,6 +397,13 @@ awin_pll2_enable(void)
 	if (ncfg != ocfg) {
 		bus_space_write_4(bst, bsh,
 		AWIN_CCM_OFFSET + AWIN_PLL2_CFG_REG, ncfg);
+
+		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+			do {
+ncfg = bus_space_read_4(bst, bsh,
+AWIN_CCM_OFFSET + AWIN_PLL2_CFG_REG);
+			} while ((ncfg  AWIN_A31_PLL2_CFG_LOCK) == 0);
+		}
 	}
 }
 
@@ -459,6 +473,13 @@ awin_pll7_enable(void)
 	if (ncfg != ocfg) {
 		bus_space_write_4(bst, bsh,
 		AWIN_CCM_OFFSET + AWIN_PLL7_CFG_REG, ncfg);
+
+		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+			do {
+ncfg = bus_space_read_4(bst, bsh,
+AWIN_CCM_OFFSET + AWIN_PLL7_CFG_REG);
+			} while ((ncfg  AWIN_A31_PLL7_CFG_LOCK) == 0);
+		}
 	}
 }
 



CVS commit: src/sys/arch/arm/allwinner

2014-12-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Dec  4 03:03:44 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_mmc.c

Log Message:
Clock fixes:

 - Don't rely on U-boot to enable AHB gating
 - Instead of always running at 100MHz (!), calculate proper clk dividers.
 - Replace PLL6 parsing code with a call to awin_pll6_get_rate()


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/allwinner/awin_mmc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_mmc.c
diff -u src/sys/arch/arm/allwinner/awin_mmc.c:1.15 src/sys/arch/arm/allwinner/awin_mmc.c:1.16
--- src/sys/arch/arm/allwinner/awin_mmc.c:1.15	Mon Oct 20 19:04:22 2014
+++ src/sys/arch/arm/allwinner/awin_mmc.c	Thu Dec  4 03:03:44 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_mmc.c,v 1.15 2014/10/20 19:04:22 jmcneill Exp $ */
+/* $NetBSD: awin_mmc.c,v 1.16 2014/12/04 03:03:44 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include locators.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.15 2014/10/20 19:04:22 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_mmc.c,v 1.16 2014/12/04 03:03:44 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -97,13 +97,10 @@ struct awin_mmc_softc {
 	kcondvar_t sc_intr_cv;
 	kcondvar_t sc_idst_cv;
 
-	int sc_mmc_number;
 	int sc_mmc_width;
 	int sc_mmc_present;
 
 	device_t sc_sdmmc_dev;
-	unsigned int sc_pll_freq;
-	unsigned int sc_mod_clk;
 
 	uint32_t sc_fifo_reg;
 
@@ -151,53 +148,6 @@ awin_mmc_match(device_t parent, cfdata_t
 	return 1;
 }
 
-static void
-awin_mmc_probe_clocks(struct awin_mmc_softc *sc, struct awinio_attach_args *aio)
-{
-	uint32_t val, freq;
-	int n, k, p, div;
-
-	val = bus_space_read_4(aio-aio_core_bst, aio-aio_ccm_bsh,
-	AWIN_PLL6_CFG_REG);
-
-	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
-		n = ((val  8)  0x1f) + 1;
-		k = ((val  4)  3) + 1;
-		freq = 2400 * n * k / 2;
-#ifdef AWIN_MMC_DEBUG
-		device_printf(sc-sc_dev, n = %d k = %d freq = %u\n,
-		n, k, freq);
-#endif
-	} else {
-		n = (val  8)  0x1f;
-		k = ((val  4)  3) + 1;
-		p = 1  ((val  16)  3);
-		freq = 2400 * n * k / p;
-#ifdef AWIN_MMC_DEBUG
-		device_printf(sc-sc_dev, n = %d k = %d p = %d freq = %u\n,
-		n, k, p, freq);
-#endif
-	}
-
-	sc-sc_pll_freq = freq;
-	div = ((sc-sc_pll_freq + ) / 1) - 1;
-	sc-sc_mod_clk = sc-sc_pll_freq / (div + 1);
-
-	bus_space_write_4(aio-aio_core_bst, aio-aio_ccm_bsh,
-	AWIN_SD0_CLK_REG + (sc-sc_mmc_number * 4),
-	AWIN_PLL_CFG_ENABLE | AWIN_PLL_CFG_PLL6 | div);
-
-	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
-		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
-		AWIN_A31_AHB_RESET0_REG,
-		AWIN_A31_AHB_RESET0_SD0_RST  sc-sc_mmc_number, 0);
-	}
-
-#ifdef AWIN_MMC_DEBUG
-	aprint_normal_dev(sc-sc_dev, PLL6 @ %u Hz\n, freq);
-#endif
-}
-
 static int
 awin_mmc_idma_setup(struct awin_mmc_softc *sc)
 {
@@ -253,7 +203,6 @@ awin_mmc_attach(device_t parent, device_
 	sc-sc_dev = self;
 	sc-sc_bst = aio-aio_core_bst;
 	sc-sc_dmat = aio-aio_dmat;
-	sc-sc_mmc_number = loc-loc_port;
 	mutex_init(sc-sc_intr_lock, MUTEX_DEFAULT, IPL_BIO);
 	cv_init(sc-sc_intr_cv, awinmmcirq);
 	cv_init(sc-sc_idst_cv, awinmmcdma);
@@ -268,7 +217,16 @@ awin_mmc_attach(device_t parent, device_
 	aprint_naive(\n);
 	aprint_normal(: SD3.0 (%s)\n, sc-sc_use_dma ? DMA : PIO);
 
-	awin_mmc_probe_clocks(sc, aio);
+	awin_pll6_enable();
+
+	awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+	AWIN_AHB_GATING0_REG,
+	AWIN_AHB_GATING0_SDMMC0  loc-loc_port, 0);
+	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_A31_AHB_RESET0_REG,
+		AWIN_A31_AHB_RESET0_SD0_RST  loc-loc_port, 0);
+	}
 
 	if (prop_dictionary_get_cstring_nocopy(cfg, detect-gpio, pin_name)) {
 		if (!awin_gpio_pin_reserve(pin_name, sc-sc_gpio_detect)) {
@@ -539,7 +497,9 @@ static int
 awin_mmc_bus_clock(sdmmc_chipset_handle_t sch, int freq)
 {
 	struct awin_mmc_softc *sc = sch;
-	uint32_t odly, sdly, clkcr;
+	uint32_t odly, sdly, clkcr, clksrc, n, m;
+	u_int pll_freq = awin_pll6_get_rate() / 1000;
+	u_int osc24m_freq = AWIN_REF_FREQ / 1000;
 
 #ifdef AWIN_MMC_DEBUG
 	aprint_normal_dev(sc-sc_dev, freq = %d\n, freq);
@@ -547,13 +507,22 @@ awin_mmc_bus_clock(sdmmc_chipset_handle_
 
 	if (freq = 400) {
 		odly = 0;
-		sdly = 7;
+		sdly = awin_chip_id() == AWIN_CHIP_ID_A31 ? 0 : 7;
+		clksrc = AWIN_SD_CLK_SRC_SEL_OSC24M;
+		n = 2;
+		m = ((osc24m_freq / (1  n)) / freq) - 1;
 	} else if (freq = 25000) {
 		odly = 0;
 		sdly = 5;
+		clksrc = AWIN_SD_CLK_SRC_SEL_PLL6;
+		n = 0;
+		m = (pll_freq / freq) - 1;
 	} else if (freq = 5) {
 		odly = 3;
 		sdly = 5;
+		clksrc = AWIN_SD_CLK_SRC_SEL_PLL6;
+		n = 0;
+		m = (pll_freq / freq) - 1;
 	} else {
 		/* UHS speeds not implemented yet */
 		return 1;
@@ 

CVS commit: src/sys/arch/arm/allwinner

2014-11-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 30 19:15:53 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c awin_fb.c awin_reg.h
Added Files:
src/sys/arch/arm/allwinner: awin_mp.c

Log Message:
hardware cursor support


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/allwinner/awin_debe.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/allwinner/awin_fb.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/allwinner/awin_mp.c
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.8 src/sys/arch/arm/allwinner/awin_debe.c:1.9
--- src/sys/arch/arm/allwinner/awin_debe.c:1.8	Fri Nov 14 23:45:02 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Sun Nov 30 19:15:53 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.8 2014/11/14 23:45:02 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.9 2014/11/30 19:15:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -33,8 +33,10 @@
 #define AWIN_DEBE_VIDEOMEM	(16 * 1024 * 1024)
 #endif
 
+#define AWIN_DEBE_CURMAX	64
+
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.8 2014/11/14 23:45:02 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.9 2014/11/30 19:15:53 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -66,6 +68,11 @@ struct awin_debe_softc {
 	void *sc_dmap;
 
 	uint16_t sc_margin;
+
+	int sc_cursor_x, sc_cursor_y;
+	int sc_hot_x, sc_hot_y;
+	uint8_t sc_cursor_bitmap[8 * AWIN_DEBE_CURMAX];
+	uint8_t sc_cursor_mask[8 * AWIN_DEBE_CURMAX];
 };
 
 #define DEBE_READ(sc, reg) \
@@ -80,6 +87,10 @@ static int	awin_debe_alloc_videomem(stru
 static void	awin_debe_setup_fbdev(struct awin_debe_softc *,
   const struct videomode *);
 
+static int	awin_debe_set_curpos(struct awin_debe_softc *, int, int);
+static int	awin_debe_set_cursor(struct awin_debe_softc *,
+ struct wsdisplay_cursor *);
+
 CFATTACH_DECL_NEW(awin_debe, sizeof(struct awin_debe_softc),
 	awin_debe_match, awin_debe_attach, NULL, NULL);
 
@@ -177,6 +188,8 @@ awin_debe_attach(device_t parent, device
 
 	DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, AWIN_DEBE_MODCTL_EN);
 
+	DEBE_WRITE(sc, AWIN_DEBE_HWC_PALETTE_TABLE, 0);
+
 	error = awin_debe_alloc_videomem(sc);
 	if (error) {
 		aprint_error_dev(sc-sc_dev,
@@ -255,6 +268,123 @@ awin_debe_setup_fbdev(struct awin_debe_s
 #endif
 }
 
+static int
+awin_debe_set_curpos(struct awin_debe_softc *sc, int x, int y)
+{
+	int xx, yy;
+	u_int yoff, xoff;
+
+	xoff = yoff = 0;
+	xx = x - sc-sc_hot_x + sc-sc_margin;
+	yy = y - sc-sc_hot_y + sc-sc_margin;
+	if (xx  0) {
+		xoff -= xx;
+		xx = 0;
+	}
+	if (yy  0) {
+		yoff -= yy;
+		yy = 0;
+	}
+
+	DEBE_WRITE(sc, AWIN_DEBE_HWCCTL_REG,
+	__SHIFTIN(yy, AWIN_DEBE_HWCCTL_YCOOR) |
+	__SHIFTIN(xx, AWIN_DEBE_HWCCTL_XCOOR));
+	DEBE_WRITE(sc, AWIN_DEBE_HWCFBCTL_REG,
+#if AWIN_DEBE_CURMAX == 32
+	__SHIFTIN(AWIN_DEBE_HWCFBCTL_YSIZE_32, AWIN_DEBE_HWCFBCTL_YSIZE) |
+	__SHIFTIN(AWIN_DEBE_HWCFBCTL_XSIZE_32, AWIN_DEBE_HWCFBCTL_XSIZE) |
+#else
+	__SHIFTIN(AWIN_DEBE_HWCFBCTL_YSIZE_64, AWIN_DEBE_HWCFBCTL_YSIZE) |
+	__SHIFTIN(AWIN_DEBE_HWCFBCTL_XSIZE_64, AWIN_DEBE_HWCFBCTL_XSIZE) |
+#endif
+	__SHIFTIN(AWIN_DEBE_HWCFBCTL_FBFMT_2BPP, AWIN_DEBE_HWCFBCTL_FBFMT) |
+	__SHIFTIN(yoff, AWIN_DEBE_HWCFBCTL_YCOOROFF) |
+	__SHIFTIN(xoff, AWIN_DEBE_HWCFBCTL_XCOOROFF));
+
+	return 0;
+}
+
+static int
+awin_debe_set_cursor(struct awin_debe_softc *sc, struct wsdisplay_cursor *cur)
+{
+	uint32_t val;
+	uint8_t r[4], g[4], b[4];
+	u_int index, count, shift, off, pcnt;
+	int i, j, idx, error;
+	uint8_t mask;
+
+	if (cur-which  WSDISPLAY_CURSOR_DOCUR) {
+		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
+		if (cur-enable)
+			val |= AWIN_DEBE_MODCTL_HWC_EN;
+		else
+			val = ~AWIN_DEBE_MODCTL_HWC_EN;
+		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
+	}
+
+	if (cur-which  WSDISPLAY_CURSOR_DOHOT) {
+		sc-sc_hot_x = cur-hot.x;
+		sc-sc_hot_y = cur-hot.y;
+		cur-which |= WSDISPLAY_CURSOR_DOPOS;
+	}
+
+	if (cur-which  WSDISPLAY_CURSOR_DOPOS) {
+		awin_debe_set_curpos(sc, cur-pos.x, cur-pos.y);
+	}
+
+	if (cur-which  WSDISPLAY_CURSOR_DOCMAP) {
+		index = cur-cmap.index;
+		count = cur-cmap.count;
+		if (index = 2 || (index + count)  2)
+			return EINVAL;
+		error = copyin(cur-cmap.red, r[index], count);
+		if (error)
+			return error;
+		error = copyin(cur-cmap.green, g[index], count);
+		if (error)
+			return error;
+		error = copyin(cur-cmap.blue, b[index], count);
+		if (error)
+			return error;
+
+		for (i = index; i  (index + count); i++) {
+			DEBE_WRITE(sc,
+			AWIN_DEBE_HWC_PALETTE_TABLE + (4 * (i + 2)),
+			(r[i]  16) | (g[i]  8) | b[i] | 0xff00);
+		}
+	}
+
+	if (cur-which  WSDISPLAY_CURSOR_DOSHAPE) {
+		error = copyin(cur-mask, sc-sc_cursor_mask,
+		 

CVS commit: src/sys/arch/arm/allwinner

2014-11-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 30 20:04:57 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c

Log Message:
hide the hw cursor when blanking the screen


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/allwinner/awin_debe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.9 src/sys/arch/arm/allwinner/awin_debe.c:1.10
--- src/sys/arch/arm/allwinner/awin_debe.c:1.9	Sun Nov 30 19:15:53 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Sun Nov 30 20:04:57 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.9 2014/11/30 19:15:53 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.10 2014/11/30 20:04:57 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -36,7 +36,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.9 2014/11/30 19:15:53 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.10 2014/11/30 20:04:57 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -69,6 +69,7 @@ struct awin_debe_softc {
 
 	uint16_t sc_margin;
 
+	bool sc_cursor_enable;
 	int sc_cursor_x, sc_cursor_y;
 	int sc_hot_x, sc_hot_y;
 	uint8_t sc_cursor_bitmap[8 * AWIN_DEBE_CURMAX];
@@ -320,6 +321,8 @@ awin_debe_set_cursor(struct awin_debe_so
 		else
 			val = ~AWIN_DEBE_MODCTL_HWC_EN;
 		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
+
+		sc-sc_cursor_enable = cur-enable;
 	}
 
 	if (cur-which  WSDISPLAY_CURSOR_DOHOT) {
@@ -504,10 +507,17 @@ awin_debe_ioctl(device_t self, u_long cm
 	case WSDISPLAYIO_SVIDEO:
 		enable = *(int *)data;
 		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
-		if (enable)
+		if (enable) {
 			val |= AWIN_DEBE_MODCTL_LAY0_EN;
-		else
+			if (sc-sc_cursor_enable) {
+val |= AWIN_DEBE_MODCTL_HWC_EN;
+			} else {
+val = ~AWIN_DEBE_MODCTL_HWC_EN;
+			}
+		} else {
 			val = ~AWIN_DEBE_MODCTL_LAY0_EN;
+			val = ~AWIN_DEBE_MODCTL_HWC_EN;
+		}
 		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
 		return 0;
 	case WSDISPLAYIO_GVIDEO:



CVS commit: src/sys/arch/arm/allwinner

2014-11-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 30 20:25:54 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_fb.c

Log Message:
make the full amount of reserved video memory available to userland


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/allwinner/awin_fb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_fb.c
diff -u src/sys/arch/arm/allwinner/awin_fb.c:1.7 src/sys/arch/arm/allwinner/awin_fb.c:1.8
--- src/sys/arch/arm/allwinner/awin_fb.c:1.7	Sun Nov 30 19:15:53 2014
+++ src/sys/arch/arm/allwinner/awin_fb.c	Sun Nov 30 20:25:54 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_fb.c,v 1.7 2014/11/30 19:15:53 jmcneill Exp $ */
+/* $NetBSD: awin_fb.c,v 1.8 2014/11/30 20:25:54 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.7 2014/11/30 19:15:53 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.8 2014/11/30 20:25:54 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -143,8 +143,10 @@ awin_fb_ioctl(void *v, void *vs, u_long 
 		fbi = data;
 		ri = sc-sc_gen.vd.active-scr_ri;
 		error = wsdisplayio_get_fbinfo(ri, fbi);
-		if (error == 0)
+		if (error == 0) {
 			fbi-fbi_flags |= WSFB_VRAM_IS_RAM;
+			fbi-fbi_fbsize = sc-sc_dmasegs[0].ds_len;
+		}
 		return error;
 	case WSDISPLAYIO_SVIDEO:
 	case WSDISPLAYIO_GVIDEO:
@@ -163,7 +165,7 @@ awin_fb_mmap(void *v, void *vs, off_t of
 {
 	struct awin_fb_softc *sc = v;
 
-	if (off  0 || off = sc-sc_gen.sc_fbsize)
+	if (off  0 || off = sc-sc_dmasegs[0].ds_len)
 		return -1;
 
 	return bus_dmamem_mmap(sc-sc_dmat, sc-sc_dmasegs, sc-sc_ndmasegs,



CVS commit: src/sys/arch/arm/allwinner

2014-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 28 15:29:48 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
add mixer processor regs


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.54 src/sys/arch/arm/allwinner/awin_reg.h:1.55
--- src/sys/arch/arm/allwinner/awin_reg.h:1.54	Tue Nov 25 00:06:32 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Fri Nov 28 15:29:48 2014
@@ -2002,6 +2002,220 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_HDMI_DDC_CLOCK_M		__BITS(6,3)
 #define AWIN_HDMI_DDC_CLOCK_N		__BITS(2,0)
 
+/* Mixer processor */
+#define AWIN_MP_CTL_REG0x
+#define AWIN_MP_STS_REG0x0004
+#define AWIN_MP_IDMAGBLCTL_REG			0x0008
+#define AWIN_MP_IDMA_H4ADD_REG			0x000C
+#define AWIN_MP_IDMA_L32ADD_REG(n)		(0x0010 + ((n) * 4))
+#define AWIN_MP_IDMALINEWIDTH_REG(n)		(0x0020 + ((n) * 4))
+#define AWIN_MP_IDMASIZE_REG(n)			(0x0030 + ((n) * 4))
+#define AWIN_MP_IDMACOOR_REG(n)			(0x0040 + ((n) * 4))
+#define AWIN_MP_IDMASET_REG(n)			(0x0050 + ((n) * 4))
+#define AWIN_MP_IDMAFILLCOLOR_REG(n)		(0x0060 + ((n) * 4))
+#define AWIN_MP_CSC0CTL_REG			0x0074
+#define AWIN_MP_CSC1CTL_REG			0x0078
+#define AWIN_MP_SCACTL_REG			0x0080
+#define AWIN_MP_SCAOUTSIZE_REG			0x0084
+#define AWIN_MP_SCAHORFCT_REG			0x0088
+#define AWIN_MP_SCAVERFCT_REG			0x008c
+#define AWIN_MP_SCAHORPHASE_REG			0x0090
+#define AWIN_MP_SCAVERPHASE_REG			0x0094
+#define AWIN_MP_ROPCTL_REG			0x00b0
+#define AWIN_MP_ROPIDX0CTL_REG			0x00b8
+#define AWIN_MP_ROPIDX1CTL_REG			0x00bc
+#define AWIN_MP_ALPHACKCTL_REG			0x00c0
+#define AWIN_MP_CKMIN_REG			0x00c4
+#define AWIN_MP_CKMAX_REG			0x00c8
+#define AWIN_MP_ROPOUTFILLCOLOR_REG		0x00cc
+#define AWIN_MP_CSC2CTL_REG			0x00d0
+#define AWIN_MP_OUTCTL_REG			0x00e0
+#define AWIN_MP_OUTSIZE_REG			0x00e8
+#define AWIN_MP_OUTH4ADD_REG			0x00ec
+#define AWIN_MP_OUTL32ADD_REG(n)		(0x00f0 + ((n) * 4))
+#define AWIN_MP_OUTLINEWIDTH_REG(n)		(0x0100 + ((n) * 4))
+#define AWIN_MP_OUTALPHACTL_REG			0x0120
+#define AWIN_MP_MBCTL_REG(n)			(0x0130 + ((n) * 4))
+#define AWIN_MP_CMDQUECTL_REG			0x0140
+#define AWIN_MP_CMDQUESTS_REG			0x0144
+#define AWIN_MP_CMDQUEADD_REG			0x0148
+#define AWIN_MP_ICSCYGCOEF_REG(n)		(0x0180 + ((n) * 4))
+#define AWIN_MP_ICSCYGCONS_REG			0x018c
+#define AWIN_MP_ICSCCURCOEF_REG(n)		(0x0190 + ((n) * 4))
+#define AWIN_MP_ICSCCURCONS_REG			0x019c
+#define AWIN_MP_ICSCVBCOEF_REG(n)		(0x01a0 + ((n) * 4))
+#define AWIN_MP_ICSCVBCONS_REG			0x01ac
+#define AWIN_MP_OCSCYGCOEF_REG(n)		(0x01c0 + ((n) * 4))
+#define AWIN_MP_OCSCYGCONS_REG			0x01cc
+#define AWIN_MP_OCSCCURCOEF_REG(n)		(0x01d0 + ((n) * 4))
+#define AWIN_MP_OCSCCURCONS_REG			0x01dc
+#define AWIN_MP_OCSCVBCOEF_REG(n)		(0x01e0 + ((n) * 4))
+#define AWIN_MP_OCSCVBCONS_REG			0x01ec
+#define AWIN_MP_SCAL_HORIZ_FILT_BLOCK		0x0200
+#define AWIN_MP_SCAL_VERT_FILT_BLOCK		0x0280
+#define AWIN_MP_PALETTE_TABLE			0x0400
+
+#define AWIN_MP_CTL_HWERRIRQ_EN			__BIT(9)
+#define AWIN_MP_CTL_FINISHIRQ_EN		__BIT(8)
+#define AWIN_MP_CTL_START_CTL			__BIT(1)
+#define AWIN_MP_CTL_MP_EN			__BIT(0)
+
+#define AWIN_MP_STS_HWERR_FLAG			__BIT(13)
+#define AWIN_MP_STS_BUSY_FLAG			__BIT(12)
+#define AWIN_MP_STS_HWERRIRQ_FLAG		__BIT(9)
+#define AWIN_MP_STS_FINISHIRQ_FLAG		__BIT(8)
+
+#define AWIN_MP_IDMAGLBCTL_MEMSCANORDER		__BITS(9,8)
+#define AWIN_MP_IDMAGLBCTL_MEMSCANORDER_TD_LR	0
+#define AWIN_MP_IDMAGLBCTL_MEMSCANORDER_TD_RL	1
+#define AWIN_MP_IDMAGLBCTL_MEMSCANORDER_DT_LR	2
+#define AWIN_MP_IDMAGLBCTL_MEMSCANORDER_DT_RL	3
+
+#define AWIN_MP_IDMA_H4ADD_IDMA3_H4ADD		__BITS(27,24)
+#define AWIN_MP_IDMA_H4ADD_IDMA2_H4ADD		__BITS(19,16)
+#define AWIN_MP_IDMA_H4ADD_IDMA1_H4ADD		__BITS(11,8)
+#define AWIN_MP_IDMA_H4ADD_IDMA0_H4ADD		__BITS(3,0)
+
+#define AWIN_MP_IDMASIZE_HEIGHT			__BITS(28,16)
+#define AWIN_MP_IDMASIZE_WIDTH			__BITS(12,0)
+
+#define AWIN_MP_IDMACOOR_YCOOR			__BITS(31,16)
+#define AWIN_MP_IDMACOOR_XCOOR			__BITS(15,0)
+
+#define AWIN_MP_IDMASET_IDMA_GLBALPHA		__BITS(31,24)
+#define AWIN_MP_IDMASET_MBFMT			__BIT(22)
+#define AWIN_MP_IDMASET_MBSIZE			__BITS(21,20)
+#define AWIN_MP_IDMASET_MBSIZE_16X16		0
+#define AWIN_MP_IDMASET_MBSIZE_32X32		1
+#define AWIN_MP_IDMASET_MBSIZE_64X64		2
+#define AWIN_MP_IDMASET_MBSIZE_128X128		3
+#define AWIN_MP_IDMASET_IDMA_FCMODEN		__BIT(16)
+#define AWIN_MP_IDMASET_IDMA_PS			__BITS(15,12)
+#define AWIN_MP_IDMASET_IDMA_FMT		__BITS(11,8)
+#define AWIN_MP_IDMASET_IDMA_FMT_ARGB888	0
+#define AWIN_MP_IDMASET_IDMA_FMT_ARGB444	1
+#define AWIN_MP_IDMASET_IDMA_FMT_ARGB155	2
+#define AWIN_MP_IDMASET_IDMA_FMT_RGB565		3
+#define AWIN_MP_IDMASET_IDMA_FMT_IYUV422	4
+#define AWIN_MP_IDMASET_IDMA_FMT_UV88		5
+#define AWIN_MP_IDMASET_IDMA_FMT_Y8		6
+#define AWIN_MP_IDMASET_IDMA_FMT_8BPP_MP	7

CVS commit: src/sys/arch/arm/allwinner

2014-11-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 25 00:06:32 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h awin_wdt.c

Log Message:
- Write the correct value to the ctrl register to restart the watchdog.
  Watchdog restart bit is 0 not 1, and we need to write a key as well.
- Add A31 support.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/allwinner/awin_wdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.53 src/sys/arch/arm/allwinner/awin_reg.h:1.54
--- src/sys/arch/arm/allwinner/awin_reg.h:1.53	Sun Nov 23 13:39:58 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Tue Nov 25 00:06:32 2014
@@ -1503,7 +1503,9 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_CNT64_CTRL_RL_ENABLE	__BIT(1)
 #define AWIN_CNT64_CTRL_CLR_ENABLE	__BIT(0)
 
-#define AWIN_WDOG_CTRL_RSTART		__BIT(1)
+#define AWIN_WDOG_CTRL_KEY		__BITS(12,1)
+#define AWIN_WDOG_CTRL_KEY_MAGIC	0xa57
+#define AWIN_WDOG_CTRL_RSTART		__BIT(0)
 #define AWIN_WDOG_MODE_INTV		__BITS(6,3)
 #define AWIN_WDOG_MODE_INTV_HALFSEC	0
 #define AWIN_WDOG_MODE_INTV_1SEC	1
@@ -2161,6 +2163,7 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_A31_WDOG_CFG_CONFIG_INT		2
 
 #define AWIN_A31_WDOG_MODE_EN			__BIT(0)
+#define AWIN_A31_WDOG_MODE_INTV			__BITS(7,4)
 
 #define AWIN_A31_MMC_FIFO			0x0200
 

Index: src/sys/arch/arm/allwinner/awin_wdt.c
diff -u src/sys/arch/arm/allwinner/awin_wdt.c:1.4 src/sys/arch/arm/allwinner/awin_wdt.c:1.5
--- src/sys/arch/arm/allwinner/awin_wdt.c:1.4	Fri Oct 10 07:36:11 2014
+++ src/sys/arch/arm/allwinner/awin_wdt.c	Tue Nov 25 00:06:32 2014
@@ -33,7 +33,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_wdt.c,v 1.4 2014/10/10 07:36:11 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_wdt.c,v 1.5 2014/11/25 00:06:32 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -78,6 +78,26 @@ static const uint8_t period_map[] = {
 	[16] = __SHIFTIN(AWIN_WDOG_MODE_INTV_16SEC, AWIN_WDOG_MODE_INTV),
 };
 
+static const uint8_t period_map_a31[] = {
+	[0] = __SHIFTIN(AWIN_WDOG_MODE_INTV_1SEC, AWIN_A31_WDOG_MODE_INTV),
+	[1] = __SHIFTIN(AWIN_WDOG_MODE_INTV_1SEC, AWIN_A31_WDOG_MODE_INTV),
+	[2] = __SHIFTIN(AWIN_WDOG_MODE_INTV_2SEC, AWIN_A31_WDOG_MODE_INTV),
+	[3] = __SHIFTIN(AWIN_WDOG_MODE_INTV_3SEC, AWIN_A31_WDOG_MODE_INTV),
+	[4] = __SHIFTIN(AWIN_WDOG_MODE_INTV_4SEC, AWIN_A31_WDOG_MODE_INTV),
+	[5] = __SHIFTIN(AWIN_WDOG_MODE_INTV_5SEC, AWIN_A31_WDOG_MODE_INTV),
+	[6] = __SHIFTIN(AWIN_WDOG_MODE_INTV_6SEC, AWIN_A31_WDOG_MODE_INTV),
+	[7] = __SHIFTIN(AWIN_WDOG_MODE_INTV_8SEC, AWIN_A31_WDOG_MODE_INTV),
+	[8] = __SHIFTIN(AWIN_WDOG_MODE_INTV_8SEC, AWIN_A31_WDOG_MODE_INTV),
+	[9] = __SHIFTIN(AWIN_WDOG_MODE_INTV_10SEC, AWIN_A31_WDOG_MODE_INTV),
+	[10] = __SHIFTIN(AWIN_WDOG_MODE_INTV_10SEC, AWIN_A31_WDOG_MODE_INTV),
+	[11] = __SHIFTIN(AWIN_WDOG_MODE_INTV_12SEC, AWIN_A31_WDOG_MODE_INTV),
+	[12] = __SHIFTIN(AWIN_WDOG_MODE_INTV_12SEC, AWIN_A31_WDOG_MODE_INTV),
+	[13] = __SHIFTIN(AWIN_WDOG_MODE_INTV_14SEC, AWIN_A31_WDOG_MODE_INTV),
+	[14] = __SHIFTIN(AWIN_WDOG_MODE_INTV_14SEC, AWIN_A31_WDOG_MODE_INTV),
+	[15] = __SHIFTIN(AWIN_WDOG_MODE_INTV_16SEC, AWIN_A31_WDOG_MODE_INTV),
+	[16] = __SHIFTIN(AWIN_WDOG_MODE_INTV_16SEC, AWIN_A31_WDOG_MODE_INTV),
+};
+
 static struct awin_wdt_softc {
 	device_t sc_dev;
 	bus_space_tag_t sc_bst;
@@ -86,6 +106,8 @@ static struct awin_wdt_softc {
 u_int sc_wdog_period;
 bool sc_wdog_armed;
 	uint32_t sc_wdog_mode;
+	bus_size_t sc_ctrl_reg;
+	bus_size_t sc_mode_reg;
 } awin_wdt_sc = {
 	.sc_bst = awin_bs_tag,
 	.sc_wdog_period = AWIN_WDT_PERIOD_DEFAULT,
@@ -95,8 +117,11 @@ static int
 awin_wdt_tickle(struct sysmon_wdog *smw)
 {
 	struct awin_wdt_softc * const sc = smw-smw_cookie;
-	bus_space_write_4(sc-sc_bst, sc-sc_bsh, AWIN_WDOG_CTRL_REG,
+
+	bus_space_write_4(sc-sc_bst, sc-sc_bsh, sc-sc_ctrl_reg,
+	__SHIFTIN(AWIN_WDOG_CTRL_KEY_MAGIC, AWIN_WDOG_CTRL_KEY) |
 	AWIN_WDOG_CTRL_RSTART);
+
 	return 0;
 }
 
@@ -104,6 +129,16 @@ static int
 awin_wdt_setmode(struct sysmon_wdog *smw)
 {
 	struct awin_wdt_softc * const sc = smw-smw_cookie;
+	const uint8_t *map;
+	size_t mapsize;
+
+	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+		map = period_map_a31;
+		mapsize = __arraycount(period_map_a31);
+	} else {
+		map = period_map;
+		mapsize = __arraycount(period_map);
+	}
 
 	if ((smw-smw_mode  WDOG_MODE_MASK) == WDOG_MODE_DISARMED) {
 		/*
@@ -113,26 +148,39 @@ awin_wdt_setmode(struct sysmon_wdog *smw
 	}
 
 	if (sc-sc_wdog_armed  smw-smw_period == sc-sc_wdog_period) {
-		bus_space_write_4(sc-sc_bst, sc-sc_bsh, AWIN_WDOG_MODE_REG,
+		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+			bus_space_write_4(sc-sc_bst, sc-sc_bsh,
+			AWIN_A31_WDOG1_CFG_REG,
+			__SHIFTIN(AWIN_A31_WDOG_CFG_CONFIG_SYS,
+

CVS commit: src/sys/arch/arm/allwinner

2014-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 23 13:39:58 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h awin_twi.c

Log Message:
Don't assume that U-Boot has enabled the TWI clock. Also, for A31, set
the iflg-rwc device property for gttwsi.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/allwinner/awin_twi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.52 src/sys/arch/arm/allwinner/awin_reg.h:1.53
--- src/sys/arch/arm/allwinner/awin_reg.h:1.52	Sat Nov 15 20:04:07 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sun Nov 23 13:39:58 2014
@@ -2039,6 +2039,7 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_A31_AHB_RESET1_REG		0x02C4
 #define AWIN_A31_AHB_RESET2_REG		0x02C8
 #define AWIN_A31_APB1_RESET_REG		0x02D0
+#define AWIN_A31_APB2_RESET_REG		0x02D8
 
 #define AWIN_A31_PRCM_APB0_GATING_CIR	__BIT(1)
 
@@ -2144,6 +2145,11 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_A31_APB1_RESET_DIGITAL_MIC_RST	__BIT(4)
 #define AWIN_A31_APB1_RESET_CODEC_RST		__BIT(0)
 
+#define AWIN_A31_APB2_RESET_TWI3_RST		__BIT(3)
+#define AWIN_A31_APB2_RESET_TWI2_RST		__BIT(2)
+#define AWIN_A31_APB2_RESET_TWI1_RST		__BIT(1)
+#define AWIN_A31_APB2_RESET_TWI0_RST		__BIT(0)
+
 #define AWIN_A31_WDOG1_IRQ_EN_REG		0x00A0
 #define AWIN_A31_WDOG1_IRQ_STA_REG		0x00A4
 #define AWIN_A31_WDOG1_CTRL_REG			0x00B0

Index: src/sys/arch/arm/allwinner/awin_twi.c
diff -u src/sys/arch/arm/allwinner/awin_twi.c:1.4 src/sys/arch/arm/allwinner/awin_twi.c:1.5
--- src/sys/arch/arm/allwinner/awin_twi.c:1.4	Sun Oct 12 14:06:18 2014
+++ src/sys/arch/arm/allwinner/awin_twi.c	Sun Nov 23 13:39:58 2014
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_twi.c,v 1.4 2014/10/12 14:06:18 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_twi.c,v 1.5 2014/11/23 13:39:58 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -45,6 +45,10 @@ __KERNEL_RCSID(1, $NetBSD: awin_twi.c,v
 #include arm/allwinner/awin_reg.h
 #include arm/allwinner/awin_var.h
 
+#define TWI_CCR_REG	0x14
+#define TWI_CCR_CLK_M	__BITS(6,3)
+#define TWI_CCR_CLK_N	__BITS(2,0)
+
 static int awin_twi_match(device_t, cfdata_t, void *);
 static void awin_twi_attach(device_t, device_t, void *);
 
@@ -109,12 +113,14 @@ awin_twi_attach(device_t parent, device_
 	struct awin_twi_softc * const asc = device_private(self);
 	struct awinio_attach_args * const aio = aux;
 	const struct awin_locators * const loc = aio-aio_loc;
+	prop_dictionary_t cfg = device_properties(self);
 	bus_space_handle_t bsh;
+	uint32_t ccr;
 
 	awin_twi_ports |= __BIT(loc-loc_port);
 
 	/*
-	 * Acquite the PIO pins needed for the TWI port.
+	 * Acquire the PIO pins needed for the TWI port.
 	 */
 	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 		awin_gpio_pinset_acquire(awin_twi_pinsets_a31[loc-loc_port]);
@@ -123,12 +129,38 @@ awin_twi_attach(device_t parent, device_
 	}
 
 	/*
+	 * Clock gating, soft reset
+	 */
+	awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+	AWIN_APB1_GATING_REG, AWIN_APB_GATING1_TWI0  loc-loc_port, 0);
+	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_A31_APB2_RESET_REG,
+		AWIN_A31_APB2_RESET_TWI0_RST  loc-loc_port, 0);
+	}
+
+	/*
 	 * Get a bus space handle for this TWI port.
 	 */
 	bus_space_subregion(aio-aio_core_bst, aio-aio_core_bsh,
 	loc-loc_offset, loc-loc_size, bsh);
 
 	/*
+	 * A31 specific quirk
+	 */
+	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+		prop_dictionary_set_bool(cfg, iflg-rwc, true);
+	}
+
+	/*
+	 * Set clock rate to 100kHz. From the datasheet:
+	 *   For 100Khz standard speed 2Wire, CLK_N=2, CLK_M=11
+	 *   F0=48M/2^2=12Mhz, F1=F0/(10*(11+1)) = 0.1Mhz
+	 */
+	ccr = __SHIFTIN(11, TWI_CCR_CLK_M) | __SHIFTIN(2, TWI_CCR_CLK_N);
+	bus_space_write_4(aio-aio_core_bst, bsh, TWI_CCR_REG, ccr);
+
+	/*
 	 * Do the MI attach
 	 */
 	gttwsi_attach_subr(self, aio-aio_core_bst, bsh);



CVS commit: src/sys/arch/arm/allwinner

2014-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 23 23:04:58 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_gpio.c awin_var.h

Log Message:
Let pinsets override the default multi-driving select level.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/allwinner/awin_gpio.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/allwinner/awin_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_gpio.c
diff -u src/sys/arch/arm/allwinner/awin_gpio.c:1.13 src/sys/arch/arm/allwinner/awin_gpio.c:1.14
--- src/sys/arch/arm/allwinner/awin_gpio.c:1.13	Sun Nov  2 23:54:16 2014
+++ src/sys/arch/arm/allwinner/awin_gpio.c	Sun Nov 23 23:04:58 2014
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_gpio.c,v 1.13 2014/11/02 23:54:16 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_gpio.c,v 1.14 2014/11/23 23:04:58 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -384,6 +384,16 @@ awin_gpio_set_pin_pull(struct awin_gpio_
 }
 
 static void
+awin_gpio_set_pin_drv(struct awin_gpio_pin_cfg *cfg, u_int pin, u_int drv)
+{
+	const u_int shift = (pin  15)  1;
+	const u_int i = (pin  4)  1;
+	
+	cfg-drv[i] = ~(0x03  shift);
+	cfg-drv[i] |= drv  shift;
+}
+
+static void
 awin_gpio_update_cfg_regs(bus_space_tag_t bst, struct awin_gpio_pin_group *grp,
 const struct awin_gpio_pin_cfg *ncfg)
 {
@@ -577,6 +587,9 @@ awin_gpio_pinset_acquire(const struct aw
 			awin_gpio_set_pin_pull(ncfg, j, AWIN_PIO_PULL_DOWN);
 		else if (req-pinset_flags  GPIO_PIN_PULLUP)
 			awin_gpio_set_pin_pull(ncfg, j, AWIN_PIO_PULL_UP);
+
+		if (req-pinset_drv)
+			awin_gpio_set_pin_drv(ncfg, j, req-pinset_drv);
 	}
 
 	/*

Index: src/sys/arch/arm/allwinner/awin_var.h
diff -u src/sys/arch/arm/allwinner/awin_var.h:1.25 src/sys/arch/arm/allwinner/awin_var.h:1.26
--- src/sys/arch/arm/allwinner/awin_var.h:1.25	Mon Nov 17 01:38:00 2014
+++ src/sys/arch/arm/allwinner/awin_var.h	Sun Nov 23 23:04:58 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_var.h,v 1.25 2014/11/17 01:38:00 jmcneill Exp $ */
+/* $NetBSD: awin_var.h,v 1.26 2014/11/23 23:04:58 jmcneill Exp $ */
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -76,6 +76,7 @@ struct awin_gpio_pinset {
 	uint8_t pinset_func;
 	uint32_t pinset_mask;
 	int pinset_flags;
+	int pinset_drv;
 };
 
 struct awin_gpio_pindata {



CVS commit: src/sys/arch/arm/allwinner

2014-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 23 23:05:19 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_gige.c

Log Message:
Set GMAC pin drv level 3 on A31


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/allwinner/awin_gige.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_gige.c
diff -u src/sys/arch/arm/allwinner/awin_gige.c:1.18 src/sys/arch/arm/allwinner/awin_gige.c:1.19
--- src/sys/arch/arm/allwinner/awin_gige.c:1.18	Fri Nov  7 11:42:28 2014
+++ src/sys/arch/arm/allwinner/awin_gige.c	Sun Nov 23 23:05:19 2014
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_gige.c,v 1.18 2014/11/07 11:42:28 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_gige.c,v 1.19 2014/11/23 23:05:19 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -66,7 +66,7 @@ static const struct awin_gpio_pinset awi
 };
 
 static const struct awin_gpio_pinset awin_gige_gpio_pinset_a31 = {
-	'A', AWIN_A31_PIO_PA_GMAC_FUNC, AWIN_A31_PIO_PA_GMAC_PINS,
+	'A', AWIN_A31_PIO_PA_GMAC_FUNC, AWIN_A31_PIO_PA_GMAC_PINS, 0, 3
 };
 
 



CVS commit: src/sys/arch/arm/allwinner

2014-11-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Nov 17 08:48:59 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_cnt.c

Log Message:
s/IPL_SCHED/IPL_HIGH/

This allows binuptime to be called from any interrupt handler.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/allwinner/awin_cnt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_cnt.c
diff -u src/sys/arch/arm/allwinner/awin_cnt.c:1.1 src/sys/arch/arm/allwinner/awin_cnt.c:1.2
--- src/sys/arch/arm/allwinner/awin_cnt.c:1.1	Wed Nov  5 15:05:20 2014
+++ src/sys/arch/arm/allwinner/awin_cnt.c	Mon Nov 17 08:48:59 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_cnt.c,v 1.1 2014/11/05 15:05:20 jmcneill Exp $ */
+/* $NetBSD: awin_cnt.c,v 1.2 2014/11/17 08:48:59 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include opt_multiprocessor.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_cnt.c,v 1.1 2014/11/05 15:05:20 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_cnt.c,v 1.2 2014/11/17 08:48:59 skrll Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -84,7 +84,7 @@ awin_cnt_attach(device_t parent, device_
 
 	sc-sc_dev = self;
 	sc-sc_bst = aio-aio_core_bst;
-	mutex_init(sc-sc_lock, MUTEX_DEFAULT, IPL_SCHED);
+	mutex_init(sc-sc_lock, MUTEX_DEFAULT, IPL_HIGH);
 	bus_space_subregion(sc-sc_bst, aio-aio_core_bsh,
 	loc-loc_offset, loc-loc_size, sc-sc_bsh);
 



CVS commit: src/sys/arch/arm/allwinner

2014-11-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Nov 17 10:00:14 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmi.c

Log Message:
clear repeater sel bits before setting -- would cause an issue if we ever 
switched away from a pixel doubling mode


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/allwinner/awin_hdmi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.14 src/sys/arch/arm/allwinner/awin_hdmi.c:1.15
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.14	Mon Nov 17 01:38:00 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Mon Nov 17 10:00:14 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.14 2014/11/17 01:38:00 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.15 2014/11/17 10:00:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -32,7 +32,7 @@
 #define AWIN_HDMI_PLL	3	/* PLL7 or PLL3 */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.14 2014/11/17 01:38:00 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.15 2014/11/17 10:00:14 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -737,11 +737,12 @@ awin_hdmi_set_videomode(struct awin_hdmi
 		val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_HDMI_MODE_HDMI,
  AWIN_HDMI_VID_CTRL_HDMI_MODE);
 	}
-	val = ~AWIN_HDMI_VID_CTRL_OUTPUT_FMT;
+	val = ~AWIN_HDMI_VID_CTRL_REPEATER_SEL;
 	if (dblscan_p) {
 		val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_REPEATER_SEL_2X,
  AWIN_HDMI_VID_CTRL_REPEATER_SEL);
 	}
+	val = ~AWIN_HDMI_VID_CTRL_OUTPUT_FMT;
 	if (interlace_p) {
 		val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_OUTPUT_FMT_INTERLACE,
  AWIN_HDMI_VID_CTRL_OUTPUT_FMT);



CVS commit: src/sys/arch/arm/allwinner

2014-11-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 18 01:53:53 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmiaudio.c files.awin

Log Message:
add software volume controls


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/allwinner/awin_hdmiaudio.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmiaudio.c
diff -u src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.4 src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.5
--- src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.4	Mon Nov 17 01:38:00 2014
+++ src/sys/arch/arm/allwinner/awin_hdmiaudio.c	Tue Nov 18 01:53:53 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmiaudio.c,v 1.4 2014/11/17 01:38:00 jmcneill Exp $ */
+/* $NetBSD: awin_hdmiaudio.c,v 1.5 2014/11/18 01:53:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmiaudio.c,v 1.4 2014/11/17 01:38:00 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmiaudio.c,v 1.5 2014/11/18 01:53:53 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -39,6 +39,7 @@ __KERNEL_RCSID(0, $NetBSD: awin_hdmiaud
 #include sys/audioio.h
 #include dev/audio_if.h
 #include dev/auconv.h
+#include dev/auvolconv.h
 
 #include arm/allwinner/awin_reg.h
 #include arm/allwinner/awin_var.h
@@ -73,7 +74,6 @@ struct awin_hdmiaudio_softc {
 	struct audio_format	sc_format;
 	struct audio_encoding_set *sc_encodings;
 
-	audio_params_t		sc_pparam;
 	struct awin_dma_channel *sc_pdma;
 	void			(*sc_pint)(void *);
 	void			*sc_pintarg;
@@ -81,6 +81,8 @@ struct awin_hdmiaudio_softc {
 	bus_addr_t		sc_pend;
 	bus_addr_t		sc_pcur;
 	int			sc_pblksize;
+
+	uint8_t			sc_swvol;
 };
 
 static int	awin_hdmiaudio_match(device_t, cfdata_t, void *);
@@ -129,6 +131,10 @@ static int	awin_hdmiaudio_trigger_input(
 	 const audio_params_t *);
 static void	awin_hdmiaudio_get_locks(void *, kmutex_t **, kmutex_t **);
 
+static stream_filter_t *awin_hdmiaudio_swvol_filter(struct audio_softc *,
+const audio_params_t *, const audio_params_t *);
+static void	awin_hdmiaudio_swvol_dtor(stream_filter_t *);
+
 static const struct audio_hw_if awin_hdmiaudio_hw_if = {
 	.open = awin_hdmiaudio_open,
 	.close = awin_hdmiaudio_close,
@@ -235,6 +241,8 @@ awin_hdmiaudio_attach(device_t parent, d
 		return;
 	}
 
+	sc-sc_swvol = 255;
+
 	awin_hdmiaudio_rescan(self, NULL, NULL);
 }
 
@@ -385,9 +393,9 @@ awin_hdmiaudio_set_params(void *priv, in
 		AUMODE_PLAY, play, true, pfil);
 		if (index  0)
 			return EINVAL;
-		sc-sc_pparam = pfil-req_size  0 ?
-		pfil-filters[0].param :
-		*play;
+		if (pfil-req_size  0)
+			play = pfil-filters[0].param;
+		pfil-prepend(pfil, awin_hdmiaudio_swvol_filter, play);
 	}
 
 	return 0;
@@ -415,9 +423,12 @@ awin_hdmiaudio_halt_input(void *priv)
 static int
 awin_hdmiaudio_set_port(void *priv, mixer_ctrl_t *mc)
 {
+	struct awin_hdmiaudio_softc *sc = priv;
+
 	switch (mc-dev) {
 	case HDMIAUDIO_OUTPUT_MASTER_VOLUME:
 	case HDMIAUDIO_INPUT_DHDMIAUDIO_VOLUME:
+		sc-sc_swvol = mc-un.value.level[AUDIO_MIXER_LEVEL_MONO];
 		return 0;
 	}
 
@@ -427,11 +438,14 @@ awin_hdmiaudio_set_port(void *priv, mixe
 static int
 awin_hdmiaudio_get_port(void *priv, mixer_ctrl_t *mc)
 {
+	struct awin_hdmiaudio_softc *sc = priv;
+	uint8_t vol = sc-sc_swvol;
+
 	switch (mc-dev) {
 	case HDMIAUDIO_OUTPUT_MASTER_VOLUME:
 	case HDMIAUDIO_INPUT_DHDMIAUDIO_VOLUME:
-		mc-un.value.level[AUDIO_MIXER_LEVEL_LEFT] = 255;
-		mc-un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = 255;
+		mc-un.value.level[AUDIO_MIXER_LEVEL_LEFT] = vol;
+		mc-un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = vol;
 		return 0;
 	}
 
@@ -679,3 +693,28 @@ awin_hdmiaudio_get_locks(void *priv, kmu
 	*intr = sc-sc_intr_lock;
 	*thread = sc-sc_lock;
 }
+
+static stream_filter_t *
+awin_hdmiaudio_swvol_filter(struct audio_softc *asc,
+const audio_params_t *from, const audio_params_t *to)
+{
+	auvolconv_filter_t *this;
+	device_t dev = audio_get_device(asc);
+	struct awin_hdmiaudio_softc *sc = device_private(dev);
+
+	this = kmem_alloc(sizeof(auvolconv_filter_t), KM_SLEEP);
+	this-base.base.fetch_to = auvolconv_slinear16_le_fetch_to;
+	this-base.dtor = awin_hdmiaudio_swvol_dtor;
+	this-base.set_fetcher = stream_filter_set_fetcher;
+	this-base.set_inputbuffer = stream_filter_set_inputbuffer;
+	this-vol = sc-sc_swvol;
+
+	return (stream_filter_t *)this;
+}
+
+static void
+awin_hdmiaudio_swvol_dtor(stream_filter_t *this)
+{
+	if (this)
+		kmem_free(this, sizeof(auvolconv_filter_t));
+}

Index: src/sys/arch/arm/allwinner/files.awin
diff -u src/sys/arch/arm/allwinner/files.awin:1.25 src/sys/arch/arm/allwinner/files.awin:1.26
--- src/sys/arch/arm/allwinner/files.awin:1.25	Tue Nov 11 19:22:32 2014
+++ src/sys/arch/arm/allwinner/files.awin	Tue Nov 

CVS commit: src/sys/arch/arm/allwinner

2014-11-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Nov 17 00:49:33 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmi.c

Log Message:
Add support for DVI displays. Detect HDMI vs DVI mode by looking for a
CEA-861-D extension block in the EDID, and then searching this block for
an HDMI vendor-specific data block (HDMI VSDB).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/allwinner/awin_hdmi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.12 src/sys/arch/arm/allwinner/awin_hdmi.c:1.13
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.12	Fri Nov 14 01:05:57 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Mon Nov 17 00:49:32 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.12 2014/11/14 01:05:57 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.13 2014/11/17 00:49:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -32,7 +32,7 @@
 #define AWIN_HDMI_PLL	3	/* PLL7 or PLL3 */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.12 2014/11/14 01:05:57 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.13 2014/11/17 00:49:32 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -65,6 +65,11 @@ struct awin_hdmi_softc {
 
 	bool sc_connected;
 
+	u_int sc_display_mode;
+#define DISPLAY_MODE_AUTO	0
+#define DISPLAY_MODE_HDMI	1
+#define DISPLAY_MODE_DVI	2
+
 	uint32_t sc_ver;
 	unsigned int sc_i2c_blklen;
 };
@@ -85,17 +90,19 @@ static int	awin_hdmi_i2c_acquire_bus(voi
 static void	awin_hdmi_i2c_release_bus(void *, int);
 static int	awin_hdmi_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *,
    size_t, void *, size_t, int);
-static int	awin_hdmi_i2c_xfer(void *, i2c_addr_t, uint8_t,
+static int	awin_hdmi_i2c_xfer(void *, i2c_addr_t, uint8_t, uint8_t,
    size_t, int, int);
 static int	awin_hdmi_i2c_reset(struct awin_hdmi_softc *, int);
 
 static void	awin_hdmi_enable(struct awin_hdmi_softc *);
 static void	awin_hdmi_read_edid(struct awin_hdmi_softc *);
+static u_int	awin_hdmi_get_display_mode(struct awin_hdmi_softc *,
+	   const struct edid_info *);
 static void	awin_hdmi_video_enable(struct awin_hdmi_softc *, bool);
 static void	awin_hdmi_set_videomode(struct awin_hdmi_softc *,
-	const struct videomode *);
+	const struct videomode *, u_int);
 static void	awin_hdmi_set_audiomode(struct awin_hdmi_softc *,
-	const struct videomode *);
+	const struct videomode *, u_int);
 static void	awin_hdmi_hpd(struct awin_hdmi_softc *);
 static void	awin_hdmi_thread(void *);
 #if 0
@@ -127,6 +134,7 @@ awin_hdmi_attach(device_t parent, device
 	struct awin_hdmi_softc *sc = device_private(self);
 	struct awinio_attach_args * const aio = aux;
 	const struct awin_locators * const loc = aio-aio_loc;
+	prop_dictionary_t cfg = device_properties(self);
 	uint32_t ver, clk;
 
 	sc-sc_dev = self;
@@ -172,6 +180,15 @@ awin_hdmi_attach(device_t parent, device
 	sc-sc_ver = ver;
 	sc-sc_i2c_blklen = 16;
 
+	const char *display_mode = NULL;
+	prop_dictionary_get_cstring_nocopy(cfg, display-mode, display_mode);
+	if (display_mode) {
+		if (strcasecmp(display_mode, hdmi) == 0)
+			sc-sc_display_mode = DISPLAY_MODE_HDMI;
+		else if (strcasecmp(display_mode, dvi) == 0)
+			sc-sc_display_mode = DISPLAY_MODE_DVI;
+	}
+
 #if 0
 	sc-sc_ih = intr_establish(loc-loc_intr, IPL_SCHED, IST_LEVEL,
 	awin_hdmi_intr, sc);
@@ -237,6 +254,7 @@ awin_hdmi_i2c_exec(void *priv, i2c_op_t 
 {
 	struct awin_hdmi_softc *sc = priv;
 	uint8_t *pbuf;
+	uint8_t block;
 	int resid;
 	off_t off;
 	int err;
@@ -251,14 +269,15 @@ awin_hdmi_i2c_exec(void *priv, i2c_op_t 
 	if (err)
 		goto done;
 
-	off = *(const uint8_t *)cmdbuf;
+	block = *(const uint8_t *)cmdbuf;
+	off = (block  1) ? 128 : 0;
 
 	pbuf = buf;
 	resid = len;
 	while (resid  0) {
 		size_t blklen = min(resid, sc-sc_i2c_blklen);
 
-		err = awin_hdmi_i2c_xfer(sc, addr, off, blklen,
+		err = awin_hdmi_i2c_xfer(sc, addr, block  1, off, blklen,
 		  AWIN_HDMI_DDC_COMMAND_ACCESS_CMD_EOREAD, flags);
 		if (err)
 			goto done;
@@ -288,7 +307,7 @@ done:
 }
 
 static int
-awin_hdmi_i2c_xfer_1_3(void *priv, i2c_addr_t addr, uint8_t reg,
+awin_hdmi_i2c_xfer_1_3(void *priv, i2c_addr_t addr, uint8_t block, uint8_t reg,
 size_t len, int type, int flags)
 {
 	struct awin_hdmi_softc *sc = priv;
@@ -299,7 +318,8 @@ awin_hdmi_i2c_xfer_1_3(void *priv, i2c_a
 	val = ~AWIN_HDMI_DDC_CTRL_FIFO_DIR;
 	HDMI_WRITE(sc, AWIN_HDMI_DDC_CTRL_REG, val);
 
-	val = __SHIFTIN(0x60, AWIN_HDMI_DDC_SLAVE_ADDR_1);
+	val |= __SHIFTIN(block, AWIN_HDMI_DDC_SLAVE_ADDR_0);
+	val |= __SHIFTIN(0x60, AWIN_HDMI_DDC_SLAVE_ADDR_1);
 	val |= __SHIFTIN(reg, AWIN_HDMI_DDC_SLAVE_ADDR_2);
 	val |= __SHIFTIN(addr, AWIN_HDMI_DDC_SLAVE_ADDR_3);
 	HDMI_WRITE(sc, AWIN_HDMI_DDC_SLAVE_ADDR_REG, val);
@@ -336,7 +356,7 @@ 

CVS commit: src/sys/arch/arm/allwinner

2014-11-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Nov 17 01:38:00 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmi.c awin_hdmiaudio.c awin_var.h

Log Message:
report hotplug status for AUDIO_GETDEV fields, only allow playback if a capable 
display is connected


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/allwinner/awin_hdmi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/allwinner/awin_hdmiaudio.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/allwinner/awin_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.13 src/sys/arch/arm/allwinner/awin_hdmi.c:1.14
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.13	Mon Nov 17 00:49:32 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Mon Nov 17 01:38:00 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.13 2014/11/17 00:49:32 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.14 2014/11/17 01:38:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -32,7 +32,7 @@
 #define AWIN_HDMI_PLL	3	/* PLL7 or PLL3 */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.13 2014/11/17 00:49:32 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.14 2014/11/17 01:38:00 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -64,8 +64,11 @@ struct awin_hdmi_softc {
 	kmutex_t sc_ic_lock;
 
 	bool sc_connected;
+	char sc_display_vendor[16];
+	char sc_display_product[16];
 
 	u_int sc_display_mode;
+	u_int sc_current_display_mode;
 #define DISPLAY_MODE_AUTO	0
 #define DISPLAY_MODE_HDMI	1
 #define DISPLAY_MODE_DVI	2
@@ -522,6 +525,12 @@ awin_hdmi_read_edid(struct awin_hdmi_sof
 	device_printf(sc-sc_dev, %s mode (%s)\n,
 	display_mode == DISPLAY_MODE_HDMI ? HDMI : DVI, forced);
 
+	strlcpy(sc-sc_display_vendor, ei.edid_vendorname,
+	sizeof(sc-sc_display_vendor));
+	strlcpy(sc-sc_display_product, ei.edid_productname,
+	sizeof(sc-sc_display_product));
+	sc-sc_current_display_mode = display_mode;
+
 	mode = ei.edid_preferred_mode;
 	if (mode == NULL)
 		mode = pick_mode_by_ref(640, 480, 60);
@@ -868,7 +877,6 @@ awin_hdmi_hpd(struct awin_hdmi_softc *sc
 	if (sc-sc_connected == con)
 		return;
 
-	sc-sc_connected = con;
 	if (con) {
 		device_printf(sc-sc_dev, display connected\n);
 		awin_hdmi_read_edid(sc);
@@ -876,6 +884,8 @@ awin_hdmi_hpd(struct awin_hdmi_softc *sc
 		device_printf(sc-sc_dev, display disconnected\n);
 		awin_tcon_set_videomode(NULL);
 	}
+
+	sc-sc_connected = con;
 }
 
 static void
@@ -908,6 +918,32 @@ awin_hdmi_intr(void *priv)
 }
 #endif
 
+void
+awin_hdmi_get_info(struct awin_hdmi_info *info)
+{
+	struct awin_hdmi_softc *sc;
+	device_t dev;
+
+	memset(info, 0, sizeof(*info));
+
+	dev = device_find_by_driver_unit(awinhdmi, 0);
+	if (dev == NULL) {
+		info-display_connected = false;
+		return;
+	}
+	sc = device_private(dev);
+
+	info-display_connected = sc-sc_connected;
+	if (info-display_connected) {
+		strlcpy(info-display_vendor, sc-sc_display_vendor,
+		sizeof(info-display_vendor));
+		strlcpy(info-display_product, sc-sc_display_product,
+		sizeof(info-display_product));
+		info-display_hdmimode =
+		sc-sc_current_display_mode == DISPLAY_MODE_HDMI;
+	}
+}
+
 #if defined(DDB)
 void
 awin_hdmi_dump_regs(void)

Index: src/sys/arch/arm/allwinner/awin_hdmiaudio.c
diff -u src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.3 src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.4
--- src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.3	Wed Nov 12 17:38:14 2014
+++ src/sys/arch/arm/allwinner/awin_hdmiaudio.c	Mon Nov 17 01:38:00 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmiaudio.c,v 1.3 2014/11/12 17:38:14 jmcneill Exp $ */
+/* $NetBSD: awin_hdmiaudio.c,v 1.4 2014/11/17 01:38:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmiaudio.c,v 1.3 2014/11/12 17:38:14 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmiaudio.c,v 1.4 2014/11/17 01:38:00 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -538,14 +538,35 @@ static int
 awin_hdmiaudio_getdev(void *priv, struct audio_device *audiodev)
 {
 	struct awin_hdmiaudio_softc *sc = priv;
+	struct awin_hdmi_info info;
+	const char *vendor = NULL, *product = NULL;
 
 	const int vmaj = __SHIFTOUT(sc-sc_ver, AWIN_HDMI_VERSION_ID_H);
 	const int vmin = __SHIFTOUT(sc-sc_ver, AWIN_HDMI_VERSION_ID_L);
 
-	snprintf(audiodev-name, sizeof(audiodev-name), Allwinner);
-	snprintf(audiodev-version, sizeof(audiodev-version),
+	awin_hdmi_get_info(info);
+
+	if (info.display_connected  info.display_hdmimode) {
+		if (strlen(info.display_vendor)  0 
+		strlen(info.display_product)  0) {
+			vendor = info.display_vendor;
+			product = info.display_product;
+		} else {
+			vendor = HDMI;
+			product = ;
+	

CVS commit: src/sys/arch/arm/allwinner

2014-11-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 15 13:40:39 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_ir.c awin_reg.h

Log Message:
Fix CIR setup. Works on A31 now.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/allwinner/awin_ir.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_ir.c
diff -u src/sys/arch/arm/allwinner/awin_ir.c:1.1 src/sys/arch/arm/allwinner/awin_ir.c:1.2
--- src/sys/arch/arm/allwinner/awin_ir.c:1.1	Sun Nov  2 23:55:48 2014
+++ src/sys/arch/arm/allwinner/awin_ir.c	Sat Nov 15 13:40:39 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_ir.c,v 1.1 2014/11/02 23:55:48 jmcneill Exp $ */
+/* $NetBSD: awin_ir.c,v 1.2 2014/11/15 13:40:39 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include opt_ddb.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_ir.c,v 1.1 2014/11/02 23:55:48 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_ir.c,v 1.2 2014/11/15 13:40:39 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -175,11 +175,11 @@ awin_ir_init(struct awin_ir_softc *sc, s
 		clk = bus_space_read_4(sc-sc_bst, prcm_bsh,
 		AWIN_A31_PRCM_CIR_CLK_REG);
 		clk = ~AWIN_CLK_SRC_SEL;
-		clk |= 1;	/* HOSC */
+		clk |= __SHIFTIN(AWIN_CLK_SRC_SEL_CIR_HOSC, AWIN_CLK_SRC_SEL);
 		clk = ~AWIN_CLK_DIV_RATIO_M;
-		clk |= 7;	/* (24MHz / 3MHz) - 1 */
+		clk |= __SHIFTIN(7, AWIN_CLK_DIV_RATIO_M);
 		clk = ~AWIN_CLK_DIV_RATIO_N;
-		clk |= 0;	/* 1 - 1 */
+		clk |= __SHIFTIN(0, AWIN_CLK_DIV_RATIO_N);
 		clk |= AWIN_CLK_ENABLE;
 		bus_space_write_4(sc-sc_bst, prcm_bsh,
 		AWIN_A31_PRCM_CIR_CLK_REG, clk);
@@ -203,7 +203,7 @@ awin_ir_intr(void *priv)
 
 	IR_WRITE(sc, AWIN_IR_RXSTA_REG, sta  AWIN_IR_RXSTA_MASK);
 
-	if (sta  AWIN_IR_RXSTA_RA) {
+	if (sta  AWIN_IR_RXSTA_RPE) {
 		mutex_enter(sc-sc_lock);
 		sc-sc_avail = __SHIFTOUT(sta, AWIN_IR_RXSTA_RAC);
 		cv_broadcast(sc-sc_cv);
@@ -217,17 +217,25 @@ static int
 awin_ir_open(void *priv, int flag, int mode, struct proc *p)
 {
 	struct awin_ir_softc *sc = priv;
-	uint32_t ctl, rxint;
+	uint32_t ctl, rxint, cir;
 
 	ctl = __SHIFTIN(AWIN_IR_CTL_MD_CIR, AWIN_IR_CTL_MD);
 	IR_WRITE(sc, AWIN_IR_CTL_REG, ctl);
 
+	cir = __SHIFTIN(3, AWIN_IR_CIR_SCS);
+	cir |= __SHIFTIN(0, AWIN_IR_CIR_SCS2);
+	cir |= __SHIFTIN(8, AWIN_IR_CIR_NTHR);
+	cir |= __SHIFTIN(2, AWIN_IR_CIR_ITHR);
+	cir |= __SHIFTIN(99, AWIN_IR_CIR_ATHR);
+	cir |= __SHIFTIN(0, AWIN_IR_CIR_ATHC);
+	IR_WRITE(sc, AWIN_IR_CIR_REG, cir);
+
 	IR_WRITE(sc, AWIN_IR_RXCTL_REG, AWIN_IR_RXCTL_RPPI);
 
 	IR_WRITE(sc, AWIN_IR_RXSTA_REG, AWIN_IR_RXSTA_MASK);
 
-	rxint = AWIN_IR_RXINT_RAI_EN;
-	rxint |= __SHIFTIN(0, AWIN_IR_RXINT_RAL);
+	rxint = AWIN_IR_RXINT_RPEI_EN;
+	rxint |= __SHIFTIN(31, AWIN_IR_RXINT_RAL);
 	IR_WRITE(sc, AWIN_IR_RXINT_REG, rxint);
 
 	ctl |= AWIN_IR_CTL_GEN;

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.49 src/sys/arch/arm/allwinner/awin_reg.h:1.50
--- src/sys/arch/arm/allwinner/awin_reg.h:1.49	Fri Nov 14 00:31:54 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sat Nov 15 13:40:39 2014
@@ -816,7 +816,7 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_IR_TXSTA_TPE		__BIT(1)
 #define AWIN_IR_TXSTA_TU		__BIT(0)
 
-#define AWIN_IR_RXINT_RAL		__BITS(11,8)
+#define AWIN_IR_RXINT_RAL		__BITS(13,8)
 #define AWIN_IR_RXINT_DRQ_EN		__BIT(5)
 #define AWIN_IR_RXINT_RAI_EN		__BIT(4)
 #define AWIN_IR_RXINT_CRCI_EN		__BIT(3)
@@ -833,6 +833,8 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_IR_RXSTA_ROI		__BIT(0)
 
 #define AWIN_IR_CIR_SCS2		__BIT(24)
+#define AWIN_IR_CIR_ATHC		__BIT(23)
+#define AWIN_IR_CIR_ATHR		__BITS(22,16)
 #define AWIN_IR_CIR_ITHR		__BITS(15,8)
 #define AWIN_IR_CIR_NTHR		__BITS(7,2)
 #define AWIN_IR_CIR_SCS			__BITS(1,0)
@@ -1072,6 +1074,8 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_CLK_SRC_SEL_DE_PLL3	0
 #define AWIN_CLK_SRC_SEL_DE_PLL7	1
 #define AWIN_CLK_SRC_SEL_DE_PLL5	2
+#define AWIN_CLK_SRC_SEL_CIR_LOSC	0
+#define AWIN_CLK_SRC_SEL_CIR_HOSC	1
 #define AWIN_CLK_DIV_RATIO_N		__BITS(17,16)
 #define AWIN_CLK_DIV_RATIO_M		__BITS(3,0)
 



CVS commit: src/sys/arch/arm/allwinner

2014-11-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 15 13:41:11 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_ir.c

Log Message:
hide a debug printf


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/allwinner/awin_ir.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_ir.c
diff -u src/sys/arch/arm/allwinner/awin_ir.c:1.2 src/sys/arch/arm/allwinner/awin_ir.c:1.3
--- src/sys/arch/arm/allwinner/awin_ir.c:1.2	Sat Nov 15 13:40:39 2014
+++ src/sys/arch/arm/allwinner/awin_ir.c	Sat Nov 15 13:41:11 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_ir.c,v 1.2 2014/11/15 13:40:39 jmcneill Exp $ */
+/* $NetBSD: awin_ir.c,v 1.3 2014/11/15 13:41:11 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include opt_ddb.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_ir.c,v 1.2 2014/11/15 13:40:39 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_ir.c,v 1.3 2014/11/15 13:41:11 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -196,7 +196,9 @@ awin_ir_intr(void *priv)
 
 	sta = IR_READ(sc, AWIN_IR_RXSTA_REG);
 
+#ifdef AWIN_IR_DEBUG
 	printf(%s: sta = 0x%08x\n, __func__, sta);
+#endif
 
 	if ((sta  AWIN_IR_RXSTA_MASK) == 0)
 		return 0;



CVS commit: src/sys/arch/arm/allwinner

2014-11-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 15 14:56:18 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_ir.c awin_reg.h

Log Message:
add A20 IR support


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/allwinner/awin_ir.c
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_ir.c
diff -u src/sys/arch/arm/allwinner/awin_ir.c:1.3 src/sys/arch/arm/allwinner/awin_ir.c:1.4
--- src/sys/arch/arm/allwinner/awin_ir.c:1.3	Sat Nov 15 13:41:11 2014
+++ src/sys/arch/arm/allwinner/awin_ir.c	Sat Nov 15 14:56:18 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_ir.c,v 1.3 2014/11/15 13:41:11 jmcneill Exp $ */
+/* $NetBSD: awin_ir.c,v 1.4 2014/11/15 14:56:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include opt_ddb.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_ir.c,v 1.3 2014/11/15 13:41:11 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_ir.c,v 1.4 2014/11/15 14:56:18 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -60,6 +60,7 @@ struct awin_ir_softc {
 	device_t sc_i2cdev;
 	void *sc_ih;
 	size_t sc_avail;
+	int sc_port;
 };
 
 #define IR_READ(sc, reg) \
@@ -118,6 +119,7 @@ awin_ir_attach(device_t parent, device_t
 
 	sc-sc_dev = self;
 	sc-sc_bst = aio-aio_core_bst;
+	sc-sc_port = loc-loc_port;
 	mutex_init(sc-sc_lock, MUTEX_DEFAULT, IPL_IR);
 	cv_init(sc-sc_cv, awinir);
 	bus_space_subregion(sc-sc_bst, aio-aio_core_bsh,
@@ -185,6 +187,29 @@ awin_ir_init(struct awin_ir_softc *sc, s
 		AWIN_A31_PRCM_CIR_CLK_REG, clk);
 
 		bus_space_unmap(sc-sc_bst, prcm_bsh, prcm_size);
+	} else  {
+		const struct awin_gpio_pinset pinset =
+		{ 'B', AWIN_PIO_PB_IR0_FUNC, AWIN_PIO_PB_IR0_PINS };
+		uint32_t clk;
+
+		awin_gpio_pinset_acquire(pinset);
+
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_APB0_GATING_REG,
+		AWIN_APB_GATING0_IR0  sc-sc_port,
+		0);
+
+		clk = bus_space_read_4(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_IR0_CLK_REG + (sc-sc_port * 4));
+		clk = ~AWIN_CLK_SRC_SEL;
+		clk |= __SHIFTIN(AWIN_CLK_SRC_SEL_OSC24M, AWIN_CLK_SRC_SEL);
+		clk = ~AWIN_CLK_DIV_RATIO_M;
+		clk |= __SHIFTIN(7, AWIN_CLK_DIV_RATIO_M);
+		clk = ~AWIN_CLK_DIV_RATIO_N;
+		clk |= __SHIFTIN(0, AWIN_CLK_DIV_RATIO_N);
+		clk |= AWIN_CLK_ENABLE;
+		bus_space_write_4(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_IR0_CLK_REG + (sc-sc_port * 4), clk);
 	}
 }
 
@@ -228,8 +253,10 @@ awin_ir_open(void *priv, int flag, int m
 	cir |= __SHIFTIN(0, AWIN_IR_CIR_SCS2);
 	cir |= __SHIFTIN(8, AWIN_IR_CIR_NTHR);
 	cir |= __SHIFTIN(2, AWIN_IR_CIR_ITHR);
-	cir |= __SHIFTIN(99, AWIN_IR_CIR_ATHR);
-	cir |= __SHIFTIN(0, AWIN_IR_CIR_ATHC);
+	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+		cir |= __SHIFTIN(99, AWIN_IR_CIR_ATHR);
+		cir |= __SHIFTIN(0, AWIN_IR_CIR_ATHC);
+	}
 	IR_WRITE(sc, AWIN_IR_CIR_REG, cir);
 
 	IR_WRITE(sc, AWIN_IR_RXCTL_REG, AWIN_IR_RXCTL_RPPI);

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.50 src/sys/arch/arm/allwinner/awin_reg.h:1.51
--- src/sys/arch/arm/allwinner/awin_reg.h:1.50	Sat Nov 15 13:40:39 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sat Nov 15 14:56:18 2014
@@ -907,7 +907,7 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_SPI0_CLK_REG		0x00A0
 #define AWIN_SPI1_CLK_REG		0x00A4
 #define AWIN_SPI2_CLK_REG		0x00A8
-#define AWIN_IR0_CLK_REG		0x00B9
+#define AWIN_IR0_CLK_REG		0x00B0
 #define AWIN_IR1_CLK_REG		0x00B4
 #define AWIN_IIS_CLK_REG		0x00B8
 #define AWIN_AC97_CLK_REG		0x00BC



CVS commit: src/sys/arch/arm/allwinner

2014-11-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 15 20:04:08 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
Split nand pins into two sets, functions differ.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.51 src/sys/arch/arm/allwinner/awin_reg.h:1.52
--- src/sys/arch/arm/allwinner/awin_reg.h:1.51	Sat Nov 15 14:56:18 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sat Nov 15 20:04:07 2014
@@ -1320,8 +1320,10 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_PIO_PB_STANBYWFI_FUNC	6
 
 #define AWIN_PIO_PC_PINS		25
-#define AWIN_PIO_PC_NAND_PINS		0x017f /* PC pins 24,22-0 */
+#define AWIN_PIO_PC_NAND_PINS		0x0107 /* PC pins 24,18-0 */
 #define AWIN_PIO_PC_NAND_FUNC		2
+#define AWIN_PIO_PC_NAND_PINS2		0x0080 /* PC pin 23 */
+#define AWIN_PIO_PC_NAND_FUNC2		3
 #define AWIN_PIO_PC_SPI0_PINS		0x0087 /* PC pins 23-23,3-0 */
 #define AWIN_PIO_PC_SPI0_FUNC		3
 #define AWIN_PIO_PC_SPI2_PINS		0x00f8 /* PC pins 23-19 */



CVS commit: src/sys/arch/arm/allwinner

2014-11-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Nov 14 08:20:22 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_usb.c

Log Message:
IPL_SCHED - IPL_VM

Something isn't MP safe.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/allwinner/awin_usb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_usb.c
diff -u src/sys/arch/arm/allwinner/awin_usb.c:1.16 src/sys/arch/arm/allwinner/awin_usb.c:1.17
--- src/sys/arch/arm/allwinner/awin_usb.c:1.16	Wed Nov  5 01:07:26 2014
+++ src/sys/arch/arm/allwinner/awin_usb.c	Fri Nov 14 08:20:22 2014
@@ -34,7 +34,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_usb.c,v 1.16 2014/11/05 01:07:26 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_usb.c,v 1.17 2014/11/14 08:20:22 skrll Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -151,7 +151,7 @@ ohci_awinusb_attach(device_t parent, dev
 	const int irq = awin_chip_id() == AWIN_CHIP_ID_A31 ?
 			awinusb_ohci_irqs_a31[usbaa-usbaa_port] :
 			awinusb_ohci_irqs[usbaa-usbaa_port];
-	usbsc-usbsc_ohci_ih = intr_establish(irq, IPL_SCHED,
+	usbsc-usbsc_ohci_ih = intr_establish(irq, IPL_VM,
 	IST_LEVEL, ohci_intr, sc);
 	if (usbsc-usbsc_ohci_ih == NULL) {
 		aprint_error_dev(self, failed to establish interrupt %d\n,
@@ -228,7 +228,7 @@ ehci_awinusb_attach(device_t parent, dev
 	const int irq = awin_chip_id() == AWIN_CHIP_ID_A31 ?
 			awinusb_ehci_irqs_a31[usbaa-usbaa_port] :
 			awinusb_ehci_irqs[usbaa-usbaa_port];
-	usbsc-usbsc_ehci_ih = intr_establish(irq, IPL_SCHED,
+	usbsc-usbsc_ehci_ih = intr_establish(irq, IPL_VM,
 	IST_LEVEL, ehci_intr, sc);
 	if (usbsc-usbsc_ehci_ih == NULL) {
 		aprint_error_dev(self, failed to establish interrupt %d\n,



CVS commit: src/sys/arch/arm/allwinner

2014-11-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 14 23:45:02 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c awin_fb.c awin_var.h

Log Message:
Implement WSDISPLAYIO_SVIDEO, WSDISPLAYIO_GVIDEO for screen blanking


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/allwinner/awin_debe.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/allwinner/awin_fb.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/allwinner/awin_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.7 src/sys/arch/arm/allwinner/awin_debe.c:1.8
--- src/sys/arch/arm/allwinner/awin_debe.c:1.7	Fri Nov 14 19:47:36 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Fri Nov 14 23:45:02 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.7 2014/11/14 19:47:36 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.8 2014/11/14 23:45:02 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -34,7 +34,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.7 2014/11/14 19:47:36 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.8 2014/11/14 23:45:02 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -49,6 +49,7 @@ __KERNEL_RCSID(0, $NetBSD: awin_debe.c,
 #include arm/allwinner/awin_var.h
 
 #include dev/videomode/videomode.h
+#include dev/wscons/wsconsio.h
 
 struct awin_debe_softc {
 	device_t sc_dev;
@@ -360,3 +361,30 @@ awin_debe_set_videomode(const struct vid
 		awin_debe_setup_fbdev(sc, mode);
 	}
 }
+
+int
+awin_debe_ioctl(device_t self, u_long cmd, void *data)
+{
+	struct awin_debe_softc *sc = device_private(self);
+	uint32_t val;
+	int enable;
+
+	switch (cmd) {
+	case WSDISPLAYIO_SVIDEO:
+		enable = *(int *)data;
+		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
+		if (enable)
+			val |= AWIN_DEBE_MODCTL_LAY0_EN;
+		else
+			val = ~AWIN_DEBE_MODCTL_LAY0_EN;
+		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
+		return 0;
+	case WSDISPLAYIO_GVIDEO:
+		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
+		*(int *)data = !!(val  AWIN_DEBE_MODCTL_LAY0_EN);
+		return 0;
+	}
+
+	return EPASSTHROUGH;
+}
+

Index: src/sys/arch/arm/allwinner/awin_fb.c
diff -u src/sys/arch/arm/allwinner/awin_fb.c:1.5 src/sys/arch/arm/allwinner/awin_fb.c:1.6
--- src/sys/arch/arm/allwinner/awin_fb.c:1.5	Fri Nov 14 19:47:36 2014
+++ src/sys/arch/arm/allwinner/awin_fb.c	Fri Nov 14 23:45:02 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_fb.c,v 1.5 2014/11/14 19:47:36 jmcneill Exp $ */
+/* $NetBSD: awin_fb.c,v 1.6 2014/11/14 23:45:02 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.5 2014/11/14 19:47:36 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.6 2014/11/14 23:45:02 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -46,6 +46,7 @@ __KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 
 
 struct awin_fb_softc {
 	struct genfb_softc sc_gen;
+	device_t sc_debedev;
 
 	bus_dma_tag_t sc_dmat;
 	bus_dma_segment_t *sc_dmasegs;
@@ -82,6 +83,7 @@ awin_fb_attach(device_t parent, device_t
 		awin_fb_consoledev = self;
 
 	sc-sc_gen.sc_dev = self;
+	sc-sc_debedev = parent;
 	sc-sc_dmat = afb-afb_dmat;
 	sc-sc_dmasegs = afb-afb_dmasegs;
 	sc-sc_ndmasegs = afb-afb_ndmasegs;
@@ -144,6 +146,9 @@ awin_fb_ioctl(void *v, void *vs, u_long 
 		if (error == 0)
 			fbi-fbi_flags |= WSFB_VRAM_IS_RAM;
 		return error;
+	case WSDISPLAYIO_SVIDEO:
+	case WSDISPLAYIO_GVIDEO:
+		return awin_debe_ioctl(sc-sc_debedev, cmd, data);
 	default:
 		return EPASSTHROUGH;
 	}

Index: src/sys/arch/arm/allwinner/awin_var.h
diff -u src/sys/arch/arm/allwinner/awin_var.h:1.23 src/sys/arch/arm/allwinner/awin_var.h:1.24
--- src/sys/arch/arm/allwinner/awin_var.h:1.23	Fri Nov 14 19:47:36 2014
+++ src/sys/arch/arm/allwinner/awin_var.h	Fri Nov 14 23:45:02 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_var.h,v 1.23 2014/11/14 19:47:36 jmcneill Exp $ */
+/* $NetBSD: awin_var.h,v 1.24 2014/11/14 23:45:02 jmcneill Exp $ */
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -131,6 +131,7 @@ void	awin_tcon_set_videomode(const struc
 void	awin_tcon_enable(bool);
 void	awin_debe_set_videomode(const struct videomode *);
 void	awin_debe_enable(bool);
+int	awin_debe_ioctl(device_t, u_long, void *);
 void	awin_fb_set_videomode(device_t, u_int, u_int);
 void	awin_fb_ddb_trap_callback(int);
 



CVS commit: src/sys/arch/arm/allwinner

2014-11-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 14 00:31:54 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c awin_fb.c awin_hdmi.c
awin_reg.h awin_tcon.c

Log Message:
Add support for interlaced video modes.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/allwinner/awin_debe.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/allwinner/awin_fb.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/allwinner/awin_hdmi.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/allwinner/awin_tcon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.5 src/sys/arch/arm/allwinner/awin_debe.c:1.6
--- src/sys/arch/arm/allwinner/awin_debe.c:1.5	Wed Nov 12 23:12:27 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Fri Nov 14 00:31:54 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.5 2014/11/12 23:12:27 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.6 2014/11/14 00:31:54 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -34,7 +34,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.5 2014/11/12 23:12:27 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.6 2014/11/14 00:31:54 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -221,10 +221,11 @@ static void
 awin_debe_setup_fbdev(struct awin_debe_softc *sc, const struct videomode *mode)
 {
 	if (mode  sc-sc_fbdev == NULL) {
+		const u_int interlace_p = !!(mode-flags  VID_INTERLACE);
 		struct awinfb_attach_args afb = {
 			.afb_fb = sc-sc_dmap,
 			.afb_width = mode-hdisplay,
-			.afb_height = mode-vdisplay,
+			.afb_height = (mode-vdisplay  interlace_p),
 			.afb_dmat = sc-sc_dmat,
 			.afb_dmasegs = sc-sc_dmasegs,
 			.afb_ndmasegs = 1
@@ -283,13 +284,15 @@ awin_debe_set_videomode(const struct vid
 	sc = device_private(dev);
 
 	if (mode) {
-		uint32_t vmem = mode-vdisplay * mode-hdisplay * 4;
+		const u_int interlace_p = !!(mode-flags  VID_INTERLACE);
+		const u_int width = mode-hdisplay;
+		const u_int height = (mode-vdisplay  interlace_p);
+		uint32_t vmem = width * height * 4;
 
 		if (vmem  sc-sc_dmasize) {
 			device_printf(sc-sc_dev,
 			not enough memory for %ux%u fb (req %u have %u)\n,
-			mode-hdisplay, mode-vdisplay,
-			vmem, (unsigned int)sc-sc_dmasize);
+			width, height, vmem, (unsigned int)sc-sc_dmasize);
 			return;
 		}
 
@@ -305,10 +308,10 @@ awin_debe_set_videomode(const struct vid
 		awin_debe_setup_fbdev(sc, mode);
 
 		DEBE_WRITE(sc, AWIN_DEBE_DISSIZE_REG,
-		((mode-vdisplay - 1)  16) | (mode-hdisplay - 1));
+		((height - 1)  16) | (width - 1));
 		DEBE_WRITE(sc, AWIN_DEBE_LAYSIZE_REG,
-		((mode-vdisplay - 1)  16) | (mode-hdisplay - 1));
-		DEBE_WRITE(sc, AWIN_DEBE_LAYLINEWIDTH_REG, mode-hdisplay  5);
+		((height - 1)  16) | (width - 1));
+		DEBE_WRITE(sc, AWIN_DEBE_LAYLINEWIDTH_REG, (width  5));
 		DEBE_WRITE(sc, AWIN_DEBE_LAYFB_L32ADD_REG, pa  3);
 		DEBE_WRITE(sc, AWIN_DEBE_LAYFB_H4ADD_REG, pa  29);
 
@@ -322,6 +325,11 @@ awin_debe_set_videomode(const struct vid
 
 		val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
 		val |= AWIN_DEBE_MODCTL_LAY0_EN;
+		if (interlace_p) {
+			val |= AWIN_DEBE_MODCTL_ITLMOD_EN;
+		} else {
+			val = ~AWIN_DEBE_MODCTL_ITLMOD_EN;
+		}
 		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
 	} else {
 		/* disable */

Index: src/sys/arch/arm/allwinner/awin_fb.c
diff -u src/sys/arch/arm/allwinner/awin_fb.c:1.3 src/sys/arch/arm/allwinner/awin_fb.c:1.4
--- src/sys/arch/arm/allwinner/awin_fb.c:1.3	Mon Nov 10 17:55:25 2014
+++ src/sys/arch/arm/allwinner/awin_fb.c	Fri Nov 14 00:31:54 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_fb.c,v 1.3 2014/11/10 17:55:25 jmcneill Exp $ */
+/* $NetBSD: awin_fb.c,v 1.4 2014/11/14 00:31:54 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.3 2014/11/10 17:55:25 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.4 2014/11/14 00:31:54 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -189,8 +189,11 @@ awin_fb_set_videomode(device_t dev, cons
 	if (mode == NULL)
 		return;
 
-	if (sc-sc_gen.sc_width != mode-hdisplay ||
-	sc-sc_gen.sc_height != mode-vdisplay) {
+	const u_int interlace_p = !!(mode-flags  VID_INTERLACE);
+	const u_int width = mode-hdisplay;
+	const u_int height = (mode-vdisplay  interlace_p);
+
+	if (sc-sc_gen.sc_width != width || sc-sc_gen.sc_height != height) {
 		device_printf(sc-sc_gen.sc_dev,
 		mode switching not yet supported\n);
 	}

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.10 src/sys/arch/arm/allwinner/awin_hdmi.c:1.11
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.10	

CVS commit: src/sys/arch/arm/allwinner

2014-11-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 14 01:05:57 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmi.c

Log Message:
disable hdmi and tcon before setting up the display


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/allwinner/awin_hdmi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.11 src/sys/arch/arm/allwinner/awin_hdmi.c:1.12
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.11	Fri Nov 14 00:31:54 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Fri Nov 14 01:05:57 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.11 2014/11/14 00:31:54 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.12 2014/11/14 01:05:57 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -32,7 +32,7 @@
 #define AWIN_HDMI_PLL	3	/* PLL7 or PLL3 */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.11 2014/11/14 00:31:54 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.12 2014/11/14 01:05:57 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -494,6 +494,10 @@ awin_hdmi_read_edid(struct awin_hdmi_sof
 		mode = pick_mode_by_ref(640, 480, 60);
 
 	if (mode != NULL) {
+		awin_hdmi_video_enable(sc, false);
+		awin_tcon_enable(false);
+		delay(2);
+
 		awin_debe_set_videomode(mode);
 		awin_tcon_set_videomode(mode);
 		awin_hdmi_set_videomode(sc, mode);



CVS commit: src/sys/arch/arm/allwinner

2014-11-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 12 17:38:14 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_dma_a10.c awin_hdmi.c awin_hdmiaudio.c

Log Message:
Add A20 HDMI audio support. Basically the same as A31, except we need to use 
dedicated DMA mode here (A31 DMA controller only supports normal DMA mode).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/allwinner/awin_dma_a10.c \
src/sys/arch/arm/allwinner/awin_hdmiaudio.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/allwinner/awin_hdmi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_dma_a10.c
diff -u src/sys/arch/arm/allwinner/awin_dma_a10.c:1.2 src/sys/arch/arm/allwinner/awin_dma_a10.c:1.3
--- src/sys/arch/arm/allwinner/awin_dma_a10.c:1.2	Sun Oct 26 15:07:33 2014
+++ src/sys/arch/arm/allwinner/awin_dma_a10.c	Wed Nov 12 17:38:14 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_dma_a10.c,v 1.2 2014/10/26 15:07:33 jmcneill Exp $ */
+/* $NetBSD: awin_dma_a10.c,v 1.3 2014/11/12 17:38:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -29,7 +29,7 @@
 #include opt_ddb.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_dma_a10.c,v 1.2 2014/10/26 15:07:33 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_dma_a10.c,v 1.3 2014/11/12 17:38:14 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -179,7 +179,8 @@ awin_dma_a10_alloc(struct awin_dma_softc
 	uint32_t irqen;
 	uint8_t ch_count, index;
 
-	if (strcmp(type, ddma) == 0) {
+	if (strcmp(type, ddma) == 0 ||
+	strcmp(type, hdmiaudio) == 0) {
 		ch_list = awin_ddma_channels;
 		ch_count = DDMA_CHANNELS;
 	} else {
@@ -239,7 +240,11 @@ awin_dma_a10_get_config(void *priv)
 {
 	struct awin_dma_a10_channel *ch = priv;
 
-	return DMACH_READ(ch, AWIN_NDMA_CTL_REG);
+	if (ch-ch_type == CH_NDMA) {
+		return DMACH_READ(ch, AWIN_NDMA_CTL_REG);
+	} else {
+		return DMACH_READ(ch, AWIN_DDMA_CTL_REG);
+	}
 }
 
 static void
@@ -247,7 +252,11 @@ awin_dma_a10_set_config(void *priv, uint
 {
 	struct awin_dma_a10_channel *ch = priv;
 
-	DMACH_WRITE(ch, AWIN_NDMA_CTL_REG, val);
+	if (ch-ch_type == CH_NDMA) {
+		DMACH_WRITE(ch, AWIN_NDMA_CTL_REG, val);
+	} else {
+		DMACH_WRITE(ch, AWIN_DDMA_CTL_REG, val);
+	}
 }
 
 static int
@@ -275,6 +284,11 @@ awin_dma_a10_transfer(void *priv, paddr_
 		DMACH_WRITE(ch, AWIN_DDMA_SRC_START_ADDR_REG, src);
 		DMACH_WRITE(ch, AWIN_DDMA_DEST_START_ADDR_REG, dst);
 		DMACH_WRITE(ch, AWIN_DDMA_BC_REG, nbytes);
+		DMACH_WRITE(ch, AWIN_DDMA_PARA_REG,
+		__SHIFTIN(31, AWIN_DDMA_PARA_DST_DATA_BLK_SIZ) |
+		__SHIFTIN(7, AWIN_DDMA_PARA_DST_WAIT_CYC) |
+		__SHIFTIN(31, AWIN_DDMA_PARA_SRC_DATA_BLK_SIZ) |
+		__SHIFTIN(7, AWIN_DDMA_PARA_SRC_WAIT_CYC));
 
 		cfg |= AWIN_DDMA_CTL_DMA_LOADING;
 		awin_dma_a10_set_config(ch, cfg);
Index: src/sys/arch/arm/allwinner/awin_hdmiaudio.c
diff -u src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.2 src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.3
--- src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.2	Tue Nov 11 17:14:38 2014
+++ src/sys/arch/arm/allwinner/awin_hdmiaudio.c	Wed Nov 12 17:38:14 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmiaudio.c,v 1.2 2014/11/11 17:14:38 jmcneill Exp $ */
+/* $NetBSD: awin_hdmiaudio.c,v 1.3 2014/11/12 17:38:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmiaudio.c,v 1.2 2014/11/11 17:14:38 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmiaudio.c,v 1.3 2014/11/12 17:38:14 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -602,18 +602,33 @@ awin_hdmiaudio_trigger_output(void *priv
 	dmacfg = 0;
 	dmacfg |= __SHIFTIN(AWIN_DMA_CTL_DATA_WIDTH_32,
 			AWIN_DMA_CTL_DST_DATA_WIDTH);
-	dmacfg |= __SHIFTIN(AWIN_DMA_CTL_BURST_LEN_4,
-			AWIN_DMA_CTL_DST_BURST_LEN);
-	dmacfg |= __SHIFTIN(AWIN_DMA_CTL_DATA_WIDTH_16,
+	dmacfg |= __SHIFTIN(AWIN_DMA_CTL_DATA_WIDTH_32,
 			AWIN_DMA_CTL_SRC_DATA_WIDTH);
-	dmacfg |= __SHIFTIN(AWIN_DMA_CTL_BURST_LEN_4,
-			AWIN_DMA_CTL_SRC_BURST_LEN);
 	dmacfg |= AWIN_DMA_CTL_BC_REMAINING;
-	dmacfg |= AWIN_NDMA_CTL_DST_ADDR_NOINCR;
-	dmacfg |= __SHIFTIN(sc-sc_drqtype_hdmiaudio,
-			AWIN_DMA_CTL_DST_DRQ_TYPE);
 	dmacfg |= __SHIFTIN(sc-sc_drqtype_sdram,
 			AWIN_DMA_CTL_SRC_DRQ_TYPE);
+	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+		/* NDMA */
+		dmacfg |= __SHIFTIN(AWIN_DMA_CTL_BURST_LEN_4,
+AWIN_DMA_CTL_DST_BURST_LEN);
+		dmacfg |= __SHIFTIN(AWIN_DMA_CTL_BURST_LEN_4,
+AWIN_DMA_CTL_SRC_BURST_LEN);
+		dmacfg |= AWIN_NDMA_CTL_DST_ADDR_NOINCR;
+		dmacfg |= __SHIFTIN(sc-sc_drqtype_hdmiaudio,
+AWIN_DMA_CTL_DST_DRQ_TYPE);
+	} else {
+		/* DDMA */
+		dmacfg |= __SHIFTIN(AWIN_DMA_CTL_BURST_LEN_8,
+AWIN_DMA_CTL_DST_BURST_LEN);
+		dmacfg |= __SHIFTIN(AWIN_DMA_CTL_BURST_LEN_8,
+

CVS commit: src/sys/arch/arm/allwinner

2014-11-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 12 21:27:48 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_board.c

Log Message:
fix pll5x rate calculation


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/allwinner/awin_board.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_board.c
diff -u src/sys/arch/arm/allwinner/awin_board.c:1.27 src/sys/arch/arm/allwinner/awin_board.c:1.28
--- src/sys/arch/arm/allwinner/awin_board.c:1.27	Mon Nov 10 17:55:25 2014
+++ src/sys/arch/arm/allwinner/awin_board.c	Wed Nov 12 21:27:48 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_board.c,v 1.27 2014/11/10 17:55:25 jmcneill Exp $	*/
+/*	$NetBSD: awin_board.c,v 1.28 2014/11/12 21:27:48 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_board.c,v 1.27 2014/11/10 17:55:25 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_board.c,v 1.28 2014/11/12 21:27:48 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -518,7 +518,7 @@ awin_pll5x_get_rate(void)
 	AWIN_CCM_OFFSET + AWIN_PLL5_CFG_REG);
 
 	n = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_N);
-	k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K);
+	k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K) + 1;
 	p = __SHIFTOUT(cfg, AWIN_PLL5_OUT_EXT_DIV_P);
 
 	return (AWIN_REF_FREQ * n * k)  p;



CVS commit: src/sys/arch/arm/allwinner

2014-11-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 12 23:12:27 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c

Log Message:
On 2GB systems, we have to subtract AWIN_SDRAM_PBASE from the physical address.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/allwinner/awin_debe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.4 src/sys/arch/arm/allwinner/awin_debe.c:1.5
--- src/sys/arch/arm/allwinner/awin_debe.c:1.4	Tue Nov 11 19:22:32 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Wed Nov 12 23:12:27 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.4 2014/11/11 19:22:32 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.5 2014/11/12 23:12:27 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -34,7 +34,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.4 2014/11/11 19:22:32 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.5 2014/11/12 23:12:27 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -293,6 +293,14 @@ awin_debe_set_videomode(const struct vid
 			return;
 		}
 
+		paddr_t pa = sc-sc_dmamap-dm_segs[0].ds_addr;
+		/*
+		 * On 2GB systems, we need to subtract AWIN_SDRAM_PBASE from
+		 * the phys addr.
+		 */
+		if (pa = AWIN_SDRAM_PBASE)
+			pa -= AWIN_SDRAM_PBASE;
+
 		/* notify fb */
 		awin_debe_setup_fbdev(sc, mode);
 
@@ -301,10 +309,8 @@ awin_debe_set_videomode(const struct vid
 		DEBE_WRITE(sc, AWIN_DEBE_LAYSIZE_REG,
 		((mode-vdisplay - 1)  16) | (mode-hdisplay - 1));
 		DEBE_WRITE(sc, AWIN_DEBE_LAYLINEWIDTH_REG, mode-hdisplay  5);
-		DEBE_WRITE(sc, AWIN_DEBE_LAYFB_L32ADD_REG,
-		sc-sc_dmamap-dm_segs[0].ds_addr  3);
-		DEBE_WRITE(sc, AWIN_DEBE_LAYFB_H4ADD_REG,
-		sc-sc_dmamap-dm_segs[0].ds_addr  29);
+		DEBE_WRITE(sc, AWIN_DEBE_LAYFB_L32ADD_REG, pa  3);
+		DEBE_WRITE(sc, AWIN_DEBE_LAYFB_H4ADD_REG, pa  29);
 
 		val = DEBE_READ(sc, AWIN_DEBE_ATTCTL1_REG);
 		val = ~AWIN_DEBE_ATTCTL1_LAY_FBFMT;



CVS commit: src/sys/arch/arm/allwinner

2014-11-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 11 17:00:59 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmi.c awin_io.c awin_reg.h files.awin
Added Files:
src/sys/arch/arm/allwinner: awin_hdmiaudio.c

Log Message:
add HDMI audio driver


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/allwinner/awin_hdmi.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/allwinner/awin_hdmiaudio.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/allwinner/awin_io.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.6 src/sys/arch/arm/allwinner/awin_hdmi.c:1.7
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.6	Mon Nov 10 18:18:09 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Tue Nov 11 17:00:59 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.6 2014/11/10 18:18:09 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.7 2014/11/11 17:00:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -33,7 +33,7 @@
 #define AWIN_HDMI_PLL	3	/* PLL7 or PLL3 */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.6 2014/11/10 18:18:09 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.7 2014/11/11 17:00:59 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -102,6 +102,7 @@ static void	awin_hdmi_thread(void *);
 #if 0
 static int	awin_hdmi_intr(void *);
 #endif
+
 #if defined(DDB)
 void		awin_hdmi_dump_regs(void);
 #endif
@@ -533,7 +534,8 @@ awin_hdmi_video_enable(struct awin_hdmi_
 }
 
 static void
-awin_hdmi_set_videomode(struct awin_hdmi_softc *sc, const struct videomode *mode)
+awin_hdmi_set_videomode(struct awin_hdmi_softc *sc,
+const struct videomode *mode)
 {
 	uint32_t val;
 	const u_int dblscan_p = !!(mode-flags  VID_DBLSCAN);
@@ -598,6 +600,8 @@ awin_hdmi_set_videomode(struct awin_hdmi
 #endif
 
 	val = HDMI_READ(sc, AWIN_HDMI_VID_CTRL_REG);
+	val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_HDMI_MODE_HDMI,
+			 AWIN_HDMI_VID_CTRL_HDMI_MODE);
 	if (dblscan_p) {
 		val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_REPEATER_SEL_2X,
  AWIN_HDMI_VID_CTRL_REPEATER_SEL);
@@ -651,13 +655,81 @@ awin_hdmi_set_videomode(struct awin_hdmi
 	val |= __SHIFTIN(AWIN_HDMI_VID_TIMING_4_TX_CLOCK_NORMAL,
 			 AWIN_HDMI_VID_TIMING_4_TX_CLOCK);
 	HDMI_WRITE(sc, AWIN_HDMI_VID_TIMING_4_REG, val);
+
+	/* Packet control */
+	HDMI_WRITE(sc, AWIN_HDMI_PKT_CTRL0_REG, 0x5321);
+	HDMI_WRITE(sc, AWIN_HDMI_PKT_CTRL1_REG, 0x000f);
 }
 
 static void
-awin_hdmi_set_audiomode(struct awin_hdmi_softc *sc, const struct videomode *mode)
+awin_hdmi_set_audiomode(struct awin_hdmi_softc *sc,
+const struct videomode *mode)
 {
-	/* TODO */
-	HDMI_WRITE(sc, AWIN_HDMI_AUD_CTRL_REG, 0);
+	uint32_t cts, n, val;
+
+	/*
+	 * Before changing audio parameters, disable and reset the
+	 * audio module. Wait for the soft reset bit to clear before
+	 * configuring the audio parameters.
+	 */
+	val = HDMI_READ(sc, AWIN_HDMI_AUD_CTRL_REG);
+	val = ~AWIN_HDMI_AUD_CTRL_EN;
+	val |= AWIN_HDMI_AUD_CTRL_RST;
+	HDMI_WRITE(sc, AWIN_HDMI_AUD_CTRL_REG, val);
+	do {
+		val = HDMI_READ(sc, AWIN_HDMI_AUD_CTRL_REG);
+	} while (val  AWIN_HDMI_AUD_CTRL_RST);
+
+	/* DMA  FIFO control */
+	val = HDMI_READ(sc, AWIN_HDMI_ADMA_CTRL_REG);
+	val |= AWIN_HDMI_ADMA_CTRL_SRC_DMA_MODE;	/* NDMA */
+	val = ~AWIN_HDMI_ADMA_CTRL_SRC_DMA_SAMPLE_RATE;
+	val = ~AWIN_HDMI_ADMA_CTRL_SRC_SAMPLE_LAYOUT;
+	val = ~AWIN_HDMI_ADMA_CTRL_SRC_WORD_LEN;
+	val = ~AWIN_HDMI_ADMA_CTRL_DATA_SEL;
+	HDMI_WRITE(sc, AWIN_HDMI_ADMA_CTRL_REG, val);
+
+	/* Audio format control */
+	val = HDMI_READ(sc, AWIN_HDMI_AUD_FMT_REG);
+	val = ~AWIN_HDMI_AUD_FMT_SRC_SEL;
+	val = ~AWIN_HDMI_AUD_FMT_SEL;
+	val = ~AWIN_HDMI_AUD_FMT_DSD_FMT;
+	val = ~AWIN_HDMI_AUD_FMT_LAYOUT;
+	val = ~AWIN_HDMI_AUD_FMT_SRC_CH_CFG;
+	val |= __SHIFTIN(1, AWIN_HDMI_AUD_FMT_SRC_CH_CFG);
+	HDMI_WRITE(sc, AWIN_HDMI_AUD_FMT_REG, val);
+
+	/* PCM control (channel map) */
+	HDMI_WRITE(sc, AWIN_HDMI_AUD_PCM_CTRL_REG, 0x76543210);
+
+	/* Clock setup */
+	n = 6144;	/* 48 kHz */
+	cts = ((mode-dot_clock * 10) * (n / 128)) / 480;
+	HDMI_WRITE(sc, AWIN_HDMI_AUD_CTS_REG, cts);
+	HDMI_WRITE(sc, AWIN_HDMI_AUD_N_REG, n);
+
+	/* Audio PCM channel status 0 */
+	val = __SHIFTIN(AWIN_HDMI_AUD_CH_STATUS0_FS_FREQ_48,
+			AWIN_HDMI_AUD_CH_STATUS0_FS_FREQ);
+	HDMI_WRITE(sc, AWIN_HDMI_AUD_CH_STATUS0_REG, val);
+
+	/* Audio PCM channel status 1 */
+	val = HDMI_READ(sc, AWIN_HDMI_AUD_CH_STATUS1_REG);
+	val = ~AWIN_HDMI_AUD_CH_STATUS1_CGMS_A;
+	val = ~AWIN_HDMI_AUD_CH_STATUS1_ORIGINAL_FS;
+	val = ~AWIN_HDMI_AUD_CH_STATUS1_WORD_LEN;
+	val |= __SHIFTIN(5, AWIN_HDMI_AUD_CH_STATUS1_WORD_LEN);
+	val |= AWIN_HDMI_AUD_CH_STATUS1_WORD_LEN_MAX;
+	HDMI_WRITE(sc, 

CVS commit: src/sys/arch/arm/allwinner

2014-11-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 11 17:14:38 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmiaudio.c

Log Message:
AWIN_HDMI_ADMA_CTRL_FIFO_CLEAR causes playback to stop working, dont set it


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/allwinner/awin_hdmiaudio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmiaudio.c
diff -u src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.1 src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.2
--- src/sys/arch/arm/allwinner/awin_hdmiaudio.c:1.1	Tue Nov 11 17:00:59 2014
+++ src/sys/arch/arm/allwinner/awin_hdmiaudio.c	Tue Nov 11 17:14:38 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmiaudio.c,v 1.1 2014/11/11 17:00:59 jmcneill Exp $ */
+/* $NetBSD: awin_hdmiaudio.c,v 1.2 2014/11/11 17:14:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmiaudio.c,v 1.1 2014/11/11 17:00:59 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmiaudio.c,v 1.2 2014/11/11 17:14:38 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -361,13 +361,6 @@ awin_hdmiaudio_close(void *priv)
 static int
 awin_hdmiaudio_drain(void *priv)
 {
-	struct awin_hdmiaudio_softc *sc = priv;
-	uint32_t val;
-
-	val = HDMIAUDIO_READ(sc, AWIN_HDMI_ADMA_CTRL_REG);
-	val |= AWIN_HDMI_ADMA_CTRL_FIFO_CLEAR;
-	HDMIAUDIO_WRITE(sc, AWIN_HDMI_ADMA_CTRL_REG, val);
-
 	return 0;
 }
 



CVS commit: src/sys/arch/arm/allwinner

2014-11-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 11 17:27:12 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmi.c

Log Message:
only dump regs when enabling audio if AWIN_HDMI_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/allwinner/awin_hdmi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.7 src/sys/arch/arm/allwinner/awin_hdmi.c:1.8
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.7	Tue Nov 11 17:00:59 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Tue Nov 11 17:27:12 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.7 2014/11/11 17:00:59 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.8 2014/11/11 17:27:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -33,7 +33,7 @@
 #define AWIN_HDMI_PLL	3	/* PLL7 or PLL3 */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.7 2014/11/11 17:00:59 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.8 2014/11/11 17:27:12 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -727,7 +727,7 @@ awin_hdmi_set_audiomode(struct awin_hdmi
 	val |= AWIN_HDMI_AUD_CTRL_EN;
 	HDMI_WRITE(sc, AWIN_HDMI_AUD_CTRL_REG, val);
 
-#if defined(DDB)
+#if defined(AWIN_HDMI_DEBUG)  defined(DDB)
 	awin_hdmi_dump_regs();
 #endif
 }



CVS commit: src/sys/arch/arm/allwinner

2014-11-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov 11 19:22:32 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c awin_hdmi.c awin_tcon.c
files.awin

Log Message:
defflag AWIN_HDMI_DEBUG, AWIN_TCON_DEBUG, AWIN_DEBE_DEBUG, and defparam 
AWIN_DEBE_VIDEOMEM


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/allwinner/awin_debe.c \
src/sys/arch/arm/allwinner/awin_tcon.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/allwinner/awin_hdmi.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.3 src/sys/arch/arm/allwinner/awin_debe.c:1.4
--- src/sys/arch/arm/allwinner/awin_debe.c:1.3	Mon Nov 10 17:55:25 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Tue Nov 11 19:22:32 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.3 2014/11/10 17:55:25 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.4 2014/11/11 19:22:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -26,14 +26,15 @@
  * SUCH DAMAGE.
  */
 
+#include opt_allwinner.h
+#include genfb.h
+
 #ifndef AWIN_DEBE_VIDEOMEM
 #define AWIN_DEBE_VIDEOMEM	(16 * 1024 * 1024)
 #endif
 
-#include genfb.h
-
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.3 2014/11/10 17:55:25 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.4 2014/11/11 19:22:32 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
Index: src/sys/arch/arm/allwinner/awin_tcon.c
diff -u src/sys/arch/arm/allwinner/awin_tcon.c:1.3 src/sys/arch/arm/allwinner/awin_tcon.c:1.4
--- src/sys/arch/arm/allwinner/awin_tcon.c:1.3	Mon Nov 10 17:55:25 2014
+++ src/sys/arch/arm/allwinner/awin_tcon.c	Tue Nov 11 19:22:32 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_tcon.c,v 1.3 2014/11/10 17:55:25 jmcneill Exp $ */
+/* $NetBSD: awin_tcon.c,v 1.4 2014/11/11 19:22:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -26,10 +26,10 @@
  * SUCH DAMAGE.
  */
 
-//#define AWIN_TCON_DEBUG
+#include opt_allwinner.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_tcon.c,v 1.3 2014/11/10 17:55:25 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_tcon.c,v 1.4 2014/11/11 19:22:32 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.8 src/sys/arch/arm/allwinner/awin_hdmi.c:1.9
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.8	Tue Nov 11 17:27:12 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Tue Nov 11 19:22:32 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.8 2014/11/11 17:27:12 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.9 2014/11/11 19:22:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -26,14 +26,13 @@
  * SUCH DAMAGE.
  */
 
-//#define AWIN_HDMI_DEBUG
-
+#include opt_allwinner.h
 #include opt_ddb.h
 
 #define AWIN_HDMI_PLL	3	/* PLL7 or PLL3 */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.8 2014/11/11 17:27:12 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.9 2014/11/11 19:22:32 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h

Index: src/sys/arch/arm/allwinner/files.awin
diff -u src/sys/arch/arm/allwinner/files.awin:1.24 src/sys/arch/arm/allwinner/files.awin:1.25
--- src/sys/arch/arm/allwinner/files.awin:1.24	Tue Nov 11 17:00:59 2014
+++ src/sys/arch/arm/allwinner/files.awin	Tue Nov 11 19:22:32 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: files.awin,v 1.24 2014/11/11 17:00:59 jmcneill Exp $
+#	$NetBSD: files.awin,v 1.25 2014/11/11 19:22:32 jmcneill Exp $
 #
 # Configuration info for Allwinner ARM Peripherals
 #
@@ -28,6 +28,10 @@ defflag opt_allwinner.hALLWINNER_A20
 defflag opt_allwinner.hALLWINNER_A31
 defflag opt_allwinner.hALLWINNER_A80
 defflag opt_allwinner.hAWIN_GPIO_IGNORE_FW
+defflag opt_allwinner.hAWIN_HDMI_DEBUG
+defflag opt_allwinner.hAWIN_TCON_DEBUG
+defflag opt_allwinner.hAWIN_DEBE_DEBUG
+defparam opt_allwinner.h			AWIN_DEBE_VIDEOMEM
 
 # SoC I/O attach point
 device	awinio { [port=-1] } : bus_space_generic



CVS commit: src/sys/arch/arm/allwinner

2014-11-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Nov 10 17:55:25 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_board.c awin_debe.c awin_fb.c
awin_hdmi.c awin_reg.h awin_tcon.c awin_var.h

Log Message:
HDMI framebuffer support, tested on Cubieboard2 and Hummingbird A31.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/allwinner/awin_board.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/allwinner/awin_debe.c \
src/sys/arch/arm/allwinner/awin_fb.c \
src/sys/arch/arm/allwinner/awin_tcon.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/allwinner/awin_hdmi.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/allwinner/awin_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_board.c
diff -u src/sys/arch/arm/allwinner/awin_board.c:1.26 src/sys/arch/arm/allwinner/awin_board.c:1.27
--- src/sys/arch/arm/allwinner/awin_board.c:1.26	Sun Nov  9 14:10:54 2014
+++ src/sys/arch/arm/allwinner/awin_board.c	Mon Nov 10 17:55:25 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_board.c,v 1.26 2014/11/09 14:10:54 jmcneill Exp $	*/
+/*	$NetBSD: awin_board.c,v 1.27 2014/11/10 17:55:25 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: awin_board.c,v 1.26 2014/11/09 14:10:54 jmcneill Exp $);
+__KERNEL_RCSID(1, $NetBSD: awin_board.c,v 1.27 2014/11/10 17:55:25 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -411,9 +411,6 @@ awin_pll3_enable(void)
 		ncfg = ~AWIN_A31_PLL3_CFG_MODE;
 		ncfg = ~AWIN_A31_PLL3_CFG_MODE_SEL;
 		ncfg |= AWIN_A31_PLL3_CFG_FRAC_CLK_OUT;
-		/* 24MHz*N/M - for 29.7MHz, N=99, M=8 */
-		ncfg |= __SHIFTIN(98, AWIN_A31_PLL3_CFG_FACTOR_N);
-		ncfg |= __SHIFTIN(7, AWIN_A31_PLL3_CFG_PREDIV_M);
 		ncfg |= AWIN_PLL_CFG_ENABLE;
 	} else {
 		ncfg = ~AWIN_PLL3_MODE_SEL;
@@ -424,6 +421,13 @@ awin_pll3_enable(void)
 	if (ncfg != ocfg) {
 		bus_space_write_4(bst, bsh,
 		AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG, ncfg);
+
+		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+			do {
+ncfg = bus_space_read_4(bst, bsh,
+AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG);
+			} while ((ncfg  AWIN_A31_PLL3_CFG_LOCK) == 0);
+		}
 	}
 }
 
@@ -445,11 +449,6 @@ awin_pll7_enable(void)
 		ncfg = ~AWIN_A31_PLL7_CFG_MODE;
 		ncfg = ~AWIN_A31_PLL7_CFG_MODE_SEL;
 		ncfg |= AWIN_A31_PLL7_CFG_FRAC_CLK_OUT;
-		/* 24MHz*N/M - for 29.7MHz, N=99, M=8 */
-		ncfg = ~AWIN_A31_PLL7_CFG_FACTOR_N;
-		ncfg = ~AWIN_A31_PLL7_CFG_PREDIV_M;
-		ncfg |= __SHIFTIN(98, AWIN_A31_PLL7_CFG_FACTOR_N);
-		ncfg |= __SHIFTIN(7, AWIN_A31_PLL7_CFG_PREDIV_M);
 		ncfg |= AWIN_PLL_CFG_ENABLE;
 	} else {
 		ncfg = ~AWIN_PLL7_MODE_SEL;
@@ -477,18 +476,18 @@ awin_pll3_set_rate(uint32_t rate)
 		ncfg = ~AWIN_PLL_CFG_ENABLE;
 	} else {
 		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
-			unsigned int m = rate / 300;
-			ncfg |= AWIN_PLL3_MODE_SEL;
-			ncfg = ~AWIN_PLL3_FACTOR_M;
-			ncfg |= __SHIFTIN(m, AWIN_PLL3_FACTOR_M);
-		} else {
 			unsigned int m = 8;
-			unsigned int n = rate / 300;
+			unsigned int n = rate / (AWIN_REF_FREQ / m);
 			ncfg |= AWIN_A31_PLL3_CFG_MODE_SEL;
 			ncfg = ~AWIN_A31_PLL3_CFG_FACTOR_N;
 			ncfg |= __SHIFTIN(n - 1, AWIN_A31_PLL3_CFG_FACTOR_N);
 			ncfg = ~AWIN_A31_PLL3_CFG_PREDIV_M;
 			ncfg |= __SHIFTIN(m - 1, AWIN_A31_PLL3_CFG_PREDIV_M);
+		} else {
+			unsigned int m = rate / 300;
+			ncfg |= AWIN_PLL3_MODE_SEL;
+			ncfg = ~AWIN_PLL3_FACTOR_M;
+			ncfg |= __SHIFTIN(m, AWIN_PLL3_FACTOR_M);
 		}
 		ncfg |= AWIN_PLL_CFG_ENABLE;
 	}
@@ -496,5 +495,54 @@ awin_pll3_set_rate(uint32_t rate)
 	if (ncfg != ocfg) {
 		bus_space_write_4(bst, bsh,
 		AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG, ncfg);
+
+		if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+			do {
+ncfg = bus_space_read_4(bst, bsh,
+AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG);
+			} while ((ncfg  AWIN_A31_PLL3_CFG_LOCK) == 0);
+		}
 	}
 }
+
+uint32_t
+awin_pll5x_get_rate(void)
+{
+	bus_space_tag_t bst = awin_bs_tag;
+	bus_space_handle_t bsh = awin_core_bsh;
+	unsigned int n, k, p;
+
+	KASSERT(awin_chip_id() != AWIN_CHIP_ID_A31);
+
+	const uint32_t cfg = bus_space_read_4(bst, bsh,
+	AWIN_CCM_OFFSET + AWIN_PLL5_CFG_REG);
+
+	n = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_N);
+	k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K);
+	p = __SHIFTOUT(cfg, AWIN_PLL5_OUT_EXT_DIV_P);
+
+	return (AWIN_REF_FREQ * n * k)  p;
+}
+
+uint32_t
+awin_pll6_get_rate(void)
+{
+	bus_space_tag_t bst = awin_bs_tag;
+	bus_space_handle_t bsh = awin_core_bsh;
+	unsigned int n, k, m;
+
+	const uint32_t cfg = bus_space_read_4(bst, bsh,
+	AWIN_CCM_OFFSET + AWIN_PLL6_CFG_REG);
+
+	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+		n = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_N) + 1;
+		k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K) + 1;
+		m = 2;
+	} else {
+		n = 

CVS commit: src/sys/arch/arm/allwinner

2014-11-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Nov 10 18:18:09 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmi.c

Log Message:
hide edid dump with AWIN_HDMI_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/allwinner/awin_hdmi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.5 src/sys/arch/arm/allwinner/awin_hdmi.c:1.6
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.5	Mon Nov 10 17:55:25 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Mon Nov 10 18:18:09 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.5 2014/11/10 17:55:25 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.6 2014/11/10 18:18:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -33,7 +33,7 @@
 #define AWIN_HDMI_PLL	3	/* PLL7 or PLL3 */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.5 2014/11/10 17:55:25 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.6 2014/11/10 18:18:09 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -271,10 +271,12 @@ awin_hdmi_i2c_exec(void *priv, i2c_op_t 
 			AWIN_A31_HDMI_DDC_FIFO_ACCESS_REG, pbuf, blklen);
 		}
 
+#ifdef AWIN_HDMI_DEBUG
 		printf(off=%d:, (int)off);
 		for (int i = 0; i  blklen; i++)
 			printf( %02x, pbuf[i]);
 		printf(\n);
+#endif
 
 		pbuf += blklen;
 		off += blklen;



CVS commit: src/sys/arch/arm/allwinner

2014-11-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  9 14:30:55 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_debe.c awin_fb.c awin_hdmi.c
awin_tcon.c awin_var.h files.awin

Log Message:
If we can't determine the preferred display mode for some reason, fallback
to 640x480.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/allwinner/awin_debe.c \
src/sys/arch/arm/allwinner/awin_fb.c \
src/sys/arch/arm/allwinner/awin_tcon.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/allwinner/awin_hdmi.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/allwinner/awin_var.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.1 src/sys/arch/arm/allwinner/awin_debe.c:1.2
--- src/sys/arch/arm/allwinner/awin_debe.c:1.1	Sun Nov  9 14:10:54 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Sun Nov  9 14:30:55 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.1 2014/11/09 14:10:54 jmcneill Exp $ */
+/* $NetBSD: awin_debe.c,v 1.2 2014/11/09 14:30:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -33,7 +33,7 @@
 #include genfb.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.1 2014/11/09 14:10:54 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_debe.c,v 1.2 2014/11/09 14:30:55 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -74,7 +74,7 @@ static void	awin_debe_attach(device_t, d
 
 static int	awin_debe_alloc_videomem(struct awin_debe_softc *);
 static void	awin_debe_setup_fbdev(struct awin_debe_softc *,
-  struct videomode *);
+  const struct videomode *);
 
 CFATTACH_DECL_NEW(awin_debe, sizeof(struct awin_debe_softc),
 	awin_debe_match, awin_debe_attach, NULL, NULL);
@@ -202,9 +202,9 @@ free:
 }
 
 static void
-awin_debe_setup_fbdev(struct awin_debe_softc *sc, struct videomode *mode)
+awin_debe_setup_fbdev(struct awin_debe_softc *sc, const struct videomode *mode)
 {
-	if (sc-sc_fbdev == NULL) {
+	if (mode  sc-sc_fbdev == NULL) {
 		struct awinfb_attach_args afb = {
 			.afb_fb = sc-sc_dmap,
 			.afb_width = mode-hdisplay,
@@ -218,14 +218,14 @@ awin_debe_setup_fbdev(struct awin_debe_s
 		afb, NULL);
 	}
 #if NGENFB  0
-	else {
+	else if (sc-sc_fbdev != NULL) {
 		awin_fb_set_videomode(sc-sc_fbdev, mode);
 	}
 #endif
 }
 
 void
-awin_debe_set_videomode(struct videomode *mode)
+awin_debe_set_videomode(const struct videomode *mode)
 {
 	struct awin_debe_softc *sc;
 	device_t dev;
Index: src/sys/arch/arm/allwinner/awin_fb.c
diff -u src/sys/arch/arm/allwinner/awin_fb.c:1.1 src/sys/arch/arm/allwinner/awin_fb.c:1.2
--- src/sys/arch/arm/allwinner/awin_fb.c:1.1	Sun Nov  9 14:10:54 2014
+++ src/sys/arch/arm/allwinner/awin_fb.c	Sun Nov  9 14:30:55 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_fb.c,v 1.1 2014/11/09 14:10:54 jmcneill Exp $ */
+/* $NetBSD: awin_fb.c,v 1.2 2014/11/09 14:30:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.1 2014/11/09 14:10:54 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_fb.c,v 1.2 2014/11/09 14:30:55 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -180,7 +180,7 @@ awin_fb_ddb_trap_callback(int where)
 }
 
 void
-awin_fb_set_videomode(device_t dev, struct videomode *mode)
+awin_fb_set_videomode(device_t dev, const struct videomode *mode)
 {
 	struct awin_fb_softc *sc = device_private(dev);
 
Index: src/sys/arch/arm/allwinner/awin_tcon.c
diff -u src/sys/arch/arm/allwinner/awin_tcon.c:1.1 src/sys/arch/arm/allwinner/awin_tcon.c:1.2
--- src/sys/arch/arm/allwinner/awin_tcon.c:1.1	Sun Nov  9 14:10:54 2014
+++ src/sys/arch/arm/allwinner/awin_tcon.c	Sun Nov  9 14:30:55 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_tcon.c,v 1.1 2014/11/09 14:10:54 jmcneill Exp $ */
+/* $NetBSD: awin_tcon.c,v 1.2 2014/11/09 14:30:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_tcon.c,v 1.1 2014/11/09 14:10:54 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_tcon.c,v 1.2 2014/11/09 14:30:55 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -60,7 +60,8 @@ struct awin_tcon_softc {
 static int	awin_tcon_match(device_t, cfdata_t, void *);
 static void	awin_tcon_attach(device_t, device_t, void *);
 
-static void	awin_tcon_set_pll(struct awin_tcon_softc *, struct videomode *);
+static void	awin_tcon_set_pll(struct awin_tcon_softc *,
+  const struct videomode *);
 
 CFATTACH_DECL_NEW(awin_tcon, sizeof(struct awin_tcon_softc),
 	awin_tcon_match, awin_tcon_attach, NULL, NULL);
@@ -133,7 +134,7 @@ awin_tcon_attach(device_t parent, device
 }
 
 static void

CVS commit: src/sys/arch/arm/allwinner

2014-11-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov  8 11:28:52 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h

Log Message:
add some more A31 soft reset bits


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.44 src/sys/arch/arm/allwinner/awin_reg.h:1.45
--- src/sys/arch/arm/allwinner/awin_reg.h:1.44	Sat Nov  8 00:31:54 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Sat Nov  8 11:28:52 2014
@@ -1888,7 +1888,21 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_A31_AHB_RESET0_SS_RST		__BIT(5)
 #define AWIN_A31_AHB_RESET0_MIPIDSI_RST		__BIT(1)
 
+#define AWIN_A31_AHB_RESET1_DRC1_RST		__BIT(26)
+#define AWIN_A31_AHB_RESET1_DRC0_RST		__BIT(25)
+#define AWIN_A31_AHB_RESET1_DEU1_RST		__BIT(24)
+#define AWIN_A31_AHB_RESET1_DEU0_RST		__BIT(23)
+#define AWIN_A31_AHB_RESET1_GPU_RST		__BIT(20)
+#define AWIN_A31_AHB_RESET1_MP_RST		__BIT(18)
+#define AWIN_A31_AHB_RESET1_FE1_RST		__BIT(15)
+#define AWIN_A31_AHB_RESET1_FE0_RST		__BIT(14)
+#define AWIN_A31_AHB_RESET1_BE1_RST		__BIT(13)
+#define AWIN_A31_AHB_RESET1_BE0_RST		__BIT(12)
 #define AWIN_A31_AHB_RESET1_HDMI_RST		__BIT(11)
+#define AWIN_A31_AHB_RESET1_CSI_RST		__BIT(8)
+#define AWIN_A31_AHB_RESET1_LCD1_RST		__BIT(5)
+#define AWIN_A31_AHB_RESET1_LCD0_RST		__BIT(4)
+#define AWIN_A31_AHB_RESET1_VE_RST		__BIT(0)
 
 #define AWIN_A31_APB1_RESET_DAUDIO1_RST		__BIT(13)
 #define AWIN_A31_APB1_RESET_DAUDIO0_RST		__BIT(12)



CVS commit: src/sys/arch/arm/allwinner

2014-11-07 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov  7 18:10:16 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_reg.h awin_rtc.c

Log Message:
Allwinner A20 RTC has a different idea about years than the rest of them.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/allwinner/awin_rtc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.42 src/sys/arch/arm/allwinner/awin_reg.h:1.43
--- src/sys/arch/arm/allwinner/awin_reg.h:1.42	Wed Nov  5 15:05:20 2014
+++ src/sys/arch/arm/allwinner/awin_reg.h	Fri Nov  7 18:10:16 2014
@@ -1517,8 +1517,10 @@ struct awin_mmc_idma_descriptor {
 	 AWIN_LOSC_CTRL_RTC_YYMMDD_ACCE)
 
 #define AWIN_RTC_YY_MM_DD_RTC_SIM_CTRL	__BIT(30)
-#define AWIN_RTC_YY_MM_DD_LEAP		__BIT(24)
-#define AWIN_RTC_YY_MM_DD_YEAR		__BITS(23,16)
+#define AWIN_RTC_YY_MM_DD_LEAP		__BIT(22)
+#define AWIN_A20_RTC_YY_MM_DD_LEAP	__BIT(24)
+#define AWIN_RTC_YY_MM_DD_YEAR		__BITS(21,16)
+#define AWIN_A20_RTC_YY_MM_DD_YEAR	__BITS(23,16)
 #define AWIN_RTC_YY_MM_DD_MONTH		__BITS(11,8)
 #define AWIN_RTC_YY_MM_DD_DAY		__BITS(4,0)
 #define AWIN_RTC_HH_MM_SS_WK_NO		__BITS(31,29)
@@ -1907,8 +1909,6 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_A31_RTC_YY_MM_DD_REG		0x0010
 #define AWIN_A31_RTC_HH_MM_SS_REG		0x0014
 
-#define AWIN_A31_RTC_YY_MM_DD_YEAR		__BITS(21,16)
-
 #define AWIN_A31_P2WI_CTRL_REG			0x
 #define AWIN_A31_P2WI_CCR_REG			0x0004
 #define AWIN_A31_P2WI_INTE_REG			0x0008

Index: src/sys/arch/arm/allwinner/awin_rtc.c
diff -u src/sys/arch/arm/allwinner/awin_rtc.c:1.6 src/sys/arch/arm/allwinner/awin_rtc.c:1.7
--- src/sys/arch/arm/allwinner/awin_rtc.c:1.6	Tue Nov  4 19:22:50 2014
+++ src/sys/arch/arm/allwinner/awin_rtc.c	Fri Nov  7 18:10:16 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_rtc.c,v 1.6 2014/11/04 19:22:50 jmcneill Exp $ */
+/* $NetBSD: awin_rtc.c,v 1.7 2014/11/07 18:10:16 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_rtc.c,v 1.6 2014/11/04 19:22:50 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_rtc.c,v 1.7 2014/11/07 18:10:16 jakllsch Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -49,6 +49,8 @@ struct awin_rtc_softc {
 	uint32_t sc_loscctrl_reg;
 	uint32_t sc_yymmdd_reg;
 	uint32_t sc_hhmmss_reg;
+	uint32_t sc_year_base;
+	uint32_t sc_year_mask;
 };
 
 #define RTC_READ(sc, reg) \
@@ -99,6 +101,17 @@ awin_rtc_attach(device_t parent, device_
 		sc-sc_hhmmss_reg = AWIN_RTC_HH_MM_SS_REG;
 	}
 
+	if (awin_chip_id() == AWIN_CHIP_ID_A20) {
+		sc-sc_year_base = 1900;
+		sc-sc_year_mask = AWIN_A20_RTC_YY_MM_DD_YEAR;
+	} else {
+		sc-sc_year_base = POSIX_BASE_YEAR;
+		sc-sc_year_mask = AWIN_RTC_YY_MM_DD_YEAR;
+	}
+#ifdef AWIN_RTC_BASE_YEAR
+	sc-sc_year_base = AWIN_RTC_BASE_YEAR;
+#endif
+
 	aprint_naive(\n);
 	aprint_normal(: RTC\n);
 
@@ -117,10 +130,7 @@ awin_rtc_gettime(todr_chip_handle_t tch,
 	yymmdd = RTC_READ(sc, sc-sc_yymmdd_reg);
 	hhmmss = RTC_READ(sc, sc-sc_hhmmss_reg);
 
-	dt-dt_year = __SHIFTOUT(yymmdd,
-	awin_chip_id() == AWIN_CHIP_ID_A31 ?
-	AWIN_A31_RTC_YY_MM_DD_YEAR : AWIN_RTC_YY_MM_DD_YEAR) +
-	POSIX_BASE_YEAR;
+	dt-dt_year = __SHIFTOUT(yymmdd, sc-sc_year_mask) + sc-sc_year_base;
 	dt-dt_mon = __SHIFTOUT(yymmdd, AWIN_RTC_YY_MM_DD_MONTH);
 	dt-dt_day = __SHIFTOUT(yymmdd, AWIN_RTC_YY_MM_DD_DAY);
 	dt-dt_wday = __SHIFTOUT(hhmmss, AWIN_RTC_HH_MM_SS_WK_NO);
@@ -149,24 +159,18 @@ awin_rtc_settime(todr_chip_handle_t tch,
 		not writing back time\n, dt-dt_year);
 		return EIO;
 	}
-	maxyear = __SHIFTOUT(0x, 
-	awin_chip_id() == AWIN_CHIP_ID_A31 ?
-	AWIN_A31_RTC_YY_MM_DD_YEAR : AWIN_RTC_YY_MM_DD_YEAR)
-	+ POSIX_BASE_YEAR;
+	maxyear = __SHIFTOUT(0x, sc-sc_year_mask) + sc-sc_year_base;
 	if (dt-dt_year  maxyear) {
 		aprint_normal_dev(sc-sc_dev, year exceeds available field:
 		 %llu, not writing back time\n, dt-dt_year);
 		return EIO;
 	}
 
-	yymmdd = __SHIFTIN(dt-dt_year - POSIX_BASE_YEAR,
-	awin_chip_id() == AWIN_CHIP_ID_A31 ?
-	AWIN_A31_RTC_YY_MM_DD_YEAR : AWIN_RTC_YY_MM_DD_YEAR);
-
-	KASSERT(__SHIFTOUT(yymmdd,
-	awin_chip_id() == AWIN_CHIP_ID_A31 ?
-	AWIN_A31_RTC_YY_MM_DD_YEAR : AWIN_RTC_YY_MM_DD_YEAR) +
-	POSIX_BASE_YEAR == dt-dt_year);
+	yymmdd = __SHIFTIN(dt-dt_year - sc-sc_year_base,
+	sc-sc_year_mask);
+
+	KASSERT(__SHIFTOUT(yymmdd, sc-sc_year_mask) +
+	sc-sc_year_base == dt-dt_year);
 
 	yymmdd |= __SHIFTIN(dt-dt_mon, AWIN_RTC_YY_MM_DD_MONTH);
 	yymmdd |= __SHIFTIN(dt-dt_day, AWIN_RTC_YY_MM_DD_DAY);



CVS commit: src/sys/arch/arm/allwinner

2014-11-07 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Nov  7 23:00:56 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: files.awin

Log Message:
Add ALLWINNER_A80


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/allwinner/files.awin

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/files.awin
diff -u src/sys/arch/arm/allwinner/files.awin:1.19 src/sys/arch/arm/allwinner/files.awin:1.20
--- src/sys/arch/arm/allwinner/files.awin:1.19	Wed Nov  5 15:05:20 2014
+++ src/sys/arch/arm/allwinner/files.awin	Fri Nov  7 23:00:56 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: files.awin,v 1.19 2014/11/05 15:05:20 jmcneill Exp $
+#	$NetBSD: files.awin,v 1.20 2014/11/07 23:00:56 matt Exp $
 #
 # Configuration info for Allwinner ARM Peripherals
 #
@@ -26,6 +26,7 @@ defflag opt_allwinner.hAWINETH_COUNT
 defflag opt_allwinner.hALLWINNER_A10
 defflag opt_allwinner.hALLWINNER_A20
 defflag opt_allwinner.hALLWINNER_A31
+defflag opt_allwinner.hALLWINNER_A80
 defflag opt_allwinner.hAWIN_GPIO_IGNORE_FW
 
 # SoC I/O attach point



CVS commit: src/sys/arch/arm/allwinner

2014-11-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov  8 00:31:54 UTC 2014

Modified Files:
src/sys/arch/arm/allwinner: awin_hdmi.c awin_reg.h

Log Message:
Core version 1.4 (as found in A31) has a different DDC register layout. Add
support for it.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/allwinner/awin_hdmi.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/allwinner/awin_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_hdmi.c
diff -u src/sys/arch/arm/allwinner/awin_hdmi.c:1.1 src/sys/arch/arm/allwinner/awin_hdmi.c:1.2
--- src/sys/arch/arm/allwinner/awin_hdmi.c:1.1	Thu Sep 11 02:21:19 2014
+++ src/sys/arch/arm/allwinner/awin_hdmi.c	Sat Nov  8 00:31:54 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.1 2014/09/11 02:21:19 jmcneill Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.2 2014/11/08 00:31:54 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill jmcne...@invisible.ca
@@ -26,8 +26,10 @@
  * SUCH DAMAGE.
  */
 
+#define AWIN_HDMI_PLL	7	/* PLL7 or PLL3 */
+
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.1 2014/09/11 02:21:19 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,v 1.2 2014/11/08 00:31:54 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -48,9 +50,6 @@ __KERNEL_RCSID(0, $NetBSD: awin_hdmi.c,
 #include dev/videomode/videomode.h
 #include dev/videomode/edidvar.h
 
-/* NB: Should be 16, but it doesn't seem to work */
-#define HDMI_I2C_MAX_BLKLEN	1
-
 struct awin_hdmi_softc {
 	device_t sc_dev;
 	bus_space_tag_t sc_bst;
@@ -62,6 +61,9 @@ struct awin_hdmi_softc {
 	kmutex_t sc_ic_lock;
 
 	bool sc_connected;
+
+	uint32_t sc_ver;
+	unsigned int sc_i2c_blklen;
 };
 
 #define HDMI_READ(sc, reg)			\
@@ -69,6 +71,9 @@ struct awin_hdmi_softc {
 #define HDMI_WRITE(sc, reg, val)		\
 bus_space_write_4((sc)-sc_bst, (sc)-sc_bsh, (reg), (val));
 
+#define HDMI_1_3_P(sc)	((sc)-sc_ver == 0x0103)
+#define HDMI_1_4_P(sc)	((sc)-sc_ver == 0x0104)
+
 static int	awin_hdmi_match(device_t, cfdata_t, void *);
 static void	awin_hdmi_attach(device_t, device_t, void *);
 
@@ -108,19 +113,34 @@ awin_hdmi_attach(device_t parent, device
 	struct awin_hdmi_softc *sc = device_private(self);
 	struct awinio_attach_args * const aio = aux;
 	const struct awin_locators * const loc = aio-aio_loc;
-	uint32_t ver;
+	uint32_t ver, clk;
 
 	sc-sc_dev = self;
 	sc-sc_bst = aio-aio_core_bst;
 	bus_space_subregion(sc-sc_bst, aio-aio_core_bsh,
 	loc-loc_offset, loc-loc_size, sc-sc_bsh);
 
+#if AWIN_HDMI_PLL == 3
+	awin_pll3_enable();
+#elif AWIN_HDMI_PLL == 7
 	awin_pll7_enable();
+#else
+#error AWIN_HDMI_PLL must be 3 or 7
+#endif
+
+	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+		awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
+		AWIN_A31_AHB_RESET1_REG, AWIN_A31_AHB_RESET1_HDMI_RST, 0);
+	}
+
+	clk = __SHIFTIN(AWIN_HDMI_CLK_SRC_SEL_PLL7, AWIN_HDMI_CLK_SRC_SEL);
+	clk |= __SHIFTIN(0, AWIN_HDMI_CLK_DIV_RATIO_M);
+	clk |= AWIN_CLK_ENABLE;
+	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+		clk |= AWIN_A31_HDMI_CLK_DDC_GATING;
+	}
 	bus_space_write_4(aio-aio_core_bst, aio-aio_ccm_bsh,
-	AWIN_HDMI_CLK_REG,
-	__SHIFTIN(AWIN_HDMI_CLK_SRC_SEL_PLL7, AWIN_HDMI_CLK_SRC_SEL) |
-	__SHIFTIN(0x0, AWIN_HDMI_CLK_DIV_RATIO_M) |
-	AWIN_CLK_ENABLE);
+	AWIN_HDMI_CLK_REG, clk);
 	awin_reg_set_clear(aio-aio_core_bst, aio-aio_ccm_bsh,
 	AWIN_AHB_GATING1_REG, AWIN_AHB_GATING1_HDMI, 0);
 
@@ -132,6 +152,13 @@ awin_hdmi_attach(device_t parent, device
 	aprint_naive(\n);
 	aprint_normal(: HDMI %d.%d\n, vmaj, vmin);
 
+	sc-sc_ver = ver;
+	if (HDMI_1_3_P(sc)) {
+		sc-sc_i2c_blklen = 1;
+	} else {
+		sc-sc_i2c_blklen = 16;
+	}
+
 	sc-sc_ih = intr_establish(loc-loc_intr, IPL_SCHED, IST_LEVEL,
 	awin_hdmi_intr, sc);
 	if (sc-sc_ih == NULL) {
@@ -210,15 +237,20 @@ awin_hdmi_i2c_exec(void *priv, i2c_op_t 
 	pbuf = buf;
 	resid = len;
 	while (resid  0) {
-		size_t blklen = min(resid, HDMI_I2C_MAX_BLKLEN);
+		size_t blklen = min(resid, sc-sc_i2c_blklen);
 
 		err = awin_hdmi_i2c_xfer(sc, addr, off, blklen,
-		AWIN_HDMI_DDC_COMMAND_ACCESS_CMD_EOREAD, flags);
+		  AWIN_HDMI_DDC_COMMAND_ACCESS_CMD_EOREAD, flags);
 		if (err)
 			goto done;
 
-		bus_space_read_multi_1(sc-sc_bst, sc-sc_bsh,
-		AWIN_HDMI_DDC_FIFO_ACCESS_REG, pbuf, blklen);
+		if (HDMI_1_3_P(sc)) {
+			bus_space_read_multi_1(sc-sc_bst, sc-sc_bsh,
+			AWIN_HDMI_DDC_FIFO_ACCESS_REG, pbuf, blklen);
+		} else {
+			bus_space_read_multi_1(sc-sc_bst, sc-sc_bsh,
+			AWIN_A31_HDMI_DDC_FIFO_ACCESS_REG, pbuf, blklen);
+		}
 
 		pbuf += blklen;
 		off += blklen;
@@ -230,7 +262,7 @@ done:
 }
 
 static int
-awin_hdmi_i2c_xfer(void *priv, i2c_addr_t addr, uint8_t reg,
+awin_hdmi_i2c_xfer_1_3(void *priv, i2c_addr_t addr, uint8_t reg,
 size_t len, int type, int flags)
 {
 	struct awin_hdmi_softc *sc = priv;
@@ -278,6 +310,61 @@ 

  1   2   3   >