Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2012 02:32:38 +0000 (UTC)
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r243688 - head/sys/arm/broadcom/bcm2835
Message-ID:  <201211300232.qAU2WcTA099569@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gonzo
Date: Fri Nov 30 02:32:37 2012
New Revision: 243688
URL: http://svnweb.freebsd.org/changeset/base/243688

Log:
  Get frequency from "clock-frequency" property of "/axi/sdhci" FDT node

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c	Fri Nov 30 02:31:08 2012	(r243687)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c	Fri Nov 30 02:32:37 2012	(r243688)
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/frame.h>
 #include <machine/intr.h>
 
+#include <dev/fdt/fdt_common.h>
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
 
@@ -66,6 +67,8 @@ __FBSDID("$FreeBSD$");
 #include <dev/sdhci/sdhci.h>
 #include "sdhci_if.h"
 
+#define	BCM2835_DEFAULT_SDHCI_FREQ	50
+
 #define	DEBUG
 
 #ifdef DEBUG
@@ -129,10 +132,20 @@ bcm_sdhci_attach(device_t dev)
 {
 	struct bcm_sdhci_softc *sc = device_get_softc(dev);
 	int rid, err;
+	phandle_t node;
+	pcell_t cell;
+	int default_freq;
 
 	sc->sc_dev = dev;
 	sc->sc_req = NULL;
 
+	default_freq = BCM2835_DEFAULT_SDHCI_FREQ;
+	node = ofw_bus_get_node(sc->sc_dev);
+	if ((OF_getprop(node, "clock-frequency", &cell, sizeof(cell))) > 0)
+		default_freq = (int)fdt32_to_cpu(cell)/1000000;
+
+	dprintf("SDHCI frequency: %dMHz\n", default_freq);
+
 	mtx_init(&sc->sc_mtx, "bcm sdhci", "sdhci", MTX_DEF);
 
 	rid = 0;
@@ -168,7 +181,7 @@ bcm_sdhci_attach(device_t dev)
 	}
 
 	sc->sc_slot.caps = SDHCI_CAN_VDD_330 | SDHCI_CAN_VDD_180 | SDHCI_CAN_DO_HISPD;
-	sc->sc_slot.caps |= (50 << SDHCI_CLOCK_BASE_SHIFT);
+	sc->sc_slot.caps |= (default_freq << SDHCI_CLOCK_BASE_SHIFT);
 	sc->sc_slot.quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK 
 		| SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
 		| SDHCI_QUIRK_MISSING_CAPS;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211300232.qAU2WcTA099569>