2019-05-27 14:55:01 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
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
|
|
|
*/
|
|
|
|
|
2011-05-28 04:04:03 +08:00
|
|
|
#ifndef LINUX_MMC_SDIO_FUNC_H
|
|
|
|
#define LINUX_MMC_SDIO_FUNC_H
|
2007-05-26 19:48:18 +08:00
|
|
|
|
2007-06-16 21:54:55 +08:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
|
2010-03-06 05:43:31 +08:00
|
|
|
#include <linux/mmc/pm.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;
|
2020-02-27 06:31:25 +08:00
|
|
|
unsigned char data[];
|
2007-06-16 14:06:47 +08:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2017-03-30 02:54:37 +08:00
|
|
|
u8 *tmpbuf; /* DMA:able scratch buffer */
|
2007-07-06 19:35:01 +08:00
|
|
|
|
2020-07-27 21:38:35 +08:00
|
|
|
u8 major_rev; /* major revision number */
|
|
|
|
u8 minor_rev; /* minor revision number */
|
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)
|
2009-09-23 07:45:30 +08:00
|
|
|
#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev)
|
2007-05-27 18:00:02 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 *);
|
|
|
|
|
2019-03-14 05:01:58 +08:00
|
|
|
/**
|
|
|
|
* module_sdio_driver() - Helper macro for registering a SDIO driver
|
|
|
|
* @__sdio_driver: sdio_driver struct
|
|
|
|
*
|
|
|
|
* Helper macro for SDIO drivers which do not do anything special in module
|
|
|
|
* init/exit. This eliminates a lot of boilerplate. Each module may only
|
|
|
|
* use this macro once, and calling it replaces module_init() and module_exit()
|
|
|
|
*/
|
|
|
|
#define module_sdio_driver(__sdio_driver) \
|
|
|
|
module_driver(__sdio_driver, sdio_register_driver, \
|
|
|
|
sdio_unregister_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);
|
|
|
|
|
2010-05-27 05:42:09 +08:00
|
|
|
extern u8 sdio_writeb_readb(struct sdio_func *func, u8 write_byte,
|
|
|
|
unsigned int addr, int *err_ret);
|
|
|
|
|
2007-07-06 19:35:01 +08: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 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);
|
|
|
|
|
2010-03-06 05:43:31 +08: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);
|
|
|
|
|
2019-06-18 01:56:50 +08:00
|
|
|
extern void sdio_retune_crc_disable(struct sdio_func *func);
|
|
|
|
extern void sdio_retune_crc_enable(struct sdio_func *func);
|
|
|
|
|
2019-06-18 01:56:52 +08:00
|
|
|
extern void sdio_retune_hold_now(struct sdio_func *func);
|
|
|
|
extern void sdio_retune_release(struct sdio_func *func);
|
|
|
|
|
2011-05-28 04:04:03 +08:00
|
|
|
#endif /* LINUX_MMC_SDIO_FUNC_H */
|