From nobody Mon Sep 18 13:24:15 2023 X-Original-To: dev-commits-src-main@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 4Rq59W2S6Zz4tCFp; Mon, 18 Sep 2023 13:24:15 +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 4Rq59W1glkz4RTr; Mon, 18 Sep 2023 13:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695043455; 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=zk3O8l3Xwl+GpezgDx5TyPQ5psJ+0w8sUyhQah+cuYw=; b=LRs60wyPkY8v36hTrB4T6Yt2jRhfyNY4dTJIGwsowDou5FU99i7Po84EjKLcmKMiloALBp qxQzKIbNjgKcigVt/oJ0vkwsa5cws+aHK84x4uQtTrhsti1YfKfZxpkwYgixTUUAlMi86M bS/p3Wa79FKDrS+Q3LLcdI8RDGLdS5ZGRa6tZs9AlUYO38NL15grh3lMue5umoB7dSkcOg RqSXRSAQgq7U3wXTlJXM4ktwirYKmUMu6I/eTlNIXAa4tkFZLRvxBZ1Q0CK0F84Qbmo1FP DNUcS4u/yN3r17eOQtOjr3uL7/6PX3bEwBXad9q5yHcKnfiMWhcOJAJc/iuNSg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695043455; a=rsa-sha256; cv=none; b=Ef8jiM98CT1YpBQg75HuPDRK+8W4sksrcIHa5icVSWsWqM2cdN0/nB0OkN0dVazWUstKZm 4iGgiBcD66G0qaT1YjXSVjsiLdgweMStb9owOIHb6nNR2tyqu4U934xjJ/Jf/rBXaP07sO IE0OExR/18nVvX6riKueNdyQEkZSf16kRYUdhhQ46xLuY/7BxDOZ7SJILkKYZnfJmXiWnT wgMBrTVR4vzJt0hlBDVVAPJckk3caTeOI63386efW22K+h8xVd5/j5bLtdbk7A20a9XKkJ sKnYq59gid+P5gcGP2iGIlX3pQ04L6wxabHfoelb+xnDWCuH710wnam8IKOqDA== 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=1695043455; 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=zk3O8l3Xwl+GpezgDx5TyPQ5psJ+0w8sUyhQah+cuYw=; b=pTvL1V8i+C9RqX4zOWbinO2W4KfAP3k66wfnT8PK8rU04QgD64BrSRfbCNnLK71yY02KRs 795vRFrA+3T8vRRGifN43MhqkZ9v+vjZiTJNHTY6RE3xP1eFS9VqBJ2/vuf1K/4GljEnP/ FQE3wizayU6IoLLUJQY/hWdF08WNpObPC5Vfzt9Gw2iPgSXwT6MLrfkw8cr9d1p7OQ1+7v glPRrEph8ELxcJm8fEwW29MsJUt17XoAzgSaxO8aOdjdEq14zP+0qQmFcx4Wt7VUBrBcwf LPbSMEXTFmejgjb2wIQU6q/LjXZrVbuKWBkV8AECDyz2YXz4wQyoywED1zxXkQ== 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 4Rq59W0kRwzYDG; Mon, 18 Sep 2023 13:24:15 +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 38IDOFhg096963; Mon, 18 Sep 2023 13:24:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38IDOFG5096960; Mon, 18 Sep 2023 13:24:15 GMT (envelope-from git) Date: Mon, 18 Sep 2023 13:24:15 GMT Message-Id: <202309181324.38IDOFG5096960@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 9377d7049c84 - main - sdhci: fdt: Always enable clock for ZynqMP and RK3399 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 9377d7049c846d1e35c8fc8809c23e6413909fca Auto-Submitted: auto-generated The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=9377d7049c846d1e35c8fc8809c23e6413909fca commit 9377d7049c846d1e35c8fc8809c23e6413909fca Author: Emmanuel Vadot AuthorDate: 2023-09-06 09:07:00 +0000 Commit: Emmanuel Vadot CommitDate: 2023-09-18 13:23:51 +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 --- 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. */