Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 May 2018 15:41:00 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334435 - head/sys/arm/allwinner
Message-ID:  <201805311541.w4VFf0x3056696@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: manu
Date: Thu May 31 15:41:00 2018
New Revision: 334435
URL: https://svnweb.freebsd.org/changeset/base/334435

Log:
  aw_mmc: Use the DEVMETHOD vccq for the IO line voltage
  
  MMC controller should use this and not set the voltage during update_ios.

Modified:
  head/sys/arm/allwinner/aw_mmc.c

Modified: head/sys/arm/allwinner/aw_mmc.c
==============================================================================
--- head/sys/arm/allwinner/aw_mmc.c	Thu May 31 15:39:39 2018	(r334434)
+++ head/sys/arm/allwinner/aw_mmc.c	Thu May 31 15:41:00 2018	(r334435)
@@ -119,8 +119,6 @@ struct aw_mmc_softc {
 	uint32_t		aw_intr;
 	uint32_t		aw_intr_wait;
 	void *			aw_intrhand;
-	int32_t			aw_vdd;
-	int32_t			aw_vccq;
 	regulator_t		aw_reg_vmmc;
 	regulator_t		aw_reg_vqmmc;
 	unsigned int		aw_clock;
@@ -941,15 +939,18 @@ aw_mmc_update_clock(struct aw_mmc_softc *sc, uint32_t 
 	return (0);
 }
 
-static void
-aw_mmc_set_vccq(struct aw_mmc_softc *sc, int32_t vccq)
+static int
+aw_mmc_switch_vccq(device_t bus, device_t child)
 {
-	int uvolt;
+	struct aw_mmc_softc *sc;
+	int uvolt, err;
 
+	sc = device_get_softc(bus);
+
 	if (sc->aw_reg_vqmmc == NULL)
-		return;
+		return EOPNOTSUPP;
 
-	switch (vccq) {
+	switch (sc->aw_host.ios.vccq) {
 	case vccq_180:
 		uvolt = 1800000;
 		break;
@@ -957,15 +958,19 @@ aw_mmc_set_vccq(struct aw_mmc_softc *sc, int32_t vccq)
 		uvolt = 3300000;
 		break;
 	default:
-		return;
+		return EINVAL;
 	}
 
-	if (regulator_set_voltage(sc->aw_reg_vqmmc,
-	    uvolt, uvolt) != 0)
+	err = regulator_set_voltage(sc->aw_reg_vqmmc, uvolt, uvolt);
+	if (err != 0) {
 		device_printf(sc->aw_dev,
 		    "Cannot set vqmmc to %d<->%d\n",
 		    uvolt,
 		    uvolt);
+		return (err);
+	}
+
+	return (0);
 }
 
 static int
@@ -1020,11 +1025,6 @@ aw_mmc_update_ios(device_t bus, device_t child)
 		break;
 	};
 
-	if (ios->vccq != sc->aw_vccq) {
-		aw_mmc_set_vccq(sc, ios->vccq);
-		sc->aw_vccq = ios->vccq;
-	}
-
 	/* Enable ddr mode if needed */
 	reg = AW_MMC_READ_4(sc, AW_MMC_GCTL);
 	if (ios->timing == bus_timing_uhs_ddr50 ||
@@ -1141,6 +1141,7 @@ static device_method_t aw_mmc_methods[] = {
 	DEVMETHOD(mmcbr_update_ios,	aw_mmc_update_ios),
 	DEVMETHOD(mmcbr_request,	aw_mmc_request),
 	DEVMETHOD(mmcbr_get_ro,		aw_mmc_get_ro),
+	DEVMETHOD(mmcbr_switch_vccq,	aw_mmc_switch_vccq),
 	DEVMETHOD(mmcbr_acquire_host,	aw_mmc_acquire_host),
 	DEVMETHOD(mmcbr_release_host,	aw_mmc_release_host),
 



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