sdhci_fdt ignores clock-frequency property in .dtb

Thomas Skibo ThomasSkibo at sbcglobal.net
Tue Apr 29 21:38:23 UTC 2014


Another Zynq bug-fix.  One Zynq board out there needs to set this 
property or else the SD card gets clocked too fast.

Thanks,

-- 
--------
Thomas Skibo
ThomasSkibo at sbcglobal.net

-------------- next part --------------
Index: sys/dev/sdhci/sdhci_fdt.c
===================================================================
--- sys/dev/sdhci/sdhci_fdt.c	(revision 264766)
+++ sys/dev/sdhci/sdhci_fdt.c	(working copy)
@@ -66,6 +66,7 @@
 	device_t	dev;		/* Controller device */
 	u_int		quirks;		/* Chip specific quirks */
 	u_int		caps;		/* If we override SDHCI_CAPABILITIES */
+	uint32_t	max_clk;	/* Max possible freq */
 	struct resource *irq_res;	/* IRQ resource */
 	void 		*intrhand;	/* Interrupt handle */
 
@@ -156,6 +157,7 @@
 
 	sc->quirks = 0;
 	sc->num_slots = 1;
+	sc->max_clk = 0;
 
 	if (!ofw_bus_status_okay(dev))
 		return (ENXIO);
@@ -170,11 +172,14 @@
 
 	node = ofw_bus_get_node(dev);
 
-	/* Allow dts to patch quirks and slots. */
-	if ((OF_getprop(node, "quirks", &cid, sizeof(cid))) > 0)
-		sc->quirks = fdt32_to_cpu(cid);
-	if ((OF_getprop(node, "num-slots", &cid, sizeof(cid))) > 0)
-		sc->num_slots = fdt32_to_cpu(cid);
+	/* Allow dts to patch quirks, slots, and clock frequency. */
+	if ((OF_getencprop(node, "quirks", &cid, sizeof(cid))) > 0)
+		sc->quirks = cid;
+	if ((OF_getencprop(node, "num-slots", &cid, sizeof(cid))) > 0)
+		sc->num_slots = cid;
+	if ((OF_getencprop(node, "clock-frequency", &cid, sizeof(cid))) > 0)
+		sc->max_clk = cid;
+
 		
 	return (0);
 }
@@ -214,6 +219,7 @@
 
 		slot->quirks = sc->quirks;
 		slot->caps = sc->caps;
+		slot->max_clk = sc->max_clk;
 
 		if (sdhci_init_slot(dev, slot, i) != 0)
 			continue;


More information about the freebsd-arm mailing list