From patchwork Fri Nov 6 09:27:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 1395569 X-Patchwork-Delegate: narmstrong@baylibre.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=S+Xz5PBC; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CSFVT5WWkz9sSn for ; Fri, 6 Nov 2020 20:30:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 52FE582249; Fri, 6 Nov 2020 10:30:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="S+Xz5PBC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 329A382249; Fri, 6 Nov 2020 10:30:08 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1B96482249 for ; Fri, 6 Nov 2020 10:30:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=narmstrong@baylibre.com Received: by mail-wm1-x343.google.com with SMTP id c9so680604wml.5 for ; Fri, 06 Nov 2020 01:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t6lf+d6uFt5Cp26dATeppQeRxqpNUSXTpM90BKJ6/fs=; b=S+Xz5PBCOhYsOubhUTLNIN60gSoy8H3DAJWzuKKXZqNA9qMHZSkBPy7qTzHjFrWzMP vHz07zJmC0gQxo7rPveuTd7p2c2BRwAg/yNsCTHGDFSfcMPnPv0mRsjEL6qCK36/ebzb 6Of9+QOZmrumAlqJDzLUHYxDrF1t7LJDouzFt4/nHbTi8WSfvXsNkQ8ALT4P5W12YSNb +H6iVFyVG06HPnJ+kIo9kb3fShqVL3xpPqef0lrWofYtX/1KsyAzGKJA557VSSlH1hJv kVW/MbPbIFEApQvzTFNcBcgEU1q50z41tOK6EyCvhAtcmi8FxkpmvL0/NJm5j8mcf23j mL3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t6lf+d6uFt5Cp26dATeppQeRxqpNUSXTpM90BKJ6/fs=; b=S9dl7DZo2cxeaItkBheOIoTiETjveBJ+PkCjVLKJ2dVQ+28/0gqB/5+6Bh5cE5+qiY 2r6++UyxRyXztD7fwAFkMH4dnDGXlvFY//31UZN/P4vioaKZ+6er+wdp70N+OVzj4Tkh INg8Qx4VKuom4PsfDCo5fSGCZ3t1YRGJ70yU2hKohsFKXiEikGUeYe0cBsgmP4wDYKaC e+N/cX0rp9W/UvvgjA/zEZct3QWYxsJZDu/MuXyHEPqgaujbSOrKtvqzcbRYM08QRlGN fV8ZPU2M/5UQbUQ6po+mCsD/ixxctCQO63pfxnXWWWg1lQxn+U7U4QY8G6vgk/GS/2i/ x9Fw== X-Gm-Message-State: AOAM532menm1axsVP7EtR+oj/Az4WiYx4Il3Tvu2H2KvSk3RN0Pz1Tm4 SWo7VYayYKN8Qhi48iiDqa6YQxReQ7xVb0OCC1Y= X-Google-Smtp-Source: ABdhPJyjk+vjBxnJIgpxGlIFuh8kuDcsiSpr1QJNZEaOx2wZorrX4eeLSDbFz72JSQ9f1abMx43osw== X-Received: by 2002:a1c:87:: with SMTP id 129mr1453758wma.34.1604655002130; Fri, 06 Nov 2020 01:30:02 -0800 (PST) Received: from localhost.localdomain (home.beaume.starnux.net. [82.236.8.43]) by smtp.gmail.com with ESMTPSA id a128sm1365176wmf.5.2020.11.06.01.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 01:30:01 -0800 (PST) From: Neil Armstrong To: u-boot@lists.denx.de Cc: u-boot-amlogic@groups.io, Neil Armstrong Subject: [PATCH 2/3] mmc: meson-gx: limit max frequency on SM1 SoCs Date: Fri, 6 Nov 2020 10:27:54 +0100 Message-Id: <20201106092755.2250773-3-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106092755.2250773-1-narmstrong@baylibre.com> References: <20201106092755.2250773-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Amlogic SM1 SoCs doesn't handle very well high clocks from the DIV2 input Thus we limit the max freq to 26MHz on SM1 SoCs until we handle higher frequencies via the first input from a composite clock. Here 26MHz corresponds to MMC_HS clock speed. We also add a u-boot only sm1 compatible to distinguish the controller. Finally a TOFIX is added to precise the clock management should use the clock controller instead of local management with fixed clock rates. Signed-off-by: Neil Armstrong --- drivers/mmc/meson_gx_mmc.c | 26 +++++++++++++++++++++++--- drivers/mmc/meson_gx_mmc.h | 5 +++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c index 9350edf3fa..2c6b6cd15b 100644 --- a/drivers/mmc/meson_gx_mmc.c +++ b/drivers/mmc/meson_gx_mmc.c @@ -17,6 +17,14 @@ #include #include "meson_gx_mmc.h" +bool meson_gx_mmc_is_compatible(struct udevice *dev, + enum meson_gx_mmc_compatible family) +{ + enum meson_gx_mmc_compatible compat = dev_get_driver_data(dev); + + return compat == family; +} + static inline void *get_regbase(const struct mmc *mmc) { struct meson_mmc_platdata *pdata = mmc->priv; @@ -42,6 +50,8 @@ static void meson_mmc_config_clock(struct mmc *mmc) if (!mmc->clock) return; + /* TOFIX This should use the proper clock taken from DT */ + /* 1GHz / CLK_MAX_DIV = 15,9 MHz */ if (mmc->clock > 16000000) { clk = SD_EMMC_CLKSRC_DIV2; @@ -265,7 +275,16 @@ static int meson_mmc_probe(struct udevice *dev) cfg->host_caps = MMC_MODE_8BIT | MMC_MODE_4BIT | MMC_MODE_HS_52MHz | MMC_MODE_HS; cfg->f_min = DIV_ROUND_UP(SD_EMMC_CLKSRC_24M, CLK_MAX_DIV); - cfg->f_max = 100000000; /* 100 MHz */; + /* + * TOFIX SM1 SoCs doesn't handle very well high clocks from the DIV2 input + * Thus we limit the max freq to 26MHz on SM1 SoCs until we handle higher + * frequencies via the first input from a composite clock + * 26MHz corresponds to MMC_HS clock speed + */ + if (meson_gx_mmc_is_compatible(dev, MMC_COMPATIBLE_SM1)) + cfg->f_max = 26000000; /* 26 MHz */ + else + cfg->f_max = 100000000; /* 100 MHz */ cfg->b_max = 511; /* max 512 - 1 blocks */ cfg->name = dev->name; @@ -308,8 +327,9 @@ int meson_mmc_bind(struct udevice *dev) } static const struct udevice_id meson_mmc_match[] = { - { .compatible = "amlogic,meson-gx-mmc" }, - { .compatible = "amlogic,meson-axg-mmc" }, + { .compatible = "amlogic,meson-gx-mmc", .data = MMC_COMPATIBLE_GX }, + { .compatible = "amlogic,meson-axg-mmc", .data = MMC_COMPATIBLE_GX }, + { .compatible = "amlogic,meson-sm1-mmc", .data = MMC_COMPATIBLE_SM1 }, { /* sentinel */ } }; diff --git a/drivers/mmc/meson_gx_mmc.h b/drivers/mmc/meson_gx_mmc.h index b4544b5562..92aec5329f 100644 --- a/drivers/mmc/meson_gx_mmc.h +++ b/drivers/mmc/meson_gx_mmc.h @@ -9,6 +9,11 @@ #include #include +enum meson_gx_mmc_compatible { + MMC_COMPATIBLE_GX, + MMC_COMPATIBLE_SM1, +}; + #define SDIO_PORT_A 0 #define SDIO_PORT_B 1 #define SDIO_PORT_C 2