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: 13900973 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 54239E7717F for ; Tue, 10 Dec 2024 07:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: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:Cc: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=01X5XB3A9zmIUMzqCJLrKleRLp MnyD5+fUh2jKjEqqI+g4gayrAD/8qTG40XuLWPTftdorECBCm6NQGeN8JOap45Lv8C9iRBuAuI82S jpPkYK1zWseAtmYooed+snCoe5NkM1J1SFn9raeT2KqWAO1sE16Hu02qIaNh1iL2CfwjaIiKGG3Xu OFtSQAsFHJe4uaxTEZQc8a9L7aGXLQmeI4nXOxEVhJpjelT2OdCMzJm5pOs4s3cMV73xS0JG+NHRD ciiUHGu90JHLr3RvRTtJXzIN+y+fVM6MtSyesh9Y81xB9P1qUBdYmyi5TgJrvELtXbi63wSve7Wg4 5JvVUseg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKulH-0000000AZOF-2vZW; Tue, 10 Dec 2024 07:34:27 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKujF-0000000AZ2j-1tNN for linux-arm-kernel@lists.infradead.org; Tue, 10 Dec 2024 07:32:23 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2164b1f05caso18573565ad.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=AUYX1vgxH6csnCBRCLTeiMboNEoFavpZQFDMXuafV3jkydDzk4Wf/hwnVutKfmYbu5 5CmbiwWWHlzT8EpkaFCknyqRBn8elJ8Lne9l//IJh6JrFG492v+dms+glpVmrwRB/LGd rO6D9I7ZRbQR+s18BgHgDAoaNlonqUwsqa4z75JdxO7ynyxyAm5JnFpQl5YrOqez+fd3 IZhrQjbrrsw8iVvPIM+xMP0BsFRsBkvLTUp4BQxiHbtEx/yssmzcPqBwN4tYrqPqJoYD DZKnYplrPcWXex/C/EwaYynB6zevjdfq7Cwkm++UMxZOTzDVH4ev/nf+a1y+gCsUJnHV LY9g== X-Forwarded-Encrypted: i=1; AJvYcCVIyn3f5GaBk7eZ7eNg2E2T/5AEUmuznaWRd6HYA8ULu/1MrwGwHK/s26+t1noIyr+krWLOk9FyNmh0rBVVWTwK@lists.infradead.org X-Gm-Message-State: AOJu0YyeP+b4lfhPGJI1eLDcDg1pJruym42PcGVHdJKGD5zuLeOKOxmd 1fRYQOL/1L7ZVsLLjbAj868TsIqDVlIis7OU0KGjR8zo12Tc+ETTUBujxHwsmA== X-Gm-Gg: ASbGncv1Bg3CwQMHu2h53pqo/MY9v6FWLndAy4JPUeVqRO1KgP/K+l6zGPJGbjanaCD oC1+Bao7Uw2FnnF48v6EBjKEtLM1S49gc5G9Q8hINdZB5e7L/6K3F/GwLIymGKOPlHDqOVp64KJ FCs5wtkBC9G9/0h8xkUTaHOA1eBZNfiB0QFdRYWhOV5yHsZmnK9Y6GbfVEPPceKVXcWs7seRU3K hiTFNmoKnVwBlpGOCu9dcoEH4DMpEm4+m6UWnJ7wzhRDq9fkT4WtGQNUY0XtxdZED9ASgKF 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 Cc: Chen-Yu Tsai , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, Frank Wunderlich , Andy-ld Lu 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_481566_A5059870 X-CRM114-Status: GOOD ( 10.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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: 13900974 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 889D0E7717F for ; Tue, 10 Dec 2024 07:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: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:Cc: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=QpPye5c9WRhESwMdPAYkny07ZA /SzAIydarSa2f8I3UW8Zbm9KHbkC/zWJLEdMj3JyqClQwPJEXVAjSPNCtrZ0fHilB4WG2WPBQ7NCg bEwV2kOE8A+r4oOBYrofymtUMEg+80qTGvTKWrfRUA4ykn8q9I+j4zfUuMZ0otBRNWu18RiwU2Oqc qFb40q1XHh9PrXQ1CRmk8wmA4kO7XU6UyjzNHHlvkURxS63BKM78IEfNTs4Fp1JojJJFnsm5vqH75 l5AuiMoVY3k5ZyAohgcUewL84APhYe05YrZITrV8E6AEQuiiVie+6JYnhFdGdliXH70ccXCP/dlc3 p9syqgpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKumJ-0000000AZZn-1EPv; Tue, 10 Dec 2024 07:35:31 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKujI-0000000AZ49-3Yrq for linux-arm-kernel@lists.infradead.org; Tue, 10 Dec 2024 07:32:26 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-7ee11ff7210so4190442a12.1 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=OhERH16fzrma6q2Z3C7bLoR1b0T3/Osgy6WFYnexsh6SdMs6GZUhD1W88aU9EftdxZ X2tVyQRaf88F6N+71fAHh18jAEjX6Isk5Fr/amLQ7HTGX5UFKydM932yHk99tKceaERq poZj1hmc3KKmsCexkysVbNJx1s5hUajDbZTl3nC276snndvfqfSXrYBfVS5QXIL79PyW 6HdCcEw//quzkuQvACa+M6cYwiRccWmZDkxL/Xznc4fkpGRptvYRcfyowxE/KvO85yw0 sLzN6TpfuJMVbYCAzr9kf+NJIlB/choKcRL5cJrz1QVjskgyC3Clgu+gmDwwF5rd2W3o 3BBg== X-Forwarded-Encrypted: i=1; AJvYcCV2g0fBKGt6d4CLBz+yzs0ZJnNSHLXR3JS5t7li6leXTlyHPBzBt6ifv488A2D+sFDcvRCG/2JxJKX6B8SIUR6N@lists.infradead.org X-Gm-Message-State: AOJu0YyqpjFh1nzV/8hSWGpC/tWXxj0/iailNu4pyC7WZSMZtlHvvZIV pdi595H41wzecLcTUO8dp2q0aEZOal/H0PR/3Q1dQeqTSIn/Hk7I/CzXT/+pUA== X-Gm-Gg: ASbGncukTvyzUuN1N0+O4wuqZMG7TivCiBIrLTV9J5ioE6wsOyCbAUmbD+Y82UTpzVE zVM2dZo1txcIePLXw4FO4Jk8jXYIBQ0TmCyKh7VsSHIWz4lmfxA8u/Wx2m+PlDHltQz4tffirwl TSgfQ/vxZDd1rGhUTYVCosZ6YmJDiCUAQVnev/trRnVG4J/4L25B0ompZgDXyzoRzb33HErE5NX BgGDKxicaHwi6HHZj/Zi72twBokIaGCl3DmlSlnDJZFjo0JhaRslOidKChoSy/ENK031Dz4 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 Cc: Chen-Yu Tsai , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, Frank Wunderlich , Andy-ld Lu 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_889659_77DE9324 X-CRM114-Status: GOOD ( 17.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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;