From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04F9A3806D1 for ; Tue, 13 Jan 2026 08:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768294665; cv=none; b=cJuYf/UaovKg0SRMoFf/+of1e1rJmnr/qu5+XeoALjS1H1WQVAUxlt2g3QbtP7qMlBKI8XhLZ0g6RRXlA+wFciBDB3Yp/ZV5Kczty3UTQLgoAaTiA77vF7lCaHYqJSXzpj5D2VEmiLOafSg/0KkIo4mCQ5vpb2TYsEG3ODIFrs4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768294665; c=relaxed/simple; bh=6kxD2UG6kAiT9t38q54b6IeYiTUM8ShWv8UwzjMSauw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=o+pJpOFIY9tG/Tv8nfuwORgKmDmOiy9MSGty5SHxW66/SxAoPJvH8Wl26iBnZZQgQl29EjeAhZPTAJr3fksxSGalZzoCtFzQ+6BOHqsH9KQ6RcmURRnhnW9bfSK56MDpU1AOIwftqIn0DUC0aruKG5FgqDLDAaNjUay1ZgL2yto= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=uFydRBhT; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="uFydRBhT" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-432d2c7a8b9so3688131f8f.2 for ; Tue, 13 Jan 2026 00:57:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1768294656; x=1768899456; darn=vger.kernel.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZMKyGWxNAwt+GdnajQbomOj6BjeEvvPWy5yBEpV57ns=; b=uFydRBhTJtNfW+tAKCQIhWMFoiR2Jy58RR7PkIJecqcEmsKMpXd0sQyeUAn9jIhhHq mJnxJKNta+IS4sUw83XNQ0sbq7UEFK8csSvu9MGBxqJd6uMQdra46oDUvA1C0MgPpiob /IZR6DA7LT0cpFZLX9YHeBXog4SDml0vMiCboiVZI1EFG535Ilw+fyOM0X6Sv75rIbTq Jt4YRYEqO9k55d7ps4pwXvrk99rvUtx85A1e+ixemrB+rNeU1e7lkb3wL0hT7uacHhPt 9NQsUpbllHJmSXMUlo+Gg1PD5C/ArVg4eBbcmCBbc1zF4Kcdi4KO2RpgciV5y7yKNkdG 8ZcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768294656; x=1768899456; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=ZMKyGWxNAwt+GdnajQbomOj6BjeEvvPWy5yBEpV57ns=; b=dbpr37FHyMa54bLZQ1kAX1DwT28ec5D1pxf9H9c7LmcwMrYO+M9GHiashDktjdi89L yYYOhu+8bphd3d8slTy0+UUTLYK1jvF6iDqlCBuNDhEKRN72Z7W5Wg0sPgUBeeAmxMml P9mEh0f10gng4f2dXdSjZAnYX48CwyCSvOFhsspDCIUM3iP8HHHPKm7dZYlzLi1tLc4K PCc9Nu65A9BGMKDnkYoe0P8BxuFHbNzHn6q0fWRyscf8c7JMH84TEd2LexCQx+OZAR4k 3952zZdilY3Ajt7ApC6QYUyT//3I8MpQSXdtx3A+LR2SaEL1r4iGOnDZg/wkatDXREBo LqLg== X-Forwarded-Encrypted: i=1; AJvYcCW39o5uC+GC0QkScneG/uNjvL1cp6YCUbmjUSvLx9FtJLoz5eDIaJs6tACeX0BICUMqhYBbpWiUSspBDCQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx69NcMomy1VOZWtLGIVohpuv9H6dZoaA4P3uWxExT5GoyCu3OU LnybMKonQfY60xAc7wdmCvF7bSbOrxSrHm8PRwtPtEmcCs9EeoVKuZNZpZRWfLRASkU= X-Gm-Gg: AY/fxX5bVMwJi0LEYzIz5RSuWfJxgUFDEuFxSAhy0YzKedoxISjxQkaSHlGOP6aNQxo Jv5SkBBKhlJOGMWx1+BjI+IW0yIetvmafAT0zHxy2MdYWKODsdOegi/qp6RelL+CzP2zjzBKyLV S89kN/ycRi3KLZaURr3l0REf0vRzEMaUYMEsteRvfiSXXdlkEyZ0/py4s83jHXluC4SG05I54cr 66i26vpyWWme6VJxbt8gmDotovMlFRvZmlu2iR7p8powiWn74qYf0rm/mKANs4Gb9wi1Q7ig8la Q21wugg0ou3lIuj9LLNP2wiPboNsJFkkLqttwQkdUlEb37m+/AA/8BvTtQ5Bzm54VO9dONt6i3n WdmQ/Q3EtAOtAr9ezp0Bx4X9xiYh9II+K1PirmeVtReK/1SBMn5KlqcWmwprtRA54RuVjYVG7sN hsv2T9vrvT9QxSBSJpwFU= X-Google-Smtp-Source: AGHT+IGwcIbZu7Reu6gEUybQVWJyifVkO6dMnAxR2TOj6PLpVKDznQPy9IHHIvvCvTuBaNu+Iuy9RA== X-Received: by 2002:a05:6000:2f82:b0:431:8f8:7f2f with SMTP id ffacd0b85a97d-432c3795323mr23143317f8f.34.1768294656128; Tue, 13 Jan 2026 00:57:36 -0800 (PST) Received: from localhost ([2a01:e0a:3c5:5fb1:982f:38af:1a7a:b10]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-432bd5fe67csm42950056f8f.40.2026.01.13.00.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 00:57:35 -0800 (PST) From: Jerome Brunet To: Nick Xie Cc: neil.armstrong@linaro.org, khilman@baylibre.com, martin.blumenstingl@googlemail.com, xianwei.zhao@amlogic.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, robh@kernel.org, nick@khadas.com Subject: Re: [PATCH] arm64: dts: amlogic: S4: fix SD card initialization failure In-Reply-To: <20260113011931.40424-1-nick@khadas.com> (Nick Xie's message of "Tue, 13 Jan 2026 09:19:31 +0800") References: <20260113011931.40424-1-nick@khadas.com> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Tue, 13 Jan 2026 09:57:34 +0100 Message-ID: <1jsec9ritd.fsf@starbuckisacylon.baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On mar. 13 janv. 2026 at 09:19, Nick Xie wrote: > The SD controller (sd@fe08a000) requires a clock source capable of > generating a 400kHz frequency for the identification phase. > > Currently, the sd node uses CLKID_SD_EMMC_B as clkin0 and CLKID_FCLK_DIV2 > as clkin1. Both of these are high-frequency clocks (e.g., ~1GHz). The reason you are having this problem is because CLKID_SD_EMMC_B does not provide 400kHz by default on this platform. We have been operating with this (weak) assumption so far ... and it was OK until now. > The internal divider of the SD controller is limited to a maximum value > of 64 (2^6). With input frequencies significantly higher than 25.6MHz > (400kHz * 64), the driver is unable to generate the required 400kHz > clock, causing the probe to fail with -EINVAL. > > Fix this by reparenting clkin0 to the 24MHz XTAL clock, consistent with > the configuration of the sdio and emmc nodes. This allows the divider > to successfully generate 400kHz (24MHz / 60). > DT generally describe what the HW is, not how you wish to configure it. What you are doing here does not reparent anything. You are actually mis-representing the clock tree, making the MMC device believe it has 24MHz on its clkin0, even-though what it is really has still is CLKID_SD_EMMC_B (presumably running a 1GHz) So if my understanding is correct, you are indeed setting the divider to 60 instead of 64, but you are still dividing 1GHz so what you actually get it 16,6MHz If you want to get 24MHz the clkin0, we need to assign the rate, something we probably should have done before. I'll send something for this > Verified on Khadas VIM1S with SoC S4 S905Y4. > > Fixes: 3ab9d54b5d847 ("arm64: dts: amlogic: enable some device nodes for S4") > > Signed-off-by: Nick Xie > --- > arch/arm64/boot/dts/amlogic/meson-s4.dtsi | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi > index 9d99ed2994dfa..b87bc83b5a9bb 100644 > --- a/arch/arm64/boot/dts/amlogic/meson-s4.dtsi > +++ b/arch/arm64/boot/dts/amlogic/meson-s4.dtsi > @@ -833,7 +833,7 @@ sd: mmc@fe08a000 { > reg = <0x0 0xfe08a000 0x0 0x800>; > interrupts = ; > clocks = <&clkc_periphs CLKID_SDEMMC_B>, > - <&clkc_periphs CLKID_SD_EMMC_B>, > + <&xtal>, > <&clkc_pll CLKID_FCLK_DIV2>; > clock-names = "core", "clkin0", "clkin1"; > resets = <&reset RESET_SD_EMMC_B>; -- Jerome