From: Hubert Feurstein <h.feurstein@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] at91sam9g45: add atmel-spi support
Date: Sat, 10 Sep 2011 21:18:33 +0200 [thread overview]
Message-ID: <1315682313-19130-2-git-send-email-h.feurstein@gmail.com> (raw)
In-Reply-To: <1315682313-19130-1-git-send-email-h.feurstein@gmail.com>
Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
---
arch/arm/mach-at91/at91sam9g45_devices.c | 41 ++++++++++++++++++++++++++++++
arch/arm/mach-at91/include/mach/board.h | 2 +
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 022f3e1..ac95260 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -256,3 +256,44 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
#endif
+#if defined(CONFIG_DRIVER_SPI_ATMEL)
+/* SPI */
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
+{
+ int i;
+ int cs_pin;
+ resource_size_t start;
+
+ for (i = 0; i < pdata->num_chipselect; i++) {
+ cs_pin = pdata->chipselect[i];
+
+ /* enable chip-select pin */
+ if (cs_pin > 0)
+ at91_set_gpio_output(cs_pin, 1);
+ }
+
+ /* Configure SPI bus(es) */
+ if (spi_id == 0) {
+ start = AT91SAM9G45_BASE_SPI0;
+ at91_set_A_periph(AT91_PIN_PB0, 0); /* SPI0_MISO */
+ at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI0_MOSI */
+ at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI0_SPCK */
+
+ add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
+ IORESOURCE_MEM, pdata);
+ }
+
+ else if (spi_id == 1) {
+ start = AT91SAM9G45_BASE_SPI1;
+ at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_MISO */
+ at91_set_A_periph(AT91_PIN_PB15, 0); /* SPI1_MOSI */
+ at91_set_A_periph(AT91_PIN_PB16, 0); /* SPI1_SPCK */
+
+ add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
+ IORESOURCE_MEM, pdata);
+ }
+}
+
+#else
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
+#endif
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index e88834b..2adc035 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -82,4 +82,6 @@ struct at91_spi_platform_data {
int *chipselect; /* array of gpio_pins */
int num_chipselect; /* chipselect array entry count */
};
+
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata);
#endif
--
1.7.4.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-09-10 19:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-10 19:18 [PATCH 1/2] spi: add atmel-spi driver Hubert Feurstein
2011-09-10 19:18 ` Hubert Feurstein [this message]
2011-09-13 19:59 ` [PATCH v2] " Hubert Feurstein
2011-09-14 8:40 ` 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=1315682313-19130-2-git-send-email-h.feurstein@gmail.com \
--to=h.feurstein@gmail.com \
--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