linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v2 0/2]
@ 2021-11-01  9:39 H. Nikolaus Schaller
  2021-11-01  9:39 ` [RFC v2 1/2] mmc: core: transplant ti,wl1251 quirks from to be retired omap_hsmmc H. Nikolaus Schaller
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: H. Nikolaus Schaller @ 2021-11-01  9:39 UTC (permalink / raw)
  To: Ulf Hansson, Jérôme Pouiller, Avri Altman, Shawn Lin,
	Linus Walleij, Tony Lindgren, Bean Huo
  Cc: notasas, linux-mmc, linux-kernel, letux-kernel, kernel,
	H. Nikolaus Schaller

RFC V2 2021-11-01 10:24:26:
* reworked to not misuse mmc_select_card() but add a call to
  mmc_fixup_device() right after where host->ops->init_card
  was called before to apply the wl1251 specific quirks.
  Device tree matching is done by a new table passed to mmc_fixup_device().
  suggested by: ulf.hansson@linaro.org
  based on patches by: jerome.pouiller@silabs.com

RFC V1 2021-10-06 13:24:13:


H. Nikolaus Schaller (2):
  mmc: core: transplant ti,wl1251 quirks from to be retired omap_hsmmc
  mmc: host: omap_hsmmc: revert special init for wl1251

 drivers/mmc/core/card.h       | 19 ++++++++++++++++++
 drivers/mmc/core/mmc.c        |  1 +
 drivers/mmc/core/quirks.h     | 22 +++++++++++++++++++++
 drivers/mmc/core/sd.c         |  2 ++
 drivers/mmc/core/sdio.c       |  1 +
 drivers/mmc/host/omap_hsmmc.c | 36 -----------------------------------
 6 files changed, 45 insertions(+), 36 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC v2 1/2] mmc: core: transplant ti,wl1251 quirks from to be retired omap_hsmmc
  2021-11-01  9:39 [RFC v2 0/2] H. Nikolaus Schaller
@ 2021-11-01  9:39 ` H. Nikolaus Schaller
  2021-11-01  9:39 ` [RFC v2 2/2] mmc: host: omap_hsmmc: revert special init for wl1251 H. Nikolaus Schaller
  2021-11-02 11:14 ` [RFC v2 0/2] Jérôme Pouiller
  2 siblings, 0 replies; 5+ messages in thread
From: H. Nikolaus Schaller @ 2021-11-01  9:39 UTC (permalink / raw)
  To: Ulf Hansson, Jérôme Pouiller, Avri Altman, Shawn Lin,
	Linus Walleij, Tony Lindgren, Bean Huo
  Cc: notasas, linux-mmc, linux-kernel, letux-kernel, kernel,
	H. Nikolaus Schaller

The TiWi 5 WiFi module 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 is called early right after where host->ops->init_card()
and omap_hsmmc_init_card() was previously called.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/mmc/core/card.h   | 19 +++++++++++++++++++
 drivers/mmc/core/mmc.c    |  1 +
 drivers/mmc/core/quirks.h | 22 ++++++++++++++++++++++
 drivers/mmc/core/sd.c     |  2 ++
 drivers/mmc/core/sdio.c   |  1 +
 5 files changed, 45 insertions(+)

diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h
index 2f73f8567e14f..a876f4585fbb9 100644
--- a/drivers/mmc/core/card.h
+++ b/drivers/mmc/core/card.h
@@ -153,6 +153,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/mmc.c b/drivers/mmc/core/mmc.c
index 29e58ffae3797..19cd138acaec9 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1634,6 +1634,7 @@ static int mmc_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);
 
 	/*
 	 * For native busses:  set card RCA and quit open drain mode.
diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
index ef368386e7112..0ffb69044a749 100644
--- a/drivers/mmc/core/quirks.h
+++ b/drivers/mmc/core/quirks.h
@@ -146,6 +146,28 @@ static const struct mmc_fixup __maybe_unused sdio_fixup_methods[] = {
 	END_FIXUP
 };
 
+static const char * const wl1251_compatible_list[] = { "ti,wl1251", NULL };
+
+// FIXME: this needs a nice macro for initialization
+
+static const struct mmc_fixup __maybe_unused sdio_card_init_methods[] = {
+	{
+		.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 = wl1251_quirk,
+		.data = 0,
+		.ext_csd_rev = EXT_CSD_REV_ANY,
+		.of_compatible = wl1251_compatible_list,
+	},
+
+	END_FIXUP
+};
+
 static inline bool mmc_fixup_of_compatible_match(struct mmc_card *card,
 						 const char *const *compat_list)
 {
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 4646b7a03db6b..0d174fdf47164 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -23,6 +23,7 @@
 #include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
+#include "quirks.h"
 #include "sd.h"
 #include "sd_ops.h"
 
@@ -1427,6 +1428,7 @@ static int mmc_sd_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);
 
 	/*
 	 * For native busses:  get card RCA and quit open drain mode.
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
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC v2 2/2] mmc: host: omap_hsmmc: revert special init for wl1251
  2021-11-01  9:39 [RFC v2 0/2] H. Nikolaus Schaller
  2021-11-01  9:39 ` [RFC v2 1/2] mmc: core: transplant ti,wl1251 quirks from to be retired omap_hsmmc H. Nikolaus Schaller
@ 2021-11-01  9:39 ` H. Nikolaus Schaller
  2021-11-02 11:14 ` [RFC v2 0/2] Jérôme Pouiller
  2 siblings, 0 replies; 5+ messages in thread
From: H. Nikolaus Schaller @ 2021-11-01  9:39 UTC (permalink / raw)
  To: Ulf Hansson, Jérôme Pouiller, Avri Altman, Shawn Lin,
	Linus Walleij, Tony Lindgren, Bean Huo
  Cc: notasas, linux-mmc, linux-kernel, letux-kernel, kernel,
	H. Nikolaus Schaller

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 omap_hsmmc")

After moving the wl1251 quirks from omap_hsmmc_init_card() to mmc_fixup_device()
we can remove omap_hsmmc_init_card() which specialized 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 <hns@goldelico.com>
---
 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,
 };
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC v2 0/2]
  2021-11-01  9:39 [RFC v2 0/2] H. Nikolaus Schaller
  2021-11-01  9:39 ` [RFC v2 1/2] mmc: core: transplant ti,wl1251 quirks from to be retired omap_hsmmc H. Nikolaus Schaller
  2021-11-01  9:39 ` [RFC v2 2/2] mmc: host: omap_hsmmc: revert special init for wl1251 H. Nikolaus Schaller
@ 2021-11-02 11:14 ` Jérôme Pouiller
  2021-11-02 13:13   ` [RFC v2 0/2] mmc_fixup_device H. Nikolaus Schaller
  2 siblings, 1 reply; 5+ messages in thread
From: Jérôme Pouiller @ 2021-11-02 11:14 UTC (permalink / raw)
  To: Ulf Hansson, Avri Altman, Shawn Lin, Linus Walleij,
	Tony Lindgren, Bean Huo, H. Nikolaus Schaller
  Cc: notasas, linux-mmc, linux-kernel, letux-kernel, kernel,
	H. Nikolaus Schaller

Hello Nikolaus,

On Monday 1 November 2021 10:39:10 CET H. Nikolaus Schaller wrote:
> 
> RFC V2 2021-11-01 10:24:26:
> * reworked to not misuse mmc_select_card() but add a call to
>   mmc_fixup_device() right after where host->ops->init_card
>   was called before to apply the wl1251 specific quirks.
>   Device tree matching is done by a new table passed to mmc_fixup_device().
>   suggested by: ulf.hansson@linaro.org
>   based on patches by: jerome.pouiller@silabs.com

To make review easier, I think you can include these patches
in this series (BTW, I have no time to care of them until end
of next week. So, it will probably go faster if you take over
these patches).

(I also suggest to add a title to your series to make your work
easier to track.)


-- 
Jérôme Pouiller



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC v2 0/2] mmc_fixup_device
  2021-11-02 11:14 ` [RFC v2 0/2] Jérôme Pouiller
@ 2021-11-02 13:13   ` H. Nikolaus Schaller
  0 siblings, 0 replies; 5+ messages in thread
From: H. Nikolaus Schaller @ 2021-11-02 13:13 UTC (permalink / raw)
  To: Jérôme Pouiller
  Cc: Ulf Hansson, Avri Altman, Shawn Lin, Linus Walleij,
	Tony Lindgren, Bean Huo, Gražvydas Ignotas, linux-mmc,
	linux-kernel, letux-kernel, kernel

Hi Jerome,

> Am 02.11.2021 um 12:14 schrieb Jérôme Pouiller <jerome.pouiller@silabs.com>:
> 
> Hello Nikolaus,
> 
> On Monday 1 November 2021 10:39:10 CET H. Nikolaus Schaller wrote:
>> 
>> RFC V2 2021-11-01 10:24:26:
>> * reworked to not misuse mmc_select_card() but add a call to
>>  mmc_fixup_device() right after where host->ops->init_card
>>  was called before to apply the wl1251 specific quirks.
>>  Device tree matching is done by a new table passed to mmc_fixup_device().
>>  suggested by: ulf.hansson@linaro.org
>>  based on patches by: jerome.pouiller@silabs.com
> 
> To make review easier, I think you can include these patches
> in this series (BTW, I have no time to care of them until end
> of next week. So, it will probably go faster if you take over
> these patches).

Ok, no problem.

Now as I understand how it should be set up I could even propose
some new macro for discussion.

> 
> (I also suggest to add a title to your series to make your work
> easier to track.)

Yes... I didn't notice before I received my copy of this mail.
There is a missing if(strlen(subject) == 0) reject; in my helper
tool...

BR and thanks,
Nikolaus


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-02 13:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-01  9:39 [RFC v2 0/2] H. Nikolaus Schaller
2021-11-01  9:39 ` [RFC v2 1/2] mmc: core: transplant ti,wl1251 quirks from to be retired omap_hsmmc H. Nikolaus Schaller
2021-11-01  9:39 ` [RFC v2 2/2] mmc: host: omap_hsmmc: revert special init for wl1251 H. Nikolaus Schaller
2021-11-02 11:14 ` [RFC v2 0/2] Jérôme Pouiller
2021-11-02 13:13   ` [RFC v2 0/2] mmc_fixup_device H. Nikolaus Schaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).