Module Name:    src
Committed By:   jmcneill
Date:           Fri Sep 28 13:24:02 UTC 2018

Modified Files:
        src/sys/arch/arm/broadcom: bcm2835_gpio.c

Log Message:
Fix previous; follow the binding spec for this device when decoding
interrupt specifiers.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/broadcom/bcm2835_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/broadcom/bcm2835_gpio.c
diff -u src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.7 src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.8
--- src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.7	Sat May 19 14:02:10 2018
+++ src/sys/arch/arm/broadcom/bcm2835_gpio.c	Fri Sep 28 13:24:02 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_gpio.c,v 1.7 2018/05/19 14:02:10 thorpej Exp $	*/
+/*	$NetBSD: bcm2835_gpio.c,v 1.8 2018/09/28 13:24:02 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2013, 2014, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.7 2018/05/19 14:02:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.8 2018/09/28 13:24:02 jmcneill Exp $");
 
 /*
  * Driver for BCM2835 GPIO
@@ -560,12 +560,11 @@ bcmgpio_fdt_intr_establish(device_t dev,
 		return (NULL);
 	}
 
-	/* 1st cell is the bank */
-	/* 2nd cell is the pin */
-	/* 3rd cell is flags */
-	const u_int bank = be32toh(specifier[0]);
-	const u_int pin = be32toh(specifier[1]);
-	const u_int type = be32toh(specifier[2]) & 0xf;
+	/* 1st cell is the GPIO number */
+	/* 2nd cell is flags */
+	const u_int bank = be32toh(specifier[0]) / 32;
+	const u_int pin = be32toh(specifier[0]) % 32;
+	const u_int type = be32toh(specifier[1]) & 0xf;
 
 	switch (type) {
 	case 0x1:
@@ -668,19 +667,16 @@ static bool
 bcmgpio_fdt_intrstr(device_t dev, u_int *specifier, char *buf, size_t buflen)
 {
 
-	/* 1st cell is the bank */
-	/* 2nd cell is the pin */
+	/* 1st cell is the GPIO number */
 	/* 3rd cell is flags */
 	if (!specifier)
 		return (false);
-	const u_int bank = be32toh(specifier[0]);
-	const u_int pin = be32toh(specifier[1]);
+	const u_int bank = be32toh(specifier[0]) / 32;
+	const u_int pin = be32toh(specifier[0]) % 32;
 
 	if (bank >= BCMGPIO_NBANKS)
 		return (false);
-	if (pin >= 32)
-		return (false);
-	
+
 	snprintf(buf, buflen, "GPIO %u", (bank * 32) + pin);
 
 	return (true);

Reply via email to