git: d6a1d41df4fa - stable/14 - sdhci: fdt: Always enable clock for ZynqMP and RK3399
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 18 Oct 2023 14:31:39 UTC
The branch stable/14 has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=d6a1d41df4faf10bb66e62a6bb2ecc5c3b3d43cd
commit d6a1d41df4faf10bb66e62a6bb2ecc5c3b3d43cd
Author: Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2023-09-06 09:07:00 +0000
Commit: Emmanuel Vadot <manu@FreeBSD.org>
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. */