2007-05-26 19:48:18 +08:00
|
|
|
/*
|
|
|
|
* include/linux/mmc/sdio_func.h
|
|
|
|
*
|
2008-06-28 18:52:45 +08:00
|
|
|
* Copyright 2007-2008 Pierre Ossman
|
2007-05-26 19:48:18 +08: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 21:54:55 +08:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
|
2007-05-26 19:48:18 +08:00
|
|
|
struct mmc_card;
|
2007-06-30 22:29:41 +08:00
|
|
|
struct sdio_func;
|
|
|
|
|
|
|
|
typedef void (sdio_irq_handler_t)(struct sdio_func *);
|
2007-05-26 19:48:18 +08:00
|
|
|
|
2007-06-16 14:06:47 +08: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 19:48:18 +08: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 22:29:41 +08:00
|
|
|
sdio_irq_handler_t *irq_handler; /* IRQ callback */
|
2007-05-26 19:48:18 +08:00
|
|
|
unsigned int num; /* function number */
|
2007-06-12 03:01:00 +08:00
|
|
|
|
|
|
|
unsigned char class; /* standard interface class */
|
|
|
|
unsigned short vendor; /* vendor id */
|
|
|
|
unsigned short device; /* device id */
|
|
|
|
|
2007-08-08 21:23:48 +08:00
|
|
|
unsigned max_blksize; /* maximum block size */
|
|
|
|
unsigned cur_blksize; /* current block size */
|
2007-07-30 21:15:30 +08:00
|
|
|
|
2008-07-10 07:41:43 +08:00
|
|
|
unsigned enable_timeout; /* max enable timeout in msec */
|
|
|
|
|
2007-05-26 19:48:18 +08:00
|
|
|
unsigned int state; /* function state */
|
|
|
|
#define SDIO_STATE_PRESENT (1<<0) /* present in sysfs */
|
2007-06-16 14:06:47 +08:00
|
|
|
|
2007-07-06 19:35:01 +08:00
|
|
|
u8 tmpbuf[4]; /* DMA:able scratch buffer */
|
|
|
|
|
2007-09-20 00:42:16 +08:00
|
|
|
unsigned num_info; /* number of info strings */
|
|
|
|
const char **info; /* info strings */
|
|
|
|
|
2007-06-16 14:06:47 +08:00
|
|
|
struct sdio_func_tuple *tuples;
|
2007-05-26 19:48:18 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define sdio_func_present(f) ((f)->state & SDIO_STATE_PRESENT)
|
|
|
|
|
|
|
|
#define sdio_func_set_present(f) ((f)->state |= SDIO_STATE_PRESENT)
|
|
|
|
|
2008-11-09 04:37:46 +08:00
|
|
|
#define sdio_func_id(f) (dev_name(&(f)->dev))
|
2007-05-26 19:48:18 +08:00
|
|
|
|
2007-05-27 18:00:02 +08:00
|
|
|
#define sdio_get_drvdata(f) dev_get_drvdata(&(f)->dev)
|
|
|
|
#define sdio_set_drvdata(f,d) dev_set_drvdata(&(f)->dev, d)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SDIO function device driver
|
|
|
|
*/
|
|
|
|
struct sdio_driver {
|
|
|
|
char *name;
|
2007-06-16 21:54:55 +08:00
|
|
|
const struct sdio_device_id *id_table;
|
2007-05-27 18:00:02 +08:00
|
|
|
|
2007-06-16 21:54:55 +08:00
|
|
|
int (*probe)(struct sdio_func *, const struct sdio_device_id *);
|
2007-05-27 18:00:02 +08:00
|
|
|
void (*remove)(struct sdio_func *);
|
|
|
|
|
|
|
|
struct device_driver drv;
|
|
|
|
};
|
|
|
|
|
2007-06-16 21:54:55 +08: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 18:00:02 +08:00
|
|
|
extern int sdio_register_driver(struct sdio_driver *);
|
|
|
|
extern void sdio_unregister_driver(struct sdio_driver *);
|
|
|
|
|
2007-05-27 18:57:15 +08: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 20:22:37 +08:00
|
|
|
extern int sdio_enable_func(struct sdio_func *func);
|
|
|
|
extern int sdio_disable_func(struct sdio_func *func);
|
|
|
|
|
2007-08-08 21:23:48 +08:00
|
|
|
extern int sdio_set_block_size(struct sdio_func *func, unsigned blksz);
|
|
|
|
|
2007-06-30 22:29:41 +08: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 18:52:45 +08:00
|
|
|
extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz);
|
|
|
|
|
2008-06-30 15:50:24 +08: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 19:35:01 +08: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 18:57:15 +08:00
|
|
|
|
2008-06-30 15:50:24 +08:00
|
|
|
extern void sdio_writeb(struct sdio_func *func, u8 b,
|
2007-05-27 18:57:15 +08:00
|
|
|
unsigned int addr, int *err_ret);
|
2008-06-30 15:50:24 +08:00
|
|
|
extern void sdio_writew(struct sdio_func *func, u16 b,
|
2007-07-06 19:35:01 +08:00
|
|
|
unsigned int addr, int *err_ret);
|
2008-06-30 15:50:24 +08:00
|
|
|
extern void sdio_writel(struct sdio_func *func, u32 b,
|
2007-07-06 19:35:01 +08:00
|
|
|
unsigned int addr, int *err_ret);
|
|
|
|
|
|
|
|
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 18:57:15 +08:00
|
|
|
|
2007-08-10 20:29:46 +08: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);
|
|
|
|
|
2007-05-26 19:48:18 +08:00
|
|
|
#endif
|
|
|
|
|