Module Name:    src
Committed By:   skrll
Date:           Tue Oct 30 20:14:22 UTC 2012

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

Log Message:
Query the EMMC clock rate and use it if it's available.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/broadcom/bcm2835_emmc.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/evbarm/rpi/rpi_machdep.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.1 src/sys/arch/arm/broadcom/bcm2835_emmc.c:1.2
--- src/sys/arch/arm/broadcom/bcm2835_emmc.c:1.1	Thu Jul 26 06:21:57 2012
+++ src/sys/arch/arm/broadcom/bcm2835_emmc.c	Tue Oct 30 20:14:22 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_emmc.c,v 1.1 2012/07/26 06:21:57 skrll Exp $	*/
+/*	$NetBSD: bcm2835_emmc.c,v 1.2 2012/10/30 20:14:22 skrll 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.1 2012/07/26 06:21:57 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_emmc.c,v 1.2 2012/10/30 20:14:22 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -77,7 +77,9 @@ static void
 bcmemmc_attach(device_t parent, device_t self, void *aux)
 {
 	struct bcmemmc_softc *sc = device_private(self);
+	prop_dictionary_t dict = device_properties(self);
 	struct amba_attach_args *aaa = aux;
+	prop_number_t frequency;
 	int error;
 
 	sc->sc.sc_dev = self;
@@ -88,9 +90,15 @@ bcmemmc_attach(device_t parent, device_t
 	sc->sc.sc_flags |= SDHC_FLAG_HOSTCAPS;
 	sc->sc.sc_caps = SDHC_VOLTAGE_SUPP_3_3V;
 	sc->sc.sc_host = sc->sc_hosts;
-	sc->sc.sc_clkbase = 50000;	/* 50MHz */
+	sc->sc.sc_clkbase = 50000;	/* Default to 50MHz */
 	sc->sc_iot = aaa->aaa_iot;
 
+        /* Fetch the EMMC clock frequency from property if set. */
+        frequency = prop_dictionary_get(dict, "frequency");
+        if (frequency != NULL) {
+		sc->sc.sc_clkbase = prop_number_integer_value(frequency) / 1000;
+	}    
+	
 	error = bus_space_map(sc->sc_iot, aaa->aaa_addr, aaa->aaa_size, 0,
 	    &sc->sc_ioh);
 	if (error) {

Index: src/sys/arch/evbarm/rpi/rpi_machdep.c
diff -u src/sys/arch/evbarm/rpi/rpi_machdep.c:1.17 src/sys/arch/evbarm/rpi/rpi_machdep.c:1.18
--- src/sys/arch/evbarm/rpi/rpi_machdep.c:1.17	Tue Oct 30 20:02:15 2012
+++ src/sys/arch/evbarm/rpi/rpi_machdep.c	Tue Oct 30 20:14:22 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpi_machdep.c,v 1.17 2012/10/30 20:02:15 skrll Exp $	*/
+/*	$NetBSD: rpi_machdep.c,v 1.18 2012/10/30 20:14:22 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.17 2012/10/30 20:02:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.18 2012/10/30 20:14:22 skrll Exp $");
 
 #include "opt_evbarm_boardtype.h"
 
@@ -39,12 +39,15 @@ __KERNEL_RCSID(0, "$NetBSD: rpi_machdep.
 #include <sys/termios.h>
 #include <sys/bus.h>
 
+#include <prop/proplib.h>
+
 #include <dev/cons.h>
 
 #include <uvm/uvm_extern.h>
 
 #include <arm/arm32/machdep.h>
 
+#include <machine/autoconf.h>
 #include <machine/vmparam.h>
 #include <machine/bootconfig.h>
 #include <machine/pmap.h>
@@ -75,6 +78,7 @@ static char bootargs[MAX_BOOT_STRING];
 char *boot_args = NULL;
 
 static void rpi_bootparams(void);
+static void rpi_device_register(device_t, void *);
 
 /*
  * Macros to translate between physical and virtual for a subset of the
@@ -125,6 +129,7 @@ static struct {
 	struct vcprop_tag_memory	vbt_memory;
 	struct vcprop_tag_boardserial	vbt_serial;
 	struct vcprop_tag_cmdline	vbt_cmdline;
+	struct vcprop_tag_clockrate	vbt_emmcclockrate;
 	struct vcprop_tag end;
 } vb __packed __aligned(16) =
 {
@@ -181,6 +186,14 @@ static struct {
 			.vpt_rcode = VCPROPTAG_REQUEST
 		},
 	},
+	.vbt_emmcclockrate = {
+		.tag = {
+			.vpt_tag = VCPROPTAG_GET_CLOCKRATE,
+			.vpt_len = VCPROPTAG_LEN(vb.vbt_emmcclockrate),
+			.vpt_rcode = VCPROPTAG_REQUEST
+		},
+		.id = VCPROP_CLK_EMMC
+	},
 	.end = {
 		.vpt_tag = VCPROPTAG_NULL
 	}
@@ -344,6 +357,9 @@ initarm(void *arg)
 	boothowto |= BOOTHOWTO;
 #endif
 
+	/* we've a specific device_register routine */
+	evbarm_device_register = rpi_device_register;
+
 	return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
 }
 
@@ -377,3 +393,15 @@ consinit(void)
 #endif
 }
 
+
+static void
+rpi_device_register(device_t dev, void *aux)
+{
+	prop_dictionary_t dict = device_properties(dev);
+
+	if (device_is_a(dev, "sdhc") &&
+	    vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag)) {
+		prop_dictionary_set_uint32(dict,
+		    "frequency", vb.vbt_emmcclockrate.rate);
+	}
+}

Reply via email to