From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <ahmad@a3f.at>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/4] mci: mci_spi: extend driver for device tree probing
Date: Mon, 28 Mar 2022 11:44:32 +0200 [thread overview]
Message-ID: <20220328094432.GR12181@pengutronix.de> (raw)
In-Reply-To: <20220319072410.1310723-2-ahmad@a3f.at>
On Sat, Mar 19, 2022 at 08:24:08AM +0100, Ahmad Fatoum wrote:
> Driver has been matched by name only so far, add optional support for
> the device tree binding.
>
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
> drivers/mci/mci_spi.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
Applied 2-4, thanks
Sascha
>
> diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
> index ed3ddf890f7f..6ae2824eddc8 100644
> --- a/drivers/mci/mci_spi.c
> +++ b/drivers/mci/mci_spi.c
> @@ -18,6 +18,8 @@
> #include <mci.h>
> #include <crc.h>
> #include <crc7.h>
> +#include <of.h>
> +#include <gpiod.h>
>
> #define to_spi_host(mci) container_of(mci, struct mmc_spi_host, mci)
> #define spi_setup(spi) spi->master->setup(spi)
> @@ -47,6 +49,7 @@ struct mmc_spi_host {
> struct mci_host mci;
> struct spi_device *spi;
> struct device_d *dev;
> + int detect_pin;
>
> /* for bulk data transfers */
> struct spi_transfer t_tx;
> @@ -351,8 +354,23 @@ static int mmc_spi_init(struct mci_host *mci, struct device_d *mci_dev)
> return 0;
> }
>
> +static int spi_mci_card_present(struct mci_host *mci)
> +{
> + struct mmc_spi_host *host = to_spi_host(mci);
> + int ret;
> +
> + /* No gpio, assume card is present */
> + if (!gpio_is_valid(host->detect_pin))
> + return 1;
> +
> + ret = gpio_get_value(host->detect_pin);
> +
> + return ret == 0 ? 1 : 0;
> +}
> +
> static int spi_mci_probe(struct device_d *dev)
> {
> + struct device_node *np = dev_of_node(dev);
> struct spi_device *spi = (struct spi_device *)dev->type_data;
> struct mmc_spi_host *host;
> void *ones;
> @@ -362,6 +380,7 @@ static int spi_mci_probe(struct device_d *dev)
> host->mci.send_cmd = mmc_spi_request;
> host->mci.set_ios = mmc_spi_set_ios;
> host->mci.init = mmc_spi_init;
> + host->mci.card_present = spi_mci_card_present;
> host->mci.hw_dev = dev;
>
> /* MMC and SD specs only seem to care that sampling is on the
> @@ -415,14 +434,26 @@ static int spi_mci_probe(struct device_d *dev)
>
> host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
> host->mci.host_caps = MMC_CAP_SPI;
> + host->detect_pin = -EINVAL;
> +
> + if (np) {
> + host->mci.devname = xstrdup(of_alias_get(np));
> + host->detect_pin = gpiod_get(dev, NULL, GPIOD_IN);
> + }
>
> mci_register(&host->mci);
>
> return 0;
> }
>
> +static __maybe_unused struct of_device_id spi_mci_compatible[] = {
> + { .compatible = "mmc-spi-slot" },
> + { /* sentinel */ }
> +};
> +
> static struct driver_d spi_mci_driver = {
> .name = "spi_mci",
> .probe = spi_mci_probe,
> + .of_compatible = DRV_OF_COMPAT(spi_mci_compatible),
> };
> device_spi_driver(spi_mci_driver);
> --
> 2.34.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2022-03-28 9:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-19 7:24 [PATCH 1/4] spi: Port SiFive SPI controller driver Ahmad Fatoum
2022-03-19 7:24 ` [PATCH 2/4] mci: mci_spi: extend driver for device tree probing Ahmad Fatoum
2022-03-28 9:44 ` Sascha Hauer [this message]
2022-03-28 9:48 ` Ahmad Fatoum
2022-03-19 7:24 ` [PATCH 3/4] mtd: spi-nor: add support for ISSI IS25WP256 Ahmad Fatoum
2022-03-19 7:24 ` [PATCH 4/4] RISC-V: sifive: enable SPI Flash and SD in config Ahmad Fatoum
2022-03-28 9:43 ` [PATCH 1/4] spi: Port SiFive SPI controller driver Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220328094432.GR12181@pengutronix.de \
--to=sha@pengutronix.de \
--cc=ahmad@a3f.at \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox