Module Name:    src
Committed By:   jmcneill
Date:           Thu Feb 20 01:44:06 UTC 2020

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

Log Message:
Add support for brcm,bcm2711-emmc2


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/arm/broadcom/bcm2835_emmc.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_emmc.c
diff -u src/sys/arch/arm/broadcom/bcm2835_emmc.c:1.35 src/sys/arch/arm/broadcom/bcm2835_emmc.c:1.36
--- src/sys/arch/arm/broadcom/bcm2835_emmc.c:1.35	Mon Dec 30 16:41:38 2019
+++ src/sys/arch/arm/broadcom/bcm2835_emmc.c	Thu Feb 20 01:44:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_emmc.c,v 1.35 2019/12/30 16:41:38 skrll Exp $	*/
+/*	$NetBSD: bcm2835_emmc.c,v 1.36 2020/02/20 01:44:06 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_emmc.c,v 1.35 2019/12/30 16:41:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_emmc.c,v 1.36 2020/02/20 01:44:06 jmcneill Exp $");
 
 #include "bcmdmac.h"
 
@@ -91,17 +91,24 @@ static void bcmemmc_dma_done(uint32_t, u
 CFATTACH_DECL_NEW(bcmemmc, sizeof(struct bcmemmc_softc),
     bcmemmc_match, bcmemmc_attach, NULL, NULL);
 
+enum bcmemmc_type {
+	BCM2835_SDHCI,
+	BCM2711_EMMC2,
+};
+
+static const struct of_compat_data compat_data[] = {
+	{ "brcm,bcm2835-sdhci",		BCM2835_SDHCI },
+	{ "brcm,bcm2711-emmc2",		BCM2711_EMMC2 },
+	{ NULL }
+};
+
 /* ARGSUSED */
 static int
 bcmemmc_match(device_t parent, struct cfdata *match, void *aux)
 {
-	const char * const compatible[] = {
-	    "brcm,bcm2835-sdhci",
-	    NULL
-	};
 	struct fdt_attach_args * const faa = aux;
 
-	return of_match_compatible(faa->faa_phandle, compatible);
+	return of_match_compat_data(faa->faa_phandle, compat_data);
 }
 
 /* ARGSUSED */
@@ -111,9 +118,13 @@ bcmemmc_attach(device_t parent, device_t
 	struct bcmemmc_softc *sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
 	prop_dictionary_t dict = device_properties(self);
+	const int phandle = faa->faa_phandle;
 	bool disable = false;
+	enum bcmemmc_type type;
 	int error;
 
+	type = of_search_compatible(phandle, compat_data)->data;
+
 	sc->sc.sc_dev = self;
 	sc->sc.sc_dmat = faa->faa_dmat;
 	sc->sc.sc_flags = 0;
@@ -137,7 +148,6 @@ bcmemmc_attach(device_t parent, device_t
 	bus_addr_t addr;
 	bus_size_t size;
 
-	const int phandle = faa->faa_phandle;
 	error = fdtbus_get_reg(phandle, 0, &addr, &size);
 	if (error) {
 		aprint_error_dev(sc->sc.sc_dev, "unable to map device\n");
@@ -185,6 +195,9 @@ bcmemmc_attach(device_t parent, device_t
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 #if NBCMDMAC > 0
+	if (type != BCM2835_SDHCI)
+		goto done;
+
 	sc->sc_dmac = bcm_dmac_alloc(BCM_DMAC_TYPE_NORMAL, IPL_SDMMC,
 	    bcmemmc_dma_done, sc);
 	if (sc->sc_dmac == NULL)

Reply via email to