[PATCH 2/2] at91sam9g45: add atmel-spi support
Hubert Feurstein
h.feurstein at gmail.com
Sat Sep 10 15:18:33 EDT 2011
Signed-off-by: Hubert Feurstein <h.feurstein at 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
More information about the barebox
mailing list