blob: bfde741a543dce055b92565b2c7f08d56cdfe2af [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
David Brownell15a05802007-08-08 09:12:54 -07002#ifndef __LINUX_SPI_MMC_SPI_H
3#define __LINUX_SPI_MMC_SPI_H
4
Anton Vorontsov9c43df52008-12-30 18:15:28 +03005#include <linux/spi/spi.h>
Anton Vorontsov63e14622008-06-01 11:49:32 +02006#include <linux/interrupt.h>
7
Paul Gortmaker313162d2012-01-30 11:46:54 -05008struct device;
David Brownell15a05802007-08-08 09:12:54 -07009struct mmc_host;
10
Laurent Pinchartbf287a92013-08-08 12:38:32 +020011#define MMC_SPI_USE_CD_GPIO (1 << 0)
12#define MMC_SPI_USE_RO_GPIO (1 << 1)
13#define MMC_SPI_CD_GPIO_ACTIVE_LOW (1 << 2)
14#define MMC_SPI_RO_GPIO_ACTIVE_LOW (1 << 3)
15
David Brownell15a05802007-08-08 09:12:54 -070016/* Put this in platform_data of a device being used to manage an MMC/SD
17 * card slot. (Modeled after PXA mmc glue; see that for usage examples.)
18 *
19 * REVISIT This is not a spi-specific notion. Any card slot should be
20 * able to handle it. If the MMC core doesn't adopt this kind of notion,
21 * switch the "struct device *" parameters over to "struct spi_device *".
22 */
23struct mmc_spi_platform_data {
24 /* driver activation and (optional) card detect irq hookup */
25 int (*init)(struct device *,
26 irqreturn_t (*)(int, void *),
27 void *);
28 void (*exit)(struct device *, void *);
29
Laurent Pinchartbf287a92013-08-08 12:38:32 +020030 /*
31 * Card Detect and Read Only GPIOs. To enable debouncing on the card
32 * detect GPIO, set the cd_debounce to the debounce time in
33 * microseconds.
34 */
35 unsigned int flags;
36 unsigned int cd_gpio;
37 unsigned int cd_debounce;
38 unsigned int ro_gpio;
39
Anton Vorontsov619ef4b2008-06-17 18:17:21 +040040 /* Capabilities to pass into mmc core (e.g. MMC_CAP_NEEDS_POLL). */
41 unsigned long caps;
Laurent Pinchartbf287a92013-08-08 12:38:32 +020042 unsigned long caps2;
Anton Vorontsov619ef4b2008-06-17 18:17:21 +040043
David Brownell15a05802007-08-08 09:12:54 -070044 /* how long to debounce card detect, in msecs */
45 u16 detect_delay;
46
47 /* power management */
48 u16 powerup_msecs; /* delay of up to 250 msec */
49 u32 ocr_mask; /* available voltages */
50 void (*setpower)(struct device *, unsigned int maskval);
51};
52
Anton Vorontsov9c43df52008-12-30 18:15:28 +030053#ifdef CONFIG_OF
54extern struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi);
55extern void mmc_spi_put_pdata(struct spi_device *spi);
56#else
57static inline struct mmc_spi_platform_data *
58mmc_spi_get_pdata(struct spi_device *spi)
59{
60 return spi->dev.platform_data;
61}
62static inline void mmc_spi_put_pdata(struct spi_device *spi) {}
63#endif /* CONFIG_OF */
64
David Brownell15a05802007-08-08 09:12:54 -070065#endif /* __LINUX_SPI_MMC_SPI_H */