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