Date: Mon, 9 Jan 2017 02:04:54 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311736 - head/sys/dev/sdhci Message-ID: <201701090204.v0924sAV010381@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Mon Jan 9 02:04:54 2017 New Revision: 311736 URL: https://svnweb.freebsd.org/changeset/base/311736 Log: Use the new sdhci_fdt_gpio helper functions to add full support for FDT gpio pins for detecting card insert/remove and write protect. Modified: head/sys/dev/sdhci/fsl_sdhci.c Modified: head/sys/dev/sdhci/fsl_sdhci.c ============================================================================== --- head/sys/dev/sdhci/fsl_sdhci.c Mon Jan 9 01:57:51 2017 (r311735) +++ head/sys/dev/sdhci/fsl_sdhci.c Mon Jan 9 02:04:54 2017 (r311736) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include <arm/freescale/imx/imx_ccmvar.h> #endif +#include <dev/gpio/gpiobusvar.h> #include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_bus_subr.h> @@ -67,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include <dev/mmc/mmcbrvar.h> #include <dev/sdhci/sdhci.h> +#include <dev/sdhci/sdhci_fdt_gpio.h> #include "sdhci_if.h" struct fsl_sdhci_softc { @@ -77,10 +79,10 @@ struct fsl_sdhci_softc { struct sdhci_slot slot; struct callout r1bfix_callout; sbintime_t r1bfix_timeout_at; + struct sdhci_fdt_gpio * gpio; uint32_t baseclk_hz; uint32_t cmd_and_mode; uint32_t r1bfix_intmask; - boolean_t force_card_present; uint16_t sdclockreg_freq_bits; uint8_t r1bfix_type; uint8_t hwtype; @@ -345,8 +347,6 @@ fsl_sdhci_read_4(device_t dev, struct sd val32 &= 0x000F0F07; val32 |= (wrk32 >> 4) & SDHCI_STATE_DAT_MASK; val32 |= (wrk32 >> 9) & SDHCI_RETUNE_REQUEST; - if (sc->force_card_present) - val32 |= SDHCI_CARD_PRESENT; return (val32); } @@ -752,9 +752,15 @@ fsl_sdhci_get_ro(device_t bus, device_t { struct fsl_sdhci_softc *sc = device_get_softc(bus); - if (RD4(sc, SDHCI_PRESENT_STATE) & SDHC_PRES_WPSPL) - return (false); - return (true); + return (sdhci_fdt_gpio_get_readonly(sc->gpio)); +} + +static bool +fsl_sdhci_get_card_present(device_t dev, struct sdhci_slot *slot) +{ + struct fsl_sdhci_softc *sc = device_get_softc(dev); + + return (sdhci_fdt_gpio_get_present(sc->gpio)); } #ifdef __powerpc__ @@ -802,6 +808,7 @@ static int fsl_sdhci_detach(device_t dev) { + /* sdhci_fdt_gpio_teardown(sc->gpio); */ return (EBUSY); } @@ -810,8 +817,8 @@ fsl_sdhci_attach(device_t dev) { struct fsl_sdhci_softc *sc = device_get_softc(dev); int rid, err; - phandle_t node; #ifdef __powerpc__ + phandle_t node; uint32_t protctl; #endif @@ -887,24 +894,13 @@ fsl_sdhci_attach(device_t dev) sc->slot.max_clk = sc->baseclk_hz; /* - * If the slot is flagged with the non-removable property, set our flag - * to always force the SDHCI_CARD_PRESENT bit on. - * - * XXX Workaround for gpio-based card detect... - * - * We don't have gpio support yet. If there's a cd-gpios property just - * force the SDHCI_CARD_PRESENT bit on for now. If there isn't really a - * card there it will fail to probe at the mmc layer and nothing bad - * happens except instantiating an mmcN device for an empty slot. + * Set up any gpio pin handling described in the FDT data. This cannot + * fail; see comments in sdhci_fdt_gpio.h for details. */ - node = ofw_bus_get_node(dev); - if (OF_hasprop(node, "non-removable")) - sc->force_card_present = true; - else if (OF_hasprop(node, "cd-gpios")) { - /* XXX put real gpio hookup here. */ - sc->force_card_present = true; - } + sc->gpio = sdhci_fdt_gpio_setup(dev, &sc->slot); + #ifdef __powerpc__ + node = ofw_bus_get_node(dev); /* Default to big-endian on powerpc */ protctl = RD4(sc, SDHC_PROT_CTRL); protctl &= ~SDHC_PROT_EMODE_MASK; @@ -974,7 +970,7 @@ static device_method_t fsl_sdhci_methods DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), - /* SDHCI registers accessors */ + /* SDHCI accessors */ DEVMETHOD(sdhci_read_1, fsl_sdhci_read_1), DEVMETHOD(sdhci_read_2, fsl_sdhci_read_2), DEVMETHOD(sdhci_read_4, fsl_sdhci_read_4), @@ -983,6 +979,7 @@ static device_method_t fsl_sdhci_methods DEVMETHOD(sdhci_write_2, fsl_sdhci_write_2), DEVMETHOD(sdhci_write_4, fsl_sdhci_write_4), DEVMETHOD(sdhci_write_multi_4, fsl_sdhci_write_multi_4), + DEVMETHOD(sdhci_get_card_present,fsl_sdhci_get_card_present), { 0, 0 } };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701090204.v0924sAV010381>