From owner-svn-src-head@freebsd.org Sun Mar 5 15:34:34 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0478FCF9C0A; Sun, 5 Mar 2017 15:34:34 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C5BA61026; Sun, 5 Mar 2017 15:34:33 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v25FYW6u033243; Sun, 5 Mar 2017 15:34:32 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v25FYWUj033242; Sun, 5 Mar 2017 15:34:32 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201703051534.v25FYWUj033242@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 5 Mar 2017 15:34:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314703 - head/sys/arm/nvidia X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Mar 2017 15:34:34 -0000 Author: mmel Date: Sun Mar 5 15:34:32 2017 New Revision: 314703 URL: https://svnweb.freebsd.org/changeset/base/314703 Log: Add support for card detect and write protect gpio pins to Tegra SDHCI. Modified: head/sys/arm/nvidia/tegra_sdhci.c Modified: head/sys/arm/nvidia/tegra_sdhci.c ============================================================================== --- head/sys/arm/nvidia/tegra_sdhci.c Sun Mar 5 13:14:18 2017 (r314702) +++ head/sys/arm/nvidia/tegra_sdhci.c Sun Mar 5 15:34:32 2017 (r314703) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "sdhci_if.h" @@ -107,9 +109,8 @@ struct tegra_sdhci_softc { uint32_t max_clk; /* Max possible freq */ clk_t clk; hwreset_t reset; - gpio_pin_t gpio_cd; - gpio_pin_t gpio_wp; gpio_pin_t gpio_power; + struct sdhci_fdt_gpio *gpio; int force_card_present; struct sdhci_slot slot; @@ -215,10 +216,19 @@ tegra_sdhci_intr(void *arg) } static int -tegra_generic_get_ro(device_t brdev, device_t reqdev) +tegra_sdhci_get_ro(device_t brdev, device_t reqdev) { + struct tegra_sdhci_softc *sc = device_get_softc(brdev); - return (0); + return (sdhci_fdt_gpio_get_readonly(sc->gpio)); +} + +static bool +tegra_sdhci_get_card_present(device_t dev, struct sdhci_slot *slot) +{ + struct tegra_sdhci_softc *sc = device_get_softc(dev); + + return (sdhci_fdt_gpio_get_present(sc->gpio)); } static int @@ -300,9 +310,7 @@ tegra_sdhci_attach(device_t dev) goto fail; } - gpio_pin_get_by_ofw_property(sc->dev, node, "cd-gpios", &sc->gpio_cd); gpio_pin_get_by_ofw_property(sc->dev, node, "power-gpios", &sc->gpio_power); - gpio_pin_get_by_ofw_property(sc->dev, node, "wp-gpios", &sc->gpio_wp); rv = clk_get_by_ofw_index(dev, 0, 0, &sc->clk); if (rv != 0) { @@ -374,6 +382,8 @@ tegra_sdhci_attach(device_t dev) goto fail; } + sc->gpio = sdhci_fdt_gpio_setup(sc->dev, &sc->slot); + bus_generic_probe(dev); bus_generic_attach(dev); @@ -382,18 +392,16 @@ tegra_sdhci_attach(device_t dev) return (0); fail: - if (sc->gpio_cd != NULL) - gpio_pin_release(sc->gpio_cd); - if (sc->gpio_wp != NULL) - gpio_pin_release(sc->gpio_wp); + if (sc->gpio != NULL) + sdhci_fdt_gpio_teardown(sc->gpio); + if (sc->intr_cookie != NULL) + bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie); if (sc->gpio_power != NULL) gpio_pin_release(sc->gpio_power); if (sc->clk != NULL) clk_release(sc->clk); if (sc->reset != NULL) hwreset_release(sc->reset); - if (sc->intr_cookie != NULL) - bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie); if (sc->irq_res != NULL) bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); if (sc->mem_res != NULL) @@ -409,6 +417,7 @@ tegra_sdhci_detach(device_t dev) struct sdhci_slot *slot = &sc->slot; bus_generic_detach(dev); + sdhci_fdt_gpio_teardown(sc->gpio); clk_release(sc->clk); bus_teardown_intr(dev, sc->irq_res, sc->intr_cookie); bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq_res), @@ -434,7 +443,7 @@ static device_method_t tegra_sdhci_metho /* MMC bridge interface */ DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios), DEVMETHOD(mmcbr_request, sdhci_generic_request), - DEVMETHOD(mmcbr_get_ro, tegra_generic_get_ro), + DEVMETHOD(mmcbr_get_ro, tegra_sdhci_get_ro), DEVMETHOD(mmcbr_acquire_host, sdhci_generic_acquire_host), DEVMETHOD(mmcbr_release_host, sdhci_generic_release_host), @@ -447,6 +456,7 @@ static device_method_t tegra_sdhci_metho DEVMETHOD(sdhci_write_2, tegra_sdhci_write_2), DEVMETHOD(sdhci_write_4, tegra_sdhci_write_4), DEVMETHOD(sdhci_write_multi_4, tegra_sdhci_write_multi_4), + DEVMETHOD(sdhci_get_card_present, tegra_sdhci_get_card_present), DEVMETHOD_END };