From nobody Wed Oct 18 14:31:39 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S9YFR6gKXz4x5yd; Wed, 18 Oct 2023 14:31:39 +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 4S9YFR484Yz3Mt4; Wed, 18 Oct 2023 14:31:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697639499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=a7oWxftNk2QtOnJ3trMS+W/3xD0xoFBrJa+VDvILBpM=; b=V2lZBJfEwdtDjoJXoVeYsG8KJY1Hg3JDgZMkGTDLh1sxeQqEkxNvyfG9XOaZwFIBMtS4k7 aIWbSYRoMOHWMOxByDRHdBR0A4MtPSsUq0AgUKf7bKtc5R1h8HqitSNUiuIm4qZxlSq5s1 DHf/jpe4N/e1KDjlUAzr+KXUmz1wfd0FXk/egl4Dsb74vbdgyLdlQvanNqG412WlJuv4BC v8XOXK4uPbdyQbImzmnnPl/6jdLnVRTQQ1Ft6XCAtQt0wLev0tnroC+JAQy2LbwHUGH9We aaccNctitLnl0ceYWUOESNTXDqNETN0MH/FkjLbIXB+nmnI0JC1U0dJxPoDqOw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697639499; a=rsa-sha256; cv=none; b=nmY9vhqZtOzRL1Ne74czrueL5gKLdytPVDLAcwsDUWjJQ9t8M6aET1fxWYJ79pYfAda/hJ rSX3Ri+8SQSwTxFJyA/GU/yobK5eeUmFYctXYptKpv0phwJy2CXdsxUUHgBoMpAMzkQKey 0uujtBS1erFaTE8WUGw9cirkyPpV7da7Df46eCWM6aslzhIFL8E/0O9UCYhJOwWTRwGk4h Kg7tAC1vrE1wiACels3fqfm7q1MpIN6WMc+d6C9TBCqkfo1qy7HjXh8m61lpH+XIJ94mWh UUFTGIG42Svcn6Etx7PNhFYW9G1N8215It3deZbWMHyn9OoLgPsvmTIvooKbrg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697639499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=a7oWxftNk2QtOnJ3trMS+W/3xD0xoFBrJa+VDvILBpM=; b=hT1OkwoB2W3LbLv4WIAUb3igJpmWIQ2kDzbqx4BHUxp31diV6nYXmLK0+aHF9iiOMvRoF5 gBMw9TXibdoNUBl5qZRq2HHXjBTNsASe432eezGH87zNZ+RAtU3g1UR3AAra5YKm57Lxlm D7uApqDrOPB9tGReCS4EypUHFbbi7nWT0e1e9eoXqkn1qLI7KUmuT8HFPnXRwB+8yH98MP OTc1cu4lB2feNXzr2i0TfbCOOVkaCS2b9yx/yVcO+MKjYeSkm+4sTm9zBEYpm+UOH4TLi2 fuvOu7b/oDQ0Ecnv4q025ihImIiggM4Z24NeIPxlXsTSeLtOEFOKbDOpxHRhGQ== 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 4S9YFR3Ftyz18rP; Wed, 18 Oct 2023 14:31:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39IEVdHw089161; Wed, 18 Oct 2023 14:31:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39IEVdev089158; Wed, 18 Oct 2023 14:31:39 GMT (envelope-from git) Date: Wed, 18 Oct 2023 14:31:39 GMT Message-Id: <202310181431.39IEVdev089158@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: d6a1d41df4fa - stable/14 - sdhci: fdt: Always enable clock for ZynqMP and RK3399 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: d6a1d41df4faf10bb66e62a6bb2ecc5c3b3d43cd Auto-Submitted: auto-generated The branch stable/14 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=d6a1d41df4faf10bb66e62a6bb2ecc5c3b3d43cd commit d6a1d41df4faf10bb66e62a6bb2ecc5c3b3d43cd Author: Emmanuel Vadot AuthorDate: 2023-09-06 09:07:00 +0000 Commit: Emmanuel Vadot CommitDate: 2023-10-18 14:31:07 +0000 sdhci: fdt: Always enable clock for ZynqMP and RK3399 Those two (in fact all of the supported one in this driver except RK3568) always needs the clocks to be enabled. Reviewed-by: bz Differential Revision: https://reviews.freebsd.org/D41808 Sponsored by: Beckhoff Automation GmbH & Co. KG (cherry picked from commit 9377d7049c846d1e35c8fc8809c23e6413909fca) --- sys/dev/sdhci/sdhci_fdt.c | 59 +++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/sys/dev/sdhci/sdhci_fdt.c b/sys/dev/sdhci/sdhci_fdt.c index 16748dd4982c..372b08a3b78a 100644 --- a/sys/dev/sdhci/sdhci_fdt.c +++ b/sys/dev/sdhci/sdhci_fdt.c @@ -268,13 +268,9 @@ sdhci_init_rk3399_emmccardclk(device_t dev) } static int -sdhci_init_rk3399(device_t dev) +sdhci_init_clocks(device_t dev) { struct sdhci_fdt_softc *sc = device_get_softc(dev); - struct syscon *grf = NULL; - phandle_t node; - uint64_t freq; - uint32_t mask, val; int error; /* Get and activate clocks */ @@ -288,11 +284,6 @@ sdhci_init_rk3399(device_t dev) device_printf(dev, "cannot enable xin clock\n"); return (ENXIO); } - error = clk_get_freq(sc->clk_xin, &freq); - if (error != 0) { - device_printf(dev, "cannot get xin clock frequency\n"); - return (ENXIO); - } error = clk_get_by_ofw_name(dev, 0, "clk_ahb", &sc->clk_ahb); if (error != 0) { device_printf(dev, "cannot get ahb clock\n"); @@ -304,6 +295,25 @@ sdhci_init_rk3399(device_t dev) return (ENXIO); } + return (0); +} + +static int +sdhci_init_rk3399(device_t dev) +{ + struct sdhci_fdt_softc *sc = device_get_softc(dev); + struct syscon *grf = NULL; + phandle_t node; + uint64_t freq; + uint32_t mask, val; + int error; + + error = clk_get_freq(sc->clk_xin, &freq); + if (error != 0) { + device_printf(dev, "cannot get xin clock frequency\n"); + return (ENXIO); + } + /* Register clock */ sdhci_init_rk3399_emmccardclk(dev); @@ -561,7 +571,7 @@ sdhci_fdt_attach(device_t dev) { struct sdhci_fdt_softc *sc = device_get_softc(dev); struct sdhci_slot *slot; - int err, slots, rid, i; + int err, slots, rid, i, compat; sc->dev = dev; @@ -574,24 +584,33 @@ sdhci_fdt_attach(device_t dev) return (ENOMEM); } - if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == - SDHCI_FDT_RK3399) { - /* Initialize SDHCI */ - err = sdhci_init_rk3399(dev); + compat = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + switch (compat) { + case SDHCI_FDT_RK3399: + case SDHCI_FDT_XLNX_ZMP: + err = sdhci_init_clocks(dev); if (err != 0) { - device_printf(dev, "Cannot init RK3399 SDHCI\n"); + device_printf(dev, "Cannot init clocks\n"); return (err); } - } - - if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == - SDHCI_FDT_RK3568) { + if (compat == SDHCI_FDT_RK3399) { + err = sdhci_init_rk3399(dev); + if (err != 0) { + device_printf(dev, "Cannot init RK3399 SDHCI\n"); + return (err); + } + } + break; + case SDHCI_FDT_RK3568: /* setup & enable clocks */ if (clk_get_by_ofw_name(dev, 0, "core", &sc->clk_core)) { device_printf(dev, "cannot get core clock\n"); return (ENXIO); } clk_enable(sc->clk_core); + break; + default: + break; } /* Scan all slots. */