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