mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/5] spi: improve devicetree support
Date: Tue, 21 May 2013 09:38:12 +0200	[thread overview]
Message-ID: <1369121895-11282-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1369121895-11282-1-git-send-email-s.hauer@pengutronix.de>

- zero spi_board_info structure to not accidently pass
  unitilialized fields
- parse spi-max-frequency property from devicetree
- parse mode flags from devicetree

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/spi/spi.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index d58b664..f460a7a 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -108,9 +108,20 @@ void spi_of_register_slaves(struct spi_master *master, struct device_node *node)
 	struct property *reg;
 
 	device_node_for_nach_child(node, n) {
-		chip.name = n->name;
+		memset(&chip, 0, sizeof(chip));
+		chip.name = xstrdup(n->name);
 		chip.bus_num = master->bus_num;
-		chip.max_speed_hz = 300000; /* FIXME */
+		/* Mode (clock phase/polarity/etc.) */
+		if (of_find_property(n, "spi-cpha"))
+			chip.mode |= SPI_CPHA;
+		if (of_find_property(n, "spi-cpol"))
+			chip.mode |= SPI_CPOL;
+		if (of_find_property(n, "spi-cs-high"))
+			chip.mode |= SPI_CS_HIGH;
+		if (of_find_property(n, "spi-3wire"))
+			chip.mode |= SPI_3WIRE;
+		of_property_read_u32(n, "spi-max-frequency",
+				&chip.max_speed_hz);
 		reg = of_find_property(n, "reg");
 		if (!reg)
 			continue;
-- 
1.8.2.rc2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-05-21  7:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21  7:38 [PATCH] misc oftree patches Sascha Hauer
2013-05-21  7:38 ` [PATCH 1/5] pinctrl: imx-iomux-v3: only register pinctrl when device node is available Sascha Hauer
2013-06-05 15:18   ` Lucas Stach
2013-06-05 20:33     ` Sascha Hauer
2013-05-21  7:38 ` Sascha Hauer [this message]
2013-05-21  7:38 ` [PATCH 3/5] mtd: dataflash: Add devicetree probing support Sascha Hauer
2013-05-21  7:38 ` [PATCH 4/5] net: Add of_register_ethaddr Sascha Hauer
2013-05-21  7:38 ` [PATCH 5/5] net: fec: Add imx25 compatible property 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=1369121895-11282-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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