summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/at91sam9x5_devices.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-11-03 12:36:30 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-11-15 20:20:29 +0100
commitd7a4acac7c9ba73eef55bf26cef5145f63e56dd7 (patch)
tree3a94c84b67f6052c263bfb23a6ddce9db760398a /arch/arm/mach-at91/at91sam9x5_devices.c
parentfe67b42201092ab76bdae944daf6bf3a867a3d51 (diff)
downloadbarebox-d7a4acac7c9ba73eef55bf26cef5145f63e56dd7.tar.gz
barebox-d7a4acac7c9ba73eef55bf26cef5145f63e56dd7.tar.xz
at91sam9x5: add spi support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-at91/at91sam9x5_devices.c')
-rw-r--r--arch/arm/mach-at91/at91sam9x5_devices.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 5a24325ca1..710ded7099 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -228,6 +228,68 @@ void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_de
#endif
/* --------------------------------------------------------------------
+ * SPI
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_DRIVER_SPI_ATMEL)
+static unsigned spi0_standard_cs[4] = { AT91_PIN_PA14, AT91_PIN_PA7, AT91_PIN_PA1, AT91_PIN_PB3 };
+
+static unsigned spi1_standard_cs[4] = { AT91_PIN_PA8, AT91_PIN_PA0, AT91_PIN_PA31, AT91_PIN_PA30 };
+
+static struct at91_spi_platform_data spi_pdata[] = {
+ [0] = {
+ .chipselect = spi0_standard_cs,
+ .num_chipselect = ARRAY_SIZE(spi0_standard_cs),
+ },
+ [1] = {
+ .chipselect = spi1_standard_cs,
+ .num_chipselect = ARRAY_SIZE(spi1_standard_cs),
+ },
+};
+
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
+{
+ int i;
+ int cs_pin;
+ resource_size_t start = ~0;
+
+ BUG_ON(spi_id > 1);
+
+ if (!pdata)
+ pdata = &spi_pdata[spi_id];
+
+ 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) */
+ switch (spi_id) {
+ case 0:
+ start = AT91SAM9X5_BASE_SPI0;
+ at91_set_A_periph(AT91_PIN_PA11, 0); /* SPI0_MISO */
+ at91_set_A_periph(AT91_PIN_PA12, 0); /* SPI0_MOSI */
+ at91_set_A_periph(AT91_PIN_PA13, 0); /* SPI0_SPCK */
+ break;
+ case 1:
+ start = AT91SAM9X5_BASE_SPI1;
+ at91_set_B_periph(AT91_PIN_PA21, 0); /* SPI1_MISO */
+ at91_set_B_periph(AT91_PIN_PA22, 0); /* SPI1_MOSI */
+ at91_set_B_periph(AT91_PIN_PA23, 0); /* SPI1_SPCK */
+ break;
+ }
+
+ 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
+
+/* --------------------------------------------------------------------
* UART
* -------------------------------------------------------------------- */