blob: 2f2b3c8544155efee9206515059be691ea54ad1d [file] [log] [blame]
Pierre Ossmane29a7d72007-05-26 13:48:18 +02001/*
2 * include/linux/mmc/sdio_func.h
3 *
4 * Copyright 2007 Pierre Ossman
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 */
11
12#ifndef MMC_SDIO_FUNC_H
13#define MMC_SDIO_FUNC_H
14
15struct mmc_card;
16
17/*
Nicolas Pitreb1538bc2007-06-16 02:06:47 -040018 * SDIO function CIS tuple (unknown to the core)
19 */
20struct sdio_func_tuple {
21 struct sdio_func_tuple *next;
22 unsigned char code;
23 unsigned char size;
24 unsigned char data[0];
25};
26
27/*
Pierre Ossmane29a7d72007-05-26 13:48:18 +020028 * SDIO function devices
29 */
30struct sdio_func {
31 struct mmc_card *card; /* the card this device belongs to */
32 struct device dev; /* the device */
33 unsigned int num; /* function number */
Pierre Ossman05970072007-06-11 21:01:00 +020034
35 unsigned char class; /* standard interface class */
36 unsigned short vendor; /* vendor id */
37 unsigned short device; /* device id */
38
Pierre Ossman1a632f82007-07-30 15:15:30 +020039 unsigned short blksize; /* maximum block size */
40
Pierre Ossmane29a7d72007-05-26 13:48:18 +020041 unsigned int state; /* function state */
42#define SDIO_STATE_PRESENT (1<<0) /* present in sysfs */
Nicolas Pitreb1538bc2007-06-16 02:06:47 -040043
44 struct sdio_func_tuple *tuples;
Pierre Ossmane29a7d72007-05-26 13:48:18 +020045};
46
47#define sdio_func_present(f) ((f)->state & SDIO_STATE_PRESENT)
48
49#define sdio_func_set_present(f) ((f)->state |= SDIO_STATE_PRESENT)
50
51#define sdio_func_id(f) ((f)->dev.bus_id)
52
Pierre Ossmanf76c8512007-05-27 12:00:02 +020053#define sdio_get_drvdata(f) dev_get_drvdata(&(f)->dev)
54#define sdio_set_drvdata(f,d) dev_set_drvdata(&(f)->dev, d)
55
56/*
57 * SDIO function device driver
58 */
59struct sdio_driver {
60 char *name;
61
62 int (*probe)(struct sdio_func *);
63 void (*remove)(struct sdio_func *);
64
65 struct device_driver drv;
66};
67
68extern int sdio_register_driver(struct sdio_driver *);
69extern void sdio_unregister_driver(struct sdio_driver *);
70
Pierre Ossman46f555f2007-05-27 12:57:15 +020071/*
72 * SDIO I/O operations
73 */
74extern void sdio_claim_host(struct sdio_func *func);
75extern void sdio_release_host(struct sdio_func *func);
76
Pierre Ossmanfa64efa2007-05-27 14:22:37 +020077extern int sdio_enable_func(struct sdio_func *func);
78extern int sdio_disable_func(struct sdio_func *func);
79
Pierre Ossman46f555f2007-05-27 12:57:15 +020080extern unsigned char sdio_readb(struct sdio_func *func,
81 unsigned int addr, int *err_ret);
82
83extern void sdio_writeb(struct sdio_func *func, unsigned char b,
84 unsigned int addr, int *err_ret);
85
Pierre Ossmane29a7d72007-05-26 13:48:18 +020086#endif
87