public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Steven A. Falco <sfalco@harris.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/2] ppc4xx: Add SPI helper routines for the 440EPX
Date: Mon, 08 Dec 2008 16:02:36 -0500	[thread overview]
Message-ID: <493D8B6C.1030306@harris.com> (raw)

This patch adds helper routines needed in support of the 440EPx SPI driver.

Signed-off-by: Steven A. Falco <sfalco@harris.com>
---

Regarding Wolfgang's comments:

The style I saw in the existing code is to have these three functions in
a board-specific file.  That way, the routines can exclude any chip
selects that are not applicable to a specific hardware platform.  Also,
the chip-selects could be on a GPIO expander, in which case the
activate/deactivate routines might have to deal with the GPIO expander
device.

So, following the existing style, I think these routines should not be
part of the generic driver.  Otherwise, we could get into the situation
where many ifdefs would be needed in the generic driver to handle the
board-specific details.

 board/amcc/sequoia/sequoia.c |   20 ++++++++++++++++++++
 include/configs/sequoia.h    |    4 ++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/board/amcc/sequoia/sequoia.c b/board/amcc/sequoia/sequoia.c
index d6668e2..cd08a77 100644
--- a/board/amcc/sequoia/sequoia.c
+++ b/board/amcc/sequoia/sequoia.c
@@ -26,6 +26,7 @@
 #include <libfdt.h>
 #include <fdt_support.h>
 #include <ppc4xx.h>
+#include <spi.h>
 #include <asm/gpio.h>
 #include <asm/processor.h>
 #include <asm/io.h>
@@ -513,3 +514,22 @@ int post_hotkeys_pressed(void)
 	return 0;	/* No hotkeys supported */
 }
 #endif /* CONFIG_POST */
+
+#if defined(CONFIG_PPC440EPX_SPI)
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+	return bus == 0 && cs >= 0 && cs < 64;
+}
+
+void spi_cs_activate(struct spi_slave *slave)
+{
+	/* Assumes chip-selects are active-low. */
+	gpio_write_bit(slave->cs, 0);
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+	gpio_write_bit(slave->cs, 1);
+}
+#endif /* CONFIG_PPC440EPX_SPI */
+
diff --git a/include/configs/sequoia.h b/include/configs/sequoia.h
index 9321bdc..551be98 100644
--- a/include/configs/sequoia.h
+++ b/include/configs/sequoia.h
@@ -236,6 +236,10 @@
 #define CONFIG_SYS_DTT_LOW_TEMP	-30
 #define CONFIG_SYS_DTT_HYSTERESIS	3
 
+/* Define these if you are using the SPI port. */
+#undef CONFIG_HARD_SPI
+#undef CONFIG_PPC440EPX_SPI
+
 /*
  * Default environment variables
  */
-- 
1.6.0.2

             reply	other threads:[~2008-12-08 21:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-08 21:02 Steven A. Falco [this message]
2008-12-09  5:43 ` [U-Boot] [PATCH v2 2/2] ppc4xx: Add SPI helper routines for the 440EPX Stefan Roese

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=493D8B6C.1030306@harris.com \
    --to=sfalco@harris.com \
    --cc=u-boot@lists.denx.de \
    /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