1 Cirrus EP93xx SPI controller driver HOWTO
2 =========================================
4 ep93xx_spi driver brings SPI master support for EP93xx SPI controller. Chip
5 selects are implemented with GPIO lines.
7 NOTE: If possible, don't use SFRMOUT (SFRM1) signal as a chip select. It will
8 not work correctly (it cannot be controlled by software). Use GPIO lines
14 Typically driver configuration is done in platform board files (the files under
15 arch/arm/mach-ep93xx/*.c). In this example we configure MMC over SPI through
16 this driver on TS-7260 board. You can adapt the code to suit your needs.
18 This example uses EGPIO9 as SD/MMC card chip select (this is wired in DIO1
21 You need to select CONFIG_MMC_SPI to use mmc_spi driver.
23 arch/arm/mach-ep93xx/ts72xx.c:
26 #include <linux/gpio.h>
27 #include <linux/spi/spi.h>
29 #include <mach/ep93xx_spi.h>
31 /* this is our GPIO line used for chip select */
32 #define MMC_CHIP_SELECT_GPIO EP93XX_GPIO_LINE_EGPIO9
34 static int ts72xx_mmc_spi_setup(struct spi_device *spi)
38 err = gpio_request(MMC_CHIP_SELECT_GPIO, spi->modalias);
42 gpio_direction_output(MMC_CHIP_SELECT_GPIO, 1);
47 static void ts72xx_mmc_spi_cleanup(struct spi_device *spi)
49 gpio_set_value(MMC_CHIP_SELECT_GPIO, 1);
50 gpio_direction_input(MMC_CHIP_SELECT_GPIO);
51 gpio_free(MMC_CHIP_SELECT_GPIO);
54 static void ts72xx_mmc_spi_cs_control(struct spi_device *spi, int value)
56 gpio_set_value(MMC_CHIP_SELECT_GPIO, value);
59 static struct ep93xx_spi_chip_ops ts72xx_mmc_spi_ops = {
60 .setup = ts72xx_mmc_spi_setup,
61 .cleanup = ts72xx_mmc_spi_cleanup,
62 .cs_control = ts72xx_mmc_spi_cs_control,
65 static struct spi_board_info ts72xx_spi_devices[] __initdata = {
67 .modalias = "mmc_spi",
68 .controller_data = &ts72xx_mmc_spi_ops,
70 * We use 10 MHz even though the maximum is 7.4 MHz. The driver
71 * will limit it automatically to max. frequency.
73 .max_speed_hz = 10 * 1000 * 1000,
80 static struct ep93xx_spi_info ts72xx_spi_info = {
81 .num_chipselect = ARRAY_SIZE(ts72xx_spi_devices),
84 static void __init ts72xx_init_machine(void)
87 ep93xx_register_spi(&ts72xx_spi_info, ts72xx_spi_devices,
88 ARRAY_SIZE(ts72xx_spi_devices));
93 Martin Guy, H. Hartley Sweeten and others who helped me during development of
94 the driver. Simplemachines.it donated me a Sim.One board which I used testing