blob: 87cdb35bedda4dce63a878f5c1fa348167e841c7 [file] [log] [blame]
David Brownell15a05802007-08-08 09:12:54 -07001#ifndef __LINUX_SPI_MMC_SPI_H
2#define __LINUX_SPI_MMC_SPI_H
3
Anton Vorontsov9c43df52008-12-30 18:15:28 +03004#include <linux/spi/spi.h>
Anton Vorontsov63e14622008-06-01 11:49:32 +02005#include <linux/interrupt.h>
6
Paul Gortmaker313162d2012-01-30 11:46:54 -05007struct device;
David Brownell15a05802007-08-08 09:12:54 -07008struct mmc_host;
9
Laurent Pinchartbf287a92013-08-08 12:38:32 +020010#define MMC_SPI_USE_CD_GPIO (1 << 0)
11#define MMC_SPI_USE_RO_GPIO (1 << 1)
12#define MMC_SPI_CD_GPIO_ACTIVE_LOW (1 << 2)
13#define MMC_SPI_RO_GPIO_ACTIVE_LOW (1 << 3)
14
David Brownell15a05802007-08-08 09:12:54 -070015/* Put this in platform_data of a device being used to manage an MMC/SD
16 * card slot. (Modeled after PXA mmc glue; see that for usage examples.)
17 *
18 * REVISIT This is not a spi-specific notion. Any card slot should be
19 * able to handle it. If the MMC core doesn't adopt this kind of notion,
20 * switch the "struct device *" parameters over to "struct spi_device *".
21 */
22struct mmc_spi_platform_data {
23 /* driver activation and (optional) card detect irq hookup */
24 int (*init)(struct device *,
25 irqreturn_t (*)(int, void *),
26 void *);
27 void (*exit)(struct device *, void *);
28
29 /* sense switch on sd cards */
30 int (*get_ro)(struct device *);
31
Anton Vorontsov619ef4b2008-06-17 18:17:21 +040032 /*
33 * If board does not use CD interrupts, driver can optimize polling
34 * using this function.
35 */
36 int (*get_cd)(struct device *);
37
Laurent Pinchartbf287a92013-08-08 12:38:32 +020038 /*
39 * Card Detect and Read Only GPIOs. To enable debouncing on the card
40 * detect GPIO, set the cd_debounce to the debounce time in
41 * microseconds.
42 */
43 unsigned int flags;
44 unsigned int cd_gpio;
45 unsigned int cd_debounce;
46 unsigned int ro_gpio;
47
Anton Vorontsov619ef4b2008-06-17 18:17:21 +040048 /* Capabilities to pass into mmc core (e.g. MMC_CAP_NEEDS_POLL). */
49 unsigned long caps;
Laurent Pinchartbf287a92013-08-08 12:38:32 +020050 unsigned long caps2;
Anton Vorontsov619ef4b2008-06-17 18:17:21 +040051
David Brownell15a05802007-08-08 09:12:54 -070052 /* how long to debounce card detect, in msecs */
53 u16 detect_delay;
54
55 /* power management */
56 u16 powerup_msecs; /* delay of up to 250 msec */
57 u32 ocr_mask; /* available voltages */
58 void (*setpower)(struct device *, unsigned int maskval);
59};
60
Anton Vorontsov9c43df52008-12-30 18:15:28 +030061#ifdef CONFIG_OF
62extern struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi);
63extern void mmc_spi_put_pdata(struct spi_device *spi);
64#else
65static inline struct mmc_spi_platform_data *
66mmc_spi_get_pdata(struct spi_device *spi)
67{
68 return spi->dev.platform_data;
69}
70static inline void mmc_spi_put_pdata(struct spi_device *spi) {}
71#endif /* CONFIG_OF */
72
David Brownell15a05802007-08-08 09:12:54 -070073#endif /* __LINUX_SPI_MMC_SPI_H */