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

2024-02-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 16 15:40:09 UTC 2024

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

Log Message:
Test sc->sc_soft_ih (not sc->sc_ih) to see if the soft interrupt got
established correctly.

>From Mori Hiroki.

Fix some error recovery while I'm here.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/broadcom/bcm53xx_eth.c

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

Modified files:

Index: src/sys/arch/arm/broadcom/bcm53xx_eth.c
diff -u src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.43 src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.44
--- src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.43	Fri Feb 16 12:08:29 2024
+++ src/sys/arch/arm/broadcom/bcm53xx_eth.c	Fri Feb 16 15:40:09 2024
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.43 2024/02/16 12:08:29 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.44 2024/02/16 15:40:09 skrll Exp $");
 
 #include 
 #include 
@@ -344,16 +344,15 @@ bcmeth_ccb_attach(device_t parent, devic
 	(PRI_USER + MAXPRI_USER) / 2, IPL_NET, WQ_MPSAFE|WQ_PERCPU);
 	if (error) {
 		aprint_error(": failed to create workqueue: %d\n", error);
-		goto fail_2;
+		goto fail_1;
 	}
 
 	sc->sc_soft_ih = softint_establish(SOFTINT_MPSAFE | SOFTINT_NET,
 	bcmeth_soft_intr, sc);
 
-	if (sc->sc_ih == NULL) {
-		aprint_error_dev(self, "failed to establish interrupt %d\n",
-		 loc->loc_intrs[0]);
-		goto fail_3;
+	if (sc->sc_soft_ih == NULL) {
+		aprint_error_dev(self, "failed to establish soft interrupt\n");
+		goto fail_2;
 	}
 
 	sc->sc_ih = intr_establish(loc->loc_intrs[0], IPL_VM, IST_LEVEL,
@@ -362,7 +361,7 @@ bcmeth_ccb_attach(device_t parent, devic
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt %d\n",
 		 loc->loc_intrs[0]);
-		goto fail_4;
+		goto fail_3;
 	} else {
 		aprint_normal_dev(self, "interrupting on irq %d\n",
 		 loc->loc_intrs[0]);
@@ -426,8 +425,6 @@ bcmeth_ccb_attach(device_t parent, devic
 
 	return;
 
-fail_4:
-	intr_disestablish(sc->sc_ih);
 fail_3:
 	softint_disestablish(sc->sc_soft_ih);
 fail_2:



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

2024-02-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 16 15:40:09 UTC 2024

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

Log Message:
Test sc->sc_soft_ih (not sc->sc_ih) to see if the soft interrupt got
established correctly.

>From Mori Hiroki.

Fix some error recovery while I'm here.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/broadcom/bcm53xx_eth.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/broadcom

2024-02-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 16 15:11:38 UTC 2024

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_bsc.c bcm2835_vcaudio.c
bcm2838_pcie.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/broadcom/bcm2835_bsc.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/broadcom/bcm2835_vcaudio.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/broadcom/bcm2838_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/broadcom

2024-02-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 16 15:11:38 UTC 2024

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_bsc.c bcm2835_vcaudio.c
bcm2838_pcie.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/broadcom/bcm2835_bsc.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/broadcom/bcm2835_vcaudio.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/broadcom/bcm2838_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/broadcom/bcm2835_bsc.c
diff -u src/sys/arch/arm/broadcom/bcm2835_bsc.c:1.15 src/sys/arch/arm/broadcom/bcm2835_bsc.c:1.16
--- src/sys/arch/arm/broadcom/bcm2835_bsc.c:1.15	Tue Mar 31 12:23:17 2020
+++ src/sys/arch/arm/broadcom/bcm2835_bsc.c	Fri Feb 16 15:11:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_bsc.c,v 1.15 2020/03/31 12:23:17 jmcneill Exp $	*/
+/*	$NetBSD: bcm2835_bsc.c,v 1.16 2024/02/16 15:11:38 skrll Exp $	*/
 
 /*
  * Copyright (c) 2019 Jason R. Thorpe
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc.c,v 1.15 2020/03/31 12:23:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc.c,v 1.16 2024/02/16 15:11:38 skrll Exp $");
 
 #include 
 #include 
@@ -203,7 +203,7 @@ bsciic_next_state(struct bsciic_softc * 
 	case BSC_EXEC_STATE_SEND_DATA:
 	case BSC_EXEC_STATE_RECV_DATA:
 		return BSC_EXEC_STATE_DONE;
-	
+
 	case BSC_EXEC_STATE_DONE:
 	case BSC_EXEC_STATE_ERROR:
 		return sc->sc_exec_state;

Index: src/sys/arch/arm/broadcom/bcm2835_vcaudio.c
diff -u src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.19 src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.20
--- src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.19	Sun Apr 30 14:20:23 2023
+++ src/sys/arch/arm/broadcom/bcm2835_vcaudio.c	Fri Feb 16 15:11:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_vcaudio.c,v 1.19 2023/04/30 14:20:23 mlelstv Exp $ */
+/* $NetBSD: bcm2835_vcaudio.c,v 1.20 2024/02/16 15:11:38 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 Jared D. McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_vcaudio.c,v 1.19 2023/04/30 14:20:23 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_vcaudio.c,v 1.20 2024/02/16 15:11:38 skrll Exp $");
 
 #include 
 #include 
@@ -88,7 +88,7 @@ enum vcaudio_dest {
  *
  * Setting blocksize to 4 x 1600 means that we send approx 33ms of audio. We
  * prefill by two blocks before starting audio meaning we have 50ms of latency.
- * 
+ *
  * Six messages of 1600 bytes was chosen working back from a desired latency of
  * 50ms.
  */

Index: src/sys/arch/arm/broadcom/bcm2838_pcie.c
diff -u src/sys/arch/arm/broadcom/bcm2838_pcie.c:1.6 src/sys/arch/arm/broadcom/bcm2838_pcie.c:1.7
--- src/sys/arch/arm/broadcom/bcm2838_pcie.c:1.6	Sat Oct 15 11:07:38 2022
+++ src/sys/arch/arm/broadcom/bcm2838_pcie.c	Fri Feb 16 15:11:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2838_pcie.c,v 1.6 2022/10/15 11:07:38 jmcneill Exp $ */
+/*	$NetBSD: bcm2838_pcie.c,v 1.7 2024/02/16 15:11:38 skrll Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2838_pcie.c,v 1.6 2022/10/15 11:07:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2838_pcie.c,v 1.7 2024/02/16 15:11:38 skrll Exp $");
 
 #include 
 #include 
@@ -417,7 +417,7 @@ bcmstb_setwin(struct bcmstb_softc *sc, i
 	STBRMW(sc, PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI(win),
 	PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI_BASE,
 	__SHIFTIN(base, PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI_BASE));
-	
+
 	STBRMW(sc, PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI(win),
 	PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI_LIMIT,
 	__SHIFTIN(base, PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI_LIMIT));



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

2024-02-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 16 15:11:17 UTC 2024

Modified Files:
src/sys/arch/arm/broadcom: bcm53xx_board.c bcm53xx_cca.c bcm53xx_idm.c
bcm53xx_pax.c bcm53xx_reg.h

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/broadcom/bcm53xx_board.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/broadcom/bcm53xx_cca.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/broadcom/bcm53xx_idm.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/broadcom/bcm53xx_pax.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/broadcom/bcm53xx_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/broadcom/bcm53xx_board.c
diff -u src/sys/arch/arm/broadcom/bcm53xx_board.c:1.25 src/sys/arch/arm/broadcom/bcm53xx_board.c:1.26
--- src/sys/arch/arm/broadcom/bcm53xx_board.c:1.25	Tue Jul 31 06:46:25 2018
+++ src/sys/arch/arm/broadcom/bcm53xx_board.c	Fri Feb 16 15:11:17 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm53xx_board.c,v 1.25 2018/07/31 06:46:25 skrll Exp $	*/
+/*	$NetBSD: bcm53xx_board.c,v 1.26 2024/02/16 15:11:17 skrll Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.25 2018/07/31 06:46:25 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.26 2024/02/16 15:11:17 skrll Exp $");
 
 #include 
 #include 
@@ -328,7 +328,7 @@ bcm53xx_usb_clock_init(struct bcm53xx_cl
 	const uint32_t ndiv = bcm53xx_value_wrap(usb2_control,
 	USB2_CONTROL_NDIV_INT);
 
-	uint32_t usb_ref = (clk->clk_usb2 / pdiv) * ndiv; 
+	uint32_t usb_ref = (clk->clk_usb2 / pdiv) * ndiv;
 	if (usb_ref != USB2_REF_CLK) {
 		/*
 		 * USB Reference Clock isn't 1.92GHz.  So we need to modify
@@ -350,7 +350,7 @@ bcm53xx_usb_clock_init(struct bcm53xx_cl
 		bus_space_write_4(bcm53xx_ioreg_bst, bcm53xx_ioreg_bsh,
 		CRU_BASE + CRU_CLKSET_KEY, 0);
 
-		usb_ref = (clk->clk_usb2 / pdiv) * new_ndiv; 
+		usb_ref = (clk->clk_usb2 / pdiv) * new_ndiv;
 	}
 
 	clk->clk_usb_ref = usb_ref;
@@ -367,7 +367,7 @@ bcm53xx_clock_init(struct bcm53xx_clock_
 /*
  * F(ddr) = ((1 / pdiv) * ndiv * CH2) / (post_div * 2)
  */
-static void 
+static void
 bcm53xx_get_ddr_freq(struct bcm53xx_clock_info *clk, uint32_t pll_status,
 uint32_t pll_dividers)
 {
@@ -402,7 +402,7 @@ bcm53xx_get_cpu_freq(struct bcm53xx_cloc
 		clk->clk_apb = clk->clk_cpu / 4;
 		return;
 	}
-		
+
 	const u_int pdiv = bcm53xx_value_wrap(pllarma, CLK_PLLARMA_PDIV);
 	const u_int ndiv_int = bcm53xx_value_wrap(pllarma, CLK_PLLARMA_NDIV_INT);
 	const u_int ndiv_frac = __SHIFTOUT(pllarmb, CLK_PLLARMB_NDIV_FRAC);
@@ -605,13 +605,13 @@ bcm53xx_device_register(device_t self, v
 		 * XXX KLUDGE ALERT XXX
 		 * The iot mainbus supplies is completely wrong since it scales
 		 * addresses by 2.  The simplest remedy is to replace with our
-		 * bus space used for the armcore registers (which armperiph uses). 
+		 * bus space used for the armcore registers (which armperiph uses).
 		 */
 		struct mainbus_attach_args * const mb = aux;
 		mb->mb_iot = bcm53xx_armcore_bst;
 		return;
 	}
- 
+
 	/*
 	 * We need to tell the A9 Global/Watchdog Timer
 	 * what frequency it runs at.
@@ -649,8 +649,8 @@ bcm53xx_srab_init(void)
 {
 	mutex_init(_lock, MUTEX_DEFAULT, IPL_VM);
 
-	bcm53xx_srab_write_4(0x0079, 0x90);	// reset switch 
-	for (u_int port = 0; port < 8; port++) {
+	bcm53xx_srab_write_4(0x0079, 0x90);	// reset switch
+	for (u_int port = 0; port < 8; port++) {
 		/* per port control: no stp */
 		bcm53xx_srab_write_4(port, 0x00);
 	}

Index: src/sys/arch/arm/broadcom/bcm53xx_cca.c
diff -u src/sys/arch/arm/broadcom/bcm53xx_cca.c:1.5 src/sys/arch/arm/broadcom/bcm53xx_cca.c:1.6
--- src/sys/arch/arm/broadcom/bcm53xx_cca.c:1.5	Thu Mar  3 06:26:28 2022
+++ src/sys/arch/arm/broadcom/bcm53xx_cca.c	Fri Feb 16 15:11:17 2024
@@ -43,7 +43,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_cca.c,v 1.5 2022/03/03 06:26:28 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_cca.c,v 1.6 2024/02/16 15:11:17 skrll Exp $");
 
 #include 
 #include 
@@ -143,7 +143,7 @@ bcmcca_intr(void *arg)
 		}
 	}
 	if (v & INTSTATUS_GPIOINT) {
-		
+
 	}
 	return rv;
 }

Index: src/sys/arch/arm/broadcom/bcm53xx_idm.c
diff -u src/sys/arch/arm/broadcom/bcm53xx_idm.c:1.3 src/sys/arch/arm/broadcom/bcm53xx_idm.c:1.4
--- src/sys/arch/arm/broadcom/bcm53xx_idm.c:1.3	Wed Dec 12 00:01:28 2012
+++ src/sys/arch/arm/broadcom/bcm53xx_idm.c	Fri Feb 16 15:11:17 2024
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_idm.c,v 1.3 2012/12/12 00:01:28 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_idm.c,v 1.4 2024/02/16 15:11:17 skrll Exp $");
 
 #include 
 #include 
@@ -59,7 +59,7 @@ struct idm_info {
 static bool
 bcmeth_unreset(bus_space_tag_t bst, bus_space_handle_t bsh,
 const struct idm_info *idm)
-{ 
+{
 	/*
 	 * To 

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

2024-02-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 16 15:11:17 UTC 2024

Modified Files:
src/sys/arch/arm/broadcom: bcm53xx_board.c bcm53xx_cca.c bcm53xx_idm.c
bcm53xx_pax.c bcm53xx_reg.h

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/broadcom/bcm53xx_board.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/broadcom/bcm53xx_cca.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/broadcom/bcm53xx_idm.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/broadcom/bcm53xx_pax.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/broadcom/bcm53xx_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/broadcom

2024-02-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 16 12:08:29 UTC 2024

Modified Files:
src/sys/arch/arm/broadcom: bcm53xx_eth.c bcm53xx_pax.c

Log Message:
Fix non-DIAGNOSTIC build


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/arm/broadcom/bcm53xx_eth.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/broadcom/bcm53xx_pax.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/broadcom

2024-02-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Feb 16 12:08:29 UTC 2024

Modified Files:
src/sys/arch/arm/broadcom: bcm53xx_eth.c bcm53xx_pax.c

Log Message:
Fix non-DIAGNOSTIC build


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/arm/broadcom/bcm53xx_eth.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/broadcom/bcm53xx_pax.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/bcm53xx_eth.c
diff -u src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.42 src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.43
--- src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.42	Sat Sep 17 19:41:18 2022
+++ src/sys/arch/arm/broadcom/bcm53xx_eth.c	Fri Feb 16 12:08:29 2024
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.42 2022/09/17 19:41:18 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.43 2024/02/16 12:08:29 skrll Exp $");
 
 #include 
 #include 
@@ -252,9 +252,7 @@ bcmeth_ccb_match(device_t parent, cfdata
 	if (strcmp(cf->cf_name, loc->loc_name))
 		return 0;
 
-#ifdef DIAGNOSTIC
-	const int port = cf->cf_loc[BCMCCBCF_PORT];
-#endif
+	const int port __diagused = cf->cf_loc[BCMCCBCF_PORT];
 	KASSERT(port == BCMCCBCF_PORT_DEFAULT || port == loc->loc_port);
 
 	return 1;

Index: src/sys/arch/arm/broadcom/bcm53xx_pax.c
diff -u src/sys/arch/arm/broadcom/bcm53xx_pax.c:1.22 src/sys/arch/arm/broadcom/bcm53xx_pax.c:1.23
--- src/sys/arch/arm/broadcom/bcm53xx_pax.c:1.22	Sat Aug  7 16:18:43 2021
+++ src/sys/arch/arm/broadcom/bcm53xx_pax.c	Fri Feb 16 12:08:29 2024
@@ -34,7 +34,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_pax.c,v 1.22 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_pax.c,v 1.23 2024/02/16 12:08:29 skrll Exp $");
 
 #include 
 #include 
@@ -136,9 +136,7 @@ bcmpax_ccb_match(device_t parent, cfdata
 	if (strcmp(cf->cf_name, loc->loc_name))
 		return 0;
 
-#ifdef DIAGNOSTIC
-	const int port = cf->cf_loc[BCMCCBCF_PORT];
-#endif
+	const int port __diagused = cf->cf_loc[BCMCCBCF_PORT];
 	KASSERT(port == BCMCCBCF_PORT_DEFAULT || port == loc->loc_port);
 
 	return 1;



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

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 12:53:08 UTC 2023

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

Log Message:
Report UART clock.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/broadcom/bcm2835_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/broadcom/bcm2835_com.c
diff -u src/sys/arch/arm/broadcom/bcm2835_com.c:1.8 src/sys/arch/arm/broadcom/bcm2835_com.c:1.9
--- src/sys/arch/arm/broadcom/bcm2835_com.c:1.8	Fri Jan 29 14:11:14 2021
+++ src/sys/arch/arm/broadcom/bcm2835_com.c	Mon Dec 11 12:53:08 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_com.c,v 1.8 2021/01/29 14:11:14 skrll Exp $ */
+/* $NetBSD: bcm2835_com.c,v 1.9 2023/12/11 12:53:08 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_com.c,v 1.8 2021/01/29 14:11:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_com.c,v 1.9 2023/12/11 12:53:08 mlelstv Exp $");
 
 #include 
 #include 
@@ -123,7 +123,8 @@ bcm_com_attach(device_t parent, device_t
 		intrstr);
 		return;
 	}
-	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
+	aprint_normal_dev(self, "interrupting on %s, clock %u Hz\n",
+	   intrstr, sc->sc_frequency);
 }
 
 static int



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

2023-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Dec 11 12:53:08 UTC 2023

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

Log Message:
Report UART clock.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/broadcom/bcm2835_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/arch/arm/broadcom

2023-09-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Sep  3 11:36:52 UTC 2023

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

Log Message:
bcm2835_spi: guard against too large clock divider and clamp if necessary


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/broadcom/bcm2835_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/broadcom/bcm2835_spi.c
diff -u src/sys/arch/arm/broadcom/bcm2835_spi.c:1.12 src/sys/arch/arm/broadcom/bcm2835_spi.c:1.13
--- src/sys/arch/arm/broadcom/bcm2835_spi.c:1.12	Sat May  7 07:26:27 2022
+++ src/sys/arch/arm/broadcom/bcm2835_spi.c	Sun Sep  3 11:36:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_spi.c,v 1.12 2022/05/07 07:26:27 skrll Exp $	*/
+/*	$NetBSD: bcm2835_spi.c,v 1.13 2023/09/03 11:36:52 tnn Exp $	*/
 
 /*
  * Copyright (c) 2012 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_spi.c,v 1.12 2022/05/07 07:26:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_spi.c,v 1.13 2023/09/03 11:36:52 tnn Exp $");
 
 #include 
 #include 
@@ -182,6 +182,8 @@ bcmspi_configure(void *cookie, int slave
 	clk = 2 * 25000 / speed; /* XXX 250MHz */
 	clk = (clk / 2) + (clk & 1);
 	clk = roundup(clk, 2);
+	if (clk >= 0xfffe)
+		clk = 0xfffe;
 	clk = __SHIFTIN(clk, SPI_CLK_CDIV);
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, SPI_CLK, clk);
 



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

2023-09-03 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Sep  3 11:36:52 UTC 2023

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

Log Message:
bcm2835_spi: guard against too large clock divider and clamp if necessary


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/broadcom/bcm2835_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/broadcom

2023-04-30 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 30 14:20:23 UTC 2023

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

Log Message:
codec translates to 16bit slinear_le, not the internal format.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/broadcom/bcm2835_vcaudio.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_vcaudio.c
diff -u src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.18 src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.19
--- src/sys/arch/arm/broadcom/bcm2835_vcaudio.c:1.18	Sat Apr 24 23:36:26 2021
+++ src/sys/arch/arm/broadcom/bcm2835_vcaudio.c	Sun Apr 30 14:20:23 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_vcaudio.c,v 1.18 2021/04/24 23:36:26 thorpej Exp $ */
+/* $NetBSD: bcm2835_vcaudio.c,v 1.19 2023/04/30 14:20:23 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2013 Jared D. McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_vcaudio.c,v 1.18 2021/04/24 23:36:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_vcaudio.c,v 1.19 2023/04/30 14:20:23 mlelstv Exp $");
 
 #include 
 #include 
@@ -840,7 +840,7 @@ vcaudio_swvol_codec(audio_filter_arg_t *
 {
 	struct vcaudio_softc *sc = arg->context;
 	const aint_t *src;
-	aint_t *dst;
+	int16_t *dst;
 	u_int sample_count;
 	u_int i;
 



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

2023-04-30 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 30 14:20:23 UTC 2023

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

Log Message:
codec translates to 16bit slinear_le, not the internal format.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/broadcom/bcm2835_vcaudio.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/broadcom

2022-11-19 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sat Nov 19 09:29:26 UTC 2022

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

Log Message:
bcm2835_intr.c: fix !MULTIPROCESSOR

Tested on Raspberry PI 3 model A+.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.43 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.44
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.43	Sat Jun 25 12:41:55 2022
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Sat Nov 19 09:29:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.43 2022/06/25 12:41:55 jmcneill Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.44 2022/11/19 09:29:26 yamt Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.43 2022/06/25 12:41:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.44 2022/11/19 09:29:26 yamt Exp $");
 
 #define _INTR_PRIVATE
 
@@ -99,7 +99,12 @@ static int  bcm2835_icu_match(device_t, 
 static void bcm2835_icu_attach(device_t, device_t, void *);
 
 static int bcm2835_int_base;
-static int bcm2836mp_int_base[BCM2836_NCPUS];
+#if defined(MULTIPROCESSOR)
+#define _BCM2836_NCPUS BCM2836_NCPUS
+#else
+#define _BCM2836_NCPUS 1
+#endif
+static int bcm2836mp_int_base[_BCM2836_NCPUS];
 
 #define	BCM2835_INT_BASE		bcm2835_int_base
 #define	BCM2836_INT_BASECPUN(n)		bcm2836mp_int_base[(n)]
@@ -180,8 +185,8 @@ static struct pic_ops bcm2836mp_picops =
 #endif
 };
 
-static struct pic_softc bcm2836mp_pic[BCM2836_NCPUS] = {
-	[0 ... BCM2836_NCPUS - 1] = {
+static struct pic_softc bcm2836mp_pic[_BCM2836_NCPUS] = {
+	[0 ... _BCM2836_NCPUS - 1] = {
 		.pic_ops = _picops,
 		.pic_maxsources = BCM2836_NIRQPERCPU,
 		.pic_name = "bcm2836 pic",
@@ -208,7 +213,7 @@ struct bcm2836mp_interrupt {
 	int bi_flags;
 	int (*bi_func)(void *);
 	void *bi_arg;
-	void *bi_ihs[BCM2836_NCPUS];
+	void *bi_ihs[_BCM2836_NCPUS];
 };
 
 static TAILQ_HEAD(, bcm2836mp_interrupt) bcm2836mp_interrupts =
@@ -360,7 +365,6 @@ bcm2835_icu_attach(device_t parent, devi
 
 		ifuncs = _fdt_funcs;
 
-#if defined(MULTIPROCESSOR)
 		/*
 		 * Register all PICs here in order to avoid pic_add() from
 		 * cpu_hatch().  This is the only approved method.
@@ -371,8 +375,8 @@ bcm2835_icu_attach(device_t parent, devi
 			const cpuid_t cpuid = ci->ci_core_id;
 			struct pic_softc * const pic = _pic[cpuid];
 
-			KASSERT(cpuid < BCM2836_NCPUS);
-
+			KASSERT(cpuid < _BCM2836_NCPUS);
+#if defined(MULTIPROCESSOR)
 			pic->pic_cpus = ci->ci_kcpuset;
 			/*
 			 * Append "#n" to avoid duplication of .pic_name[]
@@ -381,12 +385,13 @@ bcm2835_icu_attach(device_t parent, devi
 			char suffix[sizeof("#0")];
 			snprintf(suffix, sizeof(suffix), "#%lu", cpuid);
 			strlcat(pic->pic_name, suffix, sizeof(pic->pic_name));
-
+#endif
 			bcm2836mp_int_base[cpuid] =
 			pic_add(pic, PIC_IRQBASE_ALLOC);
+#if defined(MULTIPROCESSOR)
 			bcm2836mp_intr_init(ci);
-		}
 #endif
+		}
 	} else {
 		if (bcml1icu_sc == NULL)
 			arm_fdt_irq_set_handler(bcm2835_irq_handler);
@@ -414,7 +419,7 @@ bcm2835_irq_handler(void *frame)
 	const uint32_t oldipl_mask = __BIT(oldipl);
 	int ipl_mask = 0;
 
-	KASSERT(cpuid < BCM2836_NCPUS);
+	KASSERT(cpuid < _BCM2836_NCPUS);
 
 	ci->ci_data.cpu_nintr++;
 
@@ -692,7 +697,7 @@ bcm2836mp_pic_unblock_irqs(struct pic_so
 	const bus_space_handle_t ioh = bcml1icu_sc->sc_ioh;
 	const cpuid_t cpuid = pic - _pic[0];
 
-	KASSERT(cpuid < BCM2836_NCPUS);
+	KASSERT(cpuid < _BCM2836_NCPUS);
 	KASSERT(irqbase == 0);
 
 	if (irq_mask & BCM2836MP_TIMER_IRQS) {
@@ -739,7 +744,7 @@ bcm2836mp_pic_block_irqs(struct pic_soft
 	const bus_space_handle_t ioh = bcml1icu_sc->sc_ioh;
 	const cpuid_t cpuid = pic - _pic[0];
 
-	KASSERT(cpuid < BCM2836_NCPUS);
+	KASSERT(cpuid < _BCM2836_NCPUS);
 	KASSERT(irqbase == 0);
 
 	if (irq_mask & BCM2836MP_TIMER_IRQS) {
@@ -777,7 +782,7 @@ bcm2836mp_pic_find_pending_irqs(struct p
 	uint32_t lpending;
 	int ipl = 0;
 
-	KASSERT(cpuid < BCM2836_NCPUS);
+	KASSERT(cpuid < _BCM2836_NCPUS);
 	KASSERT(pic == _pic[cpuid]);
 
 	bcm2835_barrier();
@@ -816,7 +821,7 @@ static void bcm2836mp_cpu_init(struct pi
 {
 	const cpuid_t cpuid = ci->ci_core_id;
 
-	KASSERT(cpuid < BCM2836_NCPUS);
+	KASSERT(cpuid < _BCM2836_NCPUS);
 
 	/* Enable IRQ and not FIQ */
 	bus_space_write_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
@@ -831,7 +836,7 @@ bcm2836mp_send_ipi(struct pic_softc *pic
 	KASSERT(pic->pic_cpus != NULL);
 
 	const cpuid_t cpuid = pic - _pic[0];
-	KASSERT(cpuid < BCM2836_NCPUS);
+	KASSERT(cpuid < _BCM2836_NCPUS);
 
 	bus_space_write_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
 	BCM2836_LOCAL_MAILBOX0_SETN(cpuid), __BIT(ipi));
@@ -844,7 +849,7 @@ 

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

2022-11-19 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sat Nov 19 09:29:26 UTC 2022

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

Log Message:
bcm2835_intr.c: fix !MULTIPROCESSOR

Tested on Raspberry PI 3 model A+.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2022-09-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Sep 17 19:41:19 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.


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

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

Modified files:

Index: src/sys/arch/arm/broadcom/bcm53xx_eth.c
diff -u src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.41 src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.42
--- src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.41	Wed Jun 16 00:21:17 2021
+++ src/sys/arch/arm/broadcom/bcm53xx_eth.c	Sat Sep 17 19:41:18 2022
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.41 2021/06/16 00:21:17 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.42 2022/09/17 19:41:18 thorpej Exp $");
 
 #include 
 #include 
@@ -1900,9 +1900,6 @@ bcmeth_soft_txintr(struct bcmeth_softc *
 	if (!bcmeth_txq_consume(sc, >sc_txq)
 	|| !bcmeth_txq_enqueue(sc, >sc_txq)) {
 		BCMETH_EVCNT_INCR(sc->sc_ev_tx_stall);
-		sc->sc_if.if_flags |= IFF_OACTIVE;
-	} else {
-		sc->sc_if.if_flags &= ~IFF_OACTIVE;
 	}
 	if (sc->sc_if.if_flags & IFF_RUNNING) {
 		mutex_spin_enter(sc->sc_hwlock);
@@ -1936,9 +1933,6 @@ bcmeth_soft_intr(void *arg)
 		if (!bcmeth_txq_consume(sc, >sc_txq)
 		|| !bcmeth_txq_enqueue(sc, >sc_txq)) {
 			BCMETH_EVCNT_INCR(sc->sc_ev_tx_stall);
-			ifp->if_flags |= IFF_OACTIVE;
-		} else {
-			ifp->if_flags &= ~IFF_OACTIVE;
 		}
 		intmask |= XMTINT_0;
 	}



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

2022-09-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Sep 17 19:41:19 UTC 2022

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

Log Message:
Eliminate use of IFF_OACTIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/arm/broadcom/bcm53xx_eth.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/broadcom

2022-05-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May  7 07:26:27 UTC 2022

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

Log Message:
Remove unnecessary gotos and label.  Same code before and after.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/broadcom/bcm2835_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/broadcom

2022-05-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat May  7 07:26:27 UTC 2022

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

Log Message:
Remove unnecessary gotos and label.  Same code before and after.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/broadcom/bcm2835_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/broadcom/bcm2835_spi.c
diff -u src/sys/arch/arm/broadcom/bcm2835_spi.c:1.11 src/sys/arch/arm/broadcom/bcm2835_spi.c:1.12
--- src/sys/arch/arm/broadcom/bcm2835_spi.c:1.11	Sat Aug  7 16:18:43 2021
+++ src/sys/arch/arm/broadcom/bcm2835_spi.c	Sat May  7 07:26:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_spi.c,v 1.11 2021/08/07 16:18:43 thorpej Exp $	*/
+/*	$NetBSD: bcm2835_spi.c,v 1.12 2022/05/07 07:26:27 skrll Exp $	*/
 
 /*
  * Copyright (c) 2012 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_spi.c,v 1.11 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_spi.c,v 1.12 2022/05/07 07:26:27 skrll Exp $");
 
 #include 
 #include 
@@ -298,7 +298,6 @@ bcmspi_intr(void *cookie)
 	if (ISSET(cs, SPI_CS_DONE)) {
 		if (sc->sc_wchunk != NULL) {
 			bcmspi_send(sc);
-			goto end;
 		} else {
 			bus_space_write_4(sc->sc_iot, sc->sc_ioh, SPI_CS,
 			sc->sc_CS);
@@ -309,14 +308,12 @@ bcmspi_intr(void *cookie)
 			KASSERT(st != NULL);
 			spi_done(st, 0);
 			sc->sc_running = false;
-			goto end;
 		}
 	} else if (ISSET(cs, SPI_CS_RXR)) {
 		bcmspi_recv(sc);
 		bcmspi_send(sc);
 	}
 
-end:
 	mutex_exit(>sc_mutex);
 	return ISSET(cs, SPI_CS_DONE|SPI_CS_RXR);
 }



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

2022-04-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Apr 22 12:41:06 UTC 2022

Modified Files:
src/sys/arch/arm/broadcom: files.bcm2835

Log Message:
Remove stale comment


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/arm/broadcom/files.bcm2835

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/files.bcm2835
diff -u src/sys/arch/arm/broadcom/files.bcm2835:1.42 src/sys/arch/arm/broadcom/files.bcm2835:1.43
--- src/sys/arch/arm/broadcom/files.bcm2835:1.42	Sun Aug  8 18:43:21 2021
+++ src/sys/arch/arm/broadcom/files.bcm2835	Fri Apr 22 12:41:06 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.bcm2835,v 1.42 2021/08/08 18:43:21 jmcneill Exp $
+#	$NetBSD: files.bcm2835,v 1.43 2022/04/22 12:41:06 skrll Exp $
 #
 # Configuration info for Broadcom BCM2835 ARM Peripherals
 #
@@ -9,7 +9,7 @@ file	arch/arm/broadcom/bcm283x_platform.
 
 define bcmmboxbus { }
 
-# Interrupt Controller (BCM2835_ARMICU_BASE) #, pic_splfuncs
+# Interrupt Controller (BCM2835_ARMICU_BASE)
 device	bcmicu: pic, pic_splfuncs
 attach	bcmicu at fdt with bcmicu
 file	arch/arm/broadcom/bcm2835_intr.c	bcmicu



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

2022-04-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Apr 22 12:41:06 UTC 2022

Modified Files:
src/sys/arch/arm/broadcom: files.bcm2835

Log Message:
Remove stale comment


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/arm/broadcom/files.bcm2835

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/broadcom

2021-09-11 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sun Sep 12 03:58:52 UTC 2021

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

Log Message:
Fix build for uniprocessor.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2021-09-11 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sun Sep 12 03:58:52 UTC 2021

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

Log Message:
Fix build for uniprocessor.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.40 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.41
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.40	Wed Sep  1 22:11:35 2021
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Sun Sep 12 03:58:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.40 2021/09/01 22:11:35 jmcneill Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.41 2021/09/12 03:58:52 nat Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.40 2021/09/01 22:11:35 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.41 2021/09/12 03:58:52 nat Exp $");
 
 #define _INTR_PRIVATE
 
@@ -892,11 +892,11 @@ bcm2836mp_ipi_handler(void *priv)
 static void
 bcm2836mp_intr_init(void *priv, struct cpu_info *ci)
 {
+#if defined(MULTIPROCESSOR)
 	const cpuid_t cpuid = ci->ci_core_id;
 
 	KASSERT(cpuid < BCM2836_NCPUS);
 
-#if defined(MULTIPROCESSOR)
 	intr_establish(BCM2836_INT_MAILBOX0_CPUN(cpuid), IPL_HIGH,
 	IST_LEVEL | IST_MPSAFE, bcm2836mp_ipi_handler, ci);
 



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

2021-09-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Sep  1 22:11:35 UTC 2021

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

Log Message:
Install IPI handler with non-NULL context.

A side effect of interrupt handlers with NULL context when using armpic
is that the interrupt handler is only called from interrupt context, not
when lowering spl!


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.39 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.40
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.39	Wed Sep  1 03:08:08 2021
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Wed Sep  1 22:11:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.39 2021/09/01 03:08:08 rin Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.40 2021/09/01 22:11:35 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.39 2021/09/01 03:08:08 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.40 2021/09/01 22:11:35 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 
@@ -842,7 +842,7 @@ bcm2836mp_send_ipi(struct pic_softc *pic
 int
 bcm2836mp_ipi_handler(void *priv)
 {
-	const struct cpu_info *ci = curcpu();
+	const struct cpu_info *ci = priv;
 	const cpuid_t cpuid = ci->ci_core_id;
 	uint32_t ipimask, bit;
 
@@ -898,7 +898,7 @@ bcm2836mp_intr_init(void *priv, struct c
 
 #if defined(MULTIPROCESSOR)
 	intr_establish(BCM2836_INT_MAILBOX0_CPUN(cpuid), IPL_HIGH,
-	IST_LEVEL | IST_MPSAFE, bcm2836mp_ipi_handler, NULL);
+	IST_LEVEL | IST_MPSAFE, bcm2836mp_ipi_handler, ci);
 
 	struct bcm2836mp_interrupt *bip;
 	TAILQ_FOREACH(bip, _interrupts, bi_next) {



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

2021-09-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Sep  1 22:11:35 UTC 2021

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

Log Message:
Install IPI handler with non-NULL context.

A side effect of interrupt handlers with NULL context when using armpic
is that the interrupt handler is only called from interrupt context, not
when lowering spl!


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2021-08-31 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  1 03:08:08 UTC 2021

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

Log Message:
PR port-arm/56264

Register all PICs when bcmicu1 is attached, in order to avoid calling
pic_add() from cpu_hatch(), which blocks for aarch64 kernel on RPI3.
This prevented MP kernel to boot due to KASSERT failure as described
in the PR.

This is a kind of a workaround; the real fix should be to

(a) reorganize cpu_hatch() for aarch64 and arm:
http://mail-index.netbsd.org/port-arm/2021/06/21/msg007320.html

(b) or change MI abstraction of ``MP ready'':
http://mail-index.netbsd.org/port-arm/2021/06/22/msg007327.html

However, still, this fix does not bring about any penalty, and it is
not good to leave RPI3 broken for months...

Tested on RPI3 (aarch64 MP, armv7hf MP) as well as RPI1 (armv6hf UP).


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.38 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.39
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.38	Mon Mar  8 14:22:42 2021
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Wed Sep  1 03:08:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.38 2021/03/08 14:22:42 mlelstv Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.39 2021/09/01 03:08:08 rin Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.38 2021/03/08 14:22:42 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.39 2021/09/01 03:08:08 rin Exp $");
 
 #define _INTR_PRIVATE
 
@@ -359,6 +359,34 @@ bcm2835_icu_attach(device_t parent, devi
 
 		ifuncs = _fdt_funcs;
 
+		/*
+		 * XXX
+		 * Register all PICs here in order to avoid pic_add() from
+		 * cpu_hatch(). See port-arm/56264.
+		 */
+		CPU_INFO_ITERATOR cii;
+		struct cpu_info *ci;
+		for (CPU_INFO_FOREACH(cii, ci)) {
+			const cpuid_t cpuid = ci->ci_core_id;
+			struct pic_softc * const pic = _pic[cpuid];
+
+			KASSERT(cpuid < BCM2836_NCPUS);
+
+#if defined(MULTIPROCESSOR)
+			pic->pic_cpus = ci->ci_kcpuset;
+			/*
+			 * Append "#n" to avoid duplication of .pic_name[]
+			 * It should be a unique id for intr_get_source()
+			 */
+			char suffix[sizeof("#0")];
+			snprintf(suffix, sizeof(suffix), "#%lu", cpuid);
+			strlcat(pic->pic_name, suffix, sizeof(pic->pic_name));
+#endif
+
+			bcm2836mp_int_base[cpuid] =
+			pic_add(pic, PIC_IRQBASE_ALLOC);
+		}
+
 		bcm2836mp_intr_init(self, curcpu());
 		arm_fdt_cpu_hatch_register(self, bcm2836mp_intr_init);
 	} else {
@@ -865,24 +893,10 @@ static void
 bcm2836mp_intr_init(void *priv, struct cpu_info *ci)
 {
 	const cpuid_t cpuid = ci->ci_core_id;
-	struct pic_softc * const pic = _pic[cpuid];
 
 	KASSERT(cpuid < BCM2836_NCPUS);
 
 #if defined(MULTIPROCESSOR)
-	pic->pic_cpus = ci->ci_kcpuset;
-
-	/*
-	 * Append "#n" to avoid duplication of .pic_name[]
-	 * It should be a unique id for intr_get_source()
-	 */
-	char suffix[sizeof("#0")];
-	snprintf(suffix, sizeof(suffix), "#%lu", cpuid);
-	strlcat(pic->pic_name, suffix, sizeof(pic->pic_name));
-#endif
-	bcm2836mp_int_base[cpuid] = pic_add(pic, PIC_IRQBASE_ALLOC);
-
-#if defined(MULTIPROCESSOR)
 	intr_establish(BCM2836_INT_MAILBOX0_CPUN(cpuid), IPL_HIGH,
 	IST_LEVEL | IST_MPSAFE, bcm2836mp_ipi_handler, NULL);
 



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

2021-08-31 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  1 03:08:08 UTC 2021

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

Log Message:
PR port-arm/56264

Register all PICs when bcmicu1 is attached, in order to avoid calling
pic_add() from cpu_hatch(), which blocks for aarch64 kernel on RPI3.
This prevented MP kernel to boot due to KASSERT failure as described
in the PR.

This is a kind of a workaround; the real fix should be to

(a) reorganize cpu_hatch() for aarch64 and arm:
http://mail-index.netbsd.org/port-arm/2021/06/21/msg007320.html

(b) or change MI abstraction of ``MP ready'':
http://mail-index.netbsd.org/port-arm/2021/06/22/msg007327.html

However, still, this fix does not bring about any penalty, and it is
not good to leave RPI3 broken for months...

Tested on RPI3 (aarch64 MP, armv7hf MP) as well as RPI1 (armv6hf UP).


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2019-11-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Nov 29 17:44:27 UTC 2019

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

Log Message:
Account for the IRQ offset on the bcm2836.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2019-11-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Nov 29 17:44:27 UTC 2019

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

Log Message:
Account for the IRQ offset on the bcm2836.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.26 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.27
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.26	Thu Nov 28 15:35:51 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Fri Nov 29 17:44:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.27 2019/11/29 17:44:27 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.27 2019/11/29 17:44:27 thorpej Exp $");
 
 #define _INTR_PRIVATE
 
@@ -467,15 +467,16 @@ bcm2835_icu_fdt_establish(device_t dev, 
 	struct bcm2835icu_irq *firq;
 	struct bcm2835icu_irqhandler *firqh;
 	int iflags = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
-	int irq;
+	int irq, irqidx;
 
 	irq = bcm2835_icu_fdt_decode_irq(specifier);
 	if (irq == -1)
 		return NULL;
+	irqidx = irq - BCM2835_INT_BASE;
 
-	KASSERT(irq < BCM2835_NIRQ);
+	KASSERT(irqidx < BCM2835_NIRQ);
 
-	firq = sc->sc_irq[irq];
+	firq = sc->sc_irq[irqidx];
 	if (firq == NULL) {
 		firq = kmem_alloc(sizeof(*firq), KM_SLEEP);
 		firq->intr_sc = sc;
@@ -496,7 +497,7 @@ bcm2835_icu_fdt_establish(device_t dev, 
 			kmem_free(firq, sizeof(*firq));
 			return NULL;
 		}
-		sc->sc_irq[irq] = firq;
+		sc->sc_irq[irqidx] = firq;
 	} else {
 		if (firq->intr_arg == NULL || arg == NULL) {
 			device_printf(dev,
@@ -549,6 +550,7 @@ bcm2835_icu_fdt_disestablish(device_t de
 			continue;
 
 		KASSERT(firq->intr_refcnt > 0);
+		KASSERT(n == (firq->intr_irq - BCM2835_INT_BASE));
 
 		/* XXX see above */
 		if (firq->intr_refcnt > 1)
@@ -560,7 +562,7 @@ bcm2835_icu_fdt_disestablish(device_t de
 		TAILQ_REMOVE(>intr_handlers, firqh, ih_next);
 		kmem_free(firqh, sizeof(*firqh));
 
-		sc->sc_irq[firq->intr_irq] = NULL;
+		sc->sc_irq[n] = NULL;
 		kmem_free(firq, sizeof(*firq));
 
 		return;



Re: CVS commit: src/sys/arch/arm/broadcom

2019-11-28 Thread Jared McNeill
On Nov 27, 2019, at 9:08 PM, Jason R Thorpe wrote:
> 
> + firqh = kmem_alloc(sizeof(*firqh), KM_SLEEP);
> + firqh->ih_irq = firq;
> + firqh->ih_fn = func;
> + firqh->ih_arg = arg;
> + TAILQ_INSERT_TAIL(>intr_handlers, firqh, ih_next);
> +
> + return firqh;

I should have commented the code in gicv3 so that you would have realized it 
was “unnecessarily complicated” for a reason :)

The interrupt_distribute(9) API makes an assumption that the return value of 
anything_intr_establish can be used as input for the MD interrupt_distribute 
implementation. For arm pic, struct intrsource * made most sense. It is a bit 
of a hassle for fdtbus and really shows the need for an MI interrupt API.

So where this breaks things is if you have something in the kernel do:

  Ih = fdtbus_intr_establish(…)
  interrupt_distribute(ih, target, NULL)

Currently the only place where this can happen is arch/arm/fdt/pmu_fdt.c but 
IMHO the code is perfectly valid and could appear in other places in the future.

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

2019-11-28 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Nov 28 15:35:51 UTC 2019

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

Log Message:
Jared points out that interrupt_distribute(9) assumes that any interrupt
handle can be used as an input to the MD interrupt_distribute implementation
so we are forced to return the handle we got back from intr_establish().
Upshot is that the input to bcm2835_icu_fdt_disestablish() is ambiguous for
shared IRQs, rendering them un-disestablishable.

While here, make sure to actually bump the intr_refcnt, and add an
assertion on the value we get back from bcm2835_icu_fdt_decode_irq().


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.25 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.26
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.25	Thu Nov 28 01:08:06 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Thu Nov 28 15:35:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.25 2019/11/28 01:08:06 thorpej Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.25 2019/11/28 01:08:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $");
 
 #define _INTR_PRIVATE
 
@@ -473,6 +473,8 @@ bcm2835_icu_fdt_establish(device_t dev, 
 	if (irq == -1)
 		return NULL;
 
+	KASSERT(irq < BCM2835_NIRQ);
+
 	firq = sc->sc_irq[irq];
 	if (firq == NULL) {
 		firq = kmem_alloc(sizeof(*firq), KM_SLEEP);
@@ -517,31 +519,54 @@ bcm2835_icu_fdt_establish(device_t dev, 
 	firqh->ih_irq = firq;
 	firqh->ih_fn = func;
 	firqh->ih_arg = arg;
+
+	firq->intr_refcnt++;
 	TAILQ_INSERT_TAIL(>intr_handlers, firqh, ih_next);
 
-	return firqh;
+	/*
+	 * XXX interrupt_distribute(9) assumes that any interrupt
+	 * handle can be used as an input to the MD interrupt_distribute
+	 * implementationm, so we are forced to return the handle
+	 * we got back from intr_establish().  Upshot is that the
+	 * input to bcm2835_icu_fdt_disestablish() is ambiguous for
+	 * shared IRQs, rendering them un-disestablishable.
+	 */
+
+	return firq->intr_ih;
 }
 
 static void
 bcm2835_icu_fdt_disestablish(device_t dev, void *ih)
 {
 	struct bcm2835icu_softc * const sc = device_private(dev);
-	struct bcm2835icu_irqhandler *firqh = ih;
-	struct bcm2835icu_irq *firq = firqh->ih_irq;
+	struct bcm2835icu_irqhandler *firqh;
+	struct bcm2835icu_irq *firq;
+	u_int n;
 
-	KASSERT(firq->intr_refcnt > 0);
+	for (n = 0; n < BCM2835_NIRQ; n++) {
+		firq = sc->sc_irq[n];
+		if (firq == NULL || firq->intr_ih != ih)
+			continue;
+
+		KASSERT(firq->intr_refcnt > 0);
+
+		/* XXX see above */
+		if (firq->intr_refcnt > 1)
+			panic("%s: cannot disestablish shared irq", __func__);
 
-	/* XXX */
-	if (firq->intr_refcnt > 1)
-		panic("%s: cannot disestablish shared irq", __func__);
+		intr_disestablish(firq->intr_ih);
 
-	intr_disestablish(firq->intr_ih);
+		firqh = TAILQ_FIRST(>intr_handlers);
+		TAILQ_REMOVE(>intr_handlers, firqh, ih_next);
+		kmem_free(firqh, sizeof(*firqh));
 
-	TAILQ_REMOVE(>intr_handlers, firqh, ih_next);
-	kmem_free(firqh, sizeof(*firqh));
+		sc->sc_irq[firq->intr_irq] = NULL;
+		kmem_free(firq, sizeof(*firq));
+
+		return;
+	}
 
-	sc->sc_irq[firq->intr_irq] = NULL;
-	kmem_free(firq, sizeof(*firq));
+	panic("%s: interrupt not established", __func__);
 }
 
 static int



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

2019-11-28 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Nov 28 15:35:51 UTC 2019

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

Log Message:
Jared points out that interrupt_distribute(9) assumes that any interrupt
handle can be used as an input to the MD interrupt_distribute implementation
so we are forced to return the handle we got back from intr_establish().
Upshot is that the input to bcm2835_icu_fdt_disestablish() is ambiguous for
shared IRQs, rendering them un-disestablishable.

While here, make sure to actually bump the intr_refcnt, and add an
assertion on the value we get back from bcm2835_icu_fdt_decode_irq().


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/broadcom/bcm2835_intr.c

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



Re: CVS commit: src/sys/arch/arm/broadcom

2019-11-28 Thread Jason Thorpe


> On Nov 28, 2019, at 2:21 AM, Jared McNeill  wrote:
> 
> I should have commented the code in gicv3 so that you would have realized it 
> was “unnecessarily complicated” for a reason :)

Ok, I'll fix and add a comment.

> 
> The interrupt_distribute(9) API makes an assumption that the return value of 
> anything_intr_establish can be used as input for the MD interrupt_distribute 
> implementation. For arm pic, struct intrsource * made most sense. It is a bit 
> of a hassle for fdtbus and really shows the need for an MI interrupt API.
> 
> So where this breaks things is if you have something in the kernel do:
> 
>   Ih = fdtbus_intr_establish(…)
>   interrupt_distribute(ih, target, NULL)
> 
> Currently the only place where this can happen is arch/arm/fdt/pmu_fdt.c but 
> IMHO the code is perfectly valid and could appear in other places in the 
> future.

-- thorpej



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

2019-11-27 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Nov 28 01:08:06 UTC 2019

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

Log Message:
There are some devices on the bcm283x that share IRQs (notably, the i2c
controllers), but the generic ARM PIC code doesn't support this.  Add a
workaround inspired by the GICv3 driver (thanks Jared for pointint it out).


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2019-11-27 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Nov 28 01:08:06 UTC 2019

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

Log Message:
There are some devices on the bcm283x that share IRQs (notably, the i2c
controllers), but the generic ARM PIC code doesn't support this.  Add a
workaround inspired by the GICv3 driver (thanks Jared for pointint it out).


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.24 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.25
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.24	Wed Sep 25 16:57:10 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Thu Nov 28 01:08:06 2019
@@ -1,7 +1,7 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.24 2019/09/25 16:57:10 skrll Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.25 2019/11/28 01:08:06 thorpej Exp $	*/
 
 /*-
- * Copyright (c) 2012, 2015 The NetBSD Foundation, Inc.
+ * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.24 2019/09/25 16:57:10 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.25 2019/11/28 01:08:06 thorpej Exp $");
 
 #define _INTR_PRIVATE
 
@@ -87,6 +87,8 @@ static void *bcm2835_icu_fdt_establish(d
 static void bcm2835_icu_fdt_disestablish(device_t, void *);
 static bool bcm2835_icu_fdt_intrstr(device_t, u_int *, char *, size_t);
 
+static int bcm2835_icu_intr(void *);
+
 static int bcm2836mp_icu_fdt_decode_irq(u_int *);
 static void *bcm2836mp_icu_fdt_establish(device_t, u_int *, int, int,
 int (*)(void *), void *);
@@ -162,11 +164,35 @@ struct bcm2836mp_interrupt {
 static TAILQ_HEAD(, bcm2836mp_interrupt) bcm2836mp_interrupts =
 TAILQ_HEAD_INITIALIZER(bcm2836mp_interrupts);
 
+struct bcm2835icu_irqhandler;
+struct bcm2835icu_irq;
+struct bcm2835icu_softc;
+
+struct bcm2835icu_irqhandler {
+	struct bcm2835icu_irq	*ih_irq;
+	int			(*ih_fn)(void *);
+	void			*ih_arg;
+	TAILQ_ENTRY(bcm2835icu_irqhandler) ih_next;
+};
+
+struct bcm2835icu_irq {
+	struct bcm2835icu_softc	*intr_sc;
+	void			*intr_ih;
+	void			*intr_arg;
+	int			intr_refcnt;
+	int			intr_ipl;
+	int			intr_irq;
+	int			intr_mpsafe;
+	TAILQ_HEAD(, bcm2835icu_irqhandler) intr_handlers;
+};
+
 struct bcm2835icu_softc {
 	device_t		sc_dev;
 	bus_space_tag_t		sc_iot;
 	bus_space_handle_t	sc_ioh;
 
+	struct bcm2835icu_irq	*sc_irq[BCM2835_NIRQ];
+
 	int sc_phandle;
 };
 
@@ -437,6 +463,9 @@ static void *
 bcm2835_icu_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags,
 int (*func)(void *), void *arg)
 {
+	struct bcm2835icu_softc * const sc = device_private(dev);
+	struct bcm2835icu_irq *firq;
+	struct bcm2835icu_irqhandler *firqh;
 	int iflags = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
 	int irq;
 
@@ -444,13 +473,89 @@ bcm2835_icu_fdt_establish(device_t dev, 
 	if (irq == -1)
 		return NULL;
 
-	return intr_establish(irq, ipl, IST_LEVEL | iflags, func, arg);
+	firq = sc->sc_irq[irq];
+	if (firq == NULL) {
+		firq = kmem_alloc(sizeof(*firq), KM_SLEEP);
+		firq->intr_sc = sc;
+		firq->intr_refcnt = 0;
+		firq->intr_arg = arg;
+		firq->intr_ipl = ipl;
+		firq->intr_mpsafe = iflags;
+		firq->intr_irq = irq;
+		TAILQ_INIT(>intr_handlers);
+		if (arg == NULL) {
+			firq->intr_ih = intr_establish(irq, ipl,
+			IST_LEVEL | iflags, func, NULL);
+		} else {
+			firq->intr_ih = intr_establish(irq, ipl,
+			IST_LEVEL | iflags, bcm2835_icu_intr, firq);
+		}
+		if (firq->intr_ih == NULL) {
+			kmem_free(firq, sizeof(*firq));
+			return NULL;
+		}
+		sc->sc_irq[irq] = firq;
+	} else {
+		if (firq->intr_arg == NULL || arg == NULL) {
+			device_printf(dev,
+			"cannot share irq with NULL-arg handler\n");
+			return NULL;
+		}
+		if (firq->intr_ipl != ipl) {
+			device_printf(dev,
+			"cannot share irq with different ipl\n");
+			return NULL;
+		}
+		if (firq->intr_mpsafe != iflags) {
+			device_printf(dev,
+			"cannot share irq between mpsafe/non-mpsafe\n");
+			return NULL;
+		}
+	}
+
+	firqh = kmem_alloc(sizeof(*firqh), KM_SLEEP);
+	firqh->ih_irq = firq;
+	firqh->ih_fn = func;
+	firqh->ih_arg = arg;
+	TAILQ_INSERT_TAIL(>intr_handlers, firqh, ih_next);
+
+	return firqh;
 }
 
 static void
 bcm2835_icu_fdt_disestablish(device_t dev, void *ih)
 {
-	intr_disestablish(ih);
+	struct bcm2835icu_softc * const sc = device_private(dev);
+	struct bcm2835icu_irqhandler *firqh = ih;
+	struct bcm2835icu_irq *firq = firqh->ih_irq;
+
+	KASSERT(firq->intr_refcnt > 0);
+
+	/* XXX */
+	if (firq->intr_refcnt > 1)
+		panic("%s: cannot disestablish shared irq", __func__);
+
+	intr_disestablish(firq->intr_ih);
+
+	TAILQ_REMOVE(>intr_handlers, firqh, ih_next);
+	

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

2019-10-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct 12 09:46:18 UTC 2019

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

Log Message:
off by one


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 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.15 src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.16
--- src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.15	Thu Oct  3 11:24:27 2019
+++ src/sys/arch/arm/broadcom/bcm2835_gpio.c	Sat Oct 12 09:46:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_gpio.c,v 1.15 2019/10/03 11:24:27 mlelstv Exp $	*/
+/*	$NetBSD: bcm2835_gpio.c,v 1.16 2019/10/12 09:46:18 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2013, 2014, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.15 2019/10/03 11:24:27 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.16 2019/10/12 09:46:18 mlelstv Exp $");
 
 /*
  * Driver for BCM2835 GPIO
@@ -221,7 +221,7 @@ bcm283x_pinctrl_set_config(device_t dev,
 	for (int i = 0; i < npins; i++) {
 		const u_int pin = be32toh(pins[i]);
 
-		if (pin > sc->sc_maxpins)
+		if (pin >= sc->sc_maxpins)
 			continue;
 		if (pull) {
 			const int value = be32toh(pull[npull == 1 ? 0 : i]);



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

2019-10-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct 12 09:46:18 UTC 2019

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

Log Message:
off by one


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 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.



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

2019-10-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Oct  3 11:24:27 UTC 2019

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

Log Message:
remove debug printfs, add more compat strings.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.



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

2019-10-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Oct  3 11:24:27 UTC 2019

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

Log Message:
remove debug printfs, add more compat strings.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.14 src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.15
--- src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.14	Tue Oct  1 23:32:52 2019
+++ src/sys/arch/arm/broadcom/bcm2835_gpio.c	Thu Oct  3 11:24:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_gpio.c,v 1.14 2019/10/01 23:32:52 jmcneill Exp $	*/
+/*	$NetBSD: bcm2835_gpio.c,v 1.15 2019/10/03 11:24:27 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2013, 2014, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.14 2019/10/01 23:32:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.15 2019/10/03 11:24:27 mlelstv Exp $");
 
 /*
  * Driver for BCM2835 GPIO
@@ -241,7 +241,12 @@ bcm283x_pinctrl_set_config(device_t dev,
 static int
 bcmgpio_match(device_t parent, cfdata_t cf, void *aux)
 {
-	const char * const compatible[] = { "brcm,bcm2835-gpio", NULL };
+	const char * const compatible[] = {
+		"brcm,bcm2835-gpio",
+		"brcm,bcm2838-gpio",
+		"brcm,bcm2711-gpio",
+		NULL
+	};
 	struct fdt_attach_args * const faa = aux;
 
 	return of_match_compatible(faa->faa_phandle, compatible);
@@ -815,7 +820,6 @@ bcm283x_pin_setpull(const struct bcmgpio
 		mask = 1 << (pin % BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
 		regid = (pin / BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
 
-printf("2835: pin=%u, pud=%u, regid=%u, mask=%08x\n",pin,pud,regid,mask);
 		bus_space_write_4(sc->sc_iot, sc->sc_ioh,
 		BCM2835_GPIO_GPPUD, pud);
 		delay(1);
@@ -841,7 +845,6 @@ printf("2835: pin=%u, pud=%u, regid=%u, 
 			pud = BCM2838_GPIO_GPPUD_PULLOFF;
 			break;
 		}
-printf("2838: pin=%u, pud=%u, regid=%u, mask=%08x\n",pin,pud,regid,mask);
 
 		reg = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
 		BCM2838_GPIO_GPPUPPDN(regid));



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

2019-09-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Sep 28 07:39:30 UTC 2019

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

Log Message:
Fix build on SOC_BCM2835 kernels


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/broadcom/bcm283x_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/broadcom

2019-09-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Sep 28 07:39:30 UTC 2019

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

Log Message:
Fix build on SOC_BCM2835 kernels


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/broadcom/bcm283x_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/broadcom/bcm283x_platform.c
diff -u src/sys/arch/arm/broadcom/bcm283x_platform.c:1.25 src/sys/arch/arm/broadcom/bcm283x_platform.c:1.26
--- src/sys/arch/arm/broadcom/bcm283x_platform.c:1.25	Fri Sep 27 12:58:54 2019
+++ src/sys/arch/arm/broadcom/bcm283x_platform.c	Sat Sep 28 07:39:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm283x_platform.c,v 1.25 2019/09/27 12:58:54 skrll Exp $	*/
+/*	$NetBSD: bcm283x_platform.c,v 1.26 2019/09/28 07:39:30 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.25 2019/09/27 12:58:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.26 2019/09/28 07:39:30 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_bcm283x.h"
@@ -322,7 +322,6 @@ bcm2836_platform_devmap(void)
 
 	return devmap;
 }
-#endif
 
 static const struct pmap_devmap *
 bcm2838_platform_devmap(void)
@@ -342,6 +341,8 @@ bcm2838_platform_devmap(void)
 
 	return devmap;
 }
+#endif
+
 /*
  * Macros to translate between physical and virtual for a subset of the
  * kernel address space.  *Not* for general use.



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

2019-09-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 28 07:24:52 UTC 2019

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

Log Message:
Handle BCM2838 (bcm2711) SoC pecularities.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/broadcom/bcm2835_gpio.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/broadcom/bcm2835_gpioreg.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/broadcom

2019-09-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 28 07:24:52 UTC 2019

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

Log Message:
Handle BCM2838 (bcm2711) SoC pecularities.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/broadcom/bcm2835_gpio.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/broadcom/bcm2835_gpioreg.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/broadcom/bcm2835_gpio.c
diff -u src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.12 src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.13
--- src/sys/arch/arm/broadcom/bcm2835_gpio.c:1.12	Fri May 10 08:28:50 2019
+++ src/sys/arch/arm/broadcom/bcm2835_gpio.c	Sat Sep 28 07:24:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_gpio.c,v 1.12 2019/05/10 08:28:50 skrll Exp $	*/
+/*	$NetBSD: bcm2835_gpio.c,v 1.13 2019/09/28 07:24:52 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2013, 2014, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.12 2019/05/10 08:28:50 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.13 2019/09/28 07:24:52 mlelstv Exp $");
 
 /*
  * Driver for BCM2835 GPIO
@@ -65,7 +65,9 @@ int bcm2835gpiodebug = 3;
 #define DPRINTF(l, x)
 #endif
 
-#define	BCMGPIO_MAXPINS	54
+#define BCM2835_GPIO_MAXPINS 54
+#define BCM2838_GPIO_MAXPINS 58
+#define	BCMGPIO_MAXPINS	BCM2838_GPIO_MAXPINS
 
 struct bcmgpio_eint {
 	 int			(*eint_func)(void *);
@@ -101,6 +103,9 @@ struct bcmgpio_softc {
 
 	/* For interrupt support. */
 	struct bcmgpio_bank	sc_banks[BCMGPIO_NBANKS];
+
+	bool			sc_is2835;	/* for pullup on 2711 */
+	u_int			sc_maxpins;
 };
 
 struct bcmgpio_pin {
@@ -216,7 +221,7 @@ bcm283x_pinctrl_set_config(device_t dev,
 	for (int i = 0; i < npins; i++) {
 		const u_int pin = be32toh(pins[i]);
 
-		if (pin > BCMGPIO_MAXPINS)
+		if (pin > sc->sc_maxpins)
 			continue;
 		if (pull) {
 			const int value = be32toh(pull[npull == 1 ? 0 : i]);
@@ -254,6 +259,7 @@ bcmgpio_attach(device_t parent, device_t
 	int error;
 	int pin;
 	int bank;
+	uint32_t reg;
 
 	const int phandle = faa->faa_phandle;
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
@@ -263,19 +269,25 @@ bcmgpio_attach(device_t parent, device_t
 
 	sc->sc_dev = self;
 
-	aprint_naive("\n");
-	aprint_normal(": GPIO controller\n");
-
 	sc->sc_iot = faa->faa_bst;
 	error = bus_space_map(sc->sc_iot, addr, size, 0, >sc_ioh);
 	if (error) {
-		aprint_error_dev(self, "couldn't map registers\n");
+		aprint_error_dev(self, ": couldn't map registers\n");
 		return;
 	}
 
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM);
 
-	for (pin = 0; pin < BCMGPIO_MAXPINS; pin++) {
+	/* BCM2835, BCM2836, BCM2837 return 'gpio' in this unused register */
+	reg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, BCM2838_GPIO_GPPUPPDN(3));
+	sc->sc_is2835 = reg == 0x6770696f;
+	sc->sc_maxpins = sc->sc_is2835 ? BCM2835_GPIO_MAXPINS
+	   : BCM2838_GPIO_MAXPINS;
+
+	aprint_naive("\n");
+	aprint_normal(": GPIO controller %s\n", sc->sc_is2835 ? "2835" : "2838");
+
+	for (pin = 0; pin < sc->sc_maxpins; pin++) {
 		sc->sc_gpio_pins[pin].pin_num = pin;
 		/*
 		 * find out pins still available for GPIO
@@ -329,13 +341,13 @@ bcmgpio_attach(device_t parent, device_t
 			aprint_normal_dev(self,
 			"pins %d..%d interrupting on %s\n",
 			bank * 32,
-			MIN((bank * 32) + 31, BCMGPIO_MAXPINS),
+			MIN((bank * 32) + 31, sc->sc_maxpins),
 			intrstr);
 		} else {
 			aprint_error_dev(self,
 			"failed to establish interrupt for pins %d..%d\n",
 			bank * 32,
-			MIN((bank * 32) + 31, BCMGPIO_MAXPINS));
+			MIN((bank * 32) + 31, sc->sc_maxpins));
 		}
 	}
 
@@ -364,7 +376,7 @@ bcmgpio_attach(device_t parent, device_t
 
 	gba.gba_gc = >sc_gpio_gc;
 	gba.gba_pins = >sc_gpio_pins[0];
-	gba.gba_npins = BCMGPIO_MAXPINS;
+	gba.gba_npins = sc->sc_maxpins;
 	(void) config_found_ia(self, "gpiobus", , gpiobus_print);
 }
 
@@ -657,8 +669,9 @@ bcmgpio_gpio_intr_disestablish(void *vsc
 static bool
 bcmgpio_gpio_intrstr(void *vsc, int pin, int irqmode, char *buf, size_t buflen)
 {
+	struct bcmgpio_softc * const sc = vsc;
 
-	if (pin < 0 || pin >= BCMGPIO_MAXPINS)
+	if (pin < 0 || pin >= sc->sc_maxpins)
 		return (false);
 
 	snprintf(buf, buflen, "GPIO %d", pin);
@@ -797,15 +810,48 @@ bcm283x_pin_setpull(const struct bcmgpio
 
 	KASSERT(mutex_owned(>sc_lock));
 
-	const u_int mask = 1 << (pin % BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
-	const u_int regid = (pin / BCM2835_GPIO_GPPUD_PINS_PER_REGISTER);
+	u_int mask, regid;
+	uint32_t reg;
 
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_GPIO_GPPUD, pud);
-	delay(1);
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_GPIO_GPPUDCLK(regid), mask);
-	delay(1);
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_GPIO_GPPUD, 0);
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_GPIO_GPPUDCLK(regid), 0);
+	

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

2019-09-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Sep 27 12:58:55 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm283x_platform.c bcm283x_platform.h

Log Message:
BCM2838 (RPI4) support.

Based on a diff from mlelstv


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/broadcom/bcm283x_platform.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/broadcom/bcm283x_platform.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/broadcom/bcm283x_platform.c
diff -u src/sys/arch/arm/broadcom/bcm283x_platform.c:1.24 src/sys/arch/arm/broadcom/bcm283x_platform.c:1.25
--- src/sys/arch/arm/broadcom/bcm283x_platform.c:1.24	Wed Sep 25 18:01:03 2019
+++ src/sys/arch/arm/broadcom/bcm283x_platform.c	Fri Sep 27 12:58:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm283x_platform.c,v 1.24 2019/09/25 18:01:03 skrll Exp $	*/
+/*	$NetBSD: bcm283x_platform.c,v 1.25 2019/09/27 12:58:54 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.24 2019/09/25 18:01:03 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.25 2019/09/27 12:58:54 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_bcm283x.h"
@@ -113,6 +113,7 @@ __KERNEL_RCSID(0, "$NetBSD: bcm283x_plat
 void bcm2835_platform_early_putchar(char c);
 void bcm2836_platform_early_putchar(char c);
 void bcm2837_platform_early_putchar(char c);
+void bcm2838_platform_early_putchar(char c);
 
 extern void bcmgenfb_set_console_dev(device_t dev);
 void bcmgenfb_set_ioctl(int(*)(void *, void *, u_long, void *, int, struct lwp *));
@@ -129,14 +130,19 @@ bs_protos(bcm2835);
 bs_protos(bcm2835_a4x);
 bs_protos(bcm2836);
 bs_protos(bcm2836_a4x);
+bs_protos(bcm2838);
+bs_protos(bcm2838_a4x);
 
 struct bus_space bcm2835_bs_tag;
 struct bus_space bcm2835_a4x_bs_tag;
 struct bus_space bcm2836_bs_tag;
 struct bus_space bcm2836_a4x_bs_tag;
+struct bus_space bcm2838_bs_tag;
+struct bus_space bcm2838_a4x_bs_tag;
 
 static paddr_t bcm2835_bus_to_phys(bus_addr_t);
 static paddr_t bcm2836_bus_to_phys(bus_addr_t);
+static paddr_t bcm2838_bus_to_phys(bus_addr_t);
 
 #ifdef VERBOSE_INIT_ARM
 #define VPRINTF(...)	printf(__VA_ARGS__)
@@ -172,6 +178,22 @@ bcm2836_bus_to_phys(bus_addr_t ba)
 	return ba & ~BCM2835_BUSADDR_CACHE_MASK;
 }
 
+static paddr_t
+bcm2838_bus_to_phys(bus_addr_t ba)
+{
+
+	/* Attempt to find the PA device mapping */
+	if (ba >= BCM283X_PERIPHERALS_BASE_BUS &&
+	ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE)
+		return BCM2838_PERIPHERALS_BUS_TO_PHYS(ba);
+
+	if (ba >= BCM2838_ARM_LOCAL_BASE &&
+	ba < BCM2838_ARM_LOCAL_BASE + BCM2838_ARM_LOCAL_SIZE)
+		return ba;
+
+	return ba & ~BCM2835_BUSADDR_CACHE_MASK;
+}
+
 int
 bcm2835_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag,
 bus_space_handle_t *bshp)
@@ -220,6 +242,30 @@ bcm2836_a4x_bs_mmap(void *t, bus_addr_t 
 	return bcm2836_bs_mmap(t, ba, 4 * offset, prot, flags);
 }
 
+int
+bcm2838_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag,
+bus_space_handle_t *bshp)
+{
+	const paddr_t pa = bcm2838_bus_to_phys(ba);
+
+	return bus_space_map(_generic_bs_tag, pa, size, flag, bshp);
+}
+
+paddr_t
+bcm2838_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
+{
+	const paddr_t pa = bcm2838_bus_to_phys(ba);
+
+	return bus_space_mmap(_generic_bs_tag, pa, offset, prot, flags);
+}
+
+paddr_t
+bcm2838_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
+{
+
+	return bcm2838_bs_mmap(t, ba, 4 * offset, prot, flags);
+}
+
 struct arm32_dma_range bcm2835_dma_ranges[] = {
 	[0] = {
 		.dr_sysbase = 0,
@@ -234,6 +280,13 @@ struct arm32_dma_range bcm2836_dma_range
 	}
 };
 
+struct arm32_dma_range bcm2838_dma_ranges[] = {
+	[0] = {
+		.dr_sysbase = 0,
+		.dr_busbase = BCM2835_BUSADDR_CACHE_DIRECT,
+	}
+};
+
 
 #if defined(SOC_BCM2835)
 static const struct pmap_devmap *
@@ -257,7 +310,6 @@ bcm2836_platform_devmap(void)
 	static const struct pmap_devmap devmap[] = {
 		DEVMAP_ENTRY(BCM2836_PERIPHERALS_VBASE, BCM2836_PERIPHERALS_BASE,
 		BCM283X_PERIPHERALS_SIZE),	/* 16Mb */
-
 		DEVMAP_ENTRY(BCM2836_ARM_LOCAL_VBASE, BCM2836_ARM_LOCAL_BASE,
 		BCM2836_ARM_LOCAL_SIZE),
 #if defined(MULTIPROCESSOR) && defined(__aarch64__)
@@ -271,6 +323,25 @@ bcm2836_platform_devmap(void)
 	return devmap;
 }
 #endif
+
+static const struct pmap_devmap *
+bcm2838_platform_devmap(void)
+{
+	static const struct pmap_devmap devmap[] = {
+		DEVMAP_ENTRY(BCM2838_PERIPHERALS_VBASE, BCM2838_PERIPHERALS_BASE,
+		BCM283X_PERIPHERALS_SIZE),	/* 16Mb */
+		DEVMAP_ENTRY(BCM2838_ARM_LOCAL_VBASE, BCM2838_ARM_LOCAL_BASE,
+		BCM2838_ARM_LOCAL_SIZE),
+#if defined(MULTIPROCESSOR) && defined(__aarch64__)
+		/* for fdt cpu spin-table */
+		DEVMAP_ENTRY(BCM2836_ARM_SMP_VBASE, BCM2836_ARM_SMP_BASE,
+		BCM2836_ARM_SMP_SIZE),
+#endif
+		

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

2019-09-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Sep 27 12:58:55 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm283x_platform.c bcm283x_platform.h

Log Message:
BCM2838 (RPI4) support.

Based on a diff from mlelstv


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/broadcom/bcm283x_platform.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/broadcom/bcm283x_platform.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/broadcom

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 18:05:39 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835reg.h

Log Message:
Add BCM2838_{PERIPHERALS,ARM_LOCAL}_BASE and support macros


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/broadcom/bcm2835reg.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/broadcom/bcm2835reg.h
diff -u src/sys/arch/arm/broadcom/bcm2835reg.h:1.24 src/sys/arch/arm/broadcom/bcm2835reg.h:1.25
--- src/sys/arch/arm/broadcom/bcm2835reg.h:1.24	Wed Sep 25 18:01:03 2019
+++ src/sys/arch/arm/broadcom/bcm2835reg.h	Wed Sep 25 18:05:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835reg.h,v 1.24 2019/09/25 18:01:03 skrll Exp $	*/
+/*	$NetBSD: bcm2835reg.h,v 1.25 2019/09/25 18:05:39 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -44,11 +44,17 @@
 #error Must define SOC_BCM2835 or SOC_BCM2836, and not both
 #endif
 
+#define	BCM2838_PERIPHERALS_BASE	0xfe00
 #define	BCM2836_PERIPHERALS_BASE	0x3f00
 #define	BCM2835_PERIPHERALS_BASE	0x2000
 #define	BCM283X_PERIPHERALS_SIZE	0x0100	/* 16MBytes */
 #define	BCM283X_PERIPHERALS_BASE_BUS	0x7e00
 
+#define	BCM2838_PERIPHERALS_PHYS_TO_BUS(a) \
+((a) - BCM2838_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS)
+#define	BCM2838_PERIPHERALS_BUS_TO_PHYS(a) \
+((a) - BCM283X_PERIPHERALS_BASE_BUS + BCM2838_PERIPHERALS_BASE)
+
 #define	BCM2836_PERIPHERALS_PHYS_TO_BUS(a) \
 ((a) - BCM2836_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS)
 #define	BCM2836_PERIPHERALS_BUS_TO_PHYS(a) \
@@ -206,6 +212,9 @@
 
 #define	BCM2835_UART0_CLK		300
 
+#define	BCM2838_ARM_LOCAL_BASE		0xff80
+#define	BCM2838_ARM_LOCAL_SIZE		0x0010	/* 1MByte */
+
 #define	BCM2836_ARM_LOCAL_BASE		0x4000
 #define	BCM2836_ARM_LOCAL_SIZE		0x1000	/* 4KBytes */
 



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

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 18:05:39 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835reg.h

Log Message:
Add BCM2838_{PERIPHERALS,ARM_LOCAL}_BASE and support macros


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/broadcom/bcm2835reg.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/broadcom

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 18:01:03 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835reg.h bcm283x_platform.c

Log Message:
s/2835/283X/ in BCM2835_PERIPHERALS_BASE_BUS and BCM2835_PERIPHERALS_SIZE
to show they cover all of 283[5678]

NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/broadcom/bcm2835reg.h \
src/sys/arch/arm/broadcom/bcm283x_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/broadcom/bcm2835reg.h
diff -u src/sys/arch/arm/broadcom/bcm2835reg.h:1.23 src/sys/arch/arm/broadcom/bcm2835reg.h:1.24
--- src/sys/arch/arm/broadcom/bcm2835reg.h:1.23	Mon Sep 10 11:05:12 2018
+++ src/sys/arch/arm/broadcom/bcm2835reg.h	Wed Sep 25 18:01:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835reg.h,v 1.23 2018/09/10 11:05:12 ryo Exp $	*/
+/*	$NetBSD: bcm2835reg.h,v 1.24 2019/09/25 18:01:03 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -46,40 +46,40 @@
 
 #define	BCM2836_PERIPHERALS_BASE	0x3f00
 #define	BCM2835_PERIPHERALS_BASE	0x2000
-#define	BCM2835_PERIPHERALS_SIZE	0x0100	/* 16MBytes */
-#define	BCM2835_PERIPHERALS_BASE_BUS	0x7e00
+#define	BCM283X_PERIPHERALS_SIZE	0x0100	/* 16MBytes */
+#define	BCM283X_PERIPHERALS_BASE_BUS	0x7e00
 
 #define	BCM2836_PERIPHERALS_PHYS_TO_BUS(a) \
-((a) - BCM2836_PERIPHERALS_BASE + BCM2835_PERIPHERALS_BASE_BUS)
+((a) - BCM2836_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS)
 #define	BCM2836_PERIPHERALS_BUS_TO_PHYS(a) \
-((a) - BCM2835_PERIPHERALS_BASE_BUS + BCM2836_PERIPHERALS_BASE)
+((a) - BCM283X_PERIPHERALS_BASE_BUS + BCM2836_PERIPHERALS_BASE)
 
 #define	BCM2835_PERIPHERALS_PHYS_TO_BUS(a) \
-((a) - BCM2835_PERIPHERALS_BASE + BCM2835_PERIPHERALS_BASE_BUS)
+((a) - BCM2835_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS)
 #define	BCM2835_PERIPHERALS_BUS_TO_PHYS(a) \
-((a) - BCM2835_PERIPHERALS_BASE_BUS + BCM2835_PERIPHERALS_BASE)
+((a) - BCM283X_PERIPHERALS_BASE_BUS + BCM2835_PERIPHERALS_BASE)
 
-#define	BCM2835_STIMER_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x3000)
-#define	BCM2835_DMA0_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x7000)
-#define	BCM2835_ARM_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0xB000)
-#define	BCM2835_PM_BASE		(BCM2835_PERIPHERALS_BASE_BUS + 0x0010)
-#define	BCM2835_CM_BASE  	(BCM2835_PERIPHERALS_BASE_BUS + 0x00101000)
-#define	BCM2835_RNG_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00104000)
-#define	BCM2835_GPIO_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x0020)
-#define	BCM2835_UART0_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00201000)
-#define	BCM2835_SDHOST_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00202000)
-#define	BCM2835_PCM_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00203000)
-#define	BCM2835_SPI0_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00204000)
-#define	BCM2835_BSC0_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00205000)
-#define	BCM2835_PWM_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x0020C000)
-#define	BCM2835_BSCSPISLV_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00214000)
-#define	BCM2835_AUX_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00215000)
-#define	BCM2835_AUX_UART_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00215040)
-#define	BCM2835_EMMC_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x0030)
-#define	BCM2835_BSC1_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00804000)
-#define	BCM2835_BSC2_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00805000)
-#define	BCM2835_USB_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x0098)
-#define	BCM2835_DMA15_BASE	(BCM2835_PERIPHERALS_BASE_BUS + 0x00E05000)
+#define	BCM2835_STIMER_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x3000)
+#define	BCM2835_DMA0_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x7000)
+#define	BCM2835_ARM_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0xB000)
+#define	BCM2835_PM_BASE		(BCM283X_PERIPHERALS_BASE_BUS + 0x0010)
+#define	BCM2835_CM_BASE  	(BCM283X_PERIPHERALS_BASE_BUS + 0x00101000)
+#define	BCM2835_RNG_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00104000)
+#define	BCM2835_GPIO_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x0020)
+#define	BCM2835_UART0_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00201000)
+#define	BCM2835_SDHOST_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00202000)
+#define	BCM2835_PCM_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00203000)
+#define	BCM2835_SPI0_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00204000)
+#define	BCM2835_BSC0_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00205000)
+#define	BCM2835_PWM_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x0020C000)
+#define	BCM2835_BSCSPISLV_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00214000)
+#define	BCM2835_AUX_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00215000)
+#define	BCM2835_AUX_UART_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00215040)
+#define	BCM2835_EMMC_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x0030)
+#define	BCM2835_BSC1_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 0x00804000)
+#define	BCM2835_BSC2_BASE	(BCM283X_PERIPHERALS_BASE_BUS + 

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

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 18:01:03 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835reg.h bcm283x_platform.c

Log Message:
s/2835/283X/ in BCM2835_PERIPHERALS_BASE_BUS and BCM2835_PERIPHERALS_SIZE
to show they cover all of 283[5678]

NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/broadcom/bcm2835reg.h \
src/sys/arch/arm/broadcom/bcm283x_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/broadcom

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 16:57:11 UTC 2019

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

Log Message:
Sprinkle KASSERTs


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 16:57:11 UTC 2019

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

Log Message:
Sprinkle KASSERTs


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.23 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.24
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.23	Wed Sep 25 16:50:28 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Wed Sep 25 16:57:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.23 2019/09/25 16:50:28 skrll Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.24 2019/09/25 16:57:10 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.23 2019/09/25 16:50:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.24 2019/09/25 16:57:10 skrll Exp $");
 
 #define _INTR_PRIVATE
 
@@ -309,6 +309,8 @@ bcm2835_irq_handler(void *frame)
 	const uint32_t oldipl_mask = __BIT(oldipl);
 	int ipl_mask = 0;
 
+	KASSERT(cpuid < BCM2836_NCPUS);
+
 	ci->ci_data.cpu_nintr++;
 
 	bcm2835_barrier();
@@ -479,6 +481,7 @@ bcm2836mp_pic_unblock_irqs(struct pic_so
 	const bus_space_handle_t ioh = bcml1icu_sc->sc_ioh;
 	const cpuid_t cpuid = pic - _pic[0];
 
+	KASSERT(cpuid < BCM2836_NCPUS);
 	KASSERT(irqbase == 0);
 
 	if (irq_mask & BCM2836MP_TIMER_IRQS) {
@@ -525,6 +528,7 @@ bcm2836mp_pic_block_irqs(struct pic_soft
 	const bus_space_handle_t ioh = bcml1icu_sc->sc_ioh;
 	const cpuid_t cpuid = pic - _pic[0];
 
+	KASSERT(cpuid < BCM2836_NCPUS);
 	KASSERT(irqbase == 0);
 
 	if (irq_mask & BCM2836MP_TIMER_IRQS) {
@@ -562,6 +566,7 @@ bcm2836mp_pic_find_pending_irqs(struct p
 	uint32_t lpending;
 	int ipl = 0;
 
+	KASSERT(cpuid < BCM2836_NCPUS);
 	KASSERT(pic == _pic[cpuid]);
 
 	bcm2835_barrier();
@@ -598,10 +603,13 @@ bcm2836mp_pic_source_name(struct pic_sof
 #if defined(MULTIPROCESSOR)
 static void bcm2836mp_cpu_init(struct pic_softc *pic, struct cpu_info *ci)
 {
+	const cpuid_t cpuid = ci->ci_core_id;
+
+	KASSERT(cpuid < BCM2836_NCPUS);
 
 	/* Enable IRQ and not FIQ */
 	bus_space_write_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
-	BCM2836_LOCAL_MAILBOX_IRQ_CONTROLN(ci->ci_core_id), 1);
+	BCM2836_LOCAL_MAILBOX_IRQ_CONTROLN(cpuid), 1);
 }
 
 static void
@@ -612,6 +620,7 @@ bcm2836mp_send_ipi(struct pic_softc *pic
 	KASSERT(pic->pic_cpus != NULL);
 
 	const cpuid_t cpuid = pic - _pic[0];
+	KASSERT(cpuid < BCM2836_NCPUS);
 
 	bus_space_write_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
 	BCM2836_LOCAL_MAILBOX0_SETN(cpuid), __BIT(ipi));
@@ -624,6 +633,8 @@ bcm2836mp_ipi_handler(void *priv)
 	const cpuid_t cpuid = ci->ci_core_id;
 	uint32_t ipimask, bit;
 
+	KASSERT(cpuid < BCM2836_NCPUS);
+
 	ipimask = bus_space_read_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
 	BCM2836_LOCAL_MAILBOX0_CLRN(cpuid));
 	bus_space_write_4(bcml1icu_sc->sc_iot, bcml1icu_sc->sc_ioh,
@@ -671,6 +682,8 @@ bcm2836mp_intr_init(void *priv, struct c
 	const cpuid_t cpuid = ci->ci_core_id;
 	struct pic_softc * const pic = _pic[cpuid];
 
+	KASSERT(cpuid < BCM2836_NCPUS);
+
 #if defined(MULTIPROCESSOR)
 	pic->pic_cpus = ci->ci_kcpuset;
 



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

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 16:50:28 UTC 2019

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

Log Message:
Sprinkle static


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 16:50:28 UTC 2019

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

Log Message:
Sprinkle static


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.22 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.23
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.22	Wed Sep 25 16:49:37 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Wed Sep 25 16:50:28 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.22 2019/09/25 16:49:37 skrll Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.23 2019/09/25 16:50:28 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.22 2019/09/25 16:49:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.23 2019/09/25 16:50:28 skrll Exp $");
 
 #define _INTR_PRIVATE
 
@@ -170,8 +170,8 @@ struct bcm2835icu_softc {
 	int sc_phandle;
 };
 
-struct bcm2835icu_softc *bcml1icu_sc;
-struct bcm2835icu_softc *bcmicu_sc;
+static struct bcm2835icu_softc *bcml1icu_sc;
+static struct bcm2835icu_softc *bcmicu_sc;
 
 #define read_bcm2835reg(o)	\
 	bus_space_read_4(bcmicu_sc->sc_iot, bcmicu_sc->sc_ioh, (o))



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

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 16:49:37 UTC 2019

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 16:49:37 UTC 2019

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.21 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.22
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.21	Wed Sep 25 16:48:06 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Wed Sep 25 16:49:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.21 2019/09/25 16:48:06 skrll Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.22 2019/09/25 16:49:37 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.21 2019/09/25 16:48:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.22 2019/09/25 16:49:37 skrll Exp $");
 
 #define _INTR_PRIVATE
 
@@ -705,6 +705,7 @@ bcm2836mp_intr_init(void *priv, struct c
 static int
 bcm2836mp_icu_fdt_decode_irq(u_int *specifier)
 {
+
 	if (!specifier)
 		return -1;
 	return be32toh(specifier[0]);



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

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 16:48:06 UTC 2019

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

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/broadcom/bcm2835_intr.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/broadcom

2019-09-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Sep 25 16:48:06 UTC 2019

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

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/broadcom/bcm2835_intr.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_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.20 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.21
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.20	Wed Mar 27 05:47:50 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Wed Sep 25 16:48:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.20 2019/03/27 05:47:50 ryo Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.21 2019/09/25 16:48:06 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.20 2019/03/27 05:47:50 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.21 2019/09/25 16:48:06 skrll Exp $");
 
 #define _INTR_PRIVATE
 
@@ -547,7 +547,7 @@ bcm2836mp_pic_block_irqs(struct pic_soft
 	}
 	if (irq_mask & BCM2836MP_PMU_IRQ) {
 		bus_space_write_4(iot, ioh, BCM2836_LOCAL_PM_ROUTING_CLR,
-		 __BIT(cpuid));
+		__BIT(cpuid));
 	}
 
 	bcm2835_barrier();



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

2019-09-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Sep  4 05:10:38 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: files.bcm2835

Log Message:
RNG200 attachment


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/arm/broadcom/files.bcm2835

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/broadcom

2019-09-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Sep  4 05:10:38 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: files.bcm2835

Log Message:
RNG200 attachment


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/arm/broadcom/files.bcm2835

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/files.bcm2835
diff -u src/sys/arch/arm/broadcom/files.bcm2835:1.34 src/sys/arch/arm/broadcom/files.bcm2835:1.35
--- src/sys/arch/arm/broadcom/files.bcm2835:1.34	Sat Jun 22 07:58:55 2019
+++ src/sys/arch/arm/broadcom/files.bcm2835	Wed Sep  4 05:10:38 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.bcm2835,v 1.34 2019/06/22 07:58:55 skrll Exp $
+#	$NetBSD: files.bcm2835,v 1.35 2019/09/04 05:10:38 mlelstv Exp $
 #
 # Configuration info for Broadcom BCM2835 ARM Peripherals
 #
@@ -34,6 +34,12 @@ device	bcmrng
 attach bcmrng at fdt with bcmrng_fdt
 file	arch/arm/broadcom/bcm2835_rng.c		bcmrng
 
+# Random number generator (BCM2835_RNG_BASE (!))
+device	bcm2838rng
+attach bcm2838rng at fdt with bcm2838rng_fdt
+file	arch/arm/broadcom/bcm2838_rng.c		bcm2838rng
+file	dev/ic/rng200.cbcm2838rng
+
 # AUX
 device	bcmaux
 attach	bcmaux at fdt with bcmaux_fdt



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

2019-09-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 17:27:22 UTC 2019

Added Files:
src/sys/arch/arm/broadcom: bcm2838_rng.c

Log Message:
Attachment for RNG200


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/broadcom/bcm2838_rng.c

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/broadcom/bcm2838_rng.c
diff -u /dev/null src/sys/arch/arm/broadcom/bcm2838_rng.c:1.1
--- /dev/null	Sun Sep  1 17:27:22 2019
+++ src/sys/arch/arm/broadcom/bcm2838_rng.c	Sun Sep  1 17:27:22 2019
@@ -0,0 +1,92 @@
+/*	$NetBSD: bcm2838_rng.c,v 1.1 2019/09/01 17:27:22 mlelstv Exp $ */
+
+/*-
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared D. McNeill
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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: bcm2838_rng.c,v 1.1 2019/09/01 17:27:22 mlelstv Exp $");
+
+#include 
+#include 
+
+#include 
+#include 
+
+struct bcm2838rng_softc {
+	device_t		sc_dev;
+	struct rng200_softc	sc_rng200;
+};
+
+static int bcm2838rng_match(device_t, cfdata_t, void *);
+static void bcm2838rng_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(bcm2838rng_fdt, sizeof(struct bcm2838rng_softc),
+bcm2838rng_match, bcm2838rng_attach, NULL, NULL);
+
+/* ARGSUSED */
+static int
+bcm2838rng_match(device_t parent, cfdata_t match, void *aux)
+{
+	const char * const compatible[] = { "brcm,bcm2838-rng200", NULL };
+	struct fdt_attach_args * const faa = aux;
+
+	return of_match_compatible(faa->faa_phandle, compatible);
+}
+
+static void
+bcm2838rng_attach(device_t parent, device_t self, void *aux)
+{
+	struct bcm2838rng_softc *sc = device_private(self);
+	struct fdt_attach_args * const faa = aux;
+	bus_addr_t addr;
+	bus_size_t size;
+	bus_space_handle_t bsh;
+	int error;
+
+	sc->sc_dev = self;
+
+	error = fdtbus_get_reg(faa->faa_phandle, 0, , );
+	if (error) {
+		aprint_error_dev(sc->sc_dev, ": couldn't get registers\n");
+		return;
+	}
+
+	if (bus_space_map(faa->faa_bst, addr, size, 0, )) {
+		aprint_error_dev(sc->sc_dev, ": unable to map device\n");
+		return;
+	}
+
+	aprint_naive("\n");
+	aprint_normal(": Hardware RNG\n");
+
+	sc->sc_rng200.sc_bst = faa->faa_bst;
+	sc->sc_rng200.sc_bsh = bsh;
+	sc->sc_rng200.sc_name = device_xname(sc->sc_dev);
+	rng200_attach(>sc_rng200);
+}



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

2019-09-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 17:27:22 UTC 2019

Added Files:
src/sys/arch/arm/broadcom: bcm2838_rng.c

Log Message:
Attachment for RNG200


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/broadcom/bcm2838_rng.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/broadcom

2019-06-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jun  7 13:43:44 UTC 2019

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

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/broadcom/bcm2835_tmr.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_tmr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_tmr.c:1.9 src/sys/arch/arm/broadcom/bcm2835_tmr.c:1.10
--- src/sys/arch/arm/broadcom/bcm2835_tmr.c:1.9	Sun Dec 10 21:38:26 2017
+++ src/sys/arch/arm/broadcom/bcm2835_tmr.c	Fri Jun  7 13:43:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_tmr.c,v 1.9 2017/12/10 21:38:26 skrll Exp $	*/
+/*	$NetBSD: bcm2835_tmr.c,v 1.10 2019/06/07 13:43:44 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_tmr.c,v 1.9 2017/12/10 21:38:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_tmr.c,v 1.10 2019/06/07 13:43:44 skrll Exp $");
 
 #include 
 #include 
@@ -208,7 +208,6 @@ bcm2835_tmr_delay(unsigned int n)
 			delta %= counts_per_usec;
 		}
 	}
-
 }
 
 /*



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

2019-06-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jun  7 13:43:44 UTC 2019

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

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/broadcom/bcm2835_tmr.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/broadcom

2019-05-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 29 13:25:54 UTC 2019

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

Log Message:
 Remove unused variable.


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

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

Modified files:

Index: src/sys/arch/arm/broadcom/bcm53xx_eth.c
diff -u src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.37 src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.38
--- src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.37	Wed May 29 10:07:28 2019
+++ src/sys/arch/arm/broadcom/bcm53xx_eth.c	Wed May 29 13:25:54 2019
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.37 2019/05/29 10:07:28 msaitoh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.38 2019/05/29 13:25:54 msaitoh Exp $");
 
 #include 
 #include 
@@ -686,7 +686,6 @@ bcmeth_ifwatchdog(struct ifnet *ifp)
 static int
 bcmeth_ifioctl(struct ifnet *ifp, u_long cmd, void *data)
 {
-	struct bcmeth_softc *sc	 = ifp->if_softc;
 	const int s = splnet();
 	int error;
 



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

2019-05-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 29 13:25:54 UTC 2019

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

Log Message:
 Remove unused variable.


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

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



Re: CVS commit: src/sys/arch/arm/broadcom

2018-10-21 Thread Nick Hudson

On 20/10/2018 11:24, Jared McNeill wrote:

On Sat, 20 Oct 2018, Ryo Shimizu wrote:


I think the dts should be fixed rather than #ifdef __arm__


I agree that we need to change dts to eliminate 32bit enable method from
the dtb for 64bit. However, it is also strange that enable-method code
for 32bit ARM remains in the 64bit binary as well.


I don't think the dts should be changed. This lets use share a dtb 
between 32- and 64-bit kernels. The brcm,bcm2836-smp enable-method is 
documented as being supported only in 32-bit mode:


https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.txt



Can't see enable-method as property of cpus node in the standard 
bindings.  Surely, bcm2837.dtsi is using non-standard bindings


http://src.illumos.org/source/xref/netbsd-src/sys/external/gpl2/dts/dist/arch/arm/boot/dts/bcm2837.dtsi#30

30  cpus: cpus {
31  #address-cells = <1>;
32  #size-cells = <0>;
33  enable-method = "brcm,bcm2836-smp"; // for ARM 32-bit

Nick


Re: CVS commit: src/sys/arch/arm/broadcom

2018-10-20 Thread Jared McNeill

On Sat, 20 Oct 2018, Ryo Shimizu wrote:


I think the dts should be fixed rather than #ifdef __arm__


I agree that we need to change dts to eliminate 32bit enable method from
the dtb for 64bit. However, it is also strange that enable-method code
for 32bit ARM remains in the 64bit binary as well.


I don't think the dts should be changed. This lets use share a dtb between 
32- and 64-bit kernels. The brcm,bcm2836-smp enable-method is documented 
as being supported only in 32-bit mode:


https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpus.txt


Re: CVS commit: src/sys/arch/arm/broadcom

2018-10-20 Thread Ryo Shimizu


>On 20/10/2018 06:53, Ryo Shimizu wrote:
>> Module Name: src
>> Committed By:ryo
>> Date:Sat Oct 20 05:53:22 UTC 2018
>> 
>> Modified Files:
>>  src/sys/arch/arm/broadcom: bcm283x_platform.c
>> 
>> Log Message:
>> - fix AP spinup on bcm283x
>> - "brcm,bcm2836-smp" is a enable-method for only 32bit bcm2836.
>
>
>I think the dts should be fixed rather than #ifdef __arm__

I agree that we need to change dts to eliminate 32bit enable method from
the dtb for 64bit. However, it is also strange that enable-method code
for 32bit ARM remains in the 64bit binary as well.

-- 
ryo shimizu


Re: CVS commit: src/sys/arch/arm/broadcom

2018-10-20 Thread Nick Hudson




On 20/10/2018 08:19, Ryo Shimizu wrote:

On 20/10/2018 06:53, Ryo Shimizu wrote:

Module Name:src
Committed By:   ryo
Date:   Sat Oct 20 05:53:22 UTC 2018

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

Log Message:
- fix AP spinup on bcm283x
- "brcm,bcm2836-smp" is a enable-method for only 32bit bcm2836.


I think the dts should be fixed rather than #ifdef __arm__

I agree that we need to change dts to eliminate 32bit enable method from
the dtb for 64bit.


Cool


  However, it is also strange that enable-method code
for 32bit ARM remains in the 64bit binary as well.

Lots more code in GENERIC64 than this little snippet that won't ever get 
used, e.g. SOC_{RK*,TEGRA,SUN*,etc} on RPI3


Nick


Re: CVS commit: src/sys/arch/arm/broadcom

2018-10-20 Thread Nick Hudson

On 20/10/2018 06:53, Ryo Shimizu wrote:

Module Name:src
Committed By:   ryo
Date:   Sat Oct 20 05:53:22 UTC 2018

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

Log Message:
- fix AP spinup on bcm283x
- "brcm,bcm2836-smp" is a enable-method for only 32bit bcm2836.



I think the dts should be fixed rather than #ifdef __arm__

Thanks,
Nick


Re: CVS commit: src/sys/arch/arm/broadcom

2018-06-07 Thread Jason Thorpe



> On Jun 7, 2018, at 5:14 AM, Jonathan A. Kollasch  
> wrote:
> 
> I don't disagree.  That said, making use of this hardware design did not
> seem the most straightforward to me.  If you can find a better way to do
> it, that'd be great.

Yah, it’s definitely awkward to use, although one advantage it does have is 
making it easy to use the high-speed i2c modes.  The way it supports 10-bit 
addressing is just totally brain-dead, though.

I have some ideas how I want to do it, but it’s not critical right now.

-- thorpej



Re: CVS commit: src/sys/arch/arm/broadcom

2018-06-07 Thread Jonathan A. Kollasch
On Thu, Jun 07, 2018 at 05:07:28AM +, Jason R Thorpe wrote:
> Module Name:  src
> Committed By: thorpej
> Date: Thu Jun  7 05:07:28 UTC 2018
> 
> Modified Files:
>   src/sys/arch/arm/broadcom: bcm2835_bsc.c
> 
> Log Message:
> A minimal change to prevent the Raspberry Pi i2c driver from
> looping forever if the command buffer and data buffer are both
> NULL.  XXX This driver needs an overhaul.

I don't disagree.  That said, making use of this hardware design did not
seem the most straightforward to me.  If you can find a better way to do
it, that'd be great.

With apologies,
Jonathan Kollasch


Re: CVS commit: src/sys/arch/arm/broadcom

2015-07-25 Thread Matt Thomas

 On Jul 25, 2015, at 1:43 AM, Nick Hudson sk...@netbsd.org wrote:
 
 Module Name:  src
 Committed By: skrll
 Date: Sat Jul 25 08:43:41 UTC 2015
 
 Modified Files:
   src/sys/arch/arm/broadcom: bcm2835_intr.c
 
 Log Message:
 IPIs should be IPL_HIGH according to rmind@
 
 Fix bcm2836mp_pic_{un,}block_irqs to handle timer AND mailbox interrupts
 if they're both passed.  Thanks to nat@ for finding this.
 
 Sprinkle some KASSERTs

It depends on the IPI.  IPI_AST doesn't need to be IPI_HIGH since all it does
is get the target cpu out of usermode.


Re: CVS commit: src/sys/arch/arm/broadcom

2013-01-12 Thread Nick Hudson

On 01/13/13 06:10, Nick Hudson wrote:

Module Name:src
Committed By:   skrll
Date:   Sun Jan 13 06:10:25 UTC 2013

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

Log Message:
Support BUS_SPACE_MAP_CACHEABLE.


Should read Simplify by using PMAP_NOCACHE

Nick



Re: CVS commit: src/sys/arch/arm/broadcom

2012-10-13 Thread David Laight
On Fri, Oct 12, 2012 at 11:25:16PM +, Matt Thomas wrote:
 Module Name:  src
 Committed By: matt
 Date: Fri Oct 12 23:25:16 UTC 2012
 
 Modified Files:
   src/sys/arch/arm/broadcom: bcm53xx_eth.c
 
 Log Message:
 Add some defensive code to deal with issues of this interface.
 Seems it can't do DMA updates of the rxsts for mbufs with addresses
 = 256MB.  It can't also seem to properly read from the descriptor rings
 if they are  256MB.  And I have no idea why either should matter.

The combination seems even more obscure.

David

-- 
David Laight: da...@l8s.co.uk