CVS commit: src/sys/dev/i2c

2019-11-29 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Nov 29 12:42:54 UTC 2019

Modified Files:
src/sys/dev/i2c: motoi2c.c

Log Message:
Add wait for stop condition.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/motoi2c.c

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



CVS commit: src/sys/dev/i2c

2019-11-29 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Nov 29 12:42:54 UTC 2019

Modified Files:
src/sys/dev/i2c: motoi2c.c

Log Message:
Add wait for stop condition.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/motoi2c.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/dev/i2c/motoi2c.c
diff -u src/sys/dev/i2c/motoi2c.c:1.5 src/sys/dev/i2c/motoi2c.c:1.6
--- src/sys/dev/i2c/motoi2c.c:1.5	Mon Aug  5 12:21:00 2019
+++ src/sys/dev/i2c/motoi2c.c	Fri Nov 29 12:42:53 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: motoi2c.c,v 1.5 2019/08/05 12:21:00 hkenken Exp $ */
+/* $NetBSD: motoi2c.c,v 1.6 2019/11/29 12:42:53 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.5 2019/08/05 12:21:00 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.6 2019/11/29 12:42:53 hkenken Exp $");
 
 #if defined(__arm__) || defined(__aarch64__)
 #include "opt_fdt.h"
@@ -163,6 +163,24 @@ motoi2c_release_bus(void *v, int flags)
 	mutex_exit(>sc_buslock);
 }
 
+static int
+motoi2c_stop_wait(struct motoi2c_softc *sc)
+{
+	u_int timo;
+	int error = 0;
+
+	timo = 1000;
+	while ((I2C_READ(I2CSR) & SR_MBB) != 0 && --timo)
+		DELAY(1);
+
+	if (timo == 0) {
+		DPRINTF(("%s: timeout (sr=%#x)\n", __func__, I2C_READ(I2CSR)));
+		error = ETIMEDOUT;
+	}
+
+	return error;
+}
+
 /* busy waiting for byte data transfer completion */
 static int
 motoi2c_busy_wait(struct motoi2c_softc *sc, uint8_t cr)
@@ -224,15 +242,9 @@ motoi2c_exec(void *v, i2c_op_t op, i2c_a
 
 	if ((cr & CR_MSTA) == 0 && (sr & SR_MBB) != 0) {
 		/* wait for bus becoming available */
-		u_int timo = 100;
-		do {
-			DELAY(10);
-		} while (--timo > 0 && ((sr = I2C_READ(I2CSR)) & SR_MBB) != 0);
-
-		if (timo == 0) {
-			DPRINTF(("%s: bus is busy (%#x)\n", __func__, sr));
+		error = motoi2c_stop_wait(sc);
+		if (error)
 			return ETIMEDOUT;
-		}
 	}
 
 	/* reset interrupt and arbitration-lost flags (all others are RO) */
@@ -240,12 +252,10 @@ motoi2c_exec(void *v, i2c_op_t op, i2c_a
 	sr = I2C_READ(I2CSR);
 
 	/*
-	 * Generate start (or restart) condition
+	 * Generate start condition
 	 */
-	/* CR_RTSA is write-only and transitory */
-	uint8_t rsta = (cr & CR_MSTA ? CR_RSTA : 0);
 	cr = CR_MEN | CR_MTX | CR_MSTA;
-	I2C_WRITE(I2CCR, cr | rsta);
+	I2C_WRITE(I2CCR, cr);
 
 	DPRINTF(("%s: started: sr=%#x cr=%#x/%#x\n",
 	__func__, I2C_READ(I2CSR), cr, I2C_READ(I2CCR)));
@@ -339,14 +349,14 @@ motoi2c_exec(void *v, i2c_op_t op, i2c_a
 cr |= CR_TXAK;
 I2C_WRITE(I2CCR, cr);
 			} else if (i == datalen - 1 && I2C_OP_STOP_P(op)) {
-cr = CR_MEN;
+cr = CR_MEN | CR_TXAK;
 I2C_WRITE(I2CCR, cr);
 			}
 			*dataptr++ = I2C_READ(I2CDR);
 		}
 		if (datalen == 0) {
 			if (I2C_OP_STOP_P(op)) {
-cr = CR_MEN;
+cr = CR_MEN | CR_TXAK;
 I2C_WRITE(I2CCR, cr);
 			}
 			(void)I2C_READ(I2CDR);	/* dummy read */
@@ -378,6 +388,7 @@ motoi2c_exec(void *v, i2c_op_t op, i2c_a
 	if (error || (cr & CR_TXAK) || ((cr & CR_MSTA) && I2C_OP_STOP_P(op))) {
 		cr = CR_MEN;
 		I2C_WRITE(I2CCR, cr);
+		motoi2c_stop_wait(sc);
 		DPRINTF(("%s: stopping: cr=%#x/%#x\n", __func__,
 		cr, I2C_READ(I2CCR)));
 	}



CVS commit: src/sys/dev/i2c

2019-11-28 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Nov 29 04:59:15 UTC 2019

Modified Files:
src/sys/dev/i2c: at24cxx.c

Log Message:
Support more than 128Kbit model.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/i2c/at24cxx.c

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



CVS commit: src/sys/dev/i2c

2019-11-28 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Nov 29 04:59:15 UTC 2019

Modified Files:
src/sys/dev/i2c: at24cxx.c

Log Message:
Support more than 128Kbit model.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/i2c/at24cxx.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/dev/i2c/at24cxx.c
diff -u src/sys/dev/i2c/at24cxx.c:1.32 src/sys/dev/i2c/at24cxx.c:1.33
--- src/sys/dev/i2c/at24cxx.c:1.32	Sun Oct 27 19:10:38 2019
+++ src/sys/dev/i2c/at24cxx.c	Fri Nov 29 04:59:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: at24cxx.c,v 1.32 2019/10/27 19:10:38 jmcneill Exp $	*/
+/*	$NetBSD: at24cxx.c,v 1.33 2019/11/29 04:59:15 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.32 2019/10/27 19:10:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.33 2019/11/29 04:59:15 hkenken Exp $");
 
 #include 
 #include 
@@ -67,7 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 
 #define	AT24CXX_ADDR		0x50
 
 #define	AT24CXX_WRITE_CYCLE_MS	10
-#define	AT24CXX_ADDR_HI(a)	(((a) >> 8) & 0x1f)
+#define	AT24CXX_ADDR_HI(a)	(((a) >> 8) & 0xff)
 #define	AT24CXX_ADDR_LO(a)	((a) & 0xff)
 
 #include "seeprom.h"



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-28 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Nov 28 14:13:37 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_com.c

Log Message:
Remove FDT_INTR_MPSAFE flag.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_com.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/imx/fdt/imx6_com.c
diff -u src/sys/arch/arm/imx/fdt/imx6_com.c:1.1 src/sys/arch/arm/imx/fdt/imx6_com.c:1.2
--- src/sys/arch/arm/imx/fdt/imx6_com.c:1.1	Wed Jul 24 13:12:33 2019
+++ src/sys/arch/arm/imx/fdt/imx6_com.c	Thu Nov 28 14:13:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_com.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $	*/
+/*	$NetBSD: imx6_com.c,v 1.2 2019/11/28 14:13:37 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_com.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_com.c,v 1.2 2019/11/28 14:13:37 hkenken Exp $");
 
 #include "opt_fdt.h"
 #include "opt_imxuart.h"
@@ -99,9 +99,11 @@ imx6_com_attach(device_t parent, device_
 	}
 
 	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_SERIAL,
-	FDT_INTR_MPSAFE, imxuintr, sc);
-	if (sc->sc_ih == NULL)
+	0, imxuintr, sc);
+	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt\n");
+		return;
+	}
 
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-28 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Nov 28 14:13:37 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_com.c

Log Message:
Remove FDT_INTR_MPSAFE flag.


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

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



CVS commit: src/sys

2019-11-26 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Nov 27 07:26:08 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imxgpio.c
src/sys/arch/arm/imx/fdt: imx6_gpio.c
src/sys/dev/spi: spi.c spivar.h

Log Message:
Remove GPIO driver attach defer.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/imxgpio.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/imx6_gpio.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/spi/spi.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/spi/spivar.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/imx/imxgpio.c
diff -u src/sys/arch/arm/imx/imxgpio.c:1.6 src/sys/arch/arm/imx/imxgpio.c:1.7
--- src/sys/arch/arm/imx/imxgpio.c:1.6	Wed Jul 24 12:33:18 2019
+++ src/sys/arch/arm/imx/imxgpio.c	Wed Nov 27 07:26:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxgpio.c,v 1.6 2019/07/24 12:33:18 hkenken Exp $ */
+/*	$NetBSD: imxgpio.c,v 1.7 2019/11/27 07:26:08 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imxgpio.c,v 1.6 2019/07/24 12:33:18 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxgpio.c,v 1.7 2019/11/27 07:26:08 hkenken Exp $");
 
 #define	_INTR_PRIVATE
 
@@ -288,40 +288,37 @@ imxgpio_pin_ctl(void *arg, int pin, int 
 }
 
 static void
-gpio_defer(device_t self)
+imxgpio_attach_ports(struct imxgpio_softc *gpio)
 {
-	struct imxgpio_softc * const gpio = device_private(self);
 	struct gpio_chipset_tag * const gp = >gpio_chipset;
 	struct gpiobus_attach_args gba;
-	gpio_pin_t *pins;
-	uint32_t mask, dir, value;
-	int pin;
+	uint32_t dir;
+	u_int pin;
 
 	gp->gp_cookie = gpio;
 	gp->gp_pin_read = imxgpio_pin_read;
 	gp->gp_pin_write = imxgpio_pin_write;
 	gp->gp_pin_ctl = imxgpio_pin_ctl;
 
-	gba.gba_gc = gp;
-	gba.gba_pins = gpio->gpio_pins;
-	gba.gba_npins = __arraycount(gpio->gpio_pins);
-
 	dir = GPIO_READ(gpio, GPIO_DIR);
-	value = GPIO_READ(gpio, GPIO_DR);
-	for (pin = 0, mask = 1, pins = gpio->gpio_pins;
-	 pin < 32; pin++, mask <<= 1, pins++) {
+	for (pin = 0; pin < __arraycount(gpio->gpio_pins); pin++) {
+		uint32_t mask = __BIT(pin);
+		gpio_pin_t *pins = >gpio_pins[pin];
 		pins->pin_num = pin;
 		if ((gpio->gpio_edge_mask | gpio->gpio_level_mask) & mask)
 			pins->pin_caps = GPIO_PIN_INPUT;
 		else
-			pins->pin_caps = GPIO_PIN_INPUT|GPIO_PIN_OUTPUT;
+			pins->pin_caps = GPIO_PIN_INPUT | GPIO_PIN_OUTPUT;
 		pins->pin_flags =
 		(dir & mask) ? GPIO_PIN_OUTPUT : GPIO_PIN_INPUT;
-		pins->pin_state =
-		(value & mask) ? GPIO_PIN_HIGH : GPIO_PIN_LOW;
+		pins->pin_state = imxgpio_pin_read(gpio, pin);
 	}
 
-	config_found_ia(self, "gpiobus", , gpiobus_print);
+	memset(, 0, sizeof(gba));
+	gba.gba_gc = gp;
+	gba.gba_pins = gpio->gpio_pins;
+	gba.gba_npins = __arraycount(gpio->gpio_pins);
+	config_found_ia(gpio->gpio_dev, "gpiobus", , gpiobus_print);
 }
 #endif /* NGPIO > 0 */
 
@@ -351,7 +348,7 @@ imxgpio_attach_common(device_t self)
 	imxgpio_handles[gpio->gpio_unit] = gpio;
 
 #if NGPIO > 0
-	config_interrupts(self, gpio_defer);
+	imxgpio_attach_ports(gpio);
 #endif
 }
 

Index: src/sys/arch/arm/imx/fdt/imx6_gpio.c
diff -u src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.3 src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.4
--- src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.3	Sun Nov 24 11:07:19 2019
+++ src/sys/arch/arm/imx/fdt/imx6_gpio.c	Wed Nov 27 07:26:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_gpio.c,v 1.3 2019/11/24 11:07:19 skrll Exp $	*/
+/*	$NetBSD: imx6_gpio.c,v 1.4 2019/11/27 07:26:08 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_gpio.c,v 1.3 2019/11/24 11:07:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_gpio.c,v 1.4 2019/11/27 07:26:08 hkenken Exp $");
 
 #include "opt_fdt.h"
 #include "gpio.h"
@@ -123,8 +123,8 @@ imxgpio_attach(device_t parent, device_t
 		aprint_error_dev(self, "failed to decode interrupt\n");
 		return;
 	}
-	sc->gpio_is = fdtbus_intr_establish(phandle, 0, IPL_HIGH,
-	FDT_INTR_MPSAFE, pic_handle_intr, >gpio_pic);
+	sc->gpio_is = fdtbus_intr_establish(phandle, 0, IPL_HIGH, 0,
+	pic_handle_intr, >gpio_pic);
 	if (sc->gpio_is == NULL) {
 		aprint_error_dev(self, "couldn't establish interrupt on %s\n",
 		intrstr);
@@ -136,8 +136,8 @@ imxgpio_attach(device_t parent, device_t
 		aprint_error_dev(self, "failed to decode interrupt\n");
 		return;
 	}
-	sc->gpio_is_high = fdtbus_intr_establish(phandle, 1, IPL_HIGH,
-	FDT_INTR_MPSAFE, pic_handle_intr, >gpio_pic);
+	sc->gpio_is_high = fdtbus_intr_establish(phandle, 1, IPL_HIGH, 0,
+	pic_handle_intr, >gpio_pic);
 	if (sc->gpio_is_high == NULL) {
 		aprint_error_dev(self, "couldn't establish interrupt on %s\n",
 		intrstr);

Index: src/sys/dev/spi/spi.c

CVS commit: src/sys

2019-11-26 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Nov 27 07:26:08 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imxgpio.c
src/sys/arch/arm/imx/fdt: imx6_gpio.c
src/sys/dev/spi: spi.c spivar.h

Log Message:
Remove GPIO driver attach defer.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/imxgpio.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/imx6_gpio.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/spi/spi.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/spi/spivar.h

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



CVS commit: src/sys/dev/spi

2019-11-25 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Nov 26 02:41:58 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
Change manufacturer to Micron from Numonyx.

N25Q -> MT25Q


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/spi/m25p.c

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



CVS commit: src/sys/dev/spi

2019-11-25 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Nov 26 02:41:58 UTC 2019

Modified Files:
src/sys/dev/spi: m25p.c

Log Message:
Change manufacturer to Micron from Numonyx.

N25Q -> MT25Q


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/spi/m25p.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/dev/spi/m25p.c
diff -u src/sys/dev/spi/m25p.c:1.14 src/sys/dev/spi/m25p.c:1.15
--- src/sys/dev/spi/m25p.c:1.14	Sat Sep 14 15:12:12 2019
+++ src/sys/dev/spi/m25p.c	Tue Nov 26 02:41:58 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.14 2019/09/14 15:12:12 tnn Exp $ */
+/* $NetBSD: m25p.c,v 1.15 2019/11/26 02:41:58 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.14 2019/09/14 15:12:12 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.15 2019/11/26 02:41:58 hkenken Exp $");
 
 #include 
 #include 
@@ -96,7 +96,8 @@ static const struct m25p_info {
 	{ 0x14, 0x20, 0x2015, "STMicro M25P16", 2048, 64 },	/* 16Mbit */
 	{ 0x12, 0x20, 0x2013, "STMicro M25P40", 512, 64 },	/* 4Mbit */
 	{ 0xc0, 0x20, 0x7117, "STMicro M25PX64", 8192, 64 },	/* 64Mbit */
-	{ 0x00, 0x20, 0xBB18, "Numonyx N25Q128", 16384, 64 },	/* 128Mbit */
+	{ 0x00, 0x20, 0xBA18, "Micron MT25QL128", 16384, 64 },  /* 128Mbit (3V) */
+	{ 0x00, 0x20, 0xBB18, "Micron MT25QU128", 16384, 64 },  /* 128Mbit (1.8V)  */
 	{ 0x00, 0xBF, 0x2541, "Microchip SST25VF016B", 2048, 64 }, /* 16Mbit */
 	{ 0x00, 0xC2, 0x2011, "Macronix MX25L10", 128, 64 },	/* 1Mbit */
 	{ 0x00, 0xC2, 0x2012, "Macronix MX25L20", 256, 64 },	/* 2Mbit */



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

2019-11-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Nov 25 00:54:47 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet_imx6.c

Log Message:
Fixed bug.

* typo


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

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



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

2019-11-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Nov 25 00:54:47 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet_imx6.c

Log Message:
Fixed bug.

* typo


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/if_enet_imx6.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/imx/if_enet_imx6.c
diff -u src/sys/arch/arm/imx/if_enet_imx6.c:1.7 src/sys/arch/arm/imx/if_enet_imx6.c:1.8
--- src/sys/arch/arm/imx/if_enet_imx6.c:1.7	Tue Nov 12 05:09:29 2019
+++ src/sys/arch/arm/imx/if_enet_imx6.c	Mon Nov 25 00:54:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx6.c,v 1.7 2019/11/12 05:09:29 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx6.c,v 1.8 2019/11/25 00:54:47 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.7 2019/11/12 05:09:29 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.8 2019/11/25 00:54:47 hkenken Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -132,7 +132,7 @@ enet_attach(device_t parent, device_t se
 	}
 
 	sc->sc_clk_ipg = imx6_get_clock("enet");
-	if (sc->sc_clk_enet == NULL) {
+	if (sc->sc_clk_ipg == NULL) {
 		aprint_error(": couldn't get clock ipg\n");
 		return;
 	}



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

2019-11-14 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Nov 15 01:10:43 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imxspi.c

Log Message:
Keep SCLK high in the inactive state. (SPI modes 2 and 3 only)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/imxspi.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/imx/imxspi.c
diff -u src/sys/arch/arm/imx/imxspi.c:1.6 src/sys/arch/arm/imx/imxspi.c:1.7
--- src/sys/arch/arm/imx/imxspi.c:1.6	Fri Sep 27 02:59:21 2019
+++ src/sys/arch/arm/imx/imxspi.c	Fri Nov 15 01:10:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxspi.c,v 1.6 2019/09/27 02:59:21 hkenken Exp $	*/
+/*	$NetBSD: imxspi.c,v 1.7 2019/11/15 01:10:42 hkenken Exp $	*/
 
 /*-
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imxspi.c,v 1.6 2019/09/27 02:59:21 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxspi.c,v 1.7 2019/11/15 01:10:42 hkenken Exp $");
 
 #include "opt_imxspi.h"
 #include "opt_fdt.h"
@@ -69,7 +69,7 @@ void imxspi_sched(struct imxspi_softc *)
 
 #define	IMXCSPI_TYPE(type, x)		  \
 	((sc->sc_type == IMX31_CSPI) ? __CONCAT(CSPI_IMX31_, x) :	  \
-	(sc->sc_type == IMX35_CSPI) ? __CONCAT(CSPI_IMX35_, x) : 0)
+	 (sc->sc_type == IMX35_CSPI) ? __CONCAT(CSPI_IMX35_, x) : 0)
 #define	IMXCSPI(x)	__CONCAT(CSPI_, x)
 #define	IMXESPI(x)	__CONCAT(ECSPI_, x)
 #define	IMXSPI(x)	((sc->sc_enhanced) ? IMXESPI(x) : IMXCSPI(x))
@@ -228,6 +228,7 @@ imxspi_configure_enhanced(void *arg, int
 
 	config = bus_space_read_4(sc->sc_iot, sc->sc_ioh, ECSPI_CONFIGREG);
 	config &= ~(__SHIFTIN(__BIT(slave), ECSPI_CONFIG_SCLK_POL) |
+	__SHIFTIN(__BIT(slave), ECSPI_CONFIG_SCLK_CTL) |
 	__SHIFTIN(__BIT(slave), ECSPI_CONFIG_SCLK_PHA));
 	switch (mode) {
 	case SPI_MODE_0:
@@ -240,11 +241,13 @@ imxspi_configure_enhanced(void *arg, int
 	case SPI_MODE_2:
 		/* CPHA = 0, CPOL = 1 */
 		config |= __SHIFTIN(__BIT(slave), ECSPI_CONFIG_SCLK_POL);
+		config |= __SHIFTIN(__BIT(slave), ECSPI_CONFIG_SCLK_CTL);
 		break;
 	case SPI_MODE_3:
 		/* CPHA = 1, CPOL = 1 */
 		config |= __SHIFTIN(__BIT(slave), ECSPI_CONFIG_SCLK_PHA);
 		config |= __SHIFTIN(__BIT(slave), ECSPI_CONFIG_SCLK_POL);
+		config |= __SHIFTIN(__BIT(slave), ECSPI_CONFIG_SCLK_CTL);
 		break;
 	default:
 		return EINVAL;



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

2019-11-14 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Nov 15 01:10:43 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imxspi.c

Log Message:
Keep SCLK high in the inactive state. (SPI modes 2 and 3 only)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/imxspi.c

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-13 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Nov 14 06:00:16 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c

Log Message:
Fixed bug.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/fdt/if_enet_imx.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/imx/fdt/if_enet_imx.c
diff -u src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.7 src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.8
--- src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.7	Wed Nov 13 07:56:10 2019
+++ src/sys/arch/arm/imx/fdt/if_enet_imx.c	Thu Nov 14 06:00:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx.c,v 1.7 2019/11/13 07:56:10 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx.c,v 1.8 2019/11/14 06:00:16 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.7 2019/11/13 07:56:10 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.8 2019/11/14 06:00:16 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -210,7 +210,7 @@ enet_phy_reset(struct enet_fdt_softc *sc
 	fdtbus_gpio_write(sc->sc_pin_reset, 0);
 
 	/* Post delay */
-	if (!of_getprop_uint32(phandle, "phy-reset-post-delay", ))
+	if (of_getprop_uint32(phandle, "phy-reset-post-delay", ))
 		msec = 0;
 
 	delay(msec * 1000);



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-13 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Nov 14 06:00:16 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c

Log Message:
Fixed bug.


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

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-12 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Nov 13 07:56:11 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c

Log Message:
Add support "phy-reset-post-delay".


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/fdt/if_enet_imx.c

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-12 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Nov 13 07:56:11 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c

Log Message:
Add support "phy-reset-post-delay".


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/fdt/if_enet_imx.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/imx/fdt/if_enet_imx.c
diff -u src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.6 src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.7
--- src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.6	Tue Nov 12 08:40:57 2019
+++ src/sys/arch/arm/imx/fdt/if_enet_imx.c	Wed Nov 13 07:56:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx.c,v 1.6 2019/11/12 08:40:57 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx.c,v 1.7 2019/11/13 07:56:10 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.6 2019/11/12 08:40:57 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.7 2019/11/13 07:56:10 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -195,19 +195,23 @@ enet_init_clocks(struct enet_softc *sc)
 static void
 enet_phy_reset(struct enet_fdt_softc *sc, const int phandle)
 {
-	int error;
+	u_int msec;
 
 	sc->sc_pin_reset = fdtbus_gpio_acquire(phandle, "phy-reset-gpios", GPIO_PIN_OUTPUT);
 	if (sc->sc_pin_reset == NULL)
 		return;
 
-	u_int msec;
-	error = of_getprop_uint32(phandle, "phy-reset-duration", );
-	if (error)
+	if (of_getprop_uint32(phandle, "phy-reset-duration", ))
 		msec = 1;
 
 	/* Reset */
 	fdtbus_gpio_write(sc->sc_pin_reset, 1);
 	delay(msec * 1000);
 	fdtbus_gpio_write(sc->sc_pin_reset, 0);
+
+	/* Post delay */
+	if (!of_getprop_uint32(phandle, "phy-reset-post-delay", ))
+		msec = 0;
+
+	delay(msec * 1000);
 }



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-12 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Nov 12 08:40:57 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c

Log Message:
Fixed bug.

* typo


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

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-11-12 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Nov 12 08:40:57 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c

Log Message:
Fixed bug.

* typo


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/fdt/if_enet_imx.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/imx/fdt/if_enet_imx.c
diff -u src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.5 src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.6
--- src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.5	Tue Nov 12 05:09:29 2019
+++ src/sys/arch/arm/imx/fdt/if_enet_imx.c	Tue Nov 12 08:40:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx.c,v 1.5 2019/11/12 05:09:29 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx.c,v 1.6 2019/11/12 08:40:57 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.5 2019/11/12 05:09:29 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.6 2019/11/12 08:40:57 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -91,7 +91,7 @@ enet_attach(device_t parent, device_t se
 	}
 
 	sc->sc_clk_ipg = fdtbus_clock_get(phandle, "ipg");
-	if (sc->sc_clk_enet == NULL) {
+	if (sc->sc_clk_ipg == NULL) {
 		aprint_error(": couldn't get clock ipg\n");
 		goto failure;
 	}



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

2019-11-11 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Nov 12 05:09:29 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet.c if_enet_imx6.c if_enet_imx7.c
if_enetreg.h if_enetvar.h
src/sys/arch/arm/imx/fdt: if_enet_imx.c

Log Message:
IPG clock is used instead of ENET_PLL clock to set MII Speed Control Register.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/imx/if_enet.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/if_enet_imx6.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/if_enet_imx7.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/if_enetreg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/if_enetvar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/fdt/if_enet_imx.c

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



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

2019-11-11 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Nov 12 05:09:29 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet.c if_enet_imx6.c if_enet_imx7.c
if_enetreg.h if_enetvar.h
src/sys/arch/arm/imx/fdt: if_enet_imx.c

Log Message:
IPG clock is used instead of ENET_PLL clock to set MII Speed Control Register.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/imx/if_enet.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/if_enet_imx6.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/if_enet_imx7.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/if_enetreg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/if_enetvar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/fdt/if_enet_imx.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/imx/if_enet.c
diff -u src/sys/arch/arm/imx/if_enet.c:1.27 src/sys/arch/arm/imx/if_enet.c:1.28
--- src/sys/arch/arm/imx/if_enet.c:1.27	Fri Sep 20 08:48:55 2019
+++ src/sys/arch/arm/imx/if_enet.c	Tue Nov 12 05:09:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet.c,v 1.27 2019/09/20 08:48:55 maxv Exp $	*/
+/*	$NetBSD: if_enet.c,v 1.28 2019/11/12 05:09:29 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.27 2019/09/20 08:48:55 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.28 2019/11/12 05:09:29 hkenken Exp $");
 
 #include "vlan.h"
 
@@ -1769,9 +1769,9 @@ enet_init_regs(struct enet_softc *sc, in
 	ENET_REG_WRITE(sc, ENET_MIBC, ENET_MIBC_MIB_CLEAR);
 	ENET_REG_WRITE(sc, ENET_MIBC, 0);
 
-	/* MII speed setup. MDCclk(=2.5MHz) = ENET_PLL/((val+1)*2) */
-	val = ((sc->sc_pllclock) / 50 - 1) / 10;
-	ENET_REG_WRITE(sc, ENET_MSCR, val << 1);
+	/* MII speed setup. MDCclk(=2.5MHz) = (internal module clock)/((val+1)*2) */
+	val = (sc->sc_clock + (500 - 1)) / 500 - 1;
+	ENET_REG_WRITE(sc, ENET_MSCR, __SHIFTIN(val, ENET_MSCR_MII_SPEED));
 
 	/* Opcode/Pause Duration */
 	ENET_REG_WRITE(sc, ENET_OPD, 0x00010020);

Index: src/sys/arch/arm/imx/if_enet_imx6.c
diff -u src/sys/arch/arm/imx/if_enet_imx6.c:1.6 src/sys/arch/arm/imx/if_enet_imx6.c:1.7
--- src/sys/arch/arm/imx/if_enet_imx6.c:1.6	Tue Jul 30 06:26:31 2019
+++ src/sys/arch/arm/imx/if_enet_imx6.c	Tue Nov 12 05:09:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx6.c,v 1.6 2019/07/30 06:26:31 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx6.c,v 1.7 2019/11/12 05:09:29 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.6 2019/07/30 06:26:31 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.7 2019/11/12 05:09:29 hkenken Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -131,6 +131,11 @@ enet_attach(device_t parent, device_t se
 		iomux_write(IMX6UL_IOMUX_GPR1, v);
 	}
 
+	sc->sc_clk_ipg = imx6_get_clock("enet");
+	if (sc->sc_clk_enet == NULL) {
+		aprint_error(": couldn't get clock ipg\n");
+		return;
+	}
 	sc->sc_clk_enet = imx6_get_clock("enet");
 	if (sc->sc_clk_enet == NULL) {
 		aprint_error(": couldn't get clock enet\n");
@@ -146,7 +151,7 @@ enet_attach(device_t parent, device_t se
 		return;
 	}
 
-	sc->sc_pllclock = clk_get_rate(sc->sc_clk_enet_ref);
+	sc->sc_clock = clk_get_rate(sc->sc_clk_ipg);
 
 	if (bus_space_map(sc->sc_iot, aa->aa_addr, aa->aa_size, 0,
 	>sc_ioh)) {
@@ -179,6 +184,11 @@ enet_init_clocks(struct enet_softc *sc)
 {
 	int error;
 
+	error = clk_enable(sc->sc_clk_ipg);
+	if (error) {
+		aprint_error_dev(sc->sc_dev, "couldn't enable ipg: %d\n", error);
+		return error;
+	}
 	error = clk_enable(sc->sc_clk_enet);
 	if (error) {
 		aprint_error_dev(sc->sc_dev, "couldn't enable enet: %d\n", error);

Index: src/sys/arch/arm/imx/if_enet_imx7.c
diff -u src/sys/arch/arm/imx/if_enet_imx7.c:1.4 src/sys/arch/arm/imx/if_enet_imx7.c:1.5
--- src/sys/arch/arm/imx/if_enet_imx7.c:1.4	Tue Jul 30 06:26:31 2019
+++ src/sys/arch/arm/imx/if_enet_imx7.c	Tue Nov 12 05:09:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx7.c,v 1.4 2019/07/30 06:26:31 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx7.c,v 1.5 2019/11/12 05:09:29 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx7.c,v 1.4 2019/07/30 06:26:31 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx7.c,v 1.5 2019/11/12 05:09:29 hkenken Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -103,9 +103,9 @@ enet_attach(device_t parent, device_t se
 		"couldn't enable CCM_ANALOG_PLL_ENET\n");
 		return;
 	}
-	sc->sc_pllclock = imx7_get_clock(IMX7CLK_ENET_PLL);
+	sc->sc_clock = imx7_get_clock(IMX7CLK_IPG_CLK_ROOT);
 #else
-	sc->sc_pllclock = 10;
+	sc->sc_clock = 6600;
 #endif
 
 	if (bus_space_map(sc->sc_iot, aa->aa_addr, aa->aa_size, 0,

Index: src/sys/arch/arm/imx/if_enetreg.h
diff -u 

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

2019-11-11 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Nov 12 04:32:36 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_ccm.c

Log Message:
Add imxccm_clk_set_rate_div().

+ Fixed BUG in imxccm_clk_get_rate_div().


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/imx/imx6_ccm.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/imx/imx6_ccm.c
diff -u src/sys/arch/arm/imx/imx6_ccm.c:1.14 src/sys/arch/arm/imx/imx6_ccm.c:1.15
--- src/sys/arch/arm/imx/imx6_ccm.c:1.14	Mon Sep  2 01:28:41 2019
+++ src/sys/arch/arm/imx/imx6_ccm.c	Tue Nov 12 04:32:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_ccm.c,v 1.14 2019/09/02 01:28:41 hkenken Exp $	*/
+/*	$NetBSD: imx6_ccm.c,v 1.15 2019/11/12 04:32:36 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2010-2012, 2014  Genetec Corporation.  All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.14 2019/09/02 01:28:41 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.15 2019/11/12 04:32:36 hkenken Exp $");
 
 #include "opt_cputypes.h"
 
@@ -1165,7 +1165,7 @@ imxccm_clk_get_rate_div(struct imxccm_so
 		KASSERT(div->tbl != NULL);
 
 		for (int i = 0; div->tbl[i] != 0; i++)
-			if (div->tbl[i] == n)
+			if (i == n)
 rate /= div->tbl[i];
 	} else {
 		rate /= n + 1;
@@ -1275,13 +1275,56 @@ imxccm_clk_get_parent_mux(struct imxccm_
 
 static int
 imxccm_clk_set_rate_pll(struct imxccm_softc *sc,
-struct imx6_clk *eclk, u_int rate)
+struct imx6_clk *iclk, u_int rate)
 {
 	/* ToDo */
 
 	return EOPNOTSUPP;
 }
 
+static int
+imxccm_clk_set_rate_div(struct imxccm_softc *sc,
+struct imx6_clk *iclk, u_int rate)
+{
+struct imx6_clk_div *div = >clk.div;
+struct imx6_clk *parent;
+
+KASSERT(iclk->type == IMX6_CLK_DIV);
+
+parent = imx6_clk_find(iclk->parent);
+KASSERT(parent != NULL);
+
+u_int rate_parent = imxccm_clk_get_rate(sc, >base);
+u_int divider = rate_parent / rate;
+
+KASSERT(div->tbl != NULL);
+
+bus_space_handle_t ioh;
+if (div->base == IMX6_CLK_REG_CCM_ANALOG)
+ioh = sc->sc_ioh_analog;
+else
+ioh = sc->sc_ioh;
+
+uint32_t v = bus_space_read_4(sc->sc_iot, ioh, div->reg);
+v &= ~div->mask;
+if (div->type == IMX6_CLK_DIV_TABLE) {
+int n = -1;
+for (int i = 0; div->tbl[i] != 0; i++)
+if (div->tbl[i] == divider)
+n = i;
+
+if (n >= 0)
+v |= __SHIFTIN(n, div->mask);
+else
+return EINVAL;
+} else {
+v |= __SHIFTIN(divider - 1, div->mask);
+}
+bus_space_write_4(sc->sc_iot, ioh, div->reg, v);
+
+return 0;
+}
+
 /*
  * CLK Driver APIs
  */
@@ -1345,13 +1388,15 @@ imxccm_clk_set_rate(void *priv, struct c
 	switch (iclk->type) {
 	case IMX6_CLK_FIXED:
 	case IMX6_CLK_FIXED_FACTOR:
-		return EIO;
+		return ENXIO;
 	case IMX6_CLK_PLL:
 		return imxccm_clk_set_rate_pll(sc, iclk, rate);
 	case IMX6_CLK_MUX:
-		return EIO;
+		return ENXIO;
 	case IMX6_CLK_GATE:
+		return ENXIO;
 	case IMX6_CLK_DIV:
+		return imxccm_clk_set_rate_div(sc, iclk, rate);
 	case IMX6_CLK_PFD:
 		return EINVAL;
 	default:



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

2019-11-11 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Nov 12 04:32:36 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_ccm.c

Log Message:
Add imxccm_clk_set_rate_div().

+ Fixed BUG in imxccm_clk_get_rate_div().


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

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



CVS commit: src/sys

2019-10-22 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Oct 23 05:20:52 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_sdhc.c
src/sys/dev/sdmmc: sdhc.c sdhcreg.h sdhcvar.h sdmmc.c sdmmcchip.h
sdmmcvar.h

Log Message:
Add SDHC flags.

+ SDHC_FLAG_BROKEN_ADMA2_ZEROLEN
  Broken ADMA2 Zero length descriptor.
  Can't 64K Byte data transfer.
+ SDHC_FLAG_NO_1_8_V
  Support no 1.8V Supply.
  Disable UHS-I bus speed mode (SDR50, DDR50, SDR104).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/imx6_sdhc.c
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sdmmc/sdhcreg.h
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/sdmmc/sdhcvar.h
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/sdmmc/sdmmc.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/sdmmc/sdmmcchip.h
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/sdmmc/sdmmcvar.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/imx/fdt/imx6_sdhc.c
diff -u src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.3 src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.4
--- src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.3	Fri Sep 27 02:54:57 2019
+++ src/sys/arch/arm/imx/fdt/imx6_sdhc.c	Wed Oct 23 05:20:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_sdhc.c,v 1.3 2019/09/27 02:54:57 hkenken Exp $	*/
+/*	$NetBSD: imx6_sdhc.c,v 1.4 2019/10/23 05:20:52 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_sdhc.c,v 1.3 2019/09/27 02:54:57 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_sdhc.c,v 1.4 2019/10/23 05:20:52 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -120,10 +120,13 @@ imx6_sdhc_attach(device_t parent, device
 	SDHC_FLAG_32BIT_ACCESS |
 	SDHC_FLAG_USE_ADMA2 |
 	SDHC_FLAG_USDHC |
-	SDHC_FLAG_NO_BUSY_INTR;
+	SDHC_FLAG_NO_BUSY_INTR |
+	SDHC_FLAG_BROKEN_ADMA2_ZEROLEN;
 
 	if (bus_width == 8)
 		sc->sc_sdhc.sc_flags |= SDHC_FLAG_8BIT_MODE;
+	if (of_hasprop(faa->faa_phandle, "no-1-8-v"))
+		sc->sc_sdhc.sc_flags |= SDHC_FLAG_NO_1_8_V;
 
 	sc->sc_sdhc.sc_host = >sc_host;
 

Index: src/sys/dev/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.103 src/sys/dev/sdmmc/sdhc.c:1.104
--- src/sys/dev/sdmmc/sdhc.c:1.103	Wed Jul  3 23:10:08 2019
+++ src/sys/dev/sdmmc/sdhc.c	Wed Oct 23 05:20:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.103 2019/07/03 23:10:08 jmcneill Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.104 2019/10/23 05:20:52 hkenken Exp $	*/
 /*	$OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.103 2019/07/03 23:10:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.104 2019/10/23 05:20:52 hkenken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -476,21 +476,23 @@ sdhc_host_found(struct sdhc_softc *sc, b
 		SET(hp->ocr, MMC_OCR_HCS);
 		aprint_normal(" HS");
 	}
-	if (ISSET(caps2, SDHC_SDR50_SUPP)) {
-		SET(hp->ocr, MMC_OCR_S18A);
-		aprint_normal(" SDR50");
-	}
-	if (ISSET(caps2, SDHC_DDR50_SUPP)) {
-		SET(hp->ocr, MMC_OCR_S18A);
-		aprint_normal(" DDR50");
-	}
-	if (ISSET(caps2, SDHC_SDR104_SUPP)) {
-		SET(hp->ocr, MMC_OCR_S18A);
-		aprint_normal(" SDR104 HS200");
-	}
-	if (ISSET(caps, SDHC_VOLTAGE_SUPP_1_8V)) {
-		SET(hp->ocr, MMC_OCR_1_65V_1_95V);
-		aprint_normal(" 1.8V");
+	if (!ISSET(hp->sc->sc_flags, SDHC_FLAG_NO_1_8_V)) {
+		if (ISSET(caps2, SDHC_SDR50_SUPP)) {
+			SET(hp->ocr, MMC_OCR_S18A);
+			aprint_normal(" SDR50");
+		}
+		if (ISSET(caps2, SDHC_DDR50_SUPP)) {
+			SET(hp->ocr, MMC_OCR_S18A);
+			aprint_normal(" DDR50");
+		}
+		if (ISSET(caps2, SDHC_SDR104_SUPP)) {
+			SET(hp->ocr, MMC_OCR_S18A);
+			aprint_normal(" SDR104 HS200");
+		}
+		if (ISSET(caps, SDHC_VOLTAGE_SUPP_1_8V)) {
+			SET(hp->ocr, MMC_OCR_1_65V_1_95V);
+			aprint_normal(" 1.8V");
+		}
 	}
 	if (ISSET(caps, SDHC_VOLTAGE_SUPP_3_0V)) {
 		SET(hp->ocr, MMC_OCR_2_9V_3_0V | MMC_OCR_3_0V_3_1V);
@@ -620,6 +622,10 @@ adma_done:
 		saa.saa_caps |= SMC_CAPS_SINGLE_ONLY;
 	if (ISSET(sc->sc_flags, SDHC_FLAG_POLL_CARD_DET))
 		saa.saa_caps |= SMC_CAPS_POLL_CARD_DET;
+
+	if (ISSET(sc->sc_flags, SDHC_FLAG_BROKEN_ADMA2_ZEROLEN))
+		saa.saa_max_seg = 65535;
+
 	hp->sdmmc = config_found(sc->sc_dev, , sdhc_cfprint);
 
 	return 0;
@@ -1818,12 +1824,9 @@ sdhc_start_command(struct sdhc_host *hp,
 		if (ISSET(hp->sc->sc_flags, SDHC_FLAG_USDHC)) {
 			/* mode bits is in MIX_CTRL register on uSDHC */
 			HWRITE4(hp, SDHC_MIX_CTRL, mode |
-			(HREAD4(hp, SDHC_MIX_CTRL) &
-			~(SDHC_MULTI_BLOCK_MODE |
-			SDHC_READ_MODE |
-			SDHC_AUTO_CMD12_ENABLE |
-			SDHC_BLOCK_COUNT_ENABLE |
-			SDHC_DMA_ENABLE)));
+			(HREAD4(hp, SDHC_MIX_CTRL) & ~SDHC_TRANSFER_MODE_MASK));
+			if (cmd->c_opcode == MMC_STOP_TRANSMISSION)
+command |= SDHC_COMMAND_TYPE_ABORT;
 

CVS commit: src/sys

2019-10-22 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Oct 23 05:20:52 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_sdhc.c
src/sys/dev/sdmmc: sdhc.c sdhcreg.h sdhcvar.h sdmmc.c sdmmcchip.h
sdmmcvar.h

Log Message:
Add SDHC flags.

+ SDHC_FLAG_BROKEN_ADMA2_ZEROLEN
  Broken ADMA2 Zero length descriptor.
  Can't 64K Byte data transfer.
+ SDHC_FLAG_NO_1_8_V
  Support no 1.8V Supply.
  Disable UHS-I bus speed mode (SDR50, DDR50, SDR104).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/imx6_sdhc.c
cvs rdiff -u -r1.103 -r1.104 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sdmmc/sdhcreg.h
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/sdmmc/sdhcvar.h
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/sdmmc/sdmmc.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/sdmmc/sdmmcchip.h
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/sdmmc/sdmmcvar.h

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-10-22 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Oct 23 02:34:43 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_platform.c

Log Message:
Implement platform reset for i.MX6.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/fdt/imx6_platform.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/imx/fdt/imx6_platform.c
diff -u src/sys/arch/arm/imx/fdt/imx6_platform.c:1.7 src/sys/arch/arm/imx/fdt/imx6_platform.c:1.8
--- src/sys/arch/arm/imx/fdt/imx6_platform.c:1.7	Fri Oct 18 12:53:08 2019
+++ src/sys/arch/arm/imx/fdt/imx6_platform.c	Wed Oct 23 02:34:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_platform.c,v 1.7 2019/10/18 12:53:08 hkenken Exp $	*/
+/*	$NetBSD: imx6_platform.c,v 1.8 2019/10/23 02:34:43 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_platform.c,v 1.7 2019/10/18 12:53:08 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_platform.c,v 1.8 2019/10/23 02:34:43 hkenken Exp $");
 
 #include "arml2cc.h"
 #include "opt_console.h"
@@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: imx6_platfor
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -197,6 +198,27 @@ imx_platform_mpstart(void)
 static void
 imx6_platform_reset(void)
 {
+	bus_space_tag_t bst = _generic_bs_tag;
+	bus_space_handle_t bsh;
+
+	if (bus_space_map(bst, IMX6_AIPS1_BASE + AIPS1_WDOG1_BASE, AIPS1_WDOG_SIZE, 0, ))
+		panic("couldn't map wdog1 registers");
+
+	delay(1000);	/* wait for flushing FIFO of serial console */
+
+	cpsid(I32_bit|F32_bit);
+
+	/* software reset signal on wdog */
+	bus_space_write_2(bst, bsh, IMX_WDOG_WCR, WCR_WDE);
+
+	/*
+	 * write twice due to errata.
+	 * Reference: ERR004346: IMX6DQCE Chip Errata for the i.MX 6Dual/6Quad
+	 */
+	bus_space_write_2(bst, bsh, IMX_WDOG_WCR, WCR_WDE);
+
+	for (;;)
+		__asm("wfi");
 }
 
 const struct arm_platform imx6_platform = {



CVS commit: src/sys/arch/arm/imx/fdt

2019-10-22 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Oct 23 02:34:43 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_platform.c

Log Message:
Implement platform reset for i.MX6.


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

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



CVS commit: src/sys

2019-10-18 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Oct 18 12:53:09 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c imx6_platform.c
src/sys/dev/mii: atphy.c

Log Message:
Modified atphy(4)

* Support CLK_25M clock out.
* Support internal delay for RGMII interface.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/if_enet_imx.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/fdt/imx6_platform.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/mii/atphy.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/imx/fdt/if_enet_imx.c
diff -u src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.3 src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.4
--- src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.3	Mon Aug 19 03:45:51 2019
+++ src/sys/arch/arm/imx/fdt/if_enet_imx.c	Fri Oct 18 12:53:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx.c,v 1.3 2019/08/19 03:45:51 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx.c,v 1.4 2019/10/18 12:53:08 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.3 2019/08/19 03:45:51 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.4 2019/10/18 12:53:08 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -71,6 +71,7 @@ enet_attach(device_t parent, device_t se
 	struct enet_fdt_softc * const efsc = device_private(self);
 	struct enet_softc *sc = >sc_enet;
 	struct fdt_attach_args * const faa = aux;
+	prop_dictionary_t prop = device_properties(self);
 	const int phandle = faa->faa_phandle;
 	bus_space_tag_t bst = faa->faa_bst;
 	bus_space_handle_t bsh;
@@ -103,15 +104,35 @@ enet_attach(device_t parent, device_t se
 	aprint_naive("\n");
 	aprint_normal(": Gigabit Ethernet Controller\n");
 
-	enet_phy_reset(efsc, phandle);
-
 	sc->sc_dev = self;
 	sc->sc_iot = bst;
 	sc->sc_ioh = bsh;
 	sc->sc_dmat = faa->faa_dmat;
 
 	sc->sc_imxtype = 6;	/* i.MX6 */
-	sc->sc_rgmii = 1;
+	sc->sc_unit = 0;
+
+	const char *phy_mode = fdtbus_get_string(phandle, "phy-mode");
+	if (phy_mode == NULL) {
+		aprint_error(": missing 'phy-mode' property\n");
+		goto failure;
+	}
+
+	if (strcmp(phy_mode, "rgmii-txid") == 0) {
+		prop_dictionary_set_bool(prop, "tx_internal_delay", true);
+		sc->sc_rgmii = 1;
+	} else if (strcmp(phy_mode, "rgmii-rxid") == 0) {
+		prop_dictionary_set_bool(prop, "rx_internal_delay", true);
+		sc->sc_rgmii = 1;
+	} else if (strcmp(phy_mode, "rgmii-id") == 0) {
+		prop_dictionary_set_bool(prop, "tx_internal_delay", true);
+		prop_dictionary_set_bool(prop, "rx_internal_delay", true);
+		sc->sc_rgmii = 1;
+	} else if (strcmp(phy_mode, "rgmii") == 0) {
+		sc->sc_rgmii = 1;
+	} else {
+		sc->sc_rgmii = 0;
+	}
 
 	char intrstr[128];
 	if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
@@ -128,7 +149,9 @@ enet_attach(device_t parent, device_t se
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 	enet_init_clocks(sc);
-	sc->sc_pllclock = clk_get_rate(sc->sc_clk_enet);
+	sc->sc_pllclock = clk_get_rate(sc->sc_clk_enet_ref);
+
+	enet_phy_reset(efsc, phandle);
 
 	if (enet_attach_common(self) != 0)
 		goto failure;

Index: src/sys/arch/arm/imx/fdt/imx6_platform.c
diff -u src/sys/arch/arm/imx/fdt/imx6_platform.c:1.6 src/sys/arch/arm/imx/fdt/imx6_platform.c:1.7
--- src/sys/arch/arm/imx/fdt/imx6_platform.c:1.6	Mon Aug 19 10:44:35 2019
+++ src/sys/arch/arm/imx/fdt/imx6_platform.c	Fri Oct 18 12:53:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_platform.c,v 1.6 2019/08/19 10:44:35 hkenken Exp $	*/
+/*	$NetBSD: imx6_platform.c,v 1.7 2019/10/18 12:53:08 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_platform.c,v 1.6 2019/08/19 10:44:35 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_platform.c,v 1.7 2019/10/18 12:53:08 hkenken Exp $");
 
 #include "arml2cc.h"
 #include "opt_console.h"
@@ -116,6 +116,20 @@ imx_platform_early_putchar(char c)
 static void
 imx_platform_device_register(device_t self, void *aux)
 {
+	prop_dictionary_t prop = device_properties(self);
+
+	if (device_is_a(self, "atphy")) {
+		const char * compat[] = {
+			"fsl,imx6dl-sabresd",
+			"fsl,imx6q-sabresd",
+			"fsl,imx6qp-sabresd",
+			"solidrun,hummingboard2/q",
+			"solidrun,hummingboard2/dl",
+			NULL
+		};
+		if (of_match_compatible(OF_finddevice("/"), compat))
+			prop_dictionary_set_uint32(prop, "clk_25m", 12500);
+	}
 }
 
 static u_int

Index: src/sys/dev/mii/atphy.c
diff -u src/sys/dev/mii/atphy.c:1.23 src/sys/dev/mii/atphy.c:1.24
--- src/sys/dev/mii/atphy.c:1.23	Mon Sep  2 12:48:52 2019
+++ src/sys/dev/mii/atphy.c	Fri Oct 18 12:53:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: atphy.c,v 1.23 2019/09/02 

CVS commit: src/sys

2019-10-18 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Oct 18 12:53:09 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c imx6_platform.c
src/sys/dev/mii: atphy.c

Log Message:
Modified atphy(4)

* Support CLK_25M clock out.
* Support internal delay for RGMII interface.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/if_enet_imx.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/fdt/imx6_platform.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/mii/atphy.c

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



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

2019-10-16 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Oct 16 11:16:31 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_pcie.c imxpcie.c imxpciereg.h imxpcievar.h
src/sys/arch/arm/imx/fdt: imx6_pcie.c

Log Message:
Fixed bug when using PCIe external clock.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/imx/imx6_pcie.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imxpcie.c \
src/sys/arch/arm/imx/imxpciereg.h src/sys/arch/arm/imx/imxpcievar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/fdt/imx6_pcie.c

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



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

2019-10-16 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Oct 16 11:16:31 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_pcie.c imxpcie.c imxpciereg.h imxpcievar.h
src/sys/arch/arm/imx/fdt: imx6_pcie.c

Log Message:
Fixed bug when using PCIe external clock.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/imx/imx6_pcie.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imxpcie.c \
src/sys/arch/arm/imx/imxpciereg.h src/sys/arch/arm/imx/imxpcievar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/fdt/imx6_pcie.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/imx/imx6_pcie.c
diff -u src/sys/arch/arm/imx/imx6_pcie.c:1.13 src/sys/arch/arm/imx/imx6_pcie.c:1.14
--- src/sys/arch/arm/imx/imx6_pcie.c:1.13	Sat Jul 27 08:02:04 2019
+++ src/sys/arch/arm/imx/imx6_pcie.c	Wed Oct 16 11:16:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_pcie.c,v 1.13 2019/07/27 08:02:04 skrll Exp $	*/
+/*	$NetBSD: imx6_pcie.c,v 1.14 2019/10/16 11:16:30 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2016  Genetec Corporation.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_pcie.c,v 1.13 2019/07/27 08:02:04 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_pcie.c,v 1.14 2019/10/16 11:16:30 hkenken Exp $");
 
 #include "opt_pci.h"
 
@@ -151,19 +151,19 @@ imx6_pcie_attach(device_t parent, device
 	imx6_set_gpio(self, "imxpcie-reset-gpio", >sc_gpio_reset,
 	>sc_gpio_reset_active, GPIO_PIN_OUTPUT);
 
-	sc->sc_clk_pcie_axi = imx6_get_clock("pcie_axi");
-	if (sc->sc_clk_pcie_axi == NULL) {
-		aprint_error(": couldn't get clock pcie_axi\n");
+	sc->sc_clk_pcie = imx6_get_clock("pcie_axi");
+	if (sc->sc_clk_pcie == NULL) {
+		aprint_error(": couldn't get clock pcie\n");
 		return;
 	}
-	sc->sc_clk_lvds1_gate = imx6_get_clock("lvds1_gate");
-	if (sc->sc_clk_lvds1_gate == NULL) {
-		aprint_error(": couldn't get clock lvds1_gate\n");
+	sc->sc_clk_pcie_bus = imx6_get_clock("lvds1_gate");
+	if (sc->sc_clk_pcie_bus == NULL) {
+		aprint_error(": couldn't get clock pcie_bus\n");
 		return;
 	}
-	sc->sc_clk_pcie_ref = imx6_get_clock("pcie_ref_125m");
-	if (sc->sc_clk_pcie_ref == NULL) {
-		aprint_error(": couldn't get clock pcie_ref\n");
+	sc->sc_clk_pcie_phy = imx6_get_clock("pcie_ref_125m");
+	if (sc->sc_clk_pcie_phy == NULL) {
+		aprint_error(": couldn't get clock pcie_phy\n");
 		return;
 	}
 

Index: src/sys/arch/arm/imx/imxpcie.c
diff -u src/sys/arch/arm/imx/imxpcie.c:1.2 src/sys/arch/arm/imx/imxpcie.c:1.3
--- src/sys/arch/arm/imx/imxpcie.c:1.2	Mon Sep  2 01:28:41 2019
+++ src/sys/arch/arm/imx/imxpcie.c	Wed Oct 16 11:16:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxpcie.c,v 1.2 2019/09/02 01:28:41 hkenken Exp $	*/
+/*	$NetBSD: imxpcie.c,v 1.3 2019/10/16 11:16:30 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2019  Genetec Corporation.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imxpcie.c,v 1.2 2019/09/02 01:28:41 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxpcie.c,v 1.3 2019/10/16 11:16:30 hkenken Exp $");
 
 #include "opt_pci.h"
 #include "opt_fdt.h"
@@ -133,6 +133,7 @@ imxpcie_init_phy(struct imxpcie_softc *s
 	v |= __SHIFTIN(20, IOMUX_GPR8_PCS_TX_DEEMPH_GEN1);
 	sc->sc_gpr_write(sc, IOMUX_GPR8, v);
 
+	v = sc->sc_gpr_read(sc, IOMUX_GPR12);
 	v &= ~IOMUX_GPR12_DEVICE_TYPE;
 	v |= IOMUX_GPR12_DEVICE_TYPE_PCIE_RC;
 	sc->sc_gpr_write(sc, IOMUX_GPR12, v);
@@ -244,12 +245,12 @@ imxpcie_phy_read(struct imxpcie_softc *s
 static int
 imxpcie_assert_core_reset(struct imxpcie_softc *sc)
 {
+	uint32_t gpr1 = sc->sc_gpr_read(sc, IOMUX_GPR1);
+
 	if (sc->sc_have_sw_reset) {
-		uint32_t gpr1 = sc->sc_gpr_read(sc, IOMUX_GPR1);
 		gpr1 |= IOMUX_GPR1_PCIE_SW_RST;
 		sc->sc_gpr_write(sc, IOMUX_GPR1, gpr1);
 	} else {
-		uint32_t gpr1 = sc->sc_gpr_read(sc, IOMUX_GPR1);
 		uint32_t gpr12 = sc->sc_gpr_read(sc, IOMUX_GPR12);
 
 		/* already enabled by bootloader */
@@ -263,13 +264,13 @@ imxpcie_assert_core_reset(struct imxpcie
 			gpr12 &= ~IOMUX_GPR12_APP_LTSSM_ENABLE;
 			sc->sc_gpr_write(sc, IOMUX_GPR12, gpr12);
 		}
-
-		gpr1 |= IOMUX_GPR1_TEST_POWERDOWN;
-		sc->sc_gpr_write(sc, IOMUX_GPR1, gpr1);
-		gpr1 &= ~IOMUX_GPR1_REF_SSP_EN;
-		sc->sc_gpr_write(sc, IOMUX_GPR1, gpr1);
 	}
 
+	gpr1 |= IOMUX_GPR1_TEST_POWERDOWN;
+	sc->sc_gpr_write(sc, IOMUX_GPR1, gpr1);
+	gpr1 &= ~IOMUX_GPR1_REF_SSP_EN;
+	sc->sc_gpr_write(sc, IOMUX_GPR1, gpr1);
+
 	return 0;
 }
 
@@ -278,29 +279,28 @@ imxpcie_deassert_core_reset(struct imxpc
 {
 	int error;
 
-	error = clk_enable(sc->sc_clk_pcie_axi);
+	error = clk_enable(sc->sc_clk_pcie);
 	if (error) {
-		aprint_error_dev(sc->sc_dev, "couldn't enable pcie_axi: %d\n", error);
+		aprint_error_dev(sc->sc_dev, "couldn't enable pcie: %d\n", error);
 		return error;
 	}
 
 	if (sc->sc_ext_osc) {
-		clk_set_parent(sc->sc_clk_pcie_ext, sc->sc_clk_pcie_ext_src);
 		error = clk_enable(sc->sc_clk_pcie_ext);
 		if (error) {
 	

CVS commit: src/sys/arch/arm/imx/fdt

2019-10-04 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Oct  4 06:49:40 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_ahcisata.c

Log Message:
Remove FDT_INTR_MPSAFE flag.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/fdt/imx6_ahcisata.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/imx/fdt/imx6_ahcisata.c
diff -u src/sys/arch/arm/imx/fdt/imx6_ahcisata.c:1.2 src/sys/arch/arm/imx/fdt/imx6_ahcisata.c:1.3
--- src/sys/arch/arm/imx/fdt/imx6_ahcisata.c:1.2	Mon Aug 19 03:45:51 2019
+++ src/sys/arch/arm/imx/fdt/imx6_ahcisata.c	Fri Oct  4 06:49:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_ahcisata.c,v 1.2 2019/08/19 03:45:51 hkenken Exp $	*/
+/*	$NetBSD: imx6_ahcisata.c,v 1.3 2019/10/04 06:49:40 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_ahcisata.c,v 1.2 2019/08/19 03:45:51 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ahcisata.c,v 1.3 2019/10/04 06:49:40 hkenken Exp $");
 
 #include 
 #include 
@@ -116,6 +116,8 @@ imx6_ahcisata_attach(device_t parent, de
 		sc->sc_rx_eq = 3000;
 	if (of_getprop_bool(phandle, "fsl,no-spread-spectrum") == false)
 		sc->sc_ss = 1;
+	else
+		sc->sc_ss = 0;
 
 	sc->sc_clk_sata = fdtbus_clock_get(phandle, "sata");
 	if (sc->sc_clk_sata == NULL) {
@@ -181,8 +183,8 @@ imx6_ahcisata_attach(device_t parent, de
 		return;
 	}
 
-	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_BIO,
-	FDT_INTR_MPSAFE, ahci_intr, >sc);
+	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_BIO, 0,
+	ahci_intr, >sc);
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt on %s\n",
 		intrstr);
@@ -412,10 +414,10 @@ imx6_ahcisata_init(struct imx6_ahcisata_
 			val = gpr13_sata_phy_settings[i].def_val;
 		v |= __SHIFTIN(val, gpr13_sata_phy_settings[i].mask);
 	}
-	v |= __SHIFTIN(sc->sc_ss, IOMUX_GPR13_SATA_PHY_5);
 	v |= __SHIFTIN(0x12, IOMUX_GPR13_SATA_PHY_7);	/* Rx SATA2m */
 	v |= __SHIFTIN(3, IOMUX_GPR13_SATA_PHY_6);	/* Rx DPLL mode */
 	v |= __SHIFTIN(1, IOMUX_GPR13_SATA_SPEED);	/* 3.0GHz */
+	v |= __SHIFTIN(sc->sc_ss, IOMUX_GPR13_SATA_PHY_5);
 	v |= __SHIFTIN(1, IOMUX_GPR13_SATA_PHY_1);	/* PLL clock enable */
 	bus_space_write_4(sc->sc_iot, sc->sc_gpr_ioh, IOMUX_GPR13, v);
 



CVS commit: src/sys/arch/arm/imx/fdt

2019-10-04 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Oct  4 06:49:40 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_ahcisata.c

Log Message:
Remove FDT_INTR_MPSAFE flag.


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

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-10-01 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Oct  2 01:34:09 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_iomux.c

Log Message:
Fixed compile error.

remove fdtbus_pinctrl_configure().


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

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-10-01 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Oct  2 01:34:09 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_iomux.c

Log Message:
Fixed compile error.

remove fdtbus_pinctrl_configure().


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_iomux.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/imx/fdt/imx6_iomux.c
diff -u src/sys/arch/arm/imx/fdt/imx6_iomux.c:1.1 src/sys/arch/arm/imx/fdt/imx6_iomux.c:1.2
--- src/sys/arch/arm/imx/fdt/imx6_iomux.c:1.1	Wed Jul 24 13:12:33 2019
+++ src/sys/arch/arm/imx/fdt/imx6_iomux.c	Wed Oct  2 01:34:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_iomux.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $	*/
+/*	$NetBSD: imx6_iomux.c,v 1.2 2019/10/02 01:34:09 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_iomux.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_iomux.c,v 1.2 2019/10/02 01:34:09 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -172,7 +172,5 @@ imxiomux_attach(device_t parent, device_
 			fdtbus_register_pinctrl_config(self, sub, _pinctrl_funcs);
 		}
 	}
-
-	fdtbus_pinctrl_configure();
 }
 



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

2019-09-26 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Sep 27 02:59:21 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx51_spi.c imxcspireg.h imxecspireg.h imxspi.c
imxspivar.h
src/sys/arch/arm/imx/fdt: imx6_spi.c

Log Message:
Add i.MX SPI device type.

IMX31_CSPI
IMX35_CSPI
IMX51_ECSPI


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imx51_spi.c \
src/sys/arch/arm/imx/imxspivar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imxcspireg.h \
src/sys/arch/arm/imx/imxecspireg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imxspi.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_spi.c

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



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

2019-09-26 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Sep 27 02:59:21 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx51_spi.c imxcspireg.h imxecspireg.h imxspi.c
imxspivar.h
src/sys/arch/arm/imx/fdt: imx6_spi.c

Log Message:
Add i.MX SPI device type.

IMX31_CSPI
IMX35_CSPI
IMX51_ECSPI


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imx51_spi.c \
src/sys/arch/arm/imx/imxspivar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imxcspireg.h \
src/sys/arch/arm/imx/imxecspireg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imxspi.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_spi.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/imx/imx51_spi.c
diff -u src/sys/arch/arm/imx/imx51_spi.c:1.2 src/sys/arch/arm/imx/imx51_spi.c:1.3
--- src/sys/arch/arm/imx/imx51_spi.c:1.2	Mon Aug 19 11:41:36 2019
+++ src/sys/arch/arm/imx/imx51_spi.c	Fri Sep 27 02:59:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx51_spi.c,v 1.2 2019/08/19 11:41:36 hkenken Exp $	*/
+/*	$NetBSD: imx51_spi.c,v 1.3 2019/09/27 02:59:21 hkenken Exp $	*/
 
 /*-
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx51_spi.c,v 1.2 2019/08/19 11:41:36 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx51_spi.c,v 1.3 2019/09/27 02:59:21 hkenken Exp $");
 
 #include "locators.h"
 #include "opt_imx.h"
@@ -95,6 +95,10 @@ imxspi_attach(device_t parent, device_t 
 
 	sc->sc_iot = aa->aa_iot;
 	sc->sc_enhanced = cf_flags;
+	if (sc->sc_enhanced)
+		sc->sc_type = IMX51_ECSPI;
+	else
+		sc->sc_type = IMX35_CSPI;
 
 	sc->sc_nslaves = IMXSPINSLAVES;
 	sc->sc_freq = imx51_get_clock(IMX51CLK_CSPI_CLK_ROOT);
Index: src/sys/arch/arm/imx/imxspivar.h
diff -u src/sys/arch/arm/imx/imxspivar.h:1.2 src/sys/arch/arm/imx/imxspivar.h:1.3
--- src/sys/arch/arm/imx/imxspivar.h:1.2	Mon Aug 19 11:41:36 2019
+++ src/sys/arch/arm/imx/imxspivar.h	Fri Sep 27 02:59:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxspivar.h,v 1.2 2019/08/19 11:41:36 hkenken Exp $	*/
+/*	$NetBSD: imxspivar.h,v 1.3 2019/09/27 02:59:21 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -38,6 +38,12 @@ typedef struct spi_chipset_tag {
 	int (*spi_cs_disable)(void *, int);
 } *spi_chipset_tag_t;
 
+enum imxspi_type {
+	IMX31_CSPI,
+	IMX35_CSPI,
+	IMX51_ECSPI,
+};
+
 struct imxspi_softc {
 	device_t sc_dev;
 	int sc_phandle;
@@ -57,6 +63,7 @@ struct imxspi_softc {
 
 	int sc_nslaves;
 	int sc_enhanced;
+	enum imxspi_type sc_type;
 };
 
 int imxspi_attach_common(device_t);

Index: src/sys/arch/arm/imx/imxcspireg.h
diff -u src/sys/arch/arm/imx/imxcspireg.h:1.1 src/sys/arch/arm/imx/imxcspireg.h:1.2
--- src/sys/arch/arm/imx/imxcspireg.h:1.1	Sat Mar 22 09:28:08 2014
+++ src/sys/arch/arm/imx/imxcspireg.h	Fri Sep 27 02:59:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxcspireg.h,v 1.1 2014/03/22 09:28:08 hkenken Exp $	*/
+/*	$NetBSD: imxcspireg.h,v 1.2 2019/09/27 02:59:21 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -32,15 +32,12 @@
 #define	CSPI_RXDATA		0x00
 #define	CSPI_TXDATA		0x04
 #define	CSPI_CONREG		0x08
-#ifdef IMX51
-#define	 CSPI_CON_CS		__BITS(13, 12)
-#define	 CSPI_CON_DRCTL		__BITS( 9,  8)
-#define	 CSPI_CON_BITCOUNT	__BITS(31, 20)
-#else
-#define	 CSPI_CON_CS		__BITS(25, 24)
-#define	 CSPI_CON_DRCTL		__BITS(21, 20)
-#define	 CSPI_CON_BITCOUNT	__BITS(12,  8)
-#endif
+#define	 CSPI_IMX31_CON_CS		__BITS(25, 24)
+#define	 CSPI_IMX31_CON_DRCTL		__BITS(21, 20)
+#define	 CSPI_IMX31_CON_BITCOUNT	__BITS(12,  8)
+#define	 CSPI_IMX35_CON_CS		__BITS(13, 12)
+#define	 CSPI_IMX35_CON_DRCTL		__BITS( 9,  8)
+#define	 CSPI_IMX35_CON_BITCOUNT	__BITS(31, 20)
 #define	 CSPI_CON_DIV		__BITS(18, 16)
 #define	 CSPI_CON_SSPOL		__BIT(7)	/* SPI SS Polarity Select */
 #define	 CSPI_CON_SSCTL		__BIT(6)	/* In master mode, this bit
@@ -55,12 +52,9 @@
 #define	 CSPI_CON_ENABLE	__BIT(0)	/* EN */
 #define	CSPI_INTREG		0x0c
 #define	 CSPI_INTR_ALL_EN	0x01ff	/* All Intarruption Enabled */
-#ifdef IMX51
-#define	 CSPI_INTR_TC_EN	__BIT(7)	/* TX Complete */
-#else
-#define	 CSPI_INTR_TC_EN	__BIT(8)	/* TX Complete */
-#define	 CSPI_INTR_BO_EN	__BIT(7)	/* Bit Counter Overflow */
-#endif
+#define	 CSPI_IMX31_INTR_TC_EN	__BIT(8)	/* TX Complete */
+#define	 CSPI_IMX31_INTR_BO_EN	__BIT(7)	/* Bit Counter Overflow */
+#define	 CSPI_IMX35_INTR_TC_EN	__BIT(7)	/* TX Complete */
 #define	 CSPI_INTR_RO_EN	__BIT(6)	/* RXFIFO Overflow */
 #define	 CSPI_INTR_RF_EN	__BIT(5)	/* RXFIFO Full */
 #define	 CSPI_INTR_RH_EN	__BIT(4)	/* RXFIFO Half Full */
@@ -70,14 +64,11 @@
 #define	 CSPI_INTR_TE_EN	__BIT(0)	/* TXFIFO Empty */
 #define	CSPI_DMAREG		0x10
 #define	CSPI_STATREG		0x14
-#ifdef IMX51
-#define	 CSPI_STAT_CLR_TC	__BIT(7)	/* Clear TC of status register */
-#define  CSPI_STAT_CLR		CSPI_STAT_CLR_TC

CVS commit: src/sys/arch/arm/imx/fdt

2019-09-26 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Sep 27 02:54:57 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_sdhc.c

Log Message:
Add SDHC_FLAG_NO_BUSY_INTR flag.


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

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-09-26 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Sep 27 02:54:57 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_sdhc.c

Log Message:
Add SDHC_FLAG_NO_BUSY_INTR flag.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/fdt/imx6_sdhc.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/imx/fdt/imx6_sdhc.c
diff -u src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.2 src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.3
--- src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.2	Mon Aug 19 03:48:41 2019
+++ src/sys/arch/arm/imx/fdt/imx6_sdhc.c	Fri Sep 27 02:54:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_sdhc.c,v 1.2 2019/08/19 03:48:41 hkenken Exp $	*/
+/*	$NetBSD: imx6_sdhc.c,v 1.3 2019/09/27 02:54:57 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_sdhc.c,v 1.2 2019/08/19 03:48:41 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_sdhc.c,v 1.3 2019/09/27 02:54:57 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -119,7 +119,8 @@ imx6_sdhc_attach(device_t parent, device
 	SDHC_FLAG_HAVE_DVS |
 	SDHC_FLAG_32BIT_ACCESS |
 	SDHC_FLAG_USE_ADMA2 |
-	SDHC_FLAG_USDHC;
+	SDHC_FLAG_USDHC |
+	SDHC_FLAG_NO_BUSY_INTR;
 
 	if (bus_width == 8)
 		sc->sc_sdhc.sc_flags |= SDHC_FLAG_8BIT_MODE;



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

2019-09-01 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Sep  2 01:28:41 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_ccm.c imx6_iomuxreg.h imxpcie.c imxpciereg.h
imxpcievar.h
src/sys/arch/arm/imx/fdt: imx6_pcie.c

Log Message:
Add support for imx6qp-pcie.

+ Add vpcie-supply support
+ Add ext_osc support

Tested on SABRESD i.MX 6QP.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/imx/imx6_ccm.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imx6_iomuxreg.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imxpcie.c \
src/sys/arch/arm/imx/imxpciereg.h src/sys/arch/arm/imx/imxpcievar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/imx6_pcie.c

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



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

2019-09-01 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Sep  2 01:28:41 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_ccm.c imx6_iomuxreg.h imxpcie.c imxpciereg.h
imxpcievar.h
src/sys/arch/arm/imx/fdt: imx6_pcie.c

Log Message:
Add support for imx6qp-pcie.

+ Add vpcie-supply support
+ Add ext_osc support

Tested on SABRESD i.MX 6QP.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/imx/imx6_ccm.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imx6_iomuxreg.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imxpcie.c \
src/sys/arch/arm/imx/imxpciereg.h src/sys/arch/arm/imx/imxpcievar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/imx6_pcie.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/imx/imx6_ccm.c
diff -u src/sys/arch/arm/imx/imx6_ccm.c:1.13 src/sys/arch/arm/imx/imx6_ccm.c:1.14
--- src/sys/arch/arm/imx/imx6_ccm.c:1.13	Tue Jul 30 11:11:15 2019
+++ src/sys/arch/arm/imx/imx6_ccm.c	Mon Sep  2 01:28:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_ccm.c,v 1.13 2019/07/30 11:11:15 hkenken Exp $	*/
+/*	$NetBSD: imx6_ccm.c,v 1.14 2019/09/02 01:28:41 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2010-2012, 2014  Genetec Corporation.  All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.13 2019/07/30 11:11:15 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.14 2019/09/02 01:28:41 hkenken Exp $");
 
 #include "opt_cputypes.h"
 
@@ -886,6 +886,8 @@ static struct imx6_clk imx6_clks[] = {
 
 	CLK_GATE_EXCLUSIVE("lvds1_gate", "lvds1_sel", CCM_ANALOG, MISC1, LVDS_CLK1_OBEN, LVDS_CLK1_IBEN),
 	CLK_GATE_EXCLUSIVE("lvds2_gate", "lvds2_sel", CCM_ANALOG, MISC1, LVDS_CLK2_OBEN, LVDS_CLK2_IBEN),
+	CLK_GATE_EXCLUSIVE("lvds1_in", "anaclk1", CCM_ANALOG, MISC1, LVDS_CLK1_IBEN, LVDS_CLK1_OBEN),
+	CLK_GATE_EXCLUSIVE("lvds2_in", "anaclk2", CCM_ANALOG, MISC1, LVDS_CLK2_IBEN, LVDS_CLK2_OBEN),
 };
 
 static struct imx6_clk *imx6_clk_find(const char *);

Index: src/sys/arch/arm/imx/imx6_iomuxreg.h
diff -u src/sys/arch/arm/imx/imx6_iomuxreg.h:1.5 src/sys/arch/arm/imx/imx6_iomuxreg.h:1.6
--- src/sys/arch/arm/imx/imx6_iomuxreg.h:1.5	Mon Jul 22 11:44:01 2019
+++ src/sys/arch/arm/imx/imx6_iomuxreg.h	Mon Sep  2 01:28:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_iomuxreg.h,v 1.5 2019/07/22 11:44:01 hkenken Exp $	*/
+/*	$NetBSD: imx6_iomuxreg.h,v 1.6 2019/09/02 01:28:41 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -33,6 +33,7 @@
 #define IOMUX_GPR1	0x0004
 #define  IOMUX_GPR1_CFG_L1_CLK_REMOVAL_EN	__BIT(31)
 #define  IOMUX_GPR1_APP_CLK_REQ_N		__BIT(30)
+#define  IOMUX_GPR1_PCIE_SW_RST			__BIT(29)
 #define  IOMUX_GPR1_APP_REQ_EXIT_L1		__BIT(28)
 #define  IOMUX_GPR1_APP_READY_ENTR_L23		__BIT(27)
 #define  IOMUX_GPR1_APP_REQ_ENTR_L1		__BIT(26)

Index: src/sys/arch/arm/imx/imxpcie.c
diff -u src/sys/arch/arm/imx/imxpcie.c:1.1 src/sys/arch/arm/imx/imxpcie.c:1.2
--- src/sys/arch/arm/imx/imxpcie.c:1.1	Wed Jul 24 12:33:18 2019
+++ src/sys/arch/arm/imx/imxpcie.c	Mon Sep  2 01:28:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxpcie.c,v 1.1 2019/07/24 12:33:18 hkenken Exp $	*/
+/*	$NetBSD: imxpcie.c,v 1.2 2019/09/02 01:28:41 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2019  Genetec Corporation.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imxpcie.c,v 1.1 2019/07/24 12:33:18 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxpcie.c,v 1.2 2019/09/02 01:28:41 hkenken Exp $");
 
 #include "opt_pci.h"
 #include "opt_fdt.h"
@@ -244,34 +244,32 @@ imxpcie_phy_read(struct imxpcie_softc *s
 static int
 imxpcie_assert_core_reset(struct imxpcie_softc *sc)
 {
-	uint32_t gpr1;
-	uint32_t gpr12;
+	if (sc->sc_have_sw_reset) {
+		uint32_t gpr1 = sc->sc_gpr_read(sc, IOMUX_GPR1);
+		gpr1 |= IOMUX_GPR1_PCIE_SW_RST;
+		sc->sc_gpr_write(sc, IOMUX_GPR1, gpr1);
+	} else {
+		uint32_t gpr1 = sc->sc_gpr_read(sc, IOMUX_GPR1);
+		uint32_t gpr12 = sc->sc_gpr_read(sc, IOMUX_GPR12);
 
-	gpr1 = sc->sc_gpr_read(sc, IOMUX_GPR1);
-	gpr12 = sc->sc_gpr_read(sc, IOMUX_GPR12);
+		/* already enabled by bootloader */
+		if ((gpr1 & IOMUX_GPR1_REF_SSP_EN) &&
+		(gpr12 & IOMUX_GPR12_APP_LTSSM_ENABLE)) {
+			uint32_t v = PCIE_READ(sc, PCIE_PL_PFLR);
+			v &= ~PCIE_PL_PFLR_LINK_STATE;
+			v |= PCIE_PL_PFLR_FORCE_LINK;
+			PCIE_WRITE(sc, PCIE_PL_PFLR, v);
 
-	/* already enabled by bootloader */
-	if ((gpr1 & IOMUX_GPR1_REF_SSP_EN) &&
-	(gpr12 & IOMUX_GPR12_APP_LTSSM_ENABLE)) {
-		uint32_t v = PCIE_READ(sc, PCIE_PL_PFLR);
-		v &= ~PCIE_PL_PFLR_LINK_STATE;
-		v |= PCIE_PL_PFLR_FORCE_LINK;
-		PCIE_WRITE(sc, PCIE_PL_PFLR, v);
+			gpr12 &= ~IOMUX_GPR12_APP_LTSSM_ENABLE;
+			sc->sc_gpr_write(sc, IOMUX_GPR12, gpr12);
+		}
 
-		gpr12 &= ~IOMUX_GPR12_APP_LTSSM_ENABLE;
-		sc->sc_gpr_write(sc, IOMUX_GPR12, gpr12);
+		gpr1 |= IOMUX_GPR1_TEST_POWERDOWN;
+		sc->sc_gpr_write(sc, IOMUX_GPR1, gpr1);
+		gpr1 &= 

CVS commit: src/sys/arch

2019-08-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 11:41:36 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx51_spi.c imx51reg.h imxspi.c imxspivar.h
src/sys/arch/arm/imx/fdt: files.imx6
src/sys/arch/evbarm/conf: IMX
src/sys/arch/evbarm/netwalker: netwalker_spi.c
Added Files:
src/sys/arch/arm/imx/fdt: imx6_spi.c

Log Message:
Add support SPI driver for i.MX6.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imx51_spi.c \
src/sys/arch/arm/imx/imxspivar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/imx51reg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/imxspi.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/fdt/files.imx6
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/fdt/imx6_spi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/conf/IMX
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/netwalker/netwalker_spi.c

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



CVS commit: src/sys/arch

2019-08-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 11:41:36 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx51_spi.c imx51reg.h imxspi.c imxspivar.h
src/sys/arch/arm/imx/fdt: files.imx6
src/sys/arch/evbarm/conf: IMX
src/sys/arch/evbarm/netwalker: netwalker_spi.c
Added Files:
src/sys/arch/arm/imx/fdt: imx6_spi.c

Log Message:
Add support SPI driver for i.MX6.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imx51_spi.c \
src/sys/arch/arm/imx/imxspivar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/imx51reg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/imxspi.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/fdt/files.imx6
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/fdt/imx6_spi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/conf/IMX
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/netwalker/netwalker_spi.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/imx/imx51_spi.c
diff -u src/sys/arch/arm/imx/imx51_spi.c:1.1 src/sys/arch/arm/imx/imx51_spi.c:1.2
--- src/sys/arch/arm/imx/imx51_spi.c:1.1	Sat Mar 22 09:28:08 2014
+++ src/sys/arch/arm/imx/imx51_spi.c	Mon Aug 19 11:41:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx51_spi.c,v 1.1 2014/03/22 09:28:08 hkenken Exp $	*/
+/*	$NetBSD: imx51_spi.c,v 1.2 2019/08/19 11:41:36 hkenken Exp $	*/
 
 /*-
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx51_spi.c,v 1.1 2014/03/22 09:28:08 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx51_spi.c,v 1.2 2019/08/19 11:41:36 hkenken Exp $");
 
 #include "locators.h"
 #include "opt_imx.h"
@@ -43,7 +43,8 @@ __KERNEL_RCSID(0, "$NetBSD: imx51_spi.c,
 #include 
 
 struct imx51spi_softc {
-	struct imxspi_softc sc_spi;
+	struct imxspi_softc sc_spi; /* Must be first */
+
 	struct spi_chipset_tag sc_tag;
 };
 
@@ -74,26 +75,39 @@ imxspi_match(device_t parent, cfdata_t c
 void
 imxspi_attach(device_t parent, device_t self, void *aux)
 {
-	struct imx51spi_softc *sc = device_private(self);
+	struct imx51spi_softc *isc = device_private(self);
+	struct imxspi_softc *sc = >sc_spi;
 	struct axi_attach_args *aa = aux;
 	struct imxspi_attach_args saa;
 	int cf_flags = device_cfdata(self)->cf_flags;
+	bus_addr_t addr;
+	bus_size_t size;
+	int error;
+
+	addr = aa->aa_addr;
+	size = aa->aa_size;
+	if (size <= 0)
+		size = SPI_SIZE;
 
 	sc->sc_tag.cookie = sc;
 	sc->sc_tag.spi_cs_enable = imxspi_cs_enable;
 	sc->sc_tag.spi_cs_disable = imxspi_cs_disable;
 
-	saa.saa_iot = aa->aa_iot;
-	saa.saa_addr = aa->aa_addr;
-	saa.saa_size = aa->aa_size;
-	saa.saa_irq = aa->aa_irq;
-	saa.saa_enhanced = cf_flags;
-
-	saa.saa_nslaves = IMXSPINSLAVES;
-	saa.saa_freq = imx51_get_clock(IMX51CLK_CSPI_CLK_ROOT);
-	saa.saa_tag = >sc_tag;
+	sc->sc_iot = aa->aa_iot;
+	sc->sc_enhanced = cf_flags;
 
-	sc->sc_spi.sc_dev = self;
+	sc->sc_nslaves = IMXSPINSLAVES;
+	sc->sc_freq = imx51_get_clock(IMX51CLK_CSPI_CLK_ROOT);
+	sc->sc_tag = >sc_tag;
+
+	if (bus_space_map(sc->sc_iot, addr, size, 0, >sc_ioh)) {
+		aprint_error_dev(sc->sc_dev, "couldn't map registers\n");
+		return;
+	}
+
+	/* enable device interrupts */
+	sc->sc_ih = intr_establish(aa->aa_irq, IPL_BIO, IST_LEVEL,
+	imxspi_intr, sc);
 
-	imxspi_attach_common(parent, >sc_spi, );
+	imxspi_attach_common(self);
 }
Index: src/sys/arch/arm/imx/imxspivar.h
diff -u src/sys/arch/arm/imx/imxspivar.h:1.1 src/sys/arch/arm/imx/imxspivar.h:1.2
--- src/sys/arch/arm/imx/imxspivar.h:1.1	Sat Mar 22 09:28:08 2014
+++ src/sys/arch/arm/imx/imxspivar.h	Mon Aug 19 11:41:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxspivar.h,v 1.1 2014/03/22 09:28:08 hkenken Exp $	*/
+/*	$NetBSD: imxspivar.h,v 1.2 2019/08/19 11:41:36 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -38,21 +38,10 @@ typedef struct spi_chipset_tag {
 	int (*spi_cs_disable)(void *, int);
 } *spi_chipset_tag_t;
 
-struct imxspi_attach_args {
-	bus_space_tag_t saa_iot;
-	bus_addr_t saa_addr;
-	bus_size_t saa_size;
-	int saa_irq;
-
-	spi_chipset_tag_t saa_tag;
-	int saa_nslaves;
-	unsigned long saa_freq;
-
-	int saa_enhanced;
-};
-
 struct imxspi_softc {
 	device_t sc_dev;
+	int sc_phandle;
+
 	bus_space_tag_t  sc_iot;
 	bus_space_handle_t sc_ioh;
 	spi_chipset_tag_t sc_tag;
@@ -66,10 +55,12 @@ struct imxspi_softc {
 	bool  sc_running;
 	SIMPLEQ_HEAD(,spi_transfer) sc_q;
 
+	int sc_nslaves;
 	int sc_enhanced;
 };
 
-int imxspi_attach_common(device_t, struct imxspi_softc *, void *);
+int imxspi_attach_common(device_t);
+int imxspi_intr(void *);
 
 /*
  * defined in machine dependent code

Index: src/sys/arch/arm/imx/imx51reg.h
diff -u src/sys/arch/arm/imx/imx51reg.h:1.7 src/sys/arch/arm/imx/imx51reg.h:1.8
--- src/sys/arch/arm/imx/imx51reg.h:1.7	Thu May  7 04:37:29 2015
+++ src/sys/arch/arm/imx/imx51reg.h	Mon Aug 19 11:41:36 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: 

CVS commit: src/sys/dev/spi

2019-08-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 10:56:33 UTC 2019

Modified Files:
src/sys/dev/spi: oj6sh.c

Log Message:
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/spi/oj6sh.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/dev/spi/oj6sh.c
diff -u src/sys/dev/spi/oj6sh.c:1.3 src/sys/dev/spi/oj6sh.c:1.4
--- src/sys/dev/spi/oj6sh.c:1.3	Thu Jul  4 11:13:26 2019
+++ src/sys/dev/spi/oj6sh.c	Mon Aug 19 10:56:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: oj6sh.c,v 1.3 2019/07/04 11:13:26 hkenken Exp $	*/
+/*	$NetBSD: oj6sh.c,v 1.4 2019/08/19 10:56:33 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.3 2019/07/04 11:13:26 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.4 2019/08/19 10:56:33 hkenken Exp $");
 
 #include "opt_oj6sh.h"
 
@@ -127,7 +127,7 @@ static const struct wsmouse_accessops oj
 };
 
 static int
-oj6sh_match(device_t parent, cfdata_t match, void *aux)
+oj6sh_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct spi_attach_args *sa = aux;
 
@@ -180,6 +180,7 @@ oj6sh_attach(device_t parent, device_t s
 	struct spi_attach_args *sa = aux;
 	struct wsmousedev_attach_args a;
 
+	aprint_naive("\n");
 	aprint_normal(": OJ6SH-T25 Optical Joystick\n");
 
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE);
@@ -229,7 +230,7 @@ oj6sh_cb(struct work *wk, void *arg)
 	DPRINTF(3,("%s: x = %d, y = %d\n", device_xname(sc->sc_dev),
 		delta.x, delta.y));
 
-#if defined(J6SH_DOWN_Y_LEFT_X)
+#if defined(OJ6SH_DOWN_Y_LEFT_X)
 	y = -delta.y;
 	x = -delta.x;
 #elif defined(OJ6SH_UP_X_LEFT_Y)



CVS commit: src/sys/dev/spi

2019-08-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 10:56:33 UTC 2019

Modified Files:
src/sys/dev/spi: oj6sh.c

Log Message:
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/spi/oj6sh.c

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-08-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 10:44:35 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_platform.c

Log Message:
Use a9ptmr_delay().


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/fdt/imx6_platform.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/imx/fdt/imx6_platform.c
diff -u src/sys/arch/arm/imx/fdt/imx6_platform.c:1.5 src/sys/arch/arm/imx/fdt/imx6_platform.c:1.6
--- src/sys/arch/arm/imx/fdt/imx6_platform.c:1.5	Mon Aug  5 12:44:01 2019
+++ src/sys/arch/arm/imx/fdt/imx6_platform.c	Mon Aug 19 10:44:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_platform.c,v 1.5 2019/08/05 12:44:01 hkenken Exp $	*/
+/*	$NetBSD: imx6_platform.c,v 1.6 2019/08/19 10:44:35 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_platform.c,v 1.5 2019/08/05 12:44:01 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_platform.c,v 1.6 2019/08/19 10:44:35 hkenken Exp $");
 
 #include "arml2cc.h"
 #include "opt_console.h"
@@ -191,7 +191,7 @@ const struct arm_platform imx6_platform 
 	.ap_init_attach_args = imx_platform_init_attach_args,
 	.ap_device_register = imx_platform_device_register,
 	.ap_reset = imx6_platform_reset,
-	.ap_delay = a9tmr_delay,
+	.ap_delay = a9ptmr_delay,
 	.ap_uart_freq = imx_platform_uart_freq,
 	.ap_mpstart = imx_platform_mpstart,
 };



CVS commit: src/sys/arch/arm/imx/fdt

2019-08-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 10:44:35 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_platform.c

Log Message:
Use a9ptmr_delay().


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

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-08-18 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 03:48:41 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_sdhc.c

Log Message:
Support write protect gpio pin.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_sdhc.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/imx/fdt/imx6_sdhc.c
diff -u src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.1 src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.2
--- src/sys/arch/arm/imx/fdt/imx6_sdhc.c:1.1	Wed Jul 24 13:12:33 2019
+++ src/sys/arch/arm/imx/fdt/imx6_sdhc.c	Mon Aug 19 03:48:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_sdhc.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $	*/
+/*	$NetBSD: imx6_sdhc.c,v 1.2 2019/08/19 03:48:41 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_sdhc.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_sdhc.c,v 1.2 2019/08/19 03:48:41 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -50,6 +50,7 @@ static int imx6_sdhc_match(device_t, cfd
 static void imx6_sdhc_attach(device_t, device_t, void *);
 
 static int imx6_sdhc_card_detect(struct sdhc_softc *);
+static int imx6_sdhc_write_protect(struct sdhc_softc *);
 
 struct imx6_sdhc_softc {
 	struct sdhc_softc sc_sdhc;
@@ -64,6 +65,7 @@ struct imx6_sdhc_softc {
 	struct clk		*sc_clk_per;
 
 	struct fdtbus_gpio_pin	*sc_pin_cd;
+	struct fdtbus_gpio_pin	*sc_pin_wp;
 };
 
 CFATTACH_DECL_NEW(imx6_sdhc, sizeof(struct imx6_sdhc_softc),
@@ -116,13 +118,12 @@ imx6_sdhc_attach(device_t parent, device
 	SDHC_FLAG_NO_PWR0 |
 	SDHC_FLAG_HAVE_DVS |
 	SDHC_FLAG_32BIT_ACCESS |
-	SDHC_FLAG_8BIT_MODE |
 	SDHC_FLAG_USE_ADMA2 |
 	SDHC_FLAG_USDHC;
 
-	if (bus_width == 8) {
+	if (bus_width == 8)
 		sc->sc_sdhc.sc_flags |= SDHC_FLAG_8BIT_MODE;
-	}
+
 	sc->sc_sdhc.sc_host = >sc_host;
 
 	sc->sc_bst = faa->faa_bst;
@@ -135,12 +136,17 @@ imx6_sdhc_attach(device_t parent, device
 
 	sc->sc_pin_cd = fdtbus_gpio_acquire(faa->faa_phandle,
 	"cd-gpios", GPIO_PIN_INPUT);
-
 	if (sc->sc_pin_cd) {
 		sc->sc_sdhc.sc_vendor_card_detect = imx6_sdhc_card_detect;
 		sc->sc_sdhc.sc_flags |= SDHC_FLAG_POLL_CARD_DET;
 	}
 
+	sc->sc_pin_wp = fdtbus_gpio_acquire(faa->faa_phandle,
+	"wp-gpios", GPIO_PIN_INPUT);
+	if (sc->sc_pin_wp) {
+		sc->sc_sdhc.sc_vendor_write_protect = imx6_sdhc_write_protect;
+	}
+
 	error = clk_enable(sc->sc_clk_per);
 	if (error) {
 		aprint_error(": couldn't enable clock: %d\n", error);
@@ -160,8 +166,8 @@ imx6_sdhc_attach(device_t parent, device
 		return;
 	}
 
-	sc->sc_ih = fdtbus_intr_establish(faa->faa_phandle, 0, IPL_SDMMC, 0,
-	sdhc_intr, >sc_sdhc);
+	sc->sc_ih = fdtbus_intr_establish(faa->faa_phandle, 0, IPL_SDMMC,
+	FDT_INTR_MPSAFE, sdhc_intr, >sc_sdhc);
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "couldn't establish interrupt on %s\n",
 		intrstr);
@@ -189,3 +195,13 @@ imx6_sdhc_card_detect(struct sdhc_softc 
 	return fdtbus_gpio_read(sc->sc_pin_cd);
 }
 
+static int
+imx6_sdhc_write_protect(struct sdhc_softc *ssc)
+{
+	struct imx6_sdhc_softc *sc = device_private(ssc->sc_dev);
+
+	KASSERT(sc->sc_pin_wp != NULL);
+
+	return fdtbus_gpio_read(sc->sc_pin_wp);
+}
+



CVS commit: src/sys/arch/arm/imx/fdt

2019-08-18 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 03:48:41 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_sdhc.c

Log Message:
Support write protect gpio pin.


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

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-08-18 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 03:45:51 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c imx6_ahcisata.c imx6_gpio.c
imx6_pcie.c imx6_usb.c

Log Message:
Enable FDT_INTR_MPSAFE flag.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/fdt/if_enet_imx.c \
src/sys/arch/arm/imx/fdt/imx6_pcie.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_ahcisata.c \
src/sys/arch/arm/imx/fdt/imx6_gpio.c src/sys/arch/arm/imx/fdt/imx6_usb.c

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



CVS commit: src/sys/arch/arm/imx/fdt

2019-08-18 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug 19 03:45:51 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: if_enet_imx.c imx6_ahcisata.c imx6_gpio.c
imx6_pcie.c imx6_usb.c

Log Message:
Enable FDT_INTR_MPSAFE flag.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/fdt/if_enet_imx.c \
src/sys/arch/arm/imx/fdt/imx6_pcie.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_ahcisata.c \
src/sys/arch/arm/imx/fdt/imx6_gpio.c src/sys/arch/arm/imx/fdt/imx6_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/imx/fdt/if_enet_imx.c
diff -u src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.2 src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.3
--- src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.2	Tue Jul 30 06:26:31 2019
+++ src/sys/arch/arm/imx/fdt/if_enet_imx.c	Mon Aug 19 03:45:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx.c,v 1.2 2019/07/30 06:26:31 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx.c,v 1.3 2019/08/19 03:45:51 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.2 2019/07/30 06:26:31 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx.c,v 1.3 2019/08/19 03:45:51 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -118,8 +118,8 @@ enet_attach(device_t parent, device_t se
 		aprint_error_dev(self, "failed to decode interrupt\n");
 		goto failure;
 	}
-	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_NET, 0,
-	enet_intr, sc);
+	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_NET,
+	FDT_INTR_MPSAFE, enet_intr, sc);
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt on %s\n",
 		intrstr);
Index: src/sys/arch/arm/imx/fdt/imx6_pcie.c
diff -u src/sys/arch/arm/imx/fdt/imx6_pcie.c:1.2 src/sys/arch/arm/imx/fdt/imx6_pcie.c:1.3
--- src/sys/arch/arm/imx/fdt/imx6_pcie.c:1.2	Fri Jul 26 06:57:54 2019
+++ src/sys/arch/arm/imx/fdt/imx6_pcie.c	Mon Aug 19 03:45:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_pcie.c,v 1.2 2019/07/26 06:57:54 skrll Exp $	*/
+/*	$NetBSD: imx6_pcie.c,v 1.3 2019/08/19 03:45:51 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_pcie.c,v 1.2 2019/07/26 06:57:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_pcie.c,v 1.3 2019/08/19 03:45:51 hkenken Exp $");
 
 #include "opt_pci.h"
 #include "opt_fdt.h"
@@ -179,7 +179,8 @@ imx6_pcie_attach(device_t parent, device
 		return;
 	}
 
-	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_VM, 0, imxpcie_intr, sc);
+	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_VM,
+	FDT_INTR_MPSAFE, imxpcie_intr, sc);
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt on %s\n",
 		intrstr);

Index: src/sys/arch/arm/imx/fdt/imx6_ahcisata.c
diff -u src/sys/arch/arm/imx/fdt/imx6_ahcisata.c:1.1 src/sys/arch/arm/imx/fdt/imx6_ahcisata.c:1.2
--- src/sys/arch/arm/imx/fdt/imx6_ahcisata.c:1.1	Wed Jul 24 13:12:33 2019
+++ src/sys/arch/arm/imx/fdt/imx6_ahcisata.c	Mon Aug 19 03:45:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_ahcisata.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $	*/
+/*	$NetBSD: imx6_ahcisata.c,v 1.2 2019/08/19 03:45:51 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_ahcisata.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ahcisata.c,v 1.2 2019/08/19 03:45:51 hkenken Exp $");
 
 #include 
 #include 
@@ -181,8 +181,8 @@ imx6_ahcisata_attach(device_t parent, de
 		return;
 	}
 
-	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_BIO, 0,
-	ahci_intr, >sc);
+	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_BIO,
+	FDT_INTR_MPSAFE, ahci_intr, >sc);
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt on %s\n",
 		intrstr);
Index: src/sys/arch/arm/imx/fdt/imx6_gpio.c
diff -u src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.1 src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.2
--- src/sys/arch/arm/imx/fdt/imx6_gpio.c:1.1	Wed Jul 24 13:12:33 2019
+++ src/sys/arch/arm/imx/fdt/imx6_gpio.c	Mon Aug 19 03:45:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_gpio.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $	*/
+/*	$NetBSD: imx6_gpio.c,v 1.2 2019/08/19 03:45:51 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_gpio.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $");

CVS commit: src/sys/arch/arm/imx/fdt

2019-08-05 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug  5 12:44:01 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_platform.c

Log Message:
Add "fsl,imx6qp" (i.MX6QP) to ARM_PLATFORM list.


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

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



CVS commit: src/sys/arch/evbarm/netwalker

2019-08-05 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug  5 12:30:13 UTC 2019

Modified Files:
src/sys/arch/evbarm/netwalker: netwalker_usb.c

Log Message:
Remove debug print message.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/evbarm/netwalker/netwalker_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/evbarm/netwalker/netwalker_usb.c
diff -u src/sys/arch/evbarm/netwalker/netwalker_usb.c:1.6 src/sys/arch/evbarm/netwalker/netwalker_usb.c:1.7
--- src/sys/arch/evbarm/netwalker/netwalker_usb.c:1.6	Wed Jul 24 12:33:18 2019
+++ src/sys/arch/evbarm/netwalker/netwalker_usb.c	Mon Aug  5 12:30:13 2019
@@ -25,7 +25,7 @@
  *
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netwalker_usb.c,v 1.6 2019/07/24 12:33:18 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netwalker_usb.c,v 1.7 2019/08/05 12:30:13 hkenken Exp $");
 
 #include "locators.h"
 
@@ -77,10 +77,9 @@ imxusbc_match(device_t parent, cfdata_t 
 {
 	struct axi_attach_args *aa = aux;
 
-	printf("%s\n", __func__);
-
 	if (aa->aa_addr == USBOH3_BASE)
 		return 1;
+
 	return 0;
 }
 
@@ -90,7 +89,7 @@ imxusbc_attach(device_t parent, device_t
 	struct imxusbc_softc *sc = device_private(self);
 	struct axi_attach_args *aa = aux;
 
-	aprint_normal("\n");
+	aprint_naive("\n");
 	aprint_normal(": Universal Serial Bus Controller\n");
 
 	if (aa->aa_size == AXICF_SIZE_DEFAULT)



CVS commit: src/sys

2019-08-05 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug  5 12:21:00 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_i2c.c
src/sys/dev/i2c: motoi2c.c motoi2cvar.h

Log Message:
Add support FDT.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_i2c.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/motoi2c.c \
src/sys/dev/i2c/motoi2cvar.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/imx/fdt/imx6_i2c.c
diff -u src/sys/arch/arm/imx/fdt/imx6_i2c.c:1.1 src/sys/arch/arm/imx/fdt/imx6_i2c.c:1.2
--- src/sys/arch/arm/imx/fdt/imx6_i2c.c:1.1	Tue Jul 30 06:52:57 2019
+++ src/sys/arch/arm/imx/fdt/imx6_i2c.c	Mon Aug  5 12:21:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_i2c.c,v 1.1 2019/07/30 06:52:57 hkenken Exp $	*/
+/*	$NetBSD: imx6_i2c.c,v 1.2 2019/08/05 12:21:00 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_i2c.c,v 1.1 2019/07/30 06:52:57 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_i2c.c,v 1.2 2019/08/05 12:21:00 hkenken Exp $");
 
 #include 
 
@@ -75,6 +75,9 @@ imxi2c_attach(device_t parent __unused, 
 	if (error)
 		freq = 10;
 	imxi2c_set_freq(self, clk_get_rate(sc->sc_clk), freq);
+
+	sc->sc_motoi2c.sc_phandle = phandle;
+
 	imxi2c_attach_common(parent, self, bst, addr, size, -1, 0);
 }
 

Index: src/sys/dev/i2c/motoi2c.c
diff -u src/sys/dev/i2c/motoi2c.c:1.4 src/sys/dev/i2c/motoi2c.c:1.5
--- src/sys/dev/i2c/motoi2c.c:1.4	Sun Apr 17 15:14:59 2011
+++ src/sys/dev/i2c/motoi2c.c	Mon Aug  5 12:21:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: motoi2c.c,v 1.4 2011/04/17 15:14:59 phx Exp $ */
+/* $NetBSD: motoi2c.c,v 1.5 2019/08/05 12:21:00 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.4 2011/04/17 15:14:59 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.5 2019/08/05 12:21:00 hkenken Exp $");
+
+#if defined(__arm__) || defined(__aarch64__)
+#include "opt_fdt.h"
+#endif
 
 #include 
 #include 
@@ -43,6 +47,10 @@ __KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 
 #include 
 #include 
 
+#ifdef FDT
+#include 
+#endif
+
 #ifdef DEBUG
 int motoi2c_debug = 0;
 #define	DPRINTF(x)	if (motoi2c_debug) printf x
@@ -50,6 +58,20 @@ int motoi2c_debug = 0;
 #define	DPRINTF(x)
 #endif
 
+#ifdef FDT
+static i2c_tag_t
+motoi2c_get_tag(device_t dev)
+{
+	struct motoi2c_softc * const sc = device_private(dev);
+
+	return >sc_i2c;
+}
+
+static const struct fdtbus_i2c_controller_func motoi2c_funcs = {
+	.get_tag = motoi2c_get_tag,
+};
+#endif
+
 static int  motoi2c_acquire_bus(void *, int);
 static void motoi2c_release_bus(void *, int);
 static int  motoi2c_exec(void *, i2c_op_t, i2c_addr_t, const void *, size_t,
@@ -111,7 +133,14 @@ motoi2c_attach_common(device_t self, str
 	I2C_WRITE(I2CADR, i2c->i2c_adr);	/* our slave address is 0x7f */
 	I2C_WRITE(I2CSR, 0);		/* clear status flags */
 
+#ifdef FDT
+	KASSERT(sc->sc_phandle != 0);
+	fdtbus_register_i2c_controller(self, sc->sc_phandle, _funcs);
+
+	fdtbus_attach_i2cbus(self, sc->sc_phandle, >sc_i2c, iicbus_print);
+#else
 	config_found_ia(self, "i2cbus", , iicbus_print);
+#endif
 }
 
 static int
Index: src/sys/dev/i2c/motoi2cvar.h
diff -u src/sys/dev/i2c/motoi2cvar.h:1.4 src/sys/dev/i2c/motoi2cvar.h:1.5
--- src/sys/dev/i2c/motoi2cvar.h:1.4	Sun Apr 17 15:14:59 2011
+++ src/sys/dev/i2c/motoi2cvar.h	Mon Aug  5 12:21:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: motoi2cvar.h,v 1.4 2011/04/17 15:14:59 phx Exp $ */
+/* $NetBSD: motoi2cvar.h,v 1.5 2019/08/05 12:21:00 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
@@ -51,6 +51,7 @@ struct motoi2c_softc {
 	kmutex_t		sc_buslock;
 	motoi2c_iord_t		sc_iord;
 	motoi2c_iowr_t		sc_iowr;
+	int			sc_phandle;
 };
 
 #define	MOTOI2C_ADR_DEFAULT	(0x7e << 1)



CVS commit: src/sys

2019-08-05 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Aug  5 12:21:00 UTC 2019

Modified Files:
src/sys/arch/arm/imx/fdt: imx6_i2c.c
src/sys/dev/i2c: motoi2c.c motoi2cvar.h

Log Message:
Add support FDT.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/imx6_i2c.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/motoi2c.c \
src/sys/dev/i2c/motoi2cvar.h

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



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

2019-07-30 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Jul 30 11:11:15 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_ccm.c

Log Message:
Fix overflow to calculate frequencies.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/imx/imx6_ccm.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/imx/imx6_ccm.c
diff -u src/sys/arch/arm/imx/imx6_ccm.c:1.12 src/sys/arch/arm/imx/imx6_ccm.c:1.13
--- src/sys/arch/arm/imx/imx6_ccm.c:1.12	Fri Jul 26 06:57:54 2019
+++ src/sys/arch/arm/imx/imx6_ccm.c	Tue Jul 30 11:11:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_ccm.c,v 1.12 2019/07/26 06:57:54 skrll Exp $	*/
+/*	$NetBSD: imx6_ccm.c,v 1.13 2019/07/30 11:11:15 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2010-2012, 2014  Genetec Corporation.  All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.12 2019/07/26 06:57:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.13 2019/07/30 11:11:15 hkenken Exp $");
 
 #include "opt_cputypes.h"
 
@@ -1031,6 +1031,7 @@ imxccm_clk_get_rate_pll_generic(struct i
 const u_int rate_parent)
 {
 	struct imx6_clk_pll *pll = >clk.pll;
+	uint64_t freq = rate_parent;
 
 	KASSERT((pll->type == IMX6_CLK_PLL_GENNERIC) ||
 	(pll->type == IMX6_CLK_PLL_USB));
@@ -1038,7 +1039,7 @@ imxccm_clk_get_rate_pll_generic(struct i
 	uint32_t v = bus_space_read_4(sc->sc_iot, sc->sc_ioh_analog, pll->reg);
 	uint32_t div = __SHIFTOUT(v, pll->mask);
 
-	return rate_parent * ((div == 1) ? 22 : 20);
+	return freq * ((div == 1) ? 22 : 20);
 }
 
 static u_int
@@ -1046,13 +1047,14 @@ imxccm_clk_get_rate_pll_sys(struct imxcc
 const u_int rate_parent)
 {
 	struct imx6_clk_pll *pll = >clk.pll;
+	uint64_t freq = rate_parent;
 
 	KASSERT(pll->type == IMX6_CLK_PLL_SYS);
 
 	uint32_t v = bus_space_read_4(sc->sc_iot, sc->sc_ioh_analog, pll->reg);
 	uint32_t div = __SHIFTOUT(v, pll->mask);
 
-	return rate_parent * div / 2;
+	return freq * div / 2;
 }
 
 #define PLL_AUDIO_VIDEO_NUM_OFFSET	0x10
@@ -1063,7 +1065,7 @@ imxccm_clk_get_rate_pll_audio_video(stru
 struct imx6_clk *iclk, const u_int rate_parent)
 {
 	struct imx6_clk_pll *pll = >clk.pll;
-	uint64_t freq;
+	uint64_t freq = rate_parent;
 
 	KASSERT(pll->type == IMX6_CLK_PLL_AUDIO_VIDEO);
 
@@ -1074,10 +1076,9 @@ imxccm_clk_get_rate_pll_audio_video(stru
 	uint32_t denom = bus_space_read_4(sc->sc_iot, sc->sc_ioh_analog,
 	pll->reg + PLL_AUDIO_VIDEO_DENOM_OFFSET);
 
-	uint64_t tmp = rate_parent * num / denom;
-	freq = (uint64_t)rate_parent * div + tmp;
+	uint64_t tmp = freq * num / denom;
 
-	return freq;
+	return freq * div + tmp;
 }
 
 static u_int
@@ -1102,7 +1103,7 @@ imxccm_clk_get_rate_fixed_factor(struct 
 	parent = imx6_clk_find(iclk->parent);
 	KASSERT(parent != NULL);
 
-	const u_int rate_parent = imxccm_clk_get_rate(sc, >base);
+	uint64_t rate_parent = imxccm_clk_get_rate(sc, >base);
 
 	return rate_parent * fixed_factor->mult / fixed_factor->div;
 }
@@ -1118,7 +1119,7 @@ imxccm_clk_get_rate_pll(struct imxccm_so
 	parent = imx6_clk_find(iclk->parent);
 	KASSERT(parent != NULL);
 
-	const u_int rate_parent = imxccm_clk_get_rate(sc, >base);
+	uint64_t rate_parent = imxccm_clk_get_rate(sc, >base);
 
 	switch(pll->type) {
 	case IMX6_CLK_PLL_GENNERIC:
@@ -1182,7 +1183,7 @@ imxccm_clk_get_rate_pfd(struct imxccm_so
 	parent = imx6_clk_find(iclk->parent);
 	KASSERT(parent != NULL);
 
-	const u_int rate_parent = imxccm_clk_get_rate(sc, >base);
+	uint64_t rate_parent = imxccm_clk_get_rate(sc, >base);
 
 	uint32_t v = bus_space_read_4(sc->sc_iot, sc->sc_ioh_analog, pfd->reg);
 	uint32_t n = __SHIFTOUT(v, __BITS(5, 0) << (pfd->index * 8));



CVS commit: src/sys/arch

2019-07-30 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Jul 30 06:52:58 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imxi2c.c
src/sys/arch/arm/imx/fdt: files.imx6
src/sys/arch/evbarm/conf: IMX
Added Files:
src/sys/arch/arm/imx/fdt: imx6_i2c.c

Log Message:
Add IIC support.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imxi2c.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/files.imx6
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/fdt/imx6_i2c.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/conf/IMX

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



CVS commit: src/sys/arch

2019-07-30 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Jul 30 06:52:58 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imxi2c.c
src/sys/arch/arm/imx/fdt: files.imx6
src/sys/arch/evbarm/conf: IMX
Added Files:
src/sys/arch/arm/imx/fdt: imx6_i2c.c

Log Message:
Add IIC support.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imxi2c.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/fdt/files.imx6
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/fdt/imx6_i2c.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/conf/IMX

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/imx/imxi2c.c
diff -u src/sys/arch/arm/imx/imxi2c.c:1.2 src/sys/arch/arm/imx/imxi2c.c:1.3
--- src/sys/arch/arm/imx/imxi2c.c:1.2	Fri Mar 27 05:31:23 2015
+++ src/sys/arch/arm/imx/imxi2c.c	Tue Jul 30 06:52:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxi2c.c,v 1.2 2015/03/27 05:31:23 hkenken Exp $	*/
+/*	$NetBSD: imxi2c.c,v 1.3 2019/07/30 06:52:57 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2012, 2015 Genetec Corporation.  All rights reserved.
@@ -27,9 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imxi2c.c,v 1.2 2015/03/27 05:31:23 hkenken Exp $");
-
-#include "opt_imx.h"
+__KERNEL_RCSID(0, "$NetBSD: imxi2c.c,v 1.3 2019/07/30 06:52:57 hkenken Exp $");
 
 #include 
 #include 
@@ -39,12 +37,10 @@ __KERNEL_RCSID(0, "$NetBSD: imxi2c.c,v 1
 #include 
 #include 
 
-struct clk_div {
+static const struct clk_div {
 	uint8_t ic_val;
 	int div;
-};
-
-static const struct clk_div imxi2c_clk_div[] = {
+} imxi2c_clk_div[] = {
 	{0x20, 22},   {0x21, 24},   {0x22, 26},   {0x23, 28},
 	{0x00, 30},   {0x01, 32},   {0x24, 32},   {0x02, 36},
 	{0x25, 36},   {0x26, 40},   {0x03, 42},   {0x27, 44},

Index: src/sys/arch/arm/imx/fdt/files.imx6
diff -u src/sys/arch/arm/imx/fdt/files.imx6:1.3 src/sys/arch/arm/imx/fdt/files.imx6:1.4
--- src/sys/arch/arm/imx/fdt/files.imx6:1.3	Tue Jul 30 06:26:31 2019
+++ src/sys/arch/arm/imx/fdt/files.imx6	Tue Jul 30 06:52:57 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.imx6,v 1.3 2019/07/30 06:26:31 hkenken Exp $
+#	$NetBSD: files.imx6,v 1.4 2019/07/30 06:52:57 hkenken Exp $
 #
 # Configuration info for the Freescale i.MX6
 #
@@ -78,3 +78,9 @@ device	imxpcie: pcibus
 attach	imxpcie at fdt with imxpcie_fdt
 file	arch/arm/imx/imxpcie.c			imxpcie
 file	arch/arm/imx/fdt/imx6_pcie.c		imxpcie_fdt
+
+# iMX iic Controler
+device	imxi2c: motoi2c, i2cbus, i2cexec
+attach	imxi2c at fdt
+file	arch/arm/imx/imxi2c.c			imxi2c
+file	arch/arm/imx/fdt/imx6_i2c.c		imxi2c

Index: src/sys/arch/evbarm/conf/IMX
diff -u src/sys/arch/evbarm/conf/IMX:1.1 src/sys/arch/evbarm/conf/IMX:1.2
--- src/sys/arch/evbarm/conf/IMX:1.1	Wed Jul 24 13:12:34 2019
+++ src/sys/arch/evbarm/conf/IMX	Tue Jul 30 06:52:57 2019
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: IMX,v 1.1 2019/07/24 13:12:34 hkenken Exp $
+#	$NetBSD: IMX,v 1.2 2019/07/30 06:52:57 hkenken Exp $
 #
 #	NXP(Freescale) I.MX family SoCs
 #
@@ -130,5 +130,9 @@ pci*		at imxpcie?
 ppb*		at pci? dev ? function ?
 pci*		at ppb?
 
+# IIC
+imxi2c* 	at fdt?
+iic*		at imxi2c?
+
 cinclude "arch/evbarm/conf/IMX.local"
 

Added files:

Index: src/sys/arch/arm/imx/fdt/imx6_i2c.c
diff -u /dev/null src/sys/arch/arm/imx/fdt/imx6_i2c.c:1.1
--- /dev/null	Tue Jul 30 06:52:58 2019
+++ src/sys/arch/arm/imx/fdt/imx6_i2c.c	Tue Jul 30 06:52:57 2019
@@ -0,0 +1,80 @@
+/*	$NetBSD: imx6_i2c.c,v 1.1 2019/07/30 06:52:57 hkenken Exp $	*/
+/*-
+ * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
+ * Written by Hashimoto Kenichi for Genetec Corporation.
+ *
+ * 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.
+ */
+#include 
+__KERNEL_RCSID(0, "$NetBSD: imx6_i2c.c,v 1.1 2019/07/30 06:52:57 hkenken Exp 

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

2019-07-30 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Jul 30 06:26:31 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet.c if_enet_imx6.c if_enet_imx7.c
src/sys/arch/arm/imx/fdt: files.imx6 if_enet_imx.c

Log Message:
Remove fdtbus_gpio_release() from enet_phy_reset().


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/imx/if_enet.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/if_enet_imx6.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/if_enet_imx7.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/fdt/files.imx6
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/fdt/if_enet_imx.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/imx/if_enet.c
diff -u src/sys/arch/arm/imx/if_enet.c:1.24 src/sys/arch/arm/imx/if_enet.c:1.25
--- src/sys/arch/arm/imx/if_enet.c:1.24	Tue Jul 23 06:36:36 2019
+++ src/sys/arch/arm/imx/if_enet.c	Tue Jul 30 06:26:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet.c,v 1.24 2019/07/23 06:36:36 hkenken Exp $	*/
+/*	$NetBSD: if_enet.c,v 1.25 2019/07/30 06:26:31 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.24 2019/07/23 06:36:36 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.25 2019/07/30 06:26:31 hkenken Exp $");
 
 #include "vlan.h"
 
@@ -166,9 +166,6 @@ static void enet_drain_rxbuf(struct enet
 static int enet_alloc_dma(struct enet_softc *, size_t, void **,
 			  bus_dmamap_t *);
 
-CFATTACH_DECL_NEW(enet, sizeof(struct enet_softc),
-enet_match, enet_attach, NULL, NULL);
-
 int
 enet_attach_common(device_t self)
 {

Index: src/sys/arch/arm/imx/if_enet_imx6.c
diff -u src/sys/arch/arm/imx/if_enet_imx6.c:1.5 src/sys/arch/arm/imx/if_enet_imx6.c:1.6
--- src/sys/arch/arm/imx/if_enet_imx6.c:1.5	Tue Jul 23 06:36:36 2019
+++ src/sys/arch/arm/imx/if_enet_imx6.c	Tue Jul 30 06:26:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx6.c,v 1.5 2019/07/23 06:36:36 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx6.c,v 1.6 2019/07/30 06:26:31 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.5 2019/07/23 06:36:36 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.6 2019/07/30 06:26:31 hkenken Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -47,6 +47,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_enet_imx6
 #include 
 #include 
 
+CFATTACH_DECL_NEW(enet, sizeof(struct enet_softc),
+enet_match, enet_attach, NULL, NULL);
+
 static int enet_init_clocks(struct enet_softc *);
 
 int

Index: src/sys/arch/arm/imx/if_enet_imx7.c
diff -u src/sys/arch/arm/imx/if_enet_imx7.c:1.3 src/sys/arch/arm/imx/if_enet_imx7.c:1.4
--- src/sys/arch/arm/imx/if_enet_imx7.c:1.3	Tue Jul 23 06:36:36 2019
+++ src/sys/arch/arm/imx/if_enet_imx7.c	Tue Jul 30 06:26:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx7.c,v 1.3 2019/07/23 06:36:36 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx7.c,v 1.4 2019/07/30 06:26:31 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx7.c,v 1.3 2019/07/23 06:36:36 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx7.c,v 1.4 2019/07/30 06:26:31 hkenken Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -46,6 +46,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_enet_imx7
 #include 
 #include 
 
+CFATTACH_DECL_NEW(enet, sizeof(struct enet_softc),
+enet_match, enet_attach, NULL, NULL);
+
 static void get_mac_from_ocotp(struct enet_softc *, device_t self,
 const char *);
 

Index: src/sys/arch/arm/imx/fdt/files.imx6
diff -u src/sys/arch/arm/imx/fdt/files.imx6:1.2 src/sys/arch/arm/imx/fdt/files.imx6:1.3
--- src/sys/arch/arm/imx/fdt/files.imx6:1.2	Sat Jul 27 08:02:04 2019
+++ src/sys/arch/arm/imx/fdt/files.imx6	Tue Jul 30 06:26:31 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.imx6,v 1.2 2019/07/27 08:02:04 skrll Exp $
+#	$NetBSD: files.imx6,v 1.3 2019/07/30 06:26:31 hkenken Exp $
 #
 # Configuration info for the Freescale i.MX6
 #
@@ -48,9 +48,9 @@ defflag opt_imxuart.h			IMXUARTCONSOLE
 
 # FEC
 device	enet: ether, ifnet, arp, mii, bus_dma_generic
-attach	enet at fdt
+attach	enet at fdt with enet_fdt
 file	arch/arm/imx/if_enet.c		enet
-file	arch/arm/imx/fdt/if_enet_imx.c	enet
+file	arch/arm/imx/fdt/if_enet_imx.c	enet_fdt
 
 # SATA
 attach	ahcisata at fdt with imx6_ahcisata

Index: src/sys/arch/arm/imx/fdt/if_enet_imx.c
diff -u src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.1 src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.2
--- src/sys/arch/arm/imx/fdt/if_enet_imx.c:1.1	Wed Jul 24 13:12:33 2019
+++ src/sys/arch/arm/imx/fdt/if_enet_imx.c	Tue Jul 30 06:26:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx.c,v 1.1 2019/07/24 13:12:33 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx.c,v 1.2 2019/07/30 06:26:31 hkenken Exp $	*/
 /*-
  * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
  * 

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

2019-07-27 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Sat Jul 27 12:07:24 UTC 2019

Modified Files:
src/sys/arch/arm/imx: files.imx7

Log Message:
Fixed compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/files.imx7

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



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

2019-07-27 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Sat Jul 27 12:07:24 UTC 2019

Modified Files:
src/sys/arch/arm/imx: files.imx7

Log Message:
Fixed compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/files.imx7

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/imx/files.imx7
diff -u src/sys/arch/arm/imx/files.imx7:1.7 src/sys/arch/arm/imx/files.imx7:1.8
--- src/sys/arch/arm/imx/files.imx7:1.7	Wed Jul 24 12:33:18 2019
+++ src/sys/arch/arm/imx/files.imx7	Sat Jul 27 12:07:24 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.imx7,v 1.7 2019/07/24 12:33:18 hkenken Exp $
+#	$NetBSD: files.imx7,v 1.8 2019/07/27 12:07:24 hkenken Exp $
 #
 # Configuration info for the Freescale i.MX7
 #
@@ -52,7 +52,7 @@ file	arch/arm/imx/imxwdog.c			imxwdog
 # iMX GPIO
 device	imxgpio: gpiobus
 attach	imxgpio at axi
-file	arch/arm/imx/imxgpio.c			imxgpio
+file	arch/arm/imx/imxgpio.c			imxgpio		needs-flag
 file	arch/arm/imx/imx7_gpio.c		imxgpio
 
 # iMX7 IOMUX



CVS commit: src/sys/arch

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 13:12:34 UTC 2019

Added Files:
src/sys/arch/arm/imx: imx6_gpcreg.h
src/sys/arch/arm/imx/fdt: files.imx6 if_enet_imx.c imx6_ahcisata.c
imx6_clk.c imx6_com.c imx6_gpc.c imx6_gpio.c imx6_iomux.c
imx6_pcie.c imx6_platform.c imx6_platform.h imx6_sdhc.c imx6_usb.c
imx6_usbphy.c
src/sys/arch/evbarm/conf: IMX files.imx mk.imx std.imx

Log Message:
Add support for device tree.

+ CCM (clk)
+ COM (uart)
+ GPIO
+ IOMUX (pin control)
+ PCIe
+ SDHC
+ USB Host
+ USB phy


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/imx6_gpcreg.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/fdt/files.imx6 \
src/sys/arch/arm/imx/fdt/if_enet_imx.c \
src/sys/arch/arm/imx/fdt/imx6_ahcisata.c \
src/sys/arch/arm/imx/fdt/imx6_clk.c src/sys/arch/arm/imx/fdt/imx6_com.c \
src/sys/arch/arm/imx/fdt/imx6_gpc.c src/sys/arch/arm/imx/fdt/imx6_gpio.c \
src/sys/arch/arm/imx/fdt/imx6_iomux.c \
src/sys/arch/arm/imx/fdt/imx6_pcie.c \
src/sys/arch/arm/imx/fdt/imx6_platform.c \
src/sys/arch/arm/imx/fdt/imx6_platform.h \
src/sys/arch/arm/imx/fdt/imx6_sdhc.c src/sys/arch/arm/imx/fdt/imx6_usb.c \
src/sys/arch/arm/imx/fdt/imx6_usbphy.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbarm/conf/IMX \
src/sys/arch/evbarm/conf/files.imx src/sys/arch/evbarm/conf/mk.imx \
src/sys/arch/evbarm/conf/std.imx

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



CVS commit: src/sys/arch

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 13:12:34 UTC 2019

Added Files:
src/sys/arch/arm/imx: imx6_gpcreg.h
src/sys/arch/arm/imx/fdt: files.imx6 if_enet_imx.c imx6_ahcisata.c
imx6_clk.c imx6_com.c imx6_gpc.c imx6_gpio.c imx6_iomux.c
imx6_pcie.c imx6_platform.c imx6_platform.h imx6_sdhc.c imx6_usb.c
imx6_usbphy.c
src/sys/arch/evbarm/conf: IMX files.imx mk.imx std.imx

Log Message:
Add support for device tree.

+ CCM (clk)
+ COM (uart)
+ GPIO
+ IOMUX (pin control)
+ PCIe
+ SDHC
+ USB Host
+ USB phy


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/imx6_gpcreg.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/fdt/files.imx6 \
src/sys/arch/arm/imx/fdt/if_enet_imx.c \
src/sys/arch/arm/imx/fdt/imx6_ahcisata.c \
src/sys/arch/arm/imx/fdt/imx6_clk.c src/sys/arch/arm/imx/fdt/imx6_com.c \
src/sys/arch/arm/imx/fdt/imx6_gpc.c src/sys/arch/arm/imx/fdt/imx6_gpio.c \
src/sys/arch/arm/imx/fdt/imx6_iomux.c \
src/sys/arch/arm/imx/fdt/imx6_pcie.c \
src/sys/arch/arm/imx/fdt/imx6_platform.c \
src/sys/arch/arm/imx/fdt/imx6_platform.h \
src/sys/arch/arm/imx/fdt/imx6_sdhc.c src/sys/arch/arm/imx/fdt/imx6_usb.c \
src/sys/arch/arm/imx/fdt/imx6_usbphy.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbarm/conf/IMX \
src/sys/arch/evbarm/conf/files.imx src/sys/arch/evbarm/conf/mk.imx \
src/sys/arch/evbarm/conf/std.imx

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

Added files:

Index: src/sys/arch/arm/imx/imx6_gpcreg.h
diff -u /dev/null src/sys/arch/arm/imx/imx6_gpcreg.h:1.1
--- /dev/null	Wed Jul 24 13:12:34 2019
+++ src/sys/arch/arm/imx/imx6_gpcreg.h	Wed Jul 24 13:12:33 2019
@@ -0,0 +1,41 @@
+/*	$NetBSD: imx6_gpcreg.h,v 1.1 2019/07/24 13:12:33 hkenken Exp $	*/
+/*-
+ * Copyright (c) 2019 Genetec Corporation.  All rights reserved.
+ * Written by Hashimoto Kenichi for Genetec Corporation.
+ *
+ * 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.
+ */
+#ifndef _ARM_IMX_IMX6_GPCREG_H_
+#define _ARM_IMX_IMX6_GPCREG_H_
+
+#define GPC_CNTR	0x
+#define GPC_PGR		0x0004
+#define GPC_IMR1	0x0008
+#define GPC_IMR2	0x000C
+#define GPC_IMR3	0x0010
+#define GPC_IMR4	0x0014
+#define GPC_ISR1	0x0018
+#define GPC_ISR2	0x001C
+#define GPC_ISR3	0x0020
+#define GPC_ISR4	0x0024
+
+#endif /* _ARM_IMX_IMX6_GPCREG_H_ */

Index: src/sys/arch/arm/imx/fdt/files.imx6
diff -u /dev/null src/sys/arch/arm/imx/fdt/files.imx6:1.1
--- /dev/null	Wed Jul 24 13:12:34 2019
+++ src/sys/arch/arm/imx/fdt/files.imx6	Wed Jul 24 13:12:33 2019
@@ -0,0 +1,80 @@
+#	$NetBSD: files.imx6,v 1.1 2019/07/24 13:12:33 hkenken Exp $
+#
+# Configuration info for the Freescale i.MX6
+#
+
+file	arch/arm/arm32/arm32_boot.c
+file	arch/arm/arm32/arm32_kvminit.c
+file	arch/arm/arm32/arm32_reboot.c
+file	arch/arm/arm32/irq_dispatch.S
+file	arch/arm/arm32/armv7_generic_space.c
+file	arch/arm/arm/arm_generic_dma.c
+file	arch/arm/arm/bus_space_a4x.S
+
+file	arch/arm/imx/fdt/imx6_platform.c	soc_imx
+
+# SOC parameters
+defflag	opt_soc.h			SOC_IMX
+defflag	opt_soc.h			SOC_IMX6QDL: SOC_IMX
+
+# Clock
+device	imxccm : clk
+attach	imxccm at fdt
+file	arch/arm/imx/imx6_ccm.c		imxccm
+file	arch/arm/imx/fdt/imx6_clk.c	imxccm
+
+# GPC
+device	imxgpc
+attach	imxgpc at fdt
+file	arch/arm/imx/fdt/imx6_gpc.c	imxgpc
+
+# IOMUX
+device	imxiomux
+attach	imxiomux at fdt
+file	arch/arm/imx/fdt/imx6_iomux.c	imxiomux
+
+# GPIO controller
+device	imxgpio: gpiobus
+attach	imxgpio at fdt
+file	arch/arm/imx/imxgpio.c		imxgpio
+file	arch/arm/imx/fdt/imx6_gpio.c	imxgpio
+
+# UART
+device	imxuart { } : bus_space_generic
+attach	imxuart at fdt with imx6_com
+file	

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

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 12:35:26 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imxclock.c

Log Message:
No functional change.


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

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



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

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 12:35:26 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imxclock.c

Log Message:
No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/imxclock.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/imx/imxclock.c
diff -u src/sys/arch/arm/imx/imxclock.c:1.7 src/sys/arch/arm/imx/imxclock.c:1.8
--- src/sys/arch/arm/imx/imxclock.c:1.7	Fri Jul 25 07:49:56 2014
+++ src/sys/arch/arm/imx/imxclock.c	Wed Jul 24 12:35:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imxclock.c,v 1.7 2014/07/25 07:49:56 hkenken Exp $ */
+/*	$NetBSD: imxclock.c,v 1.8 2019/07/24 12:35:26 hkenken Exp $ */
 /*
  * Copyright (c) 2009, 2010  Genetec corp.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec corp.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imxclock.c,v 1.7 2014/07/25 07:49:56 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxclock.c,v 1.8 2019/07/24 12:35:26 hkenken Exp $");
 
 #include "opt_imx.h"
 
@@ -111,7 +111,7 @@ cpu_initclocks(void)
 	bus_space_write_4(imxclock->sc_iot, imxclock->sc_ioh,
 	EPIT_EPITCR, reg);
 
-	epit1_sc->sc_ih = intr_establish(imxclock->sc_intr, IPL_CLOCK,
+	imxclock->sc_ih = intr_establish(imxclock->sc_intr, IPL_CLOCK,
 	IST_LEVEL, imxclock_intr, NULL);
 }
 



CVS commit: src/sys/arch

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 12:33:19 UTC 2019

Modified Files:
src/sys/arch/arm/imx: files.imx51 files.imx6 files.imx7 imx51_gpio.c
imx51var.h imx6_gpio.c imx6_pcie.c imx6_usdhc.c imx7_gpio.c
imx7_usdhc.c imxgpio.c imxgpiovar.h
src/sys/arch/evbarm/conf: ARMADILLO-IOT-G3 CUBOX-I HUMMINGBOARD
IMX6UL-STARTER KOBO NETWALKER NITROGEN6X mk.nitrogen6 std.nitrogen6
src/sys/arch/evbarm/imx7: imx7_ioconfig.c
src/sys/arch/evbarm/kobo: kobo_machdep.c
src/sys/arch/evbarm/netwalker: netwalker_lcd.c netwalker_machdep.c
netwalker_spi.c netwalker_usb.c
src/sys/arch/evbarm/nitrogen6: nitrogen6_iomux.c
Added Files:
src/sys/arch/arm/imx: imxpcie.c imxpciereg.h imxpcievar.h

Log Message:
Modified i.MX GPIO control module and PCIe module.

+ Add imxpcie.c
  imx PCIe common driver


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/imx/files.imx51
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/imx/files.imx6
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/files.imx7 \
src/sys/arch/arm/imx/imx51var.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/imx51_gpio.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imx6_gpio.c \
src/sys/arch/arm/imx/imx7_usdhc.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/imx/imx6_pcie.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/imx6_usdhc.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imx7_gpio.c \
src/sys/arch/arm/imx/imxgpiovar.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imxgpio.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/imxpcie.c \
src/sys/arch/arm/imx/imxpciereg.h src/sys/arch/arm/imx/imxpcievar.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/evbarm/conf/ARMADILLO-IOT-G3
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/evbarm/conf/CUBOX-I
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbarm/conf/HUMMINGBOARD
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/evbarm/conf/IMX6UL-STARTER
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/evbarm/conf/KOBO
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/evbarm/conf/NETWALKER
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/evbarm/conf/NITROGEN6X
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/conf/mk.nitrogen6
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/evbarm/conf/std.nitrogen6
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/imx7/imx7_ioconfig.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbarm/kobo/kobo_machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbarm/netwalker/netwalker_lcd.c \
src/sys/arch/evbarm/netwalker/netwalker_usb.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/evbarm/netwalker/netwalker_machdep.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/netwalker/netwalker_spi.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/nitrogen6/nitrogen6_iomux.c

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



CVS commit: src/sys/arch

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 12:33:19 UTC 2019

Modified Files:
src/sys/arch/arm/imx: files.imx51 files.imx6 files.imx7 imx51_gpio.c
imx51var.h imx6_gpio.c imx6_pcie.c imx6_usdhc.c imx7_gpio.c
imx7_usdhc.c imxgpio.c imxgpiovar.h
src/sys/arch/evbarm/conf: ARMADILLO-IOT-G3 CUBOX-I HUMMINGBOARD
IMX6UL-STARTER KOBO NETWALKER NITROGEN6X mk.nitrogen6 std.nitrogen6
src/sys/arch/evbarm/imx7: imx7_ioconfig.c
src/sys/arch/evbarm/kobo: kobo_machdep.c
src/sys/arch/evbarm/netwalker: netwalker_lcd.c netwalker_machdep.c
netwalker_spi.c netwalker_usb.c
src/sys/arch/evbarm/nitrogen6: nitrogen6_iomux.c
Added Files:
src/sys/arch/arm/imx: imxpcie.c imxpciereg.h imxpcievar.h

Log Message:
Modified i.MX GPIO control module and PCIe module.

+ Add imxpcie.c
  imx PCIe common driver


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/imx/files.imx51
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/imx/files.imx6
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/files.imx7 \
src/sys/arch/arm/imx/imx51var.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/imx51_gpio.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/imx6_gpio.c \
src/sys/arch/arm/imx/imx7_usdhc.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/imx/imx6_pcie.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/imx6_usdhc.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imx7_gpio.c \
src/sys/arch/arm/imx/imxgpiovar.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imxgpio.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/imxpcie.c \
src/sys/arch/arm/imx/imxpciereg.h src/sys/arch/arm/imx/imxpcievar.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/evbarm/conf/ARMADILLO-IOT-G3
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/evbarm/conf/CUBOX-I
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbarm/conf/HUMMINGBOARD
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/evbarm/conf/IMX6UL-STARTER
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/evbarm/conf/KOBO
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/evbarm/conf/NETWALKER
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/evbarm/conf/NITROGEN6X
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/conf/mk.nitrogen6
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/evbarm/conf/std.nitrogen6
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/imx7/imx7_ioconfig.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/evbarm/kobo/kobo_machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbarm/netwalker/netwalker_lcd.c \
src/sys/arch/evbarm/netwalker/netwalker_usb.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/evbarm/netwalker/netwalker_machdep.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/netwalker/netwalker_spi.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/nitrogen6/nitrogen6_iomux.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/imx/files.imx51
diff -u src/sys/arch/arm/imx/files.imx51:1.18 src/sys/arch/arm/imx/files.imx51:1.19
--- src/sys/arch/arm/imx/files.imx51:1.18	Sat Mar 17 18:34:09 2018
+++ src/sys/arch/arm/imx/files.imx51	Wed Jul 24 12:33:18 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.imx51,v 1.18 2018/03/17 18:34:09 ryo Exp $
+#	$NetBSD: files.imx51,v 1.19 2019/07/24 12:33:18 hkenken Exp $
 #
 # Configuration info for the Freescale i.MX5x
 #
@@ -62,9 +62,8 @@ file   arch/arm/imx/imxwdog.c		imxwdog
 # iMX GPIO
 device	imxgpio: gpiobus
 attach	imxgpio at axi
-file	arch/arm/imx/imxgpio.c		imxgpio		needs-flag
+file	arch/arm/imx/imxgpio.c		imxgpio
 file	arch/arm/imx/imx51_gpio.c	imxgpio
-defflag opt_imxgpio.h			IMX_GPIO_INTR_SPLIT
 
 # iMX IOMUX
 device	imxiomux : bus_space_generic

Index: src/sys/arch/arm/imx/files.imx6
diff -u src/sys/arch/arm/imx/files.imx6:1.16 src/sys/arch/arm/imx/files.imx6:1.17
--- src/sys/arch/arm/imx/files.imx6:1.16	Wed Jul 24 11:58:00 2019
+++ src/sys/arch/arm/imx/files.imx6	Wed Jul 24 12:33:18 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.imx6,v 1.16 2019/07/24 11:58:00 hkenken Exp $
+#	$NetBSD: files.imx6,v 1.17 2019/07/24 12:33:18 hkenken Exp $
 #
 # Configuration info for the Freescale i.MX6
 #
@@ -28,8 +28,9 @@ file	arch/arm/imx/imx6_axi.c			axi
 
 # iMX6 PCIe
 device	imxpcie: pcibus
-attach	imxpcie at axi
-file	arch/arm/imx/imx6_pcie.c		imxpcie
+attach	imxpcie at axi with imx6_pcie
+file	arch/arm/imx/imxpcie.c			imxpcie
+file	arch/arm/imx/imx6_pcie.c		imx6_pcie
 
 # iMX6 Clock Control Module
 device	imxccm : clk
@@ -62,9 +63,8 @@ file	arch/arm/imx/imxwdog.c			imxwdog
 # iMX GPIO
 device	imxgpio: gpiobus
 attach	imxgpio at axi
-file	arch/arm/imx/imxgpio.c			imxgpio	needs-flag
+file	arch/arm/imx/imxgpio.c			imxgpio
 file	arch/arm/imx/imx6_gpio.c		imxgpio
-defflag opt_imxgpio.hIMX_GPIO_INTR_SPLIT
 
 # iMX6 IOMUX
 device	imxiomux

Index: src/sys/arch/arm/imx/files.imx7
diff -u src/sys/arch/arm/imx/files.imx7:1.6 src/sys/arch/arm/imx/files.imx7:1.7
--- src/sys/arch/arm/imx/files.imx7:1.6	Sat Mar 17 18:34:09 2018
+++ 

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

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 11:58:00 UTC 2019

Modified Files:
src/sys/arch/arm/imx: files.imx6 imx6_board.c imx6_ccm.c imx6_ccmreg.h
imx6_ccmvar.h imx6_reg.h
Added Files:
src/sys/arch/arm/imx: imx6_clk.c

Log Message:
Modified imx6 Clock Controller Module (CCM).

+ Add imx6_get_clock_by_id().


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/imx/files.imx6
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/imx/imx6_board.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/imx/imx6_ccm.c \
src/sys/arch/arm/imx/imx6_ccmreg.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/imx6_ccmvar.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/imx6_clk.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/imx/imx6_reg.h

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



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

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 11:58:00 UTC 2019

Modified Files:
src/sys/arch/arm/imx: files.imx6 imx6_board.c imx6_ccm.c imx6_ccmreg.h
imx6_ccmvar.h imx6_reg.h
Added Files:
src/sys/arch/arm/imx: imx6_clk.c

Log Message:
Modified imx6 Clock Controller Module (CCM).

+ Add imx6_get_clock_by_id().


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/imx/files.imx6
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/imx/imx6_board.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/imx/imx6_ccm.c \
src/sys/arch/arm/imx/imx6_ccmreg.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/imx6_ccmvar.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/imx/imx6_clk.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/imx/imx6_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/imx/files.imx6
diff -u src/sys/arch/arm/imx/files.imx6:1.15 src/sys/arch/arm/imx/files.imx6:1.16
--- src/sys/arch/arm/imx/files.imx6:1.15	Thu Jun 20 08:16:19 2019
+++ src/sys/arch/arm/imx/files.imx6	Wed Jul 24 11:58:00 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.imx6,v 1.15 2019/06/20 08:16:19 hkenken Exp $
+#	$NetBSD: files.imx6,v 1.16 2019/07/24 11:58:00 hkenken Exp $
 #
 # Configuration info for the Freescale i.MX6
 #
@@ -34,8 +34,8 @@ file	arch/arm/imx/imx6_pcie.c		imxpcie
 # iMX6 Clock Control Module
 device	imxccm : clk
 attach	imxccm at axi
-file	arch/arm/imx/imx6_ccm.c			imxccm	needs-flag
-defflag opt_imx6clk.hIMXCCMDEBUG
+file	arch/arm/imx/imx6_ccm.c			imxccm needs-flag
+file	arch/arm/imx/imx6_clk.c			imxccm
 defparam opt_imx6clk.hIMX6_OSC_FREQ
 defparam opt_imx6clk.hIMX6_CKIL_FREQ
 defparam opt_imx6clk.hIMX6_CKIH_FREQ

Index: src/sys/arch/arm/imx/imx6_board.c
diff -u src/sys/arch/arm/imx/imx6_board.c:1.12 src/sys/arch/arm/imx/imx6_board.c:1.13
--- src/sys/arch/arm/imx/imx6_board.c:1.12	Thu Oct 18 09:01:52 2018
+++ src/sys/arch/arm/imx/imx6_board.c	Wed Jul 24 11:58:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_board.c,v 1.12 2018/10/18 09:01:52 skrll Exp $	*/
+/*	$NetBSD: imx6_board.c,v 1.13 2019/07/24 11:58:00 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2012  Genetec Corporation.  All rights reserved.
@@ -27,12 +27,14 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: imx6_board.c,v 1.12 2018/10/18 09:01:52 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: imx6_board.c,v 1.13 2019/07/24 11:58:00 hkenken Exp $");
 
 #include "arml2cc.h"
 #include "opt_cputypes.h"
 #include "opt_imx.h"
 
+#define	_INTR_PRIVATE
+
 #include 
 #include 
 #include 
@@ -189,7 +191,7 @@ imx6_armrootclk(void)
 	uint32_t v;
 
 	v = bus_space_read_4(imx6_ioreg_bst, imx6_ioreg_bsh,
-	AIPS1_CCM_ANALOG_BASE + CCM_ANALOG_PLL_ARM);
+	AIPS1_CCM_BASE + CCM_ANALOG_BASE + CCM_ANALOG_PLL_ARM);
 	clk = IMX6_OSC_FREQ * (v & CCM_ANALOG_PLL_ARM_DIV_SELECT) / 2;
 	v = bus_space_read_4(imx6_ioreg_bst, imx6_ioreg_bsh,
 	AIPS1_CCM_BASE + CCM_CACRR);

Index: src/sys/arch/arm/imx/imx6_ccm.c
diff -u src/sys/arch/arm/imx/imx6_ccm.c:1.10 src/sys/arch/arm/imx/imx6_ccm.c:1.11
--- src/sys/arch/arm/imx/imx6_ccm.c:1.10	Thu Jun 20 08:16:19 2019
+++ src/sys/arch/arm/imx/imx6_ccm.c	Wed Jul 24 11:58:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_ccm.c,v 1.10 2019/06/20 08:16:19 hkenken Exp $	*/
+/*	$NetBSD: imx6_ccm.c,v 1.11 2019/07/24 11:58:00 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2010-2012, 2014  Genetec Corporation.  All rights reserved.
@@ -30,10 +30,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.10 2019/06/20 08:16:19 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.11 2019/07/24 11:58:00 hkenken Exp $");
 
 #include "opt_imx.h"
-#include "opt_imx6clk.h"
 #include "opt_cputypes.h"
 
 #include "locators.h"
@@ -48,9 +47,6 @@ __KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v
 #include 
 
 #include 
-#ifdef CPU_CORTEXA9
-#include 
-#endif
 
 #include 
 #include 
@@ -60,15 +56,6 @@ __KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v
 
 #include 
 
-struct imxccm_softc {
-	device_t sc_dev;
-	bus_space_tag_t sc_iot;
-	bus_space_handle_t sc_ioh;
-	bus_space_handle_t sc_ioh_analog;
-
-	struct clk_domain sc_clkdom;
-};
-
 /* Clock Parents Tables */
 static const char *step_p[] = {
 	"osc",
@@ -369,6 +356,275 @@ static const char *lvds_p[] = {
 	"sata_ref_100m"
 };
 
+/* DT clock ID to clock name mappings */
+static struct imx_clock_id {
+	u_int		id;
+	const char	*name;
+} imx6_clock_ids[] = {
+	{ IMX6CLK_DUMMY,		"dummy" },
+	{ IMX6CLK_CKIL,			"ckil" },
+	{ IMX6CLK_CKIH,			"ckih" },
+	{ IMX6CLK_OSC,			"osc" },
+	{ IMX6CLK_PLL2_PFD0_352M,	"pll2_pfd0_352m" },
+	{ IMX6CLK_PLL2_PFD1_594M,	"pll2_pfd1_594m" },
+	{ IMX6CLK_PLL2_PFD2_396M,	"pll2_pfd2_396m" },
+	{ IMX6CLK_PLL3_PFD0_720M,	"pll3_pfd0_720m" },
+	{ IMX6CLK_PLL3_PFD1_540M,	"pll3_pfd1_540m" },
+	{ IMX6CLK_PLL3_PFD2_508M,	"pll3_pfd2_508m" },
+	{ IMX6CLK_PLL3_PFD3_454M,	"pll3_pfd3_454m" },
+	{ IMX6CLK_PLL2_198M,		"pll2_198m" },
+	{ IMX6CLK_PLL3_120M,		

CVS commit: src/sys/arch

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 11:20:55 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx23_usb.c imx51_usb.c imx6_reg.h imx6_usb.c
imx6_usbreg.h imx7_usb.c imx7_usbreg.h imxusb.c imxusbvar.h
src/sys/arch/evbarm/kobo: kobo_usb.c
src/sys/arch/evbarm/netwalker: netwalker_usb.c
src/sys/arch/evbarm/nitrogen6: nitrogen6_usb.c

Log Message:
i.MX USB host code re-arrangement.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imx23_usb.c \
src/sys/arch/arm/imx/imx6_usbreg.h src/sys/arch/arm/imx/imx7_usbreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/imx51_usb.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/imx/imx6_reg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imx6_usb.c \
src/sys/arch/arm/imx/imxusbvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/imx7_usb.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/imx/imxusb.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/kobo/kobo_usb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/netwalker/netwalker_usb.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbarm/nitrogen6/nitrogen6_usb.c

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



CVS commit: src/sys/arch

2019-07-24 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Wed Jul 24 11:20:55 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx23_usb.c imx51_usb.c imx6_reg.h imx6_usb.c
imx6_usbreg.h imx7_usb.c imx7_usbreg.h imxusb.c imxusbvar.h
src/sys/arch/evbarm/kobo: kobo_usb.c
src/sys/arch/evbarm/netwalker: netwalker_usb.c
src/sys/arch/evbarm/nitrogen6: nitrogen6_usb.c

Log Message:
i.MX USB host code re-arrangement.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imx23_usb.c \
src/sys/arch/arm/imx/imx6_usbreg.h src/sys/arch/arm/imx/imx7_usbreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/imx51_usb.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/imx/imx6_reg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imx6_usb.c \
src/sys/arch/arm/imx/imxusbvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/imx7_usb.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/imx/imxusb.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/kobo/kobo_usb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/netwalker/netwalker_usb.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbarm/nitrogen6/nitrogen6_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/imx/imx23_usb.c
diff -u src/sys/arch/arm/imx/imx23_usb.c:1.1 src/sys/arch/arm/imx/imx23_usb.c:1.2
--- src/sys/arch/arm/imx/imx23_usb.c:1.1	Mon Oct  7 17:36:40 2013
+++ src/sys/arch/arm/imx/imx23_usb.c	Wed Jul 24 11:20:55 2019
@@ -1,4 +1,4 @@
-/* $Id: imx23_usb.c,v 1.1 2013/10/07 17:36:40 matt Exp $ */
+/* $Id: imx23_usb.c,v 1.2 2019/07/24 11:20:55 hkenken Exp $ */
 
 /*
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -54,7 +55,7 @@
 #include "locators.h"
 
 struct imx23_usb_softc {
-	struct imxusbc_softc  sc_imxusbc;
+	struct imxusbc_softc  sc_imxusbc; /* Must be first */
 };
 
 static int	imx23_usb_match(device_t, cfdata_t, void *);
@@ -94,9 +95,14 @@ imx23_usb_attach(device_t parent, device
 {
 	struct imxusbc_softc *sc = device_private(self);
 
+	sc->sc_dev = self;
+	sc->sc_iot = _bus_space;
+	sc->sc_ehci_size = IMXUSB_EHCI_SIZE;
+	sc->sc_ehci_offset = IMXUSB_EHCI_SIZE;
+
 	sc->sc_init_md_hook = imx23_usb_init;
+	sc->sc_intr_establish_md_hook = NULL;
 	sc->sc_setup_md_hook = NULL;
-	sc->sc_iot = _bus_space;
 
 	if (bus_space_map(sc->sc_iot, AHB_USB, AHB_USB_SIZE, 0, >sc_ioh)) {
 		aprint_error_dev(sc->sc_dev, "Unable to map bus space");
Index: src/sys/arch/arm/imx/imx6_usbreg.h
diff -u src/sys/arch/arm/imx/imx6_usbreg.h:1.1 src/sys/arch/arm/imx/imx6_usbreg.h:1.2
--- src/sys/arch/arm/imx/imx6_usbreg.h:1.1	Thu Sep 25 05:05:28 2014
+++ src/sys/arch/arm/imx/imx6_usbreg.h	Wed Jul 24 11:20:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_usbreg.h,v 1.1 2014/09/25 05:05:28 ryo Exp $	*/
+/*	$NetBSD: imx6_usbreg.h,v 1.2 2019/07/24 11:20:55 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -63,8 +63,9 @@
 #define USBC_UH3_PORTSC1			0x0784
 #define USBC_UH3_USBMODE			0x07a8
 
-
-#define USBNC_USB_OTG_CTRL			0x0800
+#define USBNC_BASE0x0800
+#define USBNC_SIZE0x0020
+#define USBNC_USB_OTG_CTRL			0x
 #define  USBNC_USB_OTG_CTRL_WIR			__BIT(31)
 #define  USBNC_USB_OTG_CTRL_WKUP_VBUS_EN	__BIT(17)
 #define  USBNC_USB_OTG_CTRL_WKUP_ID_EN		__BIT(16)
@@ -75,7 +76,7 @@
 #define  USBNC_USB_OTG_CTRL_PWR_POL		__BIT(9)
 #define  USBNC_USB_OTG_CTRL_OVER_CUR_POL	__BIT(8)
 #define  USBNC_USB_OTG_CTRL_OVER_CUR_DIS	__BIT(7)
-#define USBNC_USB_UH1_CTRL			0x0804
+#define USBNC_USB_UH1_CTRL			0x0004
 #define  USBNC_USB_UH1_CTRL_WIR			__BIT(31)
 #define  USBNC_USB_UH1_CTRL_WKUP_VBUS_EN	__BIT(17)
 #define  USBNC_USB_UH1_CTRL_WKUP_ID_EN		__BIT(16)
@@ -86,27 +87,27 @@
 #define  USBNC_USB_UH1_CTRL_PWR_POL		__BIT(9)
 #define  USBNC_USB_UH1_CTRL_OVER_CUR_POL	__BIT(8)
 #define  USBNC_USB_UH1_CTRL_OVER_CUR_DIS	__BIT(7)
-#define USBNC_USB_UH2_CTRL			0x0808
+#define USBNC_USB_UH2_CTRL			0x0008
 #define  USBNC_USB_UH2_CTRL_WKUP_SW		__BIT(15)
 #define  USBNC_USB_UH2_CTRL_WKUP_SW_EN		__BIT(14)
 #define  USBNC_USB_UH2_CTRL_UTMI_ON_CLOCK	__BIT(13)
 #define  USBNC_USB_UH2_CTRL_WIE			__BIT(10)
-#define USBNC_USB_UH3_CTRL			0x080c
+#define USBNC_USB_UH3_CTRL			0x000c
 #define  USBNC_USB_UH3_CTRL_WKUP_SW		__BIT(15)
 #define  USBNC_USB_UH3_CTRL_WKUP_SW_EN		__BIT(14)
 #define  USBNC_USB_UH3_CTRL_UTMI_ON_CLOCK	__BIT(13)
 #define  USBNC_USB_UH3_CTRL_WIE			__BIT(10)
-#define USBNC_USB_UH2_HSIC_CTRL			0x0810
+#define USBNC_USB_UH2_HSIC_CTRL			0x0010
 #define  USBNC_USB_UH2_HSIC_CTRL_CLK_VLK	__BIT(31)
 #define  USBNC_USB_UH2_HSIC_CTRL_HSIC_EN	__BIT(12)
 #define  USBNC_USB_UH2_HSIC_CTRL_HSIC_CLK_ON	__BIT(11)
-#define USBNC_USB_UH3_HSIC_CTRL			0x0814
+#define USBNC_USB_UH3_HSIC_CTRL			0x0014
 #define  USBNC_USB_UH3_HSIC_CTRL_CLK_VLK	__BIT(31)
 #define  USBNC_USB_UH3_HSIC_CTRL_HSIC_EN	__BIT(12)
 #define  

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

2019-07-23 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Jul 23 06:36:36 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet.c if_enet_imx6.c if_enet_imx7.c
if_enetvar.h

Log Message:
Modified enet_attach_common().


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/imx/if_enet.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/if_enet_imx6.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/if_enet_imx7.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/if_enetvar.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/imx/if_enet.c
diff -u src/sys/arch/arm/imx/if_enet.c:1.23 src/sys/arch/arm/imx/if_enet.c:1.24
--- src/sys/arch/arm/imx/if_enet.c:1.23	Tue May 28 07:41:46 2019
+++ src/sys/arch/arm/imx/if_enet.c	Tue Jul 23 06:36:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet.c,v 1.23 2019/05/28 07:41:46 msaitoh Exp $	*/
+/*	$NetBSD: if_enet.c,v 1.24 2019/07/23 06:36:36 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.23 2019/05/28 07:41:46 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.24 2019/07/23 06:36:36 hkenken Exp $");
 
 #include "vlan.h"
 
@@ -132,7 +132,6 @@ static void enet_attach_evcnt(struct ene
 static void enet_update_evcnt(struct enet_softc *);
 #endif
 
-static int enet_intr(void *);
 static void enet_tick(void *);
 static int enet_tx_intr(void *);
 static int enet_rx_intr(void *);
@@ -170,30 +169,16 @@ static int enet_alloc_dma(struct enet_so
 CFATTACH_DECL_NEW(enet, sizeof(struct enet_softc),
 enet_match, enet_attach, NULL, NULL);
 
-void
-enet_attach_common(device_t self, bus_space_tag_t iot,
-bus_dma_tag_t dmat, bus_addr_t addr, bus_size_t size, int irq)
+int
+enet_attach_common(device_t self)
 {
 	struct enet_softc *sc = device_private(self);
 	struct ifnet *ifp;
 	struct mii_data * const mii = >sc_mii;
 
-	sc->sc_dev = self;
-	sc->sc_iot = iot;
-	sc->sc_addr = addr;
-	sc->sc_dmat = dmat;
-
-	aprint_naive("\n");
-	aprint_normal(": Gigabit Ethernet Controller\n");
-	if (bus_space_map(sc->sc_iot, sc->sc_addr, size, 0,
-	>sc_ioh)) {
-		aprint_error_dev(self, "cannot map registers\n");
-		return;
-	}
-
 	/* allocate dma buffer */
 	if (enet_alloc_ring(sc))
-		return;
+		return -1;
 
 #define IS_ENADDR_ZERO(enaddr)\
 	((enaddr[0] | enaddr[1] | enaddr[2] |		\
@@ -225,32 +210,6 @@ enet_attach_common(device_t self, bus_sp
 
 	enet_init_regs(sc, 1);
 
-	/* setup interrupt handlers */
-	if ((sc->sc_ih = intr_establish(irq, IPL_NET,
-	IST_LEVEL, enet_intr, sc)) == NULL) {
-		aprint_error_dev(self, "unable to establish interrupt\n");
-		goto failure;
-	}
-
-	if (sc->sc_imxtype == 7) {
-		/* i.MX7 use 3 interrupts */
-		if ((sc->sc_ih2 = intr_establish(irq + 1, IPL_NET,
-		IST_LEVEL, enet_intr, sc)) == NULL) {
-			aprint_error_dev(self,
-			"unable to establish 2nd interrupt\n");
-			intr_disestablish(sc->sc_ih);
-			goto failure;
-		}
-		if ((sc->sc_ih3 = intr_establish(irq + 2, IPL_NET,
-		IST_LEVEL, enet_intr, sc)) == NULL) {
-			aprint_error_dev(self,
-			"unable to establish 3rd interrupt\n");
-			intr_disestablish(sc->sc_ih2);
-			intr_disestablish(sc->sc_ih);
-			goto failure;
-		}
-	}
-
 	/* callout will be scheduled from enet_init() */
 	callout_init(>sc_tick_ch, 0);
 	callout_setfunc(>sc_tick_ch, enet_tick, sc);
@@ -312,11 +271,7 @@ enet_attach_common(device_t self, bus_sp
 
 	sc->sc_stopping = false;
 
-	return;
-
- failure:
-	bus_space_unmap(sc->sc_iot, sc->sc_ioh, size);
-	return;
+	return 0;
 }
 
 #ifdef ENET_EVENT_COUNTER
@@ -446,7 +401,7 @@ enet_tick(void *arg)
 	splx(s);
 }
 
-static int
+int
 enet_intr(void *arg)
 {
 	struct enet_softc *sc;

Index: src/sys/arch/arm/imx/if_enet_imx6.c
diff -u src/sys/arch/arm/imx/if_enet_imx6.c:1.4 src/sys/arch/arm/imx/if_enet_imx6.c:1.5
--- src/sys/arch/arm/imx/if_enet_imx6.c:1.4	Thu Jun 20 08:16:19 2019
+++ src/sys/arch/arm/imx/if_enet_imx6.c	Tue Jul 23 06:36:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx6.c,v 1.4 2019/06/20 08:16:19 hkenken Exp $	*/
+/*	$NetBSD: if_enet_imx6.c,v 1.5 2019/07/23 06:36:36 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.4 2019/06/20 08:16:19 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.5 2019/07/23 06:36:36 hkenken Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -71,18 +71,19 @@ enet_match(device_t parent __unused, str
 void
 enet_attach(device_t parent, device_t self, void *aux)
 {
-	struct enet_softc *sc;
-	struct axi_attach_args *aa;
+	struct enet_softc *sc = device_private(self);
+	struct axi_attach_args *aa = aux;
 #if NIMXOCOTP > 0
 	uint32_t eaddr;
 #endif
 
-	aa = aux;
-	sc = device_private(self);
-
 	if (aa->aa_size == AXICF_SIZE_DEFAULT)
 		aa->aa_size = AIPS_ENET_SIZE;
 
+	sc->sc_dev = self;
+	

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

2019-07-23 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Tue Jul 23 06:36:36 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet.c if_enet_imx6.c if_enet_imx7.c
if_enetvar.h

Log Message:
Modified enet_attach_common().


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/imx/if_enet.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/if_enet_imx6.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/if_enet_imx7.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/if_enetvar.h

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



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

2019-07-22 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Jul 22 11:44:01 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_ahcisata.c imx6_iomuxreg.h

Log Message:
Change register assignments.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/imx/imx6_ahcisata.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/imx6_iomuxreg.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/imx/imx6_ahcisata.c
diff -u src/sys/arch/arm/imx/imx6_ahcisata.c:1.9 src/sys/arch/arm/imx/imx6_ahcisata.c:1.10
--- src/sys/arch/arm/imx/imx6_ahcisata.c:1.9	Thu Jun 20 08:16:19 2019
+++ src/sys/arch/arm/imx/imx6_ahcisata.c	Mon Jul 22 11:44:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_ahcisata.c,v 1.9 2019/06/20 08:16:19 hkenken Exp $	*/
+/*	$NetBSD: imx6_ahcisata.c,v 1.10 2019/07/22 11:44:01 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx6_ahcisata.c,v 1.9 2019/06/20 08:16:19 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ahcisata.c,v 1.10 2019/07/22 11:44:01 hkenken Exp $");
 
 #include "locators.h"
 #include "opt_imx.h"
@@ -289,26 +289,26 @@ imx6_ahcisata_init(struct imx_ahci_softc
 
 	v = iomux_read(IOMUX_GPR13);
 	/* clear */
-	v &= ~(IOMUX_GPR13_SATA_PHY_8(7) |
-	IOMUX_GPR13_SATA_PHY_7(0x1f) |
-	IOMUX_GPR13_SATA_PHY_6(7) |
-	IOMUX_GPR13_SATA_SPEED(1) |
-	IOMUX_GPR13_SATA_PHY_5(1) |
-	IOMUX_GPR13_SATA_PHY_4(7) |
-	IOMUX_GPR13_SATA_PHY_3(0xf) |
-	IOMUX_GPR13_SATA_PHY_2(0x1f) |
-	IOMUX_GPR13_SATA_PHY_1(1) |
-	IOMUX_GPR13_SATA_PHY_0(1));
+	v &= ~(IOMUX_GPR13_SATA_PHY_8 |
+	IOMUX_GPR13_SATA_PHY_7 |
+	IOMUX_GPR13_SATA_PHY_6 |
+	IOMUX_GPR13_SATA_SPEED |
+	IOMUX_GPR13_SATA_PHY_5 |
+	IOMUX_GPR13_SATA_PHY_4 |
+	IOMUX_GPR13_SATA_PHY_3 |
+	IOMUX_GPR13_SATA_PHY_2 |
+	IOMUX_GPR13_SATA_PHY_1 |
+	IOMUX_GPR13_SATA_PHY_0);
 	/* setting */
-	v |= IOMUX_GPR13_SATA_PHY_8(5) |	/* Rx 3.0db */
-	IOMUX_GPR13_SATA_PHY_7(0x12) |	/* Rx SATA2m */
-	IOMUX_GPR13_SATA_PHY_6(3) |		/* Rx DPLL mode */
-	IOMUX_GPR13_SATA_SPEED(1) |		/* 3.0GHz */
-	IOMUX_GPR13_SATA_PHY_5(0) |		/* SpreadSpectram */
-	IOMUX_GPR13_SATA_PHY_4(4) |		/* Tx Attenuation 9/16 */
-	IOMUX_GPR13_SATA_PHY_3(0) |		/* Tx Boost 0db */
-	IOMUX_GPR13_SATA_PHY_2(0x11) |	/* Tx Level 1.104V */
-	IOMUX_GPR13_SATA_PHY_1(1);		/* PLL clock enable */
+	v |= __SHIFTIN(5, IOMUX_GPR13_SATA_PHY_8);	/* Rx 3.0db */
+	v |= __SHIFTIN(0x12, IOMUX_GPR13_SATA_PHY_7);	/* Rx SATA2m */
+	v |= __SHIFTIN(3, IOMUX_GPR13_SATA_PHY_6);	/* Rx DPLL mode */
+	v |= __SHIFTIN(1, IOMUX_GPR13_SATA_SPEED);	/* 3.0GHz */
+	v |= __SHIFTIN(0, IOMUX_GPR13_SATA_PHY_5);	/* SpreadSpectram */
+	v |= __SHIFTIN(4, IOMUX_GPR13_SATA_PHY_4);	/* Tx Attenuation 9/16 */
+	v |= __SHIFTIN(0, IOMUX_GPR13_SATA_PHY_3);	/* Tx Boost 0db */
+	v |= __SHIFTIN(0x11, IOMUX_GPR13_SATA_PHY_2);	/* Tx Level 1.104V */
+	v |= __SHIFTIN(1, IOMUX_GPR13_SATA_PHY_1);	/* PLL clock enable */
 	iomux_write(IOMUX_GPR13, v);
 
 	/* phy reset */

Index: src/sys/arch/arm/imx/imx6_iomuxreg.h
diff -u src/sys/arch/arm/imx/imx6_iomuxreg.h:1.4 src/sys/arch/arm/imx/imx6_iomuxreg.h:1.5
--- src/sys/arch/arm/imx/imx6_iomuxreg.h:1.4	Fri Jun  9 18:14:59 2017
+++ src/sys/arch/arm/imx/imx6_iomuxreg.h	Mon Jul 22 11:44:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx6_iomuxreg.h,v 1.4 2017/06/09 18:14:59 ryo Exp $	*/
+/*	$NetBSD: imx6_iomuxreg.h,v 1.5 2019/07/22 11:44:01 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -93,16 +93,16 @@
 #define  IOMUX_GPR13_CAN2_STOP_REQ		__BIT(29)
 #define  IOMUX_GPR13_CAN1_STOP_REQ		__BIT(28)
 #define  IOMUX_GPR13_ENET_STOP_REQ		__BIT(27)
-#define  IOMUX_GPR13_SATA_PHY_8(n)		__SHIFTIN(n, __BITS(26, 24))
-#define  IOMUX_GPR13_SATA_PHY_7(n)		__SHIFTIN(n, __BITS(23, 19))
-#define  IOMUX_GPR13_SATA_PHY_6(n)		__SHIFTIN(n, __BITS(18, 16))
-#define  IOMUX_GPR13_SATA_SPEED(n)		__SHIFTIN(n, __BIT(15))
-#define  IOMUX_GPR13_SATA_PHY_5(n)		__SHIFTIN(n, __BIT(14))
-#define  IOMUX_GPR13_SATA_PHY_4(n)		__SHIFTIN(n, __BITS(13, 11))
-#define  IOMUX_GPR13_SATA_PHY_3(n)		__SHIFTIN(n, __BITS(10, 7))
-#define  IOMUX_GPR13_SATA_PHY_2(n)		__SHIFTIN(n, __BITS(6, 2))
-#define  IOMUX_GPR13_SATA_PHY_1(n)		__SHIFTIN(n, __BIT(1))
-#define  IOMUX_GPR13_SATA_PHY_0(n)		__SHIFTIN(n, __BIT(0))
+#define  IOMUX_GPR13_SATA_PHY_8			__BITS(26, 24)
+#define  IOMUX_GPR13_SATA_PHY_7			__BITS(23, 19)
+#define  IOMUX_GPR13_SATA_PHY_6			__BITS(18, 16)
+#define  IOMUX_GPR13_SATA_SPEED			__BIT(15)
+#define  IOMUX_GPR13_SATA_PHY_5			__BIT(14)
+#define  IOMUX_GPR13_SATA_PHY_4			__BITS(13, 11)
+#define  IOMUX_GPR13_SATA_PHY_3			__BITS(10, 7)
+#define  IOMUX_GPR13_SATA_PHY_2			__BITS(6, 2)
+#define  IOMUX_GPR13_SATA_PHY_1			__BIT(1)
+#define  IOMUX_GPR13_SATA_PHY_0			__BIT(0)
 
 /* for iMX6Dual/Quad */
 #define IMX6DQ_IOMUXC_SW_MUX_CTL_PAD_SD2_DATA1			0x004c



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

2019-07-22 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Jul 22 11:44:01 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx6_ahcisata.c imx6_iomuxreg.h

Log Message:
Change register assignments.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/imx/imx6_ahcisata.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/imx6_iomuxreg.h

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



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

2019-07-21 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Jul 22 01:35:37 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx31_gpio.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/imx/imx31_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/imx/imx31_gpio.c
diff -u src/sys/arch/arm/imx/imx31_gpio.c:1.7 src/sys/arch/arm/imx/imx31_gpio.c:1.8
--- src/sys/arch/arm/imx/imx31_gpio.c:1.7	Sat Oct 27 17:17:39 2012
+++ src/sys/arch/arm/imx/imx31_gpio.c	Mon Jul 22 01:35:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx31_gpio.c,v 1.7 2012/10/27 17:17:39 chs Exp $	*/
+/*	$NetBSD: imx31_gpio.c,v 1.8 2019/07/22 01:35:36 hkenken Exp $	*/
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,21 +28,21 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imx31_gpio.c,v 1.7 2012/10/27 17:17:39 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx31_gpio.c,v 1.8 2019/07/22 01:35:36 hkenken Exp $");
 
 #define _INTR_PRIVATE
 
 #include "locators.h"
 #include "gpio.h"
- 
+
 #include 
 #include 
 #include 
- 
+
 #include 
-  
+
 #include 
- 
+
 #include 
 #include 
 #include 
@@ -182,7 +182,7 @@ gpio_pic_establish_irq(struct pic_softc 
 	GPIO_WRITE(gpio, GPIO_ISR, irq_mask);
 
 	/*
-	 * Convert the type to a gpio type and figure out which bits in what 
+	 * Convert the type to a gpio type and figure out which bits in what
 	 * register we have to tweak.
 	 */
 	gtype = (GPIO_TYPEMAP >> (2 * is->is_type)) & 3;
@@ -202,7 +202,7 @@ gpio_pic_establish_irq(struct pic_softc 
 	 */
 	v = GPIO_READ(gpio, GPIO_DIR);
 	v &= ~irq_mask;
-	GPIO_WRITE(gpio, GPIO_DIR, v); 
+	GPIO_WRITE(gpio, GPIO_DIR, v);
 
 	/*
 	 * Now record the type of interrupt.
@@ -243,7 +243,7 @@ imxgpio_pin_write(void *arg, int pin, in
 
 	old = GPIO_READ(gpio, GPIO_DR);
 	if (value)
-		new = old | mask; 
+		new = old | mask;
 	else
 		new = old & ~mask;
 



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

2019-07-21 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Mon Jul 22 01:35:37 UTC 2019

Modified Files:
src/sys/arch/arm/imx: imx31_gpio.c

Log Message:
Trailing whitespace


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

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



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

2019-07-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Jul 19 12:14:16 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c gicv3_fdt.c

Log Message:
Fixed compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/fdt/gic_fdt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/gicv3_fdt.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/fdt/gic_fdt.c
diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.16 src/sys/arch/arm/fdt/gic_fdt.c:1.17
--- src/sys/arch/arm/fdt/gic_fdt.c:1.16	Sat Jan 26 14:43:46 2019
+++ src/sys/arch/arm/fdt/gic_fdt.c	Fri Jul 19 12:14:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $ */
+/* $NetBSD: gic_fdt.c,v 1.17 2019/07/19 12:14:15 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.17 2019/07/19 12:14:15 hkenken Exp $");
 
 #include 
 #include 
@@ -59,7 +59,7 @@ struct gic_fdt_irq;
 
 static int	gic_fdt_match(device_t, cfdata_t, void *);
 static void	gic_fdt_attach(device_t, device_t, void *);
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static void	gic_fdt_attach_v2m(struct gic_fdt_softc *, bus_space_tag_t, int);
 #endif
 
@@ -179,7 +179,7 @@ gic_fdt_attach(device_t parent, device_t
 
 	arm_fdt_irq_set_handler(armgic_irq_handler);
 
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 	for (int child = OF_child(phandle); child; child = OF_peer(child)) {
 		if (!fdtbus_status_okay(child))
 			continue;
@@ -190,7 +190,7 @@ gic_fdt_attach(device_t parent, device_t
 #endif
 }
 
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static void
 gic_fdt_attach_v2m(struct gic_fdt_softc *sc, bus_space_tag_t bst, int phandle)
 {

Index: src/sys/arch/arm/fdt/gicv3_fdt.c
diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.7 src/sys/arch/arm/fdt/gicv3_fdt.c:1.8
--- src/sys/arch/arm/fdt/gicv3_fdt.c:1.7	Sat Jan 26 14:43:46 2019
+++ src/sys/arch/arm/fdt/gicv3_fdt.c	Fri Jul 19 12:14:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $ */
+/* $NetBSD: gicv3_fdt.c,v 1.8 2019/07/19 12:14:15 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill 
@@ -31,7 +31,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.8 2019/07/19 12:14:15 hkenken Exp $");
 
 #include 
 #include 
@@ -61,7 +61,7 @@ static int	gicv3_fdt_match(device_t, cfd
 static void	gicv3_fdt_attach(device_t, device_t, void *);
 
 static int	gicv3_fdt_map_registers(struct gicv3_fdt_softc *);
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static void	gicv3_fdt_attach_its(struct gicv3_fdt_softc *, bus_space_tag_t, int);
 #endif
 
@@ -158,7 +158,7 @@ gicv3_fdt_attach(device_t parent, device
 		return;
 	}
 
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 	for (int child = OF_child(phandle); child; child = OF_peer(child)) {
 		if (!fdtbus_status_okay(child))
 			continue;
@@ -238,7 +238,7 @@ gicv3_fdt_map_registers(struct gicv3_fdt
 	return 0;
 }
 
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static void
 gicv3_fdt_attach_its(struct gicv3_fdt_softc *sc, bus_space_tag_t bst, int phandle)
 {



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

2019-07-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Jul 19 12:14:16 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c gicv3_fdt.c

Log Message:
Fixed compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/fdt/gic_fdt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/gicv3_fdt.c

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



CVS commit: src/sys/dev/spi

2019-07-04 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Jul  4 11:13:26 UTC 2019

Modified Files:
src/sys/dev/spi: oj6sh.c

Log Message:
Avoid workqueue_check_duplication().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/spi/oj6sh.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/dev/spi/oj6sh.c
diff -u src/sys/dev/spi/oj6sh.c:1.2 src/sys/dev/spi/oj6sh.c:1.3
--- src/sys/dev/spi/oj6sh.c:1.2	Mon Dec 14 10:31:38 2015
+++ src/sys/dev/spi/oj6sh.c	Thu Jul  4 11:13:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: oj6sh.c,v 1.2 2015/12/14 10:31:38 hkenken Exp $	*/
+/*	$NetBSD: oj6sh.c,v 1.3 2019/07/04 11:13:26 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014  Genetec Corporation.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.2 2015/12/14 10:31:38 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.3 2019/07/04 11:13:26 hkenken Exp $");
 
 #include "opt_oj6sh.h"
 
@@ -205,13 +205,7 @@ static void
 oj6sh_poll(void *arg)
 {
 	struct oj6sh_softc *sc = (struct oj6sh_softc *)arg;
-
 	workqueue_enqueue(sc->sc_wq, >sc_wk, NULL);
-
-	if (sc->sc_enabled)
-		callout_reset(>sc_c, POLLRATE, oj6sh_poll, sc);
-
-	return;
 }
 
 static void
@@ -254,6 +248,9 @@ oj6sh_cb(struct work *wk, void *arg)
 	splx(s);
 out:
 	mutex_exit(>sc_lock);
+
+	if (sc->sc_enabled)
+		callout_reset(>sc_c, POLLRATE, oj6sh_poll, sc);
 }
 
 static uint8_t



CVS commit: src/sys/dev/spi

2019-07-04 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Jul  4 11:13:26 UTC 2019

Modified Files:
src/sys/dev/spi: oj6sh.c

Log Message:
Avoid workqueue_check_duplication().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/spi/oj6sh.c

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



CVS commit: src/sys/arch

2019-06-20 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Jun 20 08:16:20 UTC 2019

Modified Files:
src/sys/arch/arm/imx: files.imx6 if_enet_imx6.c if_enetvar.h
imx6_ahcisata.c imx6_ccm.c imx6_ccmreg.h imx6_ccmvar.h imx6_i2c.c
imx6_pcie.c imx6_usb.c imx6_usbphy.c imx6_usdhc.c imxi2cvar.h
imxusbvar.h
src/sys/arch/evbarm/nitrogen6: nitrogen6_usb.c

Log Message:
Add support for clk subsystem in imx6 CCM driver.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/imx/files.imx6
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/if_enet_imx6.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/if_enetvar.h \
src/sys/arch/arm/imx/imx6_i2c.c src/sys/arch/arm/imx/imxi2cvar.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/imx/imx6_ahcisata.c \
src/sys/arch/arm/imx/imx6_pcie.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/imx/imx6_ccm.c \
src/sys/arch/arm/imx/imx6_ccmreg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imx6_ccmvar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/imx6_usb.c \
src/sys/arch/arm/imx/imxusbvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imx6_usbphy.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/imx6_usdhc.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/nitrogen6/nitrogen6_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/imx/files.imx6
diff -u src/sys/arch/arm/imx/files.imx6:1.14 src/sys/arch/arm/imx/files.imx6:1.15
--- src/sys/arch/arm/imx/files.imx6:1.14	Wed Jun 20 07:05:37 2018
+++ src/sys/arch/arm/imx/files.imx6	Thu Jun 20 08:16:19 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.imx6,v 1.14 2018/06/20 07:05:37 hkenken Exp $
+#	$NetBSD: files.imx6,v 1.15 2019/06/20 08:16:19 hkenken Exp $
 #
 # Configuration info for the Freescale i.MX6
 #
@@ -32,12 +32,15 @@ attach	imxpcie at axi
 file	arch/arm/imx/imx6_pcie.c		imxpcie
 
 # iMX6 Clock Control Module
-device	imxccm
+device	imxccm : clk
 attach	imxccm at axi
 file	arch/arm/imx/imx6_ccm.c			imxccm	needs-flag
 defflag opt_imx6clk.hIMXCCMDEBUG
 defparam opt_imx6clk.hIMX6_OSC_FREQ
 defparam opt_imx6clk.hIMX6_CKIL_FREQ
+defparam opt_imx6clk.hIMX6_CKIH_FREQ
+defparam opt_imx6clk.hIMX6_ANACLK1_FREQ
+defparam opt_imx6clk.hIMX6_ANACLK2_FREQ
 
 # iMX6 Enhanced Periodic Interrupt Timer
 device	imxclock

Index: src/sys/arch/arm/imx/if_enet_imx6.c
diff -u src/sys/arch/arm/imx/if_enet_imx6.c:1.3 src/sys/arch/arm/imx/if_enet_imx6.c:1.4
--- src/sys/arch/arm/imx/if_enet_imx6.c:1.3	Fri Jun  9 18:14:59 2017
+++ src/sys/arch/arm/imx/if_enet_imx6.c	Thu Jun 20 08:16:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet_imx6.c,v 1.3 2017/06/09 18:14:59 ryo Exp $	*/
+/*	$NetBSD: if_enet_imx6.c,v 1.4 2019/06/20 08:16:19 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.3 2017/06/09 18:14:59 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.4 2019/06/20 08:16:19 hkenken Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -47,6 +47,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_enet_imx6
 #include 
 #include 
 
+static int enet_init_clocks(struct enet_softc *);
+
 int
 enet_match(device_t parent __unused, struct cfdata *match __unused, void *aux)
 {
@@ -108,28 +110,9 @@ enet_attach(device_t parent, device_t se
 	sc->sc_enaddr[5] = eaddr + sc->sc_unit;
 #endif
 
-#if NIMXCCM > 0
-	/* PLL power up */
-	if (imx6_pll_power(CCM_ANALOG_PLL_ENET, 1,
-	CCM_ANALOG_PLL_ENET_ENABLE) != 0) {
-		aprint_error_dev(sc->sc_dev,
-		"couldn't enable CCM_ANALOG_PLL_ENET\n");
-		return;
-	}
-
 	if (IMX6_CHIPID_MAJOR(imx6_chip_id()) == CHIPID_MAJOR_IMX6UL) {
 		uint32_t v;
 
-		/* iMX6UL */
-		if ((imx6_pll_power(CCM_ANALOG_PLL_ENET, 1,
-		CCM_ANALOG_PLL_ENET_ENET_25M_REF_EN) != 0) ||
-		(imx6_pll_power(CCM_ANALOG_PLL_ENET, 1,
-		CCM_ANALOG_PLL_ENET_ENET2_125M_EN) != 0)) {
-			aprint_error_dev(sc->sc_dev,
-			"couldn't enable CCM_ANALOG_PLL_ENET\n");
-			return;
-		}
-
 		v = iomux_read(IMX6UL_IOMUX_GPR1);
 		switch (sc->sc_unit) {
 		case 0:
@@ -144,11 +127,42 @@ enet_attach(device_t parent, device_t se
 		iomux_write(IMX6UL_IOMUX_GPR1, v);
 	}
 
-	sc->sc_pllclock = imx6_get_clock(IMX6CLK_PLL6);
-#else
-	sc->sc_pllclock = 5000;
-#endif
+	sc->sc_clk_enet = imx6_get_clock("enet");
+	if (sc->sc_clk_enet == NULL) {
+		aprint_error(": couldn't get clock enet\n");
+		return;
+	}
+	sc->sc_clk_enet_ref = imx6_get_clock("enet_ref");
+	if (sc->sc_clk_enet_ref == NULL) {
+		aprint_error(": couldn't get clock enet_ref\n");
+		return;
+	}
+	if (enet_init_clocks(sc) != 0) {
+		aprint_error_dev(self, "couldn't init clocks\n");
+		return;
+	}
+
+	sc->sc_pllclock = clk_get_rate(sc->sc_clk_enet_ref);
 
 	enet_attach_common(self, aa->aa_iot, aa->aa_dmat, aa->aa_addr,
 	aa->aa_size, aa->aa_irq);
 }
+
+static int
+enet_init_clocks(struct enet_softc *sc)
+{
+	int error;
+
+	

CVS commit: src/sys/arch

2019-06-20 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Jun 20 08:16:20 UTC 2019

Modified Files:
src/sys/arch/arm/imx: files.imx6 if_enet_imx6.c if_enetvar.h
imx6_ahcisata.c imx6_ccm.c imx6_ccmreg.h imx6_ccmvar.h imx6_i2c.c
imx6_pcie.c imx6_usb.c imx6_usbphy.c imx6_usdhc.c imxi2cvar.h
imxusbvar.h
src/sys/arch/evbarm/nitrogen6: nitrogen6_usb.c

Log Message:
Add support for clk subsystem in imx6 CCM driver.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/imx/files.imx6
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/imx/if_enet_imx6.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/imx/if_enetvar.h \
src/sys/arch/arm/imx/imx6_i2c.c src/sys/arch/arm/imx/imxi2cvar.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/imx/imx6_ahcisata.c \
src/sys/arch/arm/imx/imx6_pcie.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/imx/imx6_ccm.c \
src/sys/arch/arm/imx/imx6_ccmreg.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/imx/imx6_ccmvar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/imx/imx6_usb.c \
src/sys/arch/arm/imx/imxusbvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/imx/imx6_usbphy.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/imx/imx6_usdhc.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/nitrogen6/nitrogen6_usb.c

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



CVS commit: src/sys/dev/fdt

2019-06-14 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Jun 14 11:08:18 UTC 2019

Modified Files:
src/sys/dev/fdt: fdt_intr.c fdt_subr.c fdtvar.h

Log Message:
Add support "interrupts-extended".

* fdtbus_get_phandle_with_data().
  Add utility subroutine to get phandle with data.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/fdt/fdt_intr.c
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/fdt/fdt_subr.c
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/fdt/fdtvar.h

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



CVS commit: src/sys/dev/fdt

2019-06-14 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Jun 14 11:08:18 UTC 2019

Modified Files:
src/sys/dev/fdt: fdt_intr.c fdt_subr.c fdtvar.h

Log Message:
Add support "interrupts-extended".

* fdtbus_get_phandle_with_data().
  Add utility subroutine to get phandle with data.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/fdt/fdt_intr.c
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/fdt/fdt_subr.c
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/fdt/fdtvar.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/dev/fdt/fdt_intr.c
diff -u src/sys/dev/fdt/fdt_intr.c:1.21 src/sys/dev/fdt/fdt_intr.c:1.22
--- src/sys/dev/fdt/fdt_intr.c:1.21	Wed Feb 27 17:01:57 2019
+++ src/sys/dev/fdt/fdt_intr.c	Fri Jun 14 11:08:18 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_intr.c,v 1.21 2019/02/27 17:01:57 jakllsch Exp $ */
+/* $NetBSD: fdt_intr.c,v 1.22 2019/06/14 11:08:18 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.21 2019/02/27 17:01:57 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.22 2019/06/14 11:08:18 hkenken Exp $");
 
 #include 
 #include 
@@ -322,12 +322,31 @@ done:
 	return result;
 }
 
+
+static const u_int *
+get_specifier_from_extended(int phandle, int pindex, int *piphandle)
+{
+	const u_int *result = NULL;
+	struct fdt_phandle_data data;
+
+	if (fdtbus_get_phandle_with_data(phandle, "interrupts-extended",
+		"#interrupt-cells", pindex, ) == 0) {
+		*piphandle = data.phandle;
+		result = data.values;
+	}
+
+	return result;
+}
+
 static const u_int *
 get_specifier_by_index(int phandle, int pindex, int *piphandle)
 {
 	const u_int *node_specifier;
 	int interrupt_parent, interrupt_cells, len;
 
+	if (of_hasprop(phandle, "interrupts-extended"))
+		return get_specifier_from_extended(phandle, pindex, piphandle);
+
 	interrupt_parent = fdtbus_get_interrupt_parent(phandle);
 	if (interrupt_parent <= 0)
 		return NULL;

Index: src/sys/dev/fdt/fdt_subr.c
diff -u src/sys/dev/fdt/fdt_subr.c:1.29 src/sys/dev/fdt/fdt_subr.c:1.30
--- src/sys/dev/fdt/fdt_subr.c:1.29	Wed Feb 27 16:56:00 2019
+++ src/sys/dev/fdt/fdt_subr.c	Fri Jun 14 11:08:18 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_subr.c,v 1.29 2019/02/27 16:56:00 jakllsch Exp $ */
+/* $NetBSD: fdt_subr.c,v 1.30 2019/06/14 11:08:18 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.29 2019/02/27 16:56:00 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.30 2019/06/14 11:08:18 hkenken Exp $");
 
 #include "opt_fdt.h"
 
@@ -130,6 +130,42 @@ fdtbus_get_phandle(int phandle, const ch
 }
 
 int
+fdtbus_get_phandle_with_data(int phandle, const char *prop, const char *cells,
+int index, struct fdt_phandle_data *data)
+{
+	int len;
+	const int offset = 1;
+
+	const u_int *p = fdtbus_get_prop(phandle, prop, );
+	if (p == NULL || len <= 0)
+		return EINVAL;
+
+	for (int i = 0; len > 0; i++) {
+		u_int phandle_ref = be32toh(*p);
+		const u_int iparent = fdtbus_get_phandle_from_native(phandle_ref);
+		uint32_t cells_num;
+		of_getprop_uint32(iparent, cells, _num);
+
+		if (index == i) {
+			if (data != NULL) {
+data->phandle = iparent;
+data->count = cells_num;
+data->values = p + offset;
+			}
+			goto done;
+		}
+
+		const u_int reclen = offset + cells_num;
+		len -= reclen * sizeof(u_int);
+		p += reclen;
+	}
+	return EINVAL;
+
+done:
+	return 0;
+}
+
+int
 fdtbus_get_phandle_from_native(int phandle)
 {
 	const int off = fdt_node_offset_by_phandle(fdt_data, phandle);

Index: src/sys/dev/fdt/fdtvar.h
diff -u src/sys/dev/fdt/fdtvar.h:1.51 src/sys/dev/fdt/fdtvar.h:1.52
--- src/sys/dev/fdt/fdtvar.h:1.51	Wed May  8 13:40:18 2019
+++ src/sys/dev/fdt/fdtvar.h	Fri Jun 14 11:08:18 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.51 2019/05/08 13:40:18 isaki Exp $ */
+/* $NetBSD: fdtvar.h,v 1.52 2019/06/14 11:08:18 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -232,6 +232,12 @@ struct fdt_console_info {
 	const struct fdt_console *ops;
 };
 
+struct fdt_phandle_data {
+	int phandle;
+	int count;
+	const u_int *values;
+};
+
 #define	_FDT_CONSOLE_REGISTER(name)	\
 	__link_set_add_rodata(fdt_consoles, __CONCAT(name,_consinfo));
 
@@ -278,6 +284,8 @@ int		fdtbus_get_reg_byname(int, const ch
 		bus_size_t *);
 int		fdtbus_get_reg64(int, u_int, uint64_t *, uint64_t *);
 int		fdtbus_get_phandle(int, const char *);
+int		fdtbus_get_phandle_with_data(int, const char *, const char *,
+		int, struct fdt_phandle_data *);
 int		fdtbus_get_phandle_from_native(int);
 i2c_tag_t	fdtbus_get_i2c_tag(int);
 i2c_tag_t	fdtbus_i2c_acquire(int, const char *);



CVS commit: src/sys/arch/evbarm

2019-06-12 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Jun 13 04:20:23 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: mk.netwalker std.netwalker
src/sys/arch/evbarm/netwalker: netwalker_machdep.c
Removed Files:
src/sys/arch/evbarm/netwalker: netwalker_start.S

Log Message:
Use armv6_start.S


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/conf/mk.netwalker
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/evbarm/conf/std.netwalker
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/evbarm/netwalker/netwalker_machdep.c
cvs rdiff -u -r1.6 -r0 src/sys/arch/evbarm/netwalker/netwalker_start.S

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/evbarm/conf/mk.netwalker
diff -u src/sys/arch/evbarm/conf/mk.netwalker:1.4 src/sys/arch/evbarm/conf/mk.netwalker:1.5
--- src/sys/arch/evbarm/conf/mk.netwalker:1.4	Wed Apr  9 04:00:50 2014
+++ src/sys/arch/evbarm/conf/mk.netwalker	Thu Jun 13 04:20:23 2019
@@ -1,12 +1,11 @@
-#	$NetBSD: mk.netwalker,v 1.4 2014/04/09 04:00:50 hkenken Exp $
+#	$NetBSD: mk.netwalker,v 1.5 2019/06/13 04:20:23 hkenken Exp $
 
 CPPFLAGS+= -mcpu=cortex-a8 -mfpu=neon
 
-SYSTEM_FIRST_OBJ=	netwalker_start.o
-SYSTEM_FIRST_SFILE=	${THISARM}/netwalker/netwalker_start.S
+ENTRYPOINT=		generic_start
 
-KERNEL_BASE_PHYS=0x9010
-KERNEL_BASE_VIRT=0x8010
+SYSTEM_FIRST_OBJ=	armv6_start.o
+SYSTEM_FIRST_SFILE=	${ARM}/arm/armv6_start.S
 
 SYSTEM_LD_TAIL_EXTRA+=; \
 	echo ${OBJCOPY} -S -O binary $@ $@.bin; \

Index: src/sys/arch/evbarm/conf/std.netwalker
diff -u src/sys/arch/evbarm/conf/std.netwalker:1.12 src/sys/arch/evbarm/conf/std.netwalker:1.13
--- src/sys/arch/evbarm/conf/std.netwalker:1.12	Mon Oct 15 16:54:54 2018
+++ src/sys/arch/evbarm/conf/std.netwalker	Thu Jun 13 04:20:23 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: std.netwalker,v 1.12 2018/10/15 16:54:54 skrll Exp $
+#	$NetBSD: std.netwalker,v 1.13 2019/06/13 04:20:23 hkenken Exp $
 #
 # standard NetBSD/evbarm options for Sharp NetWalker
 
@@ -8,21 +8,25 @@ include		"arch/evbarm/conf/std.evbarm"
 # Pull in i.mx51 config definitions.
 include		"arch/evbarm/conf/files.netwalker"
 
+options 	ARM_GENERIC_TODR
+options 	ARM_HAS_VBAR
+options 	ARM_INTR_IMPL=""
+options 	DRAM_BLOCKS=256
+options 	EVBARM_BOARDTYPE="netwalker"
+options 	FPU_VFP
 options 	MODULAR
 options 	MODULAR_DEFAULT_AUTOLOAD
-options 	__HAVE_FAST_SOFTINTS		# should be in types.h
-options 	__HAVE_CPU_COUNTER
-options 	__HAVE_MM_MD_DIRECT_MAPPED_PHYS
-options 	ARM_HAS_VBAR
 options 	TPIDRPRW_IS_CURCPU
+options 	__BUS_SPACE_HAS_STREAM_METHODS
+options 	__HAVE_CPU_COUNTER
+options 	__HAVE_CPU_UAREA_ALLOC_IDLELWP
+options 	__HAVE_GENERIC_START
+options 	__HAVE_GENERIC_CPU_INITCLOCKS
+options 	__HAVE_FAST_SOFTINTS		# should be in types.h
 options 	CORTEX_PMC
 options 	CORTEX_PMC_CCNT_HZ=8
-options 	EVBARM_BOARDTYPE="netwalker"
-options 	FPU_VFP
 
-makeoptions 	LOADADDRESS="0x9010"
-makeoptions 	BOARDTYPE="netwalker"
 makeoptions 	BOARDMKFRAG="${THISARM}/conf/mk.netwalker"
 
-options 	ARM_INTR_IMPL=""
-options 	ARM_GENERIC_TODR
+makeoptions	KERNEL_BASE_PHYS=0x90008000
+makeoptions	KERNEL_BASE_VIRT=0x80008000

Index: src/sys/arch/evbarm/netwalker/netwalker_machdep.c
diff -u src/sys/arch/evbarm/netwalker/netwalker_machdep.c:1.23 src/sys/arch/evbarm/netwalker/netwalker_machdep.c:1.24
--- src/sys/arch/evbarm/netwalker/netwalker_machdep.c:1.23	Mon Jan 21 07:47:30 2019
+++ src/sys/arch/evbarm/netwalker/netwalker_machdep.c	Thu Jun 13 04:20:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netwalker_machdep.c,v 1.23 2019/01/21 07:47:30 skrll Exp $	*/
+/*	$NetBSD: netwalker_machdep.c,v 1.24 2019/06/13 04:20:23 hkenken Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003, 2005, 2010  Genetec Corporation.
@@ -102,7 +102,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netwalker_machdep.c,v 1.23 2019/01/21 07:47:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netwalker_machdep.c,v 1.24 2019/06/13 04:20:23 hkenken Exp $");
 
 #include "opt_evbarm_boardtype.h"
 #include "opt_arm_debug.h"
@@ -164,6 +164,8 @@ char *boot_args = NULL;
 
 extern char KERNEL_BASE_phys[];
 
+u_int uboot_args[4] __attribute__((__section__(".data")));
+
 extern int cpu_do_powersave;
 
 /*



CVS commit: src/sys/arch/evbarm

2019-06-12 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Thu Jun 13 04:20:23 UTC 2019

Modified Files:
src/sys/arch/evbarm/conf: mk.netwalker std.netwalker
src/sys/arch/evbarm/netwalker: netwalker_machdep.c
Removed Files:
src/sys/arch/evbarm/netwalker: netwalker_start.S

Log Message:
Use armv6_start.S


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/conf/mk.netwalker
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/evbarm/conf/std.netwalker
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/evbarm/netwalker/netwalker_machdep.c
cvs rdiff -u -r1.6 -r0 src/sys/arch/evbarm/netwalker/netwalker_start.S

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