From owner-dev-commits-src-all@freebsd.org Tue Sep 28 18:00:43 2021 Return-Path: Delivered-To: dev-commits-src-all@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 CF25D6A96DF for ; Tue, 28 Sep 2021 18:00:43 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 4HJnNp5Fr8z4Y0D for ; Tue, 28 Sep 2021 18:00:42 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f45.google.com with SMTP id k7so7620249wrd.13 for ; Tue, 28 Sep 2021 11:00:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=HIO+OZgAAJI9Ryrzp/WPMvtKYBIz4HIEJXrrOfxID9U=; b=qcCIxtABmCQaS6Sj020nZJyPCcV1LgBW3hwHKGIUoODpSkQTZ5nY74LhdpXtOufK+h VBUK3yuG7cw5NPtB81XaJ5rUzO3bB2iBajXNnrHhVsONMUYg0wU7cffCN13OZQ+WyM6k BLbDzptPmIlCCY4+4t33q6XAnjPgyZ2aghJ7UdEpyBCo9O0TBWPBjma2TYBsLcHOihlf IedBWJKQ8HWc6mjuwTa83ajsiwx7EK8ebFF0HuA2OCONFnYMyN4pcywqrBSPx5Ow10S8 KnvefLSYUjkFwzF4oDOlbt5YZbax2sLCqGw2loguyknsKsnL6m/VlIMm6EHz4qtClY3i N6tA== X-Gm-Message-State: AOAM530n84uK/qQnFL8MbZ0UPSjVuyR0NZ8EJBRKs9LkeP6u2s+XL8u+ fq8n5GR7793HKeMxAuZX5ycMaA== X-Google-Smtp-Source: ABdhPJxXALFZcwj/YtZw3ES9/Qcy46+STBuw5SqvNk2hHQvB6vU6A9wj7zIRe+m02KhFtQ0UYGGgPQ== X-Received: by 2002:adf:b60d:: with SMTP id f13mr1665843wre.239.1632852036305; Tue, 28 Sep 2021 11:00:36 -0700 (PDT) Received: from smtpclient.apple (global-5-143.nat-2.net.cam.ac.uk. [131.111.5.143]) by smtp.gmail.com with ESMTPSA id o1sm3740722wmq.26.2021.09.28.11.00.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Sep 2021 11:00:35 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: git: 8a8166e5bcfb - main - mmc: switch mmc_helper to device_ api From: Jessica Clarke In-Reply-To: <202109201518.18KFIKnL007451@gitrepo.freebsd.org> Date: Tue, 28 Sep 2021 19:00:34 +0100 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <6D76D431-43A6-4729-90A5-D19EDE05E998@freebsd.org> References: <202109201518.18KFIKnL007451@gitrepo.freebsd.org> To: Marcin Wojtas X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Rspamd-Queue-Id: 4HJnNp5Fr8z4Y0D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of jrtc27@jrtc27.com designates 209.85.221.45 as permitted sender) smtp.mailfrom=jrtc27@jrtc27.com X-Spamd-Result: default: False [-2.50 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; MV_CASE(0.50)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FORGED_SENDER(0.30)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jrtc27@freebsd.org,jrtc27@jrtc27.com]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FREEFALL_USER(0.00)[jrtc27]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[dev-commits-src-all@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.221.45:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.221.45:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[dev-commits-src-all] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Sep 2021 18:00:43 -0000 On 20 Sep 2021, at 16:18, Marcin Wojtas wrote: >=20 > The branch main has been updated by mw: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D8a8166e5bcfb50e2b7280581b600d098= fa6c9fc7 >=20 > commit 8a8166e5bcfb50e2b7280581b600d098fa6c9fc7 > Author: Bartlomiej Grzesik > AuthorDate: 2021-08-02 14:27:23 +0000 > Commit: Marcin Wojtas > CommitDate: 2021-09-20 15:18:02 +0000 >=20 > mmc: switch mmc_helper to device_ api >=20 > Add generic mmc_helper which uses newly introduced = device_*_property > api. Thanks to this change the sd/mmc drivers will be capable > of parsing both DT and ACPI description. >=20 > Ensure backward compatibility for all mmc_fdt_helper users. >=20 > Reviewed by: manu, mw > Sponsored by: Semihalf > Differential revision: https://reviews.freebsd.org/D31598 > --- > sys/arm/allwinner/aw_mmc.c | 2 +- > sys/arm/broadcom/bcm2835/bcm2835_sdhci.c | 2 +- > sys/conf/files | 1 + > sys/dev/mmc/host/dwmmc_var.h | 2 +- > sys/dev/mmc/mmc_fdt_helpers.c | 116 = ++++---------------------- > sys/dev/mmc/mmc_fdt_helpers.h | 42 ++-------- > sys/dev/mmc/mmc_helpers.c | 134 = +++++++++++++++++++++++++++++++ > sys/dev/mmc/mmc_helpers.h | 70 ++++++++++++++++ > sys/dev/sdhci/sdhci_fsl_fdt.c | 2 +- > sys/dev/sdhci/sdhci_xenon.c | 2 +- > 10 files changed, 234 insertions(+), 139 deletions(-) >=20 > diff --git a/sys/arm/allwinner/aw_mmc.c b/sys/arm/allwinner/aw_mmc.c > index 9f215399e62b..3271090f19e3 100644 > --- a/sys/arm/allwinner/aw_mmc.c > +++ b/sys/arm/allwinner/aw_mmc.c > @@ -130,7 +130,7 @@ struct aw_mmc_softc { > int aw_timeout; > struct callout aw_timeoutc; > struct mmc_host aw_host; > - struct mmc_fdt_helper mmc_helper; > + struct mmc_helper mmc_helper; > #ifdef MMCCAM > union ccb * ccb; > struct mmc_sim mmc_sim; > diff --git a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c = b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c > index cd9b60743be3..38617dcd38eb 100644 > --- a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c > +++ b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c > @@ -156,7 +156,7 @@ struct bcm_sdhci_softc { > void * sc_intrhand; > struct mmc_request * sc_req; > struct sdhci_slot sc_slot; > - struct mmc_fdt_helper sc_mmc_helper; > + struct mmc_helper sc_mmc_helper; > int sc_dma_ch; > bus_dma_tag_t sc_dma_tag; > bus_dmamap_t sc_dma_map; > diff --git a/sys/conf/files b/sys/conf/files > index bf1c680093d1..1d3a36ac6bc7 100644 > --- a/sys/conf/files > +++ b/sys/conf/files > @@ -2483,6 +2483,7 @@ 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 ext_resources mmc fdt | = ext_resources mmccam fdt > +dev/mmc/mmc_helpers.c optional ext_resources mmc | = ext_resources mmccam > dev/mmc/mmc_pwrseq.c optional ext_resources mmc fdt | = ext_resources mmccam fdt > dev/mmc/mmc_pwrseq_if.m optional ext_resources mmc fdt | = ext_resources mmccam fdt > dev/mmcnull/mmcnull.c optional mmcnull > diff --git a/sys/dev/mmc/host/dwmmc_var.h = b/sys/dev/mmc/host/dwmmc_var.h > index ef7c91fa628e..a3f20278ad2a 100644 > --- a/sys/dev/mmc/host/dwmmc_var.h > +++ b/sys/dev/mmc/host/dwmmc_var.h > @@ -56,7 +56,7 @@ struct dwmmc_softc { > device_t dev; > void *intr_cookie; > struct mmc_host host; > - struct mmc_fdt_helper mmc_helper; > + struct mmc_helper mmc_helper; > struct mtx sc_mtx; > #ifdef MMCCAM > union ccb * ccb; > diff --git a/sys/dev/mmc/mmc_fdt_helpers.c = b/sys/dev/mmc/mmc_fdt_helpers.c > index 291a4bc72ff2..249a430311fa 100644 > --- a/sys/dev/mmc/mmc_fdt_helpers.c > +++ b/sys/dev/mmc/mmc_fdt_helpers.c > @@ -45,105 +45,21 @@ __FBSDID("$FreeBSD$"); > #include > #endif >=20 > -#include "mmc_pwrseq_if.h" > - > -static inline void > -mmc_fdt_parse_sd_speed(phandle_t node, struct mmc_host *host) > -{ > - bool no_18v =3D false; > - > - /*=20 > - * Parse SD supported modes=20 > - * All UHS-I modes requires 1.8V signaling. > - */ > - if (OF_hasprop(node, "no-1-8-v")) > - no_18v =3D true; > - if (OF_hasprop(node, "cap-sd-highspeed")) > - host->caps |=3D MMC_CAP_HSPEED; > - if (OF_hasprop(node, "sd-uhs-sdr12") && no_18v =3D=3D false) > - host->caps |=3D MMC_CAP_UHS_SDR12 | = MMC_CAP_SIGNALING_180; > - if (OF_hasprop(node, "sd-uhs-sdr25") && no_18v =3D=3D false) > - host->caps |=3D MMC_CAP_UHS_SDR25 | = MMC_CAP_SIGNALING_180; > - if (OF_hasprop(node, "sd-uhs-sdr50") && no_18v =3D=3D false) > - host->caps |=3D MMC_CAP_UHS_SDR50 | = MMC_CAP_SIGNALING_180; > - if (OF_hasprop(node, "sd-uhs-sdr104") && no_18v =3D=3D false) > - host->caps |=3D MMC_CAP_UHS_SDR104 | = MMC_CAP_SIGNALING_180; > - if (OF_hasprop(node, "sd-uhs-ddr50") && no_18v =3D=3D false) > - host->caps |=3D MMC_CAP_UHS_DDR50 | = MMC_CAP_SIGNALING_180; > -} > +#include >=20 > -static inline void > -mmc_fdt_parse_mmc_speed(phandle_t node, struct mmc_host *host) > -{ > - > - /* Parse eMMC supported modes */ > - if (OF_hasprop(node, "cap-mmc-highspeed")) > - host->caps |=3D MMC_CAP_HSPEED; > - if (OF_hasprop(node, "mmc-ddr-1_2v")) > - host->caps |=3D MMC_CAP_MMC_DDR52_120 | = MMC_CAP_SIGNALING_120; > - if (OF_hasprop(node, "mmc-ddr-1_8v")) > - host->caps |=3D MMC_CAP_MMC_DDR52_180 | = MMC_CAP_SIGNALING_180; > - if (OF_hasprop(node, "mmc-ddr-3_3v")) > - host->caps |=3D MMC_CAP_SIGNALING_330; > - if (OF_hasprop(node, "mmc-hs200-1_2v")) > - host->caps |=3D MMC_CAP_MMC_HS200_120 | = MMC_CAP_SIGNALING_120; > - if (OF_hasprop(node, "mmc-hs200-1_8v")) > - host->caps |=3D MMC_CAP_MMC_HS200_180 | = MMC_CAP_SIGNALING_180; > - if (OF_hasprop(node, "mmc-hs400-1_2v")) > - host->caps |=3D MMC_CAP_MMC_HS400_120 | = MMC_CAP_SIGNALING_120; > - if (OF_hasprop(node, "mmc-hs400-1_8v")) > - host->caps |=3D MMC_CAP_MMC_HS400_180 | = MMC_CAP_SIGNALING_180; > - if (OF_hasprop(node, "mmc-hs400-enhanced-strobe")) > - host->caps |=3D MMC_CAP_MMC_ENH_STROBE; > -} > +#include "mmc_pwrseq_if.h" >=20 > int > -mmc_fdt_parse(device_t dev, phandle_t node, struct mmc_fdt_helper = *helper, > +mmc_fdt_parse(device_t dev, phandle_t node, struct mmc_helper = *helper, > struct mmc_host *host) > { > - uint32_t bus_width; > + struct mmc_helper mmc_helper; > phandle_t pwrseq_xref; >=20 > - if (node <=3D 0) > - node =3D ofw_bus_get_node(dev); > - if (node <=3D 0) > - return (ENXIO); > - > - if (OF_getencprop(node, "bus-width", &bus_width, = sizeof(uint32_t)) <=3D 0) > - bus_width =3D 1; > - > - if (bus_width >=3D 4) > - host->caps |=3D MMC_CAP_4_BIT_DATA; > - if (bus_width >=3D 8) > - host->caps |=3D MMC_CAP_8_BIT_DATA; > + memset(&mmc_helper, 0, sizeof(mmc_helper)); > + mmc_parse(dev, &mmc_helper, host); >=20 > - /*=20 > - * max-frequency is optional, drivers should tweak this value > - * if it's not present based on the clock that the mmc = controller > - * operates on > - */ > - OF_getencprop(node, "max-frequency", &host->f_max, = sizeof(uint32_t)); > - > - if (OF_hasprop(node, "broken-cd")) > - helper->props |=3D MMC_PROP_BROKEN_CD; > - if (OF_hasprop(node, "non-removable")) > - helper->props |=3D MMC_PROP_NON_REMOVABLE; > - if (OF_hasprop(node, "wp-inverted")) > - helper->props |=3D MMC_PROP_WP_INVERTED; > - if (OF_hasprop(node, "cd-inverted")) > - helper->props |=3D MMC_PROP_CD_INVERTED; > - if (OF_hasprop(node, "no-sdio")) > - helper->props |=3D MMC_PROP_NO_SDIO; > - if (OF_hasprop(node, "no-sd")) > - helper->props |=3D MMC_PROP_NO_SD; > - if (OF_hasprop(node, "no-mmc")) > - helper->props |=3D MMC_PROP_NO_MMC; > - > - if (!(helper->props & MMC_PROP_NO_SD)) > - mmc_fdt_parse_sd_speed(node, host); > - > - if (!(helper->props & MMC_PROP_NO_MMC)) > - mmc_fdt_parse_mmc_speed(node, host); > + helper->props =3D mmc_helper.props; >=20 > #ifdef EXT_RESOURCES > /* > @@ -200,7 +116,7 @@ mmc_fdt_parse(device_t dev, phandle_t node, struct = mmc_fdt_helper *helper, > static void > cd_intr(void *arg) > { > - struct mmc_fdt_helper *helper =3D arg; > + struct mmc_helper *helper =3D arg; >=20 > taskqueue_enqueue_timeout(taskqueue_swi_giant, > &helper->cd_delayed_task, -(hz / 2)); > @@ -209,7 +125,7 @@ cd_intr(void *arg) > static void > cd_card_task(void *arg, int pending __unused) > { > - struct mmc_fdt_helper *helper =3D arg; > + struct mmc_helper *helper =3D arg; > bool cd_present; >=20 > cd_present =3D mmc_fdt_gpio_get_present(helper); > @@ -228,7 +144,7 @@ cd_card_task(void *arg, int pending __unused) > * Card detect setup. > */ > static void > -cd_setup(struct mmc_fdt_helper *helper, phandle_t node) > +cd_setup(struct mmc_helper *helper, phandle_t node) > { > int pincaps; > device_t dev; > @@ -330,7 +246,7 @@ without_interrupts: > * Write protect setup. > */ > static void > -wp_setup(struct mmc_fdt_helper *helper, phandle_t node) > +wp_setup(struct mmc_helper *helper, phandle_t node) > { > device_t dev; >=20 > @@ -352,7 +268,7 @@ wp_setup(struct mmc_fdt_helper *helper, phandle_t = node) > } >=20 > int > -mmc_fdt_gpio_setup(device_t dev, phandle_t node, struct = mmc_fdt_helper *helper, > +mmc_fdt_gpio_setup(device_t dev, phandle_t node, struct mmc_helper = *helper, > mmc_fdt_cd_handler handler) > { >=20 > @@ -377,7 +293,7 @@ mmc_fdt_gpio_setup(device_t dev, phandle_t node, = struct mmc_fdt_helper *helper, > } >=20 > void > -mmc_fdt_gpio_teardown(struct mmc_fdt_helper *helper) > +mmc_fdt_gpio_teardown(struct mmc_helper *helper) > { >=20 > if (helper =3D=3D NULL) > @@ -396,7 +312,7 @@ mmc_fdt_gpio_teardown(struct mmc_fdt_helper = *helper) > } >=20 > bool > -mmc_fdt_gpio_get_present(struct mmc_fdt_helper *helper) > +mmc_fdt_gpio_get_present(struct mmc_helper *helper) > { > bool pinstate; >=20 > @@ -411,7 +327,7 @@ mmc_fdt_gpio_get_present(struct mmc_fdt_helper = *helper) > } >=20 > bool > -mmc_fdt_gpio_get_readonly(struct mmc_fdt_helper *helper) > +mmc_fdt_gpio_get_readonly(struct mmc_helper *helper) > { > bool pinstate; >=20 > @@ -427,7 +343,7 @@ mmc_fdt_gpio_get_readonly(struct mmc_fdt_helper = *helper) > } >=20 > void > -mmc_fdt_set_power(struct mmc_fdt_helper *helper, enum mmc_power_mode = power_mode) > +mmc_fdt_set_power(struct mmc_helper *helper, enum mmc_power_mode = power_mode) > { > int reg_status; > int rv; > diff --git a/sys/dev/mmc/mmc_fdt_helpers.h = b/sys/dev/mmc/mmc_fdt_helpers.h > index e6d6f3fbfd84..f07ca1684440 100644 > --- a/sys/dev/mmc/mmc_fdt_helpers.h > +++ b/sys/dev/mmc/mmc_fdt_helpers.h > @@ -37,43 +37,17 @@ > #include > #endif >=20 > -struct mmc_fdt_helper { > - device_t dev; > - gpio_pin_t wp_pin; > - gpio_pin_t cd_pin; > - void * cd_ihandler; > - struct resource * cd_ires; > - int cd_irid; > - void (*cd_handler)(device_t, bool); > - struct timeout_task cd_delayed_task; > - bool cd_disabled; > - bool wp_disabled; > - bool cd_present; > - uint32_t props; > -#define MMC_PROP_BROKEN_CD (1 << 0) > -#define MMC_PROP_NON_REMOVABLE (1 << 1) > -#define MMC_PROP_WP_INVERTED (1 << 2) > -#define MMC_PROP_CD_INVERTED (1 << 3) > -#define MMC_PROP_DISABLE_WP (1 << 4) > -#define MMC_PROP_NO_SDIO (1 << 5) > -#define MMC_PROP_NO_SD (1 << 6) > -#define MMC_PROP_NO_MMC (1 << 7) > +#include >=20 > -#ifdef EXT_RESOURCES > - regulator_t vmmc_supply; > - regulator_t vqmmc_supply; > -#endif > - > - device_t mmc_pwrseq; > -}; > +#define mmc_fdt_helper mmc_helper /* For backwards compatibility */ >=20 > typedef void (*mmc_fdt_cd_handler)(device_t dev, bool present); >=20 > -int mmc_fdt_parse(device_t dev, phandle_t node, struct mmc_fdt_helper = *helper, struct mmc_host *host); > -int mmc_fdt_gpio_setup(device_t dev, phandle_t node, struct = mmc_fdt_helper *helper, mmc_fdt_cd_handler handler); > -void mmc_fdt_gpio_teardown(struct mmc_fdt_helper *helper); > -bool mmc_fdt_gpio_get_present(struct mmc_fdt_helper *helper); > -bool mmc_fdt_gpio_get_readonly(struct mmc_fdt_helper *helper); > -void mmc_fdt_set_power(struct mmc_fdt_helper *helper, enum = mmc_power_mode power_mode); > +int mmc_fdt_parse(device_t dev, phandle_t node, struct mmc_helper = *helper, struct mmc_host *host); > +int mmc_fdt_gpio_setup(device_t dev, phandle_t node, struct = mmc_helper *helper, mmc_fdt_cd_handler handler); > +void mmc_fdt_gpio_teardown(struct mmc_helper *helper); > +bool mmc_fdt_gpio_get_present(struct mmc_helper *helper); > +bool mmc_fdt_gpio_get_readonly(struct mmc_helper *helper); > +void mmc_fdt_set_power(struct mmc_helper *helper, enum mmc_power_mode = power_mode); >=20 > #endif > diff --git a/sys/dev/mmc/mmc_helpers.c b/sys/dev/mmc/mmc_helpers.c > new file mode 100644 > index 000000000000..0e1e16666367 > --- /dev/null > +++ b/sys/dev/mmc/mmc_helpers.c > @@ -0,0 +1,134 @@ > +/* > + * Copyright 2019 Emmanuel Vadot > + * Copyright (c) 2017 Ian Lepore All rights = reserved. > + * > + * 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 > + > +static inline void > +mmc_parse_sd_speed(device_t dev, struct mmc_host *host) > +{ > + bool no_18v =3D false; > + > + /* > + * Parse SD supported modes > + * All UHS-I modes requires 1.8V signaling. > + */ > + if (device_has_property(dev, "no-1-8-v")) > + no_18v =3D true; > + if (device_has_property(dev, "cap-sd-highspeed")) > + host->caps |=3D MMC_CAP_HSPEED; > + if (device_has_property(dev, "sd-uhs-sdr12") && !no_18v) > + host->caps |=3D MMC_CAP_UHS_SDR12 | = MMC_CAP_SIGNALING_180; > + if (device_has_property(dev, "sd-uhs-sdr25") && !no_18v) > + host->caps |=3D MMC_CAP_UHS_SDR25 | = MMC_CAP_SIGNALING_180; > + if (device_has_property(dev, "sd-uhs-sdr50") && !no_18v) > + host->caps |=3D MMC_CAP_UHS_SDR50 | = MMC_CAP_SIGNALING_180; > + if (device_has_property(dev, "sd-uhs-sdr104") && !no_18v) > + host->caps |=3D MMC_CAP_UHS_SDR104 | = MMC_CAP_SIGNALING_180; > + if (device_has_property(dev, "sd-uhs-ddr50") && !no_18v) > + host->caps |=3D MMC_CAP_UHS_DDR50 | = MMC_CAP_SIGNALING_180; > +} > + > +static inline void > +mmc_parse_mmc_speed(device_t dev, struct mmc_host *host) > +{ > + /* Parse eMMC supported modes */ > + if (device_has_property(dev, "cap-mmc-highspeed")) > + host->caps |=3D MMC_CAP_HSPEED; > + if (device_has_property(dev, "mmc-ddr-1_2v")) > + host->caps |=3D MMC_CAP_MMC_DDR52_120 | = MMC_CAP_SIGNALING_120; > + if (device_has_property(dev, "mmc-ddr-1_8v")) > + host->caps |=3D MMC_CAP_MMC_DDR52_180 | = MMC_CAP_SIGNALING_180; > + if (device_has_property(dev, "mmc-ddr-3_3v")) > + host->caps |=3D MMC_CAP_SIGNALING_330; > + if (device_has_property(dev, "mmc-hs200-1_2v")) > + host->caps |=3D MMC_CAP_MMC_HS200_120 | = MMC_CAP_SIGNALING_120; > + if (device_has_property(dev, "mmc-hs200-1_8v")) > + host->caps |=3D MMC_CAP_MMC_HS200_180 | = MMC_CAP_SIGNALING_180; > + if (device_has_property(dev, "mmc-hs400-1_2v")) > + host->caps |=3D MMC_CAP_MMC_HS400_120 | = MMC_CAP_SIGNALING_120; > + if (device_has_property(dev, "mmc-hs400-1_8v")) > + host->caps |=3D MMC_CAP_MMC_HS400_180 | = MMC_CAP_SIGNALING_180; > + if (device_has_property(dev, "mmc-hs400-enhanced-strobe")) > + host->caps |=3D MMC_CAP_MMC_ENH_STROBE; > +} > + > +int > +mmc_parse(device_t dev, struct mmc_helper *helper, struct mmc_host = *host) > +{ > + uint64_t bus_width, max_freq; > + > + bus_width =3D 0; > + if (device_get_property(dev, "bus-width", &bus_width, = sizeof(uint64_t)) <=3D 0) > + bus_width =3D 1; > + > + if (bus_width >=3D 4) > + host->caps |=3D MMC_CAP_4_BIT_DATA; > + if (bus_width >=3D 8) > + host->caps |=3D MMC_CAP_8_BIT_DATA; > + > + /* > + * max-frequency is optional, drivers should tweak this value > + * if it's not present based on the clock that the mmc = controller > + * operates on > + */ > + max_freq =3D 0; > + device_get_property(dev, "max-frequency", &max_freq, = sizeof(uint64_t)); > + host->f_max =3D max_freq; Previously OF_getencprop was called with &host->f_max so it would only be written to if it existed. Now it is instead written to with the value of 0 if the property doesn=E2=80=99t exist. Both aw_mmc and dwmmc = set f_max to a default value *before* calling mmc_fdt_parse so that is now clobbered. This commit breaks booting on the Stratix 10 which uses dwmmc (boot hangs at the point where da0 would normally attach), and reverting it succeeds. I don=E2=80=99t know if f_max being clobbered is = the cause of that (I=E2=80=99ll try tomorrow), but it seems likely, and is certainly a bug in this commit. Jess