mmc: core: provide macro and table to match the device tree to apply quirks
authorH. Nikolaus Schaller <hns@goldelico.com>
Wed, 10 Nov 2021 17:17:08 +0000 (18:17 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 14 Dec 2021 20:35:23 +0000 (21:35 +0100)
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 <hns@goldelico.com>
Link: https://lore.kernel.org/r/b13fd8b3eebc3c23b6816b254a518c224cbdcfd4.1636564631.git.hns@goldelico.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/card.h
drivers/mmc/core/quirks.h
drivers/mmc/core/sdio.c

index 483e7f2f1039ea20e9f42ce4ade2638842d2d3b0..216faf5ad10215394dd2fe33d9dd9e1df34fb1c9 100644 (file)
@@ -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 |                  \
index 4a767f2fbaaaaa5d8706513ba910f6118d42ade4..a23df65332cdf09af09bb721bb2e78c6335324c3 100644 (file)
@@ -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)
 {
index 68edf7a615be50065936aa1d4b0abd8977bd91c0..cf8ee6699050893be427c3d91d43629cb416a1b4 100644 (file)
@@ -707,6 +707,7 @@ try_again:
         */
        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