Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Aug 2018 16:27:52 +0000 (UTC)
From:      Luiz Otavio O Souza <loos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r337858 - stable/11/sys/dev/sdhci
Message-ID:  <201808151627.w7FGRqHZ027264@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: loos
Date: Wed Aug 15 16:27:52 2018
New Revision: 337858
URL: https://svnweb.freebsd.org/changeset/base/337858

Log:
  MFC r317800:
  
  Add support for the no-1-8-v and wp-inverted properties in generic SDHCI
  FDT glue.
  
  Sponsored by:	Rubicon Communications, LLC (Netgate)

Modified:
  stable/11/sys/dev/sdhci/sdhci_fdt.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/sdhci/sdhci_fdt.c
==============================================================================
--- stable/11/sys/dev/sdhci/sdhci_fdt.c	Wed Aug 15 16:22:12 2018	(r337857)
+++ stable/11/sys/dev/sdhci/sdhci_fdt.c	Wed Aug 15 16:27:52 2018	(r337858)
@@ -70,6 +70,9 @@ struct sdhci_fdt_softc {
 	int		num_slots;	/* Number of slots on this controller*/
 	struct sdhci_slot slots[MAX_SLOTS];
 	struct resource	*mem_res[MAX_SLOTS];	/* Memory resource */
+
+	bool		wp_inverted;	/* WP pin is inverted */
+	bool		no_18v;		/* No 1.8V support */
 };
 
 static uint8_t
@@ -110,8 +113,13 @@ static uint32_t
 sdhci_fdt_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off)
 {
 	struct sdhci_fdt_softc *sc = device_get_softc(dev);
+	uint32_t val32;
 
-	return (bus_read_4(sc->mem_res[slot->num], off));
+	val32 = bus_read_4(sc->mem_res[slot->num], off);
+	if (off == SDHCI_CAPABILITIES && sc->no_18v)
+		val32 &= ~SDHCI_CAN_VDD_180;
+
+	return (val32);
 }
 
 static void
@@ -152,6 +160,14 @@ sdhci_fdt_intr(void *arg)
 }
 
 static int
+sdhci_fdt_get_ro(device_t bus, device_t dev)
+{
+	struct sdhci_fdt_softc *sc = device_get_softc(bus);
+
+	return (sdhci_generic_get_ro(bus, dev) ^ sc->wp_inverted);
+}
+
+static int
 sdhci_fdt_probe(device_t dev)
 {
 	struct sdhci_fdt_softc *sc = device_get_softc(dev);
@@ -182,6 +198,10 @@ sdhci_fdt_probe(device_t dev)
 		sc->num_slots = cid;
 	if ((OF_getencprop(node, "max-frequency", &cid, sizeof(cid))) > 0)
 		sc->max_clk = cid;
+	if (OF_hasprop(node, "no-1-8-v"))
+		sc->no_18v = true;
+	if (OF_hasprop(node, "wp-inverted"))
+		sc->wp_inverted = true;
 
 	return (0);
 }
@@ -279,7 +299,7 @@ static device_method_t sdhci_fdt_methods[] = {
 	/* mmcbr_if */
 	DEVMETHOD(mmcbr_update_ios,	sdhci_generic_update_ios),
 	DEVMETHOD(mmcbr_request,	sdhci_generic_request),
-	DEVMETHOD(mmcbr_get_ro,		sdhci_generic_get_ro),
+	DEVMETHOD(mmcbr_get_ro,		sdhci_fdt_get_ro),
 	DEVMETHOD(mmcbr_acquire_host,	sdhci_generic_acquire_host),
 	DEVMETHOD(mmcbr_release_host,	sdhci_generic_release_host),
 



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