0001
0002
0003
0004
0005
0006
0007
0008 #ifndef LINUX_MMC_SDIO_FUNC_H
0009 #define LINUX_MMC_SDIO_FUNC_H
0010
0011 #include <linux/device.h>
0012 #include <linux/mod_devicetable.h>
0013
0014 #include <linux/mmc/pm.h>
0015
0016 struct mmc_card;
0017 struct sdio_func;
0018
0019 typedef void (sdio_irq_handler_t)(struct sdio_func *);
0020
0021
0022
0023
0024 struct sdio_func_tuple {
0025 struct sdio_func_tuple *next;
0026 unsigned char code;
0027 unsigned char size;
0028 unsigned char data[];
0029 };
0030
0031
0032
0033
0034 struct sdio_func {
0035 struct mmc_card *card;
0036 struct device dev;
0037 sdio_irq_handler_t *irq_handler;
0038 unsigned int num;
0039
0040 unsigned char class;
0041 unsigned short vendor;
0042 unsigned short device;
0043
0044 unsigned max_blksize;
0045 unsigned cur_blksize;
0046
0047 unsigned enable_timeout;
0048
0049 unsigned int state;
0050 #define SDIO_STATE_PRESENT (1<<0)
0051
0052 u8 *tmpbuf;
0053
0054 u8 major_rev;
0055 u8 minor_rev;
0056 unsigned num_info;
0057 const char **info;
0058
0059 struct sdio_func_tuple *tuples;
0060 };
0061
0062 #define sdio_func_present(f) ((f)->state & SDIO_STATE_PRESENT)
0063
0064 #define sdio_func_set_present(f) ((f)->state |= SDIO_STATE_PRESENT)
0065
0066 #define sdio_func_id(f) (dev_name(&(f)->dev))
0067
0068 #define sdio_get_drvdata(f) dev_get_drvdata(&(f)->dev)
0069 #define sdio_set_drvdata(f,d) dev_set_drvdata(&(f)->dev, d)
0070 #define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev)
0071
0072
0073
0074
0075 struct sdio_driver {
0076 char *name;
0077 const struct sdio_device_id *id_table;
0078
0079 int (*probe)(struct sdio_func *, const struct sdio_device_id *);
0080 void (*remove)(struct sdio_func *);
0081
0082 struct device_driver drv;
0083 };
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 #define SDIO_DEVICE(vend,dev) \
0094 .class = SDIO_ANY_ID, \
0095 .vendor = (vend), .device = (dev)
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 #define SDIO_DEVICE_CLASS(dev_class) \
0106 .class = (dev_class), \
0107 .vendor = SDIO_ANY_ID, .device = SDIO_ANY_ID
0108
0109 extern int sdio_register_driver(struct sdio_driver *);
0110 extern void sdio_unregister_driver(struct sdio_driver *);
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120 #define module_sdio_driver(__sdio_driver) \
0121 module_driver(__sdio_driver, sdio_register_driver, \
0122 sdio_unregister_driver)
0123
0124
0125
0126
0127 extern void sdio_claim_host(struct sdio_func *func);
0128 extern void sdio_release_host(struct sdio_func *func);
0129
0130 extern int sdio_enable_func(struct sdio_func *func);
0131 extern int sdio_disable_func(struct sdio_func *func);
0132
0133 extern int sdio_set_block_size(struct sdio_func *func, unsigned blksz);
0134
0135 extern int sdio_claim_irq(struct sdio_func *func, sdio_irq_handler_t *handler);
0136 extern int sdio_release_irq(struct sdio_func *func);
0137
0138 extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz);
0139
0140 extern u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret);
0141 extern u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret);
0142 extern u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret);
0143
0144 extern int sdio_memcpy_fromio(struct sdio_func *func, void *dst,
0145 unsigned int addr, int count);
0146 extern int sdio_readsb(struct sdio_func *func, void *dst,
0147 unsigned int addr, int count);
0148
0149 extern void sdio_writeb(struct sdio_func *func, u8 b,
0150 unsigned int addr, int *err_ret);
0151 extern void sdio_writew(struct sdio_func *func, u16 b,
0152 unsigned int addr, int *err_ret);
0153 extern void sdio_writel(struct sdio_func *func, u32 b,
0154 unsigned int addr, int *err_ret);
0155
0156 extern u8 sdio_writeb_readb(struct sdio_func *func, u8 write_byte,
0157 unsigned int addr, int *err_ret);
0158
0159 extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr,
0160 void *src, int count);
0161 extern int sdio_writesb(struct sdio_func *func, unsigned int addr,
0162 void *src, int count);
0163
0164 extern unsigned char sdio_f0_readb(struct sdio_func *func,
0165 unsigned int addr, int *err_ret);
0166 extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b,
0167 unsigned int addr, int *err_ret);
0168
0169 extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func);
0170 extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags);
0171
0172 extern void sdio_retune_crc_disable(struct sdio_func *func);
0173 extern void sdio_retune_crc_enable(struct sdio_func *func);
0174
0175 extern void sdio_retune_hold_now(struct sdio_func *func);
0176 extern void sdio_retune_release(struct sdio_func *func);
0177
0178 #endif