|
@@ -612,3 +612,150 @@ void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
|
|
|
at91_set_multi_drive(AT91_PIN_PB4, 1);
|
|
|
|
|
|
at91_set_A_periph(AT91_PIN_PB5, 0); /* TWCK */
|
|
|
+ at91_set_multi_drive(AT91_PIN_PB5, 1);
|
|
|
+
|
|
|
+ i2c_register_board_info(0, devices, nr_devices);
|
|
|
+ platform_device_register(&at91sam9263_twi_device);
|
|
|
+}
|
|
|
+#else
|
|
|
+void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+/* --------------------------------------------------------------------
|
|
|
+ * SPI
|
|
|
+ * -------------------------------------------------------------------- */
|
|
|
+
|
|
|
+#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
|
|
|
+static u64 spi_dmamask = DMA_BIT_MASK(32);
|
|
|
+
|
|
|
+static struct resource spi0_resources[] = {
|
|
|
+ [0] = {
|
|
|
+ .start = AT91SAM9263_BASE_SPI0,
|
|
|
+ .end = AT91SAM9263_BASE_SPI0 + SZ_16K - 1,
|
|
|
+ .flags = IORESOURCE_MEM,
|
|
|
+ },
|
|
|
+ [1] = {
|
|
|
+ .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI0,
|
|
|
+ .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI0,
|
|
|
+ .flags = IORESOURCE_IRQ,
|
|
|
+ },
|
|
|
+};
|
|
|
+
|
|
|
+static struct platform_device at91sam9263_spi0_device = {
|
|
|
+ .name = "atmel_spi",
|
|
|
+ .id = 0,
|
|
|
+ .dev = {
|
|
|
+ .dma_mask = &spi_dmamask,
|
|
|
+ .coherent_dma_mask = DMA_BIT_MASK(32),
|
|
|
+ },
|
|
|
+ .resource = spi0_resources,
|
|
|
+ .num_resources = ARRAY_SIZE(spi0_resources),
|
|
|
+};
|
|
|
+
|
|
|
+static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PB11 };
|
|
|
+
|
|
|
+static struct resource spi1_resources[] = {
|
|
|
+ [0] = {
|
|
|
+ .start = AT91SAM9263_BASE_SPI1,
|
|
|
+ .end = AT91SAM9263_BASE_SPI1 + SZ_16K - 1,
|
|
|
+ .flags = IORESOURCE_MEM,
|
|
|
+ },
|
|
|
+ [1] = {
|
|
|
+ .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI1,
|
|
|
+ .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI1,
|
|
|
+ .flags = IORESOURCE_IRQ,
|
|
|
+ },
|
|
|
+};
|
|
|
+
|
|
|
+static struct platform_device at91sam9263_spi1_device = {
|
|
|
+ .name = "atmel_spi",
|
|
|
+ .id = 1,
|
|
|
+ .dev = {
|
|
|
+ .dma_mask = &spi_dmamask,
|
|
|
+ .coherent_dma_mask = DMA_BIT_MASK(32),
|
|
|
+ },
|
|
|
+ .resource = spi1_resources,
|
|
|
+ .num_resources = ARRAY_SIZE(spi1_resources),
|
|
|
+};
|
|
|
+
|
|
|
+static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 };
|
|
|
+
|
|
|
+void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ unsigned long cs_pin;
|
|
|
+ short enable_spi0 = 0;
|
|
|
+ short enable_spi1 = 0;
|
|
|
+
|
|
|
+ /* Choose SPI chip-selects */
|
|
|
+ for (i = 0; i < nr_devices; i++) {
|
|
|
+ if (devices[i].controller_data)
|
|
|
+ cs_pin = (unsigned long) devices[i].controller_data;
|
|
|
+ else if (devices[i].bus_num == 0)
|
|
|
+ cs_pin = spi0_standard_cs[devices[i].chip_select];
|
|
|
+ else
|
|
|
+ cs_pin = spi1_standard_cs[devices[i].chip_select];
|
|
|
+
|
|
|
+ if (!gpio_is_valid(cs_pin))
|
|
|
+ continue;
|
|
|
+
|
|
|
+ if (devices[i].bus_num == 0)
|
|
|
+ enable_spi0 = 1;
|
|
|
+ else
|
|
|
+ enable_spi1 = 1;
|
|
|
+
|
|
|
+ /* enable chip-select pin */
|
|
|
+ at91_set_gpio_output(cs_pin, 1);
|
|
|
+
|
|
|
+ /* pass chip-select pin to driver */
|
|
|
+ devices[i].controller_data = (void *) cs_pin;
|
|
|
+ }
|
|
|
+
|
|
|
+ spi_register_board_info(devices, nr_devices);
|
|
|
+
|
|
|
+ /* Configure SPI bus(es) */
|
|
|
+ if (enable_spi0) {
|
|
|
+ at91_set_B_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
|
|
|
+ at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
|
|
|
+ at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
|
|
|
+
|
|
|
+ platform_device_register(&at91sam9263_spi0_device);
|
|
|
+ }
|
|
|
+ if (enable_spi1) {
|
|
|
+ at91_set_A_periph(AT91_PIN_PB12, 0); /* SPI1_MISO */
|
|
|
+ at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */
|
|
|
+ at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */
|
|
|
+
|
|
|
+ platform_device_register(&at91sam9263_spi1_device);
|
|
|
+ }
|
|
|
+}
|
|
|
+#else
|
|
|
+void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+/* --------------------------------------------------------------------
|
|
|
+ * AC97
|
|
|
+ * -------------------------------------------------------------------- */
|
|
|
+
|
|
|
+#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
|
|
|
+static u64 ac97_dmamask = DMA_BIT_MASK(32);
|
|
|
+static struct ac97c_platform_data ac97_data;
|
|
|
+
|
|
|
+static struct resource ac97_resources[] = {
|
|
|
+ [0] = {
|
|
|
+ .start = AT91SAM9263_BASE_AC97C,
|
|
|
+ .end = AT91SAM9263_BASE_AC97C + SZ_16K - 1,
|
|
|
+ .flags = IORESOURCE_MEM,
|
|
|
+ },
|
|
|
+ [1] = {
|
|
|
+ .start = NR_IRQS_LEGACY + AT91SAM9263_ID_AC97C,
|
|
|
+ .end = NR_IRQS_LEGACY + AT91SAM9263_ID_AC97C,
|
|
|
+ .flags = IORESOURCE_IRQ,
|
|
|
+ },
|
|
|
+};
|
|
|
+
|
|
|
+static struct platform_device at91sam9263_ac97_device = {
|
|
|
+ .name = "atmel_ac97c",
|
|
|
+ .id = 0,
|