From patchwork Tue Nov 9 10:59:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 12610407 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50C61C4167B for ; Tue, 9 Nov 2021 10:59:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3EBF761151 for ; Tue, 9 Nov 2021 10:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245529AbhKILCL (ORCPT ); Tue, 9 Nov 2021 06:02:11 -0500 Received: from mo4-p03-ob.smtp.rzone.de ([81.169.146.173]:14389 "EHLO mo4-p03-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245513AbhKILCJ (ORCPT ); Tue, 9 Nov 2021 06:02:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1636455551; s=strato-dkim-0002; d=goldelico.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=3WxCiJju1Jj7ObO+gVh3oAZ8JmxUqs06i+MBBHM9dzs=; b=SzJVs82v2AvhCuPHeI3lAUYlg3mEeqfFPw6HZgLOZSu4fPeQgbb1gFoR4NEulsNiJn mJVUVa8dgwdXjj9TGN5BynXxL3Zeuqom4uW8seX5lCZaHAY4XBABpPlWTAgsQtAEO/es lyST9oL9Z0u3/Yhf31+f+af33vykXGEg+yK7hzXrAB72/z1sflKYrRlIhFl/wWQHLFqy wnVfEh4+rgJ+Z149ixlJXKA8POaeXG33cVwzTuQPPT9fwgsackpPHPl3lpKaeqq40QM2 dgEGgRkU5CfXaD5PGLr9Ao7HVfD/Y42Hc2RU/xCp7e9nEtrPWj14VSb4guMrvOJR5/qD nX7A== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMhflhwDubTJ9o1KHeBQyh+ITDDFoCL4=" X-RZG-CLASS-ID: mo00 Received: from iMac.fritz.box by smtp.strato.de (RZmta 47.34.1 DYNA|AUTH) with ESMTPSA id 902c63xA9AxBOW5 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 9 Nov 2021 11:59:11 +0100 (CET) From: "H. Nikolaus Schaller" To: Ulf Hansson , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= , Avri Altman , Shawn Lin , Linus Walleij , Tony Lindgren , Bean Huo , "H. Nikolaus Schaller" , Kiwoong Kim , Tian Tao , Andreas Kemnade , Yang Li Cc: notasas@gmail.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, kernel@pyra-handheld.com, linux-omap@vger.kernel.org Subject: [PATCH 3/5] mmc: core: provide macro and table to match the device tree to apply quirks Date: Tue, 9 Nov 2021 11:59:06 +0100 Message-Id: X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org This (initially empty) table allows to match quirks early based on .compatible of the child node of some mmc/sdio interface. This allows to add quirks based on device tree instead of having card specific code in the host ops. A new macro SDIO_FIXUP_COMPATIBLE makes the definition readable. And we call mmc_fixup_device(sdio_card_init_methods) just after where host->ops->init_card() can be optionally called. Signed-off-by: H. Nikolaus Schaller Reviewed-by: Jérôme Pouiller --- drivers/mmc/core/card.h | 15 +++++++++++++++ drivers/mmc/core/quirks.h | 4 ++++ drivers/mmc/core/sdio.c | 1 + 3 files changed, 20 insertions(+) diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h index 483e7f2f1039e..216faf5ad1021 100644 --- a/drivers/mmc/core/card.h +++ b/drivers/mmc/core/card.h @@ -122,6 +122,21 @@ struct mmc_fixup { _vendor, _device, \ _fixup, _data, EXT_CSD_REV_ANY) \ +#define SDIO_FIXUP_COMPATIBLE(_compatible, _fixup, _data) \ + { \ + .name = CID_NAME_ANY, \ + .manfid = CID_MANFID_ANY, \ + .oemid = CID_OEMID_ANY, \ + .rev_start = 0, \ + .rev_end = -1ull, \ + .cis_vendor = SDIO_ANY_ID, \ + .cis_device = SDIO_ANY_ID, \ + .vendor_fixup = (_fixup), \ + .data = (_data), \ + .ext_csd_rev = EXT_CSD_REV_ANY, \ + .of_compatible = _compatible, \ + } + #define cid_rev(hwrev, fwrev, year, month) \ (((u64) hwrev) << 40 | \ ((u64) fwrev) << 32 | \ diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h index 4a767f2fbaaaa..a23df65332cdf 100644 --- a/drivers/mmc/core/quirks.h +++ b/drivers/mmc/core/quirks.h @@ -146,6 +146,10 @@ static const struct mmc_fixup __maybe_unused sdio_fixup_methods[] = { END_FIXUP }; +static const struct mmc_fixup __maybe_unused sdio_card_init_methods[] = { + END_FIXUP +}; + static inline bool mmc_fixup_of_compatible_match(struct mmc_card *card, const char *compatible) { diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 68edf7a615be5..cf8ee66990508 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -707,6 +707,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, */ if (host->ops->init_card) host->ops->init_card(host, card); + mmc_fixup_device(card, sdio_card_init_methods); /* * If the host and card support UHS-I mode request the card