blob: 14664f1fb16fb560c526dd30817cc10ae6db1adf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Pierre Ossmanaaac1b42007-02-28 15:33:10 +01002 * linux/drivers/mmc/core/core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved.
Pierre Ossmanda7fbe52006-12-24 22:46:55 +01005 * Copyright 2007 Pierre Ossman
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
Pierre Ossmanda7fbe52006-12-24 22:46:55 +010011#ifndef _MMC_CORE_CORE_H
12#define _MMC_CORE_CORE_H
Russell King00b137c2005-08-19 09:41:24 +010013
Pierre Ossmanda7fbe52006-12-24 22:46:55 +010014#include <linux/delay.h>
Pierre Ossman7104e2d2006-10-04 02:15:41 -070015
Pierre Ossmanda7fbe52006-12-24 22:46:55 +010016#define MMC_CMD_RETRIES 3
17
Pierre Ossman7ea239d2006-12-31 00:11:32 +010018struct mmc_bus_ops {
Jarkko Lavinenb1ebe382009-09-22 16:44:34 -070019 int (*awake)(struct mmc_host *);
20 int (*sleep)(struct mmc_host *);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010021 void (*remove)(struct mmc_host *);
22 void (*detect)(struct mmc_host *);
Nicolas Pitre95cdfb72009-09-22 16:45:29 -070023 int (*suspend)(struct mmc_host *);
24 int (*resume)(struct mmc_host *);
Ohad Ben-Cohen12ae6372010-10-02 13:54:06 +020025 int (*power_save)(struct mmc_host *);
26 int (*power_restore)(struct mmc_host *);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010027};
28
29void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
30void mmc_detach_bus(struct mmc_host *host);
31
Adrian Hunterdfe86cb2010-08-11 14:17:46 -070032void mmc_init_erase(struct mmc_card *card);
33
Pierre Ossmanda7fbe52006-12-24 22:46:55 +010034void mmc_set_chip_select(struct mmc_host *host, int mode);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010035void mmc_set_clock(struct mmc_host *host, unsigned int hz);
Linus Walleij04566832010-11-08 21:36:50 -050036void mmc_gate_clock(struct mmc_host *host);
37void mmc_ungate_clock(struct mmc_host *host);
38void mmc_set_ungated(struct mmc_host *host);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010039void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode);
40void mmc_set_bus_width(struct mmc_host *host, unsigned int width);
41u32 mmc_select_voltage(struct mmc_host *host, u32 ocr);
Philip Rakity261bbd42011-05-13 11:17:17 +053042int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage,
43 bool cmd11);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010044void mmc_set_timing(struct mmc_host *host, unsigned int timing);
Arindam Nathd6d50a12011-05-05 12:18:59 +053045void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type);
Ulf Hansson7f7e4122011-09-21 14:08:13 -040046void mmc_power_off(struct mmc_host *host);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010047
Pierre Ossmanda7fbe52006-12-24 22:46:55 +010048static inline void mmc_delay(unsigned int ms)
49{
50 if (ms < 1000 / HZ) {
51 cond_resched();
52 mdelay(ms);
53 } else {
54 msleep(ms);
55 }
56}
57
Pierre Ossmanb93931a2007-05-19 14:06:24 +020058void mmc_rescan(struct work_struct *work);
59void mmc_start_host(struct mmc_host *host);
60void mmc_stop_host(struct mmc_host *host);
61
Andy Ross807e8e42011-01-03 10:36:56 -080062int mmc_attach_mmc(struct mmc_host *host);
63int mmc_attach_sd(struct mmc_host *host);
64int mmc_attach_sdio(struct mmc_host *host);
Adrian Bunk98b843b2008-04-13 21:15:50 +030065
Ben Hutchingsbd68e082009-12-14 18:01:29 -080066/* Module parameters */
David Brownellaf517152007-08-08 09:11:32 -070067extern int use_spi_crc;
68
Haavard Skinnemoen6edd8ee2008-07-24 14:18:57 +020069/* Debugfs information for hosts and cards */
70void mmc_add_host_debugfs(struct mmc_host *host);
71void mmc_remove_host_debugfs(struct mmc_host *host);
72
Haavard Skinnemoenf4b7f922008-07-24 14:18:58 +020073void mmc_add_card_debugfs(struct mmc_card *card);
74void mmc_remove_card_debugfs(struct mmc_card *card);
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#endif
Pierre Ossmanda7fbe52006-12-24 22:46:55 +010077