linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] add inversion signal presence support
@ 2019-11-13 15:52 Ivan Mikhaylov
  2019-11-13 15:52 ` [PATCH 1/2] aspeed: dts: add sd card for vesnin Ivan Mikhaylov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ivan Mikhaylov @ 2019-11-13 15:52 UTC (permalink / raw)
  Cc: Ivan Mikhaylov, Joel Stanley, Andrew Jeffery, Rob Herring,
	Mark Rutland, Adrian Hunter, Ulf Hansson, devicetree,
	linux-arm-kernel, linux-aspeed, linux-kernel, linux-mmc, openbmc

Vesnin BMC uses microSD with card presence signal inversion in the
schematics. Change the .get_cd callback to detect 'cd-inverted' option
in dts. There is no WP switch, due to this 'disable-wp' also was added
into vesnin dts for sdhci.

Ivan Mikhaylov (2):
  aspeed: dts: add sd card for vesnin
  mmc: sdhci-of-aspeed: add inversion signal presence

 arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts | 13 ++++++++++++
 drivers/mmc/host/sdhci-of-aspeed.c          | 23 +++++++++++++++++++++
 2 files changed, 36 insertions(+)

-- 
2.20.1

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

* [PATCH 1/2] aspeed: dts: add sd card for vesnin
  2019-11-13 15:52 [PATCH 0/2] add inversion signal presence support Ivan Mikhaylov
@ 2019-11-13 15:52 ` Ivan Mikhaylov
  2019-11-13 15:52 ` [PATCH 2/2] mmc: sdhci-of-aspeed: add inversion signal presence Ivan Mikhaylov
  2019-11-14  0:04 ` Milton Miller II
  2 siblings, 0 replies; 4+ messages in thread
From: Ivan Mikhaylov @ 2019-11-13 15:52 UTC (permalink / raw)
  Cc: Ivan Mikhaylov, Joel Stanley, Andrew Jeffery, Rob Herring,
	Mark Rutland, Adrian Hunter, Ulf Hansson, devicetree,
	linux-arm-kernel, linux-aspeed, linux-kernel, linux-mmc, openbmc

Presence signal is inverted for vesnin boards, 'cd-inverted' added
for invertion signal enablement. Vesnin BMC uses microSD, there is
no WP switch, 'disable-wp' is used for this purpose.

Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com>

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts b/arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts
index a27c88d23056..7ae3436e0d99 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts
@@ -232,3 +232,16 @@
 &wdt2 {
 	aspeed,alt-boot;
 };
+
+&sdmmc {
+	status = "okay";
+};
+
+&sdhci1 {
+	status = "okay";
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_sd2_default>;
+	cd-inverted;
+	disable-wp;
+};
-- 
2.20.1

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

* [PATCH 2/2] mmc: sdhci-of-aspeed: add inversion signal presence
  2019-11-13 15:52 [PATCH 0/2] add inversion signal presence support Ivan Mikhaylov
  2019-11-13 15:52 ` [PATCH 1/2] aspeed: dts: add sd card for vesnin Ivan Mikhaylov
@ 2019-11-13 15:52 ` Ivan Mikhaylov
  2019-11-14  0:04 ` Milton Miller II
  2 siblings, 0 replies; 4+ messages in thread
From: Ivan Mikhaylov @ 2019-11-13 15:52 UTC (permalink / raw)
  Cc: Ivan Mikhaylov, Joel Stanley, Andrew Jeffery, Rob Herring,
	Mark Rutland, Adrian Hunter, Ulf Hansson, devicetree,
	linux-arm-kernel, linux-aspeed, linux-kernel, linux-mmc, openbmc

Change the default .get_cd callback. Add inverted signal card detection
check.

Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com>

diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c
index 8962f6664381..8eded8a6ed8d 100644
--- a/drivers/mmc/host/sdhci-of-aspeed.c
+++ b/drivers/mmc/host/sdhci-of-aspeed.c
@@ -31,6 +31,7 @@ struct aspeed_sdc {
 struct aspeed_sdhci {
 	struct aspeed_sdc *parent;
 	u32 width_mask;
+	u8 cd_inverted;
 };
 
 static void aspeed_sdc_configure_8bit_mode(struct aspeed_sdc *sdc,
@@ -143,6 +144,21 @@ static inline int aspeed_sdhci_calculate_slot(struct aspeed_sdhci *dev,
 	return (delta / 0x100) - 1;
 }
 
+static int aspeed_get_cd(struct mmc_host *mmc)
+{
+	struct aspeed_sdhci *aspeed_sdhci;
+	struct sdhci_pltfm_host *pltfm_priv;
+	struct sdhci_host *host = mmc_priv(mmc);
+
+	int presence = !!(sdhci_readl(host, SDHCI_PRESENT_STATE)
+			 & SDHCI_CARD_PRESENT);
+
+	pltfm_priv = sdhci_priv(host);
+	aspeed_sdhci = sdhci_pltfm_priv(pltfm_priv);
+
+	return presence ^ aspeed_sdhci->cd_inverted;
+}
+
 static int aspeed_sdhci_probe(struct platform_device *pdev)
 {
 	struct sdhci_pltfm_host *pltfm_host;
@@ -183,6 +199,13 @@ static int aspeed_sdhci_probe(struct platform_device *pdev)
 		goto err_pltfm_free;
 	}
 
+	dev->cd_inverted = 0;
+	host->mmc_host_ops.get_cd = aspeed_get_cd;
+	if (of_property_read_bool(pdev->dev.of_node, "cd-inverted")) {
+		dev->cd_inverted = 1;
+		dev_info(&pdev->dev, "aspeed: sdhci: presence signal inversion enabled\n");
+	}
+
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
 		goto err_sdhci_add;
-- 
2.20.1

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

* Re:  [PATCH 2/2] mmc: sdhci-of-aspeed: add inversion signal presence
  2019-11-13 15:52 [PATCH 0/2] add inversion signal presence support Ivan Mikhaylov
  2019-11-13 15:52 ` [PATCH 1/2] aspeed: dts: add sd card for vesnin Ivan Mikhaylov
  2019-11-13 15:52 ` [PATCH 2/2] mmc: sdhci-of-aspeed: add inversion signal presence Ivan Mikhaylov
@ 2019-11-14  0:04 ` Milton Miller II
  2 siblings, 0 replies; 4+ messages in thread
From: Milton Miller II @ 2019-11-14  0:04 UTC (permalink / raw)
  To: Ivan Mikhaylov
  Cc: Mark Rutland, devicetree, Ulf Hansson, linux-aspeed,
	Andrew Jeffery, openbmc, linux-mmc, Adrian Hunter, linux-kernel,
	Rob Herring, linux-arm-kernel

On 11/13/2019 around 09:57AM in some time zone, Ivan Mikhaylov wrote:
>Change the default .get_cd callback. Add inverted signal card
>detection
>check.
>
>Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com>
>
>diff --git a/drivers/mmc/host/sdhci-of-aspeed.c
>b/drivers/mmc/host/sdhci-of-aspeed.c
>index 8962f6664381..8eded8a6ed8d 100644
>--- a/drivers/mmc/host/sdhci-of-aspeed.c
>+++ b/drivers/mmc/host/sdhci-of-aspeed.c
>@@ -31,6 +31,7 @@ struct aspeed_sdc {
> struct aspeed_sdhci {
> 	struct aspeed_sdc *parent;
> 	u32 width_mask;
>+	u8 cd_inverted;

The mmc core/host.c checks the device tree and stores the
result as mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH

This appears to be accessale as sdhci_host->mmc->caps2.

Please reuse this bit like the other drivers.

> };
> 
> static void aspeed_sdc_configure_8bit_mode(struct aspeed_sdc *sdc,
>@@ -143,6 +144,21 @@ static inline int
>aspeed_sdhci_calculate_slot(struct aspeed_sdhci *dev,
> 	return (delta / 0x100) - 1;
> }
> 
>+static int aspeed_get_cd(struct mmc_host *mmc)
>+{
>+	struct aspeed_sdhci *aspeed_sdhci;
>+	struct sdhci_pltfm_host *pltfm_priv;
>+	struct sdhci_host *host = mmc_priv(mmc);
>+
>+	int presence = !!(sdhci_readl(host, SDHCI_PRESENT_STATE)
>+			 & SDHCI_CARD_PRESENT);
>+
>+	pltfm_priv = sdhci_priv(host);
>+	aspeed_sdhci = sdhci_pltfm_priv(pltfm_priv);
>+
>+	return presence ^ aspeed_sdhci->cd_inverted;
>+}
>+
> static int aspeed_sdhci_probe(struct platform_device *pdev)
> {
> 	struct sdhci_pltfm_host *pltfm_host;
>@@ -183,6 +199,13 @@ static int aspeed_sdhci_probe(struct
>platform_device *pdev)
> 		goto err_pltfm_free;
> 	}
> 
>+	dev->cd_inverted = 0;
>+	host->mmc_host_ops.get_cd = aspeed_get_cd;
>+	if (of_property_read_bool(pdev->dev.of_node, "cd-inverted")) {
>+		dev->cd_inverted = 1;
>+		dev_info(&pdev->dev, "aspeed: sdhci: presence signal inversion
>enabled\n");
>+	}
>+
> 	ret = mmc_of_parse(host->mmc);
> 	if (ret)
> 		goto err_sdhci_add;
>-- 
>2.20.1
>
>

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

end of thread, other threads:[~2019-11-14  0:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-13 15:52 [PATCH 0/2] add inversion signal presence support Ivan Mikhaylov
2019-11-13 15:52 ` [PATCH 1/2] aspeed: dts: add sd card for vesnin Ivan Mikhaylov
2019-11-13 15:52 ` [PATCH 2/2] mmc: sdhci-of-aspeed: add inversion signal presence Ivan Mikhaylov
2019-11-14  0:04 ` Milton Miller II

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).