1 /*
2  * MMC definitions for OMAP2
3  *
4  * Copyright (C) 2006 Nokia Corporation
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 
11 #define OMAP_MMC_MAX_SLOTS	2
12 
13 struct mmc_card;
14 
15 struct omap_mmc_platform_data {
16 	/* back-link to device */
17 	struct device *dev;
18 
19 	/* number of slots per controller */
20 	unsigned nr_slots:2;
21 
22 	/* set if your board has components or wiring that limits the
23 	 * maximum frequency on the MMC bus */
24 	unsigned int max_freq;
25 
26 	/* switch the bus to a new slot */
27 	int (*switch_slot)(struct device *dev, int slot);
28 	/* initialize board-specific MMC functionality, can be NULL if
29 	 * not supported */
30 	int (*init)(struct device *dev);
31 	void (*cleanup)(struct device *dev);
32 	void (*shutdown)(struct device *dev);
33 
34 	/* To handle board related suspend/resume functionality for MMC */
35 	int (*suspend)(struct device *dev, int slot);
36 	int (*resume)(struct device *dev, int slot);
37 
38 	/* Return context loss count due to PM states changing */
39 	int (*get_context_loss_count)(struct device *dev);
40 
41 	/* Integrating attributes from the omap_hwmod layer */
42 	u8 controller_flags;
43 
44 	/* Register offset deviation */
45 	u16 reg_offset;
46 
47 	struct omap_mmc_slot_data {
48 
49 		/*
50 		 * 4/8 wires and any additional host capabilities
51 		 * need to OR'd all capabilities (ref. linux/mmc/host.h)
52 		 */
53 		u8  wires;	/* Used for the MMC driver on omap1 and 2420 */
54 		u32 caps;	/* Used for the MMC driver on 2430 and later */
55 		u32 pm_caps;	/* PM capabilities of the mmc */
56 
57 		/*
58 		 * nomux means "standard" muxing is wrong on this board, and
59 		 * that board-specific code handled it before common init logic.
60 		 */
61 		unsigned nomux:1;
62 
63 		/* switch pin can be for card detect (default) or card cover */
64 		unsigned cover:1;
65 
66 		/* use the internal clock */
67 		unsigned internal_clock:1;
68 
69 		/* nonremovable e.g. eMMC */
70 		unsigned nonremovable:1;
71 
72 		/* Try to sleep or power off when possible */
73 		unsigned power_saving:1;
74 
75 		/* If using power_saving and the MMC power is not to go off */
76 		unsigned no_off:1;
77 
78 		/* eMMC does not handle power off when not in sleep state */
79 		unsigned no_regulator_off_init:1;
80 
81 		/* Regulator off remapped to sleep */
82 		unsigned vcc_aux_disable_is_sleep:1;
83 
84 		/* we can put the features above into this variable */
85 #define MMC_OMAP7XX		(1 << 3)
86 #define MMC_OMAP15XX		(1 << 4)
87 #define MMC_OMAP16XX		(1 << 5)
88 		unsigned features;
89 
90 		int switch_pin;			/* gpio (card detect) */
91 		int gpio_wp;			/* gpio (write protect) */
92 
93 		int (*set_bus_mode)(struct device *dev, int slot, int bus_mode);
94 		int (*set_power)(struct device *dev, int slot,
95 				 int power_on, int vdd);
96 		int (*get_ro)(struct device *dev, int slot);
97 		void (*remux)(struct device *dev, int slot, int power_on);
98 		/* Call back before enabling / disabling regulators */
99 		void (*before_set_reg)(struct device *dev, int slot,
100 				       int power_on, int vdd);
101 		/* Call back after enabling / disabling regulators */
102 		void (*after_set_reg)(struct device *dev, int slot,
103 				      int power_on, int vdd);
104 		/* if we have special card, init it using this callback */
105 		void (*init_card)(struct mmc_card *card);
106 
107 		/* return MMC cover switch state, can be NULL if not supported.
108 		 *
109 		 * possible return values:
110 		 *   0 - closed
111 		 *   1 - open
112 		 */
113 		int (*get_cover_state)(struct device *dev, int slot);
114 
115 		const char *name;
116 		u32 ocr_mask;
117 
118 		/* Card detection IRQs */
119 		int card_detect_irq;
120 		int (*card_detect)(struct device *dev, int slot);
121 
122 		unsigned int ban_openended:1;
123 
124 	} slots[OMAP_MMC_MAX_SLOTS];
125 };
126