Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Query the EMMC clock rate and use it if it's availa...



details:   https://anonhg.NetBSD.org/src/rev/69a4aeac5ad1
branches:  trunk
changeset: 782363:69a4aeac5ad1
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Oct 30 20:14:22 2012 +0000

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

diffstat:

 sys/arch/arm/broadcom/bcm2835_emmc.c |  14 +++++++++++---
 sys/arch/evbarm/rpi/rpi_machdep.c    |  32 ++++++++++++++++++++++++++++++--
 2 files changed, 41 insertions(+), 5 deletions(-)

diffs (136 lines):

diff -r 54436ace3c3b -r 69a4aeac5ad1 sys/arch/arm/broadcom/bcm2835_emmc.c
--- a/sys/arch/arm/broadcom/bcm2835_emmc.c      Tue Oct 30 20:11:37 2012 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_emmc.c      Tue Oct 30 20:14:22 2012 +0000
@@ -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 @@
 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 @@
        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) {
diff -r 54436ace3c3b -r 69a4aeac5ad1 sys/arch/evbarm/rpi/rpi_machdep.c
--- a/sys/arch/evbarm/rpi/rpi_machdep.c Tue Oct 30 20:11:37 2012 +0000
+++ b/sys/arch/evbarm/rpi/rpi_machdep.c Tue Oct 30 20:14:22 2012 +0000
@@ -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 @@
 #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 @@
 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 @@
        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 @@
                        .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 @@
        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 @@
 #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);
+       }
+}



Home | Main Index | Thread Index | Old Index