linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "周琰杰 (Zhou Yanjie)" <zhouyanjie@wanyeetech.com>
To: broonie@kernel.org, robh+dt@kernel.org, krzk+dt@kernel.org
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, paul@crapouillou.net,
	contact@artur-rojek.eu, dongsheng.qiu@ingenic.com,
	aric.pzqi@ingenic.com, rick.tyliu@ingenic.com,
	sernia.zhou@foxmail.com, zhenwenjin@gmail.com,
	reimu@sudomaker.com
Subject: [PATCH v2 1/3] SPI: Ingenic: Add support for use GPIO as chip select line.
Date: Sat, 23 Apr 2022 03:09:41 +0800	[thread overview]
Message-ID: <1650654583-89933-2-git-send-email-zhouyanjie@wanyeetech.com> (raw)
In-Reply-To: <1650654583-89933-1-git-send-email-zhouyanjie@wanyeetech.com>

Add support for using GPIOs as chip select lines on Ingenic SoCs.

Signed-off-by: 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
---

Notes:
    v1->v2:
    Use "device_property_read_u32()" instead
    "of_property_read_u32()" as Paul Cercueil's suggestion.

 drivers/spi/spi-ingenic.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-ingenic.c b/drivers/spi/spi-ingenic.c
index 03077a7..bb512ca 100644
--- a/drivers/spi/spi-ingenic.c
+++ b/drivers/spi/spi-ingenic.c
@@ -380,7 +380,7 @@ static int spi_ingenic_probe(struct platform_device *pdev)
 	struct spi_controller *ctlr;
 	struct ingenic_spi *priv;
 	void __iomem *base;
-	int ret;
+	int num_cs, ret;
 
 	pdata = of_device_get_match_data(dev);
 	if (!pdata) {
@@ -416,6 +416,11 @@ static int spi_ingenic_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->flen_field))
 		return PTR_ERR(priv->flen_field);
 
+	if (device_property_read_u32(dev, "num-cs", &num_cs)) {
+		dev_warn(dev, "Number of chip select lines not specified.\n");
+		num_cs = 2;
+	}
+
 	platform_set_drvdata(pdev, ctlr);
 
 	ctlr->prepare_transfer_hardware = spi_ingenic_prepare_hardware;
@@ -429,7 +434,9 @@ static int spi_ingenic_probe(struct platform_device *pdev)
 	ctlr->bits_per_word_mask = pdata->bits_per_word_mask;
 	ctlr->min_speed_hz = 7200;
 	ctlr->max_speed_hz = 54000000;
-	ctlr->num_chipselect = 2;
+	ctlr->use_gpio_descriptors = true;
+	ctlr->max_native_cs = 2;
+	ctlr->num_chipselect = num_cs;
 	ctlr->dev.of_node = pdev->dev.of_node;
 
 	if (spi_ingenic_request_dma(ctlr, dev))
-- 
2.7.4


  reply	other threads:[~2022-04-22 19:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 19:09 [PATCH v2 0/3] Improve SPI support for Ingenic SoCs 周琰杰 (Zhou Yanjie)
2022-04-22 19:09 ` 周琰杰 (Zhou Yanjie) [this message]
2022-04-22 19:20   ` [PATCH v2 1/3] SPI: Ingenic: Add support for use GPIO as chip select line Paul Cercueil
2022-04-23 12:54     ` Zhou Yanjie
2022-04-22 19:09 ` [PATCH v2 2/3] dt-bindings: SPI: Add bindings for new Ingenic SoCs 周琰杰 (Zhou Yanjie)
2022-04-22 19:09 ` [PATCH v2 3/3] SPI: Ingenic: Add support " 周琰杰 (Zhou Yanjie)

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=1650654583-89933-2-git-send-email-zhouyanjie@wanyeetech.com \
    --to=zhouyanjie@wanyeetech.com \
    --cc=aric.pzqi@ingenic.com \
    --cc=broonie@kernel.org \
    --cc=contact@artur-rojek.eu \
    --cc=devicetree@vger.kernel.org \
    --cc=dongsheng.qiu@ingenic.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=paul@crapouillou.net \
    --cc=reimu@sudomaker.com \
    --cc=rick.tyliu@ingenic.com \
    --cc=robh+dt@kernel.org \
    --cc=sernia.zhou@foxmail.com \
    --cc=zhenwenjin@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).