2007-05-26 11:48:18 +00:00
|
|
|
/*
|
|
|
|
* include/linux/mmc/sdio_func.h
|
|
|
|
*
|
2008-06-28 10:52:45 +00:00
|
|
|
* Copyright 2007-2008 Pierre Ossman
|
2007-05-26 11:48:18 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MMC_SDIO_FUNC_H
|
|
|
|
#define MMC_SDIO_FUNC_H
|
|
|
|
|
2007-06-16 13:54:55 +00:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
|
2010-03-05 21:43:31 +00:00
|
|
|
#include <linux/mmc/pm.h>
|
|
|
|
|
2007-05-26 11:48:18 +00:00
|
|
|
struct mmc_card;
|
2007-06-30 14:29:41 +00:00
|
|
|
struct sdio_func;
|
|
|
|
|
|
|
|
typedef void (sdio_irq_handler_t)(struct sdio_func *);
|
2007-05-26 11:48:18 +00:00
|
|
|
|
2007-06-16 06:06:47 +00:00
|
|
|
/*
|
|
|
|
* SDIO function CIS tuple (unknown to the core)
|
|
|
|
*/
|
|
|
|
struct sdio_func_tuple {
|
|
|
|
struct sdio_func_tuple *next;
|
|
|
|
unsigned char code;
|
|
|
|
unsigned char size;
|
|
|
|
unsigned char data[0];
|
|
|
|
};
|
|
|
|
|
2007-05-26 11:48:18 +00:00
|
|
|
/*
|
|
|
|
* SDIO function devices
|
|
|
|
*/
|
|
|
|
struct sdio_func {
|
|
|
|
struct mmc_card *card; /* the card this device belongs to */
|
|
|
|
struct device dev; /* the device */
|
2007-06-30 14:29:41 +00:00
|
|
|
sdio_irq_handler_t *irq_handler; /* IRQ callback */
|
2007-05-26 11:48:18 +00:00
|
|
|
unsigned int num; /* function number */
|
2007-06-11 19:01:00 +00:00
|
|
|
|
|
|
|
unsigned char class; /* standard interface class */
|
|
|
|
unsigned short vendor; /* vendor id */
|
|
|
|
unsigned short device; /* device id */
|
|
|
|
|
2007-08-08 13:23:48 +00:00
|
|
|
unsigned max_blksize; /* maximum block size */
|
|
|
|
unsigned cur_blksize; /* current block size */
|
2007-07-30 13:15:30 +00:00
|
|
|
|
2008-07-09 23:41:43 +00:00
|
|
|
unsigned enable_timeout; /* max enable timeout in msec */
|
|
|
|
|
2007-05-26 11:48:18 +00:00
|
|
|
unsigned int state; /* function state */
|
|
|
|
#define SDIO_STATE_PRESENT (1<<0) /* present in sysfs */
|
2007-06-16 06:06:47 +00:00
|
|
|
|
2007-07-06 11:35:01 +00:00
|
|
|
u8 tmpbuf[4]; /* DMA:able scratch buffer */
|
|
|
|
|
2007-09-19 16:42:16 +00:00
|
|
|
unsigned num_info; /* number of info strings */
|
|
|
|
const char **info; /* info strings */
|
|
|
|
|
2007-06-16 06:06:47 +00:00
|
|
|
struct sdio_func_tuple *tuples;
|
2007-05-26 11:48:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define sdio_func_present(f) ((f)->state & SDIO_STATE_PRESENT)
|
|
|
|
|
|
|
|
#define sdio_func_set_present(f) ((f)->state |= SDIO_STATE_PRESENT)
|
|
|
|
|
2008-11-08 20:37:46 +00:00
|
|
|
#define sdio_func_id(f) (dev_name(&(f)->dev))
|
2007-05-26 11:48:18 +00:00
|
|
|
|
2007-05-27 10:00:02 +00:00
|
|
|
#define sdio_get_drvdata(f) dev_get_drvdata(&(f)->dev)
|
|
|
|
#define sdio_set_drvdata(f,d) dev_set_drvdata(&(f)->dev, d)
|
2009-09-22 23:45:30 +00:00
|
|
|
#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev)
|
2007-05-27 10:00:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* SDIO function device driver
|
|
|
|
*/
|
|
|
|
struct sdio_driver {
|
|
|
|
char *name;
|
2007-06-16 13:54:55 +00:00
|
|
|
const struct sdio_device_id *id_table;
|
2007-05-27 10:00:02 +00:00
|
|
|
|
2007-06-16 13:54:55 +00:00
|
|
|
int (*probe)(struct sdio_func *, const struct sdio_device_id *);
|
2007-05-27 10:00:02 +00:00
|
|
|
void (*remove)(struct sdio_func *);
|
|
|
|
|
|
|
|
struct device_driver drv;
|
|
|
|
};
|
|
|
|
|
2009-09-22 23:45:30 +00:00
|
|
|
#define to_sdio_driver(d) container_of(d, struct sdio_driver, drv)
|
|
|
|
|
2007-06-16 13:54:55 +00:00
|
|
|
/**
|
|
|
|
* SDIO_DEVICE - macro used to describe a specific SDIO device
|
|
|
|
* @vend: the 16 bit manufacturer code
|
|
|
|
* @dev: the 16 bit function id
|
|
|
|
*
|
|
|
|
* This macro is used to create a struct sdio_device_id that matches a
|
|
|
|
* specific device. The class field will be set to SDIO_ANY_ID.
|
|
|
|
*/
|
|
|
|
#define SDIO_DEVICE(vend,dev) \
|
|
|
|
.class = SDIO_ANY_ID, \
|
|
|
|
.vendor = (vend), .device = (dev)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SDIO_DEVICE_CLASS - macro used to describe a specific SDIO device class
|
|
|
|
* @dev_class: the 8 bit standard interface code
|
|
|
|
*
|
|
|
|
* This macro is used to create a struct sdio_device_id that matches a
|
|
|
|
* specific standard SDIO function type. The vendor and device fields will
|
|
|
|
* be set to SDIO_ANY_ID.
|
|
|
|
*/
|
|
|
|
#define SDIO_DEVICE_CLASS(dev_class) \
|
|
|
|
.class = (dev_class), \
|
|
|
|
.vendor = SDIO_ANY_ID, .device = SDIO_ANY_ID
|
|
|
|
|
2007-05-27 10:00:02 +00:00
|
|
|
extern int sdio_register_driver(struct sdio_driver *);
|
|
|
|
extern void sdio_unregister_driver(struct sdio_driver *);
|
|
|
|
|
2007-05-27 10:57:15 +00:00
|
|
|
/*
|
|
|
|
* SDIO I/O operations
|
|
|
|
*/
|
|
|
|
extern void sdio_claim_host(struct sdio_func *func);
|
|
|
|
extern void sdio_release_host(struct sdio_func *func);
|
|
|
|
|
2007-05-27 12:22:37 +00:00
|
|
|
extern int sdio_enable_func(struct sdio_func *func);
|
|
|
|
extern int sdio_disable_func(struct sdio_func *func);
|
|
|
|
|
2007-08-08 13:23:48 +00:00
|
|
|
extern int sdio_set_block_size(struct sdio_func *func, unsigned blksz);
|
|
|
|
|
2007-06-30 14:29:41 +00:00
|
|
|
extern int sdio_claim_irq(struct sdio_func *func, sdio_irq_handler_t *handler);
|
|
|
|
extern int sdio_release_irq(struct sdio_func *func);
|
|
|
|
|
2008-06-28 10:52:45 +00:00
|
|
|
extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz);
|
|
|
|
|
2008-06-30 07:50:24 +00:00
|
|
|
extern u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret);
|
|
|
|
extern u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret);
|
|
|
|
extern u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret);
|
2007-07-06 11:35:01 +00:00
|
|
|
|
|
|
|
extern int sdio_memcpy_fromio(struct sdio_func *func, void *dst,
|
|
|
|
unsigned int addr, int count);
|
|
|
|
extern int sdio_readsb(struct sdio_func *func, void *dst,
|
|
|
|
unsigned int addr, int count);
|
2007-05-27 10:57:15 +00:00
|
|
|
|
2008-06-30 07:50:24 +00:00
|
|
|
extern void sdio_writeb(struct sdio_func *func, u8 b,
|
2007-05-27 10:57:15 +00:00
|
|
|
unsigned int addr, int *err_ret);
|
2008-06-30 07:50:24 +00:00
|
|
|
extern void sdio_writew(struct sdio_func *func, u16 b,
|
2007-07-06 11:35:01 +00:00
|
|
|
unsigned int addr, int *err_ret);
|
2008-06-30 07:50:24 +00:00
|
|
|
extern void sdio_writel(struct sdio_func *func, u32 b,
|
2007-07-06 11:35:01 +00:00
|
|
|
unsigned int addr, int *err_ret);
|
|
|
|
|
2010-05-26 21:42:09 +00:00
|
|
|
extern u8 sdio_writeb_readb(struct sdio_func *func, u8 write_byte,
|
|
|
|
unsigned int addr, int *err_ret);
|
|
|
|
|
2007-07-06 11:35:01 +00:00
|
|
|
extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr,
|
|
|
|
void *src, int count);
|
|
|
|
extern int sdio_writesb(struct sdio_func *func, unsigned int addr,
|
|
|
|
void *src, int count);
|
2007-05-27 10:57:15 +00:00
|
|
|
|
2007-08-10 12:29:46 +00:00
|
|
|
extern unsigned char sdio_f0_readb(struct sdio_func *func,
|
|
|
|
unsigned int addr, int *err_ret);
|
|
|
|
extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b,
|
|
|
|
unsigned int addr, int *err_ret);
|
|
|
|
|
2010-03-05 21:43:31 +00:00
|
|
|
extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func);
|
|
|
|
extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags);
|
|
|
|
|
2007-05-26 11:48:18 +00:00
|
|
|
#endif
|
|
|
|
|