blob: 18fc77f682de8dcf629c83945c4595fd3cc0b82c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/include/linux/mmc/card.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Card driver specific definitions.
9 */
10#ifndef LINUX_MMC_CARD_H
11#define LINUX_MMC_CARD_H
12
13#include <linux/mmc/mmc.h>
14
15struct mmc_cid {
16 unsigned int manfid;
17 char prod_name[8];
18 unsigned int serial;
19 unsigned short oemid;
20 unsigned short year;
21 unsigned char hwrev;
22 unsigned char fwrev;
23 unsigned char month;
24};
25
26struct mmc_csd {
27 unsigned char mmca_vsn;
28 unsigned short cmdclass;
29 unsigned short tacc_clks;
30 unsigned int tacc_ns;
31 unsigned int max_dtr;
32 unsigned int read_blkbits;
33 unsigned int capacity;
34};
35
Pierre Ossmanb57c43a2005-09-06 15:18:53 -070036struct sd_scr {
37 unsigned char sda_vsn;
38 unsigned char bus_widths;
39#define SD_SCR_BUS_WIDTH_1 (1<<0)
40#define SD_SCR_BUS_WIDTH_4 (1<<2)
41};
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043struct mmc_host;
44
45/*
46 * MMC device
47 */
48struct mmc_card {
49 struct list_head node; /* node in hosts devices list */
50 struct mmc_host *host; /* the host this device belongs to */
51 struct device dev; /* the device */
52 unsigned int rca; /* relative card address of device */
53 unsigned int state; /* (our) card state */
54#define MMC_STATE_PRESENT (1<<0) /* present in sysfs */
55#define MMC_STATE_DEAD (1<<1) /* device no longer in stack */
56#define MMC_STATE_BAD (1<<2) /* unrecognised device */
Pierre Ossman335eadf2005-09-06 15:18:50 -070057#define MMC_STATE_SDCARD (1<<3) /* is an SD card */
Pierre Ossmana00fc092005-09-06 15:18:52 -070058#define MMC_STATE_READONLY (1<<4) /* card is read-only */
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 u32 raw_cid[4]; /* raw card CID */
60 u32 raw_csd[4]; /* raw card CSD */
Pierre Ossmanb57c43a2005-09-06 15:18:53 -070061 u32 raw_scr[2]; /* raw card SCR */
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 struct mmc_cid cid; /* card identification */
63 struct mmc_csd csd; /* card specific */
Pierre Ossmanb57c43a2005-09-06 15:18:53 -070064 struct sd_scr scr; /* extra SD information */
Linus Torvalds1da177e2005-04-16 15:20:36 -070065};
66
67#define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
68#define mmc_card_dead(c) ((c)->state & MMC_STATE_DEAD)
69#define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD)
Pierre Ossman335eadf2005-09-06 15:18:50 -070070#define mmc_card_sd(c) ((c)->state & MMC_STATE_SDCARD)
Pierre Ossmana00fc092005-09-06 15:18:52 -070071#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
74#define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD)
75#define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD)
Pierre Ossman335eadf2005-09-06 15:18:50 -070076#define mmc_card_set_sd(c) ((c)->state |= MMC_STATE_SDCARD)
Pierre Ossmana00fc092005-09-06 15:18:52 -070077#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79#define mmc_card_name(c) ((c)->cid.prod_name)
80#define mmc_card_id(c) ((c)->dev.bus_id)
81
82#define mmc_list_to_card(l) container_of(l, struct mmc_card, node)
83#define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev)
84#define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d)
85
86/*
87 * MMC device driver (e.g., Flash card, I/O card...)
88 */
89struct mmc_driver {
90 struct device_driver drv;
91 int (*probe)(struct mmc_card *);
92 void (*remove)(struct mmc_card *);
93 int (*suspend)(struct mmc_card *, pm_message_t);
94 int (*resume)(struct mmc_card *);
95};
96
97extern int mmc_register_driver(struct mmc_driver *);
98extern void mmc_unregister_driver(struct mmc_driver *);
99
100static inline int mmc_card_claim_host(struct mmc_card *card)
101{
102 return __mmc_claim_host(card->host, card);
103}
104
105#define mmc_card_release_host(c) mmc_release_host((c)->host)
106
107#endif