/* * Initialize the SPI controller */ static int __init at91_spi_init(void) { init_MUTEX(&spi_lock); AT91_CfgPIO_SPI(); controller->SPI_CR = AT91C_SPI_SWRST; /* software reset of SPI controller */ /* Set Chip Select registers to good defaults */ controller->SPI_CSR0 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8); controller->SPI_CSR1 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8); controller->SPI_CSR2 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8); controller->SPI_CSR3 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8); controller->SPI_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS; memset(&spi_dev, 0, sizeof(spi_dev)); spi_dev[0].pcs = 0xE; spi_dev[1].pcs = 0xD; spi_dev[2].pcs = 0xB; spi_dev[3].pcs = 0x7; if (request_irq(AT91C_ID_SPI, spi_interrupt, 0, "spi", NULL)) return -EBUSY; controller->SPI_CR = AT91C_SPI_SPIEN; /* Enable SPI */ return 0; }
/* * Initialize the SPI controller */ static int __init at91_spi_init(void) { init_MUTEX(&spi_lock); AT91_CfgPIO_SPI(); controller->SPI_CR = AT91C_SPI_SWRST; /* software reset of SPI controller */ /* Set Chip Select registers to good defaults */ // controller->SPI_CSR0 = AT91C_SPI_CPOL |AT91C_SPI_NCPHA | AT91C_SPI_BITS_8 | (1 << 16) | (15 << 8); controller->SPI_CSR0 = AT91C_SPI_BITS_8 | (16 << 16) | (15 << 8); controller->SPI_CSR1 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8); controller->SPI_CSR2 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8); controller->SPI_CSR3 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8); controller->SPI_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS; memset(&spi_dev, 0, sizeof(spi_dev)); spi_dev[0].pcs = 0xE; spi_dev[1].pcs = 0xD; spi_dev[2].pcs = 0xB; spi_dev[3].pcs = 0x7; if (request_irq(AT91C_ID_SPI, spi_interrupt, 0, "dudu_spi", NULL)) { printk(KERN_INFO "I am Busy.\n"); return -EBUSY; } controller->SPI_CR = AT91C_SPI_SPIEN; /* Enable SPI */ /******************************************************************************/ at91_set_gpio_output(AT91_PIN_PA24, 1); at91_set_gpio_value(AT91_PIN_PA24, 1); /******************************************************************************/ return 0; }