From owner-dev-commits-src-main@freebsd.org Tue Aug 17 07:04:07 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 115C765E5CC; Tue, 17 Aug 2021 07:04:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GphpZ6md4z3qX2; Tue, 17 Aug 2021 07:04:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CFFF31967F; Tue, 17 Aug 2021 07:04:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17H7461a037316; Tue, 17 Aug 2021 07:04:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17H746L2037315; Tue, 17 Aug 2021 07:04:06 GMT (envelope-from git) Date: Tue, 17 Aug 2021 07:04:06 GMT Message-Id: <202108170704.17H746L2037315@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marcin Wojtas Subject: git: 6ad816a99917 - main - sdhci_xenon: remove redundant code in property parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6ad816a999171874c36c73d5794d0d25ff8fd311 Auto-Submitted: auto-generated 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, 17 Aug 2021 07:04:07 -0000 The branch main has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=6ad816a999171874c36c73d5794d0d25ff8fd311 commit 6ad816a999171874c36c73d5794d0d25ff8fd311 Author: Bartlomiej Grzesik AuthorDate: 2021-07-15 15:20:46 +0000 Commit: Marcin Wojtas CommitDate: 2021-08-17 07:03:45 +0000 sdhci_xenon: remove redundant code in property parsing Remove redundant ofw property parsing in driver code, is already taken care of in mmc_fdt_helpers. Move ofw parsing to attach method. Reviewed by: manu Sponsored by: Semihalf Differential Revision: https://reviews.freebsd.org/D31409 --- sys/dev/sdhci/sdhci_xenon.c | 69 +++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/sys/dev/sdhci/sdhci_xenon.c b/sys/dev/sdhci/sdhci_xenon.c index 10cbc5991119..b6f7513245eb 100644 --- a/sys/dev/sdhci/sdhci_xenon.c +++ b/sys/dev/sdhci/sdhci_xenon.c @@ -83,9 +83,6 @@ struct sdhci_xenon_softc { device_t dev; /* Controller device */ int slot_id; /* Controller ID */ phandle_t node; /* FDT node */ - uint32_t quirks; /* Chip specific quirks */ - uint32_t caps; /* If we override SDHCI_CAPABILITIES */ - uint32_t max_clk; /* Max possible freq */ struct resource *irq_res; /* IRQ resource */ void *intrhand; /* Interrupt handle */ struct sdhci_fdt_gpio *gpio; /* GPIO pins for CD detection. */ @@ -95,7 +92,6 @@ struct sdhci_xenon_softc { uint8_t znr; /* PHY ZNR */ uint8_t zpr; /* PHY ZPR */ - bool no_18v; /* No 1.8V support */ bool slow_mode; /* PHY slow mode */ struct mmc_fdt_helper mmc_helper; /* MMC helper for parsing FDT */ @@ -509,32 +505,17 @@ sdhci_xenon_switch_vccq(device_t brdev, device_t reqdev) } } -static int -sdhci_xenon_probe(device_t dev) +static void +sdhci_xenon_fdt_parse(device_t dev, struct sdhci_slot *slot) { struct sdhci_xenon_softc *sc = device_get_softc(dev); pcell_t cid; - sc->quirks = 0; - sc->slot_id = 0; - sc->max_clk = XENON_MMC_MAX_CLK; - - if (!ofw_bus_status_okay(dev)) - return (ENXIO); - - if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) - return (ENXIO); - - sc->node = ofw_bus_get_node(dev); - device_set_desc(dev, "Armada Xenon SDHCI controller"); + mmc_fdt_parse(dev, 0, &sc->mmc_helper, &slot->host); /* Allow dts to patch quirks, slots, and max-frequency. */ if ((OF_getencprop(sc->node, "quirks", &cid, sizeof(cid))) > 0) - sc->quirks = cid; - if ((OF_getencprop(sc->node, "max-frequency", &cid, sizeof(cid))) > 0) - sc->max_clk = cid; - if (OF_hasprop(sc->node, "no-1-8-v")) - sc->no_18v = true; + slot->quirks = cid; if (OF_hasprop(sc->node, "marvell,xenon-phy-slow-mode")) sc->slow_mode = true; sc->znr = XENON_ZNR_DEF_VALUE; @@ -545,6 +526,18 @@ sdhci_xenon_probe(device_t dev) if ((OF_getencprop(sc->node, "marvell,xenon-phy-zpr", &cid, sizeof(cid))) > 0) sc->zpr = cid & XENON_ZPR_MASK; +} + +static int +sdhci_xenon_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "Armada Xenon SDHCI controller"); return (0); } @@ -558,6 +551,8 @@ sdhci_xenon_attach(device_t dev) uint32_t reg; sc->dev = dev; + sc->slot_id = 0; + sc->node = ofw_bus_get_node(dev); /* Allocate IRQ. */ rid = 0; @@ -581,34 +576,34 @@ sdhci_xenon_attach(device_t dev) slot = malloc(sizeof(*slot), M_DEVBUF, M_ZERO | M_WAITOK); + /* + * Set up any gpio pin handling described in the FDT data. This cannot + * fail; see comments in sdhci_fdt_gpio.h for details. + */ + sc->gpio = sdhci_fdt_gpio_setup(dev, slot); + + sdhci_xenon_fdt_parse(dev, slot); + + slot->max_clk = XENON_MMC_MAX_CLK; + if (slot->host.f_max > 0) + slot->max_clk = slot->host.f_max; /* Check if the device is flagged as non-removable. */ - if (OF_hasprop(sc->node, "non-removable")) { + if (sc->mmc_helper.props & MMC_PROP_NON_REMOVABLE) { slot->opt |= SDHCI_NON_REMOVABLE; if (bootverbose) device_printf(dev, "Non-removable media\n"); } - slot->quirks = sc->quirks; - slot->caps = sc->caps; - slot->max_clk = sc->max_clk; sc->slot = slot; - /* - * Set up any gpio pin handling described in the FDT data. This cannot - * fail; see comments in sdhci_fdt_gpio.h for details. - */ - sc->gpio = sdhci_fdt_gpio_setup(dev, slot); - - mmc_fdt_parse(dev, 0, &sc->mmc_helper, &sc->slot->host); - if (sdhci_init_slot(dev, sc->slot, 0)) goto fail; /* 1.2V signaling is not supported. */ sc->slot->host.caps &= ~MMC_CAP_SIGNALING_120; - /* Disable UHS in case of lack of 1.8V VCCQ or the PHY slow mode. */ - if (sc->no_18v || sc->slow_mode) + /* Disable UHS in case of the PHY slow mode. */ + if (sc->slow_mode) sc->slot->host.caps &= ~MMC_CAP_SIGNALING_180; /* Activate the interrupt */