From owner-dev-commits-src-main@freebsd.org Tue May 25 23:18:48 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4A331656692; Tue, 25 May 2021 23:18:48 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FqVPz3zxYz4j6V; Tue, 25 May 2021 23:18:47 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lf1-x134.google.com with SMTP id j10so48557412lfb.12; Tue, 25 May 2021 16:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tYIo9yHWM6Oa6J+IOs0CYKP5BgpDxEAo/rH15hm+vfo=; b=o/qUVconodBqhpl3INHf/Hy0ImcBiFKXSLbq/8AxNavasRpGodw/YdWLPcux8gc7SR LpdzyBvKyVFS/yfr47pH+Fht6cElm+84M/0Xo/T+xMKeqFX+r+WLNHcFbRXgtx6pX0kb ovtOwIH3H4Ez8TZwnUUwW0m43xjWf2HvPkTbSTHzMwUHDlcWMx0lLWr+hdwhKFJypCdH rejD6HQcJDKLSqz5HUOErAJlNlG6Rvu0DmbDrBSlkCVF5SN6jBo37Bs2qkE/rLvaEXFd XbLPHmxRV3LyJRSQjGf3uCMmf6oK5DzR/atHxyYKES650R1iaeODvcxmcB02z5og64Pn ax0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tYIo9yHWM6Oa6J+IOs0CYKP5BgpDxEAo/rH15hm+vfo=; b=NTmLfh/OXLbBFQW2uYCq9Z09ZUA+W0mp+8+O8dmdwUz8mpYVjYO2BpDIXT11VA7luz T0CLwnXLplyVSu5l7gBEPzjO2m4Z2LUIlc/Ng8/OdOTEWFV7+y79F9QUjAqiLfvVUPjv 6bXdgcERquXHPku08yipR1LyJM6mU5ixEJw95Kg4kbAFPumzpN1F4hv5Ysi3CaCGKY3j WEdEUn3Xo/96Vadpkv++7cJmBBbYiTrkt9UpBjBTeNYLjzX8vDwfG6OfBHXJYjYVLDnQ 9U/mghunsY82iHKYe4kmG/qHb7uOeowDmx2VIh6F5nxpOhgLJmL0o2CjhJdIIkvTAPd8 pvcw== X-Gm-Message-State: AOAM531l7QUpNxGy0L/VGlNg6BrJyCdml8y/GwQ8GavAKRt4YRrOJRC/ gOum+ZRVzEFGopKgDUb87PUaWgUiVzNxSfAlz5qC5ktK X-Google-Smtp-Source: ABdhPJxQUgF1a9Os3y2MXdRVXHswsjri3D3vHK2XP/QcXaJpMwg4iZPWaTzxbrvTMqX1jQy0d/avW7pp2MovcLY29Hw= X-Received: by 2002:a05:6512:b0f:: with SMTP id w15mr38460lfu.118.1621984724970; Tue, 25 May 2021 16:18:44 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:9746:0:0:0:0:0 with HTTP; Tue, 25 May 2021 16:18:44 -0700 (PDT) In-Reply-To: References: <202105211604.14LG4EdR005067@gitrepo.freebsd.org> From: Mateusz Guzik Date: Wed, 26 May 2021 01:18:44 +0200 Message-ID: Subject: Re: git: 5b2a81f58dc7 - main - mmc: Add mmc-pwrseq driver To: Emmanuel Vadot Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4FqVPz3zxYz4j6V X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=o/qUVcon; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::134 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-2.03 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::134:from]; TO_DN_SOME(0.00)[]; NEURAL_SPAM_SHORT(0.97)[0.967]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::134:from:127.0.2.255]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::134:from]; NEURAL_HAM_LONG(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2021 23:18:48 -0000 There is one more: _.arm.SOCFPGA On 5/23/21, Mateusz Guzik wrote: > This breaks tinderbox, for example buildkernel TARGET_ARCH=armv6 > KERNCONF=RPI-B MODULES_OVERRIDE="": > ld: error: undefined symbol: mmc_fdt_parse >>>> referenced by bcm2835_sdhci.c:320 >>>> (/usr/src/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c:320) >>>> bcm2835_sdhci.o:(bcm_sdhci_attach) > ld: error: undefined symbol: mmc_fdt_parse >>>> referenced by bcm2835_sdhci.c:320 >>>> (/usr/src/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c:320) >>>> bcm2835_sdhci.o:(bcm_sdhci_attach) > > > > On 5/21/21, Emmanuel Vadot wrote: >> The branch main has been updated by manu: >> >> URL: >> https://cgit.FreeBSD.org/src/commit/?id=5b2a81f58dc722ca76065536f07ba47efd98dc63 >> >> commit 5b2a81f58dc722ca76065536f07ba47efd98dc63 >> Author: Emmanuel Vadot >> AuthorDate: 2021-05-16 12:48:56 +0000 >> Commit: Emmanuel Vadot >> CommitDate: 2021-05-21 15:36:20 +0000 >> >> mmc: Add mmc-pwrseq driver >> >> This driver is used to power up sdio card or eMMC. >> It handle the reset-gpio, clocks and needed delays for >> powerup/powerdown. >> >> Sponsored by: Diablotin Systems >> Differential Revision: https://reviews.freebsd.org/D30288 >> --- >> sys/conf/files | 2 + >> sys/dev/mmc/mmc_pwrseq.c | 194 >> ++++++++++++++++++++++++++++++++++++++++++++ >> sys/dev/mmc/mmc_pwrseq_if.m | 38 +++++++++ >> 3 files changed, 234 insertions(+) >> >> diff --git a/sys/conf/files b/sys/conf/files >> index 22083169bfc7..70cdd9f68dc6 100644 >> --- a/sys/conf/files >> +++ b/sys/conf/files >> @@ -2476,6 +2476,8 @@ dev/mmc/mmcbr_if.m standard >> dev/mmc/mmcbus_if.m standard >> dev/mmc/mmcsd.c optional mmcsd !mmccam >> dev/mmc/mmc_fdt_helpers.c optional mmc fdt | mmccam fdt >> +dev/mmc/mmc_pwrseq.c optional mmc fdt | mmccam fdt >> +dev/mmc/mmc_pwrseq_if.m optional mmc fdt | mmccam fdt >> dev/mmcnull/mmcnull.c optional mmcnull >> dev/mpr/mpr.c optional mpr >> dev/mpr/mpr_config.c optional mpr >> diff --git a/sys/dev/mmc/mmc_pwrseq.c b/sys/dev/mmc/mmc_pwrseq.c >> new file mode 100644 >> index 000000000000..d4ccf814fe53 >> --- /dev/null >> +++ b/sys/dev/mmc/mmc_pwrseq.c >> @@ -0,0 +1,194 @@ >> +/* >> + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD >> + * >> + * Copyright 2021 Emmanuel Vadot >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> are >> + * met: >> + * >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above copyright >> + * notice, this list of conditions and the following disclaimer in >> the >> + * documentation and/or other materials provided with the >> distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' >> AND >> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >> + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS >> BE >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR >> + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, >> + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE >> OR >> + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN >> IF >> + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +#include >> +__FBSDID("$FreeBSD$"); >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> + >> +#include >> + >> +#include "mmc_pwrseq_if.h" >> + >> +enum pwrseq_type { >> + PWRSEQ_SIMPLE = 1, >> + PWRSEQ_EMMC, >> +}; >> + >> +static struct ofw_compat_data compat_data[] = { >> + { "mmc-pwrseq-simple", PWRSEQ_SIMPLE }, >> + { "mmc-pwrseq-emmc", PWRSEQ_EMMC }, >> + { NULL, 0 } >> +}; >> + >> +struct mmc_pwrseq_softc { >> + enum pwrseq_type type; >> + clk_t ext_clock; >> + struct gpiobus_pin *reset_gpio; >> + >> + uint32_t post_power_on_delay_ms; >> + uint32_t power_off_delay_us; >> +}; >> + >> +static int >> +mmc_pwrseq_probe(device_t dev) >> +{ >> + enum pwrseq_type type; >> + >> + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) >> + return (ENXIO); >> + >> + type = (enum pwrseq_type)ofw_bus_search_compatible(dev, >> compat_data)->ocd_data; >> + switch (type) { >> + case PWRSEQ_SIMPLE: >> + device_set_desc(dev, "MMC Simple Power sequence"); >> + break; >> + case PWRSEQ_EMMC: >> + device_set_desc(dev, "MMC eMMC Power sequence"); >> + break; >> + } >> + return (BUS_PROBE_DEFAULT); >> +} >> + >> +static int >> +mmc_pwrseq_attach(device_t dev) >> +{ >> + struct mmc_pwrseq_softc *sc; >> + phandle_t node; >> + int rv; >> + >> + sc = device_get_softc(dev); >> + sc->type = (enum pwrseq_type)ofw_bus_search_compatible(dev, >> compat_data)->ocd_data; >> + node = ofw_bus_get_node(dev); >> + >> + if (sc->type == PWRSEQ_SIMPLE) { >> + if (OF_hasprop(node, "clocks")) { >> + rv = clk_get_by_ofw_name(dev, 0, "ext_clock", &sc->ext_clock); >> + if (rv != 0) { >> + device_printf(dev, >> + "Node have a clocks property but no clocks named >> \"ext_clock\"\n"); >> + return (ENXIO); >> + } >> + } >> + OF_getencprop(node, "post-power-on-delay-ms", >> &sc->post_power_on_delay_ms, sizeof(uint32_t)); >> + OF_getencprop(node, "power-off-delay-us", &sc->power_off_delay_us, >> sizeof(uint32_t)); >> + } >> + >> + if (OF_hasprop(node, "reset-gpios")) { >> + if (gpio_pin_get_by_ofw_property(dev, node, "reset-gpios", >> + &sc->reset_gpio) != 0) { >> + device_printf(dev, "Cannot get the reset-gpios\n"); >> + return (ENXIO); >> + } >> + gpio_pin_setflags(sc->reset_gpio, GPIO_PIN_OUTPUT); >> + gpio_pin_set_active(sc->reset_gpio, true); >> + } >> + >> + OF_device_register_xref(OF_xref_from_node(node), dev); >> + return (0); >> +} >> + >> +static int >> +mmc_pwrseq_detach(device_t dev) >> +{ >> + >> + return (EBUSY); >> +} >> + >> +static int >> +mmv_pwrseq_set_power(device_t dev, bool power_on) >> +{ >> + struct mmc_pwrseq_softc *sc; >> + int rv; >> + >> + sc = device_get_softc(dev); >> + >> + if (power_on) { >> + if (sc->ext_clock) { >> + rv = clk_enable(sc->ext_clock); >> + if (rv != 0) >> + return (rv); >> + } >> + >> + if (sc->reset_gpio) { >> + rv = gpio_pin_set_active(sc->reset_gpio, false); >> + if (rv != 0) >> + return (rv); >> + } >> + >> + if (sc->post_power_on_delay_ms) >> + DELAY(sc->post_power_on_delay_ms * 1000); >> + } else { >> + if (sc->reset_gpio) { >> + rv = gpio_pin_set_active(sc->reset_gpio, true); >> + if (rv != 0) >> + return (rv); >> + } >> + >> + if (sc->ext_clock) { >> + rv = clk_stop(sc->ext_clock); >> + if (rv != 0) >> + return (rv); >> + } >> + if (sc->power_off_delay_us) >> + DELAY(sc->power_off_delay_us); >> + } >> + >> + return (0); >> +} >> + >> +static device_method_t mmc_pwrseq_methods[] = { >> + /* Device interface */ >> + DEVMETHOD(device_probe, mmc_pwrseq_probe), >> + DEVMETHOD(device_attach, mmc_pwrseq_attach), >> + DEVMETHOD(device_detach, mmc_pwrseq_detach), >> + >> + DEVMETHOD(mmc_pwrseq_set_power, mmv_pwrseq_set_power), >> + DEVMETHOD_END >> +}; >> + >> +static driver_t mmc_pwrseq_driver = { >> + "mmc_pwrseq", >> + mmc_pwrseq_methods, >> + sizeof(struct mmc_pwrseq_softc), >> +}; >> + >> +static devclass_t mmc_pwrseq_devclass; >> + >> +EARLY_DRIVER_MODULE(mmc_pwrseq, simplebus, mmc_pwrseq_driver, >> mmc_pwrseq_devclass, 0, 0, >> + BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_FIRST); >> +MODULE_VERSION(mmc_pwrseq, 1); >> +SIMPLEBUS_PNP_INFO(compat_data); >> diff --git a/sys/dev/mmc/mmc_pwrseq_if.m b/sys/dev/mmc/mmc_pwrseq_if.m >> new file mode 100644 >> index 000000000000..e94b44052c20 >> --- /dev/null >> +++ b/sys/dev/mmc/mmc_pwrseq_if.m >> @@ -0,0 +1,38 @@ >> +#- >> +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD >> +# >> +# Copyright (c) 2021 Emmanuel Vadot >> +# >> +# Redistribution and use in source and binary forms, with or without >> +# modification, are permitted provided that the following conditions >> +# are met: >> +# 1. Redistributions of source code must retain the above copyright >> +# notice, this list of conditions and the following disclaimer. >> +# 2. Redistributions in binary form must reproduce the above copyright >> +# notice, this list of conditions and the following disclaimer in the >> +# documentation and/or other materials provided with the >> distribution. >> +# >> +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND >> +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >> +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >> PURPOSE >> +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE >> LIABLE >> +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >> CONSEQUENTIAL >> +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE >> GOODS >> +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >> +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, >> STRICT >> +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY >> WAY >> +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >> +# SUCH DAMAGE. >> +# >> +# $FreeBSD$ >> +# >> + >> +INTERFACE mmc_pwrseq; >> + >> +# >> +# Power up/down the card >> +# >> +METHOD int set_power { >> + device_t bus; >> + bool power_on; >> +}; >> > > > -- > Mateusz Guzik > -- Mateusz Guzik