From patchwork Tue Dec 10 07:32:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13900969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39A50E7717F for ; Tue, 10 Dec 2024 07:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fU9h1qciZfo1eCFrj9RBOWdEPoZjJk9V1VI96TtLyqU=; b=CWj8fZ5fawGz/I aEGzRB0UHr4Lqxx9tNT0i2qylcMm2qWq0WNYdWxxTHjKbEvLLjtMZ95ByMI9aSh/VlsyfY42gSPKW hYfN3G2mNsEkGLXfDryRS9Gv7p9PoqDdjVAmcCQx1f6s0fXGHxbAH5kMxlU0yGuGZhon4Ub68R7Bk PEfdw4ZA8Wzf7guuO5q4p3LD+I4K7wfNJkJVJqnw4QNHj6RFQCG9yEzl6dKue55QKOSqlxDgRhxqF uS4aUXegHABTT2JnO+W+b7zAliLbGexNILlyQQCiWq0uwtIhBdApl+CUrf9RZB+dtjzlrbVf8YDpA qDCMCVlzzoEKFnNlA0Ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKukH-0000000AZGA-1GSN; Tue, 10 Dec 2024 07:33:25 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKujF-0000000AZ2i-1oXG for linux-mediatek@lists.infradead.org; Tue, 10 Dec 2024 07:32:22 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2164b1f05caso18573545ad.3 for ; Mon, 09 Dec 2024 23:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733815941; x=1734420741; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fU9h1qciZfo1eCFrj9RBOWdEPoZjJk9V1VI96TtLyqU=; b=MxjpQU/P+tH+/qA5gojpF8fPehzNXiIYikaCOf/HspvSJfh9vRkLI6V1W0ikO6Wm9w XjzH2yJwaPBnfXRDW19HSmbGt2j3dgKXfK9+G7uQltAKcqvLE7I3l1CM1KmSZC6eSx3q 2r3JnaGHsiUnbXJEXEpefiy1dTw7SlD2GaRf0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733815941; x=1734420741; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fU9h1qciZfo1eCFrj9RBOWdEPoZjJk9V1VI96TtLyqU=; b=VSH7b/MpiGjzz3MCbp93Snt4C+ROCKq67tX9JDayfzHhPeT/2QY/l6joIYCHf7mu/l ztijUwiu+etAI2Be3HUa5z3cnJwtKafHGNsSjSk5kjEchEMZWgzWqzVqOVf9bOwo4EOw 8xtAJea+FTzLPAtm+WikA5bvVk22cqX7J2/7+jJok30ZBc/i6MDQXcpyPy8Lcnu71PNl iQlfpI9M7SdLV73A1HHhKVrocFvMwCnEVwficxU0DM56OXx81Er8DWJQ317UD2wcgeZ9 RLKjrpmUHTqkb9VZySQXxG64enz4rZJ8Od/hHM+l/ScQsEZkbOVg/KYo/7CLj1/LPaxV zRfg== X-Forwarded-Encrypted: i=1; AJvYcCXrCXWUIxlu0o9y34LES/a0h9GarZ+wg6L9flHGEtaMfZ+Zw0XLSmhGvrOYg9pMp9FYI4B9Idr3l3C8tv7kKg==@lists.infradead.org X-Gm-Message-State: AOJu0YyMTWU4TRT4Ujg/P1gsq1EJXkTQ0kzRWNTYzXzLpwsbUCr3bkqC YkHAZGsTp3VLhRpFy2FVKTuv7E0C/HJxSiMVWjf+w4bxEcWPkoUZ70L6oUGEWsNUE59jqBkB9s4 = X-Gm-Gg: ASbGncvYuLKxhXmnC36FBBe+aZFwZwRdGUy4czTCalkotz3LLDLV6DR1t+tiYOkF7d7 AXAM+TxYqJUClwq0813aaoPdEiv/EZGG5UpoMGrnZ2ugbZxeAQKHyVmnTD8WUOR7ZtKKonQrA3e Ve6w1Wd67onXcQCgo9qU8Sa1YWhpZOntH9hEepuaFXIBeRunWlbiITdKzsD5hyunEgPE/WFGV/W jtfuifUJUPnuG1xJRv5gSid07fYd8vQGGwW6rnfcAwW6HgdFV4sGAV4T8mJjTSh4FykhJy0 X-Google-Smtp-Source: AGHT+IHPmON+PwbNAPPZYDE53KwGnbvTApGQhaNGbUZe2uB605PBpV+ZcftSN2qQ7es0oLZxPl5QBA== X-Received: by 2002:a17:902:ecc1:b0:216:3876:2cff with SMTP id d9443c01a7336-21638762fcamr152395915ad.54.1733815940983; Mon, 09 Dec 2024 23:32:20 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:89ce:2db9:f7d5:156d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f09146sm83693295ad.199.2024.12.09.23.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 23:32:20 -0800 (PST) From: Chen-Yu Tsai To: Chaotian Jing , Ulf Hansson , Matthias Brugger , AngeloGioacchino Del Regno , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Wenbin Mei Subject: [PATCH v2 1/2] dt-bindings: mmc: mtk-sd: Document compatibles that need two register ranges Date: Tue, 10 Dec 2024 15:32:10 +0800 Message-ID: <20241210073212.3917912-2-wenst@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241210073212.3917912-1-wenst@chromium.org> References: <20241210073212.3917912-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241209_233221_469438_68C666FF X-CRM114-Status: UNSURE ( 9.65 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Andy-ld Lu , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Besides the MT8183's MMC controller and all its compatible derivatives, the recently added MT7986 and MT8196 also require two register ranges. This is based on the actual device trees. Properly enforce this in the binding. Fixes: 4a8bd2b07d88 ("dt-bindings: mmc: mtk-sd: Add mt7988 SoC") Fixes: 58927c9dc4ab ("dt-bindings: mmc: mtk-sd: Add support for MT8196") Cc: Frank Wunderlich Cc: Andy-ld Lu Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/mmc/mtk-sd.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mmc/mtk-sd.yaml b/Documentation/devicetree/bindings/mmc/mtk-sd.yaml index f86ebd81f5a5..0debccbd6519 100644 --- a/Documentation/devicetree/bindings/mmc/mtk-sd.yaml +++ b/Documentation/devicetree/bindings/mmc/mtk-sd.yaml @@ -235,11 +235,19 @@ allOf: properties: compatible: contains: - const: mediatek,mt8183-mmc + enum: + - mediatek,mt7986-mmc + - mediatek,mt7988-mmc + - mediatek,mt8183-mmc + - mediatek,mt8196-mmc then: properties: reg: minItems: 2 + else: + properties: + reg: + maxItems: 1 - if: properties: From patchwork Tue Dec 10 07:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13900972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A871BE77180 for ; Tue, 10 Dec 2024 07:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oIYaaljMW1uOvyE52JKpg1mRNjsi/3D4cn4UsNQnmlk=; b=1jv32+gvgDTV/8 ag2fetgZ0hTo+ta9lBkj0BUBMNfDrXrd5ad0H/emDYxZlqXQIeif13piiHET4Q4u9dbgPdKyWKa7N h3qA6Bl0slzjrtNa3tDMph2ihdZbKkbNDXpqxhK0dPg62+AS52tUxCpnzrsgGDycux3zc7qp90DPN +bJP+dWjgywY1C4J32VSW9RPhWLZwtZ0aXE6v6l3U5iWcMvzxvaLfSK8id5yfii5VJP+UG3Rfrrgu fpMKEZTBJ9D3kvc3i9MRBm87b4vHXktXR87z+kNlsKCiO0i5gR2UZdwC37gogKggGNOE4p4CBJAYl ITkwxphow9zX8pIPoPEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKumJ-0000000AZaI-3ISm; Tue, 10 Dec 2024 07:35:31 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKujI-0000000AZ48-3ZNh for linux-mediatek@lists.infradead.org; Tue, 10 Dec 2024 07:32:27 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-21636268e43so28165085ad.2 for ; Mon, 09 Dec 2024 23:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733815944; x=1734420744; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oIYaaljMW1uOvyE52JKpg1mRNjsi/3D4cn4UsNQnmlk=; b=SKF9z6GpLlR74X6XCE4QRwqNaJpeH3q6LtErFk3WWx8mK1H6aG/lKzDxkXE5xT2xid oz3yERxRevoxzAoNy27SZP2hlbvy0Tj46IQGbVGub1ziJnCjVe54B/9dvlAtTzlqaPBx nwME+K+kWv/Z2FFae67C/t824/6gtKUvcHevs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733815944; x=1734420744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oIYaaljMW1uOvyE52JKpg1mRNjsi/3D4cn4UsNQnmlk=; b=iBoXn31YvU2uEYq1fWuTKE2OfmKwsZlqb98srdq30e9hWAZsIck9uGBQBbcb4vezk/ lNV8nS112OPLdULkUg7kDoLY+Q5VPMqKiF+UXJJ7VsdTyZ5A/o+7lt/TEEFVT5pvUVie cK0B4UYYPNr1O4uKBD1cXoc6HnlUucpd6uM4ID9eehU/gQ90FUPy2PRrLdxsvg+rTGq8 RdV/1qqvOhdQixyLHyuvzrvKSQkmvWRs4A/exkpWq24FkAPwnwmOj3qHwSqs+NHSFVh1 rmQGxYUtq6TCTWQW95zIGTeNkmary6nkB+3bF9J4fImdOE7THCXVtjLPzeyvBr6qjOgO PO/Q== X-Forwarded-Encrypted: i=1; AJvYcCVMXgDZEELjdzDxP8zXAIBjQ+quJkG4LuqeWlPwS4nzu/IwASWS9B9mI+bCl6FNFWlQLDvJlcImuOTDfWBOlA==@lists.infradead.org X-Gm-Message-State: AOJu0Yy6XI8cHu3lv0Algmhzf2weqCgd1Zy3xeonEkulz4kk630iCR7o ENwKMRrMgG9mYp27i9ke4JPix0odaAoUy56vaA6B74aYgSXTJy05dR4JAB9U2A== X-Gm-Gg: ASbGncu2hd3QEX+Ao4Ln43yjdG4Ed1f89aUk1WKZ+/O2hY1xzFUTeDXOHbo/Sap7Jqf p+x7VBGXew5NxqqDJBmNkLmix3WpQVI3IErlV5Ui+gaq6OaAUzmlgx6mAV9199sNCP1WuvhJIua oual6JxhwmXjA1EDexZ0rNu84GsKI6tr/qL4ZxFsHWHPFILb2jJZUUt0s9uyMl1QFruiznjURxJ s8M8c3aDVafIJTCnenOExFC7wuJoZeAEwfFio/NoEDEl7lmFBfl/d0vo35wzyCov9qHrk93 X-Google-Smtp-Source: AGHT+IEljjpPjIkRAq9lZ+wjZ9Q+4usk5mFRZZW08ysh+jkDMPJ/btZlL9SUPYyzmbG9svkENmEq7A== X-Received: by 2002:a17:902:ce88:b0:216:55a1:35a with SMTP id d9443c01a7336-2166a0097c0mr55964065ad.30.1733815943958; Mon, 09 Dec 2024 23:32:23 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:89ce:2db9:f7d5:156d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8f09146sm83693295ad.199.2024.12.09.23.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 23:32:23 -0800 (PST) From: Chen-Yu Tsai To: Chaotian Jing , Ulf Hansson , Matthias Brugger , AngeloGioacchino Del Regno , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Wenbin Mei Subject: [PATCH v2 2/2] mmc: mtk-sd: Limit getting top_base to SoCs that require it Date: Tue, 10 Dec 2024 15:32:11 +0800 Message-ID: <20241210073212.3917912-3-wenst@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241210073212.3917912-1-wenst@chromium.org> References: <20241210073212.3917912-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241209_233224_889302_E598BE28 X-CRM114-Status: GOOD ( 16.54 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Andy-ld Lu , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Currently the mtk-sd driver tries to get and map the second register base, named top_base in the code, regardless of whether the SoC model actually has it or not. This produces confusing big error messages on the platforms that don't need it: mtk-msdc 11260000.mmc: error -EINVAL: invalid resource (null) Limit it to the platforms that actually require it, based on their device tree entries, and properly fail if it is missing. Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- drivers/mmc/host/mtk-sd.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index e2c385853eef..1bb7044f4ca1 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -414,6 +414,7 @@ struct mtk_mmc_compatible { u8 clk_div_bits; bool recheck_sdio_irq; bool hs400_tune; /* only used for MT8173 */ + bool needs_top_base; u32 pad_tune_reg; bool async_fifo; bool data_tune; @@ -587,6 +588,7 @@ static const struct mtk_mmc_compatible mt7986_compat = { .clk_div_bits = 12, .recheck_sdio_irq = true, .hs400_tune = false, + .needs_top_base = true, .pad_tune_reg = MSDC_PAD_TUNE0, .async_fifo = true, .data_tune = true, @@ -627,6 +629,7 @@ static const struct mtk_mmc_compatible mt8183_compat = { .clk_div_bits = 12, .recheck_sdio_irq = false, .hs400_tune = false, + .needs_top_base = true, .pad_tune_reg = MSDC_PAD_TUNE0, .async_fifo = true, .data_tune = true, @@ -653,6 +656,7 @@ static const struct mtk_mmc_compatible mt8196_compat = { .clk_div_bits = 12, .recheck_sdio_irq = false, .hs400_tune = false, + .needs_top_base = true, .pad_tune_reg = MSDC_PAD_TUNE0, .async_fifo = true, .data_tune = true, @@ -2887,9 +2891,13 @@ static int msdc_drv_probe(struct platform_device *pdev) if (IS_ERR(host->base)) return PTR_ERR(host->base); - host->top_base = devm_platform_ioremap_resource(pdev, 1); - if (IS_ERR(host->top_base)) - host->top_base = NULL; + host->dev_comp = of_device_get_match_data(&pdev->dev); + + if (host->dev_comp->needs_top_base) { + host->top_base = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(host->top_base)) + return PTR_ERR(host->top_base); + } ret = mmc_regulator_get_supply(mmc); if (ret) @@ -2951,7 +2959,6 @@ static int msdc_drv_probe(struct platform_device *pdev) msdc_of_property_parse(pdev, host); host->dev = &pdev->dev; - host->dev_comp = of_device_get_match_data(&pdev->dev); host->src_clk_freq = clk_get_rate(host->src_clk); /* Set host parameters to mmc */ mmc->ops = &mt_msdc_ops;