Pierre Ossman | e29a7d7 | 2007-05-26 13:48:18 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 15 | struct mmc_card; |
| 16 | |
| 17 | /* |
Nicolas Pitre | b1538bc | 2007-06-16 02:06:47 -0400 | [diff] [blame] | 18 | * SDIO function CIS tuple (unknown to the core) |
| 19 | */ |
| 20 | struct 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 Ossman | e29a7d7 | 2007-05-26 13:48:18 +0200 | [diff] [blame] | 28 | * SDIO function devices |
| 29 | */ |
| 30 | struct 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 Ossman | 0597007 | 2007-06-11 21:01:00 +0200 | [diff] [blame] | 34 | |
| 35 | unsigned char class; /* standard interface class */ |
| 36 | unsigned short vendor; /* vendor id */ |
| 37 | unsigned short device; /* device id */ |
| 38 | |
Pierre Ossman | 1a632f8 | 2007-07-30 15:15:30 +0200 | [diff] [blame^] | 39 | unsigned short blksize; /* maximum block size */ |
| 40 | |
Pierre Ossman | e29a7d7 | 2007-05-26 13:48:18 +0200 | [diff] [blame] | 41 | unsigned int state; /* function state */ |
| 42 | #define SDIO_STATE_PRESENT (1<<0) /* present in sysfs */ |
Nicolas Pitre | b1538bc | 2007-06-16 02:06:47 -0400 | [diff] [blame] | 43 | |
| 44 | struct sdio_func_tuple *tuples; |
Pierre Ossman | e29a7d7 | 2007-05-26 13:48:18 +0200 | [diff] [blame] | 45 | }; |
| 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 Ossman | f76c851 | 2007-05-27 12:00:02 +0200 | [diff] [blame] | 53 | #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 | */ |
| 59 | struct 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 | |
| 68 | extern int sdio_register_driver(struct sdio_driver *); |
| 69 | extern void sdio_unregister_driver(struct sdio_driver *); |
| 70 | |
Pierre Ossman | 46f555f | 2007-05-27 12:57:15 +0200 | [diff] [blame] | 71 | /* |
| 72 | * SDIO I/O operations |
| 73 | */ |
| 74 | extern void sdio_claim_host(struct sdio_func *func); |
| 75 | extern void sdio_release_host(struct sdio_func *func); |
| 76 | |
Pierre Ossman | fa64efa | 2007-05-27 14:22:37 +0200 | [diff] [blame] | 77 | extern int sdio_enable_func(struct sdio_func *func); |
| 78 | extern int sdio_disable_func(struct sdio_func *func); |
| 79 | |
Pierre Ossman | 46f555f | 2007-05-27 12:57:15 +0200 | [diff] [blame] | 80 | extern unsigned char sdio_readb(struct sdio_func *func, |
| 81 | unsigned int addr, int *err_ret); |
| 82 | |
| 83 | extern void sdio_writeb(struct sdio_func *func, unsigned char b, |
| 84 | unsigned int addr, int *err_ret); |
| 85 | |
Pierre Ossman | e29a7d7 | 2007-05-26 13:48:18 +0200 | [diff] [blame] | 86 | #endif |
| 87 | |