From patchwork Tue Nov 9 10:59:04 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: 12610409 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 5A966C433EF for ; Tue, 9 Nov 2021 10:59:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40F6261178 for ; Tue, 9 Nov 2021 10:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241381AbhKILCB (ORCPT ); Tue, 9 Nov 2021 06:02:01 -0500 Received: from mo4-p02-ob.smtp.rzone.de ([81.169.146.170]:9568 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240102AbhKILCA (ORCPT ); Tue, 9 Nov 2021 06:02:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1636455550; 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=rfHhgGu+rg+elNFlFNuaURtWhhkpzMlWnoVXeLgI82s=; b=liuxOwMlaSe3Vc6Y3vLpAKQDjFrw9t9k4KDYcGpM1pbt77TztT4VCwtG1d+CVwi/6Y VAiIKPinyhFwCueYHkGzqxaiePzvZ/e/NZzZjWeAIBcjCCKVS7Y+vXNGvwQpsyxFmFRk Vd21lrSff2F7zB5rvhRaW1S3YzR2uONTdSgI0Jtf/JBby/8tqgasn944Tye42gkwS5uV 4wPLx/tBcJhjndoWSIK3Ct0qoZjAgbSxet6leLC0PwCx6nsXP+45inRv3FZvGGQGotTM J76jGK+nNyPY25H4qVdz2Ynj5nJ8gLNjejlbdoH+Ikn1+zyzhbiASIcfLr6IUWqgoqhS lPaQ== 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 902c63xA9AxAOW3 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 9 Nov 2021 11:59:10 +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 1/5] mmc: core: rewrite mmc_fixup_device() Date: Tue, 9 Nov 2021 11:59:04 +0100 Message-Id: <6515c1e8b3aa69ad273726f6e877d85c20f286ad.1636455548.git.hns@goldelico.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Jérôme Pouiller Currently, mmc_fixup_device() is a bit difficult to read because of particularly long condition. Signed-off-by: Jérôme Pouiller Signed-off-by: H. Nikolaus Schaller --- drivers/mmc/core/quirks.h | 41 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h index d68e6e513a4f4..c7ef2d14b359f 100644 --- a/drivers/mmc/core/quirks.h +++ b/drivers/mmc/core/quirks.h @@ -152,22 +152,29 @@ static inline void mmc_fixup_device(struct mmc_card *card, u64 rev = cid_rev_card(card); for (f = table; f->vendor_fixup; f++) { - if ((f->manfid == CID_MANFID_ANY || - f->manfid == card->cid.manfid) && - (f->oemid == CID_OEMID_ANY || - f->oemid == card->cid.oemid) && - (f->name == CID_NAME_ANY || - !strncmp(f->name, card->cid.prod_name, - sizeof(card->cid.prod_name))) && - (f->cis_vendor == card->cis.vendor || - f->cis_vendor == (u16) SDIO_ANY_ID) && - (f->cis_device == card->cis.device || - f->cis_device == (u16) SDIO_ANY_ID) && - (f->ext_csd_rev == EXT_CSD_REV_ANY || - f->ext_csd_rev == card->ext_csd.rev) && - rev >= f->rev_start && rev <= f->rev_end) { - dev_dbg(&card->dev, "calling %ps\n", f->vendor_fixup); - f->vendor_fixup(card, f->data); - } + if (f->manfid != CID_MANFID_ANY && + f->manfid != card->cid.manfid) + continue; + if (f->oemid != CID_OEMID_ANY && + f->oemid != card->cid.oemid) + continue; + if (f->name != CID_NAME_ANY && + strncmp(f->name, card->cid.prod_name, + sizeof(card->cid.prod_name))) + continue; + if (f->cis_vendor != (u16)SDIO_ANY_ID && + f->cis_vendor != card->cis.vendor) + continue; + if (f->cis_device != (u16)SDIO_ANY_ID && + f->cis_device != card->cis.device) + continue; + if (f->ext_csd_rev != EXT_CSD_REV_ANY && + f->ext_csd_rev != card->ext_csd.rev) + continue; + if (rev < f->rev_start || rev > f->rev_end) + continue; + + dev_dbg(&card->dev, "calling %ps\n", f->vendor_fixup); + f->vendor_fixup(card, f->data); } } From patchwork Tue Nov 9 10:59:05 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: 12610415 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 B88E7C433FE for ; Tue, 9 Nov 2021 10:59:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A11BF61178 for ; Tue, 9 Nov 2021 10:59:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245518AbhKILCK (ORCPT ); Tue, 9 Nov 2021 06:02:10 -0500 Received: from mo4-p02-ob.smtp.rzone.de ([85.215.255.83]:32560 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245510AbhKILCJ (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=OzCoVJYxglf1y8GP+J0FWzWTGQYuFXTicqOEQEZRkXM=; b=ABNcbVaETPUbJMNzSDM+DsjDVEXyCq+zWBcrC8ud7WDulooVRrzfRDB1WAvrlGpXXS tlskRP48ehJ8Lc4pTAUH3FkuB2kFcMaXKkIJK5w/VusLC6hZDraZd07puUQGK3kPeINw ebvOILozc7S6PwbOTIclAgzN6VGspwFOdNvTC/d3d7AH+V/qdvOGyEkxREcjXyvQzBkF qWG4J2ik5kfNt1gy5HbGZYEA3Arr4kN2oz3cWCLkt52Z/IpkyDp9af0voGtTAZCNc/D/ TbzkIAB6ViRPRnVZTBf6/RoOD+JjkXRp3SjfAJJpAMOv6O+BjbFHFv+qFakY75D+cv+8 vbCA== 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 902c63xA9AxAOW4 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 9 Nov 2021 11:59:10 +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 2/5] mmc: core: allow to match the device tree to apply quirks Date: Tue, 9 Nov 2021 11:59:05 +0100 Message-Id: <9e68e3d23e62a78527aabc1281f89e15200c7d09.1636455548.git.hns@goldelico.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Jérôme Pouiller MMC subsystem provides a way to apply quirks when a device match some properties (VID, PID, etc...) Unfortunately, some SDIO devices do not comply with the SDIO specification and does not provide reliable VID/PID (eg. Silabs WF200). So, the drivers for these devices rely on device tree to identify the device. This patch allows the MMC to also rely on the device tree to apply a quirk. Signed-off-by: Jérôme Pouiller Signed-off-by: H. Nikolaus Schaller Reviewed-by: Jérôme Pouiller --- drivers/mmc/core/card.h | 3 +++ drivers/mmc/core/quirks.h | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h index 7bd392d55cfa5..483e7f2f1039e 100644 --- a/drivers/mmc/core/card.h +++ b/drivers/mmc/core/card.h @@ -59,6 +59,9 @@ struct mmc_fixup { /* for MMC cards */ unsigned int ext_csd_rev; + /* Match against functions declared in device tree */ + const char *of_compatible; + void (*vendor_fixup)(struct mmc_card *card, int data); int data; }; diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h index c7ef2d14b359f..4a767f2fbaaaa 100644 --- a/drivers/mmc/core/quirks.h +++ b/drivers/mmc/core/quirks.h @@ -10,6 +10,7 @@ * */ +#include #include #include "card.h" @@ -145,6 +146,19 @@ static const struct mmc_fixup __maybe_unused sdio_fixup_methods[] = { END_FIXUP }; +static inline bool mmc_fixup_of_compatible_match(struct mmc_card *card, + const char *compatible) +{ + struct device_node *np; + + for_each_child_of_node(mmc_dev(card->host)->of_node, np) { + if (of_device_is_compatible(np, compatible)) + return true; + } + + return false; +} + static inline void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table) { @@ -173,6 +187,9 @@ static inline void mmc_fixup_device(struct mmc_card *card, continue; if (rev < f->rev_start || rev > f->rev_end) continue; + if (f->of_compatible && + !mmc_fixup_of_compatible_match(card, f->of_compatible)) + continue; dev_dbg(&card->dev, "calling %ps\n", f->vendor_fixup); f->vendor_fixup(card, f->data); 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: 12610419 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 81B96C4167D for ; Tue, 9 Nov 2021 10:59:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CA9F61178 for ; Tue, 9 Nov 2021 10:59:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245528AbhKILCL (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-omap@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 From patchwork Tue Nov 9 10:59:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 12610417 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 D0507C43217 for ; Tue, 9 Nov 2021 10:59:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBC3361177 for ; Tue, 9 Nov 2021 10:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245526AbhKILCL (ORCPT ); Tue, 9 Nov 2021 06:02:11 -0500 Received: from mo4-p03-ob.smtp.rzone.de ([85.215.255.102]:35143 "EHLO mo4-p03-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245515AbhKILCK (ORCPT ); Tue, 9 Nov 2021 06:02:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1636455552; 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=Uqnxx80FjURagoMKSCCsXpe0WBFasnf3OQMszPGS01Q=; b=eScPnUOxN/ee71CjMBaOc4g73ovcTF+cr88tTE9Jl5xGgKBYey+88hGOOqrGMC6JGO hxQ0P0VAXBC/AIwEE7We+pppezMgVMAxp5Qcndtw62Ix9VWfhmVw9vIOs/2woiO8dWHK 7wYAUfa4oa9BmUPuUnPaYaNxVXdxdteHvGBMzUolJjLzyLuSZOoGBGDlrHEoNNj9/UbY anjMYJbQ6MgoIAKhoSqLBBJSfDwsaXICETmreo/GUj+U4P/etrsL1tlpTGKRgOcBenuj gcbMcZPcB3FLvlY117MHAUziCBSVNQ7of//RSv9nxqM+BNGUKxYjbEbFdSICcjTVj89g lfvg== 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 902c63xA9AxBOW6 (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 4/5] mmc: core: transplant ti,wl1251 quirks from to be retired omap_hsmmc Date: Tue, 9 Nov 2021 11:59:07 +0100 Message-Id: <2d46adc580330788df1c7ef2a45be1e003387e0b.1636455548.git.hns@goldelico.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The TiWi WL1251 WiFi chip needs special setup of the sdio interface before it can be probed. So far, this is done in omap_hsmmc_init_card() in omap_hsmmc.c which makes it useable only if connected to omap devices which use the omap_hsmmc. The OpenPandora is the most promient example. There are plans to switch to a newer sdhci-omap driver and retire omap_hsmmc. Hence this quirk must be reworked or moved somewhere else. Ideally to some location that is not dependent on the specific SoC mmc host driver. This is achieved by the new mmc_fixup_device() option introduced by ("mmc: allow to match the device tree to apply quirks") to match through device tree compatible string. This quirk will be called early right after where host->ops->init_card() and thus omap_hsmmc_init_card() was previously called. Signed-off-by: H. Nikolaus Schaller --- drivers/mmc/core/card.h | 19 +++++++++++++++++++ drivers/mmc/core/quirks.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h index 216faf5ad1021..1695ce827d512 100644 --- a/drivers/mmc/core/card.h +++ b/drivers/mmc/core/card.h @@ -168,6 +168,25 @@ static inline void __maybe_unused add_limit_rate_quirk(struct mmc_card *card, card->quirk_max_rate = data; } +static inline void __maybe_unused wl1251_quirk(struct mmc_card *card, + int data) +{ + /* + * We have TI wl1251 attached to this mmc. Pass this + * information to the SDIO core because it can't be + * probed by normal methods. + */ + + dev_info(card->host->parent, "found wl1251\n"); + card->quirks |= MMC_QUIRK_NONSTD_SDIO; + card->cccr.wide_bus = 1; + card->cis.vendor = 0x104c; + card->cis.device = 0x9066; + card->cis.blksize = 512; + card->cis.max_dtr = 24000000; + card->ocr = 0x80; +} + /* * Quirk add/remove for MMC products. */ diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h index a23df65332cdf..20f5687272778 100644 --- a/drivers/mmc/core/quirks.h +++ b/drivers/mmc/core/quirks.h @@ -147,6 +147,8 @@ static const struct mmc_fixup __maybe_unused sdio_fixup_methods[] = { }; static const struct mmc_fixup __maybe_unused sdio_card_init_methods[] = { + SDIO_FIXUP_COMPATIBLE("ti,wl1251", wl1251_quirk, 0), + END_FIXUP }; From patchwork Tue Nov 9 10:59:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 12610413 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 EEC67C43219 for ; Tue, 9 Nov 2021 10:59:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA9CA61177 for ; Tue, 9 Nov 2021 10:59:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245523AbhKILCK (ORCPT ); Tue, 9 Nov 2021 06:02:10 -0500 Received: from mo4-p03-ob.smtp.rzone.de ([85.215.255.104]:16947 "EHLO mo4-p03-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245514AbhKILCJ (ORCPT ); Tue, 9 Nov 2021 06:02:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1636455552; 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=ytqJC3tzZimA/vKcRado/QdQBzzBwoUDJjRTyS4f9aA=; b=kS7uJ6ie8RD2sDsMlTXN9Ht1/AArqSJdEZTXlRSxnN9MaKK1vIAHE18xUc70t1qF4n iAESGMAr7Vz8dehXzCh6GPtu4U8fFeaQQxXLhz4G7x6R1uz1q0U7curA6Kx3jteUOP4R mCPGiDWnp0rNBzkHMC3TgqGNp0ycPu42hVemctqxKG4Y9y4NzrHPr/CPHVgGUGekzWtL IrXMhotZh+A5RU5g5IFb1YZhnftC8gMf9hhs4uQnn0Bgk0j8xP942l3DN5azkLkxb7T0 ql3oN3FQuzmn2EM7ZdnjphncUIsSycqJKtWciwNVHxsp7gqHhvYnjJ+zvg8oRli8/ga3 KwIg== 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 902c63xA9AxCOW7 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 9 Nov 2021 11:59:12 +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 5/5] mmc: host: omap_hsmmc: revert special init for wl1251 Date: Tue, 9 Nov 2021 11:59:08 +0100 Message-Id: <6f3cd3fca958b7dbdd9957ed369cd3733e85c95a.1636455548.git.hns@goldelico.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Replaces: commit f6498b922e57 ("mmc: host: omap_hsmmc: add code for special init of wl1251 to get rid of pandora_wl1251_init_card") Requires: commit ("mmc: core: transplant ti,wl1251 quirks from to be retired omap_hsmmc") After moving the wl1251 quirks from omap_hsmmc_init_card() to wl1251_quirk() and sdio_card_init_methods[] we can remove omap_hsmmc_init_card() completely. This also removes the specialization on the combination of omap_hsmmc and wl1251. Related-to: commit f6498b922e57 ("mmc: host: omap_hsmmc: add code for special init of wl1251 to get rid of pandora_wl1251_init_card") Related-to: commit 2398c41d6432 ("omap: pdata-quirks: remove openpandora quirks for mmc3 and wl1251") Related-to: commit f9d50fef4b64 ("ARM: OMAP2+: omap3-pandora: add wifi support") Signed-off-by: H. Nikolaus Schaller --- drivers/mmc/host/omap_hsmmc.c | 36 ----------------------------------- 1 file changed, 36 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 6960e305e0a39..9749639ea8977 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -1504,41 +1504,6 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) omap_hsmmc_set_bus_mode(host); } -static void omap_hsmmc_init_card(struct mmc_host *mmc, struct mmc_card *card) -{ - struct omap_hsmmc_host *host = mmc_priv(mmc); - - if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) { - struct device_node *np = mmc_dev(mmc)->of_node; - - /* - * REVISIT: should be moved to sdio core and made more - * general e.g. by expanding the DT bindings of child nodes - * to provide a mechanism to provide this information: - * Documentation/devicetree/bindings/mmc/mmc-card.txt - */ - - np = of_get_compatible_child(np, "ti,wl1251"); - if (np) { - /* - * We have TI wl1251 attached to MMC3. Pass this - * information to the SDIO core because it can't be - * probed by normal methods. - */ - - dev_info(host->dev, "found wl1251\n"); - card->quirks |= MMC_QUIRK_NONSTD_SDIO; - card->cccr.wide_bus = 1; - card->cis.vendor = 0x104c; - card->cis.device = 0x9066; - card->cis.blksize = 512; - card->cis.max_dtr = 24000000; - card->ocr = 0x80; - of_node_put(np); - } - } -} - static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable) { struct omap_hsmmc_host *host = mmc_priv(mmc); @@ -1667,7 +1632,6 @@ static struct mmc_host_ops omap_hsmmc_ops = { .set_ios = omap_hsmmc_set_ios, .get_cd = mmc_gpio_get_cd, .get_ro = mmc_gpio_get_ro, - .init_card = omap_hsmmc_init_card, .enable_sdio_irq = omap_hsmmc_enable_sdio_irq, };